Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open sourcing my improvements #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

justjake
Copy link

This PR is a raw dump of source code from my NextJS website.

sandpack.typescript.mp4

But, it's not working here. For some reason, type acquisition is failing for me with this message:

image

This doesn't happen when the code runs in my site. I was using React@18 there, but I don't know why that would make a difference at all here. I might find more time to poke at this — but maybe you can figure out the problem faster? ¯_(ツ)_/¯

Anyways, slight brokeness aside, here's the rundown of changes:

  • Replace event emitter worker communication with an RPC-style abstraction that allows either side of the worker bridge to await calls to the other.
  • Tooltip contents are now rendered with React (to static markup). I added syntax highlighting for the code snippets in there by translating Typescript's SymbolDisplayPart to a Codemirror token type. I also did a pass over the tooltip styles and normalized some stuff out there.
  • Added lint fixing. Open the lint list with Cmd-.
  • Added auto-formatting with Cmd-S
  • Added smarter tab completion, including imports. The implementation for advanced completions is rough around the edges; I'm not supporting multiple cursors correctly compared to Codemirror's built in completion logic. It's a bummer I can't use their tab completion insertion logic and enhance that with extra actions. We either get the built-in rock-solid simple insertion, or we can do fancy stuff, but re-implement the basics too. I found this non-obvious.
  • add debug NPM module for debugging.
  • There are some shenanigans with ref to break tooltips out of the overflow: hidden container they are nested within. I also had to switch them to position: absolute to make them render in the right spot while scrolling.

@danilowoz
Copy link
Owner

This is amazing! I'm very impressed with this next iteration, looking forward to spend more time on this

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants