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