Skip to content

Commit

Permalink
fix: compatibility for some old chromium core (#995)
Browse files Browse the repository at this point in the history
* fix: compatibility for some old chromium core

* feat: resolve relative URL manually

* dev: revert the change

* dev: add some comment

* fix: wrong regrex in 5022895

* dev: upgrade version to use

---------

Co-authored-by: Myriad-Dreamin <[email protected]>
  • Loading branch information
Parsifa1 and Myriad-Dreamin authored Dec 14, 2024
1 parent b19810e commit b18c3ca
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 27 deletions.
21 changes: 14 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ insta = { version = "1.39", features = ["glob"] }

# Our Own Crates
typst-preview = { path = "./crates/typst-preview" }
tinymist-assets = { version = "0.12.10" }
tinymist-assets = { version = "0.12.11-rc1" }
tinymist = { path = "./crates/tinymist/" }
tinymist-derive = { path = "./crates/tinymist-derive/" }
tinymist-analysis = { path = "./crates/tinymist-analysis/" }
Expand Down
8 changes: 4 additions & 4 deletions tools/typst-dom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
"unlink:local": "yarn unlink @myriaddreamin/typst.ts @myriaddreamin/typst-ts-renderer"
},
"peerDependencies": {
"@myriaddreamin/typst-ts-renderer": "0.5.0-rc9",
"@myriaddreamin/typst.ts": "0.5.0-rc9"
"@myriaddreamin/typst-ts-renderer": "0.5.1",
"@myriaddreamin/typst.ts": "0.5.1"
},
"devDependencies": {
"@myriaddreamin/typst-ts-renderer": "0.5.0-rc9",
"@myriaddreamin/typst.ts": "0.5.0-rc9",
"@myriaddreamin/typst-ts-renderer": "0.5.1",
"@myriaddreamin/typst.ts": "0.5.1",
"typescript": "^5.0.2"
},
"exports": {
Expand Down
3 changes: 2 additions & 1 deletion tools/typst-dom/src/typst-doc.mts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ export class TypstDocumentContext<O = any> {
static derive(ctx: any, mode: string) {
return ["rescale", "rerender", "postRender"].reduce(
(acc: any, x: string) => {
acc[x] = ctx[`${x}$${mode}`].bind(ctx);
let index = x + "$" + mode;
acc[x] = ctx[index].bind(ctx);
console.assert(acc[x] !== undefined, `${x}$${mode} is undefined`);
return acc;
},
Expand Down
4 changes: 2 additions & 2 deletions tools/typst-preview-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"unlink:local": "yarn unlink @myriaddreamin/typst.ts @myriaddreamin/typst-ts-renderer"
},
"dependencies": {
"@myriaddreamin/typst-ts-renderer": "0.5.0-rc9",
"@myriaddreamin/typst.ts": "0.5.0-rc9",
"@myriaddreamin/typst-ts-renderer": "0.5.1",
"@myriaddreamin/typst.ts": "0.5.1",
"typst-dom": "link:../typst-dom",
"rxjs": "^7.8.1"
}
Expand Down
12 changes: 9 additions & 3 deletions tools/typst-preview-frontend/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,19 @@ function retrieveWsArgs() {

/// The string `ws://127.0.0.1:23625` is a placeholder
/// Also, it is the default url to connect to.
let url = "ws://127.0.0.1:23625";
/// Note that we must resolve the url to an absolute url as
/// the websocket connection requires an absolute url.
///
/// See [WebSocket and relative URLs](https://github.com/whatwg/websockets/issues/20)
let urlObject = new URL("ws://127.0.0.1:23625", window.location.href);
/// Rewrite the protocol to websocket.
urlObject.protocol = urlObject.protocol.replace('https:', 'wss:').replace('http:', 'ws:');
if (location.href.startsWith("https://")) {
url = url.replace("ws://", "wss://")
urlObject.protocol = urlObject.protocol.replace('ws:', 'wss:');
}

/// Return a `WsArgs` object.
return { url, previewMode, isContentPreview: false };
return { url: urlObject.href, previewMode, isContentPreview: false };
}

/// `buildWs` returns a object, which keeps track of websocket
Expand Down
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -408,15 +408,15 @@
resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz#3188bcb273a414b0d215fd22a58540b989b9409a"
integrity sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==

"@myriaddreamin/[email protected].0-rc9":
version "0.5.0-rc9"
resolved "https://registry.yarnpkg.com/@myriaddreamin/typst-ts-renderer/-/typst-ts-renderer-0.5.0-rc9.tgz#c6ed3ce01c7ce61a83b396bdd39c412b56dedcd8"
integrity sha512-YyKvGcTmCpzzv+M54vQA8zaDfMM/PqsQrThDi9DG1D5FOKt50w8+xE5POEFPfDu5y9iVyvJ/AhkRqGyy4njkcQ==

"@myriaddreamin/[email protected].0-rc9":
version "0.5.0-rc9"
resolved "https://registry.yarnpkg.com/@myriaddreamin/typst.ts/-/typst.ts-0.5.0-rc9.tgz#0d9c4c61406b0245105544d821dae5a0a88a39fc"
integrity sha512-6mnxNzuEp4ALFwzuvvCTijM756G1VUnXie9TwjCb01ey3f6jv/Xh1rWNwLds2KUYAtDdaOqO7RMctOhvqdq0rg==
"@myriaddreamin/[email protected].1":
version "0.5.1"
resolved "https://registry.yarnpkg.com/@myriaddreamin/typst-ts-renderer/-/typst-ts-renderer-0.5.1.tgz#951bb1df75c93c29b1072b71fe375fb030a8bde2"
integrity sha512-3kTixY1a9mAlfJuWCBv28DUYEhmjXdPSV8970I0/bhwOH9wqekGb2WB5BkDc+ZfEDUUx4nI51VOPmdSJZwDJ7w==

"@myriaddreamin/[email protected].1":
version "0.5.1"
resolved "https://registry.yarnpkg.com/@myriaddreamin/typst.ts/-/typst.ts-0.5.1.tgz#903deb5fff1b66c7381763611712fcdc72919da1"
integrity sha512-1G58PfWNzZp9TOgsn1v+uqL5wYvppAFcwhqBAj1/Gszelp+/t+4UeyIiF6V1S3tegQMkvtd6bPo06X+dSGTqgg==
dependencies:
idb "^7.1.1"

Expand Down

0 comments on commit b18c3ca

Please sign in to comment.