cross-state 0.37.11 → 0.37.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.
Files changed (62) hide show
  1. package/dist/cjs/diff.cjs +6 -2
  2. package/dist/cjs/diff.cjs.map +1 -1
  3. package/dist/cjs/hash.cjs +5 -2
  4. package/dist/cjs/hash.cjs.map +1 -1
  5. package/dist/cjs/index.cjs +18 -13
  6. package/dist/cjs/index.cjs.map +1 -1
  7. package/dist/cjs/mutative/index.cjs +8 -3
  8. package/dist/cjs/mutative/index.cjs.map +1 -1
  9. package/dist/cjs/mutative/register.cjs +5 -3
  10. package/dist/cjs/mutative/register.cjs.map +1 -1
  11. package/dist/cjs/mutativeMethods.cjs +5 -2
  12. package/dist/cjs/mutativeMethods.cjs.map +1 -1
  13. package/dist/cjs/patches/index.cjs +7 -3
  14. package/dist/cjs/patches/index.cjs.map +1 -1
  15. package/dist/cjs/patches/register.cjs +5 -3
  16. package/dist/cjs/patches/register.cjs.map +1 -1
  17. package/dist/cjs/propAccess.cjs +6 -1
  18. package/dist/cjs/propAccess.cjs.map +1 -1
  19. package/dist/cjs/react/index.cjs +38 -36
  20. package/dist/cjs/react/index.cjs.map +1 -1
  21. package/dist/cjs/react/register.cjs +6 -4
  22. package/dist/cjs/react/register.cjs.map +1 -1
  23. package/dist/cjs/scope.cjs +32 -43
  24. package/dist/cjs/scope.cjs.map +1 -1
  25. package/dist/cjs/store.cjs +53 -46
  26. package/dist/cjs/store.cjs.map +1 -1
  27. package/dist/cjs/storeMethods.cjs +468 -342
  28. package/dist/cjs/storeMethods.cjs.map +1 -1
  29. package/dist/cjs/urlStore.cjs +9 -6
  30. package/dist/cjs/urlStore.cjs.map +1 -1
  31. package/dist/es/diff.mjs +5 -5
  32. package/dist/es/diff.mjs.map +1 -1
  33. package/dist/es/hash.mjs +4 -4
  34. package/dist/es/hash.mjs.map +1 -1
  35. package/dist/es/index.mjs +17 -42
  36. package/dist/es/index.mjs.map +1 -1
  37. package/dist/es/mutative/index.mjs +1 -4
  38. package/dist/es/mutative/index.mjs.map +1 -1
  39. package/dist/es/mutative/register.mjs +3 -2
  40. package/dist/es/mutative/register.mjs.map +1 -1
  41. package/dist/es/mutativeMethods.mjs +4 -4
  42. package/dist/es/mutativeMethods.mjs.map +1 -1
  43. package/dist/es/patches/index.mjs +4 -4
  44. package/dist/es/patches/index.mjs.map +1 -1
  45. package/dist/es/patches/register.mjs +3 -2
  46. package/dist/es/patches/register.mjs.map +1 -1
  47. package/dist/es/propAccess.mjs +5 -12
  48. package/dist/es/propAccess.mjs.map +1 -1
  49. package/dist/es/react/index.mjs +36 -52
  50. package/dist/es/react/index.mjs.map +1 -1
  51. package/dist/es/react/register.mjs +4 -3
  52. package/dist/es/react/register.mjs.map +1 -1
  53. package/dist/es/scope.mjs +31 -52
  54. package/dist/es/scope.mjs.map +1 -1
  55. package/dist/es/store.mjs +52 -62
  56. package/dist/es/store.mjs.map +1 -1
  57. package/dist/es/storeMethods.mjs +456 -342
  58. package/dist/es/storeMethods.mjs.map +1 -1
  59. package/dist/es/urlStore.mjs +5 -7
  60. package/dist/es/urlStore.mjs.map +1 -1
  61. package/dist/types/react/useCache.d.ts +1 -1
  62. package/package.json +1 -1
@@ -1,8 +1,9 @@
1
- import { m as makeSelector, c as createStore } from "./store.mjs";
2
- import require$$0, { useRef, useMemo, useCallback, useLayoutEffect, useDebugValue, createContext, useContext, useEffect } from "react";
3
- import { jsx, jsxs, Fragment } from "react/jsx-runtime";
4
- import { i as isPlainObject, d as deepEqual } from "./propAccess.mjs";
5
- import { h as hash } from "./hash.mjs";
1
+ import { m as makeSelector, c as createStore } from './store.mjs';
2
+ import require$$0, { useRef, useMemo, useCallback, useLayoutEffect, useDebugValue, createContext, useContext, useEffect } from 'react';
3
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
+ import { i as isPlainObject, d as deepEqual } from './propAccess.mjs';
5
+ import { h as hash } from './hash.mjs';
6
+
6
7
  const unwrapProxySymbol = /* @__PURE__ */ Symbol("unwrapProxy");
7
8
  function trackingProxy(value, equals = deepEqual) {
8
9
  if (!isPlainObject(value) && !Array.isArray(value)) {
@@ -75,10 +76,15 @@ function trackingProxy(value, equals = deepEqual) {
75
76
  }
76
77
  ];
77
78
  }
