Immigration and Customs are two different things. Immigration is for ascertaining nationality and/or the right to enter the country. Customs governs goods purchased abroad and brought back into the country.
The check in St. Thomas is an Immigration check. You don't go through Customs until you get back to Port Canaveral (you have to fill out a Customs form and hand it to the agent on your way out of the terminal). Technically, you do go through Immigration here, too. Non-US citizens have to report early on the last morning of the cruise and take care of it on board. US citizens can be stopped in the terminal and asked to present proof of citizenship by the agents there, but this doesn't happen very often, since the passenger list is already on file and is checked against watch lists. Most of the time, I have my Customs form in my passport and the agent just grabs it out without giving the passport a second look.
San Juan and St. Thomas are considered foreign ports for the purposes of the Passenger Services and Jones acts, one of which mandates a stop at a foreign port for foreign-flagged passenger ships, but they are considered US ports for the post-9/11 "let's give the appearance that we're taking security seriously" Immigration check.
The Magic did do a few cruises this fall which swapped the St. Maarten call for San Juan. I don't know if they'll continue this or not. At this point, I don't think any more are scheduled. I don't think they switched the St. Thomas call to Tuesday, though. I'm not sure it would make that much difference. It would allow the ship to stay later in St. Thomas, but San Juan is not that much closer to the Bahamas than St. Thomas, maybe 40 miles, so the ship would have to leave early on Wednesday afternoon, anyway.