@mercuryworkshop/proxy-bootstrap 0.0.1

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 (102) hide show
  1. package/dist/.downloads/controller/package/dist/controller.api.js +44 -0
  2. package/dist/.downloads/controller/package/dist/controller.api.js.map +1 -0
  3. package/dist/.downloads/controller/package/dist/controller.inject.js +2 -0
  4. package/dist/.downloads/controller/package/dist/controller.inject.js.map +1 -0
  5. package/dist/.downloads/controller/package/dist/controller.sw.js +2 -0
  6. package/dist/.downloads/controller/package/dist/controller.sw.js.map +1 -0
  7. package/dist/.downloads/controller/package/dist/types/cache.d.ts +39 -0
  8. package/dist/.downloads/controller/package/dist/types/index.d.ts +74 -0
  9. package/dist/.downloads/controller/package/dist/types/inject.d.ts +16 -0
  10. package/dist/.downloads/controller/package/dist/types/sw.d.ts +2 -0
  11. package/dist/.downloads/controller/package/dist/types/symbols.d.ts +1 -0
  12. package/dist/.downloads/controller/package/dist/types/typesEntry.d.ts +5 -0
  13. package/dist/.downloads/controller/package/package.json +16 -0
  14. package/dist/.downloads/controller/package/src/cache.ts +473 -0
  15. package/dist/.downloads/controller/package/src/index.ts +809 -0
  16. package/dist/.downloads/controller/package/src/inject.ts +370 -0
  17. package/dist/.downloads/controller/package/src/sw.ts +231 -0
  18. package/dist/.downloads/controller/package/src/symbols.ts +1 -0
  19. package/dist/.downloads/controller/package/src/types.d.ts +139 -0
  20. package/dist/.downloads/controller/package/src/typesEntry.ts +6 -0
  21. package/dist/.downloads/controller/package/tsconfig.json +24 -0
  22. package/dist/.downloads/controller/package/tsconfig.types.json +16 -0
  23. package/dist/.downloads/libcurl-transport/package/LICENSE +661 -0
  24. package/dist/.downloads/libcurl-transport/package/README.md +52 -0
  25. package/dist/.downloads/libcurl-transport/package/dist/index.d.ts +25 -0
  26. package/dist/.downloads/libcurl-transport/package/dist/index.js +6500 -0
  27. package/dist/.downloads/libcurl-transport/package/dist/index.mjs +6481 -0
  28. package/dist/.downloads/libcurl-transport/package/package.json +37 -0
  29. package/dist/.downloads/scramjet/package/dist/167400cb144aab22.wasm +0 -0
  30. package/dist/.downloads/scramjet/package/dist/2919e49b986edf8c.wasm +0 -0
  31. package/dist/.downloads/scramjet/package/dist/5aed1d5e48aab205.wasm +0 -0
  32. package/dist/.downloads/scramjet/package/dist/882d77912a3c8e3a.wasm +0 -0
  33. package/dist/.downloads/scramjet/package/dist/ac6aa30297a80464.wasm +0 -0
  34. package/dist/.downloads/scramjet/package/dist/c10a57758af882c8.wasm +0 -0
  35. package/dist/.downloads/scramjet/package/dist/cfd04aaae6955b67.wasm +0 -0
  36. package/dist/.downloads/scramjet/package/dist/d06a90fd413b36cf.wasm +0 -0
  37. package/dist/.downloads/scramjet/package/dist/dda06914899a6c28.wasm +0 -0
  38. package/dist/.downloads/scramjet/package/dist/scramjet.js +34 -0
  39. package/dist/.downloads/scramjet/package/dist/scramjet.js.map +1 -0
  40. package/dist/.downloads/scramjet/package/dist/scramjet.mjs +34 -0
  41. package/dist/.downloads/scramjet/package/dist/scramjet.mjs.map +1 -0
  42. package/dist/.downloads/scramjet/package/dist/scramjet.wasm +0 -0
  43. package/dist/.downloads/scramjet/package/dist/scramjet_bundled.js +34 -0
  44. package/dist/.downloads/scramjet/package/dist/scramjet_bundled.js.map +1 -0
  45. package/dist/.downloads/scramjet/package/dist/scramjet_bundled.mjs +34 -0
  46. package/dist/.downloads/scramjet/package/dist/scramjet_bundled.mjs.map +1 -0
  47. package/dist/.downloads/scramjet/package/dist/types/Tap.d.ts +32 -0
  48. package/dist/.downloads/scramjet/package/dist/types/client/client.d.ts +115 -0
  49. package/dist/.downloads/scramjet/package/dist/types/client/entry.d.ts +5 -0
  50. package/dist/.downloads/scramjet/package/dist/types/client/events.d.ts +10 -0
  51. package/dist/.downloads/scramjet/package/dist/types/client/global.d.ts +4 -0
  52. package/dist/.downloads/scramjet/package/dist/types/client/helpers.d.ts +1 -0
  53. package/dist/.downloads/scramjet/package/dist/types/client/index.d.ts +7 -0
  54. package/dist/.downloads/scramjet/package/dist/types/client/location.d.ts +2 -0
  55. package/dist/.downloads/scramjet/package/dist/types/client/shared/eval.d.ts +3 -0
  56. package/dist/.downloads/scramjet/package/dist/types/client/shared/sourcemaps.d.ts +19 -0
  57. package/dist/.downloads/scramjet/package/dist/types/client/shared/unproxy.d.ts +19 -0
  58. package/dist/.downloads/scramjet/package/dist/types/client/shared/wrap.d.ts +4 -0
  59. package/dist/.downloads/scramjet/package/dist/types/client/singletonbox.d.ts +16 -0
  60. package/dist/.downloads/scramjet/package/dist/types/client/unproxy.generated.d.ts +50 -0
  61. package/dist/.downloads/scramjet/package/dist/types/fetch/body.d.ts +3 -0
  62. package/dist/.downloads/scramjet/package/dist/types/fetch/fetch.d.ts +7 -0
  63. package/dist/.downloads/scramjet/package/dist/types/fetch/headers.d.ts +19 -0
  64. package/dist/.downloads/scramjet/package/dist/types/fetch/index.d.ts +128 -0
  65. package/dist/.downloads/scramjet/package/dist/types/fetch/parse.d.ts +22 -0
  66. package/dist/.downloads/scramjet/package/dist/types/fetch/util.d.ts +7 -0
  67. package/dist/.downloads/scramjet/package/dist/types/index.d.ts +11 -0
  68. package/dist/.downloads/scramjet/package/dist/types/shared/cookie.d.ts +26 -0
  69. package/dist/.downloads/scramjet/package/dist/types/shared/headers.d.ts +13 -0
  70. package/dist/.downloads/scramjet/package/dist/types/shared/htmlRules.d.ts +6 -0
  71. package/dist/.downloads/scramjet/package/dist/types/shared/index.d.ts +51 -0
  72. package/dist/.downloads/scramjet/package/dist/types/shared/mime.d.ts +39 -0
  73. package/dist/.downloads/scramjet/package/dist/types/shared/refresh.d.ts +7 -0
  74. package/dist/.downloads/scramjet/package/dist/types/shared/rewriters/css.d.ts +4 -0
  75. package/dist/.downloads/scramjet/package/dist/types/shared/rewriters/html.d.ts +33 -0
  76. package/dist/.downloads/scramjet/package/dist/types/shared/rewriters/index.d.ts +6 -0
  77. package/dist/.downloads/scramjet/package/dist/types/shared/rewriters/js.d.ts +11 -0
  78. package/dist/.downloads/scramjet/package/dist/types/shared/rewriters/url.d.ts +25 -0
  79. package/dist/.downloads/scramjet/package/dist/types/shared/rewriters/wasm.d.ts +7 -0
  80. package/dist/.downloads/scramjet/package/dist/types/shared/rewriters/worker.d.ts +3 -0
  81. package/dist/.downloads/scramjet/package/dist/types/shared/set-cookie-parser.d.ts +20 -0
  82. package/dist/.downloads/scramjet/package/dist/types/shared/snapshot.d.ts +236 -0
  83. package/dist/.downloads/scramjet/package/dist/types/shared/sniffEncoding.d.ts +65 -0
  84. package/dist/.downloads/scramjet/package/dist/types/shared/util.d.ts +2 -0
  85. package/dist/.downloads/scramjet/package/dist/types/symbols.d.ts +6 -0
  86. package/dist/.downloads/scramjet/package/dist/types/types.d.ts +68 -0
  87. package/dist/.downloads/scramjet/package/lib/index.cjs +7 -0
  88. package/dist/.downloads/scramjet/package/lib/index.d.ts +8 -0
  89. package/dist/.downloads/scramjet/package/lib/types.d.ts +20 -0
  90. package/dist/.downloads/scramjet/package/package.json +93 -0
  91. package/dist/bootstrap-client.js +169 -0
  92. package/dist/bootstrap-client.js.map +1 -0
  93. package/dist/bootstrap-server.js +406 -0
  94. package/dist/bootstrap-server.js.map +1 -0
  95. package/dist/bootstrap-static.js +476 -0
  96. package/dist/bootstrap-static.js.map +1 -0
  97. package/dist/types/client.d.ts +4 -0
  98. package/dist/types/clientcommon.d.ts +2 -0
  99. package/dist/types/common.d.ts +30 -0
  100. package/dist/types/server.d.ts +24 -0
  101. package/dist/types/static.d.ts +1 -0
  102. package/package.json +30 -0
