@mercuryworkshop/scramjet 2.0.67-alpha.1 → 2.1.0

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 (38) hide show
  1. package/README.md +62 -0
  2. package/dist/scramjet-external.mjs +1 -1
  3. package/dist/scramjet.js +7 -7
  4. package/dist/scramjet.js.map +1 -1
  5. package/dist/scramjet.mjs +6 -6
  6. package/dist/scramjet.mjs.map +1 -1
  7. package/dist/scramjet.wasm +0 -0
  8. package/dist/scramjet_bundled.js +6 -6
  9. package/dist/scramjet_bundled.js.map +1 -1
  10. package/dist/scramjet_bundled.mjs +6 -6
  11. package/dist/scramjet_bundled.mjs.map +1 -1
  12. package/dist/types/Tap.d.ts +1 -1
  13. package/dist/types/client/client.d.ts +26 -25
  14. package/dist/types/client/location.d.ts +1 -1
  15. package/dist/types/client/shared/eval.d.ts +2 -2
  16. package/dist/types/client/shared/sourcemaps.d.ts +1 -1
  17. package/dist/types/client/shared/wrap.d.ts +2 -2
  18. package/dist/types/client/singletonbox.d.ts +2 -1
  19. package/dist/types/fetch/fetch.d.ts +1 -1
  20. package/dist/types/fetch/headers.d.ts +1 -1
  21. package/dist/types/fetch/index.d.ts +129 -0
  22. package/dist/types/fetch/util.d.ts +1 -1
  23. package/dist/types/index.d.ts +7 -7
  24. package/dist/types/shared/htmlRules.d.ts +2 -2
  25. package/dist/types/shared/index.d.ts +4 -5
  26. package/dist/types/shared/mime.d.ts +6 -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 +3 -3
  33. package/dist/types/shared/snapshot.d.ts +1 -0
  34. package/dist/types/types.d.ts +1 -9
  35. package/dist/types/typesEntry.d.ts +1 -1
  36. package/package.json +12 -44
  37. package/dist/temp-types-build/index.js +0 -23
  38. package/dist/temp-types-build/index.js.map +0 -1
@@ -31,7 +31,7 @@ export declare class Plugin {
31
31
  tap<T extends Description>(hook: T, callback: Callback<T>, order?: TapOrder): void;
32
32
  }
