cross-state 0.6.4 → 0.6.7

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 (148) hide show
  1. package/dist/cjs/_virtual/use-sync-external-store-with-selector.development.cjs +103 -0
  2. package/dist/cjs/_virtual/use-sync-external-store-with-selector.development.cjs.map +1 -0
  3. package/dist/cjs/_virtual/use-sync-external-store-with-selector.development2.cjs +5 -0
  4. package/dist/cjs/_virtual/use-sync-external-store-with-selector.development2.cjs.map +1 -0
  5. package/dist/cjs/_virtual/use-sync-external-store-with-selector.production.min.cjs +71 -0
  6. package/dist/cjs/_virtual/use-sync-external-store-with-selector.production.min.cjs.map +1 -0
  7. package/dist/cjs/_virtual/use-sync-external-store-with-selector.production.min2.cjs +5 -0
  8. package/dist/cjs/_virtual/use-sync-external-store-with-selector.production.min2.cjs.map +1 -0
  9. package/dist/cjs/_virtual/with-selector.cjs +12 -0
  10. package/dist/cjs/_virtual/with-selector.cjs.map +1 -0
  11. package/dist/cjs/_virtual/with-selector2.cjs +13 -0
  12. package/dist/cjs/_virtual/with-selector2.cjs.map +1 -0
  13. package/dist/cjs/core/cache.cjs +227 -0
  14. package/dist/cjs/core/cache.cjs.map +1 -0
  15. package/dist/cjs/core/resourceGroup.cjs +53 -0
  16. package/dist/cjs/core/resourceGroup.cjs.map +1 -0
  17. package/dist/cjs/core/store.cjs +259 -0
  18. package/dist/cjs/core/store.cjs.map +1 -0
  19. package/dist/cjs/immer/immerActions.cjs +10 -0
  20. package/dist/cjs/immer/immerActions.cjs.map +1 -0
  21. package/dist/cjs/immer.cjs +2 -7
  22. package/dist/cjs/immer.cjs.map +1 -1
  23. package/dist/cjs/index.cjs +19 -290
  24. package/dist/cjs/index.cjs.map +1 -1
  25. package/dist/cjs/lib/calcDuration.cjs +9 -0
  26. package/dist/cjs/lib/calcDuration.cjs.map +1 -0
  27. package/dist/cjs/lib/calculationHelper.cjs +140 -0
  28. package/dist/cjs/lib/calculationHelper.cjs.map +1 -0
  29. package/dist/cjs/lib/callable.cjs +11 -0
  30. package/dist/cjs/lib/callable.cjs.map +1 -0
  31. package/dist/cjs/lib/clone.cjs +19 -0
  32. package/dist/cjs/lib/clone.cjs.map +1 -0
  33. package/dist/cjs/lib/debounce.cjs +28 -0
  34. package/dist/cjs/lib/debounce.cjs.map +1 -0
  35. package/dist/cjs/lib/equals.cjs +5 -0
  36. package/dist/cjs/lib/equals.cjs.map +1 -0
  37. package/dist/cjs/lib/forwardError.cjs +9 -0
  38. package/dist/cjs/lib/forwardError.cjs.map +1 -0
  39. package/dist/cjs/lib/hash.cjs +19 -0
  40. package/dist/cjs/lib/hash.cjs.map +1 -0
  41. package/dist/cjs/lib/instanceCache.cjs +68 -0
  42. package/dist/cjs/lib/instanceCache.cjs.map +1 -0
  43. package/dist/cjs/lib/makeSelector.cjs +14 -0
  44. package/dist/cjs/lib/makeSelector.cjs.map +1 -0
  45. package/dist/cjs/lib/propAccess.cjs +66 -0
  46. package/dist/cjs/lib/propAccess.cjs.map +1 -0
  47. package/dist/cjs/lib/queue.cjs +61 -0
  48. package/dist/cjs/lib/queue.cjs.map +1 -0
  49. package/dist/cjs/lib/standardMethods.cjs +78 -0
  50. package/dist/cjs/lib/standardMethods.cjs.map +1 -0
  51. package/dist/cjs/lib/throttle.cjs +25 -0
  52. package/dist/cjs/lib/throttle.cjs.map +1 -0
  53. package/dist/cjs/lib/trackingProxy.cjs +39 -0
  54. package/dist/cjs/lib/trackingProxy.cjs.map +1 -0
  55. package/dist/cjs/react/read.cjs +15 -0
  56. package/dist/cjs/react/read.cjs.map +1 -0
  57. package/dist/cjs/react/storeScope.cjs +31 -0
  58. package/dist/cjs/react/storeScope.cjs.map +1 -0
  59. package/dist/cjs/react/useCache.cjs +31 -0
  60. package/dist/cjs/react/useCache.cjs.map +1 -0
  61. package/dist/cjs/react/useProp.cjs +9 -0
  62. package/dist/cjs/react/useProp.cjs.map +1 -0
  63. package/dist/cjs/react/useStore.cjs +51 -0
  64. package/dist/cjs/react/useStore.cjs.map +1 -0
  65. package/dist/cjs/react.cjs +11 -264
  66. package/dist/cjs/react.cjs.map +1 -1
  67. package/dist/es/_virtual/use-sync-external-store-with-selector.development.js +103 -0
  68. package/dist/es/_virtual/use-sync-external-store-with-selector.development.js.map +1 -0
  69. package/dist/es/_virtual/use-sync-external-store-with-selector.development2.js +5 -0
  70. package/dist/es/_virtual/use-sync-external-store-with-selector.development2.js.map +1 -0
  71. package/dist/es/_virtual/use-sync-external-store-with-selector.production.min.js +71 -0
  72. package/dist/es/_virtual/use-sync-external-store-with-selector.production.min.js.map +1 -0
  73. package/dist/es/_virtual/use-sync-external-store-with-selector.production.min2.js +5 -0
  74. package/dist/es/_virtual/use-sync-external-store-with-selector.production.min2.js.map +1 -0
  75. package/dist/es/_virtual/with-selector.js +11 -0
  76. package/dist/es/_virtual/with-selector.js.map +1 -0
  77. package/dist/es/_virtual/with-selector2.js +14 -0
  78. package/dist/es/_virtual/with-selector2.js.map +1 -0
  79. package/dist/es/core/cache.js +227 -0
  80. package/dist/es/core/cache.js.map +1 -0
  81. package/dist/es/core/resourceGroup.js +53 -0
  82. package/dist/es/core/resourceGroup.js.map +1 -0
  83. package/dist/es/core/store.js +259 -0
  84. package/dist/es/core/store.js.map +1 -0
  85. package/dist/es/{immer.mjs → immer/immerActions.js} +1 -1
  86. package/dist/es/immer/immerActions.js.map +1 -0
  87. package/dist/es/immer.js +5 -0
  88. package/dist/es/immer.js.map +1 -0
  89. package/dist/es/index.js +22 -0
  90. package/dist/es/index.js.map +1 -0
  91. package/dist/es/lib/calcDuration.js +9 -0
  92. package/dist/es/lib/calcDuration.js.map +1 -0
  93. package/dist/es/lib/calculationHelper.js +140 -0
  94. package/dist/es/lib/calculationHelper.js.map +1 -0
  95. package/dist/es/lib/callable.js +11 -0
  96. package/dist/es/lib/callable.js.map +1 -0
  97. package/dist/es/lib/clone.js +19 -0
  98. package/dist/es/lib/clone.js.map +1 -0
  99. package/dist/es/lib/debounce.js +28 -0
  100. package/dist/es/lib/debounce.js.map +1 -0
  101. package/dist/es/lib/equals.js +5 -0
  102. package/dist/es/lib/equals.js.map +1 -0
  103. package/dist/es/lib/forwardError.js +9 -0
  104. package/dist/es/lib/forwardError.js.map +1 -0
  105. package/dist/es/lib/hash.js +19 -0
  106. package/dist/es/lib/hash.js.map +1 -0
  107. package/dist/es/lib/instanceCache.js +68 -0
  108. package/dist/es/lib/instanceCache.js.map +1 -0
  109. package/dist/es/lib/makeSelector.js +14 -0
  110. package/dist/es/lib/makeSelector.js.map +1 -0
  111. package/dist/es/lib/propAccess.js +66 -0
  112. package/dist/es/lib/propAccess.js.map +1 -0
  113. package/dist/es/lib/queue.js +61 -0
  114. package/dist/es/lib/queue.js.map +1 -0
  115. package/dist/es/lib/standardMethods.js +78 -0
  116. package/dist/es/lib/standardMethods.js.map +1 -0
  117. package/dist/es/lib/throttle.js +25 -0
  118. package/dist/es/lib/throttle.js.map +1 -0
  119. package/dist/es/lib/trackingProxy.js +39 -0
  120. package/dist/es/lib/trackingProxy.js.map +1 -0
  121. package/dist/es/react/read.js +15 -0
  122. package/dist/es/react/read.js.map +1 -0
  123. package/dist/es/react/storeScope.js +31 -0
  124. package/dist/es/react/storeScope.js.map +1 -0
  125. package/dist/es/react/useCache.js +31 -0
  126. package/dist/es/react/useCache.js.map +1 -0
  127. package/dist/es/react/useProp.js +9 -0
  128. package/dist/es/react/useProp.js.map +1 -0
  129. package/dist/es/react/useStore.js +51 -0
  130. package/dist/es/react/useStore.js.map +1 -0
  131. package/dist/es/react.js +14 -0
  132. package/dist/es/react.js.map +1 -0
  133. package/dist/types/core/cache.d.ts +19 -13
  134. package/dist/types/core/store.d.ts +6 -4
  135. package/dist/types/lib/callable.d.ts +4 -0
  136. package/dist/types/lib/instanceCache.d.ts +2 -2
  137. package/dist/types/react/useCache.d.ts +1 -1
  138. package/package.json +8 -8
  139. package/dist/cjs/hash.cjs +0 -715
  140. package/dist/cjs/hash.cjs.map +0 -1
  141. package/dist/es/hash.mjs +0 -716
  142. package/dist/es/hash.mjs.map +0 -1
  143. package/dist/es/immer.mjs.map +0 -1
  144. package/dist/es/index.mjs +0 -294
  145. package/dist/es/index.mjs.map +0 -1
  146. package/dist/es/react.mjs +0 -267
  147. package/dist/es/react.mjs.map +0 -1
  148. package/dist/types/lib/bind.d.ts +0 -1
