|
| 1 | +let wasm; |
| 2 | +export function __wbg_set_wasm(val) { |
| 3 | + wasm = val; |
| 4 | +} |
| 5 | + |
| 6 | + |
| 7 | +const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder; |
| 8 | + |
| 9 | +let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true }); |
| 10 | + |
| 11 | +cachedTextDecoder.decode(); |
| 12 | + |
| 13 | +let cachedUint8Memory0 = null; |
| 14 | + |
| 15 | +function getUint8Memory0() { |
| 16 | + if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) { |
| 17 | + cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer); |
| 18 | + } |
| 19 | + return cachedUint8Memory0; |
| 20 | +} |
| 21 | + |
| 22 | +function getStringFromWasm0(ptr, len) { |
| 23 | + ptr = ptr >>> 0; |
| 24 | + return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); |
| 25 | +} |
| 26 | + |
| 27 | +function logError(f, args) { |
| 28 | + try { |
| 29 | + return f.apply(this, args); |
| 30 | + } catch (e) { |
| 31 | + let error = (function () { |
| 32 | + try { |
| 33 | + return e instanceof Error ? `${e.message}\n\nStack:\n${e.stack}` : e.toString(); |
| 34 | + } catch(_) { |
| 35 | + return "<failed to stringify thrown value>"; |
| 36 | + } |
| 37 | + }()); |
| 38 | + console.error("wasm-bindgen: imported JS function that was not marked as `catch` threw an error:", error); |
| 39 | + throw e; |
| 40 | + } |
| 41 | +} |
| 42 | + |
| 43 | +let WASM_VECTOR_LEN = 0; |
| 44 | + |
| 45 | +const lTextEncoder = typeof TextEncoder === 'undefined' ? (0, module.require)('util').TextEncoder : TextEncoder; |
| 46 | + |
| 47 | +let cachedTextEncoder = new lTextEncoder('utf-8'); |
| 48 | + |
| 49 | +const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' |
| 50 | + ? function (arg, view) { |
| 51 | + return cachedTextEncoder.encodeInto(arg, view); |
| 52 | +} |
| 53 | + : function (arg, view) { |
| 54 | + const buf = cachedTextEncoder.encode(arg); |
| 55 | + view.set(buf); |
| 56 | + return { |
| 57 | + read: arg.length, |
| 58 | + written: buf.length |
| 59 | + }; |
| 60 | +}); |
| 61 | + |
| 62 | +function passStringToWasm0(arg, malloc, realloc) { |
| 63 | + |
| 64 | + if (typeof(arg) !== 'string') throw new Error('expected a string argument'); |
| 65 | + |
| 66 | + if (realloc === undefined) { |
| 67 | + const buf = cachedTextEncoder.encode(arg); |
| 68 | + const ptr = malloc(buf.length, 1) >>> 0; |
| 69 | + getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); |
| 70 | + WASM_VECTOR_LEN = buf.length; |
| 71 | + return ptr; |
| 72 | + } |
| 73 | + |
| 74 | + let len = arg.length; |
| 75 | + let ptr = malloc(len, 1) >>> 0; |
| 76 | + |
| 77 | + const mem = getUint8Memory0(); |
| 78 | + |
| 79 | + let offset = 0; |
| 80 | + |
| 81 | + for (; offset < len; offset++) { |
| 82 | + const code = arg.charCodeAt(offset); |
| 83 | + if (code > 0x7F) break; |
| 84 | + mem[ptr + offset] = code; |
| 85 | + } |
| 86 | + |
| 87 | + if (offset !== len) { |
| 88 | + if (offset !== 0) { |
| 89 | + arg = arg.slice(offset); |
| 90 | + } |
| 91 | + ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0; |
| 92 | + const view = getUint8Memory0().subarray(ptr + offset, ptr + len); |
| 93 | + const ret = encodeString(arg, view); |
| 94 | + if (ret.read !== arg.length) throw new Error('failed to pass whole string'); |
| 95 | + offset += ret.written; |
| 96 | + } |
| 97 | + |
| 98 | + WASM_VECTOR_LEN = offset; |
| 99 | + return ptr; |
| 100 | +} |
| 101 | +/** |
| 102 | +* @param {string} name |
| 103 | +*/ |
| 104 | +export function greet(name) { |
| 105 | + const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); |
| 106 | + const len0 = WASM_VECTOR_LEN; |
| 107 | + wasm.greet(ptr0, len0); |
| 108 | +} |
| 109 | + |
| 110 | +export function __wbg_alert_9ea5a791b0d4c7a3() { return logError(function (arg0, arg1) { |
| 111 | + alert(getStringFromWasm0(arg0, arg1)); |
| 112 | +}, arguments) }; |
| 113 | + |
| 114 | +export function __wbindgen_throw(arg0, arg1) { |
| 115 | + throw new Error(getStringFromWasm0(arg0, arg1)); |
| 116 | +}; |
| 117 | + |
0 commit comments