33
33
  export declare class Tap {
34
- static dispatch<T extends Description>(hook: T, context: T["context"], props: T["props"]): Promise<void[]>;
34
+ static dispatch<T extends Description>(hook: T, context: T["context"], props: T["props"]): Promise<void[]> | null;
35
35
  static tap<T extends Description>(hook: T, callback: Callback<T>, plugin?: Plugin, order?: TapOrder): void;
36
36
  static create<T extends Record<string, Description>>(): TapInstance<T>;
37
37
  static getTappers<T extends Description>(hook: T): Plugin[];
@@ -1,12 +1,18 @@
1
1
  import { BareCompatibleClient, ProxyTransport, RawHeaders } from "@mercuryworkshop/proxy-transports";
2
- import { LifecycleHooks } from "@client/events";
3
- import { RewriteUrlOptions, type URLMeta } from "@rewriters/url";
4
- import { HtmlRewriterHooks, ScramjetContext, ScramjetHeaders } from "@/shared";
2
+ import { LifecycleHooks } from "./events";
3
+ import { RewriteUrlOptions, type URLMeta } from "../shared/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
+ type IfEquals<T, U, Y = unknown, N = never> = (<G>() => G extends T ? 1 : 2) extends <G>() => G extends U ? 1 : 2 ? Y : N;
11
+ type Traverse<O extends Record<any, any>, P extends string> = P extends `${infer K}.${infer R}` ? Traverse<O[K], R> : O[P];
12
+ type GlobalTraverse<P extends string> = Traverse<GlobalThis & Record<string, any>, P>;
13
+ type ProxyApplyThis<T extends string> = unknown extends ThisParameterType<Extract<GlobalTraverse<T>, AnyFunction>> ? T extends `${infer ClassName}.prototype.${string}` ? GlobalTraverse<ClassName> extends {
14
+ prototype: infer Proto;
15
+ } ? Proto : unknown : unknown : ThisParameterType<Extract<GlobalTraverse<T>, AnyFunction>>;
10
16
  export type ScramjetClientInit = {
11
17
  context: ScramjetContext;
12
18
  transport: ProxyTransport;
@@ -18,25 +24,13 @@ export type ScramjetClientInit = {
18
24
  };
19
25
  type NativeStore = {
20
26
  store: Record<string, any>;
21
- call: (target: string, that: any, ...args: any[]) => any;
22
- construct: (target: string, ...args: any[]) => any;
27
+ construct: <T extends string>(target: T, ...args: ConstructorParameters<GlobalTraverse<T>>) => InstanceType<GlobalTraverse<T>>;
28
+ call: <T extends string>(target: T, that: ProxyApplyThis<T>, ...args: Parameters<GlobalTraverse<T>>) => ReturnType<GlobalTraverse<T>>;
23
29
  };
24
30
  type DescriptorStore = {
25
31
  store: Record<string, PropertyDescriptor>;
26
- get: (target: string, that: any) => any;
27
- set: (target: string, that: any, value: any) => void;
28
- };
29
- type Traverse<O extends Record<any, any>, P extends string> = P extends `${infer K}.${infer R}` ? Traverse<O[K], R> : O[P];
30
- type GlobalTraverse<P extends string> = Traverse<GlobalThis & Record<string, any>, P>;
31
- type IfEquals<T, U, Y = unknown, N = never> = (<G>() => G extends T ? 1 : 2) extends <G>() => G extends U ? 1 : 2 ? Y : N;
32
- type ProxyApplyThis<T extends string> = unknown extends ThisParameterType<Extract<GlobalTraverse<T>, AnyFunction>> ? T extends `${infer ClassName}.prototype.${string}` ? GlobalTraverse<ClassName> extends {
33
- prototype: infer Proto;
34
- } ? Proto : unknown : unknown : ThisParameterType<Extract<GlobalTraverse<T>, AnyFunction>>;
35
- export type ScramjetModule = {
36
- enabled: (client: ScramjetClient) => boolean | undefined;
37
- disabled: (client: ScramjetClient, self: GlobalThis) => void | undefined;
38
- order: number | undefined;
39
- default: (client: ScramjetClient, self: GlobalThis) => void;
32
+ get: <T extends string>(target: T, that: any) => GlobalTraverse<T>;
33
+ set: <T extends string>(target: T, that: any, value: GlobalTraverse<T>) => void;
40
34
  };
41
35
  export type ProxyCtx<T extends string = string, U extends "construct" | "apply" = "apply"> = {
42
36
  fn: GlobalTraverse<T>;
@@ -63,10 +57,17 @@ export type Trap<T extends string> = {
63
57
  get?: (ctx: TrapCtx<T>) => GlobalTraverse<T>;
64
58
  set?: (ctx: TrapCtx<T>, v: GlobalTraverse<T>) => void;
65
59
  };
60
+ export type ScramjetModule = {
61
+ enabled: (client: ScramjetClient) => boolean | undefined;
62
+ disabled: (client: ScramjetClient, self: GlobalThis) => void | undefined;
63
+ order: number | undefined;
64
+ default: (client: ScramjetClient, self: GlobalThis) => void;
65
+ };
66
66
  export declare class ScramjetClient {
67
67
  global: GlobalThis;
68
68
  init: ScramjetClientInit;
69
69
  locationProxy: any;
70
+ indirectEval: any;
70
71
  serviceWorker: ServiceWorkerContainer;
71
72
  bare: BareCompatibleClient;
72
73
  natives: NativeStore;
@@ -87,9 +88,9 @@ export declare class ScramjetClient {
87
88
  private flagCache;
88
89
  hooks: {
89
90
  rewriter: {
90
- html: import("@/Tap").TapInstance<HtmlRewriterHooks>;
91
+ html: import("../Tap").TapInstance<HtmlRewriterHooks>;
91
92
  };
92
- lifecycle: import("@/Tap").TapInstance<LifecycleHooks>;
93
+ lifecycle: import("../Tap").TapInstance<LifecycleHooks>;
93
94
  };
94
95
  constructor(global: GlobalThis, init: ScramjetClientInit);
95
96
  /** Apply document injection init when a client was already installed (e.g. early contentWindow). */
@@ -1,2 +1,2 @@
1
- import { ScramjetClient } from "@client/index";
1
+ import { ScramjetClient } from "./index";
2
2
  export declare function createLocationProxy(client: ScramjetClient, self: GlobalThis): any;
@@ -1,3 +1,3 @@
1
- import { ScramjetClient } from "@client/index";
1
+ import { ScramjetClient } from "../index";
2
2
  export default function (client: ScramjetClient, self: Self): void;
3
- export declare function indirectEval(this: ScramjetClient, strict: boolean, js: any): any;
3
+ export declare function createIndirectEval(client: ScramjetClient): typeof eval;
@@ -1,4 +1,4 @@
1
- import { ScramjetClient } from "@client/index";
1
+ import { ScramjetClient } from "../index";
2
2
  declare enum RewriteType {
3
3
  Insert = 0,
4
4
  Replace = 1
@@ -1,4 +1,4 @@
1
- import { ScramjetClient } from "@client/index";
2
- export declare function createWrapFn(client: ScramjetClient, self: GlobalThis): (identifier: any, strict: boolean) => any;
1
+ import { ScramjetClient } from "../index";
2
+ export declare function createWrapFn(client: ScramjetClient, self: GlobalThis): (identifier: any) => 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 {
@@ -6,6 +6,7 @@ export declare class SingletonBox {
6
6
  clients: ScramjetClient[];
7
7
  globals: Map<Self, ScramjetClient>;
8
8
  documents: Map<Document, ScramjetClient>;
9
+ histories: Map<History, ScramjetClient>;
9
10
  locations: Map<Location, ScramjetClient>;
10
11
  writeRewriters: WeakMap<Document, IncrementalHtmlRewriter>;
11
12
  unproxy: Map<any, any>;
@@ -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>;
@@ -0,0 +1,129 @@
1
+ import { BareCompatibleClient, BareResponse, ProxyTransport, BareRequestInit } from "@mercuryworkshop/proxy-transports";
2
+ import { type URLMeta } from "../shared/rewriters/url";
3
+ import { type ScramjetRequestMode } from "./parse";
4
+ import { ScramjetHeaders } from "../shared/headers";
5
+ import { HtmlRewriterHooks, ScramjetContext } from "../shared";
6
+ import { TapInstance } from "../Tap";
7
+ import { _URL, _Map } from "../shared/snapshot";
8
+ export interface ScramjetFetchRequest {
9
+ rawUrl: URL;
10
+ rawReferrer: string | null;
11
+ rawDestination: RequestDestination;
12
+ mode: RequestMode;
13
+ referrer: string;
14
+ method: string;
15
+ body: BodyType | null;
16
+ cache: RequestCache;
17
+ initialHeaders: ScramjetHeaders;
18
+ rawClientUrl?: URL;
19
+ /** The service worker FetchEvent.clientId that originated this request. */
20
+ clientId: string;
21
+ }
22
+ export interface ScramjetFetchParsed {
23
+ url: _URL;
24
+ clientUrl?: _URL;
25
+ referrerSourceUrl?: _URL | null;
26
+ hadExtraParams: boolean;
27
+ crossSiteRedirect: boolean;
28
+ fetchSiteState?: "same-origin" | "same-site" | "cross-site";
29
+ fetchInitiatorOrigin?: string;
30
+ fetchCredentialsInclude?: boolean;
31
+ fetchMode?: ScramjetRequestMode;
32
+ isIframe?: boolean;
33
+ destination: RequestDestination;
34
+ meta: URLMeta;
35
+ isModule: boolean;
36
+ isFakeDataURL: boolean;
37
+ referrerPolicy?: string;
38
+ trackedClient?: ScramjetFetchTrackedClient;
39
+ }
40
+ export interface ScramjetFetchResponse {
41
+ body: BodyType;
42
+ headers: ScramjetHeaders;
43
+ status: number;
44
+ statusText: string;
45
+ }
46
+ export type CookieSyncEntry = {
47
+ url: URL;
48
+ cookie: string;
49
+ };
50
+ export type CookieSyncOptions = {
51
+ clear?: boolean;
52
+ destination?: RequestDestination;
53
+ };
54
+ export type FetchHandlerInit = {
55
+ transport: ProxyTransport;
56
+ context: ScramjetContext;
57
+ crossOriginIsolated?: boolean;
58
+ sendSetCookie: (cookies: CookieSyncEntry[], options?: CookieSyncOptions) => Promise<void>;
59
+ fetchDataUrl(dataUrl: string): Promise<BareResponse>;
60
+ fetchBlobUrl(blobUrl: string): Promise<BareResponse>;
61
+ };
62
+ export type TrackedHistoryState = {
63
+ url: string;
64
+ refererPolicy?: string;
65
+ };
66
+ export declare class ScramjetFetchTrackedClient {
67
+ clientId: string;
68
+ history: TrackedHistoryState[];
69
+ constructor(clientId: string);
70
+ }
71
+ export declare class ScramjetFetchHandler extends EventTarget {
72
+ client: BareCompatibleClient;
73
+ crossOriginIsolated: boolean;
74
+ context: ScramjetContext;
75
+ trackedClients: _Map<string, ScramjetFetchTrackedClient>;
76
+ hooks: {
77
+ rewriter: {
78
+ html: TapInstance<HtmlRewriterHooks>;
79
+ };
80
+ fetch: TapInstance<FetchHooks>;
81
+ };
82
+ fetchDataUrl: (dataUrl: string) => Promise<Response>;
83
+ fetchBlobUrl: (blobUrl: string) => Promise<Response>;
84
+ sendSetCookie: (cookies: CookieSyncEntry[], options?: CookieSyncOptions) => Promise<void>;
85
+ constructor(init: FetchHandlerInit);
86
+ handleFetch(request: ScramjetFetchRequest): Promise<ScramjetFetchResponse>;
87
+ }
88
+ export type FetchHooks = {
89
+ intercept: {
90
+ context: {
91
+ request: ScramjetFetchRequest;
92
+ parsed: ScramjetFetchParsed;
93
+ };
94
+ props: {
95
+ response?: ScramjetFetchResponse;
96
+ };
97
+ };
98
+ request: {
99
+ context: {
100
+ request: ScramjetFetchRequest;
101
+ parsed: ScramjetFetchParsed;
102
+ client: BareCompatibleClient;
103
+ };
104
+ props: {
105
+ init: BareRequestInit;
106
+ url: URL;
107
+ earlyResponse?: BareResponse;
108
+ };
109
+ };
110
+ preresponse: {
111
+ context: {
112
+ request: ScramjetFetchRequest;
113
+ parsed: ScramjetFetchParsed;
114
+ };
115
+ props: {
116
+ response: BareResponse;
117
+ };
118
+ };
119
+ response: {
120
+ context: {
121
+ request: ScramjetFetchRequest;
122
+ parsed: ScramjetFetchParsed;
123
+ };
124
+ props: {
125
+ response: ScramjetFetchResponse;
126
+ };
127
+ };
128
+ };
129
+ export type BodyType = string | ArrayBuffer | Blob | ReadableStream<any>;
@@ -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,11 +1,11 @@
1
1
  import "./global.d";
2
- import { ScramjetConfig } from "./types";
3
- export * from "./client";
4
- export * from "./shared";
2
+ import { ScramjetVersionInfo, ScramjetConfig } from "./types";
3
+ export declare const versionInfo: ScramjetVersionInfo;
4
+ export declare const defaultConfig: ScramjetConfig;
5
+ export declare const defaultConfigDev: ScramjetConfig;
5
6
  export * from "./symbols";
6
7
  export * from "./types";
7
- export * from "./fetch";
8
8
  export * from "./Tap";
9
- export { BareResponse } from "@mercuryworkshop/proxy-transports";
10
- export declare const defaultConfig: ScramjetConfig;
11
- export declare const defaultConfigDev: ScramjetConfig;
9
+ export * from "./shared";
10
+ export * from "./fetch";
11
+ export * from "./client";
@@ -1,5 +1,5 @@
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
5
  fn: (value: string, context: ScramjetContext, meta: URLMeta, attrs?: Record<string, string | undefined>) => string | null;
@@ -1,9 +1,9 @@
1
- import { ScramjetConfig, ScramjetFlags, ScramjetVersionInfo } from "@/types";
1
+ import { ScramjetConfig, ScramjetFlags } 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";
@@ -27,7 +27,6 @@ export type ScramjetContext = {
27
27
  };
28
28
  };
29
29
  };
30
- export declare const versionInfo: ScramjetVersionInfo;
31
30
  export type HtmlRewriterHooks = {
32
31
  pre: {
33
32
  context: {
@@ -32,6 +32,12 @@ 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
+ * Script block type string for a `<script>` element (prepare a script).
37
+ * Resolves `type` when present; otherwise maps obsolete `language` to `text/…`.
38
+ * @see https://html.spec.whatwg.org/multipage/scripting.html#prepare-a-script
39
+ */
40
+ export declare function getScriptBlockTypeString(type: string | null | undefined, language: string | null | undefined, hasTypeAttribute?: boolean, hasLanguageAttribute?: boolean): string;
35
41
  /**
36
42
  * Whether a `<script type="...">` value denotes executable JavaScript
37
43
  * (classic or module script), not a data block or import map.
@@ -1,4 +1,4 @@
1
- import { URLMeta } from "@rewriters/url";
2
- import { ScramjetContext } from "@/shared";
1
+ import { URLMeta } from "./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 "@rewriters/url";
2
- import { ScramjetContext } from "@/shared";
1
+ import { URLMeta } from "./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 "@rewriters/url";
1
+ import { ScramjetContext } from "../../shared";
2
+ import { URLMeta } from "./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 "@rewriters/url";
5
+ import { URLMeta } from "./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 "@rewriters/url";
3
- export declare function rewriteWorkers(context: ScramjetContext, js: string | Uint8Array, isModule: boolean, url: string, meta: URLMeta): string;
1
+ import { ScramjetContext } from "../../shared";
2
+ import { URLMeta } from "./url";
3
+ export declare function rewriteWorkers(js: string | Uint8Array, url: string, context: ScramjetContext, meta: URLMeta, isModule: boolean): string;
@@ -1,6 +1,7 @@
1
1
  export declare const String: StringConstructor;
2
2
  export declare const String_fromCodePoint: (...codePoints: number[]) => string;
3
3
  export declare const String_fromCharCode: (...codes: number[]) => string;
4
+ export declare const String_startsWith: (str: string, searchString: string, position?: number) => boolean;
4
5
  export declare const Number: NumberConstructor;
5
6
  export declare const Number_parseInt: (string: string, radix?: number) => number;
6
7
  export declare const Number_isSafeInteger: (number: unknown) => boolean;
@@ -43,9 +43,9 @@ export interface ScramjetConfig {
43
43
  templocid: string;
44
44
  tempunusedid: string;
45
45
  };
46
- maskedfiles: string[];
47
46
  flags: ScramjetFlags;
48
47
  siteFlags: Record<string, Partial<ScramjetFlags>>;
48
+ maskedfiles: string[];
49
49
  }
50
50
  /**
51
51
  * The config for Scramjet initialization.
@@ -57,12 +57,4 @@ export interface ScramjetInitConfig extends Omit<ScramjetConfig, "codec" | "flag
57
57
  decode: (url: string) => string;
58
58
  };
59
59
  }
60
- declare global {
61
- interface Window {
62
- WASM: string;
63
- REAL_WASM: Uint8Array;
64
- }
65
- interface HTMLDocument {
66
- }
67
- }
68
60
  export type AnyFunction = Function;
@@ -1,5 +1,5 @@
1
1
  import * as Types from "./index";
2
- export * from "./index";
3
2
  declare global {
4
3
  const $scramjet: typeof Types;
5
4
  }
5
+ export * from "./index";
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@mercuryworkshop/scramjet",
3
- "version": "2.0.67-alpha.1",
3
+ "version": "2.1.0",
4
4
  "license": "AGPL-3.0-only",
5
5
  "description": "An experimental web proxy that aims to be the successor to Ultraviolet",
6
6
  "type": "module",
7
- "types": "./dist/types/index.d.ts",
8
7
  "main": "./dist/scramjet-external.mjs",
9
8
  "module": "./dist/scramjet-external.mjs",
9
+ "types": "./dist/types/typesEntry.d.ts",
10
10
  "repository": {
11
11
  "type": "git",
12
12
  "url": "https://github.com/MercuryWorkshop/scramjet"
@@ -16,10 +16,6 @@
16
16
  "types": "./dist/types/typesEntry.d.ts",
17
17
  "default": "./dist/scramjet-external.mjs"
18
18
  },
19
- "./path": {
20
- "types": "./lib/index.d.ts",
21
- "default": "./lib/index.cjs"
22
- },
23
19
  "./bundled": {
24
20
  "types": "./dist/types/index.d.ts",
25
21
  "default": "./dist/scramjet.mjs"
@@ -27,6 +23,10 @@
27
23
  "./bundled-wasm": {
28
24
  "types": "./dist/types/index.d.ts",
29
25
  "default": "./dist/scramjet_bundled.mjs"
26
+ },
27
+ "./path": {
28
+ "types": "./lib/index.d.ts",
29
+ "default": "./lib/index.cjs"
30
30
  }
31
31
  },
32
32
  "files": [
@@ -35,65 +35,33 @@
35
35
  ],
36
36
  "keywords": [],
37
37
  "author": "",
38
- "ava": {
39
- "files": [
40
- "tests/ci/**/*.js"
41
- ],
42
- "verbose": true
43
- },
44
38
  "devDependencies": {
45
39
  "@eslint/eslintrc": "^3.3.1",
46
40
  "@eslint/js": "^9.35.0",
47
- "@estruyf/github-actions-reporter": "^1.10.0",
48
- "@fastify/static": "^8.2.0",
49
- "@mercuryworkshop/wisp-js": "^0.4.0",
50
- "@nebula-services/bare-server-node": "^2.0.4",
51
41
  "@types/eslint": "^9.6.1",
52
42
  "@types/estree": "^1.0.8",
53
43
  "@types/node": "^24.3.1",
54
- "@types/serviceworker": "^0.0.160",
55
- "@typescript-eslint/eslint-plugin": "8.57.3-alpha.3",
56
- "@typescript-eslint/parser": "8.57.3-alpha.3",
57
- "actionlint": "^2.0.6",
58
- "ava": "^6.4.1",
59
- "dotenv": "^17.2.2",
44
+ "@types/serviceworker": "^0.0.197",
45
+ "@typescript-eslint/eslint-plugin": "8.62.0",
46
+ "@typescript-eslint/parser": "8.62.0",
60
47
  "eslint": "^10.1.0",
61
- "fastify": "^5.6.0",
62
- "glob": "^11.0.3",
63
- "prettier": "^3.6.2",
64
- "remark": "^15.0.1",
65
- "remark-cli": "^12.0.1",
66
- "remark-frontmatter": "^5.0.0",
67
- "remark-mdx": "^3.1.1",
68
- "remark-stringify": "^11.0.0",
69
- "ts-checker-rspack-plugin": "^1.1.5",
70
- "tsc-alias": "^1.8.16",
71
48
  "tslib": "^2.8.1",
72
- "typescript": "^5.9.2"
49
+ "typescript": "^5.9.3"
73
50
  },
74
51
  "dependencies": {
75
52
  "@mercuryworkshop/proxy-transports": "1.0.2",
76
53
  "dom-serializer": "^2.0.0",
77
54
  "domhandler": "^5.0.3",
78
55
  "domutils": "^3.2.2",
79
- "htmlparser2": "^12.0.0",
56
+ "htmlparser2": "12.0.0",
80
57
  "idb": "^8.0.3",
81
58
  "parse-domain": "^8.2.2"
82
59
  },
83
60
  "scripts": {
84
61
  "build": "cd ../.. && rspack build --mode production",
85
62
  "rewriter:build": "cd rewriter/wasm/ && bash build.sh && cd ../../",
86
- "dev": "node server.js",
87
- "dev:debug": "DEBUG=1 node server.js",
88
- "pub": "pnpm publish --no-git-checks --access public",
89
63
  "format": "prettier --write .",
90
- "format:docs": "remark \"docs/**/*.{md,mdx}\" --output",
91
64
  "lint": "eslint ./src/",
92
- "lint:fix": "eslint ./src/ --fix",
93
- "lint:workflows": "actionlint .github/workflows/*.yml",
94
- "lint:all": "npm run lint && npm run lint:workflows",
95
- "test": "npm run test:package",
96
- "test:package": "ava tests/ci/packageValidation.js",
97
- "preinstall": "npx only-allow pnpm"
65
+ "lint:fix": "eslint ./src/ --fix"
98
66
  }
99
67
  }