react-use-singleton-hook 1.0.12 → 1.0.13

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/README.md CHANGED
@@ -28,7 +28,4 @@ This assumes that you’re using [npm](http://npmjs.com/) package manager
28
28
 
29
29
  - ✅ Supports React 18.x and 19.x
30
30
  - ✅ Works with Concurrent Mode
31
- - ✅ Compatible with Server Components (client-side only)
32
- - ✅ Supports Strict Mode
33
- - ✅ TypeScript support included
34
- - ✅ Zero dependencies (peer dependency on React only)
31
+ - ✅ Compatible with Server Components (client-side only)
package/dist/main.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { singletonHook } from './singletonHook';
2
- export { singletonHook };
2
+ export { singletonHook as useSingletonGlobalState };
3
3
  declare const ReactSingletonHook: {
4
- singletonHook: typeof singletonHook;
4
+ useSingletonGlobalState: typeof singletonHook;
5
5
  };
6
6
  export default ReactSingletonHook;
package/dist/main.js CHANGED
@@ -2,14 +2,14 @@ import i, { useEffect as v } from "react";
2
2
  import { createRoot as E } from "react-dom/client";
3
3
  const g = (t) => {
4
4
  let e;
5
- const u = /* @__PURE__ */ new Set(), r = (o, s) => {
5
+ const u = /* @__PURE__ */ new Set(), c = (o, s) => {
6
6
  const n = typeof o == "function" ? o(e) : o;
7
7
  if (!Object.is(n, e)) {
8
8
  const m = e;
9
9
  e = s ?? (typeof n != "object" || n === null) ? n : Object.assign({}, e, n), u.forEach((b) => b(e, m));
10
10
  }
11
- }, a = () => e, c = { setState: r, getState: a, getInitialState: () => l, subscribe: (o) => (u.add(o), () => u.delete(o)) }, l = e = t(r, a, c);
12
- return c;
11
+ }, a = () => e, l = { setState: c, getState: a, getInitialState: () => r, subscribe: (o) => (u.add(o), () => u.delete(o)) }, r = e = t(c, a, l);
12
+ return l;
13
13
  }, h = ((t) => t ? g(t) : g), k = (t) => t;
14
14
  function C(t, e = k) {
15
15
  const u = i.useSyncExternalStore(
@@ -20,38 +20,38 @@ function C(t, e = k) {
20
20
  return i.useDebugValue(u), u;
21
21
  }
22
22
  function j(t, e, u = {}) {
23
- const { mountId: r, unmountIfNoConsumers: a = !0 } = u, f = typeof t == "function";
24
- let S = !f, c = f ? void 0 : t;
25
- const l = h(() => ({ value: c }));
23
+ const { mountId: c, unmountIfNoConsumers: a = !0 } = u, f = typeof t == "function";
24
+ let S = !f, l = f ? void 0 : t;
25
+ const r = h(() => ({ value: l }));
26
26
  let o = 0, s = null, n = null;
27
27
  function m() {
28
28
  const d = e();
29
29
  return v(() => {
30
- l.setState({ value: d });
30
+ r.setState({ value: d });
31
31
  }, [d]), null;
32
32
  }
33
33
  function b() {
34
- s || (n = document.createElement("div"), n.style.display = "none", r && (n.id = r), document.body.appendChild(n), s = E(n), s.render(i.createElement(m)));
34
+ s || (n = document.createElement("div"), n.style.display = "none", c && (n.id = c), document.body.appendChild(n), s = E(n), s.render(i.createElement(m)));
35
35
  }
36
36
  function I() {
37
37
  !s || !n || (s.unmount(), n.remove(), s = null, n = null);
38
38
  }
39
39
  function y() {
40
- !S && f && (S = !0, c = t(), l.setState({ value: c }));
40
+ !S && f && (S = !0, l = t(), r.setState({ value: l }));
41
41
  }
42
42
  function R() {
43
43
  y();
44
- const d = C(l, (p) => p.value);
44
+ const d = C(r, (p) => p.value);
45
45
  return v(() => (o += 1, o === 1 && b(), () => {
46
46
  o -= 1, o === 0 && a && I();
47
47
  }), []), d;
48
48
  }
49
49
  return R;
50
50
  }
51
- const N = {
52
- singletonHook: j
51
+ const G = {
52
+ useSingletonGlobalState: j
53
53
  };
54
54
  export {
55
- N as default,
56
- j as singletonHook
55
+ G as default,
56
+ j as useSingletonGlobalState
57
57
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-use-singleton-hook",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "type": "module",
5
5
  "main": "dist/main.js",
6
6
  "module": "dist/main.js",