@mercuryworkshop/scramjet 2.0.0-alpha → 2.0.2-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 (61) hide show
  1. package/dist/a68dd7a5344f1722.wasm +0 -0
  2. package/dist/c34a4f083a11eae2.wasm +0 -0
  3. package/dist/scramjet.js +33 -0
  4. package/dist/scramjet.js.map +1 -0
  5. package/dist/scramjet.mjs +33 -0
  6. package/dist/scramjet.mjs.map +1 -0
  7. package/dist/scramjet.wasm +0 -0
  8. package/dist/scramjet_bundled.js +33 -0
  9. package/dist/scramjet_bundled.js.map +1 -0
  10. package/dist/scramjet_bundled.mjs +33 -0
  11. package/dist/scramjet_bundled.mjs.map +1 -0
  12. package/dist/types/client/client.d.ts +91 -0
  13. package/dist/types/client/entry.d.ts +5 -0
  14. package/dist/types/client/events.d.ts +38 -0
  15. package/dist/types/client/helpers.d.ts +1 -0
  16. package/dist/types/client/index.d.ts +7 -0
  17. package/dist/types/client/location.d.ts +2 -0
  18. package/dist/types/client/shared/eval.d.ts +3 -0
  19. package/dist/types/client/shared/sourcemaps.d.ts +19 -0
  20. package/dist/types/client/shared/wrap.d.ts +4 -0
  21. package/dist/types/client/singletonbox.d.ts +14 -0
  22. package/dist/types/fetch/index.d.ts +80 -0
  23. package/dist/types/index.d.ts +9 -0
  24. package/dist/types/index.js +26 -0
  25. package/dist/types/index.js.map +1 -0
  26. package/dist/types/shared/cookie.d.ts +18 -0
  27. package/dist/types/shared/headers.d.ts +13 -0
  28. package/dist/types/shared/htmlRules.d.ts +6 -0
  29. package/dist/types/shared/index.d.ts +23 -0
  30. package/dist/types/shared/rewriters/css.d.ts +4 -0
  31. package/dist/types/shared/rewriters/html.d.ts +6 -0
  32. package/dist/types/shared/rewriters/index.d.ts +6 -0
  33. package/dist/types/shared/rewriters/js.d.ts +11 -0
  34. package/dist/types/shared/rewriters/url.d.ts +11 -0
  35. package/dist/types/shared/rewriters/wasm.d.ts +8 -0
  36. package/dist/types/shared/rewriters/worker.d.ts +3 -0
  37. package/dist/types/shared/security/index.d.ts +1 -0
  38. package/dist/types/shared/security/siteTests.d.ts +1 -0
  39. package/dist/types/symbols.d.ts +7 -0
  40. package/dist/types/types.d.ts +115 -0
  41. package/lib/index.d.ts +5 -0
  42. package/package.json +96 -84
  43. package/LICENSE +0 -661
  44. package/README.md +0 -65
  45. package/dist/06813b79f94926ac.wasm +0 -0
  46. package/dist/09d5a95846afcaf1.wasm +0 -0
  47. package/dist/507621c43f70fc86.wasm +0 -0
  48. package/dist/63d477311eb50f38.wasm +0 -0
  49. package/dist/70102b41994b76de.wasm +0 -0
  50. package/dist/a31cde01c0b49ef3.wasm +0 -0
  51. package/dist/b4f3c1c0e4a92823.wasm +0 -0
  52. package/dist/d864ec42994880cb.wasm +0 -0
  53. package/dist/dbbe994629c3010c.wasm +0 -0
  54. package/dist/scramjet.all.js +0 -194
  55. package/dist/scramjet.all.js.map +0 -1
  56. package/dist/scramjet.bundle.js +0 -194
  57. package/dist/scramjet.bundle.js.map +0 -1
  58. package/dist/scramjet.sync.js +0 -2
  59. package/dist/scramjet.sync.js.map +0 -1
  60. package/dist/scramjet.wasm.wasm +0 -0
  61. package/lib/noop.js +0 -0
