fix: 120 type errors
All checks were successful
Deploy to GitHub Pages / build_site (push) Successful in 2m47s
All checks were successful
Deploy to GitHub Pages / build_site (push) Successful in 2m47s
This commit is contained in:
@@ -1,47 +1,84 @@
|
||||
|
||||
// https://github.com/6502/sha256/blob/main/sha256.js
|
||||
function sha256(data?: string | Uint8Array) {
|
||||
let h0 = 0x6a09e667, h1 = 0xbb67ae85, h2 = 0x3c6ef372, h3 = 0xa54ff53a,
|
||||
h4 = 0x510e527f, h5 = 0x9b05688c, h6 = 0x1f83d9ab, h7 = 0x5be0cd19,
|
||||
tsz = 0, bp = 0;
|
||||
const k = [0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
||||
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
||||
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
||||
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
||||
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
||||
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
||||
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
||||
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2],
|
||||
rrot = (x, n) => (x >>> n) | (x << (32 - n)),
|
||||
function sha256(data?: string | Int32Array) {
|
||||
let h0 = 0x6a09e667,
|
||||
h1 = 0xbb67ae85,
|
||||
h2 = 0x3c6ef372,
|
||||
h3 = 0xa54ff53a,
|
||||
h4 = 0x510e527f,
|
||||
h5 = 0x9b05688c,
|
||||
h6 = 0x1f83d9ab,
|
||||
h7 = 0x5be0cd19,
|
||||
tsz = 0,
|
||||
bp = 0;
|
||||
const k = [
|
||||
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1,
|
||||
0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
|
||||
0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786,
|
||||
0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
||||
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147,
|
||||
0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
|
||||
0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b,
|
||||
0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
||||
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a,
|
||||
0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
|
||||
0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
|
||||
],
|
||||
rrot = (x: number, n: number) => (x >>> n) | (x << (32 - n)),
|
||||
w = new Uint32Array(64),
|
||||
buf = new Uint8Array(64),
|
||||
process = () => {
|
||||
for (let j = 0, r = 0; j < 16; j++, r += 4) {
|
||||
w[j] = (buf[r] << 24) | (buf[r + 1] << 16) | (buf[r + 2] << 8) | buf[r + 3];
|
||||
w[j] =
|
||||
(buf[r] << 24) | (buf[r + 1] << 16) | (buf[r + 2] << 8) | buf[r + 3];
|
||||
}
|
||||
for (let j = 16; j < 64; j++) {
|
||||
let s0 = rrot(w[j - 15], 7) ^ rrot(w[j - 15], 18) ^ (w[j - 15] >>> 3);
|
||||
let s1 = rrot(w[j - 2], 17) ^ rrot(w[j - 2], 19) ^ (w[j - 2] >>> 10);
|
||||
w[j] = (w[j - 16] + s0 + w[j - 7] + s1) | 0;
|
||||
}
|
||||
let a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g = h6, h = h7;
|
||||
let a = h0,
|
||||
b = h1,
|
||||
c = h2,
|
||||
d = h3,
|
||||
e = h4,
|
||||
f = h5,
|
||||
g = h6,
|
||||
h = h7;
|
||||
for (let j = 0; j < 64; j++) {
|
||||
let S1 = rrot(e, 6) ^ rrot(e, 11) ^ rrot(e, 25),
|
||||
ch = (e & f) ^ ((~e) & g),
|
||||
ch = (e & f) ^ (~e & g),
|
||||
t1 = (h + S1 + ch + k[j] + w[j]) | 0,
|
||||
S0 = rrot(a, 2) ^ rrot(a, 13) ^ rrot(a, 22),
|
||||
maj = (a & b) ^ (a & c) ^ (b & c),
|
||||
t2 = (S0 + maj) | 0;
|
||||
h = g; g = f; f = e; e = (d + t1) | 0; d = c; c = b; b = a; a = (t1 + t2) | 0;
|
||||
h = g;
|
||||
g = f;
|
||||
f = e;
|
||||
e = (d + t1) | 0;
|
||||
d = c;
|
||||
c = b;
|
||||
b = a;
|
||||
a = (t1 + t2) | 0;
|
||||
}
|
||||
h0 = (h0 + a) | 0; h1 = (h1 + b) | 0; h2 = (h2 + c) | 0; h3 = (h3 + d) | 0;
|
||||
h4 = (h4 + e) | 0; h5 = (h5 + f) | 0; h6 = (h6 + g) | 0; h7 = (h7 + h) | 0;
|
||||
h0 = (h0 + a) | 0;
|
||||
h1 = (h1 + b) | 0;
|
||||
h2 = (h2 + c) | 0;
|
||||
h3 = (h3 + d) | 0;
|
||||
h4 = (h4 + e) | 0;
|
||||
h5 = (h5 + f) | 0;
|
||||
h6 = (h6 + g) | 0;
|
||||
h7 = (h7 + h) | 0;
|
||||
bp = 0;
|
||||
},
|
||||
add = data => {
|
||||
if (typeof data === "string") {
|
||||
data = typeof TextEncoder === "undefined" ? Buffer.from(data) : (new TextEncoder).encode(data);
|
||||
}
|
||||
add = (input: string | Int32Array) => {
|
||||
const data =
|
||||
typeof input === "string"
|
||||
? typeof TextEncoder === "undefined"
|
||||
? //@ts-ignore
|
||||
Buffer.from(input)
|
||||
: new TextEncoder().encode(input)
|
||||
: input;
|
||||
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
buf[bp++] = data[i];
|
||||
if (bp === 64) process();
|
||||
@@ -49,7 +86,8 @@ function sha256(data?: string | Uint8Array) {
|
||||
tsz += data.length;
|
||||
},
|
||||
digest = () => {
|
||||
buf[bp++] = 0x80; if (bp == 64) process();
|
||||
buf[bp++] = 0x80;
|
||||
if (bp == 64) process();
|
||||
if (bp + 8 > 64) {
|
||||
while (bp < 64) buf[bp++] = 0x00;
|
||||
process();
|
||||
@@ -57,24 +95,48 @@ function sha256(data?: string | Uint8Array) {
|
||||
while (bp < 58) buf[bp++] = 0x00;
|
||||
// Max number of bytes is 35,184,372,088,831
|
||||
let L = tsz * 8;
|
||||
buf[bp++] = (L / 1099511627776.) & 255;
|
||||
buf[bp++] = (L / 4294967296.) & 255;
|
||||
buf[bp++] = (L / 1099511627776) & 255;
|
||||
buf[bp++] = (L / 4294967296) & 255;
|
||||
buf[bp++] = L >>> 24;
|
||||
buf[bp++] = (L >>> 16) & 255;
|
||||
buf[bp++] = (L >>> 8) & 255;
|
||||
buf[bp++] = L & 255;
|
||||
process();
|
||||
let reply = new Uint8Array(32);
|
||||
reply[0] = h0 >>> 24; reply[1] = (h0 >>> 16) & 255; reply[2] = (h0 >>> 8) & 255; reply[3] = h0 & 255;
|
||||
reply[4] = h1 >>> 24; reply[5] = (h1 >>> 16) & 255; reply[6] = (h1 >>> 8) & 255; reply[7] = h1 & 255;
|
||||
reply[8] = h2 >>> 24; reply[9] = (h2 >>> 16) & 255; reply[10] = (h2 >>> 8) & 255; reply[11] = h2 & 255;
|
||||
reply[12] = h3 >>> 24; reply[13] = (h3 >>> 16) & 255; reply[14] = (h3 >>> 8) & 255; reply[15] = h3 & 255;
|
||||
reply[16] = h4 >>> 24; reply[17] = (h4 >>> 16) & 255; reply[18] = (h4 >>> 8) & 255; reply[19] = h4 & 255;
|
||||
reply[20] = h5 >>> 24; reply[21] = (h5 >>> 16) & 255; reply[22] = (h5 >>> 8) & 255; reply[23] = h5 & 255;
|
||||
reply[24] = h6 >>> 24; reply[25] = (h6 >>> 16) & 255; reply[26] = (h6 >>> 8) & 255; reply[27] = h6 & 255;
|
||||
reply[28] = h7 >>> 24; reply[29] = (h7 >>> 16) & 255; reply[30] = (h7 >>> 8) & 255; reply[31] = h7 & 255;
|
||||
reply[0] = h0 >>> 24;
|
||||
reply[1] = (h0 >>> 16) & 255;
|
||||
reply[2] = (h0 >>> 8) & 255;
|
||||
reply[3] = h0 & 255;
|
||||
reply[4] = h1 >>> 24;
|
||||
reply[5] = (h1 >>> 16) & 255;
|
||||
reply[6] = (h1 >>> 8) & 255;
|
||||
reply[7] = h1 & 255;
|
||||
reply[8] = h2 >>> 24;
|
||||
reply[9] = (h2 >>> 16) & 255;
|
||||
reply[10] = (h2 >>> 8) & 255;
|
||||
reply[11] = h2 & 255;
|
||||
reply[12] = h3 >>> 24;
|
||||
reply[13] = (h3 >>> 16) & 255;
|
||||
reply[14] = (h3 >>> 8) & 255;
|
||||
reply[15] = h3 & 255;
|
||||
reply[16] = h4 >>> 24;
|
||||
reply[17] = (h4 >>> 16) & 255;
|
||||
reply[18] = (h4 >>> 8) & 255;
|
||||
reply[19] = h4 & 255;
|
||||
reply[20] = h5 >>> 24;
|
||||
reply[21] = (h5 >>> 16) & 255;
|
||||
reply[22] = (h5 >>> 8) & 255;
|
||||
reply[23] = h5 & 255;
|
||||
reply[24] = h6 >>> 24;
|
||||
reply[25] = (h6 >>> 16) & 255;
|
||||
reply[26] = (h6 >>> 8) & 255;
|
||||
reply[27] = h6 & 255;
|
||||
reply[28] = h7 >>> 24;
|
||||
reply[29] = (h7 >>> 16) & 255;
|
||||
reply[30] = (h7 >>> 8) & 255;
|
||||
reply[31] = h7 & 255;
|
||||
let res = "";
|
||||
reply.forEach(x => res += ("0" + x.toString(16)).slice(-2));
|
||||
reply.forEach((x) => (res += ("0" + x.toString(16)).slice(-2)));
|
||||
return res;
|
||||
};
|
||||
|
||||
@@ -83,8 +145,8 @@ function sha256(data?: string | Uint8Array) {
|
||||
return { add, digest };
|
||||
}
|
||||
|
||||
export function fastHashArrayBuffer(buffer: ArrayBuffer): string {
|
||||
return sha256(new Uint8Array(buffer)).digest();
|
||||
export function fastHashArrayBuffer(buffer: string | Int32Array): string {
|
||||
return sha256(buffer).digest();
|
||||
}
|
||||
|
||||
// Shamelessly copied from
|
||||
@@ -101,22 +163,19 @@ export function fastHashString(input: string) {
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
||||
export function fastHash(input: (string | Int32Array | number)[]) {
|
||||
|
||||
const s = sha256();
|
||||
|
||||
for (let i = 0; i < input.length; i++) {
|
||||
const v = input[i]
|
||||
const v = input[i];
|
||||
if (typeof v === "string") {
|
||||
s.add(v);
|
||||
} else if (v instanceof Int32Array) {
|
||||
s.add(new Uint8Array(v.buffer));
|
||||
s.add(v);
|
||||
} else {
|
||||
s.add(v.toString());
|
||||
}
|
||||
}
|
||||
|
||||
return s.digest()
|
||||
|
||||
return s.digest();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
type SparseArray<T = number> = (T | T[] | SparseArray<T>)[];
|
||||
|
||||
export function concatEncodedArrays(input: (number | number[] | Int32Array)[]): Int32Array {
|
||||
|
||||
export function concatEncodedArrays(
|
||||
input: (number | number[] | Int32Array)[],
|
||||
): Int32Array {
|
||||
let totalLength = 4;
|
||||
for (let i = 0; i < input.length; i++) {
|
||||
const item = input[i];
|
||||
@@ -36,7 +37,7 @@ export function concatEncodedArrays(input: (number | number[] | Int32Array)[]):
|
||||
result[totalLength - 2] = 1;
|
||||
result[totalLength - 1] = 1;
|
||||
|
||||
return result
|
||||
return result;
|
||||
}
|
||||
|
||||
// Encodes a nested array into a flat array with bracket and distance notation
|
||||
@@ -68,12 +69,11 @@ export function encodeNestedArray(array: SparseArray): number[] {
|
||||
}
|
||||
|
||||
return [...encoded, 1, 1];
|
||||
};
|
||||
}
|
||||
|
||||
function decode_recursive(dense: number[] | Int32Array, index = 0) {
|
||||
|
||||
if (dense instanceof Int32Array) {
|
||||
dense = Array.from(dense)
|
||||
dense = Array.from(dense);
|
||||
}
|
||||
|
||||
const decoded: (number | number[])[] = [];
|
||||
@@ -82,12 +82,17 @@ function decode_recursive(dense: number[] | Int32Array, index = 0) {
|
||||
index += 2; // Skip the initial bracket notation
|
||||
while (index < dense.length) {
|
||||
if (index === nextBracketIndex) {
|
||||
if (dense[index] === 0) { // Opening bracket detected
|
||||
const [p, nextIndex, _nextBracketIndex] = decode_recursive(dense, index);
|
||||
decoded.push(p);
|
||||
if (dense[index] === 0) {
|
||||
// Opening bracket detected
|
||||
const [p, nextIndex, _nextBracketIndex] = decode_recursive(
|
||||
dense,
|
||||
index,
|
||||
);
|
||||
decoded.push(...p);
|
||||
index = nextIndex + 1;
|
||||
nextBracketIndex = _nextBracketIndex;
|
||||
} else { // Closing bracket detected
|
||||
} else {
|
||||
// Closing bracket detected
|
||||
nextBracketIndex = dense[index + 1] + index + 1;
|
||||
return [decoded, index, nextBracketIndex] as const;
|
||||
}
|
||||
@@ -103,7 +108,6 @@ export function decodeNestedArray(dense: number[] | Int32Array) {
|
||||
return decode_recursive(dense, 0)[0];
|
||||
}
|
||||
|
||||
|
||||
export function splitNestedArray(input: Int32Array) {
|
||||
let index = 0;
|
||||
const length = input.length;
|
||||
|
||||
@@ -1,21 +1,25 @@
|
||||
//@ts-nocheck
|
||||
import { NodeDefinition } from "@nodes/types";
|
||||
|
||||
const cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
||||
const cachedTextDecoder = new TextDecoder("utf-8", {
|
||||
ignoreBOM: true,
|
||||
fatal: true,
|
||||
});
|
||||
const cachedTextEncoder = new TextEncoder();
|
||||
|
||||
|
||||
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
||||
? function (arg, view) {
|
||||
return cachedTextEncoder.encodeInto(arg, view);
|
||||
}
|
||||
: function (arg, view) {
|
||||
const buf = cachedTextEncoder.encode(arg);
|
||||
view.set(buf);
|
||||
return {
|
||||
read: arg.length,
|
||||
written: buf.length
|
||||
};
|
||||
});
|
||||
const encodeString =
|
||||
typeof cachedTextEncoder.encodeInto === "function"
|
||||
? function (arg, view) {
|
||||
return cachedTextEncoder.encodeInto(arg, view);
|
||||
}
|
||||
: function (arg, view) {
|
||||
const buf = cachedTextEncoder.encode(arg);
|
||||
view.set(buf);
|
||||
return {
|
||||
read: arg.length,
|
||||
written: buf.length,
|
||||
};
|
||||
};
|
||||
|
||||
function createWrapper() {
|
||||
let wasm: any;
|
||||
@@ -53,7 +57,9 @@ function createWrapper() {
|
||||
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
||||
}
|
||||
|
||||
function getObject(idx: number) { return heap[idx]; }
|
||||
function getObject(idx: number) {
|
||||
return heap[idx];
|
||||
}
|
||||
|
||||
function addHeapObject(obj: any) {
|
||||
if (heap_next === heap.length) heap.push(heap.length + 1);
|
||||
@@ -63,9 +69,11 @@ function createWrapper() {
|
||||
return idx;
|
||||
}
|
||||
|
||||
|
||||
let WASM_VECTOR_LEN = 0;
|
||||
function passArray32ToWasm0(arg: ArrayLike<number>, malloc: (arg0: number, arg1: number) => number) {
|
||||
function passArray32ToWasm0(
|
||||
arg: ArrayLike<number>,
|
||||
malloc: (arg0: number, arg1: number) => number,
|
||||
) {
|
||||
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
||||
getUint32Memory0().set(arg, ptr / 4);
|
||||
WASM_VECTOR_LEN = arg.length;
|
||||
@@ -89,21 +97,10 @@ function createWrapper() {
|
||||
return ret;
|
||||
}
|
||||
|
||||
function getArrayJsValueFromWasm0(ptr: number, len: number) {
|
||||
ptr = ptr >>> 0;
|
||||
const mem = getUint32Memory0();
|
||||
const slice = mem.subarray(ptr / 4, ptr / 4 + len);
|
||||
const result = [];
|
||||
for (let i = 0; i < slice.length; i++) {
|
||||
result.push(takeObject(slice[i]));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function __wbindgen_string_new(arg0: number, arg1: number) {
|
||||
const ret = getStringFromWasm0(arg0, arg1);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
}
|
||||
|
||||
// Additional methods and their internal helpers can also be refactored in a similar manner.
|
||||
function get_definition() {
|
||||
@@ -124,7 +121,6 @@ function createWrapper() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function execute(args: Int32Array) {
|
||||
try {
|
||||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
||||
@@ -141,12 +137,19 @@ function createWrapper() {
|
||||
}
|
||||
}
|
||||
|
||||
function passStringToWasm0(arg: string, malloc: (arg0: any, arg1: number) => number, realloc: ((arg0: number, arg1: any, arg2: number, arg3: number) => number) | undefined) {
|
||||
|
||||
function passStringToWasm0(
|
||||
arg: string,
|
||||
malloc: (arg0: any, arg1: number) => number,
|
||||
realloc:
|
||||
| ((arg0: number, arg1: any, arg2: number, arg3: number) => number)
|
||||
| undefined,
|
||||
) {
|
||||
if (realloc === undefined) {
|
||||
const buf = cachedTextEncoder.encode(arg);
|
||||
const ptr = malloc(buf.length, 1) >>> 0;
|
||||
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
|
||||
getUint8Memory0()
|
||||
.subarray(ptr, ptr + buf.length)
|
||||
.set(buf);
|
||||
WASM_VECTOR_LEN = buf.length;
|
||||
return ptr;
|
||||
}
|
||||
@@ -160,7 +163,7 @@ function createWrapper() {
|
||||
|
||||
for (; offset < len; offset++) {
|
||||
const code = arg.charCodeAt(offset);
|
||||
if (code > 0x7F) break;
|
||||
if (code > 0x7f) break;
|
||||
mem[ptr + offset] = code;
|
||||
}
|
||||
|
||||
@@ -168,7 +171,7 @@ function createWrapper() {
|
||||
if (offset !== 0) {
|
||||
arg = arg.slice(offset);
|
||||
}
|
||||
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
||||
ptr = realloc(ptr, len, (len = offset + arg.length * 3), 1) >>> 0;
|
||||
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
|
||||
const ret = encodeString(arg, view);
|
||||
|
||||
@@ -183,15 +186,19 @@ function createWrapper() {
|
||||
function __wbg_new_abda76e883ba8a5f() {
|
||||
const ret = new Error();
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
}
|
||||
|
||||
function __wbg_stack_658279fe44541cf6(arg0, arg1) {
|
||||
const ret = getObject(arg1).stack;
|
||||
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
||||
const ptr1 = passStringToWasm0(
|
||||
ret,
|
||||
wasm.__wbindgen_malloc,
|
||||
wasm.__wbindgen_realloc,
|
||||
);
|
||||
const len1 = WASM_VECTOR_LEN;
|
||||
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
||||
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
||||
};
|
||||
}
|
||||
|
||||
function __wbg_error_f851667af71bcfc6(arg0, arg1) {
|
||||
let deferred0_0;
|
||||
@@ -203,27 +210,25 @@ function createWrapper() {
|
||||
} finally {
|
||||
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
function __wbindgen_object_drop_ref(arg0) {
|
||||
takeObject(arg0);
|
||||
};
|
||||
}
|
||||
|
||||
function __wbg_log_5bb5f88f245d7762(arg0) {
|
||||
console.log(getObject(arg0));
|
||||
};
|
||||
}
|
||||
|
||||
function __wbindgen_throw(arg0, arg1) {
|
||||
throw new Error(getStringFromWasm0(arg0, arg1));
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
setInstance(instance: WebAssembly.Instance) {
|
||||
wasm = instance.exports;
|
||||
},
|
||||
|
||||
|
||||
exports: {
|
||||
// Expose other methods that interact with the wasm instance
|
||||
execute,
|
||||
@@ -240,11 +245,12 @@ function createWrapper() {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
export function createWasmWrapper(wasmBuffer: ArrayBuffer) {
|
||||
export function createWasmWrapper(wasmBuffer: ArrayBuffer | Uint8Array) {
|
||||
const wrapper = createWrapper();
|
||||
const module = new WebAssembly.Module(wasmBuffer);
|
||||
const instance = new WebAssembly.Instance(module, { ["./index_bg.js"]: wrapper });
|
||||
const instance = new WebAssembly.Instance(module, {
|
||||
["./index_bg.js"]: wrapper,
|
||||
});
|
||||
wrapper.setInstance(instance);
|
||||
return wrapper.exports;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user