@braine/quantum-query 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,1454 +1,3 @@
1
- var __create = Object.create;
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;
7
- var __commonJS = (cb, mod) => function __require() {
8
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
19
- // If the importer is in node compatibility mode or this is not an ESM
20
- // file that has been converted to a CommonJS file using a Babel-
21
- // compatible transform (i.e. "__esModule" has not been set), then set
22
- // "default" to the CommonJS "module.exports" for node compatibility.
23
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24
- mod
25
- ));
26
-
27
- // node_modules/react/cjs/react.production.js
28
- var require_react_production = __commonJS({
29
- "node_modules/react/cjs/react.production.js"(exports) {
30
- "use strict";
31
- var REACT_ELEMENT_TYPE = /* @__PURE__ */ Symbol.for("react.transitional.element");
32
- var REACT_PORTAL_TYPE = /* @__PURE__ */ Symbol.for("react.portal");
33
- var REACT_FRAGMENT_TYPE = /* @__PURE__ */ Symbol.for("react.fragment");
34
- var REACT_STRICT_MODE_TYPE = /* @__PURE__ */ Symbol.for("react.strict_mode");
35
- var REACT_PROFILER_TYPE = /* @__PURE__ */ Symbol.for("react.profiler");
36
- var REACT_CONSUMER_TYPE = /* @__PURE__ */ Symbol.for("react.consumer");
37
- var REACT_CONTEXT_TYPE = /* @__PURE__ */ Symbol.for("react.context");
38
- var REACT_FORWARD_REF_TYPE = /* @__PURE__ */ Symbol.for("react.forward_ref");
39
- var REACT_SUSPENSE_TYPE = /* @__PURE__ */ Symbol.for("react.suspense");
40
- var REACT_MEMO_TYPE = /* @__PURE__ */ Symbol.for("react.memo");
41
- var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
42
- var REACT_ACTIVITY_TYPE = /* @__PURE__ */ Symbol.for("react.activity");
43
- var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
44
- function getIteratorFn(maybeIterable) {
45
- if (null === maybeIterable || "object" !== typeof maybeIterable) return null;
46
- maybeIterable = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable["@@iterator"];
47
- return "function" === typeof maybeIterable ? maybeIterable : null;
48
- }
49
- var ReactNoopUpdateQueue = {
50
- isMounted: function() {
51
- return false;
52
- },
53
- enqueueForceUpdate: function() {
54
- },
55
- enqueueReplaceState: function() {
56
- },
57
- enqueueSetState: function() {
58
- }
59
- };
60
- var assign = Object.assign;
61
- var emptyObject = {};
62
- function Component(props, context, updater) {
63
- this.props = props;
64
- this.context = context;
65
- this.refs = emptyObject;
66
- this.updater = updater || ReactNoopUpdateQueue;
67
- }
68
- Component.prototype.isReactComponent = {};
69
- Component.prototype.setState = function(partialState, callback) {
70
- if ("object" !== typeof partialState && "function" !== typeof partialState && null != partialState)
71
- throw Error(
72
- "takes an object of state variables to update or a function which returns an object of state variables."
73
- );
74
- this.updater.enqueueSetState(this, partialState, callback, "setState");
75
- };
76
- Component.prototype.forceUpdate = function(callback) {
77
- this.updater.enqueueForceUpdate(this, callback, "forceUpdate");
78
- };
79
- function ComponentDummy() {
80
- }
81
- ComponentDummy.prototype = Component.prototype;
82
- function PureComponent(props, context, updater) {
83
- this.props = props;
84
- this.context = context;
85
- this.refs = emptyObject;
86
- this.updater = updater || ReactNoopUpdateQueue;
87
- }
88
- var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();
89
- pureComponentPrototype.constructor = PureComponent;
90
- assign(pureComponentPrototype, Component.prototype);
91
- pureComponentPrototype.isPureReactComponent = true;
92
- var isArrayImpl = Array.isArray;
93
- function noop() {
94
- }
95
- var ReactSharedInternals = { H: null, A: null, T: null, S: null };
96
- var hasOwnProperty = Object.prototype.hasOwnProperty;
97
- function ReactElement(type, key, props) {
98
- var refProp = props.ref;
99
- return {
100
- $$typeof: REACT_ELEMENT_TYPE,
101
- type,
102
- key,
103
- ref: void 0 !== refProp ? refProp : null,
104
- props
105
- };
106
- }
107
- function cloneAndReplaceKey(oldElement, newKey) {
108
- return ReactElement(oldElement.type, newKey, oldElement.props);
109
- }
110
- function isValidElement(object) {
111
- return "object" === typeof object && null !== object && object.$$typeof === REACT_ELEMENT_TYPE;
112
- }
113
- function escape(key) {
114
- var escaperLookup = { "=": "=0", ":": "=2" };
115
- return "$" + key.replace(/[=:]/g, function(match) {
116
- return escaperLookup[match];
117
- });
118
- }
119
- var userProvidedKeyEscapeRegex = /\/+/g;
120
- function getElementKey(element, index) {
121
- return "object" === typeof element && null !== element && null != element.key ? escape("" + element.key) : index.toString(36);
122
- }
123
- function resolveThenable(thenable) {
124
- switch (thenable.status) {
125
- case "fulfilled":
126
- return thenable.value;
127
- case "rejected":
128
- throw thenable.reason;
129
- default:
130
- switch ("string" === typeof thenable.status ? thenable.then(noop, noop) : (thenable.status = "pending", thenable.then(
131
- function(fulfilledValue) {
132
- "pending" === thenable.status && (thenable.status = "fulfilled", thenable.value = fulfilledValue);
133
- },
134
- function(error) {
135
- "pending" === thenable.status && (thenable.status = "rejected", thenable.reason = error);
136
- }
137
- )), thenable.status) {
138
- case "fulfilled":
139
- return thenable.value;
140
- case "rejected":
141
- throw thenable.reason;
142
- }
143
- }
144
- throw thenable;
145
- }
146
- function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
147
- var type = typeof children;
148
- if ("undefined" === type || "boolean" === type) children = null;
149
- var invokeCallback = false;
150
- if (null === children) invokeCallback = true;
151
- else
152
- switch (type) {
153
- case "bigint":
154
- case "string":
155
- case "number":
156
- invokeCallback = true;
157
- break;
158
- case "object":
159
- switch (children.$$typeof) {
160
- case REACT_ELEMENT_TYPE:
161
- case REACT_PORTAL_TYPE:
162
- invokeCallback = true;
163
- break;
164
- case REACT_LAZY_TYPE:
165
- return invokeCallback = children._init, mapIntoArray(
166
- invokeCallback(children._payload),
167
- array,
168
- escapedPrefix,
169
- nameSoFar,
170
- callback
171
- );
172
- }
173
- }
174
- if (invokeCallback)
175
- return callback = callback(children), invokeCallback = "" === nameSoFar ? "." + getElementKey(children, 0) : nameSoFar, isArrayImpl(callback) ? (escapedPrefix = "", null != invokeCallback && (escapedPrefix = invokeCallback.replace(userProvidedKeyEscapeRegex, "$&/") + "/"), mapIntoArray(callback, array, escapedPrefix, "", function(c) {
176
- return c;
177
- })) : null != callback && (isValidElement(callback) && (callback = cloneAndReplaceKey(
178
- callback,
179
- escapedPrefix + (null == callback.key || children && children.key === callback.key ? "" : ("" + callback.key).replace(
180
- userProvidedKeyEscapeRegex,
181
- "$&/"
182
- ) + "/") + invokeCallback
183
- )), array.push(callback)), 1;
184
- invokeCallback = 0;
185
- var nextNamePrefix = "" === nameSoFar ? "." : nameSoFar + ":";
186
- if (isArrayImpl(children))
187
- for (var i = 0; i < children.length; i++)
188
- nameSoFar = children[i], type = nextNamePrefix + getElementKey(nameSoFar, i), invokeCallback += mapIntoArray(
189
- nameSoFar,
190
- array,
191
- escapedPrefix,
192
- type,
193
- callback
194
- );
195
- else if (i = getIteratorFn(children), "function" === typeof i)
196
- for (children = i.call(children), i = 0; !(nameSoFar = children.next()).done; )
197
- nameSoFar = nameSoFar.value, type = nextNamePrefix + getElementKey(nameSoFar, i++), invokeCallback += mapIntoArray(
198
- nameSoFar,
199
- array,
200
- escapedPrefix,
201
- type,
202
- callback
203
- );
204
- else if ("object" === type) {
205
- if ("function" === typeof children.then)
206
- return mapIntoArray(
207
- resolveThenable(children),
208
- array,
209
- escapedPrefix,
210
- nameSoFar,
211
- callback
212
- );
213
- array = String(children);
214
- throw Error(
215
- "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."
216
- );
217
- }
218
- return invokeCallback;
219
- }
220
- function mapChildren(children, func, context) {
221
- if (null == children) return children;
222
- var result = [], count = 0;
223
- mapIntoArray(children, result, "", "", function(child) {
224
- return func.call(context, child, count++);
225
- });
226
- return result;
227
- }
228
- function lazyInitializer(payload) {
229
- if (-1 === payload._status) {
230
- var ctor = payload._result;
231
- ctor = ctor();
232
- ctor.then(
233
- function(moduleObject) {
234
- if (0 === payload._status || -1 === payload._status)
235
- payload._status = 1, payload._result = moduleObject;
236
- },
237
- function(error) {
238
- if (0 === payload._status || -1 === payload._status)
239
- payload._status = 2, payload._result = error;
240
- }
241
- );
242
- -1 === payload._status && (payload._status = 0, payload._result = ctor);
243
- }
244
- if (1 === payload._status) return payload._result.default;
245
- throw payload._result;
246
- }
247
- var reportGlobalError = "function" === typeof reportError ? reportError : function(error) {
248
- if ("object" === typeof window && "function" === typeof window.ErrorEvent) {
249
- var event = new window.ErrorEvent("error", {
250
- bubbles: true,
251
- cancelable: true,
252
- message: "object" === typeof error && null !== error && "string" === typeof error.message ? String(error.message) : String(error),
253
- error
254
- });
255
- if (!window.dispatchEvent(event)) return;
256
- } else if ("object" === typeof process && "function" === typeof process.emit) {
257
- process.emit("uncaughtException", error);
258
- return;
259
- }
260
- console.error(error);
261
- };
262
- var Children = {
263
- map: mapChildren,
264
- forEach: function(children, forEachFunc, forEachContext) {
265
- mapChildren(
266
- children,
267
- function() {
268
- forEachFunc.apply(this, arguments);
269
- },
270
- forEachContext
271
- );
272
- },
273
- count: function(children) {
274
- var n = 0;
275
- mapChildren(children, function() {
276
- n++;
277
- });
278
- return n;
279
- },
280
- toArray: function(children) {
281
- return mapChildren(children, function(child) {
282
- return child;
283
- }) || [];
284
- },
285
- only: function(children) {
286
- if (!isValidElement(children))
287
- throw Error(
288
- "React.Children.only expected to receive a single React element child."
289
- );
290
- return children;
291
- }
292
- };
293
- exports.Activity = REACT_ACTIVITY_TYPE;
294
- exports.Children = Children;
295
- exports.Component = Component;
296
- exports.Fragment = REACT_FRAGMENT_TYPE;
297
- exports.Profiler = REACT_PROFILER_TYPE;
298
- exports.PureComponent = PureComponent;
299
- exports.StrictMode = REACT_STRICT_MODE_TYPE;
300
- exports.Suspense = REACT_SUSPENSE_TYPE;
301
- exports.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = ReactSharedInternals;
302
- exports.__COMPILER_RUNTIME = {
303
- __proto__: null,
304
- c: function(size) {
305
- return ReactSharedInternals.H.useMemoCache(size);
306
- }
307
- };
308
- exports.cache = function(fn) {
309
- return function() {
310
- return fn.apply(null, arguments);
311
- };
312
- };
313
- exports.cacheSignal = function() {
314
- return null;
315
- };
316
- exports.cloneElement = function(element, config, children) {
317
- if (null === element || void 0 === element)
318
- throw Error(
319
- "The argument must be a React element, but you passed " + element + "."
320
- );
321
- var props = assign({}, element.props), key = element.key;
322
- if (null != config)
323
- for (propName in void 0 !== config.key && (key = "" + config.key), config)
324
- !hasOwnProperty.call(config, propName) || "key" === propName || "__self" === propName || "__source" === propName || "ref" === propName && void 0 === config.ref || (props[propName] = config[propName]);
325
- var propName = arguments.length - 2;
326
- if (1 === propName) props.children = children;
327
- else if (1 < propName) {
328
- for (var childArray = Array(propName), i = 0; i < propName; i++)
329
- childArray[i] = arguments[i + 2];
330
- props.children = childArray;
331
- }
332
- return ReactElement(element.type, key, props);
333
- };
334
- exports.createContext = function(defaultValue) {
335
- defaultValue = {
336
- $$typeof: REACT_CONTEXT_TYPE,
337
- _currentValue: defaultValue,
338
- _currentValue2: defaultValue,
339
- _threadCount: 0,
340
- Provider: null,
341
- Consumer: null
342
- };
343
- defaultValue.Provider = defaultValue;
344
- defaultValue.Consumer = {
345
- $$typeof: REACT_CONSUMER_TYPE,
346
- _context: defaultValue
347
- };
348
- return defaultValue;
349
- };
350
- exports.createElement = function(type, config, children) {
351
- var propName, props = {}, key = null;
352
- if (null != config)
353
- for (propName in void 0 !== config.key && (key = "" + config.key), config)
354
- hasOwnProperty.call(config, propName) && "key" !== propName && "__self" !== propName && "__source" !== propName && (props[propName] = config[propName]);
355
- var childrenLength = arguments.length - 2;
356
- if (1 === childrenLength) props.children = children;
357
- else if (1 < childrenLength) {
358
- for (var childArray = Array(childrenLength), i = 0; i < childrenLength; i++)
359
- childArray[i] = arguments[i + 2];
360
- props.children = childArray;
361
- }
362
- if (type && type.defaultProps)
363
- for (propName in childrenLength = type.defaultProps, childrenLength)
364
- void 0 === props[propName] && (props[propName] = childrenLength[propName]);
365
- return ReactElement(type, key, props);
366
- };
367
- exports.createRef = function() {
368
- return { current: null };
369
- };
370
- exports.forwardRef = function(render) {
371
- return { $$typeof: REACT_FORWARD_REF_TYPE, render };
372
- };
373
- exports.isValidElement = isValidElement;
374
- exports.lazy = function(ctor) {
375
- return {
376
- $$typeof: REACT_LAZY_TYPE,
377
- _payload: { _status: -1, _result: ctor },
378
- _init: lazyInitializer
379
- };
380
- };
381
- exports.memo = function(type, compare) {
382
- return {
383
- $$typeof: REACT_MEMO_TYPE,
384
- type,
385
- compare: void 0 === compare ? null : compare
386
- };
387
- };
388
- exports.startTransition = function(scope) {
389
- var prevTransition = ReactSharedInternals.T, currentTransition = {};
390
- ReactSharedInternals.T = currentTransition;
391
- try {
392
- var returnValue = scope(), onStartTransitionFinish = ReactSharedInternals.S;
393
- null !== onStartTransitionFinish && onStartTransitionFinish(currentTransition, returnValue);
394
- "object" === typeof returnValue && null !== returnValue && "function" === typeof returnValue.then && returnValue.then(noop, reportGlobalError);
395
- } catch (error) {
396
- reportGlobalError(error);
397
- } finally {
398
- null !== prevTransition && null !== currentTransition.types && (prevTransition.types = currentTransition.types), ReactSharedInternals.T = prevTransition;
399
- }
400
- };
401
- exports.unstable_useCacheRefresh = function() {
402
- return ReactSharedInternals.H.useCacheRefresh();
403
- };
404
- exports.use = function(usable) {
405
- return ReactSharedInternals.H.use(usable);
406
- };
407
- exports.useActionState = function(action, initialState, permalink) {
408
- return ReactSharedInternals.H.useActionState(action, initialState, permalink);
409
- };
410
- exports.useCallback = function(callback, deps) {
411
- return ReactSharedInternals.H.useCallback(callback, deps);
412
- };
413
- exports.useContext = function(Context) {
414
- return ReactSharedInternals.H.useContext(Context);
415
- };
416
- exports.useDebugValue = function() {
417
- };
418
- exports.useDeferredValue = function(value, initialValue) {
419
- return ReactSharedInternals.H.useDeferredValue(value, initialValue);
420
- };
421
- exports.useEffect = function(create, deps) {
422
- return ReactSharedInternals.H.useEffect(create, deps);
423
- };
424
- exports.useEffectEvent = function(callback) {
425
- return ReactSharedInternals.H.useEffectEvent(callback);
426
- };
427
- exports.useId = function() {
428
- return ReactSharedInternals.H.useId();
429
- };
430
- exports.useImperativeHandle = function(ref, create, deps) {
431
- return ReactSharedInternals.H.useImperativeHandle(ref, create, deps);
432
- };
433
- exports.useInsertionEffect = function(create, deps) {
434
- return ReactSharedInternals.H.useInsertionEffect(create, deps);
435
- };
436
- exports.useLayoutEffect = function(create, deps) {
437
- return ReactSharedInternals.H.useLayoutEffect(create, deps);
438
- };
439
- exports.useMemo = function(create, deps) {
440
- return ReactSharedInternals.H.useMemo(create, deps);
441
- };
442
- exports.useOptimistic = function(passthrough, reducer) {
443
- return ReactSharedInternals.H.useOptimistic(passthrough, reducer);
444
- };
445
- exports.useReducer = function(reducer, initialArg, init) {
446
- return ReactSharedInternals.H.useReducer(reducer, initialArg, init);
447
- };
448
- exports.useRef = function(initialValue) {
449
- return ReactSharedInternals.H.useRef(initialValue);
450
- };
451
- exports.useState = function(initialState) {
452
- return ReactSharedInternals.H.useState(initialState);
453
- };
454
- exports.useSyncExternalStore = function(subscribe2, getSnapshot, getServerSnapshot) {
455
- return ReactSharedInternals.H.useSyncExternalStore(
456
- subscribe2,
457
- getSnapshot,
458
- getServerSnapshot
459
- );
460
- };
461
- exports.useTransition = function() {
462
- return ReactSharedInternals.H.useTransition();
463
- };
464
- exports.version = "19.2.3";
465
- }
466
- });
467
-
468
- // node_modules/react/cjs/react.development.js
469
- var require_react_development = __commonJS({
470
- "node_modules/react/cjs/react.development.js"(exports, module) {
471
- "use strict";
472
- "production" !== process.env.NODE_ENV && (function() {
473
- function defineDeprecationWarning(methodName, info) {
474
- Object.defineProperty(Component.prototype, methodName, {
475
- get: function() {
476
- console.warn(
477
- "%s(...) is deprecated in plain JavaScript React classes. %s",
478
- info[0],
479
- info[1]
480
- );
481
- }
482
- });
483
- }
484
- function getIteratorFn(maybeIterable) {
485
- if (null === maybeIterable || "object" !== typeof maybeIterable)
486
- return null;
487
- maybeIterable = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable["@@iterator"];
488
- return "function" === typeof maybeIterable ? maybeIterable : null;
489
- }
490
- function warnNoop(publicInstance, callerName) {
491
- publicInstance = (publicInstance = publicInstance.constructor) && (publicInstance.displayName || publicInstance.name) || "ReactClass";
492
- var warningKey = publicInstance + "." + callerName;
493
- didWarnStateUpdateForUnmountedComponent[warningKey] || (console.error(
494
- "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.",
495
- callerName,
496
- publicInstance
497
- ), didWarnStateUpdateForUnmountedComponent[warningKey] = true);
498
- }
499
- function Component(props, context, updater) {
500
- this.props = props;
501
- this.context = context;
502
- this.refs = emptyObject;
503
- this.updater = updater || ReactNoopUpdateQueue;
504
- }
505
- function ComponentDummy() {
506
- }
507
- function PureComponent(props, context, updater) {
508
- this.props = props;
509
- this.context = context;
510
- this.refs = emptyObject;
511
- this.updater = updater || ReactNoopUpdateQueue;
512
- }
513
- function noop() {
514
- }
515
- function testStringCoercion(value) {
516
- return "" + value;
517
- }
518
- function checkKeyStringCoercion(value) {
519
- try {
520
- testStringCoercion(value);
521
- var JSCompiler_inline_result = false;
522
- } catch (e) {
523
- JSCompiler_inline_result = true;
524
- }
525
- if (JSCompiler_inline_result) {
526
- JSCompiler_inline_result = console;
527
- var JSCompiler_temp_const = JSCompiler_inline_result.error;
528
- var JSCompiler_inline_result$jscomp$0 = "function" === typeof Symbol && Symbol.toStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
529
- JSCompiler_temp_const.call(
530
- JSCompiler_inline_result,
531
- "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
532
- JSCompiler_inline_result$jscomp$0
533
- );
534
- return testStringCoercion(value);
535
- }
536
- }
537
- function getComponentNameFromType(type) {
538
- if (null == type) return null;
539
- if ("function" === typeof type)
540
- return type.$$typeof === REACT_CLIENT_REFERENCE ? null : type.displayName || type.name || null;
541
- if ("string" === typeof type) return type;
542
- switch (type) {
543
- case REACT_FRAGMENT_TYPE:
544
- return "Fragment";
545
- case REACT_PROFILER_TYPE:
546
- return "Profiler";
547
- case REACT_STRICT_MODE_TYPE:
548
- return "StrictMode";
549
- case REACT_SUSPENSE_TYPE:
550
- return "Suspense";
551
- case REACT_SUSPENSE_LIST_TYPE:
552
- return "SuspenseList";
553
- case REACT_ACTIVITY_TYPE:
554
- return "Activity";
555
- }
556
- if ("object" === typeof type)
557
- switch ("number" === typeof type.tag && console.error(
558
- "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
559
- ), type.$$typeof) {
560
- case REACT_PORTAL_TYPE:
561
- return "Portal";
562
- case REACT_CONTEXT_TYPE:
563
- return type.displayName || "Context";
564
- case REACT_CONSUMER_TYPE:
565
- return (type._context.displayName || "Context") + ".Consumer";
566
- case REACT_FORWARD_REF_TYPE:
567
- var innerType = type.render;
568
- type = type.displayName;
569
- type || (type = innerType.displayName || innerType.name || "", type = "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef");
570
- return type;
571
- case REACT_MEMO_TYPE:
572
- return innerType = type.displayName || null, null !== innerType ? innerType : getComponentNameFromType(type.type) || "Memo";
573
- case REACT_LAZY_TYPE:
574
- innerType = type._payload;
575
- type = type._init;
576
- try {
577
- return getComponentNameFromType(type(innerType));
578
- } catch (x) {
579
- }
580
- }
581
- return null;
582
- }
583
- function getTaskName(type) {
584
- if (type === REACT_FRAGMENT_TYPE) return "<>";
585
- if ("object" === typeof type && null !== type && type.$$typeof === REACT_LAZY_TYPE)
586
- return "<...>";
587
- try {
588
- var name = getComponentNameFromType(type);
589
- return name ? "<" + name + ">" : "<...>";
590
- } catch (x) {
591
- return "<...>";
592
- }
593
- }
594
- function getOwner() {
595
- var dispatcher = ReactSharedInternals.A;
596
- return null === dispatcher ? null : dispatcher.getOwner();
597
- }
598
- function UnknownOwner() {
599
- return Error("react-stack-top-frame");
600
- }
601
- function hasValidKey(config) {
602
- if (hasOwnProperty.call(config, "key")) {
603
- var getter = Object.getOwnPropertyDescriptor(config, "key").get;
604
- if (getter && getter.isReactWarning) return false;
605
- }
606
- return void 0 !== config.key;
607
- }
608
- function defineKeyPropWarningGetter(props, displayName) {
609
- function warnAboutAccessingKey() {
610
- specialPropKeyWarningShown || (specialPropKeyWarningShown = true, console.error(
611
- "%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)",
612
- displayName
613
- ));
614
- }
615
- warnAboutAccessingKey.isReactWarning = true;
616
- Object.defineProperty(props, "key", {
617
- get: warnAboutAccessingKey,
618
- configurable: true
619
- });
620
- }
621
- function elementRefGetterWithDeprecationWarning() {
622
- var componentName = getComponentNameFromType(this.type);
623
- didWarnAboutElementRef[componentName] || (didWarnAboutElementRef[componentName] = true, console.error(
624
- "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."
625
- ));
626
- componentName = this.props.ref;
627
- return void 0 !== componentName ? componentName : null;
628
- }
629
- function ReactElement(type, key, props, owner, debugStack, debugTask) {
630
- var refProp = props.ref;
631
- type = {
632
- $$typeof: REACT_ELEMENT_TYPE,
633
- type,
634
- key,
635
- props,
636
- _owner: owner
637
- };
638
- null !== (void 0 !== refProp ? refProp : null) ? Object.defineProperty(type, "ref", {
639
- enumerable: false,
640
- get: elementRefGetterWithDeprecationWarning
641
- }) : Object.defineProperty(type, "ref", { enumerable: false, value: null });
642
- type._store = {};
643
- Object.defineProperty(type._store, "validated", {
644
- configurable: false,
645
- enumerable: false,
646
- writable: true,
647
- value: 0
648
- });
649
- Object.defineProperty(type, "_debugInfo", {
650
- configurable: false,
651
- enumerable: false,
652
- writable: true,
653
- value: null
654
- });
655
- Object.defineProperty(type, "_debugStack", {
656
- configurable: false,
657
- enumerable: false,
658
- writable: true,
659
- value: debugStack
660
- });
661
- Object.defineProperty(type, "_debugTask", {
662
- configurable: false,
663
- enumerable: false,
664
- writable: true,
665
- value: debugTask
666
- });
667
- Object.freeze && (Object.freeze(type.props), Object.freeze(type));
668
- return type;
669
- }
670
- function cloneAndReplaceKey(oldElement, newKey) {
671
- newKey = ReactElement(
672
- oldElement.type,
673
- newKey,
674
- oldElement.props,
675
- oldElement._owner,
676
- oldElement._debugStack,
677
- oldElement._debugTask
678
- );
679
- oldElement._store && (newKey._store.validated = oldElement._store.validated);
680
- return newKey;
681
- }
682
- function validateChildKeys(node) {
683
- 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));
684
- }
685
- function isValidElement(object) {
686
- return "object" === typeof object && null !== object && object.$$typeof === REACT_ELEMENT_TYPE;
687
- }
688
- function escape(key) {
689
- var escaperLookup = { "=": "=0", ":": "=2" };
690
- return "$" + key.replace(/[=:]/g, function(match) {
691
- return escaperLookup[match];
692
- });
693
- }
694
- function getElementKey(element, index) {
695
- return "object" === typeof element && null !== element && null != element.key ? (checkKeyStringCoercion(element.key), escape("" + element.key)) : index.toString(36);
696
- }
697
- function resolveThenable(thenable) {
698
- switch (thenable.status) {
699
- case "fulfilled":
700
- return thenable.value;
701
- case "rejected":
702
- throw thenable.reason;
703
- default:
704
- switch ("string" === typeof thenable.status ? thenable.then(noop, noop) : (thenable.status = "pending", thenable.then(
705
- function(fulfilledValue) {
706
- "pending" === thenable.status && (thenable.status = "fulfilled", thenable.value = fulfilledValue);
707
- },
708
- function(error) {
709
- "pending" === thenable.status && (thenable.status = "rejected", thenable.reason = error);
710
- }
711
- )), thenable.status) {
712
- case "fulfilled":
713
- return thenable.value;
714
- case "rejected":
715
- throw thenable.reason;
716
- }
717
- }
718
- throw thenable;
719
- }
720
- function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
721
- var type = typeof children;
722
- if ("undefined" === type || "boolean" === type) children = null;
723
- var invokeCallback = false;
724
- if (null === children) invokeCallback = true;
725
- else
726
- switch (type) {
727
- case "bigint":
728
- case "string":
729
- case "number":
730
- invokeCallback = true;
731
- break;
732
- case "object":
733
- switch (children.$$typeof) {
734
- case REACT_ELEMENT_TYPE:
735
- case REACT_PORTAL_TYPE:
736
- invokeCallback = true;
737
- break;
738
- case REACT_LAZY_TYPE:
739
- return invokeCallback = children._init, mapIntoArray(
740
- invokeCallback(children._payload),
741
- array,
742
- escapedPrefix,
743
- nameSoFar,
744
- callback
745
- );
746
- }
747
- }
748
- if (invokeCallback) {
749
- invokeCallback = children;
750
- callback = callback(invokeCallback);
751
- var childKey = "" === nameSoFar ? "." + getElementKey(invokeCallback, 0) : nameSoFar;
752
- isArrayImpl(callback) ? (escapedPrefix = "", null != childKey && (escapedPrefix = childKey.replace(userProvidedKeyEscapeRegex, "$&/") + "/"), mapIntoArray(callback, array, escapedPrefix, "", function(c) {
753
- return c;
754
- })) : null != callback && (isValidElement(callback) && (null != callback.key && (invokeCallback && invokeCallback.key === callback.key || checkKeyStringCoercion(callback.key)), escapedPrefix = cloneAndReplaceKey(
755
- callback,
756
- escapedPrefix + (null == callback.key || invokeCallback && invokeCallback.key === callback.key ? "" : ("" + callback.key).replace(
757
- userProvidedKeyEscapeRegex,
758
- "$&/"
759
- ) + "/") + childKey
760
- ), "" !== nameSoFar && null != invokeCallback && isValidElement(invokeCallback) && null == invokeCallback.key && invokeCallback._store && !invokeCallback._store.validated && (escapedPrefix._store.validated = 2), callback = escapedPrefix), array.push(callback));
761
- return 1;
762
- }
763
- invokeCallback = 0;
764
- childKey = "" === nameSoFar ? "." : nameSoFar + ":";
765
- if (isArrayImpl(children))
766
- for (var i = 0; i < children.length; i++)
767
- nameSoFar = children[i], type = childKey + getElementKey(nameSoFar, i), invokeCallback += mapIntoArray(
768
- nameSoFar,
769
- array,
770
- escapedPrefix,
771
- type,
772
- callback
773
- );
774
- else if (i = getIteratorFn(children), "function" === typeof i)
775
- for (i === children.entries && (didWarnAboutMaps || console.warn(
776
- "Using Maps as children is not supported. Use an array of keyed ReactElements instead."
777
- ), didWarnAboutMaps = true), children = i.call(children), i = 0; !(nameSoFar = children.next()).done; )
778
- nameSoFar = nameSoFar.value, type = childKey + getElementKey(nameSoFar, i++), invokeCallback += mapIntoArray(
779
- nameSoFar,
780
- array,
781
- escapedPrefix,
782
- type,
783
- callback
784
- );
785
- else if ("object" === type) {
786
- if ("function" === typeof children.then)
787
- return mapIntoArray(
788
- resolveThenable(children),
789
- array,
790
- escapedPrefix,
791
- nameSoFar,
792
- callback
793
- );
794
- array = String(children);
795
- throw Error(
796
- "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."
797
- );
798
- }
799
- return invokeCallback;
800
- }
801
- function mapChildren(children, func, context) {
802
- if (null == children) return children;
803
- var result = [], count = 0;
804
- mapIntoArray(children, result, "", "", function(child) {
805
- return func.call(context, child, count++);
806
- });
807
- return result;
808
- }
809
- function lazyInitializer(payload) {
810
- if (-1 === payload._status) {
811
- var ioInfo = payload._ioInfo;
812
- null != ioInfo && (ioInfo.start = ioInfo.end = performance.now());
813
- ioInfo = payload._result;
814
- var thenable = ioInfo();
815
- thenable.then(
816
- function(moduleObject) {
817
- if (0 === payload._status || -1 === payload._status) {
818
- payload._status = 1;
819
- payload._result = moduleObject;
820
- var _ioInfo = payload._ioInfo;
821
- null != _ioInfo && (_ioInfo.end = performance.now());
822
- void 0 === thenable.status && (thenable.status = "fulfilled", thenable.value = moduleObject);
823
- }
824
- },
825
- function(error) {
826
- if (0 === payload._status || -1 === payload._status) {
827
- payload._status = 2;
828
- payload._result = error;
829
- var _ioInfo2 = payload._ioInfo;
830
- null != _ioInfo2 && (_ioInfo2.end = performance.now());
831
- void 0 === thenable.status && (thenable.status = "rejected", thenable.reason = error);
832
- }
833
- }
834
- );
835
- ioInfo = payload._ioInfo;
836
- if (null != ioInfo) {
837
- ioInfo.value = thenable;
838
- var displayName = thenable.displayName;
839
- "string" === typeof displayName && (ioInfo.name = displayName);
840
- }
841
- -1 === payload._status && (payload._status = 0, payload._result = thenable);
842
- }
843
- if (1 === payload._status)
844
- return ioInfo = payload._result, void 0 === ioInfo && console.error(
845
- "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?",
846
- ioInfo
847
- ), "default" in ioInfo || console.error(
848
- "lazy: Expected the result of a dynamic import() call. Instead received: %s\n\nYour code should look like: \n const MyComponent = lazy(() => import('./MyComponent'))",
849
- ioInfo
850
- ), ioInfo.default;
851
- throw payload._result;
852
- }
853
- function resolveDispatcher() {
854
- var dispatcher = ReactSharedInternals.H;
855
- null === dispatcher && console.error(
856
- "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."
857
- );
858
- return dispatcher;
859
- }
860
- function releaseAsyncTransition() {
861
- ReactSharedInternals.asyncTransitions--;
862
- }
863
- function enqueueTask(task) {
864
- if (null === enqueueTaskImpl)
865
- try {
866
- var requireString = ("require" + Math.random()).slice(0, 7);
867
- enqueueTaskImpl = (module && module[requireString]).call(
868
- module,
869
- "timers"
870
- ).setImmediate;
871
- } catch (_err) {
872
- enqueueTaskImpl = function(callback) {
873
- false === didWarnAboutMessageChannel && (didWarnAboutMessageChannel = true, "undefined" === typeof MessageChannel && console.error(
874
- "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."
875
- ));
876
- var channel = new MessageChannel();
877
- channel.port1.onmessage = callback;
878
- channel.port2.postMessage(void 0);
879
- };
880
- }
881
- return enqueueTaskImpl(task);
882
- }
883
- function aggregateErrors(errors) {
884
- return 1 < errors.length && "function" === typeof AggregateError ? new AggregateError(errors) : errors[0];
885
- }
886
- function popActScope(prevActQueue, prevActScopeDepth) {
887
- prevActScopeDepth !== actScopeDepth - 1 && console.error(
888
- "You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one. "
889
- );
890
- actScopeDepth = prevActScopeDepth;
891
- }
892
- function recursivelyFlushAsyncActWork(returnValue, resolve, reject) {
893
- var queue = ReactSharedInternals.actQueue;
894
- if (null !== queue)
895
- if (0 !== queue.length)
896
- try {
897
- flushActQueue(queue);
898
- enqueueTask(function() {
899
- return recursivelyFlushAsyncActWork(returnValue, resolve, reject);
900
- });
901
- return;
902
- } catch (error) {
903
- ReactSharedInternals.thrownErrors.push(error);
904
- }
905
- else ReactSharedInternals.actQueue = null;
906
- 0 < ReactSharedInternals.thrownErrors.length ? (queue = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, reject(queue)) : resolve(returnValue);
907
- }
908
- function flushActQueue(queue) {
909
- if (!isFlushing) {
910
- isFlushing = true;
911
- var i = 0;
912
- try {
913
- for (; i < queue.length; i++) {
914
- var callback = queue[i];
915
- do {
916
- ReactSharedInternals.didUsePromise = false;
917
- var continuation = callback(false);
918
- if (null !== continuation) {
919
- if (ReactSharedInternals.didUsePromise) {
920
- queue[i] = callback;
921
- queue.splice(0, i);
922
- return;
923
- }
924
- callback = continuation;
925
- } else break;
926
- } while (1);
927
- }
928
- queue.length = 0;
929
- } catch (error) {
930
- queue.splice(0, i + 1), ReactSharedInternals.thrownErrors.push(error);
931
- } finally {
932
- isFlushing = false;
933
- }
934
- }
935
- }
936
- "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
937
- 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 = {
938
- isMounted: function() {
939
- return false;
940
- },
941
- enqueueForceUpdate: function(publicInstance) {
942
- warnNoop(publicInstance, "forceUpdate");
943
- },
944
- enqueueReplaceState: function(publicInstance) {
945
- warnNoop(publicInstance, "replaceState");
946
- },
947
- enqueueSetState: function(publicInstance) {
948
- warnNoop(publicInstance, "setState");
949
- }
950
- }, assign = Object.assign, emptyObject = {};
951
- Object.freeze(emptyObject);
952
- Component.prototype.isReactComponent = {};
953
- Component.prototype.setState = function(partialState, callback) {
954
- if ("object" !== typeof partialState && "function" !== typeof partialState && null != partialState)
955
- throw Error(
956
- "takes an object of state variables to update or a function which returns an object of state variables."
957
- );
958
- this.updater.enqueueSetState(this, partialState, callback, "setState");
959
- };
960
- Component.prototype.forceUpdate = function(callback) {
961
- this.updater.enqueueForceUpdate(this, callback, "forceUpdate");
962
- };
963
- var deprecatedAPIs = {
964
- isMounted: [
965
- "isMounted",
966
- "Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks."
967
- ],
968
- replaceState: [
969
- "replaceState",
970
- "Refactor your code to use setState instead (see https://github.com/facebook/react/issues/3236)."
971
- ]
972
- };
973
- for (fnName in deprecatedAPIs)
974
- deprecatedAPIs.hasOwnProperty(fnName) && defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
975
- ComponentDummy.prototype = Component.prototype;
976
- deprecatedAPIs = PureComponent.prototype = new ComponentDummy();
977
- deprecatedAPIs.constructor = PureComponent;
978
- assign(deprecatedAPIs, Component.prototype);
979
- deprecatedAPIs.isPureReactComponent = true;
980
- var isArrayImpl = Array.isArray, REACT_CLIENT_REFERENCE = /* @__PURE__ */ Symbol.for("react.client.reference"), ReactSharedInternals = {
981
- H: null,
982
- A: null,
983
- T: null,
984
- S: null,
985
- actQueue: null,
986
- asyncTransitions: 0,
987
- isBatchingLegacy: false,
988
- didScheduleLegacyUpdate: false,
989
- didUsePromise: false,
990
- thrownErrors: [],
991
- getCurrentStack: null,
992
- recentlyCreatedOwnerStacks: 0
993
- }, hasOwnProperty = Object.prototype.hasOwnProperty, createTask = console.createTask ? console.createTask : function() {
994
- return null;
995
- };
996
- deprecatedAPIs = {
997
- react_stack_bottom_frame: function(callStackForError) {
998
- return callStackForError();
999
- }
1000
- };
1001
- var specialPropKeyWarningShown, didWarnAboutOldJSXRuntime;
1002
- var didWarnAboutElementRef = {};
1003
- var unknownOwnerDebugStack = deprecatedAPIs.react_stack_bottom_frame.bind(
1004
- deprecatedAPIs,
1005
- UnknownOwner
1006
- )();
1007
- var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
1008
- var didWarnAboutMaps = false, userProvidedKeyEscapeRegex = /\/+/g, reportGlobalError = "function" === typeof reportError ? reportError : function(error) {
1009
- if ("object" === typeof window && "function" === typeof window.ErrorEvent) {
1010
- var event = new window.ErrorEvent("error", {
1011
- bubbles: true,
1012
- cancelable: true,
1013
- message: "object" === typeof error && null !== error && "string" === typeof error.message ? String(error.message) : String(error),
1014
- error
1015
- });
1016
- if (!window.dispatchEvent(event)) return;
1017
- } else if ("object" === typeof process && "function" === typeof process.emit) {
1018
- process.emit("uncaughtException", error);
1019
- return;
1020
- }
1021
- console.error(error);
1022
- }, didWarnAboutMessageChannel = false, enqueueTaskImpl = null, actScopeDepth = 0, didWarnNoAwaitAct = false, isFlushing = false, queueSeveralMicrotasks = "function" === typeof queueMicrotask ? function(callback) {
1023
- queueMicrotask(function() {
1024
- return queueMicrotask(callback);
1025
- });
1026
- } : enqueueTask;
1027
- deprecatedAPIs = Object.freeze({
1028
- __proto__: null,
1029
- c: function(size) {
1030
- return resolveDispatcher().useMemoCache(size);
1031
- }
1032
- });
1033
- var fnName = {
1034
- map: mapChildren,
1035
- forEach: function(children, forEachFunc, forEachContext) {
1036
- mapChildren(
1037
- children,
1038
- function() {
1039
- forEachFunc.apply(this, arguments);
1040
- },
1041
- forEachContext
1042
- );
1043
- },
1044
- count: function(children) {
1045
- var n = 0;
1046
- mapChildren(children, function() {
1047
- n++;
1048
- });
1049
- return n;
1050
- },
1051
- toArray: function(children) {
1052
- return mapChildren(children, function(child) {
1053
- return child;
1054
- }) || [];
1055
- },
1056
- only: function(children) {
1057
- if (!isValidElement(children))
1058
- throw Error(
1059
- "React.Children.only expected to receive a single React element child."
1060
- );
1061
- return children;
1062
- }
1063
- };
1064
- exports.Activity = REACT_ACTIVITY_TYPE;
1065
- exports.Children = fnName;
1066
- exports.Component = Component;
1067
- exports.Fragment = REACT_FRAGMENT_TYPE;
1068
- exports.Profiler = REACT_PROFILER_TYPE;
1069
- exports.PureComponent = PureComponent;
1070
- exports.StrictMode = REACT_STRICT_MODE_TYPE;
1071
- exports.Suspense = REACT_SUSPENSE_TYPE;
1072
- exports.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = ReactSharedInternals;
1073
- exports.__COMPILER_RUNTIME = deprecatedAPIs;
1074
- exports.act = function(callback) {
1075
- var prevActQueue = ReactSharedInternals.actQueue, prevActScopeDepth = actScopeDepth;
1076
- actScopeDepth++;
1077
- var queue = ReactSharedInternals.actQueue = null !== prevActQueue ? prevActQueue : [], didAwaitActCall = false;
1078
- try {
1079
- var result = callback();
1080
- } catch (error) {
1081
- ReactSharedInternals.thrownErrors.push(error);
1082
- }
1083
- if (0 < ReactSharedInternals.thrownErrors.length)
1084
- throw popActScope(prevActQueue, prevActScopeDepth), callback = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, callback;
1085
- if (null !== result && "object" === typeof result && "function" === typeof result.then) {
1086
- var thenable = result;
1087
- queueSeveralMicrotasks(function() {
1088
- didAwaitActCall || didWarnNoAwaitAct || (didWarnNoAwaitAct = true, console.error(
1089
- "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 () => ...);"
1090
- ));
1091
- });
1092
- return {
1093
- then: function(resolve, reject) {
1094
- didAwaitActCall = true;
1095
- thenable.then(
1096
- function(returnValue) {
1097
- popActScope(prevActQueue, prevActScopeDepth);
1098
- if (0 === prevActScopeDepth) {
1099
- try {
1100
- flushActQueue(queue), enqueueTask(function() {
1101
- return recursivelyFlushAsyncActWork(
1102
- returnValue,
1103
- resolve,
1104
- reject
1105
- );
1106
- });
1107
- } catch (error$0) {
1108
- ReactSharedInternals.thrownErrors.push(error$0);
1109
- }
1110
- if (0 < ReactSharedInternals.thrownErrors.length) {
1111
- var _thrownError = aggregateErrors(
1112
- ReactSharedInternals.thrownErrors
1113
- );
1114
- ReactSharedInternals.thrownErrors.length = 0;
1115
- reject(_thrownError);
1116
- }
1117
- } else resolve(returnValue);
1118
- },
1119
- function(error) {
1120
- popActScope(prevActQueue, prevActScopeDepth);
1121
- 0 < ReactSharedInternals.thrownErrors.length ? (error = aggregateErrors(
1122
- ReactSharedInternals.thrownErrors
1123
- ), ReactSharedInternals.thrownErrors.length = 0, reject(error)) : reject(error);
1124
- }
1125
- );
1126
- }
1127
- };
1128
- }
1129
- var returnValue$jscomp$0 = result;
1130
- popActScope(prevActQueue, prevActScopeDepth);
1131
- 0 === prevActScopeDepth && (flushActQueue(queue), 0 !== queue.length && queueSeveralMicrotasks(function() {
1132
- didAwaitActCall || didWarnNoAwaitAct || (didWarnNoAwaitAct = true, console.error(
1133
- "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(() => ...)"
1134
- ));
1135
- }), ReactSharedInternals.actQueue = null);
1136
- if (0 < ReactSharedInternals.thrownErrors.length)
1137
- throw callback = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, callback;
1138
- return {
1139
- then: function(resolve, reject) {
1140
- didAwaitActCall = true;
1141
- 0 === prevActScopeDepth ? (ReactSharedInternals.actQueue = queue, enqueueTask(function() {
1142
- return recursivelyFlushAsyncActWork(
1143
- returnValue$jscomp$0,
1144
- resolve,
1145
- reject
1146
- );
1147
- })) : resolve(returnValue$jscomp$0);
1148
- }
1149
- };
1150
- };
1151
- exports.cache = function(fn) {
1152
- return function() {
1153
- return fn.apply(null, arguments);
1154
- };
1155
- };
1156
- exports.cacheSignal = function() {
1157
- return null;
1158
- };
1159
- exports.captureOwnerStack = function() {
1160
- var getCurrentStack = ReactSharedInternals.getCurrentStack;
1161
- return null === getCurrentStack ? null : getCurrentStack();
1162
- };
1163
- exports.cloneElement = function(element, config, children) {
1164
- if (null === element || void 0 === element)
1165
- throw Error(
1166
- "The argument must be a React element, but you passed " + element + "."
1167
- );
1168
- var props = assign({}, element.props), key = element.key, owner = element._owner;
1169
- if (null != config) {
1170
- var JSCompiler_inline_result;
1171
- a: {
1172
- if (hasOwnProperty.call(config, "ref") && (JSCompiler_inline_result = Object.getOwnPropertyDescriptor(
1173
- config,
1174
- "ref"
1175
- ).get) && JSCompiler_inline_result.isReactWarning) {
1176
- JSCompiler_inline_result = false;
1177
- break a;
1178
- }
1179
- JSCompiler_inline_result = void 0 !== config.ref;
1180
- }
1181
- JSCompiler_inline_result && (owner = getOwner());
1182
- hasValidKey(config) && (checkKeyStringCoercion(config.key), key = "" + config.key);
1183
- for (propName in config)
1184
- !hasOwnProperty.call(config, propName) || "key" === propName || "__self" === propName || "__source" === propName || "ref" === propName && void 0 === config.ref || (props[propName] = config[propName]);
1185
- }
1186
- var propName = arguments.length - 2;
1187
- if (1 === propName) props.children = children;
1188
- else if (1 < propName) {
1189
- JSCompiler_inline_result = Array(propName);
1190
- for (var i = 0; i < propName; i++)
1191
- JSCompiler_inline_result[i] = arguments[i + 2];
1192
- props.children = JSCompiler_inline_result;
1193
- }
1194
- props = ReactElement(
1195
- element.type,
1196
- key,
1197
- props,
1198
- owner,
1199
- element._debugStack,
1200
- element._debugTask
1201
- );
1202
- for (key = 2; key < arguments.length; key++)
1203
- validateChildKeys(arguments[key]);
1204
- return props;
1205
- };
1206
- exports.createContext = function(defaultValue) {
1207
- defaultValue = {
1208
- $$typeof: REACT_CONTEXT_TYPE,
1209
- _currentValue: defaultValue,
1210
- _currentValue2: defaultValue,
1211
- _threadCount: 0,
1212
- Provider: null,
1213
- Consumer: null
1214
- };
1215
- defaultValue.Provider = defaultValue;
1216
- defaultValue.Consumer = {
1217
- $$typeof: REACT_CONSUMER_TYPE,
1218
- _context: defaultValue
1219
- };
1220
- defaultValue._currentRenderer = null;
1221
- defaultValue._currentRenderer2 = null;
1222
- return defaultValue;
1223
- };
1224
- exports.createElement = function(type, config, children) {
1225
- for (var i = 2; i < arguments.length; i++)
1226
- validateChildKeys(arguments[i]);
1227
- i = {};
1228
- var key = null;
1229
- if (null != config)
1230
- for (propName in didWarnAboutOldJSXRuntime || !("__self" in config) || "key" in config || (didWarnAboutOldJSXRuntime = true, console.warn(
1231
- "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"
1232
- )), hasValidKey(config) && (checkKeyStringCoercion(config.key), key = "" + config.key), config)
1233
- hasOwnProperty.call(config, propName) && "key" !== propName && "__self" !== propName && "__source" !== propName && (i[propName] = config[propName]);
1234
- var childrenLength = arguments.length - 2;
1235
- if (1 === childrenLength) i.children = children;
1236
- else if (1 < childrenLength) {
1237
- for (var childArray = Array(childrenLength), _i = 0; _i < childrenLength; _i++)
1238
- childArray[_i] = arguments[_i + 2];
1239
- Object.freeze && Object.freeze(childArray);
1240
- i.children = childArray;
1241
- }
1242
- if (type && type.defaultProps)
1243
- for (propName in childrenLength = type.defaultProps, childrenLength)
1244
- void 0 === i[propName] && (i[propName] = childrenLength[propName]);
1245
- key && defineKeyPropWarningGetter(
1246
- i,
1247
- "function" === typeof type ? type.displayName || type.name || "Unknown" : type
1248
- );
1249
- var propName = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
1250
- return ReactElement(
1251
- type,
1252
- key,
1253
- i,
1254
- getOwner(),
1255
- propName ? Error("react-stack-top-frame") : unknownOwnerDebugStack,
1256
- propName ? createTask(getTaskName(type)) : unknownOwnerDebugTask
1257
- );
1258
- };
1259
- exports.createRef = function() {
1260
- var refObject = { current: null };
1261
- Object.seal(refObject);
1262
- return refObject;
1263
- };
1264
- exports.forwardRef = function(render) {
1265
- null != render && render.$$typeof === REACT_MEMO_TYPE ? console.error(
1266
- "forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...))."
1267
- ) : "function" !== typeof render ? console.error(
1268
- "forwardRef requires a render function but was given %s.",
1269
- null === render ? "null" : typeof render
1270
- ) : 0 !== render.length && 2 !== render.length && console.error(
1271
- "forwardRef render functions accept exactly two parameters: props and ref. %s",
1272
- 1 === render.length ? "Did you forget to use the ref parameter?" : "Any additional parameter will be undefined."
1273
- );
1274
- null != render && null != render.defaultProps && console.error(
1275
- "forwardRef render functions do not support defaultProps. Did you accidentally pass a React component?"
1276
- );
1277
- var elementType = { $$typeof: REACT_FORWARD_REF_TYPE, render }, ownName;
1278
- Object.defineProperty(elementType, "displayName", {
1279
- enumerable: false,
1280
- configurable: true,
1281
- get: function() {
1282
- return ownName;
1283
- },
1284
- set: function(name) {
1285
- ownName = name;
1286
- render.name || render.displayName || (Object.defineProperty(render, "name", { value: name }), render.displayName = name);
1287
- }
1288
- });
1289
- return elementType;
1290
- };
1291
- exports.isValidElement = isValidElement;
1292
- exports.lazy = function(ctor) {
1293
- ctor = { _status: -1, _result: ctor };
1294
- var lazyType = {
1295
- $$typeof: REACT_LAZY_TYPE,
1296
- _payload: ctor,
1297
- _init: lazyInitializer
1298
- }, ioInfo = {
1299
- name: "lazy",
1300
- start: -1,
1301
- end: -1,
1302
- value: null,
1303
- owner: null,
1304
- debugStack: Error("react-stack-top-frame"),
1305
- debugTask: console.createTask ? console.createTask("lazy()") : null
1306
- };
1307
- ctor._ioInfo = ioInfo;
1308
- lazyType._debugInfo = [{ awaited: ioInfo }];
1309
- return lazyType;
1310
- };
1311
- exports.memo = function(type, compare) {
1312
- null == type && console.error(
1313
- "memo: The first argument must be a component. Instead received: %s",
1314
- null === type ? "null" : typeof type
1315
- );
1316
- compare = {
1317
- $$typeof: REACT_MEMO_TYPE,
1318
- type,
1319
- compare: void 0 === compare ? null : compare
1320
- };
1321
- var ownName;
1322
- Object.defineProperty(compare, "displayName", {
1323
- enumerable: false,
1324
- configurable: true,
1325
- get: function() {
1326
- return ownName;
1327
- },
1328
- set: function(name) {
1329
- ownName = name;
1330
- type.name || type.displayName || (Object.defineProperty(type, "name", { value: name }), type.displayName = name);
1331
- }
1332
- });
1333
- return compare;
1334
- };
1335
- exports.startTransition = function(scope) {
1336
- var prevTransition = ReactSharedInternals.T, currentTransition = {};
1337
- currentTransition._updatedFibers = /* @__PURE__ */ new Set();
1338
- ReactSharedInternals.T = currentTransition;
1339
- try {
1340
- var returnValue = scope(), onStartTransitionFinish = ReactSharedInternals.S;
1341
- null !== onStartTransitionFinish && onStartTransitionFinish(currentTransition, returnValue);
1342
- "object" === typeof returnValue && null !== returnValue && "function" === typeof returnValue.then && (ReactSharedInternals.asyncTransitions++, returnValue.then(releaseAsyncTransition, releaseAsyncTransition), returnValue.then(noop, reportGlobalError));
1343
- } catch (error) {
1344
- reportGlobalError(error);
1345
- } finally {
1346
- null === prevTransition && currentTransition._updatedFibers && (scope = currentTransition._updatedFibers.size, currentTransition._updatedFibers.clear(), 10 < scope && console.warn(
1347
- "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."
1348
- )), null !== prevTransition && null !== currentTransition.types && (null !== prevTransition.types && prevTransition.types !== currentTransition.types && console.error(
1349
- "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."
1350
- ), prevTransition.types = currentTransition.types), ReactSharedInternals.T = prevTransition;
1351
- }
1352
- };
1353
- exports.unstable_useCacheRefresh = function() {
1354
- return resolveDispatcher().useCacheRefresh();
1355
- };
1356
- exports.use = function(usable) {
1357
- return resolveDispatcher().use(usable);
1358
- };
1359
- exports.useActionState = function(action, initialState, permalink) {
1360
- return resolveDispatcher().useActionState(
1361
- action,
1362
- initialState,
1363
- permalink
1364
- );
1365
- };
1366
- exports.useCallback = function(callback, deps) {
1367
- return resolveDispatcher().useCallback(callback, deps);
1368
- };
1369
- exports.useContext = function(Context) {
1370
- var dispatcher = resolveDispatcher();
1371
- Context.$$typeof === REACT_CONSUMER_TYPE && console.error(
1372
- "Calling useContext(Context.Consumer) is not supported and will cause bugs. Did you mean to call useContext(Context) instead?"
1373
- );
1374
- return dispatcher.useContext(Context);
1375
- };
1376
- exports.useDebugValue = function(value, formatterFn) {
1377
- return resolveDispatcher().useDebugValue(value, formatterFn);
1378
- };
1379
- exports.useDeferredValue = function(value, initialValue) {
1380
- return resolveDispatcher().useDeferredValue(value, initialValue);
1381
- };
1382
- exports.useEffect = function(create, deps) {
1383
- null == create && console.warn(
1384
- "React Hook useEffect requires an effect callback. Did you forget to pass a callback to the hook?"
1385
- );
1386
- return resolveDispatcher().useEffect(create, deps);
1387
- };
1388
- exports.useEffectEvent = function(callback) {
1389
- return resolveDispatcher().useEffectEvent(callback);
1390
- };
1391
- exports.useId = function() {
1392
- return resolveDispatcher().useId();
1393
- };
1394
- exports.useImperativeHandle = function(ref, create, deps) {
1395
- return resolveDispatcher().useImperativeHandle(ref, create, deps);
1396
- };
1397
- exports.useInsertionEffect = function(create, deps) {
1398
- null == create && console.warn(
1399
- "React Hook useInsertionEffect requires an effect callback. Did you forget to pass a callback to the hook?"
1400
- );
1401
- return resolveDispatcher().useInsertionEffect(create, deps);
1402
- };
1403
- exports.useLayoutEffect = function(create, deps) {
1404
- null == create && console.warn(
1405
- "React Hook useLayoutEffect requires an effect callback. Did you forget to pass a callback to the hook?"
1406
- );
1407
- return resolveDispatcher().useLayoutEffect(create, deps);
1408
- };
1409
- exports.useMemo = function(create, deps) {
1410
- return resolveDispatcher().useMemo(create, deps);
1411
- };
1412
- exports.useOptimistic = function(passthrough, reducer) {
1413
- return resolveDispatcher().useOptimistic(passthrough, reducer);
1414
- };
1415
- exports.useReducer = function(reducer, initialArg, init) {
1416
- return resolveDispatcher().useReducer(reducer, initialArg, init);
1417
- };
1418
- exports.useRef = function(initialValue) {
1419
- return resolveDispatcher().useRef(initialValue);
1420
- };
1421
- exports.useState = function(initialState) {
1422
- return resolveDispatcher().useState(initialState);
1423
- };
1424
- exports.useSyncExternalStore = function(subscribe2, getSnapshot, getServerSnapshot) {
1425
- return resolveDispatcher().useSyncExternalStore(
1426
- subscribe2,
1427
- getSnapshot,
1428
- getServerSnapshot
1429
- );
1430
- };
1431
- exports.useTransition = function() {
1432
- return resolveDispatcher().useTransition();
1433
- };
1434
- exports.version = "19.2.3";
1435
- "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
1436
- })();
1437
- }
1438
- });
1439
-
1440
- // node_modules/react/index.js
1441
- var require_react = __commonJS({
1442
- "node_modules/react/index.js"(exports, module) {
1443
- "use strict";
1444
- if (process.env.NODE_ENV === "production") {
1445
- module.exports = require_react_production();
1446
- } else {
1447
- module.exports = require_react_development();
1448
- }
1449
- }
1450
- });
1451
-
1452
1
  // src/core/scheduler.ts