78
- var withSelector = { exports: {} };
79
+
80
+ var withSelector = {exports: {}};
81
+
79
82
  var withSelector_production_min = {};
80
- var shim = { exports: {} };
83
+
84
+ var shim = {exports: {}};
85
+
81
86
  var useSyncExternalStoreShim_production_min = {};
87
+
82
88
  /**
83
89
  * @license React
84
90
  * use-sync-external-store-shim.production.min.js
@@ -88,50 +94,19 @@ var useSyncExternalStoreShim_production_min = {};
88
94
  * This source code is licensed under the MIT license found in the
89
95
  * LICENSE file in the root directory of this source tree.
90
96
  */
97
+
91
98
  var hasRequiredUseSyncExternalStoreShim_production_min;
92
- function requireUseSyncExternalStoreShim_production_min() {
93
- if (hasRequiredUseSyncExternalStoreShim_production_min)
94
- return useSyncExternalStoreShim_production_min;
95
- hasRequiredUseSyncExternalStoreShim_production_min = 1;
96
- var e = require$$0;
97
- function h(a, b) {
98
- return a === b && (0 !== a || 1 / a === 1 / b) || a !== a && b !== b;
99
- }
100
- var k = "function" === typeof Object.is ? Object.is : h, l = e.useState, m = e.useEffect, n = e.useLayoutEffect, p = e.useDebugValue;
101
- function q(a, b) {
102
- var d = b(), f = l({ inst: { value: d, getSnapshot: b } }), c = f[0].inst, g = f[1];
103
- n(function() {
104
- c.value = d;
105
- c.getSnapshot = b;
106
- r(c) && g({ inst: c });
107
- }, [a, d, b]);
108
- m(function() {
109
- r(c) && g({ inst: c });
110
- return a(function() {
111
- r(c) && g({ inst: c });
112
- });
113
- }, [a]);
114
- p(d);
115
- return d;
116
- }
117
- function r(a) {
118
- var b = a.getSnapshot;
119
- a = a.value;
120
- try {
121
- var d = b();
122
- return !k(a, d);
123
- } catch (f) {
124
- return true;
125
- }
126
- }
127
- function t(a, b) {
128
- return b();
129
- }
130
- var u = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? t : q;
131
- useSyncExternalStoreShim_production_min.useSyncExternalStore = void 0 !== e.useSyncExternalStore ? e.useSyncExternalStore : u;
132
- return useSyncExternalStoreShim_production_min;
99
+
100
+ function requireUseSyncExternalStoreShim_production_min () {
101
+ if (hasRequiredUseSyncExternalStoreShim_production_min) return useSyncExternalStoreShim_production_min;
102
+ hasRequiredUseSyncExternalStoreShim_production_min = 1;
103
+ var e=require$$0;function h(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var k="function"===typeof Object.is?Object.is:h,l=e.useState,m=e.useEffect,n=e.useLayoutEffect,p=e.useDebugValue;function q(a,b){var d=b(),f=l({inst:{value:d,getSnapshot:b}}),c=f[0].inst,g=f[1];n(function(){c.value=d;c.getSnapshot=b;r(c)&&g({inst:c});},[a,d,b]);m(function(){r(c)&&g({inst:c});return a(function(){r(c)&&g({inst:c});})},[a]);p(d);return d}
104
+ function r(a){var b=a.getSnapshot;a=a.value;try{var d=b();return !k(a,d)}catch(f){return !0}}function t(a,b){return b()}var u="undefined"===typeof window||"undefined"===typeof window.document||"undefined"===typeof window.document.createElement?t:q;useSyncExternalStoreShim_production_min.useSyncExternalStore=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:u;
105
+ return useSyncExternalStoreShim_production_min;
133
106
  }
107
+
134
108
  var useSyncExternalStoreShim_development = {};
109
+
135
110
  /**
136
111
  * @license React
137
112
  * use-sync-external-store-shim.development.js
@@ -141,139 +116,255 @@ var useSyncExternalStoreShim_development = {};
141
116
  * This source code is licensed under the MIT license found in the
142
117
  * LICENSE file in the root directory of this source tree.
143
118
  */
119
+
144
120
  var hasRequiredUseSyncExternalStoreShim_development;
145
- function requireUseSyncExternalStoreShim_development() {
146
- if (hasRequiredUseSyncExternalStoreShim_development)
147
- return useSyncExternalStoreShim_development;
148
- hasRequiredUseSyncExternalStoreShim_development = 1;
149
- if (process.env.NODE_ENV !== "production") {
150
- (function() {
151
- if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function") {
152
- __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
153
- }
154
- var React = require$$0;
155
- var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
156
- function error(format) {
157
- {
158
- {
159
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
160
- args[_key2 - 1] = arguments[_key2];
161
- }
162
- printWarning("error", format, args);
163
- }
164
- }
165
- }
166
- function printWarning(level, format, args) {
167
- {
168
- var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
169
- var stack = ReactDebugCurrentFrame.getStackAddendum();
170
- if (stack !== "") {
171
- format += "%s";
172
- args = args.concat([stack]);
173
- }
174
- var argsWithFormat = args.map(function(item) {
175
- return String(item);
176
- });
177
- argsWithFormat.unshift("Warning: " + format);
178
- Function.prototype.apply.call(console[level], console, argsWithFormat);
179
- }
180
- }
181
- function is(x, y) {
182
- return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y;
183
- }
184
- var objectIs = typeof Object.is === "function" ? Object.is : is;
185
- var useState = React.useState, useEffect2 = React.useEffect, useLayoutEffect2 = React.useLayoutEffect, useDebugValue2 = React.useDebugValue;
186
- var didWarnOld18Alpha = false;
187
- var didWarnUncachedGetSnapshot = false;
188
- function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
189
- {
190
- if (!didWarnOld18Alpha) {
191
- if (React.startTransition !== void 0) {
192
- didWarnOld18Alpha = true;
193
- error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release.");
194
- }
195
- }
196
- }
197
- var value = getSnapshot();
198
- {
199
- if (!didWarnUncachedGetSnapshot) {
200
- var cachedValue = getSnapshot();
201
- if (!objectIs(value, cachedValue)) {
202
- error("The result of getSnapshot should be cached to avoid an infinite loop");
203
- didWarnUncachedGetSnapshot = true;
204
- }
205
- }
206
- }
207
- var _useState = useState({
208
- inst: {
209
- value,
210
- getSnapshot
211
- }
212
- }), inst = _useState[0].inst, forceUpdate = _useState[1];
213
- useLayoutEffect2(function() {
214
- inst.value = value;
215
- inst.getSnapshot = getSnapshot;
216
- if (checkIfSnapshotChanged(inst)) {
217
- forceUpdate({
218
- inst
219
- });
220
- }
221
- }, [subscribe, value, getSnapshot]);
222
- useEffect2(function() {
223
- if (checkIfSnapshotChanged(inst)) {
224
- forceUpdate({
225
- inst
226
- });
227
- }
228
- var handleStoreChange = function() {
229
- if (checkIfSnapshotChanged(inst)) {
230
- forceUpdate({
231
- inst
232
- });
233
- }
234
- };
235
- return subscribe(handleStoreChange);
236
- }, [subscribe]);
237
- useDebugValue2(value);
238
- return value;
239
- }
240
- function checkIfSnapshotChanged(inst) {
241
- var latestGetSnapshot = inst.getSnapshot;
242
- var prevValue = inst.value;
243
- try {
244
- var nextValue = latestGetSnapshot();
245
- return !objectIs(prevValue, nextValue);
246
- } catch (error2) {
247
- return true;
248
- }
249
- }
250
- function useSyncExternalStore$1(subscribe, getSnapshot, getServerSnapshot) {
251
- return getSnapshot();
252
- }
253
- var canUseDOM = !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
254
- var isServerEnvironment = !canUseDOM;
255
- var shim2 = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore;
256
- var useSyncExternalStore$2 = React.useSyncExternalStore !== void 0 ? React.useSyncExternalStore : shim2;
257
- useSyncExternalStoreShim_development.useSyncExternalStore = useSyncExternalStore$2;
258
- if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === "function") {
259
- __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
260
- }
261
- })();
262
- }
263
- return useSyncExternalStoreShim_development;
121
+
122
+ function requireUseSyncExternalStoreShim_development () {
123
+ if (hasRequiredUseSyncExternalStoreShim_development) return useSyncExternalStoreShim_development;
124
+ hasRequiredUseSyncExternalStoreShim_development = 1;
125
+
126
+ if (process.env.NODE_ENV !== "production") {
127
+ (function() {
128
+
129
+ /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
130
+ if (
131
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
132
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===
133
+ 'function'
134
+ ) {
135
+ __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
136
+ }
137
+ var React = require$$0;
138
+
139
+ var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
140
+
141
+ function error(format) {
142
+ {
143
+ {
144
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
145
+ args[_key2 - 1] = arguments[_key2];
146
+ }
147
+
148
+ printWarning('error', format, args);
149
+ }
150
+ }
151
+ }
152
+
153
+ function printWarning(level, format, args) {
154
+ // When changing this logic, you might want to also
155
+ // update consoleWithStackDev.www.js as well.
156
+ {
157
+ var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
158
+ var stack = ReactDebugCurrentFrame.getStackAddendum();
159
+
160
+ if (stack !== '') {
161
+ format += '%s';
162
+ args = args.concat([stack]);
163
+ } // eslint-disable-next-line react-internal/safe-string-coercion
164
+
165
+
166
+ var argsWithFormat = args.map(function (item) {
167
+ return String(item);
168
+ }); // Careful: RN currently depends on this prefix
169
+
170
+ argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
171
+ // breaks IE9: https://github.com/facebook/react/issues/13610
172
+ // eslint-disable-next-line react-internal/no-production-logging
173
+
174
+ Function.prototype.apply.call(console[level], console, argsWithFormat);
175
+ }
176
+ }
177
+
178
+ /**
179
+ * inlined Object.is polyfill to avoid requiring consumers ship their own
180
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
181
+ */
182
+ function is(x, y) {
183
+ return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
184
+ ;
185
+ }
186
+
187
+ var objectIs = typeof Object.is === 'function' ? Object.is : is;
188
+
189
+ // dispatch for CommonJS interop named imports.
190
+
191
+ var useState = React.useState,
192
+ useEffect = React.useEffect,
193
+ useLayoutEffect = React.useLayoutEffect,
194
+ useDebugValue = React.useDebugValue;
195
+ var didWarnOld18Alpha = false;
196
+ var didWarnUncachedGetSnapshot = false; // Disclaimer: This shim breaks many of the rules of React, and only works
197
+ // because of a very particular set of implementation details and assumptions
198
+ // -- change any one of them and it will break. The most important assumption
199
+ // is that updates are always synchronous, because concurrent rendering is
200
+ // only available in versions of React that also have a built-in
201
+ // useSyncExternalStore API. And we only use this shim when the built-in API
202
+ // does not exist.
203
+ //
204
+ // Do not assume that the clever hacks used by this hook also work in general.
205
+ // The point of this shim is to replace the need for hacks by other libraries.
206
+
207
+ function useSyncExternalStore(subscribe, getSnapshot, // Note: The shim does not use getServerSnapshot, because pre-18 versions of
208
+ // React do not expose a way to check if we're hydrating. So users of the shim
209
+ // will need to track that themselves and return the correct value
210
+ // from `getSnapshot`.
211
+ getServerSnapshot) {
212
+ {
213
+ if (!didWarnOld18Alpha) {
214
+ if (React.startTransition !== undefined) {
215
+ didWarnOld18Alpha = true;
216
+
217
+ error('You are using an outdated, pre-release alpha of React 18 that ' + 'does not support useSyncExternalStore. The ' + 'use-sync-external-store shim will not work correctly. Upgrade ' + 'to a newer pre-release.');
218
+ }
219
+ }
220
+ } // Read the current snapshot from the store on every render. Again, this
221
+ // breaks the rules of React, and only works here because of specific
222
+ // implementation details, most importantly that updates are
223
+ // always synchronous.
224
+
225
+
226
+ var value = getSnapshot();
227
+
228
+ {
229
+ if (!didWarnUncachedGetSnapshot) {
230
+ var cachedValue = getSnapshot();
231
+
232
+ if (!objectIs(value, cachedValue)) {
233
+ error('The result of getSnapshot should be cached to avoid an infinite loop');
234
+
235
+ didWarnUncachedGetSnapshot = true;
236
+ }
237
+ }
238
+ } // Because updates are synchronous, we don't queue them. Instead we force a
239
+ // re-render whenever the subscribed state changes by updating an some
240
+ // arbitrary useState hook. Then, during render, we call getSnapshot to read
241
+ // the current value.
242
+ //
243
+ // Because we don't actually use the state returned by the useState hook, we
244
+ // can save a bit of memory by storing other stuff in that slot.
245
+ //
246
+ // To implement the early bailout, we need to track some things on a mutable
247
+ // object. Usually, we would put that in a useRef hook, but we can stash it in
248
+ // our useState hook instead.
249
+ //
250
+ // To force a re-render, we call forceUpdate({inst}). That works because the
251
+ // new object always fails an equality check.
252
+
253
+
254
+ var _useState = useState({
255
+ inst: {
256
+ value: value,
257
+ getSnapshot: getSnapshot
258
+ }
259
+ }),
260
+ inst = _useState[0].inst,
261
+ forceUpdate = _useState[1]; // Track the latest getSnapshot function with a ref. This needs to be updated
262
+ // in the layout phase so we can access it during the tearing check that
263
+ // happens on subscribe.
264
+
265
+
266
+ useLayoutEffect(function () {
267
+ inst.value = value;
268
+ inst.getSnapshot = getSnapshot; // Whenever getSnapshot or subscribe changes, we need to check in the
269
+ // commit phase if there was an interleaved mutation. In concurrent mode
270
+ // this can happen all the time, but even in synchronous mode, an earlier
271
+ // effect may have mutated the store.
272
+
273
+ if (checkIfSnapshotChanged(inst)) {
274
+ // Force a re-render.
275
+ forceUpdate({
276
+ inst: inst
277
+ });
278
+ }
279
+ }, [subscribe, value, getSnapshot]);
280
+ useEffect(function () {
281
+ // Check for changes right before subscribing. Subsequent changes will be
282
+ // detected in the subscription handler.
283
+ if (checkIfSnapshotChanged(inst)) {
284
+ // Force a re-render.
285
+ forceUpdate({
286
+ inst: inst
287
+ });
288
+ }
289
+
290
+ var handleStoreChange = function () {
291
+ // TODO: Because there is no cross-renderer API for batching updates, it's
292
+ // up to the consumer of this library to wrap their subscription event
293
+ // with unstable_batchedUpdates. Should we try to detect when this isn't
294
+ // the case and print a warning in development?
295
+ // The store changed. Check if the snapshot changed since the last time we
296
+ // read from the store.
297
+ if (checkIfSnapshotChanged(inst)) {
298
+ // Force a re-render.
299
+ forceUpdate({
300
+ inst: inst
301
+ });
302
+ }
303
+ }; // Subscribe to the store and return a clean-up function.
304
+
305
+
306
+ return subscribe(handleStoreChange);
307
+ }, [subscribe]);
308
+ useDebugValue(value);
309
+ return value;
310
+ }
311
+
312
+ function checkIfSnapshotChanged(inst) {
313
+ var latestGetSnapshot = inst.getSnapshot;
314
+ var prevValue = inst.value;
315
+
316
+ try {
317
+ var nextValue = latestGetSnapshot();
318
+ return !objectIs(prevValue, nextValue);
319
+ } catch (error) {
320
+ return true;
321
+ }
322
+ }
323
+
324
+ function useSyncExternalStore$1(subscribe, getSnapshot, getServerSnapshot) {
325
+ // Note: The shim does not use getServerSnapshot, because pre-18 versions of
326
+ // React do not expose a way to check if we're hydrating. So users of the shim
327
+ // will need to track that themselves and return the correct value
328
+ // from `getSnapshot`.
329
+ return getSnapshot();
330
+ }
331
+
332
+ var canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined');
333
+
334
+ var isServerEnvironment = !canUseDOM;
335
+
336
+ var shim = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore;
337
+ var useSyncExternalStore$2 = React.useSyncExternalStore !== undefined ? React.useSyncExternalStore : shim;
338
+
339
+ useSyncExternalStoreShim_development.useSyncExternalStore = useSyncExternalStore$2;
340
+ /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
341
+ if (
342
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
343
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===
344
+ 'function'
345
+ ) {
346
+ __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
347
+ }
348
+
349
+ })();
350
+ }
351
+ return useSyncExternalStoreShim_development;
264
352
  }
