Skip to content

Commit aeaacbe

Browse files
authored
fix: pass the wasm module via module_or_path to avoid a warning being emitted to the console (#21)
1 parent 8bfe0ce commit aeaacbe

6 files changed

+170740
-173729
lines changed

pkg/csp_nonce_html_transformer.d.ts

+14-23
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,14 @@
11
/* tslint:disable */
22
/* eslint-disable */
33
export class Element {
4+
private constructor();
45
free(): void;
5-
/**
6-
* @param {string} name
7-
* @param {string} value
8-
*/
96
setAttribute(name: string, value: string): void;
107
}
118
export class HTMLRewriter {
129
free(): void;
13-
/**
14-
* @param {Function} output_sink
15-
*/
1610
constructor(output_sink: Function);
17-
/**
18-
* @param {string} selector
19-
* @param {any} handlers
20-
*/
2111
on(selector: string, handlers: any): void;
22-
/**
23-
* @param {Uint8Array} chunk
24-
*/
2512
write(chunk: Uint8Array): void;
2613
end(): void;
2714
}
@@ -42,28 +29,32 @@ export interface InitOutput {
4229
c: number,
4330
d: number,
4431
e: number,
45-
) => Array;
32+
) => [number, number];
4633
readonly __wbg_htmlrewriter_free: (a: number, b: number) => void;
47-
readonly htmlrewriter_new: (a: number) => number;
34+
readonly htmlrewriter_new: (a: any) => number;
4835
readonly htmlrewriter_on: (
4936
a: number,
5037
b: number,
5138
c: number,
52-
d: number,
53-
) => Array;
54-
readonly htmlrewriter_write: (a: number, b: number, c: number) => Array;
55-
readonly htmlrewriter_end: (a: number) => Array;
39+
d: any,
40+
) => [number, number];
41+
readonly htmlrewriter_write: (
42+
a: number,
43+
b: number,
44+
c: number,
45+
) => [number, number];
46+
readonly htmlrewriter_end: (a: number) => [number, number];
47+
readonly __wbindgen_exn_store: (a: number) => void;
48+
readonly __externref_table_alloc: () => number;
49+
readonly __wbindgen_export_2: WebAssembly.Table;
5650
readonly __wbindgen_malloc: (a: number, b: number) => number;
5751
readonly __wbindgen_realloc: (
5852
a: number,
5953
b: number,
6054
c: number,
6155
d: number,
6256
) => number;
63-
readonly __wbindgen_export_2: WebAssembly.Table;
6457
readonly __externref_table_dealloc: (a: number) => void;
65-
readonly __externref_table_alloc: () => number;
66-
readonly __wbindgen_exn_store: (a: number) => void;
6758
readonly __wbindgen_start: () => void;
6859
}
6960

pkg/csp_nonce_html_transformer.js

+45-45
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
let wasm;
22

