cross-state 0.53.3 → 0.54.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.
Files changed (236) hide show
  1. package/dist/chunk-CUT6urMc.cjs +30 -0
  2. package/dist/diff-BQ8bB3Wk.d.cts +22 -0
  3. package/dist/diff-gZezL04N.d.ts +22 -0
  4. package/dist/extendedJson-BZkQBXEv.js +29 -0
  5. package/dist/extendedJson-BZkQBXEv.js.map +1 -0
  6. package/dist/extendedJson-Dn2F7Edo.cjs +53 -0
  7. package/dist/extendedJson-Dn2F7Edo.cjs.map +1 -0
  8. package/dist/hash-BV06P7va.js +19 -0
  9. package/dist/hash-BV06P7va.js.map +1 -0
  10. package/dist/hash-CJPl7SRj.cjs +30 -0
  11. package/dist/hash-CJPl7SRj.cjs.map +1 -0
  12. package/dist/index.cjs +49 -0
  13. package/dist/index.cjs.map +1 -0
  14. package/dist/index.d.cts +59 -0
  15. package/dist/index.d.ts +59 -0
  16. package/dist/index.js +20 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/mutative/index.cjs +3 -0
  19. package/dist/mutative/index.d.cts +3 -0
  20. package/dist/mutative/index.d.ts +3 -0
  21. package/dist/mutative/index.js +3 -0
  22. package/dist/mutative/register.cjs +10 -0
  23. package/dist/mutative/register.cjs.map +1 -0
  24. package/dist/mutative/register.d.cts +11 -0
  25. package/dist/mutative/register.d.ts +9 -0
  26. package/dist/mutative/register.js +10 -0
  27. package/dist/mutative/register.js.map +1 -0
  28. package/dist/mutativeMethods-6QzygG3W.d.cts +13 -0
  29. package/dist/mutativeMethods-Br3xN2Iq.d.ts +13 -0
  30. package/dist/mutativeMethods-CZKeRIDL.js +27 -0
  31. package/dist/mutativeMethods-CZKeRIDL.js.map +1 -0
  32. package/dist/mutativeMethods-CgXk_bMt.cjs +33 -0
  33. package/dist/mutativeMethods-CgXk_bMt.cjs.map +1 -0
  34. package/dist/patchMethods-C3L7Kh8T.d.cts +48 -0
  35. package/dist/patchMethods-D5YJwcpn.cjs +264 -0
  36. package/dist/patchMethods-D5YJwcpn.cjs.map +1 -0
  37. package/dist/patchMethods-DRPfkhAe.js +241 -0
  38. package/dist/patchMethods-DRPfkhAe.js.map +1 -0
  39. package/dist/patchMethods-Dxad6HF6.d.ts +48 -0
  40. package/dist/patches/index.cjs +5 -0
  41. package/dist/patches/index.d.cts +4 -0
  42. package/dist/patches/index.d.ts +4 -0
  43. package/dist/patches/index.js +5 -0
  44. package/dist/patches/register.cjs +11 -0
  45. package/dist/patches/register.cjs.map +1 -0
  46. package/dist/patches/register.d.cts +12 -0
  47. package/dist/patches/register.d.ts +10 -0
  48. package/dist/patches/register.js +11 -0
  49. package/dist/patches/register.js.map +1 -0
  50. package/dist/persist/register.cjs +13 -0
  51. package/dist/persist/register.cjs.map +1 -0
  52. package/dist/persist/register.d.cts +15 -0
  53. package/dist/persist/register.d.ts +13 -0
  54. package/dist/persist/register.js +13 -0
  55. package/dist/persist/register.js.map +1 -0
  56. package/dist/persist-BluRVcW6.js +258 -0
  57. package/dist/persist-BluRVcW6.js.map +1 -0
  58. package/dist/persist-CPjpg6D0.d.ts +61 -0
  59. package/dist/persist-CztClydq.cjs +263 -0
  60. package/dist/persist-CztClydq.cjs.map +1 -0
  61. package/dist/persist-D7MAsyyW.d.cts +61 -0
  62. package/dist/propAccess-ByqBjC19.cjs +173 -0
  63. package/dist/propAccess-ByqBjC19.cjs.map +1 -0
  64. package/dist/propAccess-DGchzVfy.js +113 -0
  65. package/dist/propAccess-DGchzVfy.js.map +1 -0
  66. package/dist/react/index.cjs +610 -0
  67. package/dist/react/index.cjs.map +1 -0
  68. package/dist/react/index.d.cts +305 -0
  69. package/dist/react/index.d.ts +305 -0
  70. package/dist/react/index.js +590 -0
  71. package/dist/react/index.js.map +1 -0
  72. package/dist/react/register.cjs +16 -0
  73. package/dist/react/register.cjs.map +1 -0
  74. package/dist/react/register.d.cts +16 -0
  75. package/dist/react/register.d.ts +14 -0
  76. package/dist/react/register.js +16 -0
  77. package/dist/react/register.js.map +1 -0
  78. package/dist/scope-DI1OFHcr.d.ts +167 -0
  79. package/dist/scope-DO5vpLPV.d.cts +167 -0
  80. package/dist/scope-DU5dFP1T.js +322 -0
  81. package/dist/scope-DU5dFP1T.js.map +1 -0
  82. package/dist/scope-DvqvkIHB.cjs +369 -0
  83. package/dist/scope-DvqvkIHB.cjs.map +1 -0
  84. package/dist/store-BEsiS8y7.d.cts +242 -0
  85. package/dist/store-BWMWEUpu.cjs +819 -0
  86. package/dist/store-BWMWEUpu.cjs.map +1 -0
  87. package/dist/store-DKaeE840.d.ts +242 -0
  88. package/dist/store-Dr8gM3lq.js +730 -0
  89. package/dist/store-Dr8gM3lq.js.map +1 -0
  90. package/dist/storeMethods-AIJSwxHz.js +315 -0
  91. package/dist/storeMethods-AIJSwxHz.js.map +1 -0
  92. package/dist/storeMethods-BQwU2Uia.d.cts +107 -0
  93. package/dist/storeMethods-C4luym7C.d.ts +107 -0
  94. package/dist/storeMethods-DVVsmUg1.cjs +375 -0
  95. package/dist/storeMethods-DVVsmUg1.cjs.map +1 -0
  96. package/package.json +92 -135
  97. package/dist/cjs/hash.cjs +0 -30
  98. package/dist/cjs/hash.cjs.map +0 -1
  99. package/dist/cjs/index.cjs +0 -56
  100. package/dist/cjs/index.cjs.map +0 -1
  101. package/dist/cjs/index2.cjs +0 -300
  102. package/dist/cjs/index2.cjs.map +0 -1
  103. package/dist/cjs/mutative/index.cjs +0 -10
  104. package/dist/cjs/mutative/index.cjs.map +0 -1
  105. package/dist/cjs/mutative/register.cjs +0 -8
  106. package/dist/cjs/mutative/register.cjs.map +0 -1
  107. package/dist/cjs/mutativeMethods.cjs +0 -29
  108. package/dist/cjs/mutativeMethods.cjs.map +0 -1
  109. package/dist/cjs/patches/index.cjs +0 -10
  110. package/dist/cjs/patches/index.cjs.map +0 -1
  111. package/dist/cjs/patches/register.cjs +0 -8
  112. package/dist/cjs/patches/register.cjs.map +0 -1
  113. package/dist/cjs/persist/register.cjs +0 -11
  114. package/dist/cjs/persist/register.cjs.map +0 -1
  115. package/dist/cjs/persist.cjs +0 -302
  116. package/dist/cjs/persist.cjs.map +0 -1
  117. package/dist/cjs/propAccess.cjs +0 -162
  118. package/dist/cjs/propAccess.cjs.map +0 -1
  119. package/dist/cjs/react/index.cjs +0 -628
  120. package/dist/cjs/react/index.cjs.map +0 -1
  121. package/dist/cjs/react/register.cjs +0 -13
  122. package/dist/cjs/react/register.cjs.map +0 -1
  123. package/dist/cjs/scope.cjs +0 -400
  124. package/dist/cjs/scope.cjs.map +0 -1
  125. package/dist/cjs/store.cjs +0 -829
  126. package/dist/cjs/store.cjs.map +0 -1
  127. package/dist/cjs/storeMethods.cjs +0 -856
  128. package/dist/cjs/storeMethods.cjs.map +0 -1
  129. package/dist/cjs/urlStore.cjs +0 -120
  130. package/dist/cjs/urlStore.cjs.map +0 -1
  131. package/dist/es/hash.mjs +0 -27
  132. package/dist/es/hash.mjs.map +0 -1
  133. package/dist/es/index.mjs +0 -20
  134. package/dist/es/index.mjs.map +0 -1
  135. package/dist/es/index2.mjs +0 -291
  136. package/dist/es/index2.mjs.map +0 -1
  137. package/dist/es/mutative/index.mjs +0 -2
  138. package/dist/es/mutative/index.mjs.map +0 -1
  139. package/dist/es/mutative/register.mjs +0 -6
  140. package/dist/es/mutative/register.mjs.map +0 -1
  141. package/dist/es/mutativeMethods.mjs +0 -27
  142. package/dist/es/mutativeMethods.mjs.map +0 -1
  143. package/dist/es/patches/index.mjs +0 -2
  144. package/dist/es/patches/index.mjs.map +0 -1
  145. package/dist/es/patches/register.mjs +0 -6
  146. package/dist/es/patches/register.mjs.map +0 -1
  147. package/dist/es/persist/register.mjs +0 -9
  148. package/dist/es/persist/register.mjs.map +0 -1
  149. package/dist/es/persist.mjs +0 -300
  150. package/dist/es/persist.mjs.map +0 -1
  151. package/dist/es/propAccess.mjs +0 -151
  152. package/dist/es/propAccess.mjs.map +0 -1
  153. package/dist/es/react/index.mjs +0 -611
  154. package/dist/es/react/index.mjs.map +0 -1
  155. package/dist/es/react/register.mjs +0 -11
  156. package/dist/es/react/register.mjs.map +0 -1
  157. package/dist/es/scope.mjs +0 -391
  158. package/dist/es/scope.mjs.map +0 -1
  159. package/dist/es/store.mjs +0 -812
  160. package/dist/es/store.mjs.map +0 -1
  161. package/dist/es/storeMethods.mjs +0 -845
  162. package/dist/es/storeMethods.mjs.map +0 -1
  163. package/dist/es/urlStore.mjs +0 -116
  164. package/dist/es/urlStore.mjs.map +0 -1
  165. package/dist/types/core/cache.d.ts +0 -119
  166. package/dist/types/core/commonTypes.d.ts +0 -76
  167. package/dist/types/core/index.d.ts +0 -6
  168. package/dist/types/core/resourceGroup.d.ts +0 -16
  169. package/dist/types/core/scope.d.ts +0 -5
  170. package/dist/types/core/store.d.ts +0 -86
  171. package/dist/types/core/urlStore.d.ts +0 -21
  172. package/dist/types/index.d.ts +0 -14
  173. package/dist/types/lib/applyPatches.d.ts +0 -2
  174. package/dist/types/lib/autobind.d.ts +0 -1
  175. package/dist/types/lib/cacheState.d.ts +0 -20
  176. package/dist/types/lib/calcDuration.d.ts +0 -2
  177. package/dist/types/lib/calculatedValue.d.ts +0 -9
  178. package/dist/types/lib/castArray.d.ts +0 -1
  179. package/dist/types/lib/clone.d.ts +0 -1
  180. package/dist/types/lib/constrain.d.ts +0 -1
  181. package/dist/types/lib/debounce.d.ts +0 -12
  182. package/dist/types/lib/deferred.d.ts +0 -5
  183. package/dist/types/lib/diff.d.ts +0 -17
  184. package/dist/types/lib/disposable.d.ts +0 -3
  185. package/dist/types/lib/equals.d.ts +0 -3
  186. package/dist/types/lib/extendedJson.d.ts +0 -5
  187. package/dist/types/lib/forwardError.d.ts +0 -1
  188. package/dist/types/lib/hash.d.ts +0 -5
  189. package/dist/types/lib/helpers.d.ts +0 -2
  190. package/dist/types/lib/instanceCache.d.ts +0 -18
  191. package/dist/types/lib/isPromise.d.ts +0 -1
  192. package/dist/types/lib/makeSelector.d.ts +0 -2
  193. package/dist/types/lib/maybePromise.d.ts +0 -1
  194. package/dist/types/lib/path.d.ts +0 -41
  195. package/dist/types/lib/promiseChain.d.ts +0 -5
  196. package/dist/types/lib/promiseWithCancel.d.ts +0 -8
  197. package/dist/types/lib/promiseWithState.d.ts +0 -9
  198. package/dist/types/lib/propAccess.d.ts +0 -7
  199. package/dist/types/lib/queue.d.ts +0 -11
  200. package/dist/types/lib/standardMethods.d.ts +0 -20
  201. package/dist/types/lib/throttle.d.ts +0 -2
  202. package/dist/types/lib/trackingProxy.d.ts +0 -2
  203. package/dist/types/lib/trie.d.ts +0 -11
  204. package/dist/types/lib/typeHelpers.d.ts +0 -12
  205. package/dist/types/lib/unwrapPromise.d.ts +0 -1
  206. package/dist/types/lib/updateHelpers.d.ts +0 -1
  207. package/dist/types/lib/wildcardMatch.d.ts +0 -3
  208. package/dist/types/mutative/index.d.ts +0 -1
  209. package/dist/types/mutative/mutativeMethods.d.ts +0 -11
  210. package/dist/types/mutative/register.d.ts +0 -7
  211. package/dist/types/patches/index.d.ts +0 -1
  212. package/dist/types/patches/patchMethods.d.ts +0 -44
  213. package/dist/types/patches/register.d.ts +0 -7
  214. package/dist/types/persist/index.d.ts +0 -3
  215. package/dist/types/persist/persist.d.ts +0 -40
  216. package/dist/types/persist/persistPathHelpers.d.ts +0 -6
  217. package/dist/types/persist/persistStorage.d.ts +0 -17
  218. package/dist/types/persist/register.d.ts +0 -9
  219. package/dist/types/react/cacheMethods.d.ts +0 -5
  220. package/dist/types/react/form/customInput.d.ts +0 -6
  221. package/dist/types/react/form/form.d.ts +0 -98
  222. package/dist/types/react/form/formField.d.ts +0 -68
  223. package/dist/types/react/form/formForEach.d.ts +0 -19
  224. package/dist/types/react/form/index.d.ts +0 -3
  225. package/dist/types/react/form/useFormAutosave.d.ts +0 -9
  226. package/dist/types/react/index.d.ts +0 -11
  227. package/dist/types/react/loadingBoundary.d.ts +0 -21
  228. package/dist/types/react/register.d.ts +0 -15
  229. package/dist/types/react/scope.d.ts +0 -24
  230. package/dist/types/react/scopeMethods.d.ts +0 -20
  231. package/dist/types/react/storeMethods.d.ts +0 -15
  232. package/dist/types/react/useCache.d.ts +0 -34
  233. package/dist/types/react/useDecoupledState.d.ts +0 -7
  234. package/dist/types/react/useProp.d.ts +0 -8
  235. package/dist/types/react/useStore.d.ts +0 -16
  236. package/dist/types/react/useUrlParamScope.d.ts +0 -4
