UNPKG

better-blockmap

Version:

Generate better blockmap files for electron-builder

178 lines (148 loc) 4.83 kB
let imports = {}; imports['__wbindgen_placeholder__'] = module.exports; let wasm; const { TextDecoder } = require(`util`); const heap = new Array(32).fill(undefined); heap.push(undefined, null, true, false); let heap_next = heap.length; function addHeapObject(obj) { if (heap_next === heap.length) heap.push(heap.length + 1); const idx = heap_next; heap_next = heap[idx]; heap[idx] = obj; return idx; } let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); cachedTextDecoder.decode(); let cachegetUint8Memory0 = null; function getUint8Memory0() { if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) { cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer); } return cachegetUint8Memory0; } function getStringFromWasm0(ptr, len) { return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); } function isLikeNone(x) { return x === undefined || x === null; } let WASM_VECTOR_LEN = 0; function passArray8ToWasm0(arg, malloc) { const ptr = malloc(arg.length * 1); getUint8Memory0().set(arg, ptr / 1); WASM_VECTOR_LEN = arg.length; return ptr; } let cachegetInt32Memory0 = null; function getInt32Memory0() { if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) { cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer); } return cachegetInt32Memory0; } let cachegetUint32Memory0 = null; function getUint32Memory0() { if (cachegetUint32Memory0 === null || cachegetUint32Memory0.buffer !== wasm.memory.buffer) { cachegetUint32Memory0 = new Uint32Array(wasm.memory.buffer); } return cachegetUint32Memory0; } function getObject(idx) { return heap[idx]; } function dropObject(idx) { if (idx < 36) return; heap[idx] = heap_next; heap_next = idx; } function takeObject(idx) { const ret = getObject(idx); dropObject(idx); return ret; } function getArrayJsValueFromWasm0(ptr, len) { 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; } /** */ class Chunker { static __wrap(ptr) { const obj = Object.create(Chunker.prototype); obj.ptr = ptr; return obj; } __destroy_into_raw() { const ptr = this.ptr; this.ptr = 0; return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm.__wbg_chunker_free(ptr); } /** * @param {boolean | undefined} detect_zip_boundary */ constructor(detect_zip_boundary) { var ret = wasm.chunker_new(isLikeNone(detect_zip_boundary) ? 0xFFFFFF : detect_zip_boundary ? 1 : 0); return Chunker.__wrap(ret); } /** * @param {Uint8Array} data * @returns {any[]} */ update(data) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); var ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); var len0 = WASM_VECTOR_LEN; wasm.chunker_update(retptr, this.ptr, ptr0, len0); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; var v1 = getArrayJsValueFromWasm0(r0, r1).slice(); wasm.__wbindgen_free(r0, r1 * 4); return v1; } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * @returns {any[]} */ finalize_reset() { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.chunker_finalize_reset(retptr, this.ptr); var r0 = getInt32Memory0()[retptr / 4 + 0]; var r1 = getInt32Memory0()[retptr / 4 + 1]; var v0 = getArrayJsValueFromWasm0(r0, r1).slice(); wasm.__wbindgen_free(r0, r1 * 4); return v0; } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } } module.exports.Chunker = Chunker; module.exports.__wbindgen_number_new = function(arg0) { var ret = arg0; return addHeapObject(ret); }; module.exports.__wbindgen_string_new = function(arg0, arg1) { var ret = getStringFromWasm0(arg0, arg1); return addHeapObject(ret); }; module.exports.__wbindgen_throw = function(arg0, arg1) { throw new Error(getStringFromWasm0(arg0, arg1)); }; const path = require('path').join(__dirname, 'better_blockmap_wasm_bg.wasm'); const bytes = require('fs').readFileSync(path); const wasmModule = new WebAssembly.Module(bytes); const wasmInstance = new WebAssembly.Instance(wasmModule, imports); wasm = wasmInstance.exports; module.exports.__wasm = wasm;