3+
function addToExternrefTable0(obj) {
4+
const idx = wasm.__externref_table_alloc();
5+
wasm.__wbindgen_export_2.set(idx, obj);
6+
return idx;
7+
}
8+
9+
function handleError(f, args) {
10+
try {
11+
return f.apply(this, args);
12+
} catch (e) {
13+
const idx = addToExternrefTable0(e);
14+
wasm.__wbindgen_exn_store(idx);
15+
}
16+
}
17+
18+
function isLikeNone(x) {
19+
return x === undefined || x === null;
20+
}
21+
322
const cachedTextDecoder = typeof TextDecoder !== "undefined"
423
? new TextDecoder("utf-8", { ignoreBOM: true, fatal: true })
524
: {
@@ -69,7 +88,7 @@ function debugString(val) {
6988
// Test for built-in
7089
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
7190
let className;
72-
if (builtInMatches.length > 1) {
91+
if (builtInMatches && builtInMatches.length > 1) {
7392
className = builtInMatches[1];
7493
} else {
7594
// Failed to match the standard '[object ClassName]'
@@ -174,32 +193,13 @@ function takeFromExternrefTable0(idx) {
174193
return value;
175194
}
176195

177-
function isLikeNone(x) {
178-
return x === undefined || x === null;
179-
}
180-
181-
function addToExternrefTable0(obj) {
182-
const idx = wasm.__externref_table_alloc();
183-
wasm.__wbindgen_export_2.set(idx, obj);
184-
return idx;
185-
}
186-
187196
function passArray8ToWasm0(arg, malloc) {
188197
const ptr = malloc(arg.length * 1, 1) >>> 0;
189198
getUint8ArrayMemory0().set(arg, ptr / 1);
190199
WASM_VECTOR_LEN = arg.length;
191200
return ptr;
192201
}
193202

194-
function handleError(f, args) {
195-
try {
196-
return f.apply(this, args);
197-
} catch (e) {
198-
const idx = addToExternrefTable0(e);
199-
wasm.__wbindgen_exn_store(idx);
200-
}
201-
}
202-
203203
const ElementFinalization = (typeof FinalizationRegistry === "undefined")
204204
? { register: () => {}, unregister: () => {} }
205205
: new FinalizationRegistry((ptr) => wasm.__wbg_element_free(ptr >>> 0, 1));
@@ -349,44 +349,40 @@ async function __wbg_load(module, imports) {
349349
function __wbg_get_imports() {
350350
const imports = {};
351351
imports.wbg = {};
352-
imports.wbg.__wbindgen_string_new = function (arg0, arg1) {
353-
const ret = getStringFromWasm0(arg0, arg1);
352+
imports.wbg.__wbg_buffer_609cc3eee51ed158 = function (arg0) {
353+
const ret = arg0.buffer;
354354
return ret;
355355
};
356-
imports.wbg.__wbg_element_9f7a29ae173a1783 = function (arg0) {
356+
imports.wbg.__wbg_call_7cccdd69e0791ae2 = function () {
357+
return handleError(function (arg0, arg1, arg2) {
358+
const ret = arg0.call(arg1, arg2);
359+
return ret;
360+
}, arguments);
361+
};
362+
imports.wbg.__wbg_element_f2e1211cc792d467 = function (arg0) {
357363
const ret = arg0.element;
358364
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
359365
};
360366
imports.wbg.__wbg_element_new = function (arg0) {
361367
const ret = Element.__wrap(arg0);
362368
return ret;
363369
};
364-
imports.wbg.__wbg_call_3bfa248576352471 = function () {
365-
return handleError(function (arg0, arg1, arg2) {
366-
const ret = arg0.call(arg1, arg2);
367-
return ret;
368-
}, arguments);
369-
};
370-
imports.wbg.__wbg_new_9a7e38dd635a4e93 = function (arg0, arg1) {
371-
const ret = new TypeError(getStringFromWasm0(arg0, arg1));
370+
imports.wbg.__wbg_new_a12002a7f91c75be = function (arg0) {
371+
const ret = new Uint8Array(arg0);
372372
return ret;
373373
};
374-
imports.wbg.__wbg_buffer_ccaed51a635d8a2d = function (arg0) {
375-
const ret = arg0.buffer;
374+
imports.wbg.__wbg_new_b08a00743b8ae2f3 = function (arg0, arg1) {
375+
const ret = new TypeError(getStringFromWasm0(arg0, arg1));
376376
return ret;
377377
};
378-
imports.wbg.__wbg_newwithbyteoffsetandlength_7e3eb787208af730 = function (
378+
imports.wbg.__wbg_newwithbyteoffsetandlength_d97e637ebe145a9a = function (
379379
arg0,
380380
arg1,
381381
arg2,
382382
) {
383383
const ret = new Uint8Array(arg0, arg1 >>> 0, arg2 >>> 0);
384384
return ret;
385385
};
386-
imports.wbg.__wbg_new_fec2611eb9180f95 = function (arg0) {
387-
const ret = new Uint8Array(arg0);
388-
return ret;
389-
};
390386
imports.wbg.__wbindgen_debug_string = function (arg0, arg1) {
391387
const ret = debugString(arg1);
392388
const ptr1 = passStringToWasm0(
@@ -398,13 +394,6 @@ function __wbg_get_imports() {
398394
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
399395
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
400396
};
401-
imports.wbg.__wbindgen_throw = function (arg0, arg1) {
402-
throw new Error(getStringFromWasm0(arg0, arg1));
403-
};
404-
imports.wbg.__wbindgen_memory = function () {
405-
const ret = wasm.memory;
406-
return ret;
407-
};
408397
imports.wbg.__wbindgen_init_externref_table = function () {
409398
const table = wasm.__wbindgen_export_2;
410399
const offset = table.grow(4);
@@ -414,6 +403,17 @@ function __wbg_get_imports() {
414403
table.set(offset + 2, true);
415404
table.set(offset + 3, false);
416405
};
406+
imports.wbg.__wbindgen_memory = function () {
407+
const ret = wasm.memory;
408+
return ret;
409+
};
410+
imports.wbg.__wbindgen_string_new = function (arg0, arg1) {
411+
const ret = getStringFromWasm0(arg0, arg1);
412+
return ret;
413+
};
414+
imports.wbg.__wbindgen_throw = function (arg0, arg1) {
415+
throw new Error(getStringFromWasm0(arg0, arg1));
416+
};
417417

418418
return imports;
419419
}

0 commit comments

Comments
 (0)