@mercuryworkshop/scramjet 2.0.5-alpha → 2.0.6-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/scramjet-external.mjs +56 -0
  2. package/dist/scramjet.js +6 -9
  3. package/dist/scramjet.js.map +1 -1
  4. package/dist/scramjet.mjs +6 -9
  5. package/dist/scramjet.mjs.map +1 -1
  6. package/dist/scramjet.wasm +0 -0
  7. package/dist/scramjet_bundled.js +7 -10
  8. package/dist/scramjet_bundled.js.map +1 -1
  9. package/dist/scramjet_bundled.mjs +7 -10
  10. package/dist/scramjet_bundled.mjs.map +1 -1
  11. package/dist/temp-types-build/index.js +23 -0
  12. package/dist/temp-types-build/index.js.map +1 -0
  13. package/dist/types/Tap.d.ts +12 -5
  14. package/dist/types/client/client.d.ts +10 -10
  15. package/dist/types/client/location.d.ts +1 -1
  16. package/dist/types/client/shared/eval.d.ts +1 -1
  17. package/dist/types/client/shared/sourcemaps.d.ts +1 -1
  18. package/dist/types/client/shared/wrap.d.ts +1 -1
  19. package/dist/types/client/singletonbox.d.ts +1 -1
  20. package/dist/types/fetch/fetch.d.ts +1 -1
  21. package/dist/types/fetch/headers.d.ts +1 -1
  22. package/dist/types/fetch/parse.d.ts +1 -0
  23. package/dist/types/fetch/util.d.ts +1 -1
  24. package/dist/types/shared/htmlRules.d.ts +3 -3
  25. package/dist/types/shared/index.d.ts +4 -4
  26. package/dist/types/shared/mime.d.ts +8 -0
  27. package/dist/types/shared/rewriters/css.d.ts +2 -2
  28. package/dist/types/shared/rewriters/html.d.ts +3 -3
  29. package/dist/types/shared/rewriters/js.d.ts +2 -2
  30. package/dist/types/shared/rewriters/url.d.ts +1 -1
  31. package/dist/types/shared/rewriters/wasm.d.ts +2 -2
  32. package/dist/types/shared/rewriters/worker.d.ts +2 -2
  33. package/dist/types/shared/snapshot.d.ts +83 -134
  34. package/package.json +9 -3
  35. package/dist/167400cb144aab22.wasm +0 -0
  36. package/dist/2919e49b986edf8c.wasm +0 -0
  37. package/dist/5aed1d5e48aab205.wasm +0 -0
  38. package/dist/882d77912a3c8e3a.wasm +0 -0
  39. package/dist/ac6aa30297a80464.wasm +0 -0
  40. package/dist/c10a57758af882c8.wasm +0 -0
  41. package/dist/cfd04aaae6955b67.wasm +0 -0
  42. package/dist/d06a90fd413b36cf.wasm +0 -0
  43. package/dist/dda06914899a6c28.wasm +0 -0
  44. package/dist/types/client/global.d.ts +0 -4
  45. package/dist/types/client/shared/unproxy.d.ts +0 -19
  46. package/dist/types/client/unproxy.generated.d.ts +0 -50
  47. package/dist/types/fetch/index.d.ts +0 -128
@@ -3,11 +3,16 @@ type Description = {
3
3
  props?: object;
4
4
  };
5
5
  type Callback<T extends Description> = (context: T["context"], props: T["props"]) => void | Promise<void>;
6
- type Sorter = (other: Plugin) => number;
6
+ export type TapOrder = {
7
+ /** Run before these plugins. */
8
+ before?: readonly string[];
9
+ /** Run after these plugins. */
10
+ after?: readonly string[];
11
+ };
7
12
  type CallbackInfo<T extends Description> = {
8
13
  callback: Callback<T>;
9
14
  plugin: Plugin;
10
- sorter: Sorter;
15
+ order: TapOrder;
11
16
  };
