Repository navigation
Both TypeScript routes work in Safari and strict projects #886
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
474bd08
chore(quest): claim quest/m2/wasm/ts-consumers.md
kixelated db13945
Define Symbol.dispose where the engine lacks it, and check WebKit and…
kixelated 96416c6
Run the using check in a case WebKit runs
kixelated 586beda
Merge remote-tracking branch 'origin/main' into quest/m2/wasm/ts-cons…
kixelated 7c7e5ec
Merge origin/main, and run WebKit's browser cases only on Linux, whos…
kixelated 17b634d
Merge remote-tracking branch 'origin/main' into quest/m2/wasm/ts-cons…
kixelated File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| // An engine without `Symbol.dispose`, as stable Safari is: the runtime, bundled and run in a | ||
| // context whose `Symbol` lacks it, defines it as the registry's `Symbol.for("Symbol.dispose")`, | ||
| // which esbuild's `using` helper falls back to, before any class keys a method on it. | ||
| // | ||
| // usage: node dispose.ts <runtime-entry> | ||
|
|
||
| import { execFileSync } from "node:child_process"; | ||
| import vm from "node:vm"; | ||
|
|
||
| const entry = process.argv[2]; | ||
| if (!entry) throw new Error("usage: dispose.ts <runtime-entry>"); | ||
| const code = execFileSync("esbuild", [entry, "--bundle", "--format=iife", "--global-name=runtime", "--target=es2022"], { | ||
| encoding: "utf8", | ||
| }); | ||
|
|
||
| // The built-in `Symbol`, but for `dispose` and `asyncDispose`, which cannot be deleted from it. | ||
| const FakeSymbol = Object.defineProperties( | ||
| (description?: string) => Symbol(description), | ||
| Object.fromEntries(Reflect.ownKeys(Symbol).filter((key) => key !== "dispose" && key !== "asyncDispose").map((key) => [key, Object.getOwnPropertyDescriptor(Symbol, key)!])), | ||
| ); | ||
|
|
||
| // What a browser gives the runtime that a bare context lacks. | ||
| const { TextEncoder, TextDecoder, URL, console, queueMicrotask, setTimeout, clearTimeout, performance } = globalThis; | ||
| const context = vm.createContext({ Symbol: FakeSymbol, TextEncoder, TextDecoder, URL, console, queueMicrotask, setTimeout, clearTimeout, performance }); | ||
| if (vm.runInContext("typeof Symbol.dispose", context) !== "undefined") throw new Error("the context's Symbol still has dispose"); | ||
| vm.runInContext(`${code}\nglobalThis.runtime = runtime;`, context); | ||
|
|
||
| const registry = Symbol.for("Symbol.dispose"); | ||
| const defined = vm.runInContext("Symbol.dispose", context); | ||
| if (defined !== registry) throw new Error(`Symbol.dispose is ${String(defined)}, not the registry's`); | ||
|
|
||
| // Each class that disposes does so under that symbol, and none under the string "undefined". | ||
| let disposing = 0; | ||
| for (const [name, value] of Object.entries(vm.runInContext("runtime", context) as Record<string, unknown>)) { | ||
| if (typeof value !== "function" || !value.prototype) continue; | ||
| if (Object.hasOwn(value.prototype, "undefined")) throw new Error(`${name} keys a method on "undefined"`); | ||
| if (Object.getOwnPropertySymbols(value.prototype).includes(registry)) disposing++; | ||
| } | ||
| if (disposing === 0) throw new Error("no exported class disposes under the registry's symbol"); |
This file contains hidden or 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 hidden or 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 was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.