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