diff --git a/.npmignore b/.npmignore index f7794b2..bdabb4c 100644 --- a/.npmignore +++ b/.npmignore @@ -6,4 +6,7 @@ prettier* test/* scripts/* *.tgz -wasm/kzg.wasm \ No newline at end of file +wasm/kzg.wasm +src/trustedSetup.ts +dist/**/kzg.*.map +dist/**/kzg.*.ts \ No newline at end of file diff --git a/package.json b/package.json index 263c7e6..d1b0742 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "0.3.0", "description": "", "scripts": { - "build": "npm run build:ts && npm run transpileCJS && npm run fixRequire && npm run fixWasmDir", + "build": "npm run build:ts && npm run transpileCJS && npm run fixRequire", "build:ts": "scripts/ts-build.sh", "transpileCJS": "rm dist/cjs/kzg.js && babel src/kzg.js -d dist/cjs", "fixRequire": "sed -i.bak \"s/\\_require('url')/require('url')/g\" dist/cjs/kzg.js && rm dist/cjs/kzg.js.bak", diff --git a/src/kzg.js b/src/kzg.js index 563dfee..117ce7a 100644 --- a/src/kzg.js +++ b/src/kzg.js @@ -10,7 +10,7 @@ if(y){const {createRequire:a}=await import("module");var require=a(import.meta.u x)x?z=self.location.href:"undefined"!=typeof document&&document.currentScript&&(z=document.currentScript.src),_scriptDir&&(z=_scriptDir),z.startsWith("blob:")?z="":z=z.substr(0,z.replace(/[?#].*/,"").lastIndexOf("/")+1),A=a=>{var b=new XMLHttpRequest;b.open("GET",a,!1);b.send(null);return b.responseText},x&&(C=a=>{var b=new XMLHttpRequest;b.open("GET",a,!1);b.responseType="arraybuffer";b.send(null);return new Uint8Array(b.response)}),B=(a,b,d)=>{var e=new XMLHttpRequest;e.open("GET",a,!0);e.responseType= "arraybuffer";e.onload=()=>{200==e.status||0==e.status&&e.response?b(e.response):d()};e.onerror=d;e.send(null)};c.print||console.log.bind(console);var F=c.printErr||console.error.bind(console);Object.assign(c,u);u=null;var G;c.wasmBinary&&(G=c.wasmBinary);"object"!=typeof WebAssembly&&H("no native wasm support detected");var J,K=!1,L,M; function N(){var a=J.buffer;c.HEAP8=L=new Int8Array(a);c.HEAP16=new Int16Array(a);c.HEAPU8=M=new Uint8Array(a);c.HEAPU16=new Uint16Array(a);c.HEAP32=new Int32Array(a);c.HEAPU32=new Uint32Array(a);c.HEAPF32=new Float32Array(a);c.HEAPF64=new Float64Array(a)}var O=[],P=[],Q=[];function aa(){var a=c.preRun.shift();O.unshift(a)}var R=0,S=null,T=null;function H(a){c.onAbort?.(a);a="Aborted("+a+")";F(a);K=!0;a=new WebAssembly.RuntimeError(a+". Build with -sASSERTIONS for more info.");p(a);throw a;} -var ba=a=>a.startsWith("data:application/octet-stream;base64,"),E=a=>a.startsWith("file://"),U;if(c.locateFile){if(U="../wasm/../wasm/../wasm/../wasm/../wasm/kzg.wasm",!ba(U)){var ca=U;U=c.locateFile?c.locateFile(ca,z):z+ca}}else U=(new URL("../wasm/../wasm/../wasm/../wasm/../wasm/kzg.wasm",import.meta.url)).href;function da(a){if(a==U&&G)return new Uint8Array(G);if(C)return C(a);throw"both async and sync fetching of the wasm failed";} +var ba=a=>a.startsWith("data:application/octet-stream;base64,"),E=a=>a.startsWith("file://"),U;if(c.locateFile){if(U="../wasm/kzg.wasm",!ba(U)){var ca=U;U=c.locateFile?c.locateFile(ca,z):z+ca}}else U=(new URL("../wasm/kzg.wasm",import.meta.url)).href;function da(a){if(a==U&&G)return new Uint8Array(G);if(C)return C(a);throw"both async and sync fetching of the wasm failed";} function ea(a){if(!G&&(v||x)){if("function"==typeof fetch&&!E(a))return fetch(a,{credentials:"same-origin"}).then(b=>{if(!b.ok)throw`failed to load wasm binary file at '${a}'`;return b.arrayBuffer()}).catch(()=>da(a));if(B)return new Promise((b,d)=>{B(a,e=>b(new Uint8Array(e)),d)})}return Promise.resolve().then(()=>da(a))}function ha(a,b,d){return ea(a).then(e=>WebAssembly.instantiate(e,b)).then(e=>e).then(d,e=>{F(`failed to asynchronously prepare wasm: ${e}`);H(e)})} function ia(a,b){var d=U;return G||"function"!=typeof WebAssembly.instantiateStreaming||ba(d)||E(d)||y||"function"!=typeof fetch?ha(d,a,b):fetch(d,{credentials:"same-origin"}).then(e=>WebAssembly.instantiateStreaming(e,a).then(b,function(f){F(`wasm streaming compile failed: ${f}`);F("falling back to ArrayBuffer instantiation");return ha(d,a,b)}))} var V=a=>{for(;0{if(a){for(var b=M,d=a+NaN,e=a;b[e]&&!(e>=d);)++e;if(16f?d+=String.fromCharCode(f):(f-=65536,d+=String.fromCharCode(55296|f>>10,56320|f&1023))}}else d+=