Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 143cd63

Browse files
committedNov 11, 2024··
chore(javascript): Update bundled WASM module
Signed-off-by: Dmitry Dygalo <dmitry@dygalo.dev>
1 parent e38405b commit 143cd63

File tree

4 files changed

+136
-144
lines changed

4 files changed

+136
-144
lines changed
 

‎bindings/javascript/wasm/index.js

+67-71
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@ var cachedTextDecoder = typeof TextDecoder !== "undefined" ? new TextDecoder("ut
4040
if (typeof TextDecoder !== "undefined") {
4141
cachedTextDecoder.decode();
4242
}
43-
var cachedUint8Memory0 = null;
44-
function getUint8Memory0() {
45-
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
46-
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
43+
var cachedUint8ArrayMemory0 = null;
44+
function getUint8ArrayMemory0() {
45+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
46+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
4747
}
48-
return cachedUint8Memory0;
48+
return cachedUint8ArrayMemory0;
4949
}
5050
function getStringFromWasm0(ptr, len) {
5151
ptr = ptr >>> 0;
52-
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
52+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
5353
}
5454
var heap_next = heap.length;
5555
function addHeapObject(obj) {
@@ -60,6 +60,17 @@ function addHeapObject(obj) {
6060
heap[idx] = obj;
6161
return idx;
6262
}
63+
function dropObject(idx) {
64+
if (idx < 132)
65+
return;
66+
heap[idx] = heap_next;
67+
heap_next = idx;
68+
}
69+
function takeObject(idx) {
70+
const ret = getObject(idx);
71+
dropObject(idx);
72+
return ret;
73+
}
6374
var WASM_VECTOR_LEN = 0;
6475
var cachedTextEncoder = typeof TextEncoder !== "undefined" ? new TextEncoder("utf-8") : { encode: () => {
6576
throw Error("TextEncoder not available");
@@ -78,13 +89,13 @@ function passStringToWasm0(arg, malloc, realloc) {
7889
if (realloc === void 0) {
7990
const buf = cachedTextEncoder.encode(arg);
8091
const ptr2 = malloc(buf.length, 1) >>> 0;
81-
getUint8Memory0().subarray(ptr2, ptr2 + buf.length).set(buf);
92+
getUint8ArrayMemory0().subarray(ptr2, ptr2 + buf.length).set(buf);
8293
WASM_VECTOR_LEN = buf.length;
8394
return ptr2;
8495
}
8596
let len = arg.length;
8697
let ptr = malloc(len, 1) >>> 0;
87-
const mem = getUint8Memory0();
98+
const mem = getUint8ArrayMemory0();
8899
let offset = 0;
89100
for (; offset < len; offset++) {
90101
const code = arg.charCodeAt(offset);
@@ -97,7 +108,7 @@ function passStringToWasm0(arg, malloc, realloc) {
97108
arg = arg.slice(offset);
98109
}
99110
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
100-
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
111+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
101112
const ret = encodeString(arg, view);
102113
offset += ret.written;
103114
ptr = realloc(ptr, len, offset, 1) >>> 0;
@@ -108,30 +119,12 @@ function passStringToWasm0(arg, malloc, realloc) {
108119
function isLikeNone(x) {
109120
return x === void 0 || x === null;
110121
}
111-
var cachedInt32Memory0 = null;
112-
function getInt32Memory0() {
113-
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
114-
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
115-
}
116-
return cachedInt32Memory0;
117-
}
118-
function dropObject(idx) {
119-
if (idx < 132)
120-
return;
121-
heap[idx] = heap_next;
122-
heap_next = idx;
123-
}
124-
function takeObject(idx) {
125-
const ret = getObject(idx);
126-
dropObject(idx);
127-
return ret;
128-
}
129-
var cachedFloat64Memory0 = null;
130-
function getFloat64Memory0() {
131-
if (cachedFloat64Memory0 === null || cachedFloat64Memory0.byteLength === 0) {
132-
cachedFloat64Memory0 = new Float64Array(wasm.memory.buffer);
122+
var cachedDataViewMemory0 = null;
123+
function getDataViewMemory0() {
124+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || cachedDataViewMemory0.buffer.detached === void 0 && cachedDataViewMemory0.buffer !== wasm.memory.buffer) {
125+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
133126
}
134-
return cachedFloat64Memory0;
127+
return cachedDataViewMemory0;
135128
}
136129
function debugString(val) {
137130
const type = typeof val;
@@ -197,10 +190,10 @@ function inline(html, options) {
197190
const ptr0 = passStringToWasm0(html, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
198191
const len0 = WASM_VECTOR_LEN;
199192
wasm.inline(retptr, ptr0, len0, addHeapObject(options));
200-
var r0 = getInt32Memory0()[retptr / 4 + 0];
201-
var r1 = getInt32Memory0()[retptr / 4 + 1];
202-
var r2 = getInt32Memory0()[retptr / 4 + 2];
203-
var r3 = getInt32Memory0()[retptr / 4 + 3];
193+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
194+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
195+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
196+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
204197
var ptr2 = r0;
205198
var len2 = r1;
206199
if (r3) {
@@ -226,10 +219,10 @@ function inlineFragment(html, css, options) {
226219
const ptr1 = passStringToWasm0(css, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
227220
const len1 = WASM_VECTOR_LEN;
228221
wasm.inlineFragment(retptr, ptr0, len0, ptr1, len1, addHeapObject(options));
229-
var r0 = getInt32Memory0()[retptr / 4 + 0];
230-
var r1 = getInt32Memory0()[retptr / 4 + 1];
231-
var r2 = getInt32Memory0()[retptr / 4 + 2];
232-
var r3 = getInt32Memory0()[retptr / 4 + 3];
222+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
223+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
224+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
225+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
233226
var ptr3 = r0;
234227
var len3 = r1;
235228
if (r3) {
@@ -251,8 +244,8 @@ function version() {
251244
try {
252245
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
253246
wasm.version(retptr);
254-
var r0 = getInt32Memory0()[retptr / 4 + 0];
255-
var r1 = getInt32Memory0()[retptr / 4 + 1];
247+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
248+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
256249
deferred1_0 = r0;
257250
deferred1_1 = r1;
258251
return getStringFromWasm0(r0, r1);
@@ -313,14 +306,17 @@ function __wbg_get_imports() {
313306
const ret = getObject(arg0) in getObject(arg1);
314307
return ret;
315308
};
316-
imports.wbg.__wbg_isSafeInteger_f7b04ef02296c4d2 = function(arg0) {
309+
imports.wbg.__wbg_isSafeInteger_7f1ed56200d90674 = function(arg0) {
317310
const ret = Number.isSafeInteger(getObject(arg0));
318311
return ret;
319312
};
320313
imports.wbg.__wbindgen_as_number = function(arg0) {
321314
const ret = +getObject(arg0);
322315
return ret;
323316
};
317+
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
318+
takeObject(arg0);
319+
};
324320
imports.wbg.__wbindgen_boolean_get = function(arg0) {
325321
const v = getObject(arg0);
326322
const ret = typeof v === "boolean" ? v ? 1 : 0 : 2;
@@ -331,31 +327,28 @@ function __wbg_get_imports() {
331327
const ret = typeof obj === "string" ? obj : void 0;
332328
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
333329
var len1 = WASM_VECTOR_LEN;
334-
getInt32Memory0()[arg0 / 4 + 1] = len1;
335-
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
330+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
331+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
336332
};
337-
imports.wbg.__wbg_length_c20a40f15020d68a = function(arg0) {
333+
imports.wbg.__wbg_length_8339fcf5d8ecd12e = function(arg0) {
338334
const ret = getObject(arg0).length;
339335
return ret;
340336
};
341337
imports.wbg.__wbindgen_memory = function() {
342338
const ret = wasm.memory;
343339
return addHeapObject(ret);
344340
};
345-
imports.wbg.__wbg_buffer_12d079cc21e14bdb = function(arg0) {
341+
imports.wbg.__wbg_buffer_b7b08af79b0b0974 = function(arg0) {
346342
const ret = getObject(arg0).buffer;
347343
return addHeapObject(ret);
348344
};
349-
imports.wbg.__wbg_new_63b92bc8671ed464 = function(arg0) {
345+
imports.wbg.__wbg_new_ea1883e1e5e86686 = function(arg0) {
350346
const ret = new Uint8Array(getObject(arg0));
351347
return addHeapObject(ret);
352348
};
353-
imports.wbg.__wbg_set_a47bac70306a19a7 = function(arg0, arg1, arg2) {
349+
imports.wbg.__wbg_set_d1e79e2388520f18 = function(arg0, arg1, arg2) {
354350
getObject(arg0).set(getObject(arg1), arg2 >>> 0);
355351
};
356-
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
357-
takeObject(arg0);
358-
};
359352
imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
360353
const ret = new Error(getStringFromWasm0(arg0, arg1));
361354
return addHeapObject(ret);
@@ -367,10 +360,10 @@ function __wbg_get_imports() {
367360
imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
368361
const obj = getObject(arg1);
369362
const ret = typeof obj === "number" ? obj : void 0;
370-
getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
371-
getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
363+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
364+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
372365
};
373-
imports.wbg.__wbg_instanceof_Uint8Array_2b3bbecd033d19f6 = function(arg0) {
366+
imports.wbg.__wbg_instanceof_Uint8Array_247a91427532499e = function(arg0) {
374367
let result;
375368
try {
376369
result = getObject(arg0) instanceof Uint8Array;
@@ -380,7 +373,7 @@ function __wbg_get_imports() {
380373
const ret = result;
381374
return ret;
382375
};
383-
imports.wbg.__wbg_instanceof_ArrayBuffer_836825be07d4c9d2 = function(arg0) {
376+
imports.wbg.__wbg_instanceof_ArrayBuffer_61dfc3198373c902 = function(arg0) {
384377
let result;
385378
try {
386379
result = getObject(arg0) instanceof ArrayBuffer;
@@ -390,40 +383,43 @@ function __wbg_get_imports() {
390383
const ret = result;
391384
return ret;
392385
};
386+
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
387+
throw new Error(getStringFromWasm0(arg0, arg1));
388+
};
393389
imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
394390
const ret = debugString(getObject(arg1));
395391
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
396392
const len1 = WASM_VECTOR_LEN;
397-
getInt32Memory0()[arg0 / 4 + 1] = len1;
398-
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
399-
};
400-
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
401-
throw new Error(getStringFromWasm0(arg0, arg1));
393+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
394+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
402395
};
403396
return imports;
404397
}
405-
function __wbg_init_memory(imports, maybe_memory) {
398+
function __wbg_init_memory(imports, memory) {
406399
}
407400
function __wbg_finalize_init(instance, module2) {
408401
wasm = instance.exports;
409402
__wbg_init.__wbindgen_wasm_module = module2;
410-
cachedFloat64Memory0 = null;
411-
cachedInt32Memory0 = null;
412-
cachedUint8Memory0 = null;
403+
cachedDataViewMemory0 = null;
404+
cachedUint8ArrayMemory0 = null;
413405
return wasm;
414406
}
415-
async function __wbg_init(input) {
407+
async function __wbg_init(module_or_path) {
416408
if (wasm !== void 0)
417409
return wasm;
418-
if (typeof input === "undefined") {
419-
input = new URL("index_bg.wasm", void 0);
410+
if (typeof module_or_path !== "undefined" && Object.getPrototypeOf(module_or_path) === Object.prototype)
411+
({ module_or_path } = module_or_path);
412+
else
413+
console.warn("using deprecated parameters for the initialization function; pass a single object instead");
414+
if (typeof module_or_path === "undefined") {
415+
module_or_path = new URL("index_bg.wasm", void 0);
420416
}
421417
const imports = __wbg_get_imports();
422-
if (typeof input === "string" || typeof Request === "function" && input instanceof Request || typeof URL === "function" && input instanceof URL) {
423-
input = fetch(input);
418+
if (typeof module_or_path === "string" || typeof Request === "function" && module_or_path instanceof Request || typeof URL === "function" && module_or_path instanceof URL) {
419+
module_or_path = fetch(module_or_path);
424420
}
425421
__wbg_init_memory(imports);
426-
const { instance, module: module2 } = await __wbg_load(await input, imports);
422+
const { instance, module: module2 } = await __wbg_load(await module_or_path, imports);
427423
return __wbg_finalize_init(instance, module2);
428424
}
429425
var dist_default = __wbg_init;
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Please sign in to comment.