@ptolemy2002/react-proxy-context 2.1.0 → 2.1.2
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 +0 -1
- package/dist/main.d.ts +1 -1
- package/dist/main.js +38 -39
- package/package.json +1 -3
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
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import Ie, { useEffect as $e, createContext as br, useRef as X, useImperativeHandle as yr, useCallback as ue, useContext as mr } from "react";
|
|
2
2
|
import { nanoid as Rr } from "nanoid";
|
|
3
|
-
import
|
|
3
|
+
import V from "is-callable";
|
|
4
4
|
import We from "@ptolemy2002/react-force-rerender";
|
|
5
|
-
import
|
|
6
|
-
import hr from "@ptolemy2002/react-
|
|
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
|
|
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
|
|
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) {
|
|
@@ -69,14 +68,14 @@ function Tr() {
|
|
|
69
68
|
}
|
|
70
69
|
var $ = !1, W = !1, q = !1, Ye = !1, Le = !1, ce;
|
|
71
70
|
ce = Symbol.for("react.module.reference");
|
|
72
|
-
function
|
|
71
|
+
function Ve(e) {
|
|
73
72
|
return !!(typeof e == "string" || typeof e == "function" || e === T || e === p || Le || e === C || e === d || e === v || Ye || e === D || $ || W || q || typeof e == "object" && e !== null && (e.$$typeof === w || e.$$typeof === P || e.$$typeof === S || e.$$typeof === y || e.$$typeof === o || // This needs to include all possible module reference object
|
|
74
73
|
// types supported by any Flight configuration anywhere since
|
|
75
74
|
// we don't know which Flight build this will end up being used
|
|
76
75
|
// with.
|
|
77
76
|
e.$$typeof === ce || e.getModuleId !== void 0));
|
|
78
77
|
}
|
|
79
|
-
function
|
|
78
|
+
function Me(e, r, t) {
|
|
80
79
|
var n = e.displayName;
|
|
81
80
|
if (n)
|
|
82
81
|
return n;
|
|
@@ -116,7 +115,7 @@ function Tr() {
|
|
|
116
115
|
var t = e;
|
|
117
116
|
return fe(t._context) + ".Provider";
|
|
118
117
|
case o:
|
|
119
|
-
return
|
|
118
|
+
return Me(e, e.render, "ForwardRef");
|
|
120
119
|
case P:
|
|
121
120
|
var n = e.displayName || null;
|
|
122
121
|
return n !== null ? n : O(e.type) || "Memo";
|
|
@@ -131,13 +130,13 @@ function Tr() {
|
|
|
131
130
|
}
|
|
132
131
|
return null;
|
|
133
132
|
}
|
|
134
|
-
var F = Object.assign,
|
|
133
|
+
var F = Object.assign, M = 0, le, de, ve, pe, be, ye, me;
|
|
135
134
|
function Re() {
|
|
136
135
|
}
|
|
137
136
|
Re.__reactDisabledLog = !0;
|
|
138
137
|
function Ue() {
|
|
139
138
|
{
|
|
140
|
-
if (
|
|
139
|
+
if (M === 0) {
|
|
141
140
|
le = console.log, de = console.info, ve = console.warn, pe = console.error, be = console.group, ye = console.groupCollapsed, me = console.groupEnd;
|
|
142
141
|
var e = {
|
|
143
142
|
configurable: !0,
|
|
@@ -155,12 +154,12 @@ function Tr() {
|
|
|
155
154
|
groupEnd: e
|
|
156
155
|
});
|
|
157
156
|
}
|
|
158
|
-
|
|
157
|
+
M++;
|
|
159
158
|
}
|
|
160
159
|
}
|
|
161
160
|
function Ne() {
|
|
162
161
|
{
|
|
163
|
-
if (
|
|
162
|
+
if (M--, M === 0) {
|
|
164
163
|
var e = {
|
|
165
164
|
configurable: !0,
|
|
166
165
|
enumerable: !0,
|
|
@@ -190,7 +189,7 @@ function Tr() {
|
|
|
190
189
|
})
|
|
191
190
|
});
|
|
192
191
|
}
|
|
193
|
-
|
|
192
|
+
M < 0 && s("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
|
|
194
193
|
}
|
|
195
194
|
}
|
|
196
195
|
var Z = g.ReactCurrentDispatcher, Q;
|
|
@@ -581,7 +580,7 @@ Check the top-level render call using <` + t + ">.");
|
|
|
581
580
|
var ke = {};
|
|
582
581
|
function De(e, r, t, n, u, c) {
|
|
583
582
|
{
|
|
584
|
-
var i =
|
|
583
|
+
var i = Ve(e);
|
|
585
584
|
if (!i) {
|
|
586
585
|
var a = "";
|
|
587
586
|
(e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (a += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
|
|
@@ -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 =
|
|
637
|
-
var
|
|
638
|
-
function
|
|
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
|
|
642
|
+
function xr(b) {
|
|
644
643
|
$e(() => b, []);
|
|
645
644
|
}
|
|
646
|
-
function
|
|
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
|
|
654
|
-
return
|
|
652
|
+
function Fr(b) {
|
|
653
|
+
return hr(function({
|
|
655
654
|
children: k,
|
|
656
655
|
value: T,
|
|
657
656
|
onChangeProp: C,
|
|
@@ -673,49 +672,49 @@ function Ir(b) {
|
|
|
673
672
|
}, []), D = ue((R) => {
|
|
674
673
|
if (R !== o.current) {
|
|
675
674
|
const I = o.current;
|
|
676
|
-
|
|
675
|
+
R !== null ? o.current = new Proxy(R, {
|
|
677
676
|
get: function(x, g) {
|
|
678
677
|
const s = Reflect.get(x, g, R);
|
|
679
|
-
return
|
|
678
|
+
return V(s) ? s.bind(o.current) : s;
|
|
680
679
|
},
|
|
681
680
|
set: function(x, g, s) {
|
|
682
681
|
const j = g, $ = x[j];
|
|
683
682
|
return Reflect.set(x, j, s, R), s = x[j], Object.values(y.current).forEach((W) => {
|
|
684
|
-
(!W.deps || W.deps.includes(j) && $ !== s || W.deps.some((q) =>
|
|
685
|
-
}),
|
|
683
|
+
(!W.deps || W.deps.includes(j) && $ !== s || W.deps.some((q) => V(q) && q(j, s, $, R))) && W.propCallback(j, s, $);
|
|
684
|
+
}), V(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
|
+
}), V(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__ */
|
|
694
|
-
}, ["children", "onChangeProp", "onChangeReinit", "proxyRef"], `${b.name}Provider
|
|
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 });
|
|
693
|
+
}, ["children", "onChangeProp", "onChangeReinit", "proxyRef"], `${b.name}Provider`);
|
|
695
694
|
}
|
|
696
|
-
function
|
|
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
|
|
699
|
+
return Pr(() => {
|
|
701
700
|
y.current = p == null ? void 0 : p.subscribe(
|
|
702
701
|
(o, d, v) => {
|
|
703
|
-
S(),
|
|
702
|
+
S(), V(k) && k(o, d, v);
|
|
704
703
|
},
|
|
705
704
|
(o, d) => {
|
|
706
|
-
C && S(),
|
|
705
|
+
C && S(), V(T) && T(o, d);
|
|
707
706
|
},
|
|
708
707
|
_
|
|
709
708
|
);
|
|
710
|
-
}),
|
|
709
|
+
}), xr(() => {
|
|
711
710
|
p.unsubscribe(y.current);
|
|
712
|
-
}), new
|
|
711
|
+
}), new gr(
|
|
713
712
|
{ value: p.obj, set: p.set },
|
|
714
713
|
["value", "set"]
|
|
715
714
|
);
|
|
716
715
|
}
|
|
717
716
|
export {
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
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.
|
|
4
|
+
"version": "2.1.2",
|
|
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",
|