@tanstack/solid-query-devtools 5.91.3 → 6.0.0-alpha.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.
@@ -0,0 +1,1065 @@
1
+ import { createRenderEffect, untrack as untrack$1, runWithOwner, sharedConfig } from 'solid-js';
2
+
3
+ // ../../node_modules/.pnpm/@solidjs+web@2.0.0-beta.2_@solidjs+signals@0.12.0_solid-js@2.0.0-beta.2/node_modules/@solidjs/web/dist/dev.js
4
+
5
+ // ../../node_modules/.pnpm/@solidjs+signals@0.12.0/node_modules/@solidjs/signals/dist/dev.js
6
+ var NotReadyError = class extends Error {
7
+ source;
8
+ constructor(source) {
9
+ super();
10
+ this.source = source;
11
+ }
12
+ };
13
+ var StatusError = class extends Error {
14
+ source;
15
+ constructor(source, original) {
16
+ super(original instanceof Error ? original.message : String(original), { cause: original });
17
+ this.source = source;
18
+ }
19
+ };
20
+ var REACTIVE_NONE = 0;
21
+ var REACTIVE_CHECK = 1 << 0;
22
+ var REACTIVE_DIRTY = 1 << 1;
23
+ var REACTIVE_RECOMPUTING_DEPS = 1 << 2;
24
+ var REACTIVE_IN_HEAP = 1 << 3;
25
+ var REACTIVE_IN_HEAP_HEIGHT = 1 << 4;
26
+ var REACTIVE_ZOMBIE = 1 << 5;
27
+ var REACTIVE_DISPOSED = 1 << 6;
28
+ var REACTIVE_OPTIMISTIC_DIRTY = 1 << 7;
29
+ var REACTIVE_SNAPSHOT_STALE = 1 << 8;
30
+ var STATUS_PENDING = 1 << 0;
31
+ var STATUS_ERROR = 1 << 1;
32
+ var STATUS_UNINITIALIZED = 1 << 2;
33
+ var EFFECT_RENDER = 1;
34
+ var EFFECT_USER = 2;
35
+ var EFFECT_TRACKED = 3;
36
+ var NOT_PENDING = {};
37
+ function actualInsertIntoHeap(n, heap) {
38
+ const parentHeight = (n._parent?._root ? n._parent._parentComputed?._height : n._parent?._height) ?? -1;
39
+ if (parentHeight >= n._height) n._height = parentHeight + 1;
40
+ const height = n._height;
41
+ const heapAtHeight = heap._heap[height];
42
+ if (heapAtHeight === void 0) heap._heap[height] = n;
43
+ else {
44
+ const tail = heapAtHeight._prevHeap;
45
+ tail._nextHeap = n;
46
+ n._prevHeap = tail;
47
+ heapAtHeight._prevHeap = n;
48
+ }
49
+ if (height > heap._max) heap._max = height;
50
+ }
51
+ function insertIntoHeap(n, heap) {
52
+ let flags = n._flags;
53
+ if (flags & (REACTIVE_IN_HEAP | REACTIVE_RECOMPUTING_DEPS)) return;
54
+ if (flags & REACTIVE_CHECK) {
55
+ n._flags = flags & -4 | REACTIVE_DIRTY | REACTIVE_IN_HEAP;
56
+ } else n._flags = flags | REACTIVE_IN_HEAP;
57
+ if (!(flags & REACTIVE_IN_HEAP_HEIGHT)) actualInsertIntoHeap(n, heap);
58
+ }
59
+ function insertIntoHeapHeight(n, heap) {
60
+ let flags = n._flags;
61
+ if (flags & (REACTIVE_IN_HEAP | REACTIVE_RECOMPUTING_DEPS | REACTIVE_IN_HEAP_HEIGHT)) return;
62
+ n._flags = flags | REACTIVE_IN_HEAP_HEIGHT;
63
+ actualInsertIntoHeap(n, heap);
64
+ }
65
+ function deleteFromHeap(n, heap) {
66
+ const flags = n._flags;
67
+ if (!(flags & (REACTIVE_IN_HEAP | REACTIVE_IN_HEAP_HEIGHT))) return;
68
+ n._flags = flags & -25;
69
+ const height = n._height;
70
+ if (n._prevHeap === n) heap._heap[height] = void 0;
71
+ else {
72
+ const next = n._nextHeap;
73
+ const dhh = heap._heap[height];
74
+ const end = next ?? dhh;
75
+ if (n === dhh) heap._heap[height] = next;
76
+ else n._prevHeap._nextHeap = next;
77
+ end._prevHeap = n._prevHeap;
78
+ }
79
+ n._prevHeap = n;
80
+ n._nextHeap = void 0;
81
+ }
82
+ function runHeap(heap, recompute2) {
83
+ heap._marked = false;
84
+ for (heap._min = 0; heap._min <= heap._max; heap._min++) {
85
+ let el = heap._heap[heap._min];
86
+ while (el !== void 0) {
87
+ if (el._flags & REACTIVE_IN_HEAP) recompute2(el);
88
+ else adjustHeight(el, heap);
89
+ el = heap._heap[heap._min];
90
+ }
91
+ }
92
+ heap._max = 0;
93
+ }
94
+ function adjustHeight(el, heap) {
95
+ deleteFromHeap(el, heap);
96
+ let newHeight = el._height;
97
+ for (let d = el._deps; d; d = d._nextDep) {
98
+ const dep1 = d._dep;
99
+ const dep = dep1._firewall || dep1;
100
+ if (dep._fn && dep._height >= newHeight) newHeight = dep._height + 1;
101
+ }
102
+ if (el._height !== newHeight) {
103
+ el._height = newHeight;
104
+ for (let s = el._subs; s !== null; s = s._nextSub) {
105
+ insertIntoHeapHeight(s._sub, heap);
106
+ }
107
+ }
108
+ }
109
+ var transitions = /* @__PURE__ */ new Set();
110
+ var dirtyQueue = { _heap: new Array(2e3).fill(void 0), _marked: false, _min: 0, _max: 0 };
111
+ var zombieQueue = { _heap: new Array(2e3).fill(void 0), _marked: false, _min: 0, _max: 0 };
112
+ var clock = 0;
113
+ var activeTransition = null;
114
+ var scheduled = false;
115
+ var projectionWriteActive = false;
116
+ var _onUnhandledAsync = null;
117
+ function runLaneEffects(type) {
118
+ for (const lane of activeLanes) {
119
+ if (lane._mergedInto || lane._pendingAsync.size > 0) continue;
120
+ const effects = lane._effectQueues[type - 1];
121
+ if (effects.length) {
122
+ lane._effectQueues[type - 1] = [];
123
+ runQueue(effects, type);
124
+ }
125
+ }
126
+ }
127
+ function schedule() {
128
+ if (scheduled) return;
129
+ scheduled = true;
130
+ if (!globalQueue._running && !projectionWriteActive) queueMicrotask(flush);
131
+ }
132
+ var Queue = class {
133
+ _parent = null;
134
+ _queues = [[], []];
135
+ _children = [];
136
+ created = clock;
137
+ addChild(child) {
138
+ this._children.push(child);
139
+ child._parent = this;
140
+ }
141
+ removeChild(child) {
142
+ const index = this._children.indexOf(child);
143
+ if (index >= 0) {
144
+ this._children.splice(index, 1);
145
+ child._parent = null;
146
+ }
147
+ }
148
+ notify(node, mask, flags, error) {
149
+ if (this._parent) return this._parent.notify(node, mask, flags, error);
150
+ return false;
151
+ }
152
+ run(type) {
153
+ if (this._queues[type - 1].length) {
154
+ const effects = this._queues[type - 1];
155
+ this._queues[type - 1] = [];
156
+ runQueue(effects, type);
157
+ }
158
+ for (let i = 0; i < this._children.length; i++) this._children[i].run?.(type);
159
+ }
160
+ enqueue(type, fn) {
161
+ if (type) {
162
+ if (currentOptimisticLane) {
163
+ const lane = findLane(currentOptimisticLane);
164
+ lane._effectQueues[type - 1].push(fn);
165
+ } else {
166
+ this._queues[type - 1].push(fn);
167
+ }
168
+ }
169
+ schedule();
170
+ }
171
+ stashQueues(stub) {
172
+ stub._queues[0].push(...this._queues[0]);
173
+ stub._queues[1].push(...this._queues[1]);
174
+ this._queues = [[], []];
175
+ for (let i = 0; i < this._children.length; i++) {
176
+ let child = this._children[i];
177
+ let childStub = stub._children[i];
178
+ if (!childStub) {
179
+ childStub = { _queues: [[], []], _children: [] };
180
+ stub._children[i] = childStub;
181
+ }
182
+ child.stashQueues(childStub);
183
+ }
184
+ }
185
+ restoreQueues(stub) {
186
+ this._queues[0].push(...stub._queues[0]);
187
+ this._queues[1].push(...stub._queues[1]);
188
+ for (let i = 0; i < stub._children.length; i++) {
189
+ const childStub = stub._children[i];
190
+ let child = this._children[i];
191
+ if (child) child.restoreQueues(childStub);
192
+ }
193
+ }
194
+ };
195
+ var GlobalQueue = class _GlobalQueue extends Queue {
196
+ _running = false;
197
+ _pendingNodes = [];
198
+ _optimisticNodes = [];
199
+ _optimisticStores = /* @__PURE__ */ new Set();
200
+ static _update;
201
+ static _dispose;
202
+ static _clearOptimisticStore = null;
203
+ flush() {
204
+ if (this._running) return;
205
+ this._running = true;
206
+ try {
207
+ runHeap(dirtyQueue, _GlobalQueue._update);
208
+ if (activeTransition) {
209
+ const isComplete = transitionComplete(activeTransition);
210
+ if (!isComplete) {
211
+ let t = activeTransition;
212
+ runHeap(zombieQueue, _GlobalQueue._update);
213
+ this._pendingNodes = [];
214
+ this._optimisticNodes = [];
215
+ this._optimisticStores = /* @__PURE__ */ new Set();
216
+ runLaneEffects(EFFECT_RENDER);
217
+ runLaneEffects(EFFECT_USER);
218
+ this.stashQueues(activeTransition._queueStash);
219
+ clock++;
220
+ scheduled = dirtyQueue._max >= dirtyQueue._min;
221
+ reassignPendingTransition(activeTransition._pendingNodes);
222
+ activeTransition = null;
223
+ finalizePureQueue(null, true);
224
+ return;
225
+ }
226
+ this._pendingNodes !== activeTransition._pendingNodes && this._pendingNodes.push(...activeTransition._pendingNodes);
227
+ this.restoreQueues(activeTransition._queueStash);
228
+ transitions.delete(activeTransition);
229
+ const completingTransition = activeTransition;
230
+ activeTransition = null;
231
+ reassignPendingTransition(this._pendingNodes);
232
+ finalizePureQueue(completingTransition);
233
+ } else {
234
+ if (transitions.size) runHeap(zombieQueue, _GlobalQueue._update);
235
+ finalizePureQueue();
236
+ }
237
+ clock++;
238
+ scheduled = dirtyQueue._max >= dirtyQueue._min;
239
+ runLaneEffects(EFFECT_RENDER);
240
+ this.run(EFFECT_RENDER);
241
+ runLaneEffects(EFFECT_USER);
242
+ this.run(EFFECT_USER);
243
+ } finally {
244
+ this._running = false;
245
+ }
246
+ }
247
+ notify(node, mask, flags, error) {
248
+ if (mask & STATUS_PENDING) {
249
+ if (_onUnhandledAsync && flags & STATUS_PENDING) {
250
+ _onUnhandledAsync();
251
+ }
252
+ if (flags & STATUS_PENDING) {
253
+ const actualError = error !== void 0 ? error : node._error;
254
+ if (activeTransition && actualError && !activeTransition._asyncNodes.includes(actualError.source)) {
255
+ activeTransition._asyncNodes.push(actualError.source);
256
+ schedule();
257
+ }
258
+ }
259
+ return true;
260
+ }
261
+ return false;
262
+ }
263
+ initTransition(transition) {
264
+ if (transition) transition = currentTransition(transition);
265
+ if (transition && transition === activeTransition) return;
266
+ if (!transition && activeTransition && activeTransition._time === clock) return;
267
+ if (!activeTransition) {
268
+ activeTransition = transition ?? {
269
+ _time: clock,
270
+ _pendingNodes: [],
271
+ _asyncNodes: [],
272
+ _optimisticNodes: [],
273
+ _optimisticStores: /* @__PURE__ */ new Set(),
274
+ _actions: [],
275
+ _queueStash: { _queues: [[], []], _children: [] },
276
+ _done: false
277
+ };
278
+ } else if (transition) {
279
+ const outgoing = activeTransition;
280
+ outgoing._done = transition;
281
+ transition._actions.push(...outgoing._actions);
282
+ for (const lane of activeLanes) {
283
+ if (lane._transition === outgoing) lane._transition = transition;
284
+ }
285
+ transition._optimisticNodes.push(...outgoing._optimisticNodes);
286
+ for (const store of outgoing._optimisticStores) {
287
+ transition._optimisticStores.add(store);
288
+ }
289
+ transitions.delete(outgoing);
290
+ activeTransition = transition;
291
+ }
292
+ transitions.add(activeTransition);
293
+ activeTransition._time = clock;
294
+ for (let i = 0; i < this._pendingNodes.length; i++) {
295
+ const n = this._pendingNodes[i];
296
+ n._transition = activeTransition;
297
+ activeTransition._pendingNodes.push(n);
298
+ }
299
+ this._pendingNodes = activeTransition._pendingNodes;
300
+ for (let i = 0; i < this._optimisticNodes.length; i++) {
301
+ const node = this._optimisticNodes[i];
302
+ node._transition = activeTransition;
303
+ activeTransition._optimisticNodes.push(node);
304
+ }
305
+ this._optimisticNodes = activeTransition._optimisticNodes;
306
+ for (const lane of activeLanes) {
307
+ if (!lane._transition) lane._transition = activeTransition;
308
+ }
309
+ for (const store of this._optimisticStores) activeTransition._optimisticStores.add(store);
310
+ this._optimisticStores = activeTransition._optimisticStores;
311
+ }
312
+ };
313
+ function insertSubs(node, optimistic = false) {
314
+ const sourceLane = node._optimisticLane || currentOptimisticLane;
315
+ const hasSnapshot = node._snapshotValue !== void 0;
316
+ for (let s = node._subs; s !== null; s = s._nextSub) {
317
+ if (hasSnapshot && s._sub._inSnapshotScope) {
318
+ s._sub._flags |= REACTIVE_SNAPSHOT_STALE;
319
+ continue;
320
+ }
321
+ if (optimistic && sourceLane) {
322
+ s._sub._flags |= REACTIVE_OPTIMISTIC_DIRTY;
323
+ assignOrMergeLane(s._sub, sourceLane);
324
+ } else if (optimistic) {
325
+ s._sub._flags |= REACTIVE_OPTIMISTIC_DIRTY;
326
+ s._sub._optimisticLane = void 0;
327
+ }
328
+ const sub = s._sub;
329
+ if (sub._type === EFFECT_TRACKED) {
330
+ if (!sub._modified) {
331
+ sub._modified = true;
332
+ sub._queue.enqueue(EFFECT_USER, sub._run);
333
+ }
334
+ continue;
335
+ }
336
+ const queue = s._sub._flags & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue;
337
+ if (queue._min > s._sub._height) queue._min = s._sub._height;
338
+ insertIntoHeap(s._sub, queue);
339
+ }
340
+ }
341
+ function finalizePureQueue(completingTransition = null, incomplete = false) {
342
+ let resolvePending = !incomplete;
343
+ if (!incomplete) checkBoundaryChildren(globalQueue);
344
+ if (dirtyQueue._max >= dirtyQueue._min) runHeap(dirtyQueue, GlobalQueue._update);
345
+ if (resolvePending) {
346
+ const pendingNodes = globalQueue._pendingNodes;
347
+ for (let i = 0; i < pendingNodes.length; i++) {
348
+ const n = pendingNodes[i];
349
+ if (n._pendingValue !== NOT_PENDING) {
350
+ n._value = n._pendingValue;
351
+ n._pendingValue = NOT_PENDING;
352
+ if (n._type && n._type !== EFFECT_TRACKED) n._modified = true;
353
+ }
354
+ if (!(n._statusFlags & STATUS_PENDING)) n._statusFlags &= ~STATUS_UNINITIALIZED;
355
+ if (n._fn) GlobalQueue._dispose(n, false, true);
356
+ }
357
+ pendingNodes.length = 0;
358
+ const optimisticNodes = completingTransition ? completingTransition._optimisticNodes : globalQueue._optimisticNodes;
359
+ for (let i = 0; i < optimisticNodes.length; i++) {
360
+ const n = optimisticNodes[i];
361
+ const original = n._pendingValue;
362
+ n._optimisticLane = void 0;
363
+ if (original !== NOT_PENDING && n._value !== original) {
364
+ n._value = original;
365
+ insertSubs(n, true);
366
+ }
367
+ n._pendingValue = NOT_PENDING;
368
+ n._transition = null;
369
+ }
370
+ optimisticNodes.length = 0;
371
+ const optimisticStores = completingTransition ? completingTransition._optimisticStores : globalQueue._optimisticStores;
372
+ if (GlobalQueue._clearOptimisticStore && optimisticStores.size) {
373
+ for (const store of optimisticStores) {
374
+ GlobalQueue._clearOptimisticStore(store);
375
+ }
376
+ optimisticStores.clear();
377
+ schedule();
378
+ }
379
+ for (const lane of activeLanes) {
380
+ const owned = completingTransition ? lane._transition === completingTransition : !lane._transition;
381
+ if (!owned) continue;
382
+ if (!lane._mergedInto) {
383
+ if (lane._effectQueues[0].length) runQueue(lane._effectQueues[0], EFFECT_RENDER);
384
+ if (lane._effectQueues[1].length) runQueue(lane._effectQueues[1], EFFECT_USER);
385
+ }
386
+ if (lane._source._optimisticLane === lane) lane._source._optimisticLane = void 0;
387
+ lane._pendingAsync.clear();
388
+ lane._effectQueues[0].length = 0;
389
+ lane._effectQueues[1].length = 0;
390
+ activeLanes.delete(lane);
391
+ signalLanes.delete(lane._source);
392
+ }
393
+ }
394
+ }
395
+ function checkBoundaryChildren(queue) {
396
+ for (const child of queue._children) {
397
+ child.checkSources?.();
398
+ checkBoundaryChildren(child);
399
+ }
400
+ }
401
+ function reassignPendingTransition(pendingNodes) {
402
+ for (let i = 0; i < pendingNodes.length; i++) {
403
+ pendingNodes[i]._transition = activeTransition;
404
+ }
405
+ }
406
+ var globalQueue = new GlobalQueue();
407
+ function flush() {
408
+ let count = 0;
409
+ while (scheduled) {
410
+ if (++count === 1e5) throw new Error("Potential Infinite Loop Detected.");
411
+ globalQueue.flush();
412
+ }
413
+ }
414
+ function runQueue(queue, type) {
415
+ for (let i = 0; i < queue.length; i++) queue[i](type);
416
+ }
417
+ function transitionComplete(transition) {
418
+ if (transition._done) return true;
419
+ if (transition._actions.length) return false;
420
+ let done = true;
421
+ for (let i = 0; i < transition._asyncNodes.length; i++) {
422
+ const node = transition._asyncNodes[i];
423
+ if (node._statusFlags & STATUS_PENDING && node._error?.source === node) {
424
+ done = false;
425
+ break;
426
+ }
427
+ }
428
+ done && (transition._done = true);
429
+ return done;
430
+ }
431
+ function currentTransition(transition) {
432
+ while (transition._done && typeof transition._done === "object") transition = transition._done;
433
+ return transition;
434
+ }
435
+ function runInTransition(transition, fn) {
436
+ const prevTransition = activeTransition;
437
+ try {
438
+ activeTransition = currentTransition(transition);
439
+ return fn();
440
+ } finally {
441
+ activeTransition = prevTransition;
442
+ }
443
+ }
444
+ var signalLanes = /* @__PURE__ */ new WeakMap();
445
+ var activeLanes = /* @__PURE__ */ new Set();
446
+ function getOrCreateLane(signal) {
447
+ let lane = signalLanes.get(signal);
448
+ if (lane) {
449
+ return findLane(lane);
450
+ }
451
+ const parentSource = signal._parentSource;
452
+ const parentLane = parentSource?._optimisticLane ? findLane(parentSource._optimisticLane) : null;
453
+ lane = {
454
+ _source: signal,
455
+ _pendingAsync: /* @__PURE__ */ new Set(),
456
+ _effectQueues: [[], []],
457
+ _mergedInto: null,
458
+ _transition: activeTransition,
459
+ _parentLane: parentLane
460
+ };
461
+ signalLanes.set(signal, lane);
462
+ activeLanes.add(lane);
463
+ signal._laneVersion = signal._overrideVersion || 0;
464
+ return lane;
465
+ }
466
+ function findLane(lane) {
467
+ while (lane._mergedInto) lane = lane._mergedInto;
468
+ return lane;
469
+ }
470
+ function mergeLanes(lane1, lane2) {
471
+ lane1 = findLane(lane1);
472
+ lane2 = findLane(lane2);
473
+ if (lane1 === lane2) return lane1;
474
+ lane2._mergedInto = lane1;
475
+ for (const node of lane2._pendingAsync) lane1._pendingAsync.add(node);
476
+ lane1._effectQueues[0].push(...lane2._effectQueues[0]);
477
+ lane1._effectQueues[1].push(...lane2._effectQueues[1]);
478
+ return lane1;
479
+ }
480
+ function resolveLane(el) {
481
+ const lane = el._optimisticLane;
482
+ if (!lane) return void 0;
483
+ const root = findLane(lane);
484
+ if (activeLanes.has(root)) return root;
485
+ el._optimisticLane = void 0;
486
+ return void 0;
487
+ }
488
+ function hasActiveOverride(el) {
489
+ return !!(el._optimistic && el._pendingValue !== NOT_PENDING);
490
+ }
491
+ function assignOrMergeLane(el, sourceLane) {
492
+ const sourceRoot = findLane(sourceLane);
493
+ const existing = el._optimisticLane;
494
+ if (existing) {
495
+ if (existing._mergedInto) {
496
+ el._optimisticLane = sourceLane;
497
+ return;
498
+ }
499
+ const existingRoot = findLane(existing);
500
+ if (activeLanes.has(existingRoot)) {
501
+ if (existingRoot !== sourceRoot && !hasActiveOverride(el)) {
502
+ if (sourceRoot._parentLane && findLane(sourceRoot._parentLane) === existingRoot) {
503
+ el._optimisticLane = sourceLane;
504
+ } else if (existingRoot._parentLane && findLane(existingRoot._parentLane) === sourceRoot) ;
505
+ else mergeLanes(sourceRoot, existingRoot);
506
+ }
507
+ return;
508
+ }
509
+ }
510
+ el._optimisticLane = sourceLane;
511
+ }
512
+ function handleAsync(el, result, setter) {
513
+ const isObject = typeof result === "object" && result !== null;
514
+ const iterator = isObject && untrack(() => result[Symbol.asyncIterator]);
515
+ const isThenable = !iterator && isObject && untrack(() => typeof result.then === "function");
516
+ if (!isThenable && !iterator) {
517
+ el._inFlight = null;
518
+ return result;
519
+ }
520
+ el._inFlight = result;
521
+ let syncValue;
522
+ const handleError = (error) => {
523
+ if (el._inFlight !== result) return;
524
+ globalQueue.initTransition(el._transition);
525
+ notifyStatus(el, error instanceof NotReadyError ? STATUS_PENDING : STATUS_ERROR, error);
526
+ el._time = clock;
527
+ };
528
+ const asyncWrite = (value, then) => {
529
+ if (el._inFlight !== result) return;
530
+ if (el._flags & (REACTIVE_DIRTY | REACTIVE_OPTIMISTIC_DIRTY)) return;
531
+ globalQueue.initTransition(el._transition);
532
+ clearStatus(el);
533
+ const lane = resolveLane(el);
534
+ if (lane) lane._pendingAsync.delete(el);
535
+ if (el._optimistic) {
536
+ const hadOverride = el._pendingValue !== NOT_PENDING;
537
+ if (el._fn) el._pendingValue = value;
538
+ if (!hadOverride) {
539
+ el._value = value;
540
+ insertSubs(el);
541
+ }
542
+ el._time = clock;
543
+ } else if (lane) {
544
+ const prevValue = el._value;
545
+ const equals = el._equals;
546
+ if (!equals || !equals(value, prevValue)) {
547
+ el._value = value;
548
+ el._time = clock;
549
+ if (el._latestValueComputed) {
550
+ setSignal(el._latestValueComputed, value);
551
+ }
552
+ insertSubs(el, true);
553
+ }
554
+ } else {
555
+ setSignal(el, () => value);
556
+ }
557
+ schedule();
558
+ flush();
559
+ then?.();
560
+ };
561
+ if (isThenable) {
562
+ let resolved = false, isSync = true;
563
+ result.then(
564
+ (v) => {
565
+ if (isSync) {
566
+ syncValue = v;
567
+ resolved = true;
568
+ } else asyncWrite(v);
569
+ },
570
+ (e) => {
571
+ if (!isSync) handleError(e);
572
+ }
573
+ );
574
+ isSync = false;
575
+ if (!resolved) {
576
+ globalQueue.initTransition(el._transition);
577
+ throw new NotReadyError(context);
578
+ }
579
+ }
580
+ if (iterator) {
581
+ const it = result[Symbol.asyncIterator]();
582
+ let hadSyncValue = false;
583
+ const iterate = () => {
584
+ let syncResult, resolved = false, isSync = true;
585
+ it.next().then(
586
+ (r) => {
587
+ if (isSync) {
588
+ syncResult = r;
589
+ resolved = true;
590
+ } else if (!r.done) asyncWrite(r.value, iterate);
591
+ else {
592
+ schedule();
593
+ flush();
594
+ }
595
+ },
596
+ (e) => {
597
+ if (!isSync) handleError(e);
598
+ }
599
+ );
600
+ isSync = false;
601
+ if (resolved && !syncResult.done) {
602
+ syncValue = syncResult.value;
603
+ hadSyncValue = true;
604
+ return iterate();
605
+ }
606
+ return resolved && syncResult.done;
607
+ };
608
+ const immediatelyDone = iterate();
609
+ if (!hadSyncValue && !immediatelyDone) {
610
+ globalQueue.initTransition(el._transition);
611
+ throw new NotReadyError(context);
612
+ }
613
+ }
614
+ return syncValue;
615
+ }
616
+ function clearStatus(el) {
617
+ el._statusFlags = el._statusFlags & STATUS_UNINITIALIZED;
618
+ el._error = null;
619
+ updatePendingSignal(el);
620
+ el._notifyStatus?.();
621
+ }
622
+ function notifyStatus(el, status, error, blockStatus, lane) {
623
+ if (status === STATUS_ERROR && !(error instanceof StatusError) && !(error instanceof NotReadyError))
624
+ error = new StatusError(el, error);
625
+ const isSource = error instanceof NotReadyError && error.source === el;
626
+ const isOptimisticBoundary = status === STATUS_PENDING && el._optimistic && !isSource;
627
+ const startsBlocking = isOptimisticBoundary && hasActiveOverride(el);
628
+ if (!blockStatus) {
629
+ el._statusFlags = status | (status !== STATUS_ERROR ? el._statusFlags & STATUS_UNINITIALIZED : 0);
630
+ el._error = error;
631
+ updatePendingSignal(el);
632
+ }
633
+ if (lane && !blockStatus) {
634
+ assignOrMergeLane(el, lane);
635
+ }
636
+ if (startsBlocking && activeTransition && error instanceof NotReadyError) {
637
+ const source = error.source;
638
+ if (!activeTransition._asyncNodes.includes(source)) {
639
+ activeTransition._asyncNodes.push(source);
640
+ }
641
+ }
642
+ const downstreamBlockStatus = blockStatus || startsBlocking;
643
+ const downstreamLane = blockStatus || isOptimisticBoundary ? void 0 : lane;
644
+ if (el._notifyStatus) {
645
+ if (downstreamBlockStatus) {
646
+ el._notifyStatus(status, error);
647
+ } else {
648
+ el._notifyStatus();
649
+ }
650
+ return;
651
+ }
652
+ for (let s = el._subs; s !== null; s = s._nextSub) {
653
+ s._sub._time = clock;
654
+ if (s._sub._error !== error) {
655
+ !s._sub._transition && globalQueue._pendingNodes.push(s._sub);
656
+ notifyStatus(s._sub, status, error, downstreamBlockStatus, downstreamLane);
657
+ }
658
+ }
659
+ for (let child = el._child; child !== null; child = child._nextChild) {
660
+ for (let s = child._subs; s !== null; s = s._nextSub) {
661
+ s._sub._time = clock;
662
+ if (s._sub._error !== error) {
663
+ !s._sub._transition && globalQueue._pendingNodes.push(s._sub);
664
+ notifyStatus(s._sub, status, error, downstreamBlockStatus, downstreamLane);
665
+ }
666
+ }
667
+ }
668
+ }
669
+ function unlinkSubs(link) {
670
+ const dep = link._dep;
671
+ const nextDep = link._nextDep;
672
+ const nextSub = link._nextSub;
673
+ const prevSub = link._prevSub;
674
+ if (nextSub !== null) nextSub._prevSub = prevSub;
675
+ else dep._subsTail = prevSub;
676
+ if (prevSub !== null) prevSub._nextSub = nextSub;
677
+ else {
678
+ dep._subs = nextSub;
679
+ if (nextSub === null) {
680
+ dep._unobserved?.();
681
+ dep._fn && !dep._preventAutoDisposal && !(dep._flags & REACTIVE_ZOMBIE) && unobserved(dep);
682
+ }
683
+ }
684
+ return nextDep;
685
+ }
686
+ function unobserved(el) {
687
+ deleteFromHeap(el, el._flags & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
688
+ let dep = el._deps;
689
+ while (dep !== null) {
690
+ dep = unlinkSubs(dep);
691
+ }
692
+ el._deps = null;
693
+ disposeChildren(el, true);
694
+ }
695
+ function markDisposal(el) {
696
+ let child = el._firstChild;
697
+ while (child) {
698
+ child._flags |= REACTIVE_ZOMBIE;
699
+ if (child._flags & REACTIVE_IN_HEAP) {
700
+ deleteFromHeap(child, dirtyQueue);
701
+ insertIntoHeap(child, zombieQueue);
702
+ }
703
+ markDisposal(child);
704
+ child = child._nextSibling;
705
+ }
706
+ }
707
+ function disposeChildren(node, self = false, zombie) {
708
+ if (node._flags & REACTIVE_DISPOSED) return;
709
+ if (self) node._flags = REACTIVE_DISPOSED;
710
+ let child = zombie ? node._pendingFirstChild : node._firstChild;
711
+ while (child) {
712
+ const nextChild = child._nextSibling;
713
+ if (child._deps) {
714
+ const n = child;
715
+ deleteFromHeap(n, n._flags & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
716
+ let toRemove = n._deps;
717
+ do {
718
+ toRemove = unlinkSubs(toRemove);
719
+ } while (toRemove !== null);
720
+ n._deps = null;
721
+ n._depsTail = null;
722
+ }
723
+ disposeChildren(child, true);
724
+ child = nextChild;
725
+ }
726
+ if (zombie) {
727
+ node._pendingFirstChild = null;
728
+ } else {
729
+ node._firstChild = null;
730
+ node._nextSibling = null;
731
+ node._childCount = 0;
732
+ }
733
+ runDisposal(node, zombie);
734
+ }
735
+ function runDisposal(node, zombie) {
736
+ let disposal = zombie ? node._pendingDisposal : node._disposal;
737
+ if (!disposal) return;
738
+ if (Array.isArray(disposal)) {
739
+ for (let i = 0; i < disposal.length; i++) {
740
+ const callable = disposal[i];
741
+ callable.call(callable);
742
+ }
743
+ } else {
744
+ disposal.call(disposal);
745
+ }
746
+ zombie ? node._pendingDisposal = null : node._disposal = null;
747
+ }
748
+ var leafEffectActive = false;
749
+ GlobalQueue._update = recompute;
750
+ GlobalQueue._dispose = disposeChildren;
751
+ var tracking = false;
752
+ var context = null;
753
+ var currentOptimisticLane = null;
754
+ function recompute(el, create = false) {
755
+ const isEffect = el._type;
756
+ if (!create) {
757
+ if (el._transition && (!isEffect || activeTransition) && activeTransition !== el._transition)
758
+ globalQueue.initTransition(el._transition);
759
+ deleteFromHeap(el, el._flags & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
760
+ if (el._transition || isEffect === EFFECT_TRACKED) disposeChildren(el);
761
+ else {
762
+ markDisposal(el);
763
+ el._pendingDisposal = el._disposal;
764
+ el._pendingFirstChild = el._firstChild;
765
+ el._disposal = null;
766
+ el._firstChild = null;
767
+ el._childCount = 0;
768
+ }
769
+ }
770
+ const isOptimisticDirty = !!(el._flags & REACTIVE_OPTIMISTIC_DIRTY);
771
+ const hasOverride = hasActiveOverride(el);
772
+ const wasPending = !!(el._statusFlags & STATUS_PENDING);
773
+ const oldcontext = context;
774
+ context = el;
775
+ el._depsTail = null;
776
+ el._flags = REACTIVE_RECOMPUTING_DEPS;
777
+ el._time = clock;
778
+ let value = el._pendingValue === NOT_PENDING ? el._value : el._pendingValue;
779
+ let oldHeight = el._height;
780
+ let prevTracking = tracking;
781
+ let prevLane = currentOptimisticLane;
782
+ let prevStrictRead = false;
783
+ {
784
+ prevStrictRead = strictRead;
785
+ strictRead = false;
786
+ }
787
+ tracking = true;
788
+ if (isOptimisticDirty) {
789
+ const lane = resolveLane(el);
790
+ if (lane) currentOptimisticLane = lane;
791
+ }
792
+ try {
793
+ value = handleAsync(el, el._fn(value));
794
+ clearStatus(el);
795
+ const resolvedLane = resolveLane(el);
796
+ if (resolvedLane) {
797
+ resolvedLane._pendingAsync.delete(el);
798
+ updatePendingSignal(resolvedLane._source);
799
+ }
800
+ } catch (e) {
801
+ if (e instanceof NotReadyError && currentOptimisticLane) {
802
+ const lane = findLane(currentOptimisticLane);
803
+ if (lane._source !== el) {
804
+ lane._pendingAsync.add(el);
805
+ el._optimisticLane = lane;
806
+ updatePendingSignal(lane._source);
807
+ }
808
+ }
809
+ notifyStatus(
810
+ el,
811
+ e instanceof NotReadyError ? STATUS_PENDING : STATUS_ERROR,
812
+ e,
813
+ void 0,
814
+ e instanceof NotReadyError ? el._optimisticLane : void 0
815
+ );
816
+ } finally {
817
+ tracking = prevTracking;
818
+ strictRead = prevStrictRead;
819
+ el._flags = REACTIVE_NONE | (create ? el._flags & REACTIVE_SNAPSHOT_STALE : 0);
820
+ context = oldcontext;
821
+ }
822
+ if (!el._error) {
823
+ const depsTail = el._depsTail;
824
+ let toRemove = depsTail !== null ? depsTail._nextDep : el._deps;
825
+ if (toRemove !== null) {
826
+ do {
827
+ toRemove = unlinkSubs(toRemove);
828
+ } while (toRemove !== null);
829
+ if (depsTail !== null) depsTail._nextDep = null;
830
+ else el._deps = null;
831
+ }
832
+ const compareValue = hasOverride ? el._value : el._pendingValue === NOT_PENDING ? el._value : el._pendingValue;
833
+ const valueChanged = !el._equals || !el._equals(compareValue, value);
834
+ if (valueChanged) {
835
+ const prevVisible = hasOverride ? el._value : void 0;
836
+ if (create || isEffect && activeTransition !== el._transition || isOptimisticDirty)
837
+ el._value = value;
838
+ else el._pendingValue = value;
839
+ if (hasOverride && !isOptimisticDirty && wasPending) {
840
+ const ov = el._overrideVersion || 0;
841
+ const lv = el._laneVersion || 0;
842
+ if (ov <= lv) el._value = value;
843
+ }
844
+ if (!hasOverride || isOptimisticDirty || el._value !== prevVisible) {
845
+ insertSubs(el, isOptimisticDirty || hasOverride);
846
+ }
847
+ } else if (hasOverride) {
848
+ el._pendingValue = value;
849
+ } else if (el._height != oldHeight) {
850
+ for (let s = el._subs; s !== null; s = s._nextSub) {
851
+ insertIntoHeapHeight(s._sub, s._sub._flags & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
852
+ }
853
+ }
854
+ }
855
+ currentOptimisticLane = prevLane;
856
+ (!create || el._statusFlags & STATUS_PENDING) && !el._transition && !(activeTransition && el._optimistic) && globalQueue._pendingNodes.push(el);
857
+ el._transition && isEffect && activeTransition !== el._transition && runInTransition(el._transition, () => recompute(el));
858
+ }
859
+ var strictRead = false;
860
+ function untrack(fn, strictReadLabel) {
861
+ if (!tracking && !strictRead && true) return fn();
862
+ const prevTracking = tracking;
863
+ const prevStrictRead = strictRead;
864
+ tracking = false;
865
+ strictRead = false;
866
+ try {
867
+ return fn();
868
+ } finally {
869
+ tracking = prevTracking;
870
+ strictRead = prevStrictRead;
871
+ }
872
+ }
873
+ function setSignal(el, v) {
874
+ if (!el._pureWrite && !leafEffectActive && context && el._firewall !== context)
875
+ console.warn("A Signal was written to in an owned scope.");
876
+ if (el._transition && activeTransition !== el._transition)
877
+ globalQueue.initTransition(el._transition);
878
+ const isOptimistic = el._optimistic && !projectionWriteActive;
879
+ const currentValue = isOptimistic ? el._value : el._pendingValue === NOT_PENDING ? el._value : el._pendingValue;
880
+ if (typeof v === "function") v = v(currentValue);
881
+ const valueChanged = !el._equals || !el._equals(currentValue, v) || !!(el._statusFlags & STATUS_UNINITIALIZED);
882
+ if (!valueChanged) {
883
+ if (isOptimistic && el._pendingValue !== NOT_PENDING && el._fn) {
884
+ insertSubs(el, true);
885
+ schedule();
886
+ }
887
+ return v;
888
+ }
889
+ if (isOptimistic) {
890
+ const alreadyTracked = globalQueue._optimisticNodes.includes(el);
891
+ if (el._transition && alreadyTracked) {
892
+ globalQueue.initTransition(el._transition);
893
+ }
894
+ if (el._pendingValue === NOT_PENDING) {
895
+ el._pendingValue = el._value;
896
+ }
897
+ if (!alreadyTracked) {
898
+ globalQueue._optimisticNodes.push(el);
899
+ }
900
+ el._overrideVersion = (el._overrideVersion || 0) + 1;
901
+ const lane = getOrCreateLane(el);
902
+ el._optimisticLane = lane;
903
+ el._value = v;
904
+ } else {
905
+ if (el._pendingValue === NOT_PENDING) globalQueue._pendingNodes.push(el);
906
+ el._pendingValue = v;
907
+ }
908
+ updatePendingSignal(el);
909
+ if (el._latestValueComputed) {
910
+ setSignal(el._latestValueComputed, v);
911
+ }
912
+ el._time = clock;
913
+ insertSubs(el, isOptimistic);
914
+ schedule();
915
+ return v;
916
+ }
917
+ function computePendingState(el) {
918
+ const comp = el;
919
+ if (el._optimistic && el._pendingValue !== NOT_PENDING) {
920
+ if (comp._statusFlags & STATUS_PENDING && !(comp._statusFlags & STATUS_UNINITIALIZED))
921
+ return true;
922
+ if (el._parentSource) {
923
+ const lane = el._optimisticLane ? findLane(el._optimisticLane) : null;
924
+ return !!(lane && lane._pendingAsync.size > 0);
925
+ }
926
+ return true;
927
+ }
928
+ if (el._pendingValue !== NOT_PENDING && !(comp._statusFlags & STATUS_UNINITIALIZED)) return true;
929
+ return !!(comp._statusFlags & STATUS_PENDING && !(comp._statusFlags & STATUS_UNINITIALIZED));
930
+ }
931
+ function updatePendingSignal(el) {
932
+ if (el._pendingSignal) {
933
+ const pending = computePendingState(el);
934
+ const sig = el._pendingSignal;
935
+ setSignal(sig, pending);
936
+ if (!pending && sig._optimisticLane) {
937
+ const sourceLane = resolveLane(el);
938
+ if (sourceLane && sourceLane._pendingAsync.size > 0) {
939
+ const sigLane = findLane(sig._optimisticLane);
940
+ if (sigLane !== sourceLane) {
941
+ mergeLanes(sourceLane, sigLane);
942
+ }
943
+ }
944
+ signalLanes.delete(sig);
945
+ sig._optimisticLane = void 0;
946
+ }
947
+ }
948
+ }
949
+ function isWrappable(obj) {
950
+ return obj != null && typeof obj === "object" && !Object.isFrozen(obj);
951
+ }
952
+ var DELETE = /* @__PURE__ */ Symbol("STORE_PATH_DELETE");
953
+ function updatePath(current, args, i = 0) {
954
+ let part, prev = current;
955
+ if (i < args.length - 1) {
956
+ part = args[i];
957
+ const partType = typeof part;
958
+ const isArray = Array.isArray(current);
959
+ if (Array.isArray(part)) {
960
+ for (let j = 0; j < part.length; j++) {
961
+ args[i] = part[j];
962
+ updatePath(current, args, i);
963
+ }
964
+ args[i] = part;
965
+ return;
966
+ } else if (isArray && partType === "function") {
967
+ for (let j = 0; j < current.length; j++) {
968
+ if (part(current[j], j)) {
969
+ args[i] = j;
970
+ updatePath(current, args, i);
971
+ }
972
+ }
973
+ args[i] = part;
974
+ return;
975
+ } else if (isArray && partType === "object") {
976
+ const { from = 0, to = current.length - 1, by = 1 } = part;
977
+ for (let j = from; j <= to; j += by) {
978
+ args[i] = j;
979
+ updatePath(current, args, i);
980
+ }
981
+ args[i] = part;
982
+ return;
983
+ } else if (i < args.length - 2) {
984
+ updatePath(current[part], args, i + 1);
985
+ return;
986
+ }
987
+ prev = current[part];
988
+ }
989
+ let value = args[args.length - 1];
990
+ if (typeof value === "function") {
991
+ value = value(prev);
992
+ if (value === prev) return;
993
+ }
994
+ if (part === void 0 && value == void 0) return;
995
+ if (value === DELETE) {
996
+ delete current[part];
997
+ } else if (part === void 0 || isWrappable(prev) && isWrappable(value) && !Array.isArray(value)) {
998
+ const target = part !== void 0 ? current[part] : current;
999
+ const keys = Object.keys(value);
1000
+ for (let i2 = 0; i2 < keys.length; i2++) target[keys[i2]] = value[keys[i2]];
1001
+ } else {
1002
+ current[part] = value;
1003
+ }
1004
+ }
1005
+ Object.assign(
1006
+ function storePath2(...args) {
1007
+ return (state) => {
1008
+ updatePath(state, args);
1009
+ };
1010
+ },
1011
+ { DELETE }
1012
+ );
1013
+
1014
+ // ../../node_modules/.pnpm/@solidjs+web@2.0.0-beta.2_@solidjs+signals@0.12.0_solid-js@2.0.0-beta.2/node_modules/@solidjs/web/dist/dev.js
1015
+ var effect = (fn, effectFn, initial) => createRenderEffect(fn, effectFn, initial, {
1016
+ transparent: true
1017
+ });
1018
+ function template(html, isImportNode, isSVG, isMathML) {
1019
+ let node;
1020
+ const create = (bypassGuard) => {
1021
+ if (isHydrating() && !bypassGuard) throw new Error("Failed attempt to create new DOM elements during hydration. Check that the libraries you are using support hydration.");
1022
+ const t = isMathML ? document.createElementNS("http://www.w3.org/1998/Math/MathML", "template") : document.createElement("template");
1023
+ t.innerHTML = html;
1024
+ return isSVG ? t.content.firstChild.firstChild : isMathML ? t.firstChild : t.content.firstChild;
1025
+ };
1026
+ const fn = isImportNode ? (bypassGuard) => untrack$1(() => document.importNode(node || (node = create(bypassGuard)), true)) : (bypassGuard) => (node || (node = create(bypassGuard))).cloneNode(true);
1027
+ fn._html = html;
1028
+ return fn;
1029
+ }
1030
+ function setAttribute(node, name, value) {
1031
+ if (isHydrating(node)) return;
1032
+ node.removeAttribute(name);
1033
+ }
1034
+ function style(node, value, prev) {
1035
+ if (!value) {
1036
+ if (prev) setAttribute(node, "style");
1037
+ return;
1038
+ }
1039
+ const nodeStyle = node.style;
1040
+ if (typeof value === "string") return nodeStyle.cssText = value;
1041
+ typeof prev === "string" && (nodeStyle.cssText = prev = void 0);
1042
+ prev || (prev = {});
1043
+ value || (value = {});
1044
+ let v, s;
1045
+ for (s in value) {
1046
+ v = value[s];
1047
+ if (v !== prev[s]) nodeStyle.setProperty(s, v);
1048
+ delete prev[s];
1049
+ }
1050
+ for (s in prev) value[s] == null && nodeStyle.removeProperty(s);
1051
+ }
1052
+ function applyRef(r, element) {
1053
+ Array.isArray(r) ? r.flat(Infinity).forEach((f) => f && f(element)) : r(element);
1054
+ }
1055
+ function ref(fn, element) {
1056
+ const resolved = untrack$1(fn);
1057
+ runWithOwner(null, () => applyRef(resolved, element));
1058
+ }
1059
+ function isHydrating(node) {
1060
+ return sharedConfig.hydrating && (!node || node.isConnected);
1061
+ }
1062
+ var isServer = false;
1063
+ var isDev = true;
1064
+
1065
+ export { effect, isDev, isServer, ref, style, template };