-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update VS Code and enable Intellisense (#6222)
**Problem:** Our version of VS Code is extremely outdated and built using a reverse engineered build, but since then the web version of VS Code has come a long way and can now support Intellisense. **Fix:** This PR changes 3 fundamental things: 1. Rather than using IndexedDB for communicating between Utopia and the VS Code extension, we now use VS Code's commands service. This allows us to register a command handler on either side of the air gap, and pass any arbitrary information in the command's parameters. We therefore are able to use two new commands for passing messages directly across that air gap, removing the reliance on async polling of the store. 2. The version of VS Code has been bumped up to 1.91.1, which required a newer version of node, and a load of changes to the patch file to actually be able to build it. When we first implemented the VS Code embed, we had to reverse engineer a build file based on the electron build. This newer version of VS Code includes a build script, so it was a case of finding and calling that, and figuring out where the patches needed to be applied now. The end result is significantly simpler than the previous approach. 3. To actually support Intellisense, we needed to add some new cross origin headers to the editor assets and vs code assets, and serve both the editor and vs code iframe up on the same TLD to ensure that `crossOriginIsolated` would be set to true. There is also a `vscode-coi` query param that we have to include in the iframe's URL. For the VS Code parts of the diff (the patch and the extension changes) it might be easier to view some files in full rather than trying to read the diff... **Commit Details:** - Update the vscode-build's `shell.nix` to use newer versions of node and yarn, and supply an extra package required for building it - Update the pulled version of VS Code to 1.91.1 - Remove the reliance on IndexedDB for communicating between the outer edge of the iframe and the extension, and instead use VS Code's command service for passing messages between the two, meaning that we no longer need to use polling to watch for file changes, and can instead directly trigger them - This required the registering of some extra commands, and the code for then communicating those across the iframe boundary - Remove the `fs` files from `utopia-vscode-common`, and instead use an in memory fs implementation in the extension. This stores the files in a `Map<string, FSNode>`, and stores both the saved and unsaved content of text files - Since we are now passing messages directly between Utopia and VS Code, I've flattened the message types (previously there were two types: one for file changes; one for other changes such as cursor position, highlight bounds etc) - The server now passes down the headers required to enable [`crossOriginIsolated`](https://developer.mozilla.org/en-US/docs/Web/API/Window/crossOriginIsolated). `crossOriginIsolated` is required for full Intellisense on the web, which requires 2 new cross origin headers, and for the code editor iframe to be served up from the same TLD as the rest of the editor. - This does mean that the code editor will be running on the same process as Utopia - To actually build this version of VS Code I had to: - Disable code mangling. I'm, not sure why, but with that enabled the build was just silently hanging on my machine - Remove some native keyboard mapping code. This was causing an issue related to electron, which we are clearly not interested in, so I just ripped it out after failing to fix it. - To simplify the VS Code UI I have: - Forcibly enabled Zen mode (the `isZenModeActive` check always returns true) - Changed some Zen mode defaults to prevent the code editor trying to fullscreen itself, or centre the code pane inside itself - Forcibly hidden other parts of the UI that would normally still be shown when in non-fullscreen Zen mode **Manual Tests:** I hereby swear that: - [x] I opened a hydrogen project and it loaded - [x] I could navigate to various routes in Preview mode
- Loading branch information
Showing
34 changed files
with
2,225 additions
and
3,354 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.