Myriad-Dreamin / tinymist

Tinymist [ˈtaɪni mɪst] is an integrated language service for Typst [taɪpst].
https://myriad-dreamin.github.io/tinymist
Apache License 2.0
352 stars 15 forks source link

Typst Preview fails on VSCode web and others. #382

Open tani opened 2 weeks ago

tani commented 2 weeks ago

Describe the bug Typst Preview uses the address of the local host to communicate with the server for preview, so VSCode used from a web browser, such as Gitpod, VSCode web or Coder, will cause address mismatch and the preview will fail.

Package/Software version:

VSCode version(Help -> About):

Gitpod Code
Version: 1.90.2
Commit: dc0e7217f8f11d3249dcd2cd1d2152a2fdb45f3e
Date: 2024-06-20T12:06:32.291Z (2 wks ago)
Browser: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:127.0) Gecko/20100101 Firefox/127.0

tinymist extension version: v0.11.0. Get it by tinymist --version in terminal.

Typst Version:       0.11.1

Additional context

https://github.com/Enter-tainer/typst-preview/blob/971dbc7f63ba12af4497204e7c433e0ed62d89a4/addons/frontend/src/main.js#L40

https://github.com/Enter-tainer/typst-preview/issues/292

Myriad-Dreamin commented 2 weeks ago

In browser environment, you should use the official app, https://typst.app. Regard to this, we may not develop this feature very actively.

tani commented 2 weeks ago

Noted. Anyhow thanks for the great lsp and extension. I will use it. However, would you mind to review and accept pull request if I could write it in the near future?

Myriad-Dreamin commented 2 weeks ago

However, would you mind to review and accept pull request if I could write it in the near future?

Glad that you have feeling to contribute this project. I'll review it for sure. :smiley:

tani commented 2 weeks ago

I have investigated this problem and found it to be difficult to solve. I share my conclusions with future colleagues with the same problem.

https://github.com/Enter-tainer/typst-preview/blob/971dbc7f63ba12af4497204e7c433e0ed62d89a4/addons/vscode/src/extension.ts#L502-L505

The obstacle is that WebSockets are not supported when port forwarding is being used here. This is a problem on the VSCode side. To bypass this, it is necessary to use HTTP Polling or similar instead of WebSocket. However, I have not found a way to bypass this in the RXJS WebSocket client. I will continue to investigate and share any findings.