1453
2
  var pending = /* @__PURE__ */ new Set();
1454
3
  var timer = null;
@@ -1509,6 +58,7 @@ function getPromiseState(promise) {
1509
58
  // src/core/proxy.ts
1510
59
  var LISTENERS = /* @__PURE__ */ new WeakMap();
1511
60
  var PROXIES = /* @__PURE__ */ new WeakMap();
61
+ var PROXY_TO_TARGET = /* @__PURE__ */ new WeakMap();
1512
62
  var activeListener = null;
1513
63
  function setActiveListener(listener) {
1514
64
  activeListener = listener;
@@ -1518,10 +68,11 @@ function getActiveListener() {
1518
68
  }
1519
69
  var GLOBAL_LISTENERS = /* @__PURE__ */ new WeakMap();
1520
70
  function subscribe(store, callback) {
1521
- let listeners = GLOBAL_LISTENERS.get(store);
71
+ const target = PROXY_TO_TARGET.get(store) || store;
72
+ let listeners = GLOBAL_LISTENERS.get(target);
1522
73
  if (!listeners) {
1523
74
  listeners = /* @__PURE__ */ new Set();
1524
- GLOBAL_LISTENERS.set(store, listeners);
75
+ GLOBAL_LISTENERS.set(target, listeners);
1525
76
  }
1526
77
  listeners.add(callback);
1527
78
  return () => listeners?.delete(callback);
@@ -1538,8 +89,6 @@ var handler = {
1538
89
  }
1539
90
  const value = Reflect.get(target, prop, receiver);
1540
91
  if (isPromise(value)) {
1541
- if (prop === "$state") {
1542
- }
1543
92
  return unwrapPromise(value);
1544
93
  }
1545
94
  if (typeof value === "object" && value !== null) {
@@ -1583,10 +132,18 @@ function createState(initialState) {
1583
132
  }
1584
133
  const proxy = new Proxy(initialState, handler);
1585
134
  PROXIES.set(initialState, proxy);
135
+ PROXY_TO_TARGET.set(proxy, initialState);
1586
136
  return proxy;
1587
137
  }
1588
138
 
1589
139
  // src/core/model.ts
140
+ function debounce(fn, ms) {
141
+ let timeout;
142
+ return (...args) => {
143
+ clearTimeout(timeout);
144
+ timeout = setTimeout(() => fn(...args), ms);
145
+ };
146
+ }
1590
147
  function defineModel(def) {
1591
148
  const target = def.state;
1592
149
  if (def.actions) {
@@ -1607,28 +164,90 @@ function defineModel(def) {
1607
164
  }
1608
165
  }
1609
166
  }
1610
- return createState(target);
167
+ const proxy = createState(target);
168
+ if (def.persist) {
169
+ const { key, storage = "local", paths, debug } = def.persist;
170
+ let engine = null;
171
+ if (typeof storage === "string") {
172
+ if (typeof window !== "undefined") {
173
+ engine = storage === "local" ? window.localStorage : window.sessionStorage;
174
+ }
175
+ } else {
176
+ engine = storage;
177
+ }
178
+ if (engine) {
179
+ const hydrate = () => {
180
+ const process = (stored) => {
181
+ try {
182
+ if (stored) {
183
+ const parsed = JSON.parse(stored);
184
+ Object.assign(proxy, parsed);
185
+ if (debug) console.log(`[Quantum] Hydrated '${key}'`, parsed);
186
+ }
187
+ } catch (err) {
188
+ if (debug) console.error(`[Quantum] Hydration Failed for '${key}'`, err);
189
+ }
190
+ };
191
+ try {
192
+ const result = engine.getItem(key);
193
+ if (result instanceof Promise) {
194
+ result.then(process);
195
+ } else {
196
+ process(result);
197
+ }
198
+ } catch (err) {
199
+ if (debug) console.error(`[Quantum] Storage Access Failed`, err);
200
+ }
201
+ };
202
+ hydrate();
203
+ const save = debounce(async () => {
204
+ try {
205
+ let stateToSave;
206
+ if (paths) {
207
+ stateToSave = {};
208
+ for (const p of paths) {
209
+ stateToSave[p] = proxy[p];
210
+ }
211
+ } else {
212
+ stateToSave = {};
213
+ const keys = Object.keys(def.state);
214
+ for (const k of keys) {
215
+ stateToSave[k] = proxy[k];
216
+ }
217
+ }
218
+ const serialized = JSON.stringify(stateToSave);
219
+ await engine.setItem(key, serialized);
220
+ if (debug) console.log(`[Quantum] Saved '${key}'`);
221
+ } catch (err) {
222
+ }
223
+ }, 100);
224
+ subscribe(proxy, () => {
225
+ save();
226
+ });
227
+ }
228
+ }
229
+ return proxy;
1611
230
  }
1612
231
 
1613
232
  // src/react/autoHook.ts
1614
- var import_react = __toESM(require_react(), 1);
233
+ import { useSyncExternalStore, useRef, useCallback, useLayoutEffect, useEffect } from "react";
1615
234
  function useStore(store) {
1616
- const versionRef = (0, import_react.useRef)(0);
1617
- const notifyRef = (0, import_react.useRef)(void 0);
1618
- const listener = (0, import_react.useCallback)(() => {
235
+ const versionRef = useRef(0);
236
+ const notifyRef = useRef(void 0);
237
+ const listener = useCallback(() => {
1619
238
  versionRef.current++;
1620
239
  if (notifyRef.current) {
1621
240
  notifyRef.current();
1622
241
  }
1623
242
  }, []);
1624
- const subscribe2 = (0, import_react.useCallback)((onStoreChange) => {
243
+ const subscribe2 = useCallback((onStoreChange) => {
1625
244
  notifyRef.current = onStoreChange;
1626
245
  return () => {
1627
246
  notifyRef.current = void 0;
1628
247
  };
1629
248
  }, []);
1630
- const getSnapshot = (0, import_react.useCallback)(() => versionRef.current, []);
1631
- (0, import_react.useSyncExternalStore)(subscribe2, getSnapshot, getSnapshot);
249
+ const getSnapshot = useCallback(() => versionRef.current, []);
250
+ useSyncExternalStore(subscribe2, getSnapshot, getSnapshot);
1632
251
  const proxy = new Proxy(store, {
1633
252
  get(target, prop, receiver) {
1634
253
  const prev = getActiveListener();
@@ -1668,8 +287,7 @@ function computed(fn) {
1668
287
  };
1669
288
  }
1670
289
 
1671
- // src/addon/httpClient.ts
1672
- var delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
290
+ // src/addon/clientTypes.ts
1673
291
  var HttpError = class extends Error {
1674
292
  constructor(status, message) {
1675
293
  super(message);
@@ -1677,156 +295,259 @@ var HttpError = class extends Error {
1677
295
  this.name = "HttpError";
1678
296
  }
1679
297
  };
1680
- function createHttpClient(config) {
1681
- let isRefreshing = false;
1682
- let refreshPromise = null;
1683
- const inflightRequests = /* @__PURE__ */ new Map();
1684
- const getRetryConfig = (reqConfig) => {
1685
- const raw = reqConfig?.retry ?? config.retry;
1686
- if (raw === void 0 || raw === 0) return null;
1687
- if (typeof raw === "number") {
1688
- return { retries: raw, baseDelay: 1e3, maxDelay: 5e3 };
298
+
299
+ // src/addon/middleware/types.ts
300
+ function compose(middleware) {
301
+ return (ctx, next) => {
302
+ let index = -1;
303
+ async function dispatch(i) {
304
+ index = i;
305
+ let fn = middleware[i];
306
+ if (i === middleware.length) fn = next;
307
+ if (!fn) return Promise.resolve(new Response(null, { status: 404 }));
308
+ try {
309
+ return fn(ctx, dispatch.bind(null, i + 1));
310
+ } catch (err) {
311
+ return Promise.reject(err);
312
+ }
313
+ }
314
+ return dispatch(0);
315
+ };
316
+ }
317
+
318
+ // src/addon/middleware/dedupe.ts
319
+ var DedupeMiddleware = async (ctx, next) => {
320
+ if (ctx.req.method !== "GET") {
321
+ return next(ctx);
322
+ }
323
+ const key = `${ctx.req.method}:${ctx.req.url}`;
324
+ if (ctx.inflight.has(key)) {
325
+ const promise = ctx.inflight.get(key);
326
+ const response = await promise;
327
+ return response.clone();
328
+ }
329
+ const sharedPromise = next(ctx).then((res) => {
330
+ return res;
331
+ }).catch((err) => {
332
+ ctx.inflight.delete(key);
333
+ throw err;
334
+ });
335
+ ctx.inflight.set(key, sharedPromise);
336
+ try {
337
+ const response = await sharedPromise;
338
+ return response.clone();
339
+ } finally {
340
+ ctx.inflight.delete(key);
341
+ }
342
+ };
343
+
344
+ // src/addon/middleware/cache.ts
345
+ var CacheMiddleware = async (ctx, next) => {
346
+ const { method, url } = ctx.req;
347
+ const { cache: cacheConfig } = ctx.config;
348
+ if (method !== "GET" || !cacheConfig?.ttl || cacheConfig.force) {
349
+ return next(ctx);
350
+ }
351
+ const key = `${method}:${url}`;
352
+ const cache = ctx.cache;
353
+ if (cache.has(key)) {
354
+ const entry = cache.get(key);
355
+ if (entry.expiresAt > Date.now()) {
356
+ const blob = JSON.stringify(entry.data);
357
+ return new Response(blob, { status: 200, statusText: "OK (Cached)" });
358
+ } else {
359
+ cache.delete(key);
360
+ }
361
+ }
362
+ const response = await next(ctx);
363
+ if (response.ok) {
364
+ const clone = response.clone();
365
+ const text = await clone.text();
366
+ try {
367
+ const data = JSON.parse(text);
368
+ cache.set(key, {
369
+ data,
370
+ // Storing raw data object
371
+ timestamp: Date.now(),
372
+ expiresAt: Date.now() + cacheConfig.ttl
373
+ });
374
+ } catch {
375
+ }
376
+ }
377
+ return response;
378
+ };
379
+
380
+ // src/addon/middleware/auth.ts
381
+ var AuthMiddleware = async (ctx, next) => {
382
+ const { auth } = ctx.client.config;
383
+ if (auth && auth.getToken && !ctx.req.headers.get("Authorization")) {
384
+ const token = await auth.getToken();
385
+ if (token) {
386
+ const newHeaders = new Headers(ctx.req.headers);
387
+ newHeaders.set("Authorization", `Bearer ${token}`);
388
+ const newReq = new Request(ctx.req, {
389
+ headers: newHeaders
390
+ });
391
+ ctx.req = newReq;
392
+ }
393
+ }
394
+ const response = await next(ctx);
395
+ if (response.status === 401 && auth && auth.onTokenExpired) {
396
+ try {
397
+ const newToken = await auth.onTokenExpired(ctx.client);
398
+ if (newToken) {
399
+ const newHeaders = new Headers(ctx.req.headers);
400
+ newHeaders.set("Authorization", `Bearer ${newToken}`);
401
+ const newReq = new Request(ctx.req.url, {
402
+ method: ctx.req.method,
403
+ headers: newHeaders,
404
+ body: ctx.req.body,
405
+ mode: ctx.req.mode,
406
+ credentials: ctx.req.credentials,
407
+ cache: ctx.req.cache,
408
+ redirect: ctx.req.redirect,
409
+ referrer: ctx.req.referrer,
410
+ integrity: ctx.req.integrity
411
+ });
412
+ ctx.req = newReq;
413
+ return next(ctx);
414
+ } else {
415
+ auth.onAuthFailed?.();
416
+ throw new HttpError(401, "Authentication Failed");
417
+ }
418
+ } catch (err) {
419
+ throw err;
420
+ }
421
+ }
422
+ return response;
423
+ };
424
+
425
+ // src/addon/middleware/fetch.ts
426
+ var FetchMiddleware = async (ctx) => {
427
+ return fetch(ctx.req);
428
+ };
429
+ var delay = (ms) => new Promise((res) => setTimeout(res, ms));
430
+ var RetryMiddleware = async (ctx, next) => {
431
+ const retryConfig = ctx.config.retry;
432
+ if (!retryConfig) return next(ctx);
433
+ const { retries = 0, baseDelay = 1e3, maxDelay = 3e3 } = typeof retryConfig === "number" ? { retries: retryConfig } : retryConfig;
434
+ const attempt = async (count) => {
435
+ try {
436
+ const response = await next(ctx);
437
+ if (!response.ok && response.status !== 401) {
438
+ if (response.status < 500 && response.status !== 429) {
439
+ return response;
440
+ }
441
+ throw new HttpError(response.status, response.statusText);
442
+ }
443
+ return response;
444
+ } catch (err) {
445
+ if (count < retries) {
446
+ if (err.name === "AbortError") throw err;
447
+ const d = Math.min(baseDelay * 2 ** count, maxDelay);
448
+ await delay(d);
449
+ return attempt(count + 1);
450
+ }
451
+ throw err;
1689
452
  }
1690
- return raw;
1691
453
  };
454
+ return attempt(0);
455
+ };
456
+
457
+ // src/addon/httpClient.ts
458
+ function createHttpClient(config) {
459
+ const cache = /* @__PURE__ */ new Map();
460
+ const inflight = /* @__PURE__ */ new Map();
461
+ const pipeline = compose([
462
+ DedupeMiddleware,
463
+ CacheMiddleware,
464
+ AuthMiddleware,
465
+ RetryMiddleware,
466
+ FetchMiddleware
467
+ ]);
1692
468
  const client = {
469
+ config,
470
+ // Expose for middleware access
1693
471
  async request(endpoint, options = {}) {
1694
472
  let url = config.baseURL ? `${config.baseURL}${endpoint}` : endpoint;
1695
- const method = options.method || "GET";
1696
- const isGet = method.toUpperCase() === "GET";
1697
- const dedupeKey = isGet ? `${method}:${url}` : null;
1698
- if (dedupeKey && inflightRequests.has(dedupeKey)) {
1699
- return inflightRequests.get(dedupeKey);
1700
- }
1701
- const retryConfig = getRetryConfig(options);
473
+ let headers = new Headers({
474
+ "Content-Type": "application/json",
475
+ ...config.headers,
476
+ ...options.headers
477
+ });
1702
478
  const timeoutMs = options.timeout ?? config.timeout ?? 1e4;
1703
479
  const controller = new AbortController();
1704
480
  const id = setTimeout(() => controller.abort(), timeoutMs);
1705
481
  const userSignal = options.signal;
1706
- let finalSignal = controller.signal;
1707
482
  if (userSignal) {
1708
483
  if (userSignal.aborted) {
1709
484
  clearTimeout(id);
1710
485
  throw new Error("Aborted");
1711
486
  }
487
+ userSignal.addEventListener("abort", () => {
488
+ clearTimeout(id);
489
+ controller.abort();
490
+ });
1712
491
  }
1713
- const executeBaseRequest = async (overrideToken) => {
1714
- let headers = {
1715
- "Content-Type": "application/json",
1716
- ...config.headers,
1717
- ...options.headers
1718
- };
1719
- if (overrideToken) {
1720
- headers["Authorization"] = `Bearer ${overrideToken}`;
1721
- } else if (config.auth) {
1722
- const token = await config.auth.getToken();
1723
- if (token) {
1724
- headers["Authorization"] = `Bearer ${token}`;
1725
- }
1726
- }
1727
- let requestConfig = {
492
+ let req = new Request(url, {
493
+ ...options,
494
+ headers,
495
+ signal: controller.signal
496
+ });
497
+ if (config.interceptors?.request) {
498
+ const newConfig = await config.interceptors.request({ ...options, headers: Object.fromEntries(headers) });
499
+ req = new Request(url, {
500
+ ...newConfig,
501
+ signal: controller.signal
502
+ });
503
+ }
504
+ const ctx = {
505
+ req,
506
+ config: {
1728
507
  ...options,
1729
- headers,
1730
- signal: finalSignal
1731
- };
1732
- if (config.interceptors?.request) {
1733
- requestConfig = await config.interceptors.request(requestConfig);
508
+ retry: options.retry !== void 0 ? options.retry : config.retry
509
+ },
510
+ // Merge retry
511
+ cache,
512
+ inflight,
513
+ client: this
514
+ // Pass client for Auth access hooks
515
+ };
516
+ try {
517
+ let response = await pipeline(ctx, async () => new Response("Internal Error", { status: 500 }));
518
+ clearTimeout(id);
519
+ if (config.interceptors?.response) {
520
+ response = await config.interceptors.response(response);
1734
521
  }
1735
- try {
1736
- if (userSignal?.aborted) throw new DOMException("Aborted", "AbortError");
1737
- let response = await fetch(url, requestConfig);
1738
- if (config.interceptors?.response) {
1739
- response = await config.interceptors.response(response);
1740
- }
1741
- return response;
1742
- } catch (error) {
1743
- throw error;
522
+ if (!response.ok) {
523
+ throw new HttpError(response.status, `HTTP Error ${response.status}`);
1744
524
  }
1745
- };
1746
- const attemptRequest = async (attempt) => {
1747
- try {
1748
- const response = await executeBaseRequest();
1749
- if (response.status === 401 && config.auth) {
1750
- if (!isRefreshing) {
1751
- isRefreshing = true;
1752
- refreshPromise = config.auth.onTokenExpired(client).finally(() => {
1753
- isRefreshing = false;
1754
- refreshPromise = null;
1755
- });
1756
- }
1757
- const newToken = await refreshPromise;
1758
- if (newToken) {
1759
- return executeBaseRequest(newToken);
1760
- } else {
1761
- config.auth.onAuthFailed?.();
1762
- throw new HttpError(401, "Authentication Failed");
1763
- }
1764
- }
1765
- if (!response.ok) {
1766
- throw new HttpError(response.status, `HTTP Error ${response.status}`);
1767
- }
1768
- return response;
1769
- } catch (error) {
1770
- if (retryConfig && attempt < retryConfig.retries) {
1771
- const isAbort = error.name === "AbortError";
1772
- if (isAbort) throw error;
1773
- if (error instanceof HttpError) {
1774
- if (error.status < 500 && error.status !== 429) {
1775
- throw error;
1776
- }
1777
- }
1778
- const d = Math.min(
1779
- retryConfig.baseDelay * 2 ** attempt,
1780
- retryConfig.maxDelay
1781
- );
1782
- await delay(d);
1783
- return attemptRequest(attempt + 1);
525
+ let data;
526
+ if (response.status === 204) {
527
+ data = {};
528
+ } else {
529
+ const text = await response.text();
530
+ try {
531
+ data = JSON.parse(text);
532
+ } catch {
533
+ data = text;
1784
534
  }
1785
- throw error;
1786
535
  }
1787
- };
1788
- const execute = async () => {
1789
- try {
1790
- const response = await attemptRequest(0);
1791
- clearTimeout(id);
1792
- let data;
1793
- if (response.status === 204) {
1794
- data = {};
1795
- } else {
1796
- const text = await response.text();
1797
- try {
1798
- data = JSON.parse(text);
1799
- } catch {
1800
- data = text;
1801
- }
1802
- }
1803
- if (options.schema) {
1804
- try {
1805
- if (options.schema.parse) {
1806
- return options.schema.parse(data);
1807
- } else if (options.schema.validateSync) {
1808
- return options.schema.validateSync(data);
1809
- }
1810
- } catch (error) {
1811
- throw new Error(`Validation Error: ${error}`);
536
+ if (options.schema) {
537
+ try {
538
+ if (options.schema.parse) return options.schema.parse(data);
539
+ if (options.schema.validateSync) return options.schema.validateSync(data);
540
+ } catch (error) {
541
+ if (error.errors || error.name === "ZodError" || error.name === "ValidationError") {
542
+ throw new Error(`Validation Error: ${JSON.stringify(error.errors || error.message)}`);
1812
543
  }
544
+ throw error;
1813
545
  }
1814
- return data;
1815
- } catch (err) {
1816
- clearTimeout(id);
1817
- throw err;
1818
- }
1819
- };
1820
- const promise = execute();
1821
- if (dedupeKey) {
1822
- inflightRequests.set(dedupeKey, promise);
1823
- }
1824
- try {
1825
- return await promise;
1826
- } finally {
1827
- if (dedupeKey) {
1828
- inflightRequests.delete(dedupeKey);
1829
546
  }
547
+ return data;
548
+ } catch (err) {
549
+ clearTimeout(id);
550
+ throw err;
1830
551
  }
1831
552
  },
1832
553
  get(url, config2) {
@@ -1847,7 +568,993 @@ function createHttpClient(config) {
1847
568
  };
1848
569
  return client;
1849
570
  }
571
+
572
+ // src/addon/query/utils.ts
573
+ function stableHash(value) {
574
+ if (value === null || typeof value !== "object") {
575
+ return String(value);
576
+ }
577
+ if (Array.isArray(value)) {
578
+ return "[" + value.map(stableHash).join(",") + "]";
579
+ }
580
+ const keys = Object.keys(value).sort();
581
+ return "{" + keys.map((key) => `${key}:${stableHash(value[key])}`).join(",") + "}";
582
+ }
583
+
584
+ // src/addon/signals.ts
585
+ var pendingSignals = /* @__PURE__ */ new Set();
586
+ var isFlushScheduled = false;
587
+ function flushPendingSignals() {
588
+ const toFlush = Array.from(pendingSignals);
589
+ pendingSignals.clear();
590
+ isFlushScheduled = false;
591
+ toFlush.forEach((signal) => signal.flush());
592
+ }
593
+ var SignalImpl = class {
594
+ value;
595
+ subscribers = /* @__PURE__ */ new Set();
596
+ constructor(initialValue) {
597
+ this.value = initialValue;
598
+ }
599
+ get = () => this.value;
600
+ set = (newValue) => {
601
+ if (this.value === newValue) return;
602
+ this.value = newValue;
603
+ pendingSignals.add(this);
604
+ if (!isFlushScheduled) {
605
+ isFlushScheduled = true;
606
+ queueMicrotask(flushPendingSignals);
607
+ }
608
+ };
609
+ flush() {
610
+ const currentValue = this.value;
611
+ this.subscribers.forEach((fn) => fn(currentValue));
612
+ }
613
+ subscribe = (fn) => {
614
+ this.subscribers.add(fn);
615
+ return () => {
616
+ this.subscribers.delete(fn);
617
+ };
618
+ };
619
+ };
620
+ function createSignal(initialValue) {
621
+ return new SignalImpl(initialValue);
622
+ }
623
+
624
+ // src/addon/query/queryCache.ts
625
+ var QueryCache = class {
626
+ // Store signals instead of raw values
627
+ signals = /* @__PURE__ */ new Map();
628
+ gcInterval = null;
629
+ defaultStaleTime = 0;
630
+ // Immediately stale
631
+ defaultCacheTime = 5 * 60 * 1e3;
632
+ // 5 minutes
633
+ constructor(config) {
634
+ if (config?.enableGC !== false) {
635
+ this.startGarbageCollection();
636
+ }
637
+ }
638
+ /**
639
+ * Generate cache key from query key array
640
+ */
641
+ generateKey(queryKey) {
642
+ if (Array.isArray(queryKey)) {
643
+ return stableHash(queryKey);
644
+ }
645
+ return stableHash([queryKey.key, queryKey.params]);
646
+ }
647
+ /**
648
+ * Get data (wrapper around signal.get)
649
+ */
650
+ get(queryKey) {
651
+ const key = this.generateKey(queryKey);
652
+ const signal = this.signals.get(key);
653
+ if (!signal) return void 0;
654
+ const entry = signal.get();
655
+ if (!entry) return void 0;
656
+ const now = Date.now();
657
+ const age = now - entry.timestamp;
658
+ if (age > entry.cacheTime) {
659
+ this.signals.delete(key);
660
+ return void 0;
661
+ }
662
+ return entry.data;
663
+ }
664
+ /**
665
+ * Get Signal for a key (Low level API for hooks)
666
+ * Automatically creates a signal if one doesn't exist
667
+ */
668
+ getSignal(queryKey) {
669
+ const key = this.generateKey(queryKey);
670
+ let signal = this.signals.get(key);
671
+ if (!signal) {
672
+ signal = createSignal(void 0);
673
+ this.signals.set(key, signal);
674
+ }
675
+ return signal;
676
+ }
677
+ /**
678
+ * Check if data is stale
679
+ */
680
+ isStale(queryKey) {
681
+ const key = this.generateKey(queryKey);
682
+ const signal = this.signals.get(key);
683
+ if (!signal) return true;
684
+ const entry = signal.get();
685
+ if (!entry) return true;
686
+ const now = Date.now();
687
+ const age = now - entry.timestamp;
688
+ return age > entry.staleTime;
689
+ }
690
+ /**
691
+ * Set cached data (updates signal)
692
+ */
693
+ set(queryKey, data, options) {
694
+ const key = this.generateKey(queryKey);
695
+ const entry = {
696
+ data,
697
+ timestamp: Date.now(),
698
+ staleTime: options?.staleTime !== void 0 ? options.staleTime : this.defaultStaleTime,
699
+ cacheTime: options?.cacheTime !== void 0 ? options.cacheTime : this.defaultCacheTime,
700
+ key: Array.isArray(queryKey) ? queryKey : [queryKey]
701
+ };
702
+ const existingSignal = this.signals.get(key);
703
+ if (existingSignal) {
704
+ existingSignal.set(entry);
705
+ } else {
706
+ this.signals.set(key, createSignal(entry));
707
+ }
708
+ const normalizedKey = Array.isArray(queryKey) ? queryKey : [queryKey.key, queryKey.params];
709
+ this.plugins.forEach((p) => p.onQueryUpdated?.(normalizedKey, data));
710
+ }
711
+ // --- DEDUPLICATION ---
712
+ deduplicationCache = /* @__PURE__ */ new Map();
713
+ // --- MIDDLEWARE / PLUGINS ---
714
+ plugins = [];
715
+ /**
716
+ * Register a middleware plugin
717
+ */
718
+ use(plugin) {
719
+ this.plugins.push(plugin);
720
+ return this;
721
+ }
722
+ /**
723
+ * Fetch data with deduplication.
724
+ * If a request for the same key is already in flight, returns the existing promise.
725
+ */
726
+ async fetch(queryKey, fn) {
727
+ const key = this.generateKey(queryKey);
728
+ const normalizedKey = Array.isArray(queryKey) ? queryKey : [queryKey.key, queryKey.params];
729
+ if (this.deduplicationCache.has(key)) {
730
+ return this.deduplicationCache.get(key);
731
+ }
732
+ this.plugins.forEach((p) => p.onFetchStart?.(normalizedKey));
733
+ const promise = fn().then(
734
+ (data) => {
735
+ this.deduplicationCache.delete(key);
736
+ this.plugins.forEach((p) => p.onFetchSuccess?.(normalizedKey, data));
737
+ return data;
738
+ },
739
+ (error) => {
740
+ this.deduplicationCache.delete(key);
741
+ this.plugins.forEach((p) => p.onFetchError?.(normalizedKey, error));
742
+ throw error;
743
+ }
744
+ );
745
+ this.deduplicationCache.set(key, promise);
746
+ return promise;
747
+ }
748
+ /**
749
+ * Invalidate queries matching the key prefix
750
+ * Marks them as undefined to trigger refetches without breaking subscriptions
751
+ */
752
+ invalidate(queryKey) {
753
+ const prefix = this.generateKey(queryKey);
754
+ const normalizedKey = Array.isArray(queryKey) ? queryKey : [queryKey.key, queryKey.params];
755
+ this.plugins.forEach((p) => p.onInvalidate?.(normalizedKey));
756
+ const invalidateKey = (key) => {
757
+ const signal = this.signals.get(key);
758
+ if (signal) {
759
+ signal.set(void 0);
760
+ }
761
+ };
762
+ invalidateKey(prefix);
763
+ for (const key of this.signals.keys()) {
764
+ if (key.startsWith(prefix.slice(0, -1))) {
765
+ invalidateKey(key);
766
+ }
767
+ }
768
+ }
769
+ /**
770
+ * Remove all cache entries
771
+ */
772
+ clear() {
773
+ this.signals.clear();
774
+ }
775
+ /**
776
+ * Prefetch data (same as set but explicit intent)
777
+ */
778
+ prefetch(queryKey, data, options) {
779
+ this.set(queryKey, data, options);
780
+ }
781
+ /**
782
+ * Garbage collection - remove expired entries
783
+ */
784
+ startGarbageCollection() {
785
+ this.gcInterval = setInterval(() => {
786
+ const now = Date.now();
787
+ for (const [key, signal] of this.signals.entries()) {
788
+ const entry = signal.get();
789
+ if (!entry) continue;
790
+ const age = now - entry.timestamp;
791
+ if (age > entry.cacheTime) {
792
+ this.signals.delete(key);
793
+ }
794
+ }
795
+ }, 60 * 1e3);
796
+ }
797
+ /**
798
+ * Stop garbage collection
799
+ */
800
+ destroy() {
801
+ if (this.gcInterval) {
802
+ clearInterval(this.gcInterval);
803
+ this.gcInterval = null;
804
+ }
805
+ this.clear();
806
+ }
807
+ /**
808
+ * Get cache stats (for debugging)
809
+ */
810
+ getStats() {
811
+ return {
812
+ size: this.signals.size,
813
+ keys: Array.from(this.signals.keys())
814
+ };
815
+ }
816
+ /**
817
+ * Get all entries (wrapper for DevTools)
818
+ */
819
+ getAll() {
820
+ const map = /* @__PURE__ */ new Map();
821
+ for (const [key, signal] of this.signals.entries()) {
822
+ const val = signal.get();
823
+ if (val) map.set(key, val);
824
+ }
825
+ return map;
826
+ }
827
+ };
828
+ var queryCache = new QueryCache();
829
+
830
+ // src/addon/query/pagination.ts
831
+ import { useState, useEffect as useEffect2, useCallback as useCallback2, useRef as useRef2 } from "react";
832
+ function usePaginatedQuery({
833
+ queryKey,
834
+ queryFn,
835
+ pageSize = 20,
836
+ staleTime,
837
+ cacheTime,
838
+ enabled = true
839
+ }) {
840
+ const [page, setPage] = useState(0);
841
+ const [data, setData] = useState();
842
+ const [isLoading, setIsLoading] = useState(true);
843
+ const [isError, setIsError] = useState(false);
844
+ const [error, setError] = useState(null);
845
+ const [hasNext, setHasNext] = useState(true);
846
+ const queryFnRef = useRef2(queryFn);
847
+ useEffect2(() => {
848
+ queryFnRef.current = queryFn;
849
+ });
850
+ const queryKeyHash = JSON.stringify(queryKey);
851
+ const fetchPage = useCallback2(async (pageNum) => {
852
+ if (!enabled) return;
853
+ const pageQueryKey = [...queryKey, "page", pageNum];
854
+ const cached = queryCache.get(pageQueryKey);
855
+ if (cached && !queryCache.isStale(pageQueryKey)) {
856
+ setData(cached);
857
+ setIsLoading(false);
858
+ return;
859
+ }
860
+ try {
861
+ setIsLoading(true);
862
+ setIsError(false);
863
+ setError(null);
864
+ const result = await queryFnRef.current(pageNum);
865
+ queryCache.set(pageQueryKey, result, { staleTime, cacheTime });
866
+ setData(result);
867
+ if (Array.isArray(result)) {
868
+ setHasNext(result.length === pageSize);
869
+ } else if (result && typeof result === "object" && "hasMore" in result) {
870
+ setHasNext(result.hasMore);
871
+ }
872
+ setIsLoading(false);
873
+ } catch (err) {
874
+ setIsError(true);
875
+ setError(err);
876
+ setIsLoading(false);
877
+ }
878
+ }, [queryKeyHash, enabled, pageSize, staleTime, cacheTime]);
879
+ useEffect2(() => {
880
+ fetchPage(page);
881
+ }, [page, fetchPage]);
882
+ const nextPage = useCallback2(() => {
883
+ if (hasNext) {
884
+ setPage((p) => p + 1);
885
+ }
886
+ }, [hasNext]);
887
+ const previousPage = useCallback2(() => {
888
+ if (page > 0) {
889
+ setPage((p) => p - 1);
890
+ }
891
+ }, [page]);
892
+ const refetch = useCallback2(async () => {
893
+ queryCache.invalidate([...queryKey, "page", String(page)]);
894
+ await fetchPage(page);
895
+ }, [queryKeyHash, page, fetchPage]);
896
+ return {
897
+ data,
898
+ isLoading,
899
+ isError,
900
+ error,
901
+ page,
902
+ setPage,
903
+ nextPage,
904
+ previousPage,
905
+ hasNext,
906
+ hasPrevious: page > 0,
907
+ refetch
908
+ };
909
+ }
910
+
911
+ // src/addon/query/useQuery.ts
912
+ import { useEffect as useEffect3, useCallback as useCallback3, useRef as useRef3, useSyncExternalStore as useSyncExternalStore2, useReducer } from "react";
913
+
914
+ // src/addon/query/context.tsx
915
+ import { createContext, useContext } from "react";
916
+ import { jsx } from "react/jsx-runtime";
917
+ var QueryClientContext = createContext(void 0);
918
+ var QueryClientProvider = ({
919
+ client,
920
+ children
921
+ }) => {
922
+ return /* @__PURE__ */ jsx(QueryClientContext.Provider, { value: client, children });
923
+ };
924
+ var useQueryClient = () => {
925
+ const client = useContext(QueryClientContext);
926
+ return client || queryCache;
927
+ };
928
+
929
+ // src/addon/query/useQuery.ts
930
+ function useQuery({
931
+ queryKey,
932
+ queryFn,
933
+ schema,
934
+ staleTime = 0,
935
+ cacheTime = 5 * 60 * 1e3,
936
+ enabled = true,
937
+ refetchOnWindowFocus = false,
938
+ refetchOnReconnect = false,
939
+ refetchInterval
940
+ }) {
941
+ const client = useQueryClient();
942
+ const queryKeyHash = stableHash(queryKey);
943
+ const subscribe2 = useCallback3((onStoreChange) => {
944
+ const signal = client.getSignal(queryKey);
945
+ return signal.subscribe(() => {
946
+ onStoreChange();
947
+ });
948
+ }, [client, queryKeyHash]);
949
+ const getSnapshot = useCallback3(() => {
950
+ const signal = client.getSignal(queryKey);
951
+ return signal.get();
952
+ }, [client, queryKeyHash]);
953
+ const cacheEntry = useSyncExternalStore2(subscribe2, getSnapshot);
954
+ const data = cacheEntry?.data;
955
+ const dataTimestamp = cacheEntry?.timestamp;
956
+ const [statusState, dispatch] = useReducer(statusReducer, {
957
+ isFetching: false,
958
+ error: null
959
+ });
960
+ const abortControllerRef = useRef3(null);
961
+ const intervalRef = useRef3(null);
962
+ const isStale = dataTimestamp ? Date.now() - dataTimestamp > staleTime : true;
963
+ const isLoading = data === void 0 && statusState.isFetching;
964
+ const derivedIsLoading = data === void 0;
965
+ const queryFnRef = useRef3(queryFn);
966
+ const schemaRef = useRef3(schema);
967
+ const queryKeyRef = useRef3(queryKey);
968
+ useEffect3(() => {
969
+ queryFnRef.current = queryFn;
970
+ schemaRef.current = schema;
971
+ queryKeyRef.current = queryKey;
972
+ });
973
+ const fetchData = useCallback3(async (background = false) => {
974
+ if (!enabled) return;
975
+ if (abortControllerRef.current) abortControllerRef.current.abort();
976
+ abortControllerRef.current = new AbortController();
977
+ if (!background) {
978
+ const currentEntry = getSnapshot();
979
+ if (currentEntry && Date.now() - currentEntry.timestamp <= staleTime) {
980
+ return;
981
+ }
982
+ }
983
+ try {
984
+ dispatch({ type: "FETCH_START", background });
985
+ const fn = queryFnRef.current;
986
+ const sc = schemaRef.current;
987
+ const key = queryKeyRef.current;
988
+ let result = await client.fetch(key, async () => {
989
+ let res = await fn();
990
+ if (sc) {
991
+ res = sc.parse(res);
992
+ }
993
+ return res;
994
+ });
995
+ client.set(key, result, { staleTime, cacheTime });
996
+ dispatch({ type: "FETCH_SUCCESS" });
997
+ } catch (err) {
998
+ if (err.name === "AbortError") return;
999
+ dispatch({ type: "FETCH_ERROR", error: err });
1000
+ }
1001
+ }, [queryKeyHash, enabled, staleTime, cacheTime, client, getSnapshot]);
1002
+ useEffect3(() => {
1003
+ if (data === void 0 && !statusState.error) {
1004
+ fetchData();
1005
+ }
1006
+ }, [fetchData, data, statusState.error]);
1007
+ useEffect3(() => {
1008
+ if (!enabled || !refetchInterval) return;
1009
+ intervalRef.current = setInterval(() => fetchData(true), refetchInterval);
1010
+ return () => {
1011
+ if (intervalRef.current) clearInterval(intervalRef.current);
1012
+ };
1013
+ }, [enabled, refetchInterval, fetchData]);
1014
+ useEffect3(() => {
1015
+ if (!enabled || !refetchOnWindowFocus) return;
1016
+ const handleFocus = () => {
1017
+ const entry = getSnapshot();
1018
+ const isStaleNow = !entry || Date.now() - entry.timestamp > staleTime;
1019
+ if (isStaleNow) fetchData(true);
1020
+ };
1021
+ window.addEventListener("focus", handleFocus);
1022
+ return () => window.removeEventListener("focus", handleFocus);
1023
+ }, [enabled, refetchOnWindowFocus, fetchData, getSnapshot, staleTime]);
1024
+ useEffect3(() => {
1025
+ if (!enabled || !refetchOnReconnect) return;
1026
+ const handleOnline = () => {
1027
+ const entry = getSnapshot();
1028
+ const isStaleNow = !entry || Date.now() - entry.timestamp > staleTime;
1029
+ if (isStaleNow) fetchData(true);
1030
+ };
1031
+ window.addEventListener("online", handleOnline);
1032
+ return () => window.removeEventListener("online", handleOnline);
1033
+ }, [enabled, refetchOnReconnect, fetchData, getSnapshot, staleTime]);
1034
+ const refetch = useCallback3(async () => {
1035
+ client.invalidate(queryKey);
1036
+ await fetchData();
1037
+ }, [queryKeyHash, fetchData, client]);
1038
+ return {
1039
+ data,
1040
+ isLoading: derivedIsLoading,
1041
+ isError: !!statusState.error,
1042
+ isFetching: statusState.isFetching,
1043
+ isStale,
1044
+ error: statusState.error,
1045
+ refetch
1046
+ };
1047
+ }
1048
+ function statusReducer(state, action) {
1049
+ switch (action.type) {
1050
+ case "FETCH_START":
1051
+ return {
1052
+ ...state,
1053
+ isFetching: true,
1054
+ error: null
1055
+ };
1056
+ case "FETCH_SUCCESS":
1057
+ return {
1058
+ ...state,
1059
+ isFetching: false,
1060
+ error: null
1061
+ };
1062
+ case "FETCH_ERROR":
1063
+ return {
1064
+ ...state,
1065
+ isFetching: false,
1066
+ error: action.error
1067
+ };
1068
+ default:
1069
+ return state;
1070
+ }
1071
+ }
1072
+
1073
+ // src/addon/query/useMutation.ts
1074
+ import { useState as useState3, useCallback as useCallback4 } from "react";
1075
+ function useMutation({
1076
+ mutationFn,
1077
+ onMutate,
1078
+ onSuccess,
1079
+ onError,
1080
+ onSettled
1081
+ }) {
1082
+ const [data, setData] = useState3();
1083
+ const [error, setError] = useState3(null);
1084
+ const [isLoading, setIsLoading] = useState3(false);
1085
+ const [isError, setIsError] = useState3(false);
1086
+ const [isSuccess, setIsSuccess] = useState3(false);
1087
+ const mutateAsync = useCallback4(async (variables) => {
1088
+ let context;
1089
+ try {
1090
+ setIsLoading(true);
1091
+ setIsError(false);
1092
+ setError(null);
1093
+ setIsSuccess(false);
1094
+ if (onMutate) {
1095
+ context = await onMutate(variables);
1096
+ }
1097
+ const result = await mutationFn(variables);
1098
+ setData(result);
1099
+ setIsSuccess(true);
1100
+ setIsLoading(false);
1101
+ if (onSuccess) {
1102
+ onSuccess(result, variables, context);
1103
+ }
1104
+ if (onSettled) {
1105
+ onSettled(result, null, variables, context);
1106
+ }
1107
+ return result;
1108
+ } catch (err) {
1109
+ setIsError(true);
1110
+ setError(err);
1111
+ setIsLoading(false);
1112
+ if (onError) {
1113
+ onError(err, variables, context);
1114
+ }
1115
+ if (onSettled) {
1116
+ onSettled(void 0, err, variables, context);
1117
+ }
1118
+ throw err;
1119
+ }
1120
+ }, [mutationFn, onMutate, onSuccess, onError, onSettled]);
1121
+ const mutate = useCallback4(async (variables) => {
1122
+ try {
1123
+ await mutateAsync(variables);
1124
+ } catch {
1125
+ }
1126
+ }, [mutateAsync]);
1127
+ const reset = useCallback4(() => {
1128
+ setData(void 0);
1129
+ setError(null);
1130
+ setIsLoading(false);
1131
+ setIsError(false);
1132
+ setIsSuccess(false);
1133
+ }, []);
1134
+ return {
1135
+ mutate,
1136
+ mutateAsync,
1137
+ data,
1138
+ error,
1139
+ isLoading,
1140
+ isError,
1141
+ isSuccess,
1142
+ reset
1143
+ };
1144
+ }
1145
+ var optimisticHelpers = {
1146
+ /**
1147
+ * Cancel ongoing queries for a key
1148
+ */
1149
+ async cancelQueries(queryKey) {
1150
+ },
1151
+ /**
1152
+ * Get current query data
1153
+ */
1154
+ getQueryData(queryKey) {
1155
+ return queryCache.get(queryKey);
1156
+ },
1157
+ /**
1158
+ * Set query data (for optimistic updates)
1159
+ */
1160
+ setQueryData(queryKey, updater) {
1161
+ const current = queryCache.get(queryKey);
1162
+ const newData = typeof updater === "function" ? updater(current) : updater;
1163
+ queryCache.set(queryKey, newData);
1164
+ return current;
1165
+ },
1166
+ /**
1167
+ * Invalidate queries (trigger refetch)
1168
+ */
1169
+ invalidateQueries(queryKey) {
1170
+ queryCache.invalidate(queryKey);
1171
+ }
1172
+ };
1173
+
1174
+ // src/addon/query/infiniteQuery.ts
1175
+ import { useEffect as useEffect4, useCallback as useCallback5, useRef as useRef4, useReducer as useReducer2, useSyncExternalStore as useSyncExternalStore3 } from "react";
1176
+ function statusReducer2(state, action) {
1177
+ switch (action.type) {
1178
+ case "FETCH_START":
1179
+ return {
1180
+ ...state,
1181
+ isFetching: true,
1182
+ isFetchingNextPage: action.direction === "next",
1183
+ isFetchingPreviousPage: action.direction === "previous",
1184
+ error: null
1185
+ };
1186
+ case "FETCH_SUCCESS":
1187
+ return {
1188
+ ...state,
1189
+ isFetching: false,
1190
+ isFetchingNextPage: false,
1191
+ isFetchingPreviousPage: false,
1192
+ hasNextPage: action.hasNextPage !== void 0 ? action.hasNextPage : state.hasNextPage,
1193
+ hasPreviousPage: action.hasPreviousPage !== void 0 ? action.hasPreviousPage : state.hasPreviousPage
1194
+ };
1195
+ case "FETCH_ERROR":
1196
+ return {
1197
+ ...state,
1198
+ isFetching: false,
1199
+ isFetchingNextPage: false,
1200
+ isFetchingPreviousPage: false,
1201
+ error: action.error
1202
+ };
1203
+ case "SET_PAGINATION":
1204
+ return {
1205
+ ...state,
1206
+ hasNextPage: action.hasNextPage !== void 0 ? action.hasNextPage : state.hasNextPage,
1207
+ hasPreviousPage: action.hasPreviousPage !== void 0 ? action.hasPreviousPage : state.hasPreviousPage
1208
+ };
1209
+ default:
1210
+ return state;
1211
+ }
1212
+ }
1213
+ function useInfiniteQuery({
1214
+ queryKey,
1215
+ queryFn,
1216
+ getNextPageParam,
1217
+ getPreviousPageParam,
1218
+ initialPageParam,
1219
+ staleTime = 0,
1220
+ cacheTime = 5 * 60 * 1e3,
1221
+ enabled = true
1222
+ }) {
1223
+ const client = useQueryClient();
1224
+ const queryKeyHash = stableHash(queryKey);
1225
+ const infiniteQueryKey = [...queryKey, "__infinite__"];
1226
+ const subscribe2 = useCallback5((onStoreChange) => {
1227
+ const signal = client.getSignal(infiniteQueryKey);
1228
+ return signal.subscribe(() => onStoreChange());
1229
+ }, [client, queryKeyHash]);
1230
+ const getSnapshot = useCallback5(() => {
1231
+ const signal = client.getSignal(infiniteQueryKey);
1232
+ return signal.get();
1233
+ }, [client, queryKeyHash]);
1234
+ const cacheEntry = useSyncExternalStore3(subscribe2, getSnapshot);
1235
+ const data = cacheEntry?.data;
1236
+ const [statusState, dispatch] = useReducer2(statusReducer2, {
1237
+ isFetching: false,
1238
+ isFetchingNextPage: false,
1239
+ isFetchingPreviousPage: false,
1240
+ error: null,
1241
+ hasNextPage: false,
1242
+ // Will be set after first fetch
1243
+ hasPreviousPage: false
1244
+ });
1245
+ const queryFnRef = useRef4(queryFn);
1246
+ const getNextPageParamRef = useRef4(getNextPageParam);
1247
+ const getPreviousPageParamRef = useRef4(getPreviousPageParam);
1248
+ const initialFetchDoneRef = useRef4(false);
1249
+ const clientRef = useRef4(client);
1250
+ const infiniteQueryKeyRef = useRef4(infiniteQueryKey);
1251
+ const initialPageParamRef = useRef4(initialPageParam);
1252
+ const staleTimeRef = useRef4(staleTime);
1253
+ const cacheTimeRef = useRef4(cacheTime);
1254
+ useEffect4(() => {
1255
+ queryFnRef.current = queryFn;
1256
+ getNextPageParamRef.current = getNextPageParam;
1257
+ getPreviousPageParamRef.current = getPreviousPageParam;
1258
+ clientRef.current = client;
1259
+ infiniteQueryKeyRef.current = infiniteQueryKey;
1260
+ initialPageParamRef.current = initialPageParam;
1261
+ staleTimeRef.current = staleTime;
1262
+ cacheTimeRef.current = cacheTime;
1263
+ });
1264
+ const prevDataRef = useRef4(data);
1265
+ useEffect4(() => {
1266
+ if (prevDataRef.current && !data) {
1267
+ initialFetchDoneRef.current = false;
1268
+ }
1269
+ prevDataRef.current = data;
1270
+ }, [data]);
1271
+ useEffect4(() => {
1272
+ if (!enabled) return;
1273
+ if (data) return;
1274
+ const doFetch = async () => {
1275
+ const initialParam = initialPageParamRef.current;
1276
+ const firstParam = initialParam !== void 0 ? initialParam : 0;
1277
+ if (!initialFetchDoneRef.current) {
1278
+ initialFetchDoneRef.current = true;
1279
+ }
1280
+ dispatch({ type: "FETCH_START", direction: "initial" });
1281
+ const pageKey = [...infiniteQueryKey, "initial", String(firstParam)];
1282
+ let firstPage;
1283
+ try {
1284
+ firstPage = await clientRef.current.fetch(
1285
+ pageKey,
1286
+ () => queryFnRef.current({ pageParam: firstParam })
1287
+ );
1288
+ } catch (error) {
1289
+ dispatch({ type: "FETCH_ERROR", error });
1290
+ return;
1291
+ }
1292
+ if (firstPage) {
1293
+ const initialData = {
1294
+ pages: [firstPage],
1295
+ pageParams: [firstParam]
1296
+ };
1297
+ let hasNext = false;
1298
+ if (getNextPageParamRef.current) {
1299
+ const nextParam = getNextPageParamRef.current(firstPage, [firstPage]);
1300
+ hasNext = nextParam !== void 0;
1301
+ }
1302
+ clientRef.current.set(infiniteQueryKeyRef.current, initialData, {
1303
+ staleTime: staleTimeRef.current,
1304
+ cacheTime: cacheTimeRef.current
1305
+ });
1306
+ dispatch({ type: "FETCH_SUCCESS", hasNextPage: hasNext });
1307
+ }
1308
+ };
1309
+ doFetch();
1310
+ }, [enabled, data]);
1311
+ const fetchPageHelper = useCallback5(async (pageParam) => {
1312
+ try {
1313
+ const pageKey = [...infiniteQueryKey, String(pageParam)];
1314
+ return await clientRef.current.fetch(
1315
+ pageKey,
1316
+ () => queryFnRef.current({ pageParam })
1317
+ );
1318
+ } catch (error) {
1319
+ dispatch({ type: "FETCH_ERROR", error });
1320
+ return void 0;
1321
+ }
1322
+ }, [client, infiniteQueryKey]);
1323
+ const fetchNextPage = useCallback5(async () => {
1324
+ if (!statusState.hasNextPage || statusState.isFetchingNextPage || !data) return;
1325
+ const lastPage = data.pages[data.pages.length - 1];
1326
+ if (!lastPage || !getNextPageParamRef.current) return;
1327
+ const nextPageParam = getNextPageParamRef.current(lastPage, data.pages);
1328
+ if (nextPageParam === void 0) return;
1329
+ dispatch({ type: "FETCH_START", direction: "next" });
1330
+ const newPage = await fetchPageHelper(nextPageParam);
1331
+ if (newPage) {
1332
+ const updatedData = {
1333
+ pages: [...data.pages, newPage],
1334
+ pageParams: [...data.pageParams, nextPageParam]
1335
+ };
1336
+ let hasNext = false;
1337
+ if (getNextPageParamRef.current) {
1338
+ const nextParam = getNextPageParamRef.current(newPage, updatedData.pages);
1339
+ hasNext = nextParam !== void 0;
1340
+ }
1341
+ clientRef.current.set(infiniteQueryKeyRef.current, updatedData, {
1342
+ staleTime: staleTimeRef.current,
1343
+ cacheTime: cacheTimeRef.current
1344
+ });
1345
+ dispatch({ type: "FETCH_SUCCESS", hasNextPage: hasNext });
1346
+ }
1347
+ }, [statusState.hasNextPage, statusState.isFetchingNextPage, data, fetchPageHelper]);
1348
+ const fetchPreviousPage = useCallback5(async () => {
1349
+ if (!statusState.hasPreviousPage || statusState.isFetchingPreviousPage || !data) return;
1350
+ const firstPage = data.pages[0];
1351
+ if (!firstPage || !getPreviousPageParamRef.current) return;
1352
+ const previousPageParam = getPreviousPageParamRef.current(firstPage, data.pages);
1353
+ if (previousPageParam === void 0) return;
1354
+ dispatch({ type: "FETCH_START", direction: "previous" });
1355
+ const newPage = await fetchPageHelper(previousPageParam);
1356
+ if (newPage) {
1357
+ const updatedData = {
1358
+ pages: [newPage, ...data.pages],
1359
+ pageParams: [previousPageParam, ...data.pageParams]
1360
+ };
1361
+ let hasPrev = false;
1362
+ if (getPreviousPageParamRef.current) {
1363
+ const prevParam = getPreviousPageParamRef.current(newPage, updatedData.pages);
1364
+ hasPrev = prevParam !== void 0;
1365
+ }
1366
+ clientRef.current.set(infiniteQueryKeyRef.current, updatedData, {
1367
+ staleTime: staleTimeRef.current,
1368
+ cacheTime: cacheTimeRef.current
1369
+ });
1370
+ dispatch({ type: "FETCH_SUCCESS", hasPreviousPage: hasPrev });
1371
+ }
1372
+ }, [statusState.hasPreviousPage, statusState.isFetchingPreviousPage, data, fetchPageHelper]);
1373
+ const refetch = useCallback5(async () => {
1374
+ initialFetchDoneRef.current = false;
1375
+ clientRef.current.invalidate(infiniteQueryKeyRef.current);
1376
+ }, []);
1377
+ return {
1378
+ data,
1379
+ fetchNextPage,
1380
+ fetchPreviousPage,
1381
+ hasNextPage: statusState.hasNextPage,
1382
+ hasPreviousPage: statusState.hasPreviousPage,
1383
+ isFetching: statusState.isFetching,
1384
+ isFetchingNextPage: statusState.isFetchingNextPage,
1385
+ isFetchingPreviousPage: statusState.isFetchingPreviousPage,
1386
+ isLoading: data === void 0 && statusState.isFetching,
1387
+ isError: !!statusState.error,
1388
+ error: statusState.error,
1389
+ refetch
1390
+ };
1391
+ }
1392
+
1393
+ // src/addon/query/devtools.tsx
1394
+ import { useState as useState5 } from "react";
1395
+
1396
+ // src/addon/query/useQueryCache.ts
1397
+ import { useState as useState4, useEffect as useEffect5 } from "react";
1398
+ function useQueryCache() {
1399
+ const client = useQueryClient();
1400
+ const [cache, setCache] = useState4(client.getAll());
1401
+ useEffect5(() => {
1402
+ const interval = setInterval(() => {
1403
+ setCache({ ...client.getAll() });
1404
+ }, 500);
1405
+ return () => clearInterval(interval);
1406
+ }, [client]);
1407
+ return cache;
1408
+ }
1409
+
1410
+ // src/addon/query/devtools.tsx
1411
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
1412
+ function QuantumDevTools() {
1413
+ const [isOpen, setIsOpen] = useState5(false);
1414
+ const cache = useQueryCache();
1415
+ const client = useQueryClient();
1416
+ if (!isOpen) {
1417
+ return /* @__PURE__ */ jsx2(
1418
+ "button",
1419
+ {
1420
+ onClick: () => setIsOpen(true),
1421
+ style: {
1422
+ position: "fixed",
1423
+ bottom: "10px",
1424
+ right: "10px",
1425
+ background: "#000",
1426
+ color: "#fff",
1427
+ border: "none",
1428
+ borderRadius: "50%",
1429
+ width: "40px",
1430
+ height: "40px",
1431
+ cursor: "pointer",
1432
+ zIndex: 9999,
1433
+ boxShadow: "0 4px 6px rgba(0,0,0,0.1)",
1434
+ fontSize: "20px",
1435
+ display: "flex",
1436
+ alignItems: "center",
1437
+ justifyContent: "center"
1438
+ },
1439
+ children: "\u26A1\uFE0F"
1440
+ }
1441
+ );
1442
+ }
1443
+ return /* @__PURE__ */ jsxs("div", { style: {
1444
+ position: "fixed",
1445
+ bottom: 0,
1446
+ right: 0,
1447
+ width: "100%",
1448
+ maxWidth: "600px",
1449
+ height: "400px",
1450
+ background: "#1a1a1a",
1451
+ color: "#fff",
1452
+ borderTopLeftRadius: "10px",
1453
+ boxShadow: "0 -4px 20px rgba(0,0,0,0.3)",
1454
+ zIndex: 9999,
1455
+ display: "flex",
1456
+ flexDirection: "column",
1457
+ fontFamily: "monospace"
1458
+ }, children: [
1459
+ /* @__PURE__ */ jsxs("div", { style: {
1460
+ padding: "10px",
1461
+ borderBottom: "1px solid #333",
1462
+ display: "flex",
1463
+ justifyContent: "space-between",
1464
+ alignItems: "center",
1465
+ background: "#222",
1466
+ borderTopLeftRadius: "10px"
1467
+ }, children: [
1468
+ /* @__PURE__ */ jsx2("span", { style: { fontWeight: "bold" }, children: "\u26A1\uFE0F Quantum DevTools" }),
1469
+ /* @__PURE__ */ jsx2(
1470
+ "button",
1471
+ {
1472
+ onClick: () => setIsOpen(false),
1473
+ style: {
1474
+ background: "transparent",
1475
+ border: "none",
1476
+ color: "#999",
1477
+ cursor: "pointer",
1478
+ fontSize: "16px"
1479
+ },
1480
+ children: "\u2715"
1481
+ }
1482
+ )
1483
+ ] }),
1484
+ /* @__PURE__ */ jsx2("div", { style: {
1485
+ flex: 1,
1486
+ overflowY: "auto",
1487
+ padding: "10px",
1488
+ display: "flex",
1489
+ flexDirection: "column",
1490
+ gap: "8px"
1491
+ }, children: Array.from(cache.entries()).length === 0 ? /* @__PURE__ */ jsx2("div", { style: { padding: "20px", textAlign: "center", color: "#666" }, children: "No active queries" }) : Array.from(cache.entries()).map(([keyHash, entry]) => /* @__PURE__ */ jsxs("div", { style: {
1492
+ background: "#2a2a2a",
1493
+ borderRadius: "4px",
1494
+ padding: "8px",
1495
+ border: "1px solid #333"
1496
+ }, children: [
1497
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "space-between", marginBottom: "8px" }, children: [
1498
+ /* @__PURE__ */ jsx2("span", { style: { color: "#aaa", fontSize: "12px" }, children: entry.key.map((k) => String(k)).join(" / ") }),
1499
+ /* @__PURE__ */ jsx2("div", { style: { display: "flex", gap: "5px" }, children: /* @__PURE__ */ jsx2("span", { style: {
1500
+ fontSize: "10px",
1501
+ padding: "2px 4px",
1502
+ borderRadius: "2px",
1503
+ background: client.isStale(entry.key) ? "#dda0dd" : "#90ee90",
1504
+ color: "#000"
1505
+ }, children: client.isStale(entry.key) ? "STALE" : "FRESH" }) })
1506
+ ] }),
1507
+ /* @__PURE__ */ jsx2("div", { style: {
1508
+ fontSize: "11px",
1509
+ color: "#ddd",
1510
+ whiteSpace: "pre-wrap",
1511
+ maxHeight: "100px",
1512
+ overflow: "hidden",
1513
+ opacity: 0.8
1514
+ }, children: JSON.stringify(entry.data, null, 2) }),
1515
+ /* @__PURE__ */ jsxs("div", { style: { marginTop: "8px", display: "flex", gap: "8px" }, children: [
1516
+ /* @__PURE__ */ jsx2(
1517
+ "button",
1518
+ {
1519
+ onClick: () => client.invalidate(entry.key),
1520
+ style: {
1521
+ background: "#444",
1522
+ border: "none",
1523
+ color: "#fff",
1524
+ padding: "4px 8px",
1525
+ borderRadius: "3px",
1526
+ cursor: "pointer",
1527
+ fontSize: "10px"
1528
+ },
1529
+ children: "Invalidate"
1530
+ }
1531
+ ),
1532
+ /* @__PURE__ */ jsx2(
1533
+ "button",
1534
+ {
1535
+ onClick: () => {
1536
+ client.invalidate(entry.key);
1537
+ },
1538
+ style: {
1539
+ background: "#444",
1540
+ border: "none",
1541
+ color: "#fff",
1542
+ padding: "4px 8px",
1543
+ borderRadius: "3px",
1544
+ cursor: "pointer",
1545
+ fontSize: "10px"
1546
+ },
1547
+ children: "Refetch"
1548
+ }
1549
+ )
1550
+ ] })
1551
+ ] }, keyHash)) })
1552
+ ] });
1553
+ }
1850
1554
  export {
1555
+ QuantumDevTools,
1556
+ QueryCache,
1557
+ QueryClientProvider,
1851
1558
  computed,
1852
1559
  createHttpClient,
1853
1560
  createState,
@@ -1856,32 +1563,16 @@ export {
1856
1563
  getPromiseState,
1857
1564
  handlePromise,
1858
1565
  isPromise,
1566
+ optimisticHelpers,
1567
+ queryCache,
1859
1568
  scheduleUpdate,
1860
1569
  subscribe,
1861
1570
  unwrapPromise,
1571
+ useInfiniteQuery,
1572
+ useMutation,
1573
+ usePaginatedQuery,
1574
+ useQuery,
1575
+ useQueryCache,
1576
+ useQueryClient,
1862
1577
  useStore
1863
1578
  };
1864
- /*! Bundled license information:
1865
-
1866
- react/cjs/react.production.js:
1867
- (**
1868
- * @license React
1869
- * react.production.js
1870
- *
1871
- * Copyright (c) Meta Platforms, Inc. and affiliates.
1872
- *
1873
- * This source code is licensed under the MIT license found in the
1874
- * LICENSE file in the root directory of this source tree.
1875
- *)
1876
-
1877
- react/cjs/react.development.js:
1878
- (**
1879
- * @license React
1880
- * react.development.js
1881
- *
1882
- * Copyright (c) Meta Platforms, Inc. and affiliates.
1883
- *
1884
- * This source code is licensed under the MIT license found in the
1885
- * LICENSE file in the root directory of this source tree.
1886
- *)
1887
- */