package/dist/es/react.mjs DELETED
@@ -1,267 +0,0 @@
1
- import require$$0, { useRef, useCallback, useLayoutEffect, useDebugValue, useMemo, useEffect, useContext, createContext } from "react";
2
- import { h as hash, t as trackingProxy, c as createStore } from "./hash.mjs";
3
- import { jsx } from "react/jsx-runtime";
4
- var withSelectorExports = {};
5
- var withSelector = {
6
- get exports() {
7
- return withSelectorExports;
8
- },
9
- set exports(v) {
10
- withSelectorExports = v;
11
- }
12
- };
13
- var useSyncExternalStoreWithSelector_production_min = {};
14
- /**
15
- * @license React
16
- * use-sync-external-store-with-selector.production.min.js
17
- *
18
- * Copyright (c) Facebook, Inc. and its affiliates.
19
- *
20
- * This source code is licensed under the MIT license found in the
21
- * LICENSE file in the root directory of this source tree.
22
- */
23
- var hasRequiredUseSyncExternalStoreWithSelector_production_min;
24
- function requireUseSyncExternalStoreWithSelector_production_min() {
25
- if (hasRequiredUseSyncExternalStoreWithSelector_production_min)
26
- return useSyncExternalStoreWithSelector_production_min;
27
- hasRequiredUseSyncExternalStoreWithSelector_production_min = 1;
28
- var g = require$$0;
29
- function n(a, b) {
30
- return a === b && (0 !== a || 1 / a === 1 / b) || a !== a && b !== b;
31
- }
32
- var p = "function" === typeof Object.is ? Object.is : n, q = g.useSyncExternalStore, r = g.useRef, t = g.useEffect, u = g.useMemo, v = g.useDebugValue;
33
- useSyncExternalStoreWithSelector_production_min.useSyncExternalStoreWithSelector = function(a, b, e, l, h) {
34
- var c = r(null);
35
- if (null === c.current) {
36
- var f = { hasValue: false, value: null };
37
- c.current = f;
38
- } else
39
- f = c.current;
40
- c = u(function() {
41
- function a2(a3) {
42
- if (!c2) {
43
- c2 = true;
44
- d2 = a3;
45
- a3 = l(a3);
46
- if (void 0 !== h && f.hasValue) {
47
- var b2 = f.value;
48
- if (h(b2, a3))
49
- return k = b2;
50
- }
51
- return k = a3;
52
- }
53
- b2 = k;
54
- if (p(d2, a3))
55
- return b2;
56
- var e2 = l(a3);
57
- if (void 0 !== h && h(b2, e2))
58
- return b2;
59
- d2 = a3;
60
- return k = e2;
61
- }
62
- var c2 = false, d2, k, m = void 0 === e ? null : e;
63
- return [function() {
64
- return a2(b());
65
- }, null === m ? void 0 : function() {
66
- return a2(m());
67
- }];
68
- }, [b, e, l, h]);
69
- var d = q(a, c[0], c[1]);
70
- t(function() {
71
- f.hasValue = true;
72
- f.value = d;
73
- }, [d]);
74
- v(d);
75
- return d;
76
- };
77
- return useSyncExternalStoreWithSelector_production_min;
78
- }
79
- var useSyncExternalStoreWithSelector_development = {};
80
- /**
81
- * @license React
82
- * use-sync-external-store-with-selector.development.js
83
- *
84
- * Copyright (c) Facebook, Inc. and its affiliates.
85
- *
86
- * This source code is licensed under the MIT license found in the
87
- * LICENSE file in the root directory of this source tree.
88
- */
89
- var hasRequiredUseSyncExternalStoreWithSelector_development;
90
- function requireUseSyncExternalStoreWithSelector_development() {
91
- if (hasRequiredUseSyncExternalStoreWithSelector_development)
92
- return useSyncExternalStoreWithSelector_development;
93
- hasRequiredUseSyncExternalStoreWithSelector_development = 1;
94
- if (process.env.NODE_ENV !== "production") {
95
- (function() {
96
- if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function") {
97
- __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
98
- }
99
- var React = require$$0;
100
- function is(x, y) {
101
- return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y;
102
- }
103
- var objectIs = typeof Object.is === "function" ? Object.is : is;
104
- var useSyncExternalStore = React.useSyncExternalStore;
105
- var useRef2 = React.useRef, useEffect2 = React.useEffect, useMemo2 = React.useMemo, useDebugValue2 = React.useDebugValue;
106
- function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
107
- var instRef = useRef2(null);
108
- var inst;
109
- if (instRef.current === null) {
110
- inst = {
111
- hasValue: false,
112
- value: null
113
- };
114
- instRef.current = inst;
115
- } else {
116
- inst = instRef.current;
117
- }
118
- var _useMemo = useMemo2(function() {
119
- var hasMemo = false;
120
- var memoizedSnapshot;
121
- var memoizedSelection;
122
- var memoizedSelector = function(nextSnapshot) {
123
- if (!hasMemo) {
124
- hasMemo = true;
125
- memoizedSnapshot = nextSnapshot;
126
- var _nextSelection = selector(nextSnapshot);
127
- if (isEqual !== void 0) {
128
- if (inst.hasValue) {
129
- var currentSelection = inst.value;
130
- if (isEqual(currentSelection, _nextSelection)) {
131
- memoizedSelection = currentSelection;
132
- return currentSelection;
133
- }
134
- }
135
- }
136
- memoizedSelection = _nextSelection;
137
- return _nextSelection;
138
- }
139
- var prevSnapshot = memoizedSnapshot;
140
- var prevSelection = memoizedSelection;
141
- if (objectIs(prevSnapshot, nextSnapshot)) {
142
- return prevSelection;
143
- }
144
- var nextSelection = selector(nextSnapshot);
145
- if (isEqual !== void 0 && isEqual(prevSelection, nextSelection)) {
146
- return prevSelection;
147
- }
148
- memoizedSnapshot = nextSnapshot;
149
- memoizedSelection = nextSelection;
150
- return nextSelection;
151
- };
152
- var maybeGetServerSnapshot = getServerSnapshot === void 0 ? null : getServerSnapshot;
153
- var getSnapshotWithSelector = function() {
154
- return memoizedSelector(getSnapshot());
155
- };
156
- var getServerSnapshotWithSelector = maybeGetServerSnapshot === null ? void 0 : function() {
157
- return memoizedSelector(maybeGetServerSnapshot());
158
- };
159
- return [getSnapshotWithSelector, getServerSnapshotWithSelector];
160
- }, [getSnapshot, getServerSnapshot, selector, isEqual]), getSelection = _useMemo[0], getServerSelection = _useMemo[1];
161
- var value = useSyncExternalStore(subscribe, getSelection, getServerSelection);
162
- useEffect2(function() {
163
- inst.hasValue = true;
164
- inst.value = value;
165
- }, [value]);
166
- useDebugValue2(value);
167
- return value;
168
- }
169
- useSyncExternalStoreWithSelector_development.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector;
170
- if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === "function") {
171
- __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
172
- }
173
- })();
174
- }
175
- return useSyncExternalStoreWithSelector_development;
176
- }
177
- (function(module) {
178
- if (process.env.NODE_ENV === "production") {
179
- module.exports = requireUseSyncExternalStoreWithSelector_production_min();
180
- } else {
181
- module.exports = requireUseSyncExternalStoreWithSelector_development();
182
- }
183
- })(withSelector);
184
- function useStore(store, options) {
185
- const lastEqualsRef = useRef();
186
- const subOptions = { ...options, runNow: false, equals: void 0, passive: false };
187
- const subscribe = useCallback(
188
- (listener) => {
189
- return store.sub(listener, subOptions);
190
- },
191
- [store, hash(subOptions)]
192
- );
193
- const value = withSelectorExports.useSyncExternalStoreWithSelector(
194
- //
195
- subscribe,
196
- store.get,
197
- void 0,
198
- (x) => x,
199
- (options == null ? void 0 : options.equals) ?? ((_v, newValue) => {
200
- var _a;
201
- return ((_a = lastEqualsRef.current) == null ? void 0 : _a.call(lastEqualsRef, newValue)) ?? false;
202
- })
203
- );
204
- const [proxiedValue, equals] = trackingProxy(value);
205
- useLayoutEffect(() => {
206
- lastEqualsRef.current = equals;
207
- });
208
- useDebugValue(value);
209
- return proxiedValue;
210
- }
211
- function useCache(cache, { passive, ...options } = {}) {
212
- const mappedStore = useMemo(
213
- () => cache.state.map(
214
- (state) => Object.assign(
215
- [state.value, state.error, state.isUpdating, state.isStale],
216
- state
217
- )
218
- ),
219
- [cache]
220
- );
221
- useEffect(() => !passive ? cache.sub(() => void 0) : void 0, [cache, passive]);
222
- return useStore(mappedStore, options);
223
- }
224
- function read(cache, options) {
225
- const { status, value, error } = useCache(cache, options);
226
- if (status === "value") {
227
- return value;
228
- }
229
- if (status === "error") {
230
- throw error;
231
- }
232
- throw cache.state.once((state) => state.status !== "pending");
233
- }
234
- const contextMap = /* @__PURE__ */ new WeakMap();
235
- function getStoreScopeContext(scope) {
236
- let context = contextMap.get(scope);
237
- if (!context) {
238
- context = createContext(createStore(scope.defaultValue));
239
- contextMap.set(scope, context);
240
- }
241
- return context;
242
- }
243
- function StoreScopeProvider({ scope, store: inputStore, children }) {
244
- const context = getStoreScopeContext(scope);
245
- const currentStore = useMemo(
246
- () => inputStore ?? createStore(scope.defaultValue),
247
- [scope, inputStore]
248
- );
249
- return /* @__PURE__ */ jsx(context.Provider, { value: currentStore, children });
250
- }
251
- function useStoreScope(scope) {
252
- const context = getStoreScopeContext(scope);
253
- return useContext(context);
254
- }
255
- function useProp(store, options) {
256
- const value = useStore(store, options);
257
- return [value, store.set];
258
- }
259
- export {
260
- StoreScopeProvider,
261
- read,
262
- useCache,
263
- useProp,
264
- useStore,
265
- useStoreScope
266
- };
267
- //# sourceMappingURL=react.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"react.mjs","sources":["../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/cjs/use-sync-external-store-with-selector.production.min.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/cjs/use-sync-external-store-with-selector.development.js","../../node_modules/.pnpm/use-sync-external-store@1.2.0_react@18.2.0/node_modules/use-sync-external-store/with-selector.js","../../src/react/useStore.ts","../../src/react/useCache.ts","../../src/react/read.ts","../../src/react/storeScope.tsx","../../src/react/useProp.ts"],"sourcesContent":["/**\n * @license React\n * use-sync-external-store-with-selector.production.min.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n'use strict';var g=require(\"react\");function n(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var p=\"function\"===typeof Object.is?Object.is:n,q=g.useSyncExternalStore,r=g.useRef,t=g.useEffect,u=g.useMemo,v=g.useDebugValue;\nexports.useSyncExternalStoreWithSelector=function(a,b,e,l,h){var c=r(null);if(null===c.current){var f={hasValue:!1,value:null};c.current=f}else f=c.current;c=u(function(){function a(a){if(!c){c=!0;d=a;a=l(a);if(void 0!==h&&f.hasValue){var b=f.value;if(h(b,a))return k=b}return k=a}b=k;if(p(d,a))return b;var e=l(a);if(void 0!==h&&h(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,h]);var d=q(a,c[0],c[1]);\nt(function(){f.hasValue=!0;f.value=d},[d]);v(d);return d};\n","/**\n * @license React\n * use-sync-external-store-with-selector.development.js\n *\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nif (process.env.NODE_ENV !== \"production\") {\n (function() {\n\n 'use strict';\n\n/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());\n}\n var React = require('react');\n\n/**\n * inlined Object.is polyfill to avoid requiring consumers ship their own\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is\n */\nfunction is(x, y) {\n return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare\n ;\n}\n\nvar objectIs = typeof Object.is === 'function' ? Object.is : is;\n\nvar useSyncExternalStore = React.useSyncExternalStore;\n\n// for CommonJS interop.\n\nvar useRef = React.useRef,\n useEffect = React.useEffect,\n useMemo = React.useMemo,\n useDebugValue = React.useDebugValue; // Same as useSyncExternalStore, but supports selector and isEqual arguments.\n\nfunction useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {\n // Use this to track the rendered snapshot.\n var instRef = useRef(null);\n var inst;\n\n if (instRef.current === null) {\n inst = {\n hasValue: false,\n value: null\n };\n instRef.current = inst;\n } else {\n inst = instRef.current;\n }\n\n var _useMemo = useMemo(function () {\n // Track the memoized state using closure variables that are local to this\n // memoized instance of a getSnapshot function. Intentionally not using a\n // useRef hook, because that state would be shared across all concurrent\n // copies of the hook/component.\n var hasMemo = false;\n var memoizedSnapshot;\n var memoizedSelection;\n\n var memoizedSelector = function (nextSnapshot) {\n if (!hasMemo) {\n // The first time the hook is called, there is no memoized result.\n hasMemo = true;\n memoizedSnapshot = nextSnapshot;\n\n var _nextSelection = selector(nextSnapshot);\n\n if (isEqual !== undefined) {\n // Even if the selector has changed, the currently rendered selection\n // may be equal to the new selection. We should attempt to reuse the\n // current value if possible, to preserve downstream memoizations.\n if (inst.hasValue) {\n var currentSelection = inst.value;\n\n if (isEqual(currentSelection, _nextSelection)) {\n memoizedSelection = currentSelection;\n return currentSelection;\n }\n }\n }\n\n memoizedSelection = _nextSelection;\n return _nextSelection;\n } // We may be able to reuse the previous invocation's result.\n\n\n // We may be able to reuse the previous invocation's result.\n var prevSnapshot = memoizedSnapshot;\n var prevSelection = memoizedSelection;\n\n if (objectIs(prevSnapshot, nextSnapshot)) {\n // The snapshot is the same as last time. Reuse the previous selection.\n return prevSelection;\n } // The snapshot has changed, so we need to compute a new selection.\n\n\n // The snapshot has changed, so we need to compute a new selection.\n var nextSelection = selector(nextSnapshot); // If a custom isEqual function is provided, use that to check if the data\n // has changed. If it hasn't, return the previous selection. That signals\n // to React that the selections are conceptually equal, and we can bail\n // out of rendering.\n\n // If a custom isEqual function is provided, use that to check if the data\n // has changed. If it hasn't, return the previous selection. That signals\n // to React that the selections are conceptually equal, and we can bail\n // out of rendering.\n if (isEqual !== undefined && isEqual(prevSelection, nextSelection)) {\n return prevSelection;\n }\n\n memoizedSnapshot = nextSnapshot;\n memoizedSelection = nextSelection;\n return nextSelection;\n }; // Assigning this to a constant so that Flow knows it can't change.\n\n\n // Assigning this to a constant so that Flow knows it can't change.\n var maybeGetServerSnapshot = getServerSnapshot === undefined ? null : getServerSnapshot;\n\n var getSnapshotWithSelector = function () {\n return memoizedSelector(getSnapshot());\n };\n\n var getServerSnapshotWithSelector = maybeGetServerSnapshot === null ? undefined : function () {\n return memoizedSelector(maybeGetServerSnapshot());\n };\n return [getSnapshotWithSelector, getServerSnapshotWithSelector];\n }, [getSnapshot, getServerSnapshot, selector, isEqual]),\n getSelection = _useMemo[0],\n getServerSelection = _useMemo[1];\n\n var value = useSyncExternalStore(subscribe, getSelection, getServerSelection);\n useEffect(function () {\n inst.hasValue = true;\n inst.value = value;\n }, [value]);\n useDebugValue(value);\n return value;\n}\n\nexports.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector;\n /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\nif (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===\n 'function'\n) {\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());\n}\n \n })();\n}\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./cjs/use-sync-external-store-with-selector.production.min.js');\n} else {\n module.exports = require('./cjs/use-sync-external-store-with-selector.development.js');\n}\n","import { useCallback, useDebugValue, useLayoutEffect, useRef } from 'react';\nimport { useSyncExternalStoreWithSelector } from 'use-sync-external-store/with-selector.js';\nimport type { SubscribeOptions } from '@core/commonTypes';\nimport type { Store } from '@core/store';\nimport { hash } from '@lib/hash';\nimport { trackingProxy } from '@lib/trackingProxy';\n\nexport type UseStoreOptions = Omit<SubscribeOptions, 'runNow' | 'passive'>;\n\nexport function useStore<T>(store: Store<T>, options?: UseStoreOptions): T {\n const lastEqualsRef = useRef<(newValue: T) => boolean>();\n\n const subOptions = { ...options, runNow: false, equals: undefined, passive: false };\n\n const subscribe = useCallback(\n (listener: () => void) => {\n return store.sub(listener, subOptions);\n },\n [store, hash(subOptions)],\n );\n\n const value = useSyncExternalStoreWithSelector<T, T>(\n //\n subscribe,\n store.get,\n undefined,\n (x) => x,\n options?.equals ?? ((_v, newValue) => lastEqualsRef.current?.(newValue) ?? false),\n );\n const [proxiedValue, equals] = trackingProxy(value);\n\n useLayoutEffect(() => {\n lastEqualsRef.current = equals;\n });\n\n useDebugValue(value);\n return proxiedValue;\n}\n","import { useEffect, useMemo } from 'react';\nimport type { UseStoreOptions } from './useStore';\nimport { useStore } from './useStore';\nimport type { CacheState } from '@lib/cacheState';\nimport type { Cache } from '@core';\n\nexport type UseCacheArray<T> = [\n value: T | undefined,\n error: unknown | undefined,\n isUpdating: boolean,\n isStale: boolean,\n];\n\nexport type UseCacheValue<T> = UseCacheArray<T> & CacheState<T>;\n\nexport interface UseCacheOptions extends UseStoreOptions {\n passive?: boolean;\n}\n\nexport function useCache<T>(\n cache: Cache<T>,\n { passive, ...options }: UseCacheOptions = {},\n): UseCacheValue<T> {\n const mappedStore = useMemo(\n () =>\n cache.state.map((state) =>\n Object.assign<UseCacheArray<T>, CacheState<T>>(\n [state.value, state.error, state.isUpdating, state.isStale],\n state,\n ),\n ),\n [cache],\n );\n\n useEffect(() => (!passive ? cache.sub(() => undefined) : undefined), [cache, passive]);\n\n return useStore(mappedStore, options);\n}\n","import { useCache } from './useCache';\nimport type { UseStoreOptions } from './useStore';\nimport type { Cache } from '@core';\n\nexport function read<T>(cache: Cache<T>, options?: UseStoreOptions): T {\n const { status, value, error } = useCache(cache, options);\n\n if (status === 'value') {\n return value;\n }\n\n if (status === 'error') {\n throw error;\n }\n\n throw cache.state.once((state) => state.status !== 'pending');\n}\n","import type { Context, ReactNode } from 'react';\nimport { createContext, useContext, useMemo } from 'react';\nimport type { Store } from '@core/store';\nimport { createStore } from '@core/store';\nimport type { StoreScope } from '@core/storeScope';\n\nexport type StoreScopeProps<T> = { scope: StoreScope<T>; store?: Store<T>; children?: ReactNode };\n\nexport const contextMap = new WeakMap<StoreScope<any>, Context<Store<any>>>();\n\nexport function getStoreScopeContext<T>(scope: StoreScope<T>): Context<Store<T>> {\n let context = contextMap.get(scope);\n\n if (!context) {\n context = createContext<Store<T>>(createStore(scope.defaultValue));\n contextMap.set(scope, context);\n }\n\n return context;\n}\n\nexport function StoreScopeProvider<T>({ scope, store: inputStore, children }: StoreScopeProps<T>) {\n const context = getStoreScopeContext(scope);\n const currentStore = useMemo(\n () => inputStore ?? createStore(scope.defaultValue),\n [scope, inputStore],\n );\n\n return <context.Provider value={currentStore}>{children}</context.Provider>;\n}\n\nexport function useStoreScope<T>(scope: StoreScope<T>): Store<T> {\n const context = getStoreScopeContext(scope);\n return useContext(context);\n}\n","import type { UseStoreOptions } from './useStore';\nimport { useStore } from './useStore';\nimport type { Store } from '@core/store';\nimport type { UpdateFunction } from '@core/commonTypes';\n\nexport function useProp<T>(\n store: Store<T>,\n options?: UseStoreOptions,\n): [value: T, setValue: UpdateFunction<T>] {\n const value = useStore(store, options);\n\n return [value, store.set];\n}\n"],"names":["a","c","d","b","e","useRef","useEffect","useMemo","useDebugValue","require$$0","require$$1","useSyncExternalStoreWithSelector"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AASa,MAAI,IAAE;AAAiB,WAAS,EAAE,GAAE,GAAE;AAAC,WAAO,MAAI,MAAI,MAAI,KAAG,IAAE,MAAI,IAAE,MAAI,MAAI,KAAG,MAAI;AAAA,EAAC;AAAC,MAAI,IAAE,eAAa,OAAO,OAAO,KAAG,OAAO,KAAG,GAAE,IAAE,EAAE,sBAAqB,IAAE,EAAE,QAAO,IAAE,EAAE,WAAU,IAAE,EAAE,SAAQ,IAAE,EAAE;AACrN,kDAAA,mCAAyC,SAAS,GAAE,GAA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