@solidjs/signals 0.7.5 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev.js +1049 -1406
- package/dist/node.cjs +1177 -1535
- package/dist/prod.js +1163 -1514
- package/dist/types/boundaries.d.ts +12 -8
- package/dist/types/core/constants.d.ts +22 -13
- package/dist/types/core/context.d.ts +28 -0
- package/dist/types/core/core.d.ts +96 -135
- package/dist/types/core/effect.d.ts +14 -42
- package/dist/types/core/error.d.ts +2 -1
- package/dist/types/core/heap.d.ts +15 -0
- package/dist/types/core/index.d.ts +4 -5
- package/dist/types/core/scheduler.d.ts +28 -54
- package/dist/types/index.d.ts +4 -4
- package/dist/types/map.d.ts +1 -1
- package/dist/types/signals.d.ts +5 -43
- package/dist/types/store/projection.d.ts +1 -2
- package/dist/types/store/store.d.ts +2 -2
- package/package.json +1 -1
- package/dist/types/core/flags.d.ts +0 -11
- package/dist/types/core/owner.d.ts +0 -95
package/dist/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,910 @@ 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.q) == null ? void 0 : _a._) ? (_b = n.q.$) == null ? void 0 : _b.c : (_c = n.q) == null ? void 0 : _c.c) ?? -1;
|
|
31
|
+
if (parentHeight >= n.c)
|
|
32
|
+
n.c = parentHeight + 1;
|
|
33
|
+
const height = n.c;
|
|
34
|
+
const heapAtHeight = heap.p[height];
|
|
35
|
+
if (heapAtHeight === void 0) {
|
|
36
|
+
heap.p[height] = n;
|
|
37
|
+
} else {
|
|
38
|
+
const tail = heapAtHeight.x;
|
|
39
|
+
tail.P = 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.c;
|
|
72
|
+
if (n.x === n) {
|
|
73
|
+
heap.p[height] = void 0;
|
|
74
|
+
} else {
|
|
75
|
+
const next = n.P;
|
|
76
|
+
const dhh = heap.p[height];
|
|
77
|
+
const end = next ?? dhh;
|
|
78
|
+
if (n === dhh) {
|
|
79
|
+
heap.p[height] = next;
|
|
80
|
+
} else {
|
|
81
|
+
n.x.P = next;
|
|
82
|
+
}
|
|
83
|
+
end.x = n.x;
|
|
84
|
+
}
|
|
85
|
+
n.x = n;
|
|
86
|
+
n.P = void 0;
|
|
87
|
+
}
|
|
88
|
+
function markHeap(heap) {
|
|
89
|
+
if (heap.aa)
|
|
90
|
+
return;
|
|
91
|
+
heap.aa = true;
|
|
92
|
+
for (let i = 0; i <= heap.J; i++) {
|
|
93
|
+
for (let el = heap.p[i]; el !== void 0; el = el.P) {
|
|
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.r; link2 !== null; link2 = link2.y) {
|
|
105
|
+
markNode(link2.j, 1 /* Check */);
|
|
106
|
+
}
|
|
107
|
+
if (el.ba !== null) {
|
|
108
|
+
for (let child = el.ba; child !== null; child = child.ra) {
|
|
109
|
+
for (let link2 = child.r; link2 !== null; link2 = link2.y) {
|
|
110
|
+
markNode(link2.j, 1 /* Check */);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function runHeap(heap, recompute2) {
|
|
116
|
+
heap.aa = false;
|
|
117
|
+
for (heap.n = 0; heap.n <= heap.J; heap.n++) {
|
|
118
|
+
let el = heap.p[heap.n];
|
|
119
|
+
while (el !== void 0) {
|
|
120
|
+
if (el.b & 8 /* InHeap */)
|
|
121
|
+
recompute2(el);
|
|
122
|
+
else {
|
|
123
|
+
adjustHeight(el, heap);
|
|
124
|
+
}
|
|
125
|
+
el = heap.p[heap.n];
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
heap.J = 0;
|
|
129
|
+
}
|
|
130
|
+
function adjustHeight(el, heap) {
|
|
131
|
+
deleteFromHeap(el, heap);
|
|
132
|
+
let newHeight = el.c;
|
|
133
|
+
for (let d = el.u; d; d = d.E) {
|
|
134
|
+
const dep1 = d.Q;
|
|
135
|
+
const dep = "_owner" in dep1 ? dep1.z : dep1;
|
|
136
|
+
if ("_fn" in dep) {
|
|
137
|
+
if (dep.c >= newHeight) {
|
|
138
|
+
newHeight = dep.c + 1;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (el.c !== newHeight) {
|
|
143
|
+
el.c = newHeight;
|
|
144
|
+
for (let s = el.r; s !== null; s = s.y) {
|
|
145
|
+
insertIntoHeapHeight(s.j, 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.ca)
|
|
55
161
|
queueMicrotask(flush);
|
|
56
162
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
163
|
+
var dirtyQueue = {
|
|
164
|
+
p: new Array(2e3).fill(void 0),
|
|
165
|
+
aa: false,
|
|
166
|
+
n: 0,
|
|
167
|
+
J: 0
|
|
168
|
+
};
|
|
169
|
+
var zombieQueue = {
|
|
170
|
+
p: new Array(2e3).fill(void 0),
|
|
171
|
+
aa: false,
|
|
172
|
+
n: 0,
|
|
173
|
+
J: 0
|
|
174
|
+
};
|
|
67
175
|
var Queue = class {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
i = [];
|
|
176
|
+
q = null;
|
|
177
|
+
A = [[], []];
|
|
178
|
+
R = [];
|
|
72
179
|
created = clock;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
180
|
+
addChild(child) {
|
|
181
|
+
this.R.push(child);
|
|
182
|
+
child.q = this;
|
|
183
|
+
}
|
|
184
|
+
removeChild(child) {
|
|
185
|
+
const index = this.R.indexOf(child);
|
|
186
|
+
if (index >= 0) {
|
|
187
|
+
this.R.splice(index, 1);
|
|
188
|
+
child.q = null;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
notify(node, mask, flags) {
|
|
192
|
+
if (this.q)
|
|
193
|
+
return this.q.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.R.length; i++) {
|
|
203
|
+
this.R[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
|
+
ca = false;
|
|
214
|
+
h = [];
|
|
215
|
+
static S;
|
|
216
|
+
static la;
|
|
93
217
|
flush() {
|
|
94
|
-
if (this.
|
|
218
|
+
if (this.ca)
|
|
95
219
|
return;
|
|
96
|
-
this.
|
|
220
|
+
this.ca = true;
|
|
97
221
|
try {
|
|
98
|
-
|
|
99
|
-
|
|
222
|
+
runHeap(dirtyQueue, _GlobalQueue.S);
|
|
223
|
+
if (activeTransition) {
|
|
224
|
+
if (!transitionComplete(activeTransition)) {
|
|
225
|
+
runHeap(zombieQueue, _GlobalQueue.S);
|
|
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.S);
|
|
243
|
+
} else if (transitions.size)
|
|
244
|
+
runHeap(zombieQueue, _GlobalQueue.S);
|
|
245
|
+
for (let i = 0; i < globalQueue.h.length; i++) {
|
|
246
|
+
const n = globalQueue.h[i];
|
|
247
|
+
if (n.e !== NOT_PENDING) {
|
|
248
|
+
n.g = n.e;
|
|
249
|
+
n.e = NOT_PENDING;
|
|
250
|
+
}
|
|
251
|
+
if (n.ha)
|
|
252
|
+
_GlobalQueue.la(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.ca = 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.T ?? {
|
|
279
|
+
time: clock,
|
|
280
|
+
pendingNodes: [],
|
|
281
|
+
asyncNodes: [],
|
|
282
|
+
queues: [[], []]
|
|
283
|
+
};
|
|
137
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.T = activeTransition;
|
|
290
|
+
activeTransition.pendingNodes.push(n);
|
|
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.T = activeTransition;
|
|
301
|
+
if (n.G) {
|
|
302
|
+
n.G.da(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.r)
|
|
333
|
+
(_b = (_a = unobserved[i]).sa) == 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.S = recompute;
|
|
340
|
+
GlobalQueue.la = 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.e !== NOT_PENDING || el.U || el.V)
|
|
351
|
+
disposeChildren(el);
|
|
352
|
+
else {
|
|
353
|
+
markDisposal(el);
|
|
354
|
+
globalQueue.h.push(el);
|
|
355
|
+
el.V = el.s;
|
|
356
|
+
el.U = el.o;
|
|
357
|
+
el.s = null;
|
|
358
|
+
el.o = null;
|
|
359
|
+
}
|
|
360
|
+
const oldcontext = context;
|
|
361
|
+
context = el;
|
|
362
|
+
el.H = null;
|
|
363
|
+
el.b = 4 /* RecomputingDeps */;
|
|
364
|
+
el.W = clock;
|
|
365
|
+
let value = el.e === NOT_PENDING ? el.g : el.e;
|
|
366
|
+
let oldHeight = el.c;
|
|
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.ea || !el.ea(el.e === NOT_PENDING ? el.g : el.e, value);
|
|
400
|
+
const statusFlagsChanged = el.f !== prevStatusFlags || el.B !== prevError;
|
|
401
|
+
(_a = el.ma) == 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.e === NOT_PENDING)
|
|
408
|
+
globalQueue.h.push(el);
|
|
409
|
+
el.e = value;
|
|
309
410
|
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
ActiveTransition = null;
|
|
313
|
-
finishTransition(transition2);
|
|
411
|
+
if (el.C)
|
|
412
|
+
el.C.da(value);
|
|
314
413
|
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
return;
|
|
414
|
+
for (let s = el.r; s !== null; s = s.y) {
|
|
415
|
+
const queue = s.j.b & 32 /* Zombie */ ? zombieQueue : dirtyQueue;
|
|
416
|
+
if (s.j.c < el.c && queue.n > s.j.c)
|
|
417
|
+
queue.n = s.j.c;
|
|
418
|
+
insertIntoHeap(s.j, 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);
|
|
332
|
-
}
|
|
333
|
-
return node;
|
|
334
|
-
}
|
|
335
|
-
if (node.f) {
|
|
336
|
-
if (node.f !== ActiveTransition) {
|
|
337
|
-
mergeTransitions(node.f, ActiveTransition);
|
|
338
|
-
ActiveTransition = node.f;
|
|
420
|
+
} else if (el.c != oldHeight) {
|
|
421
|
+
for (let s = el.r; s !== null; s = s.y) {
|
|
422
|
+
insertIntoHeapHeight(s.j, s.j.b & 32 /* Zombie */ ? zombieQueue : dirtyQueue);
|
|
339
423
|
}
|
|
340
|
-
return node.f.b.get(node);
|
|
341
424
|
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
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.Q;
|
|
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.Q;
|
|
446
|
+
const nextDep = link2.E;
|
|
447
|
+
const nextSub = link2.y;
|
|
448
|
+
const prevSub = link2.na;
|
|
449
|
+
if (nextSub !== null) {
|
|
450
|
+
nextSub.na = prevSub;
|
|
451
|
+
} else {
|
|
452
|
+
dep.X = prevSub;
|
|
491
453
|
}
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
454
|
+
if (prevSub !== null) {
|
|
455
|
+
prevSub.y = nextSub;
|
|
456
|
+
} else {
|
|
457
|
+
dep.r = 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.Q === 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.Q === 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.X;
|
|
476
|
+
if (prevSub !== null && prevSub.j === sub && (!isRecomputing || isValidLink(prevSub, sub))) {
|
|
477
|
+
return;
|
|
590
478
|
}
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
479
|
+
const newLink = sub.H = dep.X = {
|
|
480
|
+
Q: dep,
|
|
481
|
+
j: sub,
|
|
482
|
+
E: nextDep,
|
|
483
|
+
na: 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.r = 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.o;
|
|
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.U : node.o;
|
|
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.U = null;
|
|
625
559
|
} else {
|
|
626
|
-
node.o =
|
|
560
|
+
node.o = null;
|
|
561
|
+
node.K = null;
|
|
627
562
|
}
|
|
628
|
-
|
|
563
|
+
runDisposal(node, zombie);
|
|
564
|
+
}
|
|
565
|
+
function runDisposal(node, zombie) {
|
|
566
|
+
let disposal = zombie ? node.V : node.s;
|
|
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.V = null : node.s = 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.ea = (options == null ? void 0 : options.equals) != null ? options.equals : isEqual;
|
|
582
|
+
obj.ya = !!(options == null ? void 0 : options.pureWrite);
|
|
583
|
+
obj.sa = 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.oa++);
|
|
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
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
597
|
+
function computed(fn, initialValue, options) {
|
|
598
|
+
const self = withOptions(
|
|
599
|
+
{
|
|
600
|
+
s: null,
|
|
601
|
+
i: globalQueue,
|
|
602
|
+
D: defaultContext,
|
|
603
|
+
oa: 0,
|
|
604
|
+
ha: fn,
|
|
605
|
+
g: initialValue,
|
|
606
|
+
c: 0,
|
|
607
|
+
ba: null,
|
|
608
|
+
P: void 0,
|
|
609
|
+
x: null,
|
|
610
|
+
u: null,
|
|
611
|
+
H: null,
|
|
612
|
+
r: null,
|
|
613
|
+
X: null,
|
|
614
|
+
q: context,
|
|
615
|
+
K: null,
|
|
616
|
+
o: null,
|
|
617
|
+
b: 0 /* None */,
|
|
618
|
+
f: 4 /* Uninitialized */,
|
|
619
|
+
W: clock,
|
|
620
|
+
e: NOT_PENDING,
|
|
621
|
+
V: null,
|
|
622
|
+
U: null
|
|
623
|
+
},
|
|
624
|
+
options
|
|
625
|
+
);
|
|
626
|
+
self.x = self;
|
|
627
|
+
const parent = (context == null ? void 0 : context._) ? context.$ : context;
|
|
628
|
+
if (context) {
|
|
629
|
+
context.i && (self.i = context.i);
|
|
630
|
+
context.D && (self.D = context.D);
|
|
631
|
+
const lastChild = context.o;
|
|
632
|
+
if (lastChild === null) {
|
|
633
|
+
context.o = self;
|
|
634
|
+
} else {
|
|
635
|
+
self.K = lastChild;
|
|
636
|
+
context.o = self;
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
if (parent)
|
|
640
|
+
self.c = parent.c + 1;
|
|
641
|
+
recompute(self, true);
|
|
642
|
+
return self;
|
|
649
643
|
}
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
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.ta = () => {
|
|
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.ba = withOptions(
|
|
703
|
+
{
|
|
704
|
+
g: v,
|
|
705
|
+
r: null,
|
|
706
|
+
X: null,
|
|
707
|
+
z: firewall,
|
|
708
|
+
ra: firewall.ba,
|
|
709
|
+
f: 0 /* None */,
|
|
710
|
+
W: clock,
|
|
711
|
+
e: NOT_PENDING
|
|
712
|
+
},
|
|
713
|
+
options
|
|
714
|
+
);
|
|
715
|
+
} else {
|
|
716
|
+
return withOptions(
|
|
717
|
+
{
|
|
718
|
+
g: v,
|
|
719
|
+
r: null,
|
|
720
|
+
X: null,
|
|
721
|
+
f: 0 /* None */,
|
|
722
|
+
W: clock,
|
|
723
|
+
e: 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._)
|
|
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.c >= (isZombie ? zombieQueue.n : dirtyQueue.n)) {
|
|
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.c;
|
|
757
|
+
if (height >= c.c && el.q !== c) {
|
|
758
|
+
c.c = 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.T || false;
|
|
764
|
+
if (!el.G) {
|
|
765
|
+
el.G = signal(pendingResult);
|
|
766
|
+
el.G.ia = true;
|
|
767
|
+
el.G.da = (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.e === NOT_PENDING ? el.g : el.e
|
|
779
|
+
);
|
|
780
|
+
el.C.ia = true;
|
|
781
|
+
el.C.da = (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.W < 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.e === NOT_PENDING || stale && !pendingCheck && el.T && activeTransition !== el.T ? el.g : el.e;
|
|
810
|
+
}
|
|
811
|
+
function setSignal(el, v) {
|
|
812
|
+
if (typeof v === "function") {
|
|
813
|
+
v = v(
|
|
814
|
+
el.e === NOT_PENDING ? el.g : el.e
|
|
815
|
+
);
|
|
867
816
|
}
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
817
|
+
const valueChanged = !el.ea || !el.ea(el.e === NOT_PENDING ? el.g : el.e, 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.e === NOT_PENDING)
|
|
825
|
+
globalQueue.h.push(el);
|
|
826
|
+
el.e = v;
|
|
827
|
+
}
|
|
828
|
+
if (el.C)
|
|
829
|
+
el.C.da(v);
|
|
830
|
+
}
|
|
831
|
+
clearStatusFlags(el);
|
|
832
|
+
el.W = clock;
|
|
833
|
+
for (let s = el.r; s !== null; s = s.y) {
|
|
834
|
+
const queue = s.j.b & 32 /* Zombie */ ? zombieQueue : dirtyQueue;
|
|
835
|
+
if (queue.n > s.j.c)
|
|
836
|
+
queue.n = s.j.c;
|
|
837
|
+
insertIntoHeap(s.j, queue);
|
|
838
|
+
}
|
|
839
|
+
schedule();
|
|
840
|
+
return v;
|
|
841
|
+
}
|
|
842
|
+
function getObserver() {
|
|
843
|
+
return tracking ? context : null;
|
|
844
|
+
}
|
|
845
|
+
function getOwner() {
|
|
846
|
+
return context;
|
|
847
|
+
}
|
|
848
|
+
function onCleanup(fn) {
|
|
849
|
+
if (!context)
|
|
850
|
+
return fn;
|
|
851
|
+
const node = context;
|
|
852
|
+
if (!node.s) {
|
|
853
|
+
node.s = fn;
|
|
854
|
+
} else if (Array.isArray(node.s)) {
|
|
855
|
+
node.s.push(fn);
|
|
856
|
+
} else {
|
|
857
|
+
node.s = [node.s, fn];
|
|
858
|
+
}
|
|
859
|
+
return fn;
|
|
860
|
+
}
|
|
861
|
+
function createOwner(options) {
|
|
862
|
+
const parent = context;
|
|
863
|
+
const owner = {
|
|
864
|
+
_: true,
|
|
865
|
+
$: (parent == null ? void 0 : parent._) ? parent.$ : parent,
|
|
866
|
+
o: null,
|
|
867
|
+
K: null,
|
|
868
|
+
s: null,
|
|
869
|
+
id: (options == null ? void 0 : options.id) ?? ((parent == null ? void 0 : parent.id) != null ? getNextChildId(parent) : void 0),
|
|
870
|
+
i: (parent == null ? void 0 : parent.i) ?? globalQueue,
|
|
871
|
+
D: (parent == null ? void 0 : parent.D) || defaultContext,
|
|
872
|
+
oa: 0,
|
|
873
|
+
V: null,
|
|
874
|
+
U: null,
|
|
875
|
+
q: parent,
|
|
876
|
+
dispose(self = true) {
|
|
877
|
+
disposeChildren(owner, self);
|
|
910
878
|
}
|
|
911
|
-
}
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
}
|
|
920
|
-
} else {
|
|
921
|
-
node.b = newSources;
|
|
922
|
-
}
|
|
923
|
-
let source;
|
|
924
|
-
for (let i = newSourcesIndex; i < node.b.length; i++) {
|
|
925
|
-
source = getTransitionSource(node.b[i]);
|
|
926
|
-
if (!source.c)
|
|
927
|
-
source.c = [node];
|
|
928
|
-
else
|
|
929
|
-
source.c.push(node);
|
|
930
|
-
}
|
|
931
|
-
} else if (node.b && newSourcesIndex < node.b.length) {
|
|
932
|
-
removeSourceObservers(node, newSourcesIndex);
|
|
933
|
-
node.b.length = newSourcesIndex;
|
|
879
|
+
};
|
|
880
|
+
if (parent) {
|
|
881
|
+
const lastChild = parent.o;
|
|
882
|
+
if (lastChild === null) {
|
|
883
|
+
parent.o = owner;
|
|
884
|
+
} else {
|
|
885
|
+
owner.K = lastChild;
|
|
886
|
+
parent.o = owner;
|
|
934
887
|
}
|
|
935
|
-
newSources = prevSources;
|
|
936
|
-
newSourcesIndex = prevSourcesIndex;
|
|
937
|
-
newFlags = prevFlags;
|
|
938
|
-
node.Q = clock + 1;
|
|
939
|
-
node.a = STATE_CLEAN;
|
|
940
888
|
}
|
|
889
|
+
return owner;
|
|
941
890
|
}
|
|
942
|
-
function
|
|
943
|
-
|
|
891
|
+
function createRoot(init, options) {
|
|
892
|
+
const owner = createOwner(options);
|
|
893
|
+
return runWithOwner(owner, () => init(owner.dispose));
|
|
944
894
|
}
|
|
945
|
-
function
|
|
946
|
-
|
|
895
|
+
function runWithOwner(owner, fn) {
|
|
896
|
+
const oldContext = context;
|
|
897
|
+
context = owner;
|
|
898
|
+
try {
|
|
947
899
|
return fn();
|
|
948
|
-
|
|
900
|
+
} finally {
|
|
901
|
+
context = oldContext;
|
|
902
|
+
}
|
|
949
903
|
}
|
|
950
|
-
function
|
|
951
|
-
const
|
|
952
|
-
|
|
904
|
+
function staleValues(fn, set = true) {
|
|
905
|
+
const prevStale = stale;
|
|
906
|
+
stale = set;
|
|
953
907
|
try {
|
|
954
|
-
fn();
|
|
955
|
-
return updateCheck.m;
|
|
908
|
+
return fn();
|
|
956
909
|
} finally {
|
|
957
|
-
|
|
910
|
+
stale = prevStale;
|
|
958
911
|
}
|
|
959
912
|
}
|
|
960
|
-
function
|
|
961
|
-
const
|
|
962
|
-
|
|
913
|
+
function pending(fn) {
|
|
914
|
+
const prevLatest = pendingValueCheck;
|
|
915
|
+
pendingValueCheck = true;
|
|
963
916
|
try {
|
|
964
|
-
|
|
965
|
-
|
|
917
|
+
return staleValues(fn, false);
|
|
918
|
+
} finally {
|
|
919
|
+
pendingValueCheck = prevLatest;
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
function isPending(fn, loadingValue) {
|
|
923
|
+
const current = pendingCheck;
|
|
924
|
+
pendingCheck = { g: false };
|
|
925
|
+
try {
|
|
926
|
+
staleValues(fn);
|
|
927
|
+
return pendingCheck.g;
|
|
966
928
|
} catch (err) {
|
|
967
929
|
if (!(err instanceof NotReadyError))
|
|
968
930
|
return false;
|
|
@@ -970,420 +932,167 @@ function pendingCheck(fn, loadingValue) {
|
|
|
970
932
|
return loadingValue;
|
|
971
933
|
throw err;
|
|
972
934
|
} finally {
|
|
973
|
-
|
|
935
|
+
pendingCheck = current;
|
|
974
936
|
}
|
|
975
937
|
}
|
|
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;
|
|
938
|
+
|
|
939
|
+
// src/core/context.ts
|
|
940
|
+
function createContext(defaultValue, description) {
|
|
941
|
+
return { id: Symbol(description), defaultValue };
|
|
991
942
|
}
|
|
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;
|
|
943
|
+
function getContext(context2, owner = getOwner()) {
|
|
944
|
+
if (!owner) {
|
|
945
|
+
throw new NoOwnerError();
|
|
1006
946
|
}
|
|
947
|
+
const value = hasContext(context2, owner) ? owner.D[context2.id] : context2.defaultValue;
|
|
948
|
+
if (isUndefined(value)) {
|
|
949
|
+
throw new ContextNotFoundError();
|
|
950
|
+
}
|
|
951
|
+
return value;
|
|
1007
952
|
}
|
|
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;
|
|
953
|
+
function setContext(context2, value, owner = getOwner()) {
|
|
954
|
+
if (!owner) {
|
|
955
|
+
throw new NoOwnerError();
|
|
1020
956
|
}
|
|
957
|
+
owner.D = {
|
|
958
|
+
...owner.D,
|
|
959
|
+
[context2.id]: isUndefined(value) ? context2.defaultValue : value
|
|
960
|
+
};
|
|
961
|
+
}
|
|
962
|
+
function hasContext(context2, owner) {
|
|
963
|
+
return !isUndefined(owner == null ? void 0 : owner.D[context2.id]);
|
|
964
|
+
}
|
|
965
|
+
function isUndefined(value) {
|
|
966
|
+
return typeof value === "undefined";
|
|
1021
967
|
}
|
|
1022
968
|
|
|
1023
969
|
// 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;
|
|
970
|
+
function effect(compute, effect2, error, initialValue, options) {
|
|
971
|
+
var _a;
|
|
972
|
+
let initialized = false;
|
|
973
|
+
const node = computed(compute, initialValue, {
|
|
974
|
+
...options,
|
|
975
|
+
ja: {
|
|
976
|
+
fa: true,
|
|
977
|
+
pa: initialValue,
|
|
978
|
+
ua: effect2,
|
|
979
|
+
qa: error,
|
|
980
|
+
L: void 0,
|
|
981
|
+
i: ((_a = getOwner()) == null ? void 0 : _a.i) ?? globalQueue,
|
|
982
|
+
I: (options == null ? void 0 : options.render) ? 1 /* Render */ : 2 /* User */,
|
|
983
|
+
ma(statusFlagsChanged, prevStatusFlags) {
|
|
984
|
+
if (initialized) {
|
|
985
|
+
const errorChanged = this.f && this.f === prevStatusFlags && statusFlagsChanged;
|
|
986
|
+
this.fa = !(this.f & 2 /* Error */) && !(this.f & 1 /* Pending */ & ~prevStatusFlags) && !errorChanged;
|
|
987
|
+
if (this.fa)
|
|
988
|
+
this.i.enqueue(this.I, runEffect.bind(this));
|
|
989
|
+
}
|
|
990
|
+
if (this.f & 2 /* Error */) {
|
|
991
|
+
let error2 = this.B;
|
|
992
|
+
this.i.notify(this, 1 /* Pending */, 0);
|
|
993
|
+
if (this.I === 2 /* User */) {
|
|
994
|
+
try {
|
|
995
|
+
return this.qa ? this.qa(error2, () => {
|
|
996
|
+
var _a2;
|
|
997
|
+
(_a2 = this.L) == null ? void 0 : _a2.call(this);
|
|
998
|
+
this.L = void 0;
|
|
999
|
+
}) : console.error(error2);
|
|
1000
|
+
} catch (e) {
|
|
1001
|
+
error2 = e;
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
if (!this.i.notify(this, 2 /* Error */, 2 /* Error */))
|
|
1005
|
+
throw error2;
|
|
1006
|
+
} else if (this.I === 1 /* Render */) {
|
|
1007
|
+
this.i.notify(
|
|
1008
|
+
this,
|
|
1009
|
+
1 /* Pending */ | 2 /* Error */,
|
|
1010
|
+
this.f
|
|
1011
|
+
);
|
|
1121
1012
|
}
|
|
1122
1013
|
}
|
|
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
1014
|
}
|
|
1201
|
-
}
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1015
|
+
});
|
|
1016
|
+
initialized = true;
|
|
1017
|
+
if (node.I === 1 /* Render */) {
|
|
1018
|
+
node.ha = (p) => !(node.f & 2 /* Error */) ? staleValues(() => compute(p)) : compute(p);
|
|
1019
|
+
}
|
|
1020
|
+
!(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));
|
|
1021
|
+
onCleanup(() => {
|
|
1022
|
+
var _a2;
|
|
1023
|
+
return (_a2 = node.L) == null ? void 0 : _a2.call(node);
|
|
1024
|
+
});
|
|
1025
|
+
}
|
|
1026
|
+
function runEffect() {
|
|
1027
|
+
var _a;
|
|
1028
|
+
if (!this.fa || this.b & 64 /* Disposed */)
|
|
1029
|
+
return;
|
|
1030
|
+
(_a = this.L) == null ? void 0 : _a.call(this);
|
|
1031
|
+
this.L = void 0;
|
|
1032
|
+
try {
|
|
1033
|
+
this.L = this.ua(this.g, this.pa);
|
|
1034
|
+
} catch (error) {
|
|
1035
|
+
if (!this.i.notify(this, 2 /* Error */, 2 /* Error */))
|
|
1036
|
+
throw error;
|
|
1037
|
+
} finally {
|
|
1038
|
+
this.pa = this.g;
|
|
1039
|
+
this.fa = false;
|
|
1215
1040
|
}
|
|
1216
1041
|
}
|
|
1217
1042
|
|
|
1218
1043
|
// src/signals.ts
|
|
1219
1044
|
function createSignal(first, second, third) {
|
|
1220
1045
|
if (typeof first === "function") {
|
|
1221
|
-
const node2 =
|
|
1046
|
+
const node2 = computed(first, second, third);
|
|
1222
1047
|
return [
|
|
1223
|
-
|
|
1224
|
-
(
|
|
1225
|
-
node2.F();
|
|
1226
|
-
return node2.write(v);
|
|
1227
|
-
}
|
|
1048
|
+
read.bind(null, node2),
|
|
1049
|
+
setSignal.bind(null, node2)
|
|
1228
1050
|
];
|
|
1229
1051
|
}
|
|
1230
1052
|
const o = getOwner();
|
|
1231
1053
|
const needsId = (o == null ? void 0 : o.id) != null;
|
|
1232
|
-
const node =
|
|
1054
|
+
const node = signal(
|
|
1233
1055
|
first,
|
|
1234
|
-
|
|
1235
|
-
needsId ? { id: o.getNextChildId(), ...second } : second
|
|
1236
|
-
);
|
|
1237
|
-
return [node.read.bind(node), node.write.bind(node)];
|
|
1238
|
-
}
|
|
1239
|
-
function createMemo(compute2, value, options) {
|
|
1240
|
-
let node = new Computation(
|
|
1241
|
-
value,
|
|
1242
|
-
compute2,
|
|
1243
|
-
options
|
|
1244
|
-
);
|
|
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
|
-
}
|
|
1262
|
-
function createAsync(compute2, value, options) {
|
|
1263
|
-
let refreshing = false;
|
|
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
|
|
1056
|
+
needsId ? { id: getNextChildId(o), ...second } : second
|
|
1324
1057
|
);
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1058
|
+
return [
|
|
1059
|
+
read.bind(null, node),
|
|
1060
|
+
setSignal.bind(null, node)
|
|
1061
|
+
];
|
|
1062
|
+
}
|
|
1063
|
+
function createMemo(compute, value, options) {
|
|
1064
|
+
let node = computed(compute, value, options);
|
|
1065
|
+
return read.bind(null, node);
|
|
1066
|
+
}
|
|
1067
|
+
function createAsync(compute, value, options) {
|
|
1068
|
+
const node = asyncComputed(compute, value, options);
|
|
1069
|
+
const ret = read.bind(null, node);
|
|
1070
|
+
ret.refresh = node.ta;
|
|
1071
|
+
return ret;
|
|
1072
|
+
}
|
|
1073
|
+
function createEffect(compute, effectFn, value, options) {
|
|
1074
|
+
void effect(
|
|
1075
|
+
compute,
|
|
1076
|
+
effectFn.effect || effectFn,
|
|
1077
|
+
effectFn.error,
|
|
1339
1078
|
value,
|
|
1340
|
-
compute2,
|
|
1341
|
-
effect.effect || effect,
|
|
1342
|
-
effect.error,
|
|
1343
1079
|
options
|
|
1344
1080
|
);
|
|
1345
1081
|
}
|
|
1346
|
-
function createRenderEffect(
|
|
1347
|
-
void
|
|
1082
|
+
function createRenderEffect(compute, effectFn, value, options) {
|
|
1083
|
+
void effect(compute, effectFn, void 0, value, {
|
|
1348
1084
|
render: true,
|
|
1349
1085
|
...options
|
|
1350
1086
|
});
|
|
1351
1087
|
}
|
|
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
|
-
};
|
|
1088
|
+
function createTrackedEffect(compute, options) {
|
|
1375
1089
|
}
|
|
1376
|
-
function
|
|
1377
|
-
const owner = new Owner(options == null ? void 0 : options.id);
|
|
1378
|
-
return compute(owner, !init.length ? init : () => init(() => owner.dispose()), null);
|
|
1379
|
-
}
|
|
1380
|
-
function runWithOwner(owner, run) {
|
|
1381
|
-
return compute(owner, run, null);
|
|
1090
|
+
function createReaction(effect2, options) {
|
|
1382
1091
|
}
|
|
1383
1092
|
function resolve(fn) {
|
|
1384
1093
|
return new Promise((res, rej) => {
|
|
1385
1094
|
createRoot((dispose) => {
|
|
1386
|
-
|
|
1095
|
+
computed(() => {
|
|
1387
1096
|
try {
|
|
1388
1097
|
res(fn());
|
|
1389
1098
|
} catch (err) {
|
|
@@ -1397,44 +1106,9 @@ function resolve(fn) {
|
|
|
1397
1106
|
});
|
|
1398
1107
|
}
|
|
1399
1108
|
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];
|
|
1109
|
+
return {};
|
|
1424
1110
|
}
|
|
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];
|
|
1111
|
+
function onSettled(callback) {
|
|
1438
1112
|
}
|
|
1439
1113
|
|
|
1440
1114
|
// src/store/reconcile.ts
|
|
@@ -1443,7 +1117,7 @@ function unwrap(value) {
|
|
|
1443
1117
|
return ((_a = value == null ? void 0 : value[$TARGET]) == null ? void 0 : _a[STORE_NODE]) ?? value;
|
|
1444
1118
|
}
|
|
1445
1119
|
function getOverrideValue(value, override, nodes, key) {
|
|
1446
|
-
return nodes && key in nodes ? nodes[key]
|
|
1120
|
+
return nodes && key in nodes ? read(nodes[key]) : override && key in override ? override[key] : value[key];
|
|
1447
1121
|
}
|
|
1448
1122
|
function getAllKeys(value, override, next) {
|
|
1449
1123
|
const keys = getKeys(value, override);
|
|
@@ -1451,7 +1125,6 @@ function getAllKeys(value, override, next) {
|
|
|
1451
1125
|
return Array.from(/* @__PURE__ */ new Set([...keys, ...nextKeys]));
|
|
1452
1126
|
}
|
|
1453
1127
|
function applyState(next, state, keyFn, all) {
|
|
1454
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1455
1128
|
const target = state == null ? void 0 : state[$TARGET];
|
|
1456
1129
|
if (!target)
|
|
1457
1130
|
return;
|
|
@@ -1478,16 +1151,16 @@ function applyState(next, state, keyFn, all) {
|
|
|
1478
1151
|
if (start > newEnd || start > end) {
|
|
1479
1152
|
for (j = start; j <= newEnd; j++) {
|
|
1480
1153
|
changed = true;
|
|
1481
|
-
|
|
1154
|
+
target[STORE_NODE][j] && setSignal(target[STORE_NODE][j], wrap(next[j], target));
|
|
1482
1155
|
}
|
|
1483
1156
|
for (; j < next.length; j++) {
|
|
1484
1157
|
changed = true;
|
|
1485
1158
|
const wrapped = wrap(temp[j], target);
|
|
1486
|
-
|
|
1159
|
+
target[STORE_NODE][j] && setSignal(target[STORE_NODE][j], wrapped);
|
|
1487
1160
|
applyState(next[j], wrapped, keyFn, all);
|
|
1488
1161
|
}
|
|
1489
|
-
changed &&
|
|
1490
|
-
prevLength !== next.length &&
|
|
1162
|
+
changed && target[STORE_NODE][$TRACK] && setSignal(target[STORE_NODE][$TRACK], void 0);
|
|
1163
|
+
prevLength !== next.length && target[STORE_NODE].length && setSignal(target[STORE_NODE].length, next.length);
|
|
1491
1164
|
return;
|
|
1492
1165
|
}
|
|
1493
1166
|
newIndicesNext = new Array(newEnd + 1);
|
|
@@ -1511,10 +1184,10 @@ function applyState(next, state, keyFn, all) {
|
|
|
1511
1184
|
for (j = start; j < next.length; j++) {
|
|
1512
1185
|
if (j in temp) {
|
|
1513
1186
|
const wrapped = wrap(temp[j], target);
|
|
1514
|
-
|
|
1187
|
+
target[STORE_NODE][j] && setSignal(target[STORE_NODE][j], wrapped);
|
|
1515
1188
|
applyState(next[j], wrapped, keyFn, all);
|
|
1516
1189
|
} else
|
|
1517
|
-
|
|
1190
|
+
target[STORE_NODE][j] && setSignal(target[STORE_NODE][j], wrap(next[j], target));
|
|
1518
1191
|
}
|
|
1519
1192
|
if (start < next.length)
|
|
1520
1193
|
changed = true;
|
|
@@ -1526,9 +1199,9 @@ function applyState(next, state, keyFn, all) {
|
|
|
1526
1199
|
}
|
|
1527
1200
|
if (prevLength !== next.length) {
|
|
1528
1201
|
changed = true;
|
|
1529
|
-
|
|
1202
|
+
target[STORE_NODE].length && setSignal(target[STORE_NODE].length, next.length);
|
|
1530
1203
|
}
|
|
1531
|
-
changed &&
|
|
1204
|
+
changed && target[STORE_NODE][$TRACK] && setSignal(target[STORE_NODE][$TRACK], void 0);
|
|
1532
1205
|
return;
|
|
1533
1206
|
}
|
|
1534
1207
|
if (nodes) {
|
|
@@ -1542,8 +1215,8 @@ function applyState(next, state, keyFn, all) {
|
|
|
1542
1215
|
if (previousValue === nextValue)
|
|
1543
1216
|
continue;
|
|
1544
1217
|
if (!previousValue || !isWrappable(previousValue) || keyFn(previousValue) != null && keyFn(previousValue) !== keyFn(nextValue)) {
|
|
1545
|
-
tracked
|
|
1546
|
-
node
|
|
1218
|
+
tracked && setSignal(tracked, void 0);
|
|
1219
|
+
node && setSignal(node, isWrappable(nextValue) ? wrap(nextValue, target) : nextValue);
|
|
1547
1220
|
} else
|
|
1548
1221
|
applyState(nextValue, wrap(previousValue, target), keyFn, all);
|
|
1549
1222
|
}
|
|
@@ -1551,7 +1224,8 @@ function applyState(next, state, keyFn, all) {
|
|
|
1551
1224
|
if (nodes = target[STORE_HAS]) {
|
|
1552
1225
|
const keys = Object.keys(nodes);
|
|
1553
1226
|
for (let i = 0, len = keys.length; i < len; i++) {
|
|
1554
|
-
|
|
1227
|
+
const key = keys[i];
|
|
1228
|
+
setSignal(nodes[key], key in next);
|
|
1555
1229
|
}
|
|
1556
1230
|
}
|
|
1557
1231
|
}
|
|
@@ -1569,13 +1243,14 @@ function reconcile(value, key, all = false) {
|
|
|
1569
1243
|
|
|
1570
1244
|
// src/store/projection.ts
|
|
1571
1245
|
function createProjectionInternal(fn, initialValue = {}, options) {
|
|
1246
|
+
let node;
|
|
1572
1247
|
const wrappedMap = /* @__PURE__ */ new WeakMap();
|
|
1573
1248
|
const traps = {
|
|
1574
1249
|
...storeTraps,
|
|
1575
1250
|
get(target, property, receiver) {
|
|
1576
1251
|
const o = getOwner();
|
|
1577
|
-
const n =
|
|
1578
|
-
(!o || o !== n) && n
|
|
1252
|
+
const n = node;
|
|
1253
|
+
(!o || o !== n) && n && read(n);
|
|
1579
1254
|
return storeTraps.get(target, property, receiver);
|
|
1580
1255
|
}
|
|
1581
1256
|
};
|
|
@@ -1593,7 +1268,7 @@ function createProjectionInternal(fn, initialValue = {}, options) {
|
|
|
1593
1268
|
return wrapped;
|
|
1594
1269
|
};
|
|
1595
1270
|
const wrappedStore = wrapProjection(initialValue);
|
|
1596
|
-
|
|
1271
|
+
node = computed(() => {
|
|
1597
1272
|
storeSetter(wrappedStore, (s) => {
|
|
1598
1273
|
const value = fn(s);
|
|
1599
1274
|
if (value !== s && value !== void 0) {
|
|
@@ -1651,7 +1326,7 @@ function getNodes(target, type) {
|
|
|
1651
1326
|
function getNode(nodes, property, value, equals = isEqual) {
|
|
1652
1327
|
if (nodes[property])
|
|
1653
1328
|
return nodes[property];
|
|
1654
|
-
return nodes[property] =
|
|
1329
|
+
return nodes[property] = signal(value, {
|
|
1655
1330
|
equals,
|
|
1656
1331
|
unobserved() {
|
|
1657
1332
|
delete nodes[property];
|
|
@@ -1659,7 +1334,7 @@ function getNode(nodes, property, value, equals = isEqual) {
|
|
|
1659
1334
|
});
|
|
1660
1335
|
}
|
|
1661
1336
|
function trackSelf(target, symbol = $TRACK) {
|
|
1662
|
-
getObserver() && getNode(getNodes(target, STORE_NODE), symbol, void 0, false)
|
|
1337
|
+
getObserver() && read(getNode(getNodes(target, STORE_NODE), symbol, void 0, false));
|
|
1663
1338
|
}
|
|
1664
1339
|
function getKeys(source, override, enumerable = true) {
|
|
1665
1340
|
const baseKeys = untrack(() => enumerable ? Object.keys(source) : Reflect.ownKeys(source));
|
|
@@ -1707,7 +1382,7 @@ var storeTraps = {
|
|
|
1707
1382
|
return desc.get.call(receiver);
|
|
1708
1383
|
}
|
|
1709
1384
|
if (Writing == null ? void 0 : Writing.has(receiver)) {
|
|
1710
|
-
let value2 = tracked && (overridden || !proxySource) ? tracked.
|
|
1385
|
+
let value2 = tracked && (overridden || !proxySource) ? tracked.e !== NOT_PENDING ? tracked.e : tracked.g : storeValue[property];
|
|
1711
1386
|
value2 === $DELETED && (value2 = void 0);
|
|
1712
1387
|
if (!isWrappable(value2))
|
|
1713
1388
|
return value2;
|
|
@@ -1715,14 +1390,14 @@ var storeTraps = {
|
|
|
1715
1390
|
Writing.add(wrapped);
|
|
1716
1391
|
return wrapped;
|
|
1717
1392
|
}
|
|
1718
|
-
let value = tracked ? overridden || !proxySource ? nodes[property]
|
|
1393
|
+
let value = tracked ? overridden || !proxySource ? read(nodes[property]) : (read(nodes[property]), storeValue[property]) : storeValue[property];
|
|
1719
1394
|
value === $DELETED && (value = void 0);
|
|
1720
1395
|
if (!tracked) {
|
|
1721
1396
|
if (!overridden && typeof value === "function" && !storeValue.hasOwnProperty(property)) {
|
|
1722
1397
|
let proto;
|
|
1723
1398
|
return !Array.isArray(target[STORE_VALUE]) && (proto = Object.getPrototypeOf(target[STORE_VALUE])) && proto !== Object.prototype ? value.bind(storeValue) : value;
|
|
1724
1399
|
} else if (getObserver()) {
|
|
1725
|
-
return getNode(nodes, property, isWrappable(value) ? wrap(value, target) : value)
|
|
1400
|
+
return read(getNode(nodes, property, isWrappable(value) ? wrap(value, target) : value));
|
|
1726
1401
|
}
|
|
1727
1402
|
}
|
|
1728
1403
|
return isWrappable(value) ? wrap(value, target) : value;
|
|
@@ -1731,14 +1406,14 @@ var storeTraps = {
|
|
|
1731
1406
|
if (property === $PROXY || property === $TRACK || property === "__proto__")
|
|
1732
1407
|
return true;
|
|
1733
1408
|
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)
|
|
1409
|
+
getObserver() && read(getNode(getNodes(target, STORE_HAS), property, has));
|
|
1735
1410
|
return has;
|
|
1736
1411
|
},
|
|
1737
1412
|
set(target, property, rawValue) {
|
|
1738
1413
|
const store = target[$PROXY];
|
|
1739
1414
|
if (Writing == null ? void 0 : Writing.has(target[$PROXY])) {
|
|
1740
1415
|
untrack(() => {
|
|
1741
|
-
var _a, _b, _c
|
|
1416
|
+
var _a, _b, _c;
|
|
1742
1417
|
const state = target[STORE_VALUE];
|
|
1743
1418
|
const base = state[property];
|
|
1744
1419
|
const prev = target[STORE_OVERRIDE] && property in target[STORE_OVERRIDE] ? target[STORE_OVERRIDE][property] : base;
|
|
@@ -1757,15 +1432,15 @@ var storeTraps = {
|
|
|
1757
1432
|
}
|
|
1758
1433
|
if (recursivelyNotify(store, storeLookup) && wrappable)
|
|
1759
1434
|
recursivelyAddParent(value, store);
|
|
1760
|
-
(
|
|
1435
|
+
((_c = target[STORE_HAS]) == null ? void 0 : _c[property]) && setSignal(target[STORE_HAS][property], true);
|
|
1761
1436
|
const nodes = getNodes(target, STORE_NODE);
|
|
1762
|
-
|
|
1437
|
+
nodes[property] && setSignal(nodes[property], () => wrappable ? wrap(value, target) : value);
|
|
1763
1438
|
if (Array.isArray(state)) {
|
|
1764
1439
|
const index = parseInt(property) + 1;
|
|
1765
1440
|
if (index > len)
|
|
1766
|
-
|
|
1441
|
+
nodes.length && setSignal(nodes.length, index);
|
|
1767
1442
|
}
|
|
1768
|
-
|
|
1443
|
+
nodes[$TRACK] && setSignal(nodes[$TRACK], void 0);
|
|
1769
1444
|
});
|
|
1770
1445
|
}
|
|
1771
1446
|
return true;
|
|
@@ -1774,7 +1449,7 @@ var storeTraps = {
|
|
|
1774
1449
|
var _a;
|
|
1775
1450
|
if ((Writing == null ? void 0 : Writing.has(target[$PROXY])) && ((_a = target[STORE_OVERRIDE]) == null ? void 0 : _a[property]) !== $DELETED) {
|
|
1776
1451
|
untrack(() => {
|
|
1777
|
-
var _a2
|
|
1452
|
+
var _a2;
|
|
1778
1453
|
const prev = target[STORE_OVERRIDE] && property in target[STORE_OVERRIDE] ? target[STORE_OVERRIDE][property] : target[STORE_VALUE][property];
|
|
1779
1454
|
if (property in target[STORE_VALUE]) {
|
|
1780
1455
|
(target[STORE_OVERRIDE] || (target[STORE_OVERRIDE] = /* @__PURE__ */ Object.create(null)))[property] = $DELETED;
|
|
@@ -1786,10 +1461,11 @@ var storeTraps = {
|
|
|
1786
1461
|
const parents = PARENTS.get(prev);
|
|
1787
1462
|
parents && (parents instanceof Set ? parents.delete(target) : PARENTS.delete(prev));
|
|
1788
1463
|
}
|
|
1789
|
-
|
|
1464
|
+
if ((_a2 = target[STORE_HAS]) == null ? void 0 : _a2[property])
|
|
1465
|
+
setSignal(target[STORE_HAS][property], false);
|
|
1790
1466
|
const nodes = getNodes(target, STORE_NODE);
|
|
1791
|
-
|
|
1792
|
-
|
|
1467
|
+
nodes[property] && setSignal(nodes[property], void 0);
|
|
1468
|
+
nodes[$TRACK] && setSignal(nodes[$TRACK], void 0);
|
|
1793
1469
|
});
|
|
1794
1470
|
}
|
|
1795
1471
|
return true;
|
|
@@ -1844,7 +1520,7 @@ function recursivelyNotify(state, lookup) {
|
|
|
1844
1520
|
if (target) {
|
|
1845
1521
|
const deep2 = getNodes(target, STORE_NODE)[$DEEP];
|
|
1846
1522
|
if (deep2) {
|
|
1847
|
-
deep2
|
|
1523
|
+
setSignal(deep2, void 0);
|
|
1848
1524
|
notified = true;
|
|
1849
1525
|
}
|
|
1850
1526
|
lookup = target[STORE_LOOKUP] || lookup;
|
|
@@ -1901,31 +1577,7 @@ function deep(store) {
|
|
|
1901
1577
|
|
|
1902
1578
|
// src/store/optimistic.ts
|
|
1903
1579
|
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];
|
|
1580
|
+
return [];
|
|
1929
1581
|
}
|
|
1930
1582
|
|
|
1931
1583
|
// src/store/utils.ts
|
|
@@ -2132,348 +1784,343 @@ function omit(props, ...keys) {
|
|
|
2132
1784
|
// src/map.ts
|
|
2133
1785
|
function mapArray(list, map, options) {
|
|
2134
1786
|
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
|
-
|
|
1787
|
+
return createMemo(
|
|
1788
|
+
updateKeyedMap.bind({
|
|
1789
|
+
z: createOwner(),
|
|
1790
|
+
k: 0,
|
|
1791
|
+
va: list,
|
|
1792
|
+
F: [],
|
|
1793
|
+
M: map,
|
|
1794
|
+
d: [],
|
|
1795
|
+
a: [],
|
|
1796
|
+
N: keyFn,
|
|
1797
|
+
l: keyFn || (options == null ? void 0 : options.keyed) === false ? [] : void 0,
|
|
1798
|
+
m: map.length > 1 ? [] : void 0,
|
|
1799
|
+
Y: options == null ? void 0 : options.fallback
|
|
1800
|
+
})
|
|
1801
|
+
);
|
|
2148
1802
|
}
|
|
2149
1803
|
var pureOptions = { pureWrite: true };
|
|
2150
1804
|
function updateKeyedMap() {
|
|
2151
|
-
const newItems = this.
|
|
1805
|
+
const newItems = this.va() || [], newLen = newItems.length;
|
|
2152
1806
|
newItems[$TRACK];
|
|
2153
|
-
runWithOwner(this.
|
|
2154
|
-
let i, j, mapper = this.
|
|
2155
|
-
this.
|
|
2156
|
-
this.
|
|
2157
|
-
return this.
|
|
2158
|
-
|
|
2159
|
-
this.
|
|
1807
|
+
runWithOwner(this.z, () => {
|
|
1808
|
+
let i, j, mapper = this.l ? () => {
|
|
1809
|
+
this.l[j] = signal(newItems[j], pureOptions);
|
|
1810
|
+
this.m && (this.m[j] = signal(j, pureOptions));
|
|
1811
|
+
return this.M(
|
|
1812
|
+
read.bind(null, this.l[j]),
|
|
1813
|
+
this.m ? read.bind(null, this.m[j]) : void 0
|
|
2160
1814
|
);
|
|
2161
|
-
} : this.
|
|
1815
|
+
} : this.m ? () => {
|
|
2162
1816
|
const item = newItems[j];
|
|
2163
|
-
this.
|
|
2164
|
-
return this.
|
|
1817
|
+
this.m[j] = signal(j, pureOptions);
|
|
1818
|
+
return this.M(
|
|
1819
|
+
() => item,
|
|
1820
|
+
read.bind(null, this.m[j])
|
|
1821
|
+
);
|
|
2165
1822
|
} : () => {
|
|
2166
1823
|
const item = newItems[j];
|
|
2167
|
-
return this.
|
|
1824
|
+
return this.M(() => item);
|
|
2168
1825
|
};
|
|
2169
1826
|
if (newLen === 0) {
|
|
2170
|
-
if (this.
|
|
2171
|
-
this.
|
|
2172
|
-
this.
|
|
2173
|
-
this.
|
|
2174
|
-
this.
|
|
2175
|
-
this.
|
|
2176
|
-
this.
|
|
2177
|
-
this.
|
|
1827
|
+
if (this.k !== 0) {
|
|
1828
|
+
this.z.dispose(false);
|
|
1829
|
+
this.a = [];
|
|
1830
|
+
this.F = [];
|
|
1831
|
+
this.d = [];
|
|
1832
|
+
this.k = 0;
|
|
1833
|
+
this.l && (this.l = []);
|
|
1834
|
+
this.m && (this.m = []);
|
|
2178
1835
|
}
|
|
2179
|
-
if (this.
|
|
2180
|
-
this.
|
|
2181
|
-
this.
|
|
2182
|
-
this.
|
|
2183
|
-
null
|
|
1836
|
+
if (this.Y && !this.d[0]) {
|
|
1837
|
+
this.d[0] = runWithOwner(
|
|
1838
|
+
this.a[0] = createOwner(),
|
|
1839
|
+
this.Y
|
|
2184
1840
|
);
|
|
2185
1841
|
}
|
|
2186
|
-
} else if (this.
|
|
2187
|
-
if (this.
|
|
2188
|
-
this.
|
|
2189
|
-
this.
|
|
1842
|
+
} else if (this.k === 0) {
|
|
1843
|
+
if (this.a[0])
|
|
1844
|
+
this.a[0].dispose();
|
|
1845
|
+
this.d = new Array(newLen);
|
|
2190
1846
|
for (j = 0; j < newLen; j++) {
|
|
2191
|
-
this.
|
|
2192
|
-
this.
|
|
1847
|
+
this.F[j] = newItems[j];
|
|
1848
|
+
this.d[j] = runWithOwner(this.a[j] = createOwner(), mapper);
|
|
2193
1849
|
}
|
|
2194
|
-
this.
|
|
1850
|
+
this.k = newLen;
|
|
2195
1851
|
} 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.
|
|
1852
|
+
let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.l ? new Array(newLen) : void 0, tempIndexes = this.m ? new Array(newLen) : void 0;
|
|
1853
|
+
for (start = 0, end = Math.min(this.k, newLen); start < end && (this.F[start] === newItems[start] || this.l && compare(this.N, this.F[start], newItems[start])); start++) {
|
|
1854
|
+
if (this.l)
|
|
1855
|
+
setSignal(this.l[start], newItems[start]);
|
|
2200
1856
|
}
|
|
2201
|
-
for (end = this.
|
|
2202
|
-
temp[newEnd] = this.
|
|
2203
|
-
tempNodes[newEnd] = this.
|
|
2204
|
-
tempRows && (tempRows[newEnd] = this.
|
|
2205
|
-
tempIndexes && (tempIndexes[newEnd] = this.
|
|
1857
|
+
for (end = this.k - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.F[end] === newItems[newEnd] || this.l && compare(this.N, this.F[end], newItems[newEnd])); end--, newEnd--) {
|
|
1858
|
+
temp[newEnd] = this.d[end];
|
|
1859
|
+
tempNodes[newEnd] = this.a[end];
|
|
1860
|
+
tempRows && (tempRows[newEnd] = this.l[end]);
|
|
1861
|
+
tempIndexes && (tempIndexes[newEnd] = this.m[end]);
|
|
2206
1862
|
}
|
|
2207
1863
|
newIndices = /* @__PURE__ */ new Map();
|
|
2208
1864
|
newIndicesNext = new Array(newEnd + 1);
|
|
2209
1865
|
for (j = newEnd; j >= start; j--) {
|
|
2210
1866
|
item = newItems[j];
|
|
2211
|
-
key = this.
|
|
1867
|
+
key = this.N ? this.N(item) : item;
|
|
2212
1868
|
i = newIndices.get(key);
|
|
2213
1869
|
newIndicesNext[j] = i === void 0 ? -1 : i;
|
|
2214
1870
|
newIndices.set(key, j);
|
|
2215
1871
|
}
|
|
2216
1872
|
for (i = start; i <= end; i++) {
|
|
2217
|
-
item = this.
|
|
2218
|
-
key = this.
|
|
1873
|
+
item = this.F[i];
|
|
1874
|
+
key = this.N ? this.N(item) : item;
|
|
2219
1875
|
j = newIndices.get(key);
|
|
2220
1876
|
if (j !== void 0 && j !== -1) {
|
|
2221
|
-
temp[j] = this.
|
|
2222
|
-
tempNodes[j] = this.
|
|
2223
|
-
tempRows && (tempRows[j] = this.
|
|
2224
|
-
tempIndexes && (tempIndexes[j] = this.
|
|
1877
|
+
temp[j] = this.d[i];
|
|
1878
|
+
tempNodes[j] = this.a[i];
|
|
1879
|
+
tempRows && (tempRows[j] = this.l[i]);
|
|
1880
|
+
tempIndexes && (tempIndexes[j] = this.m[i]);
|
|
2225
1881
|
j = newIndicesNext[j];
|
|
2226
1882
|
newIndices.set(key, j);
|
|
2227
1883
|
} else
|
|
2228
|
-
this.
|
|
1884
|
+
this.a[i].dispose();
|
|
2229
1885
|
}
|
|
2230
1886
|
for (j = start; j < newLen; j++) {
|
|
2231
1887
|
if (j in temp) {
|
|
2232
|
-
this.
|
|
2233
|
-
this.
|
|
1888
|
+
this.d[j] = temp[j];
|
|
1889
|
+
this.a[j] = tempNodes[j];
|
|
2234
1890
|
if (tempRows) {
|
|
2235
|
-
this.
|
|
2236
|
-
this.
|
|
1891
|
+
this.l[j] = tempRows[j];
|
|
1892
|
+
setSignal(this.l[j], newItems[j]);
|
|
2237
1893
|
}
|
|
2238
1894
|
if (tempIndexes) {
|
|
2239
|
-
this.
|
|
2240
|
-
this.
|
|
1895
|
+
this.m[j] = tempIndexes[j];
|
|
1896
|
+
setSignal(this.m[j], j);
|
|
2241
1897
|
}
|
|
2242
1898
|
} else {
|
|
2243
|
-
this.
|
|
1899
|
+
this.d[j] = runWithOwner(this.a[j] = createOwner(), mapper);
|
|
2244
1900
|
}
|
|
2245
1901
|
}
|
|
2246
|
-
this.
|
|
2247
|
-
this.
|
|
1902
|
+
this.d = this.d.slice(0, this.k = newLen);
|
|
1903
|
+
this.F = newItems.slice(0);
|
|
2248
1904
|
}
|
|
2249
1905
|
});
|
|
2250
|
-
return this.
|
|
1906
|
+
return this.d;
|
|
2251
1907
|
}
|
|
2252
1908
|
function repeat(count, map, options) {
|
|
2253
1909
|
return updateRepeat.bind({
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
1910
|
+
z: createOwner(),
|
|
1911
|
+
k: 0,
|
|
1912
|
+
w: 0,
|
|
1913
|
+
wa: count,
|
|
1914
|
+
M: map,
|
|
1915
|
+
a: [],
|
|
1916
|
+
d: [],
|
|
1917
|
+
xa: options == null ? void 0 : options.from,
|
|
1918
|
+
Y: options == null ? void 0 : options.fallback
|
|
2263
1919
|
});
|
|
2264
1920
|
}
|
|
2265
1921
|
function updateRepeat() {
|
|
2266
1922
|
var _a;
|
|
2267
|
-
const newLen = this.
|
|
2268
|
-
const from = ((_a = this.
|
|
2269
|
-
runWithOwner(this.
|
|
1923
|
+
const newLen = this.wa();
|
|
1924
|
+
const from = ((_a = this.xa) == null ? void 0 : _a.call(this)) || 0;
|
|
1925
|
+
runWithOwner(this.z, () => {
|
|
2270
1926
|
if (newLen === 0) {
|
|
2271
|
-
if (this.
|
|
2272
|
-
this.
|
|
2273
|
-
this.
|
|
2274
|
-
this.
|
|
2275
|
-
this.
|
|
1927
|
+
if (this.k !== 0) {
|
|
1928
|
+
this.z.dispose(false);
|
|
1929
|
+
this.a = [];
|
|
1930
|
+
this.d = [];
|
|
1931
|
+
this.k = 0;
|
|
2276
1932
|
}
|
|
2277
|
-
if (this.
|
|
2278
|
-
this.
|
|
2279
|
-
this.
|
|
2280
|
-
this.
|
|
2281
|
-
null
|
|
1933
|
+
if (this.Y && !this.d[0]) {
|
|
1934
|
+
this.d[0] = runWithOwner(
|
|
1935
|
+
this.a[0] = createOwner(),
|
|
1936
|
+
this.Y
|
|
2282
1937
|
);
|
|
2283
1938
|
}
|
|
2284
1939
|
return;
|
|
2285
1940
|
}
|
|
2286
1941
|
const to = from + newLen;
|
|
2287
|
-
const prevTo = this.
|
|
2288
|
-
if (this.
|
|
2289
|
-
this.
|
|
1942
|
+
const prevTo = this.w + this.k;
|
|
1943
|
+
if (this.k === 0 && this.a[0])
|
|
1944
|
+
this.a[0].dispose();
|
|
2290
1945
|
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.
|
|
1946
|
+
this.a[i - this.w].dispose();
|
|
1947
|
+
if (this.w < from) {
|
|
1948
|
+
let i = this.w;
|
|
1949
|
+
while (i < from && i < this.k)
|
|
1950
|
+
this.a[i++].dispose();
|
|
1951
|
+
this.a.splice(0, from - this.w);
|
|
1952
|
+
this.d.splice(0, from - this.w);
|
|
1953
|
+
} else if (this.w > from) {
|
|
1954
|
+
let i = prevTo - this.w - 1;
|
|
1955
|
+
let difference = this.w - from;
|
|
1956
|
+
this.a.length = this.d.length = newLen;
|
|
2302
1957
|
while (i >= difference) {
|
|
2303
|
-
this.
|
|
2304
|
-
this.
|
|
1958
|
+
this.a[i] = this.a[i - difference];
|
|
1959
|
+
this.d[i] = this.d[i - difference];
|
|
2305
1960
|
i--;
|
|
2306
1961
|
}
|
|
2307
1962
|
for (let i2 = 0; i2 < difference; i2++) {
|
|
2308
|
-
this.
|
|
2309
|
-
this.
|
|
2310
|
-
() => this.
|
|
2311
|
-
null
|
|
1963
|
+
this.d[i2] = runWithOwner(
|
|
1964
|
+
this.a[i2] = createOwner(),
|
|
1965
|
+
() => this.M(i2 + from)
|
|
2312
1966
|
);
|
|
2313
1967
|
}
|
|
2314
1968
|
}
|
|
2315
1969
|
for (let i = prevTo; i < to; i++) {
|
|
2316
|
-
this.
|
|
2317
|
-
this.
|
|
2318
|
-
() => this.
|
|
2319
|
-
null
|
|
1970
|
+
this.d[i - from] = runWithOwner(
|
|
1971
|
+
this.a[i - from] = createOwner(),
|
|
1972
|
+
() => this.M(i)
|
|
2320
1973
|
);
|
|
2321
1974
|
}
|
|
2322
|
-
this.
|
|
2323
|
-
this.
|
|
2324
|
-
this.
|
|
1975
|
+
this.d = this.d.slice(0, newLen);
|
|
1976
|
+
this.w = from;
|
|
1977
|
+
this.k = newLen;
|
|
2325
1978
|
});
|
|
2326
|
-
return this.
|
|
1979
|
+
return this.d;
|
|
2327
1980
|
}
|
|
2328
1981
|
function compare(key, a, b) {
|
|
2329
1982
|
return key ? key(a) === key(b) : true;
|
|
2330
1983
|
}
|
|
2331
1984
|
|
|
2332
1985
|
// src/boundaries.ts
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
1986
|
+
function boundaryComputed(fn, propagationMask) {
|
|
1987
|
+
const node = computed(fn, void 0, {
|
|
1988
|
+
ja: {
|
|
1989
|
+
ma() {
|
|
1990
|
+
let flags = this.f;
|
|
1991
|
+
this.f &= ~this.Z;
|
|
1992
|
+
if (this.Z & 1 /* Pending */ && !(this.f & 4 /* Uninitialized */)) {
|
|
1993
|
+
flags &= ~1 /* Pending */;
|
|
1994
|
+
}
|
|
1995
|
+
this.i.notify(this, this.Z, flags);
|
|
1996
|
+
},
|
|
1997
|
+
Z: propagationMask
|
|
2343
1998
|
}
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
}
|
|
1999
|
+
});
|
|
2000
|
+
node.Z = propagationMask;
|
|
2001
|
+
return node;
|
|
2002
|
+
}
|
|
2348
2003
|
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
|
-
);
|
|
2004
|
+
const parentQueue = owner.i;
|
|
2005
|
+
parentQueue.addChild(owner.i = queue);
|
|
2006
|
+
onCleanup(() => parentQueue.removeChild(owner.i));
|
|
2007
|
+
return runWithOwner(owner, () => {
|
|
2008
|
+
const c = computed(fn);
|
|
2009
|
+
return boundaryComputed(() => staleValues(() => flatten(read(c))), mask);
|
|
2010
|
+
});
|
|
2360
2011
|
}
|
|
2361
2012
|
var ConditionalQueue = class extends Queue {
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2013
|
+
t;
|
|
2014
|
+
ga = /* @__PURE__ */ new Set();
|
|
2015
|
+
h = /* @__PURE__ */ new Set();
|
|
2365
2016
|
constructor(disabled) {
|
|
2366
2017
|
super();
|
|
2367
|
-
this.
|
|
2018
|
+
this.t = disabled;
|
|
2368
2019
|
}
|
|
2369
2020
|
run(type) {
|
|
2370
|
-
if (!type || this.
|
|
2021
|
+
if (!type || read(this.t))
|
|
2371
2022
|
return;
|
|
2372
2023
|
return super.run(type);
|
|
2373
2024
|
}
|
|
2374
2025
|
notify(node, type, flags) {
|
|
2375
|
-
if (this.
|
|
2376
|
-
if (type &
|
|
2377
|
-
if (flags &
|
|
2378
|
-
this.
|
|
2379
|
-
type &= ~
|
|
2380
|
-
} else if (this.
|
|
2381
|
-
type &= ~
|
|
2026
|
+
if (read(this.t)) {
|
|
2027
|
+
if (type & 1 /* Pending */) {
|
|
2028
|
+
if (flags & 1 /* Pending */) {
|
|
2029
|
+
this.h.add(node);
|
|
2030
|
+
type &= ~1 /* Pending */;
|
|
2031
|
+
} else if (this.h.delete(node))
|
|
2032
|
+
type &= ~1 /* Pending */;
|
|
2382
2033
|
}
|
|
2383
|
-
if (type &
|
|
2384
|
-
if (flags &
|
|
2385
|
-
this.
|
|
2386
|
-
type &= ~
|
|
2387
|
-
} else if (this.
|
|
2388
|
-
type &= ~
|
|
2034
|
+
if (type & 2 /* Error */) {
|
|
2035
|
+
if (flags & 2 /* Error */) {
|
|
2036
|
+
this.ga.add(node);
|
|
2037
|
+
type &= ~2 /* Error */;
|
|
2038
|
+
} else if (this.ga.delete(node))
|
|
2039
|
+
type &= ~2 /* Error */;
|
|
2389
2040
|
}
|
|
2390
2041
|
}
|
|
2391
2042
|
return type ? super.notify(node, type, flags) : true;
|
|
2392
2043
|
}
|
|
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
2044
|
};
|
|
2399
2045
|
var CollectionQueue = class extends Queue {
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2046
|
+
O;
|
|
2047
|
+
a = /* @__PURE__ */ new Set();
|
|
2048
|
+
t = signal(false, { pureWrite: true });
|
|
2049
|
+
ka = false;
|
|
2403
2050
|
constructor(type) {
|
|
2404
2051
|
super();
|
|
2405
|
-
this.
|
|
2052
|
+
this.O = type;
|
|
2406
2053
|
}
|
|
2407
2054
|
run(type) {
|
|
2408
|
-
if (!type || this.
|
|
2055
|
+
if (!type || read(this.t))
|
|
2409
2056
|
return;
|
|
2410
2057
|
return super.run(type);
|
|
2411
2058
|
}
|
|
2059
|
+
enqueue(type, fn) {
|
|
2060
|
+
var _a;
|
|
2061
|
+
if (this.O & 1 /* Pending */ && this.ka) {
|
|
2062
|
+
return (_a = this.q) == null ? void 0 : _a.enqueue(type, fn);
|
|
2063
|
+
}
|
|
2064
|
+
return super.enqueue(type, fn);
|
|
2065
|
+
}
|
|
2412
2066
|
notify(node, type, flags) {
|
|
2413
|
-
if (!(type & this.
|
|
2067
|
+
if (!(type & this.O) || this.O & 1 /* Pending */ && this.ka)
|
|
2414
2068
|
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.
|
|
2069
|
+
if (flags & this.O) {
|
|
2070
|
+
this.a.add(node);
|
|
2071
|
+
if (this.a.size === 1)
|
|
2072
|
+
setSignal(this.t, true);
|
|
2073
|
+
} else if (this.a.size > 0) {
|
|
2074
|
+
this.a.delete(node);
|
|
2075
|
+
if (this.a.size === 0)
|
|
2076
|
+
setSignal(this.t, false);
|
|
2077
|
+
}
|
|
2078
|
+
type &= ~this.O;
|
|
2425
2079
|
return type ? super.notify(node, type, flags) : true;
|
|
2426
2080
|
}
|
|
2427
|
-
merge(queue) {
|
|
2428
|
-
queue.e.forEach((n) => this.notify(n, this.L, this.L));
|
|
2429
|
-
super.merge(queue);
|
|
2430
|
-
}
|
|
2431
2081
|
};
|
|
2432
2082
|
function createBoundary(fn, condition) {
|
|
2433
|
-
const owner =
|
|
2434
|
-
const queue = new ConditionalQueue(
|
|
2435
|
-
new Computation(void 0, () => condition() === "hidden" /* HIDDEN */)
|
|
2436
|
-
);
|
|
2083
|
+
const owner = createOwner();
|
|
2084
|
+
const queue = new ConditionalQueue(computed(() => condition() === "hidden" /* HIDDEN */));
|
|
2437
2085
|
const tree = createBoundChildren(owner, fn, queue, 0);
|
|
2438
|
-
|
|
2439
|
-
const disabled = queue.
|
|
2440
|
-
tree.
|
|
2086
|
+
computed(() => {
|
|
2087
|
+
const disabled = read(queue.t);
|
|
2088
|
+
tree.Z = disabled ? 2 /* Error */ | 1 /* Pending */ : 0;
|
|
2441
2089
|
if (!disabled) {
|
|
2442
|
-
queue.
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
queue.
|
|
2090
|
+
queue.h.forEach(
|
|
2091
|
+
(node) => queue.notify(node, 1 /* Pending */, 1 /* Pending */)
|
|
2092
|
+
);
|
|
2093
|
+
queue.ga.forEach((node) => queue.notify(node, 2 /* Error */, 2 /* Error */));
|
|
2094
|
+
queue.h.clear();
|
|
2095
|
+
queue.ga.clear();
|
|
2446
2096
|
}
|
|
2447
2097
|
});
|
|
2448
|
-
return () => queue.
|
|
2098
|
+
return () => read(queue.t) ? void 0 : read(tree);
|
|
2449
2099
|
}
|
|
2450
2100
|
function createCollectionBoundary(type, fn, fallback) {
|
|
2451
|
-
const owner =
|
|
2101
|
+
const owner = createOwner();
|
|
2452
2102
|
const queue = new CollectionQueue(type);
|
|
2453
2103
|
const tree = createBoundChildren(owner, fn, queue, type);
|
|
2454
|
-
const decision =
|
|
2455
|
-
if (!queue.
|
|
2456
|
-
const resolved =
|
|
2457
|
-
if (!untrack(() => queue.
|
|
2458
|
-
|
|
2104
|
+
const decision = computed(() => {
|
|
2105
|
+
if (!read(queue.t)) {
|
|
2106
|
+
const resolved = read(tree);
|
|
2107
|
+
if (!untrack(() => read(queue.t)))
|
|
2108
|
+
queue.ka = true;
|
|
2109
|
+
return resolved;
|
|
2459
2110
|
}
|
|
2460
2111
|
return fallback(queue);
|
|
2461
2112
|
});
|
|
2462
|
-
return
|
|
2113
|
+
return read.bind(null, decision);
|
|
2463
2114
|
}
|
|
2464
|
-
function
|
|
2465
|
-
return createCollectionBoundary(
|
|
2115
|
+
function createLoadBoundary(fn, fallback) {
|
|
2116
|
+
return createCollectionBoundary(1 /* Pending */, fn, () => fallback());
|
|
2466
2117
|
}
|
|
2467
2118
|
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));
|
|
2119
|
+
return createCollectionBoundary(2 /* Error */, fn, (queue) => {
|
|
2120
|
+
let node = queue.a.values().next().value;
|
|
2121
|
+
return fallback(node.B, () => {
|
|
2122
|
+
for (let node2 of queue.a) {
|
|
2123
|
+
recompute(node2, true);
|
|
2477
2124
|
}
|
|
2478
2125
|
});
|
|
2479
2126
|
});
|
|
@@ -2536,18 +2183,16 @@ function flattenArray(children, results = [], options) {
|
|
|
2536
2183
|
exports.$PROXY = $PROXY;
|
|
2537
2184
|
exports.$TARGET = $TARGET;
|
|
2538
2185
|
exports.$TRACK = $TRACK;
|
|
2539
|
-
exports.Computation = Computation;
|
|
2540
2186
|
exports.ContextNotFoundError = ContextNotFoundError;
|
|
2541
2187
|
exports.NoOwnerError = NoOwnerError;
|
|
2542
2188
|
exports.NotReadyError = NotReadyError;
|
|
2543
|
-
exports.Owner = Owner;
|
|
2544
|
-
exports.Queue = Queue;
|
|
2545
2189
|
exports.SUPPORTS_PROXY = SUPPORTS_PROXY;
|
|
2546
2190
|
exports.createAsync = createAsync;
|
|
2547
2191
|
exports.createBoundary = createBoundary;
|
|
2548
2192
|
exports.createContext = createContext;
|
|
2549
2193
|
exports.createEffect = createEffect;
|
|
2550
2194
|
exports.createErrorBoundary = createErrorBoundary;
|
|
2195
|
+
exports.createLoadBoundary = createLoadBoundary;
|
|
2551
2196
|
exports.createMemo = createMemo;
|
|
2552
2197
|
exports.createOptimistic = createOptimistic;
|
|
2553
2198
|
exports.createOptimisticStore = createOptimisticStore;
|
|
@@ -2557,30 +2202,27 @@ exports.createRenderEffect = createRenderEffect;
|
|
|
2557
2202
|
exports.createRoot = createRoot;
|
|
2558
2203
|
exports.createSignal = createSignal;
|
|
2559
2204
|
exports.createStore = createStore;
|
|
2560
|
-
exports.createSuspense = createSuspense;
|
|
2561
2205
|
exports.createTrackedEffect = createTrackedEffect;
|
|
2562
2206
|
exports.deep = deep;
|
|
2563
2207
|
exports.flatten = flatten;
|
|
2564
2208
|
exports.flush = flush;
|
|
2565
2209
|
exports.getContext = getContext;
|
|
2210
|
+
exports.getNextChildId = getNextChildId;
|
|
2566
2211
|
exports.getObserver = getObserver;
|
|
2567
2212
|
exports.getOwner = getOwner;
|
|
2568
|
-
exports.hasContext = hasContext;
|
|
2569
|
-
exports.hasUpdated = hasUpdated;
|
|
2570
2213
|
exports.isEqual = isEqual;
|
|
2571
2214
|
exports.isPending = isPending;
|
|
2572
2215
|
exports.isWrappable = isWrappable;
|
|
2573
|
-
exports.latest = latest;
|
|
2574
2216
|
exports.mapArray = mapArray;
|
|
2575
2217
|
exports.merge = merge;
|
|
2576
2218
|
exports.omit = omit;
|
|
2577
2219
|
exports.onCleanup = onCleanup;
|
|
2220
|
+
exports.onSettled = onSettled;
|
|
2221
|
+
exports.pending = pending;
|
|
2578
2222
|
exports.reconcile = reconcile;
|
|
2579
2223
|
exports.repeat = repeat;
|
|
2580
2224
|
exports.resolve = resolve;
|
|
2581
2225
|
exports.runWithOwner = runWithOwner;
|
|
2582
2226
|
exports.setContext = setContext;
|
|
2583
2227
|
exports.snapshot = snapshot;
|
|
2584
|
-
exports.transition = transition;
|
|
2585
2228
|
exports.untrack = untrack;
|
|
2586
|
-
exports.useTransition = useTransition;
|