@@ -0,0 +1,7 @@
1
+ export type ParsedDeclarativeRefresh = {
2
+ time: number;
3
+ urlStart: number;
4
+ urlEnd: number;
5
+ url: string | null;
6
+ };
7
+ export declare function parseDeclarativeRefresh(input: string): ParsedDeclarativeRefresh | null;
@@ -0,0 +1,4 @@
1
+ import { URLMeta } from "./url";
2
+ import { ScramjetContext } from "../../shared";
3
+ export declare function rewriteCss(css: string, context: ScramjetContext, meta: URLMeta): string;
4
+ export declare function unrewriteCss(css: string, context: ScramjetContext): string;
@@ -0,0 +1,33 @@
1
+ import { URLMeta } from "./url";
2
+ import { ScramjetContext } from "../../shared";
3
+ import { RawHeaders } from "@mercuryworkshop/proxy-transports";
4
+ import { TrackedHistoryState } from "../../fetch";
5
+ export type ForeignContext = "svg" | "math" | "html";
6
+ export type HtmlContext = {
7
+ loadScripts: boolean;
8
+ inline: boolean;
9
+ source: string;
10
+ apisource?: string;
11
+ headers?: RawHeaders;
12
+ foreignContext?: ForeignContext;
13
+ history?: TrackedHistoryState[];
14
+ };
15
+ export declare class IncrementalHtmlRewriter {
16
+ private readonly context;
17
+ private readonly meta;
18
+ private readonly htmlcontext;
19
+ private readonly handler;
20
+ private readonly parser;
21
+ private readonly completedElements;
22
+ private readonly emittedLengths;
23
+ private readonly rewrittenNodes;
24
+ private ended;
25
+ constructor(context: ScramjetContext, meta: URLMeta, htmlcontext: HtmlContext);
26
+ write(html: string): string;
27
+ end(html?: string): string;
28
+ private flush;
29
+ private getAvailableOutput;
30
+ }
31
+ export declare function rewriteHtml(html: string, context: ScramjetContext, meta: URLMeta, htmlcontext: HtmlContext): string;
32
+ export declare function unrewriteHtml(html: string, foreignContext?: ForeignContext): string;
33
+ 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 "../../shared";
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, isModule?: boolean): RewriterResult;
10
+ export declare function rewriteJs(js: string | Uint8Array, url: string | null, context: ScramjetContext, meta: URLMeta, isModule?: boolean): string | Uint8Array;
11
+ export {};
@@ -0,0 +1,25 @@
1
+ import { ScramjetContext } from "../../shared";
2
+ import { _URL } from "../snapshot";
3
+ export type NavigationType = "user" | "link" | "location";
4
+ export type RewriteUrlOptions = {
5
+ referrerPolicy?: string;
6
+ isModule?: boolean;
7
+ navigateType?: NavigationType;
8
+ topFrame?: string;
9
+ parentFrame?: string;
10
+ isIframe?: string;
11
+ mode?: string;
12
+ credentials?: string;
13
+ destination?: RequestDestination;
14
+ };
15
+ export type URLMeta = {
16
+ origin: _URL;
17
+ base: _URL;
18
+ topFrameName?: string;
19
+ parentFrameName?: string;
20
+ referrerPolicy?: string;
21
+ };
22
+ export declare function rewriteBlob(url: string, context: ScramjetContext, meta: URLMeta): string;
23
+ export declare function unrewriteBlob(url: string, context: ScramjetContext, _meta: URLMeta): string;
24
+ export declare function rewriteUrl(url: string | URL, context: ScramjetContext, meta: URLMeta, options?: RewriteUrlOptions): string;
25
+ export declare function unrewriteUrl(url: string | URL, context: ScramjetContext): string;
@@ -0,0 +1,7 @@
1
+ import { Rewriter } from "../../../rewriter/wasm/out/wasm.js";
2
+ import type { JsRewriterOutput } from "../../../rewriter/wasm/out/wasm.js";
3
+ import { ScramjetContext } from "../../shared";
4
+ export type { JsRewriterOutput, Rewriter };
5
+ import { URLMeta } from "./url";
6
+ export declare function setWasm(u8: Uint8Array | ArrayBuffer): void;
7
+ export declare function getRewriter(context: ScramjetContext, meta: URLMeta): [Rewriter, () => void];
@@ -0,0 +1,3 @@
1
+ import { ScramjetContext } from "../../shared";
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,20 @@
1
+ type ParsedCookie = {
2
+ name: string;
3
+ value: string;
4
+ expires?: Date;
5
+ maxAge?: number;
6
+ secure?: boolean;
7
+ httpOnly?: boolean;
8
+ sameSite?: string;
9
+ partitioned?: boolean;
10
+ [key: string]: unknown;
11
+ };
12
+ declare function parseString(setCookieValue: string): ParsedCookie | null;
13
+ declare function parseNameValuePair(nameValuePairStr: string): {
14
+ name: string;
15
+ value: string;
16
+ } | null;
17
+ declare function parse(input: string | undefined): ParsedCookie[];
18
+ declare function splitCookiesString(cookiesString: unknown): string[];
19
+ export default parse;
20
+ export { parse, parseNameValuePair, parseString, splitCookiesString };
@@ -0,0 +1,236 @@
1
+ export declare const String: StringConstructor;
2
+ export declare const String_fromCodePoint: (...codePoints: number[]) => string;
3
+ export declare const String_fromCharCode: (...codes: number[]) => string;
4
+ export declare const Number: NumberConstructor;
5
+ export declare const Number_parseInt: (string: string, radix?: number) => number;
6
+ export declare const Object_keys: {
7
+ (o: object): string[];
8
+ (o: {}): string[];
9
+ };
10
+ export declare const Object_values: {
11
+ <T>(o: {
12
+ [s: string]: T;
13
+ } | ArrayLike<T>): T[];
14
+ (o: {}): any[];
15
+ };
16
+ export declare const Object_entries: {
17
+ <T>(o: {
18
+ [s: string]: T;
19
+ } | ArrayLike<T>): [string, T][];
20
+ (o: {}): [string, any][];
21
+ };
22
+ export declare const Object_hasOwn: (o: object, v: PropertyKey) => boolean;
23
+ export declare const Object_getOwnPropertyNames: (o: any) => string[];
24
+ export declare const Object_getOwnPropertyDescriptor: (o: any, p: PropertyKey) => PropertyDescriptor | undefined;
25
+ export declare const Object_getOwnPropertyDescriptors: <T>(o: T) => { [P in keyof T]: TypedPropertyDescriptor<T[P]>; } & {
26
+ [x: string]: PropertyDescriptor;
27
+ };
28
+ export declare const Object_getOwnPropertySymbols: (o: any) => symbol[];
29
+ export declare const Object_defineProperty: <T>(o: T, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>) => T;
30
+ export declare const Object_defineProperties: <T>(o: T, properties: PropertyDescriptorMap & ThisType<any>) => T;
31
+ export declare const Object_setPrototypeOf: (o: any, proto: object | null) => any;
32
+ export declare const Reflect_get: typeof Reflect.get;
33
+ export declare const Reflect_set: typeof Reflect.set;
34
+ export declare const Reflect_has: typeof Reflect.has;
35
+ export declare const Reflect_ownKeys: typeof Reflect.ownKeys;
36
+ export declare const Reflect_construct: typeof Reflect.construct;
37
+ export declare const Reflect_apply: typeof Reflect.apply;
38
+ export declare const Array_from: {
39
+ <T>(arrayLike: ArrayLike<T>): T[];
40
+ <T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[];
41
+ <T>(iterable: Iterable<T> | ArrayLike<T>): T[];
42
+ <T, U>(iterable: Iterable<T> | ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[];
43
+ };
44
+ export declare const Array_isArray: (arg: any) => arg is any[];
45
+ export declare const Array_of: <T>(...items: T[]) => T[];
46
+ export declare const JSON_parse: (text: string, reviver?: (this: any, key: string, value: any) => any) => any;
47
+ export declare const JSON_stringify: {
48
+ (value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string;
49
+ (value: any, replacer?: (number | string)[] | null, space?: string | number): string;
50
+ };
51
+ export declare const TextEncoder_encode: any;
52
+ export declare const TextDecoder_decode: any;
53
+ export declare const Performance_now: any;
54
+ export declare const btoa: typeof globalThis.btoa;
55
+ export declare const atob: typeof globalThis.atob;
56
+ export declare const URL_createObjectURL: any;
57
+ export declare const URL_revokeObjectURL: any;
58
+ export declare const Error: ErrorConstructor;
59
+ export declare const Math_random: () => number;
60
+ export declare const Math_min: (...values: number[]) => number;
61
+ export declare const Promise_all: any;
62
+ export declare const Promise_race: any;
63
+ export declare const Promise_resolve: any;
64
+ export declare const Promise_reject: any;
65
+ export declare const Promise_allSettled: any;
66
+ export declare const Promise_any: any;
67
+ export declare const Symbol_for: (key: string) => symbol;
68
+ declare const WrappedBrand: unique symbol;
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"> & {
71
+ new (...args: Args): WrappedInstance<Instance>;
72
+ prototype: WrappedInstance<Instance>;
73
+ readonly [WrappedBrand]: T;
74
+ } : T & {
75
+ readonly [WrappedBrand]: T;
76
+ };
77
+ export declare const _URL: Omit<{
78
+ new (url: string | URL, base?: string | URL): URL;
79
+ prototype: URL;
80
+ canParse(url: string | URL, base?: string | URL): boolean;
81
+ createObjectURL(obj: Blob | MediaSource): string;
82
+ parse(url: string | URL, base?: string | URL): URL | null;
83
+ 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
+ };
100
+ export type _URL = Wrapped<URL>;
101
+ export declare const _Headers: Omit<{
102
+ new (init?: HeadersInit): Headers;
103
+ 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
+ };
116
+ 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
+ };
126
+ export type _Date = Wrapped<Date>;
127
+ export declare const _URLSearchParams: Omit<{
128
+ new (init?: string[][] | Record<string, string> | string | URLSearchParams): URLSearchParams;
129
+ 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
+ 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
+ };
152
+ 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
+ };
162
+ 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
+ };
172
+ 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
+ };
182
+ 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
+ };
192
+ 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
+ };
202
+ export type _Uint8Array = Wrapped<Uint8Array>;
203
+ export declare const _TextDecoder: Omit<{
204
+ new (label?: string, options?: TextDecoderOptions): TextDecoder;
205
+ 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
+ };
218
+ export type _TextDecoder = Wrapped<TextDecoder>;
219
+ export declare const _TextEncoder: Omit<{
220
+ new (): TextEncoder;
221
+ 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
+ };
234
+ export type _TextEncoder = Wrapped<TextEncoder>;
235
+ export declare function makeWrap<T extends object>(source: T): Wrapped<T>;
236
+ export {};
@@ -0,0 +1,65 @@
1
+ /**
2
+ * WHATWG Encoding Sniffing Algorithm
3
+ *
4
+ * Implements the encoding sniffing algorithm from the HTML spec:
5
+ * https://html.spec.whatwg.org/multipage/parsing.html#determining-the-character-encoding
6
+ *
7
+ * And the "algorithm for extracting a character encoding from a meta element":
8
+ * https://html.spec.whatwg.org/multipage/urls-and-fetching.html#algorithm-for-extracting-a-character-encoding-from-a-meta-element
9
+ *
10
+ * And "get an encoding" from the Encoding spec:
11
+ * https://encoding.spec.whatwg.org/#concept-encoding-get
12
+ */
13
+ /**
14
+ * https://encoding.spec.whatwg.org/#concept-encoding-get
15
+ *
16
+ * "To get an encoding from a string label":
17
+ * 1. Remove any leading and trailing ASCII whitespace from label.
18
+ * 2. If label is an ASCII case-insensitive match for any of the labels listed
19
+ * in the table, return the corresponding encoding; otherwise return failure.
20
+ */
21
+ export declare function getEncoding(label: string): string | null;
22
+ /**
23
+ * https://html.spec.whatwg.org/multipage/urls-and-fetching.html#algorithm-for-extracting-a-character-encoding-from-a-meta-element
24
+ *
25
+ * The algorithm for extracting a character encoding from a `meta` element,
26
+ * given a string s.
27
+ */
28
+ export declare function extractCharsetFromMeta(s: string): string | null;
29
+ /**
30
+ * https://html.spec.whatwg.org/multipage/parsing.html#prescan-a-byte-stream-to-determine-its-encoding
31
+ *
32
+ * Prescan the first `limit` bytes of a byte stream to determine its encoding.
33
+ * Returns an encoding name or null if none found.
34
+ */
35
+ export declare function prescanByteStream(bytes: Uint8Array, limit?: number): string | null;
36
+ /**
37
+ * https://encoding.spec.whatwg.org/#bom-sniff
38
+ *
39
+ * BOM sniff: check the first 2-3 bytes for a byte order mark.
40
+ */
41
+ export declare function bomSniff(bytes: Uint8Array): string | null;
42
+ /**
43
+ * Extract the charset parameter from a Content-Type header value.
44
+ *
45
+ * This parses the Content-Type more carefully than a naive split — it handles
46
+ * quoted values and multiple parameters.
47
+ *
48
+ * This follows what MIME Sniffing / HTTP specs say: find `charset=` parameter.
49
+ */
50
+ export declare function extractCharsetFromContentType(contentType: string): string | null;
51
+ /**
52
+ * Determine the character encoding of an HTML document's byte stream.
53
+ *
54
+ * Implements a simplified version of the WHATWG encoding sniffing algorithm
55
+ * for use in a service worker / proxy context:
56
+ *
57
+ * 1. BOM sniffing (certain)
58
+ * 2. Transport layer: Content-Type header charset parameter (certain)
59
+ * 3. Prescan byte stream: look for <meta charset> or
60
+ * <meta http-equiv="content-type" content="...charset=..."> in first 1024 bytes (tentative)
61
+ * 4. Default to UTF-8
62
+ *
63
+ * Returns an encoding name suitable for use with TextDecoder.
64
+ */
65
+ export declare function sniffEncoding(bytes: Uint8Array, contentTypeHeader: string | null): string;
@@ -0,0 +1,2 @@
1
+ export declare const bytesToBase64: (bytes: Uint8Array) => string;
2
+ export declare function base64Encode(text: string): string;
@@ -0,0 +1,6 @@
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: symbol;
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Version information for the current Scramjet build.
3
+ * Contains both the semantic version string and the git commit hash for build identification.
4
+ */
5
+ export interface ScramjetVersionInfo {
6
+ /** The semantic version */
7
+ version: string;
8
+ /** The git commit hash that this build was created from */
9
+ build: string;
10
+ /** The date of the build */
11
+ date: string;
12
+ }
13
+ /**
14
+ * Scramjet Feature Flags, configured at build time
15
+ */
16
+ export type ScramjetFlags = {
17
+ syncxhr: boolean;
18
+ disableComputedWrap: boolean;
19
+ rewriterLogs: boolean;
20
+ captureErrors: boolean;
21
+ cleanErrors: boolean;
22
+ scramitize: boolean;
23
+ sourcemaps: boolean;
24
+ destructureRewrites: boolean;
25
+ allowInvalidJs: boolean;
26
+ allowFailedIntercepts: boolean;
27
+ debugTrampolines: boolean;
28
+ debugSourceURL: boolean;
29
+ encapsulateWorkers: boolean;
30
+ };
31
+ export interface ScramjetConfig {
32
+ globals: {
33
+ wrapfn: string;
34
+ wrappropertybase: string;
35
+ wrappropertyfn: string;
36
+ cleanrestfn: string;
37
+ importfn: string;
38
+ rewritefn: string;
39
+ metafn: string;
40
+ wrappostmessagefn: string;
41
+ pushsourcemapfn: string;
42
+ trysetfn: string;
43
+ templocid: string;
44
+ tempunusedid: string;
45
+ };
46
+ maskedfiles: string[];
47
+ flags: ScramjetFlags;
48
+ siteFlags: Record<string, Partial<ScramjetFlags>>;
49
+ }
50
+ /**
51
+ * The config for Scramjet initialization.
52
+ */
53
+ export interface ScramjetInitConfig extends Omit<ScramjetConfig, "codec" | "flags"> {
54
+ flags: Partial<ScramjetFlags>;
55
+ codec: {
56
+ encode: (url: string) => string;
57
+ decode: (url: string) => string;
58
+ };
59
+ }
60
+ declare global {
61
+ interface Window {
62
+ WASM: string;
63
+ REAL_WASM: Uint8Array;
64
+ }
65
+ interface HTMLDocument {
66
+ }
67
+ }
68
+ export type AnyFunction = Function;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ const { resolve } = require("node:path");
4
+
5
+ const scramjetPath = resolve(__dirname, "..", "dist");
6
+
7
+ exports.scramjetPath = scramjetPath;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @fileoverview
3
+ * Scramjet path export for routing functionality
4
+ */
5
+
6
+ declare const scramjetPath: string;
7
+
8
+ export { scramjetPath };
@@ -0,0 +1,20 @@
1
+ import * as controller from "../dist/types/controller/index.ts";
2
+ import { ScramjetConfig } from "../dist/types/types.ts";
3
+ import * as worker from "../dist/types/worker";
4
+ import * as shared from "../dist/types/shared";
5
+ import * as client from "../dist/types/shared";
6
+
7
+ declare global {
8
+ function $scramjetLoadController(): typeof controller;
9
+ function $scramjetLoadWorker(): typeof worker;
10
+ function $scramjetLoadClient(config: ScramjetConfig): typeof client;
11
+ function $scramjetLoadShared(): typeof shared;
12
+ /// load any file from scramjet source
13
+ function $scramjetRequire(path: string): any;
14
+ var $scramjetVersion: {
15
+ build: string;
16
+ version: string;
17
+ };
18
+ }
19
+
20
+ export type * from "../dist/types/index";
@@ -0,0 +1,93 @@
1
+ {
2
+ "name": "@mercuryworkshop/scramjet",
3
+ "version": "2.0.5-alpha",
4
+ "description": "An experimental web proxy that aims to be the successor to Ultraviolet",
5
+ "type": "module",
6
+ "types": "./dist/types/index.d.ts",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/MercuryWorkshop/scramjet"
10
+ },
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/types/index.d.ts",
14
+ "default": "./dist/scramjet.mjs"
15
+ },
16
+ "./path": {
17
+ "types": "./lib/index.d.ts",
18
+ "default": "./lib/index.cjs"
19
+ },
20
+ "./bundled": {
21
+ "types": "./dist/types/index.d.ts",
22
+ "default": "./dist/scramjet_bundled.mjs"
23
+ }
24
+ },
25
+ "files": [
26
+ "dist",
27
+ "lib"
28
+ ],
29
+ "keywords": [],
30
+ "author": "",
31
+ "license": "MIT",
32
+ "ava": {
33
+ "files": [
34
+ "tests/ci/**/*.js"
35
+ ],
36
+ "verbose": true
37
+ },
38
+ "devDependencies": {
39
+ "@eslint/eslintrc": "^3.3.1",
40
+ "@eslint/js": "^9.35.0",
41
+ "@estruyf/github-actions-reporter": "^1.10.0",
42
+ "@fastify/static": "^8.2.0",
43
+ "@mercuryworkshop/wisp-js": "^0.4.0",
44
+ "@nebula-services/bare-server-node": "^2.0.4",
45
+ "@types/eslint": "^9.6.1",
46
+ "@types/estree": "^1.0.8",
47
+ "@types/node": "^24.3.1",
48
+ "@types/serviceworker": "^0.0.160",
49
+ "@typescript-eslint/eslint-plugin": "8.57.3-alpha.3",
50
+ "@typescript-eslint/parser": "8.57.3-alpha.3",
51
+ "actionlint": "^2.0.6",
52
+ "ava": "^6.4.1",
53
+ "dotenv": "^17.2.2",
54
+ "eslint": "^10.1.0",
55
+ "fastify": "^5.6.0",
56
+ "glob": "^11.0.3",
57
+ "prettier": "^3.6.2",
58
+ "remark": "^15.0.1",
59
+ "remark-cli": "^12.0.1",
60
+ "remark-frontmatter": "^5.0.0",
61
+ "remark-mdx": "^3.1.1",
62
+ "remark-stringify": "^11.0.0",
63
+ "ts-checker-rspack-plugin": "^1.1.5",
64
+ "tsc-alias": "^1.8.16",
65
+ "tslib": "^2.8.1",
66
+ "typescript": "^5.9.2"
67
+ },
68
+ "dependencies": {
69
+ "@mercuryworkshop/proxy-transports": "1.0.2",
70
+ "dom-serializer": "^2.0.0",
71
+ "domhandler": "^5.0.3",
72
+ "domutils": "^3.2.2",
73
+ "htmlparser2": "^12.0.0",
74
+ "idb": "^8.0.3",
75
+ "parse-domain": "^8.2.2"
76
+ },
77
+ "scripts": {
78
+ "build": "cd ../.. && rspack build --mode production",
79
+ "rewriter:build": "cd rewriter/wasm/ && bash build.sh && cd ../../",
80
+ "dev": "node server.js",
81
+ "dev:debug": "DEBUG=1 node server.js",
82
+ "pub": "npm publish --no-git-checks --access public",
83
+ "format": "prettier --write .",
84
+ "format:docs": "remark \"docs/**/*.{md,mdx}\" --output",
85
+ "lint": "eslint ./src/",
86
+ "lint:fix": "eslint ./src/ --fix",
87
+ "lint:workflows": "actionlint .github/workflows/*.yml",
88
+ "lint:all": "npm run lint && npm run lint:workflows",
89
+ "test": "npm run test:package",
90
+ "test:package": "ava tests/ci/packageValidation.js",
91
+ "preinstall": "npx only-allow pnpm"
92
+ }
93
+ }