@ptolemy2002/react-proxy-context 2.4.0 → 2.5.0

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
@@ -17,7 +17,7 @@ type OnChangePropCallback<T> =
17
17
  <K extends keyof T>(prop: K, current: T[K], prev?: T[K]) => void
18
18
  ;
19
19
  type OnChangeReinitCallback<T> =
20
- (current: T, prev?: T) => void
20
+ (current: T, prev?: T, initial?: boolean) => void
21
21
  ;
22
22
 
23
23
  type Dependency<_T, T=Exclude<_T, null | undefined>> = keyof T | (
@@ -113,7 +113,7 @@ Creates a new proxy context provider component with the specified type. `ProxyCo
113
113
  The component has the following props:
114
114
  - `value` (`T | ProxyContextValueWrapper<T>`): The value of the context. This can be either a raw value of type `T`, which will be automatically wrapped in a `ProxyContextValueWrapper`, or a pre-existing `ProxyContextValueWrapper<T>` instance. This allows you to initialize the wrapper outside of the context and pass it in, giving you more control over the proxy lifecycle.
115
115
  - `onChangeProp` (`OnChangePropCallback<T>`): A function that is called whenever a property of the context is changed. The first parameter is the property that was changed, the second parameter is the current value of the property, and the third parameter is the previous value of the property. This is useful for listening to changes in the provider's parent component.
116
- - `onChangeReinit` (`OnChangeReinitCallback<T>`): A function that is called whenever the context is reinitialized. The first parameter is the current value of the context, and the second parameter is the previous value of the context. This is useful for listening to changes in the provider's parent component.
116
+ - `onChangeReinit` (`OnChangeReinitCallback<T>`): A function that is called whenever the context is reinitialized. The first parameter is the current value of the context, the second parameter is the previous value of the context, and the third parameter is a boolean indicating whether this is the first initialization. Also called on first initialization, with the previous value being `undefined` if you passed in a raw value instead of a `ProxyContextValueWrapper`. This is useful for listening to changes in the provider's parent component.
117
117
  - `proxyRef` (`React.MutableRefObject<T>`): A ref object that is assigned the proxy object of the context. This is useful for accessing the proxy object directly by the provider's parent component.
118
118
 
119
119
  ## Hooks
@@ -126,7 +126,7 @@ A hook that uses the context provided by the `ProxyContextProvider` component. T
126
126
  - `contextClass` (`ProxyContext<T>`): The context class that was created using `createProxyContext`.
127
127
  - `deps` (`Dependency<T>[] | null`): An array of dependencies to listen to. If any of these properties on the context change, the hook will re-render. If this is falsy, any mutation will trigger a re-render. If a dependency is an array, it represents a nested property dependency. You can also specify a function that returns a boolean to determine whether to re-render. By default, this is an empty array.
128
128
  - `onChangeProp` (`OnChangePropCallback<T> | undefined`): A function that is called whenever a property of the context is changed. The first parameter is the property that was changed, the second parameter is the current value of the property, and the third parameter is the previous value of the property. This is useful for listening to changes in the consumer component.
129
- - `onChangeReinit` (`OnChangeReinitCallback<T> | undefined`): A function that is called whenever the context is reinitialized. The first parameter is the current value of the context, and the second parameter is the previous value of the context. Also called on initial initialization with the second parameter being `undefined`. This is useful for listening to changes in the consumer component.
129
+ - `onChangeReinit` (`OnChangeReinitCallback<T> | undefined`): A function that is called whenever the context is reinitialized. The first parameter is the current value of the context, the second parameter is the previous value of the context, and the third parameter is a boolean indicating whether this is the first initialization.
130
130
  - `listenReinit` (`boolean`): Whether to listen to full reassignments of the context. If this is true, the hook will re-render whenever the context is reinitialized. By default, this is true.
131
131
 
132
132
  #### Returns
package/dist/main.d.ts CHANGED
@@ -4,7 +4,7 @@ export type ContextWithName<T> = Context<T> & {
4
4
  name: string;
5
5
  };
6
6
  export type OnChangePropCallback<T> = <K extends keyof T>(prop: K, current: T[K], prev?: T[K]) => void;
7
- export type OnChangeReinitCallback<T> = (current: T, prev?: T) => void;
7
+ export type OnChangeReinitCallback<T> = (current: T, prev?: T, initial?: boolean) => void;
8
8
  export declare function createProxyContext<T>(name: string): ProxyContext<T>;
9
9
  export type Dependency<_T, T = Exclude<_T, null | undefined>> = keyof T | (<K extends keyof T>(prop: K, current: T[K], prev: T[K], obj: T) => boolean) | null | undefined | false | [keyof T, ...PropertyKey[]];
10
10
  export declare function evaluateDependency<T>(dep: Dependency<T>): Exclude<Dependency<T>, any[]>;
@@ -29,7 +29,7 @@ export declare class ProxyContextValueWrapper<T> {
29
29
  subscribe(propCallback: OnChangePropCallback<T>, reinitCallback: OnChangeReinitCallback<T>, deps: Dependency<T>[] | null): string;
30
30
  unsubscribe(id: string): void;
31
31
  emitChange(prop: keyof T, current: T[keyof T], prev?: T[keyof T]): void;
32
- emitReinit(current: T, prev?: T): void;
32
+ emitReinit(current: T, prev?: T, initial?: boolean): void;
33
33
  get(): T;
34
34
  set(newObj: T): T;
35
35
  }
package/dist/main.js CHANGED
@@ -1,13 +1,13 @@
1
1
  var dr = Object.defineProperty;
2
- var pr = (h, a, l) => a in h ? dr(h, a, { enumerable: !0, configurable: !0, writable: !0, value: l }) : h[a] = l;
3
- var X = (h, a, l) => pr(h, typeof a != "symbol" ? a + "" : a, l);
2
+ var pr = (h, a, c) => a in h ? dr(h, a, { enumerable: !0, configurable: !0, writable: !0, value: c }) : h[a] = c;
3
+ var X = (h, a, c) => pr(h, typeof a != "symbol" ? a + "" : a, c);
4
4
  import Oe, { createContext as br, useRef as Ce, useImperativeHandle as hr, useEffect as yr, useContext as mr, useCallback as Er, useSyncExternalStore as gr } from "react";
5
5
  import { nanoid as _r } from "nanoid";
6
6
  import Y from "is-callable";
7
7
  import Rr from "@ptolemy2002/react-force-rerender";
8
8
  import Tr from "@ptolemy2002/react-hook-result";
9
9
  import { partialMemo as Sr } from "@ptolemy2002/react-utils";
10
- var Z = { exports: {} }, $ = {};
10
+ var Q = { exports: {} }, $ = {};
11
11
  /**
12
12
  * @license React
13
13
  * react-jsx-runtime.production.min.js
@@ -17,19 +17,19 @@ var Z = { exports: {} }, $ = {};
17
17
  * This source code is licensed under the MIT license found in the
18
18
  * LICENSE file in the root directory of this source tree.
19
19
  */
20
- var xe;
20
+ var Pe;
21
21
  function xr() {
22
- if (xe) return $;
23
- xe = 1;
24
- var h = Oe, a = Symbol.for("react.element"), l = Symbol.for("react.fragment"), p = Object.prototype.hasOwnProperty, c = h.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, b = { key: !0, ref: !0, __self: !0, __source: !0 };
22
+ if (Pe) return $;
23
+ Pe = 1;
24
+ var h = Oe, a = Symbol.for("react.element"), c = Symbol.for("react.fragment"), p = Object.prototype.hasOwnProperty, s = h.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, b = { key: !0, ref: !0, __self: !0, __source: !0 };
25
25
  function i(v, d, x) {
26
26
  var E, T = {}, P = null, k = null;
27
27
  x !== void 0 && (P = "" + x), d.key !== void 0 && (P = "" + d.key), d.ref !== void 0 && (k = d.ref);
28
28
  for (E in d) p.call(d, E) && !b.hasOwnProperty(E) && (T[E] = d[E]);
29
29
  if (v && v.defaultProps) for (E in d = v.defaultProps, d) T[E] === void 0 && (T[E] = d[E]);
30
- return { $$typeof: a, type: v, key: P, ref: k, props: T, _owner: c.current };
30
+ return { $$typeof: a, type: v, key: P, ref: k, props: T, _owner: s.current };
31
31
  }
32
- return $.Fragment = l, $.jsx = i, $.jsxs = i, $;
32
+ return $.Fragment = c, $.jsx = i, $.jsxs = i, $;
33
33
  }
34
34
  var W = {};
35
35
  /**
@@ -41,14 +41,14 @@ var W = {};
41
41
  * This source code is licensed under the MIT license found in the
42
42
  * LICENSE file in the root directory of this source tree.
43
43
  */
44
- var Pe;
44
+ var we;
45
45
  function Pr() {
46
- return Pe || (Pe = 1, process.env.NODE_ENV !== "production" && function() {
47
- var h = Oe, a = Symbol.for("react.element"), l = Symbol.for("react.portal"), p = Symbol.for("react.fragment"), c = Symbol.for("react.strict_mode"), b = Symbol.for("react.profiler"), i = Symbol.for("react.provider"), v = Symbol.for("react.context"), d = Symbol.for("react.forward_ref"), x = Symbol.for("react.suspense"), E = Symbol.for("react.suspense_list"), T = Symbol.for("react.memo"), P = Symbol.for("react.lazy"), k = Symbol.for("react.offscreen"), Q = Symbol.iterator, ke = "@@iterator";
46
+ return we || (we = 1, process.env.NODE_ENV !== "production" && function() {
47
+ var h = Oe, a = Symbol.for("react.element"), c = Symbol.for("react.portal"), p = Symbol.for("react.fragment"), s = Symbol.for("react.strict_mode"), b = Symbol.for("react.profiler"), i = Symbol.for("react.provider"), v = Symbol.for("react.context"), d = Symbol.for("react.forward_ref"), x = Symbol.for("react.suspense"), E = Symbol.for("react.suspense_list"), T = Symbol.for("react.memo"), P = Symbol.for("react.lazy"), k = Symbol.for("react.offscreen"), ee = Symbol.iterator, ke = "@@iterator";
48
48
  function je(e) {
49
49
  if (e === null || typeof e != "object")
50
50
  return null;
51
- var r = Q && e[Q] || e[ke];
51
+ var r = ee && e[ee] || e[ke];
52
52
  return typeof r == "function" ? r : null;
53
53
  }
54
54
  var j = h.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
@@ -61,31 +61,31 @@ function Pr() {
61
61
  }
62
62
  function De(e, r, t) {
63
63
  {
64
- var n = j.ReactDebugCurrentFrame, s = n.getStackAddendum();
65
- s !== "" && (r += "%s", t = t.concat([s]));
64
+ var n = j.ReactDebugCurrentFrame, l = n.getStackAddendum();
65
+ l !== "" && (r += "%s", t = t.concat([l]));
66
66
  var f = t.map(function(u) {
67
67
  return String(u);
68
68
  });
69
69
  f.unshift("Warning: " + r), Function.prototype.apply.call(console[e], console, f);
70
70
  }
71
71
  }
72
- var Fe = !1, Ae = !1, Ie = !1, $e = !1, We = !1, ee;
73
- ee = Symbol.for("react.module.reference");
72
+ var Fe = !1, Ae = !1, Ie = !1, $e = !1, We = !1, re;
73
+ re = Symbol.for("react.module.reference");
74
74
  function Ye(e) {
75
- return !!(typeof e == "string" || typeof e == "function" || e === p || e === b || We || e === c || e === x || e === E || $e || e === k || Fe || Ae || Ie || typeof e == "object" && e !== null && (e.$$typeof === P || e.$$typeof === T || e.$$typeof === i || e.$$typeof === v || e.$$typeof === d || // This needs to include all possible module reference object
75
+ return !!(typeof e == "string" || typeof e == "function" || e === p || e === b || We || e === s || e === x || e === E || $e || e === k || Fe || Ae || Ie || typeof e == "object" && e !== null && (e.$$typeof === P || e.$$typeof === T || e.$$typeof === i || e.$$typeof === v || e.$$typeof === d || // This needs to include all possible module reference object
76
76
  // types supported by any Flight configuration anywhere since
77
77
  // we don't know which Flight build this will end up being used
78
78
  // with.
79
- e.$$typeof === ee || e.getModuleId !== void 0));
79
+ e.$$typeof === re || e.getModuleId !== void 0));
80
80
  }
81
81
  function Ve(e, r, t) {
82
82
  var n = e.displayName;
83
83
  if (n)
84
84
  return n;
85
- var s = r.displayName || r.name || "";
86
- return s !== "" ? t + "(" + s + ")" : t;
85
+ var l = r.displayName || r.name || "";
86
+ return l !== "" ? t + "(" + l + ")" : t;
87
87
  }
88
- function re(e) {
88
+ function te(e) {
89
89
  return e.displayName || "Context";
90
90
  }
91
91
  function w(e) {
@@ -98,11 +98,11 @@ function Pr() {
98
98
  switch (e) {
99
99
  case p:
100
100
  return "Fragment";
101
- case l:
101
+ case c:
102
102
  return "Portal";
103
103
  case b:
104
104
  return "Profiler";
105
- case c:
105
+ case s:
106
106
  return "StrictMode";
107
107
  case x:
108
108
  return "Suspense";
@@ -113,17 +113,17 @@ function Pr() {
113
113
  switch (e.$$typeof) {
114
114
  case v:
115
115
  var r = e;
116
- return re(r) + ".Consumer";
116
+ return te(r) + ".Consumer";
117
117
  case i:
118
118
  var t = e;
119
- return re(t._context) + ".Provider";
119
+ return te(t._context) + ".Provider";
120
120
  case d:
121
121
  return Ve(e, e.render, "ForwardRef");
122
122
  case T:
123
123
  var n = e.displayName || null;
124
124
  return n !== null ? n : w(e.type) || "Memo";
125
125
  case P: {
126
- var s = e, f = s._payload, u = s._init;
126
+ var l = e, f = l._payload, u = l._init;
127
127
  try {
128
128
  return w(u(f));
129
129
  } catch {
@@ -133,18 +133,18 @@ function Pr() {
133
133
  }
134
134
  return null;
135
135
  }
136
- var O = Object.assign, A = 0, te, ne, ae, ie, oe, ue, se;
137
- function ce() {
136
+ var O = Object.assign, A = 0, ne, ae, ie, oe, ue, se, ce;
137
+ function le() {
138
138
  }
139
- ce.__reactDisabledLog = !0;
139
+ le.__reactDisabledLog = !0;
140
140
  function Le() {
141
141
  {
142
142
  if (A === 0) {
143
- te = console.log, ne = console.info, ae = console.warn, ie = console.error, oe = console.group, ue = console.groupCollapsed, se = console.groupEnd;
143
+ ne = console.log, ae = console.info, ie = console.warn, oe = console.error, ue = console.group, se = console.groupCollapsed, ce = console.groupEnd;
144
144
  var e = {
145
145
  configurable: !0,
146
146
  enumerable: !0,
147
- value: ce,
147
+ value: le,
148
148
  writable: !0
149
149
  };
150
150
  Object.defineProperties(console, {
@@ -170,25 +170,25 @@ function Pr() {
170
170
  };
171
171
  Object.defineProperties(console, {
172
172
  log: O({}, e, {
173
- value: te
173
+ value: ne
174
174
  }),
175
175
  info: O({}, e, {
176
- value: ne
176
+ value: ae
177
177
  }),
178
178
  warn: O({}, e, {
179
- value: ae
179
+ value: ie
180
180
  }),
181
181
  error: O({}, e, {
182
- value: ie
182
+ value: oe
183
183
  }),
184
184
  group: O({}, e, {
185
- value: oe
185
+ value: ue
186
186
  }),
187
187
  groupCollapsed: O({}, e, {
188
- value: ue
188
+ value: se
189
189
  }),
190
190
  groupEnd: O({}, e, {
191
- value: se
191
+ value: ce
192
192
  })
193
193
  });
194
194
  }
@@ -201,8 +201,8 @@ function Pr() {
201
201
  if (B === void 0)
202
202
  try {
203
203
  throw Error();
204
- } catch (s) {
205
- var n = s.stack.trim().match(/\n( *(at )?)/);
204
+ } catch (l) {
205
+ var n = l.stack.trim().match(/\n( *(at )?)/);
206
206
  B = n && n[1] || "";
207
207
  }
208
208
  return `
@@ -214,7 +214,7 @@ function Pr() {
214
214
  var Ue = typeof WeakMap == "function" ? WeakMap : Map;
215
215
  L = new Ue();
216
216
  }
217
- function le(e, r) {
217
+ function fe(e, r) {
218
218
  if (!e || J)
219
219
  return "";
220
220
  {
@@ -224,7 +224,7 @@ function Pr() {
224
224
  }
225
225
  var n;
226
226
  J = !0;
227
- var s = Error.prepareStackTrace;
227
+ var l = Error.prepareStackTrace;
228
228
  Error.prepareStackTrace = void 0;
229
229
  var f;
230
230
  f = N.current, N.current = null, Le();
@@ -280,13 +280,13 @@ function Pr() {
280
280
  }
281
281
  }
282
282
  } finally {
283
- J = !1, N.current = f, Me(), Error.prepareStackTrace = s;
283
+ J = !1, N.current = f, Me(), Error.prepareStackTrace = l;
284
284
  }
285
285
  var F = e ? e.displayName || e.name : "", C = F ? V(F) : "";
286
286
  return typeof e == "function" && L.set(e, C), C;
287
287
  }
288
288
  function Ne(e, r, t) {
289
- return le(e, !1);
289
+ return fe(e, !1);
290
290
  }
291
291
  function Be(e) {
292
292
  var r = e.prototype;
@@ -296,7 +296,7 @@ function Pr() {
296
296
  if (e == null)
297
297
  return "";
298
298
  if (typeof e == "function")
299
- return le(e, Be(e));
299
+ return fe(e, Be(e));
300
300
  if (typeof e == "string")
301
301
  return V(e);
302
302
  switch (e) {
@@ -312,24 +312,24 @@ function Pr() {
312
312
  case T:
313
313
  return M(e.type, r, t);
314
314
  case P: {
315
- var n = e, s = n._payload, f = n._init;
315
+ var n = e, l = n._payload, f = n._init;
316
316
  try {
317
- return M(f(s), r, t);
317
+ return M(f(l), r, t);
318
318
  } catch {
319
319
  }
320
320
  }
321
321
  }
322
322
  return "";
323
323
  }
324
- var I = Object.prototype.hasOwnProperty, fe = {}, ve = j.ReactDebugCurrentFrame;
324
+ var I = Object.prototype.hasOwnProperty, ve = {}, de = j.ReactDebugCurrentFrame;
325
325
  function U(e) {
326
326
  if (e) {
327
327
  var r = e._owner, t = M(e.type, e._source, r ? r.type : null);
328
- ve.setExtraStackFrame(t);
328
+ de.setExtraStackFrame(t);
329
329
  } else
330
- ve.setExtraStackFrame(null);
330
+ de.setExtraStackFrame(null);
331
331
  }
332
- function Je(e, r, t, n, s) {
332
+ function Je(e, r, t, n, l) {
333
333
  {
334
334
  var f = Function.call.bind(I);
335
335
  for (var u in e)
@@ -344,7 +344,7 @@ function Pr() {
344
344
  } catch (y) {
345
345
  o = y;
346
346
  }
347
- o && !(o instanceof Error) && (U(s), g("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", n || "React class", t, u, typeof o), U(null)), o instanceof Error && !(o.message in fe) && (fe[o.message] = !0, U(s), g("Failed %s type: %s", t, o.message), U(null));
347
+ o && !(o instanceof Error) && (U(l), g("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", n || "React class", t, u, typeof o), U(null)), o instanceof Error && !(o.message in ve) && (ve[o.message] = !0, U(l), g("Failed %s type: %s", t, o.message), U(null));
348
348
  }
349
349
  }
350
350
  }
@@ -360,24 +360,24 @@ function Pr() {
360
360
  }
361
361
  function Ge(e) {
362
362
  try {
363
- return de(e), !1;
363
+ return pe(e), !1;
364
364
  } catch {
365
365
  return !0;
366
366
  }
367
367
  }
368
- function de(e) {
368
+ function pe(e) {
369
369
  return "" + e;
370
370
  }
371
- function pe(e) {
371
+ function be(e) {
372
372
  if (Ge(e))
373
- return g("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", Ke(e)), de(e);
373
+ return g("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", Ke(e)), pe(e);
374
374
  }
375
- var be = j.ReactCurrentOwner, ze = {
375
+ var he = j.ReactCurrentOwner, ze = {
376
376
  key: !0,
377
377
  ref: !0,
378
378
  __self: !0,
379
379
  __source: !0
380
- }, he, ye;
380
+ }, ye, me;
381
381
  function He(e) {
382
382
  if (I.call(e, "ref")) {
383
383
  var r = Object.getOwnPropertyDescriptor(e, "ref").get;
@@ -395,12 +395,12 @@ function Pr() {
395
395
  return e.key !== void 0;
396
396
  }
397
397
  function Ze(e, r) {
398
- typeof e.ref == "string" && be.current;
398
+ typeof e.ref == "string" && he.current;
399
399
  }
400
400
  function Qe(e, r) {
401
401
  {
402
402
  var t = function() {
403
- he || (he = !0, g("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r));
403
+ ye || (ye = !0, g("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r));
404
404
  };
405
405
  t.isReactWarning = !0, Object.defineProperty(e, "key", {
406
406
  get: t,
@@ -411,7 +411,7 @@ function Pr() {
411
411
  function er(e, r) {
412
412
  {
413
413
  var t = function() {
414
- ye || (ye = !0, g("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r));
414
+ me || (me = !0, g("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r));
415
415
  };
416
416
  t.isReactWarning = !0, Object.defineProperty(e, "ref", {
417
417
  get: t,
@@ -419,7 +419,7 @@ function Pr() {
419
419
  });
420
420
  }
421
421
  }
422
- var rr = function(e, r, t, n, s, f, u) {
422
+ var rr = function(e, r, t, n, l, f, u) {
423
423
  var o = {
424
424
  // This tag allows us to uniquely identify this as a React Element
425
425
  $$typeof: a,
@@ -445,13 +445,13 @@ function Pr() {
445
445
  configurable: !1,
446
446
  enumerable: !1,
447
447
  writable: !1,
448
- value: s
448
+ value: l
449
449
  }), Object.freeze && (Object.freeze(o.props), Object.freeze(o)), o;
450
450
  };
451
- function tr(e, r, t, n, s) {
451
+ function tr(e, r, t, n, l) {
452
452
  {
453
453
  var f, u = {}, o = null, _ = null;
454
- t !== void 0 && (pe(t), o = "" + t), Xe(r) && (pe(r.key), o = "" + r.key), He(r) && (_ = r.ref, Ze(r, s));
454
+ t !== void 0 && (be(t), o = "" + t), Xe(r) && (be(r.key), o = "" + r.key), He(r) && (_ = r.ref, Ze(r, l));
455
455
  for (f in r)
456
456
  I.call(r, f) && !ze.hasOwnProperty(f) && (u[f] = r[f]);
457
457
  if (e && e.defaultProps) {
@@ -463,23 +463,23 @@ function Pr() {
463
463
  var m = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
464
464
  o && Qe(u, m), _ && er(u, m);
465
465
  }
466
- return rr(e, o, _, s, n, be.current, u);
466
+ return rr(e, o, _, l, n, he.current, u);
467
467
  }
468
468
  }
469
- var K = j.ReactCurrentOwner, me = j.ReactDebugCurrentFrame;
469
+ var K = j.ReactCurrentOwner, Ee = j.ReactDebugCurrentFrame;
470
470
  function D(e) {
471
471
  if (e) {
472
472
  var r = e._owner, t = M(e.type, e._source, r ? r.type : null);
473
- me.setExtraStackFrame(t);
473
+ Ee.setExtraStackFrame(t);
474
474
  } else
475
- me.setExtraStackFrame(null);
475
+ Ee.setExtraStackFrame(null);
476
476
  }
477
477
  var G;
478
478
  G = !1;
479
479
  function z(e) {
480
480
  return typeof e == "object" && e !== null && e.$$typeof === a;
481
481
  }
482
- function Ee() {
482
+ function ge() {
483
483
  {
484
484
  if (K.current) {
485
485
  var e = w(K.current.type);
@@ -494,10 +494,10 @@ Check the render method of \`` + e + "`.";
494
494
  function nr(e) {
495
495
  return "";
496
496
  }
497
- var ge = {};
497
+ var _e = {};
498
498
  function ar(e) {
499
499
  {
500
- var r = Ee();
500
+ var r = ge();
501
501
  if (!r) {
502
502
  var t = typeof e == "string" ? e : e.displayName || e.name;
503
503
  t && (r = `
@@ -507,35 +507,35 @@ Check the top-level render call using <` + t + ">.");
507
507
  return r;
508
508
  }
509
509
  }
510
- function _e(e, r) {
510
+ function Re(e, r) {
511
511
  {
512
512
  if (!e._store || e._store.validated || e.key != null)
513
513
  return;
514
514
  e._store.validated = !0;
515
515
  var t = ar(r);
516
- if (ge[t])
516
+ if (_e[t])
517
517
  return;
518
- ge[t] = !0;
518
+ _e[t] = !0;
519
519
  var n = "";
520
520
  e && e._owner && e._owner !== K.current && (n = " It was passed a child from " + w(e._owner.type) + "."), D(e), g('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', t, n), D(null);
521
521
  }
522
522
  }
523
- function Re(e, r) {
523
+ function Te(e, r) {
524
524
  {
525
525
  if (typeof e != "object")
526
526
  return;
527
527
  if (q(e))
528
528
  for (var t = 0; t < e.length; t++) {
529
529
  var n = e[t];
530
- z(n) && _e(n, r);
530
+ z(n) && Re(n, r);
531
531
  }
532
532
  else if (z(e))
533
533
  e._store && (e._store.validated = !0);
534
534
  else if (e) {
535
- var s = je(e);
536
- if (typeof s == "function" && s !== e.entries)
537
- for (var f = s.call(e), u; !(u = f.next()).done; )
538
- z(u.value) && _e(u.value, r);
535
+ var l = je(e);
536
+ if (typeof l == "function" && l !== e.entries)
537
+ for (var f = l.call(e), u; !(u = f.next()).done; )
538
+ z(u.value) && Re(u.value, r);
539
539
  }
540
540
  }
541
541
  }
@@ -558,8 +558,8 @@ Check the top-level render call using <` + t + ">.");
558
558
  Je(t, e.props, "prop", n, e);
559
559
  } else if (r.PropTypes !== void 0 && !G) {
560
560
  G = !0;
561
- var s = w(r);
562
- g("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", s || "Unknown");
561
+ var l = w(r);
562
+ g("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", l || "Unknown");
563
563
  }
564
564
  typeof r.getDefaultProps == "function" && !r.getDefaultProps.isReactClassApproved && g("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
565
565
  }
@@ -576,19 +576,19 @@ Check the top-level render call using <` + t + ">.");
576
576
  e.ref !== null && (D(e), g("Invalid attribute `ref` supplied to `React.Fragment`."), D(null));
577
577
  }
578
578
  }
579
- var Te = {};
580
- function Se(e, r, t, n, s, f) {
579
+ var Se = {};
580
+ function xe(e, r, t, n, l, f) {
581
581
  {
582
582
  var u = Ye(e);
583
583
  if (!u) {
584
584
  var o = "";
585
585
  (e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (o += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
586
586
  var _ = nr();
587
- _ ? o += _ : o += Ee();
587
+ _ ? o += _ : o += ge();
588
588
  var y;
589
589
  e === null ? y = "null" : q(e) ? y = "array" : e !== void 0 && e.$$typeof === a ? (y = "<" + (w(e.type) || "Unknown") + " />", o = " Did you accidentally export a JSX literal instead of a component?") : y = typeof e, g("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", y, o);
590
590
  }
591
- var m = tr(e, r, t, s, f);
591
+ var m = tr(e, r, t, l, f);
592
592
  if (m == null)
593
593
  return m;
594
594
  if (u) {
@@ -597,42 +597,42 @@ Check the top-level render call using <` + t + ">.");
597
597
  if (n)
598
598
  if (q(S)) {
599
599
  for (var F = 0; F < S.length; F++)
600
- Re(S[F], e);
600
+ Te(S[F], e);
601
601
  Object.freeze && Object.freeze(S);
602
602
  } else
603
603
  g("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
604
604
  else
605
- Re(S, e);
605
+ Te(S, e);
606
606
  }
607
607
  if (I.call(r, "key")) {
608
608
  var C = w(e), R = Object.keys(r).filter(function(vr) {
609
609
  return vr !== "key";
610
610
  }), H = R.length > 0 ? "{key: someKey, " + R.join(": ..., ") + ": ...}" : "{key: someKey}";
611
- if (!Te[C + H]) {
611
+ if (!Se[C + H]) {
612
612
  var fr = R.length > 0 ? "{" + R.join(": ..., ") + ": ...}" : "{}";
613
613
  g(`A props object containing a "key" prop is being spread into JSX:
614
614
  let props = %s;
615
615
  <%s {...props} />
616
616
  React keys must be passed directly to JSX without using spread:
617
617
  let props = %s;
618
- <%s key={someKey} {...props} />`, H, C, fr, C), Te[C + H] = !0;
618
+ <%s key={someKey} {...props} />`, H, C, fr, C), Se[C + H] = !0;
619
619
  }
620
620
  }
621
621
  return e === p ? or(m) : ir(m), m;
622
622
  }
623
623
  }
624
624
  function ur(e, r, t) {
625
- return Se(e, r, t, !0);
625
+ return xe(e, r, t, !0);
626
626
  }
627
627
  function sr(e, r, t) {
628
- return Se(e, r, t, !1);
628
+ return xe(e, r, t, !1);
629
629
  }
630
630
  var cr = sr, lr = ur;
631
631
  W.Fragment = p, W.jsx = cr, W.jsxs = lr;
632
632
  }()), W;
633
633
  }
634
- process.env.NODE_ENV === "production" ? Z.exports = xr() : Z.exports = Pr();
635
- var wr = Z.exports;
634
+ process.env.NODE_ENV === "production" ? Q.exports = xr() : Q.exports = Pr();
635
+ var wr = Q.exports;
636
636
  function $r(h) {
637
637
  if (typeof Proxy > "u") throw new Error("Proxy is not supported in this environment.");
638
638
  const a = br(
@@ -642,64 +642,64 @@ function $r(h) {
642
642
  }
643
643
  function Or(h) {
644
644
  if (Array.isArray(h)) {
645
- const [a, ...l] = h;
646
- return (p, c, b) => {
645
+ const [a, ...c] = h;
646
+ return (p, s, b) => {
647
647
  if (p !== a) return !1;
648
- let i = c, v = b;
649
- for (const d of l)
648
+ let i = s, v = b;
649
+ for (const d of c)
650
650
  i = i == null ? void 0 : i[d], v = v == null ? void 0 : v[d];
651
651
  return i !== v;
652
652
  };
653
653
  }
654
654
  return h;
655
655
  }
656
- class we {
656
+ class Z {
657
657
  constructor(a) {
658
658
  X(this, "value");
659
659
  X(this, "changeSubscribers", {});
660
660
  this.set(a);
661
661
  }
662
- subscribe(a, l, p) {
663
- const c = _r();
664
- return this.changeSubscribers[c] = {
665
- id: c,
662
+ subscribe(a, c, p) {
663
+ const s = _r();
664
+ return this.changeSubscribers[s] = {
665
+ id: s,
666
666
  deps: p,
667
667
  propCallback: a,
668
- reinitCallback: l
669
- }, c;
668
+ reinitCallback: c
669
+ }, s;
670
670
  }
671
671
  unsubscribe(a) {
672
672
  delete this.changeSubscribers[a];
673
673
  }
674
- emitChange(a, l, p) {
675
- Object.values(this.changeSubscribers).forEach((c) => {
674
+ emitChange(a, c, p) {
675
+ Object.values(this.changeSubscribers).forEach((s) => {
676
676
  var i;
677
- const b = (i = c.deps) == null ? void 0 : i.map(Or);
678
- (!b || b.includes(a) && p !== l || b.some(
679
- (v) => Y(v) && v(a, l, p, this.value)
680
- )) && c.propCallback(a, l, p);
677
+ const b = (i = s.deps) == null ? void 0 : i.map(Or);
678
+ (!b || b.includes(a) && p !== c || b.some(
679
+ (v) => Y(v) && v(a, c, p, this.value)
680
+ )) && s.propCallback(a, c, p);
681
681
  });
682
682
  }
683
- emitReinit(a, l) {
684
- Object.values(this.changeSubscribers).forEach((p) => {
685
- p.reinitCallback(a, l);
683
+ emitReinit(a, c, p = !1) {
684
+ Object.values(this.changeSubscribers).forEach((s) => {
685
+ s.reinitCallback(a, c, p);
686
686
  });
687
687
  }
688
688
  get() {
689
689
  return this.value;
690
690
  }
691
691
  set(a) {
692
- const l = this;
692
+ const c = this;
693
693
  if (a !== this.value) {
694
694
  const p = this.value;
695
695
  a != null ? this.value = new Proxy(a, {
696
- get: function(c, b) {
697
- const i = Reflect.get(c, b, a);
698
- return Y(i) ? i.bind(l.value) : i;
696
+ get: function(s, b) {
697
+ const i = Reflect.get(s, b, a);
698
+ return Y(i) ? i.bind(c.value) : i;
699
699
  },
700
- set: (c, b, i) => {
701
- const v = b, d = c[v];
702
- return Reflect.set(c, v, i, a), i = c[v], this.emitChange(v, i, d), !0;
700
+ set: (s, b, i) => {
701
+ const v = b, d = s[v];
702
+ return Reflect.set(s, v, i, a), i = s[v], this.emitChange(v, i, d), !0;
703
703
  }
704
704
  }) : this.value = a, this.emitReinit(this.value, p);
705
705
  }
@@ -710,48 +710,48 @@ function Wr(h) {
710
710
  return Sr(
711
711
  ({
712
712
  children: a,
713
- value: l,
713
+ value: c,
714
714
  onChangeProp: p,
715
- onChangeReinit: c,
715
+ onChangeReinit: s,
716
716
  proxyRef: b
717
717
  }) => {
718
718
  const i = Ce(void 0);
719
- i.current === void 0 && (i.current = l instanceof we ? l : new we(l), c == null || c(i.current.get(), void 0));
719
+ i.current === void 0 && (i.current = c instanceof Z ? c : new Z(c), s == null || s(i.current.get(), c instanceof Z ? c.get() : void 0, !0));
720
720
  const v = Rr();
721
721
  return hr(b, () => i.current.get(), [i.current.get()]), yr(() => {
722
722
  const d = i.current.subscribe(
723
723
  p ?? (() => {
724
724
  }),
725
725
  (...x) => {
726
- Y(c) && c(...x), v();
726
+ Y(s) && s(...x), v();
727
727
  },
728
728
  null
729
729
  );
730
730
  return () => {
731
731
  i.current.unsubscribe(d);
732
732
  };
733
- }, [p, c, v]), /* @__PURE__ */ wr.jsx(h.Provider, { value: i.current, children: a });
733
+ }, [p, s, v]), /* @__PURE__ */ wr.jsx(h.Provider, { value: i.current, children: a });
734
734
  },
735
735
  ["children", "onChangeProp", "onChangeReinit", "proxyRef"],
736
736
  h.name + ".Provider"
737
737
  );
738
738
  }
739
- function Yr(h, a = [], l, p, c = !0) {
739
+ function Yr(h, a = [], c, p, s = !0) {
740
740
  const b = mr(h);
741
741
  if (b === void 0)
742
742
  throw new Error(`No ${h.name} provider found.`);
743
743
  const i = Ce({ value: b }), v = Er((x) => {
744
744
  const E = b.subscribe(
745
745
  (T, P, k) => {
746
- i.current = { value: b }, x(), Y(l) && l(T, P, k);
746
+ i.current = { value: b }, x(), Y(c) && c(T, P, k);
747
747
  },
748
748
  (T, P) => {
749
- c && (i.current = { value: b }, x()), Y(p) && p(T, P);
749
+ s && (i.current = { value: b }, x()), Y(p) && p(T, P);
750
750
  },
751
751
  a
752
752
  );
753
753
  return () => b.unsubscribe(E);
754
- }, [a, c, l, p, b]), d = gr(
754
+ }, [a, s, c, p, b]), d = gr(
755
755
  v,
756
756
  () => i.current,
757
757
  () => i.current
@@ -763,7 +763,7 @@ function Yr(h, a = [], l, p, c = !0) {
763
763
  );
764
764
  }
765
765
  export {
766
- we as ProxyContextValueWrapper,
766
+ Z as ProxyContextValueWrapper,
767
767
  $r as createProxyContext,
768
768
  Wr as createProxyContextProvider,
769
769
  Or as evaluateDependency,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ptolemy2002/react-proxy-context",
3
3
  "private": false,
4
- "version": "2.4.0",
4
+ "version": "2.5.0",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",