@ichaingo/web-worker 1.3.96 → 1.3.97

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.
Files changed (2) hide show
  1. package/dist/index.js +15 -15
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -1,24 +1,24 @@
1
1
  'use client';
2
- import { jsx as W } from "react/jsx-runtime";
3
- import { createContext as f, useState as s, useEffect as i, useContext as k } from "react";
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
4
  import { logger as g } from "@ichaingo/logger";
5
- const a = f({ worker: null, message: null });
6
- function E({ children: n }) {
7
- const [u, l] = s(null), [m, c] = s(null);
8
- return i(() => {
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
9
  const e = new Worker(new URL(
10
10
  /* @vite-ignore */
11
- "" + new URL("assets/webWorker-CvepzMkT.js", import.meta.url).href,
11
+ "./assets/webWorker-CvepzMkT.js",
12
12
  import.meta.url
13
13
  ), { type: "module" });
14
14
  return e.postMessage({ type: "INIT", data: { url: process.env.NEXT_PUBLIC_WS_URL, debug: !1 } }), e.onmessage = (r) => {
15
- const { type: t, data: p } = (r == null ? void 0 : r.data) || {};
16
- if (t === "INIT_OK")
15
+ const { type: s, data: W } = (r == null ? void 0 : r.data) || {};
16
+ if (s === "INIT_OK")
17
17
  l(e);
18
- else if (t === "RECEIVE_MESSAGE")
18
+ else if (s === "RECEIVE_MESSAGE")
19
19
  try {
20
- const o = JSON.parse(p);
21
- c(o);
20
+ const o = JSON.parse(W);
21
+ m(o);
22
22
  } catch (o) {
23
23
  g.error(o, "WebWorker", "parse message error");
24
24
  }
@@ -27,12 +27,12 @@ function E({ children: n }) {
27
27
  }, () => {
28
28
  e.terminate();
29
29
  };
30
- }, []), /* @__PURE__ */ W(a.Provider, { value: { worker: u, message: m }, children: n });
30
+ }, []), /* @__PURE__ */ p(a.Provider, { value: { worker: u, message: c }, children: n });
31
31
  }
32
32
  function C() {
33
- return k(a);
33
+ return i(a);
34
34
  }
35
35
  export {
36
- E as default,
36
+ w as default,
37
37
  C as useWebWorker
38
38
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ichaingo/web-worker",
3
- "version": "1.3.96",
3
+ "version": "1.3.97",
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/web-socket": "1.3.96",
23
- "@ichaingo/logger": "1.3.96"
22
+ "@ichaingo/logger": "1.3.97",
23
+ "@ichaingo/web-socket": "1.3.97"
24
24
  },
25
25
  "devDependencies": {
26
26
  "rollup-plugin-preserve-use-client": "^3.0.1"