char/avril

(wip) why'd you have to go and make things so complicaaaaated?

git clone https://git.t4t.associates/char/avril

Charlotte Somgenerate std typedefs from typescript impl38d7f6c

main
1.2 KiB38 linesraw
1// Ambient augmentation composed from several extensions rather than one
2// module surface: `avril:std` provides the `avril` brand and `Pledge`, the
3// web platform provides `Navigator` and `WorkerNavigator`, and workers own
4// `WorkerOptions`, `postMessage`, and the `import.meta` extras. It stays
5// handwritten because no single facade owns it.
6import type { avril, Pledge } from "avril:std";
7
8declare global {
9  interface ImportMeta {
10    readonly main: boolean;
11    readonly filename?: string;
12    readonly dirname?: string;
13    resolve(specifier: string): string;
14  }
15
16  interface Navigator {
17    /** Isolate-local User-Agent for fetch, EventSource, and WebSocket; explicit fetch headers take precedence. */
18    userAgent: string;
19  }
20
21  interface WorkerNavigator {
22    userAgent: string;
23  }
24
25  interface WorkerOptions {
26    [avril]?: {
27      readonly caps?: Pledge;
28    };
29  }
30
31  interface GlobalThis {
32    /** Always `true` in avril; detect with `globalThis[Symbol.for("runtime:avril")]`. */
33    readonly [avril]: true;
34  }
35
36  function postMessage(message: unknown, transfer?: Transferable[]): void;
37  function postMessage(message: unknown, options?: StructuredSerializeOptions): void;
38}