@mercuryworkshop/scramjet 2.0.0-alpha → 2.0.1-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 (57) hide show
  1. package/dist/c34a4f083a11eae2.wasm +0 -0
  2. package/dist/scramjet.js +33 -0
  3. package/dist/scramjet.js.map +1 -0
  4. package/dist/scramjet.mjs +33 -0
  5. package/dist/scramjet.mjs.map +1 -0
  6. package/dist/scramjet.wasm.wasm +0 -0
  7. package/dist/scramjet_bundled.js +33 -0
  8. package/dist/scramjet_bundled.js.map +1 -0
  9. package/dist/scramjet_bundled.mjs +33 -0
  10. package/dist/scramjet_bundled.mjs.map +1 -0
  11. package/dist/types/client/client.d.ts +91 -0
  12. package/dist/types/client/entry.d.ts +5 -0
  13. package/dist/types/client/events.d.ts +38 -0
  14. package/dist/types/client/helpers.d.ts +1 -0
  15. package/dist/types/client/index.d.ts +7 -0
  16. package/dist/types/client/location.d.ts +2 -0
  17. package/dist/types/client/shared/eval.d.ts +3 -0
  18. package/dist/types/client/shared/sourcemaps.d.ts +19 -0
  19. package/dist/types/client/shared/wrap.d.ts +4 -0
  20. package/dist/types/client/singletonbox.d.ts +14 -0
  21. package/dist/types/fetch/index.d.ts +80 -0
  22. package/dist/types/index.d.ts +9 -0
  23. package/dist/types/shared/cookie.d.ts +18 -0
  24. package/dist/types/shared/headers.d.ts +13 -0
  25. package/dist/types/shared/htmlRules.d.ts +6 -0
  26. package/dist/types/shared/index.d.ts +23 -0
  27. package/dist/types/shared/rewriters/css.d.ts +4 -0
  28. package/dist/types/shared/rewriters/html.d.ts +6 -0
  29. package/dist/types/shared/rewriters/index.d.ts +6 -0
  30. package/dist/types/shared/rewriters/js.d.ts +11 -0
  31. package/dist/types/shared/rewriters/url.d.ts +11 -0
  32. package/dist/types/shared/rewriters/wasm.d.ts +8 -0
  33. package/dist/types/shared/rewriters/worker.d.ts +3 -0
  34. package/dist/types/shared/security/index.d.ts +1 -0
  35. package/dist/types/shared/security/siteTests.d.ts +1 -0
  36. package/dist/types/symbols.d.ts +7 -0
  37. package/dist/types/types.d.ts +114 -0
  38. package/lib/index.d.ts +5 -0
  39. package/package.json +98 -84
  40. package/LICENSE +0 -661
  41. package/README.md +0 -65
  42. package/dist/06813b79f94926ac.wasm +0 -0
  43. package/dist/09d5a95846afcaf1.wasm +0 -0
  44. package/dist/507621c43f70fc86.wasm +0 -0
  45. package/dist/63d477311eb50f38.wasm +0 -0
  46. package/dist/70102b41994b76de.wasm +0 -0
  47. package/dist/a31cde01c0b49ef3.wasm +0 -0
  48. package/dist/b4f3c1c0e4a92823.wasm +0 -0
  49. package/dist/d864ec42994880cb.wasm +0 -0
  50. package/dist/dbbe994629c3010c.wasm +0 -0
  51. package/dist/scramjet.all.js +0 -194
  52. package/dist/scramjet.all.js.map +0 -1
  53. package/dist/scramjet.bundle.js +0 -194
  54. package/dist/scramjet.bundle.js.map +0 -1
  55. package/dist/scramjet.sync.js +0 -2
  56. package/dist/scramjet.sync.js.map +0 -1
  57. 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;
