And in any case the treaty doesn't allow for invasion upon the government being perceived as illegitimate. This is an aggressive war, considered since the end of WW2 to be the supreme international crime.
The problem still so far is everything done to hold Putin accountable is viewed by Russians as the West vs Russia. This invasion is viewed not as aggressive war, but liberating Ukraine from Nazis. Exactly what Putin says domestically.
And yes, most of the rest of the world recognizes Taiwan as a sovereign country, except formally they use language consistent with One China to avoid a row with China
Taiwan, the island, was once a part of territory claimed by Imperial China. Eventually, Taiwan was given to Japan in some war back in the day.
Right before WWII, civil war broke out. The Chinese Communist party wanted to overthrow the ROC and reform the government in their image. Then WWII happened and they agreed to pause the civil war to deal with the Japanese coming in from East.
WWII ended with the defeat of Japan and as part of the terms of surrender, Taiwan was given back to the ROC.
After WWII, the civil war was back on, but with the ROC having been significantly weakened by WWII. Eventually, the CCP overthrew the ROC on the mainland and formed the People's Republic of China (PRC), while the ROC fled to the island of Taiwan.
The PRC sees Taiwan as part of China thanks to the Japanese terms of surrender. Taiwan was ceded to the government of China, they are the government of China. QED, Taiwan is theirs.
The ROC sees themselves as the rightful government of China in exile. Yes, Taiwan belongs to China, but they are China. The PRC needs to give the mainland back to them.
Things have progressed since then. There are some on the island with different opinions these days.
The policy of the PRC and some factions in the ROC is the One-China policy. There is only one China, it includes the mainland and Taiwan. The only disagreement is about which government is legitimate.
Some in the ROC advocate a two-state solution, in which you'd have the PRC and ROC, each with their territories and that's that.
Then there are people in Taiwan who feel that they should be their own independent nation and not "Chinese" at all.
So basically, with regards to your question, the answer is every answer possible. I think the official position is One-China though. I think there's enough of that faction to make winning elections impossible if you explicitly reject it.
I think it’s important to add that Taiwan, like China, was an authoritarian state up until the 90s. The shift to democracy since then has given room for a lot of these different factions to take hold and develop on the island.
Like, I said, things have progressed. There's "One China", "Two Chinas", and "China and Taiwan".
I think the longer things remain as they are, the more likely it'll settle into a "China and Taiwan" situation as both sides just kind of tire of fighting an issue their great grandparents started.