@ichaingo/web-worker 1.4.97 → 1.4.99
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/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { createContext as
|
|
4
|
-
import { logger as
|
|
5
|
-
var
|
|
6
|
-
const n =
|
|
2
|
+
import { jsx as W } from "react/jsx-runtime";
|
|
3
|
+
import { createContext as k, useState as a, useEffect as p, useContext as f } from "react";
|
|
4
|
+
import { logger as L } from "@ichaingo/logger";
|
|
5
|
+
var _ = /* @__PURE__ */ ((e) => (e.ALL_CHAIN_LATEST_BLOCK = "allChainLatestBlock", e.CHAIN_LATEST_BLOCK = "chainLatestBlock", e))(_ || {});
|
|
6
|
+
const n = k({ worker: null, message: null });
|
|
7
7
|
function E({ children: e }) {
|
|
8
8
|
const [l, u] = a(null), [c, m] = a(null);
|
|
9
|
-
return
|
|
9
|
+
return p(() => {
|
|
10
10
|
const r = new Worker(new URL(
|
|
11
11
|
/* @vite-ignore */
|
|
12
|
-
"./assets/webWorker-
|
|
12
|
+
"./assets/webWorker-v_XNdBW-.js",
|
|
13
13
|
import.meta.url
|
|
14
14
|
), { type: "module" });
|
|
15
15
|
return r.postMessage({ type: "INIT", data: { url: process.env.NEXT_PUBLIC_WS_URL, debug: !1 } }), r.onmessage = (o) => {
|
|
@@ -21,20 +21,20 @@ function E({ children: e }) {
|
|
|
21
21
|
const t = JSON.parse(i);
|
|
22
22
|
m(t);
|
|
23
23
|
} catch (t) {
|
|
24
|
-
|
|
24
|
+
L.error(t, "WebWorker", "parse message error");
|
|
25
25
|
}
|
|
26
26
|
}, r.onerror = (o) => {
|
|
27
27
|
console.error("[WebWorker] onerror:", o);
|
|
28
28
|
}, () => {
|
|
29
29
|
r.terminate();
|
|
30
30
|
};
|
|
31
|
-
}, []), /* @__PURE__ */
|
|
31
|
+
}, []), /* @__PURE__ */ W(n.Provider, { value: { worker: l, message: c }, children: e });
|
|
32
32
|
}
|
|
33
33
|
function I() {
|
|
34
34
|
return f(n);
|
|
35
35
|
}
|
|
36
36
|
export {
|
|
37
|
-
|
|
37
|
+
_ as WebWorkerEnv,
|
|
38
38
|
E as default,
|
|
39
39
|
I as useWebWorker
|
|
40
40
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ichaingo/web-worker",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.99",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"!**/*.tsbuildinfo"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@ichaingo/
|
|
30
|
-
"@ichaingo/
|
|
29
|
+
"@ichaingo/web-socket": "1.4.99",
|
|
30
|
+
"@ichaingo/logger": "1.4.99"
|
|
31
31
|
}
|
|
32
32
|
}
|