@@ -1,845 +0,0 @@
1
- import { h as makeSelector, b as createStore } from './store.mjs';
2
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
- import require$$0, { useRef, useCallback, useLayoutEffect, useDebugValue, useContext, createContext, useMemo, useEffect } from 'react';
4
- import { d as deepEqual, i as isPlainObject } from './propAccess.mjs';
5
- import { s as simpleHash } from './hash.mjs';
6
-
7
- const unwrapProxySymbol = /* @__PURE__ */ Symbol("unwrapProxy");
8
- function trackingProxy(value, equals = deepEqual) {
9
- if (!isPlainObject(value) && !Array.isArray(value)) {
10
- return [value, (other) => equals(value, other)];
11
- }
12
- value = value[unwrapProxySymbol] ?? value;
13
- const deps = new Array();
14
- const revokations = new Array();
15
- let revoked = false;
16
- function trackComplexProp(function_, ...args) {
17
- const [proxiedValue, equals2, revoke] = trackingProxy(function_(value, ...args));
18
- deps.push((otherValue) => {
19
- if (!isPlainObject(otherValue) && !Array.isArray(otherValue)) {
20
- return false;
21
- }
22
- return equals2(function_(otherValue, ...args));
23
- });
24
- if (revoke) {
25
- revokations.push(revoke);
26
- }
27
- return proxiedValue;
28
- }
29
- function trackSimpleProp(function_, ...args) {
30
- const calculatedValue = function_(value, ...args);
31
- deps.push((otherValue) => {
32
- return function_(otherValue, ...args) === calculatedValue;
33
- });
34
- return calculatedValue;
35
- }
36
- const proxy = new Proxy(value, {
37
- get(target, p, receiver) {
38
- if (p === unwrapProxySymbol) {
39
- return value;
40
- }
41
- if (revoked) {
42
- return target[p];
43
- }
44
- const { writable, configurable } = Object.getOwnPropertyDescriptor(target, p) ?? {};
45
- if (writable === false && configurable === false) {
46
- return target[p];
47
- }
48
- return trackComplexProp(Reflect.get, p, receiver);
49
- },
50
- getOwnPropertyDescriptor(target, p) {
51
- const { writable, configurable } = Object.getOwnPropertyDescriptor(target, p) ?? {};
52
- if (writable === false && configurable === false) {
53
- return Reflect.getOwnPropertyDescriptor(target, p);
54
- }
55
- return trackComplexProp(Reflect.getOwnPropertyDescriptor, p);
56
- },
57
- ownKeys() {
58
- return trackComplexProp(Reflect.ownKeys);
59
- },
60
- getPrototypeOf() {
61
- return trackSimpleProp(Reflect.getPrototypeOf);
62
- },
63
- has(_target, p) {
64
- return trackSimpleProp(Reflect.has, p);
65
- },
66
- isExtensible() {
67
- return trackSimpleProp(Reflect.isExtensible);
68
- }
69
- });
70
- return [
71
- proxy,
72
- (other) => !!other && deps.every((equals2) => equals2(other)),
73
- () => {
74
- revoked = true;
75
- revokations.forEach((revoke) => revoke());
76
- }
77
- ];
78
- }
79
-
80
- var withSelector = {exports: {}};
81
-
82
- var withSelector_production_min = {};
83
-
84
- var shim = {exports: {}};
85
-
86
- var useSyncExternalStoreShim_production_min = {};
87
-
88
- /**
89
- * @license React
90
- * use-sync-external-store-shim.production.min.js
91
- *
92
- * Copyright (c) Facebook, Inc. and its affiliates.
93
- *
94
- * This source code is licensed under the MIT license found in the
95
- * LICENSE file in the root directory of this source tree.
96
- */
97
-
98
- var hasRequiredUseSyncExternalStoreShim_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 true}}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=undefined!==e.useSyncExternalStore?e.useSyncExternalStore:u;
105
- return useSyncExternalStoreShim_production_min;
106
- }
107
-
108
- var useSyncExternalStoreShim_development = {};
109
-
110
- /**
111
- * @license React
112
- * use-sync-external-store-shim.development.js
113
- *
114
- * Copyright (c) Facebook, Inc. and its affiliates.
115
- *
116
- * This source code is licensed under the MIT license found in the
117
- * LICENSE file in the root directory of this source tree.
118
- */
119
-
120
- var hasRequiredUseSyncExternalStoreShim_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;
352
- }
353
-
354
- var hasRequiredShim;
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;
366
- }
367
-
368
- /**
369
- * @license React
370
- * use-sync-external-store-shim/with-selector.production.min.js
371
- *
372
- * Copyright (c) Facebook, Inc. and its affiliates.
373
- *
374
- * This source code is licensed under the MIT license found in the
375
- * LICENSE file in the root directory of this source tree.
376
- */
377
-
378
- var hasRequiredWithSelector_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:false,value:null};c.current=f;}else f=c.current;c=v(function(){function a(a){if(!c){c=true;d=a;a=l(a);if(undefined!==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(undefined!==g&&g(b,e))return b;d=a;return k=e}var c=false,d,k,m=undefined===e?null:e;return [function(){return a(b())},null===m?undefined:function(){return a(m())}]},[b,e,l,g]);var d=r(a,c[0],c[1]);
385
- u(function(){f.hasValue=true;f.value=d;},[d]);w(d);return d};
386
- return withSelector_production_min;
387
- }
388
-
389
- var withSelector_development = {};
390
-
391
- /**
392
- * @license React
393
- * use-sync-external-store-shim/with-selector.development.js
394
- *
395
- * Copyright (c) Facebook, Inc. and its affiliates.
396
- *
397
- * This source code is licensed under the MIT license found in the
398
- * LICENSE file in the root directory of this source tree.
399
- */
400
-
401
- var hasRequiredWithSelector_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;
559
- }
560
-
561
- var hasRequiredWithSelector;
562
-
563
- function requireWithSelector () {
564
- if (hasRequiredWithSelector) return withSelector.exports;
565
- hasRequiredWithSelector = 1;
566
-
567
- if (process.env.NODE_ENV === 'production') {
568
- withSelector.exports = requireWithSelector_production_min();
569
- } else {
570
- withSelector.exports = requireWithSelector_development();
571
- }
572
- return withSelector.exports;
573
- }
574
-
575
- var withSelectorExports = requireWithSelector();
576
-
577
- function useStore(store, argument1, argument2) {
578
- const selector = makeSelector(
579
- typeof argument1 === "function" || typeof argument1 === "string" ? argument1 : undefined
580
- );
581
- const allOptions = typeof argument1 === "object" ? argument1 : argument2 ?? {};
582
- const lastEqualsRef = useRef();
583
- if (store.derivedFrom) {
584
- return useStore(
585
- store.derivedFrom.store,
586
- (value2) => {
587
- for (const selector2 of store.derivedFrom.selectors) {
588
- value2 = makeSelector(selector2)(value2);
589
- }
590
- return selector(value2);
591
- },
592
- allOptions
593
- );
594
- }
595
- const {
596
- disableTrackingProxy = true,
597
- equals = store.options.equals ?? deepEqual,
598
- withViewTransition,
599
- ...options
600
- } = allOptions;
601
- const subOptions = { ...options, runNow: false };
602
- const subscribe = useCallback(
603
- (listener) => {
604
- let _listener = listener;
605
- let stopped = false;
606
- if (withViewTransition && document.startViewTransition) {
607
- let lastObservedValue;
608
- _listener = (value2) => {
609
- const observedValue = withViewTransition instanceof Function ? withViewTransition(value2) : value2;
610
- if (equals(lastObservedValue, observedValue)) {
611
- listener();
612
- return;
613
- }
614
- lastObservedValue = observedValue;
615
- let hasChanges = false;
616
- const mutationObserver = new MutationObserver(() => {
617
- hasChanges = true;
618
- mutationObserver.disconnect();
619
- });
620
- mutationObserver.observe(document.body, { childList: true, subtree: true });
621
- document.startViewTransition(() => {
622
- mutationObserver.disconnect();
623
- if (!stopped) {
624
- listener();
625
- }
626
- if (!hasChanges) {
627
- throw new Error("no change");
628
- }
629
- });
630
- };
631
- }
632
- const cancel = store.subscribe(_listener, subOptions);
633
- return () => {
634
- stopped = true;
635
- cancel();
636
- };
637
- },
638
- [store, simpleHash(subOptions)]
639
- );
640
- let value = withSelectorExports.useSyncExternalStoreWithSelector(
641
- //
642
- subscribe,
643
- store.get,
644
- undefined,
645
- (x) => selector(x),
646
- (_v, newValue) => lastEqualsRef.current?.(newValue) ?? false
647
- );
648
- let lastEquals = (newValue) => equals(newValue, value);
649
- let revoke;
650
- if (!disableTrackingProxy) {
651
- [value, lastEquals, revoke] = trackingProxy(value, equals);
652
- }
653
- useLayoutEffect(() => {
654
- lastEqualsRef.current = lastEquals;
655
- revoke?.();
656
- });
657
- useDebugValue(value);
658
- return value;
659
- }
660
-
661
- const LoadingBoundaryContext = createContext(createStore(/* @__PURE__ */ new Set()));
662
- function LoadingBoundary({
663
- fallback,
664
- children,
665
- isLoading: isLoadingExternal
666
- }) {
667
- const store = useMemo(() => createStore(/* @__PURE__ */ new Set()), []);
668
- const entries = useStore(store);
669
- const isLoading = entries.size > 0 || isLoadingExternal;
670
- const fallbackNode = isLoading ? typeof fallback === "function" ? fallback([...entries]) : fallback : undefined;
671
- return /* @__PURE__ */ jsx(LoadingBoundaryContext.Provider, { value: store, children: fallbackNode !== undefined ? /* @__PURE__ */ jsxs(Fragment, { children: [
672
- fallbackNode,
673
- /* @__PURE__ */ jsx("div", { style: { display: "none" }, children })
674
- ] }) : children });
675
- }
676
- function useLoadingBoundary(isLoading, label) {
677
- const store = useContext(LoadingBoundaryContext);
678
- useLayoutEffect(() => {
679
- if (!isLoading) {
680
- return;
681
- }
682
- const entry = { label };
683
- store.set((entries) => new Set(entries).add(entry));
684
- return () => {
685
- store.set((entries) => {
686
- const newEntries = new Set(entries);
687
- newEntries.delete(entry);
688
- return newEntries;
689
- });
690
- };
691
- }, [isLoading]);
692
- }
693
-
694
- function useCache(cache, {
695
- passive,
696
- disabled,
697
- updateOnMount,
698
- withViewTransition,
699
- suspense,
700
- loadingBoundary,
701
- ...options
702
- } = {}) {
703
- if (withViewTransition === true) {
704
- withViewTransition = (state) => state.value;
705
- }
706
- const { rootCache, selector } = useMemo(() => {
707
- const rootCache2 = cache.derivedFromCache?.cache ?? cache;
708
- let selector2 = (x) => x;
709
- if (cache.derivedFromCache) {
710
- selector2 = (value) => {
711
- for (const s of cache.derivedFromCache.selectors) {
712
- value = makeSelector(s)(value);
713
- }
714
- return value;
715
- };
716
- }
717
- return { rootCache: rootCache2, selector: selector2 };
718
- }, [cache]);
719
- const hasMounted = useRef(false);
720
- useEffect(() => {
721
- hasMounted.current = true;
722
- if (updateOnMount) {
723
- rootCache.invalidate();
724
- }
725
- }, []);
726
- const result = useStore(
727
- rootCache.state,
728
- (state) => {
729
- if (disabled) {
730
- return Object.assign(
731
- [undefined, undefined, false, false],
732
- { status: "pending", isUpdating: false, isStale: false, isConnected: false }
733
- );
734
- }
735
- const isStale = updateOnMount && !hasMounted.current ? true : state.isStale;
736
- try {
737
- const value = state.status === "value" ? selector(state.value) : void 0;
738
- return Object.assign(
739
- [value, state.error, state.isUpdating, isStale],
740
- { ...state, value, isStale }
741
- );
742
- } catch (error) {
743
- return Object.assign(
744
- [undefined, error, state.isUpdating, isStale],
745
- {
746
- status: "error",
747
- error,
748
- isUpdating: state.isUpdating,
749
- isStale,
750
- isConnected: state.isConnected
751
- }
752
- );
753
- }
754
- },
755
- { ...options, withViewTransition, passive: passive || disabled }
756
- );
757
- useEffect(
758
- () => rootCache.subscribe(() => undefined, { passive: passive || disabled }),
759
- [rootCache, passive || disabled]
760
- );
761
- useLoadingBoundary(loadingBoundary && !disabled && result.status === "pending");
762
- if (suspense && result.status === "pending") {
763
- throw rootCache.get();
764
- }
765
- return result;
766
- }
767
-
768
- const cacheMethods = {
769
- useCache(options) {
770
- return useCache(this, options);
771
- }
772
- };
773
-
774
- function useProp(store, argument1, argument2, argument3) {
775
- const selector = typeof argument1 === "function" || typeof argument1 === "string" ? argument1 : undefined;
776
- const updater = typeof argument2 === "function" ? argument2 : undefined;
777
- const options = typeof argument1 === "object" ? argument1 : typeof argument2 === "object" ? argument2 : argument3;
778
- if (selector) {
779
- store = store.map(selector, updater);
780
- }
781
- const value = useStore(store, options);
782
- return [value, store.set];
783
- }
784
-
785
- function getScopeContext(scope) {
786
- scope.context ??= createContext(createStore(scope.defaultValue));
787
- return scope.context;
788
- }
789
- function ScopeProvider({
790
- scope,
791
- store: inputStore,
792
- children
793
- }) {
794
- const context = getScopeContext(scope);
795
- const currentStore = useMemo(
796
- () => inputStore ?? createStore(scope.defaultValue),
797
- [scope, inputStore]
798
- );
799
- return /* @__PURE__ */ jsx(context.Provider, { value: currentStore, children });
800
- }
801
- function useScope(scope) {
802
- const context = getScopeContext(scope);
803
- return useContext(context);
804
- }
805
- function useScopeStore(scope, ...args) {
806
- const store = useScope(scope);
807
- return useStore(store, ...args);
808
- }
809
- function useScopeProp(scope, ...args) {
810
- const store = useScope(scope);
811
- return useProp(store, ...args);
812
- }
813
-
814
- function boundUseScope() {
815
- return useScope(this);
816
- }
817
- function boundUseScopeStore(...args) {
818
- return useScopeStore(this, ...args);
819
- }
820
- function boundUseScopeProp(...args) {
821
- return useScopeProp(this, ...args);
822
- }
823
- function Provider(props) {
824
- return ScopeProvider({ ...props, scope: this });
825
- }
826
- const scopeMethods = {
827
- useScope: boundUseScope,
828
- useStore: boundUseScopeStore,
829
- useProp: boundUseScopeProp,
830
- Provider
831
- };
832
-
833
- function boundUseStore(...args) {
834
- return useStore(this, ...args);
835
- }
836
- function boundUseProp(...args) {
837
- return useProp(this, ...args);
838
- }
839
- const storeMethods = {
840
- useStore: boundUseStore,
841
- useProp: boundUseProp
842
- };
843
-
844
- 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 };
845
- //# sourceMappingURL=storeMethods.mjs.map