From 8badc671a056575781ec98c2c66ef7b99d3242a2 Mon Sep 17 00:00:00 2001 From: Nicolas Schapeler Date: Thu, 18 Jan 2024 11:40:11 +0100 Subject: [PATCH] remove node 12 & 14 support --- .github/workflows/ci.yml | 2 +- build/browser.esm.js | 26 +++++++++++++++----------- package-lock.json | 7 +++++-- package.json | 5 ++++- 4 files changed, 25 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5430111..309f281 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: strategy: matrix: - node-version: [12.x, 14.x, 16.x, 18.x] + node-version: [16.x, 18.x] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: diff --git a/build/browser.esm.js b/build/browser.esm.js index 439dcfd..069852c 100644 --- a/build/browser.esm.js +++ b/build/browser.esm.js @@ -15552,20 +15552,24 @@ function thread(self) { }; } - async function init(data) { + function init(data){ const code = new Uint8Array(data.code); - const wasmModule = await WebAssembly.compile(code); - memory = new WebAssembly.Memory({initial:data.init, maximum: MAXMEM}); - - instance = await WebAssembly.instantiate(wasmModule, { - env: { - "memory": memory - } + const initPromise = new Promise((resolve, reject) => { + WebAssembly.compile(code).then(wasmModule => { + memory = new WebAssembly.Memory({initial:data.init, maximum: MAXMEM}); + WebAssembly.instantiate(wasmModule, { + env: { + "memory": memory + }, + }).then( inst => { + instance = inst; + resolve(inst); + }); + }).catch(err => reject(err)); }); + return initPromise; } - - function alloc(length) { const u32 = new Uint32Array(memory.buffer, 0, 1); while (u32[0] & 3) u32[0]++; // Return always aligned pointers @@ -15707,7 +15711,7 @@ function stringToBase64(str) { } } -const threadSource = stringToBase64("(" + "function thread(self) {\n const MAXMEM = 32767;\n let instance;\n let memory;\n\n if (self) {\n self.onmessage = function(e) {\n let data;\n if (e.data) {\n data = e.data;\n } else {\n data = e;\n }\n\n if (data[0].cmd == \"INIT\") {\n init(data[0]).then(function() {\n self.postMessage(data.result);\n });\n } else if (data[0].cmd == \"TERMINATE\") {\n self.close();\n } else {\n const res = runTask(data);\n self.postMessage(res);\n }\n };\n }\n\n async function init(data) {\n const code = new Uint8Array(data.code);\n const wasmModule = await WebAssembly.compile(code);\n memory = new WebAssembly.Memory({initial:data.init, maximum: MAXMEM});\n\n instance = await WebAssembly.instantiate(wasmModule, {\n env: {\n \"memory\": memory\n }\n });\n }\n\n\n\n function alloc(length) {\n const u32 = new Uint32Array(memory.buffer, 0, 1);\n while (u32[0] & 3) u32[0]++; // Return always aligned pointers\n const res = u32[0];\n u32[0] += length;\n if (u32[0] + length > memory.buffer.byteLength) {\n const currentPages = memory.buffer.byteLength / 0x10000;\n let requiredPages = Math.floor((u32[0] + length) / 0x10000)+1;\n if (requiredPages>MAXMEM) requiredPages=MAXMEM;\n memory.grow(requiredPages-currentPages);\n }\n return res;\n }\n\n function allocBuffer(buffer) {\n const p = alloc(buffer.byteLength);\n setBuffer(p, buffer);\n return p;\n }\n\n function getBuffer(pointer, length) {\n const u8 = new Uint8Array(memory.buffer);\n return new Uint8Array(u8.buffer, u8.byteOffset + pointer, length);\n }\n\n function setBuffer(pointer, buffer) {\n const u8 = new Uint8Array(memory.buffer);\n u8.set(new Uint8Array(buffer), pointer);\n }\n\n function runTask(task) {\n if (task[0].cmd == \"INIT\") {\n return init(task[0]);\n }\n const ctx = {\n vars: [],\n out: []\n };\n const u32a = new Uint32Array(memory.buffer, 0, 1);\n const oldAlloc = u32a[0];\n for (let i=0; i {\n WebAssembly.compile(code).then(wasmModule => {\n memory = new WebAssembly.Memory({initial:data.init, maximum: MAXMEM});\n WebAssembly.instantiate(wasmModule, {\n env: {\n \"memory\": memory\n },\n }).then( inst => {\n instance = inst;\n resolve(inst);\n });\n }).catch(err => reject(err));\n });\n return initPromise;\n }\n\n function alloc(length) {\n const u32 = new Uint32Array(memory.buffer, 0, 1);\n while (u32[0] & 3) u32[0]++; // Return always aligned pointers\n const res = u32[0];\n u32[0] += length;\n if (u32[0] + length > memory.buffer.byteLength) {\n const currentPages = memory.buffer.byteLength / 0x10000;\n let requiredPages = Math.floor((u32[0] + length) / 0x10000)+1;\n if (requiredPages>MAXMEM) requiredPages=MAXMEM;\n memory.grow(requiredPages-currentPages);\n }\n return res;\n }\n\n function allocBuffer(buffer) {\n const p = alloc(buffer.byteLength);\n setBuffer(p, buffer);\n return p;\n }\n\n function getBuffer(pointer, length) {\n const u8 = new Uint8Array(memory.buffer);\n return new Uint8Array(u8.buffer, u8.byteOffset + pointer, length);\n }\n\n function setBuffer(pointer, buffer) {\n const u8 = new Uint8Array(memory.buffer);\n u8.set(new Uint8Array(buffer), pointer);\n }\n\n function runTask(task) {\n if (task[0].cmd == \"INIT\") {\n return init(task[0]);\n }\n const ctx = {\n vars: [],\n out: []\n };\n const u32a = new Uint32Array(memory.buffer, 0, 1);\n const oldAlloc = u32a[0];\n for (let i=0; i=16.0.0" } }, "node_modules/@aashutoshrathi/word-wrap": { diff --git a/package.json b/package.json index 61b3edb..4e8640a 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,9 @@ "build:browser": "rollup -c rollup.browser.esm.config.js", "build": "npm run build:node && npm run build:browser" }, + "engines": { + "node": ">=16.0.0" + }, "repository": { "type": "git", "url": "https://github.com/elusiv-privacy/ffjavascript.git" @@ -53,4 +56,4 @@ "mocha": "^10.0.0", "rollup": "^3.29.4" } -} +} \ No newline at end of file