@solidjs/signals 0.7.5 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev.js +1049 -1406
- package/dist/node.cjs +1177 -1535
- package/dist/prod.js +1163 -1514
- package/dist/types/boundaries.d.ts +12 -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,907 @@ 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.q?._ ? n.q.$?.c : n.q?.c) ?? -1;
|
|
28
|
+
if (parentHeight >= n.c)
|
|
29
|
+
n.c = parentHeight + 1;
|
|
30
|
+
const height = n.c;
|
|
31
|
+
const heapAtHeight = heap.p[height];
|
|
32
|
+
if (heapAtHeight === void 0) {
|
|
33
|
+
heap.p[height] = n;
|
|
34
|
+
} else {
|
|
35
|
+
const tail = heapAtHeight.x;
|
|
36
|
+
tail.P = 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.c;
|
|
69
|
+
if (n.x === n) {
|
|
70
|
+
heap.p[height] = void 0;
|
|
71
|
+
} else {
|
|
72
|
+
const next = n.P;
|
|
73
|
+
const dhh = heap.p[height];
|
|
74
|
+
const end = next ?? dhh;
|
|
75
|
+
if (n === dhh) {
|
|
76
|
+
heap.p[height] = next;
|
|
77
|
+
} else {
|
|
78
|
+
n.x.P = next;
|
|
79
|
+
}
|
|
80
|
+
end.x = n.x;
|
|
81
|
+
}
|
|
82
|
+
n.x = n;
|
|
83
|
+
n.P = void 0;
|
|
84
|
+
}
|
|
85
|
+
function markHeap(heap) {
|
|
86
|
+
if (heap.aa)
|
|
87
|
+
return;
|
|
88
|
+
heap.aa = true;
|
|
89
|
+
for (let i = 0; i <= heap.J; i++) {
|
|
90
|
+
for (let el = heap.p[i]; el !== void 0; el = el.P) {
|
|
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.r; link2 !== null; link2 = link2.y) {
|
|
102
|
+
markNode(link2.j, 1 /* Check */);
|
|
103
|
+
}
|
|
104
|
+
if (el.ba !== null) {
|
|
105
|
+
for (let child = el.ba; child !== null; child = child.ra) {
|
|
106
|
+
for (let link2 = child.r; link2 !== null; link2 = link2.y) {
|
|
107
|
+
markNode(link2.j, 1 /* Check */);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function runHeap(heap, recompute2) {
|
|
113
|
+
heap.aa = false;
|
|
114
|
+
for (heap.n = 0; heap.n <= heap.J; heap.n++) {
|
|
115
|
+
let el = heap.p[heap.n];
|
|
116
|
+
while (el !== void 0) {
|
|
117
|
+
if (el.b & 8 /* InHeap */)
|
|
118
|
+
recompute2(el);
|
|
119
|
+
else {
|
|
120
|
+
adjustHeight(el, heap);
|
|
121
|
+
}
|
|
122
|
+
el = heap.p[heap.n];
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
heap.J = 0;
|
|
126
|
+
}
|
|
127
|
+
function adjustHeight(el, heap) {
|
|
128
|
+
deleteFromHeap(el, heap);
|
|
129
|
+
let newHeight = el.c;
|
|
130
|
+
for (let d = el.u; d; d = d.E) {
|
|
131
|
+
const dep1 = d.Q;
|
|
132
|
+
const dep = "_owner" in dep1 ? dep1.z : dep1;
|
|
133
|
+
if ("_fn" in dep) {
|
|
134
|
+
if (dep.c >= newHeight) {
|
|
135
|
+
newHeight = dep.c + 1;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (el.c !== newHeight) {
|
|
140
|
+
el.c = newHeight;
|
|
141
|
+
for (let s = el.r; s !== null; s = s.y) {
|
|
142
|
+
insertIntoHeapHeight(s.j, 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.ca)
|
|
53
158
|
queueMicrotask(flush);
|
|
54
159
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
160
|
+
var dirtyQueue = {
|
|
161
|
+
p: new Array(2e3).fill(void 0),
|
|
162
|
+
aa: false,
|
|
163
|
+
n: 0,
|
|
164
|
+
J: 0
|
|
165
|
+
};
|
|
166
|
+
var zombieQueue = {
|
|
167
|
+
p: new Array(2e3).fill(void 0),
|
|
168
|
+
aa: false,
|
|
169
|
+
n: 0,
|
|
170
|
+
J: 0
|
|
171
|
+
};
|
|
64
172
|
var Queue = class {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
i = [];
|
|
173
|
+
q = null;
|
|
174
|
+
A = [[], []];
|
|
175
|
+
R = [];
|
|
69
176
|
created = clock;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
177
|
+
addChild(child) {
|
|
178
|
+
this.R.push(child);
|
|
179
|
+
child.q = this;
|
|
180
|
+
}
|
|
181
|
+
removeChild(child) {
|
|
182
|
+
const index = this.R.indexOf(child);
|
|
183
|
+
if (index >= 0) {
|
|
184
|
+
this.R.splice(index, 1);
|
|
185
|
+
child.q = null;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
notify(node, mask, flags) {
|
|
189
|
+
if (this.q)
|
|
190
|
+
return this.q.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.R.length; i++) {
|
|
200
|
+
this.R[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
|
+
ca = false;
|
|
211
|
+
h = [];
|
|
212
|
+
static S;
|
|
213
|
+
static la;
|
|
90
214
|
flush() {
|
|
91
|
-
if (this.
|
|
215
|
+
if (this.ca)
|
|
92
216
|
return;
|
|
93
|
-
this.
|
|
217
|
+
this.ca = true;
|
|
94
218
|
try {
|
|
95
|
-
|
|
96
|
-
|
|
219
|
+
runHeap(dirtyQueue, _GlobalQueue.S);
|
|
220
|
+
if (activeTransition) {
|
|
221
|
+
if (!transitionComplete(activeTransition)) {
|
|
222
|
+
runHeap(zombieQueue, _GlobalQueue.S);
|
|
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.S);
|
|
240
|
+
} else if (transitions.size)
|
|
241
|
+
runHeap(zombieQueue, _GlobalQueue.S);
|
|
242
|
+
for (let i = 0; i < globalQueue.h.length; i++) {
|
|
243
|
+
const n = globalQueue.h[i];
|
|
244
|
+
if (n.e !== NOT_PENDING) {
|
|
245
|
+
n.g = n.e;
|
|
246
|
+
n.e = NOT_PENDING;
|
|
247
|
+
}
|
|
248
|
+
if (n.ha)
|
|
249
|
+
_GlobalQueue.la(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.ca = 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.T ?? {
|
|
276
|
+
time: clock,
|
|
277
|
+
pendingNodes: [],
|
|
278
|
+
asyncNodes: [],
|
|
279
|
+
queues: [[], []]
|
|
280
|
+
};
|
|
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.T = activeTransition;
|
|
287
|
+
activeTransition.pendingNodes.push(n);
|
|
134
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.T = activeTransition;
|
|
298
|
+
if (n.G) {
|
|
299
|
+
n.G.da(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.r)
|
|
329
|
+
unobserved[i].sa?.();
|
|
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.S = recompute;
|
|
336
|
+
GlobalQueue.la = 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.e !== NOT_PENDING || el.U || el.V)
|
|
346
|
+
disposeChildren(el);
|
|
347
|
+
else {
|
|
348
|
+
markDisposal(el);
|
|
349
|
+
globalQueue.h.push(el);
|
|
350
|
+
el.V = el.s;
|
|
351
|
+
el.U = el.o;
|
|
352
|
+
el.s = null;
|
|
353
|
+
el.o = null;
|
|
354
|
+
}
|
|
355
|
+
const oldcontext = context;
|
|
356
|
+
context = el;
|
|
357
|
+
el.H = null;
|
|
358
|
+
el.b = 4 /* RecomputingDeps */;
|
|
359
|
+
el.W = clock;
|
|
360
|
+
let value = el.e === NOT_PENDING ? el.g : el.e;
|
|
361
|
+
let oldHeight = el.c;
|
|
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.ea || !el.ea(el.e === NOT_PENDING ? el.g : el.e, value);
|
|
395
|
+
const statusFlagsChanged = el.f !== prevStatusFlags || el.B !== prevError;
|
|
396
|
+
el.ma?.(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.e === NOT_PENDING)
|
|
403
|
+
globalQueue.h.push(el);
|
|
404
|
+
el.e = value;
|
|
306
405
|
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
ActiveTransition = null;
|
|
310
|
-
finishTransition(transition2);
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
addOptimistic(fn) {
|
|
314
|
-
if (fn.f && fn.f !== this) {
|
|
315
|
-
mergeTransitions(fn.f, this);
|
|
316
|
-
ActiveTransition = fn.f;
|
|
317
|
-
return;
|
|
406
|
+
if (el.C)
|
|
407
|
+
el.C.da(value);
|
|
318
408
|
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
if (node.j) {
|
|
325
|
-
if (node.a !== STATE_DISPOSED) {
|
|
326
|
-
!node.f && node.j.ia?.();
|
|
327
|
-
ActiveTransition.addOptimistic(node.j);
|
|
409
|
+
for (let s = el.r; s !== null; s = s.y) {
|
|
410
|
+
const queue = s.j.b & 32 /* Zombie */ ? zombieQueue : dirtyQueue;
|
|
411
|
+
if (s.j.c < el.c && queue.n > s.j.c)
|
|
412
|
+
queue.n = s.j.c;
|
|
413
|
+
insertIntoHeap(s.j, queue);
|
|
328
414
|
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
if (node.f !== ActiveTransition) {
|
|
333
|
-
mergeTransitions(node.f, ActiveTransition);
|
|
334
|
-
ActiveTransition = node.f;
|
|
415
|
+
} else if (el.c != oldHeight) {
|
|
416
|
+
for (let s = el.r; s !== null; s = s.y) {
|
|
417
|
+
insertIntoHeapHeight(s.j, s.j.b & 32 /* Zombie */ ? zombieQueue : dirtyQueue);
|
|
335
418
|
}
|
|
336
|
-
return node.f.b.get(node);
|
|
337
419
|
}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
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.Q;
|
|
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.Q;
|
|
441
|
+
const nextDep = link2.E;
|
|
442
|
+
const nextSub = link2.y;
|
|
443
|
+
const prevSub = link2.na;
|
|
444
|
+
if (nextSub !== null) {
|
|
445
|
+
nextSub.na = prevSub;
|
|
446
|
+
} else {
|
|
447
|
+
dep.X = prevSub;
|
|
448
|
+
}
|
|
449
|
+
if (prevSub !== null) {
|
|
450
|
+
prevSub.y = nextSub;
|
|
451
|
+
} else {
|
|
452
|
+
dep.r = nextSub;
|
|
453
|
+
}
|
|
454
|
+
return nextDep;
|
|
455
|
+
}
|
|
456
|
+
function link(dep, sub) {
|
|
457
|
+
const prevDep = sub.H;
|
|
458
|
+
if (prevDep !== null && prevDep.Q === 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.Q === 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.X;
|
|
471
|
+
if (prevSub !== null && prevSub.j === sub && (!isRecomputing || isValidLink(prevSub, sub))) {
|
|
472
|
+
return;
|
|
585
473
|
}
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
474
|
+
const newLink = sub.H = dep.X = {
|
|
475
|
+
Q: dep,
|
|
476
|
+
j: sub,
|
|
477
|
+
E: nextDep,
|
|
478
|
+
na: 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.r = 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.o;
|
|
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.U : node.o;
|
|
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.U = null;
|
|
620
554
|
} else {
|
|
621
|
-
node.o =
|
|
555
|
+
node.o = null;
|
|
556
|
+
node.K = null;
|
|
622
557
|
}
|
|
623
|
-
|
|
558
|
+
runDisposal(node, zombie);
|
|
559
|
+
}
|
|
560
|
+
function runDisposal(node, zombie) {
|
|
561
|
+
let disposal = zombie ? node.V : node.s;
|
|
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.V = null : node.s = null;
|
|
573
|
+
}
|
|
574
|
+
function withOptions(obj, options) {
|
|
575
|
+
obj.id = options?.id ?? (context?.id != null ? getNextChildId(context) : void 0);
|
|
576
|
+
obj.ea = options?.equals != null ? options.equals : isEqual;
|
|
577
|
+
obj.ya = !!options?.pureWrite;
|
|
578
|
+
obj.sa = 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.oa++);
|
|
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
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
592
|
+
function computed(fn, initialValue, options) {
|
|
593
|
+
const self = withOptions(
|
|
594
|
+
{
|
|
595
|
+
s: null,
|
|
596
|
+
i: globalQueue,
|
|
597
|
+
D: defaultContext,
|
|
598
|
+
oa: 0,
|
|
599
|
+
ha: fn,
|
|
600
|
+
g: initialValue,
|
|
601
|
+
c: 0,
|
|
602
|
+
ba: null,
|
|
603
|
+
P: void 0,
|
|
604
|
+
x: null,
|
|
605
|
+
u: null,
|
|
606
|
+
H: null,
|
|
607
|
+
r: null,
|
|
608
|
+
X: null,
|
|
609
|
+
q: context,
|
|
610
|
+
K: null,
|
|
611
|
+
o: null,
|
|
612
|
+
b: 0 /* None */,
|
|
613
|
+
f: 4 /* Uninitialized */,
|
|
614
|
+
W: clock,
|
|
615
|
+
e: NOT_PENDING,
|
|
616
|
+
V: null,
|
|
617
|
+
U: null
|
|
618
|
+
},
|
|
619
|
+
options
|
|
620
|
+
);
|
|
621
|
+
self.x = self;
|
|
622
|
+
const parent = context?._ ? context.$ : context;
|
|
623
|
+
if (context) {
|
|
624
|
+
context.i && (self.i = context.i);
|
|
625
|
+
context.D && (self.D = context.D);
|
|
626
|
+
const lastChild = context.o;
|
|
627
|
+
if (lastChild === null) {
|
|
628
|
+
context.o = self;
|
|
629
|
+
} else {
|
|
630
|
+
self.K = lastChild;
|
|
631
|
+
context.o = self;
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
if (parent)
|
|
635
|
+
self.c = parent.c + 1;
|
|
636
|
+
recompute(self, true);
|
|
637
|
+
return self;
|
|
644
638
|
}
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
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
|
-
if (staleCheck && (this.g & LOADING_BIT || this.f)) {
|
|
685
|
-
staleCheck.m = true;
|
|
686
|
-
this.f?.aa.read();
|
|
687
|
-
}
|
|
688
|
-
track(this);
|
|
689
|
-
newFlags |= this.g & ~currentMask;
|
|
690
|
-
if (this.g & ERROR_BIT) {
|
|
691
|
-
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
|
+
});
|
|
692
665
|
} else {
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
update(this);
|
|
709
|
-
else
|
|
710
|
-
this.F();
|
|
711
|
-
}
|
|
712
|
-
return this.ha();
|
|
713
|
-
}
|
|
714
|
-
/**
|
|
715
|
-
* Return the current value of this computation
|
|
716
|
-
* Automatically re-executes the surrounding computation when the value changes
|
|
717
|
-
*
|
|
718
|
-
* If the computation has any unresolved ancestors, this function waits for the value to resolve
|
|
719
|
-
* before continuing
|
|
720
|
-
*/
|
|
721
|
-
wait() {
|
|
722
|
-
if (ActiveTransition && (ActiveTransition.b.has(this) || !this.d && this.g & (UNINITIALIZED_BIT | ERROR_BIT))) {
|
|
723
|
-
const clone = ActiveTransition.b.get(this) || cloneGraph(this);
|
|
724
|
-
if (clone !== this)
|
|
725
|
-
return clone.wait();
|
|
726
|
-
}
|
|
727
|
-
if (this.P) {
|
|
728
|
-
if (this.g & ERROR_BIT && this.Q <= clock)
|
|
729
|
-
update(this);
|
|
730
|
-
else
|
|
731
|
-
this.F();
|
|
732
|
-
}
|
|
733
|
-
if ((notStale || this.g & UNINITIALIZED_BIT) && this.g & LOADING_BIT) {
|
|
734
|
-
throw new NotReadyError(this);
|
|
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.ta = () => {
|
|
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.ba = withOptions(
|
|
698
|
+
{
|
|
699
|
+
g: v,
|
|
700
|
+
r: null,
|
|
701
|
+
X: null,
|
|
702
|
+
z: firewall,
|
|
703
|
+
ra: firewall.ba,
|
|
704
|
+
f: 0 /* None */,
|
|
705
|
+
W: clock,
|
|
706
|
+
e: NOT_PENDING
|
|
707
|
+
},
|
|
708
|
+
options
|
|
709
|
+
);
|
|
710
|
+
} else {
|
|
711
|
+
return withOptions(
|
|
712
|
+
{
|
|
713
|
+
g: v,
|
|
714
|
+
r: null,
|
|
715
|
+
X: null,
|
|
716
|
+
f: 0 /* None */,
|
|
717
|
+
W: clock,
|
|
718
|
+
e: 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?._)
|
|
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.c >= (isZombie ? zombieQueue.n : dirtyQueue.n)) {
|
|
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.c;
|
|
752
|
+
if (height >= c.c && el.q !== c) {
|
|
753
|
+
c.c = 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.T || false;
|
|
759
|
+
if (!el.G) {
|
|
760
|
+
el.G = signal(pendingResult);
|
|
761
|
+
el.G.ia = true;
|
|
762
|
+
el.G.da = (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.e === NOT_PENDING ? el.g : el.e
|
|
774
|
+
);
|
|
775
|
+
el.C.ia = true;
|
|
776
|
+
el.C.da = (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.W < 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.e === NOT_PENDING || stale && !pendingCheck && el.T && activeTransition !== el.T ? el.g : el.e;
|
|
805
|
+
}
|
|
806
|
+
function setSignal(el, v) {
|
|
807
|
+
if (typeof v === "function") {
|
|
808
|
+
v = v(
|
|
809
|
+
el.e === NOT_PENDING ? el.g : el.e
|
|
810
|
+
);
|
|
861
811
|
}
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
812
|
+
const valueChanged = !el.ea || !el.ea(el.e === NOT_PENDING ? el.g : el.e, 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.e === NOT_PENDING)
|
|
820
|
+
globalQueue.h.push(el);
|
|
821
|
+
el.e = v;
|
|
822
|
+
}
|
|
823
|
+
if (el.C)
|
|
824
|
+
el.C.da(v);
|
|
825
|
+
}
|
|
826
|
+
clearStatusFlags(el);
|
|
827
|
+
el.W = clock;
|
|
828
|
+
for (let s = el.r; s !== null; s = s.y) {
|
|
829
|
+
const queue = s.j.b & 32 /* Zombie */ ? zombieQueue : dirtyQueue;
|
|
830
|
+
if (queue.n > s.j.c)
|
|
831
|
+
queue.n = s.j.c;
|
|
832
|
+
insertIntoHeap(s.j, queue);
|
|
833
|
+
}
|
|
834
|
+
schedule();
|
|
835
|
+
return v;
|
|
836
|
+
}
|
|
837
|
+
function getObserver() {
|
|
838
|
+
return tracking ? context : null;
|
|
839
|
+
}
|
|
840
|
+
function getOwner() {
|
|
841
|
+
return context;
|
|
842
|
+
}
|
|
843
|
+
function onCleanup(fn) {
|
|
844
|
+
if (!context)
|
|
845
|
+
return fn;
|
|
846
|
+
const node = context;
|
|
847
|
+
if (!node.s) {
|
|
848
|
+
node.s = fn;
|
|
849
|
+
} else if (Array.isArray(node.s)) {
|
|
850
|
+
node.s.push(fn);
|
|
851
|
+
} else {
|
|
852
|
+
node.s = [node.s, fn];
|
|
853
|
+
}
|
|
854
|
+
return fn;
|
|
855
|
+
}
|
|
856
|
+
function createOwner(options) {
|
|
857
|
+
const parent = context;
|
|
858
|
+
const owner = {
|
|
859
|
+
_: true,
|
|
860
|
+
$: parent?._ ? parent.$ : parent,
|
|
861
|
+
o: null,
|
|
862
|
+
K: null,
|
|
863
|
+
s: null,
|
|
864
|
+
id: options?.id ?? (parent?.id != null ? getNextChildId(parent) : void 0),
|
|
865
|
+
i: parent?.i ?? globalQueue,
|
|
866
|
+
D: parent?.D || defaultContext,
|
|
867
|
+
oa: 0,
|
|
868
|
+
V: null,
|
|
869
|
+
U: null,
|
|
870
|
+
q: parent,
|
|
871
|
+
dispose(self = true) {
|
|
872
|
+
disposeChildren(owner, self);
|
|
904
873
|
}
|
|
905
|
-
}
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
}
|
|
914
|
-
} else {
|
|
915
|
-
node.b = newSources;
|
|
916
|
-
}
|
|
917
|
-
let source;
|
|
918
|
-
for (let i = newSourcesIndex; i < node.b.length; i++) {
|
|
919
|
-
source = getTransitionSource(node.b[i]);
|
|
920
|
-
if (!source.c)
|
|
921
|
-
source.c = [node];
|
|
922
|
-
else
|
|
923
|
-
source.c.push(node);
|
|
924
|
-
}
|
|
925
|
-
} else if (node.b && newSourcesIndex < node.b.length) {
|
|
926
|
-
removeSourceObservers(node, newSourcesIndex);
|
|
927
|
-
node.b.length = newSourcesIndex;
|
|
874
|
+
};
|
|
875
|
+
if (parent) {
|
|
876
|
+
const lastChild = parent.o;
|
|
877
|
+
if (lastChild === null) {
|
|
878
|
+
parent.o = owner;
|
|
879
|
+
} else {
|
|
880
|
+
owner.K = lastChild;
|
|
881
|
+
parent.o = owner;
|
|
928
882
|
}
|
|
929
|
-
newSources = prevSources;
|
|
930
|
-
newSourcesIndex = prevSourcesIndex;
|
|
931
|
-
newFlags = prevFlags;
|
|
932
|
-
node.Q = clock + 1;
|
|
933
|
-
node.a = STATE_CLEAN;
|
|
934
883
|
}
|
|
884
|
+
return owner;
|
|
935
885
|
}
|
|
936
|
-
function
|
|
937
|
-
|
|
886
|
+
function createRoot(init, options) {
|
|
887
|
+
const owner = createOwner(options);
|
|
888
|
+
return runWithOwner(owner, () => init(owner.dispose));
|
|
938
889
|
}
|
|
939
|
-
function
|
|
940
|
-
|
|
890
|
+
function runWithOwner(owner, fn) {
|
|
891
|
+
const oldContext = context;
|
|
892
|
+
context = owner;
|
|
893
|
+
try {
|
|
894
|
+
return fn();
|
|
895
|
+
} finally {
|
|
896
|
+
context = oldContext;
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
function staleValues(fn, set = true) {
|
|
900
|
+
const prevStale = stale;
|
|
901
|
+
stale = set;
|
|
902
|
+
try {
|
|
941
903
|
return fn();
|
|
942
|
-
|
|
904
|
+
} finally {
|
|
905
|
+
stale = prevStale;
|
|
906
|
+
}
|
|
943
907
|
}
|
|
944
|
-
function
|
|
945
|
-
const
|
|
946
|
-
|
|
908
|
+
function pending(fn) {
|
|
909
|
+
const prevLatest = pendingValueCheck;
|
|
910
|
+
pendingValueCheck = true;
|
|
947
911
|
try {
|
|
948
|
-
fn
|
|
949
|
-
return updateCheck.m;
|
|
912
|
+
return staleValues(fn, false);
|
|
950
913
|
} finally {
|
|
951
|
-
|
|
914
|
+
pendingValueCheck = prevLatest;
|
|
952
915
|
}
|
|
953
916
|
}
|
|
954
|
-
function
|
|
955
|
-
const current =
|
|
956
|
-
|
|
917
|
+
function isPending(fn, loadingValue) {
|
|
918
|
+
const current = pendingCheck;
|
|
919
|
+
pendingCheck = { g: false };
|
|
957
920
|
try {
|
|
958
|
-
|
|
959
|
-
return
|
|
921
|
+
staleValues(fn);
|
|
922
|
+
return pendingCheck.g;
|
|
960
923
|
} catch (err) {
|
|
961
924
|
if (!(err instanceof NotReadyError))
|
|
962
925
|
return false;
|
|
@@ -964,413 +927,161 @@ function pendingCheck(fn, loadingValue) {
|
|
|
964
927
|
return loadingValue;
|
|
965
928
|
throw err;
|
|
966
929
|
} finally {
|
|
967
|
-
|
|
930
|
+
pendingCheck = current;
|
|
968
931
|
}
|
|
969
932
|
}
|
|
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;
|
|
933
|
+
|
|
934
|
+
// src/core/context.ts
|
|
935
|
+
function createContext(defaultValue, description) {
|
|
936
|
+
return { id: Symbol(description), defaultValue };
|
|
985
937
|
}
|
|
986
|
-
function
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
const prevNotStale = notStale;
|
|
990
|
-
notStale = false;
|
|
991
|
-
try {
|
|
992
|
-
return fn();
|
|
993
|
-
} catch (err) {
|
|
994
|
-
if (argLength > 1 && err instanceof NotReadyError)
|
|
995
|
-
return fallback;
|
|
996
|
-
throw err;
|
|
997
|
-
} finally {
|
|
998
|
-
newFlags = prevFlags;
|
|
999
|
-
notStale = prevNotStale;
|
|
938
|
+
function getContext(context2, owner = getOwner()) {
|
|
939
|
+
if (!owner) {
|
|
940
|
+
throw new NoOwnerError();
|
|
1000
941
|
}
|
|
942
|
+
const value = hasContext(context2, owner) ? owner.D[context2.id] : context2.defaultValue;
|
|
943
|
+
if (isUndefined(value)) {
|
|
944
|
+
throw new ContextNotFoundError();
|
|
945
|
+
}
|
|
946
|
+
return value;
|
|
1001
947
|
}
|
|
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;
|
|
948
|
+
function setContext(context2, value, owner = getOwner()) {
|
|
949
|
+
if (!owner) {
|
|
950
|
+
throw new NoOwnerError();
|
|
1014
951
|
}
|
|
952
|
+
owner.D = {
|
|
953
|
+
...owner.D,
|
|
954
|
+
[context2.id]: isUndefined(value) ? context2.defaultValue : value
|
|
955
|
+
};
|
|
956
|
+
}
|
|
957
|
+
function hasContext(context2, owner) {
|
|
958
|
+
return !isUndefined(owner?.D[context2.id]);
|
|
959
|
+
}
|
|
960
|
+
function isUndefined(value) {
|
|
961
|
+
return typeof value === "undefined";
|
|
1015
962
|
}
|
|
1016
963
|
|
|
1017
964
|
// 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;
|
|
965
|
+
function effect(compute, effect2, error, initialValue, options) {
|
|
966
|
+
let initialized = false;
|
|
967
|
+
const node = computed(compute, initialValue, {
|
|
968
|
+
...options,
|
|
969
|
+
ja: {
|
|
970
|
+
fa: true,
|
|
971
|
+
pa: initialValue,
|
|
972
|
+
ua: effect2,
|
|
973
|
+
qa: error,
|
|
974
|
+
L: void 0,
|
|
975
|
+
i: getOwner()?.i ?? globalQueue,
|
|
976
|
+
I: options?.render ? 1 /* Render */ : 2 /* User */,
|
|
977
|
+
ma(statusFlagsChanged, prevStatusFlags) {
|
|
978
|
+
if (initialized) {
|
|
979
|
+
const errorChanged = this.f && this.f === prevStatusFlags && statusFlagsChanged;
|
|
980
|
+
this.fa = !(this.f & 2 /* Error */) && !(this.f & 1 /* Pending */ & ~prevStatusFlags) && !errorChanged;
|
|
981
|
+
if (this.fa)
|
|
982
|
+
this.i.enqueue(this.I, runEffect.bind(this));
|
|
983
|
+
}
|
|
984
|
+
if (this.f & 2 /* Error */) {
|
|
985
|
+
let error2 = this.B;
|
|
986
|
+
this.i.notify(this, 1 /* Pending */, 0);
|
|
987
|
+
if (this.I === 2 /* User */) {
|
|
988
|
+
try {
|
|
989
|
+
return this.qa ? this.qa(error2, () => {
|
|
990
|
+
this.L?.();
|
|
991
|
+
this.L = void 0;
|
|
992
|
+
}) : console.error(error2);
|
|
993
|
+
} catch (e) {
|
|
994
|
+
error2 = e;
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
if (!this.i.notify(this, 2 /* Error */, 2 /* Error */))
|
|
998
|
+
throw error2;
|
|
999
|
+
} else if (this.I === 1 /* Render */) {
|
|
1000
|
+
this.i.notify(
|
|
1001
|
+
this,
|
|
1002
|
+
1 /* Pending */ | 2 /* Error */,
|
|
1003
|
+
this.f
|
|
1004
|
+
);
|
|
1112
1005
|
}
|
|
1113
1006
|
}
|
|
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
1007
|
}
|
|
1008
|
+
});
|
|
1009
|
+
initialized = true;
|
|
1010
|
+
if (node.I === 1 /* Render */) {
|
|
1011
|
+
node.ha = (p) => !(node.f & 2 /* Error */) ? staleValues(() => compute(p)) : compute(p);
|
|
1200
1012
|
}
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1013
|
+
!options?.defer && !(node.f & (2 /* Error */ | 1 /* Pending */)) && (node.I === 2 /* User */ ? node.i.enqueue(node.I, runEffect.bind(node)) : runEffect.call(node));
|
|
1014
|
+
onCleanup(() => node.L?.());
|
|
1015
|
+
}
|
|
1016
|
+
function runEffect() {
|
|
1017
|
+
if (!this.fa || this.b & 64 /* Disposed */)
|
|
1018
|
+
return;
|
|
1019
|
+
this.L?.();
|
|
1020
|
+
this.L = void 0;
|
|
1021
|
+
try {
|
|
1022
|
+
this.L = this.ua(this.g, this.pa);
|
|
1023
|
+
} catch (error) {
|
|
1024
|
+
if (!this.i.notify(this, 2 /* Error */, 2 /* Error */))
|
|
1025
|
+
throw error;
|
|
1026
|
+
} finally {
|
|
1027
|
+
this.pa = this.g;
|
|
1028
|
+
this.fa = false;
|
|
1204
1029
|
}
|
|
1205
1030
|
}
|
|
1206
1031
|
|
|
1207
1032
|
// src/signals.ts
|
|
1208
1033
|
function createSignal(first, second, third) {
|
|
1209
1034
|
if (typeof first === "function") {
|
|
1210
|
-
const node2 =
|
|
1035
|
+
const node2 = computed(first, second, third);
|
|
1211
1036
|
return [
|
|
1212
|
-
|
|
1213
|
-
(
|
|
1214
|
-
node2.F();
|
|
1215
|
-
return node2.write(v);
|
|
1216
|
-
}
|
|
1037
|
+
read.bind(null, node2),
|
|
1038
|
+
setSignal.bind(null, node2)
|
|
1217
1039
|
];
|
|
1218
1040
|
}
|
|
1219
1041
|
const o = getOwner();
|
|
1220
1042
|
const needsId = o?.id != null;
|
|
1221
|
-
const node =
|
|
1043
|
+
const node = signal(
|
|
1222
1044
|
first,
|
|
1223
|
-
|
|
1224
|
-
needsId ? { id: o.getNextChildId(), ...second } : second
|
|
1225
|
-
);
|
|
1226
|
-
return [node.read.bind(node), node.write.bind(node)];
|
|
1227
|
-
}
|
|
1228
|
-
function createMemo(compute2, value, options) {
|
|
1229
|
-
let node = new Computation(
|
|
1230
|
-
value,
|
|
1231
|
-
compute2,
|
|
1232
|
-
options
|
|
1233
|
-
);
|
|
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
|
-
}
|
|
1250
|
-
function createAsync(compute2, value, options) {
|
|
1251
|
-
let refreshing = false;
|
|
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
|
|
1045
|
+
needsId ? { id: getNextChildId(o), ...second } : second
|
|
1312
1046
|
);
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1047
|
+
return [
|
|
1048
|
+
read.bind(null, node),
|
|
1049
|
+
setSignal.bind(null, node)
|
|
1050
|
+
];
|
|
1051
|
+
}
|
|
1052
|
+
function createMemo(compute, value, options) {
|
|
1053
|
+
let node = computed(compute, value, options);
|
|
1054
|
+
return read.bind(null, node);
|
|
1055
|
+
}
|
|
1056
|
+
function createAsync(compute, value, options) {
|
|
1057
|
+
const node = asyncComputed(compute, value, options);
|
|
1058
|
+
const ret = read.bind(null, node);
|
|
1059
|
+
ret.refresh = node.ta;
|
|
1060
|
+
return ret;
|
|
1061
|
+
}
|
|
1062
|
+
function createEffect(compute, effectFn, value, options) {
|
|
1063
|
+
void effect(
|
|
1064
|
+
compute,
|
|
1065
|
+
effectFn.effect || effectFn,
|
|
1066
|
+
effectFn.error,
|
|
1327
1067
|
value,
|
|
1328
|
-
compute2,
|
|
1329
|
-
effect.effect || effect,
|
|
1330
|
-
effect.error,
|
|
1331
1068
|
options
|
|
1332
1069
|
);
|
|
1333
1070
|
}
|
|
1334
|
-
function createRenderEffect(
|
|
1335
|
-
void
|
|
1071
|
+
function createRenderEffect(compute, effectFn, value, options) {
|
|
1072
|
+
void effect(compute, effectFn, void 0, value, {
|
|
1336
1073
|
render: true,
|
|
1337
1074
|
...options
|
|
1338
1075
|
});
|
|
1339
1076
|
}
|
|
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);
|
|
1077
|
+
function createTrackedEffect(compute, options) {
|
|
1366
1078
|
}
|
|
1367
|
-
function
|
|
1368
|
-
return compute(owner, run, null);
|
|
1079
|
+
function createReaction(effect2, options) {
|
|
1369
1080
|
}
|
|
1370
1081
|
function resolve(fn) {
|
|
1371
1082
|
return new Promise((res, rej) => {
|
|
1372
1083
|
createRoot((dispose) => {
|
|
1373
|
-
|
|
1084
|
+
computed(() => {
|
|
1374
1085
|
try {
|
|
1375
1086
|
res(fn());
|
|
1376
1087
|
} catch (err) {
|
|
@@ -1384,44 +1095,9 @@ function resolve(fn) {
|
|
|
1384
1095
|
});
|
|
1385
1096
|
}
|
|
1386
1097
|
function createOptimistic(first, second, third) {
|
|
1387
|
-
|
|
1388
|
-
second,
|
|
1389
|
-
(prev) => {
|
|
1390
|
-
if (node.j.f) {
|
|
1391
|
-
latest(() => first(prev));
|
|
1392
|
-
return prev;
|
|
1393
|
-
}
|
|
1394
|
-
return first(prev);
|
|
1395
|
-
},
|
|
1396
|
-
third
|
|
1397
|
-
) : new Computation(first, null, second);
|
|
1398
|
-
node.j = () => node.write(first);
|
|
1399
|
-
function write(v) {
|
|
1400
|
-
if (!ActiveTransition)
|
|
1401
|
-
throw new Error("createOptimistic can only be updated inside a transition");
|
|
1402
|
-
ActiveTransition.addOptimistic(node.j);
|
|
1403
|
-
queueMicrotask(() => {
|
|
1404
|
-
if (node.j.f) {
|
|
1405
|
-
node.F();
|
|
1406
|
-
node.write(v);
|
|
1407
|
-
}
|
|
1408
|
-
});
|
|
1409
|
-
}
|
|
1410
|
-
return [node.wait.bind(node), write];
|
|
1098
|
+
return {};
|
|
1411
1099
|
}
|
|
1412
|
-
function
|
|
1413
|
-
let t = new Transition(new Computation(void 0, null));
|
|
1414
|
-
queueMicrotask(() => t.runTransition(() => fn((fn2) => t.runTransition(fn2))));
|
|
1415
|
-
}
|
|
1416
|
-
function useTransition() {
|
|
1417
|
-
const [pending, setPending] = createOptimistic(false);
|
|
1418
|
-
function start(fn) {
|
|
1419
|
-
transition((resume) => {
|
|
1420
|
-
setPending(true);
|
|
1421
|
-
return fn(resume);
|
|
1422
|
-
});
|
|
1423
|
-
}
|
|
1424
|
-
return [pending, start];
|
|
1100
|
+
function onSettled(callback) {
|
|
1425
1101
|
}
|
|
1426
1102
|
|
|
1427
1103
|
// src/store/reconcile.ts
|
|
@@ -1429,7 +1105,7 @@ function unwrap(value) {
|
|
|
1429
1105
|
return value?.[$TARGET]?.[STORE_NODE] ?? value;
|
|
1430
1106
|
}
|
|
1431
1107
|
function getOverrideValue(value, override, nodes, key) {
|
|
1432
|
-
return nodes && key in nodes ? nodes[key]
|
|
1108
|
+
return nodes && key in nodes ? read(nodes[key]) : override && key in override ? override[key] : value[key];
|
|
1433
1109
|
}
|
|
1434
1110
|
function getAllKeys(value, override, next) {
|
|
1435
1111
|
const keys = getKeys(value, override);
|
|
@@ -1463,16 +1139,16 @@ function applyState(next, state, keyFn, all) {
|
|
|
1463
1139
|
if (start > newEnd || start > end) {
|
|
1464
1140
|
for (j = start; j <= newEnd; j++) {
|
|
1465
1141
|
changed = true;
|
|
1466
|
-
target[STORE_NODE][j]
|
|
1142
|
+
target[STORE_NODE][j] && setSignal(target[STORE_NODE][j], wrap(next[j], target));
|
|
1467
1143
|
}
|
|
1468
1144
|
for (; j < next.length; j++) {
|
|
1469
1145
|
changed = true;
|
|
1470
1146
|
const wrapped = wrap(temp[j], target);
|
|
1471
|
-
target[STORE_NODE][j]
|
|
1147
|
+
target[STORE_NODE][j] && setSignal(target[STORE_NODE][j], wrapped);
|
|
1472
1148
|
applyState(next[j], wrapped, keyFn, all);
|
|
1473
1149
|
}
|
|
1474
|
-
changed && target[STORE_NODE][$TRACK]
|
|
1475
|
-
prevLength !== next.length && target[STORE_NODE].length
|
|
1150
|
+
changed && target[STORE_NODE][$TRACK] && setSignal(target[STORE_NODE][$TRACK], void 0);
|
|
1151
|
+
prevLength !== next.length && target[STORE_NODE].length && setSignal(target[STORE_NODE].length, next.length);
|
|
1476
1152
|
return;
|
|
1477
1153
|
}
|
|
1478
1154
|
newIndicesNext = new Array(newEnd + 1);
|
|
@@ -1496,10 +1172,10 @@ function applyState(next, state, keyFn, all) {
|
|
|
1496
1172
|
for (j = start; j < next.length; j++) {
|
|
1497
1173
|
if (j in temp) {
|
|
1498
1174
|
const wrapped = wrap(temp[j], target);
|
|
1499
|
-
target[STORE_NODE][j]
|
|
1175
|
+
target[STORE_NODE][j] && setSignal(target[STORE_NODE][j], wrapped);
|
|
1500
1176
|
applyState(next[j], wrapped, keyFn, all);
|
|
1501
1177
|
} else
|
|
1502
|
-
target[STORE_NODE][j]
|
|
1178
|
+
target[STORE_NODE][j] && setSignal(target[STORE_NODE][j], wrap(next[j], target));
|
|
1503
1179
|
}
|
|
1504
1180
|
if (start < next.length)
|
|
1505
1181
|
changed = true;
|
|
@@ -1511,9 +1187,9 @@ function applyState(next, state, keyFn, all) {
|
|
|
1511
1187
|
}
|
|
1512
1188
|
if (prevLength !== next.length) {
|
|
1513
1189
|
changed = true;
|
|
1514
|
-
target[STORE_NODE].length
|
|
1190
|
+
target[STORE_NODE].length && setSignal(target[STORE_NODE].length, next.length);
|
|
1515
1191
|
}
|
|
1516
|
-
changed && target[STORE_NODE][$TRACK]
|
|
1192
|
+
changed && target[STORE_NODE][$TRACK] && setSignal(target[STORE_NODE][$TRACK], void 0);
|
|
1517
1193
|
return;
|
|
1518
1194
|
}
|
|
1519
1195
|
if (nodes) {
|
|
@@ -1527,8 +1203,8 @@ function applyState(next, state, keyFn, all) {
|
|
|
1527
1203
|
if (previousValue === nextValue)
|
|
1528
1204
|
continue;
|
|
1529
1205
|
if (!previousValue || !isWrappable(previousValue) || keyFn(previousValue) != null && keyFn(previousValue) !== keyFn(nextValue)) {
|
|
1530
|
-
tracked
|
|
1531
|
-
node
|
|
1206
|
+
tracked && setSignal(tracked, void 0);
|
|
1207
|
+
node && setSignal(node, isWrappable(nextValue) ? wrap(nextValue, target) : nextValue);
|
|
1532
1208
|
} else
|
|
1533
1209
|
applyState(nextValue, wrap(previousValue, target), keyFn, all);
|
|
1534
1210
|
}
|
|
@@ -1536,7 +1212,8 @@ function applyState(next, state, keyFn, all) {
|
|
|
1536
1212
|
if (nodes = target[STORE_HAS]) {
|
|
1537
1213
|
const keys = Object.keys(nodes);
|
|
1538
1214
|
for (let i = 0, len = keys.length; i < len; i++) {
|
|
1539
|
-
|
|
1215
|
+
const key = keys[i];
|
|
1216
|
+
setSignal(nodes[key], key in next);
|
|
1540
1217
|
}
|
|
1541
1218
|
}
|
|
1542
1219
|
}
|
|
@@ -1554,13 +1231,14 @@ function reconcile(value, key, all = false) {
|
|
|
1554
1231
|
|
|
1555
1232
|
// src/store/projection.ts
|
|
1556
1233
|
function createProjectionInternal(fn, initialValue = {}, options) {
|
|
1234
|
+
let node;
|
|
1557
1235
|
const wrappedMap = /* @__PURE__ */ new WeakMap();
|
|
1558
1236
|
const traps = {
|
|
1559
1237
|
...storeTraps,
|
|
1560
1238
|
get(target, property, receiver) {
|
|
1561
1239
|
const o = getOwner();
|
|
1562
|
-
const n =
|
|
1563
|
-
(!o || o !== n) && n
|
|
1240
|
+
const n = node;
|
|
1241
|
+
(!o || o !== n) && n && read(n);
|
|
1564
1242
|
return storeTraps.get(target, property, receiver);
|
|
1565
1243
|
}
|
|
1566
1244
|
};
|
|
@@ -1577,7 +1255,7 @@ function createProjectionInternal(fn, initialValue = {}, options) {
|
|
|
1577
1255
|
return wrapped;
|
|
1578
1256
|
};
|
|
1579
1257
|
const wrappedStore = wrapProjection(initialValue);
|
|
1580
|
-
|
|
1258
|
+
node = computed(() => {
|
|
1581
1259
|
storeSetter(wrappedStore, (s) => {
|
|
1582
1260
|
const value = fn(s);
|
|
1583
1261
|
if (value !== s && value !== void 0) {
|
|
@@ -1635,7 +1313,7 @@ function getNodes(target, type) {
|
|
|
1635
1313
|
function getNode(nodes, property, value, equals = isEqual) {
|
|
1636
1314
|
if (nodes[property])
|
|
1637
1315
|
return nodes[property];
|
|
1638
|
-
return nodes[property] =
|
|
1316
|
+
return nodes[property] = signal(value, {
|
|
1639
1317
|
equals,
|
|
1640
1318
|
unobserved() {
|
|
1641
1319
|
delete nodes[property];
|
|
@@ -1643,7 +1321,7 @@ function getNode(nodes, property, value, equals = isEqual) {
|
|
|
1643
1321
|
});
|
|
1644
1322
|
}
|
|
1645
1323
|
function trackSelf(target, symbol = $TRACK) {
|
|
1646
|
-
getObserver() && getNode(getNodes(target, STORE_NODE), symbol, void 0, false)
|
|
1324
|
+
getObserver() && read(getNode(getNodes(target, STORE_NODE), symbol, void 0, false));
|
|
1647
1325
|
}
|
|
1648
1326
|
function getKeys(source, override, enumerable = true) {
|
|
1649
1327
|
const baseKeys = untrack(() => enumerable ? Object.keys(source) : Reflect.ownKeys(source));
|
|
@@ -1691,7 +1369,7 @@ var storeTraps = {
|
|
|
1691
1369
|
return desc.get.call(receiver);
|
|
1692
1370
|
}
|
|
1693
1371
|
if (Writing?.has(receiver)) {
|
|
1694
|
-
let value2 = tracked && (overridden || !proxySource) ? tracked.
|
|
1372
|
+
let value2 = tracked && (overridden || !proxySource) ? tracked.e !== NOT_PENDING ? tracked.e : tracked.g : storeValue[property];
|
|
1695
1373
|
value2 === $DELETED && (value2 = void 0);
|
|
1696
1374
|
if (!isWrappable(value2))
|
|
1697
1375
|
return value2;
|
|
@@ -1699,14 +1377,14 @@ var storeTraps = {
|
|
|
1699
1377
|
Writing.add(wrapped);
|
|
1700
1378
|
return wrapped;
|
|
1701
1379
|
}
|
|
1702
|
-
let value = tracked ? overridden || !proxySource ? nodes[property]
|
|
1380
|
+
let value = tracked ? overridden || !proxySource ? read(nodes[property]) : (read(nodes[property]), storeValue[property]) : storeValue[property];
|
|
1703
1381
|
value === $DELETED && (value = void 0);
|
|
1704
1382
|
if (!tracked) {
|
|
1705
1383
|
if (!overridden && typeof value === "function" && !storeValue.hasOwnProperty(property)) {
|
|
1706
1384
|
let proto;
|
|
1707
1385
|
return !Array.isArray(target[STORE_VALUE]) && (proto = Object.getPrototypeOf(target[STORE_VALUE])) && proto !== Object.prototype ? value.bind(storeValue) : value;
|
|
1708
1386
|
} else if (getObserver()) {
|
|
1709
|
-
return getNode(nodes, property, isWrappable(value) ? wrap(value, target) : value)
|
|
1387
|
+
return read(getNode(nodes, property, isWrappable(value) ? wrap(value, target) : value));
|
|
1710
1388
|
}
|
|
1711
1389
|
}
|
|
1712
1390
|
return isWrappable(value) ? wrap(value, target) : value;
|
|
@@ -1715,7 +1393,7 @@ var storeTraps = {
|
|
|
1715
1393
|
if (property === $PROXY || property === $TRACK || property === "__proto__")
|
|
1716
1394
|
return true;
|
|
1717
1395
|
const has = target[STORE_OVERRIDE] && property in target[STORE_OVERRIDE] ? target[STORE_OVERRIDE][property] !== $DELETED : property in target[STORE_VALUE];
|
|
1718
|
-
getObserver() && getNode(getNodes(target, STORE_HAS), property, has)
|
|
1396
|
+
getObserver() && read(getNode(getNodes(target, STORE_HAS), property, has));
|
|
1719
1397
|
return has;
|
|
1720
1398
|
},
|
|
1721
1399
|
set(target, property, rawValue) {
|
|
@@ -1740,15 +1418,15 @@ var storeTraps = {
|
|
|
1740
1418
|
}
|
|
1741
1419
|
if (recursivelyNotify(store, storeLookup) && wrappable)
|
|
1742
1420
|
recursivelyAddParent(value, store);
|
|
1743
|
-
target[STORE_HAS]?.[property]
|
|
1421
|
+
target[STORE_HAS]?.[property] && setSignal(target[STORE_HAS][property], true);
|
|
1744
1422
|
const nodes = getNodes(target, STORE_NODE);
|
|
1745
|
-
nodes[property]
|
|
1423
|
+
nodes[property] && setSignal(nodes[property], () => wrappable ? wrap(value, target) : value);
|
|
1746
1424
|
if (Array.isArray(state)) {
|
|
1747
1425
|
const index = parseInt(property) + 1;
|
|
1748
1426
|
if (index > len)
|
|
1749
|
-
nodes.length
|
|
1427
|
+
nodes.length && setSignal(nodes.length, index);
|
|
1750
1428
|
}
|
|
1751
|
-
nodes[$TRACK]
|
|
1429
|
+
nodes[$TRACK] && setSignal(nodes[$TRACK], void 0);
|
|
1752
1430
|
});
|
|
1753
1431
|
}
|
|
1754
1432
|
return true;
|
|
@@ -1767,10 +1445,11 @@ var storeTraps = {
|
|
|
1767
1445
|
const parents = PARENTS.get(prev);
|
|
1768
1446
|
parents && (parents instanceof Set ? parents.delete(target) : PARENTS.delete(prev));
|
|
1769
1447
|
}
|
|
1770
|
-
target[STORE_HAS]?.[property]
|
|
1448
|
+
if (target[STORE_HAS]?.[property])
|
|
1449
|
+
setSignal(target[STORE_HAS][property], false);
|
|
1771
1450
|
const nodes = getNodes(target, STORE_NODE);
|
|
1772
|
-
nodes[property]
|
|
1773
|
-
nodes[$TRACK]
|
|
1451
|
+
nodes[property] && setSignal(nodes[property], void 0);
|
|
1452
|
+
nodes[$TRACK] && setSignal(nodes[$TRACK], void 0);
|
|
1774
1453
|
});
|
|
1775
1454
|
}
|
|
1776
1455
|
return true;
|
|
@@ -1824,7 +1503,7 @@ function recursivelyNotify(state, lookup) {
|
|
|
1824
1503
|
if (target) {
|
|
1825
1504
|
const deep2 = getNodes(target, STORE_NODE)[$DEEP];
|
|
1826
1505
|
if (deep2) {
|
|
1827
|
-
deep2
|
|
1506
|
+
setSignal(deep2, void 0);
|
|
1828
1507
|
notified = true;
|
|
1829
1508
|
}
|
|
1830
1509
|
lookup = target[STORE_LOOKUP] || lookup;
|
|
@@ -1881,31 +1560,7 @@ function deep(store) {
|
|
|
1881
1560
|
|
|
1882
1561
|
// src/store/optimistic.ts
|
|
1883
1562
|
function createOptimisticStore(first, second, options) {
|
|
1884
|
-
|
|
1885
|
-
const { store, node } = derived ? createProjectionInternal(
|
|
1886
|
-
(draft) => {
|
|
1887
|
-
if (reset.f) {
|
|
1888
|
-
latest(() => first(draft));
|
|
1889
|
-
return draft;
|
|
1890
|
-
}
|
|
1891
|
-
return first(draft);
|
|
1892
|
-
},
|
|
1893
|
-
second,
|
|
1894
|
-
options
|
|
1895
|
-
) : createProjectionInternal(() => {
|
|
1896
|
-
}, first);
|
|
1897
|
-
const reset = () => storeSetter(
|
|
1898
|
-
store,
|
|
1899
|
-
reconcile(derived ? first(store) || store : first, options?.key || "id", options?.all)
|
|
1900
|
-
);
|
|
1901
|
-
const write = (v) => {
|
|
1902
|
-
if (!ActiveTransition)
|
|
1903
|
-
throw new Error("createOptimisticStore can only be updated inside a transition");
|
|
1904
|
-
ActiveTransition.addOptimistic(reset);
|
|
1905
|
-
queueMicrotask(() => reset.f && storeSetter(store, v));
|
|
1906
|
-
};
|
|
1907
|
-
node.j = reset;
|
|
1908
|
-
return [store, write];
|
|
1563
|
+
return [];
|
|
1909
1564
|
}
|
|
1910
1565
|
|
|
1911
1566
|
// src/store/utils.ts
|
|
@@ -2111,347 +1766,341 @@ function omit(props, ...keys) {
|
|
|
2111
1766
|
// src/map.ts
|
|
2112
1767
|
function mapArray(list, map, options) {
|
|
2113
1768
|
const keyFn = typeof options?.keyed === "function" ? options.keyed : void 0;
|
|
2114
|
-
return
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
1769
|
+
return createMemo(
|
|
1770
|
+
updateKeyedMap.bind({
|
|
1771
|
+
z: createOwner(),
|
|
1772
|
+
k: 0,
|
|
1773
|
+
va: list,
|
|
1774
|
+
F: [],
|
|
1775
|
+
M: map,
|
|
1776
|
+
d: [],
|
|
1777
|
+
a: [],
|
|
1778
|
+
N: keyFn,
|
|
1779
|
+
l: keyFn || options?.keyed === false ? [] : void 0,
|
|
1780
|
+
m: map.length > 1 ? [] : void 0,
|
|
1781
|
+
Y: options?.fallback
|
|
1782
|
+
})
|
|
1783
|
+
);
|
|
2127
1784
|
}
|
|
2128
1785
|
var pureOptions = { pureWrite: true };
|
|
2129
1786
|
function updateKeyedMap() {
|
|
2130
|
-
const newItems = this.
|
|
1787
|
+
const newItems = this.va() || [], newLen = newItems.length;
|
|
2131
1788
|
newItems[$TRACK];
|
|
2132
|
-
runWithOwner(this.
|
|
2133
|
-
let i, j, mapper = this.
|
|
2134
|
-
this.
|
|
2135
|
-
this.
|
|
2136
|
-
return this.
|
|
2137
|
-
|
|
2138
|
-
this.
|
|
1789
|
+
runWithOwner(this.z, () => {
|
|
1790
|
+
let i, j, mapper = this.l ? () => {
|
|
1791
|
+
this.l[j] = signal(newItems[j], pureOptions);
|
|
1792
|
+
this.m && (this.m[j] = signal(j, pureOptions));
|
|
1793
|
+
return this.M(
|
|
1794
|
+
read.bind(null, this.l[j]),
|
|
1795
|
+
this.m ? read.bind(null, this.m[j]) : void 0
|
|
2139
1796
|
);
|
|
2140
|
-
} : this.
|
|
1797
|
+
} : this.m ? () => {
|
|
2141
1798
|
const item = newItems[j];
|
|
2142
|
-
this.
|
|
2143
|
-
return this.
|
|
1799
|
+
this.m[j] = signal(j, pureOptions);
|
|
1800
|
+
return this.M(
|
|
1801
|
+
() => item,
|
|
1802
|
+
read.bind(null, this.m[j])
|
|
1803
|
+
);
|
|
2144
1804
|
} : () => {
|
|
2145
1805
|
const item = newItems[j];
|
|
2146
|
-
return this.
|
|
1806
|
+
return this.M(() => item);
|
|
2147
1807
|
};
|
|
2148
1808
|
if (newLen === 0) {
|
|
2149
|
-
if (this.
|
|
2150
|
-
this.
|
|
2151
|
-
this.
|
|
2152
|
-
this.
|
|
2153
|
-
this.
|
|
2154
|
-
this.
|
|
2155
|
-
this.
|
|
2156
|
-
this.
|
|
1809
|
+
if (this.k !== 0) {
|
|
1810
|
+
this.z.dispose(false);
|
|
1811
|
+
this.a = [];
|
|
1812
|
+
this.F = [];
|
|
1813
|
+
this.d = [];
|
|
1814
|
+
this.k = 0;
|
|
1815
|
+
this.l && (this.l = []);
|
|
1816
|
+
this.m && (this.m = []);
|
|
2157
1817
|
}
|
|
2158
|
-
if (this.
|
|
2159
|
-
this.
|
|
2160
|
-
this.
|
|
2161
|
-
this.
|
|
2162
|
-
null
|
|
1818
|
+
if (this.Y && !this.d[0]) {
|
|
1819
|
+
this.d[0] = runWithOwner(
|
|
1820
|
+
this.a[0] = createOwner(),
|
|
1821
|
+
this.Y
|
|
2163
1822
|
);
|
|
2164
1823
|
}
|
|
2165
|
-
} else if (this.
|
|
2166
|
-
if (this.
|
|
2167
|
-
this.
|
|
2168
|
-
this.
|
|
1824
|
+
} else if (this.k === 0) {
|
|
1825
|
+
if (this.a[0])
|
|
1826
|
+
this.a[0].dispose();
|
|
1827
|
+
this.d = new Array(newLen);
|
|
2169
1828
|
for (j = 0; j < newLen; j++) {
|
|
2170
|
-
this.
|
|
2171
|
-
this.
|
|
1829
|
+
this.F[j] = newItems[j];
|
|
1830
|
+
this.d[j] = runWithOwner(this.a[j] = createOwner(), mapper);
|
|
2172
1831
|
}
|
|
2173
|
-
this.
|
|
1832
|
+
this.k = newLen;
|
|
2174
1833
|
} else {
|
|
2175
|
-
let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.
|
|
2176
|
-
for (start = 0, end = Math.min(this.
|
|
2177
|
-
if (this.
|
|
2178
|
-
this.
|
|
1834
|
+
let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.l ? new Array(newLen) : void 0, tempIndexes = this.m ? new Array(newLen) : void 0;
|
|
1835
|
+
for (start = 0, end = Math.min(this.k, newLen); start < end && (this.F[start] === newItems[start] || this.l && compare(this.N, this.F[start], newItems[start])); start++) {
|
|
1836
|
+
if (this.l)
|
|
1837
|
+
setSignal(this.l[start], newItems[start]);
|
|
2179
1838
|
}
|
|
2180
|
-
for (end = this.
|
|
2181
|
-
temp[newEnd] = this.
|
|
2182
|
-
tempNodes[newEnd] = this.
|
|
2183
|
-
tempRows && (tempRows[newEnd] = this.
|
|
2184
|
-
tempIndexes && (tempIndexes[newEnd] = this.
|
|
1839
|
+
for (end = this.k - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.F[end] === newItems[newEnd] || this.l && compare(this.N, this.F[end], newItems[newEnd])); end--, newEnd--) {
|
|
1840
|
+
temp[newEnd] = this.d[end];
|
|
1841
|
+
tempNodes[newEnd] = this.a[end];
|
|
1842
|
+
tempRows && (tempRows[newEnd] = this.l[end]);
|
|
1843
|
+
tempIndexes && (tempIndexes[newEnd] = this.m[end]);
|
|
2185
1844
|
}
|
|
2186
1845
|
newIndices = /* @__PURE__ */ new Map();
|
|
2187
1846
|
newIndicesNext = new Array(newEnd + 1);
|
|
2188
1847
|
for (j = newEnd; j >= start; j--) {
|
|
2189
1848
|
item = newItems[j];
|
|
2190
|
-
key = this.
|
|
1849
|
+
key = this.N ? this.N(item) : item;
|
|
2191
1850
|
i = newIndices.get(key);
|
|
2192
1851
|
newIndicesNext[j] = i === void 0 ? -1 : i;
|
|
2193
1852
|
newIndices.set(key, j);
|
|
2194
1853
|
}
|
|
2195
1854
|
for (i = start; i <= end; i++) {
|
|
2196
|
-
item = this.
|
|
2197
|
-
key = this.
|
|
1855
|
+
item = this.F[i];
|
|
1856
|
+
key = this.N ? this.N(item) : item;
|
|
2198
1857
|
j = newIndices.get(key);
|
|
2199
1858
|
if (j !== void 0 && j !== -1) {
|
|
2200
|
-
temp[j] = this.
|
|
2201
|
-
tempNodes[j] = this.
|
|
2202
|
-
tempRows && (tempRows[j] = this.
|
|
2203
|
-
tempIndexes && (tempIndexes[j] = this.
|
|
1859
|
+
temp[j] = this.d[i];
|
|
1860
|
+
tempNodes[j] = this.a[i];
|
|
1861
|
+
tempRows && (tempRows[j] = this.l[i]);
|
|
1862
|
+
tempIndexes && (tempIndexes[j] = this.m[i]);
|
|
2204
1863
|
j = newIndicesNext[j];
|
|
2205
1864
|
newIndices.set(key, j);
|
|
2206
1865
|
} else
|
|
2207
|
-
this.
|
|
1866
|
+
this.a[i].dispose();
|
|
2208
1867
|
}
|
|
2209
1868
|
for (j = start; j < newLen; j++) {
|
|
2210
1869
|
if (j in temp) {
|
|
2211
|
-
this.
|
|
2212
|
-
this.
|
|
1870
|
+
this.d[j] = temp[j];
|
|
1871
|
+
this.a[j] = tempNodes[j];
|
|
2213
1872
|
if (tempRows) {
|
|
2214
|
-
this.
|
|
2215
|
-
this.
|
|
1873
|
+
this.l[j] = tempRows[j];
|
|
1874
|
+
setSignal(this.l[j], newItems[j]);
|
|
2216
1875
|
}
|
|
2217
1876
|
if (tempIndexes) {
|
|
2218
|
-
this.
|
|
2219
|
-
this.
|
|
1877
|
+
this.m[j] = tempIndexes[j];
|
|
1878
|
+
setSignal(this.m[j], j);
|
|
2220
1879
|
}
|
|
2221
1880
|
} else {
|
|
2222
|
-
this.
|
|
1881
|
+
this.d[j] = runWithOwner(this.a[j] = createOwner(), mapper);
|
|
2223
1882
|
}
|
|
2224
1883
|
}
|
|
2225
|
-
this.
|
|
2226
|
-
this.
|
|
1884
|
+
this.d = this.d.slice(0, this.k = newLen);
|
|
1885
|
+
this.F = newItems.slice(0);
|
|
2227
1886
|
}
|
|
2228
1887
|
});
|
|
2229
|
-
return this.
|
|
1888
|
+
return this.d;
|
|
2230
1889
|
}
|
|
2231
1890
|
function repeat(count, map, options) {
|
|
2232
1891
|
return updateRepeat.bind({
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
1892
|
+
z: createOwner(),
|
|
1893
|
+
k: 0,
|
|
1894
|
+
w: 0,
|
|
1895
|
+
wa: count,
|
|
1896
|
+
M: map,
|
|
1897
|
+
a: [],
|
|
1898
|
+
d: [],
|
|
1899
|
+
xa: options?.from,
|
|
1900
|
+
Y: options?.fallback
|
|
2242
1901
|
});
|
|
2243
1902
|
}
|
|
2244
1903
|
function updateRepeat() {
|
|
2245
|
-
const newLen = this.
|
|
2246
|
-
const from = this.
|
|
2247
|
-
runWithOwner(this.
|
|
1904
|
+
const newLen = this.wa();
|
|
1905
|
+
const from = this.xa?.() || 0;
|
|
1906
|
+
runWithOwner(this.z, () => {
|
|
2248
1907
|
if (newLen === 0) {
|
|
2249
|
-
if (this.
|
|
2250
|
-
this.
|
|
2251
|
-
this.
|
|
2252
|
-
this.
|
|
2253
|
-
this.
|
|
1908
|
+
if (this.k !== 0) {
|
|
1909
|
+
this.z.dispose(false);
|
|
1910
|
+
this.a = [];
|
|
1911
|
+
this.d = [];
|
|
1912
|
+
this.k = 0;
|
|
2254
1913
|
}
|
|
2255
|
-
if (this.
|
|
2256
|
-
this.
|
|
2257
|
-
this.
|
|
2258
|
-
this.
|
|
2259
|
-
null
|
|
1914
|
+
if (this.Y && !this.d[0]) {
|
|
1915
|
+
this.d[0] = runWithOwner(
|
|
1916
|
+
this.a[0] = createOwner(),
|
|
1917
|
+
this.Y
|
|
2260
1918
|
);
|
|
2261
1919
|
}
|
|
2262
1920
|
return;
|
|
2263
1921
|
}
|
|
2264
1922
|
const to = from + newLen;
|
|
2265
|
-
const prevTo = this.
|
|
2266
|
-
if (this.
|
|
2267
|
-
this.
|
|
1923
|
+
const prevTo = this.w + this.k;
|
|
1924
|
+
if (this.k === 0 && this.a[0])
|
|
1925
|
+
this.a[0].dispose();
|
|
2268
1926
|
for (let i = to; i < prevTo; i++)
|
|
2269
|
-
this.
|
|
2270
|
-
if (this.
|
|
2271
|
-
let i = this.
|
|
2272
|
-
while (i < from && i < this.
|
|
2273
|
-
this.
|
|
2274
|
-
this.
|
|
2275
|
-
this.
|
|
2276
|
-
} else if (this.
|
|
2277
|
-
let i = prevTo - this.
|
|
2278
|
-
let difference = this.
|
|
2279
|
-
this.
|
|
1927
|
+
this.a[i - this.w].dispose();
|
|
1928
|
+
if (this.w < from) {
|
|
1929
|
+
let i = this.w;
|
|
1930
|
+
while (i < from && i < this.k)
|
|
1931
|
+
this.a[i++].dispose();
|
|
1932
|
+
this.a.splice(0, from - this.w);
|
|
1933
|
+
this.d.splice(0, from - this.w);
|
|
1934
|
+
} else if (this.w > from) {
|
|
1935
|
+
let i = prevTo - this.w - 1;
|
|
1936
|
+
let difference = this.w - from;
|
|
1937
|
+
this.a.length = this.d.length = newLen;
|
|
2280
1938
|
while (i >= difference) {
|
|
2281
|
-
this.
|
|
2282
|
-
this.
|
|
1939
|
+
this.a[i] = this.a[i - difference];
|
|
1940
|
+
this.d[i] = this.d[i - difference];
|
|
2283
1941
|
i--;
|
|
2284
1942
|
}
|
|
2285
1943
|
for (let i2 = 0; i2 < difference; i2++) {
|
|
2286
|
-
this.
|
|
2287
|
-
this.
|
|
2288
|
-
() => this.
|
|
2289
|
-
null
|
|
1944
|
+
this.d[i2] = runWithOwner(
|
|
1945
|
+
this.a[i2] = createOwner(),
|
|
1946
|
+
() => this.M(i2 + from)
|
|
2290
1947
|
);
|
|
2291
1948
|
}
|
|
2292
1949
|
}
|
|
2293
1950
|
for (let i = prevTo; i < to; i++) {
|
|
2294
|
-
this.
|
|
2295
|
-
this.
|
|
2296
|
-
() => this.
|
|
2297
|
-
null
|
|
1951
|
+
this.d[i - from] = runWithOwner(
|
|
1952
|
+
this.a[i - from] = createOwner(),
|
|
1953
|
+
() => this.M(i)
|
|
2298
1954
|
);
|
|
2299
1955
|
}
|
|
2300
|
-
this.
|
|
2301
|
-
this.
|
|
2302
|
-
this.
|
|
1956
|
+
this.d = this.d.slice(0, newLen);
|
|
1957
|
+
this.w = from;
|
|
1958
|
+
this.k = newLen;
|
|
2303
1959
|
});
|
|
2304
|
-
return this.
|
|
1960
|
+
return this.d;
|
|
2305
1961
|
}
|
|
2306
1962
|
function compare(key, a, b) {
|
|
2307
1963
|
return key ? key(a) === key(b) : true;
|
|
2308
1964
|
}
|
|
2309
1965
|
|
|
2310
1966
|
// src/boundaries.ts
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
1967
|
+
function boundaryComputed(fn, propagationMask) {
|
|
1968
|
+
const node = computed(fn, void 0, {
|
|
1969
|
+
ja: {
|
|
1970
|
+
ma() {
|
|
1971
|
+
let flags = this.f;
|
|
1972
|
+
this.f &= ~this.Z;
|
|
1973
|
+
if (this.Z & 1 /* Pending */ && !(this.f & 4 /* Uninitialized */)) {
|
|
1974
|
+
flags &= ~1 /* Pending */;
|
|
1975
|
+
}
|
|
1976
|
+
this.i.notify(this, this.Z, flags);
|
|
1977
|
+
},
|
|
1978
|
+
Z: propagationMask
|
|
2321
1979
|
}
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
}
|
|
1980
|
+
});
|
|
1981
|
+
node.Z = propagationMask;
|
|
1982
|
+
return node;
|
|
1983
|
+
}
|
|
2326
1984
|
function createBoundChildren(owner, fn, queue, mask) {
|
|
2327
|
-
const parentQueue = owner.
|
|
2328
|
-
parentQueue.addChild(owner.
|
|
2329
|
-
onCleanup(() => parentQueue.removeChild(owner.
|
|
2330
|
-
return
|
|
2331
|
-
|
|
2332
|
-
() =>
|
|
2333
|
-
|
|
2334
|
-
return new BoundaryComputation(() => latest(() => flatten(c.wait())), mask);
|
|
2335
|
-
},
|
|
2336
|
-
null
|
|
2337
|
-
);
|
|
1985
|
+
const parentQueue = owner.i;
|
|
1986
|
+
parentQueue.addChild(owner.i = queue);
|
|
1987
|
+
onCleanup(() => parentQueue.removeChild(owner.i));
|
|
1988
|
+
return runWithOwner(owner, () => {
|
|
1989
|
+
const c = computed(fn);
|
|
1990
|
+
return boundaryComputed(() => staleValues(() => flatten(read(c))), mask);
|
|
1991
|
+
});
|
|
2338
1992
|
}
|
|
2339
1993
|
var ConditionalQueue = class extends Queue {
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
1994
|
+
t;
|
|
1995
|
+
ga = /* @__PURE__ */ new Set();
|
|
1996
|
+
h = /* @__PURE__ */ new Set();
|
|
2343
1997
|
constructor(disabled) {
|
|
2344
1998
|
super();
|
|
2345
|
-
this.
|
|
1999
|
+
this.t = disabled;
|
|
2346
2000
|
}
|
|
2347
2001
|
run(type) {
|
|
2348
|
-
if (!type || this.
|
|
2002
|
+
if (!type || read(this.t))
|
|
2349
2003
|
return;
|
|
2350
2004
|
return super.run(type);
|
|
2351
2005
|
}
|
|
2352
2006
|
notify(node, type, flags) {
|
|
2353
|
-
if (this.
|
|
2354
|
-
if (type &
|
|
2355
|
-
if (flags &
|
|
2356
|
-
this.
|
|
2357
|
-
type &= ~
|
|
2358
|
-
} else if (this.
|
|
2359
|
-
type &= ~
|
|
2007
|
+
if (read(this.t)) {
|
|
2008
|
+
if (type & 1 /* Pending */) {
|
|
2009
|
+
if (flags & 1 /* Pending */) {
|
|
2010
|
+
this.h.add(node);
|
|
2011
|
+
type &= ~1 /* Pending */;
|
|
2012
|
+
} else if (this.h.delete(node))
|
|
2013
|
+
type &= ~1 /* Pending */;
|
|
2360
2014
|
}
|
|
2361
|
-
if (type &
|
|
2362
|
-
if (flags &
|
|
2363
|
-
this.
|
|
2364
|
-
type &= ~
|
|
2365
|
-
} else if (this.
|
|
2366
|
-
type &= ~
|
|
2015
|
+
if (type & 2 /* Error */) {
|
|
2016
|
+
if (flags & 2 /* Error */) {
|
|
2017
|
+
this.ga.add(node);
|
|
2018
|
+
type &= ~2 /* Error */;
|
|
2019
|
+
} else if (this.ga.delete(node))
|
|
2020
|
+
type &= ~2 /* Error */;
|
|
2367
2021
|
}
|
|
2368
2022
|
}
|
|
2369
2023
|
return type ? super.notify(node, type, flags) : true;
|
|
2370
2024
|
}
|
|
2371
|
-
merge(queue) {
|
|
2372
|
-
queue.t.forEach((n) => this.notify(n, LOADING_BIT, LOADING_BIT));
|
|
2373
|
-
queue.X.forEach((n) => this.notify(n, ERROR_BIT, ERROR_BIT));
|
|
2374
|
-
super.merge(queue);
|
|
2375
|
-
}
|
|
2376
2025
|
};
|
|
2377
2026
|
var CollectionQueue = class extends Queue {
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2027
|
+
O;
|
|
2028
|
+
a = /* @__PURE__ */ new Set();
|
|
2029
|
+
t = signal(false, { pureWrite: true });
|
|
2030
|
+
ka = false;
|
|
2381
2031
|
constructor(type) {
|
|
2382
2032
|
super();
|
|
2383
|
-
this.
|
|
2033
|
+
this.O = type;
|
|
2384
2034
|
}
|
|
2385
2035
|
run(type) {
|
|
2386
|
-
if (!type || this.
|
|
2036
|
+
if (!type || read(this.t))
|
|
2387
2037
|
return;
|
|
2388
2038
|
return super.run(type);
|
|
2389
2039
|
}
|
|
2040
|
+
enqueue(type, fn) {
|
|
2041
|
+
if (this.O & 1 /* Pending */ && this.ka) {
|
|
2042
|
+
return this.q?.enqueue(type, fn);
|
|
2043
|
+
}
|
|
2044
|
+
return super.enqueue(type, fn);
|
|
2045
|
+
}
|
|
2390
2046
|
notify(node, type, flags) {
|
|
2391
|
-
if (!(type & this.
|
|
2047
|
+
if (!(type & this.O) || this.O & 1 /* Pending */ && this.ka)
|
|
2392
2048
|
return super.notify(node, type, flags);
|
|
2393
|
-
if (flags & this.
|
|
2394
|
-
this.
|
|
2395
|
-
if (this.
|
|
2396
|
-
this.
|
|
2397
|
-
} else if (this.
|
|
2398
|
-
this.
|
|
2399
|
-
if (this.
|
|
2400
|
-
this.
|
|
2401
|
-
}
|
|
2402
|
-
type &= ~this.
|
|
2049
|
+
if (flags & this.O) {
|
|
2050
|
+
this.a.add(node);
|
|
2051
|
+
if (this.a.size === 1)
|
|
2052
|
+
setSignal(this.t, true);
|
|
2053
|
+
} else if (this.a.size > 0) {
|
|
2054
|
+
this.a.delete(node);
|
|
2055
|
+
if (this.a.size === 0)
|
|
2056
|
+
setSignal(this.t, false);
|
|
2057
|
+
}
|
|
2058
|
+
type &= ~this.O;
|
|
2403
2059
|
return type ? super.notify(node, type, flags) : true;
|
|
2404
2060
|
}
|
|
2405
|
-
merge(queue) {
|
|
2406
|
-
queue.e.forEach((n) => this.notify(n, this.L, this.L));
|
|
2407
|
-
super.merge(queue);
|
|
2408
|
-
}
|
|
2409
2061
|
};
|
|
2410
2062
|
function createBoundary(fn, condition) {
|
|
2411
|
-
const owner =
|
|
2412
|
-
const queue = new ConditionalQueue(
|
|
2413
|
-
new Computation(void 0, () => condition() === "hidden" /* HIDDEN */)
|
|
2414
|
-
);
|
|
2063
|
+
const owner = createOwner();
|
|
2064
|
+
const queue = new ConditionalQueue(computed(() => condition() === "hidden" /* HIDDEN */));
|
|
2415
2065
|
const tree = createBoundChildren(owner, fn, queue, 0);
|
|
2416
|
-
|
|
2417
|
-
const disabled = queue.
|
|
2418
|
-
tree.
|
|
2066
|
+
computed(() => {
|
|
2067
|
+
const disabled = read(queue.t);
|
|
2068
|
+
tree.Z = disabled ? 2 /* Error */ | 1 /* Pending */ : 0;
|
|
2419
2069
|
if (!disabled) {
|
|
2420
|
-
queue.
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
queue.
|
|
2070
|
+
queue.h.forEach(
|
|
2071
|
+
(node) => queue.notify(node, 1 /* Pending */, 1 /* Pending */)
|
|
2072
|
+
);
|
|
2073
|
+
queue.ga.forEach((node) => queue.notify(node, 2 /* Error */, 2 /* Error */));
|
|
2074
|
+
queue.h.clear();
|
|
2075
|
+
queue.ga.clear();
|
|
2424
2076
|
}
|
|
2425
2077
|
});
|
|
2426
|
-
return () => queue.
|
|
2078
|
+
return () => read(queue.t) ? void 0 : read(tree);
|
|
2427
2079
|
}
|
|
2428
2080
|
function createCollectionBoundary(type, fn, fallback) {
|
|
2429
|
-
const owner =
|
|
2081
|
+
const owner = createOwner();
|
|
2430
2082
|
const queue = new CollectionQueue(type);
|
|
2431
2083
|
const tree = createBoundChildren(owner, fn, queue, type);
|
|
2432
|
-
const decision =
|
|
2433
|
-
if (!queue.
|
|
2434
|
-
const resolved =
|
|
2435
|
-
if (!untrack(() => queue.
|
|
2436
|
-
|
|
2084
|
+
const decision = computed(() => {
|
|
2085
|
+
if (!read(queue.t)) {
|
|
2086
|
+
const resolved = read(tree);
|
|
2087
|
+
if (!untrack(() => read(queue.t)))
|
|
2088
|
+
queue.ka = true;
|
|
2089
|
+
return resolved;
|
|
2437
2090
|
}
|
|
2438
2091
|
return fallback(queue);
|
|
2439
2092
|
});
|
|
2440
|
-
return
|
|
2093
|
+
return read.bind(null, decision);
|
|
2441
2094
|
}
|
|
2442
|
-
function
|
|
2443
|
-
return createCollectionBoundary(
|
|
2095
|
+
function createLoadBoundary(fn, fallback) {
|
|
2096
|
+
return createCollectionBoundary(1 /* Pending */, fn, () => fallback());
|
|
2444
2097
|
}
|
|
2445
2098
|
function createErrorBoundary(fn, fallback) {
|
|
2446
|
-
return createCollectionBoundary(
|
|
2447
|
-
let node =
|
|
2448
|
-
return fallback(node.
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
if (ActiveTransition && !node2.d)
|
|
2452
|
-
node2 = cloneGraph(node2);
|
|
2453
|
-
node2.a = STATE_DIRTY;
|
|
2454
|
-
getQueue(node2).enqueue(node2.s, node2.x.bind(node2));
|
|
2099
|
+
return createCollectionBoundary(2 /* Error */, fn, (queue) => {
|
|
2100
|
+
let node = queue.a.values().next().value;
|
|
2101
|
+
return fallback(node.B, () => {
|
|
2102
|
+
for (let node2 of queue.a) {
|
|
2103
|
+
recompute(node2, true);
|
|
2455
2104
|
}
|
|
2456
2105
|
});
|
|
2457
2106
|
});
|
|
@@ -2511,4 +2160,4 @@ function flattenArray(children, results = [], options) {
|
|
|
2511
2160
|
return needsUnwrap;
|
|
2512
2161
|
}
|
|
2513
2162
|
|
|
2514
|
-
export { $PROXY, $TARGET, $TRACK,
|
|
2163
|
+
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 };
|