@ichaingo/web-worker 1.3.97 → 1.3.98

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.d.ts CHANGED
@@ -1,4 +1,8 @@
1
1
  import { default as React } from 'react';
2
+ export declare const enum WebWorkerEnv {
3
+ ALL_CHAIN_LATEST_BLOCK = "allChainLatestBlock",
4
+ CHAIN_LATEST_BLOCK = "chainLatestBlock"
5
+ }
2
6
  export default function WebWorkerProvider({ children }: {
3
7
  children: React.ReactNode;
4
8
  }): import("react/jsx-runtime").JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAyD,MAAM,OAAO,CAAC;AAO9E,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,2CA+BpF;AACD,wBAAgB,YAAY;YAnClB,MAAM,GAAG,IAAI;aACZ,GAAG,GAAG,IAAI;EAoCpB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAyD,MAAM,OAAO,CAAC;AAI9E,0BAAkB,YAAY;IAC5B,sBAAsB,wBAAwB;IAC9C,kBAAkB,qBAAqB;CACxC;AAKD,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,2CA+BpF;AACD,wBAAgB,YAAY;YAnClB,MAAM,GAAG,IAAI;aACZ,GAAG,GAAG,IAAI;EAoCpB"}
package/dist/index.js CHANGED
@@ -1,38 +1,40 @@
1
1
  'use client';
2
- import { jsx as p } from "react/jsx-runtime";
3
- import { createContext as k, useState as t, useEffect as f, useContext as i } from "react";
4
- import { logger as g } from "@ichaingo/logger";
5
- const a = k({ worker: null, message: null });
6
- function w({ children: n }) {
7
- const [u, l] = t(null), [c, m] = t(null);
8
- return f(() => {
9
- const e = new Worker(new URL(
2
+ import { jsx as k } from "react/jsx-runtime";
3
+ import { createContext as p, useState as a, useEffect as W, useContext as f } from "react";
4
+ import { logger as C } from "@ichaingo/logger";
5
+ var L = /* @__PURE__ */ ((e) => (e.ALL_CHAIN_LATEST_BLOCK = "allChainLatestBlock", e.CHAIN_LATEST_BLOCK = "chainLatestBlock", e))(L || {});
6
+ const n = p({ worker: null, message: null });
7
+ function E({ children: e }) {
8
+ const [l, u] = a(null), [c, m] = a(null);
9
+ return W(() => {
10
+ const r = new Worker(new URL(
10
11
  /* @vite-ignore */
11
12
  "./assets/webWorker-CvepzMkT.js",
12
13
  import.meta.url
13
14
  ), { type: "module" });
14
- return e.postMessage({ type: "INIT", data: { url: process.env.NEXT_PUBLIC_WS_URL, debug: !1 } }), e.onmessage = (r) => {
15
- const { type: s, data: W } = (r == null ? void 0 : r.data) || {};
15
+ return r.postMessage({ type: "INIT", data: { url: process.env.NEXT_PUBLIC_WS_URL, debug: !1 } }), r.onmessage = (o) => {
16
+ const { type: s, data: i } = (o == null ? void 0 : o.data) || {};
16
17
  if (s === "INIT_OK")
17
- l(e);
18
+ u(r);
18
19
  else if (s === "RECEIVE_MESSAGE")
19
20
  try {
20
- const o = JSON.parse(W);
21
- m(o);
22
- } catch (o) {
23
- g.error(o, "WebWorker", "parse message error");
21
+ const t = JSON.parse(i);
22
+ m(t);
23
+ } catch (t) {
24
+ C.error(t, "WebWorker", "parse message error");
24
25
  }
25
- }, e.onerror = (r) => {
26
- console.error("[WebWorker] onerror:", r);
26
+ }, r.onerror = (o) => {
27
+ console.error("[WebWorker] onerror:", o);
27
28
  }, () => {
28
- e.terminate();
29
+ r.terminate();
29
30
  };
30
- }, []), /* @__PURE__ */ p(a.Provider, { value: { worker: u, message: c }, children: n });
31
+ }, []), /* @__PURE__ */ k(n.Provider, { value: { worker: l, message: c }, children: e });
31
32
  }
32
- function C() {
33
- return i(a);
33
+ function I() {
34
+ return f(n);
34
35
  }
35
36
  export {
36
- w as default,
37
- C as useWebWorker
37
+ L as WebWorkerEnv,
38
+ E as default,
39
+ I as useWebWorker
38
40
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ichaingo/web-worker",
3
- "version": "1.3.97",
3
+ "version": "1.3.98",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -19,8 +19,8 @@
19
19
  }
20
20
  },
21
21
  "peerDependencies": {
22
- "@ichaingo/logger": "1.3.97",
23
- "@ichaingo/web-socket": "1.3.97"
22
+ "@ichaingo/web-socket": "1.3.98",
23
+ "@ichaingo/logger": "1.3.98"
24
24
  },
25
25
  "devDependencies": {
26
26
  "rollup-plugin-preserve-use-client": "^3.0.1"