cross-state 0.26.0 → 0.27.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +9 -9
- package/dist/cjs/react/index.cjs +4 -3
- package/dist/cjs/react/index.cjs.map +1 -1
- package/dist/cjs/react/register.cjs +3 -3
- package/dist/cjs/scope.cjs +348 -569
- package/dist/cjs/scope.cjs.map +1 -1
- package/dist/cjs/scope2.cjs +570 -349
- package/dist/cjs/scope2.cjs.map +1 -1
- package/dist/es/index.mjs +2 -2
- package/dist/es/react/index.mjs +5 -4
- package/dist/es/react/index.mjs.map +1 -1
- package/dist/es/react/register.mjs +3 -3
- package/dist/es/scope.mjs +349 -570
- package/dist/es/scope.mjs.map +1 -1
- package/dist/es/scope2.mjs +571 -350
- package/dist/es/scope2.mjs.map +1 -1
- package/dist/types/react/form/formField.d.ts +10 -2
- package/package.json +28 -28
package/dist/es/scope2.mjs
CHANGED
|
@@ -1,393 +1,614 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { d as deepEqual, m as makeSelector, c as createStore } from "./store.mjs";
|
|
2
|
+
import require$$0, { useRef, useMemo, useCallback, useLayoutEffect, useDebugValue, useEffect, useContext, createContext } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
4
|
import { h as hash } from "./hash.mjs";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
add(resource) {
|
|
11
|
-
const ref = new WeakRef(resource);
|
|
12
|
-
this.refMap.set(resource, ref);
|
|
13
|
-
this.refSet.add(ref);
|
|
14
|
-
}
|
|
15
|
-
delete(resource) {
|
|
16
|
-
const ref = this.refMap.get(resource);
|
|
17
|
-
if (ref) {
|
|
18
|
-
this.refMap.delete(resource);
|
|
19
|
-
this.refSet.delete(ref);
|
|
20
|
-
}
|
|
5
|
+
const unwrapProxySymbol = /* @__PURE__ */ Symbol("unwrapProxy");
|
|
6
|
+
function isPlainObject(value) {
|
|
7
|
+
return typeof value === "object" && value !== null && Object.getPrototypeOf(value) === Object.prototype;
|
|
8
|
+
}
|
|
9
|
+
function trackingProxy(value, equals = deepEqual) {
|
|
10
|
+
if (!isPlainObject(value) && !Array.isArray(value)) {
|
|
11
|
+
return [value, (other) => equals(value, other)];
|
|
21
12
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
13
|
+
value = value[unwrapProxySymbol] ?? value;
|
|
14
|
+
const deps = new Array();
|
|
15
|
+
const revokations = new Array();
|
|
16
|
+
let revoked = false;
|
|
17
|
+
function trackComplexProp(function_, ...args) {
|
|
18
|
+
const [proxiedValue, equals2, revoke] = trackingProxy(function_(value, ...args));
|
|
19
|
+
deps.push((otherValue) => {
|
|
20
|
+
if (!isPlainObject(otherValue) && !Array.isArray(otherValue)) {
|
|
21
|
+
return false;
|
|
29
22
|
}
|
|
23
|
+
return equals2(function_(otherValue, ...args));
|
|
24
|
+
});
|
|
25
|
+
if (revoke) {
|
|
26
|
+
revokations.push(revoke);
|
|
30
27
|
}
|
|
28
|
+
return proxiedValue;
|
|
29
|
+
}
|
|
30
|
+
function trackSimpleProp(function_, ...args) {
|
|
31
|
+
const calculatedValue = function_(value, ...args);
|
|
32
|
+
deps.push((otherValue) => {
|
|
33
|
+
return function_(otherValue, ...args) === calculatedValue;
|
|
34
|
+
});
|
|
35
|
+
return calculatedValue;
|
|
31
36
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
const proxy = new Proxy(value, {
|
|
38
|
+
get(target, p, receiver) {
|
|
39
|
+
if (p === unwrapProxySymbol) {
|
|
40
|
+
return value;
|
|
41
|
+
}
|
|
42
|
+
if (revoked) {
|
|
43
|
+
return target[p];
|
|
39
44
|
}
|
|
45
|
+
const { writable, configurable } = Object.getOwnPropertyDescriptor(target, p) ?? {};
|
|
46
|
+
if (writable === false && configurable === false) {
|
|
47
|
+
return target[p];
|
|
48
|
+
}
|
|
49
|
+
return trackComplexProp(Reflect.get, p, receiver);
|
|
50
|
+
},
|
|
51
|
+
getOwnPropertyDescriptor(target, p) {
|
|
52
|
+
const { writable, configurable } = Object.getOwnPropertyDescriptor(target, p) ?? {};
|
|
53
|
+
if (writable === false && configurable === false) {
|
|
54
|
+
return Reflect.getOwnPropertyDescriptor(target, p);
|
|
55
|
+
}
|
|
56
|
+
return trackComplexProp(Reflect.getOwnPropertyDescriptor, p);
|
|
57
|
+
},
|
|
58
|
+
ownKeys() {
|
|
59
|
+
return trackComplexProp(Reflect.ownKeys);
|
|
60
|
+
},
|
|
61
|
+
getPrototypeOf() {
|
|
62
|
+
return trackSimpleProp(Reflect.getPrototypeOf);
|
|
63
|
+
},
|
|
64
|
+
has(_target, p) {
|
|
65
|
+
return trackSimpleProp(Reflect.has, p);
|
|
66
|
+
},
|
|
67
|
+
isExtensible() {
|
|
68
|
+
return trackSimpleProp(Reflect.isExtensible);
|
|
40
69
|
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
70
|
+
});
|
|
71
|
+
return [
|
|
72
|
+
proxy,
|
|
73
|
+
(other) => !!other && deps.every((equals2) => equals2(other)),
|
|
74
|
+
() => {
|
|
75
|
+
revoked = true;
|
|
76
|
+
revokations.forEach((revoke) => revoke());
|
|
77
|
+
}
|
|
78
|
+
];
|
|
46
79
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
80
|
+
var withSelector = { exports: {} };
|
|
81
|
+
var withSelector_development = {};
|
|
82
|
+
var shim = { exports: {} };
|
|
83
|
+
var useSyncExternalStoreShim_development = {};
|
|
84
|
+
/**
|
|
85
|
+
* @license React
|
|
86
|
+
* use-sync-external-store-shim.development.js
|
|
87
|
+
*
|
|
88
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
89
|
+
*
|
|
90
|
+
* This source code is licensed under the MIT license found in the
|
|
91
|
+
* LICENSE file in the root directory of this source tree.
|
|
92
|
+
*/
|
|
93
|
+
var hasRequiredUseSyncExternalStoreShim_development;
|
|
94
|
+
function requireUseSyncExternalStoreShim_development() {
|
|
95
|
+
if (hasRequiredUseSyncExternalStoreShim_development)
|
|
96
|
+
return useSyncExternalStoreShim_development;
|
|
97
|
+
hasRequiredUseSyncExternalStoreShim_development = 1;
|
|
98
|
+
if (process.env.NODE_ENV !== "production") {
|
|
99
|
+
(function() {
|
|
100
|
+
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function") {
|
|
101
|
+
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
|
|
60
102
|
}
|
|
61
|
-
|
|
62
|
-
|
|
103
|
+
var React = require$$0;
|
|
104
|
+
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
105
|
+
function error(format) {
|
|
106
|
+
{
|
|
107
|
+
{
|
|
108
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
109
|
+
args[_key2 - 1] = arguments[_key2];
|
|
110
|
+
}
|
|
111
|
+
printWarning("error", format, args);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
63
114
|
}
|
|
64
|
-
|
|
115
|
+
function printWarning(level, format, args) {
|
|
116
|
+
{
|
|
117
|
+
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
118
|
+
var stack = ReactDebugCurrentFrame.getStackAddendum();
|
|
119
|
+
if (stack !== "") {
|
|
120
|
+
format += "%s";
|
|
121
|
+
args = args.concat([stack]);
|
|
122
|
+
}
|
|
123
|
+
var argsWithFormat = args.map(function(item) {
|
|
124
|
+
return String(item);
|
|
125
|
+
});
|
|
126
|
+
argsWithFormat.unshift("Warning: " + format);
|
|
127
|
+
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function is(x, y) {
|
|
131
|
+
return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y;
|
|
132
|
+
}
|
|
133
|
+
var objectIs = typeof Object.is === "function" ? Object.is : is;
|
|
134
|
+
var useState = React.useState, useEffect2 = React.useEffect, useLayoutEffect2 = React.useLayoutEffect, useDebugValue2 = React.useDebugValue;
|
|
135
|
+
var didWarnOld18Alpha = false;
|
|
136
|
+
var didWarnUncachedGetSnapshot = false;
|
|
137
|
+
function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
|
|
138
|
+
{
|
|
139
|
+
if (!didWarnOld18Alpha) {
|
|
140
|
+
if (React.startTransition !== void 0) {
|
|
141
|
+
didWarnOld18Alpha = true;
|
|
142
|
+
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.");
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
var value = getSnapshot();
|
|
147
|
+
{
|
|
148
|
+
if (!didWarnUncachedGetSnapshot) {
|
|
149
|
+
var cachedValue = getSnapshot();
|
|
150
|
+
if (!objectIs(value, cachedValue)) {
|
|
151
|
+
error("The result of getSnapshot should be cached to avoid an infinite loop");
|
|
152
|
+
didWarnUncachedGetSnapshot = true;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
var _useState = useState({
|
|
157
|
+
inst: {
|
|
158
|
+
value,
|
|
159
|
+
getSnapshot
|
|
160
|
+
}
|
|
161
|
+
}), inst = _useState[0].inst, forceUpdate = _useState[1];
|
|
162
|
+
useLayoutEffect2(function() {
|
|
163
|
+
inst.value = value;
|
|
164
|
+
inst.getSnapshot = getSnapshot;
|
|
165
|
+
if (checkIfSnapshotChanged(inst)) {
|
|
166
|
+
forceUpdate({
|
|
167
|
+
inst
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
}, [subscribe, value, getSnapshot]);
|
|
171
|
+
useEffect2(function() {
|
|
172
|
+
if (checkIfSnapshotChanged(inst)) {
|
|
173
|
+
forceUpdate({
|
|
174
|
+
inst
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
var handleStoreChange = function() {
|
|
178
|
+
if (checkIfSnapshotChanged(inst)) {
|
|
179
|
+
forceUpdate({
|
|
180
|
+
inst
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
return subscribe(handleStoreChange);
|
|
185
|
+
}, [subscribe]);
|
|
186
|
+
useDebugValue2(value);
|
|
187
|
+
return value;
|
|
188
|
+
}
|
|
189
|
+
function checkIfSnapshotChanged(inst) {
|
|
190
|
+
var latestGetSnapshot = inst.getSnapshot;
|
|
191
|
+
var prevValue = inst.value;
|
|
192
|
+
try {
|
|
193
|
+
var nextValue = latestGetSnapshot();
|
|
194
|
+
return !objectIs(prevValue, nextValue);
|
|
195
|
+
} catch (error2) {
|
|
196
|
+
return true;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
function useSyncExternalStore$1(subscribe, getSnapshot, getServerSnapshot) {
|
|
200
|
+
return getSnapshot();
|
|
201
|
+
}
|
|
202
|
+
var canUseDOM = !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
|
|
203
|
+
var isServerEnvironment = !canUseDOM;
|
|
204
|
+
var shim2 = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore;
|
|
205
|
+
var useSyncExternalStore$2 = React.useSyncExternalStore !== void 0 ? React.useSyncExternalStore : shim2;
|
|
206
|
+
useSyncExternalStoreShim_development.useSyncExternalStore = useSyncExternalStore$2;
|
|
207
|
+
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === "function") {
|
|
208
|
+
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
|
|
209
|
+
}
|
|
210
|
+
})();
|
|
65
211
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
212
|
+
return useSyncExternalStoreShim_development;
|
|
213
|
+
}
|
|
214
|
+
var useSyncExternalStoreShim_production_min = {};
|
|
215
|
+
/**
|
|
216
|
+
* @license React
|
|
217
|
+
* use-sync-external-store-shim.production.min.js
|
|
218
|
+
*
|
|
219
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
220
|
+
*
|
|
221
|
+
* This source code is licensed under the MIT license found in the
|
|
222
|
+
* LICENSE file in the root directory of this source tree.
|
|
223
|
+
*/
|
|
224
|
+
var hasRequiredUseSyncExternalStoreShim_production_min;
|
|
225
|
+
function requireUseSyncExternalStoreShim_production_min() {
|
|
226
|
+
if (hasRequiredUseSyncExternalStoreShim_production_min)
|
|
227
|
+
return useSyncExternalStoreShim_production_min;
|
|
228
|
+
hasRequiredUseSyncExternalStoreShim_production_min = 1;
|
|
229
|
+
var e = require$$0;
|
|
230
|
+
function h(a, b) {
|
|
231
|
+
return a === b && (0 !== a || 1 / a === 1 / b) || a !== a && b !== b;
|
|
84
232
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
233
|
+
var k = "function" === typeof Object.is ? Object.is : h, l = e.useState, m = e.useEffect, n = e.useLayoutEffect, p = e.useDebugValue;
|
|
234
|
+
function q(a, b) {
|
|
235
|
+
var d = b(), f = l({ inst: { value: d, getSnapshot: b } }), c = f[0].inst, g = f[1];
|
|
236
|
+
n(function() {
|
|
237
|
+
c.value = d;
|
|
238
|
+
c.getSnapshot = b;
|
|
239
|
+
r(c) && g({ inst: c });
|
|
240
|
+
}, [a, d, b]);
|
|
241
|
+
m(function() {
|
|
242
|
+
r(c) && g({ inst: c });
|
|
243
|
+
return a(function() {
|
|
244
|
+
r(c) && g({ inst: c });
|
|
245
|
+
});
|
|
246
|
+
}, [a]);
|
|
247
|
+
p(d);
|
|
248
|
+
return d;
|
|
90
249
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
250
|
+
function r(a) {
|
|
251
|
+
var b = a.getSnapshot;
|
|
252
|
+
a = a.value;
|
|
253
|
+
try {
|
|
254
|
+
var d = b();
|
|
255
|
+
return !k(a, d);
|
|
256
|
+
} catch (f) {
|
|
257
|
+
return true;
|
|
94
258
|
}
|
|
95
259
|
}
|
|
96
|
-
|
|
97
|
-
return
|
|
98
|
-
count: this.cache.size,
|
|
99
|
-
withRef: [...this.cache.values()].filter((x) => !!x.ref).length,
|
|
100
|
-
withWeakRef: [...this.cache.values()].filter((x) => {
|
|
101
|
-
var _a;
|
|
102
|
-
return !!((_a = x.weakRef) == null ? void 0 : _a.deref());
|
|
103
|
-
}).length
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
now() {
|
|
107
|
-
return performance.now();
|
|
260
|
+
function t(a, b) {
|
|
261
|
+
return b();
|
|
108
262
|
}
|
|
263
|
+
var u = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? t : q;
|
|
264
|
+
useSyncExternalStoreShim_production_min.useSyncExternalStore = void 0 !== e.useSyncExternalStore ? e.useSyncExternalStore : u;
|
|
265
|
+
return useSyncExternalStoreShim_production_min;
|
|
109
266
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
static resolve(value) {
|
|
121
|
-
return new PromiseWithState(Promise.resolve(value), {
|
|
122
|
-
status: "value",
|
|
123
|
-
value
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
static reject(error) {
|
|
127
|
-
return new PromiseWithState(Promise.reject(error), { status: "error", error });
|
|
267
|
+
var hasRequiredShim;
|
|
268
|
+
function requireShim() {
|
|
269
|
+
if (hasRequiredShim)
|
|
270
|
+
return shim.exports;
|
|
271
|
+
hasRequiredShim = 1;
|
|
272
|
+
if (process.env.NODE_ENV === "production") {
|
|
273
|
+
shim.exports = requireUseSyncExternalStoreShim_production_min();
|
|
274
|
+
} else {
|
|
275
|
+
shim.exports = requireUseSyncExternalStoreShim_development();
|
|
128
276
|
}
|
|
277
|
+
return shim.exports;
|
|
129
278
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
279
|
+
/**
|
|
280
|
+
* @license React
|
|
281
|
+
* use-sync-external-store-shim/with-selector.development.js
|
|
282
|
+
*
|
|
283
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
284
|
+
*
|
|
285
|
+
* This source code is licensed under the MIT license found in the
|
|
286
|
+
* LICENSE file in the root directory of this source tree.
|
|
287
|
+
*/
|
|
288
|
+
var hasRequiredWithSelector_development;
|
|
289
|
+
function requireWithSelector_development() {
|
|
290
|
+
if (hasRequiredWithSelector_development)
|
|
291
|
+
return withSelector_development;
|
|
292
|
+
hasRequiredWithSelector_development = 1;
|
|
293
|
+
if (process.env.NODE_ENV !== "production") {
|
|
294
|
+
(function() {
|
|
295
|
+
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function") {
|
|
296
|
+
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
|
|
297
|
+
}
|
|
298
|
+
var React = require$$0;
|
|
299
|
+
var shim2 = requireShim();
|
|
300
|
+
function is(x, y) {
|
|
301
|
+
return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y;
|
|
302
|
+
}
|
|
303
|
+
var objectIs = typeof Object.is === "function" ? Object.is : is;
|
|
304
|
+
var useSyncExternalStore = shim2.useSyncExternalStore;
|
|
305
|
+
var useRef2 = React.useRef, useEffect2 = React.useEffect, useMemo2 = React.useMemo, useDebugValue2 = React.useDebugValue;
|
|
306
|
+
function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
|
|
307
|
+
var instRef = useRef2(null);
|
|
308
|
+
var inst;
|
|
309
|
+
if (instRef.current === null) {
|
|
310
|
+
inst = {
|
|
311
|
+
hasValue: false,
|
|
312
|
+
value: null
|
|
313
|
+
};
|
|
314
|
+
instRef.current = inst;
|
|
315
|
+
} else {
|
|
316
|
+
inst = instRef.current;
|
|
137
317
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
318
|
+
var _useMemo = useMemo2(function() {
|
|
319
|
+
var hasMemo = false;
|
|
320
|
+
var memoizedSnapshot;
|
|
321
|
+
var memoizedSelection;
|
|
322
|
+
var memoizedSelector = function(nextSnapshot) {
|
|
323
|
+
if (!hasMemo) {
|
|
324
|
+
hasMemo = true;
|
|
325
|
+
memoizedSnapshot = nextSnapshot;
|
|
326
|
+
var _nextSelection = selector(nextSnapshot);
|
|
327
|
+
if (isEqual !== void 0) {
|
|
328
|
+
if (inst.hasValue) {
|
|
329
|
+
var currentSelection = inst.value;
|
|
330
|
+
if (isEqual(currentSelection, _nextSelection)) {
|
|
331
|
+
memoizedSelection = currentSelection;
|
|
332
|
+
return currentSelection;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
memoizedSelection = _nextSelection;
|
|
337
|
+
return _nextSelection;
|
|
338
|
+
}
|
|
339
|
+
var prevSnapshot = memoizedSnapshot;
|
|
340
|
+
var prevSelection = memoizedSelection;
|
|
341
|
+
if (objectIs(prevSnapshot, nextSnapshot)) {
|
|
342
|
+
return prevSelection;
|
|
343
|
+
}
|
|
344
|
+
var nextSelection = selector(nextSnapshot);
|
|
345
|
+
if (isEqual !== void 0 && isEqual(prevSelection, nextSelection)) {
|
|
346
|
+
return prevSelection;
|
|
347
|
+
}
|
|
348
|
+
memoizedSnapshot = nextSnapshot;
|
|
349
|
+
memoizedSelection = nextSelection;
|
|
350
|
+
return nextSelection;
|
|
351
|
+
};
|
|
352
|
+
var maybeGetServerSnapshot = getServerSnapshot === void 0 ? null : getServerSnapshot;
|
|
353
|
+
var getSnapshotWithSelector = function() {
|
|
354
|
+
return memoizedSelector(getSnapshot());
|
|
355
|
+
};
|
|
356
|
+
var getServerSnapshotWithSelector = maybeGetServerSnapshot === null ? void 0 : function() {
|
|
357
|
+
return memoizedSelector(maybeGetServerSnapshot());
|
|
358
|
+
};
|
|
359
|
+
return [getSnapshotWithSelector, getServerSnapshotWithSelector];
|
|
360
|
+
}, [getSnapshot, getServerSnapshot, selector, isEqual]), getSelection = _useMemo[0], getServerSelection = _useMemo[1];
|
|
361
|
+
var value = useSyncExternalStore(subscribe, getSelection, getServerSelection);
|
|
362
|
+
useEffect2(function() {
|
|
363
|
+
inst.hasValue = true;
|
|
364
|
+
inst.value = value;
|
|
365
|
+
}, [value]);
|
|
366
|
+
useDebugValue2(value);
|
|
367
|
+
return value;
|
|
164
368
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
updateValue(value) {
|
|
172
|
-
this.set(PromiseWithState.resolve(value));
|
|
369
|
+
withSelector_development.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector;
|
|
370
|
+
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === "function") {
|
|
371
|
+
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
|
|
372
|
+
}
|
|
373
|
+
})();
|
|
173
374
|
}
|
|
174
|
-
|
|
175
|
-
|
|
375
|
+
return withSelector_development;
|
|
376
|
+
}
|
|
377
|
+
var withSelector_production_min = {};
|
|
378
|
+
/**
|
|
379
|
+
* @license React
|
|
380
|
+
* use-sync-external-store-shim/with-selector.production.min.js
|
|
381
|
+
*
|
|
382
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
383
|
+
*
|
|
384
|
+
* This source code is licensed under the MIT license found in the
|
|
385
|
+
* LICENSE file in the root directory of this source tree.
|
|
386
|
+
*/
|
|
387
|
+
var hasRequiredWithSelector_production_min;
|
|
388
|
+
function requireWithSelector_production_min() {
|
|
389
|
+
if (hasRequiredWithSelector_production_min)
|
|
390
|
+
return withSelector_production_min;
|
|
391
|
+
hasRequiredWithSelector_production_min = 1;
|
|
392
|
+
var h = require$$0, n = requireShim();
|
|
393
|
+
function p(a, b) {
|
|
394
|
+
return a === b && (0 !== a || 1 / a === 1 / b) || a !== a && b !== b;
|
|
176
395
|
}
|
|
177
|
-
|
|
396
|
+
var q = "function" === typeof Object.is ? Object.is : p, r = n.useSyncExternalStore, t = h.useRef, u = h.useEffect, v = h.useMemo, w = h.useDebugValue;
|
|
397
|
+
withSelector_production_min.useSyncExternalStoreWithSelector = function(a, b, e, l, g) {
|
|
398
|
+
var c = t(null);
|
|
399
|
+
if (null === c.current) {
|
|
400
|
+
var f = { hasValue: false, value: null };
|
|
401
|
+
c.current = f;
|
|
402
|
+
} else
|
|
403
|
+
f = c.current;
|
|
404
|
+
c = v(function() {
|
|
405
|
+
function a2(a3) {
|
|
406
|
+
if (!c2) {
|
|
407
|
+
c2 = true;
|
|
408
|
+
d2 = a3;
|
|
409
|
+
a3 = l(a3);
|
|
410
|
+
if (void 0 !== g && f.hasValue) {
|
|
411
|
+
var b2 = f.value;
|
|
412
|
+
if (g(b2, a3))
|
|
413
|
+
return k = b2;
|
|
414
|
+
}
|
|
415
|
+
return k = a3;
|
|
416
|
+
}
|
|
417
|
+
b2 = k;
|
|
418
|
+
if (q(d2, a3))
|
|
419
|
+
return b2;
|
|
420
|
+
var e2 = l(a3);
|
|
421
|
+
if (void 0 !== g && g(b2, e2))
|
|
422
|
+
return b2;
|
|
423
|
+
d2 = a3;
|
|
424
|
+
return k = e2;
|
|
425
|
+
}
|
|
426
|
+
var c2 = false, d2, k, m = void 0 === e ? null : e;
|
|
427
|
+
return [function() {
|
|
428
|
+
return a2(b());
|
|
429
|
+
}, null === m ? void 0 : function() {
|
|
430
|
+
return a2(m());
|
|
431
|
+
}];
|
|
432
|
+
}, [b, e, l, g]);
|
|
433
|
+
var d = r(a, c[0], c[1]);
|
|
434
|
+
u(function() {
|
|
435
|
+
f.hasValue = true;
|
|
436
|
+
f.value = d;
|
|
437
|
+
}, [d]);
|
|
438
|
+
w(d);
|
|
439
|
+
return d;
|
|
440
|
+
};
|
|
441
|
+
return withSelector_production_min;
|
|
442
|
+
}
|
|
443
|
+
if (process.env.NODE_ENV === "production") {
|
|
444
|
+
withSelector.exports = requireWithSelector_production_min();
|
|
445
|
+
} else {
|
|
446
|
+
withSelector.exports = requireWithSelector_development();
|
|
447
|
+
}
|
|
448
|
+
var withSelectorExports = withSelector.exports;
|
|
449
|
+
function useStore(store, argument1, argument2) {
|
|
450
|
+
const selector = makeSelector(
|
|
451
|
+
typeof argument1 === "function" || typeof argument1 === "string" ? argument1 : void 0
|
|
452
|
+
);
|
|
453
|
+
const {
|
|
454
|
+
disableTrackingProxy = true,
|
|
455
|
+
equals = deepEqual,
|
|
456
|
+
withViewTransition,
|
|
457
|
+
...options
|
|
458
|
+
} = typeof argument1 === "object" ? argument1 : argument2 ?? {};
|
|
459
|
+
const lastEqualsRef = useRef();
|
|
460
|
+
const { rootStore, mappingSelector } = useMemo(() => {
|
|
178
461
|
var _a;
|
|
179
|
-
const
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}
|
|
186
|
-
const { status, isStale, isUpdating } = this.state.get();
|
|
187
|
-
if (status !== "pending" && !isStale && !isUpdating) {
|
|
188
|
-
this.stalePromise = (_a = this._value) == null ? void 0 : _a.v;
|
|
189
|
-
}
|
|
190
|
-
this.state.set((state) => ({
|
|
191
|
-
...state,
|
|
192
|
-
isStale: true,
|
|
193
|
-
isUpdating: false
|
|
194
|
-
}));
|
|
195
|
-
this.calculationHelper.stop();
|
|
196
|
-
super.reset();
|
|
197
|
-
}
|
|
198
|
-
clear({ invalidateDependencies = true } = {}) {
|
|
199
|
-
if (invalidateDependencies) {
|
|
200
|
-
this.calculationHelper.invalidateDependencies();
|
|
201
|
-
}
|
|
202
|
-
this.state.set({
|
|
203
|
-
status: "pending",
|
|
204
|
-
isStale: true,
|
|
205
|
-
isUpdating: false
|
|
206
|
-
});
|
|
207
|
-
delete this.stalePromise;
|
|
208
|
-
this.calculationHelper.stop();
|
|
209
|
-
super.reset();
|
|
210
|
-
}
|
|
211
|
-
mapValue(_selector) {
|
|
212
|
-
const selector = makeSelector(_selector);
|
|
213
|
-
const derivedFromCache = {
|
|
214
|
-
cache: this.derivedFromCache ? this.derivedFromCache.cache : this,
|
|
215
|
-
selectors: this.derivedFromCache ? [...this.derivedFromCache.selectors, _selector] : [_selector]
|
|
216
|
-
};
|
|
217
|
-
const that = this;
|
|
218
|
-
return new Cache(
|
|
219
|
-
async function() {
|
|
220
|
-
const value = await this.use(that);
|
|
221
|
-
return selector(value);
|
|
222
|
-
},
|
|
223
|
-
{},
|
|
224
|
-
derivedFromCache
|
|
225
|
-
);
|
|
226
|
-
}
|
|
227
|
-
watchPromise() {
|
|
228
|
-
this.subscribe(
|
|
229
|
-
async (promise) => {
|
|
230
|
-
var _a, _b;
|
|
231
|
-
if (promise instanceof PromiseWithState) {
|
|
232
|
-
this.state.set({
|
|
233
|
-
...promise.state,
|
|
234
|
-
isStale: false,
|
|
235
|
-
isUpdating: false
|
|
236
|
-
});
|
|
237
|
-
delete this.stalePromise;
|
|
238
|
-
this.setTimers();
|
|
239
|
-
return;
|
|
462
|
+
const rootStore2 = ((_a = store.derivedFrom) == null ? void 0 : _a.store) ?? store;
|
|
463
|
+
let mappingSelector2 = (x) => x;
|
|
464
|
+
if (store.derivedFrom) {
|
|
465
|
+
mappingSelector2 = (value2) => {
|
|
466
|
+
for (const s of store.derivedFrom.selectors) {
|
|
467
|
+
value2 = makeSelector(s)(value2);
|
|
240
468
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
469
|
+
return value2;
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
return { rootStore: rootStore2, mappingSelector: mappingSelector2 };
|
|
473
|
+
}, [store]);
|
|
474
|
+
const subOptions = { ...options, runNow: false, passive: false };
|
|
475
|
+
const subscribe = useCallback(
|
|
476
|
+
(listener) => {
|
|
477
|
+
let _listener = listener;
|
|
478
|
+
if (withViewTransition && document.startViewTransition) {
|
|
479
|
+
let lastObservedValue;
|
|
480
|
+
_listener = (value2) => {
|
|
481
|
+
const observedValue = withViewTransition instanceof Function ? withViewTransition(value2) : value2;
|
|
482
|
+
if (equals(lastObservedValue, observedValue)) {
|
|
483
|
+
listener();
|
|
249
484
|
return;
|
|
250
485
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
486
|
+
lastObservedValue = observedValue;
|
|
487
|
+
let hasChanges = false;
|
|
488
|
+
const mutationObserver = new MutationObserver(() => {
|
|
489
|
+
hasChanges = true;
|
|
490
|
+
mutationObserver.disconnect();
|
|
256
491
|
});
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
this.state.set({
|
|
264
|
-
status: "error",
|
|
265
|
-
error,
|
|
266
|
-
isStale: false,
|
|
267
|
-
isUpdating: false
|
|
492
|
+
mutationObserver.observe(document.body, { childList: true, subtree: true });
|
|
493
|
+
document.startViewTransition(() => {
|
|
494
|
+
listener();
|
|
495
|
+
if (!hasChanges) {
|
|
496
|
+
throw new Error("no change");
|
|
497
|
+
}
|
|
268
498
|
});
|
|
269
|
-
|
|
270
|
-
this.setTimers();
|
|
271
|
-
}
|
|
272
|
-
},
|
|
273
|
-
{ passive: true }
|
|
274
|
-
);
|
|
275
|
-
}
|
|
276
|
-
setTimers() {
|
|
277
|
-
if (this.invalidationTimer) {
|
|
278
|
-
clearTimeout(this.invalidationTimer);
|
|
279
|
-
}
|
|
280
|
-
this.invalidationTimer = void 0;
|
|
281
|
-
const state = this.state.get();
|
|
282
|
-
let { invalidateAfter = createCache.defaultOptions.invalidateAfter } = this.options;
|
|
283
|
-
const ref = new WeakRef(this);
|
|
284
|
-
if (state.status === "pending") {
|
|
285
|
-
return;
|
|
286
|
-
}
|
|
287
|
-
if (invalidateAfter instanceof Function) {
|
|
288
|
-
invalidateAfter = invalidateAfter(state);
|
|
289
|
-
}
|
|
290
|
-
if (invalidateAfter !== null && invalidateAfter !== void 0) {
|
|
291
|
-
this.invalidationTimer = setTimeout(
|
|
292
|
-
() => {
|
|
293
|
-
var _a;
|
|
294
|
-
return (_a = ref == null ? void 0 : ref.deref()) == null ? void 0 : _a.invalidate();
|
|
295
|
-
},
|
|
296
|
-
calcDuration(invalidateAfter)
|
|
297
|
-
);
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
watchFocus() {
|
|
301
|
-
const { invalidateOnWindowFocus = createCache.defaultOptions.invalidateOnWindowFocus } = this.options;
|
|
302
|
-
if (!invalidateOnWindowFocus || typeof document === "undefined" || typeof document.addEventListener === "undefined") {
|
|
303
|
-
return;
|
|
304
|
-
}
|
|
305
|
-
const ref = new WeakRef(this);
|
|
306
|
-
const onFocus = () => {
|
|
307
|
-
const that = ref == null ? void 0 : ref.deref();
|
|
308
|
-
if (!that) {
|
|
309
|
-
document.removeEventListener("visibilitychange", onFocus);
|
|
310
|
-
return;
|
|
311
|
-
}
|
|
312
|
-
if (!document.hidden) {
|
|
313
|
-
that.invalidate();
|
|
499
|
+
};
|
|
314
500
|
}
|
|
315
|
-
|
|
316
|
-
document.addEventListener("visibilitychange", onFocus);
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
function create(cacheFunction, options) {
|
|
320
|
-
const { clearUnusedAfter = createCache.defaultOptions.clearUnusedAfter, resourceGroup } = options ?? {};
|
|
321
|
-
let baseInstance;
|
|
322
|
-
const instanceCache = new InstanceCache(
|
|
323
|
-
(...args) => {
|
|
324
|
-
if (args.length === 0 && baseInstance) {
|
|
325
|
-
return baseInstance;
|
|
326
|
-
}
|
|
327
|
-
return new Cache(function() {
|
|
328
|
-
return cacheFunction.apply(this, args);
|
|
329
|
-
}, options);
|
|
501
|
+
return rootStore.subscribe(_listener, subOptions);
|
|
330
502
|
},
|
|
331
|
-
|
|
503
|
+
[rootStore, hash(subOptions)]
|
|
332
504
|
);
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
for (const instance of instanceCache.values()) {
|
|
343
|
-
instance.clear();
|
|
344
|
-
}
|
|
345
|
-
};
|
|
346
|
-
baseInstance = Object.assign(
|
|
347
|
-
new Cache(
|
|
348
|
-
function() {
|
|
349
|
-
return cacheFunction.apply(this);
|
|
350
|
-
},
|
|
351
|
-
options,
|
|
352
|
-
void 0,
|
|
353
|
-
get
|
|
354
|
-
),
|
|
355
|
-
{
|
|
356
|
-
invalidateAll,
|
|
357
|
-
clearAll
|
|
505
|
+
let value = withSelectorExports.useSyncExternalStoreWithSelector(
|
|
506
|
+
//
|
|
507
|
+
subscribe,
|
|
508
|
+
rootStore.get,
|
|
509
|
+
void 0,
|
|
510
|
+
(x) => selector(mappingSelector(x)),
|
|
511
|
+
(_v, newValue) => {
|
|
512
|
+
var _a;
|
|
513
|
+
return ((_a = lastEqualsRef.current) == null ? void 0 : _a.call(lastEqualsRef, newValue)) ?? false;
|
|
358
514
|
}
|
|
359
515
|
);
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
516
|
+
let lastEquals = (newValue) => equals(newValue, value);
|
|
517
|
+
let revoke;
|
|
518
|
+
if (!disableTrackingProxy) {
|
|
519
|
+
[value, lastEquals, revoke] = trackingProxy(value, equals);
|
|
363
520
|
}
|
|
364
|
-
|
|
365
|
-
|
|
521
|
+
useLayoutEffect(() => {
|
|
522
|
+
lastEqualsRef.current = lastEquals;
|
|
523
|
+
revoke == null ? void 0 : revoke();
|
|
524
|
+
});
|
|
525
|
+
useDebugValue(value);
|
|
526
|
+
return value;
|
|
366
527
|
}
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
528
|
+
function useProp(store, argument1, argument2, argument3) {
|
|
529
|
+
const selector = typeof argument1 === "function" || typeof argument1 === "string" ? argument1 : void 0;
|
|
530
|
+
const updater = typeof argument2 === "function" ? argument2 : void 0;
|
|
531
|
+
const options = typeof argument1 === "object" ? argument1 : typeof argument2 === "object" ? argument2 : argument3;
|
|
532
|
+
if (selector) {
|
|
533
|
+
store = store.map(selector, updater);
|
|
372
534
|
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
535
|
+
const value = useStore(store, options);
|
|
536
|
+
return [value, store.set];
|
|
537
|
+
}
|
|
538
|
+
function boundUseStore(...args) {
|
|
539
|
+
return useStore(this, ...args);
|
|
540
|
+
}
|
|
541
|
+
function boundUseProp(...args) {
|
|
542
|
+
return useProp(this, ...args);
|
|
543
|
+
}
|
|
544
|
+
const reactMethods = {
|
|
545
|
+
useStore: boundUseStore,
|
|
546
|
+
useProp: boundUseProp
|
|
547
|
+
};
|
|
548
|
+
function useCache(cache, { passive, updateOnMount, withViewTransition, ...options } = {}) {
|
|
549
|
+
if (withViewTransition === true) {
|
|
550
|
+
withViewTransition = (state) => state.value;
|
|
378
551
|
}
|
|
552
|
+
const mappedState = useMemo(() => {
|
|
553
|
+
var _a;
|
|
554
|
+
const rootCache = ((_a = cache.derivedFromCache) == null ? void 0 : _a.cache) ?? cache;
|
|
555
|
+
let selector = (x) => x;
|
|
556
|
+
if (cache.derivedFromCache) {
|
|
557
|
+
selector = (value) => {
|
|
558
|
+
for (const s of cache.derivedFromCache.selectors) {
|
|
559
|
+
value = makeSelector(s)(value);
|
|
560
|
+
}
|
|
561
|
+
return value;
|
|
562
|
+
};
|
|
563
|
+
}
|
|
564
|
+
return rootCache.state.map((state) => {
|
|
565
|
+
const value = state.status === "value" ? selector(state.value) : void 0;
|
|
566
|
+
return Object.assign(
|
|
567
|
+
[value, state.error, state.isUpdating, state.isStale],
|
|
568
|
+
{ ...state, value }
|
|
569
|
+
);
|
|
570
|
+
});
|
|
571
|
+
}, [cache]);
|
|
572
|
+
useEffect(() => !passive ? cache.subscribe(() => void 0) : void 0, [cache, passive]);
|
|
573
|
+
useEffect(() => {
|
|
574
|
+
if (updateOnMount) {
|
|
575
|
+
cache.invalidate();
|
|
576
|
+
}
|
|
577
|
+
}, []);
|
|
578
|
+
return useStore(mappedState, { ...options, withViewTransition });
|
|
579
|
+
}
|
|
580
|
+
function getScopeContext(scope) {
|
|
581
|
+
scope.context ?? (scope.context = createContext(createStore(scope.defaultValue)));
|
|
582
|
+
return scope.context;
|
|
583
|
+
}
|
|
584
|
+
function ScopeProvider({ scope, store: inputStore, children }) {
|
|
585
|
+
const context = getScopeContext(scope);
|
|
586
|
+
const currentStore = useMemo(
|
|
587
|
+
() => inputStore ?? createStore(scope.defaultValue),
|
|
588
|
+
[scope, inputStore]
|
|
589
|
+
);
|
|
590
|
+
return /* @__PURE__ */ jsx(context.Provider, { value: currentStore, children });
|
|
591
|
+
}
|
|
592
|
+
function useScope(scope) {
|
|
593
|
+
const context = getScopeContext(scope);
|
|
594
|
+
return useContext(context);
|
|
595
|
+
}
|
|
596
|
+
function useScopeStore(scope, options) {
|
|
597
|
+
const store = useScope(scope);
|
|
598
|
+
return useStore(store, options);
|
|
379
599
|
}
|
|
380
|
-
function
|
|
381
|
-
|
|
600
|
+
function useScopeProp(scope, options) {
|
|
601
|
+
const store = useScope(scope);
|
|
602
|
+
return useProp(store, options);
|
|
382
603
|
}
|
|
383
604
|
export {
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
605
|
+
ScopeProvider as S,
|
|
606
|
+
useScope as a,
|
|
607
|
+
useScopeStore as b,
|
|
608
|
+
useScopeProp as c,
|
|
609
|
+
useStore as d,
|
|
610
|
+
useProp as e,
|
|
611
|
+
reactMethods as r,
|
|
612
|
+
useCache as u
|
|
392
613
|
};
|
|
393
614
|
//# sourceMappingURL=scope2.mjs.map
|