@biglogic/rgs 3.8.0 → 3.8.4
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/README.md +313 -300
- package/docs/README.md +313 -300
- package/docs/SUMMARY.md +10 -19
- package/index.js +1868 -43
- package/package.json +2 -2
- package/docs/api.md +0 -381
- package/docs/chapters/05-plugin-sdk.md +0 -290
- package/docs/chapters/05-plugins-and-extensibility.md +0 -190
- package/docs/qa.md +0 -47
- /package/docs/chapters/{06-case-studies.md → case-studies.md} +0 -0
- /package/docs/chapters/{07-faq.md → faq.md} +0 -0
- /package/docs/chapters/{02-getting-started.md → getting-started.md} +0 -0
- /package/docs/chapters/{10-local-first-sync.md → local-first-sync.md} +0 -0
- /package/docs/chapters/{08-migration-guide.md → migration-guide.md} +0 -0
- /package/docs/chapters/{04-persistence-and-safety.md → persistence-and-safety.md} +0 -0
- /package/docs/chapters/{01-philosophy.md → philosophy.md} +0 -0
- /package/docs/chapters/{09-security-architecture.md → security-architecture.md} +0 -0
- /package/docs/chapters/{03-the-magnetar-way.md → the-magnetar-way.md} +0 -0
package/index.js
CHANGED
|
@@ -1,9 +1,1835 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
2
7
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
3
27
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
28
|
|
|
5
|
-
//
|
|
6
|
-
|
|
29
|
+
// node_modules/react/cjs/react.development.js
|
|
30
|
+
var require_react_development = __commonJS({
|
|
31
|
+
"node_modules/react/cjs/react.development.js"(exports, module) {
|
|
32
|
+
"use strict";
|
|
33
|
+
(function() {
|
|
34
|
+
function defineDeprecationWarning(methodName, info) {
|
|
35
|
+
Object.defineProperty(Component.prototype, methodName, {
|
|
36
|
+
get: function() {
|
|
37
|
+
console.warn(
|
|
38
|
+
"%s(...) is deprecated in plain JavaScript React classes. %s",
|
|
39
|
+
info[0],
|
|
40
|
+
info[1]
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function getIteratorFn(maybeIterable) {
|
|
46
|
+
if (null === maybeIterable || "object" !== typeof maybeIterable)
|
|
47
|
+
return null;
|
|
48
|
+
maybeIterable = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable["@@iterator"];
|
|
49
|
+
return "function" === typeof maybeIterable ? maybeIterable : null;
|
|
50
|
+
}
|
|
51
|
+
function warnNoop(publicInstance, callerName) {
|
|
52
|
+
publicInstance = (publicInstance = publicInstance.constructor) && (publicInstance.displayName || publicInstance.name) || "ReactClass";
|
|
53
|
+
var warningKey = publicInstance + "." + callerName;
|
|
54
|
+
didWarnStateUpdateForUnmountedComponent[warningKey] || (console.error(
|
|
55
|
+
"Can't call %s on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the %s component.",
|
|
56
|
+
callerName,
|
|
57
|
+
publicInstance
|
|
58
|
+
), didWarnStateUpdateForUnmountedComponent[warningKey] = true);
|
|
59
|
+
}
|
|
60
|
+
function Component(props, context, updater) {
|
|
61
|
+
this.props = props;
|
|
62
|
+
this.context = context;
|
|
63
|
+
this.refs = emptyObject;
|
|
64
|
+
this.updater = updater || ReactNoopUpdateQueue;
|
|
65
|
+
}
|
|
66
|
+
function ComponentDummy() {
|
|
67
|
+
}
|
|
68
|
+
function PureComponent(props, context, updater) {
|
|
69
|
+
this.props = props;
|
|
70
|
+
this.context = context;
|
|
71
|
+
this.refs = emptyObject;
|
|
72
|
+
this.updater = updater || ReactNoopUpdateQueue;
|
|
73
|
+
}
|
|
74
|
+
function noop() {
|
|
75
|
+
}
|
|
76
|
+
function testStringCoercion(value) {
|
|
77
|
+
return "" + value;
|
|
78
|
+
}
|
|
79
|
+
function checkKeyStringCoercion(value) {
|
|
80
|
+
try {
|
|
81
|
+
testStringCoercion(value);
|
|
82
|
+
var JSCompiler_inline_result = false;
|
|
83
|
+
} catch (e) {
|
|
84
|
+
JSCompiler_inline_result = true;
|
|
85
|
+
}
|
|
86
|
+
if (JSCompiler_inline_result) {
|
|
87
|
+
JSCompiler_inline_result = console;
|
|
88
|
+
var JSCompiler_temp_const = JSCompiler_inline_result.error;
|
|
89
|
+
var JSCompiler_inline_result$jscomp$0 = "function" === typeof Symbol && Symbol.toStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
|
|
90
|
+
JSCompiler_temp_const.call(
|
|
91
|
+
JSCompiler_inline_result,
|
|
92
|
+
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
93
|
+
JSCompiler_inline_result$jscomp$0
|
|
94
|
+
);
|
|
95
|
+
return testStringCoercion(value);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function getComponentNameFromType(type) {
|
|
99
|
+
if (null == type) return null;
|
|
100
|
+
if ("function" === typeof type)
|
|
101
|
+
return type.$$typeof === REACT_CLIENT_REFERENCE ? null : type.displayName || type.name || null;
|
|
102
|
+
if ("string" === typeof type) return type;
|
|
103
|
+
switch (type) {
|
|
104
|
+
case REACT_FRAGMENT_TYPE:
|
|
105
|
+
return "Fragment";
|
|
106
|
+
case REACT_PROFILER_TYPE:
|
|
107
|
+
return "Profiler";
|
|
108
|
+
case REACT_STRICT_MODE_TYPE:
|
|
109
|
+
return "StrictMode";
|
|
110
|
+
case REACT_SUSPENSE_TYPE:
|
|
111
|
+
return "Suspense";
|
|
112
|
+
case REACT_SUSPENSE_LIST_TYPE:
|
|
113
|
+
return "SuspenseList";
|
|
114
|
+
case REACT_ACTIVITY_TYPE:
|
|
115
|
+
return "Activity";
|
|
116
|
+
}
|
|
117
|
+
if ("object" === typeof type)
|
|
118
|
+
switch ("number" === typeof type.tag && console.error(
|
|
119
|
+
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
120
|
+
), type.$$typeof) {
|
|
121
|
+
case REACT_PORTAL_TYPE:
|
|
122
|
+
return "Portal";
|
|
123
|
+
case REACT_CONTEXT_TYPE:
|
|
124
|
+
return type.displayName || "Context";
|
|
125
|
+
case REACT_CONSUMER_TYPE:
|
|
126
|
+
return (type._context.displayName || "Context") + ".Consumer";
|
|
127
|
+
case REACT_FORWARD_REF_TYPE:
|
|
128
|
+
var innerType = type.render;
|
|
129
|
+
type = type.displayName;
|
|
130
|
+
type || (type = innerType.displayName || innerType.name || "", type = "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef");
|
|
131
|
+
return type;
|
|
132
|
+
case REACT_MEMO_TYPE:
|
|
133
|
+
return innerType = type.displayName || null, null !== innerType ? innerType : getComponentNameFromType(type.type) || "Memo";
|
|
134
|
+
case REACT_LAZY_TYPE:
|
|
135
|
+
innerType = type._payload;
|
|
136
|
+
type = type._init;
|
|
137
|
+
try {
|
|
138
|
+
return getComponentNameFromType(type(innerType));
|
|
139
|
+
} catch (x) {
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
function getTaskName(type) {
|
|
145
|
+
if (type === REACT_FRAGMENT_TYPE) return "<>";
|
|
146
|
+
if ("object" === typeof type && null !== type && type.$$typeof === REACT_LAZY_TYPE)
|
|
147
|
+
return "<...>";
|
|
148
|
+
try {
|
|
149
|
+
var name = getComponentNameFromType(type);
|
|
150
|
+
return name ? "<" + name + ">" : "<...>";
|
|
151
|
+
} catch (x) {
|
|
152
|
+
return "<...>";
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function getOwner() {
|
|
156
|
+
var dispatcher = ReactSharedInternals.A;
|
|
157
|
+
return null === dispatcher ? null : dispatcher.getOwner();
|
|
158
|
+
}
|
|
159
|
+
function UnknownOwner() {
|
|
160
|
+
return Error("react-stack-top-frame");
|
|
161
|
+
}
|
|
162
|
+
function hasValidKey(config) {
|
|
163
|
+
if (hasOwnProperty.call(config, "key")) {
|
|
164
|
+
var getter = Object.getOwnPropertyDescriptor(config, "key").get;
|
|
165
|
+
if (getter && getter.isReactWarning) return false;
|
|
166
|
+
}
|
|
167
|
+
return void 0 !== config.key;
|
|
168
|
+
}
|
|
169
|
+
function defineKeyPropWarningGetter(props, displayName) {
|
|
170
|
+
function warnAboutAccessingKey() {
|
|
171
|
+
specialPropKeyWarningShown || (specialPropKeyWarningShown = true, console.error(
|
|
172
|
+
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
173
|
+
displayName
|
|
174
|
+
));
|
|
175
|
+
}
|
|
176
|
+
warnAboutAccessingKey.isReactWarning = true;
|
|
177
|
+
Object.defineProperty(props, "key", {
|
|
178
|
+
get: warnAboutAccessingKey,
|
|
179
|
+
configurable: true
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
function elementRefGetterWithDeprecationWarning() {
|
|
183
|
+
var componentName = getComponentNameFromType(this.type);
|
|
184
|
+
didWarnAboutElementRef[componentName] || (didWarnAboutElementRef[componentName] = true, console.error(
|
|
185
|
+
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
186
|
+
));
|
|
187
|
+
componentName = this.props.ref;
|
|
188
|
+
return void 0 !== componentName ? componentName : null;
|
|
189
|
+
}
|
|
190
|
+
function ReactElement(type, key, props, owner, debugStack, debugTask) {
|
|
191
|
+
var refProp = props.ref;
|
|
192
|
+
type = {
|
|
193
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
|
194
|
+
type,
|
|
195
|
+
key,
|
|
196
|
+
props,
|
|
197
|
+
_owner: owner
|
|
198
|
+
};
|
|
199
|
+
null !== (void 0 !== refProp ? refProp : null) ? Object.defineProperty(type, "ref", {
|
|
200
|
+
enumerable: false,
|
|
201
|
+
get: elementRefGetterWithDeprecationWarning
|
|
202
|
+
}) : Object.defineProperty(type, "ref", { enumerable: false, value: null });
|
|
203
|
+
type._store = {};
|
|
204
|
+
Object.defineProperty(type._store, "validated", {
|
|
205
|
+
configurable: false,
|
|
206
|
+
enumerable: false,
|
|
207
|
+
writable: true,
|
|
208
|
+
value: 0
|
|
209
|
+
});
|
|
210
|
+
Object.defineProperty(type, "_debugInfo", {
|
|
211
|
+
configurable: false,
|
|
212
|
+
enumerable: false,
|
|
213
|
+
writable: true,
|
|
214
|
+
value: null
|
|
215
|
+
});
|
|
216
|
+
Object.defineProperty(type, "_debugStack", {
|
|
217
|
+
configurable: false,
|
|
218
|
+
enumerable: false,
|
|
219
|
+
writable: true,
|
|
220
|
+
value: debugStack
|
|
221
|
+
});
|
|
222
|
+
Object.defineProperty(type, "_debugTask", {
|
|
223
|
+
configurable: false,
|
|
224
|
+
enumerable: false,
|
|
225
|
+
writable: true,
|
|
226
|
+
value: debugTask
|
|
227
|
+
});
|
|
228
|
+
Object.freeze && (Object.freeze(type.props), Object.freeze(type));
|
|
229
|
+
return type;
|
|
230
|
+
}
|
|
231
|
+
function cloneAndReplaceKey(oldElement, newKey) {
|
|
232
|
+
newKey = ReactElement(
|
|
233
|
+
oldElement.type,
|
|
234
|
+
newKey,
|
|
235
|
+
oldElement.props,
|
|
236
|
+
oldElement._owner,
|
|
237
|
+
oldElement._debugStack,
|
|
238
|
+
oldElement._debugTask
|
|
239
|
+
);
|
|
240
|
+
oldElement._store && (newKey._store.validated = oldElement._store.validated);
|
|
241
|
+
return newKey;
|
|
242
|
+
}
|
|
243
|
+
function validateChildKeys(node) {
|
|
244
|
+
isValidElement(node) ? node._store && (node._store.validated = 1) : "object" === typeof node && null !== node && node.$$typeof === REACT_LAZY_TYPE && ("fulfilled" === node._payload.status ? isValidElement(node._payload.value) && node._payload.value._store && (node._payload.value._store.validated = 1) : node._store && (node._store.validated = 1));
|
|
245
|
+
}
|
|
246
|
+
function isValidElement(object) {
|
|
247
|
+
return "object" === typeof object && null !== object && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
248
|
+
}
|
|
249
|
+
function escape(key) {
|
|
250
|
+
var escaperLookup = { "=": "=0", ":": "=2" };
|
|
251
|
+
return "$" + key.replace(/[=:]/g, function(match) {
|
|
252
|
+
return escaperLookup[match];
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
function getElementKey(element, index) {
|
|
256
|
+
return "object" === typeof element && null !== element && null != element.key ? (checkKeyStringCoercion(element.key), escape("" + element.key)) : index.toString(36);
|
|
257
|
+
}
|
|
258
|
+
function resolveThenable(thenable) {
|
|
259
|
+
switch (thenable.status) {
|
|
260
|
+
case "fulfilled":
|
|
261
|
+
return thenable.value;
|
|
262
|
+
case "rejected":
|
|
263
|
+
throw thenable.reason;
|
|
264
|
+
default:
|
|
265
|
+
switch ("string" === typeof thenable.status ? thenable.then(noop, noop) : (thenable.status = "pending", thenable.then(
|
|
266
|
+
function(fulfilledValue) {
|
|
267
|
+
"pending" === thenable.status && (thenable.status = "fulfilled", thenable.value = fulfilledValue);
|
|
268
|
+
},
|
|
269
|
+
function(error) {
|
|
270
|
+
"pending" === thenable.status && (thenable.status = "rejected", thenable.reason = error);
|
|
271
|
+
}
|
|
272
|
+
)), thenable.status) {
|
|
273
|
+
case "fulfilled":
|
|
274
|
+
return thenable.value;
|
|
275
|
+
case "rejected":
|
|
276
|
+
throw thenable.reason;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
throw thenable;
|
|
280
|
+
}
|
|
281
|
+
function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
|
|
282
|
+
var type = typeof children;
|
|
283
|
+
if ("undefined" === type || "boolean" === type) children = null;
|
|
284
|
+
var invokeCallback = false;
|
|
285
|
+
if (null === children) invokeCallback = true;
|
|
286
|
+
else
|
|
287
|
+
switch (type) {
|
|
288
|
+
case "bigint":
|
|
289
|
+
case "string":
|
|
290
|
+
case "number":
|
|
291
|
+
invokeCallback = true;
|
|
292
|
+
break;
|
|
293
|
+
case "object":
|
|
294
|
+
switch (children.$$typeof) {
|
|
295
|
+
case REACT_ELEMENT_TYPE:
|
|
296
|
+
case REACT_PORTAL_TYPE:
|
|
297
|
+
invokeCallback = true;
|
|
298
|
+
break;
|
|
299
|
+
case REACT_LAZY_TYPE:
|
|
300
|
+
return invokeCallback = children._init, mapIntoArray(
|
|
301
|
+
invokeCallback(children._payload),
|
|
302
|
+
array,
|
|
303
|
+
escapedPrefix,
|
|
304
|
+
nameSoFar,
|
|
305
|
+
callback
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
if (invokeCallback) {
|
|
310
|
+
invokeCallback = children;
|
|
311
|
+
callback = callback(invokeCallback);
|
|
312
|
+
var childKey = "" === nameSoFar ? "." + getElementKey(invokeCallback, 0) : nameSoFar;
|
|
313
|
+
isArrayImpl(callback) ? (escapedPrefix = "", null != childKey && (escapedPrefix = childKey.replace(userProvidedKeyEscapeRegex, "$&/") + "/"), mapIntoArray(callback, array, escapedPrefix, "", function(c) {
|
|
314
|
+
return c;
|
|
315
|
+
})) : null != callback && (isValidElement(callback) && (null != callback.key && (invokeCallback && invokeCallback.key === callback.key || checkKeyStringCoercion(callback.key)), escapedPrefix = cloneAndReplaceKey(
|
|
316
|
+
callback,
|
|
317
|
+
escapedPrefix + (null == callback.key || invokeCallback && invokeCallback.key === callback.key ? "" : ("" + callback.key).replace(
|
|
318
|
+
userProvidedKeyEscapeRegex,
|
|
319
|
+
"$&/"
|
|
320
|
+
) + "/") + childKey
|
|
321
|
+
), "" !== nameSoFar && null != invokeCallback && isValidElement(invokeCallback) && null == invokeCallback.key && invokeCallback._store && !invokeCallback._store.validated && (escapedPrefix._store.validated = 2), callback = escapedPrefix), array.push(callback));
|
|
322
|
+
return 1;
|
|
323
|
+
}
|
|
324
|
+
invokeCallback = 0;
|
|
325
|
+
childKey = "" === nameSoFar ? "." : nameSoFar + ":";
|
|
326
|
+
if (isArrayImpl(children))
|
|
327
|
+
for (var i = 0; i < children.length; i++)
|
|
328
|
+
nameSoFar = children[i], type = childKey + getElementKey(nameSoFar, i), invokeCallback += mapIntoArray(
|
|
329
|
+
nameSoFar,
|
|
330
|
+
array,
|
|
331
|
+
escapedPrefix,
|
|
332
|
+
type,
|
|
333
|
+
callback
|
|
334
|
+
);
|
|
335
|
+
else if (i = getIteratorFn(children), "function" === typeof i)
|
|
336
|
+
for (i === children.entries && (didWarnAboutMaps || console.warn(
|
|
337
|
+
"Using Maps as children is not supported. Use an array of keyed ReactElements instead."
|
|
338
|
+
), didWarnAboutMaps = true), children = i.call(children), i = 0; !(nameSoFar = children.next()).done; )
|
|
339
|
+
nameSoFar = nameSoFar.value, type = childKey + getElementKey(nameSoFar, i++), invokeCallback += mapIntoArray(
|
|
340
|
+
nameSoFar,
|
|
341
|
+
array,
|
|
342
|
+
escapedPrefix,
|
|
343
|
+
type,
|
|
344
|
+
callback
|
|
345
|
+
);
|
|
346
|
+
else if ("object" === type) {
|
|
347
|
+
if ("function" === typeof children.then)
|
|
348
|
+
return mapIntoArray(
|
|
349
|
+
resolveThenable(children),
|
|
350
|
+
array,
|
|
351
|
+
escapedPrefix,
|
|
352
|
+
nameSoFar,
|
|
353
|
+
callback
|
|
354
|
+
);
|
|
355
|
+
array = String(children);
|
|
356
|
+
throw Error(
|
|
357
|
+
"Objects are not valid as a React child (found: " + ("[object Object]" === array ? "object with keys {" + Object.keys(children).join(", ") + "}" : array) + "). If you meant to render a collection of children, use an array instead."
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
return invokeCallback;
|
|
361
|
+
}
|
|
362
|
+
function mapChildren(children, func, context) {
|
|
363
|
+
if (null == children) return children;
|
|
364
|
+
var result = [], count = 0;
|
|
365
|
+
mapIntoArray(children, result, "", "", function(child) {
|
|
366
|
+
return func.call(context, child, count++);
|
|
367
|
+
});
|
|
368
|
+
return result;
|
|
369
|
+
}
|
|
370
|
+
function lazyInitializer(payload) {
|
|
371
|
+
if (-1 === payload._status) {
|
|
372
|
+
var ioInfo = payload._ioInfo;
|
|
373
|
+
null != ioInfo && (ioInfo.start = ioInfo.end = performance.now());
|
|
374
|
+
ioInfo = payload._result;
|
|
375
|
+
var thenable = ioInfo();
|
|
376
|
+
thenable.then(
|
|
377
|
+
function(moduleObject) {
|
|
378
|
+
if (0 === payload._status || -1 === payload._status) {
|
|
379
|
+
payload._status = 1;
|
|
380
|
+
payload._result = moduleObject;
|
|
381
|
+
var _ioInfo = payload._ioInfo;
|
|
382
|
+
null != _ioInfo && (_ioInfo.end = performance.now());
|
|
383
|
+
void 0 === thenable.status && (thenable.status = "fulfilled", thenable.value = moduleObject);
|
|
384
|
+
}
|
|
385
|
+
},
|
|
386
|
+
function(error) {
|
|
387
|
+
if (0 === payload._status || -1 === payload._status) {
|
|
388
|
+
payload._status = 2;
|
|
389
|
+
payload._result = error;
|
|
390
|
+
var _ioInfo2 = payload._ioInfo;
|
|
391
|
+
null != _ioInfo2 && (_ioInfo2.end = performance.now());
|
|
392
|
+
void 0 === thenable.status && (thenable.status = "rejected", thenable.reason = error);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
);
|
|
396
|
+
ioInfo = payload._ioInfo;
|
|
397
|
+
if (null != ioInfo) {
|
|
398
|
+
ioInfo.value = thenable;
|
|
399
|
+
var displayName = thenable.displayName;
|
|
400
|
+
"string" === typeof displayName && (ioInfo.name = displayName);
|
|
401
|
+
}
|
|
402
|
+
-1 === payload._status && (payload._status = 0, payload._result = thenable);
|
|
403
|
+
}
|
|
404
|
+
if (1 === payload._status)
|
|
405
|
+
return ioInfo = payload._result, void 0 === ioInfo && console.error(
|
|
406
|
+
"lazy: Expected the result of a dynamic import() call. Instead received: %s\n\nYour code should look like: \n const MyComponent = lazy(() => import('./MyComponent'))\n\nDid you accidentally put curly braces around the import?",
|
|
407
|
+
ioInfo
|
|
408
|
+
), "default" in ioInfo || console.error(
|
|
409
|
+
"lazy: Expected the result of a dynamic import() call. Instead received: %s\n\nYour code should look like: \n const MyComponent = lazy(() => import('./MyComponent'))",
|
|
410
|
+
ioInfo
|
|
411
|
+
), ioInfo.default;
|
|
412
|
+
throw payload._result;
|
|
413
|
+
}
|
|
414
|
+
function resolveDispatcher() {
|
|
415
|
+
var dispatcher = ReactSharedInternals.H;
|
|
416
|
+
null === dispatcher && console.error(
|
|
417
|
+
"Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem."
|
|
418
|
+
);
|
|
419
|
+
return dispatcher;
|
|
420
|
+
}
|
|
421
|
+
function releaseAsyncTransition() {
|
|
422
|
+
ReactSharedInternals.asyncTransitions--;
|
|
423
|
+
}
|
|
424
|
+
function enqueueTask(task) {
|
|
425
|
+
if (null === enqueueTaskImpl)
|
|
426
|
+
try {
|
|
427
|
+
var requireString = ("require" + Math.random()).slice(0, 7);
|
|
428
|
+
enqueueTaskImpl = (module && module[requireString]).call(
|
|
429
|
+
module,
|
|
430
|
+
"timers"
|
|
431
|
+
).setImmediate;
|
|
432
|
+
} catch (_err) {
|
|
433
|
+
enqueueTaskImpl = function(callback) {
|
|
434
|
+
false === didWarnAboutMessageChannel && (didWarnAboutMessageChannel = true, "undefined" === typeof MessageChannel && console.error(
|
|
435
|
+
"This browser does not have a MessageChannel implementation, so enqueuing tasks via await act(async () => ...) will fail. Please file an issue at https://github.com/facebook/react/issues if you encounter this warning."
|
|
436
|
+
));
|
|
437
|
+
var channel = new MessageChannel();
|
|
438
|
+
channel.port1.onmessage = callback;
|
|
439
|
+
channel.port2.postMessage(void 0);
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
return enqueueTaskImpl(task);
|
|
443
|
+
}
|
|
444
|
+
function aggregateErrors(errors2) {
|
|
445
|
+
return 1 < errors2.length && "function" === typeof AggregateError ? new AggregateError(errors2) : errors2[0];
|
|
446
|
+
}
|
|
447
|
+
function popActScope(prevActQueue, prevActScopeDepth) {
|
|
448
|
+
prevActScopeDepth !== actScopeDepth - 1 && console.error(
|
|
449
|
+
"You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one. "
|
|
450
|
+
);
|
|
451
|
+
actScopeDepth = prevActScopeDepth;
|
|
452
|
+
}
|
|
453
|
+
function recursivelyFlushAsyncActWork(returnValue, resolve, reject) {
|
|
454
|
+
var queue = ReactSharedInternals.actQueue;
|
|
455
|
+
if (null !== queue)
|
|
456
|
+
if (0 !== queue.length)
|
|
457
|
+
try {
|
|
458
|
+
flushActQueue(queue);
|
|
459
|
+
enqueueTask(function() {
|
|
460
|
+
return recursivelyFlushAsyncActWork(returnValue, resolve, reject);
|
|
461
|
+
});
|
|
462
|
+
return;
|
|
463
|
+
} catch (error) {
|
|
464
|
+
ReactSharedInternals.thrownErrors.push(error);
|
|
465
|
+
}
|
|
466
|
+
else ReactSharedInternals.actQueue = null;
|
|
467
|
+
0 < ReactSharedInternals.thrownErrors.length ? (queue = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, reject(queue)) : resolve(returnValue);
|
|
468
|
+
}
|
|
469
|
+
function flushActQueue(queue) {
|
|
470
|
+
if (!isFlushing) {
|
|
471
|
+
isFlushing = true;
|
|
472
|
+
var i = 0;
|
|
473
|
+
try {
|
|
474
|
+
for (; i < queue.length; i++) {
|
|
475
|
+
var callback = queue[i];
|
|
476
|
+
do {
|
|
477
|
+
ReactSharedInternals.didUsePromise = false;
|
|
478
|
+
var continuation = callback(false);
|
|
479
|
+
if (null !== continuation) {
|
|
480
|
+
if (ReactSharedInternals.didUsePromise) {
|
|
481
|
+
queue[i] = callback;
|
|
482
|
+
queue.splice(0, i);
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
callback = continuation;
|
|
486
|
+
} else break;
|
|
487
|
+
} while (1);
|
|
488
|
+
}
|
|
489
|
+
queue.length = 0;
|
|
490
|
+
} catch (error) {
|
|
491
|
+
queue.splice(0, i + 1), ReactSharedInternals.thrownErrors.push(error);
|
|
492
|
+
} finally {
|
|
493
|
+
isFlushing = false;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
498
|
+
var REACT_ELEMENT_TYPE = /* @__PURE__ */ Symbol.for("react.transitional.element"), REACT_PORTAL_TYPE = /* @__PURE__ */ Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = /* @__PURE__ */ Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = /* @__PURE__ */ Symbol.for("react.strict_mode"), REACT_PROFILER_TYPE = /* @__PURE__ */ Symbol.for("react.profiler"), REACT_CONSUMER_TYPE = /* @__PURE__ */ Symbol.for("react.consumer"), REACT_CONTEXT_TYPE = /* @__PURE__ */ Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = /* @__PURE__ */ Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = /* @__PURE__ */ Symbol.for("react.suspense"), REACT_SUSPENSE_LIST_TYPE = /* @__PURE__ */ Symbol.for("react.suspense_list"), REACT_MEMO_TYPE = /* @__PURE__ */ Symbol.for("react.memo"), REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy"), REACT_ACTIVITY_TYPE = /* @__PURE__ */ Symbol.for("react.activity"), MAYBE_ITERATOR_SYMBOL = Symbol.iterator, didWarnStateUpdateForUnmountedComponent = {}, ReactNoopUpdateQueue = {
|
|
499
|
+
isMounted: function() {
|
|
500
|
+
return false;
|
|
501
|
+
},
|
|
502
|
+
enqueueForceUpdate: function(publicInstance) {
|
|
503
|
+
warnNoop(publicInstance, "forceUpdate");
|
|
504
|
+
},
|
|
505
|
+
enqueueReplaceState: function(publicInstance) {
|
|
506
|
+
warnNoop(publicInstance, "replaceState");
|
|
507
|
+
},
|
|
508
|
+
enqueueSetState: function(publicInstance) {
|
|
509
|
+
warnNoop(publicInstance, "setState");
|
|
510
|
+
}
|
|
511
|
+
}, assign = Object.assign, emptyObject = {};
|
|
512
|
+
Object.freeze(emptyObject);
|
|
513
|
+
Component.prototype.isReactComponent = {};
|
|
514
|
+
Component.prototype.setState = function(partialState, callback) {
|
|
515
|
+
if ("object" !== typeof partialState && "function" !== typeof partialState && null != partialState)
|
|
516
|
+
throw Error(
|
|
517
|
+
"takes an object of state variables to update or a function which returns an object of state variables."
|
|
518
|
+
);
|
|
519
|
+
this.updater.enqueueSetState(this, partialState, callback, "setState");
|
|
520
|
+
};
|
|
521
|
+
Component.prototype.forceUpdate = function(callback) {
|
|
522
|
+
this.updater.enqueueForceUpdate(this, callback, "forceUpdate");
|
|
523
|
+
};
|
|
524
|
+
var deprecatedAPIs = {
|
|
525
|
+
isMounted: [
|
|
526
|
+
"isMounted",
|
|
527
|
+
"Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks."
|
|
528
|
+
],
|
|
529
|
+
replaceState: [
|
|
530
|
+
"replaceState",
|
|
531
|
+
"Refactor your code to use setState instead (see https://github.com/facebook/react/issues/3236)."
|
|
532
|
+
]
|
|
533
|
+
};
|
|
534
|
+
for (fnName in deprecatedAPIs)
|
|
535
|
+
deprecatedAPIs.hasOwnProperty(fnName) && defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
|
|
536
|
+
ComponentDummy.prototype = Component.prototype;
|
|
537
|
+
deprecatedAPIs = PureComponent.prototype = new ComponentDummy();
|
|
538
|
+
deprecatedAPIs.constructor = PureComponent;
|
|
539
|
+
assign(deprecatedAPIs, Component.prototype);
|
|
540
|
+
deprecatedAPIs.isPureReactComponent = true;
|
|
541
|
+
var isArrayImpl = Array.isArray, REACT_CLIENT_REFERENCE = /* @__PURE__ */ Symbol.for("react.client.reference"), ReactSharedInternals = {
|
|
542
|
+
H: null,
|
|
543
|
+
A: null,
|
|
544
|
+
T: null,
|
|
545
|
+
S: null,
|
|
546
|
+
actQueue: null,
|
|
547
|
+
asyncTransitions: 0,
|
|
548
|
+
isBatchingLegacy: false,
|
|
549
|
+
didScheduleLegacyUpdate: false,
|
|
550
|
+
didUsePromise: false,
|
|
551
|
+
thrownErrors: [],
|
|
552
|
+
getCurrentStack: null,
|
|
553
|
+
recentlyCreatedOwnerStacks: 0
|
|
554
|
+
}, hasOwnProperty = Object.prototype.hasOwnProperty, createTask = console.createTask ? console.createTask : function() {
|
|
555
|
+
return null;
|
|
556
|
+
};
|
|
557
|
+
deprecatedAPIs = {
|
|
558
|
+
react_stack_bottom_frame: function(callStackForError) {
|
|
559
|
+
return callStackForError();
|
|
560
|
+
}
|
|
561
|
+
};
|
|
562
|
+
var specialPropKeyWarningShown, didWarnAboutOldJSXRuntime;
|
|
563
|
+
var didWarnAboutElementRef = {};
|
|
564
|
+
var unknownOwnerDebugStack = deprecatedAPIs.react_stack_bottom_frame.bind(
|
|
565
|
+
deprecatedAPIs,
|
|
566
|
+
UnknownOwner
|
|
567
|
+
)();
|
|
568
|
+
var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
|
|
569
|
+
var didWarnAboutMaps = false, userProvidedKeyEscapeRegex = /\/+/g, reportGlobalError = "function" === typeof reportError ? reportError : function(error) {
|
|
570
|
+
if ("object" === typeof window && "function" === typeof window.ErrorEvent) {
|
|
571
|
+
var event = new window.ErrorEvent("error", {
|
|
572
|
+
bubbles: true,
|
|
573
|
+
cancelable: true,
|
|
574
|
+
message: "object" === typeof error && null !== error && "string" === typeof error.message ? String(error.message) : String(error),
|
|
575
|
+
error
|
|
576
|
+
});
|
|
577
|
+
if (!window.dispatchEvent(event)) return;
|
|
578
|
+
} else if ("object" === typeof process && "function" === typeof process.emit) {
|
|
579
|
+
process.emit("uncaughtException", error);
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
console.error(error);
|
|
583
|
+
}, didWarnAboutMessageChannel = false, enqueueTaskImpl = null, actScopeDepth = 0, didWarnNoAwaitAct = false, isFlushing = false, queueSeveralMicrotasks = "function" === typeof queueMicrotask ? function(callback) {
|
|
584
|
+
queueMicrotask(function() {
|
|
585
|
+
return queueMicrotask(callback);
|
|
586
|
+
});
|
|
587
|
+
} : enqueueTask;
|
|
588
|
+
deprecatedAPIs = Object.freeze({
|
|
589
|
+
__proto__: null,
|
|
590
|
+
c: function(size) {
|
|
591
|
+
return resolveDispatcher().useMemoCache(size);
|
|
592
|
+
}
|
|
593
|
+
});
|
|
594
|
+
var fnName = {
|
|
595
|
+
map: mapChildren,
|
|
596
|
+
forEach: function(children, forEachFunc, forEachContext) {
|
|
597
|
+
mapChildren(
|
|
598
|
+
children,
|
|
599
|
+
function() {
|
|
600
|
+
forEachFunc.apply(this, arguments);
|
|
601
|
+
},
|
|
602
|
+
forEachContext
|
|
603
|
+
);
|
|
604
|
+
},
|
|
605
|
+
count: function(children) {
|
|
606
|
+
var n = 0;
|
|
607
|
+
mapChildren(children, function() {
|
|
608
|
+
n++;
|
|
609
|
+
});
|
|
610
|
+
return n;
|
|
611
|
+
},
|
|
612
|
+
toArray: function(children) {
|
|
613
|
+
return mapChildren(children, function(child) {
|
|
614
|
+
return child;
|
|
615
|
+
}) || [];
|
|
616
|
+
},
|
|
617
|
+
only: function(children) {
|
|
618
|
+
if (!isValidElement(children))
|
|
619
|
+
throw Error(
|
|
620
|
+
"React.Children.only expected to receive a single React element child."
|
|
621
|
+
);
|
|
622
|
+
return children;
|
|
623
|
+
}
|
|
624
|
+
};
|
|
625
|
+
exports.Activity = REACT_ACTIVITY_TYPE;
|
|
626
|
+
exports.Children = fnName;
|
|
627
|
+
exports.Component = Component;
|
|
628
|
+
exports.Fragment = REACT_FRAGMENT_TYPE;
|
|
629
|
+
exports.Profiler = REACT_PROFILER_TYPE;
|
|
630
|
+
exports.PureComponent = PureComponent;
|
|
631
|
+
exports.StrictMode = REACT_STRICT_MODE_TYPE;
|
|
632
|
+
exports.Suspense = REACT_SUSPENSE_TYPE;
|
|
633
|
+
exports.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = ReactSharedInternals;
|
|
634
|
+
exports.__COMPILER_RUNTIME = deprecatedAPIs;
|
|
635
|
+
exports.act = function(callback) {
|
|
636
|
+
var prevActQueue = ReactSharedInternals.actQueue, prevActScopeDepth = actScopeDepth;
|
|
637
|
+
actScopeDepth++;
|
|
638
|
+
var queue = ReactSharedInternals.actQueue = null !== prevActQueue ? prevActQueue : [], didAwaitActCall = false;
|
|
639
|
+
try {
|
|
640
|
+
var result = callback();
|
|
641
|
+
} catch (error) {
|
|
642
|
+
ReactSharedInternals.thrownErrors.push(error);
|
|
643
|
+
}
|
|
644
|
+
if (0 < ReactSharedInternals.thrownErrors.length)
|
|
645
|
+
throw popActScope(prevActQueue, prevActScopeDepth), callback = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, callback;
|
|
646
|
+
if (null !== result && "object" === typeof result && "function" === typeof result.then) {
|
|
647
|
+
var thenable = result;
|
|
648
|
+
queueSeveralMicrotasks(function() {
|
|
649
|
+
didAwaitActCall || didWarnNoAwaitAct || (didWarnNoAwaitAct = true, console.error(
|
|
650
|
+
"You called act(async () => ...) without await. This could lead to unexpected testing behaviour, interleaving multiple act calls and mixing their scopes. You should - await act(async () => ...);"
|
|
651
|
+
));
|
|
652
|
+
});
|
|
653
|
+
return {
|
|
654
|
+
then: function(resolve, reject) {
|
|
655
|
+
didAwaitActCall = true;
|
|
656
|
+
thenable.then(
|
|
657
|
+
function(returnValue) {
|
|
658
|
+
popActScope(prevActQueue, prevActScopeDepth);
|
|
659
|
+
if (0 === prevActScopeDepth) {
|
|
660
|
+
try {
|
|
661
|
+
flushActQueue(queue), enqueueTask(function() {
|
|
662
|
+
return recursivelyFlushAsyncActWork(
|
|
663
|
+
returnValue,
|
|
664
|
+
resolve,
|
|
665
|
+
reject
|
|
666
|
+
);
|
|
667
|
+
});
|
|
668
|
+
} catch (error$0) {
|
|
669
|
+
ReactSharedInternals.thrownErrors.push(error$0);
|
|
670
|
+
}
|
|
671
|
+
if (0 < ReactSharedInternals.thrownErrors.length) {
|
|
672
|
+
var _thrownError = aggregateErrors(
|
|
673
|
+
ReactSharedInternals.thrownErrors
|
|
674
|
+
);
|
|
675
|
+
ReactSharedInternals.thrownErrors.length = 0;
|
|
676
|
+
reject(_thrownError);
|
|
677
|
+
}
|
|
678
|
+
} else resolve(returnValue);
|
|
679
|
+
},
|
|
680
|
+
function(error) {
|
|
681
|
+
popActScope(prevActQueue, prevActScopeDepth);
|
|
682
|
+
0 < ReactSharedInternals.thrownErrors.length ? (error = aggregateErrors(
|
|
683
|
+
ReactSharedInternals.thrownErrors
|
|
684
|
+
), ReactSharedInternals.thrownErrors.length = 0, reject(error)) : reject(error);
|
|
685
|
+
}
|
|
686
|
+
);
|
|
687
|
+
}
|
|
688
|
+
};
|
|
689
|
+
}
|
|
690
|
+
var returnValue$jscomp$0 = result;
|
|
691
|
+
popActScope(prevActQueue, prevActScopeDepth);
|
|
692
|
+
0 === prevActScopeDepth && (flushActQueue(queue), 0 !== queue.length && queueSeveralMicrotasks(function() {
|
|
693
|
+
didAwaitActCall || didWarnNoAwaitAct || (didWarnNoAwaitAct = true, console.error(
|
|
694
|
+
"A component suspended inside an `act` scope, but the `act` call was not awaited. When testing React components that depend on asynchronous data, you must await the result:\n\nawait act(() => ...)"
|
|
695
|
+
));
|
|
696
|
+
}), ReactSharedInternals.actQueue = null);
|
|
697
|
+
if (0 < ReactSharedInternals.thrownErrors.length)
|
|
698
|
+
throw callback = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, callback;
|
|
699
|
+
return {
|
|
700
|
+
then: function(resolve, reject) {
|
|
701
|
+
didAwaitActCall = true;
|
|
702
|
+
0 === prevActScopeDepth ? (ReactSharedInternals.actQueue = queue, enqueueTask(function() {
|
|
703
|
+
return recursivelyFlushAsyncActWork(
|
|
704
|
+
returnValue$jscomp$0,
|
|
705
|
+
resolve,
|
|
706
|
+
reject
|
|
707
|
+
);
|
|
708
|
+
})) : resolve(returnValue$jscomp$0);
|
|
709
|
+
}
|
|
710
|
+
};
|
|
711
|
+
};
|
|
712
|
+
exports.cache = function(fn) {
|
|
713
|
+
return function() {
|
|
714
|
+
return fn.apply(null, arguments);
|
|
715
|
+
};
|
|
716
|
+
};
|
|
717
|
+
exports.cacheSignal = function() {
|
|
718
|
+
return null;
|
|
719
|
+
};
|
|
720
|
+
exports.captureOwnerStack = function() {
|
|
721
|
+
var getCurrentStack = ReactSharedInternals.getCurrentStack;
|
|
722
|
+
return null === getCurrentStack ? null : getCurrentStack();
|
|
723
|
+
};
|
|
724
|
+
exports.cloneElement = function(element, config, children) {
|
|
725
|
+
if (null === element || void 0 === element)
|
|
726
|
+
throw Error(
|
|
727
|
+
"The argument must be a React element, but you passed " + element + "."
|
|
728
|
+
);
|
|
729
|
+
var props = assign({}, element.props), key = element.key, owner = element._owner;
|
|
730
|
+
if (null != config) {
|
|
731
|
+
var JSCompiler_inline_result;
|
|
732
|
+
a: {
|
|
733
|
+
if (hasOwnProperty.call(config, "ref") && (JSCompiler_inline_result = Object.getOwnPropertyDescriptor(
|
|
734
|
+
config,
|
|
735
|
+
"ref"
|
|
736
|
+
).get) && JSCompiler_inline_result.isReactWarning) {
|
|
737
|
+
JSCompiler_inline_result = false;
|
|
738
|
+
break a;
|
|
739
|
+
}
|
|
740
|
+
JSCompiler_inline_result = void 0 !== config.ref;
|
|
741
|
+
}
|
|
742
|
+
JSCompiler_inline_result && (owner = getOwner());
|
|
743
|
+
hasValidKey(config) && (checkKeyStringCoercion(config.key), key = "" + config.key);
|
|
744
|
+
for (propName in config)
|
|
745
|
+
!hasOwnProperty.call(config, propName) || "key" === propName || "__self" === propName || "__source" === propName || "ref" === propName && void 0 === config.ref || (props[propName] = config[propName]);
|
|
746
|
+
}
|
|
747
|
+
var propName = arguments.length - 2;
|
|
748
|
+
if (1 === propName) props.children = children;
|
|
749
|
+
else if (1 < propName) {
|
|
750
|
+
JSCompiler_inline_result = Array(propName);
|
|
751
|
+
for (var i = 0; i < propName; i++)
|
|
752
|
+
JSCompiler_inline_result[i] = arguments[i + 2];
|
|
753
|
+
props.children = JSCompiler_inline_result;
|
|
754
|
+
}
|
|
755
|
+
props = ReactElement(
|
|
756
|
+
element.type,
|
|
757
|
+
key,
|
|
758
|
+
props,
|
|
759
|
+
owner,
|
|
760
|
+
element._debugStack,
|
|
761
|
+
element._debugTask
|
|
762
|
+
);
|
|
763
|
+
for (key = 2; key < arguments.length; key++)
|
|
764
|
+
validateChildKeys(arguments[key]);
|
|
765
|
+
return props;
|
|
766
|
+
};
|
|
767
|
+
exports.createContext = function(defaultValue) {
|
|
768
|
+
defaultValue = {
|
|
769
|
+
$$typeof: REACT_CONTEXT_TYPE,
|
|
770
|
+
_currentValue: defaultValue,
|
|
771
|
+
_currentValue2: defaultValue,
|
|
772
|
+
_threadCount: 0,
|
|
773
|
+
Provider: null,
|
|
774
|
+
Consumer: null
|
|
775
|
+
};
|
|
776
|
+
defaultValue.Provider = defaultValue;
|
|
777
|
+
defaultValue.Consumer = {
|
|
778
|
+
$$typeof: REACT_CONSUMER_TYPE,
|
|
779
|
+
_context: defaultValue
|
|
780
|
+
};
|
|
781
|
+
defaultValue._currentRenderer = null;
|
|
782
|
+
defaultValue._currentRenderer2 = null;
|
|
783
|
+
return defaultValue;
|
|
784
|
+
};
|
|
785
|
+
exports.createElement = function(type, config, children) {
|
|
786
|
+
for (var i = 2; i < arguments.length; i++)
|
|
787
|
+
validateChildKeys(arguments[i]);
|
|
788
|
+
i = {};
|
|
789
|
+
var key = null;
|
|
790
|
+
if (null != config)
|
|
791
|
+
for (propName in didWarnAboutOldJSXRuntime || !("__self" in config) || "key" in config || (didWarnAboutOldJSXRuntime = true, console.warn(
|
|
792
|
+
"Your app (or one of its dependencies) is using an outdated JSX transform. Update to the modern JSX transform for faster performance: https://react.dev/link/new-jsx-transform"
|
|
793
|
+
)), hasValidKey(config) && (checkKeyStringCoercion(config.key), key = "" + config.key), config)
|
|
794
|
+
hasOwnProperty.call(config, propName) && "key" !== propName && "__self" !== propName && "__source" !== propName && (i[propName] = config[propName]);
|
|
795
|
+
var childrenLength = arguments.length - 2;
|
|
796
|
+
if (1 === childrenLength) i.children = children;
|
|
797
|
+
else if (1 < childrenLength) {
|
|
798
|
+
for (var childArray = Array(childrenLength), _i = 0; _i < childrenLength; _i++)
|
|
799
|
+
childArray[_i] = arguments[_i + 2];
|
|
800
|
+
Object.freeze && Object.freeze(childArray);
|
|
801
|
+
i.children = childArray;
|
|
802
|
+
}
|
|
803
|
+
if (type && type.defaultProps)
|
|
804
|
+
for (propName in childrenLength = type.defaultProps, childrenLength)
|
|
805
|
+
void 0 === i[propName] && (i[propName] = childrenLength[propName]);
|
|
806
|
+
key && defineKeyPropWarningGetter(
|
|
807
|
+
i,
|
|
808
|
+
"function" === typeof type ? type.displayName || type.name || "Unknown" : type
|
|
809
|
+
);
|
|
810
|
+
var propName = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
|
|
811
|
+
return ReactElement(
|
|
812
|
+
type,
|
|
813
|
+
key,
|
|
814
|
+
i,
|
|
815
|
+
getOwner(),
|
|
816
|
+
propName ? Error("react-stack-top-frame") : unknownOwnerDebugStack,
|
|
817
|
+
propName ? createTask(getTaskName(type)) : unknownOwnerDebugTask
|
|
818
|
+
);
|
|
819
|
+
};
|
|
820
|
+
exports.createRef = function() {
|
|
821
|
+
var refObject = { current: null };
|
|
822
|
+
Object.seal(refObject);
|
|
823
|
+
return refObject;
|
|
824
|
+
};
|
|
825
|
+
exports.forwardRef = function(render) {
|
|
826
|
+
null != render && render.$$typeof === REACT_MEMO_TYPE ? console.error(
|
|
827
|
+
"forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...))."
|
|
828
|
+
) : "function" !== typeof render ? console.error(
|
|
829
|
+
"forwardRef requires a render function but was given %s.",
|
|
830
|
+
null === render ? "null" : typeof render
|
|
831
|
+
) : 0 !== render.length && 2 !== render.length && console.error(
|
|
832
|
+
"forwardRef render functions accept exactly two parameters: props and ref. %s",
|
|
833
|
+
1 === render.length ? "Did you forget to use the ref parameter?" : "Any additional parameter will be undefined."
|
|
834
|
+
);
|
|
835
|
+
null != render && null != render.defaultProps && console.error(
|
|
836
|
+
"forwardRef render functions do not support defaultProps. Did you accidentally pass a React component?"
|
|
837
|
+
);
|
|
838
|
+
var elementType = { $$typeof: REACT_FORWARD_REF_TYPE, render }, ownName;
|
|
839
|
+
Object.defineProperty(elementType, "displayName", {
|
|
840
|
+
enumerable: false,
|
|
841
|
+
configurable: true,
|
|
842
|
+
get: function() {
|
|
843
|
+
return ownName;
|
|
844
|
+
},
|
|
845
|
+
set: function(name) {
|
|
846
|
+
ownName = name;
|
|
847
|
+
render.name || render.displayName || (Object.defineProperty(render, "name", { value: name }), render.displayName = name);
|
|
848
|
+
}
|
|
849
|
+
});
|
|
850
|
+
return elementType;
|
|
851
|
+
};
|
|
852
|
+
exports.isValidElement = isValidElement;
|
|
853
|
+
exports.lazy = function(ctor) {
|
|
854
|
+
ctor = { _status: -1, _result: ctor };
|
|
855
|
+
var lazyType = {
|
|
856
|
+
$$typeof: REACT_LAZY_TYPE,
|
|
857
|
+
_payload: ctor,
|
|
858
|
+
_init: lazyInitializer
|
|
859
|
+
}, ioInfo = {
|
|
860
|
+
name: "lazy",
|
|
861
|
+
start: -1,
|
|
862
|
+
end: -1,
|
|
863
|
+
value: null,
|
|
864
|
+
owner: null,
|
|
865
|
+
debugStack: Error("react-stack-top-frame"),
|
|
866
|
+
debugTask: console.createTask ? console.createTask("lazy()") : null
|
|
867
|
+
};
|
|
868
|
+
ctor._ioInfo = ioInfo;
|
|
869
|
+
lazyType._debugInfo = [{ awaited: ioInfo }];
|
|
870
|
+
return lazyType;
|
|
871
|
+
};
|
|
872
|
+
exports.memo = function(type, compare) {
|
|
873
|
+
null == type && console.error(
|
|
874
|
+
"memo: The first argument must be a component. Instead received: %s",
|
|
875
|
+
null === type ? "null" : typeof type
|
|
876
|
+
);
|
|
877
|
+
compare = {
|
|
878
|
+
$$typeof: REACT_MEMO_TYPE,
|
|
879
|
+
type,
|
|
880
|
+
compare: void 0 === compare ? null : compare
|
|
881
|
+
};
|
|
882
|
+
var ownName;
|
|
883
|
+
Object.defineProperty(compare, "displayName", {
|
|
884
|
+
enumerable: false,
|
|
885
|
+
configurable: true,
|
|
886
|
+
get: function() {
|
|
887
|
+
return ownName;
|
|
888
|
+
},
|
|
889
|
+
set: function(name) {
|
|
890
|
+
ownName = name;
|
|
891
|
+
type.name || type.displayName || (Object.defineProperty(type, "name", { value: name }), type.displayName = name);
|
|
892
|
+
}
|
|
893
|
+
});
|
|
894
|
+
return compare;
|
|
895
|
+
};
|
|
896
|
+
exports.startTransition = function(scope) {
|
|
897
|
+
var prevTransition = ReactSharedInternals.T, currentTransition = {};
|
|
898
|
+
currentTransition._updatedFibers = /* @__PURE__ */ new Set();
|
|
899
|
+
ReactSharedInternals.T = currentTransition;
|
|
900
|
+
try {
|
|
901
|
+
var returnValue = scope(), onStartTransitionFinish = ReactSharedInternals.S;
|
|
902
|
+
null !== onStartTransitionFinish && onStartTransitionFinish(currentTransition, returnValue);
|
|
903
|
+
"object" === typeof returnValue && null !== returnValue && "function" === typeof returnValue.then && (ReactSharedInternals.asyncTransitions++, returnValue.then(releaseAsyncTransition, releaseAsyncTransition), returnValue.then(noop, reportGlobalError));
|
|
904
|
+
} catch (error) {
|
|
905
|
+
reportGlobalError(error);
|
|
906
|
+
} finally {
|
|
907
|
+
null === prevTransition && currentTransition._updatedFibers && (scope = currentTransition._updatedFibers.size, currentTransition._updatedFibers.clear(), 10 < scope && console.warn(
|
|
908
|
+
"Detected a large number of updates inside startTransition. If this is due to a subscription please re-write it to use React provided hooks. Otherwise concurrent mode guarantees are off the table."
|
|
909
|
+
)), null !== prevTransition && null !== currentTransition.types && (null !== prevTransition.types && prevTransition.types !== currentTransition.types && console.error(
|
|
910
|
+
"We expected inner Transitions to have transferred the outer types set and that you cannot add to the outer Transition while inside the inner.This is a bug in React."
|
|
911
|
+
), prevTransition.types = currentTransition.types), ReactSharedInternals.T = prevTransition;
|
|
912
|
+
}
|
|
913
|
+
};
|
|
914
|
+
exports.unstable_useCacheRefresh = function() {
|
|
915
|
+
return resolveDispatcher().useCacheRefresh();
|
|
916
|
+
};
|
|
917
|
+
exports.use = function(usable) {
|
|
918
|
+
return resolveDispatcher().use(usable);
|
|
919
|
+
};
|
|
920
|
+
exports.useActionState = function(action, initialState, permalink) {
|
|
921
|
+
return resolveDispatcher().useActionState(
|
|
922
|
+
action,
|
|
923
|
+
initialState,
|
|
924
|
+
permalink
|
|
925
|
+
);
|
|
926
|
+
};
|
|
927
|
+
exports.useCallback = function(callback, deps) {
|
|
928
|
+
return resolveDispatcher().useCallback(callback, deps);
|
|
929
|
+
};
|
|
930
|
+
exports.useContext = function(Context) {
|
|
931
|
+
var dispatcher = resolveDispatcher();
|
|
932
|
+
Context.$$typeof === REACT_CONSUMER_TYPE && console.error(
|
|
933
|
+
"Calling useContext(Context.Consumer) is not supported and will cause bugs. Did you mean to call useContext(Context) instead?"
|
|
934
|
+
);
|
|
935
|
+
return dispatcher.useContext(Context);
|
|
936
|
+
};
|
|
937
|
+
exports.useDebugValue = function(value, formatterFn) {
|
|
938
|
+
return resolveDispatcher().useDebugValue(value, formatterFn);
|
|
939
|
+
};
|
|
940
|
+
exports.useDeferredValue = function(value, initialValue) {
|
|
941
|
+
return resolveDispatcher().useDeferredValue(value, initialValue);
|
|
942
|
+
};
|
|
943
|
+
exports.useEffect = function(create, deps) {
|
|
944
|
+
null == create && console.warn(
|
|
945
|
+
"React Hook useEffect requires an effect callback. Did you forget to pass a callback to the hook?"
|
|
946
|
+
);
|
|
947
|
+
return resolveDispatcher().useEffect(create, deps);
|
|
948
|
+
};
|
|
949
|
+
exports.useEffectEvent = function(callback) {
|
|
950
|
+
return resolveDispatcher().useEffectEvent(callback);
|
|
951
|
+
};
|
|
952
|
+
exports.useId = function() {
|
|
953
|
+
return resolveDispatcher().useId();
|
|
954
|
+
};
|
|
955
|
+
exports.useImperativeHandle = function(ref, create, deps) {
|
|
956
|
+
return resolveDispatcher().useImperativeHandle(ref, create, deps);
|
|
957
|
+
};
|
|
958
|
+
exports.useInsertionEffect = function(create, deps) {
|
|
959
|
+
null == create && console.warn(
|
|
960
|
+
"React Hook useInsertionEffect requires an effect callback. Did you forget to pass a callback to the hook?"
|
|
961
|
+
);
|
|
962
|
+
return resolveDispatcher().useInsertionEffect(create, deps);
|
|
963
|
+
};
|
|
964
|
+
exports.useLayoutEffect = function(create, deps) {
|
|
965
|
+
null == create && console.warn(
|
|
966
|
+
"React Hook useLayoutEffect requires an effect callback. Did you forget to pass a callback to the hook?"
|
|
967
|
+
);
|
|
968
|
+
return resolveDispatcher().useLayoutEffect(create, deps);
|
|
969
|
+
};
|
|
970
|
+
exports.useMemo = function(create, deps) {
|
|
971
|
+
return resolveDispatcher().useMemo(create, deps);
|
|
972
|
+
};
|
|
973
|
+
exports.useOptimistic = function(passthrough, reducer) {
|
|
974
|
+
return resolveDispatcher().useOptimistic(passthrough, reducer);
|
|
975
|
+
};
|
|
976
|
+
exports.useReducer = function(reducer, initialArg, init) {
|
|
977
|
+
return resolveDispatcher().useReducer(reducer, initialArg, init);
|
|
978
|
+
};
|
|
979
|
+
exports.useRef = function(initialValue) {
|
|
980
|
+
return resolveDispatcher().useRef(initialValue);
|
|
981
|
+
};
|
|
982
|
+
exports.useState = function(initialState) {
|
|
983
|
+
return resolveDispatcher().useState(initialState);
|
|
984
|
+
};
|
|
985
|
+
exports.useSyncExternalStore = function(subscribe, getSnapshot, getServerSnapshot) {
|
|
986
|
+
return resolveDispatcher().useSyncExternalStore(
|
|
987
|
+
subscribe,
|
|
988
|
+
getSnapshot,
|
|
989
|
+
getServerSnapshot
|
|
990
|
+
);
|
|
991
|
+
};
|
|
992
|
+
exports.useTransition = function() {
|
|
993
|
+
return resolveDispatcher().useTransition();
|
|
994
|
+
};
|
|
995
|
+
exports.version = "19.2.4";
|
|
996
|
+
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
997
|
+
})();
|
|
998
|
+
}
|
|
999
|
+
});
|
|
1000
|
+
|
|
1001
|
+
// node_modules/react/index.js
|
|
1002
|
+
var require_react = __commonJS({
|
|
1003
|
+
"node_modules/react/index.js"(exports, module) {
|
|
1004
|
+
"use strict";
|
|
1005
|
+
if (false) {
|
|
1006
|
+
module.exports = null;
|
|
1007
|
+
} else {
|
|
1008
|
+
module.exports = require_react_development();
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
});
|
|
1012
|
+
|
|
1013
|
+
// node_modules/immer/dist/immer.mjs
|
|
1014
|
+
var NOTHING = /* @__PURE__ */ Symbol.for("immer-nothing");
|
|
1015
|
+
var DRAFTABLE = /* @__PURE__ */ Symbol.for("immer-draftable");
|
|
1016
|
+
var DRAFT_STATE = /* @__PURE__ */ Symbol.for("immer-state");
|
|
1017
|
+
var errors = true ? [
|
|
1018
|
+
// All error codes, starting by 0:
|
|
1019
|
+
function(plugin) {
|
|
1020
|
+
return `The plugin for '${plugin}' has not been loaded into Immer. To enable the plugin, import and call \`enable${plugin}()\` when initializing your application.`;
|
|
1021
|
+
},
|
|
1022
|
+
function(thing) {
|
|
1023
|
+
return `produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${thing}'`;
|
|
1024
|
+
},
|
|
1025
|
+
"This object has been frozen and should not be mutated",
|
|
1026
|
+
function(data) {
|
|
1027
|
+
return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? " + data;
|
|
1028
|
+
},
|
|
1029
|
+
"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",
|
|
1030
|
+
"Immer forbids circular references",
|
|
1031
|
+
"The first or second argument to `produce` must be a function",
|
|
1032
|
+
"The third argument to `produce` must be a function or undefined",
|
|
1033
|
+
"First argument to `createDraft` must be a plain object, an array, or an immerable object",
|
|
1034
|
+
"First argument to `finishDraft` must be a draft returned by `createDraft`",
|
|
1035
|
+
function(thing) {
|
|
1036
|
+
return `'current' expects a draft, got: ${thing}`;
|
|
1037
|
+
},
|
|
1038
|
+
"Object.defineProperty() cannot be used on an Immer draft",
|
|
1039
|
+
"Object.setPrototypeOf() cannot be used on an Immer draft",
|
|
1040
|
+
"Immer only supports deleting array indices",
|
|
1041
|
+
"Immer only supports setting array indices and the 'length' property",
|
|
1042
|
+
function(thing) {
|
|
1043
|
+
return `'original' expects a draft, got: ${thing}`;
|
|
1044
|
+
}
|
|
1045
|
+
// Note: if more errors are added, the errorOffset in Patches.ts should be increased
|
|
1046
|
+
// See Patches.ts for additional errors
|
|
1047
|
+
] : [];
|
|
1048
|
+
function die(error, ...args) {
|
|
1049
|
+
if (true) {
|
|
1050
|
+
const e = errors[error];
|
|
1051
|
+
const msg = isFunction(e) ? e.apply(null, args) : e;
|
|
1052
|
+
throw new Error(`[Immer] ${msg}`);
|
|
1053
|
+
}
|
|
1054
|
+
throw new Error(
|
|
1055
|
+
`[Immer] minified error nr: ${error}. Full error at: [SEC-REMOVED]`
|
|
1056
|
+
);
|
|
1057
|
+
}
|
|
1058
|
+
var O = Object;
|
|
1059
|
+
var getPrototypeOf = O.getPrototypeOf;
|
|
1060
|
+
var CONSTRUCTOR = "constructor";
|
|
1061
|
+
var PROTOTYPE = "prototype";
|
|
1062
|
+
var CONFIGURABLE = "configurable";
|
|
1063
|
+
var ENUMERABLE = "enumerable";
|
|
1064
|
+
var WRITABLE = "writable";
|
|
1065
|
+
var VALUE = "value";
|
|
1066
|
+
var isDraft = (value) => !!value && !!value[DRAFT_STATE];
|
|
1067
|
+
function isDraftable(value) {
|
|
1068
|
+
if (!value)
|
|
1069
|
+
return false;
|
|
1070
|
+
return isPlainObject(value) || isArray(value) || !!value[DRAFTABLE] || !!value[CONSTRUCTOR]?.[DRAFTABLE] || isMap(value) || isSet(value);
|
|
1071
|
+
}
|
|
1072
|
+
var objectCtorString = O[PROTOTYPE][CONSTRUCTOR].toString();
|
|
1073
|
+
var cachedCtorStrings = /* @__PURE__ */ new WeakMap();
|
|
1074
|
+
function isPlainObject(value) {
|
|
1075
|
+
if (!value || !isObjectish(value))
|
|
1076
|
+
return false;
|
|
1077
|
+
const proto = getPrototypeOf(value);
|
|
1078
|
+
if (proto === null || proto === O[PROTOTYPE])
|
|
1079
|
+
return true;
|
|
1080
|
+
const Ctor = O.hasOwnProperty.call(proto, CONSTRUCTOR) && proto[CONSTRUCTOR];
|
|
1081
|
+
if (Ctor === Object)
|
|
1082
|
+
return true;
|
|
1083
|
+
if (!isFunction(Ctor))
|
|
1084
|
+
return false;
|
|
1085
|
+
let ctorString = cachedCtorStrings.get(Ctor);
|
|
1086
|
+
if (ctorString === void 0) {
|
|
1087
|
+
ctorString = Function.toString.call(Ctor);
|
|
1088
|
+
cachedCtorStrings.set(Ctor, ctorString);
|
|
1089
|
+
}
|
|
1090
|
+
return ctorString === objectCtorString;
|
|
1091
|
+
}
|
|
1092
|
+
function each(obj, iter, strict = true) {
|
|
1093
|
+
if (getArchtype(obj) === 0) {
|
|
1094
|
+
const keys = strict ? Reflect.ownKeys(obj) : O.keys(obj);
|
|
1095
|
+
keys.forEach((key) => {
|
|
1096
|
+
iter(key, obj[key], obj);
|
|
1097
|
+
});
|
|
1098
|
+
} else {
|
|
1099
|
+
obj.forEach((entry, index) => iter(index, entry, obj));
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
function getArchtype(thing) {
|
|
1103
|
+
const state = thing[DRAFT_STATE];
|
|
1104
|
+
return state ? state.type_ : isArray(thing) ? 1 : isMap(thing) ? 2 : isSet(thing) ? 3 : 0;
|
|
1105
|
+
}
|
|
1106
|
+
var has = (thing, prop, type = getArchtype(thing)) => type === 2 ? thing.has(prop) : O[PROTOTYPE].hasOwnProperty.call(thing, prop);
|
|
1107
|
+
var get = (thing, prop, type = getArchtype(thing)) => (
|
|
1108
|
+
// @ts-ignore
|
|
1109
|
+
type === 2 ? thing.get(prop) : thing[prop]
|
|
1110
|
+
);
|
|
1111
|
+
var set = (thing, propOrOldValue, value, type = getArchtype(thing)) => {
|
|
1112
|
+
if (type === 2)
|
|
1113
|
+
thing.set(propOrOldValue, value);
|
|
1114
|
+
else if (type === 3) {
|
|
1115
|
+
thing.add(value);
|
|
1116
|
+
} else
|
|
1117
|
+
thing[propOrOldValue] = value;
|
|
1118
|
+
};
|
|
1119
|
+
function is(x, y) {
|
|
1120
|
+
if (x === y) {
|
|
1121
|
+
return x !== 0 || 1 / x === 1 / y;
|
|
1122
|
+
} else {
|
|
1123
|
+
return x !== x && y !== y;
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
var isArray = Array.isArray;
|
|
1127
|
+
var isMap = (target) => target instanceof Map;
|
|
1128
|
+
var isSet = (target) => target instanceof Set;
|
|
1129
|
+
var isObjectish = (target) => typeof target === "object";
|
|
1130
|
+
var isFunction = (target) => typeof target === "function";
|
|
1131
|
+
var isBoolean = (target) => typeof target === "boolean";
|
|
1132
|
+
function isArrayIndex(value) {
|
|
1133
|
+
const n = +value;
|
|
1134
|
+
return Number.isInteger(n) && String(n) === value;
|
|
1135
|
+
}
|
|
1136
|
+
var latest = (state) => state.copy_ || state.base_;
|
|
1137
|
+
var getFinalValue = (state) => state.modified_ ? state.copy_ : state.base_;
|
|
1138
|
+
function shallowCopy(base, strict) {
|
|
1139
|
+
if (isMap(base)) {
|
|
1140
|
+
return new Map(base);
|
|
1141
|
+
}
|
|
1142
|
+
if (isSet(base)) {
|
|
1143
|
+
return new Set(base);
|
|
1144
|
+
}
|
|
1145
|
+
if (isArray(base))
|
|
1146
|
+
return Array[PROTOTYPE].slice.call(base);
|
|
1147
|
+
const isPlain = isPlainObject(base);
|
|
1148
|
+
if (strict === true || strict === "class_only" && !isPlain) {
|
|
1149
|
+
const descriptors = O.getOwnPropertyDescriptors(base);
|
|
1150
|
+
delete descriptors[DRAFT_STATE];
|
|
1151
|
+
let keys = Reflect.ownKeys(descriptors);
|
|
1152
|
+
for (let i = 0; i < keys.length; i++) {
|
|
1153
|
+
const key = keys[i];
|
|
1154
|
+
const desc = descriptors[key];
|
|
1155
|
+
if (desc[WRITABLE] === false) {
|
|
1156
|
+
desc[WRITABLE] = true;
|
|
1157
|
+
desc[CONFIGURABLE] = true;
|
|
1158
|
+
}
|
|
1159
|
+
if (desc.get || desc.set)
|
|
1160
|
+
descriptors[key] = {
|
|
1161
|
+
[CONFIGURABLE]: true,
|
|
1162
|
+
[WRITABLE]: true,
|
|
1163
|
+
// could live with !!desc.set as well here...
|
|
1164
|
+
[ENUMERABLE]: desc[ENUMERABLE],
|
|
1165
|
+
[VALUE]: base[key]
|
|
1166
|
+
};
|
|
1167
|
+
}
|
|
1168
|
+
return O.create(getPrototypeOf(base), descriptors);
|
|
1169
|
+
} else {
|
|
1170
|
+
const proto = getPrototypeOf(base);
|
|
1171
|
+
if (proto !== null && isPlain) {
|
|
1172
|
+
return { ...base };
|
|
1173
|
+
}
|
|
1174
|
+
const obj = O.create(proto);
|
|
1175
|
+
return O.assign(obj, base);
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
function freeze(obj, deep = false) {
|
|
1179
|
+
if (isFrozen(obj) || isDraft(obj) || !isDraftable(obj))
|
|
1180
|
+
return obj;
|
|
1181
|
+
if (getArchtype(obj) > 1) {
|
|
1182
|
+
O.defineProperties(obj, {
|
|
1183
|
+
set: dontMutateMethodOverride,
|
|
1184
|
+
add: dontMutateMethodOverride,
|
|
1185
|
+
clear: dontMutateMethodOverride,
|
|
1186
|
+
delete: dontMutateMethodOverride
|
|
1187
|
+
});
|
|
1188
|
+
}
|
|
1189
|
+
O.freeze(obj);
|
|
1190
|
+
if (deep)
|
|
1191
|
+
each(
|
|
1192
|
+
obj,
|
|
1193
|
+
(_key, value) => {
|
|
1194
|
+
freeze(value, true);
|
|
1195
|
+
},
|
|
1196
|
+
false
|
|
1197
|
+
);
|
|
1198
|
+
return obj;
|
|
1199
|
+
}
|
|
1200
|
+
function dontMutateFrozenCollections() {
|
|
1201
|
+
die(2);
|
|
1202
|
+
}
|
|
1203
|
+
var dontMutateMethodOverride = {
|
|
1204
|
+
[VALUE]: dontMutateFrozenCollections
|
|
1205
|
+
};
|
|
1206
|
+
function isFrozen(obj) {
|
|
1207
|
+
if (obj === null || !isObjectish(obj))
|
|
1208
|
+
return true;
|
|
1209
|
+
return O.isFrozen(obj);
|
|
1210
|
+
}
|
|
1211
|
+
var PluginMapSet = "MapSet";
|
|
1212
|
+
var PluginPatches = "Patches";
|
|
1213
|
+
var PluginArrayMethods = "ArrayMethods";
|
|
1214
|
+
var plugins = {};
|
|
1215
|
+
function getPlugin(pluginKey) {
|
|
1216
|
+
const plugin = plugins[pluginKey];
|
|
1217
|
+
if (!plugin) {
|
|
1218
|
+
die(0, pluginKey);
|
|
1219
|
+
}
|
|
1220
|
+
return plugin;
|
|
1221
|
+
}
|
|
1222
|
+
var isPluginLoaded = (pluginKey) => !!plugins[pluginKey];
|
|
1223
|
+
var currentScope;
|
|
1224
|
+
var getCurrentScope = () => currentScope;
|
|
1225
|
+
var createScope = (parent_, immer_) => ({
|
|
1226
|
+
drafts_: [],
|
|
1227
|
+
parent_,
|
|
1228
|
+
immer_,
|
|
1229
|
+
// Whenever the modified draft contains a draft from another scope, we
|
|
1230
|
+
// need to prevent auto-freezing so the unowned draft can be finalized.
|
|
1231
|
+
canAutoFreeze_: true,
|
|
1232
|
+
unfinalizedDrafts_: 0,
|
|
1233
|
+
handledSet_: /* @__PURE__ */ new Set(),
|
|
1234
|
+
processedForPatches_: /* @__PURE__ */ new Set(),
|
|
1235
|
+
mapSetPlugin_: isPluginLoaded(PluginMapSet) ? getPlugin(PluginMapSet) : void 0,
|
|
1236
|
+
arrayMethodsPlugin_: isPluginLoaded(PluginArrayMethods) ? getPlugin(PluginArrayMethods) : void 0
|
|
1237
|
+
});
|
|
1238
|
+
function usePatchesInScope(scope, patchListener) {
|
|
1239
|
+
if (patchListener) {
|
|
1240
|
+
scope.patchPlugin_ = getPlugin(PluginPatches);
|
|
1241
|
+
scope.patches_ = [];
|
|
1242
|
+
scope.inversePatches_ = [];
|
|
1243
|
+
scope.patchListener_ = patchListener;
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
function revokeScope(scope) {
|
|
1247
|
+
leaveScope(scope);
|
|
1248
|
+
scope.drafts_.forEach(revokeDraft);
|
|
1249
|
+
scope.drafts_ = null;
|
|
1250
|
+
}
|
|
1251
|
+
function leaveScope(scope) {
|
|
1252
|
+
if (scope === currentScope) {
|
|
1253
|
+
currentScope = scope.parent_;
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
var enterScope = (immer2) => currentScope = createScope(currentScope, immer2);
|
|
1257
|
+
function revokeDraft(draft) {
|
|
1258
|
+
const state = draft[DRAFT_STATE];
|
|
1259
|
+
if (state.type_ === 0 || state.type_ === 1)
|
|
1260
|
+
state.revoke_();
|
|
1261
|
+
else
|
|
1262
|
+
state.revoked_ = true;
|
|
1263
|
+
}
|
|
1264
|
+
function processResult(result, scope) {
|
|
1265
|
+
scope.unfinalizedDrafts_ = scope.drafts_.length;
|
|
1266
|
+
const baseDraft = scope.drafts_[0];
|
|
1267
|
+
const isReplaced = result !== void 0 && result !== baseDraft;
|
|
1268
|
+
if (isReplaced) {
|
|
1269
|
+
if (baseDraft[DRAFT_STATE].modified_) {
|
|
1270
|
+
revokeScope(scope);
|
|
1271
|
+
die(4);
|
|
1272
|
+
}
|
|
1273
|
+
if (isDraftable(result)) {
|
|
1274
|
+
result = finalize(scope, result);
|
|
1275
|
+
}
|
|
1276
|
+
const { patchPlugin_ } = scope;
|
|
1277
|
+
if (patchPlugin_) {
|
|
1278
|
+
patchPlugin_.generateReplacementPatches_(
|
|
1279
|
+
baseDraft[DRAFT_STATE].base_,
|
|
1280
|
+
result,
|
|
1281
|
+
scope
|
|
1282
|
+
);
|
|
1283
|
+
}
|
|
1284
|
+
} else {
|
|
1285
|
+
result = finalize(scope, baseDraft);
|
|
1286
|
+
}
|
|
1287
|
+
maybeFreeze(scope, result, true);
|
|
1288
|
+
revokeScope(scope);
|
|
1289
|
+
if (scope.patches_) {
|
|
1290
|
+
scope.patchListener_(scope.patches_, scope.inversePatches_);
|
|
1291
|
+
}
|
|
1292
|
+
return result !== NOTHING ? result : void 0;
|
|
1293
|
+
}
|
|
1294
|
+
function finalize(rootScope, value) {
|
|
1295
|
+
if (isFrozen(value))
|
|
1296
|
+
return value;
|
|
1297
|
+
const state = value[DRAFT_STATE];
|
|
1298
|
+
if (!state) {
|
|
1299
|
+
const finalValue = handleValue(value, rootScope.handledSet_, rootScope);
|
|
1300
|
+
return finalValue;
|
|
1301
|
+
}
|
|
1302
|
+
if (!isSameScope(state, rootScope)) {
|
|
1303
|
+
return value;
|
|
1304
|
+
}
|
|
1305
|
+
if (!state.modified_) {
|
|
1306
|
+
return state.base_;
|
|
1307
|
+
}
|
|
1308
|
+
if (!state.finalized_) {
|
|
1309
|
+
const { callbacks_ } = state;
|
|
1310
|
+
if (callbacks_) {
|
|
1311
|
+
while (callbacks_.length > 0) {
|
|
1312
|
+
const callback = callbacks_.pop();
|
|
1313
|
+
callback(rootScope);
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
generatePatchesAndFinalize(state, rootScope);
|
|
1317
|
+
}
|
|
1318
|
+
return state.copy_;
|
|
1319
|
+
}
|
|
1320
|
+
function maybeFreeze(scope, value, deep = false) {
|
|
1321
|
+
if (!scope.parent_ && scope.immer_.autoFreeze_ && scope.canAutoFreeze_) {
|
|
1322
|
+
freeze(value, deep);
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
function markStateFinalized(state) {
|
|
1326
|
+
state.finalized_ = true;
|
|
1327
|
+
state.scope_.unfinalizedDrafts_--;
|
|
1328
|
+
}
|
|
1329
|
+
var isSameScope = (state, rootScope) => state.scope_ === rootScope;
|
|
1330
|
+
var EMPTY_LOCATIONS_RESULT = [];
|
|
1331
|
+
function updateDraftInParent(parent, draftValue, finalizedValue, originalKey) {
|
|
1332
|
+
const parentCopy = latest(parent);
|
|
1333
|
+
const parentType = parent.type_;
|
|
1334
|
+
if (originalKey !== void 0) {
|
|
1335
|
+
const currentValue = get(parentCopy, originalKey, parentType);
|
|
1336
|
+
if (currentValue === draftValue) {
|
|
1337
|
+
set(parentCopy, originalKey, finalizedValue, parentType);
|
|
1338
|
+
return;
|
|
1339
|
+
}
|
|
1340
|
+
}
|
|
1341
|
+
if (!parent.draftLocations_) {
|
|
1342
|
+
const draftLocations = parent.draftLocations_ = /* @__PURE__ */ new Map();
|
|
1343
|
+
each(parentCopy, (key, value) => {
|
|
1344
|
+
if (isDraft(value)) {
|
|
1345
|
+
const keys = draftLocations.get(value) || [];
|
|
1346
|
+
keys.push(key);
|
|
1347
|
+
draftLocations.set(value, keys);
|
|
1348
|
+
}
|
|
1349
|
+
});
|
|
1350
|
+
}
|
|
1351
|
+
const locations = parent.draftLocations_.get(draftValue) ?? EMPTY_LOCATIONS_RESULT;
|
|
1352
|
+
for (const location of locations) {
|
|
1353
|
+
set(parentCopy, location, finalizedValue, parentType);
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
function registerChildFinalizationCallback(parent, child, key) {
|
|
1357
|
+
parent.callbacks_.push(function childCleanup(rootScope) {
|
|
1358
|
+
const state = child;
|
|
1359
|
+
if (!state || !isSameScope(state, rootScope)) {
|
|
1360
|
+
return;
|
|
1361
|
+
}
|
|
1362
|
+
rootScope.mapSetPlugin_?.fixSetContents(state);
|
|
1363
|
+
const finalizedValue = getFinalValue(state);
|
|
1364
|
+
updateDraftInParent(parent, state.draft_ ?? state, finalizedValue, key);
|
|
1365
|
+
generatePatchesAndFinalize(state, rootScope);
|
|
1366
|
+
});
|
|
1367
|
+
}
|
|
1368
|
+
function generatePatchesAndFinalize(state, rootScope) {
|
|
1369
|
+
const shouldFinalize = state.modified_ && !state.finalized_ && (state.type_ === 3 || state.type_ === 1 && state.allIndicesReassigned_ || (state.assigned_?.size ?? 0) > 0);
|
|
1370
|
+
if (shouldFinalize) {
|
|
1371
|
+
const { patchPlugin_ } = rootScope;
|
|
1372
|
+
if (patchPlugin_) {
|
|
1373
|
+
const basePath = patchPlugin_.getPath(state);
|
|
1374
|
+
if (basePath) {
|
|
1375
|
+
patchPlugin_.generatePatches_(state, basePath, rootScope);
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
markStateFinalized(state);
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
function handleCrossReference(target, key, value) {
|
|
1382
|
+
const { scope_ } = target;
|
|
1383
|
+
if (isDraft(value)) {
|
|
1384
|
+
const state = value[DRAFT_STATE];
|
|
1385
|
+
if (isSameScope(state, scope_)) {
|
|
1386
|
+
state.callbacks_.push(function crossReferenceCleanup() {
|
|
1387
|
+
prepareCopy(target);
|
|
1388
|
+
const finalizedValue = getFinalValue(state);
|
|
1389
|
+
updateDraftInParent(target, value, finalizedValue, key);
|
|
1390
|
+
});
|
|
1391
|
+
}
|
|
1392
|
+
} else if (isDraftable(value)) {
|
|
1393
|
+
target.callbacks_.push(function nestedDraftCleanup() {
|
|
1394
|
+
const targetCopy = latest(target);
|
|
1395
|
+
if (target.type_ === 3) {
|
|
1396
|
+
if (targetCopy.has(value)) {
|
|
1397
|
+
handleValue(value, scope_.handledSet_, scope_);
|
|
1398
|
+
}
|
|
1399
|
+
} else {
|
|
1400
|
+
if (get(targetCopy, key, target.type_) === value) {
|
|
1401
|
+
if (scope_.drafts_.length > 1 && (target.assigned_.get(key) ?? false) === true && target.copy_) {
|
|
1402
|
+
handleValue(
|
|
1403
|
+
get(target.copy_, key, target.type_),
|
|
1404
|
+
scope_.handledSet_,
|
|
1405
|
+
scope_
|
|
1406
|
+
);
|
|
1407
|
+
}
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1410
|
+
});
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
function handleValue(target, handledSet, rootScope) {
|
|
1414
|
+
if (!rootScope.immer_.autoFreeze_ && rootScope.unfinalizedDrafts_ < 1) {
|
|
1415
|
+
return target;
|
|
1416
|
+
}
|
|
1417
|
+
if (isDraft(target) || handledSet.has(target) || !isDraftable(target) || isFrozen(target)) {
|
|
1418
|
+
return target;
|
|
1419
|
+
}
|
|
1420
|
+
handledSet.add(target);
|
|
1421
|
+
each(target, (key, value) => {
|
|
1422
|
+
if (isDraft(value)) {
|
|
1423
|
+
const state = value[DRAFT_STATE];
|
|
1424
|
+
if (isSameScope(state, rootScope)) {
|
|
1425
|
+
const updatedValue = getFinalValue(state);
|
|
1426
|
+
set(target, key, updatedValue, target.type_);
|
|
1427
|
+
markStateFinalized(state);
|
|
1428
|
+
}
|
|
1429
|
+
} else if (isDraftable(value)) {
|
|
1430
|
+
handleValue(value, handledSet, rootScope);
|
|
1431
|
+
}
|
|
1432
|
+
});
|
|
1433
|
+
return target;
|
|
1434
|
+
}
|
|
1435
|
+
function createProxyProxy(base, parent) {
|
|
1436
|
+
const baseIsArray = isArray(base);
|
|
1437
|
+
const state = {
|
|
1438
|
+
type_: baseIsArray ? 1 : 0,
|
|
1439
|
+
// Track which produce call this is associated with.
|
|
1440
|
+
scope_: parent ? parent.scope_ : getCurrentScope(),
|
|
1441
|
+
// True for both shallow and deep changes.
|
|
1442
|
+
modified_: false,
|
|
1443
|
+
// Used during finalization.
|
|
1444
|
+
finalized_: false,
|
|
1445
|
+
// Track which properties have been assigned (true) or deleted (false).
|
|
1446
|
+
// actually instantiated in `prepareCopy()`
|
|
1447
|
+
assigned_: void 0,
|
|
1448
|
+
// The parent draft state.
|
|
1449
|
+
parent_: parent,
|
|
1450
|
+
// The base state.
|
|
1451
|
+
base_: base,
|
|
1452
|
+
// The base proxy.
|
|
1453
|
+
draft_: null,
|
|
1454
|
+
// set below
|
|
1455
|
+
// The base copy with any updated values.
|
|
1456
|
+
copy_: null,
|
|
1457
|
+
// Called by the `produce` function.
|
|
1458
|
+
revoke_: null,
|
|
1459
|
+
isManual_: false,
|
|
1460
|
+
// `callbacks` actually gets assigned in `createProxy`
|
|
1461
|
+
callbacks_: void 0
|
|
1462
|
+
};
|
|
1463
|
+
let target = state;
|
|
1464
|
+
let traps = objectTraps;
|
|
1465
|
+
if (baseIsArray) {
|
|
1466
|
+
target = [state];
|
|
1467
|
+
traps = arrayTraps;
|
|
1468
|
+
}
|
|
1469
|
+
const { revoke, proxy } = Proxy.revocable(target, traps);
|
|
1470
|
+
state.draft_ = proxy;
|
|
1471
|
+
state.revoke_ = revoke;
|
|
1472
|
+
return [proxy, state];
|
|
1473
|
+
}
|
|
1474
|
+
var objectTraps = {
|
|
1475
|
+
get(state, prop) {
|
|
1476
|
+
if (prop === DRAFT_STATE)
|
|
1477
|
+
return state;
|
|
1478
|
+
let arrayPlugin = state.scope_.arrayMethodsPlugin_;
|
|
1479
|
+
const isArrayWithStringProp = state.type_ === 1 && typeof prop === "string";
|
|
1480
|
+
if (isArrayWithStringProp) {
|
|
1481
|
+
if (arrayPlugin?.isArrayOperationMethod(prop)) {
|
|
1482
|
+
return arrayPlugin.createMethodInterceptor(state, prop);
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
const source = latest(state);
|
|
1486
|
+
if (!has(source, prop, state.type_)) {
|
|
1487
|
+
return readPropFromProto(state, source, prop);
|
|
1488
|
+
}
|
|
1489
|
+
const value = source[prop];
|
|
1490
|
+
if (state.finalized_ || !isDraftable(value)) {
|
|
1491
|
+
return value;
|
|
1492
|
+
}
|
|
1493
|
+
if (isArrayWithStringProp && state.operationMethod && arrayPlugin?.isMutatingArrayMethod(
|
|
1494
|
+
state.operationMethod
|
|
1495
|
+
) && isArrayIndex(prop)) {
|
|
1496
|
+
return value;
|
|
1497
|
+
}
|
|
1498
|
+
if (value === peek(state.base_, prop)) {
|
|
1499
|
+
prepareCopy(state);
|
|
1500
|
+
const childKey = state.type_ === 1 ? +prop : prop;
|
|
1501
|
+
const childDraft = createProxy(state.scope_, value, state, childKey);
|
|
1502
|
+
return state.copy_[childKey] = childDraft;
|
|
1503
|
+
}
|
|
1504
|
+
return value;
|
|
1505
|
+
},
|
|
1506
|
+
has(state, prop) {
|
|
1507
|
+
return prop in latest(state);
|
|
1508
|
+
},
|
|
1509
|
+
ownKeys(state) {
|
|
1510
|
+
return Reflect.ownKeys(latest(state));
|
|
1511
|
+
},
|
|
1512
|
+
set(state, prop, value) {
|
|
1513
|
+
const desc = getDescriptorFromProto(latest(state), prop);
|
|
1514
|
+
if (desc?.set) {
|
|
1515
|
+
desc.set.call(state.draft_, value);
|
|
1516
|
+
return true;
|
|
1517
|
+
}
|
|
1518
|
+
if (!state.modified_) {
|
|
1519
|
+
const current2 = peek(latest(state), prop);
|
|
1520
|
+
const currentState = current2?.[DRAFT_STATE];
|
|
1521
|
+
if (currentState && currentState.base_ === value) {
|
|
1522
|
+
state.copy_[prop] = value;
|
|
1523
|
+
state.assigned_.set(prop, false);
|
|
1524
|
+
return true;
|
|
1525
|
+
}
|
|
1526
|
+
if (is(value, current2) && (value !== void 0 || has(state.base_, prop, state.type_)))
|
|
1527
|
+
return true;
|
|
1528
|
+
prepareCopy(state);
|
|
1529
|
+
markChanged(state);
|
|
1530
|
+
}
|
|
1531
|
+
if (state.copy_[prop] === value && // special case: handle new props with value 'undefined'
|
|
1532
|
+
(value !== void 0 || prop in state.copy_) || // special case: NaN
|
|
1533
|
+
Number.isNaN(value) && Number.isNaN(state.copy_[prop]))
|
|
1534
|
+
return true;
|
|
1535
|
+
state.copy_[prop] = value;
|
|
1536
|
+
state.assigned_.set(prop, true);
|
|
1537
|
+
handleCrossReference(state, prop, value);
|
|
1538
|
+
return true;
|
|
1539
|
+
},
|
|
1540
|
+
deleteProperty(state, prop) {
|
|
1541
|
+
prepareCopy(state);
|
|
1542
|
+
if (peek(state.base_, prop) !== void 0 || prop in state.base_) {
|
|
1543
|
+
state.assigned_.set(prop, false);
|
|
1544
|
+
markChanged(state);
|
|
1545
|
+
} else {
|
|
1546
|
+
state.assigned_.delete(prop);
|
|
1547
|
+
}
|
|
1548
|
+
if (state.copy_) {
|
|
1549
|
+
delete state.copy_[prop];
|
|
1550
|
+
}
|
|
1551
|
+
return true;
|
|
1552
|
+
},
|
|
1553
|
+
// Note: We never coerce `desc.value` into an Immer draft, because we can't make
|
|
1554
|
+
// the same guarantee in ES5 mode.
|
|
1555
|
+
getOwnPropertyDescriptor(state, prop) {
|
|
1556
|
+
const owner = latest(state);
|
|
1557
|
+
const desc = Reflect.getOwnPropertyDescriptor(owner, prop);
|
|
1558
|
+
if (!desc)
|
|
1559
|
+
return desc;
|
|
1560
|
+
return {
|
|
1561
|
+
[WRITABLE]: true,
|
|
1562
|
+
[CONFIGURABLE]: state.type_ !== 1 || prop !== "length",
|
|
1563
|
+
[ENUMERABLE]: desc[ENUMERABLE],
|
|
1564
|
+
[VALUE]: owner[prop]
|
|
1565
|
+
};
|
|
1566
|
+
},
|
|
1567
|
+
defineProperty() {
|
|
1568
|
+
die(11);
|
|
1569
|
+
},
|
|
1570
|
+
getPrototypeOf(state) {
|
|
1571
|
+
return getPrototypeOf(state.base_);
|
|
1572
|
+
},
|
|
1573
|
+
setPrototypeOf() {
|
|
1574
|
+
die(12);
|
|
1575
|
+
}
|
|
1576
|
+
};
|
|
1577
|
+
var arrayTraps = {};
|
|
1578
|
+
for (let key in objectTraps) {
|
|
1579
|
+
let fn = objectTraps[key];
|
|
1580
|
+
arrayTraps[key] = function() {
|
|
1581
|
+
const args = arguments;
|
|
1582
|
+
args[0] = args[0][0];
|
|
1583
|
+
return fn.apply(this, args);
|
|
1584
|
+
};
|
|
1585
|
+
}
|
|
1586
|
+
arrayTraps.deleteProperty = function(state, prop) {
|
|
1587
|
+
if (isNaN(parseInt(prop)))
|
|
1588
|
+
die(13);
|
|
1589
|
+
return arrayTraps.set.call(this, state, prop, void 0);
|
|
1590
|
+
};
|
|
1591
|
+
arrayTraps.set = function(state, prop, value) {
|
|
1592
|
+
if (prop !== "length" && isNaN(parseInt(prop)))
|
|
1593
|
+
die(14);
|
|
1594
|
+
return objectTraps.set.call(this, state[0], prop, value, state[0]);
|
|
1595
|
+
};
|
|
1596
|
+
function peek(draft, prop) {
|
|
1597
|
+
const state = draft[DRAFT_STATE];
|
|
1598
|
+
const source = state ? latest(state) : draft;
|
|
1599
|
+
return source[prop];
|
|
1600
|
+
}
|
|
1601
|
+
function readPropFromProto(state, source, prop) {
|
|
1602
|
+
const desc = getDescriptorFromProto(source, prop);
|
|
1603
|
+
return desc ? VALUE in desc ? desc[VALUE] : (
|
|
1604
|
+
// This is a very special case, if the prop is a getter defined by the
|
|
1605
|
+
// prototype, we should invoke it with the draft as context!
|
|
1606
|
+
desc.get?.call(state.draft_)
|
|
1607
|
+
) : void 0;
|
|
1608
|
+
}
|
|
1609
|
+
function getDescriptorFromProto(source, prop) {
|
|
1610
|
+
if (!(prop in source))
|
|
1611
|
+
return void 0;
|
|
1612
|
+
let proto = getPrototypeOf(source);
|
|
1613
|
+
while (proto) {
|
|
1614
|
+
const desc = Object.getOwnPropertyDescriptor(proto, prop);
|
|
1615
|
+
if (desc)
|
|
1616
|
+
return desc;
|
|
1617
|
+
proto = getPrototypeOf(proto);
|
|
1618
|
+
}
|
|
1619
|
+
return void 0;
|
|
1620
|
+
}
|
|
1621
|
+
function markChanged(state) {
|
|
1622
|
+
if (!state.modified_) {
|
|
1623
|
+
state.modified_ = true;
|
|
1624
|
+
if (state.parent_) {
|
|
1625
|
+
markChanged(state.parent_);
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1629
|
+
function prepareCopy(state) {
|
|
1630
|
+
if (!state.copy_) {
|
|
1631
|
+
state.assigned_ = /* @__PURE__ */ new Map();
|
|
1632
|
+
state.copy_ = shallowCopy(
|
|
1633
|
+
state.base_,
|
|
1634
|
+
state.scope_.immer_.useStrictShallowCopy_
|
|
1635
|
+
);
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
var Immer2 = class {
|
|
1639
|
+
constructor(config) {
|
|
1640
|
+
this.autoFreeze_ = true;
|
|
1641
|
+
this.useStrictShallowCopy_ = false;
|
|
1642
|
+
this.useStrictIteration_ = false;
|
|
1643
|
+
this.produce = (base, recipe, patchListener) => {
|
|
1644
|
+
if (isFunction(base) && !isFunction(recipe)) {
|
|
1645
|
+
const defaultBase = recipe;
|
|
1646
|
+
recipe = base;
|
|
1647
|
+
const self = this;
|
|
1648
|
+
return function curriedProduce(base2 = defaultBase, ...args) {
|
|
1649
|
+
return self.produce(base2, (draft) => recipe.call(this, draft, ...args));
|
|
1650
|
+
};
|
|
1651
|
+
}
|
|
1652
|
+
if (!isFunction(recipe))
|
|
1653
|
+
die(6);
|
|
1654
|
+
if (patchListener !== void 0 && !isFunction(patchListener))
|
|
1655
|
+
die(7);
|
|
1656
|
+
let result;
|
|
1657
|
+
if (isDraftable(base)) {
|
|
1658
|
+
const scope = enterScope(this);
|
|
1659
|
+
const proxy = createProxy(scope, base, void 0);
|
|
1660
|
+
let hasError = true;
|
|
1661
|
+
try {
|
|
1662
|
+
result = recipe(proxy);
|
|
1663
|
+
hasError = false;
|
|
1664
|
+
} finally {
|
|
1665
|
+
if (hasError)
|
|
1666
|
+
revokeScope(scope);
|
|
1667
|
+
else
|
|
1668
|
+
leaveScope(scope);
|
|
1669
|
+
}
|
|
1670
|
+
usePatchesInScope(scope, patchListener);
|
|
1671
|
+
return processResult(result, scope);
|
|
1672
|
+
} else if (!base || !isObjectish(base)) {
|
|
1673
|
+
result = recipe(base);
|
|
1674
|
+
if (result === void 0)
|
|
1675
|
+
result = base;
|
|
1676
|
+
if (result === NOTHING)
|
|
1677
|
+
result = void 0;
|
|
1678
|
+
if (this.autoFreeze_)
|
|
1679
|
+
freeze(result, true);
|
|
1680
|
+
if (patchListener) {
|
|
1681
|
+
const p = [];
|
|
1682
|
+
const ip = [];
|
|
1683
|
+
getPlugin(PluginPatches).generateReplacementPatches_(base, result, {
|
|
1684
|
+
patches_: p,
|
|
1685
|
+
inversePatches_: ip
|
|
1686
|
+
});
|
|
1687
|
+
patchListener(p, ip);
|
|
1688
|
+
}
|
|
1689
|
+
return result;
|
|
1690
|
+
} else
|
|
1691
|
+
die(1, base);
|
|
1692
|
+
};
|
|
1693
|
+
this.produceWithPatches = (base, recipe) => {
|
|
1694
|
+
if (isFunction(base)) {
|
|
1695
|
+
return (state, ...args) => this.produceWithPatches(state, (draft) => base(draft, ...args));
|
|
1696
|
+
}
|
|
1697
|
+
let patches, inversePatches;
|
|
1698
|
+
const result = this.produce(base, recipe, (p, ip) => {
|
|
1699
|
+
patches = p;
|
|
1700
|
+
inversePatches = ip;
|
|
1701
|
+
});
|
|
1702
|
+
return [result, patches, inversePatches];
|
|
1703
|
+
};
|
|
1704
|
+
if (isBoolean(config?.autoFreeze))
|
|
1705
|
+
this.setAutoFreeze(config.autoFreeze);
|
|
1706
|
+
if (isBoolean(config?.useStrictShallowCopy))
|
|
1707
|
+
this.setUseStrictShallowCopy(config.useStrictShallowCopy);
|
|
1708
|
+
if (isBoolean(config?.useStrictIteration))
|
|
1709
|
+
this.setUseStrictIteration(config.useStrictIteration);
|
|
1710
|
+
}
|
|
1711
|
+
createDraft(base) {
|
|
1712
|
+
if (!isDraftable(base))
|
|
1713
|
+
die(8);
|
|
1714
|
+
if (isDraft(base))
|
|
1715
|
+
base = current(base);
|
|
1716
|
+
const scope = enterScope(this);
|
|
1717
|
+
const proxy = createProxy(scope, base, void 0);
|
|
1718
|
+
proxy[DRAFT_STATE].isManual_ = true;
|
|
1719
|
+
leaveScope(scope);
|
|
1720
|
+
return proxy;
|
|
1721
|
+
}
|
|
1722
|
+
finishDraft(draft, patchListener) {
|
|
1723
|
+
const state = draft && draft[DRAFT_STATE];
|
|
1724
|
+
if (!state || !state.isManual_)
|
|
1725
|
+
die(9);
|
|
1726
|
+
const { scope_: scope } = state;
|
|
1727
|
+
usePatchesInScope(scope, patchListener);
|
|
1728
|
+
return processResult(void 0, scope);
|
|
1729
|
+
}
|
|
1730
|
+
/**
|
|
1731
|
+
* Pass true to automatically freeze all copies created by Immer.
|
|
1732
|
+
*
|
|
1733
|
+
* By default, auto-freezing is enabled.
|
|
1734
|
+
*/
|
|
1735
|
+
setAutoFreeze(value) {
|
|
1736
|
+
this.autoFreeze_ = value;
|
|
1737
|
+
}
|
|
1738
|
+
/**
|
|
1739
|
+
* Pass true to enable strict shallow copy.
|
|
1740
|
+
*
|
|
1741
|
+
* By default, immer does not copy the object descriptors such as getter, setter and non-enumrable properties.
|
|
1742
|
+
*/
|
|
1743
|
+
setUseStrictShallowCopy(value) {
|
|
1744
|
+
this.useStrictShallowCopy_ = value;
|
|
1745
|
+
}
|
|
1746
|
+
/**
|
|
1747
|
+
* Pass false to use faster iteration that skips non-enumerable properties
|
|
1748
|
+
* but still handles symbols for compatibility.
|
|
1749
|
+
*
|
|
1750
|
+
* By default, strict iteration is enabled (includes all own properties).
|
|
1751
|
+
*/
|
|
1752
|
+
setUseStrictIteration(value) {
|
|
1753
|
+
this.useStrictIteration_ = value;
|
|
1754
|
+
}
|
|
1755
|
+
shouldUseStrictIteration() {
|
|
1756
|
+
return this.useStrictIteration_;
|
|
1757
|
+
}
|
|
1758
|
+
applyPatches(base, patches) {
|
|
1759
|
+
let i;
|
|
1760
|
+
for (i = patches.length - 1; i >= 0; i--) {
|
|
1761
|
+
const patch = patches[i];
|
|
1762
|
+
if (patch.path.length === 0 && patch.op === "replace") {
|
|
1763
|
+
base = patch.value;
|
|
1764
|
+
break;
|
|
1765
|
+
}
|
|
1766
|
+
}
|
|
1767
|
+
if (i > -1) {
|
|
1768
|
+
patches = patches.slice(i + 1);
|
|
1769
|
+
}
|
|
1770
|
+
const applyPatchesImpl = getPlugin(PluginPatches).applyPatches_;
|
|
1771
|
+
if (isDraft(base)) {
|
|
1772
|
+
return applyPatchesImpl(base, patches);
|
|
1773
|
+
}
|
|
1774
|
+
return this.produce(
|
|
1775
|
+
base,
|
|
1776
|
+
(draft) => applyPatchesImpl(draft, patches)
|
|
1777
|
+
);
|
|
1778
|
+
}
|
|
1779
|
+
};
|
|
1780
|
+
function createProxy(rootScope, value, parent, key) {
|
|
1781
|
+
const [draft, state] = isMap(value) ? getPlugin(PluginMapSet).proxyMap_(value, parent) : isSet(value) ? getPlugin(PluginMapSet).proxySet_(value, parent) : createProxyProxy(value, parent);
|
|
1782
|
+
const scope = parent?.scope_ ?? getCurrentScope();
|
|
1783
|
+
scope.drafts_.push(draft);
|
|
1784
|
+
state.callbacks_ = parent?.callbacks_ ?? [];
|
|
1785
|
+
state.key_ = key;
|
|
1786
|
+
if (parent && key !== void 0) {
|
|
1787
|
+
registerChildFinalizationCallback(parent, state, key);
|
|
1788
|
+
} else {
|
|
1789
|
+
state.callbacks_.push(function rootDraftCleanup(rootScope2) {
|
|
1790
|
+
rootScope2.mapSetPlugin_?.fixSetContents(state);
|
|
1791
|
+
const { patchPlugin_ } = rootScope2;
|
|
1792
|
+
if (state.modified_ && patchPlugin_) {
|
|
1793
|
+
patchPlugin_.generatePatches_(state, [], rootScope2);
|
|
1794
|
+
}
|
|
1795
|
+
});
|
|
1796
|
+
}
|
|
1797
|
+
return draft;
|
|
1798
|
+
}
|
|
1799
|
+
function current(value) {
|
|
1800
|
+
if (!isDraft(value))
|
|
1801
|
+
die(10, value);
|
|
1802
|
+
return currentImpl(value);
|
|
1803
|
+
}
|
|
1804
|
+
function currentImpl(value) {
|
|
1805
|
+
if (!isDraftable(value) || isFrozen(value))
|
|
1806
|
+
return value;
|
|
1807
|
+
const state = value[DRAFT_STATE];
|
|
1808
|
+
let copy;
|
|
1809
|
+
let strict = true;
|
|
1810
|
+
if (state) {
|
|
1811
|
+
if (!state.modified_)
|
|
1812
|
+
return state.base_;
|
|
1813
|
+
state.finalized_ = true;
|
|
1814
|
+
copy = shallowCopy(value, state.scope_.immer_.useStrictShallowCopy_);
|
|
1815
|
+
strict = state.scope_.immer_.shouldUseStrictIteration();
|
|
1816
|
+
} else {
|
|
1817
|
+
copy = shallowCopy(value, true);
|
|
1818
|
+
}
|
|
1819
|
+
each(
|
|
1820
|
+
copy,
|
|
1821
|
+
(key, childValue) => {
|
|
1822
|
+
set(copy, key, currentImpl(childValue));
|
|
1823
|
+
},
|
|
1824
|
+
strict
|
|
1825
|
+
);
|
|
1826
|
+
if (state) {
|
|
1827
|
+
state.finalized_ = false;
|
|
1828
|
+
}
|
|
1829
|
+
return copy;
|
|
1830
|
+
}
|
|
1831
|
+
var immer = new Immer2();
|
|
1832
|
+
var produce = immer.produce;
|
|
7
1833
|
|
|
8
1834
|
// core/security.ts
|
|
9
1835
|
var REGEX_TIMEOUT_MS = 100;
|
|
@@ -259,7 +2085,6 @@ var isEqual = (a, b) => {
|
|
|
259
2085
|
};
|
|
260
2086
|
|
|
261
2087
|
// core/persistence.ts
|
|
262
|
-
import { freeze as _immerFreeze } from "immer";
|
|
263
2088
|
var _getPrefix = (namespace) => `${namespace}_`;
|
|
264
2089
|
var flushDisk = async (ctx) => {
|
|
265
2090
|
if (!ctx.storage) return;
|
|
@@ -329,7 +2154,7 @@ var flushDisk = async (ctx) => {
|
|
|
329
2154
|
var hydrateStore = async (ctx, calculateSize, emit) => {
|
|
330
2155
|
const { storage, config, encryptionKey, audit, onError, silent, currentVersion, store, sizes, versions } = ctx;
|
|
331
2156
|
const prefix = _getPrefix(config.namespace || "gstate");
|
|
332
|
-
const
|
|
2157
|
+
const immer2 = config.immer ?? true;
|
|
333
2158
|
if (!storage) return;
|
|
334
2159
|
try {
|
|
335
2160
|
const persisted = {};
|
|
@@ -374,7 +2199,7 @@ var hydrateStore = async (ctx, calculateSize, emit) => {
|
|
|
374
2199
|
}
|
|
375
2200
|
const final = savedV < currentVersion && config.migrate ? config.migrate(persisted, savedV) : persisted;
|
|
376
2201
|
Object.entries(final).forEach(([k, v]) => {
|
|
377
|
-
const frozen =
|
|
2202
|
+
const frozen = immer2 && v !== null && typeof v === "object" ? freeze(deepClone(v), true) : v;
|
|
378
2203
|
const size = calculateSize(frozen);
|
|
379
2204
|
const oldSize = sizes.get(k) || 0;
|
|
380
2205
|
ctx.totalSize = ctx.totalSize - oldSize + size;
|
|
@@ -529,7 +2354,7 @@ var SyncEngine = class {
|
|
|
529
2354
|
const startTime = Date.now();
|
|
530
2355
|
const syncedKeys = [];
|
|
531
2356
|
const conflicts = [];
|
|
532
|
-
const
|
|
2357
|
+
const errors2 = [];
|
|
533
2358
|
try {
|
|
534
2359
|
const pendingChanges = Array.from(this.pendingQueue.values());
|
|
535
2360
|
if (pendingChanges.length === 0) {
|
|
@@ -572,14 +2397,14 @@ var SyncEngine = class {
|
|
|
572
2397
|
this.pendingQueue.delete(change.key);
|
|
573
2398
|
}
|
|
574
2399
|
} catch (err) {
|
|
575
|
-
|
|
2400
|
+
errors2.push(`Failed to sync "${change.key}": ${err}`);
|
|
576
2401
|
}
|
|
577
2402
|
}
|
|
578
2403
|
const result = {
|
|
579
|
-
success:
|
|
2404
|
+
success: errors2.length === 0,
|
|
580
2405
|
syncedKeys,
|
|
581
2406
|
conflicts,
|
|
582
|
-
errors,
|
|
2407
|
+
errors: errors2,
|
|
583
2408
|
timestamp: Date.now(),
|
|
584
2409
|
duration: Date.now() - startTime
|
|
585
2410
|
};
|
|
@@ -587,12 +2412,12 @@ var SyncEngine = class {
|
|
|
587
2412
|
return result;
|
|
588
2413
|
} catch (err) {
|
|
589
2414
|
const errorMsg = `Sync failed: ${err}`;
|
|
590
|
-
|
|
2415
|
+
errors2.push(errorMsg);
|
|
591
2416
|
return {
|
|
592
2417
|
success: false,
|
|
593
2418
|
syncedKeys,
|
|
594
2419
|
conflicts,
|
|
595
|
-
errors,
|
|
2420
|
+
errors: errors2,
|
|
596
2421
|
timestamp: Date.now(),
|
|
597
2422
|
duration: Date.now() - startTime
|
|
598
2423
|
};
|
|
@@ -863,7 +2688,7 @@ var createStore = (config) => {
|
|
|
863
2688
|
});
|
|
864
2689
|
comp.deps = depsFound;
|
|
865
2690
|
if (!isEqual(comp.lastValue, newValue)) {
|
|
866
|
-
comp.lastValue = _immer && newValue !== null && typeof newValue === "object" ?
|
|
2691
|
+
comp.lastValue = _immer && newValue !== null && typeof newValue === "object" ? freeze(deepClone(newValue), true) : newValue;
|
|
867
2692
|
_versions.set(key, (_versions.get(key) || 0) + 1);
|
|
868
2693
|
_emit(key);
|
|
869
2694
|
}
|
|
@@ -922,7 +2747,7 @@ var createStore = (config) => {
|
|
|
922
2747
|
const _methodNamespace = {};
|
|
923
2748
|
const instance = {
|
|
924
2749
|
_setSilently: (key, value) => {
|
|
925
|
-
const oldSize = _sizes.get(key) || 0, frozen = _immer && value !== null && typeof value === "object" ?
|
|
2750
|
+
const oldSize = _sizes.get(key) || 0, frozen = _immer && value !== null && typeof value === "object" ? freeze(deepClone(value), true) : value;
|
|
926
2751
|
const hasLimits = (_maxObjectSize > 0 || _maxTotalSize > 0) && !isProduction();
|
|
927
2752
|
const newSize = hasLimits ? _calculateSize(frozen) : 0;
|
|
928
2753
|
_totalSize = _totalSize - oldSize + newSize;
|
|
@@ -947,7 +2772,7 @@ var createStore = (config) => {
|
|
|
947
2772
|
_methodNamespace[pluginName][methodName] = fn;
|
|
948
2773
|
},
|
|
949
2774
|
set: (key, valOrUp, options = {}) => {
|
|
950
|
-
const oldVal = _store.get(key), newVal = _immer && typeof valOrUp === "function" ?
|
|
2775
|
+
const oldVal = _store.get(key), newVal = _immer && typeof valOrUp === "function" ? produce(oldVal, valOrUp) : valOrUp;
|
|
951
2776
|
if (_validateInput && !validateKey(key)) {
|
|
952
2777
|
if (!_silent) console.warn(`[gstate] Invalid key: ${key}`);
|
|
953
2778
|
return false;
|
|
@@ -960,7 +2785,7 @@ var createStore = (config) => {
|
|
|
960
2785
|
const sani = _validateInput ? sanitizeValue(newVal) : newVal;
|
|
961
2786
|
const oldSize = _sizes.get(key) || 0;
|
|
962
2787
|
_runHook("onBeforeSet", { key, value: sani, store: instance, version: _versions.get(key) || 0 });
|
|
963
|
-
const frozen = _immer && sani !== null && typeof sani === "object" ?
|
|
2788
|
+
const frozen = _immer && sani !== null && typeof sani === "object" ? freeze(deepClone(sani), true) : sani;
|
|
964
2789
|
if (!isEqual(oldVal, frozen)) {
|
|
965
2790
|
const hasLimits = (_maxObjectSize > 0 || _maxTotalSize > 0) && !isProduction();
|
|
966
2791
|
const finalSize = hasLimits ? _calculateSize(frozen) : 0;
|
|
@@ -1021,11 +2846,11 @@ var createStore = (config) => {
|
|
|
1021
2846
|
},
|
|
1022
2847
|
watch: (key, callback) => {
|
|
1023
2848
|
if (!_watchers.has(key)) _watchers.set(key, /* @__PURE__ */ new Set());
|
|
1024
|
-
const
|
|
1025
|
-
|
|
2849
|
+
const set2 = _watchers.get(key);
|
|
2850
|
+
set2.add(callback);
|
|
1026
2851
|
return () => {
|
|
1027
|
-
|
|
1028
|
-
if (
|
|
2852
|
+
set2.delete(callback);
|
|
2853
|
+
if (set2.size === 0) _watchers.delete(key);
|
|
1029
2854
|
};
|
|
1030
2855
|
},
|
|
1031
2856
|
remove: (key) => {
|
|
@@ -1114,11 +2939,11 @@ var createStore = (config) => {
|
|
|
1114
2939
|
_subscribe: (cb, key) => {
|
|
1115
2940
|
if (key) {
|
|
1116
2941
|
if (!_keyListeners.has(key)) _keyListeners.set(key, /* @__PURE__ */ new Set());
|
|
1117
|
-
const
|
|
1118
|
-
|
|
2942
|
+
const set2 = _keyListeners.get(key);
|
|
2943
|
+
set2.add(cb);
|
|
1119
2944
|
return () => {
|
|
1120
|
-
|
|
1121
|
-
if (
|
|
2945
|
+
set2.delete(cb);
|
|
2946
|
+
if (set2.size === 0) _keyListeners.delete(key);
|
|
1122
2947
|
};
|
|
1123
2948
|
}
|
|
1124
2949
|
_listeners.add(cb);
|
|
@@ -1194,7 +3019,7 @@ var createStore = (config) => {
|
|
|
1194
3019
|
};
|
|
1195
3020
|
|
|
1196
3021
|
// core/hooks.ts
|
|
1197
|
-
|
|
3022
|
+
var import_react = __toESM(require_react(), 1);
|
|
1198
3023
|
var _defaultStore = null;
|
|
1199
3024
|
var initState = (config) => {
|
|
1200
3025
|
if (_defaultStore && !config?.namespace) {
|
|
@@ -1216,12 +3041,12 @@ var destroyState = () => {
|
|
|
1216
3041
|
};
|
|
1217
3042
|
var useIsStoreReady = (store) => {
|
|
1218
3043
|
const targetStore = store || _defaultStore;
|
|
1219
|
-
const subscribe = useMemo(
|
|
3044
|
+
const subscribe = (0, import_react.useMemo)(
|
|
1220
3045
|
() => (callback) => targetStore ? targetStore._subscribe(callback) : () => {
|
|
1221
3046
|
},
|
|
1222
3047
|
[targetStore]
|
|
1223
3048
|
);
|
|
1224
|
-
return useSyncExternalStore(
|
|
3049
|
+
return (0, import_react.useSyncExternalStore)(
|
|
1225
3050
|
subscribe,
|
|
1226
3051
|
() => targetStore ? targetStore.isReady : false,
|
|
1227
3052
|
() => true
|
|
@@ -1230,11 +3055,11 @@ var useIsStoreReady = (store) => {
|
|
|
1230
3055
|
};
|
|
1231
3056
|
var getStore = () => _defaultStore;
|
|
1232
3057
|
function useStore(keyOrSelector, store) {
|
|
1233
|
-
const targetStore = useMemo(
|
|
3058
|
+
const targetStore = (0, import_react.useMemo)(
|
|
1234
3059
|
() => store || _defaultStore,
|
|
1235
3060
|
[store]
|
|
1236
3061
|
);
|
|
1237
|
-
const ghostStore = useMemo(() => {
|
|
3062
|
+
const ghostStore = (0, import_react.useMemo)(() => {
|
|
1238
3063
|
const noop = () => {
|
|
1239
3064
|
};
|
|
1240
3065
|
const noopFalse = () => false;
|
|
@@ -1280,7 +3105,7 @@ function useStore(keyOrSelector, store) {
|
|
|
1280
3105
|
const isSelector = typeof keyOrSelector === "function";
|
|
1281
3106
|
const key = !isSelector ? keyOrSelector : null;
|
|
1282
3107
|
const selector = isSelector ? keyOrSelector : null;
|
|
1283
|
-
const subscribe = useCallback(
|
|
3108
|
+
const subscribe = (0, import_react.useCallback)(
|
|
1284
3109
|
(callback) => {
|
|
1285
3110
|
if (isSelector) {
|
|
1286
3111
|
return safeStore._subscribe(callback);
|
|
@@ -1290,14 +3115,14 @@ function useStore(keyOrSelector, store) {
|
|
|
1290
3115
|
},
|
|
1291
3116
|
[safeStore, isSelector, key]
|
|
1292
3117
|
);
|
|
1293
|
-
const getSnapshot = useCallback(() => {
|
|
3118
|
+
const getSnapshot = (0, import_react.useCallback)(() => {
|
|
1294
3119
|
if (isSelector) {
|
|
1295
3120
|
return selector(safeStore.getSnapshot());
|
|
1296
3121
|
} else {
|
|
1297
3122
|
return safeStore.get(key) ?? void 0;
|
|
1298
3123
|
}
|
|
1299
3124
|
}, [safeStore, isSelector, key, selector]);
|
|
1300
|
-
const getServerSnapshot = useCallback(() => {
|
|
3125
|
+
const getServerSnapshot = (0, import_react.useCallback)(() => {
|
|
1301
3126
|
if (isSelector) {
|
|
1302
3127
|
try {
|
|
1303
3128
|
return selector({});
|
|
@@ -1308,13 +3133,13 @@ function useStore(keyOrSelector, store) {
|
|
|
1308
3133
|
return void 0;
|
|
1309
3134
|
}
|
|
1310
3135
|
}, [selector, isSelector]);
|
|
1311
|
-
const value = useSyncExternalStore(
|
|
3136
|
+
const value = (0, import_react.useSyncExternalStore)(
|
|
1312
3137
|
subscribe,
|
|
1313
3138
|
getSnapshot,
|
|
1314
3139
|
// Cast needed for union types
|
|
1315
3140
|
getServerSnapshot
|
|
1316
3141
|
);
|
|
1317
|
-
const setter = useCallback(
|
|
3142
|
+
const setter = (0, import_react.useCallback)(
|
|
1318
3143
|
(val, options) => {
|
|
1319
3144
|
if (isSelector) {
|
|
1320
3145
|
if (!isProduction()) {
|
|
@@ -1326,7 +3151,7 @@ function useStore(keyOrSelector, store) {
|
|
|
1326
3151
|
},
|
|
1327
3152
|
[safeStore, isSelector, key]
|
|
1328
3153
|
);
|
|
1329
|
-
useDebugValue(value, (v) => isSelector ? `Selector: ${JSON.stringify(v)}` : `${key}: ${JSON.stringify(v)}`);
|
|
3154
|
+
(0, import_react.useDebugValue)(value, (v) => isSelector ? `Selector: ${JSON.stringify(v)}` : `${key}: ${JSON.stringify(v)}`);
|
|
1330
3155
|
if (isSelector) {
|
|
1331
3156
|
return value;
|
|
1332
3157
|
}
|
|
@@ -1357,19 +3182,19 @@ function useSyncedState(key, store) {
|
|
|
1357
3182
|
const result = useStore(key, targetStore);
|
|
1358
3183
|
const value = result[0];
|
|
1359
3184
|
const setter = result[1];
|
|
1360
|
-
const [syncState, setSyncState] = useState(() => engine?.getState() || {
|
|
3185
|
+
const [syncState, setSyncState] = (0, import_react.useState)(() => engine?.getState() || {
|
|
1361
3186
|
isOnline: true,
|
|
1362
3187
|
isSyncing: false,
|
|
1363
3188
|
lastSyncTimestamp: null,
|
|
1364
3189
|
pendingChanges: 0,
|
|
1365
3190
|
conflicts: 0
|
|
1366
3191
|
});
|
|
1367
|
-
useEffect(() => {
|
|
3192
|
+
(0, import_react.useEffect)(() => {
|
|
1368
3193
|
if (!engine) return;
|
|
1369
3194
|
const unsubscribe = engine.onStateChange(setSyncState);
|
|
1370
3195
|
return unsubscribe;
|
|
1371
3196
|
}, [engine]);
|
|
1372
|
-
const syncedSetter = useCallback(
|
|
3197
|
+
const syncedSetter = (0, import_react.useCallback)(
|
|
1373
3198
|
(val, options) => {
|
|
1374
3199
|
const result2 = setter(val, options);
|
|
1375
3200
|
if (result2 && engine) {
|
|
@@ -1383,14 +3208,14 @@ function useSyncedState(key, store) {
|
|
|
1383
3208
|
return [value, syncedSetter, syncState];
|
|
1384
3209
|
}
|
|
1385
3210
|
var useSyncStatus = () => {
|
|
1386
|
-
const [state, setState] = useState({
|
|
3211
|
+
const [state, setState] = (0, import_react.useState)({
|
|
1387
3212
|
isOnline: true,
|
|
1388
3213
|
isSyncing: false,
|
|
1389
3214
|
lastSyncTimestamp: null,
|
|
1390
3215
|
pendingChanges: 0,
|
|
1391
3216
|
conflicts: 0
|
|
1392
3217
|
});
|
|
1393
|
-
useEffect(() => {
|
|
3218
|
+
(0, import_react.useEffect)(() => {
|
|
1394
3219
|
const updateState = () => {
|
|
1395
3220
|
let isOnline = true;
|
|
1396
3221
|
let isSyncing = false;
|
|
@@ -1439,9 +3264,9 @@ var createAsyncStore = (resolver, options) => {
|
|
|
1439
3264
|
store.set(key, { data: null, loading: false, error: null, updatedAt: null });
|
|
1440
3265
|
}
|
|
1441
3266
|
const run = async () => {
|
|
1442
|
-
const
|
|
3267
|
+
const current2 = store.get(key);
|
|
1443
3268
|
store.set(key, {
|
|
1444
|
-
...
|
|
3269
|
+
...current2 || { data: null, loading: false, error: null, updatedAt: null },
|
|
1445
3270
|
loading: true,
|
|
1446
3271
|
error: null
|
|
1447
3272
|
});
|
|
@@ -1911,8 +3736,8 @@ var cloudSyncPlugin = (options) => {
|
|
|
1911
3736
|
store._registerMethod("cloudSync", "getStats", () => stats);
|
|
1912
3737
|
if (autoSyncInterval && autoSyncInterval > 0) {
|
|
1913
3738
|
timer = setInterval(() => {
|
|
1914
|
-
const
|
|
1915
|
-
const cs =
|
|
3739
|
+
const plugins2 = store.plugins;
|
|
3740
|
+
const cs = plugins2.cloudSync;
|
|
1916
3741
|
if (cs) cs.sync();
|
|
1917
3742
|
}, autoSyncInterval);
|
|
1918
3743
|
}
|