@@ -0,0 +1,18 @@
1
+ export type Cookie = {
2
+ name: string;
3
+ value: string;
4
+ path?: string;
5
+ expires?: string;
6
+ maxAge?: number;
7
+ domain?: string;
8
+ secure?: boolean;
9
+ httpOnly?: boolean;
10
+ sameSite?: "strict" | "lax" | "none";
11
+ };
12
+ export declare class CookieJar {
13
+ private cookies;
14
+ setCookies(cookies: string[], url: URL): void;
15
+ getCookies(url: URL, fromJs: boolean): string;
16
+ load(cookies: string): null;
17
+ dump(): string;
18
+ }
@@ -0,0 +1,13 @@
1
+ import { RawHeaders } from "@mercuryworkshop/proxy-transports";
2
+ export declare class ScramjetHeaders {
3
+ headers: {};
4
+ set(key: string, v: string): void;
5
+ get(key: string): string | null;
6
+ delete(key: string): void;
7
+ has(key: string): boolean;
8
+ toRawHeaders(): RawHeaders;
9
+ toNativeHeaders(): Headers;
10
+ static fromRawHeaders(raw: RawHeaders): ScramjetHeaders;
11
+ static fromNativeHeaders(native: Headers): ScramjetHeaders;
12
+ clone(): ScramjetHeaders;
13
+ }
@@ -0,0 +1,6 @@
1
+ import { URLMeta } from "./rewriters/url";
2
+ import { ScramjetContext } from "./";
3
+ export declare const htmlRules: {
4
+ [key: string]: "*" | string[] | ((...any: any[]) => string | null);
5
+ fn: (value: string, context: ScramjetContext, meta: URLMeta) => string | null;
6
+ }[];
@@ -0,0 +1,23 @@
1
+ import { ScramjetConfig, ScramjetFlags, ScramjetVersionInfo } from "../types";
2
+ import DomHandler, { Element } from "domhandler";
3
+ import { URLMeta } from "./rewriters/url";
4
+ import { CookieJar } from "./cookie";
5
+ export * from "./cookie";
6
+ export * from "./headers";
7
+ export * from "./htmlRules";
8
+ export * from "./rewriters";
9
+ export * from "./security";
10
+ export declare function flagEnabled(flag: keyof ScramjetFlags, context: ScramjetContext, url: URL): boolean;
11
+ export type ScramjetInterface = {
12
+ codecEncode: (input: string) => string;
13
+ codecDecode: (input: string) => string;
14
+ getInjectScripts(meta: URLMeta, handler: DomHandler, script: (src: string) => Element): Element[];
15
+ getWorkerInjectScripts?(meta: URLMeta, type: "module" | "regular", script: (src: string) => string): string;
16
+ };
17
+ export type ScramjetContext = {
18
+ config: ScramjetConfig;
19
+ prefix: URL;
20
+ interface: ScramjetInterface;
21
+ cookieJar: CookieJar;
22
+ };
23
+ export declare const versionInfo: ScramjetVersionInfo;
@@ -0,0 +1,4 @@
1
+ import { URLMeta } from "./url";
2
+ import { ScramjetContext } from "..";
3
+ export declare function rewriteCss(css: string, context: ScramjetContext, meta: URLMeta): string;
4
+ export declare function unrewriteCss(css: string): string;
@@ -0,0 +1,6 @@
1
+ import { DomHandler } from "domhandler";
2
+ import { URLMeta } from "./url";
3
+ import { ScramjetContext } from "..";
4
+ export declare function rewriteHtml(html: string, context: ScramjetContext, meta: URLMeta, fromTop?: boolean, preRewrite?: (handler: DomHandler) => void, postRewrite?: (handler: DomHandler) => void): string;
5
+ export declare function unrewriteHtml(html: string): string;
6
+ export declare function rewriteSrcset(srcset: string, context: ScramjetContext, meta: URLMeta): string;
@@ -0,0 +1,6 @@
1
+ export * from "./css";
2
+ export * from "./html";
3
+ export * from "./js";
4
+ export * from "./url";
5
+ export * from "./worker";
6
+ export * from "./wasm";
@@ -0,0 +1,11 @@
1
+ import { ScramjetContext } from "..";
2
+ import { URLMeta } from "./url";
3
+ type RewriterResult = {
4
+ js: string | Uint8Array;
5
+ map: Uint8Array | null;
6
+ tag: string;
7
+ errors: string[];
8
+ };
9
+ export declare function rewriteJsInner(js: string | Uint8Array, url: string | null, context: ScramjetContext, meta: URLMeta, module?: boolean): RewriterResult;
10
+ export declare function rewriteJs(js: string | Uint8Array, url: string | null, context: ScramjetContext, meta: URLMeta, module?: boolean): string | Uint8Array;
11
+ export {};
@@ -0,0 +1,11 @@
1
+ import { ScramjetContext } from "..";
2
+ export type URLMeta = {
3
+ origin: URL;
4
+ base: URL;
5
+ topFrameName?: string;
6
+ parentFrameName?: string;
7
+ };
8
+ export declare function rewriteBlob(url: string, context: ScramjetContext, meta: URLMeta): string;
9
+ export declare function unrewriteBlob(url: string, context: ScramjetContext, meta: URLMeta): string;
10
+ export declare function rewriteUrl(url: string | URL, context: ScramjetContext, meta: URLMeta): string;
11
+ export declare function unrewriteUrl(url: string | URL, context: ScramjetContext): string;
@@ -0,0 +1,8 @@
1
+ import { Rewriter } from "../../../rewriter/wasm/out/wasm.js";
2
+ import type { JsRewriterOutput } from "../../../rewriter/wasm/out/wasm.js";
3
+ import { ScramjetContext } from "..";
4
+ export type { JsRewriterOutput, Rewriter };
5
+ import { URLMeta } from "./url";
6
+ export declare function setWasm(u8: Uint8Array | ArrayBuffer): void;
7
+ export declare const textDecoder: TextDecoder;
8
+ export declare function getRewriter(context: ScramjetContext, meta: URLMeta): [Rewriter, () => void];
@@ -0,0 +1,3 @@
1
+ import { ScramjetContext } from "..";
2
+ import { URLMeta } from "./url";
3
+ export declare function rewriteWorkers(context: ScramjetContext, js: string | Uint8Array, type: "module" | "regular", url: string, meta: URLMeta): string;
@@ -0,0 +1 @@
1
+ export * from "./siteTests";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @fileoverview
3
+ * See `types.ts` for context on these symbols.
4
+ */
5
+ export declare const SCRAMJETCLIENTNAME = "scramjet client global";
6
+ export declare const SCRAMJETCLIENT: unique symbol;
7
+ export declare const SCRAMJETFRAME: unique symbol;
@@ -0,0 +1,114 @@
1
+ import { ScramjetClient } from "./client/index";
2
+ import { SCRAMJETCLIENT } from "./symbols";
3
+ import { DBSchema } from "idb";
4
+ /**
5
+ * Version information for the current Scramjet build.
6
+ * Contains both the semantic version string and the git commit hash for build identification.
7
+ */
8
+ export interface ScramjetVersionInfo {
9
+ /** The semantic version */
10
+ version: string;
11
+ /** The git commit hash that this build was created from */
12
+ build: string;
13
+ /** The date of the build */
14
+ date: string;
15
+ }
16
+ /**
17
+ * Scramjet Feature Flags, configured at build time
18
+ */
19
+ export type ScramjetFlags = {
20
+ syncxhr: boolean;
21
+ strictRewrites: boolean;
22
+ rewriterLogs: boolean;
23
+ captureErrors: boolean;
24
+ cleanErrors: boolean;
25
+ scramitize: boolean;
26
+ sourcemaps: boolean;
27
+ destructureRewrites: boolean;
28
+ allowInvalidJs: boolean;
29
+ allowFailedIntercepts: boolean;
30
+ debugTrampolines: boolean;
31
+ };
32
+ export interface ScramjetConfig {
33
+ globals: {
34
+ wrapfn: string;
35
+ wrappropertybase: string;
36
+ wrappropertyfn: string;
37
+ cleanrestfn: string;
38
+ importfn: string;
39
+ rewritefn: string;
40
+ metafn: string;
41
+ wrappostmessagefn: string;
42
+ pushsourcemapfn: string;
43
+ trysetfn: string;
44
+ templocid: string;
45
+ tempunusedid: string;
46
+ };
47
+ maskedfiles: string[];
48
+ flags: ScramjetFlags;
49
+ siteFlags: Record<string, Partial<ScramjetFlags>>;
50
+ }
51
+ /**
52
+ * The config for Scramjet initialization.
53
+ */
54
+ export interface ScramjetInitConfig extends Omit<ScramjetConfig, "codec" | "flags"> {
55
+ flags: Partial<ScramjetFlags>;
56
+ codec: {
57
+ encode: (url: string) => string;
58
+ decode: (url: string) => string;
59
+ };
60
+ }
61
+ declare global {
62
+ interface Window {
63
+ WASM: string;
64
+ REAL_WASM: Uint8Array;
65
+ /**
66
+ * The scramjet client belonging to a window.
67
+ */
68
+ [SCRAMJETCLIENT]: ScramjetClient;
69
+ }
70
+ interface HTMLDocument {
71
+ /**
72
+ * Should be the same as window.
73
+ */
74
+ [SCRAMJETCLIENT]: ScramjetClient;
75
+ }
76
+ interface HTMLIFrameElement {
77
+ }
78
+ }
79
+ export type SiteDirective = "same-origin" | "same-site" | "cross-site" | "none";
80
+ export interface RedirectTracker {
81
+ originalReferrer: string;
82
+ mostRestrictiveSite: SiteDirective;
83
+ referrerPolicy: string;
84
+ chainStarted: number;
85
+ }
86
+ export interface ReferrerPolicyData {
87
+ policy: string;
88
+ referrer: string;
89
+ }
90
+ export interface ScramjetDB extends DBSchema {
91
+ config: {
92
+ key: string;
93
+ value: ScramjetConfig;
94
+ };
95
+ cookies: {
96
+ key: string;
97
+ value: any;
98
+ };
99
+ redirectTrackers: {
100
+ key: string;
101
+ value: RedirectTracker;
102
+ };
103
+ referrerPolicies: {
104
+ key: string;
105
+ value: ReferrerPolicyData;
106
+ };
107
+ publicSuffixList: {
108
+ key: string;
109
+ value: {
110
+ data: string[];
111
+ expiry: number;
112
+ };
113
+ };
114
+ }
package/lib/index.d.ts CHANGED
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @fileoverview
3
+ * Scramjet path export for routing functionality
4
+ */
5
+
1
6
  declare const scramjetPath: string;
2
7
 
3
8
  export { scramjetPath };