@ptolemy2002/react-proxy-context 2.1.0 → 2.1.1

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
@@ -100,7 +100,6 @@ A hook that uses the context provided by the `ProxyContextProvider` component. T
100
100
  These should be installed in order to use the library, as npm does not automatically add peer dependencies to your project.
101
101
  - `react^18.3.1`
102
102
  - `react-dom^18.3.1`
103
- - `@ptolemy2002/js-utils^3.0.2`
104
103
  - `@ptolemy2002/react-utils^3.0.0`
105
104
  - `@ptolemy2002/react-force-rerender^2.0.0`
106
105
  - `@ptolemy2002/react-hook-result^2.1.1`
package/dist/main.d.ts CHANGED
@@ -21,7 +21,7 @@ export type ProxyContextProviderProps<T> = {
21
21
  onChangeReinit?: OnChangeReinitCallback<T>;
22
22
  proxyRef?: React.MutableRefObject<T>;
23
23
  };
24
- export declare function createProxyContextProvider<T extends object>(contextClass: ProxyContext<T>): import('react').MemoExoticComponent<import('react').FunctionComponent<ProxyContextProviderProps<T> & {
24
+ export declare function createProxyContextProvider<T extends object | null>(contextClass: ProxyContext<T>): import('react').MemoExoticComponent<import('react').FunctionComponent<ProxyContextProviderProps<T> & {
25
25
  renderDeps?: any[];
26
26
  }>>;
27
27
  export type UseProxyContextResult<T> = HookResultData<{
package/dist/main.js CHANGED
@@ -2,9 +2,8 @@ import Ie, { useEffect as $e, createContext as br, useRef as X, useImperativeHan
2
2
  import { nanoid as Rr } from "nanoid";
3
3
  import M from "is-callable";
4
4
  import We from "@ptolemy2002/react-force-rerender";
5
- import { isNullOrUndefined as gr } from "@ptolemy2002/js-utils";
6
- import hr from "@ptolemy2002/react-hook-result";
7
- import { partialMemo as Er } from "@ptolemy2002/react-utils";
5
+ import gr from "@ptolemy2002/react-hook-result";
6
+ import { partialMemo as hr } from "@ptolemy2002/react-utils";
8
7
  var se = { exports: {} }, B = {};
9
8
  /**
10
9
  * @license React
@@ -16,7 +15,7 @@ var se = { exports: {} }, B = {};
16
15
  * LICENSE file in the root directory of this source tree.
17
16
  */
18
17
  var Fe;
19
- function _r() {
18
+ function Er() {
20
19
  if (Fe) return B;
21
20
  Fe = 1;
22
21
  var b = Ie, _ = Symbol.for("react.element"), k = Symbol.for("react.fragment"), T = Object.prototype.hasOwnProperty, C = b.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: !0, ref: !0, __self: !0, __source: !0 };
@@ -40,7 +39,7 @@ var J = {};
40
39
  * LICENSE file in the root directory of this source tree.
41
40
  */
42
41
  var Ae;
43
- function Tr() {
42
+ function _r() {
44
43
  return Ae || (Ae = 1, process.env.NODE_ENV !== "production" && function() {
45
44
  var b = Ie, _ = Symbol.for("react.element"), k = Symbol.for("react.portal"), T = Symbol.for("react.fragment"), C = Symbol.for("react.strict_mode"), p = Symbol.for("react.profiler"), S = Symbol.for("react.provider"), y = Symbol.for("react.context"), o = Symbol.for("react.forward_ref"), d = Symbol.for("react.suspense"), v = Symbol.for("react.suspense_list"), P = Symbol.for("react.memo"), w = Symbol.for("react.lazy"), D = Symbol.for("react.offscreen"), R = Symbol.iterator, I = "@@iterator";
46
45
  function x(e) {
@@ -633,25 +632,25 @@ React keys must be passed directly to JSX without using spread:
633
632
  J.Fragment = T, J.jsx = lr, J.jsxs = dr;
634
633
  }()), J;
635
634
  }
636
- process.env.NODE_ENV === "production" ? se.exports = _r() : se.exports = Tr();
637
- var Pr = se.exports;
638
- function xr(b) {
635
+ process.env.NODE_ENV === "production" ? se.exports = Er() : se.exports = _r();
636
+ var Tr = se.exports;
637
+ function Pr(b) {
639
638
  $e(() => {
640
639
  b();
641
640
  }, []);
642
641
  }
643
- function Cr(b) {
642
+ function xr(b) {
644
643
  $e(() => b, []);
645
644
  }
646
- function Ar(b) {
645
+ function Dr(b) {
647
646
  if (typeof Proxy > "u") throw new Error("Proxy is not supported in this environment.");
648
647
  const _ = br(
649
648
  void 0
650
649
  );
651
650
  return _.name = b, _;
652
651
  }
653
- function Ir(b) {
654
- return Er(function({
652
+ function Fr(b) {
653
+ return hr(function({
655
654
  children: k,
656
655
  value: T,
657
656
  onChangeProp: C,
@@ -673,7 +672,7 @@ function Ir(b) {
673
672
  }, []), D = ue((R) => {
674
673
  if (R !== o.current) {
675
674
  const I = o.current;
676
- gr(R) ? o.current = R : o.current = new Proxy(R, {
675
+ R !== null ? o.current = new Proxy(R, {
677
676
  get: function(x, g) {
678
677
  const s = Reflect.get(x, g, R);
679
678
  return M(s) ? s.bind(o.current) : s;
@@ -684,20 +683,20 @@ function Ir(b) {
684
683
  (!W.deps || W.deps.includes(j) && $ !== s || W.deps.some((q) => M(q) && q(j, s, $, R))) && W.propCallback(j, s, $);
685
684
  }), M(C) && C(j, s, $), !0;
686
685
  }
687
- }), Object.values(y.current).forEach((x) => {
686
+ }) : o.current = R, Object.values(y.current).forEach((x) => {
688
687
  x.reinitCallback(o.current, I);
689
688
  }), M(p) && p(o.current, I), v();
690
689
  }
691
690
  return d.current.obj = o.current, o.current;
692
691
  }, [C, p]);
693
- return o.current === void 0 && (o.current = D(T)), d.current.obj = o.current, d.current.set = D, d.current.subscribe = P, d.current.unsubscribe = w, /* @__PURE__ */ Pr.jsx(b.Provider, { value: d.current, children: k });
692
+ return o.current === void 0 && (o.current = D(T)), d.current.obj = o.current, d.current.set = D, d.current.subscribe = P, d.current.unsubscribe = w, /* @__PURE__ */ Tr.jsx(b.Provider, { value: d.current, children: k });
694
693
  }, ["children", "onChangeProp", "onChangeReinit", "proxyRef"], `${b.name}Provider (Memo)`);
695
694
  }
696
- function $r(b, _ = [], k, T, C = !0) {
695
+ function Ar(b, _ = [], k, T, C = !0) {
697
696
  const p = mr(b), S = We(), y = X(null);
698
697
  if (p === void 0)
699
698
  throw new Error(`No ${b.name} provider found.`);
700
- return xr(() => {
699
+ return Pr(() => {
701
700
  y.current = p == null ? void 0 : p.subscribe(
702
701
  (o, d, v) => {
703
702
  S(), M(k) && k(o, d, v);
@@ -707,15 +706,15 @@ function $r(b, _ = [], k, T, C = !0) {
707
706
  },
708
707
  _
709
708
  );
710
- }), Cr(() => {
709
+ }), xr(() => {
711
710
  p.unsubscribe(y.current);
712
- }), new hr(
711
+ }), new gr(
713
712
  { value: p.obj, set: p.set },
714
713
  ["value", "set"]
715
714
  );
716
715
  }
717
716
  export {
718
- Ar as createProxyContext,
719
- Ir as createProxyContextProvider,
720
- $r as useProxyContext
717
+ Dr as createProxyContext,
718
+ Fr as createProxyContextProvider,
719
+ Ar as useProxyContext
721
720
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ptolemy2002/react-proxy-context",
3
3
  "private": false,
4
- "version": "2.1.0",
4
+ "version": "2.1.1",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",
@@ -21,7 +21,6 @@
21
21
  "release-major": "bash ./scripts/release.sh major"
22
22
  },
23
23
  "peerDependencies": {
24
- "@ptolemy2002/js-utils": "^3.0.2",
25
24
  "@ptolemy2002/react-force-rerender": "^2.0.0",
26
25
  "@ptolemy2002/react-hook-result": "^2.1.1",
27
26
  "@ptolemy2002/react-mount-effects": "^2.0.0",
@@ -33,7 +32,6 @@
33
32
  },
34
33
  "devDependencies": {
35
34
  "@eslint/js": "^9.11.1",
36
- "@ptolemy2002/js-utils": "^3.0.2",
37
35
  "@ptolemy2002/react-force-rerender": "^2.0.0",
38
36
  "@ptolemy2002/react-hook-result": "^2.1.1",
39
37
  "@ptolemy2002/react-mount-effects": "^2.0.0",