@solidjs/signals 0.8.2 → 0.8.4
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 +808 -819
- package/dist/node.cjs +1622 -1820
- package/dist/prod.js +1645 -1757
- package/dist/types/boundaries.d.ts +1 -1
- package/dist/types/core/constants.d.ts +16 -21
- package/dist/types/core/core.d.ts +7 -4
- package/dist/types/core/effect.d.ts +0 -1
- package/dist/types/core/heap.d.ts +1 -2
- package/dist/types/core/index.d.ts +1 -1
- package/dist/types/core/scheduler.d.ts +3 -4
- package/dist/types/signals.d.ts +1 -1
- package/dist/types/store/store.d.ts +3 -2
- package/package.json +8 -3
package/dist/prod.js
CHANGED
|
@@ -1,716 +1,641 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
constructor(
|
|
1
|
+
class NotReadyError extends Error {
|
|
2
|
+
cause;
|
|
3
|
+
constructor(e) {
|
|
4
4
|
super();
|
|
5
|
-
this.cause =
|
|
5
|
+
this.cause = e;
|
|
6
6
|
}
|
|
7
|
-
}
|
|
8
|
-
|
|
7
|
+
}
|
|
8
|
+
class NoOwnerError extends Error {
|
|
9
9
|
constructor() {
|
|
10
10
|
super("");
|
|
11
11
|
}
|
|
12
|
-
};
|
|
13
|
-
var ContextNotFoundError = class extends Error {
|
|
14
|
-
constructor() {
|
|
15
|
-
super(
|
|
16
|
-
""
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
// src/core/constants.ts
|
|
22
|
-
var NOT_PENDING = {};
|
|
23
|
-
var SUPPORTS_PROXY = typeof Proxy === "function";
|
|
24
|
-
|
|
25
|
-
// src/core/heap.ts
|
|
26
|
-
function actualInsertIntoHeap(n, heap) {
|
|
27
|
-
const parentHeight = (n.w?._ ? n.w.$?.c : n.w?.c) ?? -1;
|
|
28
|
-
if (parentHeight >= n.c)
|
|
29
|
-
n.c = parentHeight + 1;
|
|
30
|
-
const height = n.c;
|
|
31
|
-
const heapAtHeight = heap.r[height];
|
|
32
|
-
if (heapAtHeight === void 0) {
|
|
33
|
-
heap.r[height] = n;
|
|
34
|
-
} else {
|
|
35
|
-
const tail = heapAtHeight.z;
|
|
36
|
-
tail.Q = n;
|
|
37
|
-
n.z = tail;
|
|
38
|
-
heapAtHeight.z = n;
|
|
39
|
-
}
|
|
40
|
-
if (height > heap.L) {
|
|
41
|
-
heap.L = height;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
function insertIntoHeap(n, heap) {
|
|
45
|
-
let flags = n.b;
|
|
46
|
-
if (flags & (8 /* InHeap */ | 4 /* RecomputingDeps */))
|
|
47
|
-
return;
|
|
48
|
-
if (flags & 1 /* Check */) {
|
|
49
|
-
n.b = flags & ~(1 /* Check */ | 2 /* Dirty */) | 2 /* Dirty */ | 8 /* InHeap */;
|
|
50
|
-
} else
|
|
51
|
-
n.b = flags | 8 /* InHeap */;
|
|
52
|
-
if (!(flags & 16 /* InHeapHeight */)) {
|
|
53
|
-
actualInsertIntoHeap(n, heap);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
function insertIntoHeapHeight(n, heap) {
|
|
57
|
-
let flags = n.b;
|
|
58
|
-
if (flags & (8 /* InHeap */ | 4 /* RecomputingDeps */ | 16 /* InHeapHeight */))
|
|
59
|
-
return;
|
|
60
|
-
n.b = flags | 16 /* InHeapHeight */;
|
|
61
|
-
actualInsertIntoHeap(n, heap);
|
|
62
|
-
}
|
|
63
|
-
function deleteFromHeap(n, heap) {
|
|
64
|
-
const flags = n.b;
|
|
65
|
-
if (!(flags & (8 /* InHeap */ | 16 /* InHeapHeight */)))
|
|
66
|
-
return;
|
|
67
|
-
n.b = flags & ~(8 /* InHeap */ | 16 /* InHeapHeight */);
|
|
68
|
-
const height = n.c;
|
|
69
|
-
if (n.z === n) {
|
|
70
|
-
heap.r[height] = void 0;
|
|
71
|
-
} else {
|
|
72
|
-
const next = n.Q;
|
|
73
|
-
const dhh = heap.r[height];
|
|
74
|
-
const end = next ?? dhh;
|
|
75
|
-
if (n === dhh) {
|
|
76
|
-
heap.r[height] = next;
|
|
77
|
-
} else {
|
|
78
|
-
n.z.Q = next;
|
|
79
|
-
}
|
|
80
|
-
end.z = n.z;
|
|
81
|
-
}
|
|
82
|
-
n.z = n;
|
|
83
|
-
n.Q = void 0;
|
|
84
12
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
heap.aa = true;
|
|
89
|
-
for (let i = 0; i <= heap.L; i++) {
|
|
90
|
-
for (let el = heap.r[i]; el !== void 0; el = el.Q) {
|
|
91
|
-
if (el.b & 8 /* InHeap */)
|
|
92
|
-
markNode(el);
|
|
93
|
-
}
|
|
13
|
+
class ContextNotFoundError extends Error {
|
|
14
|
+
constructor() {
|
|
15
|
+
super("");
|
|
94
16
|
}
|
|
95
17
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
18
|
+
const REACTIVE_NONE = 0;
|
|
19
|
+
const REACTIVE_CHECK = 1 << 0;
|
|
20
|
+
const REACTIVE_DIRTY = 1 << 1;
|
|
21
|
+
const REACTIVE_RECOMPUTING_DEPS = 1 << 2;
|
|
22
|
+
const REACTIVE_IN_HEAP = 1 << 3;
|
|
23
|
+
const REACTIVE_IN_HEAP_HEIGHT = 1 << 4;
|
|
24
|
+
const REACTIVE_ZOMBIE = 1 << 5;
|
|
25
|
+
const REACTIVE_DISPOSED = 1 << 6;
|
|
26
|
+
const STATUS_NONE = 0;
|
|
27
|
+
const STATUS_PENDING = 1 << 0;
|
|
28
|
+
const STATUS_ERROR = 1 << 1;
|
|
29
|
+
const STATUS_UNINITIALIZED = 1 << 2;
|
|
30
|
+
const EFFECT_RENDER = 1;
|
|
31
|
+
const EFFECT_USER = 2;
|
|
32
|
+
const NOT_PENDING = {};
|
|
33
|
+
const SUPPORTS_PROXY = typeof Proxy === "function";
|
|
34
|
+
const defaultContext = {};
|
|
35
|
+
function actualInsertIntoHeap(e, t) {
|
|
36
|
+
const n = (e.i?.t ? e.i.u?.o : e.i?.o) ?? -1;
|
|
37
|
+
if (n >= e.o) e.o = n + 1;
|
|
38
|
+
const i = e.o;
|
|
39
|
+
const r = t.l[i];
|
|
40
|
+
if (r === undefined) t.l[i] = e;
|
|
41
|
+
else {
|
|
42
|
+
const t = r.T;
|
|
43
|
+
t.R = e;
|
|
44
|
+
e.T = t;
|
|
45
|
+
r.T = e;
|
|
46
|
+
}
|
|
47
|
+
if (i > t.h) t.h = i;
|
|
48
|
+
}
|
|
49
|
+
function insertIntoHeap(e, t) {
|
|
50
|
+
let n = e._;
|
|
51
|
+
if (n & (REACTIVE_IN_HEAP | REACTIVE_RECOMPUTING_DEPS)) return;
|
|
52
|
+
if (n & REACTIVE_CHECK) {
|
|
53
|
+
e._ = (n & -4) | REACTIVE_DIRTY | REACTIVE_IN_HEAP;
|
|
54
|
+
} else e._ = n | REACTIVE_IN_HEAP;
|
|
55
|
+
if (!(n & REACTIVE_IN_HEAP_HEIGHT)) actualInsertIntoHeap(e, t);
|
|
56
|
+
}
|
|
57
|
+
function insertIntoHeapHeight(e, t) {
|
|
58
|
+
let n = e._;
|
|
59
|
+
if (n & (REACTIVE_IN_HEAP | REACTIVE_RECOMPUTING_DEPS | REACTIVE_IN_HEAP_HEIGHT)) return;
|
|
60
|
+
e._ = n | REACTIVE_IN_HEAP_HEIGHT;
|
|
61
|
+
actualInsertIntoHeap(e, t);
|
|
62
|
+
}
|
|
63
|
+
function deleteFromHeap(e, t) {
|
|
64
|
+
const n = e._;
|
|
65
|
+
if (!(n & (REACTIVE_IN_HEAP | REACTIVE_IN_HEAP_HEIGHT))) return;
|
|
66
|
+
e._ = n & -25;
|
|
67
|
+
const i = e.o;
|
|
68
|
+
if (e.T === e) t.l[i] = undefined;
|
|
69
|
+
else {
|
|
70
|
+
const n = e.R;
|
|
71
|
+
const r = t.l[i];
|
|
72
|
+
const s = n ?? r;
|
|
73
|
+
if (e === r) t.l[i] = n;
|
|
74
|
+
else e.T.R = n;
|
|
75
|
+
s.T = e.T;
|
|
76
|
+
}
|
|
77
|
+
e.T = e;
|
|
78
|
+
e.R = undefined;
|
|
79
|
+
}
|
|
80
|
+
function markHeap(e) {
|
|
81
|
+
if (e.S) return;
|
|
82
|
+
e.S = true;
|
|
83
|
+
for (let t = 0; t <= e.h; t++) {
|
|
84
|
+
for (let n = e.l[t]; n !== undefined; n = n.R) {
|
|
85
|
+
if (n._ & REACTIVE_IN_HEAP) markNode(n);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function markNode(e, t = REACTIVE_DIRTY) {
|
|
90
|
+
const n = e._;
|
|
91
|
+
if ((n & (REACTIVE_CHECK | REACTIVE_DIRTY)) >= t) return;
|
|
92
|
+
e._ = (n & -4) | t;
|
|
93
|
+
for (let t = e.O; t !== null; t = t.p) {
|
|
94
|
+
markNode(t.A, REACTIVE_CHECK);
|
|
95
|
+
}
|
|
96
|
+
if (e.N !== null) {
|
|
97
|
+
for (let t = e.N; t !== null; t = t.I) {
|
|
98
|
+
for (let e = t.O; e !== null; e = e.p) {
|
|
99
|
+
markNode(e.A, REACTIVE_CHECK);
|
|
108
100
|
}
|
|
109
101
|
}
|
|
110
102
|
}
|
|
111
103
|
}
|
|
112
|
-
function runHeap(
|
|
113
|
-
|
|
114
|
-
for (
|
|
115
|
-
let
|
|
116
|
-
while (
|
|
117
|
-
if (
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
adjustHeight(el, heap);
|
|
121
|
-
}
|
|
122
|
-
el = heap.r[heap.p];
|
|
104
|
+
function runHeap(e, t) {
|
|
105
|
+
e.S = false;
|
|
106
|
+
for (e.C = 0; e.C <= e.h; e.C++) {
|
|
107
|
+
let n = e.l[e.C];
|
|
108
|
+
while (n !== undefined) {
|
|
109
|
+
if (n._ & REACTIVE_IN_HEAP) t(n);
|
|
110
|
+
else adjustHeight(n, e);
|
|
111
|
+
n = e.l[e.C];
|
|
123
112
|
}
|
|
124
113
|
}
|
|
125
|
-
|
|
114
|
+
e.h = 0;
|
|
126
115
|
}
|
|
127
|
-
function adjustHeight(
|
|
128
|
-
deleteFromHeap(
|
|
129
|
-
let
|
|
130
|
-
for (let
|
|
131
|
-
const
|
|
132
|
-
const
|
|
133
|
-
if (
|
|
134
|
-
if (dep.c >= newHeight) {
|
|
135
|
-
newHeight = dep.c + 1;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
116
|
+
function adjustHeight(e, t) {
|
|
117
|
+
deleteFromHeap(e, t);
|
|
118
|
+
let n = e.o;
|
|
119
|
+
for (let t = e.D; t; t = t.P) {
|
|
120
|
+
const e = t.V;
|
|
121
|
+
const i = e.U || e;
|
|
122
|
+
if (i.m && i.o >= n) n = i.o + 1;
|
|
138
123
|
}
|
|
139
|
-
if (
|
|
140
|
-
|
|
141
|
-
for (let
|
|
142
|
-
insertIntoHeapHeight(
|
|
124
|
+
if (e.o !== n) {
|
|
125
|
+
e.o = n;
|
|
126
|
+
for (let n = e.O; n !== null; n = n.p) {
|
|
127
|
+
insertIntoHeapHeight(n.A, t);
|
|
143
128
|
}
|
|
144
129
|
}
|
|
145
130
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
var scheduled = false;
|
|
131
|
+
const transitions = new Set();
|
|
132
|
+
const dirtyQueue = { l: new Array(2e3).fill(undefined), S: false, C: 0, h: 0 };
|
|
133
|
+
const zombieQueue = { l: new Array(2e3).fill(undefined), S: false, C: 0, h: 0 };
|
|
134
|
+
let clock = 0;
|
|
135
|
+
let activeTransition = null;
|
|
136
|
+
let scheduled = false;
|
|
153
137
|
function schedule() {
|
|
154
|
-
if (scheduled)
|
|
155
|
-
return;
|
|
138
|
+
if (scheduled) return;
|
|
156
139
|
scheduled = true;
|
|
157
|
-
if (!globalQueue.
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
p: 0,
|
|
164
|
-
L: 0
|
|
165
|
-
};
|
|
166
|
-
var zombieQueue = {
|
|
167
|
-
r: new Array(2e3).fill(void 0),
|
|
168
|
-
aa: false,
|
|
169
|
-
p: 0,
|
|
170
|
-
L: 0
|
|
171
|
-
};
|
|
172
|
-
var Queue = class {
|
|
173
|
-
w = null;
|
|
174
|
-
k = [[], []];
|
|
175
|
-
l = [];
|
|
140
|
+
if (!globalQueue.k) queueMicrotask(flush);
|
|
141
|
+
}
|
|
142
|
+
class Queue {
|
|
143
|
+
i = null;
|
|
144
|
+
G = [[], []];
|
|
145
|
+
H = [];
|
|
176
146
|
created = clock;
|
|
177
|
-
addChild(
|
|
178
|
-
this.
|
|
179
|
-
|
|
147
|
+
addChild(e) {
|
|
148
|
+
this.H.push(e);
|
|
149
|
+
e.i = this;
|
|
180
150
|
}
|
|
181
|
-
removeChild(
|
|
182
|
-
const
|
|
183
|
-
if (
|
|
184
|
-
this.
|
|
185
|
-
|
|
151
|
+
removeChild(e) {
|
|
152
|
+
const t = this.H.indexOf(e);
|
|
153
|
+
if (t >= 0) {
|
|
154
|
+
this.H.splice(t, 1);
|
|
155
|
+
e.i = null;
|
|
186
156
|
}
|
|
187
157
|
}
|
|
188
|
-
notify(
|
|
189
|
-
if (this.
|
|
190
|
-
return this.w.notify(node, mask, flags);
|
|
158
|
+
notify(e, t, n) {
|
|
159
|
+
if (this.i) return this.i.notify(e, t, n);
|
|
191
160
|
return false;
|
|
192
161
|
}
|
|
193
|
-
run(
|
|
194
|
-
if (this.
|
|
195
|
-
const
|
|
196
|
-
this.
|
|
197
|
-
runQueue(
|
|
162
|
+
run(e) {
|
|
163
|
+
if (this.G[e - 1].length) {
|
|
164
|
+
const t = this.G[e - 1];
|
|
165
|
+
this.G[e - 1] = [];
|
|
166
|
+
runQueue(t, e);
|
|
198
167
|
}
|
|
199
|
-
for (let
|
|
200
|
-
this.
|
|
168
|
+
for (let t = 0; t < this.H.length; t++) {
|
|
169
|
+
this.H[t].run(e);
|
|
201
170
|
}
|
|
202
171
|
}
|
|
203
|
-
enqueue(
|
|
204
|
-
if (
|
|
205
|
-
this.k[type - 1].push(fn);
|
|
172
|
+
enqueue(e, t) {
|
|
173
|
+
if (e) this.G[e - 1].push(t);
|
|
206
174
|
schedule();
|
|
207
175
|
}
|
|
208
|
-
stashQueues(
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
this.
|
|
212
|
-
for (let
|
|
213
|
-
let
|
|
214
|
-
let
|
|
215
|
-
if (!
|
|
216
|
-
|
|
217
|
-
|
|
176
|
+
stashQueues(e) {
|
|
177
|
+
e.G[0].push(...this.G[0]);
|
|
178
|
+
e.G[1].push(...this.G[1]);
|
|
179
|
+
this.G = [[], []];
|
|
180
|
+
for (let t = 0; t < this.H.length; t++) {
|
|
181
|
+
let n = this.H[t];
|
|
182
|
+
let i = e.H[t];
|
|
183
|
+
if (!i) {
|
|
184
|
+
i = { G: [[], []], H: [] };
|
|
185
|
+
e.H[t] = i;
|
|
218
186
|
}
|
|
219
|
-
|
|
187
|
+
n.stashQueues(i);
|
|
220
188
|
}
|
|
221
189
|
}
|
|
222
|
-
restoreQueues(
|
|
223
|
-
this.
|
|
224
|
-
this.
|
|
225
|
-
for (let
|
|
226
|
-
const
|
|
227
|
-
let
|
|
228
|
-
if (
|
|
229
|
-
child.restoreQueues(childStub);
|
|
190
|
+
restoreQueues(e) {
|
|
191
|
+
this.G[0].push(...e.G[0]);
|
|
192
|
+
this.G[1].push(...e.G[1]);
|
|
193
|
+
for (let t = 0; t < e.H.length; t++) {
|
|
194
|
+
const n = e.H[t];
|
|
195
|
+
let i = this.H[t];
|
|
196
|
+
if (i) i.restoreQueues(n);
|
|
230
197
|
}
|
|
231
198
|
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
static
|
|
237
|
-
static
|
|
199
|
+
}
|
|
200
|
+
class GlobalQueue extends Queue {
|
|
201
|
+
k = false;
|
|
202
|
+
$ = [];
|
|
203
|
+
static L;
|
|
204
|
+
static F;
|
|
238
205
|
flush() {
|
|
239
|
-
if (this.
|
|
240
|
-
|
|
241
|
-
this.ca = true;
|
|
206
|
+
if (this.k) return;
|
|
207
|
+
this.k = true;
|
|
242
208
|
try {
|
|
243
|
-
runHeap(dirtyQueue,
|
|
209
|
+
runHeap(dirtyQueue, GlobalQueue.L);
|
|
244
210
|
if (activeTransition) {
|
|
245
211
|
if (!transitionComplete(activeTransition)) {
|
|
246
|
-
runHeap(zombieQueue,
|
|
247
|
-
|
|
248
|
-
|
|
212
|
+
runHeap(zombieQueue, GlobalQueue.L);
|
|
213
|
+
this.$ = [];
|
|
214
|
+
this.stashQueues(activeTransition.queueStash);
|
|
249
215
|
clock++;
|
|
250
216
|
scheduled = false;
|
|
251
217
|
runPending(activeTransition.pendingNodes, true);
|
|
252
218
|
activeTransition = null;
|
|
253
219
|
return;
|
|
254
220
|
}
|
|
255
|
-
|
|
256
|
-
|
|
221
|
+
this.$.push(...activeTransition.pendingNodes);
|
|
222
|
+
this.restoreQueues(activeTransition.queueStash);
|
|
257
223
|
transitions.delete(activeTransition);
|
|
258
224
|
activeTransition = null;
|
|
259
|
-
if (runPending(
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
n.e = NOT_PENDING;
|
|
225
|
+
if (runPending(this.$, false)) runHeap(dirtyQueue, GlobalQueue.L);
|
|
226
|
+
} else if (transitions.size) runHeap(zombieQueue, GlobalQueue.L);
|
|
227
|
+
for (let e = 0; e < this.$.length; e++) {
|
|
228
|
+
const t = this.$[e];
|
|
229
|
+
if (t.W !== NOT_PENDING) {
|
|
230
|
+
t.j = t.W;
|
|
231
|
+
t.W = NOT_PENDING;
|
|
232
|
+
if (t.K) t.M = true;
|
|
268
233
|
}
|
|
269
|
-
if (
|
|
270
|
-
_GlobalQueue.ka(n, false, true);
|
|
234
|
+
if (t.m) GlobalQueue.F(t, false, true);
|
|
271
235
|
}
|
|
272
|
-
|
|
236
|
+
this.$.length = 0;
|
|
273
237
|
clock++;
|
|
274
238
|
scheduled = false;
|
|
275
|
-
this.run(
|
|
276
|
-
this.run(
|
|
239
|
+
this.run(EFFECT_RENDER);
|
|
240
|
+
this.run(EFFECT_USER);
|
|
277
241
|
} finally {
|
|
278
|
-
this.
|
|
279
|
-
unobserved.length && notifyUnobserved();
|
|
242
|
+
this.k = false;
|
|
280
243
|
}
|
|
281
244
|
}
|
|
282
|
-
notify(
|
|
283
|
-
if (
|
|
284
|
-
if (
|
|
285
|
-
if (activeTransition && !activeTransition.asyncNodes.includes(
|
|
286
|
-
activeTransition.asyncNodes.push(
|
|
245
|
+
notify(e, t, n) {
|
|
246
|
+
if (t & STATUS_PENDING) {
|
|
247
|
+
if (n & STATUS_PENDING) {
|
|
248
|
+
if (activeTransition && !activeTransition.asyncNodes.includes(e.Y.cause))
|
|
249
|
+
activeTransition.asyncNodes.push(e.Y.cause);
|
|
287
250
|
}
|
|
288
251
|
return true;
|
|
289
252
|
}
|
|
290
253
|
return false;
|
|
291
254
|
}
|
|
292
|
-
initTransition(
|
|
293
|
-
if (activeTransition && activeTransition.time === clock)
|
|
294
|
-
return;
|
|
255
|
+
initTransition(e) {
|
|
256
|
+
if (activeTransition && activeTransition.time === clock) return;
|
|
295
257
|
if (!activeTransition) {
|
|
296
|
-
activeTransition =
|
|
258
|
+
activeTransition = e.B ?? {
|
|
297
259
|
time: clock,
|
|
298
260
|
pendingNodes: [],
|
|
299
261
|
asyncNodes: [],
|
|
300
|
-
queueStash: {
|
|
262
|
+
queueStash: { G: [[], []], H: [] }
|
|
301
263
|
};
|
|
302
264
|
}
|
|
303
265
|
transitions.add(activeTransition);
|
|
304
266
|
activeTransition.time = clock;
|
|
305
|
-
for (let
|
|
306
|
-
const
|
|
307
|
-
|
|
308
|
-
activeTransition.pendingNodes.push(
|
|
267
|
+
for (let e = 0; e < this.$.length; e++) {
|
|
268
|
+
const t = this.$[e];
|
|
269
|
+
t.B = activeTransition;
|
|
270
|
+
activeTransition.pendingNodes.push(t);
|
|
309
271
|
}
|
|
310
|
-
|
|
272
|
+
this.$ = activeTransition.pendingNodes;
|
|
311
273
|
}
|
|
312
|
-
}
|
|
313
|
-
function runPending(
|
|
314
|
-
let
|
|
315
|
-
const
|
|
316
|
-
for (let
|
|
317
|
-
const
|
|
318
|
-
|
|
319
|
-
if (
|
|
320
|
-
|
|
321
|
-
|
|
274
|
+
}
|
|
275
|
+
function runPending(e, t) {
|
|
276
|
+
let n = false;
|
|
277
|
+
const i = e.slice();
|
|
278
|
+
for (let e = 0; e < i.length; e++) {
|
|
279
|
+
const r = i[e];
|
|
280
|
+
r.B = activeTransition;
|
|
281
|
+
if (r.X) {
|
|
282
|
+
r.X.q(t);
|
|
283
|
+
n = true;
|
|
284
|
+
}
|
|
285
|
+
if (r.Z && r.Z.W !== NOT_PENDING) {
|
|
286
|
+
r.Z.q(r.Z.W);
|
|
287
|
+
r.Z.W = NOT_PENDING;
|
|
288
|
+
n = true;
|
|
322
289
|
}
|
|
323
290
|
}
|
|
324
|
-
return
|
|
291
|
+
return n;
|
|
325
292
|
}
|
|
326
|
-
|
|
293
|
+
const globalQueue = new GlobalQueue();
|
|
327
294
|
function flush() {
|
|
328
295
|
while (scheduled) {
|
|
329
296
|
globalQueue.flush();
|
|
330
297
|
}
|
|
331
298
|
}
|
|
332
|
-
function runQueue(
|
|
333
|
-
for (let
|
|
334
|
-
queue[i](type);
|
|
299
|
+
function runQueue(e, t) {
|
|
300
|
+
for (let n = 0; n < e.length; n++) e[n](t);
|
|
335
301
|
}
|
|
336
|
-
function transitionComplete(
|
|
337
|
-
let
|
|
338
|
-
for (let
|
|
339
|
-
if (
|
|
340
|
-
|
|
302
|
+
function transitionComplete(e) {
|
|
303
|
+
let t = true;
|
|
304
|
+
for (let n = 0; n < e.asyncNodes.length; n++) {
|
|
305
|
+
if (e.asyncNodes[n].J & STATUS_PENDING) {
|
|
306
|
+
t = false;
|
|
341
307
|
break;
|
|
342
308
|
}
|
|
343
309
|
}
|
|
344
|
-
return
|
|
345
|
-
}
|
|
346
|
-
function
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
insertIntoHeap(s.j, queue);
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
function recompute(el, create = false) {
|
|
373
|
-
deleteFromHeap(el, el.b & 32 /* Zombie */ ? zombieQueue : dirtyQueue);
|
|
374
|
-
if (el.e !== NOT_PENDING || el.U || el.V)
|
|
375
|
-
disposeChildren(el);
|
|
310
|
+
return t;
|
|
311
|
+
}
|
|
312
|
+
function runInTransition(e, t) {
|
|
313
|
+
const n = activeTransition;
|
|
314
|
+
activeTransition = e.B;
|
|
315
|
+
t(e);
|
|
316
|
+
activeTransition = n;
|
|
317
|
+
}
|
|
318
|
+
GlobalQueue.L = recompute;
|
|
319
|
+
GlobalQueue.F = disposeChildren;
|
|
320
|
+
let tracking = false;
|
|
321
|
+
let stale = false;
|
|
322
|
+
let pendingValueCheck = false;
|
|
323
|
+
let pendingCheck = null;
|
|
324
|
+
let context = null;
|
|
325
|
+
function notifySubs(e) {
|
|
326
|
+
for (let t = e.O; t !== null; t = t.p) {
|
|
327
|
+
const e = t.A._ & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue;
|
|
328
|
+
if (e.C > t.A.o) e.C = t.A.o;
|
|
329
|
+
insertIntoHeap(t.A, e);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
function recompute(e, t = false) {
|
|
333
|
+
deleteFromHeap(e, e._ & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
334
|
+
if (e.W !== NOT_PENDING || e.ee || e.te) disposeChildren(e);
|
|
376
335
|
else {
|
|
377
|
-
markDisposal(
|
|
378
|
-
globalQueue
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
}
|
|
384
|
-
const
|
|
385
|
-
context =
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
let
|
|
390
|
-
let
|
|
391
|
-
let
|
|
392
|
-
let
|
|
393
|
-
let
|
|
394
|
-
|
|
336
|
+
markDisposal(e);
|
|
337
|
+
globalQueue.$.push(e);
|
|
338
|
+
e.te = e.ne;
|
|
339
|
+
e.ee = e.ie;
|
|
340
|
+
e.ne = null;
|
|
341
|
+
e.ie = null;
|
|
342
|
+
}
|
|
343
|
+
const n = context;
|
|
344
|
+
context = e;
|
|
345
|
+
e.re = null;
|
|
346
|
+
e._ = REACTIVE_RECOMPUTING_DEPS;
|
|
347
|
+
e.se = clock;
|
|
348
|
+
let i = e.W === NOT_PENDING ? e.j : e.W;
|
|
349
|
+
let r = e.o;
|
|
350
|
+
let s = e.J;
|
|
351
|
+
let o = e.Y;
|
|
352
|
+
let u = tracking;
|
|
353
|
+
setStatusFlags(e, STATUS_NONE | (s & STATUS_UNINITIALIZED));
|
|
395
354
|
tracking = true;
|
|
396
355
|
try {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
setStatusFlags(
|
|
403
|
-
} else
|
|
404
|
-
setError(el, e);
|
|
405
|
-
}
|
|
356
|
+
i = e.m(i);
|
|
357
|
+
e.J &= ~STATUS_UNINITIALIZED;
|
|
358
|
+
} catch (t) {
|
|
359
|
+
if (t instanceof NotReadyError) {
|
|
360
|
+
if (t.cause !== e) link(t.cause, e);
|
|
361
|
+
setStatusFlags(e, (s & ~STATUS_ERROR) | STATUS_PENDING, t);
|
|
362
|
+
} else setStatusFlags(e, STATUS_ERROR, t);
|
|
406
363
|
} finally {
|
|
407
|
-
tracking =
|
|
364
|
+
tracking = u;
|
|
408
365
|
}
|
|
409
|
-
|
|
410
|
-
context =
|
|
411
|
-
const
|
|
412
|
-
let
|
|
413
|
-
if (
|
|
366
|
+
e._ = REACTIVE_NONE;
|
|
367
|
+
context = n;
|
|
368
|
+
const l = e.re;
|
|
369
|
+
let c = l !== null ? l.P : e.D;
|
|
370
|
+
if (c !== null) {
|
|
414
371
|
do {
|
|
415
|
-
|
|
416
|
-
} while (
|
|
417
|
-
if (
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
if (valueChanged || statusFlagsChanged) {
|
|
427
|
-
if (valueChanged) {
|
|
428
|
-
if (create || el.ia || el.K)
|
|
429
|
-
el.g = value;
|
|
372
|
+
c = unlinkSubs(c);
|
|
373
|
+
} while (c !== null);
|
|
374
|
+
if (l !== null) l.P = null;
|
|
375
|
+
else e.D = null;
|
|
376
|
+
}
|
|
377
|
+
const a = !e.oe || !e.oe(e.W === NOT_PENDING || e.ue ? e.j : e.W, i);
|
|
378
|
+
const f = e.J !== s || e.Y !== o;
|
|
379
|
+
e.le?.(f, s);
|
|
380
|
+
if (a || f) {
|
|
381
|
+
if (a) {
|
|
382
|
+
if (t || e.ue || (e.K && e.B != activeTransition)) e.j = i;
|
|
430
383
|
else {
|
|
431
|
-
if (
|
|
432
|
-
|
|
433
|
-
el.e = value;
|
|
384
|
+
if (e.W === NOT_PENDING) globalQueue.$.push(e);
|
|
385
|
+
e.W = i;
|
|
434
386
|
}
|
|
435
|
-
if (
|
|
436
|
-
el.D.da(value);
|
|
387
|
+
if (e.Z) e.Z.q(i);
|
|
437
388
|
}
|
|
438
|
-
for (let
|
|
439
|
-
const
|
|
440
|
-
if (
|
|
441
|
-
|
|
442
|
-
insertIntoHeap(s.j, queue);
|
|
389
|
+
for (let t = e.O; t !== null; t = t.p) {
|
|
390
|
+
const n = t.A._ & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue;
|
|
391
|
+
if (t.A.o < e.o && n.C > t.A.o) n.C = t.A.o;
|
|
392
|
+
insertIntoHeap(t.A, n);
|
|
443
393
|
}
|
|
444
|
-
} else if (
|
|
445
|
-
for (let
|
|
446
|
-
insertIntoHeapHeight(
|
|
394
|
+
} else if (e.o != r) {
|
|
395
|
+
for (let t = e.O; t !== null; t = t.p) {
|
|
396
|
+
insertIntoHeapHeight(t.A, t.A._ & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
447
397
|
}
|
|
448
398
|
}
|
|
399
|
+
if (e.K && e.B && activeTransition !== e.B) runInTransition(e, recompute);
|
|
449
400
|
}
|
|
450
|
-
function updateIfNecessary(
|
|
451
|
-
if (
|
|
452
|
-
for (let
|
|
453
|
-
const
|
|
454
|
-
const
|
|
455
|
-
if (
|
|
456
|
-
updateIfNecessary(
|
|
401
|
+
function updateIfNecessary(e) {
|
|
402
|
+
if (e._ & REACTIVE_CHECK) {
|
|
403
|
+
for (let t = e.D; t; t = t.P) {
|
|
404
|
+
const n = t.V;
|
|
405
|
+
const i = n.U || n;
|
|
406
|
+
if (i.m) {
|
|
407
|
+
updateIfNecessary(i);
|
|
457
408
|
}
|
|
458
|
-
if (
|
|
409
|
+
if (e._ & REACTIVE_DIRTY) {
|
|
459
410
|
break;
|
|
460
411
|
}
|
|
461
412
|
}
|
|
462
413
|
}
|
|
463
|
-
if (
|
|
464
|
-
recompute(
|
|
465
|
-
}
|
|
466
|
-
el.b = 0 /* None */;
|
|
467
|
-
}
|
|
468
|
-
function unlinkSubs(link2) {
|
|
469
|
-
const dep = link2.R;
|
|
470
|
-
const nextDep = link2.F;
|
|
471
|
-
const nextSub = link2.A;
|
|
472
|
-
const prevSub = link2.ma;
|
|
473
|
-
if (nextSub !== null) {
|
|
474
|
-
nextSub.ma = prevSub;
|
|
475
|
-
} else {
|
|
476
|
-
dep.W = prevSub;
|
|
477
|
-
}
|
|
478
|
-
if (prevSub !== null) {
|
|
479
|
-
prevSub.A = nextSub;
|
|
480
|
-
} else {
|
|
481
|
-
dep.s = nextSub;
|
|
414
|
+
if (e._ & REACTIVE_DIRTY) {
|
|
415
|
+
recompute(e);
|
|
482
416
|
}
|
|
483
|
-
|
|
417
|
+
e._ = REACTIVE_NONE;
|
|
484
418
|
}
|
|
485
|
-
function
|
|
486
|
-
const
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
if (
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
419
|
+
function unlinkSubs(e) {
|
|
420
|
+
const t = e.V;
|
|
421
|
+
const n = e.P;
|
|
422
|
+
const i = e.p;
|
|
423
|
+
const r = e.ce;
|
|
424
|
+
if (i !== null) i.ce = r;
|
|
425
|
+
else t.ae = r;
|
|
426
|
+
if (r !== null) r.p = i;
|
|
427
|
+
else {
|
|
428
|
+
t.O = i;
|
|
429
|
+
if (i === null) {
|
|
430
|
+
t.fe?.();
|
|
431
|
+
t.m && unobserved(t);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
return n;
|
|
435
|
+
}
|
|
436
|
+
function unobserved(e) {
|
|
437
|
+
deleteFromHeap(e, e._ & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
438
|
+
let t = e.D;
|
|
439
|
+
while (t !== null) {
|
|
440
|
+
t = unlinkSubs(t);
|
|
441
|
+
}
|
|
442
|
+
e.D = null;
|
|
443
|
+
runDisposal(e);
|
|
444
|
+
}
|
|
445
|
+
function link(e, t) {
|
|
446
|
+
const n = t.re;
|
|
447
|
+
if (n !== null && n.V === e) return;
|
|
448
|
+
let i = null;
|
|
449
|
+
const r = t._ & REACTIVE_RECOMPUTING_DEPS;
|
|
450
|
+
if (r) {
|
|
451
|
+
i = n !== null ? n.P : t.D;
|
|
452
|
+
if (i !== null && i.V === e) {
|
|
453
|
+
t.re = i;
|
|
496
454
|
return;
|
|
497
455
|
}
|
|
498
456
|
}
|
|
499
|
-
const
|
|
500
|
-
if (
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
F: nextDep,
|
|
507
|
-
ma: prevSub,
|
|
508
|
-
A: null
|
|
509
|
-
};
|
|
510
|
-
if (prevDep !== null) {
|
|
511
|
-
prevDep.F = newLink;
|
|
512
|
-
} else {
|
|
513
|
-
sub.x = newLink;
|
|
514
|
-
}
|
|
515
|
-
if (prevSub !== null) {
|
|
516
|
-
prevSub.A = newLink;
|
|
517
|
-
} else {
|
|
518
|
-
dep.s = newLink;
|
|
519
|
-
}
|
|
457
|
+
const s = e.ae;
|
|
458
|
+
if (s !== null && s.A === t && (!r || isValidLink(s, t))) return;
|
|
459
|
+
const o = (t.re = e.ae = { V: e, A: t, P: i, ce: s, p: null });
|
|
460
|
+
if (n !== null) n.P = o;
|
|
461
|
+
else t.D = o;
|
|
462
|
+
if (s !== null) s.p = o;
|
|
463
|
+
else e.O = o;
|
|
520
464
|
}
|
|
521
|
-
function isValidLink(
|
|
522
|
-
const
|
|
523
|
-
if (
|
|
524
|
-
let
|
|
465
|
+
function isValidLink(e, t) {
|
|
466
|
+
const n = t.re;
|
|
467
|
+
if (n !== null) {
|
|
468
|
+
let i = t.D;
|
|
525
469
|
do {
|
|
526
|
-
if (
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
break;
|
|
531
|
-
}
|
|
532
|
-
link2 = link2.F;
|
|
533
|
-
} while (link2 !== null);
|
|
470
|
+
if (i === e) return true;
|
|
471
|
+
if (i === n) break;
|
|
472
|
+
i = i.P;
|
|
473
|
+
} while (i !== null);
|
|
534
474
|
}
|
|
535
475
|
return false;
|
|
536
476
|
}
|
|
537
|
-
function setStatusFlags(
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
}
|
|
541
|
-
function
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
if (
|
|
564
|
-
|
|
565
|
-
let
|
|
566
|
-
while (
|
|
567
|
-
const
|
|
568
|
-
if (
|
|
569
|
-
const
|
|
570
|
-
deleteFromHeap(
|
|
571
|
-
let
|
|
477
|
+
function setStatusFlags(e, t, n = null) {
|
|
478
|
+
e.J = t;
|
|
479
|
+
e.Y = n;
|
|
480
|
+
}
|
|
481
|
+
function markDisposal(e) {
|
|
482
|
+
let t = e.ie;
|
|
483
|
+
while (t) {
|
|
484
|
+
t._ |= REACTIVE_ZOMBIE;
|
|
485
|
+
if (t._ & REACTIVE_IN_HEAP) {
|
|
486
|
+
deleteFromHeap(t, dirtyQueue);
|
|
487
|
+
insertIntoHeap(t, zombieQueue);
|
|
488
|
+
}
|
|
489
|
+
markDisposal(t);
|
|
490
|
+
t = t.Ee;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
function dispose(e) {
|
|
494
|
+
let t = e.D || null;
|
|
495
|
+
do {
|
|
496
|
+
t = unlinkSubs(t);
|
|
497
|
+
} while (t !== null);
|
|
498
|
+
e.D = null;
|
|
499
|
+
e.re = null;
|
|
500
|
+
disposeChildren(e, true);
|
|
501
|
+
}
|
|
502
|
+
function disposeChildren(e, t = false, n) {
|
|
503
|
+
if (e._ & REACTIVE_DISPOSED) return;
|
|
504
|
+
if (t) e._ = REACTIVE_DISPOSED;
|
|
505
|
+
let i = n ? e.ee : e.ie;
|
|
506
|
+
while (i) {
|
|
507
|
+
const e = i.Ee;
|
|
508
|
+
if (i.D) {
|
|
509
|
+
const e = i;
|
|
510
|
+
deleteFromHeap(e, e._ & REACTIVE_ZOMBIE ? zombieQueue : dirtyQueue);
|
|
511
|
+
let t = e.D;
|
|
572
512
|
do {
|
|
573
|
-
|
|
574
|
-
} while (
|
|
575
|
-
|
|
576
|
-
|
|
513
|
+
t = unlinkSubs(t);
|
|
514
|
+
} while (t !== null);
|
|
515
|
+
e.D = null;
|
|
516
|
+
e.re = null;
|
|
577
517
|
}
|
|
578
|
-
disposeChildren(
|
|
579
|
-
|
|
518
|
+
disposeChildren(i, true);
|
|
519
|
+
i = e;
|
|
580
520
|
}
|
|
581
|
-
if (
|
|
582
|
-
|
|
521
|
+
if (n) {
|
|
522
|
+
e.ee = null;
|
|
583
523
|
} else {
|
|
584
|
-
|
|
585
|
-
|
|
524
|
+
e.ie = null;
|
|
525
|
+
e.Ee = null;
|
|
586
526
|
}
|
|
587
|
-
runDisposal(
|
|
527
|
+
runDisposal(e, n);
|
|
588
528
|
}
|
|
589
|
-
function runDisposal(
|
|
590
|
-
let
|
|
591
|
-
if (!
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
callable.call(callable);
|
|
529
|
+
function runDisposal(e, t) {
|
|
530
|
+
let n = t ? e.te : e.ne;
|
|
531
|
+
if (!n) return;
|
|
532
|
+
if (Array.isArray(n)) {
|
|
533
|
+
for (let e = 0; e < n.length; e++) {
|
|
534
|
+
const t = n[e];
|
|
535
|
+
t.call(t);
|
|
597
536
|
}
|
|
598
537
|
} else {
|
|
599
|
-
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
}
|
|
603
|
-
function withOptions(obj, options) {
|
|
604
|
-
obj.id = options?.id ?? (context?.id != null ? getNextChildId(context) : void 0);
|
|
605
|
-
obj.ea = options?.equals != null ? options.equals : isEqual;
|
|
606
|
-
obj.ya = !!options?.pureWrite;
|
|
607
|
-
obj.sa = options?.unobserved;
|
|
608
|
-
if (options?.ja)
|
|
609
|
-
Object.assign(obj, options.ja);
|
|
610
|
-
return obj;
|
|
611
|
-
}
|
|
612
|
-
function getNextChildId(owner) {
|
|
613
|
-
if (owner.id != null)
|
|
614
|
-
return formatId(owner.id, owner.na++);
|
|
615
|
-
throw new Error("Cannot get child id from owner without an id");
|
|
538
|
+
n.call(n);
|
|
539
|
+
}
|
|
540
|
+
t ? (e.te = null) : (e.ne = null);
|
|
616
541
|
}
|
|
617
|
-
function
|
|
618
|
-
|
|
619
|
-
|
|
542
|
+
function getNextChildId(e) {
|
|
543
|
+
if (e.id != null) return formatId(e.id, e.de++);
|
|
544
|
+
throw new Error("Cannot get child id from owner without an id");
|
|
620
545
|
}
|
|
621
|
-
function
|
|
622
|
-
const
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
546
|
+
function formatId(e, t) {
|
|
547
|
+
const n = t.toString(36),
|
|
548
|
+
i = n.length - 1;
|
|
549
|
+
return e + (i ? String.fromCharCode(64 + i) : "") + n;
|
|
550
|
+
}
|
|
551
|
+
function computed(e, t, n) {
|
|
552
|
+
const i = {
|
|
553
|
+
id: n?.id ?? (context?.id != null ? getNextChildId(context) : undefined),
|
|
554
|
+
oe: n?.equals != null ? n.equals : isEqual,
|
|
555
|
+
Te: !!n?.pureWrite,
|
|
556
|
+
fe: n?.unobserved,
|
|
557
|
+
ne: null,
|
|
558
|
+
Re: context?.Re ?? globalQueue,
|
|
559
|
+
he: context?.he ?? defaultContext,
|
|
560
|
+
de: 0,
|
|
561
|
+
m: e,
|
|
562
|
+
j: t,
|
|
563
|
+
o: 0,
|
|
564
|
+
N: null,
|
|
565
|
+
R: undefined,
|
|
566
|
+
T: null,
|
|
567
|
+
D: null,
|
|
568
|
+
re: null,
|
|
569
|
+
O: null,
|
|
570
|
+
ae: null,
|
|
571
|
+
i: context,
|
|
572
|
+
Ee: null,
|
|
573
|
+
ie: null,
|
|
574
|
+
_: REACTIVE_NONE,
|
|
575
|
+
J: STATUS_UNINITIALIZED,
|
|
576
|
+
se: clock,
|
|
577
|
+
W: NOT_PENDING,
|
|
578
|
+
te: null,
|
|
579
|
+
ee: null
|
|
580
|
+
};
|
|
581
|
+
if (n?._e) Object.assign(i, n._e);
|
|
582
|
+
i.T = i;
|
|
583
|
+
const r = context?.t ? context.u : context;
|
|
652
584
|
if (context) {
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
if (lastChild === null) {
|
|
657
|
-
context.q = self;
|
|
585
|
+
const e = context.ie;
|
|
586
|
+
if (e === null) {
|
|
587
|
+
context.ie = i;
|
|
658
588
|
} else {
|
|
659
|
-
|
|
660
|
-
context.
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
if (
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
let
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
const
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
globalQueue.initTransition(self);
|
|
685
|
-
setSignal(self, () => v);
|
|
589
|
+
i.Ee = e;
|
|
590
|
+
context.ie = i;
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
if (r) i.o = r.o + 1;
|
|
594
|
+
recompute(i, true);
|
|
595
|
+
return i;
|
|
596
|
+
}
|
|
597
|
+
function asyncComputed(e, t, n) {
|
|
598
|
+
let i = undefined;
|
|
599
|
+
let r = false;
|
|
600
|
+
const fn = t => {
|
|
601
|
+
const n = e(t, r);
|
|
602
|
+
r = false;
|
|
603
|
+
i = n;
|
|
604
|
+
const o = n instanceof Promise;
|
|
605
|
+
const u = n[Symbol.asyncIterator];
|
|
606
|
+
if (!o && !u) {
|
|
607
|
+
return n;
|
|
608
|
+
}
|
|
609
|
+
if (o) {
|
|
610
|
+
n.then(e => {
|
|
611
|
+
if (i !== n) return;
|
|
612
|
+
globalQueue.initTransition(s);
|
|
613
|
+
setSignal(s, () => e);
|
|
686
614
|
flush();
|
|
687
|
-
}).catch(
|
|
688
|
-
if (
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
notifySubs(self);
|
|
615
|
+
}).catch(e => {
|
|
616
|
+
if (i !== n) return;
|
|
617
|
+
globalQueue.initTransition(s);
|
|
618
|
+
setStatusFlags(s, STATUS_ERROR, e);
|
|
619
|
+
s.se = clock;
|
|
620
|
+
notifySubs(s);
|
|
694
621
|
schedule();
|
|
695
622
|
flush();
|
|
696
623
|
});
|
|
697
624
|
} else {
|
|
698
625
|
(async () => {
|
|
699
626
|
try {
|
|
700
|
-
for await (let
|
|
701
|
-
if (
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
setSignal(self, () => value);
|
|
627
|
+
for await (let e of n) {
|
|
628
|
+
if (i !== n) return;
|
|
629
|
+
globalQueue.initTransition(s);
|
|
630
|
+
setSignal(s, () => e);
|
|
705
631
|
flush();
|
|
706
632
|
}
|
|
707
|
-
} catch (
|
|
708
|
-
if (
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
notifySubs(self);
|
|
633
|
+
} catch (e) {
|
|
634
|
+
if (i !== n) return;
|
|
635
|
+
globalQueue.initTransition(s);
|
|
636
|
+
setStatusFlags(s, STATUS_ERROR, e);
|
|
637
|
+
s.se = clock;
|
|
638
|
+
notifySubs(s);
|
|
714
639
|
schedule();
|
|
715
640
|
flush();
|
|
716
641
|
}
|
|
@@ -719,150 +644,128 @@ function asyncComputed(asyncFn, initialValue, options) {
|
|
|
719
644
|
globalQueue.initTransition(context);
|
|
720
645
|
throw new NotReadyError(context);
|
|
721
646
|
};
|
|
722
|
-
const
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
recompute(
|
|
647
|
+
const s = computed(fn, t, n);
|
|
648
|
+
s.Se = () => {
|
|
649
|
+
r = true;
|
|
650
|
+
recompute(s);
|
|
651
|
+
schedule();
|
|
726
652
|
flush();
|
|
727
653
|
};
|
|
728
|
-
return
|
|
729
|
-
}
|
|
730
|
-
function signal(
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
{
|
|
748
|
-
g: v,
|
|
749
|
-
s: null,
|
|
750
|
-
W: null,
|
|
751
|
-
f: 0 /* None */,
|
|
752
|
-
J: clock,
|
|
753
|
-
e: NOT_PENDING
|
|
754
|
-
},
|
|
755
|
-
options
|
|
756
|
-
);
|
|
757
|
-
}
|
|
654
|
+
return s;
|
|
655
|
+
}
|
|
656
|
+
function signal(e, t, n = null) {
|
|
657
|
+
const i = {
|
|
658
|
+
id: t?.id ?? (context?.id != null ? getNextChildId(context) : undefined),
|
|
659
|
+
oe: t?.equals != null ? t.equals : isEqual,
|
|
660
|
+
Te: !!t?.pureWrite,
|
|
661
|
+
fe: t?.unobserved,
|
|
662
|
+
j: e,
|
|
663
|
+
O: null,
|
|
664
|
+
ae: null,
|
|
665
|
+
J: STATUS_NONE,
|
|
666
|
+
se: clock,
|
|
667
|
+
U: n,
|
|
668
|
+
I: n?.N || null,
|
|
669
|
+
W: NOT_PENDING
|
|
670
|
+
};
|
|
671
|
+
n && (n.N = i);
|
|
672
|
+
return i;
|
|
758
673
|
}
|
|
759
|
-
function isEqual(
|
|
760
|
-
return
|
|
674
|
+
function isEqual(e, t) {
|
|
675
|
+
return e === t;
|
|
761
676
|
}
|
|
762
|
-
function untrack(
|
|
763
|
-
if (!tracking)
|
|
764
|
-
return fn();
|
|
677
|
+
function untrack(e) {
|
|
678
|
+
if (!tracking) return e();
|
|
765
679
|
tracking = false;
|
|
766
680
|
try {
|
|
767
|
-
return
|
|
681
|
+
return e();
|
|
768
682
|
} finally {
|
|
769
683
|
tracking = true;
|
|
770
684
|
}
|
|
771
685
|
}
|
|
772
|
-
function read(
|
|
773
|
-
let
|
|
774
|
-
if (
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
updateIfNecessary(owner);
|
|
686
|
+
function read(e) {
|
|
687
|
+
let t = context;
|
|
688
|
+
if (t?.t) t = t.u;
|
|
689
|
+
if (t && tracking && !pendingCheck && !pendingValueCheck) {
|
|
690
|
+
link(e, t);
|
|
691
|
+
const n = e.U || e;
|
|
692
|
+
if (n.m) {
|
|
693
|
+
const i = e._ & REACTIVE_ZOMBIE;
|
|
694
|
+
if (n.o >= (i ? zombieQueue.C : dirtyQueue.C)) {
|
|
695
|
+
markNode(t);
|
|
696
|
+
markHeap(i ? zombieQueue : dirtyQueue);
|
|
697
|
+
updateIfNecessary(n);
|
|
785
698
|
}
|
|
786
|
-
const
|
|
787
|
-
if (
|
|
788
|
-
|
|
699
|
+
const r = n.o;
|
|
700
|
+
if (r >= t.o && e.i !== t) {
|
|
701
|
+
t.o = r + 1;
|
|
789
702
|
}
|
|
790
703
|
}
|
|
791
704
|
}
|
|
792
705
|
if (pendingCheck) {
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
el.H.da = (v) => setSignal(el.H, v);
|
|
706
|
+
if (!e.X) {
|
|
707
|
+
e.X = signal(false);
|
|
708
|
+
e.X.ue = true;
|
|
709
|
+
e.X.q = t => setSignal(e.X, t);
|
|
798
710
|
}
|
|
799
|
-
const
|
|
711
|
+
const t = pendingCheck;
|
|
800
712
|
pendingCheck = null;
|
|
801
|
-
read(
|
|
802
|
-
pendingCheck =
|
|
803
|
-
prev.g = pendingResult || prev.g;
|
|
713
|
+
t.j = read(e.X) || t.j;
|
|
714
|
+
pendingCheck = t;
|
|
804
715
|
}
|
|
805
716
|
if (pendingValueCheck) {
|
|
806
|
-
if (!
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
);
|
|
810
|
-
el.D.ia = true;
|
|
811
|
-
el.D.da = (v) => queueMicrotask(() => queueMicrotask(() => setSignal(el.D, v)));
|
|
717
|
+
if (!e.Z) {
|
|
718
|
+
e.Z = signal(e.j);
|
|
719
|
+
e.Z.ue = true;
|
|
720
|
+
e.Z.q = t => setSignal(e.Z, t);
|
|
812
721
|
}
|
|
813
722
|
pendingValueCheck = false;
|
|
814
723
|
try {
|
|
815
|
-
return read(
|
|
724
|
+
return read(e.Z);
|
|
816
725
|
} finally {
|
|
817
726
|
pendingValueCheck = true;
|
|
818
727
|
}
|
|
819
728
|
}
|
|
820
|
-
if (
|
|
821
|
-
if (
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
setStatusFlags(
|
|
825
|
-
c,
|
|
826
|
-
c.f | 1,
|
|
827
|
-
el.C
|
|
828
|
-
);
|
|
729
|
+
if (e.J & STATUS_PENDING) {
|
|
730
|
+
if ((t && !stale) || e.J & STATUS_UNINITIALIZED) throw e.Y;
|
|
731
|
+
else if (t && stale && !pendingCheck) {
|
|
732
|
+
setStatusFlags(t, t.J | 1, e.Y);
|
|
829
733
|
}
|
|
830
734
|
}
|
|
831
|
-
if (
|
|
832
|
-
if (
|
|
833
|
-
recompute(
|
|
834
|
-
return read(
|
|
735
|
+
if (e.J & STATUS_ERROR) {
|
|
736
|
+
if (e.se < clock) {
|
|
737
|
+
recompute(e, true);
|
|
738
|
+
return read(e);
|
|
835
739
|
} else {
|
|
836
|
-
throw
|
|
740
|
+
throw e.Y;
|
|
837
741
|
}
|
|
838
742
|
}
|
|
839
|
-
return !
|
|
743
|
+
return !t ||
|
|
744
|
+
e.ue ||
|
|
745
|
+
e.W === NOT_PENDING ||
|
|
746
|
+
(stale && !pendingCheck && e.B && activeTransition !== e.B)
|
|
747
|
+
? e.j
|
|
748
|
+
: e.W;
|
|
840
749
|
}
|
|
841
|
-
function setSignal(
|
|
842
|
-
if (typeof
|
|
843
|
-
|
|
844
|
-
el.e === NOT_PENDING ? el.g : el.e
|
|
845
|
-
);
|
|
750
|
+
function setSignal(e, t) {
|
|
751
|
+
if (typeof t === "function") {
|
|
752
|
+
t = t(e.W === NOT_PENDING ? e.j : e.W);
|
|
846
753
|
}
|
|
847
|
-
const
|
|
848
|
-
if (!
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
if (el.ia)
|
|
852
|
-
el.g = v;
|
|
754
|
+
const n = !e.oe || !e.oe(e.W === NOT_PENDING || e.ue ? e.j : e.W, t);
|
|
755
|
+
if (!n && !e.J) return t;
|
|
756
|
+
if (n) {
|
|
757
|
+
if (e.ue) e.j = t;
|
|
853
758
|
else {
|
|
854
|
-
if (
|
|
855
|
-
|
|
856
|
-
el.e = v;
|
|
759
|
+
if (e.W === NOT_PENDING) globalQueue.$.push(e);
|
|
760
|
+
e.W = t;
|
|
857
761
|
}
|
|
858
|
-
if (
|
|
859
|
-
el.D.da(v);
|
|
762
|
+
if (e.Z) e.Z.W = t;
|
|
860
763
|
}
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
notifySubs(
|
|
764
|
+
setStatusFlags(e, STATUS_NONE);
|
|
765
|
+
e.se = clock;
|
|
766
|
+
notifySubs(e);
|
|
864
767
|
schedule();
|
|
865
|
-
return
|
|
768
|
+
return t;
|
|
866
769
|
}
|
|
867
770
|
function getObserver() {
|
|
868
771
|
return tracking ? context : null;
|
|
@@ -870,1317 +773,1302 @@ function getObserver() {
|
|
|
870
773
|
function getOwner() {
|
|
871
774
|
return context;
|
|
872
775
|
}
|
|
873
|
-
function onCleanup(
|
|
874
|
-
if (!context)
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
node.t.push(fn);
|
|
776
|
+
function onCleanup(e) {
|
|
777
|
+
if (!context) return e;
|
|
778
|
+
const t = context;
|
|
779
|
+
if (!t.ne) {
|
|
780
|
+
t.ne = e;
|
|
781
|
+
} else if (Array.isArray(t.ne)) {
|
|
782
|
+
t.ne.push(e);
|
|
881
783
|
} else {
|
|
882
|
-
|
|
883
|
-
}
|
|
884
|
-
return
|
|
885
|
-
}
|
|
886
|
-
function createOwner(
|
|
887
|
-
const
|
|
888
|
-
const
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
id:
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
dispose(
|
|
902
|
-
disposeChildren(
|
|
784
|
+
t.ne = [t.ne, e];
|
|
785
|
+
}
|
|
786
|
+
return e;
|
|
787
|
+
}
|
|
788
|
+
function createOwner(e) {
|
|
789
|
+
const t = context;
|
|
790
|
+
const n = {
|
|
791
|
+
t: true,
|
|
792
|
+
u: t?.t ? t.u : t,
|
|
793
|
+
ie: null,
|
|
794
|
+
Ee: null,
|
|
795
|
+
ne: null,
|
|
796
|
+
id: e?.id ?? (t?.id != null ? getNextChildId(t) : undefined),
|
|
797
|
+
Re: t?.Re ?? globalQueue,
|
|
798
|
+
he: t?.he || defaultContext,
|
|
799
|
+
de: 0,
|
|
800
|
+
te: null,
|
|
801
|
+
ee: null,
|
|
802
|
+
i: t,
|
|
803
|
+
dispose(e = true) {
|
|
804
|
+
disposeChildren(n, e);
|
|
903
805
|
}
|
|
904
806
|
};
|
|
905
|
-
if (
|
|
906
|
-
const
|
|
907
|
-
if (
|
|
908
|
-
|
|
807
|
+
if (t) {
|
|
808
|
+
const e = t.ie;
|
|
809
|
+
if (e === null) {
|
|
810
|
+
t.ie = n;
|
|
909
811
|
} else {
|
|
910
|
-
|
|
911
|
-
|
|
812
|
+
n.Ee = e;
|
|
813
|
+
t.ie = n;
|
|
912
814
|
}
|
|
913
815
|
}
|
|
914
|
-
return
|
|
816
|
+
return n;
|
|
915
817
|
}
|
|
916
|
-
function createRoot(
|
|
917
|
-
const
|
|
918
|
-
return runWithOwner(
|
|
818
|
+
function createRoot(e, t) {
|
|
819
|
+
const n = createOwner(t);
|
|
820
|
+
return runWithOwner(n, () => e(n.dispose));
|
|
919
821
|
}
|
|
920
|
-
function runWithOwner(
|
|
921
|
-
const
|
|
922
|
-
context =
|
|
822
|
+
function runWithOwner(e, t) {
|
|
823
|
+
const n = context;
|
|
824
|
+
context = e;
|
|
923
825
|
try {
|
|
924
|
-
return
|
|
826
|
+
return t();
|
|
925
827
|
} finally {
|
|
926
|
-
context =
|
|
828
|
+
context = n;
|
|
927
829
|
}
|
|
928
830
|
}
|
|
929
|
-
function staleValues(
|
|
930
|
-
const
|
|
931
|
-
stale =
|
|
831
|
+
function staleValues(e, t = true) {
|
|
832
|
+
const n = stale;
|
|
833
|
+
stale = t;
|
|
932
834
|
try {
|
|
933
|
-
return
|
|
835
|
+
return e();
|
|
934
836
|
} finally {
|
|
935
|
-
stale =
|
|
837
|
+
stale = n;
|
|
936
838
|
}
|
|
937
839
|
}
|
|
938
|
-
function pending(
|
|
939
|
-
const
|
|
840
|
+
function pending(e) {
|
|
841
|
+
const t = pendingValueCheck;
|
|
940
842
|
pendingValueCheck = true;
|
|
941
843
|
try {
|
|
942
|
-
return staleValues(
|
|
844
|
+
return staleValues(e, false);
|
|
943
845
|
} finally {
|
|
944
|
-
pendingValueCheck =
|
|
846
|
+
pendingValueCheck = t;
|
|
945
847
|
}
|
|
946
848
|
}
|
|
947
|
-
function isPending(
|
|
948
|
-
const
|
|
949
|
-
pendingCheck = {
|
|
849
|
+
function isPending(e, t) {
|
|
850
|
+
const n = pendingCheck;
|
|
851
|
+
pendingCheck = { j: false };
|
|
950
852
|
try {
|
|
951
|
-
staleValues(
|
|
952
|
-
return pendingCheck.
|
|
953
|
-
} catch (
|
|
954
|
-
if (!(
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
return loadingValue;
|
|
958
|
-
throw err;
|
|
853
|
+
staleValues(e);
|
|
854
|
+
return pendingCheck.j;
|
|
855
|
+
} catch (e) {
|
|
856
|
+
if (!(e instanceof NotReadyError)) return false;
|
|
857
|
+
if (t !== undefined) return t;
|
|
858
|
+
throw e;
|
|
959
859
|
} finally {
|
|
960
|
-
pendingCheck =
|
|
860
|
+
pendingCheck = n;
|
|
961
861
|
}
|
|
962
862
|
}
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
function createContext(defaultValue, description) {
|
|
966
|
-
return { id: Symbol(description), defaultValue };
|
|
863
|
+
function createContext(e, t) {
|
|
864
|
+
return { id: Symbol(t), defaultValue: e };
|
|
967
865
|
}
|
|
968
|
-
function getContext(
|
|
969
|
-
if (!
|
|
866
|
+
function getContext(e, t = getOwner()) {
|
|
867
|
+
if (!t) {
|
|
970
868
|
throw new NoOwnerError();
|
|
971
869
|
}
|
|
972
|
-
const
|
|
973
|
-
if (isUndefined(
|
|
870
|
+
const n = hasContext(e, t) ? t.he[e.id] : e.defaultValue;
|
|
871
|
+
if (isUndefined(n)) {
|
|
974
872
|
throw new ContextNotFoundError();
|
|
975
873
|
}
|
|
976
|
-
return
|
|
874
|
+
return n;
|
|
977
875
|
}
|
|
978
|
-
function setContext(
|
|
979
|
-
if (!
|
|
876
|
+
function setContext(e, t, n = getOwner()) {
|
|
877
|
+
if (!n) {
|
|
980
878
|
throw new NoOwnerError();
|
|
981
879
|
}
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
}
|
|
987
|
-
function
|
|
988
|
-
return
|
|
989
|
-
}
|
|
990
|
-
function
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
K: options?.render ? 1 /* Render */ : 2 /* User */,
|
|
1007
|
-
la(statusFlagsChanged, prevStatusFlags) {
|
|
1008
|
-
if (initialized) {
|
|
1009
|
-
const errorChanged = this.f && this.f === prevStatusFlags && statusFlagsChanged;
|
|
1010
|
-
this.fa = !(this.f & 2 /* Error */) && !(this.f & 1 /* Pending */ & ~prevStatusFlags) && !errorChanged;
|
|
1011
|
-
if (this.fa)
|
|
1012
|
-
this.i.enqueue(this.K, runEffect.bind(this));
|
|
880
|
+
n.he = { ...n.he, [e.id]: isUndefined(t) ? e.defaultValue : t };
|
|
881
|
+
}
|
|
882
|
+
function hasContext(e, t) {
|
|
883
|
+
return !isUndefined(t?.he[e.id]);
|
|
884
|
+
}
|
|
885
|
+
function isUndefined(e) {
|
|
886
|
+
return typeof e === "undefined";
|
|
887
|
+
}
|
|
888
|
+
function effect(e, t, n, i, r) {
|
|
889
|
+
let s = false;
|
|
890
|
+
const o = computed(e, i, {
|
|
891
|
+
...r,
|
|
892
|
+
_e: {
|
|
893
|
+
M: true,
|
|
894
|
+
Oe: i,
|
|
895
|
+
pe: t,
|
|
896
|
+
Ae: n,
|
|
897
|
+
Ne: undefined,
|
|
898
|
+
K: r?.render ? EFFECT_RENDER : EFFECT_USER,
|
|
899
|
+
le(e, t) {
|
|
900
|
+
if (s) {
|
|
901
|
+
const n = this.J && this.J === t && e;
|
|
902
|
+
this.M = !(this.J & STATUS_ERROR) && !(this.J & STATUS_PENDING & ~t) && !n;
|
|
903
|
+
if (this.M) this.Re.enqueue(this.K, runEffect.bind(this));
|
|
1013
904
|
}
|
|
1014
|
-
if (this.
|
|
1015
|
-
let
|
|
1016
|
-
this.
|
|
1017
|
-
if (this.K ===
|
|
905
|
+
if (this.J & STATUS_ERROR) {
|
|
906
|
+
let e = this.Y;
|
|
907
|
+
this.Re.notify(this, STATUS_PENDING, 0);
|
|
908
|
+
if (this.K === EFFECT_USER) {
|
|
1018
909
|
try {
|
|
1019
|
-
return this.
|
|
1020
|
-
this.
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
910
|
+
return this.Ae
|
|
911
|
+
? this.Ae(e, () => {
|
|
912
|
+
this.Ne?.();
|
|
913
|
+
this.Ne = undefined;
|
|
914
|
+
})
|
|
915
|
+
: console.error(e);
|
|
916
|
+
} catch (t) {
|
|
917
|
+
e = t;
|
|
1025
918
|
}
|
|
1026
919
|
}
|
|
1027
|
-
if (!this.
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
this.i.notify(
|
|
1031
|
-
this,
|
|
1032
|
-
1 /* Pending */ | 2 /* Error */,
|
|
1033
|
-
this.f
|
|
1034
|
-
);
|
|
920
|
+
if (!this.Re.notify(this, STATUS_ERROR, STATUS_ERROR)) throw e;
|
|
921
|
+
} else if (this.K === EFFECT_RENDER) {
|
|
922
|
+
this.Re.notify(this, STATUS_PENDING | STATUS_ERROR, this.J);
|
|
1035
923
|
}
|
|
1036
924
|
}
|
|
1037
925
|
}
|
|
1038
926
|
});
|
|
1039
|
-
|
|
1040
|
-
if (
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
927
|
+
s = true;
|
|
928
|
+
if (o.K === EFFECT_RENDER) o.m = t => staleValues(() => e(t));
|
|
929
|
+
!r?.defer &&
|
|
930
|
+
!(o.J & (STATUS_ERROR | STATUS_PENDING)) &&
|
|
931
|
+
(o.K === EFFECT_USER ? o.Re.enqueue(o.K, runEffect.bind(o)) : runEffect.call(o));
|
|
932
|
+
onCleanup(() => o.Ne?.());
|
|
1044
933
|
}
|
|
1045
934
|
function runEffect() {
|
|
1046
|
-
if (!this.
|
|
1047
|
-
|
|
1048
|
-
this.
|
|
1049
|
-
this.N = void 0;
|
|
935
|
+
if (!this.M || this._ & REACTIVE_DISPOSED) return;
|
|
936
|
+
this.Ne?.();
|
|
937
|
+
this.Ne = undefined;
|
|
1050
938
|
try {
|
|
1051
|
-
this.
|
|
1052
|
-
} catch (
|
|
1053
|
-
if (!this.
|
|
1054
|
-
throw error;
|
|
939
|
+
this.Ne = this.pe(this.j, this.Oe);
|
|
940
|
+
} catch (e) {
|
|
941
|
+
if (!this.Re.notify(this, STATUS_ERROR, STATUS_ERROR)) throw e;
|
|
1055
942
|
} finally {
|
|
1056
|
-
this.
|
|
1057
|
-
this.
|
|
1058
|
-
}
|
|
1059
|
-
}
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
);
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
}
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
}
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
}
|
|
1106
|
-
function createTrackedEffect(compute, options) {
|
|
1107
|
-
}
|
|
1108
|
-
function createReaction(effect2, options) {
|
|
943
|
+
this.Oe = this.j;
|
|
944
|
+
this.M = false;
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
function createSignal(e, t, n) {
|
|
948
|
+
if (typeof e === "function") {
|
|
949
|
+
const i = computed(e, t, n);
|
|
950
|
+
return [read.bind(null, i), setSignal.bind(null, i)];
|
|
951
|
+
}
|
|
952
|
+
const i = getOwner();
|
|
953
|
+
const r = i?.id != null;
|
|
954
|
+
const s = signal(e, r ? { id: getNextChildId(i), ...t } : t);
|
|
955
|
+
return [read.bind(null, s), setSignal.bind(null, s)];
|
|
956
|
+
}
|
|
957
|
+
function createMemo(e, t, n) {
|
|
958
|
+
let i = computed(e, t, n);
|
|
959
|
+
return read.bind(null, i);
|
|
960
|
+
}
|
|
961
|
+
function createAsync(e, t, n) {
|
|
962
|
+
const i = asyncComputed(e, t, n);
|
|
963
|
+
const r = read.bind(null, i);
|
|
964
|
+
r.refresh = i.Se;
|
|
965
|
+
return r;
|
|
966
|
+
}
|
|
967
|
+
function createEffect(e, t, n, i) {
|
|
968
|
+
void effect(e, t.effect || t, t.error, n, i);
|
|
969
|
+
}
|
|
970
|
+
function createRenderEffect(e, t, n, i) {
|
|
971
|
+
void effect(e, t, undefined, n, { render: true, ...i });
|
|
972
|
+
}
|
|
973
|
+
function createTrackedEffect(e, t) {}
|
|
974
|
+
function createReaction(e, t) {
|
|
975
|
+
let n = undefined;
|
|
976
|
+
onCleanup(() => n?.());
|
|
977
|
+
const i = getOwner();
|
|
978
|
+
return r => {
|
|
979
|
+
runWithOwner(i, () => {
|
|
980
|
+
effect(
|
|
981
|
+
() => (r(), getOwner()),
|
|
982
|
+
t => {
|
|
983
|
+
n?.();
|
|
984
|
+
n = (e.effect || e)?.();
|
|
985
|
+
dispose(t);
|
|
986
|
+
},
|
|
987
|
+
e.error,
|
|
988
|
+
undefined,
|
|
989
|
+
{ defer: true, ...(false ? { ...t, name: t?.name ?? "effect" } : t) }
|
|
990
|
+
);
|
|
991
|
+
});
|
|
992
|
+
};
|
|
1109
993
|
}
|
|
1110
|
-
function resolve(
|
|
1111
|
-
return new Promise((
|
|
1112
|
-
createRoot(
|
|
994
|
+
function resolve(e) {
|
|
995
|
+
return new Promise((t, n) => {
|
|
996
|
+
createRoot(i => {
|
|
1113
997
|
computed(() => {
|
|
1114
998
|
try {
|
|
1115
|
-
|
|
1116
|
-
} catch (
|
|
1117
|
-
if (
|
|
1118
|
-
|
|
1119
|
-
rej(err);
|
|
999
|
+
t(e());
|
|
1000
|
+
} catch (e) {
|
|
1001
|
+
if (e instanceof NotReadyError) throw e;
|
|
1002
|
+
n(e);
|
|
1120
1003
|
}
|
|
1121
|
-
|
|
1004
|
+
i();
|
|
1122
1005
|
});
|
|
1123
1006
|
});
|
|
1124
1007
|
});
|
|
1125
1008
|
}
|
|
1126
|
-
function createOptimistic(
|
|
1009
|
+
function createOptimistic(e, t, n) {
|
|
1127
1010
|
return {};
|
|
1128
1011
|
}
|
|
1129
|
-
function onSettled(
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
return nodes && key in nodes ? read(nodes[key]) : override && key in override ? override[key] : value[key];
|
|
1138
|
-
}
|
|
1139
|
-
function getAllKeys(value, override, next) {
|
|
1140
|
-
const keys = getKeys(value, override);
|
|
1141
|
-
const nextKeys = Object.keys(next);
|
|
1142
|
-
return Array.from(/* @__PURE__ */ new Set([...keys, ...nextKeys]));
|
|
1012
|
+
function onSettled(e) {
|
|
1013
|
+
let t;
|
|
1014
|
+
const n = getOwner();
|
|
1015
|
+
if (n) onCleanup(() => t?.());
|
|
1016
|
+
globalQueue.enqueue(EFFECT_USER, () => {
|
|
1017
|
+
t = e();
|
|
1018
|
+
!n && t?.();
|
|
1019
|
+
});
|
|
1143
1020
|
}
|
|
1144
|
-
function
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1021
|
+
function unwrap(e) {
|
|
1022
|
+
return e?.[$TARGET]?.[STORE_NODE] ?? e;
|
|
1023
|
+
}
|
|
1024
|
+
function getOverrideValue(e, t, n, i) {
|
|
1025
|
+
return n && i in n ? read(n[i]) : t && i in t ? t[i] : e[i];
|
|
1026
|
+
}
|
|
1027
|
+
function getAllKeys(e, t, n) {
|
|
1028
|
+
const i = getKeys(e, t);
|
|
1029
|
+
const r = Object.keys(n);
|
|
1030
|
+
return Array.from(new Set([...i, ...r]));
|
|
1031
|
+
}
|
|
1032
|
+
function applyState(e, t, n, i) {
|
|
1033
|
+
const r = t?.[$TARGET];
|
|
1034
|
+
if (!r) return;
|
|
1035
|
+
const s = r[STORE_VALUE];
|
|
1036
|
+
const o = r[STORE_OVERRIDE];
|
|
1037
|
+
let u = r[STORE_NODE];
|
|
1038
|
+
if (e === s && !o) return;
|
|
1039
|
+
(r[STORE_LOOKUP] || storeLookup).set(e, r[$PROXY]);
|
|
1040
|
+
r[STORE_VALUE] = e;
|
|
1041
|
+
r[STORE_OVERRIDE] = undefined;
|
|
1042
|
+
if (Array.isArray(s)) {
|
|
1043
|
+
let t = false;
|
|
1044
|
+
const l = getOverrideValue(s, o, u, "length");
|
|
1045
|
+
if (e.length && l && e[0] && n(e[0]) != null) {
|
|
1046
|
+
let c, a, f, E, d, T, R, h;
|
|
1047
|
+
for (
|
|
1048
|
+
f = 0, E = Math.min(l, e.length);
|
|
1049
|
+
f < E && ((T = getOverrideValue(s, o, u, f)) === e[f] || (T && e[f] && n(T) === n(e[f])));
|
|
1050
|
+
f++
|
|
1051
|
+
) {
|
|
1052
|
+
applyState(e[f], wrap(T, r), n, i);
|
|
1163
1053
|
}
|
|
1164
|
-
const
|
|
1165
|
-
|
|
1166
|
-
|
|
1054
|
+
const _ = new Array(e.length),
|
|
1055
|
+
S = new Map();
|
|
1056
|
+
for (
|
|
1057
|
+
E = l - 1, d = e.length - 1;
|
|
1058
|
+
E >= f &&
|
|
1059
|
+
d >= f &&
|
|
1060
|
+
((T = getOverrideValue(s, o, u, E)) === e[d] || (T && e[d] && n(T) === n(e[d])));
|
|
1061
|
+
E--, d--
|
|
1062
|
+
) {
|
|
1063
|
+
_[d] = T;
|
|
1167
1064
|
}
|
|
1168
|
-
if (
|
|
1169
|
-
for (
|
|
1170
|
-
|
|
1171
|
-
|
|
1065
|
+
if (f > d || f > E) {
|
|
1066
|
+
for (a = f; a <= d; a++) {
|
|
1067
|
+
t = true;
|
|
1068
|
+
r[STORE_NODE][a] && setSignal(r[STORE_NODE][a], wrap(e[a], r));
|
|
1172
1069
|
}
|
|
1173
|
-
for (;
|
|
1174
|
-
|
|
1175
|
-
const
|
|
1176
|
-
|
|
1177
|
-
applyState(
|
|
1070
|
+
for (; a < e.length; a++) {
|
|
1071
|
+
t = true;
|
|
1072
|
+
const s = wrap(_[a], r);
|
|
1073
|
+
r[STORE_NODE][a] && setSignal(r[STORE_NODE][a], s);
|
|
1074
|
+
applyState(e[a], s, n, i);
|
|
1178
1075
|
}
|
|
1179
|
-
|
|
1180
|
-
|
|
1076
|
+
t && r[STORE_NODE][$TRACK] && setSignal(r[STORE_NODE][$TRACK], void 0);
|
|
1077
|
+
l !== e.length && r[STORE_NODE].length && setSignal(r[STORE_NODE].length, e.length);
|
|
1181
1078
|
return;
|
|
1182
1079
|
}
|
|
1183
|
-
|
|
1184
|
-
for (
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1080
|
+
R = new Array(d + 1);
|
|
1081
|
+
for (a = d; a >= f; a--) {
|
|
1082
|
+
T = e[a];
|
|
1083
|
+
h = T ? n(T) : T;
|
|
1084
|
+
c = S.get(h);
|
|
1085
|
+
R[a] = c === undefined ? -1 : c;
|
|
1086
|
+
S.set(h, a);
|
|
1190
1087
|
}
|
|
1191
|
-
for (
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
if (
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1088
|
+
for (c = f; c <= E; c++) {
|
|
1089
|
+
T = getOverrideValue(s, o, u, c);
|
|
1090
|
+
h = T ? n(T) : T;
|
|
1091
|
+
a = S.get(h);
|
|
1092
|
+
if (a !== undefined && a !== -1) {
|
|
1093
|
+
_[a] = T;
|
|
1094
|
+
a = R[a];
|
|
1095
|
+
S.set(h, a);
|
|
1199
1096
|
}
|
|
1200
1097
|
}
|
|
1201
|
-
for (
|
|
1202
|
-
if (
|
|
1203
|
-
const
|
|
1204
|
-
|
|
1205
|
-
applyState(
|
|
1206
|
-
} else
|
|
1207
|
-
target[STORE_NODE][j] && setSignal(target[STORE_NODE][j], wrap(next[j], target));
|
|
1098
|
+
for (a = f; a < e.length; a++) {
|
|
1099
|
+
if (a in _) {
|
|
1100
|
+
const t = wrap(_[a], r);
|
|
1101
|
+
r[STORE_NODE][a] && setSignal(r[STORE_NODE][a], t);
|
|
1102
|
+
applyState(e[a], t, n, i);
|
|
1103
|
+
} else r[STORE_NODE][a] && setSignal(r[STORE_NODE][a], wrap(e[a], r));
|
|
1208
1104
|
}
|
|
1209
|
-
if (
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
isWrappable(item) && applyState(next[i], wrap(item, target), keyFn, all);
|
|
1105
|
+
if (f < e.length) t = true;
|
|
1106
|
+
} else if (l && e.length) {
|
|
1107
|
+
for (let t = 0, l = e.length; t < l; t++) {
|
|
1108
|
+
const l = getOverrideValue(s, o, u, t);
|
|
1109
|
+
isWrappable(l) && applyState(e[t], wrap(l, r), n, i);
|
|
1215
1110
|
}
|
|
1216
1111
|
}
|
|
1217
|
-
if (
|
|
1218
|
-
|
|
1219
|
-
|
|
1112
|
+
if (l !== e.length) {
|
|
1113
|
+
t = true;
|
|
1114
|
+
r[STORE_NODE].length && setSignal(r[STORE_NODE].length, e.length);
|
|
1220
1115
|
}
|
|
1221
|
-
|
|
1116
|
+
t && r[STORE_NODE][$TRACK] && setSignal(r[STORE_NODE][$TRACK], void 0);
|
|
1222
1117
|
return;
|
|
1223
1118
|
}
|
|
1224
|
-
if (
|
|
1225
|
-
const
|
|
1226
|
-
const
|
|
1227
|
-
for (let
|
|
1228
|
-
const
|
|
1229
|
-
const
|
|
1230
|
-
const
|
|
1231
|
-
let
|
|
1232
|
-
if (
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
const keyFn = typeof key === "string" ? (item) => item[key] : key;
|
|
1254
|
-
const eq = keyFn(state);
|
|
1255
|
-
if (eq !== void 0 && keyFn(value) !== keyFn(state))
|
|
1119
|
+
if (u) {
|
|
1120
|
+
const t = u[$TRACK];
|
|
1121
|
+
const l = t || i ? getAllKeys(s, o, e) : Object.keys(u);
|
|
1122
|
+
for (let c = 0, a = l.length; c < a; c++) {
|
|
1123
|
+
const a = l[c];
|
|
1124
|
+
const f = u[a];
|
|
1125
|
+
const E = unwrap(getOverrideValue(s, o, u, a));
|
|
1126
|
+
let d = unwrap(e[a]);
|
|
1127
|
+
if (E === d) continue;
|
|
1128
|
+
if (!E || !isWrappable(E) || (n(E) != null && n(E) !== n(d))) {
|
|
1129
|
+
t && setSignal(t, void 0);
|
|
1130
|
+
f && setSignal(f, isWrappable(d) ? wrap(d, r) : d);
|
|
1131
|
+
} else applyState(d, wrap(E, r), n, i);
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
if ((u = r[STORE_HAS])) {
|
|
1135
|
+
const t = Object.keys(u);
|
|
1136
|
+
for (let n = 0, i = t.length; n < i; n++) {
|
|
1137
|
+
const i = t[n];
|
|
1138
|
+
setSignal(u[i], i in e);
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
function reconcile(e, t, n = false) {
|
|
1143
|
+
return i => {
|
|
1144
|
+
if (i == null) throw new Error("Cannot reconcile null or undefined state");
|
|
1145
|
+
const r = typeof t === "string" ? e => e[t] : t;
|
|
1146
|
+
const s = r(i);
|
|
1147
|
+
if (s !== undefined && r(e) !== r(i))
|
|
1256
1148
|
throw new Error("Cannot reconcile states with different identity");
|
|
1257
|
-
applyState(
|
|
1149
|
+
applyState(e, i, r, n);
|
|
1258
1150
|
};
|
|
1259
1151
|
}
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
get(target, property, receiver) {
|
|
1268
|
-
const o = getOwner();
|
|
1269
|
-
const n = node;
|
|
1270
|
-
(!o || o !== n) && n && read(n);
|
|
1271
|
-
return storeTraps.get(target, property, receiver);
|
|
1272
|
-
}
|
|
1273
|
-
};
|
|
1274
|
-
const wrapProjection = (source) => {
|
|
1275
|
-
if (wrappedMap.has(source))
|
|
1276
|
-
return wrappedMap.get(source);
|
|
1277
|
-
if (source[$TARGET]?.[STORE_WRAP] === wrapProjection)
|
|
1278
|
-
return source;
|
|
1279
|
-
const wrapped = createStoreProxy(source, traps, {
|
|
1152
|
+
function createProjectionInternal(e, t = {}, n) {
|
|
1153
|
+
let i;
|
|
1154
|
+
const r = new WeakMap();
|
|
1155
|
+
const wrapProjection = e => {
|
|
1156
|
+
if (r.has(e)) return r.get(e);
|
|
1157
|
+
if (e[$TARGET]?.[STORE_WRAP] === wrapProjection) return e;
|
|
1158
|
+
const t = createStoreProxy(e, storeTraps, {
|
|
1280
1159
|
[STORE_WRAP]: wrapProjection,
|
|
1281
|
-
[STORE_LOOKUP]:
|
|
1160
|
+
[STORE_LOOKUP]: r,
|
|
1161
|
+
[STORE_FIREWALL]() {
|
|
1162
|
+
return i;
|
|
1163
|
+
}
|
|
1282
1164
|
});
|
|
1283
|
-
|
|
1284
|
-
return
|
|
1165
|
+
r.set(e, t);
|
|
1166
|
+
return t;
|
|
1285
1167
|
};
|
|
1286
|
-
const
|
|
1287
|
-
|
|
1288
|
-
storeSetter(
|
|
1289
|
-
const
|
|
1290
|
-
if (
|
|
1291
|
-
reconcile(
|
|
1168
|
+
const s = wrapProjection(t);
|
|
1169
|
+
i = computed(() => {
|
|
1170
|
+
storeSetter(s, t => {
|
|
1171
|
+
const i = e(t);
|
|
1172
|
+
if (i !== t && i !== undefined) {
|
|
1173
|
+
reconcile(i, n?.key || "id", n?.all)(t);
|
|
1292
1174
|
}
|
|
1293
1175
|
});
|
|
1294
1176
|
});
|
|
1295
|
-
return { store:
|
|
1296
|
-
}
|
|
1297
|
-
function createProjection(
|
|
1298
|
-
return createProjectionInternal(
|
|
1299
|
-
}
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
if (
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
if (
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
const
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
return
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
let value = tracked ? overridden || !proxySource ? read(nodes[property]) : (read(nodes[property]), storeValue[property]) : storeValue[property];
|
|
1410
|
-
value === $DELETED && (value = void 0);
|
|
1411
|
-
if (!tracked) {
|
|
1412
|
-
if (!overridden && typeof value === "function" && !storeValue.hasOwnProperty(property)) {
|
|
1413
|
-
let proto;
|
|
1414
|
-
return !Array.isArray(target[STORE_VALUE]) && (proto = Object.getPrototypeOf(target[STORE_VALUE])) && proto !== Object.prototype ? value.bind(storeValue) : value;
|
|
1177
|
+
return { store: s, node: i };
|
|
1178
|
+
}
|
|
1179
|
+
function createProjection(e, t = {}, n) {
|
|
1180
|
+
return createProjectionInternal(e, t, n).store;
|
|
1181
|
+
}
|
|
1182
|
+
const $TRACK = Symbol(0),
|
|
1183
|
+
$DEEP = Symbol(0),
|
|
1184
|
+
$TARGET = Symbol(0),
|
|
1185
|
+
$PROXY = Symbol(0),
|
|
1186
|
+
$DELETED = Symbol(0);
|
|
1187
|
+
const PARENTS = new WeakMap();
|
|
1188
|
+
const STORE_VALUE = "v",
|
|
1189
|
+
STORE_OVERRIDE = "o",
|
|
1190
|
+
STORE_NODE = "n",
|
|
1191
|
+
STORE_HAS = "h",
|
|
1192
|
+
STORE_WRAP = "w",
|
|
1193
|
+
STORE_LOOKUP = "l",
|
|
1194
|
+
STORE_FIREWALL = "f";
|
|
1195
|
+
function createStoreProxy(e, t = storeTraps, n) {
|
|
1196
|
+
let i;
|
|
1197
|
+
if (Array.isArray(e)) {
|
|
1198
|
+
i = [];
|
|
1199
|
+
i.v = e;
|
|
1200
|
+
} else i = { v: e };
|
|
1201
|
+
n && Object.assign(i, n);
|
|
1202
|
+
return (i[$PROXY] = new Proxy(i, t));
|
|
1203
|
+
}
|
|
1204
|
+
const storeLookup = new WeakMap();
|
|
1205
|
+
function wrap(e, t) {
|
|
1206
|
+
if (t?.[STORE_WRAP]) return t[STORE_WRAP](e, t);
|
|
1207
|
+
let n = e[$PROXY] || storeLookup.get(e);
|
|
1208
|
+
if (!n) storeLookup.set(e, (n = createStoreProxy(e)));
|
|
1209
|
+
return n;
|
|
1210
|
+
}
|
|
1211
|
+
function isWrappable(e) {
|
|
1212
|
+
return e != null && typeof e === "object" && !Object.isFrozen(e);
|
|
1213
|
+
}
|
|
1214
|
+
function getNodes(e, t) {
|
|
1215
|
+
let n = e[t];
|
|
1216
|
+
if (!n) e[t] = n = Object.create(null);
|
|
1217
|
+
return n;
|
|
1218
|
+
}
|
|
1219
|
+
function getNode(e, t, n, i, r = isEqual) {
|
|
1220
|
+
if (e[t]) return e[t];
|
|
1221
|
+
return (e[t] = signal(
|
|
1222
|
+
n,
|
|
1223
|
+
{
|
|
1224
|
+
equals: r,
|
|
1225
|
+
unobserved() {
|
|
1226
|
+
delete e[t];
|
|
1227
|
+
}
|
|
1228
|
+
},
|
|
1229
|
+
i
|
|
1230
|
+
));
|
|
1231
|
+
}
|
|
1232
|
+
function trackSelf(e, t = $TRACK) {
|
|
1233
|
+
getObserver() &&
|
|
1234
|
+
read(getNode(getNodes(e, STORE_NODE), t, undefined, e[STORE_FIREWALL]?.(), false));
|
|
1235
|
+
}
|
|
1236
|
+
function getKeys(e, t, n = true) {
|
|
1237
|
+
const i = untrack(() => (n ? Object.keys(e) : Reflect.ownKeys(e)));
|
|
1238
|
+
if (!t) return i;
|
|
1239
|
+
const r = new Set(i);
|
|
1240
|
+
const s = Reflect.ownKeys(t);
|
|
1241
|
+
for (const e of s) {
|
|
1242
|
+
if (t[e] !== $DELETED) r.add(e);
|
|
1243
|
+
else r.delete(e);
|
|
1244
|
+
}
|
|
1245
|
+
return Array.from(r);
|
|
1246
|
+
}
|
|
1247
|
+
function getPropertyDescriptor(e, t, n) {
|
|
1248
|
+
let i = e;
|
|
1249
|
+
if (t && n in t) {
|
|
1250
|
+
if (i[n] === $DELETED) return void 0;
|
|
1251
|
+
if (!(n in i)) i = t;
|
|
1252
|
+
}
|
|
1253
|
+
return Reflect.getOwnPropertyDescriptor(i, n);
|
|
1254
|
+
}
|
|
1255
|
+
let Writing = null;
|
|
1256
|
+
const storeTraps = {
|
|
1257
|
+
get(e, t, n) {
|
|
1258
|
+
if (t === $TARGET) return e;
|
|
1259
|
+
if (t === $PROXY) return n;
|
|
1260
|
+
if (t === $TRACK || t === $DEEP) {
|
|
1261
|
+
trackSelf(e, t);
|
|
1262
|
+
return n;
|
|
1263
|
+
}
|
|
1264
|
+
const i = getNodes(e, STORE_NODE);
|
|
1265
|
+
const r = i[t];
|
|
1266
|
+
const s = e[STORE_OVERRIDE] && t in e[STORE_OVERRIDE];
|
|
1267
|
+
const o = !!e[STORE_VALUE][$TARGET];
|
|
1268
|
+
const u = s ? e[STORE_OVERRIDE] : e[STORE_VALUE];
|
|
1269
|
+
if (!r) {
|
|
1270
|
+
const e = Object.getOwnPropertyDescriptor(u, t);
|
|
1271
|
+
if (e && e.get) return e.get.call(n);
|
|
1272
|
+
}
|
|
1273
|
+
if (Writing?.has(n)) {
|
|
1274
|
+
let n = r && (s || !o) ? (r.W !== NOT_PENDING ? r.W : r.j) : u[t];
|
|
1275
|
+
n === $DELETED && (n = undefined);
|
|
1276
|
+
if (!isWrappable(n)) return n;
|
|
1277
|
+
const i = wrap(n, e);
|
|
1278
|
+
Writing.add(i);
|
|
1279
|
+
return i;
|
|
1280
|
+
}
|
|
1281
|
+
let l = r ? (s || !o ? read(i[t]) : (read(i[t]), u[t])) : u[t];
|
|
1282
|
+
l === $DELETED && (l = undefined);
|
|
1283
|
+
if (!r) {
|
|
1284
|
+
if (!s && typeof l === "function" && !u.hasOwnProperty(t)) {
|
|
1285
|
+
let t;
|
|
1286
|
+
return !Array.isArray(e[STORE_VALUE]) &&
|
|
1287
|
+
(t = Object.getPrototypeOf(e[STORE_VALUE])) &&
|
|
1288
|
+
t !== Object.prototype
|
|
1289
|
+
? l.bind(u)
|
|
1290
|
+
: l;
|
|
1415
1291
|
} else if (getObserver()) {
|
|
1416
|
-
return read(getNode(
|
|
1292
|
+
return read(getNode(i, t, isWrappable(l) ? wrap(l, e) : l, e[STORE_FIREWALL]?.()));
|
|
1417
1293
|
}
|
|
1418
1294
|
}
|
|
1419
|
-
return isWrappable(
|
|
1295
|
+
return isWrappable(l) ? wrap(l, e) : l;
|
|
1420
1296
|
},
|
|
1421
|
-
has(
|
|
1422
|
-
if (
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1297
|
+
has(e, t) {
|
|
1298
|
+
if (t === $PROXY || t === $TRACK || t === "__proto__") return true;
|
|
1299
|
+
const n =
|
|
1300
|
+
e[STORE_OVERRIDE] && t in e[STORE_OVERRIDE]
|
|
1301
|
+
? e[STORE_OVERRIDE][t] !== $DELETED
|
|
1302
|
+
: t in e[STORE_VALUE];
|
|
1303
|
+
getObserver() && read(getNode(getNodes(e, STORE_HAS), t, n, e[STORE_FIREWALL]?.()));
|
|
1304
|
+
return n;
|
|
1427
1305
|
},
|
|
1428
|
-
set(
|
|
1429
|
-
const
|
|
1430
|
-
if (Writing?.has(
|
|
1306
|
+
set(e, t, n) {
|
|
1307
|
+
const i = e[$PROXY];
|
|
1308
|
+
if (Writing?.has(e[$PROXY])) {
|
|
1431
1309
|
untrack(() => {
|
|
1432
|
-
const
|
|
1433
|
-
const
|
|
1434
|
-
const
|
|
1435
|
-
const
|
|
1436
|
-
if (
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
if (isWrappable(prev)) {
|
|
1445
|
-
const parents = PARENTS.get(prev);
|
|
1446
|
-
parents && (parents instanceof Set ? parents.delete(store) : PARENTS.delete(prev));
|
|
1310
|
+
const r = e[STORE_VALUE];
|
|
1311
|
+
const s = r[t];
|
|
1312
|
+
const o = e[STORE_OVERRIDE] && t in e[STORE_OVERRIDE] ? e[STORE_OVERRIDE][t] : s;
|
|
1313
|
+
const u = n?.[$TARGET]?.[STORE_VALUE] ?? n;
|
|
1314
|
+
if (o === u) return true;
|
|
1315
|
+
const l = e[STORE_OVERRIDE]?.length || r.length;
|
|
1316
|
+
if (u !== undefined && u === s) delete e[STORE_OVERRIDE][t];
|
|
1317
|
+
else (e[STORE_OVERRIDE] || (e[STORE_OVERRIDE] = Object.create(null)))[t] = u;
|
|
1318
|
+
const c = isWrappable(u);
|
|
1319
|
+
if (isWrappable(o)) {
|
|
1320
|
+
const e = PARENTS.get(o);
|
|
1321
|
+
e && (e instanceof Set ? e.delete(i) : PARENTS.delete(o));
|
|
1447
1322
|
}
|
|
1448
|
-
if (recursivelyNotify(
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
if (index > len)
|
|
1456
|
-
nodes.length && setSignal(nodes.length, index);
|
|
1323
|
+
if (recursivelyNotify(i, storeLookup) && c) recursivelyAddParent(u, i);
|
|
1324
|
+
e[STORE_HAS]?.[t] && setSignal(e[STORE_HAS][t], true);
|
|
1325
|
+
const a = getNodes(e, STORE_NODE);
|
|
1326
|
+
a[t] && setSignal(a[t], () => (c ? wrap(u, e) : u));
|
|
1327
|
+
if (Array.isArray(r)) {
|
|
1328
|
+
const e = parseInt(t) + 1;
|
|
1329
|
+
if (e > l) a.length && setSignal(a.length, e);
|
|
1457
1330
|
}
|
|
1458
|
-
|
|
1331
|
+
a[$TRACK] && setSignal(a[$TRACK], undefined);
|
|
1459
1332
|
});
|
|
1460
1333
|
}
|
|
1461
1334
|
return true;
|
|
1462
1335
|
},
|
|
1463
|
-
deleteProperty(
|
|
1464
|
-
if (Writing?.has(
|
|
1336
|
+
deleteProperty(e, t) {
|
|
1337
|
+
if (Writing?.has(e[$PROXY]) && e[STORE_OVERRIDE]?.[t] !== $DELETED) {
|
|
1465
1338
|
untrack(() => {
|
|
1466
|
-
const
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
if (isWrappable(
|
|
1474
|
-
const
|
|
1475
|
-
|
|
1339
|
+
const n =
|
|
1340
|
+
e[STORE_OVERRIDE] && t in e[STORE_OVERRIDE] ? e[STORE_OVERRIDE][t] : e[STORE_VALUE][t];
|
|
1341
|
+
if (t in e[STORE_VALUE]) {
|
|
1342
|
+
(e[STORE_OVERRIDE] || (e[STORE_OVERRIDE] = Object.create(null)))[t] = $DELETED;
|
|
1343
|
+
} else if (e[STORE_OVERRIDE] && t in e[STORE_OVERRIDE]) {
|
|
1344
|
+
delete e[STORE_OVERRIDE][t];
|
|
1345
|
+
} else return true;
|
|
1346
|
+
if (isWrappable(n)) {
|
|
1347
|
+
const t = PARENTS.get(n);
|
|
1348
|
+
t && (t instanceof Set ? t.delete(e) : PARENTS.delete(n));
|
|
1476
1349
|
}
|
|
1477
|
-
if (
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
nodes[$TRACK] && setSignal(nodes[$TRACK], void 0);
|
|
1350
|
+
if (e[STORE_HAS]?.[t]) setSignal(e[STORE_HAS][t], false);
|
|
1351
|
+
const i = getNodes(e, STORE_NODE);
|
|
1352
|
+
i[t] && setSignal(i[t], undefined);
|
|
1353
|
+
i[$TRACK] && setSignal(i[$TRACK], undefined);
|
|
1482
1354
|
});
|
|
1483
1355
|
}
|
|
1484
1356
|
return true;
|
|
1485
1357
|
},
|
|
1486
|
-
ownKeys(
|
|
1487
|
-
trackSelf(
|
|
1488
|
-
return getKeys(
|
|
1358
|
+
ownKeys(e) {
|
|
1359
|
+
trackSelf(e);
|
|
1360
|
+
return getKeys(e[STORE_VALUE], e[STORE_OVERRIDE], false);
|
|
1489
1361
|
},
|
|
1490
|
-
getOwnPropertyDescriptor(
|
|
1491
|
-
if (
|
|
1492
|
-
|
|
1493
|
-
return getPropertyDescriptor(target[STORE_VALUE], target[STORE_OVERRIDE], property);
|
|
1362
|
+
getOwnPropertyDescriptor(e, t) {
|
|
1363
|
+
if (t === $PROXY) return { value: e[$PROXY], writable: true, configurable: true };
|
|
1364
|
+
return getPropertyDescriptor(e[STORE_VALUE], e[STORE_OVERRIDE], t);
|
|
1494
1365
|
},
|
|
1495
|
-
getPrototypeOf(
|
|
1496
|
-
return Object.getPrototypeOf(
|
|
1366
|
+
getPrototypeOf(e) {
|
|
1367
|
+
return Object.getPrototypeOf(e[STORE_VALUE]);
|
|
1497
1368
|
}
|
|
1498
1369
|
};
|
|
1499
|
-
function storeSetter(
|
|
1500
|
-
const
|
|
1501
|
-
Writing =
|
|
1502
|
-
Writing.add(
|
|
1370
|
+
function storeSetter(e, t) {
|
|
1371
|
+
const n = Writing;
|
|
1372
|
+
Writing = new Set();
|
|
1373
|
+
Writing.add(e);
|
|
1503
1374
|
try {
|
|
1504
|
-
const
|
|
1505
|
-
if (
|
|
1506
|
-
if (Array.isArray(
|
|
1507
|
-
for (let
|
|
1508
|
-
|
|
1509
|
-
store.length = value.length;
|
|
1375
|
+
const n = t(e);
|
|
1376
|
+
if (n !== e && n !== undefined) {
|
|
1377
|
+
if (Array.isArray(n)) {
|
|
1378
|
+
for (let t = 0, i = n.length; t < i; t++) e[t] = n[t];
|
|
1379
|
+
e.length = n.length;
|
|
1510
1380
|
} else {
|
|
1511
|
-
const
|
|
1512
|
-
|
|
1513
|
-
if (
|
|
1514
|
-
|
|
1515
|
-
else
|
|
1516
|
-
delete store[key];
|
|
1381
|
+
const t = new Set([...Object.keys(e), ...Object.keys(n)]);
|
|
1382
|
+
t.forEach(t => {
|
|
1383
|
+
if (t in n) e[t] = n[t];
|
|
1384
|
+
else delete e[t];
|
|
1517
1385
|
});
|
|
1518
1386
|
}
|
|
1519
1387
|
}
|
|
1520
1388
|
} finally {
|
|
1521
1389
|
Writing.clear();
|
|
1522
|
-
Writing =
|
|
1523
|
-
}
|
|
1524
|
-
}
|
|
1525
|
-
function createStore(
|
|
1526
|
-
const
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
let
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
if (
|
|
1544
|
-
for (let
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
}
|
|
1570
|
-
if (Array.isArray(state)) {
|
|
1571
|
-
const len = override?.length || state.length;
|
|
1572
|
-
for (let i = 0; i < len; i++) {
|
|
1573
|
-
const item = override && i in override ? override[i] : state[i];
|
|
1574
|
-
isWrappable(item) && recursivelyAddParent(item, state);
|
|
1390
|
+
Writing = n;
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
function createStore(e, t, n) {
|
|
1394
|
+
const i = typeof e === "function",
|
|
1395
|
+
r = i ? createProjectionInternal(e, t, n).store : wrap(e);
|
|
1396
|
+
return [r, e => storeSetter(r, e)];
|
|
1397
|
+
}
|
|
1398
|
+
function recursivelyNotify(e, t) {
|
|
1399
|
+
let n = e[$TARGET] || t?.get(e)?.[$TARGET];
|
|
1400
|
+
let i = false;
|
|
1401
|
+
if (n) {
|
|
1402
|
+
const e = getNodes(n, STORE_NODE)[$DEEP];
|
|
1403
|
+
if (e) {
|
|
1404
|
+
setSignal(e, undefined);
|
|
1405
|
+
i = true;
|
|
1406
|
+
}
|
|
1407
|
+
t = n[STORE_LOOKUP] || t;
|
|
1408
|
+
}
|
|
1409
|
+
const r = PARENTS.get(n?.[STORE_VALUE] || e);
|
|
1410
|
+
if (!r) return i;
|
|
1411
|
+
if (r instanceof Set) {
|
|
1412
|
+
for (let e of r) i = recursivelyNotify(e, t) || i;
|
|
1413
|
+
} else i = recursivelyNotify(r, t) || i;
|
|
1414
|
+
return i;
|
|
1415
|
+
}
|
|
1416
|
+
function recursivelyAddParent(e, t) {
|
|
1417
|
+
let n;
|
|
1418
|
+
const i = e[$TARGET];
|
|
1419
|
+
if (i) {
|
|
1420
|
+
n = i[STORE_OVERRIDE];
|
|
1421
|
+
e = i[STORE_VALUE];
|
|
1422
|
+
}
|
|
1423
|
+
if (t) {
|
|
1424
|
+
let n = PARENTS.get(e);
|
|
1425
|
+
if (!n) PARENTS.set(e, t);
|
|
1426
|
+
else if (n !== t) {
|
|
1427
|
+
if (!(n instanceof Set)) PARENTS.set(e, (n = new Set([n])));
|
|
1428
|
+
else if (n.has(t)) return;
|
|
1429
|
+
n.add(t);
|
|
1430
|
+
} else return;
|
|
1431
|
+
}
|
|
1432
|
+
if (Array.isArray(e)) {
|
|
1433
|
+
const t = n?.length || e.length;
|
|
1434
|
+
for (let i = 0; i < t; i++) {
|
|
1435
|
+
const t = n && i in n ? n[i] : e[i];
|
|
1436
|
+
isWrappable(t) && recursivelyAddParent(t, e);
|
|
1575
1437
|
}
|
|
1576
1438
|
} else {
|
|
1577
|
-
const
|
|
1578
|
-
for (let i = 0; i <
|
|
1579
|
-
const
|
|
1580
|
-
const
|
|
1581
|
-
isWrappable(
|
|
1439
|
+
const t = getKeys(e, n);
|
|
1440
|
+
for (let i = 0; i < t.length; i++) {
|
|
1441
|
+
const r = t[i];
|
|
1442
|
+
const s = n && r in n ? n[r] : e[r];
|
|
1443
|
+
isWrappable(s) && recursivelyAddParent(s, e);
|
|
1582
1444
|
}
|
|
1583
1445
|
}
|
|
1584
1446
|
}
|
|
1585
|
-
function deep(
|
|
1586
|
-
recursivelyAddParent(
|
|
1587
|
-
return
|
|
1447
|
+
function deep(e) {
|
|
1448
|
+
recursivelyAddParent(e);
|
|
1449
|
+
return e[$DEEP];
|
|
1588
1450
|
}
|
|
1589
|
-
|
|
1590
|
-
// src/store/optimistic.ts
|
|
1591
|
-
function createOptimisticStore(first, second, options) {
|
|
1451
|
+
function createOptimisticStore(e, t, n) {
|
|
1592
1452
|
return [];
|
|
1593
1453
|
}
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
if (!
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
override = target[STORE_OVERRIDE];
|
|
1606
|
-
isArray = Array.isArray(target[STORE_VALUE]);
|
|
1607
|
-
map.set(
|
|
1608
|
-
item,
|
|
1609
|
-
override ? result = isArray ? [] : Object.create(Object.getPrototypeOf(target[STORE_VALUE])) : target[STORE_VALUE]
|
|
1454
|
+
function snapshot(e, t, n) {
|
|
1455
|
+
let i, r, s, o, u, l;
|
|
1456
|
+
if (!isWrappable(e)) return e;
|
|
1457
|
+
if (t && t.has(e)) return t.get(e);
|
|
1458
|
+
if (!t) t = new Map();
|
|
1459
|
+
if ((i = e[$TARGET] || n?.get(e)?.[$TARGET])) {
|
|
1460
|
+
s = i[STORE_OVERRIDE];
|
|
1461
|
+
r = Array.isArray(i[STORE_VALUE]);
|
|
1462
|
+
t.set(
|
|
1463
|
+
e,
|
|
1464
|
+
s ? (o = r ? [] : Object.create(Object.getPrototypeOf(i[STORE_VALUE]))) : i[STORE_VALUE]
|
|
1610
1465
|
);
|
|
1611
|
-
|
|
1612
|
-
|
|
1466
|
+
e = i[STORE_VALUE];
|
|
1467
|
+
n = storeLookup;
|
|
1613
1468
|
} else {
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
}
|
|
1617
|
-
if (
|
|
1618
|
-
const
|
|
1619
|
-
for (let
|
|
1620
|
-
|
|
1621
|
-
if (
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
map.set(item, result = [...item]);
|
|
1626
|
-
result[i] = unwrapped;
|
|
1469
|
+
r = Array.isArray(e);
|
|
1470
|
+
t.set(e, e);
|
|
1471
|
+
}
|
|
1472
|
+
if (r) {
|
|
1473
|
+
const i = s?.length || e.length;
|
|
1474
|
+
for (let r = 0; r < i; r++) {
|
|
1475
|
+
l = s && r in s ? s[r] : e[r];
|
|
1476
|
+
if (l === $DELETED) continue;
|
|
1477
|
+
if ((u = snapshot(l, t, n)) !== l || o) {
|
|
1478
|
+
if (!o) t.set(e, (o = [...e]));
|
|
1479
|
+
o[r] = u;
|
|
1627
1480
|
}
|
|
1628
1481
|
}
|
|
1629
1482
|
} else {
|
|
1630
|
-
const
|
|
1631
|
-
for (let
|
|
1632
|
-
let
|
|
1633
|
-
const
|
|
1634
|
-
if (
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
Object.assign(result, item);
|
|
1483
|
+
const i = getKeys(e, s);
|
|
1484
|
+
for (let r = 0, c = i.length; r < c; r++) {
|
|
1485
|
+
let c = i[r];
|
|
1486
|
+
const a = getPropertyDescriptor(e, s, c);
|
|
1487
|
+
if (a.get) continue;
|
|
1488
|
+
l = s && c in s ? s[c] : e[c];
|
|
1489
|
+
if ((u = snapshot(l, t, n)) !== e[c] || o) {
|
|
1490
|
+
if (!o) {
|
|
1491
|
+
o = Object.create(Object.getPrototypeOf(e));
|
|
1492
|
+
Object.assign(o, e);
|
|
1641
1493
|
}
|
|
1642
|
-
|
|
1494
|
+
o[c] = u;
|
|
1643
1495
|
}
|
|
1644
1496
|
}
|
|
1645
1497
|
}
|
|
1646
|
-
return
|
|
1498
|
+
return o || e;
|
|
1647
1499
|
}
|
|
1648
1500
|
function trueFn() {
|
|
1649
1501
|
return true;
|
|
1650
1502
|
}
|
|
1651
|
-
|
|
1652
|
-
get(
|
|
1653
|
-
if (
|
|
1654
|
-
|
|
1655
|
-
return _.get(property);
|
|
1503
|
+
const propTraps = {
|
|
1504
|
+
get(e, t, n) {
|
|
1505
|
+
if (t === $PROXY) return n;
|
|
1506
|
+
return e.get(t);
|
|
1656
1507
|
},
|
|
1657
|
-
has(
|
|
1658
|
-
if (
|
|
1659
|
-
|
|
1660
|
-
return _.has(property);
|
|
1508
|
+
has(e, t) {
|
|
1509
|
+
if (t === $PROXY) return true;
|
|
1510
|
+
return e.has(t);
|
|
1661
1511
|
},
|
|
1662
1512
|
set: trueFn,
|
|
1663
1513
|
deleteProperty: trueFn,
|
|
1664
|
-
getOwnPropertyDescriptor(
|
|
1514
|
+
getOwnPropertyDescriptor(e, t) {
|
|
1665
1515
|
return {
|
|
1666
1516
|
configurable: true,
|
|
1667
1517
|
enumerable: true,
|
|
1668
1518
|
get() {
|
|
1669
|
-
return
|
|
1519
|
+
return e.get(t);
|
|
1670
1520
|
},
|
|
1671
1521
|
set: trueFn,
|
|
1672
1522
|
deleteProperty: trueFn
|
|
1673
1523
|
};
|
|
1674
1524
|
},
|
|
1675
|
-
ownKeys(
|
|
1676
|
-
return
|
|
1525
|
+
ownKeys(e) {
|
|
1526
|
+
return e.keys();
|
|
1677
1527
|
}
|
|
1678
1528
|
};
|
|
1679
|
-
function resolveSource(
|
|
1680
|
-
return !(
|
|
1681
|
-
}
|
|
1682
|
-
|
|
1683
|
-
function merge(...
|
|
1684
|
-
if (
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
flattened.push(
|
|
1696
|
-
typeof s === "function" ? (proxy = true, createMemo(s)) : s
|
|
1697
|
-
);
|
|
1698
|
-
}
|
|
1699
|
-
if (SUPPORTS_PROXY && proxy) {
|
|
1529
|
+
function resolveSource(e) {
|
|
1530
|
+
return !(e = typeof e === "function" ? e() : e) ? {} : e;
|
|
1531
|
+
}
|
|
1532
|
+
const $SOURCES = Symbol(0);
|
|
1533
|
+
function merge(...e) {
|
|
1534
|
+
if (e.length === 1 && typeof e[0] !== "function") return e[0];
|
|
1535
|
+
let t = false;
|
|
1536
|
+
const n = [];
|
|
1537
|
+
for (let i = 0; i < e.length; i++) {
|
|
1538
|
+
const r = e[i];
|
|
1539
|
+
t = t || (!!r && $PROXY in r);
|
|
1540
|
+
const s = !!r && r[$SOURCES];
|
|
1541
|
+
if (s) n.push(...s);
|
|
1542
|
+
else n.push(typeof r === "function" ? ((t = true), createMemo(r)) : r);
|
|
1543
|
+
}
|
|
1544
|
+
if (SUPPORTS_PROXY && t) {
|
|
1700
1545
|
return new Proxy(
|
|
1701
1546
|
{
|
|
1702
|
-
get(
|
|
1703
|
-
if (
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
if (property in s)
|
|
1708
|
-
return s[property];
|
|
1547
|
+
get(e) {
|
|
1548
|
+
if (e === $SOURCES) return n;
|
|
1549
|
+
for (let t = n.length - 1; t >= 0; t--) {
|
|
1550
|
+
const i = resolveSource(n[t]);
|
|
1551
|
+
if (e in i) return i[e];
|
|
1709
1552
|
}
|
|
1710
1553
|
},
|
|
1711
|
-
has(
|
|
1712
|
-
for (let
|
|
1713
|
-
if (
|
|
1714
|
-
return true;
|
|
1554
|
+
has(e) {
|
|
1555
|
+
for (let t = n.length - 1; t >= 0; t--) {
|
|
1556
|
+
if (e in resolveSource(n[t])) return true;
|
|
1715
1557
|
}
|
|
1716
1558
|
return false;
|
|
1717
1559
|
},
|
|
1718
1560
|
keys() {
|
|
1719
|
-
const
|
|
1720
|
-
for (let
|
|
1721
|
-
|
|
1722
|
-
return [...new Set(keys)];
|
|
1561
|
+
const e = [];
|
|
1562
|
+
for (let t = 0; t < n.length; t++) e.push(...Object.keys(resolveSource(n[t])));
|
|
1563
|
+
return [...new Set(e)];
|
|
1723
1564
|
}
|
|
1724
1565
|
},
|
|
1725
1566
|
propTraps
|
|
1726
1567
|
);
|
|
1727
1568
|
}
|
|
1728
|
-
const
|
|
1729
|
-
let
|
|
1730
|
-
let
|
|
1731
|
-
for (let
|
|
1732
|
-
const
|
|
1733
|
-
if (!
|
|
1734
|
-
|
|
1569
|
+
const i = Object.create(null);
|
|
1570
|
+
let r = false;
|
|
1571
|
+
let s = n.length - 1;
|
|
1572
|
+
for (let e = s; e >= 0; e--) {
|
|
1573
|
+
const t = n[e];
|
|
1574
|
+
if (!t) {
|
|
1575
|
+
e === s && s--;
|
|
1735
1576
|
continue;
|
|
1736
1577
|
}
|
|
1737
|
-
const
|
|
1738
|
-
for (let
|
|
1739
|
-
const
|
|
1740
|
-
if (
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
defined[key] = desc.get ? {
|
|
1746
|
-
enumerable: true,
|
|
1747
|
-
configurable: true,
|
|
1748
|
-
get: desc.get.bind(source)
|
|
1749
|
-
} : desc;
|
|
1578
|
+
const o = Object.getOwnPropertyNames(t);
|
|
1579
|
+
for (let n = o.length - 1; n >= 0; n--) {
|
|
1580
|
+
const u = o[n];
|
|
1581
|
+
if (u === "__proto__" || u === "constructor") continue;
|
|
1582
|
+
if (!i[u]) {
|
|
1583
|
+
r = r || e !== s;
|
|
1584
|
+
const n = Object.getOwnPropertyDescriptor(t, u);
|
|
1585
|
+
i[u] = n.get ? { enumerable: true, configurable: true, get: n.get.bind(t) } : n;
|
|
1750
1586
|
}
|
|
1751
1587
|
}
|
|
1752
1588
|
}
|
|
1753
|
-
if (!
|
|
1754
|
-
|
|
1755
|
-
const
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
if (
|
|
1760
|
-
|
|
1761
|
-
else
|
|
1762
|
-
target[key] = desc.value;
|
|
1589
|
+
if (!r) return n[s];
|
|
1590
|
+
const o = {};
|
|
1591
|
+
const u = Object.keys(i);
|
|
1592
|
+
for (let e = u.length - 1; e >= 0; e--) {
|
|
1593
|
+
const t = u[e],
|
|
1594
|
+
n = i[t];
|
|
1595
|
+
if (n.get) Object.defineProperty(o, t, n);
|
|
1596
|
+
else o[t] = n.value;
|
|
1763
1597
|
}
|
|
1764
|
-
|
|
1765
|
-
return
|
|
1598
|
+
o[$SOURCES] = n;
|
|
1599
|
+
return o;
|
|
1766
1600
|
}
|
|
1767
|
-
function omit(
|
|
1768
|
-
const
|
|
1769
|
-
if (SUPPORTS_PROXY && $PROXY in
|
|
1601
|
+
function omit(e, ...t) {
|
|
1602
|
+
const n = new Set(t);
|
|
1603
|
+
if (SUPPORTS_PROXY && $PROXY in e) {
|
|
1770
1604
|
return new Proxy(
|
|
1771
1605
|
{
|
|
1772
|
-
get(
|
|
1773
|
-
return
|
|
1606
|
+
get(t) {
|
|
1607
|
+
return n.has(t) ? undefined : e[t];
|
|
1774
1608
|
},
|
|
1775
|
-
has(
|
|
1776
|
-
return !
|
|
1609
|
+
has(t) {
|
|
1610
|
+
return !n.has(t) && t in e;
|
|
1777
1611
|
},
|
|
1778
1612
|
keys() {
|
|
1779
|
-
return Object.keys(
|
|
1613
|
+
return Object.keys(e).filter(e => !n.has(e));
|
|
1780
1614
|
}
|
|
1781
1615
|
},
|
|
1782
1616
|
propTraps
|
|
1783
1617
|
);
|
|
1784
1618
|
}
|
|
1785
|
-
const
|
|
1786
|
-
for (const
|
|
1787
|
-
if (!
|
|
1788
|
-
const
|
|
1789
|
-
!
|
|
1619
|
+
const i = {};
|
|
1620
|
+
for (const t of Object.getOwnPropertyNames(e)) {
|
|
1621
|
+
if (!n.has(t)) {
|
|
1622
|
+
const n = Object.getOwnPropertyDescriptor(e, t);
|
|
1623
|
+
!n.get && !n.set && n.enumerable && n.writable && n.configurable
|
|
1624
|
+
? (i[t] = n.value)
|
|
1625
|
+
: Object.defineProperty(i, t, n);
|
|
1790
1626
|
}
|
|
1791
1627
|
}
|
|
1792
|
-
return
|
|
1628
|
+
return i;
|
|
1793
1629
|
}
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
function mapArray(list, map, options) {
|
|
1797
|
-
const keyFn = typeof options?.keyed === "function" ? options.keyed : void 0;
|
|
1630
|
+
function mapArray(e, t, n) {
|
|
1631
|
+
const i = typeof n?.keyed === "function" ? n.keyed : undefined;
|
|
1798
1632
|
return createMemo(
|
|
1799
1633
|
updateKeyedMap.bind({
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1634
|
+
Ie: createOwner(),
|
|
1635
|
+
ge: 0,
|
|
1636
|
+
ye: e,
|
|
1637
|
+
Ce: [],
|
|
1638
|
+
De: t,
|
|
1639
|
+
Pe: [],
|
|
1640
|
+
we: [],
|
|
1641
|
+
be: i,
|
|
1642
|
+
Ve: i || n?.keyed === false ? [] : undefined,
|
|
1643
|
+
Ue: t.length > 1 ? [] : undefined,
|
|
1644
|
+
me: n?.fallback
|
|
1811
1645
|
})
|
|
1812
1646
|
);
|
|
1813
1647
|
}
|
|
1814
|
-
|
|
1648
|
+
const pureOptions = { pureWrite: true };
|
|
1815
1649
|
function updateKeyedMap() {
|
|
1816
|
-
const
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
this.
|
|
1844
|
-
this.
|
|
1845
|
-
this.
|
|
1650
|
+
const e = this.ye() || [],
|
|
1651
|
+
t = e.length;
|
|
1652
|
+
e[$TRACK];
|
|
1653
|
+
runWithOwner(this.Ie, () => {
|
|
1654
|
+
let n,
|
|
1655
|
+
i,
|
|
1656
|
+
r = this.Ve
|
|
1657
|
+
? () => {
|
|
1658
|
+
this.Ve[i] = signal(e[i], pureOptions);
|
|
1659
|
+
this.Ue && (this.Ue[i] = signal(i, pureOptions));
|
|
1660
|
+
return this.De(
|
|
1661
|
+
read.bind(null, this.Ve[i]),
|
|
1662
|
+
this.Ue ? read.bind(null, this.Ue[i]) : undefined
|
|
1663
|
+
);
|
|
1664
|
+
}
|
|
1665
|
+
: this.Ue
|
|
1666
|
+
? () => {
|
|
1667
|
+
const t = e[i];
|
|
1668
|
+
this.Ue[i] = signal(i, pureOptions);
|
|
1669
|
+
return this.De(() => t, read.bind(null, this.Ue[i]));
|
|
1670
|
+
}
|
|
1671
|
+
: () => {
|
|
1672
|
+
const t = e[i];
|
|
1673
|
+
return this.De(() => t);
|
|
1674
|
+
};
|
|
1675
|
+
if (t === 0) {
|
|
1676
|
+
if (this.ge !== 0) {
|
|
1677
|
+
this.Ie.dispose(false);
|
|
1678
|
+
this.we = [];
|
|
1679
|
+
this.Ce = [];
|
|
1680
|
+
this.Pe = [];
|
|
1681
|
+
this.ge = 0;
|
|
1682
|
+
this.Ve && (this.Ve = []);
|
|
1683
|
+
this.Ue && (this.Ue = []);
|
|
1846
1684
|
}
|
|
1847
|
-
if (this.
|
|
1848
|
-
this.
|
|
1849
|
-
this.a[0] = createOwner(),
|
|
1850
|
-
this.X
|
|
1851
|
-
);
|
|
1685
|
+
if (this.me && !this.Pe[0]) {
|
|
1686
|
+
this.Pe[0] = runWithOwner((this.we[0] = createOwner()), this.me);
|
|
1852
1687
|
}
|
|
1853
|
-
} else if (this.
|
|
1854
|
-
if (this.
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
this.
|
|
1859
|
-
this.d[j] = runWithOwner(this.a[j] = createOwner(), mapper);
|
|
1688
|
+
} else if (this.ge === 0) {
|
|
1689
|
+
if (this.we[0]) this.we[0].dispose();
|
|
1690
|
+
this.Pe = new Array(t);
|
|
1691
|
+
for (i = 0; i < t; i++) {
|
|
1692
|
+
this.Ce[i] = e[i];
|
|
1693
|
+
this.Pe[i] = runWithOwner((this.we[i] = createOwner()), r);
|
|
1860
1694
|
}
|
|
1861
|
-
this.
|
|
1695
|
+
this.ge = t;
|
|
1862
1696
|
} else {
|
|
1863
|
-
let
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1697
|
+
let s,
|
|
1698
|
+
o,
|
|
1699
|
+
u,
|
|
1700
|
+
l,
|
|
1701
|
+
c,
|
|
1702
|
+
a,
|
|
1703
|
+
f,
|
|
1704
|
+
E = new Array(t),
|
|
1705
|
+
d = new Array(t),
|
|
1706
|
+
T = this.Ve ? new Array(t) : undefined,
|
|
1707
|
+
R = this.Ue ? new Array(t) : undefined;
|
|
1708
|
+
for (
|
|
1709
|
+
s = 0, o = Math.min(this.ge, t);
|
|
1710
|
+
s < o && (this.Ce[s] === e[s] || (this.Ve && compare(this.be, this.Ce[s], e[s])));
|
|
1711
|
+
s++
|
|
1712
|
+
) {
|
|
1713
|
+
if (this.Ve) setSignal(this.Ve[s], e[s]);
|
|
1867
1714
|
}
|
|
1868
|
-
for (
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1715
|
+
for (
|
|
1716
|
+
o = this.ge - 1, u = t - 1;
|
|
1717
|
+
o >= s &&
|
|
1718
|
+
u >= s &&
|
|
1719
|
+
(this.Ce[o] === e[u] || (this.Ve && compare(this.be, this.Ce[o], e[u])));
|
|
1720
|
+
o--, u--
|
|
1721
|
+
) {
|
|
1722
|
+
E[u] = this.Pe[o];
|
|
1723
|
+
d[u] = this.we[o];
|
|
1724
|
+
T && (T[u] = this.Ve[o]);
|
|
1725
|
+
R && (R[u] = this.Ue[o]);
|
|
1873
1726
|
}
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
for (
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1727
|
+
a = new Map();
|
|
1728
|
+
f = new Array(u + 1);
|
|
1729
|
+
for (i = u; i >= s; i--) {
|
|
1730
|
+
l = e[i];
|
|
1731
|
+
c = this.be ? this.be(l) : l;
|
|
1732
|
+
n = a.get(c);
|
|
1733
|
+
f[i] = n === undefined ? -1 : n;
|
|
1734
|
+
a.set(c, i);
|
|
1882
1735
|
}
|
|
1883
|
-
for (
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
if (
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
} else
|
|
1895
|
-
this.a[i].dispose();
|
|
1736
|
+
for (n = s; n <= o; n++) {
|
|
1737
|
+
l = this.Ce[n];
|
|
1738
|
+
c = this.be ? this.be(l) : l;
|
|
1739
|
+
i = a.get(c);
|
|
1740
|
+
if (i !== undefined && i !== -1) {
|
|
1741
|
+
E[i] = this.Pe[n];
|
|
1742
|
+
d[i] = this.we[n];
|
|
1743
|
+
T && (T[i] = this.Ve[n]);
|
|
1744
|
+
R && (R[i] = this.Ue[n]);
|
|
1745
|
+
i = f[i];
|
|
1746
|
+
a.set(c, i);
|
|
1747
|
+
} else this.we[n].dispose();
|
|
1896
1748
|
}
|
|
1897
|
-
for (
|
|
1898
|
-
if (
|
|
1899
|
-
this.
|
|
1900
|
-
this.
|
|
1901
|
-
if (
|
|
1902
|
-
this.
|
|
1903
|
-
setSignal(this.
|
|
1749
|
+
for (i = s; i < t; i++) {
|
|
1750
|
+
if (i in E) {
|
|
1751
|
+
this.Pe[i] = E[i];
|
|
1752
|
+
this.we[i] = d[i];
|
|
1753
|
+
if (T) {
|
|
1754
|
+
this.Ve[i] = T[i];
|
|
1755
|
+
setSignal(this.Ve[i], e[i]);
|
|
1904
1756
|
}
|
|
1905
|
-
if (
|
|
1906
|
-
this.
|
|
1907
|
-
setSignal(this.
|
|
1757
|
+
if (R) {
|
|
1758
|
+
this.Ue[i] = R[i];
|
|
1759
|
+
setSignal(this.Ue[i], i);
|
|
1908
1760
|
}
|
|
1909
1761
|
} else {
|
|
1910
|
-
this.
|
|
1762
|
+
this.Pe[i] = runWithOwner((this.we[i] = createOwner()), r);
|
|
1911
1763
|
}
|
|
1912
1764
|
}
|
|
1913
|
-
this.
|
|
1914
|
-
this.
|
|
1765
|
+
this.Pe = this.Pe.slice(0, (this.ge = t));
|
|
1766
|
+
this.Ce = e.slice(0);
|
|
1915
1767
|
}
|
|
1916
1768
|
});
|
|
1917
|
-
return this.
|
|
1769
|
+
return this.Pe;
|
|
1918
1770
|
}
|
|
1919
|
-
function repeat(
|
|
1771
|
+
function repeat(e, t, n) {
|
|
1920
1772
|
return updateRepeat.bind({
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1773
|
+
Ie: createOwner(),
|
|
1774
|
+
ge: 0,
|
|
1775
|
+
ke: 0,
|
|
1776
|
+
ve: e,
|
|
1777
|
+
De: t,
|
|
1778
|
+
we: [],
|
|
1779
|
+
Pe: [],
|
|
1780
|
+
xe: n?.from,
|
|
1781
|
+
me: n?.fallback
|
|
1930
1782
|
});
|
|
1931
1783
|
}
|
|
1932
1784
|
function updateRepeat() {
|
|
1933
|
-
const
|
|
1934
|
-
const
|
|
1935
|
-
runWithOwner(this.
|
|
1936
|
-
if (
|
|
1937
|
-
if (this.
|
|
1938
|
-
this.
|
|
1939
|
-
this.
|
|
1940
|
-
this.
|
|
1941
|
-
this.
|
|
1785
|
+
const e = this.ve();
|
|
1786
|
+
const t = this.xe?.() || 0;
|
|
1787
|
+
runWithOwner(this.Ie, () => {
|
|
1788
|
+
if (e === 0) {
|
|
1789
|
+
if (this.ge !== 0) {
|
|
1790
|
+
this.Ie.dispose(false);
|
|
1791
|
+
this.we = [];
|
|
1792
|
+
this.Pe = [];
|
|
1793
|
+
this.ge = 0;
|
|
1942
1794
|
}
|
|
1943
|
-
if (this.
|
|
1944
|
-
this.
|
|
1945
|
-
this.a[0] = createOwner(),
|
|
1946
|
-
this.X
|
|
1947
|
-
);
|
|
1795
|
+
if (this.me && !this.Pe[0]) {
|
|
1796
|
+
this.Pe[0] = runWithOwner((this.we[0] = createOwner()), this.me);
|
|
1948
1797
|
}
|
|
1949
1798
|
return;
|
|
1950
1799
|
}
|
|
1951
|
-
const
|
|
1952
|
-
const
|
|
1953
|
-
if (this.
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
this.
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
this.a[i] = this.a[i - difference];
|
|
1969
|
-
this.d[i] = this.d[i - difference];
|
|
1970
|
-
i--;
|
|
1800
|
+
const n = t + e;
|
|
1801
|
+
const i = this.ke + this.ge;
|
|
1802
|
+
if (this.ge === 0 && this.we[0]) this.we[0].dispose();
|
|
1803
|
+
for (let e = n; e < i; e++) this.we[e - this.ke].dispose();
|
|
1804
|
+
if (this.ke < t) {
|
|
1805
|
+
let e = this.ke;
|
|
1806
|
+
while (e < t && e < this.ge) this.we[e++].dispose();
|
|
1807
|
+
this.we.splice(0, t - this.ke);
|
|
1808
|
+
this.Pe.splice(0, t - this.ke);
|
|
1809
|
+
} else if (this.ke > t) {
|
|
1810
|
+
let n = i - this.ke - 1;
|
|
1811
|
+
let r = this.ke - t;
|
|
1812
|
+
this.we.length = this.Pe.length = e;
|
|
1813
|
+
while (n >= r) {
|
|
1814
|
+
this.we[n] = this.we[n - r];
|
|
1815
|
+
this.Pe[n] = this.Pe[n - r];
|
|
1816
|
+
n--;
|
|
1971
1817
|
}
|
|
1972
|
-
for (let
|
|
1973
|
-
this.
|
|
1974
|
-
this.a[i2] = createOwner(),
|
|
1975
|
-
() => this.O(i2 + from)
|
|
1976
|
-
);
|
|
1818
|
+
for (let e = 0; e < r; e++) {
|
|
1819
|
+
this.Pe[e] = runWithOwner((this.we[e] = createOwner()), () => this.De(e + t));
|
|
1977
1820
|
}
|
|
1978
1821
|
}
|
|
1979
|
-
for (let
|
|
1980
|
-
this.
|
|
1981
|
-
this.a[i - from] = createOwner(),
|
|
1982
|
-
() => this.O(i)
|
|
1983
|
-
);
|
|
1822
|
+
for (let e = i; e < n; e++) {
|
|
1823
|
+
this.Pe[e - t] = runWithOwner((this.we[e - t] = createOwner()), () => this.De(e));
|
|
1984
1824
|
}
|
|
1985
|
-
this.
|
|
1986
|
-
this.
|
|
1987
|
-
this.
|
|
1825
|
+
this.Pe = this.Pe.slice(0, e);
|
|
1826
|
+
this.ke = t;
|
|
1827
|
+
this.ge = e;
|
|
1988
1828
|
});
|
|
1989
|
-
return this.
|
|
1990
|
-
}
|
|
1991
|
-
function compare(
|
|
1992
|
-
return
|
|
1993
|
-
}
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
if (this.Y & 1 /* Pending */ && !(this.f & 4 /* Uninitialized */)) {
|
|
2003
|
-
flags &= ~1 /* Pending */;
|
|
1829
|
+
return this.Pe;
|
|
1830
|
+
}
|
|
1831
|
+
function compare(e, t, n) {
|
|
1832
|
+
return e ? e(t) === e(n) : true;
|
|
1833
|
+
}
|
|
1834
|
+
function boundaryComputed(e, t) {
|
|
1835
|
+
const n = computed(e, undefined, {
|
|
1836
|
+
_e: {
|
|
1837
|
+
le() {
|
|
1838
|
+
let e = this.J;
|
|
1839
|
+
this.J &= ~this.Ge;
|
|
1840
|
+
if (this.Ge & STATUS_PENDING && !(this.J & STATUS_UNINITIALIZED)) {
|
|
1841
|
+
e &= ~STATUS_PENDING;
|
|
2004
1842
|
}
|
|
2005
|
-
this.
|
|
1843
|
+
this.Re.notify(this, this.Ge, e);
|
|
2006
1844
|
},
|
|
2007
|
-
|
|
1845
|
+
Ge: t
|
|
2008
1846
|
}
|
|
2009
1847
|
});
|
|
2010
|
-
|
|
2011
|
-
return
|
|
2012
|
-
}
|
|
2013
|
-
function createBoundChildren(
|
|
2014
|
-
const
|
|
2015
|
-
|
|
2016
|
-
onCleanup(() =>
|
|
2017
|
-
return runWithOwner(
|
|
2018
|
-
const
|
|
2019
|
-
return boundaryComputed(() => staleValues(() => flatten(read(
|
|
1848
|
+
n.Ge = t;
|
|
1849
|
+
return n;
|
|
1850
|
+
}
|
|
1851
|
+
function createBoundChildren(e, t, n, i) {
|
|
1852
|
+
const r = e.Re;
|
|
1853
|
+
r.addChild((e.Re = n));
|
|
1854
|
+
onCleanup(() => r.removeChild(e.Re));
|
|
1855
|
+
return runWithOwner(e, () => {
|
|
1856
|
+
const e = computed(t);
|
|
1857
|
+
return boundaryComputed(() => staleValues(() => flatten(read(e))), i);
|
|
2020
1858
|
});
|
|
2021
1859
|
}
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
constructor(
|
|
1860
|
+
class ConditionalQueue extends Queue {
|
|
1861
|
+
He;
|
|
1862
|
+
Qe = new Set();
|
|
1863
|
+
$ = new Set();
|
|
1864
|
+
constructor(e) {
|
|
2027
1865
|
super();
|
|
2028
|
-
this.
|
|
2029
|
-
}
|
|
2030
|
-
run(
|
|
2031
|
-
if (!
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
} else if (this.h.delete(node))
|
|
2042
|
-
type &= ~1 /* Pending */;
|
|
1866
|
+
this.He = e;
|
|
1867
|
+
}
|
|
1868
|
+
run(e) {
|
|
1869
|
+
if (!e || read(this.He)) return;
|
|
1870
|
+
return super.run(e);
|
|
1871
|
+
}
|
|
1872
|
+
notify(e, t, n) {
|
|
1873
|
+
if (read(this.He)) {
|
|
1874
|
+
if (t & STATUS_PENDING) {
|
|
1875
|
+
if (n & STATUS_PENDING) {
|
|
1876
|
+
this.$.add(e);
|
|
1877
|
+
t &= ~STATUS_PENDING;
|
|
1878
|
+
} else if (this.$.delete(e)) t &= ~STATUS_PENDING;
|
|
2043
1879
|
}
|
|
2044
|
-
if (
|
|
2045
|
-
if (
|
|
2046
|
-
this.
|
|
2047
|
-
|
|
2048
|
-
} else if (this.
|
|
2049
|
-
type &= ~2 /* Error */;
|
|
1880
|
+
if (t & STATUS_ERROR) {
|
|
1881
|
+
if (n & STATUS_ERROR) {
|
|
1882
|
+
this.Qe.add(e);
|
|
1883
|
+
t &= ~STATUS_ERROR;
|
|
1884
|
+
} else if (this.Qe.delete(e)) t &= ~STATUS_ERROR;
|
|
2050
1885
|
}
|
|
2051
1886
|
}
|
|
2052
|
-
return
|
|
1887
|
+
return t ? super.notify(e, t, n) : true;
|
|
2053
1888
|
}
|
|
2054
|
-
}
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
constructor(
|
|
1889
|
+
}
|
|
1890
|
+
class CollectionQueue extends Queue {
|
|
1891
|
+
$e;
|
|
1892
|
+
we = new Set();
|
|
1893
|
+
He = signal(false, { pureWrite: true });
|
|
1894
|
+
Le = false;
|
|
1895
|
+
constructor(e) {
|
|
2061
1896
|
super();
|
|
2062
|
-
this
|
|
2063
|
-
}
|
|
2064
|
-
run(
|
|
2065
|
-
if (!
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
if (
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
}
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
const
|
|
2088
|
-
const
|
|
1897
|
+
this.$e = e;
|
|
1898
|
+
}
|
|
1899
|
+
run(e) {
|
|
1900
|
+
if (!e || read(this.He)) return;
|
|
1901
|
+
return super.run(e);
|
|
1902
|
+
}
|
|
1903
|
+
notify(e, t, n) {
|
|
1904
|
+
if (!(t & this.$e) || (this.$e & STATUS_PENDING && this.Le)) return super.notify(e, t, n);
|
|
1905
|
+
if (n & this.$e) {
|
|
1906
|
+
this.we.add(e);
|
|
1907
|
+
if (this.we.size === 1) setSignal(this.He, true);
|
|
1908
|
+
} else if (this.we.size > 0) {
|
|
1909
|
+
this.we.delete(e);
|
|
1910
|
+
if (this.we.size === 0) setSignal(this.He, false);
|
|
1911
|
+
}
|
|
1912
|
+
t &= ~this.$e;
|
|
1913
|
+
return t ? super.notify(e, t, n) : true;
|
|
1914
|
+
}
|
|
1915
|
+
}
|
|
1916
|
+
var BoundaryMode;
|
|
1917
|
+
(function (e) {
|
|
1918
|
+
e["VISIBLE"] = "visible";
|
|
1919
|
+
e["HIDDEN"] = "hidden";
|
|
1920
|
+
})(BoundaryMode || (BoundaryMode = {}));
|
|
1921
|
+
function createBoundary(e, t) {
|
|
1922
|
+
const n = createOwner();
|
|
1923
|
+
const i = new ConditionalQueue(computed(() => t() === BoundaryMode.HIDDEN));
|
|
1924
|
+
const r = createBoundChildren(n, e, i, 0);
|
|
2089
1925
|
computed(() => {
|
|
2090
|
-
const
|
|
2091
|
-
|
|
2092
|
-
if (!
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
);
|
|
2096
|
-
|
|
2097
|
-
queue.h.clear();
|
|
2098
|
-
queue.ga.clear();
|
|
1926
|
+
const e = read(i.He);
|
|
1927
|
+
r.Ge = e ? STATUS_ERROR | STATUS_PENDING : 0;
|
|
1928
|
+
if (!e) {
|
|
1929
|
+
i.$.forEach(e => i.notify(e, STATUS_PENDING, STATUS_PENDING));
|
|
1930
|
+
i.Qe.forEach(e => i.notify(e, STATUS_ERROR, STATUS_ERROR));
|
|
1931
|
+
i.$.clear();
|
|
1932
|
+
i.Qe.clear();
|
|
2099
1933
|
}
|
|
2100
1934
|
});
|
|
2101
|
-
return () => read(
|
|
2102
|
-
}
|
|
2103
|
-
function createCollectionBoundary(
|
|
2104
|
-
const
|
|
2105
|
-
const
|
|
2106
|
-
const
|
|
2107
|
-
const
|
|
2108
|
-
if (!read(
|
|
2109
|
-
const
|
|
2110
|
-
if (!untrack(() => read(
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
return fallback(queue);
|
|
1935
|
+
return () => (read(i.He) ? undefined : read(r));
|
|
1936
|
+
}
|
|
1937
|
+
function createCollectionBoundary(e, t, n) {
|
|
1938
|
+
const i = createOwner();
|
|
1939
|
+
const r = new CollectionQueue(e);
|
|
1940
|
+
const s = createBoundChildren(i, t, r, e);
|
|
1941
|
+
const o = computed(() => {
|
|
1942
|
+
if (!read(r.He)) {
|
|
1943
|
+
const e = read(s);
|
|
1944
|
+
if (!untrack(() => read(r.He))) r.Le = true;
|
|
1945
|
+
return e;
|
|
1946
|
+
}
|
|
1947
|
+
return n(r);
|
|
2115
1948
|
});
|
|
2116
|
-
return read.bind(null,
|
|
2117
|
-
}
|
|
2118
|
-
function createLoadBoundary(
|
|
2119
|
-
return createCollectionBoundary(
|
|
2120
|
-
}
|
|
2121
|
-
function
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
1949
|
+
return read.bind(null, o);
|
|
1950
|
+
}
|
|
1951
|
+
function createLoadBoundary(e, t) {
|
|
1952
|
+
return createCollectionBoundary(STATUS_PENDING, e, () => t());
|
|
1953
|
+
}
|
|
1954
|
+
function collectErrorSources(e, t) {
|
|
1955
|
+
let n = true;
|
|
1956
|
+
let i = e.D;
|
|
1957
|
+
while (i !== null) {
|
|
1958
|
+
const e = i.V;
|
|
1959
|
+
if (e.D && e.J & STATUS_ERROR) {
|
|
1960
|
+
n = false;
|
|
1961
|
+
collectErrorSources(e, t);
|
|
1962
|
+
}
|
|
1963
|
+
i = i.P;
|
|
1964
|
+
}
|
|
1965
|
+
n && t.push(e);
|
|
1966
|
+
}
|
|
1967
|
+
function createErrorBoundary(e, t) {
|
|
1968
|
+
return createCollectionBoundary(STATUS_ERROR, e, e => {
|
|
1969
|
+
let n = e.we.values().next().value;
|
|
1970
|
+
return t(n.Y, () => {
|
|
1971
|
+
const t = [];
|
|
1972
|
+
for (const n of e.we) collectErrorSources(n, t);
|
|
1973
|
+
for (const e of t) recompute(e);
|
|
1974
|
+
schedule();
|
|
2128
1975
|
});
|
|
2129
1976
|
});
|
|
2130
1977
|
}
|
|
2131
|
-
function flatten(
|
|
2132
|
-
if (typeof
|
|
2133
|
-
if (
|
|
2134
|
-
return children;
|
|
1978
|
+
function flatten(e, t) {
|
|
1979
|
+
if (typeof e === "function" && !e.length) {
|
|
1980
|
+
if (t?.doNotUnwrap) return e;
|
|
2135
1981
|
do {
|
|
2136
|
-
|
|
2137
|
-
} while (typeof
|
|
1982
|
+
e = e();
|
|
1983
|
+
} while (typeof e === "function" && !e.length);
|
|
2138
1984
|
}
|
|
2139
|
-
if (
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
if (flattenArray(children, results, options)) {
|
|
1985
|
+
if (t?.skipNonRendered && (e == null || e === true || e === false || e === "")) return;
|
|
1986
|
+
if (Array.isArray(e)) {
|
|
1987
|
+
let n = [];
|
|
1988
|
+
if (flattenArray(e, n, t)) {
|
|
2144
1989
|
return () => {
|
|
2145
|
-
let
|
|
2146
|
-
flattenArray(
|
|
2147
|
-
return
|
|
1990
|
+
let e = [];
|
|
1991
|
+
flattenArray(n, e, { ...t, doNotUnwrap: false });
|
|
1992
|
+
return e;
|
|
2148
1993
|
};
|
|
2149
1994
|
}
|
|
2150
|
-
return
|
|
1995
|
+
return n;
|
|
2151
1996
|
}
|
|
2152
|
-
return
|
|
1997
|
+
return e;
|
|
2153
1998
|
}
|
|
2154
|
-
function flattenArray(
|
|
2155
|
-
let
|
|
2156
|
-
let
|
|
2157
|
-
for (let
|
|
1999
|
+
function flattenArray(e, t = [], n) {
|
|
2000
|
+
let i = null;
|
|
2001
|
+
let r = false;
|
|
2002
|
+
for (let s = 0; s < e.length; s++) {
|
|
2158
2003
|
try {
|
|
2159
|
-
let
|
|
2160
|
-
if (typeof
|
|
2161
|
-
if (
|
|
2162
|
-
|
|
2163
|
-
|
|
2004
|
+
let i = e[s];
|
|
2005
|
+
if (typeof i === "function" && !i.length) {
|
|
2006
|
+
if (n?.doNotUnwrap) {
|
|
2007
|
+
t.push(i);
|
|
2008
|
+
r = true;
|
|
2164
2009
|
continue;
|
|
2165
2010
|
}
|
|
2166
2011
|
do {
|
|
2167
|
-
|
|
2168
|
-
} while (typeof
|
|
2012
|
+
i = i();
|
|
2013
|
+
} while (typeof i === "function" && !i.length);
|
|
2169
2014
|
}
|
|
2170
|
-
if (Array.isArray(
|
|
2171
|
-
|
|
2172
|
-
} else if (
|
|
2173
|
-
} else
|
|
2174
|
-
results.push(child);
|
|
2015
|
+
if (Array.isArray(i)) {
|
|
2016
|
+
r = flattenArray(i, t, n);
|
|
2017
|
+
} else if (n?.skipNonRendered && (i == null || i === true || i === false || i === "")) {
|
|
2018
|
+
} else t.push(i);
|
|
2175
2019
|
} catch (e) {
|
|
2176
|
-
if (!(e instanceof NotReadyError))
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2020
|
+
if (!(e instanceof NotReadyError)) throw e;
|
|
2021
|
+
i = e;
|
|
2022
|
+
}
|
|
2023
|
+
}
|
|
2024
|
+
if (i) throw i;
|
|
2025
|
+
return r;
|
|
2026
|
+
}
|
|
2027
|
+
export {
|
|
2028
|
+
$PROXY,
|
|
2029
|
+
$TARGET,
|
|
2030
|
+
$TRACK,
|
|
2031
|
+
ContextNotFoundError,
|
|
2032
|
+
NoOwnerError,
|
|
2033
|
+
NotReadyError,
|
|
2034
|
+
SUPPORTS_PROXY,
|
|
2035
|
+
createAsync,
|
|
2036
|
+
createBoundary,
|
|
2037
|
+
createContext,
|
|
2038
|
+
createEffect,
|
|
2039
|
+
createErrorBoundary,
|
|
2040
|
+
createLoadBoundary,
|
|
2041
|
+
createMemo,
|
|
2042
|
+
createOptimistic,
|
|
2043
|
+
createOptimisticStore,
|
|
2044
|
+
createProjection,
|
|
2045
|
+
createReaction,
|
|
2046
|
+
createRenderEffect,
|
|
2047
|
+
createRoot,
|
|
2048
|
+
createSignal,
|
|
2049
|
+
createStore,
|
|
2050
|
+
createTrackedEffect,
|
|
2051
|
+
deep,
|
|
2052
|
+
flatten,
|
|
2053
|
+
flush,
|
|
2054
|
+
getContext,
|
|
2055
|
+
getNextChildId,
|
|
2056
|
+
getObserver,
|
|
2057
|
+
getOwner,
|
|
2058
|
+
isEqual,
|
|
2059
|
+
isPending,
|
|
2060
|
+
isWrappable,
|
|
2061
|
+
mapArray,
|
|
2062
|
+
merge,
|
|
2063
|
+
omit,
|
|
2064
|
+
onCleanup,
|
|
2065
|
+
onSettled,
|
|
2066
|
+
pending,
|
|
2067
|
+
reconcile,
|
|
2068
|
+
repeat,
|
|
2069
|
+
resolve,
|
|
2070
|
+
runWithOwner,
|
|
2071
|
+
setContext,
|
|
2072
|
+
snapshot,
|
|
2073
|
+
untrack
|
|
2074
|
+
};
|