353
+
265
354
  var hasRequiredShim;
266
- function requireShim() {
267
- if (hasRequiredShim)
268
- return shim.exports;
269
- hasRequiredShim = 1;
270
- if (process.env.NODE_ENV === "production") {
271
- shim.exports = requireUseSyncExternalStoreShim_production_min();
272
- } else {
273
- shim.exports = requireUseSyncExternalStoreShim_development();
274
- }
275
- return shim.exports;
355
+
356
+ function requireShim () {
357
+ if (hasRequiredShim) return shim.exports;
358
+ hasRequiredShim = 1;
359
+
360
+ if (process.env.NODE_ENV === 'production') {
361
+ shim.exports = requireUseSyncExternalStoreShim_production_min();
362
+ } else {
363
+ shim.exports = requireUseSyncExternalStoreShim_development();
364
+ }
365
+ return shim.exports;
276
366
  }
367
+
277
368
  /**
278
369
  * @license React
279
370
  * use-sync-external-store-shim/with-selector.production.min.js
@@ -283,63 +374,20 @@ function requireShim() {
283
374
  * This source code is licensed under the MIT license found in the
284
375
  * LICENSE file in the root directory of this source tree.
285
376
  */
377
+
286
378
  var hasRequiredWithSelector_production_min;
287
- function requireWithSelector_production_min() {
288
- if (hasRequiredWithSelector_production_min)
289
- return withSelector_production_min;
290
- hasRequiredWithSelector_production_min = 1;
291
- var h = require$$0, n = requireShim();
292
- function p(a, b) {
293
- return a === b && (0 !== a || 1 / a === 1 / b) || a !== a && b !== b;
294
- }
295
- var q = "function" === typeof Object.is ? Object.is : p, r = n.useSyncExternalStore, t = h.useRef, u = h.useEffect, v = h.useMemo, w = h.useDebugValue;
296
- withSelector_production_min.useSyncExternalStoreWithSelector = function(a, b, e, l, g) {
297
- var c = t(null);
298
- if (null === c.current) {
299
- var f = { hasValue: false, value: null };
300
- c.current = f;
301
- } else
302
- f = c.current;
303
- c = v(function() {
304
- function a2(a3) {
305
- if (!c2) {
306
- c2 = true;
307
- d2 = a3;
308
- a3 = l(a3);
309
- if (void 0 !== g && f.hasValue) {
310
- var b2 = f.value;
311
- if (g(b2, a3))
312
- return k = b2;
313
- }
314
- return k = a3;
315
- }
316
- b2 = k;
317
- if (q(d2, a3))
318
- return b2;
319
- var e2 = l(a3);
320
- if (void 0 !== g && g(b2, e2))
321
- return b2;
322
- d2 = a3;
323
- return k = e2;
324
- }
325
- var c2 = false, d2, k, m = void 0 === e ? null : e;
326
- return [function() {
327
- return a2(b());
328
- }, null === m ? void 0 : function() {
329
- return a2(m());
330
- }];
331
- }, [b, e, l, g]);
332
- var d = r(a, c[0], c[1]);
333
- u(function() {
334
- f.hasValue = true;
335
- f.value = d;
336
- }, [d]);
337
- w(d);
338
- return d;
339
- };
340
- return withSelector_production_min;
379
+
380
+ function requireWithSelector_production_min () {
381
+ if (hasRequiredWithSelector_production_min) return withSelector_production_min;
382
+ hasRequiredWithSelector_production_min = 1;
383
+ var h=require$$0,n=requireShim();function p(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var q="function"===typeof Object.is?Object.is:p,r=n.useSyncExternalStore,t=h.useRef,u=h.useEffect,v=h.useMemo,w=h.useDebugValue;
384
+ withSelector_production_min.useSyncExternalStoreWithSelector=function(a,b,e,l,g){var c=t(null);if(null===c.current){var f={hasValue:!1,value:null};c.current=f;}else f=c.current;c=v(function(){function a(a){if(!c){c=!0;d=a;a=l(a);if(void 0!==g&&f.hasValue){var b=f.value;if(g(b,a))return k=b}return k=a}b=k;if(q(d,a))return b;var e=l(a);if(void 0!==g&&g(b,e))return b;d=a;return k=e}var c=!1,d,k,m=void 0===e?null:e;return [function(){return a(b())},null===m?void 0:function(){return a(m())}]},[b,e,l,g]);var d=r(a,c[0],c[1]);
385
+ u(function(){f.hasValue=!0;f.value=d;},[d]);w(d);return d};
386
+ return withSelector_production_min;
341
387
  }
388
+
342
389
  var withSelector_development = {};
390
+
343
391
  /**
344
392
  * @license React
345
393
  * use-sync-external-store-shim/with-selector.development.js
@@ -349,101 +397,175 @@ var withSelector_development = {};
349
397
  * This source code is licensed under the MIT license found in the
350
398
  * LICENSE file in the root directory of this source tree.
351
399
  */
400
+
352
401
  var hasRequiredWithSelector_development;
353
- function requireWithSelector_development() {
354
- if (hasRequiredWithSelector_development)
355
- return withSelector_development;
356
- hasRequiredWithSelector_development = 1;
357
- if (process.env.NODE_ENV !== "production") {
358
- (function() {
359
- if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function") {
360
- __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
361
- }
362
- var React = require$$0;
363
- var shim2 = requireShim();
364
- function is(x, y) {
365
- return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y;
366
- }
367
- var objectIs = typeof Object.is === "function" ? Object.is : is;
368
- var useSyncExternalStore = shim2.useSyncExternalStore;
369
- var useRef2 = React.useRef, useEffect2 = React.useEffect, useMemo2 = React.useMemo, useDebugValue2 = React.useDebugValue;
370
- function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
371
- var instRef = useRef2(null);
372
- var inst;
373
- if (instRef.current === null) {
374
- inst = {
375
- hasValue: false,
376
- value: null
377
- };
378
- instRef.current = inst;
379
- } else {
380
- inst = instRef.current;
381
- }
382
- var _useMemo = useMemo2(function() {
383
- var hasMemo = false;
384
- var memoizedSnapshot;
385
- var memoizedSelection;
386
- var memoizedSelector = function(nextSnapshot) {
387
- if (!hasMemo) {
388
- hasMemo = true;
389
- memoizedSnapshot = nextSnapshot;
390
- var _nextSelection = selector(nextSnapshot);
391
- if (isEqual !== void 0) {
392
- if (inst.hasValue) {
393
- var currentSelection = inst.value;
394
- if (isEqual(currentSelection, _nextSelection)) {
395
- memoizedSelection = currentSelection;
396
- return currentSelection;
397
- }
398
- }
399
- }
400
- memoizedSelection = _nextSelection;
401
- return _nextSelection;
402
- }
403
- var prevSnapshot = memoizedSnapshot;
404
- var prevSelection = memoizedSelection;
405
- if (objectIs(prevSnapshot, nextSnapshot)) {
406
- return prevSelection;
407
- }
408
- var nextSelection = selector(nextSnapshot);
409
- if (isEqual !== void 0 && isEqual(prevSelection, nextSelection)) {
410
- return prevSelection;
411
- }
412
- memoizedSnapshot = nextSnapshot;
413
- memoizedSelection = nextSelection;
414
- return nextSelection;
415
- };
416
- var maybeGetServerSnapshot = getServerSnapshot === void 0 ? null : getServerSnapshot;
417
- var getSnapshotWithSelector = function() {
418
- return memoizedSelector(getSnapshot());
419
- };
420
- var getServerSnapshotWithSelector = maybeGetServerSnapshot === null ? void 0 : function() {
421
- return memoizedSelector(maybeGetServerSnapshot());
422
- };
423
- return [getSnapshotWithSelector, getServerSnapshotWithSelector];
424
- }, [getSnapshot, getServerSnapshot, selector, isEqual]), getSelection = _useMemo[0], getServerSelection = _useMemo[1];
425
- var value = useSyncExternalStore(subscribe, getSelection, getServerSelection);
426
- useEffect2(function() {
427
- inst.hasValue = true;
428
- inst.value = value;
429
- }, [value]);
430
- useDebugValue2(value);
431
- return value;
432
- }
433
- withSelector_development.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector;
434
- if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === "function") {
435
- __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
436
- }
437
- })();
438
- }
439
- return withSelector_development;
402
+
403
+ function requireWithSelector_development () {
404
+ if (hasRequiredWithSelector_development) return withSelector_development;
405
+ hasRequiredWithSelector_development = 1;
406
+
407
+ if (process.env.NODE_ENV !== "production") {
408
+ (function() {
409
+
410
+ /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
411
+ if (
412
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
413
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===
414
+ 'function'
415
+ ) {
416
+ __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
417
+ }
418
+ var React = require$$0;
419
+ var shim = requireShim();
420
+
421
+ /**
422
+ * inlined Object.is polyfill to avoid requiring consumers ship their own
423
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
424
+ */
425
+ function is(x, y) {
426
+ return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
427
+ ;
428
+ }
429
+
430
+ var objectIs = typeof Object.is === 'function' ? Object.is : is;
431
+
432
+ var useSyncExternalStore = shim.useSyncExternalStore;
433
+
434
+ // for CommonJS interop.
435
+
436
+ var useRef = React.useRef,
437
+ useEffect = React.useEffect,
438
+ useMemo = React.useMemo,
439
+ useDebugValue = React.useDebugValue; // Same as useSyncExternalStore, but supports selector and isEqual arguments.
440
+
441
+ function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
442
+ // Use this to track the rendered snapshot.
443
+ var instRef = useRef(null);
444
+ var inst;
445
+
446
+ if (instRef.current === null) {
447
+ inst = {
448
+ hasValue: false,
449
+ value: null
450
+ };
451
+ instRef.current = inst;
452
+ } else {
453
+ inst = instRef.current;
454
+ }
455
+
456
+ var _useMemo = useMemo(function () {
457
+ // Track the memoized state using closure variables that are local to this
458
+ // memoized instance of a getSnapshot function. Intentionally not using a
459
+ // useRef hook, because that state would be shared across all concurrent
460
+ // copies of the hook/component.
461
+ var hasMemo = false;
462
+ var memoizedSnapshot;
463
+ var memoizedSelection;
464
+
465
+ var memoizedSelector = function (nextSnapshot) {
466
+ if (!hasMemo) {
467
+ // The first time the hook is called, there is no memoized result.
468
+ hasMemo = true;
469
+ memoizedSnapshot = nextSnapshot;
470
+
471
+ var _nextSelection = selector(nextSnapshot);
472
+
473
+ if (isEqual !== undefined) {
474
+ // Even if the selector has changed, the currently rendered selection
475
+ // may be equal to the new selection. We should attempt to reuse the
476
+ // current value if possible, to preserve downstream memoizations.
477
+ if (inst.hasValue) {
478
+ var currentSelection = inst.value;
479
+
480
+ if (isEqual(currentSelection, _nextSelection)) {
481
+ memoizedSelection = currentSelection;
482
+ return currentSelection;
483
+ }
484
+ }
485
+ }
486
+
487
+ memoizedSelection = _nextSelection;
488
+ return _nextSelection;
489
+ } // We may be able to reuse the previous invocation's result.
490
+
491
+
492
+ // We may be able to reuse the previous invocation's result.
493
+ var prevSnapshot = memoizedSnapshot;
494
+ var prevSelection = memoizedSelection;
495
+
496
+ if (objectIs(prevSnapshot, nextSnapshot)) {
497
+ // The snapshot is the same as last time. Reuse the previous selection.
498
+ return prevSelection;
499
+ } // The snapshot has changed, so we need to compute a new selection.
500
+
501
+
502
+ // The snapshot has changed, so we need to compute a new selection.
503
+ var nextSelection = selector(nextSnapshot); // If a custom isEqual function is provided, use that to check if the data
504
+ // has changed. If it hasn't, return the previous selection. That signals
505
+ // to React that the selections are conceptually equal, and we can bail
506
+ // out of rendering.
507
+
508
+ // If a custom isEqual function is provided, use that to check if the data
509
+ // has changed. If it hasn't, return the previous selection. That signals
510
+ // to React that the selections are conceptually equal, and we can bail
511
+ // out of rendering.
512
+ if (isEqual !== undefined && isEqual(prevSelection, nextSelection)) {
513
+ return prevSelection;
514
+ }
515
+
516
+ memoizedSnapshot = nextSnapshot;
517
+ memoizedSelection = nextSelection;
518
+ return nextSelection;
519
+ }; // Assigning this to a constant so that Flow knows it can't change.
520
+
521
+
522
+ // Assigning this to a constant so that Flow knows it can't change.
523
+ var maybeGetServerSnapshot = getServerSnapshot === undefined ? null : getServerSnapshot;
524
+
525
+ var getSnapshotWithSelector = function () {
526
+ return memoizedSelector(getSnapshot());
527
+ };
528
+
529
+ var getServerSnapshotWithSelector = maybeGetServerSnapshot === null ? undefined : function () {
530
+ return memoizedSelector(maybeGetServerSnapshot());
531
+ };
532
+ return [getSnapshotWithSelector, getServerSnapshotWithSelector];
533
+ }, [getSnapshot, getServerSnapshot, selector, isEqual]),
534
+ getSelection = _useMemo[0],
535
+ getServerSelection = _useMemo[1];
536
+
537
+ var value = useSyncExternalStore(subscribe, getSelection, getServerSelection);
538
+ useEffect(function () {
539
+ inst.hasValue = true;
540
+ inst.value = value;
541
+ }, [value]);
542
+ useDebugValue(value);
543
+ return value;
544
+ }
545
+
546
+ withSelector_development.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector;
547
+ /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
548
+ if (
549
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
550
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===
551
+ 'function'
552
+ ) {
553
+ __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
554
+ }
555
+
556
+ })();
557
+ }
558
+ return withSelector_development;
440
559
  }
