@invopop/gobl-worker 0.212.1 → 0.214.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/gobl-worker.js +11 -11
- package/dist/gobl-worker.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/gobl-worker.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const a = '(function(){"use strict";(()=>{const r=()=>{const
|
|
1
|
+
const a = '(function(){"use strict";(()=>{const r=()=>{const h=new Error("not implemented");return h.code="ENOSYS",h};if(!globalThis.fs){let h="";globalThis.fs={constants:{O_WRONLY:-1,O_RDWR:-1,O_CREAT:-1,O_TRUNC:-1,O_APPEND:-1,O_EXCL:-1,O_DIRECTORY:-1},writeSync(i,s){h+=g.decode(s);const n=h.lastIndexOf(`\n`);return n!=-1&&(console.log(h.substring(0,n)),h=h.substring(n+1)),s.length},write(i,s,n,a,f,c){if(n!==0||a!==s.length||f!==null){c(r());return}const y=this.writeSync(i,s);c(null,y)},chmod(i,s,n){n(r())},chown(i,s,n,a){a(r())},close(i,s){s(r())},fchmod(i,s,n){n(r())},fchown(i,s,n,a){a(r())},fstat(i,s){s(r())},fsync(i,s){s(null)},ftruncate(i,s,n){n(r())},lchown(i,s,n,a){a(r())},link(i,s,n){n(r())},lstat(i,s){s(r())},mkdir(i,s,n){n(r())},open(i,s,n,a){a(r())},read(i,s,n,a,f,c){c(r())},readdir(i,s){s(r())},readlink(i,s){s(r())},rename(i,s,n){n(r())},rmdir(i,s){s(r())},stat(i,s){s(r())},symlink(i,s,n){n(r())},truncate(i,s,n){n(r())},unlink(i,s){s(r())},utimes(i,s,n,a){a(r())}}}if(globalThis.process||(globalThis.process={getuid(){return-1},getgid(){return-1},geteuid(){return-1},getegid(){return-1},getgroups(){throw r()},pid:-1,ppid:-1,umask(){throw r()},cwd(){throw r()},chdir(){throw r()}}),globalThis.path||(globalThis.path={resolve(...h){return h.join("/")}}),!globalThis.crypto)throw new Error("globalThis.crypto is not available, polyfill required (crypto.getRandomValues only)");if(!globalThis.performance)throw new Error("globalThis.performance is not available, polyfill required (performance.now only)");if(!globalThis.TextEncoder)throw new Error("globalThis.TextEncoder is not available, polyfill required");if(!globalThis.TextDecoder)throw new Error("globalThis.TextDecoder is not available, polyfill required");const d=new TextEncoder("utf-8"),g=new TextDecoder("utf-8");globalThis.Go=class{constructor(){this.argv=["js"],this.env={},this.exit=t=>{t!==0&&console.warn("exit code:",t)},this._exitPromise=new Promise(t=>{this._resolveExitPromise=t}),this._pendingEvent=null,this._scheduledTimeouts=new Map,this._nextCallbackTimeoutID=1;const h=(t,e)=>{this.mem.setUint32(t+0,e,!0),this.mem.setUint32(t+4,Math.floor(e/4294967296),!0)},i=t=>{const e=this.mem.getUint32(t+0,!0),o=this.mem.getInt32(t+4,!0);return e+o*4294967296},s=t=>{const e=this.mem.getFloat64(t,!0);if(e===0)return;if(!isNaN(e))return e;const o=this.mem.getUint32(t,!0);return this._values[o]},n=(t,e)=>{if(typeof e=="number"&&e!==0){if(isNaN(e)){this.mem.setUint32(t+4,2146959360,!0),this.mem.setUint32(t,0,!0);return}this.mem.setFloat64(t,e,!0);return}if(e===void 0){this.mem.setFloat64(t,0,!0);return}let l=this._ids.get(e);l===void 0&&(l=this._idPool.pop(),l===void 0&&(l=this._values.length),this._values[l]=e,this._goRefCounts[l]=0,this._ids.set(e,l)),this._goRefCounts[l]++;let u=0;switch(typeof e){case"object":e!==null&&(u=1);break;case"string":u=2;break;case"symbol":u=3;break;case"function":u=4;break}this.mem.setUint32(t+4,2146959360|u,!0),this.mem.setUint32(t,l,!0)},a=t=>{const e=i(t+0),o=i(t+8);return new Uint8Array(this._inst.exports.mem.buffer,e,o)},f=t=>{const e=i(t+0),o=i(t+8),l=new Array(o);for(let u=0;u<o;u++)l[u]=s(e+u*8);return l},c=t=>{const e=i(t+0),o=i(t+8);return g.decode(new DataView(this._inst.exports.mem.buffer,e,o))},y=(t,e)=>(this._inst.exports.testExport0(),this._inst.exports.testExport(t,e)),m=Date.now()-performance.now();this.importObject={_gotest:{add:(t,e)=>t+e,callExport:y},gojs:{"runtime.wasmExit":t=>{t>>>=0;const e=this.mem.getInt32(t+8,!0);this.exited=!0,delete this._inst,delete this._values,delete this._goRefCounts,delete this._ids,delete this._idPool,this.exit(e)},"runtime.wasmWrite":t=>{t>>>=0;const e=i(t+8),o=i(t+16),l=this.mem.getInt32(t+24,!0);fs.writeSync(e,new Uint8Array(this._inst.exports.mem.buffer,o,l))},"runtime.resetMemoryDataView":t=>{this.mem=new DataView(this._inst.exports.mem.buffer)},"runtime.nanotime1":t=>{t>>>=0,h(t+8,(m+performance.now())*1e6)},"runtime.walltime":t=>{t>>>=0;const e=new Date().getTime();h(t+8,e/1e3),this.mem.setInt32(t+16,e%1e3*1e6,!0)},"runtime.scheduleTimeoutEvent":t=>{t>>>=0;const e=this._nextCallbackTimeoutID;this._nextCallbackTimeoutID++,this._scheduledTimeouts.set(e,setTimeout(()=>{for(this._resume();this._scheduledTimeouts.has(e);)console.warn("scheduleTimeoutEvent: missed timeout event"),this._resume()},i(t+8))),this.mem.setInt32(t+16,e,!0)},"runtime.clearTimeoutEvent":t=>{t>>>=0;const e=this.mem.getInt32(t+8,!0);clearTimeout(this._scheduledTimeouts.get(e)),this._scheduledTimeouts.delete(e)},"runtime.getRandomData":t=>{t>>>=0,crypto.getRandomValues(a(t+8))},"syscall/js.finalizeRef":t=>{t>>>=0;const e=this.mem.getUint32(t+8,!0);if(this._goRefCounts[e]--,this._goRefCounts[e]===0){const o=this._values[e];this._values[e]=null,this._ids.delete(o),this._idPool.push(e)}},"syscall/js.stringVal":t=>{t>>>=0,n(t+24,c(t+8))},"syscall/js.valueGet":t=>{t>>>=0;const e=Reflect.get(s(t+8),c(t+16));t=this._inst.exports.getsp()>>>0,n(t+32,e)},"syscall/js.valueSet":t=>{t>>>=0,Reflect.set(s(t+8),c(t+16),s(t+32))},"syscall/js.valueDelete":t=>{t>>>=0,Reflect.deleteProperty(s(t+8),c(t+16))},"syscall/js.valueIndex":t=>{t>>>=0,n(t+24,Reflect.get(s(t+8),i(t+16)))},"syscall/js.valueSetIndex":t=>{t>>>=0,Reflect.set(s(t+8),i(t+16),s(t+24))},"syscall/js.valueCall":t=>{t>>>=0;try{const e=s(t+8),o=Reflect.get(e,c(t+16)),l=f(t+32),u=Reflect.apply(o,e,l);t=this._inst.exports.getsp()>>>0,n(t+56,u),this.mem.setUint8(t+64,1)}catch(e){t=this._inst.exports.getsp()>>>0,n(t+56,e),this.mem.setUint8(t+64,0)}},"syscall/js.valueInvoke":t=>{t>>>=0;try{const e=s(t+8),o=f(t+16),l=Reflect.apply(e,void 0,o);t=this._inst.exports.getsp()>>>0,n(t+40,l),this.mem.setUint8(t+48,1)}catch(e){t=this._inst.exports.getsp()>>>0,n(t+40,e),this.mem.setUint8(t+48,0)}},"syscall/js.valueNew":t=>{t>>>=0;try{const e=s(t+8),o=f(t+16),l=Reflect.construct(e,o);t=this._inst.exports.getsp()>>>0,n(t+40,l),this.mem.setUint8(t+48,1)}catch(e){t=this._inst.exports.getsp()>>>0,n(t+40,e),this.mem.setUint8(t+48,0)}},"syscall/js.valueLength":t=>{t>>>=0,h(t+16,parseInt(s(t+8).length))},"syscall/js.valuePrepareString":t=>{t>>>=0;const e=d.encode(String(s(t+8)));n(t+16,e),h(t+24,e.length)},"syscall/js.valueLoadString":t=>{t>>>=0;const e=s(t+8);a(t+16).set(e)},"syscall/js.valueInstanceOf":t=>{t>>>=0,this.mem.setUint8(t+24,s(t+8)instanceof s(t+16)?1:0)},"syscall/js.copyBytesToGo":t=>{t>>>=0;const e=a(t+8),o=s(t+32);if(!(o instanceof Uint8Array||o instanceof Uint8ClampedArray)){this.mem.setUint8(t+48,0);return}const l=o.subarray(0,e.length);e.set(l),h(t+40,l.length),this.mem.setUint8(t+48,1)},"syscall/js.copyBytesToJS":t=>{t>>>=0;const e=s(t+8),o=a(t+16);if(!(e instanceof Uint8Array||e instanceof Uint8ClampedArray)){this.mem.setUint8(t+48,0);return}const l=o.subarray(0,e.length);e.set(l),h(t+40,l.length),this.mem.setUint8(t+48,1)},debug:t=>{console.log(t)}}}}async run(h){if(!(h instanceof WebAssembly.Instance))throw new Error("Go.run: WebAssembly.Instance expected");this._inst=h,this.mem=new DataView(this._inst.exports.mem.buffer),this._values=[NaN,0,null,!0,!1,globalThis,this],this._goRefCounts=new Array(this._values.length).fill(1/0),this._ids=new Map([[0,1],[null,2],[!0,3],[!1,4],[globalThis,5],[this,6]]),this._idPool=[],this.exited=!1;let i=4096;const s=m=>{const t=i,e=d.encode(m+"\\0");return new Uint8Array(this.mem.buffer,i,e.length).set(e),i+=e.length,i%8!==0&&(i+=8-i%8),t},n=this.argv.length,a=[];this.argv.forEach(m=>{a.push(s(m))}),a.push(0),Object.keys(this.env).sort().forEach(m=>{a.push(s(`${m}=${this.env[m]}`))}),a.push(0);const c=i;if(a.forEach(m=>{this.mem.setUint32(i,m,!0),this.mem.setUint32(i+4,0,!0),i+=8}),i>=12288)throw new Error("total length of command line and environment variables exceeds limit");this._inst.exports.run(n,c),this.exited&&this._resolveExitPromise(),await this._exitPromise}_resume(){if(this.exited)throw new Error("Go program has already exited");this._inst.exports.resume(),this.exited&&this._resolveExitPromise()}_makeFuncWrapper(h){const i=this;return function(){const s={id:h,this:this,args:arguments};return i._pendingEvent=s,i._resume(),s.result}}}})();const w="https://cdn.gobl.org/cli/gobl.0.214.0.wasm";WebAssembly.instantiateStreaming||(WebAssembly.instantiateStreaming=async(r,d)=>{const g=await(await r).arrayBuffer();return await WebAssembly.instantiate(g,d)});const _=new Go;WebAssembly.instantiateStreaming(fetch(w),_.importObject).then(r=>{_.run(r.instance)}).catch(r=>{console.error("Failed to run GOBL WASM instance: ",r)})})();\n', l = typeof self < "u" && self.Blob && new Blob([a], { type: "text/javascript;charset=utf-8" });
|
|
2
2
|
function u(t) {
|
|
3
3
|
let e;
|
|
4
4
|
try {
|
|
@@ -90,7 +90,7 @@ async function p({
|
|
|
90
90
|
indent: e
|
|
91
91
|
});
|
|
92
92
|
}
|
|
93
|
-
async function
|
|
93
|
+
async function _({
|
|
94
94
|
payload: t,
|
|
95
95
|
indent: e
|
|
96
96
|
}) {
|
|
@@ -100,7 +100,7 @@ async function w({
|
|
|
100
100
|
indent: e
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
|
-
async function
|
|
103
|
+
async function w({
|
|
104
104
|
payload: t,
|
|
105
105
|
indent: e
|
|
106
106
|
}) {
|
|
@@ -110,7 +110,7 @@ async function b({
|
|
|
110
110
|
indent: e
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
|
-
async function
|
|
113
|
+
async function b(t) {
|
|
114
114
|
return JSON.parse(
|
|
115
115
|
await s({
|
|
116
116
|
action: "keygen",
|
|
@@ -134,10 +134,10 @@ async function x({
|
|
|
134
134
|
indent: e
|
|
135
135
|
});
|
|
136
136
|
}
|
|
137
|
-
async function
|
|
137
|
+
async function T() {
|
|
138
138
|
return s({ action: "schemas" });
|
|
139
139
|
}
|
|
140
|
-
async function
|
|
140
|
+
async function U(t) {
|
|
141
141
|
return s({
|
|
142
142
|
action: "schema",
|
|
143
143
|
payload: { path: t }
|
|
@@ -164,15 +164,15 @@ function j(t) {
|
|
|
164
164
|
}
|
|
165
165
|
export {
|
|
166
166
|
d as build,
|
|
167
|
-
|
|
167
|
+
_ as correct,
|
|
168
168
|
j as isEnvelope,
|
|
169
|
-
|
|
169
|
+
b as keygen,
|
|
170
170
|
E as parseGOBLError,
|
|
171
171
|
v as ping,
|
|
172
172
|
R as regime,
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
173
|
+
w as replicate,
|
|
174
|
+
U as schema,
|
|
175
|
+
T as schemas,
|
|
176
176
|
g as sign,
|
|
177
177
|
x as sleep,
|
|
178
178
|
y as validate,
|
package/dist/gobl-worker.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(s,r){typeof exports=="object"&&typeof module<"u"?r(exports):typeof define=="function"&&define.amd?define(["exports"],r):(s=typeof globalThis<"u"?globalThis:s||self,r(s["gobl-worker"]={}))})(this,function(s){"use strict";const r='(function(){"use strict";(()=>{const r=()=>{const c=new Error("not implemented");return c.code="ENOSYS",c};if(!globalThis.fs){let c="";globalThis.fs={constants:{O_WRONLY:-1,O_RDWR:-1,O_CREAT:-1,O_TRUNC:-1,O_APPEND:-1,O_EXCL:-1},writeSync(i,s){c+=d.decode(s);const n=c.lastIndexOf(`\n`);return n!=-1&&(console.log(c.substring(0,n)),c=c.substring(n+1)),s.length},write(i,s,n,a,m,h){if(n!==0||a!==s.length||m!==null){h(r());return}const g=this.writeSync(i,s);h(null,g)},chmod(i,s,n){n(r())},chown(i,s,n,a){a(r())},close(i,s){s(r())},fchmod(i,s,n){n(r())},fchown(i,s,n,a){a(r())},fstat(i,s){s(r())},fsync(i,s){s(null)},ftruncate(i,s,n){n(r())},lchown(i,s,n,a){a(r())},link(i,s,n){n(r())},lstat(i,s){s(r())},mkdir(i,s,n){n(r())},open(i,s,n,a){a(r())},read(i,s,n,a,m,h){h(r())},readdir(i,s){s(r())},readlink(i,s){s(r())},rename(i,s,n){n(r())},rmdir(i,s){s(r())},stat(i,s){s(r())},symlink(i,s,n){n(r())},truncate(i,s,n){n(r())},unlink(i,s){s(r())},utimes(i,s,n,a){a(r())}}}if(globalThis.process||(globalThis.process={getuid(){return-1},getgid(){return-1},geteuid(){return-1},getegid(){return-1},getgroups(){throw r()},pid:-1,ppid:-1,umask(){throw r()},cwd(){throw r()},chdir(){throw r()}}),!globalThis.crypto)throw new Error("globalThis.crypto is not available, polyfill required (crypto.getRandomValues only)");if(!globalThis.performance)throw new Error("globalThis.performance is not available, polyfill required (performance.now only)");if(!globalThis.TextEncoder)throw new Error("globalThis.TextEncoder is not available, polyfill required");if(!globalThis.TextDecoder)throw new Error("globalThis.TextDecoder is not available, polyfill required");const f=new TextEncoder("utf-8"),d=new TextDecoder("utf-8");globalThis.Go=class{constructor(){this.argv=["js"],this.env={},this.exit=t=>{t!==0&&console.warn("exit code:",t)},this._exitPromise=new Promise(t=>{this._resolveExitPromise=t}),this._pendingEvent=null,this._scheduledTimeouts=new Map,this._nextCallbackTimeoutID=1;const c=(t,e)=>{this.mem.setUint32(t+0,e,!0),this.mem.setUint32(t+4,Math.floor(e/4294967296),!0)},i=t=>{const e=this.mem.getUint32(t+0,!0),o=this.mem.getInt32(t+4,!0);return e+o*4294967296},s=t=>{const e=this.mem.getFloat64(t,!0);if(e===0)return;if(!isNaN(e))return e;const o=this.mem.getUint32(t,!0);return this._values[o]},n=(t,e)=>{if(typeof e=="number"&&e!==0){if(isNaN(e)){this.mem.setUint32(t+4,2146959360,!0),this.mem.setUint32(t,0,!0);return}this.mem.setFloat64(t,e,!0);return}if(e===void 0){this.mem.setFloat64(t,0,!0);return}let l=this._ids.get(e);l===void 0&&(l=this._idPool.pop(),l===void 0&&(l=this._values.length),this._values[l]=e,this._goRefCounts[l]=0,this._ids.set(e,l)),this._goRefCounts[l]++;let u=0;switch(typeof e){case"object":e!==null&&(u=1);break;case"string":u=2;break;case"symbol":u=3;break;case"function":u=4;break}this.mem.setUint32(t+4,2146959360|u,!0),this.mem.setUint32(t,l,!0)},a=t=>{const e=i(t+0),o=i(t+8);return new Uint8Array(this._inst.exports.mem.buffer,e,o)},m=t=>{const e=i(t+0),o=i(t+8),l=new Array(o);for(let u=0;u<o;u++)l[u]=s(e+u*8);return l},h=t=>{const e=i(t+0),o=i(t+8);return d.decode(new DataView(this._inst.exports.mem.buffer,e,o))},g=Date.now()-performance.now();this.importObject={_gotest:{add:(t,e)=>t+e},gojs:{"runtime.wasmExit":t=>{t>>>=0;const e=this.mem.getInt32(t+8,!0);this.exited=!0,delete this._inst,delete this._values,delete this._goRefCounts,delete this._ids,delete this._idPool,this.exit(e)},"runtime.wasmWrite":t=>{t>>>=0;const e=i(t+8),o=i(t+16),l=this.mem.getInt32(t+24,!0);fs.writeSync(e,new Uint8Array(this._inst.exports.mem.buffer,o,l))},"runtime.resetMemoryDataView":t=>{this.mem=new DataView(this._inst.exports.mem.buffer)},"runtime.nanotime1":t=>{t>>>=0,c(t+8,(g+performance.now())*1e6)},"runtime.walltime":t=>{t>>>=0;const e=new Date().getTime();c(t+8,e/1e3),this.mem.setInt32(t+16,e%1e3*1e6,!0)},"runtime.scheduleTimeoutEvent":t=>{t>>>=0;const e=this._nextCallbackTimeoutID;this._nextCallbackTimeoutID++,this._scheduledTimeouts.set(e,setTimeout(()=>{for(this._resume();this._scheduledTimeouts.has(e);)console.warn("scheduleTimeoutEvent: missed timeout event"),this._resume()},i(t+8))),this.mem.setInt32(t+16,e,!0)},"runtime.clearTimeoutEvent":t=>{t>>>=0;const e=this.mem.getInt32(t+8,!0);clearTimeout(this._scheduledTimeouts.get(e)),this._scheduledTimeouts.delete(e)},"runtime.getRandomData":t=>{t>>>=0,crypto.getRandomValues(a(t+8))},"syscall/js.finalizeRef":t=>{t>>>=0;const e=this.mem.getUint32(t+8,!0);if(this._goRefCounts[e]--,this._goRefCounts[e]===0){const o=this._values[e];this._values[e]=null,this._ids.delete(o),this._idPool.push(e)}},"syscall/js.stringVal":t=>{t>>>=0,n(t+24,h(t+8))},"syscall/js.valueGet":t=>{t>>>=0;const e=Reflect.get(s(t+8),h(t+16));t=this._inst.exports.getsp()>>>0,n(t+32,e)},"syscall/js.valueSet":t=>{t>>>=0,Reflect.set(s(t+8),h(t+16),s(t+32))},"syscall/js.valueDelete":t=>{t>>>=0,Reflect.deleteProperty(s(t+8),h(t+16))},"syscall/js.valueIndex":t=>{t>>>=0,n(t+24,Reflect.get(s(t+8),i(t+16)))},"syscall/js.valueSetIndex":t=>{t>>>=0,Reflect.set(s(t+8),i(t+16),s(t+24))},"syscall/js.valueCall":t=>{t>>>=0;try{const e=s(t+8),o=Reflect.get(e,h(t+16)),l=m(t+32),u=Reflect.apply(o,e,l);t=this._inst.exports.getsp()>>>0,n(t+56,u),this.mem.setUint8(t+64,1)}catch(e){t=this._inst.exports.getsp()>>>0,n(t+56,e),this.mem.setUint8(t+64,0)}},"syscall/js.valueInvoke":t=>{t>>>=0;try{const e=s(t+8),o=m(t+16),l=Reflect.apply(e,void 0,o);t=this._inst.exports.getsp()>>>0,n(t+40,l),this.mem.setUint8(t+48,1)}catch(e){t=this._inst.exports.getsp()>>>0,n(t+40,e),this.mem.setUint8(t+48,0)}},"syscall/js.valueNew":t=>{t>>>=0;try{const e=s(t+8),o=m(t+16),l=Reflect.construct(e,o);t=this._inst.exports.getsp()>>>0,n(t+40,l),this.mem.setUint8(t+48,1)}catch(e){t=this._inst.exports.getsp()>>>0,n(t+40,e),this.mem.setUint8(t+48,0)}},"syscall/js.valueLength":t=>{t>>>=0,c(t+16,parseInt(s(t+8).length))},"syscall/js.valuePrepareString":t=>{t>>>=0;const e=f.encode(String(s(t+8)));n(t+16,e),c(t+24,e.length)},"syscall/js.valueLoadString":t=>{t>>>=0;const e=s(t+8);a(t+16).set(e)},"syscall/js.valueInstanceOf":t=>{t>>>=0,this.mem.setUint8(t+24,s(t+8)instanceof s(t+16)?1:0)},"syscall/js.copyBytesToGo":t=>{t>>>=0;const e=a(t+8),o=s(t+32);if(!(o instanceof Uint8Array||o instanceof Uint8ClampedArray)){this.mem.setUint8(t+48,0);return}const l=o.subarray(0,e.length);e.set(l),c(t+40,l.length),this.mem.setUint8(t+48,1)},"syscall/js.copyBytesToJS":t=>{t>>>=0;const e=s(t+8),o=a(t+16);if(!(e instanceof Uint8Array||e instanceof Uint8ClampedArray)){this.mem.setUint8(t+48,0);return}const l=o.subarray(0,e.length);e.set(l),c(t+40,l.length),this.mem.setUint8(t+48,1)},debug:t=>{console.log(t)}}}}async run(c){if(!(c instanceof WebAssembly.Instance))throw new Error("Go.run: WebAssembly.Instance expected");this._inst=c,this.mem=new DataView(this._inst.exports.mem.buffer),this._values=[NaN,0,null,!0,!1,globalThis,this],this._goRefCounts=new Array(this._values.length).fill(1/0),this._ids=new Map([[0,1],[null,2],[!0,3],[!1,4],[globalThis,5],[this,6]]),this._idPool=[],this.exited=!1;let i=4096;const s=t=>{const e=i,o=f.encode(t+"\\0");return new Uint8Array(this.mem.buffer,i,o.length).set(o),i+=o.length,i%8!==0&&(i+=8-i%8),e},n=this.argv.length,a=[];this.argv.forEach(t=>{a.push(s(t))}),a.push(0),Object.keys(this.env).sort().forEach(t=>{a.push(s(`${t}=${this.env[t]}`))}),a.push(0);const h=i;if(a.forEach(t=>{this.mem.setUint32(i,t,!0),this.mem.setUint32(i+4,0,!0),i+=8}),i>=12288)throw new Error("total length of command line and environment variables exceeds limit");this._inst.exports.run(n,h),this.exited&&this._resolveExitPromise(),await this._exitPromise}_resume(){if(this.exited)throw new Error("Go program has already exited");this._inst.exports.resume(),this.exited&&this._resolveExitPromise()}_makeFuncWrapper(c){const i=this;return function(){const s={id:c,this:this,args:arguments};return i._pendingEvent=s,i._resume(),s.result}}}})();const w="https://cdn.gobl.org/cli/gobl.0.212.1.wasm";WebAssembly.instantiateStreaming||(WebAssembly.instantiateStreaming=async(r,f)=>{const d=await(await r).arrayBuffer();return await WebAssembly.instantiate(d,f)});const y=new Go;WebAssembly.instantiateStreaming(fetch(w),y.importObject).then(r=>{y.run(r.instance)}).catch(r=>{console.error("Failed to run GOBL WASM instance: ",r)})})();\n',c=typeof self<"u"&&self.Blob&&new Blob([r],{type:"text/javascript;charset=utf-8"});function u(e){let t;try{if(t=c&&(self.URL||self.webkitURL).createObjectURL(c),!t)throw"";const i=new Worker(t,{name:e==null?void 0:e.name});return i.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),i}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(r),{name:e==null?void 0:e.name})}finally{t&&(self.URL||self.webkitURL).revokeObjectURL(t)}}const o=[],l={};let m=0,h=!1;const a=new u;a.onmessage=({data:e})=>{if("ready"in e){console.log("GOBLWorker is ready ..."),h=!0;for(let i=0;i<o.length;i++)a.postMessage(o[i]);return!0}const t=l[e.req_id];if(delete l[e.req_id],!t)return console.error(`Received response for an unregistered request (req_id: ${e.req_id}).`,{data:e}),!0;if(e.error)return console.error(e.error),t.reject(e.error),!0;t.resolve(e.payload)};async function n(e){e.req_id||(e.req_id=`req${++m}`);const t=new Promise((i,k)=>{l[e.req_id]={resolve:i,reject:k}});return h?(a.postMessage(e),t):(o.push(e),t)}async function f({payload:e,indent:t}){return n({action:"build",payload:e,indent:t})}async function d({payload:e,indent:t}){return n({action:"sign",payload:e,indent:t})}async function g({payload:e,indent:t}){return n({action:"validate",payload:e,indent:t})}async function y({payload:e,indent:t}){return n({action:"verify",payload:e,indent:t})}async function p({payload:e,indent:t}){return n({action:"correct",payload:e,indent:t})}async function w({payload:e,indent:t}){return n({action:"replicate",payload:e,indent:t})}async function b(e){return JSON.parse(await n({action:"keygen",indent:e==null?void 0:e.indent}))}async function _(e){return n({action:"ping",indent:e==null?void 0:e.indent})}async function v({duration:e,indent:t}){return n({action:"sleep",payload:e,indent:t})}async function T(){return n({action:"schemas"})}async function U(e){return n({action:"schema",payload:{path:e}})}async function R(e){return n({action:"regime",payload:{code:e}})}const x=/^code=(\d+), message=(.+)$/;function E(e){if(typeof e!="string")throw e;const t=e.match(x);return{message:t&&t[2]||e,code:t&&+t[1]||0}}function j(e){return e.$schema==="https://gobl.org/draft-0/envelope"}s.build=f,s.correct=p,s.isEnvelope=j,s.keygen=b,s.parseGOBLError=E,s.ping=_,s.regime=R,s.replicate=w,s.schema=U,s.schemas=T,s.sign=d,s.sleep=v,s.validate=g,s.verify=y,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(s,r){typeof exports=="object"&&typeof module<"u"?r(exports):typeof define=="function"&&define.amd?define(["exports"],r):(s=typeof globalThis<"u"?globalThis:s||self,r(s["gobl-worker"]={}))})(this,function(s){"use strict";const r='(function(){"use strict";(()=>{const r=()=>{const h=new Error("not implemented");return h.code="ENOSYS",h};if(!globalThis.fs){let h="";globalThis.fs={constants:{O_WRONLY:-1,O_RDWR:-1,O_CREAT:-1,O_TRUNC:-1,O_APPEND:-1,O_EXCL:-1,O_DIRECTORY:-1},writeSync(i,s){h+=g.decode(s);const n=h.lastIndexOf(`\n`);return n!=-1&&(console.log(h.substring(0,n)),h=h.substring(n+1)),s.length},write(i,s,n,a,f,c){if(n!==0||a!==s.length||f!==null){c(r());return}const y=this.writeSync(i,s);c(null,y)},chmod(i,s,n){n(r())},chown(i,s,n,a){a(r())},close(i,s){s(r())},fchmod(i,s,n){n(r())},fchown(i,s,n,a){a(r())},fstat(i,s){s(r())},fsync(i,s){s(null)},ftruncate(i,s,n){n(r())},lchown(i,s,n,a){a(r())},link(i,s,n){n(r())},lstat(i,s){s(r())},mkdir(i,s,n){n(r())},open(i,s,n,a){a(r())},read(i,s,n,a,f,c){c(r())},readdir(i,s){s(r())},readlink(i,s){s(r())},rename(i,s,n){n(r())},rmdir(i,s){s(r())},stat(i,s){s(r())},symlink(i,s,n){n(r())},truncate(i,s,n){n(r())},unlink(i,s){s(r())},utimes(i,s,n,a){a(r())}}}if(globalThis.process||(globalThis.process={getuid(){return-1},getgid(){return-1},geteuid(){return-1},getegid(){return-1},getgroups(){throw r()},pid:-1,ppid:-1,umask(){throw r()},cwd(){throw r()},chdir(){throw r()}}),globalThis.path||(globalThis.path={resolve(...h){return h.join("/")}}),!globalThis.crypto)throw new Error("globalThis.crypto is not available, polyfill required (crypto.getRandomValues only)");if(!globalThis.performance)throw new Error("globalThis.performance is not available, polyfill required (performance.now only)");if(!globalThis.TextEncoder)throw new Error("globalThis.TextEncoder is not available, polyfill required");if(!globalThis.TextDecoder)throw new Error("globalThis.TextDecoder is not available, polyfill required");const d=new TextEncoder("utf-8"),g=new TextDecoder("utf-8");globalThis.Go=class{constructor(){this.argv=["js"],this.env={},this.exit=t=>{t!==0&&console.warn("exit code:",t)},this._exitPromise=new Promise(t=>{this._resolveExitPromise=t}),this._pendingEvent=null,this._scheduledTimeouts=new Map,this._nextCallbackTimeoutID=1;const h=(t,e)=>{this.mem.setUint32(t+0,e,!0),this.mem.setUint32(t+4,Math.floor(e/4294967296),!0)},i=t=>{const e=this.mem.getUint32(t+0,!0),o=this.mem.getInt32(t+4,!0);return e+o*4294967296},s=t=>{const e=this.mem.getFloat64(t,!0);if(e===0)return;if(!isNaN(e))return e;const o=this.mem.getUint32(t,!0);return this._values[o]},n=(t,e)=>{if(typeof e=="number"&&e!==0){if(isNaN(e)){this.mem.setUint32(t+4,2146959360,!0),this.mem.setUint32(t,0,!0);return}this.mem.setFloat64(t,e,!0);return}if(e===void 0){this.mem.setFloat64(t,0,!0);return}let l=this._ids.get(e);l===void 0&&(l=this._idPool.pop(),l===void 0&&(l=this._values.length),this._values[l]=e,this._goRefCounts[l]=0,this._ids.set(e,l)),this._goRefCounts[l]++;let u=0;switch(typeof e){case"object":e!==null&&(u=1);break;case"string":u=2;break;case"symbol":u=3;break;case"function":u=4;break}this.mem.setUint32(t+4,2146959360|u,!0),this.mem.setUint32(t,l,!0)},a=t=>{const e=i(t+0),o=i(t+8);return new Uint8Array(this._inst.exports.mem.buffer,e,o)},f=t=>{const e=i(t+0),o=i(t+8),l=new Array(o);for(let u=0;u<o;u++)l[u]=s(e+u*8);return l},c=t=>{const e=i(t+0),o=i(t+8);return g.decode(new DataView(this._inst.exports.mem.buffer,e,o))},y=(t,e)=>(this._inst.exports.testExport0(),this._inst.exports.testExport(t,e)),m=Date.now()-performance.now();this.importObject={_gotest:{add:(t,e)=>t+e,callExport:y},gojs:{"runtime.wasmExit":t=>{t>>>=0;const e=this.mem.getInt32(t+8,!0);this.exited=!0,delete this._inst,delete this._values,delete this._goRefCounts,delete this._ids,delete this._idPool,this.exit(e)},"runtime.wasmWrite":t=>{t>>>=0;const e=i(t+8),o=i(t+16),l=this.mem.getInt32(t+24,!0);fs.writeSync(e,new Uint8Array(this._inst.exports.mem.buffer,o,l))},"runtime.resetMemoryDataView":t=>{this.mem=new DataView(this._inst.exports.mem.buffer)},"runtime.nanotime1":t=>{t>>>=0,h(t+8,(m+performance.now())*1e6)},"runtime.walltime":t=>{t>>>=0;const e=new Date().getTime();h(t+8,e/1e3),this.mem.setInt32(t+16,e%1e3*1e6,!0)},"runtime.scheduleTimeoutEvent":t=>{t>>>=0;const e=this._nextCallbackTimeoutID;this._nextCallbackTimeoutID++,this._scheduledTimeouts.set(e,setTimeout(()=>{for(this._resume();this._scheduledTimeouts.has(e);)console.warn("scheduleTimeoutEvent: missed timeout event"),this._resume()},i(t+8))),this.mem.setInt32(t+16,e,!0)},"runtime.clearTimeoutEvent":t=>{t>>>=0;const e=this.mem.getInt32(t+8,!0);clearTimeout(this._scheduledTimeouts.get(e)),this._scheduledTimeouts.delete(e)},"runtime.getRandomData":t=>{t>>>=0,crypto.getRandomValues(a(t+8))},"syscall/js.finalizeRef":t=>{t>>>=0;const e=this.mem.getUint32(t+8,!0);if(this._goRefCounts[e]--,this._goRefCounts[e]===0){const o=this._values[e];this._values[e]=null,this._ids.delete(o),this._idPool.push(e)}},"syscall/js.stringVal":t=>{t>>>=0,n(t+24,c(t+8))},"syscall/js.valueGet":t=>{t>>>=0;const e=Reflect.get(s(t+8),c(t+16));t=this._inst.exports.getsp()>>>0,n(t+32,e)},"syscall/js.valueSet":t=>{t>>>=0,Reflect.set(s(t+8),c(t+16),s(t+32))},"syscall/js.valueDelete":t=>{t>>>=0,Reflect.deleteProperty(s(t+8),c(t+16))},"syscall/js.valueIndex":t=>{t>>>=0,n(t+24,Reflect.get(s(t+8),i(t+16)))},"syscall/js.valueSetIndex":t=>{t>>>=0,Reflect.set(s(t+8),i(t+16),s(t+24))},"syscall/js.valueCall":t=>{t>>>=0;try{const e=s(t+8),o=Reflect.get(e,c(t+16)),l=f(t+32),u=Reflect.apply(o,e,l);t=this._inst.exports.getsp()>>>0,n(t+56,u),this.mem.setUint8(t+64,1)}catch(e){t=this._inst.exports.getsp()>>>0,n(t+56,e),this.mem.setUint8(t+64,0)}},"syscall/js.valueInvoke":t=>{t>>>=0;try{const e=s(t+8),o=f(t+16),l=Reflect.apply(e,void 0,o);t=this._inst.exports.getsp()>>>0,n(t+40,l),this.mem.setUint8(t+48,1)}catch(e){t=this._inst.exports.getsp()>>>0,n(t+40,e),this.mem.setUint8(t+48,0)}},"syscall/js.valueNew":t=>{t>>>=0;try{const e=s(t+8),o=f(t+16),l=Reflect.construct(e,o);t=this._inst.exports.getsp()>>>0,n(t+40,l),this.mem.setUint8(t+48,1)}catch(e){t=this._inst.exports.getsp()>>>0,n(t+40,e),this.mem.setUint8(t+48,0)}},"syscall/js.valueLength":t=>{t>>>=0,h(t+16,parseInt(s(t+8).length))},"syscall/js.valuePrepareString":t=>{t>>>=0;const e=d.encode(String(s(t+8)));n(t+16,e),h(t+24,e.length)},"syscall/js.valueLoadString":t=>{t>>>=0;const e=s(t+8);a(t+16).set(e)},"syscall/js.valueInstanceOf":t=>{t>>>=0,this.mem.setUint8(t+24,s(t+8)instanceof s(t+16)?1:0)},"syscall/js.copyBytesToGo":t=>{t>>>=0;const e=a(t+8),o=s(t+32);if(!(o instanceof Uint8Array||o instanceof Uint8ClampedArray)){this.mem.setUint8(t+48,0);return}const l=o.subarray(0,e.length);e.set(l),h(t+40,l.length),this.mem.setUint8(t+48,1)},"syscall/js.copyBytesToJS":t=>{t>>>=0;const e=s(t+8),o=a(t+16);if(!(e instanceof Uint8Array||e instanceof Uint8ClampedArray)){this.mem.setUint8(t+48,0);return}const l=o.subarray(0,e.length);e.set(l),h(t+40,l.length),this.mem.setUint8(t+48,1)},debug:t=>{console.log(t)}}}}async run(h){if(!(h instanceof WebAssembly.Instance))throw new Error("Go.run: WebAssembly.Instance expected");this._inst=h,this.mem=new DataView(this._inst.exports.mem.buffer),this._values=[NaN,0,null,!0,!1,globalThis,this],this._goRefCounts=new Array(this._values.length).fill(1/0),this._ids=new Map([[0,1],[null,2],[!0,3],[!1,4],[globalThis,5],[this,6]]),this._idPool=[],this.exited=!1;let i=4096;const s=m=>{const t=i,e=d.encode(m+"\\0");return new Uint8Array(this.mem.buffer,i,e.length).set(e),i+=e.length,i%8!==0&&(i+=8-i%8),t},n=this.argv.length,a=[];this.argv.forEach(m=>{a.push(s(m))}),a.push(0),Object.keys(this.env).sort().forEach(m=>{a.push(s(`${m}=${this.env[m]}`))}),a.push(0);const c=i;if(a.forEach(m=>{this.mem.setUint32(i,m,!0),this.mem.setUint32(i+4,0,!0),i+=8}),i>=12288)throw new Error("total length of command line and environment variables exceeds limit");this._inst.exports.run(n,c),this.exited&&this._resolveExitPromise(),await this._exitPromise}_resume(){if(this.exited)throw new Error("Go program has already exited");this._inst.exports.resume(),this.exited&&this._resolveExitPromise()}_makeFuncWrapper(h){const i=this;return function(){const s={id:h,this:this,args:arguments};return i._pendingEvent=s,i._resume(),s.result}}}})();const w="https://cdn.gobl.org/cli/gobl.0.214.0.wasm";WebAssembly.instantiateStreaming||(WebAssembly.instantiateStreaming=async(r,d)=>{const g=await(await r).arrayBuffer();return await WebAssembly.instantiate(g,d)});const _=new Go;WebAssembly.instantiateStreaming(fetch(w),_.importObject).then(r=>{_.run(r.instance)}).catch(r=>{console.error("Failed to run GOBL WASM instance: ",r)})})();\n',c=typeof self<"u"&&self.Blob&&new Blob([r],{type:"text/javascript;charset=utf-8"});function u(e){let t;try{if(t=c&&(self.URL||self.webkitURL).createObjectURL(c),!t)throw"";const i=new Worker(t,{name:e==null?void 0:e.name});return i.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),i}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(r),{name:e==null?void 0:e.name})}finally{t&&(self.URL||self.webkitURL).revokeObjectURL(t)}}const o=[],l={};let m=0,h=!1;const a=new u;a.onmessage=({data:e})=>{if("ready"in e){console.log("GOBLWorker is ready ..."),h=!0;for(let i=0;i<o.length;i++)a.postMessage(o[i]);return!0}const t=l[e.req_id];if(delete l[e.req_id],!t)return console.error(`Received response for an unregistered request (req_id: ${e.req_id}).`,{data:e}),!0;if(e.error)return console.error(e.error),t.reject(e.error),!0;t.resolve(e.payload)};async function n(e){e.req_id||(e.req_id=`req${++m}`);const t=new Promise((i,k)=>{l[e.req_id]={resolve:i,reject:k}});return h?(a.postMessage(e),t):(o.push(e),t)}async function f({payload:e,indent:t}){return n({action:"build",payload:e,indent:t})}async function d({payload:e,indent:t}){return n({action:"sign",payload:e,indent:t})}async function g({payload:e,indent:t}){return n({action:"validate",payload:e,indent:t})}async function y({payload:e,indent:t}){return n({action:"verify",payload:e,indent:t})}async function p({payload:e,indent:t}){return n({action:"correct",payload:e,indent:t})}async function b({payload:e,indent:t}){return n({action:"replicate",payload:e,indent:t})}async function w(e){return JSON.parse(await n({action:"keygen",indent:e==null?void 0:e.indent}))}async function _(e){return n({action:"ping",indent:e==null?void 0:e.indent})}async function v({duration:e,indent:t}){return n({action:"sleep",payload:e,indent:t})}async function T(){return n({action:"schemas"})}async function U(e){return n({action:"schema",payload:{path:e}})}async function x(e){return n({action:"regime",payload:{code:e}})}const R=/^code=(\d+), message=(.+)$/;function E(e){if(typeof e!="string")throw e;const t=e.match(R);return{message:t&&t[2]||e,code:t&&+t[1]||0}}function j(e){return e.$schema==="https://gobl.org/draft-0/envelope"}s.build=f,s.correct=p,s.isEnvelope=j,s.keygen=w,s.parseGOBLError=E,s.ping=_,s.regime=x,s.replicate=b,s.schema=U,s.schemas=T,s.sign=d,s.sleep=v,s.validate=g,s.verify=y,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
|