12
17
  type InternalHookDescription = {
13
18
  tap: TapInternal;
@@ -21,12 +26,14 @@ export type TapInstance<T extends Record<string, Description>> = {
21
26
  };
22
27
  export declare class Plugin {
23
28
  name: string;
24
- constructor(name: string);
25
- tap<T extends Description>(hook: T, callback: Callback<T>, sorter?: Sorter): void;
29
+ readonly tapOrder: TapOrder;
30
+ constructor(name: string, tapOrder?: TapOrder);
31
+ tap<T extends Description>(hook: T, callback: Callback<T>, order?: TapOrder): void;
26
32
  }
27
33
  export declare class Tap {
28
34
  static dispatch<T extends Description>(hook: T, context: T["context"], props: T["props"]): Promise<void[]>;
29
- static tap<T extends Description>(hook: T, callback: Callback<T>, plugin: Plugin, sorter: Sorter): void;
35
+ static tap<T extends Description>(hook: T, callback: Callback<T>, plugin?: Plugin, order?: TapOrder): void;
30
36
  static create<T extends Record<string, Description>>(): TapInstance<T>;
37
+ static getTappers<T extends Description>(hook: T): Plugin[];
31
38
  }
32
39
  export {};
@@ -1,17 +1,16 @@
1
1
  import { BareCompatibleClient, ProxyTransport, RawHeaders } from "@mercuryworkshop/proxy-transports";
2
- import { LifecycleHooks } from "./events";
3
- import { RewriteUrlOptions, type URLMeta } from "../shared/rewriters/url";
4
- import { HtmlRewriterHooks, ScramjetContext, ScramjetHeaders } from "../shared";
2
+ import { LifecycleHooks } from "@client/events";
3
+ import { RewriteUrlOptions, type URLMeta } from "@rewriters/url";
4
+ import { HtmlRewriterHooks, ScramjetContext, ScramjetHeaders } from "@/shared";
5
5
  import { SingletonBox } from "./singletonbox";
6
- import { ScramjetConfig } from "../types";
7
- import { type CookieSyncEntry, type CookieSyncOptions, TrackedHistoryState } from "../fetch";
8
- import { AnyFunction } from "../types";
9
- import { _URL } from "../shared/snapshot";
6
+ import { ScramjetConfig } from "@/types";
7
+ import { type CookieSyncEntry, type CookieSyncOptions, TrackedHistoryState } from "@/fetch";
8
+ import { AnyFunction } from "@/types";
9
+ import { _URL } from "@/shared/snapshot";
10
10
  export type ScramjetClientInit = {
11
11
  context: ScramjetContext;
12
12
  transport: ProxyTransport;
13
13
  sendSetCookie: (cookies: CookieSyncEntry[], options?: CookieSyncOptions) => Promise<void>;
14
- shouldPassthroughWebsocket?: (url: string | URL) => boolean;
15
14
  shouldBlockMessageEvent?: (ev: MessageEvent) => boolean;
16
15
  hookSubcontext: (self: Self, frame?: HTMLIFrameElement) => ScramjetClient;
17
16
  initHeaders: RawHeaders;
@@ -85,11 +84,12 @@ export declare class ScramjetClient {
85
84
  context: ScramjetContext;
86
85
  initHeaders: ScramjetHeaders;
87
86
  history: TrackedHistoryState[];
87
+ private flagCache;
88
88
  hooks: {
89
89
  rewriter: {
90
- html: import("../Tap").TapInstance<HtmlRewriterHooks>;
90
+ html: import("@/Tap").TapInstance<HtmlRewriterHooks>;
91
91
  };
92
- lifecycle: import("../Tap").TapInstance<LifecycleHooks>;
92
+ lifecycle: import("@/Tap").TapInstance<LifecycleHooks>;
93
93
  };
94
94
  constructor(global: GlobalThis, init: ScramjetClientInit);
95
95
  /** Apply document injection init when a client was already installed (e.g. early contentWindow). */
@@ -1,2 +1,2 @@
1
- import { ScramjetClient } from "./index";
1
+ import { ScramjetClient } from "@client/index";
2
2
  export declare function createLocationProxy(client: ScramjetClient, self: GlobalThis): any;
@@ -1,3 +1,3 @@
1
- import { ScramjetClient } from "../index";
1
+ import { ScramjetClient } from "@client/index";
2
2
  export default function (client: ScramjetClient, self: Self): void;
3
3
  export declare function indirectEval(this: ScramjetClient, strict: boolean, js: any): any;
@@ -1,4 +1,4 @@
1
- import { ScramjetClient } from "../index";
1
+ import { ScramjetClient } from "@client/index";
2
2
  declare enum RewriteType {
3
3
  Insert = 0,
4
4
  Replace = 1
@@ -1,4 +1,4 @@
1
- import { ScramjetClient } from "../index";
1
+ import { ScramjetClient } from "@client/index";
2
2
  export declare function createWrapFn(client: ScramjetClient, self: GlobalThis): (identifier: any, strict: boolean) => any;
3
3
  export declare const order = 4;
4
4
  export default function (client: ScramjetClient, self: GlobalThis): void;
@@ -1,4 +1,4 @@
1
- import { IncrementalHtmlRewriter } from "../shared";
1
+ import { IncrementalHtmlRewriter } from "@/shared";
2
2
  import { ScramjetClient } from "./client";
3
3
  import { SourceMaps } from "./shared/sourcemaps";
4
4
  export declare class SingletonBox {
@@ -1,6 +1,6 @@
1
1
  import { BareResponse } from "@mercuryworkshop/proxy-transports";
2
2
  import { ScramjetFetchHandler, ScramjetFetchParsed, ScramjetFetchRequest, ScramjetFetchResponse } from ".";
3
- import { ScramjetHeaders } from "../shared";
3
+ import { ScramjetHeaders } from "@/shared";
4
4
  export declare function doHandleFetch(handler: ScramjetFetchHandler, request: ScramjetFetchRequest): Promise<ScramjetFetchResponse>;
5
5
  export declare function doNetworkFetch(handler: ScramjetFetchHandler, request: ScramjetFetchRequest, parsed: ScramjetFetchParsed, newheaders: ScramjetHeaders): Promise<BareResponse>;
6
6
  /** Simplified registrable-domain check used for cross-site redirect detection. */
@@ -1,4 +1,4 @@
1
- import { ScramjetHeaders } from "../shared";
1
+ import { ScramjetHeaders } from "@/shared";
2
2
  import { ScramjetFetchHandler, ScramjetFetchParsed, ScramjetFetchRequest } from ".";
3
3
  import { RawHeaders } from "@mercuryworkshop/proxy-transports";
4
4
  export declare function rewriteResponseHeaders(handler: ScramjetFetchHandler, request: ScramjetFetchRequest, parsed: ScramjetFetchParsed, rawHeaders: RawHeaders): Promise<ScramjetHeaders>;
@@ -12,6 +12,7 @@ export declare const QP: {
12
12
  readonly initiatorOrigin: "$io";
13
13
  readonly fetchSite: "$fs";
14
14
  readonly crossSiteRedirect: "$csr";
15
+ readonly fakeDataURL: "$fakedataurl";
15
16
  };
16
17
  export type QueryParamKey = keyof typeof QP;
17
18
  export type QueryParams = Partial<Record<QueryParamKey, string>>;
@@ -1,4 +1,4 @@
1
- import { ScramjetHeaders } from "../shared";
1
+ import { ScramjetHeaders } from "@/shared";
2
2
  import { BareResponse } from "@mercuryworkshop/proxy-transports";
3
3
  import { ScramjetFetchParsed } from ".";
4
4
  export declare function normalizeContentType(parsed: ScramjetFetchParsed, headers: ScramjetHeaders): void;
@@ -1,6 +1,6 @@
1
- import { URLMeta } from "./rewriters/url";
2
- import { ScramjetContext } from "../shared";
1
+ import { URLMeta } from "@rewriters/url";
2
+ import { ScramjetContext } from "@/shared";
3
3
  export declare const htmlRules: {
4
4
  [key: string]: "*" | string[] | ((...any: any[]) => string | null);
5
- fn: (value: string, context: ScramjetContext, meta: URLMeta) => string | null;
5
+ fn: (value: string, context: ScramjetContext, meta: URLMeta, attrs?: Record<string, string | undefined>) => string | null;
6
6
  }[];
@@ -1,9 +1,9 @@
1
- import { ScramjetConfig, ScramjetFlags, ScramjetVersionInfo } from "../types";
1
+ import { ScramjetConfig, ScramjetFlags, ScramjetVersionInfo } from "@/types";
2
2
  import DomHandler, { Element } from "domhandler";
3
- import { URLMeta } from "./rewriters/url";
3
+ import { URLMeta } from "@rewriters/url";
4
4
  import { CookieJar } from "./cookie";
5
- import { TapInstance } from "../Tap";
6
- import { HtmlContext } from "../shared/rewriters/html";
5
+ import { TapInstance } from "@/Tap";
6
+ import { HtmlContext } from "@/shared/rewriters/html";
7
7
  export * from "./cookie";
8
8
  export * from "./headers";
9
9
  export * from "./htmlRules";
@@ -32,6 +32,14 @@ export declare function isJavascriptMimeType(mime: string | ParsedMimeType): boo
32
32
  * JavaScript MIME type essence strings (not necessarily a full parsed MIME type).
33
33
  */
34
34
  export declare function isJavascriptMimeTypeEssenceMatch(s: string): boolean;
35
+ /**
36
+ * Whether a `<script type="...">` value denotes executable JavaScript
37
+ * (classic or module script), not a data block or import map.
38
+ * @see https://html.spec.whatwg.org/multipage/scripting.html#attr-script-type
39
+ */
40
+ export declare function isScriptType(type: string | null | undefined): boolean;
41
+ /** Whether `type` denotes a JavaScript module script. */
42
+ export declare function isModuleScriptType(type: string | null | undefined): boolean;
35
43
  /**
36
44
  * MIME types typically shown inline in a browsing context (navigation / iframe),
37
45
  * as opposed to triggering a download when Content-Disposition is absent.
@@ -1,4 +1,4 @@
1
- import { URLMeta } from "./url";
2
- import { ScramjetContext } from "../../shared";
1
+ import { URLMeta } from "@rewriters/url";
2
+ import { ScramjetContext } from "@/shared";
3
3
  export declare function rewriteCss(css: string, context: ScramjetContext, meta: URLMeta): string;
4
4
  export declare function unrewriteCss(css: string, context: ScramjetContext): string;
@@ -1,7 +1,7 @@
1
- import { URLMeta } from "./url";
2
- import { ScramjetContext } from "../../shared";
1
+ import { URLMeta } from "@rewriters/url";
2
+ import { ScramjetContext } from "@/shared";
3
3
  import { RawHeaders } from "@mercuryworkshop/proxy-transports";
4
- import { TrackedHistoryState } from "../../fetch";
4
+ import { TrackedHistoryState } from "@/fetch";
5
5
  export type ForeignContext = "svg" | "math" | "html";
6
6
  export type HtmlContext = {
7
7
  loadScripts: boolean;
@@ -1,5 +1,5 @@
1
- import { ScramjetContext } from "../../shared";
2
- import { URLMeta } from "./url";
1
+ import { ScramjetContext } from "@/shared";
2
+ import { URLMeta } from "@rewriters/url";
3
3
  type RewriterResult = {
4
4
  js: string | Uint8Array;
5
5
  map: Uint8Array | null;
@@ -1,4 +1,4 @@
1
- import { ScramjetContext } from "../../shared";
1
+ import { ScramjetContext } from "@/shared";
2
2
  import { _URL } from "../snapshot";
3
3
  export type NavigationType = "user" | "link" | "location";
4
4
  export type RewriteUrlOptions = {
@@ -1,7 +1,7 @@
1
1
  import { Rewriter } from "../../../rewriter/wasm/out/wasm.js";
2
2
  import type { JsRewriterOutput } from "../../../rewriter/wasm/out/wasm.js";
3
- import { ScramjetContext } from "../../shared";
3
+ import { ScramjetContext } from "@/shared";
4
4
  export type { JsRewriterOutput, Rewriter };
5
- import { URLMeta } from "./url";
5
+ import { URLMeta } from "@rewriters/url";
6
6
  export declare function setWasm(u8: Uint8Array | ArrayBuffer): void;
7
7
  export declare function getRewriter(context: ScramjetContext, meta: URLMeta): [Rewriter, () => void];
@@ -1,3 +1,3 @@
1
- import { ScramjetContext } from "../../shared";
2
- import { URLMeta } from "./url";
1
+ import { ScramjetContext } from "@/shared";
2
+ import { URLMeta } from "@rewriters/url";
3
3
  export declare function rewriteWorkers(context: ScramjetContext, js: string | Uint8Array, type: "module" | "regular", url: string, meta: URLMeta): string;
@@ -67,170 +67,119 @@ export declare const Promise_any: any;
67
67
  export declare const Symbol_for: (key: string) => symbol;
68
68
  declare const WrappedBrand: unique symbol;
69
69
  type WrappedInstance<T> = T extends object ? Wrapped<T> : T;
70
- export type Wrapped<T> = T extends abstract new (...args: infer Args) => infer Instance ? Omit<T, "prototype"> & {
70
+ type ConstructorPrototype<T> = T extends {
71
+ prototype: infer P;
72
+ } ? P : never;
73
+ type InstantiatePrototype<P, Params extends unknown[]> = Params extends [
74
+ infer A,
75
+ infer B
76
+ ] ? P extends WeakMap<any, any> ? WeakMap<A & WeakKey, B> : P extends Map<any, any> ? Map<A, B> : P : Params extends [infer A] ? P extends WeakSet<any> ? WeakSet<A & object> : P extends Set<any> ? Set<A> : P : P;
77
+ type WrappedCtorStatics<T> = Pick<T, Exclude<keyof T, "prototype">>;
78
+ type WrappedCtor<T, Params extends unknown[], New extends abstract new (...a: any) => any> = New & WrappedCtorStatics<T> & {
79
+ prototype: Wrapped<InstantiatePrototype<ConstructorPrototype<T>, Params>>;
80
+ readonly [WrappedBrand]: T;
81
+ };
82
+ type WrappedConstructor<T> = ConstructorPrototype<T> extends Map<any, any> ? T extends {
83
+ new <K, V>(...args: infer Args): any;
84
+ } ? WrappedCtor<T, [
85
+ unknown,
86
+ unknown
87
+ ], new <K, V>(...args: Args) => Wrapped<Map<K, V>>> : never : ConstructorPrototype<T> extends WeakMap<any, any> ? T extends {
88
+ new <K extends WeakKey, V>(...args: infer Args): any;
89
+ } ? WrappedCtor<T, [
90
+ WeakKey,
91
+ unknown
92
+ ], new <K extends WeakKey, V>(...args: Args) => Wrapped<WeakMap<K, V>>> : never : ConstructorPrototype<T> extends WeakSet<any> ? T extends {
93
+ new <U extends object>(...args: infer Args): any;
94
+ } ? WrappedCtor<T, [
95
+ object
96
+ ], new <U extends object>(...args: Args) => Wrapped<WeakSet<U>>> : never : ConstructorPrototype<T> extends Set<any> ? T extends {
97
+ new <U>(...args: infer Args): any;
98
+ } ? WrappedCtor<T, [
99
+ unknown
100
+ ], new <U>(...args: Args) => Wrapped<Set<U>>> : never : T extends {
101
+ new <K, V>(...args: infer Args): any;
102
+ } ? WrappedCtor<T, [
103
+ unknown,
104
+ unknown
105
+ ], new <K, V>(...args: Args) => Wrapped<InstantiatePrototype<ConstructorPrototype<T>, [K, V]>>> : T extends {
106
+ new <U>(...args: infer Args): any;
107
+ } ? WrappedCtor<T, [
108
+ unknown
109
+ ], new <U>(...args: Args) => Wrapped<InstantiatePrototype<ConstructorPrototype<T>, [U]>>> : T extends abstract new (...args: infer Args) => infer Instance ? Omit<T, "prototype"> & {
71
110
  new (...args: Args): WrappedInstance<Instance>;
72
111
  prototype: WrappedInstance<Instance>;
73
112
  readonly [WrappedBrand]: T;
74
- } : T & {
113
+ } : never;
114
+ export type Wrapped<T> = T extends abstract new (...args: any) => any ? WrappedConstructor<T> : T & {
75
115
  readonly [WrappedBrand]: T;
76
116
  };
77
- export declare const _URL: Omit<{
117
+ export declare const _URL: WrappedCtor<{
78
118
  new (url: string | URL, base?: string | URL): URL;
79
119
  prototype: URL;
80
120
  canParse(url: string | URL, base?: string | URL): boolean;
81
121
  createObjectURL(obj: Blob | MediaSource): string;
82
122
  parse(url: string | URL, base?: string | URL): URL | null;
83
123
  revokeObjectURL(url: string): void;
84
- }, "prototype"> & {
85
- new (url: string | URL, base?: string | URL): URL & {
86
- readonly [WrappedBrand]: URL;
87
- };
88
- prototype: URL & {
89
- readonly [WrappedBrand]: URL;
90
- };
91
- readonly [WrappedBrand]: {
92
- new (url: string | URL, base?: string | URL): URL;
93
- prototype: URL;
94
- canParse(url: string | URL, base?: string | URL): boolean;
95
- createObjectURL(obj: Blob | MediaSource): string;
96
- parse(url: string | URL, base?: string | URL): URL | null;
97
- revokeObjectURL(url: string): void;
98
- };
99
- };
124
+ }, [unknown, unknown], new <K, V>(url: string | URL, base?: string | URL) => URL & {
125
+ readonly [WrappedBrand]: URL;
126
+ }>;
100
127
  export type _URL = Wrapped<URL>;
101
- export declare const _Headers: Omit<{
128
+ export declare const _Headers: WrappedCtor<{
102
129
  new (init?: HeadersInit): Headers;
103
130
  prototype: Headers;
104
- }, "prototype"> & {
105
- new (init?: HeadersInit): Headers & {
106
- readonly [WrappedBrand]: Headers;
107
- };
108
- prototype: Headers & {
109
- readonly [WrappedBrand]: Headers;
110
- };
111
- readonly [WrappedBrand]: {
112
- new (init?: HeadersInit): Headers;
113
- prototype: Headers;
114
- };
115
- };
131
+ }, [unknown, unknown], new <K, V>(init?: HeadersInit) => Headers & {
132
+ readonly [WrappedBrand]: Headers;
133
+ }>;
116
134
  export type _Headers = Wrapped<Headers>;
117
- export declare const _Date: Omit<DateConstructor, "prototype"> & {
118
- new (value: string | number | Date): Date & {
119
- readonly [WrappedBrand]: Date;
120
- };
121
- prototype: Date & {
122
- readonly [WrappedBrand]: Date;
123
- };
124
- readonly [WrappedBrand]: DateConstructor;
125
- };
135
+ export declare const _Date: WrappedCtor<DateConstructor, [unknown, unknown], new <K, V>(value: string | number | Date) => Date & {
136
+ readonly [WrappedBrand]: Date;
137
+ }>;
126
138
  export type _Date = Wrapped<Date>;
127
- export declare const _URLSearchParams: Omit<{
139
+ export declare const _URLSearchParams: WrappedCtor<{
128
140
  new (init?: string[][] | Record<string, string> | string | URLSearchParams): URLSearchParams;
129
141
  prototype: URLSearchParams;
130
- }, "prototype"> & {
131
- new (init?: string | Record<string, string> | string[][] | URLSearchParams): URLSearchParams & {
132
- readonly [WrappedBrand]: URLSearchParams;
133
- };
134
- prototype: URLSearchParams & {
135
- readonly [WrappedBrand]: URLSearchParams;
136
- };
137
- readonly [WrappedBrand]: {
138
- new (init?: string[][] | Record<string, string> | string | URLSearchParams): URLSearchParams;
139
- prototype: URLSearchParams;
140
- };
141
- };
142
+ }, [unknown, unknown], new <K, V>(init?: string | Record<string, string> | URLSearchParams | string[][]) => URLSearchParams & {
143
+ readonly [WrappedBrand]: URLSearchParams;
144
+ }>;
142
145
  export type _URLSearchParams = Wrapped<URLSearchParams>;
143
- export declare const _RegExp: Omit<RegExpConstructor, "prototype"> & {
144
- new (pattern: string | RegExp, flags?: string): RegExp & {
145
- readonly [WrappedBrand]: RegExp;
146
- };
147
- prototype: RegExp & {
148
- readonly [WrappedBrand]: RegExp;
149
- };
150
- readonly [WrappedBrand]: RegExpConstructor;
151
- };
146
+ export declare const _RegExp: WrappedCtor<RegExpConstructor, [unknown, unknown], new <K, V>(pattern: string | RegExp, flags?: string) => RegExp & {
147
+ readonly [WrappedBrand]: RegExp;
148
+ }>;
152
149
  export type _RegExp = Wrapped<RegExp>;
153
- export declare const _Set: Omit<SetConstructor, "prototype"> & {
154
- new (iterable?: Iterable<unknown>): Set<unknown> & {
155
- readonly [WrappedBrand]: Set<unknown>;
156
- };
157
- prototype: Set<unknown> & {
158
- readonly [WrappedBrand]: Set<unknown>;
159
- };
160
- readonly [WrappedBrand]: SetConstructor;
161
- };
150
+ export declare const _Set: WrappedCtor<SetConstructor, [object], new <U extends object>(iterable?: Iterable<unknown>) => WeakSet<U> & {
151
+ readonly [WrappedBrand]: WeakSet<U>;
152
+ }>;
162
153
  export type _Set<T> = Wrapped<Set<T>>;
163
- export declare const _Map: Omit<MapConstructor, "prototype"> & {
164
- new (iterable?: Iterable<readonly [unknown, unknown]>): Map<unknown, unknown> & {
165
- readonly [WrappedBrand]: Map<unknown, unknown>;
166
- };
167
- prototype: Map<unknown, unknown> & {
168
- readonly [WrappedBrand]: Map<unknown, unknown>;
169
- };
170
- readonly [WrappedBrand]: MapConstructor;
171
- };
154
+ export declare const _Map: WrappedCtor<MapConstructor, [unknown, unknown], new <K, V>(iterable?: Iterable<readonly [unknown, unknown]>) => Map<K, V> & {
155
+ readonly [WrappedBrand]: Map<K, V>;
156
+ }>;
172
157
  export type _Map<K, V> = Wrapped<Map<K, V>>;
173
- export declare const _WeakSet: Omit<WeakSetConstructor, "prototype"> & {
174
- new (iterable: Iterable<WeakKey>): WeakSet<WeakKey> & {
175
- readonly [WrappedBrand]: WeakSet<WeakKey>;
176
- };
177
- prototype: WeakSet<WeakKey> & {
178
- readonly [WrappedBrand]: WeakSet<WeakKey>;
179
- };
180
- readonly [WrappedBrand]: WeakSetConstructor;
181
- };
158
+ export declare const _WeakSet: WrappedCtor<WeakSetConstructor, [object], new <U extends object>(iterable: Iterable<WeakKey>) => WeakSet<U> & {
159
+ readonly [WrappedBrand]: WeakSet<U>;
160
+ }>;
182
161
  export type _WeakSet<T extends object> = Wrapped<WeakSet<T>>;
183
- export declare const _WeakMap: Omit<WeakMapConstructor, "prototype"> & {
184
- new (iterable: Iterable<readonly [WeakKey, unknown]>): WeakMap<WeakKey, unknown> & {
185
- readonly [WrappedBrand]: WeakMap<WeakKey, unknown>;
186
- };
187
- prototype: WeakMap<WeakKey, unknown> & {
188
- readonly [WrappedBrand]: WeakMap<WeakKey, unknown>;
189
- };
190
- readonly [WrappedBrand]: WeakMapConstructor;
191
- };
162
+ export declare const _WeakMap: WrappedCtor<WeakMapConstructor, [WeakKey, unknown], new <K extends WeakKey, V>(iterable: Iterable<readonly [WeakKey, unknown]>) => WeakMap<K, V> & {
163
+ readonly [WrappedBrand]: WeakMap<K, V>;
164
+ }>;
192
165
  export type _WeakMap<K extends object, V extends object> = Wrapped<WeakMap<K, V>>;
193
- export declare const _Uint8Array: Omit<Uint8ArrayConstructor, "prototype"> & {
194
- new (): Uint8Array<ArrayBuffer> & {
195
- readonly [WrappedBrand]: Uint8Array<ArrayBuffer>;
196
- };
197
- prototype: Uint8Array<ArrayBuffer> & {
198
- readonly [WrappedBrand]: Uint8Array<ArrayBuffer>;
199
- };
200
- readonly [WrappedBrand]: Uint8ArrayConstructor;
201
- };
166
+ export declare const _Uint8Array: WrappedCtor<Uint8ArrayConstructor, [unknown, unknown], new <K, V>() => Uint8Array<ArrayBufferLike> & {
167
+ readonly [WrappedBrand]: Uint8Array<ArrayBufferLike>;
168
+ }>;
202
169
  export type _Uint8Array = Wrapped<Uint8Array>;
203
- export declare const _TextDecoder: Omit<{
170
+ export declare const _TextDecoder: WrappedCtor<{
204
171
  new (label?: string, options?: TextDecoderOptions): TextDecoder;
205
172
  prototype: TextDecoder;
206
- }, "prototype"> & {
207
- new (label?: string, options?: TextDecoderOptions): TextDecoder & {
208
- readonly [WrappedBrand]: TextDecoder;
209
- };
210
- prototype: TextDecoder & {
211
- readonly [WrappedBrand]: TextDecoder;
212
- };
213
- readonly [WrappedBrand]: {
214
- new (label?: string, options?: TextDecoderOptions): TextDecoder;
215
- prototype: TextDecoder;
216
- };
217
- };
173
+ }, [unknown, unknown], new <K, V>(label?: string, options?: TextDecoderOptions) => TextDecoder & {
174
+ readonly [WrappedBrand]: TextDecoder;
175
+ }>;
218
176
  export type _TextDecoder = Wrapped<TextDecoder>;
219
- export declare const _TextEncoder: Omit<{
177
+ export declare const _TextEncoder: WrappedCtor<{
220
178
  new (): TextEncoder;
221
179
  prototype: TextEncoder;
222
- }, "prototype"> & {
223
- new (): TextEncoder & {
224
- readonly [WrappedBrand]: TextEncoder;
225
- };
226
- prototype: TextEncoder & {
227
- readonly [WrappedBrand]: TextEncoder;
228
- };
229
- readonly [WrappedBrand]: {
230
- new (): TextEncoder;
231
- prototype: TextEncoder;
232
- };
233
- };
180
+ }, [unknown, unknown], new <K, V>() => TextEncoder & {
181
+ readonly [WrappedBrand]: TextEncoder;
182
+ }>;
234
183
  export type _TextEncoder = Wrapped<TextEncoder>;
235
184
  export declare function makeWrap<T extends object>(source: T): Wrapped<T>;
236
185
  export {};
package/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "@mercuryworkshop/scramjet",
3
- "version": "2.0.5-alpha",
3
+ "version": "2.0.6-alpha",
4
+ "license": "AGPL-3.0-only",
4
5
  "description": "An experimental web proxy that aims to be the successor to Ultraviolet",
5
6
  "type": "module",
6
7
  "types": "./dist/types/index.d.ts",
8
+ "main": "./dist/scramjet-external.mjs",
9
+ "module": "./dist/scramjet-external.mjs",
7
10
  "repository": {
8
11
  "type": "git",
9
12
  "url": "https://github.com/MercuryWorkshop/scramjet"
@@ -11,13 +14,17 @@
11
14
  "exports": {
12
15
  ".": {
13
16
  "types": "./dist/types/index.d.ts",
14
- "default": "./dist/scramjet.mjs"
17
+ "default": "./dist/scramjet-external.mjs"
15
18
  },
16
19
  "./path": {
17
20
  "types": "./lib/index.d.ts",
18
21
  "default": "./lib/index.cjs"
19
22
  },
20
23
  "./bundled": {
24
+ "types": "./dist/types/index.d.ts",
25
+ "default": "./dist/scramjet.mjs"
26
+ },
27
+ "./bundled-wasm": {
21
28
  "types": "./dist/types/index.d.ts",
22
29
  "default": "./dist/scramjet_bundled.mjs"
23
30
  }
@@ -28,7 +35,6 @@
28
35
  ],
29
36
  "keywords": [],
30
37
  "author": "",
31
- "license": "MIT",
32
38
  "ava": {
33
39
  "files": [
34
40
  "tests/ci/**/*.js"
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,4 +0,0 @@
1
- import { ScramjetClient } from "./index";
2
- export declare const UNSAFE_GLOBALS: string[];
3
- export declare function createGlobalProxy(client: ScramjetClient, self: typeof globalThis): typeof globalThis;
4
- export declare function createDocumentProxy(client: ScramjetClient, self: typeof globalThis): any;
@@ -1,19 +0,0 @@
1
- import { ProxyCtx, ScramjetClient } from "../client";
2
- /**
3
- * Maps each fast-path wrapper function back to the native function it
4
- * stands in for, so `Function.prototype.toString` interception
5
- * (sourcemaps.ts) can return the original native source string and avoid
6
- * leaking our wrapper's body to anti-tampering checks. Module-level so
7
- * it survives across module loads and is shared with sourcemaps.ts.
8
- */
9
- export declare const NATIVE_BACKING: WeakMap<AnyFunction, AnyFunction>;
10
- type AnyFunction = (...args: any[]) => any;
11
- export declare const order = 3;
12
- export declare const enabled: (c: ScramjetClient) => boolean;
13
- export default function (client: ScramjetClient, self: typeof window): void;
14
- /**
15
- * Legacy helper retained for backward compatibility with any consumer that
16
- * imported it. New code should rely on the IDL-driven hooks installed above.
17
- */
18
- export declare function unproxy(ctx: ProxyCtx, client: ScramjetClient): void;
19
- export {};
@@ -1,50 +0,0 @@
1
- /**
2
- * Single character proxy "kind" tag:
3
- * "w" -> Window/WindowProxy "d" -> Document
4
- * "*" -> overload disagrees, probe the value at runtime
5
- */
6
- export type ProxyKind = "w" | "d" | "*";
7
- /**
8
- * Selector for a Window/Document value reachable from an operation argument.
9
- * [argIdx, kind] -- the entire argument
10
- * [argIdx, kind, ...path] -- a property path inside a dict arg
11
- * (e.g. options.root)
12
- */
13
- export type ArgSelector = readonly [
14
- argIdx: number,
15
- kind: "w" | "d",
16
- ...path: string[]
17
- ];
18
- /**
19
- * Operation/constructor table entry:
20
- * [owner, member, isStatic, isCtor, argSelectors, returnKind]
21
- *
22
- * - owner is the interface/namespace name (e.g. "Document", "Window")
23
- * - member is the method name; "" for constructors
24
- * - isStatic=true patches `Owner.member`, false patches `Owner.prototype.member`
25
- * - isCtor=true patches the interface constructor itself
26
- * - returnKind="" means no return wrapping needed
27
- */
28
- export type OpEntry = readonly [
29
- owner: string,
30
- member: string,
31
- isStatic: boolean,
32
- isCtor: boolean,
33
- argSelectors: readonly ArgSelector[],
34
- returnKind: ProxyKind | ""
35
- ];
36
- /**
37
- * Attribute table entry:
38
- * [owner, member, isStatic, kind, readonly]
39
- *
40
- * isStatic=true patches `Owner.member`, false patches `Owner.prototype.member`.
41
- */
42
- export type AttrEntry = readonly [
43
- owner: string,
44
- member: string,
45
- isStatic: boolean,
46
- kind: ProxyKind,
47
- readonly: boolean
48
- ];
49
- export declare const OPERATIONS: readonly OpEntry[];
50
- export declare const ATTRIBUTES: readonly AttrEntry[];