@solidjs/signals 0.7.4 → 0.8.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/dev.js +1036 -1402
- package/dist/node.cjs +1164 -1532
- package/dist/prod.js +1151 -1511
- package/dist/types/boundaries.d.ts +10 -8
- package/dist/types/core/constants.d.ts +22 -13
- package/dist/types/core/context.d.ts +28 -0
- package/dist/types/core/core.d.ts +96 -135
- package/dist/types/core/effect.d.ts +14 -42
- package/dist/types/core/error.d.ts +2 -1
- package/dist/types/core/heap.d.ts +15 -0
- package/dist/types/core/index.d.ts +4 -5
- package/dist/types/core/scheduler.d.ts +28 -54
- package/dist/types/index.d.ts +4 -4
- package/dist/types/map.d.ts +1 -1
- package/dist/types/signals.d.ts +5 -43
- package/dist/types/store/projection.d.ts +1 -2
- package/dist/types/store/store.d.ts +2 -2
- package/package.json +1 -1
- package/dist/types/core/flags.d.ts +0 -11
- package/dist/types/core/owner.d.ts +0 -95
package/dist/prod.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// src/core/error.ts
|
|
2
2
|
var NotReadyError = class extends Error {
|
|
3
|
-
constructor(
|
|
3
|
+
constructor(cause) {
|
|
4
4
|
super();
|
|
5
|
-
this.cause =
|
|
5
|
+
this.cause = cause;
|
|
6
6
|
}
|
|
7
7
|
};
|
|
8
8
|
var NoOwnerError = class extends Error {
|
|
@@ -19,944 +19,904 @@ var ContextNotFoundError = class extends Error {
|
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
// src/core/constants.ts
|
|
22
|
-
var
|
|
23
|
-
var STATE_CHECK = 1;
|
|
24
|
-
var STATE_DIRTY = 2;
|
|
25
|
-
var STATE_DISPOSED = 3;
|
|
26
|
-
var EFFECT_PURE = 0;
|
|
27
|
-
var EFFECT_RENDER = 1;
|
|
28
|
-
var EFFECT_USER = 2;
|
|
22
|
+
var NOT_PENDING = {};
|
|
29
23
|
var SUPPORTS_PROXY = typeof Proxy === "function";
|
|
30
24
|
|
|
31
|
-
// src/core/
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
25
|
+
// src/core/heap.ts
|
|
26
|
+
function actualInsertIntoHeap(n, heap) {
|
|
27
|
+
const parentHeight = (n.s?.Z ? n.s._?.e : n.s?.e) ?? -1;
|
|
28
|
+
if (parentHeight >= n.e)
|
|
29
|
+
n.e = parentHeight + 1;
|
|
30
|
+
const height = n.e;
|
|
31
|
+
const heapAtHeight = heap.o[height];
|
|
32
|
+
if (heapAtHeight === void 0) {
|
|
33
|
+
heap.o[height] = n;
|
|
34
|
+
} else {
|
|
35
|
+
const tail = heapAtHeight.x;
|
|
36
|
+
tail.O = n;
|
|
37
|
+
n.x = tail;
|
|
38
|
+
heapAtHeight.x = n;
|
|
39
|
+
}
|
|
40
|
+
if (height > heap.J) {
|
|
41
|
+
heap.J = height;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function insertIntoHeap(n, heap) {
|
|
45
|
+
let flags = n.b;
|
|
46
|
+
if (flags & (8 /* InHeap */ | 4 /* RecomputingDeps */))
|
|
47
|
+
return;
|
|
48
|
+
if (flags & 1 /* Check */) {
|
|
49
|
+
n.b = flags & ~(1 /* Check */ | 2 /* Dirty */) | 2 /* Dirty */ | 8 /* InHeap */;
|
|
50
|
+
} else
|
|
51
|
+
n.b = flags | 8 /* InHeap */;
|
|
52
|
+
if (!(flags & 16 /* InHeapHeight */)) {
|
|
53
|
+
actualInsertIntoHeap(n, heap);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function insertIntoHeapHeight(n, heap) {
|
|
57
|
+
let flags = n.b;
|
|
58
|
+
if (flags & (8 /* InHeap */ | 4 /* RecomputingDeps */ | 16 /* InHeapHeight */))
|
|
59
|
+
return;
|
|
60
|
+
n.b = flags | 16 /* InHeapHeight */;
|
|
61
|
+
actualInsertIntoHeap(n, heap);
|
|
62
|
+
}
|
|
63
|
+
function deleteFromHeap(n, heap) {
|
|
64
|
+
const flags = n.b;
|
|
65
|
+
if (!(flags & (8 /* InHeap */ | 16 /* InHeapHeight */)))
|
|
66
|
+
return;
|
|
67
|
+
n.b = flags & ~(8 /* InHeap */ | 16 /* InHeapHeight */);
|
|
68
|
+
const height = n.e;
|
|
69
|
+
if (n.x === n) {
|
|
70
|
+
heap.o[height] = void 0;
|
|
71
|
+
} else {
|
|
72
|
+
const next = n.O;
|
|
73
|
+
const dhh = heap.o[height];
|
|
74
|
+
const end = next ?? dhh;
|
|
75
|
+
if (n === dhh) {
|
|
76
|
+
heap.o[height] = next;
|
|
77
|
+
} else {
|
|
78
|
+
n.x.O = next;
|
|
79
|
+
}
|
|
80
|
+
end.x = n.x;
|
|
81
|
+
}
|
|
82
|
+
n.x = n;
|
|
83
|
+
n.O = void 0;
|
|
84
|
+
}
|
|
85
|
+
function markHeap(heap) {
|
|
86
|
+
if (heap.$)
|
|
87
|
+
return;
|
|
88
|
+
heap.$ = true;
|
|
89
|
+
for (let i = 0; i <= heap.J; i++) {
|
|
90
|
+
for (let el = heap.o[i]; el !== void 0; el = el.O) {
|
|
91
|
+
if (el.b & 8 /* InHeap */)
|
|
92
|
+
markNode(el);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function markNode(el, newState = 2 /* Dirty */) {
|
|
97
|
+
const flags = el.b;
|
|
98
|
+
if ((flags & (1 /* Check */ | 2 /* Dirty */)) >= newState)
|
|
99
|
+
return;
|
|
100
|
+
el.b = flags & ~(1 /* Check */ | 2 /* Dirty */) | newState;
|
|
101
|
+
for (let link2 = el.p; link2 !== null; link2 = link2.y) {
|
|
102
|
+
markNode(link2.m, 1 /* Check */);
|
|
103
|
+
}
|
|
104
|
+
if (el.aa !== null) {
|
|
105
|
+
for (let child = el.aa; child !== null; child = child.qa) {
|
|
106
|
+
for (let link2 = child.p; link2 !== null; link2 = link2.y) {
|
|
107
|
+
markNode(link2.m, 1 /* Check */);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function runHeap(heap, recompute2) {
|
|
113
|
+
heap.$ = false;
|
|
114
|
+
for (heap.t = 0; heap.t <= heap.J; heap.t++) {
|
|
115
|
+
let el = heap.o[heap.t];
|
|
116
|
+
while (el !== void 0) {
|
|
117
|
+
if (el.b & 8 /* InHeap */)
|
|
118
|
+
recompute2(el);
|
|
119
|
+
else {
|
|
120
|
+
adjustHeight(el, heap);
|
|
121
|
+
}
|
|
122
|
+
el = heap.o[heap.t];
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
heap.J = 0;
|
|
126
|
+
}
|
|
127
|
+
function adjustHeight(el, heap) {
|
|
128
|
+
deleteFromHeap(el, heap);
|
|
129
|
+
let newHeight = el.e;
|
|
130
|
+
for (let d = el.u; d; d = d.E) {
|
|
131
|
+
const dep1 = d.P;
|
|
132
|
+
const dep = "_owner" in dep1 ? dep1.z : dep1;
|
|
133
|
+
if ("_fn" in dep) {
|
|
134
|
+
if (dep.e >= newHeight) {
|
|
135
|
+
newHeight = dep.e + 1;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (el.e !== newHeight) {
|
|
140
|
+
el.e = newHeight;
|
|
141
|
+
for (let s = el.p; s !== null; s = s.y) {
|
|
142
|
+
insertIntoHeapHeight(s.m, heap);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
39
146
|
|
|
40
147
|
// src/core/scheduler.ts
|
|
41
148
|
var clock = 0;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
var ActiveTransition = null;
|
|
46
|
-
var Unobserved = [];
|
|
149
|
+
var activeTransition = null;
|
|
150
|
+
var unobserved = [];
|
|
151
|
+
var transitions = /* @__PURE__ */ new Set();
|
|
47
152
|
var scheduled = false;
|
|
48
153
|
function schedule() {
|
|
49
154
|
if (scheduled)
|
|
50
155
|
return;
|
|
51
156
|
scheduled = true;
|
|
52
|
-
if (!globalQueue.
|
|
157
|
+
if (!globalQueue.ba)
|
|
53
158
|
queueMicrotask(flush);
|
|
54
159
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
160
|
+
var dirtyQueue = {
|
|
161
|
+
o: new Array(2e3).fill(void 0),
|
|
162
|
+
$: false,
|
|
163
|
+
t: 0,
|
|
164
|
+
J: 0
|
|
165
|
+
};
|
|
166
|
+
var zombieQueue = {
|
|
167
|
+
o: new Array(2e3).fill(void 0),
|
|
168
|
+
$: false,
|
|
169
|
+
t: 0,
|
|
170
|
+
J: 0
|
|
171
|
+
};
|
|
64
172
|
var Queue = class {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
i = [];
|
|
173
|
+
s = null;
|
|
174
|
+
A = [[], []];
|
|
175
|
+
Q = [];
|
|
69
176
|
created = clock;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
177
|
+
addChild(child) {
|
|
178
|
+
this.Q.push(child);
|
|
179
|
+
child.s = this;
|
|
180
|
+
}
|
|
181
|
+
removeChild(child) {
|
|
182
|
+
const index = this.Q.indexOf(child);
|
|
183
|
+
if (index >= 0) {
|
|
184
|
+
this.Q.splice(index, 1);
|
|
185
|
+
child.s = null;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
notify(node, mask, flags) {
|
|
189
|
+
if (this.s)
|
|
190
|
+
return this.s.notify(node, mask, flags);
|
|
191
|
+
return false;
|
|
75
192
|
}
|
|
76
193
|
run(type) {
|
|
77
|
-
if (type
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
return;
|
|
81
|
-
} else if (this.h[type - 1].length) {
|
|
82
|
-
const effects = this.h[type - 1];
|
|
83
|
-
this.h[type - 1] = [];
|
|
194
|
+
if (this.A[type - 1].length) {
|
|
195
|
+
const effects = this.A[type - 1];
|
|
196
|
+
this.A[type - 1] = [];
|
|
84
197
|
runQueue(effects, type);
|
|
85
198
|
}
|
|
86
|
-
for (let i = 0; i < this.
|
|
87
|
-
this.
|
|
199
|
+
for (let i = 0; i < this.Q.length; i++) {
|
|
200
|
+
this.Q[i].run(type);
|
|
88
201
|
}
|
|
89
202
|
}
|
|
203
|
+
enqueue(type, fn) {
|
|
204
|
+
if (type)
|
|
205
|
+
this.A[type - 1].push(fn);
|
|
206
|
+
schedule();
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
var GlobalQueue = class _GlobalQueue extends Queue {
|
|
210
|
+
ba = false;
|
|
211
|
+
h = [];
|
|
212
|
+
static R;
|
|
213
|
+
static ka;
|
|
90
214
|
flush() {
|
|
91
|
-
if (this.
|
|
215
|
+
if (this.ba)
|
|
92
216
|
return;
|
|
93
|
-
this.
|
|
217
|
+
this.ba = true;
|
|
94
218
|
try {
|
|
95
|
-
|
|
96
|
-
|
|
219
|
+
runHeap(dirtyQueue, _GlobalQueue.R);
|
|
220
|
+
if (activeTransition) {
|
|
221
|
+
if (!transitionComplete(activeTransition)) {
|
|
222
|
+
runHeap(zombieQueue, _GlobalQueue.R);
|
|
223
|
+
globalQueue.h = [];
|
|
224
|
+
activeTransition.queues[0].push(...globalQueue.A[0]);
|
|
225
|
+
activeTransition.queues[1].push(...globalQueue.A[1]);
|
|
226
|
+
globalQueue.A = [[], []];
|
|
227
|
+
clock++;
|
|
228
|
+
scheduled = false;
|
|
229
|
+
runPending(activeTransition.pendingNodes, true);
|
|
230
|
+
activeTransition = null;
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
globalQueue.h.push(...activeTransition.pendingNodes);
|
|
234
|
+
globalQueue.A[0].push(...activeTransition.queues[0]);
|
|
235
|
+
globalQueue.A[1].push(...activeTransition.queues[1]);
|
|
236
|
+
transitions.delete(activeTransition);
|
|
237
|
+
activeTransition = null;
|
|
238
|
+
if (runPending(globalQueue.h, false))
|
|
239
|
+
runHeap(dirtyQueue, _GlobalQueue.R);
|
|
240
|
+
} else if (transitions.size)
|
|
241
|
+
runHeap(zombieQueue, _GlobalQueue.R);
|
|
242
|
+
for (let i = 0; i < globalQueue.h.length; i++) {
|
|
243
|
+
const n = globalQueue.h[i];
|
|
244
|
+
if (n.d !== NOT_PENDING) {
|
|
245
|
+
n.g = n.d;
|
|
246
|
+
n.d = NOT_PENDING;
|
|
247
|
+
}
|
|
248
|
+
if (n.ha)
|
|
249
|
+
_GlobalQueue.ka(n, false, true);
|
|
250
|
+
}
|
|
251
|
+
globalQueue.h.length = 0;
|
|
252
|
+
clock++;
|
|
97
253
|
scheduled = false;
|
|
98
|
-
this.run(
|
|
99
|
-
this.run(
|
|
254
|
+
this.run(1 /* Render */);
|
|
255
|
+
this.run(2 /* User */);
|
|
100
256
|
} finally {
|
|
101
|
-
this.
|
|
102
|
-
|
|
257
|
+
this.ba = false;
|
|
258
|
+
unobserved.length && notifyUnobserved();
|
|
103
259
|
}
|
|
104
260
|
}
|
|
105
|
-
|
|
106
|
-
if (
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
if (ActiveTransition && ActiveTransition.J.has(this))
|
|
113
|
-
return ActiveTransition.J.get(this).removeChild(child);
|
|
114
|
-
const index = this.i.indexOf(child);
|
|
115
|
-
if (index >= 0) {
|
|
116
|
-
this.i.splice(index, 1);
|
|
117
|
-
child.l = null;
|
|
261
|
+
notify(node, mask, flags) {
|
|
262
|
+
if (mask & 1 /* Pending */) {
|
|
263
|
+
if (flags & 1 /* Pending */) {
|
|
264
|
+
if (activeTransition && !activeTransition.asyncNodes.includes(node.B.cause))
|
|
265
|
+
activeTransition.asyncNodes.push(node.B.cause);
|
|
266
|
+
}
|
|
267
|
+
return true;
|
|
118
268
|
}
|
|
119
|
-
}
|
|
120
|
-
notify(...args) {
|
|
121
|
-
if (this.l)
|
|
122
|
-
return this.l.notify(...args);
|
|
123
269
|
return false;
|
|
124
270
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
271
|
+
initTransition(node) {
|
|
272
|
+
if (activeTransition && activeTransition.time === clock)
|
|
273
|
+
return;
|
|
274
|
+
if (!activeTransition) {
|
|
275
|
+
activeTransition = node.S ?? {
|
|
276
|
+
time: clock,
|
|
277
|
+
pendingNodes: [],
|
|
278
|
+
asyncNodes: [],
|
|
279
|
+
queues: [[], []]
|
|
280
|
+
};
|
|
134
281
|
}
|
|
282
|
+
transitions.add(activeTransition);
|
|
283
|
+
activeTransition.time = clock;
|
|
284
|
+
for (let i = 0; i < globalQueue.h.length; i++) {
|
|
285
|
+
const n = globalQueue.h[i];
|
|
286
|
+
n.S = activeTransition;
|
|
287
|
+
activeTransition.pendingNodes.push(n);
|
|
288
|
+
}
|
|
289
|
+
globalQueue.h = activeTransition.pendingNodes;
|
|
135
290
|
}
|
|
136
291
|
};
|
|
137
|
-
|
|
292
|
+
function runPending(pendingNodes, value) {
|
|
293
|
+
let needsReset = false;
|
|
294
|
+
const p = pendingNodes.slice();
|
|
295
|
+
for (let i = 0; i < p.length; i++) {
|
|
296
|
+
const n = p[i];
|
|
297
|
+
n.S = activeTransition;
|
|
298
|
+
if (n.G) {
|
|
299
|
+
n.G.ca(value);
|
|
300
|
+
needsReset = true;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
return needsReset;
|
|
304
|
+
}
|
|
305
|
+
var globalQueue = new GlobalQueue();
|
|
138
306
|
function flush() {
|
|
139
307
|
while (scheduled) {
|
|
140
308
|
globalQueue.flush();
|
|
141
309
|
}
|
|
142
310
|
}
|
|
143
|
-
function removeSourceObservers(node, index) {
|
|
144
|
-
let source;
|
|
145
|
-
let swap;
|
|
146
|
-
for (let i = index; i < node.b.length; i++) {
|
|
147
|
-
source = getTransitionSource(node.b[i]);
|
|
148
|
-
if (source.c) {
|
|
149
|
-
if ((swap = source.c.indexOf(node)) !== -1) {
|
|
150
|
-
source.c[swap] = source.c[source.c.length - 1];
|
|
151
|
-
source.c.pop();
|
|
152
|
-
}
|
|
153
|
-
if (!source.c.length)
|
|
154
|
-
Unobserved.push(source);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
311
|
function runQueue(queue, type) {
|
|
159
312
|
for (let i = 0; i < queue.length; i++)
|
|
160
313
|
queue[i](type);
|
|
161
314
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
h = [[], []];
|
|
169
|
-
J = /* @__PURE__ */ new Map();
|
|
170
|
-
G = [];
|
|
171
|
-
i = [];
|
|
172
|
-
l = null;
|
|
173
|
-
C = false;
|
|
174
|
-
Y = false;
|
|
175
|
-
d = globalQueue;
|
|
176
|
-
aa;
|
|
177
|
-
created = clock;
|
|
178
|
-
constructor(signal) {
|
|
179
|
-
this.aa = signal;
|
|
180
|
-
this.J.set(globalQueue, this);
|
|
181
|
-
for (const child of globalQueue.i) {
|
|
182
|
-
cloneQueue(child, this, this);
|
|
315
|
+
function transitionComplete(transition) {
|
|
316
|
+
let done = true;
|
|
317
|
+
for (let i = 0; i < transition.asyncNodes.length; i++) {
|
|
318
|
+
if (transition.asyncNodes[i].f & 1 /* Pending */) {
|
|
319
|
+
done = false;
|
|
320
|
+
break;
|
|
183
321
|
}
|
|
184
322
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
if (type === EFFECT_PURE) {
|
|
193
|
-
this.G.length && runQueue(this.G, type);
|
|
194
|
-
this.G = [];
|
|
195
|
-
return;
|
|
196
|
-
} else if (this.h[type - 1].length) {
|
|
197
|
-
const effects = this.h[type - 1];
|
|
198
|
-
this.h[type - 1] = [];
|
|
199
|
-
runQueue(effects, type);
|
|
200
|
-
}
|
|
201
|
-
for (let i = 0; i < this.i.length; i++) {
|
|
202
|
-
this.i[i].run(type);
|
|
203
|
-
}
|
|
323
|
+
return done;
|
|
324
|
+
}
|
|
325
|
+
function notifyUnobserved() {
|
|
326
|
+
for (let i = 0; i < unobserved.length; i++) {
|
|
327
|
+
const source = unobserved[i];
|
|
328
|
+
if (!source.p)
|
|
329
|
+
unobserved[i].ra?.();
|
|
204
330
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
331
|
+
unobserved = [];
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// src/core/core.ts
|
|
335
|
+
GlobalQueue.R = recompute;
|
|
336
|
+
GlobalQueue.ka = disposeChildren;
|
|
337
|
+
var tracking = false;
|
|
338
|
+
var stale = false;
|
|
339
|
+
var pendingValueCheck = false;
|
|
340
|
+
var pendingCheck = null;
|
|
341
|
+
var context = null;
|
|
342
|
+
var defaultContext = {};
|
|
343
|
+
function recompute(el, create = false) {
|
|
344
|
+
deleteFromHeap(el, el.b & 32 /* Zombie */ ? zombieQueue : dirtyQueue);
|
|
345
|
+
if (el.d !== NOT_PENDING || el.T || el.U)
|
|
346
|
+
disposeChildren(el);
|
|
347
|
+
else {
|
|
348
|
+
markDisposal(el);
|
|
349
|
+
globalQueue.h.push(el);
|
|
350
|
+
el.U = el.q;
|
|
351
|
+
el.T = el.n;
|
|
352
|
+
el.q = null;
|
|
353
|
+
el.n = null;
|
|
354
|
+
}
|
|
355
|
+
const oldcontext = context;
|
|
356
|
+
context = el;
|
|
357
|
+
el.H = null;
|
|
358
|
+
el.b = 4 /* RecomputingDeps */;
|
|
359
|
+
el.V = clock;
|
|
360
|
+
let value = el.d === NOT_PENDING ? el.g : el.d;
|
|
361
|
+
let oldHeight = el.e;
|
|
362
|
+
let prevStatusFlags = el.f;
|
|
363
|
+
let prevError = el.B;
|
|
364
|
+
let prevTracking = tracking;
|
|
365
|
+
clearStatusFlags(el);
|
|
366
|
+
tracking = true;
|
|
367
|
+
try {
|
|
368
|
+
value = el.ha(value);
|
|
369
|
+
} catch (e) {
|
|
370
|
+
if (e instanceof NotReadyError) {
|
|
371
|
+
if (e.cause !== el)
|
|
372
|
+
link(e.cause, el);
|
|
373
|
+
setStatusFlags(el, prevStatusFlags & ~2 /* Error */ | 1 /* Pending */, e);
|
|
374
|
+
} else {
|
|
375
|
+
setError(el, e);
|
|
221
376
|
}
|
|
377
|
+
} finally {
|
|
378
|
+
tracking = prevTracking;
|
|
222
379
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
if (!(type & LOADING_BIT))
|
|
234
|
-
return false;
|
|
235
|
-
if (flags & LOADING_BIT) {
|
|
236
|
-
this.t.add(node);
|
|
380
|
+
el.b = 0 /* None */;
|
|
381
|
+
context = oldcontext;
|
|
382
|
+
const depsTail = el.H;
|
|
383
|
+
let toRemove = depsTail !== null ? depsTail.E : el.u;
|
|
384
|
+
if (toRemove !== null) {
|
|
385
|
+
do {
|
|
386
|
+
toRemove = unlinkSubs(toRemove);
|
|
387
|
+
} while (toRemove !== null);
|
|
388
|
+
if (depsTail !== null) {
|
|
389
|
+
depsTail.E = null;
|
|
237
390
|
} else {
|
|
238
|
-
|
|
391
|
+
el.u = null;
|
|
239
392
|
}
|
|
240
|
-
return true;
|
|
241
393
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
else
|
|
254
|
-
this.addChild(queue.i[i]);
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
schedule() {
|
|
258
|
-
if (this.Y)
|
|
259
|
-
return;
|
|
260
|
-
this.Y = true;
|
|
261
|
-
if (!this.C)
|
|
262
|
-
queueMicrotask(() => this.flush());
|
|
263
|
-
}
|
|
264
|
-
runTransition(fn, force = false) {
|
|
265
|
-
if (this.D) {
|
|
266
|
-
if (this.D instanceof _Transition)
|
|
267
|
-
return this.D.runTransition(fn, force);
|
|
268
|
-
if (!force)
|
|
269
|
-
throw new Error("Transition already completed");
|
|
270
|
-
fn();
|
|
271
|
-
return;
|
|
272
|
-
}
|
|
273
|
-
ActiveTransition = this;
|
|
274
|
-
try {
|
|
275
|
-
let result = fn();
|
|
276
|
-
let transition2 = ActiveTransition;
|
|
277
|
-
if (result?.next) {
|
|
278
|
-
(async function() {
|
|
279
|
-
let temp, value;
|
|
280
|
-
while (!(temp = result.next(value)).done) {
|
|
281
|
-
transition2 = ActiveTransition;
|
|
282
|
-
if (temp.value instanceof Promise) {
|
|
283
|
-
transition2.K.add(temp.value);
|
|
284
|
-
try {
|
|
285
|
-
value = await temp.value;
|
|
286
|
-
} finally {
|
|
287
|
-
transition2 = latestTransition(transition2);
|
|
288
|
-
transition2.K.delete(temp.value);
|
|
289
|
-
}
|
|
290
|
-
ActiveTransition = transition2;
|
|
291
|
-
} else
|
|
292
|
-
value = temp.value;
|
|
293
|
-
}
|
|
294
|
-
ActiveTransition = null;
|
|
295
|
-
finishTransition(transition2);
|
|
296
|
-
})();
|
|
297
|
-
}
|
|
298
|
-
if (result instanceof Promise) {
|
|
299
|
-
transition2.K.add(result);
|
|
300
|
-
result.finally(() => {
|
|
301
|
-
transition2 = latestTransition(transition2);
|
|
302
|
-
transition2.K.delete(result);
|
|
303
|
-
ActiveTransition = null;
|
|
304
|
-
finishTransition(transition2);
|
|
305
|
-
});
|
|
394
|
+
const valueChanged = !el.da || !el.da(el.d === NOT_PENDING ? el.g : el.d, value);
|
|
395
|
+
const statusFlagsChanged = el.f !== prevStatusFlags || el.B !== prevError;
|
|
396
|
+
el.la?.(statusFlagsChanged, prevStatusFlags);
|
|
397
|
+
if (valueChanged || statusFlagsChanged) {
|
|
398
|
+
if (valueChanged) {
|
|
399
|
+
if (create || el.ia || el.I)
|
|
400
|
+
el.g = value;
|
|
401
|
+
else {
|
|
402
|
+
if (el.d === NOT_PENDING)
|
|
403
|
+
globalQueue.h.push(el);
|
|
404
|
+
el.d = value;
|
|
306
405
|
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
ActiveTransition = null;
|
|
310
|
-
finishTransition(transition2);
|
|
406
|
+
if (el.C)
|
|
407
|
+
el.C.ca(value);
|
|
311
408
|
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
return;
|
|
409
|
+
for (let s = el.p; s !== null; s = s.y) {
|
|
410
|
+
const queue = s.m.b & 32 /* Zombie */ ? zombieQueue : dirtyQueue;
|
|
411
|
+
if (s.m.e < el.e && queue.t > s.m.e)
|
|
412
|
+
queue.t = s.m.e;
|
|
413
|
+
insertIntoHeap(s.m, queue);
|
|
318
414
|
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
};
|
|
323
|
-
function cloneGraph(node) {
|
|
324
|
-
if (node.j) {
|
|
325
|
-
if (node.a !== STATE_DISPOSED) {
|
|
326
|
-
node.j.ia?.();
|
|
327
|
-
ActiveTransition.addOptimistic(node.j);
|
|
415
|
+
} else if (el.e != oldHeight) {
|
|
416
|
+
for (let s = el.p; s !== null; s = s.y) {
|
|
417
|
+
insertIntoHeapHeight(s.m, s.m.b & 32 /* Zombie */ ? zombieQueue : dirtyQueue);
|
|
328
418
|
}
|
|
329
|
-
return node;
|
|
330
419
|
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
c: null,
|
|
343
|
-
b: node.b ? [...node.b] : null,
|
|
344
|
-
d: node
|
|
345
|
-
});
|
|
346
|
-
delete clone.T;
|
|
347
|
-
ActiveTransition.b.set(node, clone);
|
|
348
|
-
node.f = ActiveTransition;
|
|
349
|
-
if (node.b) {
|
|
350
|
-
for (let i = 0; i < node.b.length; i++)
|
|
351
|
-
node.b[i].c.push(clone);
|
|
352
|
-
}
|
|
353
|
-
if (node.c) {
|
|
354
|
-
clone.c = [];
|
|
355
|
-
for (let i = 0, length = node.c.length; i < length; i++) {
|
|
356
|
-
!node.c[i].d && clone.c.push(cloneGraph(node.c[i]));
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
return clone;
|
|
360
|
-
}
|
|
361
|
-
function latestTransition(t) {
|
|
362
|
-
while (t.D instanceof Transition)
|
|
363
|
-
t = t.D;
|
|
364
|
-
return t;
|
|
365
|
-
}
|
|
366
|
-
function replaceSourceObservers(node, transition2) {
|
|
367
|
-
let source;
|
|
368
|
-
let transitionSource;
|
|
369
|
-
let swap;
|
|
370
|
-
for (let i = 0; i < node.b.length; i++) {
|
|
371
|
-
transitionSource = transition2.b.get(node.b[i]);
|
|
372
|
-
source = transitionSource || node.b[i];
|
|
373
|
-
if (source.c && (swap = source.c.indexOf(node)) !== -1) {
|
|
374
|
-
source.c[swap] = transitionSource ? node.d : source.c[source.c.length - 1];
|
|
375
|
-
!transitionSource && source.c.pop();
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
function cloneQueue(queue, parent, transition2) {
|
|
380
|
-
const clone = Object.create(Object.getPrototypeOf(queue));
|
|
381
|
-
Object.assign(clone, queue, {
|
|
382
|
-
d: queue,
|
|
383
|
-
l: parent,
|
|
384
|
-
i: [],
|
|
385
|
-
enqueue(type, fn) {
|
|
386
|
-
transition2 = latestTransition(transition2);
|
|
387
|
-
transition2.enqueue(type, fn);
|
|
388
|
-
},
|
|
389
|
-
notify(node, type, flags) {
|
|
390
|
-
node = node.d || node;
|
|
391
|
-
if (!clone.L || type & LOADING_BIT) {
|
|
392
|
-
type &= ~LOADING_BIT;
|
|
393
|
-
transition2 = latestTransition(transition2);
|
|
394
|
-
transition2.notify(node, LOADING_BIT, flags);
|
|
395
|
-
if (!type)
|
|
396
|
-
return true;
|
|
420
|
+
}
|
|
421
|
+
function updateIfNecessary(el) {
|
|
422
|
+
if (el.b & 1 /* Check */) {
|
|
423
|
+
for (let d = el.u; d; d = d.E) {
|
|
424
|
+
const dep1 = d.P;
|
|
425
|
+
const dep = "_owner" in dep1 ? dep1.z : dep1;
|
|
426
|
+
if ("_fn" in dep) {
|
|
427
|
+
updateIfNecessary(dep);
|
|
428
|
+
}
|
|
429
|
+
if (el.b & 2 /* Dirty */) {
|
|
430
|
+
break;
|
|
397
431
|
}
|
|
398
|
-
return queue.notify.call(this, node, type, flags);
|
|
399
|
-
}
|
|
400
|
-
});
|
|
401
|
-
parent.i.push(clone);
|
|
402
|
-
transition2.J.set(queue, clone);
|
|
403
|
-
for (const child of queue.i) {
|
|
404
|
-
cloneQueue(child, clone, transition2);
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
function resolveQueues(children) {
|
|
408
|
-
for (const child of children) {
|
|
409
|
-
const og = child.d;
|
|
410
|
-
if (og) {
|
|
411
|
-
const clonedChildren = child.i;
|
|
412
|
-
delete child.enqueue;
|
|
413
|
-
delete child.notify;
|
|
414
|
-
delete child.l;
|
|
415
|
-
delete child.i;
|
|
416
|
-
Object.assign(og, child);
|
|
417
|
-
delete og.d;
|
|
418
|
-
resolveQueues(clonedChildren);
|
|
419
|
-
} else if (child.l.d) {
|
|
420
|
-
child.l.d.addChild(child);
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
function mergeTransitions(t1, t2) {
|
|
425
|
-
t2.b.forEach((value, key) => {
|
|
426
|
-
key.f = t1;
|
|
427
|
-
t1.b.set(key, value);
|
|
428
|
-
});
|
|
429
|
-
t2.j.forEach((c) => {
|
|
430
|
-
c.f = t1;
|
|
431
|
-
t1.j.add(c);
|
|
432
|
-
});
|
|
433
|
-
t2.K.forEach((p) => t1.K.add(p));
|
|
434
|
-
t2.t.forEach((n) => t1.t.add(n));
|
|
435
|
-
t1.merge(t2);
|
|
436
|
-
t2.D = t1;
|
|
437
|
-
}
|
|
438
|
-
function getTransitionSource(input) {
|
|
439
|
-
return ActiveTransition && ActiveTransition.b.get(input) || input;
|
|
440
|
-
}
|
|
441
|
-
function getQueue(node) {
|
|
442
|
-
const transition2 = ActiveTransition || node.d?.f;
|
|
443
|
-
return transition2 && transition2.J.get(node.E) || node.E;
|
|
444
|
-
}
|
|
445
|
-
function initialDispose(node) {
|
|
446
|
-
let current = node.n;
|
|
447
|
-
while (current !== null && current.l === node) {
|
|
448
|
-
initialDispose(current);
|
|
449
|
-
const clone = ActiveTransition.b.get(current);
|
|
450
|
-
if (clone && !clone.Z)
|
|
451
|
-
clone.dispose(true);
|
|
452
|
-
current = current.n;
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
function finishTransition(transition2) {
|
|
456
|
-
if (transition2.D || transition2.Y || transition2.K.size || transition2.t.size)
|
|
457
|
-
return;
|
|
458
|
-
globalQueue.h[0].push.apply(globalQueue.h[0], transition2.h[0]);
|
|
459
|
-
globalQueue.h[1].push.apply(globalQueue.h[1], transition2.h[1]);
|
|
460
|
-
resolveQueues(transition2.i);
|
|
461
|
-
for (const [source, clone] of transition2.b) {
|
|
462
|
-
if (source === clone || source.f !== transition2) {
|
|
463
|
-
delete source.f;
|
|
464
|
-
continue;
|
|
465
|
-
}
|
|
466
|
-
if (clone.b)
|
|
467
|
-
replaceSourceObservers(clone, transition2);
|
|
468
|
-
if (clone.Z || clone.a === STATE_DISPOSED) {
|
|
469
|
-
source.dispose(clone.a === STATE_DISPOSED);
|
|
470
|
-
source.emptyDisposal();
|
|
471
|
-
delete clone.Z;
|
|
472
|
-
} else {
|
|
473
|
-
delete clone.n;
|
|
474
|
-
delete clone.o;
|
|
475
|
-
}
|
|
476
|
-
Object.assign(source, clone);
|
|
477
|
-
delete source.d;
|
|
478
|
-
let current = clone.n;
|
|
479
|
-
if (current?.z === clone)
|
|
480
|
-
current.z = source;
|
|
481
|
-
while (current?.l === clone) {
|
|
482
|
-
current.l = source;
|
|
483
|
-
current = current.n;
|
|
484
432
|
}
|
|
485
|
-
delete source.f;
|
|
486
433
|
}
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
delete reset.f;
|
|
490
|
-
reset();
|
|
434
|
+
if (el.b & 2 /* Dirty */) {
|
|
435
|
+
recompute(el);
|
|
491
436
|
}
|
|
492
|
-
|
|
493
|
-
globalQueue.flush();
|
|
437
|
+
el.b = 0 /* None */;
|
|
494
438
|
}
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
!skipAppend && currentOwner.append(this);
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
append(child) {
|
|
527
|
-
child.l = this;
|
|
528
|
-
child.z = this;
|
|
529
|
-
if (this.n)
|
|
530
|
-
this.n.z = child;
|
|
531
|
-
child.n = this.n;
|
|
532
|
-
this.n = child;
|
|
533
|
-
if (this.id != null && child.id == null)
|
|
534
|
-
child.id = this.getNextChildId();
|
|
535
|
-
if (child.A !== this.A) {
|
|
536
|
-
child.A = { ...this.A, ...child.A };
|
|
537
|
-
}
|
|
538
|
-
if (this.E)
|
|
539
|
-
child.E = this.E;
|
|
540
|
-
}
|
|
541
|
-
dispose(self = true) {
|
|
542
|
-
if (this.a === STATE_DISPOSED)
|
|
543
|
-
return;
|
|
544
|
-
let head = self ? this.z || this.l : this, current = this.n, next = null;
|
|
545
|
-
while (current && current.l === this) {
|
|
546
|
-
current.dispose(true);
|
|
547
|
-
next = current.n;
|
|
548
|
-
current.n = null;
|
|
549
|
-
current = next;
|
|
550
|
-
}
|
|
551
|
-
this.ga = 0;
|
|
552
|
-
if (self)
|
|
553
|
-
this.M();
|
|
554
|
-
if (current)
|
|
555
|
-
current.z = !self ? this : this.z;
|
|
556
|
-
if (head)
|
|
557
|
-
head.n = current;
|
|
558
|
-
}
|
|
559
|
-
M() {
|
|
560
|
-
if (this.z)
|
|
561
|
-
this.z.n = null;
|
|
562
|
-
this.l = null;
|
|
563
|
-
this.z = null;
|
|
564
|
-
this.A = defaultContext;
|
|
565
|
-
this.a = STATE_DISPOSED;
|
|
566
|
-
this.emptyDisposal();
|
|
567
|
-
}
|
|
568
|
-
emptyDisposal() {
|
|
569
|
-
if (!this.o)
|
|
439
|
+
function unlinkSubs(link2) {
|
|
440
|
+
const dep = link2.P;
|
|
441
|
+
const nextDep = link2.E;
|
|
442
|
+
const nextSub = link2.y;
|
|
443
|
+
const prevSub = link2.ma;
|
|
444
|
+
if (nextSub !== null) {
|
|
445
|
+
nextSub.ma = prevSub;
|
|
446
|
+
} else {
|
|
447
|
+
dep.W = prevSub;
|
|
448
|
+
}
|
|
449
|
+
if (prevSub !== null) {
|
|
450
|
+
prevSub.y = nextSub;
|
|
451
|
+
} else {
|
|
452
|
+
dep.p = nextSub;
|
|
453
|
+
}
|
|
454
|
+
return nextDep;
|
|
455
|
+
}
|
|
456
|
+
function link(dep, sub) {
|
|
457
|
+
const prevDep = sub.H;
|
|
458
|
+
if (prevDep !== null && prevDep.P === dep) {
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
let nextDep = null;
|
|
462
|
+
const isRecomputing = sub.b & 4 /* RecomputingDeps */;
|
|
463
|
+
if (isRecomputing) {
|
|
464
|
+
nextDep = prevDep !== null ? prevDep.E : sub.u;
|
|
465
|
+
if (nextDep !== null && nextDep.P === dep) {
|
|
466
|
+
sub.H = nextDep;
|
|
570
467
|
return;
|
|
571
|
-
if (Array.isArray(this.o)) {
|
|
572
|
-
for (let i = 0; i < this.o.length; i++) {
|
|
573
|
-
const callable = this.o[i];
|
|
574
|
-
callable.call(callable);
|
|
575
|
-
}
|
|
576
|
-
} else {
|
|
577
|
-
this.o.call(this.o);
|
|
578
468
|
}
|
|
579
|
-
this.o = null;
|
|
580
469
|
}
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
throw new Error("Cannot get child id from owner without an id");
|
|
470
|
+
const prevSub = dep.W;
|
|
471
|
+
if (prevSub !== null && prevSub.m === sub && (!isRecomputing || isValidLink(prevSub, sub))) {
|
|
472
|
+
return;
|
|
585
473
|
}
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
474
|
+
const newLink = sub.H = dep.W = {
|
|
475
|
+
P: dep,
|
|
476
|
+
m: sub,
|
|
477
|
+
E: nextDep,
|
|
478
|
+
ma: prevSub,
|
|
479
|
+
y: null
|
|
480
|
+
};
|
|
481
|
+
if (prevDep !== null) {
|
|
482
|
+
prevDep.E = newLink;
|
|
483
|
+
} else {
|
|
484
|
+
sub.u = newLink;
|
|
593
485
|
}
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
486
|
+
if (prevSub !== null) {
|
|
487
|
+
prevSub.y = newLink;
|
|
488
|
+
} else {
|
|
489
|
+
dep.p = newLink;
|
|
597
490
|
}
|
|
598
|
-
return value;
|
|
599
491
|
}
|
|
600
|
-
function
|
|
601
|
-
|
|
602
|
-
|
|
492
|
+
function isValidLink(checkLink, sub) {
|
|
493
|
+
const depsTail = sub.H;
|
|
494
|
+
if (depsTail !== null) {
|
|
495
|
+
let link2 = sub.u;
|
|
496
|
+
do {
|
|
497
|
+
if (link2 === checkLink) {
|
|
498
|
+
return true;
|
|
499
|
+
}
|
|
500
|
+
if (link2 === depsTail) {
|
|
501
|
+
break;
|
|
502
|
+
}
|
|
503
|
+
link2 = link2.E;
|
|
504
|
+
} while (link2 !== null);
|
|
603
505
|
}
|
|
604
|
-
|
|
605
|
-
...owner.A,
|
|
606
|
-
[context.id]: isUndefined(value) ? context.defaultValue : value
|
|
607
|
-
};
|
|
506
|
+
return false;
|
|
608
507
|
}
|
|
609
|
-
function
|
|
610
|
-
|
|
508
|
+
function setStatusFlags(signal2, flags, error = null) {
|
|
509
|
+
signal2.f = flags;
|
|
510
|
+
signal2.B = error;
|
|
611
511
|
}
|
|
612
|
-
function
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
512
|
+
function setError(signal2, error) {
|
|
513
|
+
setStatusFlags(signal2, 2 /* Error */ | 4 /* Uninitialized */, error);
|
|
514
|
+
}
|
|
515
|
+
function clearStatusFlags(signal2) {
|
|
516
|
+
setStatusFlags(signal2, 0 /* None */);
|
|
517
|
+
}
|
|
518
|
+
function markDisposal(el) {
|
|
519
|
+
let child = el.n;
|
|
520
|
+
while (child) {
|
|
521
|
+
child.b |= 32 /* Zombie */;
|
|
522
|
+
const inHeap = child.b & 8 /* InHeap */;
|
|
523
|
+
if (inHeap) {
|
|
524
|
+
deleteFromHeap(child, dirtyQueue);
|
|
525
|
+
insertIntoHeap(child, zombieQueue);
|
|
526
|
+
}
|
|
527
|
+
markDisposal(child);
|
|
528
|
+
child = child.K;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
function disposeChildren(node, self = false, zombie) {
|
|
532
|
+
if (node.b & 64 /* Disposed */)
|
|
533
|
+
return;
|
|
534
|
+
if (self)
|
|
535
|
+
node.b = 64 /* Disposed */;
|
|
536
|
+
let child = zombie ? node.T : node.n;
|
|
537
|
+
while (child) {
|
|
538
|
+
const nextChild = child.K;
|
|
539
|
+
if (child.u) {
|
|
540
|
+
const n = child;
|
|
541
|
+
deleteFromHeap(n, n.b & 32 /* Zombie */ ? zombieQueue : dirtyQueue);
|
|
542
|
+
let toRemove = n.u;
|
|
543
|
+
do {
|
|
544
|
+
toRemove = unlinkSubs(toRemove);
|
|
545
|
+
} while (toRemove !== null);
|
|
546
|
+
n.u = null;
|
|
547
|
+
n.H = null;
|
|
548
|
+
}
|
|
549
|
+
disposeChildren(child, true);
|
|
550
|
+
child = nextChild;
|
|
551
|
+
}
|
|
552
|
+
if (zombie) {
|
|
553
|
+
node.T = null;
|
|
620
554
|
} else {
|
|
621
|
-
node.
|
|
555
|
+
node.n = null;
|
|
556
|
+
node.K = null;
|
|
622
557
|
}
|
|
623
|
-
|
|
558
|
+
runDisposal(node, zombie);
|
|
559
|
+
}
|
|
560
|
+
function runDisposal(node, zombie) {
|
|
561
|
+
let disposal = zombie ? node.U : node.q;
|
|
562
|
+
if (!disposal)
|
|
563
|
+
return;
|
|
564
|
+
if (Array.isArray(disposal)) {
|
|
565
|
+
for (let i = 0; i < disposal.length; i++) {
|
|
566
|
+
const callable = disposal[i];
|
|
567
|
+
callable.call(callable);
|
|
568
|
+
}
|
|
569
|
+
} else {
|
|
570
|
+
disposal.call(disposal);
|
|
571
|
+
}
|
|
572
|
+
zombie ? node.U = null : node.q = null;
|
|
573
|
+
}
|
|
574
|
+
function withOptions(obj, options) {
|
|
575
|
+
obj.id = options?.id ?? (context?.id != null ? getNextChildId(context) : void 0);
|
|
576
|
+
obj.da = options?.equals != null ? options.equals : isEqual;
|
|
577
|
+
obj.xa = !!options?.pureWrite;
|
|
578
|
+
obj.ra = options?.unobserved;
|
|
579
|
+
if (options?.ja)
|
|
580
|
+
Object.assign(obj, options.ja);
|
|
581
|
+
return obj;
|
|
582
|
+
}
|
|
583
|
+
function getNextChildId(owner) {
|
|
584
|
+
if (owner.id != null)
|
|
585
|
+
return formatId(owner.id, owner.na++);
|
|
586
|
+
throw new Error("Cannot get child id from owner without an id");
|
|
624
587
|
}
|
|
625
588
|
function formatId(prefix, id) {
|
|
626
589
|
const num = id.toString(36), len = num.length - 1;
|
|
627
590
|
return prefix + (len ? String.fromCharCode(64 + len) : "") + num;
|
|
628
591
|
}
|
|
629
|
-
function
|
|
630
|
-
|
|
592
|
+
function computed(fn, initialValue, options) {
|
|
593
|
+
const self = withOptions(
|
|
594
|
+
{
|
|
595
|
+
q: null,
|
|
596
|
+
i: globalQueue,
|
|
597
|
+
D: defaultContext,
|
|
598
|
+
na: 0,
|
|
599
|
+
ha: fn,
|
|
600
|
+
g: initialValue,
|
|
601
|
+
e: 0,
|
|
602
|
+
aa: null,
|
|
603
|
+
O: void 0,
|
|
604
|
+
x: null,
|
|
605
|
+
u: null,
|
|
606
|
+
H: null,
|
|
607
|
+
p: null,
|
|
608
|
+
W: null,
|
|
609
|
+
s: context,
|
|
610
|
+
K: null,
|
|
611
|
+
n: null,
|
|
612
|
+
b: 0 /* None */,
|
|
613
|
+
f: 4 /* Uninitialized */,
|
|
614
|
+
V: clock,
|
|
615
|
+
d: NOT_PENDING,
|
|
616
|
+
U: null,
|
|
617
|
+
T: null
|
|
618
|
+
},
|
|
619
|
+
options
|
|
620
|
+
);
|
|
621
|
+
self.x = self;
|
|
622
|
+
const parent = context?.Z ? context._ : context;
|
|
623
|
+
if (context) {
|
|
624
|
+
context.i && (self.i = context.i);
|
|
625
|
+
context.D && (self.D = context.D);
|
|
626
|
+
const lastChild = context.n;
|
|
627
|
+
if (lastChild === null) {
|
|
628
|
+
context.n = self;
|
|
629
|
+
} else {
|
|
630
|
+
self.K = lastChild;
|
|
631
|
+
context.n = self;
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
if (parent)
|
|
635
|
+
self.e = parent.e + 1;
|
|
636
|
+
recompute(self, true);
|
|
637
|
+
return self;
|
|
631
638
|
}
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
ja = false;
|
|
659
|
-
/** Whether the computation is an error or has ancestors that are unresolved */
|
|
660
|
-
g = 0;
|
|
661
|
-
/** Which flags raised by sources are handled, vs. being passed through. */
|
|
662
|
-
ca = DEFAULT_FLAGS;
|
|
663
|
-
Q = -1;
|
|
664
|
-
H = false;
|
|
665
|
-
f;
|
|
666
|
-
d;
|
|
667
|
-
j;
|
|
668
|
-
constructor(initialValue, compute2, options) {
|
|
669
|
-
super(options?.id, compute2 === null);
|
|
670
|
-
this.P = compute2;
|
|
671
|
-
this.a = compute2 ? STATE_DIRTY : STATE_CLEAN;
|
|
672
|
-
this.g = compute2 && initialValue === void 0 ? UNINITIALIZED_BIT : 0;
|
|
673
|
-
this.m = initialValue;
|
|
674
|
-
if (options?.equals !== void 0)
|
|
675
|
-
this.ba = options.equals;
|
|
676
|
-
this.ja = !!options?.pureWrite;
|
|
677
|
-
this.fa = options?.unobserved;
|
|
678
|
-
if (ActiveTransition) {
|
|
679
|
-
this.f = ActiveTransition;
|
|
680
|
-
ActiveTransition.b.set(this, this);
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
ha() {
|
|
684
|
-
track(this);
|
|
685
|
-
newFlags |= this.g & ~currentMask;
|
|
686
|
-
if (this.g & ERROR_BIT) {
|
|
687
|
-
throw this.O;
|
|
639
|
+
function asyncComputed(asyncFn, initialValue, options) {
|
|
640
|
+
let lastResult = void 0;
|
|
641
|
+
let refreshing = false;
|
|
642
|
+
const fn = (prev) => {
|
|
643
|
+
const result = asyncFn(prev, refreshing);
|
|
644
|
+
refreshing = false;
|
|
645
|
+
lastResult = result;
|
|
646
|
+
const isPromise = result instanceof Promise;
|
|
647
|
+
const iterator = result[Symbol.asyncIterator];
|
|
648
|
+
if (!isPromise && !iterator) {
|
|
649
|
+
return result;
|
|
650
|
+
}
|
|
651
|
+
if (isPromise) {
|
|
652
|
+
result.then((v) => {
|
|
653
|
+
if (lastResult !== result)
|
|
654
|
+
return;
|
|
655
|
+
globalQueue.initTransition(self);
|
|
656
|
+
setSignal(self, () => v);
|
|
657
|
+
flush();
|
|
658
|
+
}).catch((e) => {
|
|
659
|
+
if (lastResult !== result)
|
|
660
|
+
return;
|
|
661
|
+
globalQueue.initTransition(self);
|
|
662
|
+
setError(self, e);
|
|
663
|
+
flush();
|
|
664
|
+
});
|
|
688
665
|
} else {
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
update(this);
|
|
705
|
-
else
|
|
706
|
-
this.F();
|
|
707
|
-
}
|
|
708
|
-
return this.ha();
|
|
709
|
-
}
|
|
710
|
-
/**
|
|
711
|
-
* Return the current value of this computation
|
|
712
|
-
* Automatically re-executes the surrounding computation when the value changes
|
|
713
|
-
*
|
|
714
|
-
* If the computation has any unresolved ancestors, this function waits for the value to resolve
|
|
715
|
-
* before continuing
|
|
716
|
-
*/
|
|
717
|
-
wait() {
|
|
718
|
-
if (ActiveTransition && (ActiveTransition.b.has(this) || !this.d && this.g & (UNINITIALIZED_BIT | ERROR_BIT))) {
|
|
719
|
-
const clone = ActiveTransition.b.get(this) || cloneGraph(this);
|
|
720
|
-
if (clone !== this)
|
|
721
|
-
return clone.wait();
|
|
722
|
-
}
|
|
723
|
-
if (this.P) {
|
|
724
|
-
if (this.g & ERROR_BIT && this.Q <= clock)
|
|
725
|
-
update(this);
|
|
726
|
-
else
|
|
727
|
-
this.F();
|
|
728
|
-
}
|
|
729
|
-
if ((notStale || this.g & UNINITIALIZED_BIT) && this.g & LOADING_BIT) {
|
|
730
|
-
throw new NotReadyError(this);
|
|
731
|
-
}
|
|
732
|
-
if (staleCheck && (this.g & LOADING_BIT || this.f)) {
|
|
733
|
-
staleCheck.m = true;
|
|
734
|
-
this.f?.aa.read();
|
|
735
|
-
}
|
|
736
|
-
return this.ha();
|
|
737
|
-
}
|
|
738
|
-
/** Update the computation with a new value. */
|
|
739
|
-
write(value, flags = 0, raw = false) {
|
|
740
|
-
if (ActiveTransition && !this.d) {
|
|
741
|
-
const clone = cloneGraph(this);
|
|
742
|
-
if (clone !== this)
|
|
743
|
-
return clone.write(value, flags, raw);
|
|
744
|
-
}
|
|
745
|
-
const newValue = !raw && typeof value === "function" ? value(this.m) : value;
|
|
746
|
-
const valueChanged = newValue !== UNCHANGED && (!!(this.g & UNINITIALIZED_BIT) || // this._stateFlags & LOADING_BIT & ~flags ||
|
|
747
|
-
this.ba === false || !this.ba(this.m, newValue));
|
|
748
|
-
if (valueChanged) {
|
|
749
|
-
this.m = newValue;
|
|
750
|
-
this.O = void 0;
|
|
751
|
-
}
|
|
752
|
-
const changedFlagsMask = this.g ^ flags, changedFlags = changedFlagsMask & flags;
|
|
753
|
-
this.g = flags;
|
|
754
|
-
this.Q = clock + 1;
|
|
755
|
-
if (this.c && !(this.j && ActiveTransition)) {
|
|
756
|
-
for (let i = 0; i < this.c.length; i++) {
|
|
757
|
-
if (valueChanged) {
|
|
758
|
-
this.c[i].u(STATE_DIRTY);
|
|
759
|
-
} else if (changedFlagsMask) {
|
|
760
|
-
this.c[i]._(changedFlagsMask, changedFlags);
|
|
666
|
+
(async () => {
|
|
667
|
+
try {
|
|
668
|
+
for await (let value of result) {
|
|
669
|
+
if (lastResult !== result)
|
|
670
|
+
return;
|
|
671
|
+
globalQueue.initTransition(self);
|
|
672
|
+
setSignal(self, () => value);
|
|
673
|
+
flush();
|
|
674
|
+
}
|
|
675
|
+
} catch (error) {
|
|
676
|
+
if (lastResult !== result)
|
|
677
|
+
return;
|
|
678
|
+
globalQueue.initTransition(self);
|
|
679
|
+
setError(self, error);
|
|
680
|
+
flush();
|
|
761
681
|
}
|
|
762
|
-
}
|
|
682
|
+
})();
|
|
763
683
|
}
|
|
764
|
-
|
|
684
|
+
globalQueue.initTransition(context);
|
|
685
|
+
throw new NotReadyError(context);
|
|
686
|
+
};
|
|
687
|
+
const self = computed(fn, initialValue, options);
|
|
688
|
+
self.sa = () => {
|
|
689
|
+
refreshing = true;
|
|
690
|
+
recompute(self);
|
|
691
|
+
flush();
|
|
692
|
+
};
|
|
693
|
+
return self;
|
|
694
|
+
}
|
|
695
|
+
function signal(v, options, firewall = null) {
|
|
696
|
+
if (firewall !== null) {
|
|
697
|
+
return firewall.aa = withOptions(
|
|
698
|
+
{
|
|
699
|
+
g: v,
|
|
700
|
+
p: null,
|
|
701
|
+
W: null,
|
|
702
|
+
z: firewall,
|
|
703
|
+
qa: firewall.aa,
|
|
704
|
+
f: 0 /* None */,
|
|
705
|
+
V: clock,
|
|
706
|
+
d: NOT_PENDING
|
|
707
|
+
},
|
|
708
|
+
options
|
|
709
|
+
);
|
|
710
|
+
} else {
|
|
711
|
+
return withOptions(
|
|
712
|
+
{
|
|
713
|
+
g: v,
|
|
714
|
+
p: null,
|
|
715
|
+
W: null,
|
|
716
|
+
f: 0 /* None */,
|
|
717
|
+
V: clock,
|
|
718
|
+
d: NOT_PENDING
|
|
719
|
+
},
|
|
720
|
+
options
|
|
721
|
+
);
|
|
765
722
|
}
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
723
|
+
}
|
|
724
|
+
function isEqual(a, b) {
|
|
725
|
+
return a === b;
|
|
726
|
+
}
|
|
727
|
+
function untrack(fn) {
|
|
728
|
+
if (!tracking)
|
|
729
|
+
return fn();
|
|
730
|
+
tracking = false;
|
|
731
|
+
try {
|
|
732
|
+
return fn();
|
|
733
|
+
} finally {
|
|
734
|
+
tracking = true;
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
function read(el) {
|
|
738
|
+
let c = context;
|
|
739
|
+
if (c?.Z)
|
|
740
|
+
c = c._;
|
|
741
|
+
if (c && tracking) {
|
|
742
|
+
link(el, c);
|
|
743
|
+
const owner = "_owner" in el ? el.z : el;
|
|
744
|
+
if ("_fn" in owner) {
|
|
745
|
+
const isZombie = el.b & 32 /* Zombie */;
|
|
746
|
+
if (owner.e >= (isZombie ? zombieQueue.t : dirtyQueue.t)) {
|
|
747
|
+
markNode(c);
|
|
748
|
+
markHeap(isZombie ? zombieQueue : dirtyQueue);
|
|
749
|
+
updateIfNecessary(owner);
|
|
777
750
|
}
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
* Notify the computation that one of its sources has changed flags.
|
|
782
|
-
*
|
|
783
|
-
* @param mask A bitmask for which flag(s) were changed.
|
|
784
|
-
* @param newFlags The source's new flags, masked to just the changed ones.
|
|
785
|
-
*/
|
|
786
|
-
_(mask, newFlags2) {
|
|
787
|
-
if (this.a >= STATE_DIRTY)
|
|
788
|
-
return;
|
|
789
|
-
if (mask & this.ca || this.j && ActiveTransition) {
|
|
790
|
-
this.u(STATE_DIRTY);
|
|
791
|
-
return;
|
|
792
|
-
}
|
|
793
|
-
if (this.a >= STATE_CHECK && !this.H)
|
|
794
|
-
return;
|
|
795
|
-
const prevFlags = this.g & mask;
|
|
796
|
-
const deltaFlags = prevFlags ^ newFlags2;
|
|
797
|
-
if (newFlags2 === prevFlags) ; else if (deltaFlags & prevFlags & mask) {
|
|
798
|
-
this.u(STATE_CHECK);
|
|
799
|
-
} else {
|
|
800
|
-
this.g ^= deltaFlags;
|
|
801
|
-
if (this.c) {
|
|
802
|
-
for (let i = 0; i < this.c.length; i++) {
|
|
803
|
-
this.c[i]._(mask, newFlags2);
|
|
804
|
-
}
|
|
751
|
+
const height = owner.e;
|
|
752
|
+
if (height >= c.e && el.s !== c) {
|
|
753
|
+
c.e = height + 1;
|
|
805
754
|
}
|
|
806
755
|
}
|
|
807
756
|
}
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
this.O = error;
|
|
815
|
-
this.write(UNCHANGED, this.g & ~LOADING_BIT | ERROR_BIT | UNINITIALIZED_BIT);
|
|
816
|
-
}
|
|
817
|
-
/**
|
|
818
|
-
* This is the core part of the reactivity system, which makes sure that the values are updated
|
|
819
|
-
* before they are read. We've also adapted it to return the loading state of the computation,
|
|
820
|
-
* so that we can propagate that to the computation's observers.
|
|
821
|
-
*
|
|
822
|
-
* This function will ensure that the value and states we read from the computation are up to date
|
|
823
|
-
*/
|
|
824
|
-
F() {
|
|
825
|
-
if (!this.P) {
|
|
826
|
-
return;
|
|
757
|
+
if (pendingCheck) {
|
|
758
|
+
const pendingResult = (el.f & 1 /* Pending */) !== 0 || !!el.S || false;
|
|
759
|
+
if (!el.G) {
|
|
760
|
+
el.G = signal(pendingResult);
|
|
761
|
+
el.G.ia = true;
|
|
762
|
+
el.G.ca = (v) => setSignal(el.G, v);
|
|
827
763
|
}
|
|
828
|
-
|
|
829
|
-
|
|
764
|
+
const prev = pendingCheck;
|
|
765
|
+
pendingCheck = null;
|
|
766
|
+
read(el.G);
|
|
767
|
+
pendingCheck = prev;
|
|
768
|
+
prev.g = pendingResult || prev.g;
|
|
769
|
+
}
|
|
770
|
+
if (pendingValueCheck) {
|
|
771
|
+
if (!el.C) {
|
|
772
|
+
el.C = signal(
|
|
773
|
+
el.d === NOT_PENDING ? el.g : el.d
|
|
774
|
+
);
|
|
775
|
+
el.C.ia = true;
|
|
776
|
+
el.C.ca = (v) => queueMicrotask(() => queueMicrotask(() => setSignal(el.C, v)));
|
|
830
777
|
}
|
|
831
|
-
|
|
832
|
-
|
|
778
|
+
pendingValueCheck = false;
|
|
779
|
+
try {
|
|
780
|
+
return read(el.C);
|
|
781
|
+
} finally {
|
|
782
|
+
pendingValueCheck = true;
|
|
833
783
|
}
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
784
|
+
}
|
|
785
|
+
if (el.f & 1 /* Pending */) {
|
|
786
|
+
if (c && !stale || el.f & 4 /* Uninitialized */)
|
|
787
|
+
throw el.B;
|
|
788
|
+
else if (c && stale && !pendingCheck) {
|
|
789
|
+
setStatusFlags(
|
|
790
|
+
c,
|
|
791
|
+
c.f | 1,
|
|
792
|
+
el.B
|
|
793
|
+
);
|
|
844
794
|
}
|
|
845
|
-
|
|
846
|
-
|
|
795
|
+
}
|
|
796
|
+
if (el.f & 2 /* Error */) {
|
|
797
|
+
if (el.V < clock) {
|
|
798
|
+
recompute(el, true);
|
|
799
|
+
return read(el);
|
|
847
800
|
} else {
|
|
848
|
-
|
|
849
|
-
this.a = STATE_CLEAN;
|
|
801
|
+
throw el.B;
|
|
850
802
|
}
|
|
851
803
|
}
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
removeSourceObservers(this, 0);
|
|
860
|
-
super.M();
|
|
804
|
+
return !c || el.d === NOT_PENDING || stale && !pendingCheck && el.S && activeTransition !== el.S ? el.g : el.d;
|
|
805
|
+
}
|
|
806
|
+
function setSignal(el, v) {
|
|
807
|
+
if (typeof v === "function") {
|
|
808
|
+
v = v(
|
|
809
|
+
el.d === NOT_PENDING ? el.g : el.d
|
|
810
|
+
);
|
|
861
811
|
}
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
newSources.push(computation);
|
|
873
|
-
}
|
|
874
|
-
if (updateCheck) {
|
|
875
|
-
updateCheck.m = computation.Q > currentObserver.Q;
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
}
|
|
879
|
-
function update(node) {
|
|
880
|
-
const prevSources = newSources, prevSourcesIndex = newSourcesIndex, prevFlags = newFlags;
|
|
881
|
-
newSources = null;
|
|
882
|
-
newSourcesIndex = 0;
|
|
883
|
-
newFlags = 0;
|
|
884
|
-
try {
|
|
885
|
-
if (ActiveTransition && node.d && !node.Z) {
|
|
886
|
-
initialDispose(node.d);
|
|
887
|
-
node.Z = true;
|
|
888
|
-
}
|
|
889
|
-
node.dispose(false);
|
|
890
|
-
node.emptyDisposal();
|
|
891
|
-
const result = compute(node, node.P, node);
|
|
892
|
-
node.write(result, newFlags, true);
|
|
893
|
-
} catch (error) {
|
|
894
|
-
if (error instanceof NotReadyError) {
|
|
895
|
-
if (error.cause !== node)
|
|
896
|
-
compute(
|
|
897
|
-
node,
|
|
898
|
-
() => track(error.cause),
|
|
899
|
-
node
|
|
900
|
-
);
|
|
901
|
-
node.write(UNCHANGED, newFlags | LOADING_BIT | node.g & UNINITIALIZED_BIT);
|
|
902
|
-
} else {
|
|
903
|
-
node.N(error);
|
|
812
|
+
const valueChanged = !el.da || !el.da(el.d === NOT_PENDING ? el.g : el.d, v);
|
|
813
|
+
if (!valueChanged && !el.f)
|
|
814
|
+
return v;
|
|
815
|
+
if (valueChanged) {
|
|
816
|
+
if (el.ia)
|
|
817
|
+
el.g = v;
|
|
818
|
+
else {
|
|
819
|
+
if (el.d === NOT_PENDING)
|
|
820
|
+
globalQueue.h.push(el);
|
|
821
|
+
el.d = v;
|
|
904
822
|
}
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
823
|
+
if (el.C)
|
|
824
|
+
el.C.ca(v);
|
|
825
|
+
}
|
|
826
|
+
clearStatusFlags(el);
|
|
827
|
+
el.V = clock;
|
|
828
|
+
for (let link2 = el.p; link2 !== null; link2 = link2.y) {
|
|
829
|
+
insertIntoHeap(link2.m, link2.m.b & 32 /* Zombie */ ? zombieQueue : dirtyQueue);
|
|
830
|
+
}
|
|
831
|
+
schedule();
|
|
832
|
+
return v;
|
|
833
|
+
}
|
|
834
|
+
function getObserver() {
|
|
835
|
+
return tracking ? context : null;
|
|
836
|
+
}
|
|
837
|
+
function getOwner() {
|
|
838
|
+
return context;
|
|
839
|
+
}
|
|
840
|
+
function onCleanup(fn) {
|
|
841
|
+
if (!context)
|
|
842
|
+
return fn;
|
|
843
|
+
const node = context;
|
|
844
|
+
if (!node.q) {
|
|
845
|
+
node.q = fn;
|
|
846
|
+
} else if (Array.isArray(node.q)) {
|
|
847
|
+
node.q.push(fn);
|
|
848
|
+
} else {
|
|
849
|
+
node.q = [node.q, fn];
|
|
850
|
+
}
|
|
851
|
+
return fn;
|
|
852
|
+
}
|
|
853
|
+
function createOwner(options) {
|
|
854
|
+
const parent = context;
|
|
855
|
+
const owner = {
|
|
856
|
+
Z: true,
|
|
857
|
+
_: parent?.Z ? parent._ : parent,
|
|
858
|
+
n: null,
|
|
859
|
+
K: null,
|
|
860
|
+
q: null,
|
|
861
|
+
id: options?.id ?? (parent?.id != null ? getNextChildId(parent) : void 0),
|
|
862
|
+
i: parent?.i ?? globalQueue,
|
|
863
|
+
D: parent?.D || defaultContext,
|
|
864
|
+
na: 0,
|
|
865
|
+
U: null,
|
|
866
|
+
T: null,
|
|
867
|
+
s: parent,
|
|
868
|
+
dispose(self = true) {
|
|
869
|
+
disposeChildren(owner, self);
|
|
870
|
+
}
|
|
871
|
+
};
|
|
872
|
+
if (parent) {
|
|
873
|
+
const lastChild = parent.n;
|
|
874
|
+
if (lastChild === null) {
|
|
875
|
+
parent.n = owner;
|
|
876
|
+
} else {
|
|
877
|
+
owner.K = lastChild;
|
|
878
|
+
parent.n = owner;
|
|
928
879
|
}
|
|
929
|
-
newSources = prevSources;
|
|
930
|
-
newSourcesIndex = prevSourcesIndex;
|
|
931
|
-
newFlags = prevFlags;
|
|
932
|
-
node.Q = clock + 1;
|
|
933
|
-
node.a = STATE_CLEAN;
|
|
934
880
|
}
|
|
881
|
+
return owner;
|
|
935
882
|
}
|
|
936
|
-
function
|
|
937
|
-
|
|
883
|
+
function createRoot(init, options) {
|
|
884
|
+
const owner = createOwner(options);
|
|
885
|
+
return runWithOwner(owner, () => init(owner.dispose));
|
|
938
886
|
}
|
|
939
|
-
function
|
|
940
|
-
|
|
887
|
+
function runWithOwner(owner, fn) {
|
|
888
|
+
const oldContext = context;
|
|
889
|
+
context = owner;
|
|
890
|
+
try {
|
|
941
891
|
return fn();
|
|
942
|
-
|
|
892
|
+
} finally {
|
|
893
|
+
context = oldContext;
|
|
894
|
+
}
|
|
943
895
|
}
|
|
944
|
-
function
|
|
945
|
-
const
|
|
946
|
-
|
|
896
|
+
function staleValues(fn, set = true) {
|
|
897
|
+
const prevStale = stale;
|
|
898
|
+
stale = set;
|
|
947
899
|
try {
|
|
948
|
-
fn();
|
|
949
|
-
return updateCheck.m;
|
|
900
|
+
return fn();
|
|
950
901
|
} finally {
|
|
951
|
-
|
|
902
|
+
stale = prevStale;
|
|
952
903
|
}
|
|
953
904
|
}
|
|
954
|
-
function
|
|
955
|
-
const
|
|
956
|
-
|
|
905
|
+
function pending(fn) {
|
|
906
|
+
const prevLatest = pendingValueCheck;
|
|
907
|
+
pendingValueCheck = true;
|
|
957
908
|
try {
|
|
958
|
-
|
|
959
|
-
|
|
909
|
+
return staleValues(fn, false);
|
|
910
|
+
} finally {
|
|
911
|
+
pendingValueCheck = prevLatest;
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
function isPending(fn, loadingValue) {
|
|
915
|
+
const current = pendingCheck;
|
|
916
|
+
pendingCheck = { g: false };
|
|
917
|
+
try {
|
|
918
|
+
staleValues(fn);
|
|
919
|
+
return pendingCheck.g;
|
|
960
920
|
} catch (err) {
|
|
961
921
|
if (!(err instanceof NotReadyError))
|
|
962
922
|
return false;
|
|
@@ -964,413 +924,161 @@ function pendingCheck(fn, loadingValue) {
|
|
|
964
924
|
return loadingValue;
|
|
965
925
|
throw err;
|
|
966
926
|
} finally {
|
|
967
|
-
|
|
927
|
+
pendingCheck = current;
|
|
968
928
|
}
|
|
969
929
|
}
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
c.j = () => c.write(false);
|
|
975
|
-
c.j.ia = () => globalQueue.enqueue(0, () => c.j.f && c.write(true));
|
|
976
|
-
c.ca |= LOADING_BIT;
|
|
977
|
-
const res = c.wait();
|
|
978
|
-
c.o = () => {
|
|
979
|
-
if (c.j.f) {
|
|
980
|
-
c.j.f.j.delete(c.j);
|
|
981
|
-
delete c.j.f;
|
|
982
|
-
}
|
|
983
|
-
};
|
|
984
|
-
return res;
|
|
930
|
+
|
|
931
|
+
// src/core/context.ts
|
|
932
|
+
function createContext(defaultValue, description) {
|
|
933
|
+
return { id: Symbol(description), defaultValue };
|
|
985
934
|
}
|
|
986
|
-
function
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
} catch (err) {
|
|
994
|
-
if (argLength > 1 && err instanceof NotReadyError)
|
|
995
|
-
return fallback;
|
|
996
|
-
throw err;
|
|
997
|
-
} finally {
|
|
998
|
-
newFlags = prevFlags;
|
|
999
|
-
notStale = prevNotStale;
|
|
935
|
+
function getContext(context2, owner = getOwner()) {
|
|
936
|
+
if (!owner) {
|
|
937
|
+
throw new NoOwnerError();
|
|
938
|
+
}
|
|
939
|
+
const value = hasContext(context2, owner) ? owner.D[context2.id] : context2.defaultValue;
|
|
940
|
+
if (isUndefined(value)) {
|
|
941
|
+
throw new ContextNotFoundError();
|
|
1000
942
|
}
|
|
943
|
+
return value;
|
|
1001
944
|
}
|
|
1002
|
-
function
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
currentMask = observer?.ca ?? DEFAULT_FLAGS;
|
|
1006
|
-
notStale = true;
|
|
1007
|
-
try {
|
|
1008
|
-
return fn.call(observer, observer ? observer.m : void 0);
|
|
1009
|
-
} finally {
|
|
1010
|
-
setOwner(prevOwner);
|
|
1011
|
-
currentObserver = prevObserver;
|
|
1012
|
-
currentMask = prevMask;
|
|
1013
|
-
notStale = prevNotStale;
|
|
945
|
+
function setContext(context2, value, owner = getOwner()) {
|
|
946
|
+
if (!owner) {
|
|
947
|
+
throw new NoOwnerError();
|
|
1014
948
|
}
|
|
949
|
+
owner.D = {
|
|
950
|
+
...owner.D,
|
|
951
|
+
[context2.id]: isUndefined(value) ? context2.defaultValue : value
|
|
952
|
+
};
|
|
953
|
+
}
|
|
954
|
+
function hasContext(context2, owner) {
|
|
955
|
+
return !isUndefined(owner?.D[context2.id]);
|
|
956
|
+
}
|
|
957
|
+
function isUndefined(value) {
|
|
958
|
+
return typeof value === "undefined";
|
|
1015
959
|
}
|
|
1016
960
|
|
|
1017
961
|
// src/core/effect.ts
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
this.a = state;
|
|
1059
|
-
}
|
|
1060
|
-
_(mask, newFlags2) {
|
|
1061
|
-
if (this.d) {
|
|
1062
|
-
if (this.a >= STATE_DIRTY)
|
|
1063
|
-
return;
|
|
1064
|
-
if (mask & 3) {
|
|
1065
|
-
this.u(STATE_DIRTY);
|
|
1066
|
-
return;
|
|
1067
|
-
}
|
|
1068
|
-
}
|
|
1069
|
-
super._(mask, newFlags2);
|
|
1070
|
-
}
|
|
1071
|
-
N(error) {
|
|
1072
|
-
this.O = error;
|
|
1073
|
-
getQueue(this).notify(this, LOADING_BIT, 0);
|
|
1074
|
-
this.g = ERROR_BIT;
|
|
1075
|
-
if (this.s === EFFECT_USER) {
|
|
1076
|
-
try {
|
|
1077
|
-
return this.$ ? this.$(error, () => {
|
|
1078
|
-
this.w?.();
|
|
1079
|
-
this.w = void 0;
|
|
1080
|
-
}) : console.error(error);
|
|
1081
|
-
} catch (e) {
|
|
1082
|
-
error = e;
|
|
1083
|
-
}
|
|
1084
|
-
}
|
|
1085
|
-
if (!getQueue(this).notify(this, ERROR_BIT, ERROR_BIT))
|
|
1086
|
-
throw error;
|
|
1087
|
-
}
|
|
1088
|
-
M() {
|
|
1089
|
-
if (this.a === STATE_DISPOSED)
|
|
1090
|
-
return;
|
|
1091
|
-
this.da = void 0;
|
|
1092
|
-
this.T = void 0;
|
|
1093
|
-
this.$ = void 0;
|
|
1094
|
-
this.w?.();
|
|
1095
|
-
this.w = void 0;
|
|
1096
|
-
getQueue(this).notify(this, ERROR_BIT | LOADING_BIT, 0);
|
|
1097
|
-
super.M();
|
|
1098
|
-
}
|
|
1099
|
-
x(type) {
|
|
1100
|
-
if (type) {
|
|
1101
|
-
const effect = this.d || this;
|
|
1102
|
-
if (effect.ea && effect.a !== STATE_DISPOSED) {
|
|
1103
|
-
effect.w?.();
|
|
1104
|
-
try {
|
|
1105
|
-
effect.w = effect.da(effect.m, effect.T);
|
|
1106
|
-
} catch (e) {
|
|
1107
|
-
if (!getQueue(effect).notify(effect, ERROR_BIT, ERROR_BIT))
|
|
1108
|
-
throw e;
|
|
1109
|
-
} finally {
|
|
1110
|
-
effect.T = effect.m;
|
|
1111
|
-
effect.ea = false;
|
|
962
|
+
function effect(compute, effect2, error, initialValue, options) {
|
|
963
|
+
let initialized = false;
|
|
964
|
+
const node = computed(compute, initialValue, {
|
|
965
|
+
...options,
|
|
966
|
+
ja: {
|
|
967
|
+
ea: true,
|
|
968
|
+
oa: initialValue,
|
|
969
|
+
ta: effect2,
|
|
970
|
+
pa: error,
|
|
971
|
+
L: void 0,
|
|
972
|
+
i: getOwner()?.i ?? globalQueue,
|
|
973
|
+
I: options?.render ? 1 /* Render */ : 2 /* User */,
|
|
974
|
+
la(statusFlagsChanged, prevStatusFlags) {
|
|
975
|
+
if (initialized) {
|
|
976
|
+
const errorChanged = this.f && this.f === prevStatusFlags && statusFlagsChanged;
|
|
977
|
+
this.ea = !(this.f & 2 /* Error */) && !(this.f & 1 /* Pending */ & ~prevStatusFlags) && !errorChanged;
|
|
978
|
+
if (this.ea)
|
|
979
|
+
this.i.enqueue(this.I, runEffect.bind(this));
|
|
980
|
+
}
|
|
981
|
+
if (this.f & 2 /* Error */) {
|
|
982
|
+
let error2 = this.B;
|
|
983
|
+
this.i.notify(this, 1 /* Pending */, 0);
|
|
984
|
+
if (this.I === 2 /* User */) {
|
|
985
|
+
try {
|
|
986
|
+
return this.pa ? this.pa(error2, () => {
|
|
987
|
+
this.L?.();
|
|
988
|
+
this.L = void 0;
|
|
989
|
+
}) : console.error(error2);
|
|
990
|
+
} catch (e) {
|
|
991
|
+
error2 = e;
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
if (!this.i.notify(this, 2 /* Error */, 2 /* Error */))
|
|
995
|
+
throw error2;
|
|
996
|
+
} else if (this.I === 1 /* Render */) {
|
|
997
|
+
this.i.notify(
|
|
998
|
+
this,
|
|
999
|
+
1 /* Pending */ | 2 /* Error */,
|
|
1000
|
+
this.f
|
|
1001
|
+
);
|
|
1112
1002
|
}
|
|
1113
1003
|
}
|
|
1114
|
-
} else
|
|
1115
|
-
this.a !== STATE_CLEAN && runTop(this);
|
|
1116
|
-
}
|
|
1117
|
-
};
|
|
1118
|
-
var TrackedEffect = class extends Computation {
|
|
1119
|
-
s = EFFECT_USER;
|
|
1120
|
-
w;
|
|
1121
|
-
constructor(compute2, options) {
|
|
1122
|
-
super(
|
|
1123
|
-
void 0,
|
|
1124
|
-
() => {
|
|
1125
|
-
this.w?.();
|
|
1126
|
-
this.w = latest(compute2);
|
|
1127
|
-
return void 0;
|
|
1128
|
-
},
|
|
1129
|
-
options
|
|
1130
|
-
);
|
|
1131
|
-
getQueue(this).enqueue(this.s, this.x.bind(this));
|
|
1132
|
-
}
|
|
1133
|
-
u(state, skipQueue) {
|
|
1134
|
-
if (this.a >= state || skipQueue)
|
|
1135
|
-
return;
|
|
1136
|
-
if (this.a === STATE_CLEAN || this.d && !ActiveTransition)
|
|
1137
|
-
getQueue(this).enqueue(this.s, this.x.bind(this));
|
|
1138
|
-
this.a = state;
|
|
1139
|
-
}
|
|
1140
|
-
M() {
|
|
1141
|
-
if (this.a === STATE_DISPOSED)
|
|
1142
|
-
return;
|
|
1143
|
-
this.w?.();
|
|
1144
|
-
this.w = void 0;
|
|
1145
|
-
getQueue(this).notify(this, ERROR_BIT | LOADING_BIT, 0);
|
|
1146
|
-
super.M();
|
|
1147
|
-
}
|
|
1148
|
-
x(type) {
|
|
1149
|
-
if (type)
|
|
1150
|
-
this.a !== STATE_CLEAN && runTop(this);
|
|
1151
|
-
}
|
|
1152
|
-
};
|
|
1153
|
-
var EagerComputation = class extends Computation {
|
|
1154
|
-
constructor(initialValue, compute2, options) {
|
|
1155
|
-
super(initialValue, compute2, options);
|
|
1156
|
-
!options?.defer && this.F();
|
|
1157
|
-
}
|
|
1158
|
-
u(state, skipQueue) {
|
|
1159
|
-
if (this.a >= state && !this.H)
|
|
1160
|
-
return;
|
|
1161
|
-
if (!skipQueue && (this.a === STATE_CLEAN || this.a === STATE_CHECK && this.H))
|
|
1162
|
-
getQueue(this).enqueue(EFFECT_PURE, this.x.bind(this));
|
|
1163
|
-
super.u(state, skipQueue);
|
|
1164
|
-
}
|
|
1165
|
-
x() {
|
|
1166
|
-
this.a !== STATE_CLEAN && runTop(this);
|
|
1167
|
-
}
|
|
1168
|
-
};
|
|
1169
|
-
var FirewallComputation = class extends Computation {
|
|
1170
|
-
firewall = true;
|
|
1171
|
-
constructor(compute2) {
|
|
1172
|
-
super(void 0, compute2);
|
|
1173
|
-
}
|
|
1174
|
-
u(state, skipQueue) {
|
|
1175
|
-
if (this.a >= state && !this.H)
|
|
1176
|
-
return;
|
|
1177
|
-
if (!skipQueue && (this.a === STATE_CLEAN || this.a === STATE_CHECK && this.H))
|
|
1178
|
-
getQueue(this).enqueue(EFFECT_PURE, this.x.bind(this));
|
|
1179
|
-
super.u(state, true);
|
|
1180
|
-
this.H = !!skipQueue;
|
|
1181
|
-
}
|
|
1182
|
-
x() {
|
|
1183
|
-
const prevFlags = this.g;
|
|
1184
|
-
this.a !== STATE_CLEAN && runTop(this);
|
|
1185
|
-
if (ActiveTransition && this.j && (this.g !== prevFlags || this.g !== this.j.flags)) {
|
|
1186
|
-
getQueue(this).notify(this, LOADING_BIT | ERROR_BIT, this.g);
|
|
1187
|
-
this.j.flags = this.g;
|
|
1188
|
-
this.g = prevFlags;
|
|
1189
|
-
}
|
|
1190
|
-
}
|
|
1191
|
-
};
|
|
1192
|
-
function runTop(node) {
|
|
1193
|
-
const ancestors = [];
|
|
1194
|
-
for (let current = node; current !== null; current = current.l) {
|
|
1195
|
-
if (ActiveTransition && current.f)
|
|
1196
|
-
current = ActiveTransition.b.get(current);
|
|
1197
|
-
if (current.a !== STATE_CLEAN) {
|
|
1198
|
-
ancestors.push(current);
|
|
1199
1004
|
}
|
|
1005
|
+
});
|
|
1006
|
+
initialized = true;
|
|
1007
|
+
if (node.I === 1 /* Render */) {
|
|
1008
|
+
node.ha = (p) => !(node.f & 2 /* Error */) ? staleValues(() => compute(p)) : compute(p);
|
|
1200
1009
|
}
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1010
|
+
!options?.defer && !(node.f & (2 /* Error */ | 1 /* Pending */)) && (node.I === 2 /* User */ ? node.i.enqueue(node.I, runEffect.bind(node)) : runEffect.call(node));
|
|
1011
|
+
onCleanup(() => node.L?.());
|
|
1012
|
+
}
|
|
1013
|
+
function runEffect() {
|
|
1014
|
+
if (!this.ea || this.b & 64 /* Disposed */)
|
|
1015
|
+
return;
|
|
1016
|
+
this.L?.();
|
|
1017
|
+
this.L = void 0;
|
|
1018
|
+
try {
|
|
1019
|
+
this.L = this.ta(this.g, this.oa);
|
|
1020
|
+
} catch (error) {
|
|
1021
|
+
if (!this.i.notify(this, 2 /* Error */, 2 /* Error */))
|
|
1022
|
+
throw error;
|
|
1023
|
+
} finally {
|
|
1024
|
+
this.oa = this.g;
|
|
1025
|
+
this.ea = false;
|
|
1204
1026
|
}
|
|
1205
1027
|
}
|
|
1206
1028
|
|
|
1207
1029
|
// src/signals.ts
|
|
1208
1030
|
function createSignal(first, second, third) {
|
|
1209
1031
|
if (typeof first === "function") {
|
|
1210
|
-
const node2 =
|
|
1032
|
+
const node2 = computed(first, second, third);
|
|
1211
1033
|
return [
|
|
1212
|
-
|
|
1213
|
-
(
|
|
1214
|
-
node2.F();
|
|
1215
|
-
return node2.write(v);
|
|
1216
|
-
}
|
|
1034
|
+
read.bind(null, node2),
|
|
1035
|
+
setSignal.bind(null, node2)
|
|
1217
1036
|
];
|
|
1218
1037
|
}
|
|
1219
1038
|
const o = getOwner();
|
|
1220
1039
|
const needsId = o?.id != null;
|
|
1221
|
-
const node =
|
|
1040
|
+
const node = signal(
|
|
1222
1041
|
first,
|
|
1223
|
-
|
|
1224
|
-
needsId ? { id: o.getNextChildId(), ...second } : second
|
|
1042
|
+
needsId ? { id: getNextChildId(o), ...second } : second
|
|
1225
1043
|
);
|
|
1226
|
-
return [
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1044
|
+
return [
|
|
1045
|
+
read.bind(null, node),
|
|
1046
|
+
setSignal.bind(null, node)
|
|
1047
|
+
];
|
|
1048
|
+
}
|
|
1049
|
+
function createMemo(compute, value, options) {
|
|
1050
|
+
let node = computed(compute, value, options);
|
|
1051
|
+
return read.bind(null, node);
|
|
1052
|
+
}
|
|
1053
|
+
function createAsync(compute, value, options) {
|
|
1054
|
+
const node = asyncComputed(compute, value, options);
|
|
1055
|
+
const ret = read.bind(null, node);
|
|
1056
|
+
ret.refresh = node.sa;
|
|
1057
|
+
return ret;
|
|
1058
|
+
}
|
|
1059
|
+
function createEffect(compute, effectFn, value, options) {
|
|
1060
|
+
void effect(
|
|
1061
|
+
compute,
|
|
1062
|
+
effectFn.effect || effectFn,
|
|
1063
|
+
effectFn.error,
|
|
1230
1064
|
value,
|
|
1231
|
-
compute2,
|
|
1232
1065
|
options
|
|
1233
1066
|
);
|
|
1234
|
-
let resolvedValue;
|
|
1235
|
-
return () => {
|
|
1236
|
-
if (node) {
|
|
1237
|
-
if (node.a === STATE_DISPOSED) {
|
|
1238
|
-
node = void 0;
|
|
1239
|
-
return resolvedValue;
|
|
1240
|
-
}
|
|
1241
|
-
resolvedValue = node.wait();
|
|
1242
|
-
if (!node.b?.length && node.n?.l !== node && !(node.g & UNINITIALIZED_BIT)) {
|
|
1243
|
-
node.dispose();
|
|
1244
|
-
node = void 0;
|
|
1245
|
-
}
|
|
1246
|
-
}
|
|
1247
|
-
return resolvedValue;
|
|
1248
|
-
};
|
|
1249
1067
|
}
|
|
1250
|
-
function
|
|
1251
|
-
|
|
1252
|
-
const node = new EagerComputation(
|
|
1253
|
-
value,
|
|
1254
|
-
(p) => {
|
|
1255
|
-
const source = compute2(p, refreshing);
|
|
1256
|
-
refreshing = false;
|
|
1257
|
-
const isPromise = source instanceof Promise;
|
|
1258
|
-
const iterator = source[Symbol.asyncIterator];
|
|
1259
|
-
if (!isPromise && !iterator) {
|
|
1260
|
-
return source;
|
|
1261
|
-
}
|
|
1262
|
-
let abort = false;
|
|
1263
|
-
onCleanup(() => abort = true);
|
|
1264
|
-
let transition2 = ActiveTransition;
|
|
1265
|
-
if (isPromise) {
|
|
1266
|
-
source.then(
|
|
1267
|
-
(value3) => {
|
|
1268
|
-
if (abort)
|
|
1269
|
-
return;
|
|
1270
|
-
if (transition2)
|
|
1271
|
-
return transition2.runTransition(() => {
|
|
1272
|
-
node.write(value3, 0, true);
|
|
1273
|
-
}, true);
|
|
1274
|
-
node.write(value3, 0, true);
|
|
1275
|
-
},
|
|
1276
|
-
(error) => {
|
|
1277
|
-
if (abort)
|
|
1278
|
-
return;
|
|
1279
|
-
if (transition2)
|
|
1280
|
-
return transition2.runTransition(() => node.N(error), true);
|
|
1281
|
-
node.N(error);
|
|
1282
|
-
}
|
|
1283
|
-
);
|
|
1284
|
-
} else {
|
|
1285
|
-
(async () => {
|
|
1286
|
-
try {
|
|
1287
|
-
for await (let value3 of source) {
|
|
1288
|
-
if (abort)
|
|
1289
|
-
return;
|
|
1290
|
-
if (transition2)
|
|
1291
|
-
return transition2.runTransition(() => {
|
|
1292
|
-
node.write(value3, 0, true);
|
|
1293
|
-
transition2 = null;
|
|
1294
|
-
}, true);
|
|
1295
|
-
node.write(value3, 0, true);
|
|
1296
|
-
}
|
|
1297
|
-
} catch (error) {
|
|
1298
|
-
if (abort)
|
|
1299
|
-
return;
|
|
1300
|
-
if (transition2)
|
|
1301
|
-
return transition2.runTransition(() => {
|
|
1302
|
-
node.N(error);
|
|
1303
|
-
transition2 = null;
|
|
1304
|
-
}, true);
|
|
1305
|
-
node.N(error);
|
|
1306
|
-
}
|
|
1307
|
-
})();
|
|
1308
|
-
}
|
|
1309
|
-
throw new NotReadyError(getOwner());
|
|
1310
|
-
},
|
|
1311
|
-
options
|
|
1312
|
-
);
|
|
1313
|
-
const read = node.wait.bind(node);
|
|
1314
|
-
read.refresh = () => {
|
|
1315
|
-
let n = node;
|
|
1316
|
-
if (ActiveTransition && !node.d) {
|
|
1317
|
-
n = cloneGraph(node);
|
|
1318
|
-
}
|
|
1319
|
-
n.a = STATE_DIRTY;
|
|
1320
|
-
refreshing = true;
|
|
1321
|
-
n.F();
|
|
1322
|
-
};
|
|
1323
|
-
return read;
|
|
1324
|
-
}
|
|
1325
|
-
function createEffect(compute2, effect, value, options) {
|
|
1326
|
-
void new Effect(
|
|
1327
|
-
value,
|
|
1328
|
-
compute2,
|
|
1329
|
-
effect.effect || effect,
|
|
1330
|
-
effect.error,
|
|
1331
|
-
options
|
|
1332
|
-
);
|
|
1333
|
-
}
|
|
1334
|
-
function createRenderEffect(compute2, effect, value, options) {
|
|
1335
|
-
void new Effect(value, compute2, effect, void 0, {
|
|
1068
|
+
function createRenderEffect(compute, effectFn, value, options) {
|
|
1069
|
+
void effect(compute, effectFn, void 0, value, {
|
|
1336
1070
|
render: true,
|
|
1337
1071
|
...options
|
|
1338
1072
|
});
|
|
1339
1073
|
}
|
|
1340
|
-
function createTrackedEffect(
|
|
1341
|
-
void new TrackedEffect(compute2, options);
|
|
1342
|
-
}
|
|
1343
|
-
function createReaction(effect, options) {
|
|
1344
|
-
let cleanup = void 0;
|
|
1345
|
-
onCleanup(() => cleanup?.());
|
|
1346
|
-
return (tracking) => {
|
|
1347
|
-
const node = new Effect(
|
|
1348
|
-
void 0,
|
|
1349
|
-
tracking,
|
|
1350
|
-
() => {
|
|
1351
|
-
cleanup?.();
|
|
1352
|
-
cleanup = (effect.effect || effect)?.();
|
|
1353
|
-
node.dispose(true);
|
|
1354
|
-
},
|
|
1355
|
-
effect.error,
|
|
1356
|
-
{
|
|
1357
|
-
defer: true,
|
|
1358
|
-
...options
|
|
1359
|
-
}
|
|
1360
|
-
);
|
|
1361
|
-
};
|
|
1362
|
-
}
|
|
1363
|
-
function createRoot(init, options) {
|
|
1364
|
-
const owner = new Owner(options?.id);
|
|
1365
|
-
return compute(owner, !init.length ? init : () => init(() => owner.dispose()), null);
|
|
1074
|
+
function createTrackedEffect(compute, options) {
|
|
1366
1075
|
}
|
|
1367
|
-
function
|
|
1368
|
-
return compute(owner, run, null);
|
|
1076
|
+
function createReaction(effect2, options) {
|
|
1369
1077
|
}
|
|
1370
1078
|
function resolve(fn) {
|
|
1371
1079
|
return new Promise((res, rej) => {
|
|
1372
1080
|
createRoot((dispose) => {
|
|
1373
|
-
|
|
1081
|
+
computed(() => {
|
|
1374
1082
|
try {
|
|
1375
1083
|
res(fn());
|
|
1376
1084
|
} catch (err) {
|
|
@@ -1384,43 +1092,9 @@ function resolve(fn) {
|
|
|
1384
1092
|
});
|
|
1385
1093
|
}
|
|
1386
1094
|
function createOptimistic(first, second, third) {
|
|
1387
|
-
|
|
1388
|
-
second,
|
|
1389
|
-
(prev) => {
|
|
1390
|
-
const res = first(prev);
|
|
1391
|
-
if (node.j.f)
|
|
1392
|
-
return prev;
|
|
1393
|
-
return res;
|
|
1394
|
-
},
|
|
1395
|
-
third
|
|
1396
|
-
) : new Computation(first, null, second);
|
|
1397
|
-
node.j = () => node.write(first);
|
|
1398
|
-
function write(v) {
|
|
1399
|
-
if (!ActiveTransition)
|
|
1400
|
-
throw new Error("createOptimistic can only be updated inside a transition");
|
|
1401
|
-
ActiveTransition.addOptimistic(node.j);
|
|
1402
|
-
queueMicrotask(() => {
|
|
1403
|
-
if (node.j.f) {
|
|
1404
|
-
node.F();
|
|
1405
|
-
node.write(v);
|
|
1406
|
-
}
|
|
1407
|
-
});
|
|
1408
|
-
}
|
|
1409
|
-
return [node.wait.bind(node), write];
|
|
1095
|
+
return {};
|
|
1410
1096
|
}
|
|
1411
|
-
function
|
|
1412
|
-
let t = new Transition(new Computation(void 0, null));
|
|
1413
|
-
queueMicrotask(() => t.runTransition(() => fn((fn2) => t.runTransition(fn2))));
|
|
1414
|
-
}
|
|
1415
|
-
function useTransition() {
|
|
1416
|
-
const [pending, setPending] = createOptimistic(false);
|
|
1417
|
-
function start(fn) {
|
|
1418
|
-
transition((resume) => {
|
|
1419
|
-
setPending(true);
|
|
1420
|
-
return fn(resume);
|
|
1421
|
-
});
|
|
1422
|
-
}
|
|
1423
|
-
return [pending, start];
|
|
1097
|
+
function onSettled(callback) {
|
|
1424
1098
|
}
|
|
1425
1099
|
|
|
1426
1100
|
// src/store/reconcile.ts
|
|
@@ -1428,7 +1102,7 @@ function unwrap(value) {
|
|
|
1428
1102
|
return value?.[$TARGET]?.[STORE_NODE] ?? value;
|
|
1429
1103
|
}
|
|
1430
1104
|
function getOverrideValue(value, override, nodes, key) {
|
|
1431
|
-
return nodes && key in nodes ? nodes[key]
|
|
1105
|
+
return nodes && key in nodes ? read(nodes[key]) : override && key in override ? override[key] : value[key];
|
|
1432
1106
|
}
|
|
1433
1107
|
function getAllKeys(value, override, next) {
|
|
1434
1108
|
const keys = getKeys(value, override);
|
|
@@ -1462,16 +1136,16 @@ function applyState(next, state, keyFn, all) {
|
|
|
1462
1136
|
if (start > newEnd || start > end) {
|
|
1463
1137
|
for (j = start; j <= newEnd; j++) {
|
|
1464
1138
|
changed = true;
|
|
1465
|
-
target[STORE_NODE][j]
|
|
1139
|
+
target[STORE_NODE][j] && setSignal(target[STORE_NODE][j], wrap(next[j], target));
|
|
1466
1140
|
}
|
|
1467
1141
|
for (; j < next.length; j++) {
|
|
1468
1142
|
changed = true;
|
|
1469
1143
|
const wrapped = wrap(temp[j], target);
|
|
1470
|
-
target[STORE_NODE][j]
|
|
1144
|
+
target[STORE_NODE][j] && setSignal(target[STORE_NODE][j], wrapped);
|
|
1471
1145
|
applyState(next[j], wrapped, keyFn, all);
|
|
1472
1146
|
}
|
|
1473
|
-
changed && target[STORE_NODE][$TRACK]
|
|
1474
|
-
prevLength !== next.length && target[STORE_NODE].length
|
|
1147
|
+
changed && target[STORE_NODE][$TRACK] && setSignal(target[STORE_NODE][$TRACK], void 0);
|
|
1148
|
+
prevLength !== next.length && target[STORE_NODE].length && setSignal(target[STORE_NODE].length, next.length);
|
|
1475
1149
|
return;
|
|
1476
1150
|
}
|
|
1477
1151
|
newIndicesNext = new Array(newEnd + 1);
|
|
@@ -1495,10 +1169,10 @@ function applyState(next, state, keyFn, all) {
|
|
|
1495
1169
|
for (j = start; j < next.length; j++) {
|
|
1496
1170
|
if (j in temp) {
|
|
1497
1171
|
const wrapped = wrap(temp[j], target);
|
|
1498
|
-
target[STORE_NODE][j]
|
|
1172
|
+
target[STORE_NODE][j] && setSignal(target[STORE_NODE][j], wrapped);
|
|
1499
1173
|
applyState(next[j], wrapped, keyFn, all);
|
|
1500
1174
|
} else
|
|
1501
|
-
target[STORE_NODE][j]
|
|
1175
|
+
target[STORE_NODE][j] && setSignal(target[STORE_NODE][j], wrap(next[j], target));
|
|
1502
1176
|
}
|
|
1503
1177
|
if (start < next.length)
|
|
1504
1178
|
changed = true;
|
|
@@ -1510,9 +1184,9 @@ function applyState(next, state, keyFn, all) {
|
|
|
1510
1184
|
}
|
|
1511
1185
|
if (prevLength !== next.length) {
|
|
1512
1186
|
changed = true;
|
|
1513
|
-
target[STORE_NODE].length
|
|
1187
|
+
target[STORE_NODE].length && setSignal(target[STORE_NODE].length, next.length);
|
|
1514
1188
|
}
|
|
1515
|
-
changed && target[STORE_NODE][$TRACK]
|
|
1189
|
+
changed && target[STORE_NODE][$TRACK] && setSignal(target[STORE_NODE][$TRACK], void 0);
|
|
1516
1190
|
return;
|
|
1517
1191
|
}
|
|
1518
1192
|
if (nodes) {
|
|
@@ -1526,8 +1200,8 @@ function applyState(next, state, keyFn, all) {
|
|
|
1526
1200
|
if (previousValue === nextValue)
|
|
1527
1201
|
continue;
|
|
1528
1202
|
if (!previousValue || !isWrappable(previousValue) || keyFn(previousValue) != null && keyFn(previousValue) !== keyFn(nextValue)) {
|
|
1529
|
-
tracked
|
|
1530
|
-
node
|
|
1203
|
+
tracked && setSignal(tracked, void 0);
|
|
1204
|
+
node && setSignal(node, isWrappable(nextValue) ? wrap(nextValue, target) : nextValue);
|
|
1531
1205
|
} else
|
|
1532
1206
|
applyState(nextValue, wrap(previousValue, target), keyFn, all);
|
|
1533
1207
|
}
|
|
@@ -1535,7 +1209,8 @@ function applyState(next, state, keyFn, all) {
|
|
|
1535
1209
|
if (nodes = target[STORE_HAS]) {
|
|
1536
1210
|
const keys = Object.keys(nodes);
|
|
1537
1211
|
for (let i = 0, len = keys.length; i < len; i++) {
|
|
1538
|
-
|
|
1212
|
+
const key = keys[i];
|
|
1213
|
+
setSignal(nodes[key], key in next);
|
|
1539
1214
|
}
|
|
1540
1215
|
}
|
|
1541
1216
|
}
|
|
@@ -1553,13 +1228,14 @@ function reconcile(value, key, all = false) {
|
|
|
1553
1228
|
|
|
1554
1229
|
// src/store/projection.ts
|
|
1555
1230
|
function createProjectionInternal(fn, initialValue = {}, options) {
|
|
1231
|
+
let node;
|
|
1556
1232
|
const wrappedMap = /* @__PURE__ */ new WeakMap();
|
|
1557
1233
|
const traps = {
|
|
1558
1234
|
...storeTraps,
|
|
1559
1235
|
get(target, property, receiver) {
|
|
1560
1236
|
const o = getOwner();
|
|
1561
|
-
const n =
|
|
1562
|
-
(!o || o !== n) && n
|
|
1237
|
+
const n = node;
|
|
1238
|
+
(!o || o !== n) && n && read(n);
|
|
1563
1239
|
return storeTraps.get(target, property, receiver);
|
|
1564
1240
|
}
|
|
1565
1241
|
};
|
|
@@ -1576,7 +1252,7 @@ function createProjectionInternal(fn, initialValue = {}, options) {
|
|
|
1576
1252
|
return wrapped;
|
|
1577
1253
|
};
|
|
1578
1254
|
const wrappedStore = wrapProjection(initialValue);
|
|
1579
|
-
|
|
1255
|
+
node = computed(() => {
|
|
1580
1256
|
storeSetter(wrappedStore, (s) => {
|
|
1581
1257
|
const value = fn(s);
|
|
1582
1258
|
if (value !== s && value !== void 0) {
|
|
@@ -1634,7 +1310,7 @@ function getNodes(target, type) {
|
|
|
1634
1310
|
function getNode(nodes, property, value, equals = isEqual) {
|
|
1635
1311
|
if (nodes[property])
|
|
1636
1312
|
return nodes[property];
|
|
1637
|
-
return nodes[property] =
|
|
1313
|
+
return nodes[property] = signal(value, {
|
|
1638
1314
|
equals,
|
|
1639
1315
|
unobserved() {
|
|
1640
1316
|
delete nodes[property];
|
|
@@ -1642,7 +1318,7 @@ function getNode(nodes, property, value, equals = isEqual) {
|
|
|
1642
1318
|
});
|
|
1643
1319
|
}
|
|
1644
1320
|
function trackSelf(target, symbol = $TRACK) {
|
|
1645
|
-
getObserver() && getNode(getNodes(target, STORE_NODE), symbol, void 0, false)
|
|
1321
|
+
getObserver() && read(getNode(getNodes(target, STORE_NODE), symbol, void 0, false));
|
|
1646
1322
|
}
|
|
1647
1323
|
function getKeys(source, override, enumerable = true) {
|
|
1648
1324
|
const baseKeys = untrack(() => enumerable ? Object.keys(source) : Reflect.ownKeys(source));
|
|
@@ -1690,7 +1366,7 @@ var storeTraps = {
|
|
|
1690
1366
|
return desc.get.call(receiver);
|
|
1691
1367
|
}
|
|
1692
1368
|
if (Writing?.has(receiver)) {
|
|
1693
|
-
let value2 = tracked && (overridden || !proxySource) ? tracked.
|
|
1369
|
+
let value2 = tracked && (overridden || !proxySource) ? tracked.d !== NOT_PENDING ? tracked.d : tracked.g : storeValue[property];
|
|
1694
1370
|
value2 === $DELETED && (value2 = void 0);
|
|
1695
1371
|
if (!isWrappable(value2))
|
|
1696
1372
|
return value2;
|
|
@@ -1698,14 +1374,14 @@ var storeTraps = {
|
|
|
1698
1374
|
Writing.add(wrapped);
|
|
1699
1375
|
return wrapped;
|
|
1700
1376
|
}
|
|
1701
|
-
let value = tracked ? overridden || !proxySource ? nodes[property]
|
|
1377
|
+
let value = tracked ? overridden || !proxySource ? read(nodes[property]) : (read(nodes[property]), storeValue[property]) : storeValue[property];
|
|
1702
1378
|
value === $DELETED && (value = void 0);
|
|
1703
1379
|
if (!tracked) {
|
|
1704
1380
|
if (!overridden && typeof value === "function" && !storeValue.hasOwnProperty(property)) {
|
|
1705
1381
|
let proto;
|
|
1706
1382
|
return !Array.isArray(target[STORE_VALUE]) && (proto = Object.getPrototypeOf(target[STORE_VALUE])) && proto !== Object.prototype ? value.bind(storeValue) : value;
|
|
1707
1383
|
} else if (getObserver()) {
|
|
1708
|
-
return getNode(nodes, property, isWrappable(value) ? wrap(value, target) : value)
|
|
1384
|
+
return read(getNode(nodes, property, isWrappable(value) ? wrap(value, target) : value));
|
|
1709
1385
|
}
|
|
1710
1386
|
}
|
|
1711
1387
|
return isWrappable(value) ? wrap(value, target) : value;
|
|
@@ -1714,7 +1390,7 @@ var storeTraps = {
|
|
|
1714
1390
|
if (property === $PROXY || property === $TRACK || property === "__proto__")
|
|
1715
1391
|
return true;
|
|
1716
1392
|
const has = target[STORE_OVERRIDE] && property in target[STORE_OVERRIDE] ? target[STORE_OVERRIDE][property] !== $DELETED : property in target[STORE_VALUE];
|
|
1717
|
-
getObserver() && getNode(getNodes(target, STORE_HAS), property, has)
|
|
1393
|
+
getObserver() && read(getNode(getNodes(target, STORE_HAS), property, has));
|
|
1718
1394
|
return has;
|
|
1719
1395
|
},
|
|
1720
1396
|
set(target, property, rawValue) {
|
|
@@ -1739,15 +1415,15 @@ var storeTraps = {
|
|
|
1739
1415
|
}
|
|
1740
1416
|
if (recursivelyNotify(store, storeLookup) && wrappable)
|
|
1741
1417
|
recursivelyAddParent(value, store);
|
|
1742
|
-
target[STORE_HAS]?.[property]
|
|
1418
|
+
target[STORE_HAS]?.[property] && setSignal(target[STORE_HAS][property], true);
|
|
1743
1419
|
const nodes = getNodes(target, STORE_NODE);
|
|
1744
|
-
nodes[property]
|
|
1420
|
+
nodes[property] && setSignal(nodes[property], () => wrappable ? wrap(value, target) : value);
|
|
1745
1421
|
if (Array.isArray(state)) {
|
|
1746
1422
|
const index = parseInt(property) + 1;
|
|
1747
1423
|
if (index > len)
|
|
1748
|
-
nodes.length
|
|
1424
|
+
nodes.length && setSignal(nodes.length, index);
|
|
1749
1425
|
}
|
|
1750
|
-
nodes[$TRACK]
|
|
1426
|
+
nodes[$TRACK] && setSignal(nodes[$TRACK], void 0);
|
|
1751
1427
|
});
|
|
1752
1428
|
}
|
|
1753
1429
|
return true;
|
|
@@ -1766,10 +1442,11 @@ var storeTraps = {
|
|
|
1766
1442
|
const parents = PARENTS.get(prev);
|
|
1767
1443
|
parents && (parents instanceof Set ? parents.delete(target) : PARENTS.delete(prev));
|
|
1768
1444
|
}
|
|
1769
|
-
target[STORE_HAS]?.[property]
|
|
1445
|
+
if (target[STORE_HAS]?.[property])
|
|
1446
|
+
setSignal(target[STORE_HAS][property], false);
|
|
1770
1447
|
const nodes = getNodes(target, STORE_NODE);
|
|
1771
|
-
nodes[property]
|
|
1772
|
-
nodes[$TRACK]
|
|
1448
|
+
nodes[property] && setSignal(nodes[property], void 0);
|
|
1449
|
+
nodes[$TRACK] && setSignal(nodes[$TRACK], void 0);
|
|
1773
1450
|
});
|
|
1774
1451
|
}
|
|
1775
1452
|
return true;
|
|
@@ -1823,7 +1500,7 @@ function recursivelyNotify(state, lookup) {
|
|
|
1823
1500
|
if (target) {
|
|
1824
1501
|
const deep2 = getNodes(target, STORE_NODE)[$DEEP];
|
|
1825
1502
|
if (deep2) {
|
|
1826
|
-
deep2
|
|
1503
|
+
setSignal(deep2, void 0);
|
|
1827
1504
|
notified = true;
|
|
1828
1505
|
}
|
|
1829
1506
|
lookup = target[STORE_LOOKUP] || lookup;
|
|
@@ -1880,30 +1557,7 @@ function deep(store) {
|
|
|
1880
1557
|
|
|
1881
1558
|
// src/store/optimistic.ts
|
|
1882
1559
|
function createOptimisticStore(first, second, options) {
|
|
1883
|
-
|
|
1884
|
-
const { store, node } = derived ? createProjectionInternal(
|
|
1885
|
-
(draft) => {
|
|
1886
|
-
const res = first(draft);
|
|
1887
|
-
if (reset.f)
|
|
1888
|
-
return draft;
|
|
1889
|
-
return res;
|
|
1890
|
-
},
|
|
1891
|
-
second,
|
|
1892
|
-
options
|
|
1893
|
-
) : createProjectionInternal(() => {
|
|
1894
|
-
}, first);
|
|
1895
|
-
const reset = () => storeSetter(
|
|
1896
|
-
store,
|
|
1897
|
-
reconcile(derived ? first(store) || store : first, options?.key || "id", options?.all)
|
|
1898
|
-
);
|
|
1899
|
-
const write = (v) => {
|
|
1900
|
-
if (!ActiveTransition)
|
|
1901
|
-
throw new Error("createOptimisticStore can only be updated inside a transition");
|
|
1902
|
-
ActiveTransition.addOptimistic(reset);
|
|
1903
|
-
queueMicrotask(() => reset.f && storeSetter(store, v));
|
|
1904
|
-
};
|
|
1905
|
-
node.j = reset;
|
|
1906
|
-
return [store, write];
|
|
1560
|
+
return [];
|
|
1907
1561
|
}
|
|
1908
1562
|
|
|
1909
1563
|
// src/store/utils.ts
|
|
@@ -2109,347 +1763,333 @@ function omit(props, ...keys) {
|
|
|
2109
1763
|
// src/map.ts
|
|
2110
1764
|
function mapArray(list, map, options) {
|
|
2111
1765
|
const keyFn = typeof options?.keyed === "function" ? options.keyed : void 0;
|
|
2112
|
-
return
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
1766
|
+
return createMemo(
|
|
1767
|
+
updateKeyedMap.bind({
|
|
1768
|
+
z: createOwner(),
|
|
1769
|
+
j: 0,
|
|
1770
|
+
ua: list,
|
|
1771
|
+
F: [],
|
|
1772
|
+
M: map,
|
|
1773
|
+
c: [],
|
|
1774
|
+
a: [],
|
|
1775
|
+
N: keyFn,
|
|
1776
|
+
k: keyFn || options?.keyed === false ? [] : void 0,
|
|
1777
|
+
l: map.length > 1 ? [] : void 0,
|
|
1778
|
+
X: options?.fallback
|
|
1779
|
+
})
|
|
1780
|
+
);
|
|
2125
1781
|
}
|
|
2126
1782
|
var pureOptions = { pureWrite: true };
|
|
2127
1783
|
function updateKeyedMap() {
|
|
2128
|
-
const newItems = this.
|
|
1784
|
+
const newItems = this.ua() || [], newLen = newItems.length;
|
|
2129
1785
|
newItems[$TRACK];
|
|
2130
|
-
runWithOwner(this.
|
|
2131
|
-
let i, j, mapper = this.
|
|
2132
|
-
this.
|
|
2133
|
-
this.
|
|
2134
|
-
return this.
|
|
2135
|
-
|
|
2136
|
-
this.
|
|
1786
|
+
runWithOwner(this.z, () => {
|
|
1787
|
+
let i, j, mapper = this.k ? () => {
|
|
1788
|
+
this.k[j] = signal(newItems[j], pureOptions);
|
|
1789
|
+
this.l && (this.l[j] = signal(j, pureOptions));
|
|
1790
|
+
return this.M(
|
|
1791
|
+
read.bind(null, this.k[j]),
|
|
1792
|
+
this.l ? read.bind(null, this.l[j]) : void 0
|
|
2137
1793
|
);
|
|
2138
|
-
} : this.
|
|
1794
|
+
} : this.l ? () => {
|
|
2139
1795
|
const item = newItems[j];
|
|
2140
|
-
this.
|
|
2141
|
-
return this.
|
|
1796
|
+
this.l[j] = signal(j, pureOptions);
|
|
1797
|
+
return this.M(
|
|
1798
|
+
() => item,
|
|
1799
|
+
read.bind(null, this.l[j])
|
|
1800
|
+
);
|
|
2142
1801
|
} : () => {
|
|
2143
1802
|
const item = newItems[j];
|
|
2144
|
-
return this.
|
|
1803
|
+
return this.M(() => item);
|
|
2145
1804
|
};
|
|
2146
1805
|
if (newLen === 0) {
|
|
2147
|
-
if (this.
|
|
2148
|
-
this.
|
|
2149
|
-
this.
|
|
2150
|
-
this.
|
|
2151
|
-
this.
|
|
2152
|
-
this.
|
|
2153
|
-
this.
|
|
2154
|
-
this.
|
|
1806
|
+
if (this.j !== 0) {
|
|
1807
|
+
this.z.dispose(false);
|
|
1808
|
+
this.a = [];
|
|
1809
|
+
this.F = [];
|
|
1810
|
+
this.c = [];
|
|
1811
|
+
this.j = 0;
|
|
1812
|
+
this.k && (this.k = []);
|
|
1813
|
+
this.l && (this.l = []);
|
|
2155
1814
|
}
|
|
2156
|
-
if (this.
|
|
2157
|
-
this.
|
|
2158
|
-
this.
|
|
2159
|
-
this.
|
|
2160
|
-
null
|
|
1815
|
+
if (this.X && !this.c[0]) {
|
|
1816
|
+
this.c[0] = runWithOwner(
|
|
1817
|
+
this.a[0] = createOwner(),
|
|
1818
|
+
this.X
|
|
2161
1819
|
);
|
|
2162
1820
|
}
|
|
2163
|
-
} else if (this.
|
|
2164
|
-
if (this.
|
|
2165
|
-
this.
|
|
2166
|
-
this.
|
|
1821
|
+
} else if (this.j === 0) {
|
|
1822
|
+
if (this.a[0])
|
|
1823
|
+
this.a[0].dispose();
|
|
1824
|
+
this.c = new Array(newLen);
|
|
2167
1825
|
for (j = 0; j < newLen; j++) {
|
|
2168
|
-
this.
|
|
2169
|
-
this.
|
|
1826
|
+
this.F[j] = newItems[j];
|
|
1827
|
+
this.c[j] = runWithOwner(this.a[j] = createOwner(), mapper);
|
|
2170
1828
|
}
|
|
2171
|
-
this.
|
|
1829
|
+
this.j = newLen;
|
|
2172
1830
|
} else {
|
|
2173
|
-
let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.
|
|
2174
|
-
for (start = 0, end = Math.min(this.
|
|
2175
|
-
if (this.
|
|
2176
|
-
this.
|
|
1831
|
+
let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.k ? new Array(newLen) : void 0, tempIndexes = this.l ? new Array(newLen) : void 0;
|
|
1832
|
+
for (start = 0, end = Math.min(this.j, newLen); start < end && (this.F[start] === newItems[start] || this.k && compare(this.N, this.F[start], newItems[start])); start++) {
|
|
1833
|
+
if (this.k)
|
|
1834
|
+
setSignal(this.k[start], newItems[start]);
|
|
2177
1835
|
}
|
|
2178
|
-
for (end = this.
|
|
2179
|
-
temp[newEnd] = this.
|
|
2180
|
-
tempNodes[newEnd] = this.
|
|
2181
|
-
tempRows && (tempRows[newEnd] = this.
|
|
2182
|
-
tempIndexes && (tempIndexes[newEnd] = this.
|
|
1836
|
+
for (end = this.j - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.F[end] === newItems[newEnd] || this.k && compare(this.N, this.F[end], newItems[newEnd])); end--, newEnd--) {
|
|
1837
|
+
temp[newEnd] = this.c[end];
|
|
1838
|
+
tempNodes[newEnd] = this.a[end];
|
|
1839
|
+
tempRows && (tempRows[newEnd] = this.k[end]);
|
|
1840
|
+
tempIndexes && (tempIndexes[newEnd] = this.l[end]);
|
|
2183
1841
|
}
|
|
2184
1842
|
newIndices = /* @__PURE__ */ new Map();
|
|
2185
1843
|
newIndicesNext = new Array(newEnd + 1);
|
|
2186
1844
|
for (j = newEnd; j >= start; j--) {
|
|
2187
1845
|
item = newItems[j];
|
|
2188
|
-
key = this.
|
|
1846
|
+
key = this.N ? this.N(item) : item;
|
|
2189
1847
|
i = newIndices.get(key);
|
|
2190
1848
|
newIndicesNext[j] = i === void 0 ? -1 : i;
|
|
2191
1849
|
newIndices.set(key, j);
|
|
2192
1850
|
}
|
|
2193
1851
|
for (i = start; i <= end; i++) {
|
|
2194
|
-
item = this.
|
|
2195
|
-
key = this.
|
|
1852
|
+
item = this.F[i];
|
|
1853
|
+
key = this.N ? this.N(item) : item;
|
|
2196
1854
|
j = newIndices.get(key);
|
|
2197
1855
|
if (j !== void 0 && j !== -1) {
|
|
2198
|
-
temp[j] = this.
|
|
2199
|
-
tempNodes[j] = this.
|
|
2200
|
-
tempRows && (tempRows[j] = this.
|
|
2201
|
-
tempIndexes && (tempIndexes[j] = this.
|
|
1856
|
+
temp[j] = this.c[i];
|
|
1857
|
+
tempNodes[j] = this.a[i];
|
|
1858
|
+
tempRows && (tempRows[j] = this.k[i]);
|
|
1859
|
+
tempIndexes && (tempIndexes[j] = this.l[i]);
|
|
2202
1860
|
j = newIndicesNext[j];
|
|
2203
1861
|
newIndices.set(key, j);
|
|
2204
1862
|
} else
|
|
2205
|
-
this.
|
|
1863
|
+
this.a[i].dispose();
|
|
2206
1864
|
}
|
|
2207
1865
|
for (j = start; j < newLen; j++) {
|
|
2208
1866
|
if (j in temp) {
|
|
2209
|
-
this.
|
|
2210
|
-
this.
|
|
1867
|
+
this.c[j] = temp[j];
|
|
1868
|
+
this.a[j] = tempNodes[j];
|
|
2211
1869
|
if (tempRows) {
|
|
2212
|
-
this.
|
|
2213
|
-
this.
|
|
1870
|
+
this.k[j] = tempRows[j];
|
|
1871
|
+
setSignal(this.k[j], newItems[j]);
|
|
2214
1872
|
}
|
|
2215
1873
|
if (tempIndexes) {
|
|
2216
|
-
this.
|
|
2217
|
-
this.
|
|
1874
|
+
this.l[j] = tempIndexes[j];
|
|
1875
|
+
setSignal(this.l[j], j);
|
|
2218
1876
|
}
|
|
2219
1877
|
} else {
|
|
2220
|
-
this.
|
|
1878
|
+
this.c[j] = runWithOwner(this.a[j] = createOwner(), mapper);
|
|
2221
1879
|
}
|
|
2222
1880
|
}
|
|
2223
|
-
this.
|
|
2224
|
-
this.
|
|
1881
|
+
this.c = this.c.slice(0, this.j = newLen);
|
|
1882
|
+
this.F = newItems.slice(0);
|
|
2225
1883
|
}
|
|
2226
1884
|
});
|
|
2227
|
-
return this.
|
|
1885
|
+
return this.c;
|
|
2228
1886
|
}
|
|
2229
1887
|
function repeat(count, map, options) {
|
|
2230
1888
|
return updateRepeat.bind({
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
1889
|
+
z: createOwner(),
|
|
1890
|
+
j: 0,
|
|
1891
|
+
w: 0,
|
|
1892
|
+
va: count,
|
|
1893
|
+
M: map,
|
|
1894
|
+
a: [],
|
|
1895
|
+
c: [],
|
|
1896
|
+
wa: options?.from,
|
|
1897
|
+
X: options?.fallback
|
|
2240
1898
|
});
|
|
2241
1899
|
}
|
|
2242
1900
|
function updateRepeat() {
|
|
2243
|
-
const newLen = this.
|
|
2244
|
-
const from = this.
|
|
2245
|
-
runWithOwner(this.
|
|
1901
|
+
const newLen = this.va();
|
|
1902
|
+
const from = this.wa?.() || 0;
|
|
1903
|
+
runWithOwner(this.z, () => {
|
|
2246
1904
|
if (newLen === 0) {
|
|
2247
|
-
if (this.
|
|
2248
|
-
this.
|
|
2249
|
-
this.
|
|
2250
|
-
this.
|
|
2251
|
-
this.
|
|
1905
|
+
if (this.j !== 0) {
|
|
1906
|
+
this.z.dispose(false);
|
|
1907
|
+
this.a = [];
|
|
1908
|
+
this.c = [];
|
|
1909
|
+
this.j = 0;
|
|
2252
1910
|
}
|
|
2253
|
-
if (this.
|
|
2254
|
-
this.
|
|
2255
|
-
this.
|
|
2256
|
-
this.
|
|
2257
|
-
null
|
|
1911
|
+
if (this.X && !this.c[0]) {
|
|
1912
|
+
this.c[0] = runWithOwner(
|
|
1913
|
+
this.a[0] = createOwner(),
|
|
1914
|
+
this.X
|
|
2258
1915
|
);
|
|
2259
1916
|
}
|
|
2260
1917
|
return;
|
|
2261
1918
|
}
|
|
2262
1919
|
const to = from + newLen;
|
|
2263
|
-
const prevTo = this.
|
|
2264
|
-
if (this.
|
|
2265
|
-
this.
|
|
1920
|
+
const prevTo = this.w + this.j;
|
|
1921
|
+
if (this.j === 0 && this.a[0])
|
|
1922
|
+
this.a[0].dispose();
|
|
2266
1923
|
for (let i = to; i < prevTo; i++)
|
|
2267
|
-
this.
|
|
2268
|
-
if (this.
|
|
2269
|
-
let i = this.
|
|
2270
|
-
while (i < from && i < this.
|
|
2271
|
-
this.
|
|
2272
|
-
this.
|
|
2273
|
-
this.
|
|
2274
|
-
} else if (this.
|
|
2275
|
-
let i = prevTo - this.
|
|
2276
|
-
let difference = this.
|
|
2277
|
-
this.
|
|
1924
|
+
this.a[i - this.w].dispose();
|
|
1925
|
+
if (this.w < from) {
|
|
1926
|
+
let i = this.w;
|
|
1927
|
+
while (i < from && i < this.j)
|
|
1928
|
+
this.a[i++].dispose();
|
|
1929
|
+
this.a.splice(0, from - this.w);
|
|
1930
|
+
this.c.splice(0, from - this.w);
|
|
1931
|
+
} else if (this.w > from) {
|
|
1932
|
+
let i = prevTo - this.w - 1;
|
|
1933
|
+
let difference = this.w - from;
|
|
1934
|
+
this.a.length = this.c.length = newLen;
|
|
2278
1935
|
while (i >= difference) {
|
|
2279
|
-
this.
|
|
2280
|
-
this.
|
|
1936
|
+
this.a[i] = this.a[i - difference];
|
|
1937
|
+
this.c[i] = this.c[i - difference];
|
|
2281
1938
|
i--;
|
|
2282
1939
|
}
|
|
2283
1940
|
for (let i2 = 0; i2 < difference; i2++) {
|
|
2284
|
-
this.
|
|
2285
|
-
this.
|
|
2286
|
-
() => this.
|
|
2287
|
-
null
|
|
1941
|
+
this.c[i2] = runWithOwner(
|
|
1942
|
+
this.a[i2] = createOwner(),
|
|
1943
|
+
() => this.M(i2 + from)
|
|
2288
1944
|
);
|
|
2289
1945
|
}
|
|
2290
1946
|
}
|
|
2291
1947
|
for (let i = prevTo; i < to; i++) {
|
|
2292
|
-
this.
|
|
2293
|
-
this.
|
|
2294
|
-
() => this.
|
|
2295
|
-
null
|
|
1948
|
+
this.c[i - from] = runWithOwner(
|
|
1949
|
+
this.a[i - from] = createOwner(),
|
|
1950
|
+
() => this.M(i)
|
|
2296
1951
|
);
|
|
2297
1952
|
}
|
|
2298
|
-
this.
|
|
2299
|
-
this.
|
|
2300
|
-
this.
|
|
1953
|
+
this.c = this.c.slice(0, newLen);
|
|
1954
|
+
this.w = from;
|
|
1955
|
+
this.j = newLen;
|
|
2301
1956
|
});
|
|
2302
|
-
return this.
|
|
1957
|
+
return this.c;
|
|
2303
1958
|
}
|
|
2304
1959
|
function compare(key, a, b) {
|
|
2305
1960
|
return key ? key(a) === key(b) : true;
|
|
2306
1961
|
}
|
|
2307
1962
|
|
|
2308
1963
|
// src/boundaries.ts
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
1964
|
+
function boundaryComputed(fn, propagationMask) {
|
|
1965
|
+
const node = computed(fn, void 0, {
|
|
1966
|
+
ja: {
|
|
1967
|
+
la() {
|
|
1968
|
+
let flags = this.f;
|
|
1969
|
+
this.f &= ~this.Y;
|
|
1970
|
+
if (this.Y & 1 /* Pending */ && !(this.f & 4 /* Uninitialized */)) {
|
|
1971
|
+
flags &= ~1 /* Pending */;
|
|
1972
|
+
}
|
|
1973
|
+
this.i.notify(this, this.Y, flags);
|
|
1974
|
+
},
|
|
1975
|
+
Y: propagationMask
|
|
2319
1976
|
}
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
}
|
|
1977
|
+
});
|
|
1978
|
+
node.Y = propagationMask;
|
|
1979
|
+
return node;
|
|
1980
|
+
}
|
|
2324
1981
|
function createBoundChildren(owner, fn, queue, mask) {
|
|
2325
|
-
const parentQueue = owner.
|
|
2326
|
-
parentQueue.addChild(owner.
|
|
2327
|
-
onCleanup(() => parentQueue.removeChild(owner.
|
|
2328
|
-
return
|
|
2329
|
-
|
|
2330
|
-
() =>
|
|
2331
|
-
|
|
2332
|
-
return new BoundaryComputation(() => latest(() => flatten(c.wait())), mask);
|
|
2333
|
-
},
|
|
2334
|
-
null
|
|
2335
|
-
);
|
|
1982
|
+
const parentQueue = owner.i;
|
|
1983
|
+
parentQueue.addChild(owner.i = queue);
|
|
1984
|
+
onCleanup(() => parentQueue.removeChild(owner.i));
|
|
1985
|
+
return runWithOwner(owner, () => {
|
|
1986
|
+
const c = computed(fn);
|
|
1987
|
+
return boundaryComputed(() => staleValues(() => flatten(read(c))), mask);
|
|
1988
|
+
});
|
|
2336
1989
|
}
|
|
2337
1990
|
var ConditionalQueue = class extends Queue {
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
1991
|
+
r;
|
|
1992
|
+
fa = /* @__PURE__ */ new Set();
|
|
1993
|
+
h = /* @__PURE__ */ new Set();
|
|
2341
1994
|
constructor(disabled) {
|
|
2342
1995
|
super();
|
|
2343
|
-
this.
|
|
1996
|
+
this.r = disabled;
|
|
2344
1997
|
}
|
|
2345
1998
|
run(type) {
|
|
2346
|
-
if (!type || this.
|
|
1999
|
+
if (!type || read(this.r))
|
|
2347
2000
|
return;
|
|
2348
2001
|
return super.run(type);
|
|
2349
2002
|
}
|
|
2350
2003
|
notify(node, type, flags) {
|
|
2351
|
-
if (this.
|
|
2352
|
-
if (type &
|
|
2353
|
-
if (flags &
|
|
2354
|
-
this.
|
|
2355
|
-
type &= ~
|
|
2356
|
-
} else if (this.
|
|
2357
|
-
type &= ~
|
|
2004
|
+
if (read(this.r)) {
|
|
2005
|
+
if (type & 1 /* Pending */) {
|
|
2006
|
+
if (flags & 1 /* Pending */) {
|
|
2007
|
+
this.h.add(node);
|
|
2008
|
+
type &= ~1 /* Pending */;
|
|
2009
|
+
} else if (this.h.delete(node))
|
|
2010
|
+
type &= ~1 /* Pending */;
|
|
2358
2011
|
}
|
|
2359
|
-
if (type &
|
|
2360
|
-
if (flags &
|
|
2361
|
-
this.
|
|
2362
|
-
type &= ~
|
|
2363
|
-
} else if (this.
|
|
2364
|
-
type &= ~
|
|
2012
|
+
if (type & 2 /* Error */) {
|
|
2013
|
+
if (flags & 2 /* Error */) {
|
|
2014
|
+
this.fa.add(node);
|
|
2015
|
+
type &= ~2 /* Error */;
|
|
2016
|
+
} else if (this.fa.delete(node))
|
|
2017
|
+
type &= ~2 /* Error */;
|
|
2365
2018
|
}
|
|
2366
2019
|
}
|
|
2367
2020
|
return type ? super.notify(node, type, flags) : true;
|
|
2368
2021
|
}
|
|
2369
|
-
merge(queue) {
|
|
2370
|
-
queue.t.forEach((n) => this.notify(n, LOADING_BIT, LOADING_BIT));
|
|
2371
|
-
queue.X.forEach((n) => this.notify(n, ERROR_BIT, ERROR_BIT));
|
|
2372
|
-
super.merge(queue);
|
|
2373
|
-
}
|
|
2374
2022
|
};
|
|
2375
2023
|
var CollectionQueue = class extends Queue {
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2024
|
+
ga;
|
|
2025
|
+
a = /* @__PURE__ */ new Set();
|
|
2026
|
+
r = signal(false, { pureWrite: true });
|
|
2379
2027
|
constructor(type) {
|
|
2380
2028
|
super();
|
|
2381
|
-
this.
|
|
2029
|
+
this.ga = type;
|
|
2382
2030
|
}
|
|
2383
2031
|
run(type) {
|
|
2384
|
-
if (!type || this.
|
|
2032
|
+
if (!type || read(this.r))
|
|
2385
2033
|
return;
|
|
2386
2034
|
return super.run(type);
|
|
2387
2035
|
}
|
|
2388
2036
|
notify(node, type, flags) {
|
|
2389
|
-
if (!(type & this.
|
|
2037
|
+
if (!(type & this.ga))
|
|
2390
2038
|
return super.notify(node, type, flags);
|
|
2391
|
-
if (flags & this.
|
|
2392
|
-
this.
|
|
2393
|
-
if (this.
|
|
2394
|
-
this.
|
|
2395
|
-
} else if (this.
|
|
2396
|
-
this.
|
|
2397
|
-
if (this.
|
|
2398
|
-
this.
|
|
2399
|
-
}
|
|
2400
|
-
type &= ~this.
|
|
2039
|
+
if (flags & this.ga) {
|
|
2040
|
+
this.a.add(node);
|
|
2041
|
+
if (this.a.size === 1)
|
|
2042
|
+
setSignal(this.r, true);
|
|
2043
|
+
} else if (this.a.size > 0) {
|
|
2044
|
+
this.a.delete(node);
|
|
2045
|
+
if (this.a.size === 0)
|
|
2046
|
+
setSignal(this.r, false);
|
|
2047
|
+
}
|
|
2048
|
+
type &= ~this.ga;
|
|
2401
2049
|
return type ? super.notify(node, type, flags) : true;
|
|
2402
2050
|
}
|
|
2403
|
-
merge(queue) {
|
|
2404
|
-
queue.e.forEach((n) => this.notify(n, this.L, this.L));
|
|
2405
|
-
super.merge(queue);
|
|
2406
|
-
}
|
|
2407
2051
|
};
|
|
2408
2052
|
function createBoundary(fn, condition) {
|
|
2409
|
-
const owner =
|
|
2410
|
-
const queue = new ConditionalQueue(
|
|
2411
|
-
new Computation(void 0, () => condition() === "hidden" /* HIDDEN */)
|
|
2412
|
-
);
|
|
2053
|
+
const owner = createOwner();
|
|
2054
|
+
const queue = new ConditionalQueue(computed(() => condition() === "hidden" /* HIDDEN */));
|
|
2413
2055
|
const tree = createBoundChildren(owner, fn, queue, 0);
|
|
2414
|
-
|
|
2415
|
-
const disabled = queue.
|
|
2416
|
-
tree.
|
|
2056
|
+
computed(() => {
|
|
2057
|
+
const disabled = read(queue.r);
|
|
2058
|
+
tree.Y = disabled ? 2 /* Error */ | 1 /* Pending */ : 0;
|
|
2417
2059
|
if (!disabled) {
|
|
2418
|
-
queue.
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
queue.
|
|
2060
|
+
queue.h.forEach(
|
|
2061
|
+
(node) => queue.notify(node, 1 /* Pending */, 1 /* Pending */)
|
|
2062
|
+
);
|
|
2063
|
+
queue.fa.forEach((node) => queue.notify(node, 2 /* Error */, 2 /* Error */));
|
|
2064
|
+
queue.h.clear();
|
|
2065
|
+
queue.fa.clear();
|
|
2422
2066
|
}
|
|
2423
2067
|
});
|
|
2424
|
-
return () => queue.
|
|
2068
|
+
return () => read(queue.r) ? void 0 : read(tree);
|
|
2425
2069
|
}
|
|
2426
2070
|
function createCollectionBoundary(type, fn, fallback) {
|
|
2427
|
-
const owner =
|
|
2071
|
+
const owner = createOwner();
|
|
2428
2072
|
const queue = new CollectionQueue(type);
|
|
2429
2073
|
const tree = createBoundChildren(owner, fn, queue, type);
|
|
2430
|
-
const decision =
|
|
2431
|
-
if (!queue.
|
|
2432
|
-
const resolved =
|
|
2433
|
-
if (!untrack(() => queue.
|
|
2074
|
+
const decision = computed(() => {
|
|
2075
|
+
if (!read(queue.r)) {
|
|
2076
|
+
const resolved = read(tree);
|
|
2077
|
+
if (!untrack(() => read(queue.r)))
|
|
2434
2078
|
return resolved;
|
|
2435
2079
|
}
|
|
2436
2080
|
return fallback(queue);
|
|
2437
2081
|
});
|
|
2438
|
-
return
|
|
2082
|
+
return read.bind(null, decision);
|
|
2439
2083
|
}
|
|
2440
|
-
function
|
|
2441
|
-
return createCollectionBoundary(
|
|
2084
|
+
function createLoadBoundary(fn, fallback) {
|
|
2085
|
+
return createCollectionBoundary(1 /* Pending */, fn, () => fallback());
|
|
2442
2086
|
}
|
|
2443
2087
|
function createErrorBoundary(fn, fallback) {
|
|
2444
|
-
return createCollectionBoundary(
|
|
2445
|
-
let node =
|
|
2446
|
-
return fallback(node.
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
if (ActiveTransition && !node2.d)
|
|
2450
|
-
node2 = cloneGraph(node2);
|
|
2451
|
-
node2.a = STATE_DIRTY;
|
|
2452
|
-
getQueue(node2).enqueue(node2.s, node2.x.bind(node2));
|
|
2088
|
+
return createCollectionBoundary(2 /* Error */, fn, (queue) => {
|
|
2089
|
+
let node = queue.a.values().next().value;
|
|
2090
|
+
return fallback(node.B, () => {
|
|
2091
|
+
for (let node2 of queue.a) {
|
|
2092
|
+
recompute(node2, true);
|
|
2453
2093
|
}
|
|
2454
2094
|
});
|
|
2455
2095
|
});
|
|
@@ -2509,4 +2149,4 @@ function flattenArray(children, results = [], options) {
|
|
|
2509
2149
|
return needsUnwrap;
|
|
2510
2150
|
}
|
|
2511
2151
|
|
|
2512
|
-
export { $PROXY, $TARGET, $TRACK,
|
|
2152
|
+
export { $PROXY, $TARGET, $TRACK, ContextNotFoundError, NoOwnerError, NotReadyError, SUPPORTS_PROXY, createAsync, createBoundary, createContext, createEffect, createErrorBoundary, createLoadBoundary, createMemo, createOptimistic, createOptimisticStore, createProjection, createReaction, createRenderEffect, createRoot, createSignal, createStore, createTrackedEffect, deep, flatten, flush, getContext, getNextChildId, getObserver, getOwner, isEqual, isPending, isWrappable, mapArray, merge, omit, onCleanup, onSettled, pending, reconcile, repeat, resolve, runWithOwner, setContext, snapshot, untrack };
|