@sabaaa1/common 0.1.2 → 0.1.3
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/assets/{snarkjsWorkerLauncher-CTJxY_k6.js → snarkjsWorkerLauncher-B7rmy0gx.js} +1 -1
- package/assets/{snarkjsWorkerLogic-BTc2hrlU.js → snarkjsWorkerLogic-C3GGRlcw.js} +412 -390
- package/assets/{utxoWorkerLauncher-B6d6svhO.js → utxoWorkerLauncher-BP1uNzSU.js} +1 -1
- package/assets/{utxoWorkerLogic-YPywVy-e.js → utxoWorkerLogic-KxVg3qs6.js} +1625 -1603
- package/assets/{zkProofWorkerLauncher-CCedBtfh.js → zkProofWorkerLauncher-D-WqUrAW.js} +1 -1
- package/assets/{zkProofWorkerLogic-B_sgmDOg.js → zkProofWorkerLogic-CenLarOM.js} +1607 -1585
- package/package.json +1 -1
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.cjs +1 -1
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.mjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLauncher.cjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLauncher.mjs +1 -1
- package/webworker/workerProxy.cjs +1 -1
- package/webworker/workerProxy.d.ts +2 -0
- package/webworker/workerProxy.mjs +34 -12
- package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const r=""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/../../assets/snarkjsWorkerLauncher-B7rmy0gx.js").href:new URL("../../assets/snarkjsWorkerLauncher-B7rmy0gx.js",document.currentScript&&document.currentScript.src||document.baseURI).href);module.exports=r;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/../../assets/utxoWorkerLauncher-
|
|
1
|
+
"use strict";const e=""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/../../assets/utxoWorkerLauncher-BP1uNzSU.js").href:new URL("../../assets/utxoWorkerLauncher-BP1uNzSU.js",document.currentScript&&document.currentScript.src||document.baseURI).href);module.exports=e;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class o{isNode=!1;isSandbox=!1;errorCount=0;MAX_ERRORS=5;onmessage=null;onerror=null;_eventEmitter;get eventEmitter(){if(this._eventEmitter)return this._eventEmitter;if(this.isNode){const e=require("events");this._eventEmitter=new e}else this._eventEmitter=new EventTarget;return this._eventEmitter}constructor(){this.isNode=typeof process<"u"&&process.versions!=null&&process.versions.node!=null,this.isSandbox=typeof window<"u"&&window.origin==="null"}terminate(){}postMessage(e){this.isNode?this.eventEmitter.emit("message",e):this.isSandbox?this.eventEmitter?.dispatchEvent(new CustomEvent("worker-message",{detail:e})):postMessage(e)}postMessageToMainThread(e){const s={data:e};if(this.onmessage){this.onmessage(s);return}const t=typeof self<"u"?self:globalThis;t.postMessage&&t.postMessage(e)}postErrorToMainThread(e){if(this.errorCount++,this.errorCount>this.MAX_ERRORS){console.error("Too many errors, stopping error reporting"),typeof self<"u"&&self.close&&self.close();return}const s={data:{error:e}};if(this.onerror){try{this.onerror(s)}catch(r){console.error("Error in onerror handler:",r)}return}const t={error:!0,message:e instanceof Error?e.message:String(e),stack:e instanceof Error?e.stack:void 0};try{const r=typeof self<"u"?self:globalThis;r.postMessage&&r.postMessage(t)}catch(r){console.error("Failed to post error:",r)}}attachWorkerSideOnMessage(e){if(this.isNode){this.eventEmitter.on("message",t=>{e(t)});return}if(this.isSandbox){this.eventEmitter.addEventListener("worker-message",t=>{e(t.detail)});return}const s=typeof self<"u"?self:globalThis;s.addEventListener&&s.addEventListener("message",t=>{if(this.errorCount=0,!t||!t.data){console.warn("Worker received invalid message:",t);return}try{e(t.data)}catch(r){console.error("Error in message handler:",r),this.postErrorToMainThread(r)}})}}exports.WorkerProxy=o;
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
export declare class WorkerProxy {
|
|
12
12
|
private isNode;
|
|
13
13
|
private isSandbox;
|
|
14
|
+
private errorCount;
|
|
15
|
+
private readonly MAX_ERRORS;
|
|
14
16
|
/**
|
|
15
17
|
* This allow browser or main thread to listen for worker response message
|
|
16
18
|
* using the normal `worker.onmessage = () => {}` syntax. Is should only be side on the
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
class
|
|
1
|
+
class n {
|
|
2
2
|
isNode = !1;
|
|
3
3
|
isSandbox = !1;
|
|
4
|
+
errorCount = 0;
|
|
5
|
+
MAX_ERRORS = 5;
|
|
4
6
|
/**
|
|
5
7
|
* This allow browser or main thread to listen for worker response message
|
|
6
8
|
* using the normal `worker.onmessage = () => {}` syntax. Is should only be side on the
|
|
@@ -34,26 +36,39 @@ class o {
|
|
|
34
36
|
this.isNode ? this.eventEmitter.emit("message", e) : this.isSandbox ? this.eventEmitter?.dispatchEvent(new CustomEvent("worker-message", { detail: e })) : postMessage(e);
|
|
35
37
|
}
|
|
36
38
|
postMessageToMainThread(e) {
|
|
37
|
-
const
|
|
39
|
+
const r = { data: e };
|
|
38
40
|
if (this.onmessage) {
|
|
39
|
-
this.onmessage(
|
|
41
|
+
this.onmessage(r);
|
|
40
42
|
return;
|
|
41
43
|
}
|
|
42
44
|
const t = typeof self < "u" ? self : globalThis;
|
|
43
45
|
t.postMessage && t.postMessage(e);
|
|
44
46
|
}
|
|
45
47
|
postErrorToMainThread(e) {
|
|
46
|
-
|
|
48
|
+
if (this.errorCount++, this.errorCount > this.MAX_ERRORS) {
|
|
49
|
+
console.error("Too many errors, stopping error reporting"), typeof self < "u" && self.close && self.close();
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const r = { data: { error: e } };
|
|
47
53
|
if (this.onerror) {
|
|
48
|
-
|
|
54
|
+
try {
|
|
55
|
+
this.onerror(r);
|
|
56
|
+
} catch (s) {
|
|
57
|
+
console.error("Error in onerror handler:", s);
|
|
58
|
+
}
|
|
49
59
|
return;
|
|
50
60
|
}
|
|
51
61
|
const t = {
|
|
52
62
|
error: !0,
|
|
53
63
|
message: e instanceof Error ? e.message : String(e),
|
|
54
64
|
stack: e instanceof Error ? e.stack : void 0
|
|
55
|
-
}
|
|
56
|
-
|
|
65
|
+
};
|
|
66
|
+
try {
|
|
67
|
+
const s = typeof self < "u" ? self : globalThis;
|
|
68
|
+
s.postMessage && s.postMessage(t);
|
|
69
|
+
} catch (s) {
|
|
70
|
+
console.error("Failed to post error:", s);
|
|
71
|
+
}
|
|
57
72
|
}
|
|
58
73
|
attachWorkerSideOnMessage(e) {
|
|
59
74
|
if (this.isNode) {
|
|
@@ -68,13 +83,20 @@ class o {
|
|
|
68
83
|
});
|
|
69
84
|
return;
|
|
70
85
|
}
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
86
|
+
const r = typeof self < "u" ? self : globalThis;
|
|
87
|
+
r.addEventListener && r.addEventListener("message", (t) => {
|
|
88
|
+
if (this.errorCount = 0, !t || !t.data) {
|
|
89
|
+
console.warn("Worker received invalid message:", t);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
e(t.data);
|
|
94
|
+
} catch (s) {
|
|
95
|
+
console.error("Error in message handler:", s), this.postErrorToMainThread(s);
|
|
96
|
+
}
|
|
75
97
|
});
|
|
76
98
|
}
|
|
77
99
|
}
|
|
78
100
|
export {
|
|
79
|
-
|
|
101
|
+
n as WorkerProxy
|
|
80
102
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const r=""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/../../assets/zkProofWorkerLauncher-D-WqUrAW.js").href:new URL("../../assets/zkProofWorkerLauncher-D-WqUrAW.js",document.currentScript&&document.currentScript.src||document.baseURI).href);module.exports=r;
|