@tanstack/solid-query-persist-client 5.94.5 → 6.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.js CHANGED
@@ -1,21 +1,1166 @@
1
1
  import { persistQueryClientRestore, persistQueryClientSubscribe } from '@tanstack/query-persist-client-core';
2
2
  export * from '@tanstack/query-persist-client-core';
3
- import { createComponent } from 'solid-js/web';
4
- import { createSignal, createMemo, createEffect, onCleanup } from 'solid-js';
5
- import { QueryClientProvider, IsRestoringProvider } from '@tanstack/solid-query';
3
+ import { createSignal, createMemo, createEffect, onCleanup, createComponent } from 'solid-js';
4
+ import { QueryClientProvider, IsRestoringContext } from '@tanstack/solid-query';
6
5
 
7
6
  // src/index.ts
7
+
8
+ // ../../node_modules/.pnpm/@solidjs+signals@0.13.6/node_modules/@solidjs/signals/dist/prod.js
9
+ var NotReadyError = class extends Error {
10
+ source;
11
+ constructor(e) {
12
+ super();
13
+ this.source = e;
14
+ }
15
+ };
16
+ var StatusError = class extends Error {
17
+ source;
18
+ constructor(e, t) {
19
+ super(t instanceof Error ? t.message : String(t), { cause: t });
20
+ this.source = e;
21
+ }
22
+ };
23
+ var REACTIVE_NONE = 0;
24
+ var REACTIVE_CHECK = 1 << 0;
25
+ var REACTIVE_DIRTY = 1 << 1;
26
+ var REACTIVE_RECOMPUTING_DEPS = 1 << 2;
27
+ var REACTIVE_IN_HEAP = 1 << 3;
28
+ var REACTIVE_IN_HEAP_HEIGHT = 1 << 4;
29
+ var REACTIVE_ZOMBIE = 1 << 5;
30
+ var REACTIVE_DISPOSED = 1 << 6;
31
+ var REACTIVE_OPTIMISTIC_DIRTY = 1 << 7;
32
+ var REACTIVE_SNAPSHOT_STALE = 1 << 8;
33
+ var STATUS_PENDING = 1 << 0;
34
+ var STATUS_ERROR = 1 << 1;
35
+ var STATUS_UNINITIALIZED = 1 << 2;
36
+ var EFFECT_RENDER = 1;
37
+ var EFFECT_USER = 2;
38
+ var EFFECT_TRACKED = 3;
39
+ var NOT_PENDING = {};
40
+ function actualInsertIntoHeap(e, t) {
41
+ const n = (e.i?.t ? e.i.u?.o : e.i?.o) ?? -1;
42
+ if (n >= e.o) e.o = n + 1;
43
+ const i = e.o;
44
+ const r = t.l[i];
45
+ if (r === void 0) t.l[i] = e;
46
+ else {
47
+ const t2 = r.T;
48
+ t2.S = e;
49
+ e.T = t2;
50
+ r.T = e;
51
+ }
52
+ if (i > t.R) t.R = i;
53
+ }
54
+ function insertIntoHeap(e, t) {
55
+ let n = e.O;
56
+ if (n & (REACTIVE_IN_HEAP | REACTIVE_RECOMPUTING_DEPS)) return;
57
+ if (n & REACTIVE_CHECK) {
58
+ e.O = n & -4 | REACTIVE_DIRTY | REACTIVE_IN_HEAP;
59
+ } else e.O = n | REACTIVE_IN_HEAP;
60
+ if (!(n & REACTIVE_IN_HEAP_HEIGHT)) actualInsertIntoHeap(e, t);
61
+ }
62
+ function insertIntoHeapHeight(e, t) {
63
+ let n = e.O;
64
+ if (n & (REACTIVE_IN_HEAP | REACTIVE_RECOMPUTING_DEPS | REACTIVE_IN_HEAP_HEIGHT)) return;
65
+ e.O = n | REACTIVE_IN_HEAP_HEIGHT;
66
+ actualInsertIntoHeap(e, t);
67
+ }
68
+ function deleteFromHeap(e, t) {
69
+ const n = e.O;
70
+ if (!(n & (REACTIVE_IN_HEAP | REACTIVE_IN_HEAP_HEIGHT))) return;
71
+ e.O = n & -25;
72
+ const i = e.o;
73
+ if (e.T === e) t.l[i] = void 0;
74
+ else {
75
+ const n2 = e.S;
76
+ const r = t.l[i];
77
+ const s = n2 ?? r;
78
+ if (e === r) t.l[i] = n2;
79
+ else e.T.S = n2;
80
+ s.T = e.T;
81
+ }
82
+ e.T = e;
83
+ e.S = void 0;
84
+ }
85
+ function runHeap(e, t) {
86
+ e._ = false;
87
+ for (e.P = 0; e.P <= e.R; e.P++) {
88
+ let n = e.l[e.P];
89
+ while (n !== void 0) {
90
+ if (n.O & REACTIVE_IN_HEAP) t(n);
91
+ else adjustHeight(n, e);
92
+ n = e.l[e.P];
93
+ }
94
+ }
95
+ e.R = 0;
96
+ }
97
+ function adjustHeight(e, t) {
98
+ deleteFromHeap(e, t);
99
+ let n = e.o;
100
+ for (let t2 = e.C; t2; t2 = t2.D) {
101
+ const e2 = t2.m;
102
+ const i = e2.V || e2;
103
+ if (i.L && i.o >= n) n = i.o + 1;
104
+ }
105
+ if (e.o !== n) {
106
+ e.o = n;
107
+ for (let n2 = e.I; n2 !== null; n2 = n2.p) {
108
+ insertIntoHeapHeight(n2.h, t);
109
+ }
110
+ }
111
+ }
112
+ var transitions = /* @__PURE__ */ new Set();
113
+ var dirtyQueue = { l: new Array(2e3).fill(void 0), _: false, P: 0, R: 0 };
114
+ var zombieQueue = { l: new Array(2e3).fill(void 0), _: false, P: 0, R: 0 };
115
+ var clock = 0;
116
+ var activeTransition = null;
117
+ var scheduled = false;
118
+ var projectionWriteActive = false;
119
+ var stashedOptimisticReads = null;
120
+ function runLaneEffects(e) {
121
+ for (const t of activeLanes) {
122
+ if (t.U || t.k.size > 0) continue;
123
+ const n = t.G[e - 1];
124
+ if (n.length) {
125
+ t.G[e - 1] = [];
126
+ runQueue(n, e);
127
+ }
128
+ }
129
+ }
130
+ function queueStashedOptimisticEffects(e) {
131
+ for (let t = e.I; t !== null; t = t.p) {
132
+ const e2 = t.h;
133
+ if (!e2.W) continue;
134
+ if (e2.W === EFFECT_TRACKED) {
135
+ if (!e2.H) {
136
+ e2.H = true;
137
+ e2.F.enqueue(EFFECT_USER, e2.M);
138
+ }
139
+ continue;
140
+ }
141
+ const n = e2.O & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue;
142
+ if (n.P > e2.o) n.P = e2.o;
143
+ insertIntoHeap(e2, n);
144
+ }
145
+ }
146
+ function mergeTransitionState(e, t) {
147
+ t.$ = e;
148
+ e.j.push(...t.j);
149
+ for (const n of activeLanes) {
150
+ if (n.K === t) n.K = e;
151
+ }
152
+ e.Y.push(...t.Y);
153
+ for (const n of t.Z) e.Z.add(n);
154
+ for (const n of t.B) {
155
+ if (!e.B.includes(n)) e.B.push(n);
156
+ }
157
+ }
158
+ function resolveOptimisticNodes(e) {
159
+ for (let t = 0; t < e.length; t++) {
160
+ const n = e[t];
161
+ n.q = void 0;
162
+ if (n.X !== NOT_PENDING) {
163
+ n.J = n.X;
164
+ n.X = NOT_PENDING;
165
+ }
166
+ const i = n.ee;
167
+ n.ee = NOT_PENDING;
168
+ if (i !== NOT_PENDING && n.J !== i) insertSubs(n, true);
169
+ n.K = null;
170
+ }
171
+ e.length = 0;
172
+ }
173
+ function cleanupCompletedLanes(e) {
174
+ for (const t of activeLanes) {
175
+ const n = e ? t.K === e : !t.K;
176
+ if (!n) continue;
177
+ if (!t.U) {
178
+ if (t.G[0].length) runQueue(t.G[0], EFFECT_RENDER);
179
+ if (t.G[1].length) runQueue(t.G[1], EFFECT_USER);
180
+ }
181
+ if (t.te.q === t) t.te.q = void 0;
182
+ t.k.clear();
183
+ t.G[0].length = 0;
184
+ t.G[1].length = 0;
185
+ activeLanes.delete(t);
186
+ signalLanes.delete(t.te);
187
+ }
188
+ }
189
+ function schedule() {
190
+ if (scheduled) return;
191
+ scheduled = true;
192
+ if (!globalQueue.ne && !projectionWriteActive) queueMicrotask(flush);
193
+ }
194
+ var Queue = class {
195
+ i = null;
196
+ ie = [[], []];
197
+ re = [];
198
+ created = clock;
199
+ addChild(e) {
200
+ this.re.push(e);
201
+ e.i = this;
202
+ }
203
+ removeChild(e) {
204
+ const t = this.re.indexOf(e);
205
+ if (t >= 0) {
206
+ this.re.splice(t, 1);
207
+ e.i = null;
208
+ }
209
+ }
210
+ notify(e, t, n, i) {
211
+ if (this.i) return this.i.notify(e, t, n, i);
212
+ return false;
213
+ }
214
+ run(e) {
215
+ if (this.ie[e - 1].length) {
216
+ const t = this.ie[e - 1];
217
+ this.ie[e - 1] = [];
218
+ runQueue(t, e);
219
+ }
220
+ for (let t = 0; t < this.re.length; t++) this.re[t].run?.(e);
221
+ }
222
+ enqueue(e, t) {
223
+ if (e) {
224
+ if (currentOptimisticLane) {
225
+ const n = findLane(currentOptimisticLane);
226
+ n.G[e - 1].push(t);
227
+ } else {
228
+ this.ie[e - 1].push(t);
229
+ }
230
+ }
231
+ schedule();
232
+ }
233
+ stashQueues(e) {
234
+ e.ie[0].push(...this.ie[0]);
235
+ e.ie[1].push(...this.ie[1]);
236
+ this.ie = [[], []];
237
+ for (let t = 0; t < this.re.length; t++) {
238
+ let n = this.re[t];
239
+ let i = e.re[t];
240
+ if (!i) {
241
+ i = { ie: [[], []], re: [] };
242
+ e.re[t] = i;
243
+ }
244
+ n.stashQueues(i);
245
+ }
246
+ }
247
+ restoreQueues(e) {
248
+ this.ie[0].push(...e.ie[0]);
249
+ this.ie[1].push(...e.ie[1]);
250
+ for (let t = 0; t < e.re.length; t++) {
251
+ const n = e.re[t];
252
+ let i = this.re[t];
253
+ if (i) i.restoreQueues(n);
254
+ }
255
+ }
256
+ };
257
+ var GlobalQueue = class _GlobalQueue extends Queue {
258
+ ne = false;
259
+ se = [];
260
+ Y = [];
261
+ Z = /* @__PURE__ */ new Set();
262
+ static oe;
263
+ static ue;
264
+ static ce = null;
265
+ flush() {
266
+ if (this.ne) return;
267
+ this.ne = true;
268
+ try {
269
+ runHeap(dirtyQueue, _GlobalQueue.oe);
270
+ if (activeTransition) {
271
+ const e = transitionComplete(activeTransition);
272
+ if (!e) {
273
+ const e2 = activeTransition;
274
+ runHeap(zombieQueue, _GlobalQueue.oe);
275
+ this.se = [];
276
+ this.Y = [];
277
+ this.Z = /* @__PURE__ */ new Set();
278
+ runLaneEffects(EFFECT_RENDER);
279
+ runLaneEffects(EFFECT_USER);
280
+ this.stashQueues(e2.ae);
281
+ clock++;
282
+ scheduled = dirtyQueue.R >= dirtyQueue.P;
283
+ reassignPendingTransition(e2.se);
284
+ activeTransition = null;
285
+ if (!e2.j.length && e2.Y.length) {
286
+ stashedOptimisticReads = /* @__PURE__ */ new Set();
287
+ for (let t2 = 0; t2 < e2.Y.length; t2++) {
288
+ const n = e2.Y[t2];
289
+ if (n.L || n.fe) continue;
290
+ stashedOptimisticReads.add(n);
291
+ queueStashedOptimisticEffects(n);
292
+ }
293
+ }
294
+ try {
295
+ finalizePureQueue(null, true);
296
+ } finally {
297
+ stashedOptimisticReads = null;
298
+ }
299
+ return;
300
+ }
301
+ this.se !== activeTransition.se && this.se.push(...activeTransition.se);
302
+ this.restoreQueues(activeTransition.ae);
303
+ transitions.delete(activeTransition);
304
+ const t = activeTransition;
305
+ activeTransition = null;
306
+ reassignPendingTransition(this.se);
307
+ finalizePureQueue(t);
308
+ } else {
309
+ if (transitions.size) runHeap(zombieQueue, _GlobalQueue.oe);
310
+ finalizePureQueue();
311
+ }
312
+ clock++;
313
+ scheduled = dirtyQueue.R >= dirtyQueue.P;
314
+ runLaneEffects(EFFECT_RENDER);
315
+ this.run(EFFECT_RENDER);
316
+ runLaneEffects(EFFECT_USER);
317
+ this.run(EFFECT_USER);
318
+ } finally {
319
+ this.ne = false;
320
+ }
321
+ }
322
+ notify(e, t, n, i) {
323
+ if (t & STATUS_PENDING) {
324
+ if (n & STATUS_PENDING) {
325
+ const t2 = i !== void 0 ? i : e.le;
326
+ if (activeTransition && t2) {
327
+ const e2 = t2.source;
328
+ if (!activeTransition.B.includes(e2)) {
329
+ activeTransition.B.push(e2);
330
+ schedule();
331
+ }
332
+ }
333
+ }
334
+ return true;
335
+ }
336
+ return false;
337
+ }
338
+ initTransition(e) {
339
+ if (e) e = currentTransition(e);
340
+ if (e && e === activeTransition) return;
341
+ if (!e && activeTransition && activeTransition.Ee === clock) return;
342
+ if (!activeTransition) {
343
+ activeTransition = e ?? {
344
+ Ee: clock,
345
+ se: [],
346
+ B: [],
347
+ Y: [],
348
+ Z: /* @__PURE__ */ new Set(),
349
+ j: [],
350
+ ae: { ie: [[], []], re: [] },
351
+ $: false
352
+ };
353
+ } else if (e) {
354
+ const t = activeTransition;
355
+ mergeTransitionState(e, t);
356
+ transitions.delete(t);
357
+ activeTransition = e;
358
+ }
359
+ transitions.add(activeTransition);
360
+ activeTransition.Ee = clock;
361
+ if (this.se !== activeTransition.se) {
362
+ for (let e2 = 0; e2 < this.se.length; e2++) {
363
+ const t = this.se[e2];
364
+ t.K = activeTransition;
365
+ activeTransition.se.push(t);
366
+ }
367
+ this.se = activeTransition.se;
368
+ }
369
+ if (this.Y !== activeTransition.Y) {
370
+ for (let e2 = 0; e2 < this.Y.length; e2++) {
371
+ const t = this.Y[e2];
372
+ t.K = activeTransition;
373
+ activeTransition.Y.push(t);
374
+ }
375
+ this.Y = activeTransition.Y;
376
+ }
377
+ for (const e2 of activeLanes) {
378
+ if (!e2.K) e2.K = activeTransition;
379
+ }
380
+ if (this.Z !== activeTransition.Z) {
381
+ for (const e2 of this.Z) activeTransition.Z.add(e2);
382
+ this.Z = activeTransition.Z;
383
+ }
384
+ }
385
+ };
386
+ function insertSubs(e, t = false) {
387
+ const n = e.q || currentOptimisticLane;
388
+ const i = e.Te !== void 0;
389
+ for (let r = e.I; r !== null; r = r.p) {
390
+ if (i && r.h.de) {
391
+ r.h.O |= REACTIVE_SNAPSHOT_STALE;
392
+ continue;
393
+ }
394
+ if (t && n) {
395
+ r.h.O |= REACTIVE_OPTIMISTIC_DIRTY;
396
+ assignOrMergeLane(r.h, n);
397
+ } else if (t) {
398
+ r.h.O |= REACTIVE_OPTIMISTIC_DIRTY;
399
+ r.h.q = void 0;
400
+ }
401
+ const e2 = r.h;
402
+ if (e2.W === EFFECT_TRACKED) {
403
+ if (!e2.H) {
404
+ e2.H = true;
405
+ e2.F.enqueue(EFFECT_USER, e2.M);
406
+ }
407
+ continue;
408
+ }
409
+ const s = r.h.O & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue;
410
+ if (s.P > r.h.o) s.P = r.h.o;
411
+ insertIntoHeap(r.h, s);
412
+ }
413
+ }
414
+ function commitPendingNodes() {
415
+ const e = globalQueue.se;
416
+ for (let t = 0; t < e.length; t++) {
417
+ const n = e[t];
418
+ if (n.X !== NOT_PENDING) {
419
+ n.J = n.X;
420
+ n.X = NOT_PENDING;
421
+ if (n.W && n.W !== EFFECT_TRACKED) n.H = true;
422
+ }
423
+ if (!(n.Se & STATUS_PENDING)) n.Se &= ~STATUS_UNINITIALIZED;
424
+ if (n.L) GlobalQueue.ue(n, false, true);
425
+ }
426
+ e.length = 0;
427
+ }
428
+ function finalizePureQueue(e = null, t = false) {
429
+ const n = !t;
430
+ if (n) commitPendingNodes();
431
+ if (!t) checkBoundaryChildren(globalQueue);
432
+ if (dirtyQueue.R >= dirtyQueue.P) runHeap(dirtyQueue, GlobalQueue.oe);
433
+ if (n) {
434
+ commitPendingNodes();
435
+ resolveOptimisticNodes(e ? e.Y : globalQueue.Y);
436
+ const t2 = e ? e.Z : globalQueue.Z;
437
+ if (GlobalQueue.ce && t2.size) {
438
+ for (const e2 of t2) {
439
+ GlobalQueue.ce(e2);
440
+ }
441
+ t2.clear();
442
+ schedule();
443
+ }
444
+ cleanupCompletedLanes(e);
445
+ }
446
+ }
447
+ function checkBoundaryChildren(e) {
448
+ for (const t of e.re) {
449
+ t.checkSources?.();
450
+ checkBoundaryChildren(t);
451
+ }
452
+ }
453
+ function reassignPendingTransition(e) {
454
+ for (let t = 0; t < e.length; t++) {
455
+ e[t].K = activeTransition;
456
+ }
457
+ }
458
+ var globalQueue = new GlobalQueue();
459
+ function flush() {
460
+ if (globalQueue.ne) {
461
+ return;
462
+ }
463
+ while (scheduled || activeTransition) {
464
+ globalQueue.flush();
465
+ }
466
+ }
467
+ function runQueue(e, t) {
468
+ for (let n = 0; n < e.length; n++) e[n](t);
469
+ }
470
+ function transitionComplete(e) {
471
+ if (e.$) return true;
472
+ if (e.j.length) return false;
473
+ let t = true;
474
+ for (let n = 0; n < e.B.length; n++) {
475
+ const i = e.B[n];
476
+ if (i.Se & STATUS_PENDING && i.le?.source === i) {
477
+ t = false;
478
+ break;
479
+ }
480
+ }
481
+ if (t) {
482
+ for (let n = 0; n < e.Y.length; n++) {
483
+ const i = e.Y[n];
484
+ if (hasActiveOverride(i) && "Se" in i && i.Se & STATUS_PENDING && i.le instanceof NotReadyError && i.le.source !== i) {
485
+ t = false;
486
+ break;
487
+ }
488
+ }
489
+ }
490
+ t && (e.$ = true);
491
+ return t;
492
+ }
493
+ function currentTransition(e) {
494
+ while (e.$ && typeof e.$ === "object") e = e.$;
495
+ return e;
496
+ }
497
+ function runInTransition(e, t) {
498
+ const n = activeTransition;
499
+ try {
500
+ activeTransition = currentTransition(e);
501
+ return t();
502
+ } finally {
503
+ activeTransition = n;
504
+ }
505
+ }
506
+ var signalLanes = /* @__PURE__ */ new WeakMap();
507
+ var activeLanes = /* @__PURE__ */ new Set();
508
+ function getOrCreateLane(e) {
509
+ let t = signalLanes.get(e);
510
+ if (t) {
511
+ return findLane(t);
512
+ }
513
+ const n = e.Re;
514
+ const i = n?.q ? findLane(n.q) : null;
515
+ t = { te: e, k: /* @__PURE__ */ new Set(), G: [[], []], U: null, K: activeTransition, Oe: i };
516
+ signalLanes.set(e, t);
517
+ activeLanes.add(t);
518
+ e._e = false;
519
+ return t;
520
+ }
521
+ function findLane(e) {
522
+ while (e.U) e = e.U;
523
+ return e;
524
+ }
525
+ function mergeLanes(e, t) {
526
+ e = findLane(e);
527
+ t = findLane(t);
528
+ if (e === t) return e;
529
+ t.U = e;
530
+ for (const n of t.k) e.k.add(n);
531
+ e.G[0].push(...t.G[0]);
532
+ e.G[1].push(...t.G[1]);
533
+ return e;
534
+ }
535
+ function resolveLane(e) {
536
+ const t = e.q;
537
+ if (!t) return void 0;
538
+ const n = findLane(t);
539
+ if (activeLanes.has(n)) return n;
540
+ e.q = void 0;
541
+ return void 0;
542
+ }
543
+ function resolveTransition(e) {
544
+ return resolveLane(e)?.K ?? e.K;
545
+ }
546
+ function hasActiveOverride(e) {
547
+ return !!(e.ee !== void 0 && e.ee !== NOT_PENDING);
548
+ }
549
+ function assignOrMergeLane(e, t) {
550
+ const n = findLane(t);
551
+ const i = e.q;
552
+ if (i) {
553
+ if (i.U) {
554
+ e.q = t;
555
+ return;
556
+ }
557
+ const r = findLane(i);
558
+ if (activeLanes.has(r)) {
559
+ if (r !== n && !hasActiveOverride(e)) {
560
+ if (n.Oe && findLane(n.Oe) === r) {
561
+ e.q = t;
562
+ } else if (r.Oe && findLane(r.Oe) === n) ;
563
+ else mergeLanes(n, r);
564
+ }
565
+ return;
566
+ }
567
+ }
568
+ e.q = t;
569
+ }
570
+ function addPendingSource(e, t) {
571
+ if (e.Ie === t || e.pe?.has(t)) return false;
572
+ if (!e.Ie) {
573
+ e.Ie = t;
574
+ return true;
575
+ }
576
+ if (!e.pe) {
577
+ e.pe = /* @__PURE__ */ new Set([e.Ie, t]);
578
+ } else {
579
+ e.pe.add(t);
580
+ }
581
+ e.Ie = void 0;
582
+ return true;
583
+ }
584
+ function removePendingSource(e, t) {
585
+ if (e.Ie) {
586
+ if (e.Ie !== t) return false;
587
+ e.Ie = void 0;
588
+ return true;
589
+ }
590
+ if (!e.pe?.delete(t)) return false;
591
+ if (e.pe.size === 1) {
592
+ e.Ie = e.pe.values().next().value;
593
+ e.pe = void 0;
594
+ } else if (e.pe.size === 0) {
595
+ e.pe = void 0;
596
+ }
597
+ return true;
598
+ }
599
+ function clearPendingSources(e) {
600
+ e.Ie = void 0;
601
+ e.pe?.clear();
602
+ e.pe = void 0;
603
+ }
604
+ function setPendingError(e, t, n) {
605
+ if (!t) {
606
+ e.le = null;
607
+ return;
608
+ }
609
+ if (n instanceof NotReadyError && n.source === t) {
610
+ e.le = n;
611
+ return;
612
+ }
613
+ const i = e.le;
614
+ if (!(i instanceof NotReadyError) || i.source !== t) {
615
+ e.le = new NotReadyError(t);
616
+ }
617
+ }
618
+ function forEachDependent(e, t) {
619
+ for (let n = e.I; n !== null; n = n.p) t(n.h);
620
+ for (let n = e.A; n !== null; n = n.N) {
621
+ for (let e2 = n.I; e2 !== null; e2 = e2.p) t(e2.h);
622
+ }
623
+ }
624
+ function settlePendingSource(e) {
625
+ let t = false;
626
+ const n = /* @__PURE__ */ new Set();
627
+ const settle = (i) => {
628
+ if (n.has(i) || !removePendingSource(i, e)) return;
629
+ n.add(i);
630
+ i.Ee = clock;
631
+ const r = i.Ie ?? i.pe?.values().next().value;
632
+ if (r) {
633
+ setPendingError(i, r);
634
+ updatePendingSignal(i);
635
+ } else {
636
+ i.Se &= ~STATUS_PENDING;
637
+ setPendingError(i);
638
+ updatePendingSignal(i);
639
+ if (i.he) {
640
+ if (i.W === EFFECT_TRACKED) {
641
+ const e2 = i;
642
+ if (!e2.H) {
643
+ e2.H = true;
644
+ e2.F.enqueue(EFFECT_USER, e2.M);
645
+ }
646
+ } else {
647
+ const e2 = i.O & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue;
648
+ if (e2.P > i.o) e2.P = i.o;
649
+ insertIntoHeap(i, e2);
650
+ }
651
+ t = true;
652
+ }
653
+ i.he = false;
654
+ }
655
+ forEachDependent(i, settle);
656
+ };
657
+ forEachDependent(e, settle);
658
+ if (t) schedule();
659
+ }
660
+ function handleAsync(e, t, n) {
661
+ const i = typeof t === "object" && t !== null;
662
+ const r = i && untrack(() => t[Symbol.asyncIterator]);
663
+ const s = !r && i && untrack(() => typeof t.then === "function");
664
+ if (!s && !r) {
665
+ e.Ae = null;
666
+ return t;
667
+ }
668
+ e.Ae = t;
669
+ let o;
670
+ const handleError = (n2) => {
671
+ if (e.Ae !== t) return;
672
+ globalQueue.initTransition(resolveTransition(e));
673
+ notifyStatus(e, n2 instanceof NotReadyError ? STATUS_PENDING : STATUS_ERROR, n2);
674
+ e.Ee = clock;
675
+ };
676
+ const asyncWrite = (i2, r2) => {
677
+ if (e.Ae !== t) return;
678
+ if (e.O & (REACTIVE_DIRTY | REACTIVE_OPTIMISTIC_DIRTY)) return;
679
+ globalQueue.initTransition(resolveTransition(e));
680
+ clearStatus(e);
681
+ const s2 = resolveLane(e);
682
+ if (s2) s2.k.delete(e);
683
+ if (e.ee !== void 0) {
684
+ if (e.ee !== void 0 && e.ee !== NOT_PENDING) e.X = i2;
685
+ else {
686
+ e.J = i2;
687
+ insertSubs(e);
688
+ }
689
+ e.Ee = clock;
690
+ } else if (s2) {
691
+ const t2 = e.J;
692
+ const n2 = e.Ne;
693
+ if (!n2 || !n2(i2, t2)) {
694
+ e.J = i2;
695
+ e.Ee = clock;
696
+ if (e.Pe) {
697
+ setSignal(e.Pe, i2);
698
+ }
699
+ insertSubs(e, true);
700
+ }
701
+ } else {
702
+ setSignal(e, () => i2);
703
+ }
704
+ settlePendingSource(e);
705
+ schedule();
706
+ flush();
707
+ r2?.();
708
+ };
709
+ if (s) {
710
+ let n2 = false, i2 = true;
711
+ t.then(
712
+ (e2) => {
713
+ if (i2) {
714
+ o = e2;
715
+ n2 = true;
716
+ } else asyncWrite(e2);
717
+ },
718
+ (e2) => {
719
+ if (!i2) handleError(e2);
720
+ }
721
+ );
722
+ i2 = false;
723
+ if (!n2) {
724
+ globalQueue.initTransition(resolveTransition(e));
725
+ throw new NotReadyError(context);
726
+ }
727
+ }
728
+ if (r) {
729
+ const n2 = t[Symbol.asyncIterator]();
730
+ let i2 = false;
731
+ const iterate = () => {
732
+ let e2, t2 = false, r3 = true;
733
+ n2.next().then(
734
+ (n3) => {
735
+ if (r3) {
736
+ e2 = n3;
737
+ t2 = true;
738
+ } else if (!n3.done) asyncWrite(n3.value, iterate);
739
+ else {
740
+ schedule();
741
+ flush();
742
+ }
743
+ },
744
+ (e3) => {
745
+ if (!r3) handleError(e3);
746
+ }
747
+ );
748
+ r3 = false;
749
+ if (t2 && !e2.done) {
750
+ o = e2.value;
751
+ i2 = true;
752
+ return iterate();
753
+ }
754
+ return t2 && e2.done;
755
+ };
756
+ const r2 = iterate();
757
+ if (!i2 && !r2) {
758
+ globalQueue.initTransition(resolveTransition(e));
759
+ throw new NotReadyError(context);
760
+ }
761
+ }
762
+ return o;
763
+ }
764
+ function clearStatus(e, t = false) {
765
+ clearPendingSources(e);
766
+ e.he = false;
767
+ e.Se = t ? 0 : e.Se & STATUS_UNINITIALIZED;
768
+ setPendingError(e);
769
+ updatePendingSignal(e);
770
+ e.ge?.();
771
+ }
772
+ function notifyStatus(e, t, n, i, r) {
773
+ if (t === STATUS_ERROR && !(n instanceof StatusError) && !(n instanceof NotReadyError))
774
+ n = new StatusError(e, n);
775
+ const s = t === STATUS_PENDING && n instanceof NotReadyError ? n.source : void 0;
776
+ const o = s === e;
777
+ const u = t === STATUS_PENDING && e.ee !== void 0 && !o;
778
+ const c = u && hasActiveOverride(e);
779
+ if (!i) {
780
+ if (t === STATUS_PENDING && s) {
781
+ addPendingSource(e, s);
782
+ e.Se = STATUS_PENDING | e.Se & STATUS_UNINITIALIZED;
783
+ setPendingError(e, s, n);
784
+ } else {
785
+ clearPendingSources(e);
786
+ e.Se = t | (t !== STATUS_ERROR ? e.Se & STATUS_UNINITIALIZED : 0);
787
+ e.le = n;
788
+ }
789
+ updatePendingSignal(e);
790
+ }
791
+ if (r && !i) {
792
+ assignOrMergeLane(e, r);
793
+ }
794
+ const a = i || c;
795
+ const f = i || u ? void 0 : r;
796
+ if (e.ge) {
797
+ if (i && t === STATUS_PENDING) {
798
+ return;
799
+ }
800
+ if (a) {
801
+ e.ge(t, n);
802
+ } else {
803
+ e.ge();
804
+ }
805
+ return;
806
+ }
807
+ forEachDependent(e, (e2) => {
808
+ e2.Ee = clock;
809
+ if (t === STATUS_PENDING && s && e2.Ie !== s && !e2.pe?.has(s) || t !== STATUS_PENDING && (e2.le !== n || e2.Ie || e2.pe)) {
810
+ if (!a && !e2.K) globalQueue.se.push(e2);
811
+ notifyStatus(e2, t, n, a, f);
812
+ }
813
+ });
814
+ }
815
+ var externalSourceConfig = null;
816
+ function markDisposal(e) {
817
+ let t = e.Ce;
818
+ while (t) {
819
+ t.O |= REACTIVE_ZOMBIE;
820
+ if (t.O & REACTIVE_IN_HEAP) {
821
+ deleteFromHeap(t, dirtyQueue);
822
+ insertIntoHeap(t, zombieQueue);
823
+ }
824
+ markDisposal(t);
825
+ t = t.De;
826
+ }
827
+ }
828
+ function disposeChildren(e, t = false, n) {
829
+ if (e.O & REACTIVE_DISPOSED) return;
830
+ if (t) e.O = REACTIVE_DISPOSED;
831
+ let i = n ? e.me : e.Ce;
832
+ while (i) {
833
+ const e2 = i.De;
834
+ if (i.C) {
835
+ const e3 = i;
836
+ deleteFromHeap(e3, e3.O & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
837
+ let t2 = e3.C;
838
+ do {
839
+ t2 = unlinkSubs(t2);
840
+ } while (t2 !== null);
841
+ e3.C = null;
842
+ e3.ye = null;
843
+ }
844
+ disposeChildren(i, true);
845
+ i = e2;
846
+ }
847
+ if (n) {
848
+ e.me = null;
849
+ } else {
850
+ e.Ce = null;
851
+ e.ve = 0;
852
+ }
853
+ runDisposal(e, n);
854
+ }
855
+ function runDisposal(e, t) {
856
+ let n = t ? e.we : e.be;
857
+ if (!n) return;
858
+ if (Array.isArray(n)) {
859
+ for (let e2 = 0; e2 < n.length; e2++) {
860
+ const t2 = n[e2];
861
+ t2.call(t2);
862
+ }
863
+ } else {
864
+ n.call(n);
865
+ }
866
+ t ? e.we = null : e.be = null;
867
+ }
868
+ function unlinkSubs(e) {
869
+ const t = e.m;
870
+ const n = e.D;
871
+ const i = e.p;
872
+ const r = e.Ue;
873
+ if (i !== null) i.Ue = r;
874
+ else t.ke = r;
875
+ if (r !== null) r.p = i;
876
+ else {
877
+ t.I = i;
878
+ if (i === null) {
879
+ t.Ge?.();
880
+ t.L && !t.xe && !(t.O & REACTIVE_ZOMBIE) && unobserved(t);
881
+ }
882
+ }
883
+ return n;
884
+ }
885
+ function unobserved(e) {
886
+ deleteFromHeap(e, e.O & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
887
+ let t = e.C;
888
+ while (t !== null) {
889
+ t = unlinkSubs(t);
890
+ }
891
+ e.C = null;
892
+ disposeChildren(e, true);
893
+ }
894
+ GlobalQueue.oe = recompute;
895
+ GlobalQueue.ue = disposeChildren;
896
+ var tracking = false;
897
+ var context = null;
898
+ var currentOptimisticLane = null;
899
+ function recompute(e, t = false) {
900
+ const n = e.W;
901
+ if (!t) {
902
+ if (e.K && (!n || activeTransition) && activeTransition !== e.K)
903
+ globalQueue.initTransition(e.K);
904
+ deleteFromHeap(e, e.O & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
905
+ if (e.K || n === EFFECT_TRACKED) disposeChildren(e);
906
+ else {
907
+ markDisposal(e);
908
+ e.we = e.be;
909
+ e.me = e.Ce;
910
+ e.be = null;
911
+ e.Ce = null;
912
+ e.ve = 0;
913
+ }
914
+ }
915
+ const i = !!(e.O & REACTIVE_OPTIMISTIC_DIRTY);
916
+ const r = e.ee !== void 0 && e.ee !== NOT_PENDING;
917
+ const s = !!(e.Se & STATUS_PENDING);
918
+ const o = context;
919
+ context = e;
920
+ e.ye = null;
921
+ e.O = REACTIVE_RECOMPUTING_DEPS;
922
+ e.Ee = clock;
923
+ let u = e.X === NOT_PENDING ? e.J : e.X;
924
+ let c = e.o;
925
+ let a = tracking;
926
+ let f = currentOptimisticLane;
927
+ tracking = true;
928
+ if (i) {
929
+ const t2 = resolveLane(e);
930
+ if (t2) currentOptimisticLane = t2;
931
+ }
932
+ try {
933
+ u = handleAsync(e, e.L(u));
934
+ clearStatus(e, t);
935
+ const n2 = resolveLane(e);
936
+ if (n2) {
937
+ n2.k.delete(e);
938
+ updatePendingSignal(n2.te);
939
+ }
940
+ } catch (t2) {
941
+ if (t2 instanceof NotReadyError && currentOptimisticLane) {
942
+ const t3 = findLane(currentOptimisticLane);
943
+ if (t3.te !== e) {
944
+ t3.k.add(e);
945
+ e.q = t3;
946
+ updatePendingSignal(t3.te);
947
+ }
948
+ }
949
+ if (t2 instanceof NotReadyError) e.he = true;
950
+ notifyStatus(
951
+ e,
952
+ t2 instanceof NotReadyError ? STATUS_PENDING : STATUS_ERROR,
953
+ t2,
954
+ void 0,
955
+ t2 instanceof NotReadyError ? e.q : void 0
956
+ );
957
+ } finally {
958
+ tracking = a;
959
+ e.O = REACTIVE_NONE | (t ? e.O & REACTIVE_SNAPSHOT_STALE : 0);
960
+ context = o;
961
+ }
962
+ if (!e.le) {
963
+ const o2 = e.ye;
964
+ let a2 = o2 !== null ? o2.D : e.C;
965
+ if (a2 !== null) {
966
+ do {
967
+ a2 = unlinkSubs(a2);
968
+ } while (a2 !== null);
969
+ if (o2 !== null) o2.D = null;
970
+ else e.C = null;
971
+ }
972
+ const f2 = r ? e.ee : e.X === NOT_PENDING ? e.J : e.X;
973
+ const l = !e.Ne || !e.Ne(f2, u);
974
+ if (l) {
975
+ const o3 = r ? e.ee : void 0;
976
+ if (t || n && activeTransition !== e.K || i) {
977
+ e.J = u;
978
+ if (r && i) {
979
+ e.ee = u;
980
+ e.X = u;
981
+ }
982
+ } else e.X = u;
983
+ if (r && !i && s && !e._e) e.ee = u;
984
+ if (!r || i || e.ee !== o3) insertSubs(e, i || r);
985
+ } else if (r) {
986
+ e.X = u;
987
+ } else if (e.o != c) {
988
+ for (let t2 = e.I; t2 !== null; t2 = t2.p) {
989
+ insertIntoHeapHeight(t2.h, t2.h.O & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
990
+ }
991
+ }
992
+ }
993
+ currentOptimisticLane = f;
994
+ (!t || e.Se & STATUS_PENDING) && !e.K && !(activeTransition && r) && globalQueue.se.push(e);
995
+ e.K && n && activeTransition !== e.K && runInTransition(e.K, () => recompute(e));
996
+ }
997
+ function untrack(e, t) {
998
+ if (!externalSourceConfig && !tracking && true) return e();
999
+ const n = tracking;
1000
+ tracking = false;
1001
+ try {
1002
+ if (externalSourceConfig) return externalSourceConfig.untrack(e);
1003
+ return e();
1004
+ } finally {
1005
+ tracking = n;
1006
+ }
1007
+ }
1008
+ function setSignal(e, t) {
1009
+ if (e.K && activeTransition !== e.K) globalQueue.initTransition(e.K);
1010
+ const n = e.ee !== void 0 && !projectionWriteActive;
1011
+ const i = e.ee !== void 0 && e.ee !== NOT_PENDING;
1012
+ const r = n ? i ? e.ee : e.J : e.X === NOT_PENDING ? e.J : e.X;
1013
+ if (typeof t === "function") t = t(r);
1014
+ const s = !e.Ne || !e.Ne(r, t) || !!(e.Se & STATUS_UNINITIALIZED);
1015
+ if (!s) {
1016
+ if (n && i && e.L) {
1017
+ insertSubs(e, true);
1018
+ schedule();
1019
+ }
1020
+ return t;
1021
+ }
1022
+ if (n) {
1023
+ const n2 = e.ee === NOT_PENDING;
1024
+ if (!n2) globalQueue.initTransition(resolveTransition(e));
1025
+ if (n2) {
1026
+ e.X = e.J;
1027
+ globalQueue.Y.push(e);
1028
+ }
1029
+ e._e = true;
1030
+ const i2 = getOrCreateLane(e);
1031
+ e.q = i2;
1032
+ e.ee = t;
1033
+ } else {
1034
+ if (e.X === NOT_PENDING) globalQueue.se.push(e);
1035
+ e.X = t;
1036
+ }
1037
+ updatePendingSignal(e);
1038
+ if (e.Pe) {
1039
+ setSignal(e.Pe, t);
1040
+ }
1041
+ e.Ee = clock;
1042
+ insertSubs(e, n);
1043
+ schedule();
1044
+ return t;
1045
+ }
1046
+ function computePendingState(e) {
1047
+ const t = e;
1048
+ const n = e.V;
1049
+ if (n && e.X !== NOT_PENDING) {
1050
+ return !n.Ae && !(n.Se & STATUS_PENDING);
1051
+ }
1052
+ if (e.ee !== void 0 && e.ee !== NOT_PENDING) {
1053
+ if (t.Se & STATUS_PENDING && !(t.Se & STATUS_UNINITIALIZED)) return true;
1054
+ if (e.Re) {
1055
+ const t2 = e.q ? findLane(e.q) : null;
1056
+ return !!(t2 && t2.k.size > 0);
1057
+ }
1058
+ return true;
1059
+ }
1060
+ if (e.ee !== void 0 && e.ee === NOT_PENDING && !e.Re) {
1061
+ return false;
1062
+ }
1063
+ if (e.X !== NOT_PENDING && !(t.Se & STATUS_UNINITIALIZED)) return true;
1064
+ return !!(t.Se & STATUS_PENDING && !(t.Se & STATUS_UNINITIALIZED));
1065
+ }
1066
+ function updatePendingSignal(e) {
1067
+ if (e.Qe) {
1068
+ const t = computePendingState(e);
1069
+ const n = e.Qe;
1070
+ setSignal(n, t);
1071
+ if (!t && n.q) {
1072
+ const t2 = resolveLane(e);
1073
+ if (t2 && t2.k.size > 0) {
1074
+ const e2 = findLane(n.q);
1075
+ if (e2 !== t2) {
1076
+ mergeLanes(t2, e2);
1077
+ }
1078
+ }
1079
+ signalLanes.delete(n);
1080
+ n.q = void 0;
1081
+ }
1082
+ }
1083
+ }
1084
+ function isWrappable(e) {
1085
+ return e != null && typeof e === "object" && !Object.isFrozen(e);
1086
+ }
1087
+ var DELETE = /* @__PURE__ */ Symbol(0);
1088
+ function updatePath(e, t, n = 0) {
1089
+ let i, r = e;
1090
+ if (n < t.length - 1) {
1091
+ i = t[n];
1092
+ const s2 = typeof i;
1093
+ const o = Array.isArray(e);
1094
+ if (Array.isArray(i)) {
1095
+ for (let r2 = 0; r2 < i.length; r2++) {
1096
+ t[n] = i[r2];
1097
+ updatePath(e, t, n);
1098
+ }
1099
+ t[n] = i;
1100
+ return;
1101
+ } else if (o && s2 === "function") {
1102
+ for (let r2 = 0; r2 < e.length; r2++) {
1103
+ if (i(e[r2], r2)) {
1104
+ t[n] = r2;
1105
+ updatePath(e, t, n);
1106
+ }
1107
+ }
1108
+ t[n] = i;
1109
+ return;
1110
+ } else if (o && s2 === "object") {
1111
+ const { from: r2 = 0, to: s3 = e.length - 1, by: o2 = 1 } = i;
1112
+ for (let i2 = r2; i2 <= s3; i2 += o2) {
1113
+ t[n] = i2;
1114
+ updatePath(e, t, n);
1115
+ }
1116
+ t[n] = i;
1117
+ return;
1118
+ } else if (n < t.length - 2) {
1119
+ updatePath(e[i], t, n + 1);
1120
+ return;
1121
+ }
1122
+ r = e[i];
1123
+ }
1124
+ let s = t[t.length - 1];
1125
+ if (typeof s === "function") {
1126
+ s = s(r);
1127
+ if (s === r) return;
1128
+ }
1129
+ if (i === void 0 && s == void 0) return;
1130
+ if (s === DELETE) {
1131
+ delete e[i];
1132
+ } else if (i === void 0 || isWrappable(r) && isWrappable(s) && !Array.isArray(s)) {
1133
+ const t2 = i !== void 0 ? e[i] : e;
1134
+ const n2 = Object.keys(s);
1135
+ for (let e2 = 0; e2 < n2.length; e2++) t2[n2[e2]] = s[n2[e2]];
1136
+ } else {
1137
+ e[i] = s;
1138
+ }
1139
+ }
1140
+ Object.assign(
1141
+ function storePath2(...e) {
1142
+ return (t) => {
1143
+ updatePath(t, e);
1144
+ };
1145
+ },
1146
+ { DELETE }
1147
+ );
8
1148
  var PersistQueryClientProvider = (props) => {
9
1149
  const [isRestoring, setIsRestoring] = createSignal(true);
1150
+ let didRestore = false;
10
1151
  const options = createMemo(() => ({
11
1152
  ...props.persistOptions,
12
1153
  queryClient: props.client
13
1154
  }));
14
1155
  createEffect(() => {
15
- setIsRestoring(true);
16
- persistQueryClientRestore(options()).then(() => props.onSuccess?.()).catch(() => props.onError?.()).finally(() => {
17
- setIsRestoring(false);
18
- });
1156
+ const opts = options();
1157
+ if (!didRestore) {
1158
+ didRestore = true;
1159
+ persistQueryClientRestore(opts).then(() => props.onSuccess?.()).catch(() => props.onError?.()).finally(() => {
1160
+ setIsRestoring(false);
1161
+ });
1162
+ }
1163
+ }, () => {
19
1164
  });
20
1165
  createEffect(() => {
21
1166
  let unsubscribe = () => {
@@ -24,13 +1169,14 @@ var PersistQueryClientProvider = (props) => {
24
1169
  unsubscribe = persistQueryClientSubscribe(options());
25
1170
  }
26
1171
  onCleanup(() => unsubscribe());
1172
+ }, () => {
27
1173
  });
28
1174
  return createComponent(QueryClientProvider, {
29
1175
  get client() {
30
1176
  return props.client;
31
1177
  },
32
1178
  get children() {
33
- return createComponent(IsRestoringProvider, {
1179
+ return createComponent(IsRestoringContext, {
34
1180
  value: isRestoring,
35
1181
  get children() {
36
1182
  return props.children;