diff --git a/.gitignore b/.gitignore index ef43d76..f07b615 100644 --- a/.gitignore +++ b/.gitignore @@ -8,10 +8,10 @@ static/epoxy-client.js static/bare-mux-worker.js meta.json rewriter/target -rewriter/out +rewriter/wasm/out static/wasm.js rewriter/*.js pnpm-lock.yaml playwright-report test-results -*.tgz \ No newline at end of file +*.tgz diff --git a/rewriter/wasm/out/optimized.wasm b/rewriter/wasm/out/optimized.wasm deleted file mode 100644 index a5f8072..0000000 Binary files a/rewriter/wasm/out/optimized.wasm and /dev/null differ diff --git a/rewriter/wasm/out/snippets/wasm-4b0f351a8e6eeb46/inline0.js b/rewriter/wasm/out/snippets/wasm-4b0f351a8e6eeb46/inline0.js deleted file mode 100644 index 72a52d9..0000000 --- a/rewriter/wasm/out/snippets/wasm-4b0f351a8e6eeb46/inline0.js +++ /dev/null @@ -1,7 +0,0 @@ - -// slightly modified https://github.com/ungap/random-uuid/blob/main/index.js -export function scramtag() { - return (""+1e10).replace(/[018]/g, - c => (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16) - ); -} diff --git a/rewriter/wasm/out/wasm.d.ts b/rewriter/wasm/out/wasm.d.ts deleted file mode 100644 index 449fb4f..0000000 --- a/rewriter/wasm/out/wasm.d.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -export function rewrite_js(js: string, url: string, script_url: string, scramjet: object): RewriterOutput; -export function rewrite_js_from_arraybuffer(js: Uint8Array, url: string, script_url: string, scramjet: object): RewriterOutput; - -type RewriterOutput = { js: Uint8Array, errors: string[], duration: bigint }; - - - -export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module; - -export interface InitOutput { - readonly rewrite_js: (a: number, b: number, c: number, d: number, e: number, f: number, g: any) => [number, number, number]; - readonly rewrite_js_from_arraybuffer: (a: number, b: number, c: number, d: number, e: number, f: number, g: any) => [number, number, number]; - readonly __wbindgen_exn_store: (a: number) => void; - readonly __externref_table_alloc: () => number; - readonly __wbindgen_export_2: WebAssembly.Table; - readonly memory: WebAssembly.Memory; - readonly __wbindgen_malloc: (a: number, b: number) => number; - readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number; - readonly __wbindgen_free: (a: number, b: number, c: number) => void; - readonly __externref_table_dealloc: (a: number) => void; - readonly __wbindgen_thread_destroy: (a?: number, b?: number, c?: number) => void; - readonly __wbindgen_start: (a: number) => void; -} - -export type SyncInitInput = BufferSource | WebAssembly.Module; -/** -* Instantiates the given `module`, which can either be bytes or -* a precompiled `WebAssembly.Module`. -* -* @param {{ module: SyncInitInput, memory?: WebAssembly.Memory, thread_stack_size?: number }} module - Passing `SyncInitInput` directly is deprecated. -* @param {WebAssembly.Memory} memory - Deprecated. -* -* @returns {InitOutput} -*/ -export function initSync(module: { module: SyncInitInput, memory?: WebAssembly.Memory, thread_stack_size?: number } | SyncInitInput, memory?: WebAssembly.Memory): InitOutput; - -/** -* If `module_or_path` is {RequestInfo} or {URL}, makes a request and -* for everything else, calls `WebAssembly.instantiate` directly. -* -* @param {{ module_or_path: InitInput | Promise, memory?: WebAssembly.Memory, thread_stack_size?: number }} module_or_path - Passing `InitInput` directly is deprecated. -* @param {WebAssembly.Memory} memory - Deprecated. -* -* @returns {Promise} -*/ -export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise, memory?: WebAssembly.Memory, thread_stack_size?: number } | InitInput | Promise, memory?: WebAssembly.Memory): Promise; diff --git a/rewriter/wasm/out/wasm.js b/rewriter/wasm/out/wasm.js deleted file mode 100644 index 2bbc855..0000000 --- a/rewriter/wasm/out/wasm.js +++ /dev/null @@ -1,390 +0,0 @@ -import { scramtag } from './snippets/wasm-4b0f351a8e6eeb46/inline0.js'; - -let wasm; - -function addToExternrefTable0(obj) { - const idx = wasm.__externref_table_alloc(); - wasm.__wbindgen_export_2.set(idx, obj); - return idx; -} - -function handleError(f, args) { - try { - return f.apply(this, args); - } catch (e) { - const idx = addToExternrefTable0(e); - wasm.__wbindgen_exn_store(idx); - } -} - -const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } ); - -if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }; - -let cachedUint8ArrayMemory0 = null; - -function getUint8ArrayMemory0() { - if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.buffer !== wasm.memory.buffer) { - cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer); - } - return cachedUint8ArrayMemory0; -} - -function getStringFromWasm0(ptr, len) { - ptr = ptr >>> 0; - return cachedTextDecoder.decode(getUint8ArrayMemory0().slice(ptr, ptr + len)); -} - -let WASM_VECTOR_LEN = 0; - -const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } ); - -const encodeString = function (arg, view) { - const buf = cachedTextEncoder.encode(arg); - view.set(buf); - return { - read: arg.length, - written: buf.length - }; -}; - -function passStringToWasm0(arg, malloc, realloc) { - - if (realloc === undefined) { - const buf = cachedTextEncoder.encode(arg); - const ptr = malloc(buf.length, 1) >>> 0; - getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf); - WASM_VECTOR_LEN = buf.length; - return ptr; - } - - let len = arg.length; - let ptr = malloc(len, 1) >>> 0; - - const mem = getUint8ArrayMemory0(); - - let offset = 0; - - for (; offset < len; offset++) { - const code = arg.charCodeAt(offset); - if (code > 0x7F) break; - mem[ptr + offset] = code; - } - - if (offset !== len) { - if (offset !== 0) { - arg = arg.slice(offset); - } - ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0; - const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len); - const ret = encodeString(arg, view); - - offset += ret.written; - ptr = realloc(ptr, len, offset, 1) >>> 0; - } - - WASM_VECTOR_LEN = offset; - return ptr; -} - -let cachedDataViewMemory0 = null; - -function getDataViewMemory0() { - if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer !== wasm.memory.buffer) { - cachedDataViewMemory0 = new DataView(wasm.memory.buffer); - } - return cachedDataViewMemory0; -} - -function isLikeNone(x) { - return x === undefined || x === null; -} - -function getArrayU8FromWasm0(ptr, len) { - ptr = ptr >>> 0; - return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len); -} - -function takeFromExternrefTable0(idx) { - const value = wasm.__wbindgen_export_2.get(idx); - wasm.__externref_table_dealloc(idx); - return value; -} -/** - * @param {string} js - * @param {string} url - * @param {string} script_url - * @param {object} scramjet - * @returns {RewriterOutput} - */ -export function rewrite_js(js, url, script_url, scramjet) { - const ptr0 = passStringToWasm0(js, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(script_url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ret = wasm.rewrite_js(ptr0, len0, ptr1, len1, ptr2, len2, scramjet); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); -} - -function passArray8ToWasm0(arg, malloc) { - const ptr = malloc(arg.length * 1, 1) >>> 0; - getUint8ArrayMemory0().set(arg, ptr / 1); - WASM_VECTOR_LEN = arg.length; - return ptr; -} -/** - * @param {Uint8Array} js - * @param {string} url - * @param {string} script_url - * @param {object} scramjet - * @returns {RewriterOutput} - */ -export function rewrite_js_from_arraybuffer(js, url, script_url, scramjet) { - const ptr0 = passArray8ToWasm0(js, wasm.__wbindgen_malloc); - const len0 = WASM_VECTOR_LEN; - const ptr1 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - const ptr2 = passStringToWasm0(script_url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len2 = WASM_VECTOR_LEN; - const ret = wasm.rewrite_js_from_arraybuffer(ptr0, len0, ptr1, len1, ptr2, len2, scramjet); - if (ret[2]) { - throw takeFromExternrefTable0(ret[1]); - } - return takeFromExternrefTable0(ret[0]); -} - -async function __wbg_load(module, imports) { - if (typeof Response === 'function' && module instanceof Response) { - if (typeof WebAssembly.instantiateStreaming === 'function') { - try { - return await WebAssembly.instantiateStreaming(module, imports); - - } catch (e) { - if (module.headers.get('Content-Type') != 'application/wasm') { - console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e); - - } else { - throw e; - } - } - } - - const bytes = await module.arrayBuffer(); - return await WebAssembly.instantiate(bytes, imports); - - } else { - const instance = await WebAssembly.instantiate(module, imports); - - if (instance instanceof WebAssembly.Instance) { - return { instance, module }; - - } else { - return instance; - } - } -} - -function __wbg_get_imports() { - const imports = {}; - imports.wbg = {}; - imports.wbg.__wbg_call_3b770f0d6eb4720e = function() { return handleError(function (arg0, arg1, arg2, arg3) { - const ret = arg0.call(arg1, arg2, arg3); - return ret; - }, arguments) }; - imports.wbg.__wbg_call_500db948e69c7330 = function() { return handleError(function (arg0, arg1, arg2) { - const ret = arg0.call(arg1, arg2); - return ret; - }, arguments) }; - imports.wbg.__wbg_call_b0d8e36992d9900d = function() { return handleError(function (arg0, arg1) { - const ret = arg0.call(arg1); - return ret; - }, arguments) }; - imports.wbg.__wbg_get_bbccf8970793c087 = function() { return handleError(function (arg0, arg1) { - const ret = Reflect.get(arg0, arg1); - return ret; - }, arguments) }; - imports.wbg.__wbg_new_17f755666e48d1d8 = function() { return handleError(function (arg0, arg1) { - const ret = new URL(getStringFromWasm0(arg0, arg1)); - return ret; - }, arguments) }; - imports.wbg.__wbg_new_688846f374351c92 = function() { - const ret = new Object(); - return ret; - }; - imports.wbg.__wbg_newnoargs_fd9e4bf8be2bc16d = function(arg0, arg1) { - const ret = new Function(getStringFromWasm0(arg0, arg1)); - return ret; - }; - imports.wbg.__wbg_now_62a101fe35b60230 = function(arg0) { - const ret = arg0.now(); - return ret; - }; - imports.wbg.__wbg_scramtag_bd98edaa0eaec45e = function(arg0) { - const ret = scramtag(); - const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); - getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); - }; - imports.wbg.__wbg_set_4e647025551483bd = function() { return handleError(function (arg0, arg1, arg2) { - const ret = Reflect.set(arg0, arg1, arg2); - return ret; - }, arguments) }; - imports.wbg.__wbg_static_accessor_GLOBAL_0be7472e492ad3e3 = function() { - const ret = typeof global === 'undefined' ? null : global; - return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); - }; - imports.wbg.__wbg_static_accessor_GLOBAL_THIS_1a6eb482d12c9bfb = function() { - const ret = typeof globalThis === 'undefined' ? null : globalThis; - return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); - }; - imports.wbg.__wbg_static_accessor_SELF_1dc398a895c82351 = function() { - const ret = typeof self === 'undefined' ? null : self; - return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); - }; - imports.wbg.__wbg_static_accessor_WINDOW_ae1c80c7eea8d64a = function() { - const ret = typeof window === 'undefined' ? null : window; - return isLikeNone(ret) ? 0 : addToExternrefTable0(ret); - }; - imports.wbg.__wbg_toString_cbcf95f260c441ae = function(arg0) { - const ret = arg0.toString(); - return ret; - }; - imports.wbg.__wbindgen_array_new = function() { - const ret = []; - return ret; - }; - imports.wbg.__wbindgen_array_push = function(arg0, arg1) { - arg0.push(arg1); - }; - imports.wbg.__wbindgen_boolean_get = function(arg0) { - const v = arg0; - const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2; - return ret; - }; - imports.wbg.__wbindgen_error_new = function(arg0, arg1) { - const ret = new Error(getStringFromWasm0(arg0, arg1)); - return ret; - }; - imports.wbg.__wbindgen_init_externref_table = function() { - const table = wasm.__wbindgen_export_2; - const offset = table.grow(4); - table.set(0, undefined); - table.set(offset + 0, undefined); - table.set(offset + 1, null); - table.set(offset + 2, true); - table.set(offset + 3, false); - ; - }; - imports.wbg.__wbindgen_is_function = function(arg0) { - const ret = typeof(arg0) === 'function'; - return ret; - }; - imports.wbg.__wbindgen_is_undefined = function(arg0) { - const ret = arg0 === undefined; - return ret; - }; - imports.wbg.__wbindgen_number_new = function(arg0) { - const ret = arg0; - return ret; - }; - imports.wbg.__wbindgen_string_get = function(arg0, arg1) { - const obj = arg1; - const ret = typeof(obj) === 'string' ? obj : undefined; - var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - var len1 = WASM_VECTOR_LEN; - getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); - getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); - }; - imports.wbg.__wbindgen_string_new = function(arg0, arg1) { - const ret = getStringFromWasm0(arg0, arg1); - return ret; - }; - imports.wbg.__wbindgen_throw = function(arg0, arg1) { - throw new Error(getStringFromWasm0(arg0, arg1)); - }; - imports.wbg.__wbindgen_uint8_array_new = function(arg0, arg1) { - var v0 = getArrayU8FromWasm0(arg0, arg1).slice(); - wasm.__wbindgen_free(arg0, arg1 * 1, 1); - const ret = v0; - return ret; - }; - - return imports; -} - -function __wbg_init_memory(imports, memory) { - imports.wbg.memory = memory || new WebAssembly.Memory({initial:21,maximum:16384,shared:true}); -} - -function __wbg_finalize_init(instance, module, thread_stack_size) { - wasm = instance.exports; - __wbg_init.__wbindgen_wasm_module = module; - cachedDataViewMemory0 = null; - cachedUint8ArrayMemory0 = null; - - if (typeof thread_stack_size !== 'undefined' && (typeof thread_stack_size !== 'number' || thread_stack_size === 0 || thread_stack_size % 65536 !== 0)) { throw 'invalid stack size' } - wasm.__wbindgen_start(thread_stack_size); - return wasm; -} - -function initSync(module, memory) { - if (wasm !== undefined) return wasm; - - let thread_stack_size - if (typeof module !== 'undefined') { - if (Object.getPrototypeOf(module) === Object.prototype) { - ({module, memory, thread_stack_size} = module) - } else { - console.warn('using deprecated parameters for `initSync()`; pass a single object instead') - } - } - - const imports = __wbg_get_imports(); - - __wbg_init_memory(imports, memory); - - if (!(module instanceof WebAssembly.Module)) { - module = new WebAssembly.Module(module); - } - - const instance = new WebAssembly.Instance(module, imports); - - return __wbg_finalize_init(instance, module, thread_stack_size); -} - -async function __wbg_init(module_or_path, memory) { - if (wasm !== undefined) return wasm; - - let thread_stack_size - if (typeof module_or_path !== 'undefined') { - if (Object.getPrototypeOf(module_or_path) === Object.prototype) { - ({module_or_path, memory, thread_stack_size} = module_or_path) - } else { - console.warn('using deprecated parameters for the initialization function; pass a single object instead') - } - } - - if (typeof module_or_path === 'undefined') { - module_or_path = new URL('wasm_bg.wasm', ""); - } - const imports = __wbg_get_imports(); - - if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) { - module_or_path = fetch(module_or_path); - } - - __wbg_init_memory(imports, memory); - - const { instance, module } = await __wbg_load(await module_or_path, imports); - - return __wbg_finalize_init(instance, module, thread_stack_size); -} - -export { initSync }; -export default __wbg_init; diff --git a/rewriter/wasm/out/wasm_bg.wasm b/rewriter/wasm/out/wasm_bg.wasm deleted file mode 100644 index b167e28..0000000 Binary files a/rewriter/wasm/out/wasm_bg.wasm and /dev/null differ diff --git a/rewriter/wasm/out/wasm_bg.wasm.d.ts b/rewriter/wasm/out/wasm_bg.wasm.d.ts deleted file mode 100644 index 626d2dd..0000000 --- a/rewriter/wasm/out/wasm_bg.wasm.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -export const rewrite_js: (a: number, b: number, c: number, d: number, e: number, f: number, g: any) => [number, number, number]; -export const rewrite_js_from_arraybuffer: (a: number, b: number, c: number, d: number, e: number, f: number, g: any) => [number, number, number]; -export const __wbindgen_exn_store: (a: number) => void; -export const __externref_table_alloc: () => number; -export const __wbindgen_export_2: WebAssembly.Table; -export const memory: WebAssembly.Memory; -export const __wbindgen_malloc: (a: number, b: number) => number; -export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number; -export const __wbindgen_free: (a: number, b: number, c: number) => void; -export const __externref_table_dealloc: (a: number) => void; -export const __wbindgen_thread_destroy: (a?: number, b?: number, c?: number) => void; -export const __wbindgen_start: (a: number) => void;