441
- if (process.env.NODE_ENV === "production") {
560
+
561
+ if (process.env.NODE_ENV === 'production') {
442
562
  withSelector.exports = requireWithSelector_production_min();
443
563
  } else {
444
564
  withSelector.exports = requireWithSelector_development();
445
565
  }
566
+
446
567
  var withSelectorExports = withSelector.exports;
568
+
447
569
  function useStore(store, argument1, argument2) {
448
570
  const selector = makeSelector(
449
571
  typeof argument1 === "function" || typeof argument1 === "string" ? argument1 : void 0
@@ -456,8 +578,7 @@ function useStore(store, argument1, argument2) {
456
578
  } = typeof argument1 === "object" ? argument1 : argument2 ?? {};
457
579
  const lastEqualsRef = useRef();
458
580
  const { rootStore, mappingSelector } = useMemo(() => {
459
- var _a;
460
- const rootStore2 = ((_a = store.derivedFrom) == null ? void 0 : _a.store) ?? store;
581
+ const rootStore2 = store.derivedFrom?.store ?? store;
461
582
  let mappingSelector2 = (x) => x;
462
583
  if (store.derivedFrom) {
463
584
  mappingSelector2 = (value2) => {
@@ -506,10 +627,7 @@ function useStore(store, argument1, argument2) {
506
627
  rootStore.get,
507
628
  void 0,
508
629
  (x) => selector(mappingSelector(x)),
509
- (_v, newValue) => {
510
- var _a;
511
- return ((_a = lastEqualsRef.current) == null ? void 0 : _a.call(lastEqualsRef, newValue)) ?? false;
512
- }
630
+ (_v, newValue) => lastEqualsRef.current?.(newValue) ?? false
513
631
  );
514
632
  let lastEquals = (newValue) => equals(newValue, value);
515
633
  let revoke;
@@ -518,11 +636,12 @@ function useStore(store, argument1, argument2) {
518
636
  }
519
637
  useLayoutEffect(() => {
520
638
  lastEqualsRef.current = lastEquals;
521
- revoke == null ? void 0 : revoke();
639
+ revoke?.();
522
640
  });
523
641
  useDebugValue(value);
524
642
  return value;
525
643
  }
644
+
526
645
  const LoadingBoundaryContext = createContext(createStore(/* @__PURE__ */ new Set()));
527
646
  function LoadingBoundary({
528
647
  fallback,
@@ -555,21 +674,21 @@ function useLoadingBoundary(isLoading, label) {
555
674
  };
556
675
  }, [isLoading]);
557
676
  }
677
+
558
678
  function useCache(cache, {
559
679
  passive,
560
680
  disabled,
561
681
  updateOnMount,
562
682
  withViewTransition,
563
683
  suspense,
564
- loadingBoundary = true,
684
+ loadingBoundary,
565
685
  ...options
566
686
  } = {}) {
567
687
  if (withViewTransition === true) {
568
688
  withViewTransition = (state) => state.value;
569
689
  }
570
690
  const { rootCache, selector } = useMemo(() => {
571
- var _a;
572
- const rootCache2 = ((_a = cache.derivedFromCache) == null ? void 0 : _a.cache) ?? cache;
691
+ const rootCache2 = cache.derivedFromCache?.cache ?? cache;
573
692
  let selector2 = (x) => x;
574
693
  if (cache.derivedFromCache) {
575
694
  selector2 = (value) => {
@@ -625,11 +744,13 @@ function useCache(cache, {
625
744
  }
626
745
  return result;
627
746
  }
747
+
628
748
  const cacheMethods = {
629
749
  useCache(options) {
630
750
  return useCache(this, options);
631
751
  }
632
752
  };
753
+
633
754
  function useProp(store, argument1, argument2, argument3) {
634
755
  const selector = typeof argument1 === "function" || typeof argument1 === "string" ? argument1 : void 0;
635
756
  const updater = typeof argument2 === "function" ? argument2 : void 0;
@@ -640,8 +761,9 @@ function useProp(store, argument1, argument2, argument3) {
640
761
  const value = useStore(store, options);
641
762
  return [value, store.set];
642
763
  }
764
+
643
765
  function getScopeContext(scope) {
644
- scope.context ?? (scope.context = createContext(createStore(scope.defaultValue)));
766
+ scope.context ??= createContext(createStore(scope.defaultValue));
645
767
  return scope.context;
646
768
  }
647
769
  function ScopeProvider({
@@ -668,6 +790,7 @@ function useScopeProp(scope, options) {
668
790
  const store = useScope(scope);
669
791
  return useProp(store, options);
670
792
  }
793
+
671
794
  const scopeMethods = {
672
795
  useScope() {
673
796
  return useScope(this);
@@ -682,6 +805,7 @@ const scopeMethods = {
682
805
  return ScopeProvider({ ...props, scope: this });
683
806
  }
684
807
  };
808
+
685
809
  function boundUseStore(...args) {
686
810
  return useStore(this, ...args);
687
811
  }
@@ -692,16 +816,6 @@ const storeMethods = {
692
816
  useStore: boundUseStore,
693
817
  useProp: boundUseProp
694
818
  };
695
- export {
696
- LoadingBoundary as L,
697
- ScopeProvider as S,
698
- scopeMethods as a,
699
- useLoadingBoundary as b,
700
- cacheMethods as c,
701
- useScope as d,
702
- useCache as e,
703
- useProp as f,
704
- storeMethods as s,
705
- useStore as u
706
- };
819
+
820
+ export { LoadingBoundary as L, ScopeProvider as S, scopeMethods as a, useLoadingBoundary as b, cacheMethods as c, useScope as d, useCache as e, useProp as f, storeMethods as s, useStore as u };
707
821
  //# sourceMappingURL=storeMethods.mjs.map