@@ -0,0 +1,91 @@
1
+ type ScramjetFrame = any;
2
+ import { BareCompatibleClient, ProxyTransport } from "@mercuryworkshop/proxy-transports";
3
+ import { type URLMeta } from "../shared/rewriters/url";
4
+ import { ScramjetContext } from "../shared";
5
+ import { SingletonBox } from "./singletonbox";
6
+ import { ScramjetConfig } from "../types";
7
+ export type ScramjetClientInit = {
8
+ context: ScramjetContext;
9
+ transport: ProxyTransport;
10
+ sendSetCookie: (url: URL, cookie: string) => Promise<void>;
11
+ shouldPassthroughWebsocket?: (url: string | URL) => boolean;
12
+ shouldBlockMessageEvent?: (ev: MessageEvent) => boolean;
13
+ hookSubcontext: (self: Self, frame?: HTMLIFrameElement) => ScramjetClient;
14
+ };
15
+ type NativeStore = {
16
+ store: Record<string, any>;
17
+ call: (target: string, that: any, ...args: any[]) => any;
18
+ construct: (target: string, ...args: any[]) => any;
19
+ };
20
+ type DescriptorStore = {
21
+ store: Record<string, PropertyDescriptor>;
22
+ get: (target: string, that: any) => any;
23
+ set: (target: string, that: any, value: any) => void;
24
+ };
25
+ export type AnyFunction = Function;
26
+ export type ScramjetModule = {
27
+ enabled: (client: ScramjetClient) => boolean | undefined;
28
+ disabled: (client: ScramjetClient, self: typeof globalThis) => void | undefined;
29
+ order: number | undefined;
30
+ default: (client: ScramjetClient, self: typeof globalThis) => void;
31
+ };
32
+ export type ProxyCtx = {
33
+ fn: AnyFunction;
34
+ this: any;
35
+ args: any[];
36
+ newTarget: AnyFunction;
37
+ return: (r: any) => void;
38
+ call: () => any;
39
+ };
40
+ export type Proxy = {
41
+ construct?(ctx: ProxyCtx): any;
42
+ apply?(ctx: ProxyCtx): any;
43
+ };
44
+ export type TrapCtx<T> = {
45
+ this: any;
46
+ get: () => T;
47
+ set: (v: T) => void;
48
+ };
49
+ export type Trap<T> = {
50
+ writable?: boolean;
51
+ value?: any;
52
+ enumerable?: boolean;
53
+ configurable?: boolean;
54
+ get?: (ctx: TrapCtx<T>) => T;
55
+ set?: (ctx: TrapCtx<T>, v: T) => void;
56
+ };
57
+ export declare class ScramjetClient {
58
+ global: typeof globalThis;
59
+ init: ScramjetClientInit;
60
+ locationProxy: any;
61
+ serviceWorker: ServiceWorkerContainer;
62
+ bare: BareCompatibleClient;
63
+ natives: NativeStore;
64
+ descriptors: DescriptorStore;
65
+ wrapfn: (i: any, ...args: any) => any;
66
+ eventcallbacks: Map<any, [
67
+ {
68
+ event: string;
69
+ originalCallback: AnyFunction;
70
+ proxiedCallback: AnyFunction;
71
+ }
72
+ ]>;
73
+ meta: URLMeta;
74
+ box: SingletonBox;
75
+ context: ScramjetContext;
76
+ constructor(global: typeof globalThis, init: ScramjetClientInit);
77
+ get frame(): ScramjetFrame | null;
78
+ get isSubframe(): boolean;
79
+ hook(): void;
80
+ get url(): URL;
81
+ set url(url: URL | string);
82
+ Proxy(name: string | string[], handler: Proxy): void;
83
+ RawProxy(target: any, prop: string, handler: Proxy, debugname?: string): void;
84
+ Trap<T>(name: string | string[], descriptor: Trap<T>): PropertyDescriptor;
85
+ RawTrap<T>(target: any, prop: string, descriptor: Trap<T>): PropertyDescriptor;
86
+ rewriteUrl(url: string | URL): string;
87
+ unrewriteUrl(url: string | URL): string;
88
+ flagEnabled(flag: keyof ScramjetConfig["flags"]): boolean;
89
+ get config(): ScramjetConfig;
90
+ }
91
+ export {};
@@ -0,0 +1,5 @@
1
+ export declare const iswindow: boolean;
2
+ export declare const isworker: boolean;
3
+ export declare const issw: boolean;
4
+ export declare const isdedicated: boolean;
5
+ export declare const isshared: boolean;
@@ -0,0 +1,38 @@
1
+ import { ScramjetClient } from "./index";
2
+ /**
3
+ * Union type for all Scramjet proxified navigation events.
4
+ */
5
+ export type ScramjetEvent = NavigateEvent | UrlChangeEvent | ScramjetContextEvent;
6
+ /**
7
+ * Type map for all Scramjet navigation events with their corresponding event types.
8
+ */
9
+ export type ScramjetEvents = {
10
+ navigate: NavigateEvent;
11
+ urlchange: UrlChangeEvent;
12
+ contextInit: ScramjetContextEvent;
13
+ };
14
+ /**
15
+ * Navigation event class fired when Scramjet frame navigates to a new proxified URL.
16
+ */
17
+ export declare class NavigateEvent extends Event {
18
+ url: string;
19
+ type: string;
20
+ constructor(url: string);
21
+ }
22
+ /**
23
+ * URL change event class fired when the proxified URL changes in a Scramjet frame.
24
+ */
25
+ export declare class UrlChangeEvent extends Event {
26
+ url: string;
27
+ type: string;
28
+ constructor(url: string);
29
+ }
30
+ /**
31
+ * Event class fired when Scramjet initializes in a frame.
32
+ */
33
+ export declare class ScramjetContextEvent extends Event {
34
+ window: Self;
35
+ client: ScramjetClient;
36
+ type: string;
37
+ constructor(window: Self, client: ScramjetClient);
38
+ }
@@ -0,0 +1 @@
1
+ export declare function getOwnPropertyDescriptorHandler(target: any, prop: any): TypedPropertyDescriptor<any>;
@@ -0,0 +1,7 @@
1
+ export * from "./client";
2
+ export * from "./entry";
3
+ export * from "./events";
4
+ export * from "./helpers";
5
+ export * from "./location";
6
+ export * from "./index";
7
+ export * from "./location";
@@ -0,0 +1,2 @@
1
+ import { ScramjetClient } from "./index";
2
+ export declare function createLocationProxy(client: ScramjetClient, self: typeof globalThis): any;
@@ -0,0 +1,3 @@
1
+ import { ScramjetClient } from "../index";
2
+ export default function (client: ScramjetClient, self: Self): void;
3
+ export declare function indirectEval(this: ScramjetClient, strict: boolean, js: any): any;
@@ -0,0 +1,19 @@
1
+ import { ScramjetClient } from "../index";
2
+ declare enum RewriteType {
3
+ Insert = 0,
4
+ Replace = 1
5
+ }
6
+ type Rewrite = {
7
+ start: number;
8
+ } & ({
9
+ type: RewriteType.Insert;
10
+ size: number;
11
+ } | {
12
+ type: RewriteType.Replace;
13
+ end: number;
14
+ str: string;
15
+ });
16
+ export type SourceMaps = Record<string, Rewrite[]>;
17
+ export declare const enabled: (client: ScramjetClient) => boolean;
18
+ export default function (client: ScramjetClient, self: Self): void;
19
+ export {};
@@ -0,0 +1,4 @@
1
+ import { ScramjetClient } from "../index";
2
+ export declare function createWrapFn(client: ScramjetClient, self: typeof globalThis): (identifier: any, strict: boolean) => any;
3
+ export declare const order = 4;
4
+ export default function (client: ScramjetClient, self: typeof globalThis): void;
@@ -0,0 +1,14 @@
1
+ import { ScramjetClient } from "./client";
2
+ import { SourceMaps } from "./shared/sourcemaps";
3
+ export declare class SingletonBox {
4
+ ownerclient: ScramjetClient;
5
+ clients: ScramjetClient[];
6
+ globals: Map<Self, ScramjetClient>;
7
+ documents: Map<Document, ScramjetClient>;
8
+ locations: Map<Location, ScramjetClient>;
9
+ ctors: Record<string, Function[]>;
10
+ sourcemaps: SourceMaps;
11
+ constructor(ownerclient: ScramjetClient);
12
+ registerClient(client: ScramjetClient, global: Self): void;
13
+ instanceof(obj: any, name: string): boolean;
14
+ }
@@ -0,0 +1,80 @@
1
+ import { BareCompatibleClient, BareResponse, ProxyTransport, RawHeaders, BareRequestInit } from "@mercuryworkshop/proxy-transports";
2
+ import { type URLMeta } from "../shared/rewriters/url";
3
+ import { ScramjetHeaders } from "../shared/headers";
4
+ import { ScramjetContext } from "../shared";
5
+ import DomHandler from "domhandler";
6
+ export interface ScramjetFetchRequest {
7
+ rawUrl: URL;
8
+ destination: RequestDestination;
9
+ mode: RequestMode;
10
+ referrer: string;
11
+ method: string;
12
+ body: BodyType | null;
13
+ cache: RequestCache;
14
+ initialHeaders: ScramjetHeaders;
15
+ rawClientUrl?: URL;
16
+ }
17
+ export interface ScramjetFetchParsed {
18
+ url: URL;
19
+ clientUrl?: URL;
20
+ meta: URLMeta;
21
+ scriptType: "module" | "regular";
22
+ }
23
+ export interface ScramjetFetchResponse {
24
+ body: BodyType;
25
+ headers: ScramjetHeaders;
26
+ status: number;
27
+ statusText: string;
28
+ }
29
+ export type FetchHandlerInit = {
30
+ transport: ProxyTransport;
31
+ context: ScramjetContext;
32
+ crossOriginIsolated?: boolean;
33
+ sendSetCookie: (url: URL, cookie: string) => Promise<void>;
34
+ fetchDataUrl(dataUrl: string): Promise<BareResponse>;
35
+ fetchBlobUrl(blobUrl: string): Promise<BareResponse>;
36
+ };
37
+ export declare class ScramjetFetchHandler extends EventTarget {
38
+ client: BareCompatibleClient;
39
+ crossOriginIsolated: boolean;
40
+ context: ScramjetContext;
41
+ fetchDataUrl: (dataUrl: string) => Promise<Response>;
42
+ fetchBlobUrl: (blobUrl: string) => Promise<Response>;
43
+ sendSetCookie: (url: URL, cookie: string) => Promise<void>;
44
+ constructor(init: FetchHandlerInit);
45
+ handleFetch(request: ScramjetFetchRequest): Promise<ScramjetFetchResponse>;
46
+ }
47
+ export declare function parseRequest(request: ScramjetFetchRequest, handler: ScramjetFetchHandler): ScramjetFetchParsed;
48
+ export declare function rewriteHeaders(handler: ScramjetFetchHandler, request: ScramjetFetchRequest, parsed: ScramjetFetchParsed, rawHeaders: RawHeaders): Promise<ScramjetHeaders>;
49
+ type BodyType = string | ArrayBuffer | Blob | ReadableStream<any>;
50
+ export declare class ScramjetHTMLPreRewriteEvent extends Event {
51
+ handler: DomHandler;
52
+ context: ScramjetFetchRequest;
53
+ parsed: ScramjetFetchParsed;
54
+ constructor(handler: DomHandler, context: ScramjetFetchRequest, parsed: ScramjetFetchParsed);
55
+ }
56
+ export declare class ScramjetHTMLPostRewriteEvent extends Event {
57
+ handler: DomHandler;
58
+ context: ScramjetFetchRequest;
59
+ parsed: ScramjetFetchParsed;
60
+ constructor(handler: DomHandler, context: ScramjetFetchRequest, parsed: ScramjetFetchParsed);
61
+ }
62
+ export declare class ScramjetResponseEvent extends Event {
63
+ context: ScramjetFetchRequest;
64
+ parsed: ScramjetFetchParsed;
65
+ response: ScramjetFetchResponse;
66
+ _response?: ScramjetFetchResponse | Promise<ScramjetFetchResponse>;
67
+ constructor(context: ScramjetFetchRequest, parsed: ScramjetFetchParsed, response: ScramjetFetchResponse);
68
+ respondWith(response: ScramjetFetchResponse | Promise<ScramjetFetchResponse>): void;
69
+ }
70
+ export declare class ScramjetRequestEvent extends Event {
71
+ context: ScramjetFetchRequest;
72
+ url: URL;
73
+ parsed: ScramjetFetchParsed;
74
+ init: BareRequestInit;
75
+ client: BareCompatibleClient;
76
+ _response?: BareResponse | Promise<BareResponse> | Response | Promise<Response>;
77
+ constructor(context: ScramjetFetchRequest, url: URL, parsed: ScramjetFetchParsed, init: BareRequestInit, client: BareCompatibleClient);
78
+ respondWith(response: BareResponse | Promise<BareResponse>): void;
79
+ }
80
+ export {};
@@ -0,0 +1,9 @@
1
+ import "./global.d";
2
+ import { ScramjetConfig } from "./types";
3
+ export * from "./client";
4
+ export * from "./shared";
5
+ export * from "./symbols";
6
+ export * from "./types";
7
+ export * from "./fetch";
8
+ export declare const defaultConfig: ScramjetConfig;
9
+ export declare const defaultConfigDev: ScramjetConfig;