@solidjs/signals 0.3.1 → 0.3.2
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 +23 -22
- package/dist/node.cjs +132 -131
- package/dist/prod.js +132 -131
- package/dist/types/core/boundaries.d.ts +1 -0
- package/dist/types/core/scheduler.d.ts +2 -2
- package/package.json +1 -1
package/dist/prod.js
CHANGED
|
@@ -43,66 +43,62 @@ function schedule() {
|
|
|
43
43
|
if (scheduled)
|
|
44
44
|
return;
|
|
45
45
|
scheduled = true;
|
|
46
|
-
if (!globalQueue.
|
|
46
|
+
if (!globalQueue.J)
|
|
47
47
|
queueMicrotask(flushSync);
|
|
48
48
|
}
|
|
49
|
+
var pureQueue = [];
|
|
49
50
|
var Queue = class {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
o = null;
|
|
52
|
+
J = false;
|
|
53
|
+
K = [[], []];
|
|
54
|
+
E = [];
|
|
54
55
|
created = clock;
|
|
55
56
|
enqueue(type, node) {
|
|
56
|
-
|
|
57
|
+
pureQueue.push(node);
|
|
57
58
|
if (type)
|
|
58
|
-
this.
|
|
59
|
+
this.K[type - 1].push(node);
|
|
59
60
|
schedule();
|
|
60
61
|
}
|
|
61
62
|
run(type) {
|
|
62
|
-
if (
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
63
|
+
if (type === EFFECT_PURE) {
|
|
64
|
+
pureQueue.length && runPureQueue(pureQueue);
|
|
65
|
+
pureQueue = [];
|
|
66
|
+
return;
|
|
67
|
+
} else if (this.K[type - 1].length) {
|
|
68
|
+
const effects = this.K[type - 1];
|
|
69
|
+
this.K[type - 1] = [];
|
|
70
|
+
runEffectQueue(effects);
|
|
71
71
|
}
|
|
72
|
-
let
|
|
73
|
-
|
|
74
|
-
rerun = this.F[i].run(type) || rerun;
|
|
72
|
+
for (let i = 0; i < this.E.length; i++) {
|
|
73
|
+
this.E[i].run(type);
|
|
75
74
|
}
|
|
76
|
-
if (type === EFFECT_PURE)
|
|
77
|
-
return rerun || !!this.s[type].length;
|
|
78
75
|
}
|
|
79
76
|
flush() {
|
|
80
|
-
if (this.
|
|
77
|
+
if (this.J)
|
|
81
78
|
return;
|
|
82
|
-
this.
|
|
79
|
+
this.J = true;
|
|
83
80
|
try {
|
|
84
|
-
|
|
85
|
-
}
|
|
81
|
+
this.run(EFFECT_PURE);
|
|
86
82
|
incrementClock();
|
|
87
83
|
scheduled = false;
|
|
88
84
|
this.run(EFFECT_RENDER);
|
|
89
85
|
this.run(EFFECT_USER);
|
|
90
86
|
} finally {
|
|
91
|
-
this.
|
|
87
|
+
this.J = false;
|
|
92
88
|
}
|
|
93
89
|
}
|
|
94
90
|
addChild(child) {
|
|
95
|
-
this.
|
|
96
|
-
child.
|
|
91
|
+
this.E.push(child);
|
|
92
|
+
child.o = this;
|
|
97
93
|
}
|
|
98
94
|
removeChild(child) {
|
|
99
|
-
const index = this.
|
|
95
|
+
const index = this.E.indexOf(child);
|
|
100
96
|
if (index >= 0)
|
|
101
|
-
this.
|
|
97
|
+
this.E.splice(index, 1);
|
|
102
98
|
}
|
|
103
99
|
notify(...args) {
|
|
104
|
-
if (this.
|
|
105
|
-
return this.
|
|
100
|
+
if (this.o)
|
|
101
|
+
return this.o.notify(...args);
|
|
106
102
|
return false;
|
|
107
103
|
}
|
|
108
104
|
};
|
|
@@ -114,7 +110,7 @@ function flushSync() {
|
|
|
114
110
|
}
|
|
115
111
|
function runTop(node) {
|
|
116
112
|
const ancestors = [];
|
|
117
|
-
for (let current = node; current !== null; current = current.
|
|
113
|
+
for (let current = node; current !== null; current = current.o) {
|
|
118
114
|
if (current.a !== STATE_CLEAN) {
|
|
119
115
|
ancestors.push(current);
|
|
120
116
|
}
|
|
@@ -179,32 +175,32 @@ var Owner = class {
|
|
|
179
175
|
// We flatten the owner tree into a linked list so that we don't need a pointer to .firstChild
|
|
180
176
|
// However, the children are actually added in reverse creation order
|
|
181
177
|
// See comment at the top of the file for an example of the _nextSibling traversal
|
|
182
|
-
|
|
178
|
+
o = null;
|
|
183
179
|
m = null;
|
|
184
|
-
|
|
180
|
+
s = null;
|
|
185
181
|
a = STATE_CLEAN;
|
|
186
182
|
l = null;
|
|
187
|
-
|
|
183
|
+
p = defaultContext;
|
|
188
184
|
h = globalQueue;
|
|
189
185
|
W = 0;
|
|
190
186
|
id = null;
|
|
191
187
|
constructor(id = null, skipAppend = false) {
|
|
192
188
|
this.id = id;
|
|
193
189
|
if (currentOwner) {
|
|
194
|
-
if (
|
|
190
|
+
if (id == null && currentOwner.id != null)
|
|
195
191
|
this.id = currentOwner.getNextChildId();
|
|
196
192
|
!skipAppend && currentOwner.append(this);
|
|
197
193
|
}
|
|
198
194
|
}
|
|
199
195
|
append(child) {
|
|
200
|
-
child.
|
|
201
|
-
child.
|
|
196
|
+
child.o = this;
|
|
197
|
+
child.s = this;
|
|
202
198
|
if (this.m)
|
|
203
|
-
this.m.
|
|
199
|
+
this.m.s = child;
|
|
204
200
|
child.m = this.m;
|
|
205
201
|
this.m = child;
|
|
206
|
-
if (child.
|
|
207
|
-
child.
|
|
202
|
+
if (child.p !== this.p) {
|
|
203
|
+
child.p = { ...this.p, ...child.p };
|
|
208
204
|
}
|
|
209
205
|
if (this.h)
|
|
210
206
|
child.h = this.h;
|
|
@@ -212,8 +208,8 @@ var Owner = class {
|
|
|
212
208
|
dispose(self = true) {
|
|
213
209
|
if (this.a === STATE_DISPOSED)
|
|
214
210
|
return;
|
|
215
|
-
let head = self ? this.
|
|
216
|
-
while (current && current.
|
|
211
|
+
let head = self ? this.s || this.o : this, current = this.m, next = null;
|
|
212
|
+
while (current && current.o === this) {
|
|
217
213
|
current.dispose(true);
|
|
218
214
|
current.y();
|
|
219
215
|
next = current.m;
|
|
@@ -224,16 +220,16 @@ var Owner = class {
|
|
|
224
220
|
if (self)
|
|
225
221
|
this.y();
|
|
226
222
|
if (current)
|
|
227
|
-
current.
|
|
223
|
+
current.s = !self ? this : this.s;
|
|
228
224
|
if (head)
|
|
229
225
|
head.m = current;
|
|
230
226
|
}
|
|
231
227
|
y() {
|
|
232
|
-
if (this.
|
|
233
|
-
this.
|
|
234
|
-
this.
|
|
235
|
-
this.
|
|
236
|
-
this.
|
|
228
|
+
if (this.s)
|
|
229
|
+
this.s.m = null;
|
|
230
|
+
this.o = null;
|
|
231
|
+
this.s = null;
|
|
232
|
+
this.p = defaultContext;
|
|
237
233
|
this.a = STATE_DISPOSED;
|
|
238
234
|
this.emptyDisposal();
|
|
239
235
|
}
|
|
@@ -251,7 +247,7 @@ var Owner = class {
|
|
|
251
247
|
this.l = null;
|
|
252
248
|
}
|
|
253
249
|
getNextChildId() {
|
|
254
|
-
if (this.id)
|
|
250
|
+
if (this.id != null)
|
|
255
251
|
return formatId(this.id, this.W++);
|
|
256
252
|
throw new Error("Cannot get child id from owner without an id");
|
|
257
253
|
}
|
|
@@ -263,7 +259,7 @@ function getContext(context, owner = currentOwner) {
|
|
|
263
259
|
if (!owner) {
|
|
264
260
|
throw new NoOwnerError();
|
|
265
261
|
}
|
|
266
|
-
const value = hasContext(context, owner) ? owner.
|
|
262
|
+
const value = hasContext(context, owner) ? owner.p[context.id] : context.defaultValue;
|
|
267
263
|
if (isUndefined(value)) {
|
|
268
264
|
throw new ContextNotFoundError();
|
|
269
265
|
}
|
|
@@ -273,13 +269,13 @@ function setContext(context, value, owner = currentOwner) {
|
|
|
273
269
|
if (!owner) {
|
|
274
270
|
throw new NoOwnerError();
|
|
275
271
|
}
|
|
276
|
-
owner.
|
|
277
|
-
...owner.
|
|
272
|
+
owner.p = {
|
|
273
|
+
...owner.p,
|
|
278
274
|
[context.id]: isUndefined(value) ? context.defaultValue : value
|
|
279
275
|
};
|
|
280
276
|
}
|
|
281
277
|
function hasContext(context, owner = currentOwner) {
|
|
282
|
-
return !isUndefined(owner?.
|
|
278
|
+
return !isUndefined(owner?.p[context.id]);
|
|
283
279
|
}
|
|
284
280
|
function onCleanup(fn) {
|
|
285
281
|
if (!currentOwner)
|
|
@@ -321,7 +317,7 @@ var Computation = class extends Owner {
|
|
|
321
317
|
c = null;
|
|
322
318
|
e = null;
|
|
323
319
|
g;
|
|
324
|
-
|
|
320
|
+
F;
|
|
325
321
|
z;
|
|
326
322
|
// Used in __DEV__ mode, hopefully removed in production
|
|
327
323
|
ba;
|
|
@@ -334,7 +330,7 @@ var Computation = class extends Owner {
|
|
|
334
330
|
/** Which flags raised by sources are handled, vs. being passed through. */
|
|
335
331
|
T = DEFAULT_FLAGS;
|
|
336
332
|
A = -1;
|
|
337
|
-
|
|
333
|
+
w = false;
|
|
338
334
|
constructor(initialValue, compute2, options) {
|
|
339
335
|
super(null, compute2 === null);
|
|
340
336
|
this.z = compute2;
|
|
@@ -356,7 +352,7 @@ var Computation = class extends Owner {
|
|
|
356
352
|
track(this);
|
|
357
353
|
newFlags |= this.f & ~currentMask;
|
|
358
354
|
if (this.f & ERROR_BIT) {
|
|
359
|
-
throw this.
|
|
355
|
+
throw this.F;
|
|
360
356
|
} else {
|
|
361
357
|
return this.g;
|
|
362
358
|
}
|
|
@@ -396,7 +392,7 @@ var Computation = class extends Owner {
|
|
|
396
392
|
const valueChanged = newValue !== UNCHANGED && (!!(this.f & UNINITIALIZED_BIT) || this.f & LOADING_BIT & ~flags || this.S === false || !this.S(this.g, newValue));
|
|
397
393
|
if (valueChanged) {
|
|
398
394
|
this.g = newValue;
|
|
399
|
-
this.
|
|
395
|
+
this.F = void 0;
|
|
400
396
|
}
|
|
401
397
|
const changedFlagsMask = this.f ^ flags, changedFlags = changedFlagsMask & flags;
|
|
402
398
|
this.f = flags;
|
|
@@ -416,9 +412,9 @@ var Computation = class extends Owner {
|
|
|
416
412
|
* Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK
|
|
417
413
|
*/
|
|
418
414
|
r(state, skipQueue) {
|
|
419
|
-
if (this.a >= state && !this.
|
|
415
|
+
if (this.a >= state && !this.w)
|
|
420
416
|
return;
|
|
421
|
-
this.
|
|
417
|
+
this.w = !!skipQueue;
|
|
422
418
|
this.a = state;
|
|
423
419
|
if (this.e) {
|
|
424
420
|
for (let i = 0; i < this.e.length; i++) {
|
|
@@ -455,7 +451,7 @@ var Computation = class extends Owner {
|
|
|
455
451
|
}
|
|
456
452
|
}
|
|
457
453
|
L(error) {
|
|
458
|
-
this.
|
|
454
|
+
this.F = error;
|
|
459
455
|
this.write(UNCHANGED, this.f & ~LOADING_BIT | ERROR_BIT | UNINITIALIZED_BIT);
|
|
460
456
|
}
|
|
461
457
|
/**
|
|
@@ -756,27 +752,27 @@ function flattenArray(children, results = [], options) {
|
|
|
756
752
|
var Effect = class extends Computation {
|
|
757
753
|
M;
|
|
758
754
|
N;
|
|
759
|
-
|
|
755
|
+
B;
|
|
760
756
|
U = false;
|
|
761
757
|
O;
|
|
762
|
-
|
|
758
|
+
t;
|
|
763
759
|
constructor(initialValue, compute2, effect, error, options) {
|
|
764
760
|
super(initialValue, compute2, options);
|
|
765
761
|
this.M = effect;
|
|
766
762
|
this.N = error;
|
|
767
763
|
this.O = initialValue;
|
|
768
|
-
this.
|
|
769
|
-
if (this.
|
|
764
|
+
this.t = options?.render ? EFFECT_RENDER : EFFECT_USER;
|
|
765
|
+
if (this.t === EFFECT_RENDER) {
|
|
770
766
|
this.z = (p) => getClock() > this.h.created && !(this.f & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p);
|
|
771
767
|
}
|
|
772
768
|
this.x();
|
|
773
|
-
!options?.defer && (this.
|
|
769
|
+
!options?.defer && (this.t === EFFECT_USER ? this.h.enqueue(this.t, this) : this.V());
|
|
774
770
|
}
|
|
775
771
|
write(value, flags = 0) {
|
|
776
772
|
if (this.a == STATE_DIRTY) {
|
|
777
773
|
this.f;
|
|
778
774
|
this.f = flags;
|
|
779
|
-
if (this.
|
|
775
|
+
if (this.t === EFFECT_RENDER) {
|
|
780
776
|
this.h.notify(this, LOADING_BIT | ERROR_BIT, flags);
|
|
781
777
|
}
|
|
782
778
|
}
|
|
@@ -790,17 +786,17 @@ var Effect = class extends Computation {
|
|
|
790
786
|
if (this.a >= state || skipQueue)
|
|
791
787
|
return;
|
|
792
788
|
if (this.a === STATE_CLEAN)
|
|
793
|
-
this.h.enqueue(this.
|
|
789
|
+
this.h.enqueue(this.t, this);
|
|
794
790
|
this.a = state;
|
|
795
791
|
}
|
|
796
792
|
L(error) {
|
|
797
|
-
this.
|
|
798
|
-
this.
|
|
793
|
+
this.F = error;
|
|
794
|
+
this.B?.();
|
|
799
795
|
this.h.notify(this, LOADING_BIT, 0);
|
|
800
796
|
this.f = ERROR_BIT;
|
|
801
|
-
if (this.
|
|
797
|
+
if (this.t === EFFECT_USER) {
|
|
802
798
|
try {
|
|
803
|
-
return this.N ? this.
|
|
799
|
+
return this.N ? this.B = this.N(error) : console.error(new EffectError(this.M, error));
|
|
804
800
|
} catch (e) {
|
|
805
801
|
error = e;
|
|
806
802
|
}
|
|
@@ -814,15 +810,15 @@ var Effect = class extends Computation {
|
|
|
814
810
|
this.M = void 0;
|
|
815
811
|
this.O = void 0;
|
|
816
812
|
this.N = void 0;
|
|
817
|
-
this.
|
|
818
|
-
this.
|
|
813
|
+
this.B?.();
|
|
814
|
+
this.B = void 0;
|
|
819
815
|
super.y();
|
|
820
816
|
}
|
|
821
817
|
V() {
|
|
822
818
|
if (this.U && this.a !== STATE_DISPOSED) {
|
|
823
|
-
this.
|
|
819
|
+
this.B?.();
|
|
824
820
|
try {
|
|
825
|
-
this.
|
|
821
|
+
this.B = this.M(this.g, this.O);
|
|
826
822
|
} catch (e) {
|
|
827
823
|
if (!this.h.notify(this, ERROR_BIT, ERROR_BIT))
|
|
828
824
|
throw e;
|
|
@@ -839,9 +835,9 @@ var EagerComputation = class extends Computation {
|
|
|
839
835
|
!options?.defer && this.x();
|
|
840
836
|
}
|
|
841
837
|
r(state, skipQueue) {
|
|
842
|
-
if (this.a >= state && !this.
|
|
838
|
+
if (this.a >= state && !this.w)
|
|
843
839
|
return;
|
|
844
|
-
if (this.a === STATE_CLEAN &&
|
|
840
|
+
if (!skipQueue && (this.a === STATE_CLEAN || this.a === STATE_CHECK && this.w))
|
|
845
841
|
this.h.enqueue(EFFECT_PURE, this);
|
|
846
842
|
super.r(state, skipQueue);
|
|
847
843
|
}
|
|
@@ -851,28 +847,28 @@ var ProjectionComputation = class extends Computation {
|
|
|
851
847
|
super(void 0, compute2);
|
|
852
848
|
}
|
|
853
849
|
r(state, skipQueue) {
|
|
854
|
-
if (this.a >= state && !this.
|
|
850
|
+
if (this.a >= state && !this.w)
|
|
855
851
|
return;
|
|
856
|
-
if (!skipQueue && (this.a === STATE_CLEAN || this.a === STATE_CHECK && this.
|
|
852
|
+
if (!skipQueue && (this.a === STATE_CLEAN || this.a === STATE_CHECK && this.w))
|
|
857
853
|
this.h.enqueue(EFFECT_PURE, this);
|
|
858
854
|
super.r(state, true);
|
|
859
|
-
this.
|
|
855
|
+
this.w = !!skipQueue;
|
|
860
856
|
}
|
|
861
857
|
};
|
|
862
858
|
|
|
863
859
|
// src/core/boundaries.ts
|
|
864
860
|
var BoundaryComputation = class extends EagerComputation {
|
|
865
|
-
|
|
861
|
+
G;
|
|
866
862
|
constructor(compute2, propagationMask) {
|
|
867
863
|
super(void 0, compute2, { defer: true });
|
|
868
|
-
this.
|
|
864
|
+
this.G = propagationMask;
|
|
869
865
|
}
|
|
870
866
|
write(value, flags) {
|
|
871
|
-
super.write(value, flags & ~this.
|
|
872
|
-
if (this.
|
|
867
|
+
super.write(value, flags & ~this.G);
|
|
868
|
+
if (this.G & LOADING_BIT && !(this.f & UNINITIALIZED_BIT)) {
|
|
873
869
|
flags &= ~LOADING_BIT;
|
|
874
870
|
}
|
|
875
|
-
this.h.notify(this, this.
|
|
871
|
+
this.h.notify(this, this.G, flags);
|
|
876
872
|
return this.g;
|
|
877
873
|
}
|
|
878
874
|
};
|
|
@@ -890,20 +886,20 @@ function createBoundChildren(owner, fn, queue, mask) {
|
|
|
890
886
|
);
|
|
891
887
|
}
|
|
892
888
|
var ConditionalQueue = class extends Queue {
|
|
893
|
-
|
|
889
|
+
n;
|
|
894
890
|
P = /* @__PURE__ */ new Set();
|
|
895
891
|
Q = /* @__PURE__ */ new Set();
|
|
896
892
|
constructor(disabled) {
|
|
897
893
|
super();
|
|
898
|
-
this.
|
|
894
|
+
this.n = disabled;
|
|
899
895
|
}
|
|
900
896
|
run(type) {
|
|
901
|
-
if (type
|
|
897
|
+
if (!type || this.n.read())
|
|
902
898
|
return;
|
|
903
899
|
return super.run(type);
|
|
904
900
|
}
|
|
905
901
|
notify(node, type, flags) {
|
|
906
|
-
if (this.
|
|
902
|
+
if (this.n.read()) {
|
|
907
903
|
if (type === LOADING_BIT) {
|
|
908
904
|
flags & LOADING_BIT ? this.Q.add(node) : this.Q.delete(node);
|
|
909
905
|
}
|
|
@@ -918,22 +914,27 @@ var ConditionalQueue = class extends Queue {
|
|
|
918
914
|
var CollectionQueue = class extends Queue {
|
|
919
915
|
R;
|
|
920
916
|
b = /* @__PURE__ */ new Set();
|
|
921
|
-
|
|
917
|
+
n = new Computation(false, null);
|
|
922
918
|
constructor(type) {
|
|
923
919
|
super();
|
|
924
920
|
this.R = type;
|
|
925
921
|
}
|
|
922
|
+
run(type) {
|
|
923
|
+
if (!type || this.n.read())
|
|
924
|
+
return;
|
|
925
|
+
return super.run(type);
|
|
926
|
+
}
|
|
926
927
|
notify(node, type, flags) {
|
|
927
928
|
if (!(type & this.R))
|
|
928
929
|
return super.notify(node, type, flags);
|
|
929
930
|
if (flags & this.R) {
|
|
930
931
|
this.b.add(node);
|
|
931
932
|
if (this.b.size === 1)
|
|
932
|
-
this.
|
|
933
|
+
this.n.write(true);
|
|
933
934
|
} else {
|
|
934
935
|
this.b.delete(node);
|
|
935
936
|
if (this.b.size === 0)
|
|
936
|
-
this.
|
|
937
|
+
this.n.write(false);
|
|
937
938
|
}
|
|
938
939
|
type &= ~this.R;
|
|
939
940
|
return type ? super.notify(node, type, flags) : true;
|
|
@@ -944,8 +945,8 @@ function createBoundary(fn, condition) {
|
|
|
944
945
|
const queue = new ConditionalQueue(new Computation(void 0, () => condition() === "hidden" /* HIDDEN */));
|
|
945
946
|
const tree = createBoundChildren(owner, fn, queue, 0);
|
|
946
947
|
new EagerComputation(void 0, () => {
|
|
947
|
-
const disabled = queue.
|
|
948
|
-
tree.
|
|
948
|
+
const disabled = queue.n.read();
|
|
949
|
+
tree.G = disabled ? ERROR_BIT | LOADING_BIT : 0;
|
|
949
950
|
if (!disabled) {
|
|
950
951
|
queue.Q.forEach((node) => queue.notify(node, LOADING_BIT, LOADING_BIT));
|
|
951
952
|
queue.P.forEach((node) => queue.notify(node, ERROR_BIT, ERROR_BIT));
|
|
@@ -953,16 +954,16 @@ function createBoundary(fn, condition) {
|
|
|
953
954
|
queue.P.clear();
|
|
954
955
|
}
|
|
955
956
|
});
|
|
956
|
-
return () => queue.
|
|
957
|
+
return () => queue.n.read() ? void 0 : tree.read();
|
|
957
958
|
}
|
|
958
959
|
function createCollectionBoundary(type, fn, fallback) {
|
|
959
960
|
const owner = new Owner();
|
|
960
961
|
const queue = new CollectionQueue(type);
|
|
961
962
|
const tree = createBoundChildren(owner, fn, queue, type);
|
|
962
963
|
const decision = new Computation(void 0, () => {
|
|
963
|
-
if (!queue.
|
|
964
|
+
if (!queue.n.read()) {
|
|
964
965
|
const resolved = tree.read();
|
|
965
|
-
if (!queue.
|
|
966
|
+
if (!queue.n.read())
|
|
966
967
|
return resolved;
|
|
967
968
|
}
|
|
968
969
|
return fallback(queue);
|
|
@@ -976,11 +977,11 @@ function createErrorBoundary(fn, fallback) {
|
|
|
976
977
|
return createCollectionBoundary(
|
|
977
978
|
ERROR_BIT,
|
|
978
979
|
fn,
|
|
979
|
-
(queue) => fallback(queue.b.values().next().value.
|
|
980
|
+
(queue) => fallback(queue.b.values().next().value.F, () => {
|
|
980
981
|
incrementClock();
|
|
981
982
|
for (let node of queue.b) {
|
|
982
983
|
node.a = STATE_DIRTY;
|
|
983
|
-
node.h?.enqueue(node.
|
|
984
|
+
node.h?.enqueue(node.t, node);
|
|
984
985
|
}
|
|
985
986
|
})
|
|
986
987
|
);
|
|
@@ -1016,7 +1017,7 @@ function createMemo(compute2, value, options) {
|
|
|
1016
1017
|
return resolvedValue;
|
|
1017
1018
|
}
|
|
1018
1019
|
resolvedValue = node.wait();
|
|
1019
|
-
if (!node.c?.length && node.m?.
|
|
1020
|
+
if (!node.c?.length && node.m?.o !== node) {
|
|
1020
1021
|
node.dispose();
|
|
1021
1022
|
node = void 0;
|
|
1022
1023
|
}
|
|
@@ -1651,52 +1652,52 @@ function omit(props, ...keys) {
|
|
|
1651
1652
|
function mapArray(list, map, options) {
|
|
1652
1653
|
const keyFn = typeof options?.keyed === "function" ? options.keyed : void 0;
|
|
1653
1654
|
return updateKeyedMap.bind({
|
|
1654
|
-
|
|
1655
|
+
H: new Owner(),
|
|
1655
1656
|
i: 0,
|
|
1656
1657
|
_: list,
|
|
1657
|
-
|
|
1658
|
-
|
|
1658
|
+
u: [],
|
|
1659
|
+
C: map,
|
|
1659
1660
|
d: [],
|
|
1660
1661
|
b: [],
|
|
1661
|
-
|
|
1662
|
+
D: keyFn,
|
|
1662
1663
|
j: keyFn || options?.keyed === false ? [] : void 0,
|
|
1663
1664
|
k: map.length > 1 ? [] : void 0,
|
|
1664
|
-
|
|
1665
|
+
I: options?.fallback
|
|
1665
1666
|
});
|
|
1666
1667
|
}
|
|
1667
1668
|
function updateKeyedMap() {
|
|
1668
1669
|
const newItems = this._() || [], newLen = newItems.length;
|
|
1669
1670
|
newItems[$TRACK];
|
|
1670
|
-
runWithOwner(this.
|
|
1671
|
+
runWithOwner(this.H, () => {
|
|
1671
1672
|
let i, j, mapper = this.j ? () => {
|
|
1672
1673
|
this.j[j] = new Computation(newItems[j], null);
|
|
1673
1674
|
this.k && (this.k[j] = new Computation(j, null));
|
|
1674
|
-
return this.
|
|
1675
|
+
return this.C(
|
|
1675
1676
|
Computation.prototype.read.bind(this.j[j]),
|
|
1676
1677
|
this.k ? Computation.prototype.read.bind(this.k[j]) : void 0
|
|
1677
1678
|
);
|
|
1678
1679
|
} : this.k ? () => {
|
|
1679
1680
|
const item = newItems[j];
|
|
1680
1681
|
this.k[j] = new Computation(j, null);
|
|
1681
|
-
return this.
|
|
1682
|
+
return this.C(() => item, Computation.prototype.read.bind(this.k[j]));
|
|
1682
1683
|
} : () => {
|
|
1683
1684
|
const item = newItems[j];
|
|
1684
|
-
return this.
|
|
1685
|
+
return this.C(() => item);
|
|
1685
1686
|
};
|
|
1686
1687
|
if (newLen === 0) {
|
|
1687
1688
|
if (this.i !== 0) {
|
|
1688
|
-
this.
|
|
1689
|
+
this.H.dispose(false);
|
|
1689
1690
|
this.b = [];
|
|
1690
|
-
this.
|
|
1691
|
+
this.u = [];
|
|
1691
1692
|
this.d = [];
|
|
1692
1693
|
this.i = 0;
|
|
1693
1694
|
this.j && (this.j = []);
|
|
1694
1695
|
this.k && (this.k = []);
|
|
1695
1696
|
}
|
|
1696
|
-
if (this.
|
|
1697
|
+
if (this.I && !this.d[0]) {
|
|
1697
1698
|
this.d[0] = compute(
|
|
1698
1699
|
this.b[0] = new Owner(),
|
|
1699
|
-
this.
|
|
1700
|
+
this.I,
|
|
1700
1701
|
null
|
|
1701
1702
|
);
|
|
1702
1703
|
}
|
|
@@ -1705,17 +1706,17 @@ function updateKeyedMap() {
|
|
|
1705
1706
|
this.b[0].dispose();
|
|
1706
1707
|
this.d = new Array(newLen);
|
|
1707
1708
|
for (j = 0; j < newLen; j++) {
|
|
1708
|
-
this.
|
|
1709
|
+
this.u[j] = newItems[j];
|
|
1709
1710
|
this.d[j] = compute(this.b[j] = new Owner(), mapper, null);
|
|
1710
1711
|
}
|
|
1711
1712
|
this.i = newLen;
|
|
1712
1713
|
} else {
|
|
1713
1714
|
let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.j ? new Array(newLen) : void 0, tempIndexes = this.k ? new Array(newLen) : void 0;
|
|
1714
|
-
for (start = 0, end = Math.min(this.i, newLen); start < end && (this.
|
|
1715
|
+
for (start = 0, end = Math.min(this.i, newLen); start < end && (this.u[start] === newItems[start] || this.j && compare(this.D, this.u[start], newItems[start])); start++) {
|
|
1715
1716
|
if (this.j)
|
|
1716
1717
|
this.j[start].write(newItems[start]);
|
|
1717
1718
|
}
|
|
1718
|
-
for (end = this.i - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.
|
|
1719
|
+
for (end = this.i - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.u[end] === newItems[newEnd] || this.j && compare(this.D, this.u[end], newItems[newEnd])); end--, newEnd--) {
|
|
1719
1720
|
temp[newEnd] = this.d[end];
|
|
1720
1721
|
tempNodes[newEnd] = this.b[end];
|
|
1721
1722
|
tempRows && (tempRows[newEnd] = this.j[end]);
|
|
@@ -1725,14 +1726,14 @@ function updateKeyedMap() {
|
|
|
1725
1726
|
newIndicesNext = new Array(newEnd + 1);
|
|
1726
1727
|
for (j = newEnd; j >= start; j--) {
|
|
1727
1728
|
item = newItems[j];
|
|
1728
|
-
key = this.
|
|
1729
|
+
key = this.D ? this.D(item) : item;
|
|
1729
1730
|
i = newIndices.get(key);
|
|
1730
1731
|
newIndicesNext[j] = i === void 0 ? -1 : i;
|
|
1731
1732
|
newIndices.set(key, j);
|
|
1732
1733
|
}
|
|
1733
1734
|
for (i = start; i <= end; i++) {
|
|
1734
|
-
item = this.
|
|
1735
|
-
key = this.
|
|
1735
|
+
item = this.u[i];
|
|
1736
|
+
key = this.D ? this.D(item) : item;
|
|
1736
1737
|
j = newIndices.get(key);
|
|
1737
1738
|
if (j !== void 0 && j !== -1) {
|
|
1738
1739
|
temp[j] = this.d[i];
|
|
@@ -1761,39 +1762,39 @@ function updateKeyedMap() {
|
|
|
1761
1762
|
}
|
|
1762
1763
|
}
|
|
1763
1764
|
this.d = this.d.slice(0, this.i = newLen);
|
|
1764
|
-
this.
|
|
1765
|
+
this.u = newItems.slice(0);
|
|
1765
1766
|
}
|
|
1766
1767
|
});
|
|
1767
1768
|
return this.d;
|
|
1768
1769
|
}
|
|
1769
1770
|
function repeat(count, map, options) {
|
|
1770
1771
|
return updateRepeat.bind({
|
|
1771
|
-
|
|
1772
|
+
H: new Owner(),
|
|
1772
1773
|
i: 0,
|
|
1773
1774
|
q: 0,
|
|
1774
1775
|
$: count,
|
|
1775
|
-
|
|
1776
|
+
C: map,
|
|
1776
1777
|
b: [],
|
|
1777
1778
|
d: [],
|
|
1778
1779
|
aa: options?.from,
|
|
1779
|
-
|
|
1780
|
+
I: options?.fallback
|
|
1780
1781
|
});
|
|
1781
1782
|
}
|
|
1782
1783
|
function updateRepeat() {
|
|
1783
1784
|
const newLen = this.$();
|
|
1784
1785
|
const from = this.aa?.() || 0;
|
|
1785
|
-
runWithOwner(this.
|
|
1786
|
+
runWithOwner(this.H, () => {
|
|
1786
1787
|
if (newLen === 0) {
|
|
1787
1788
|
if (this.i !== 0) {
|
|
1788
|
-
this.
|
|
1789
|
+
this.H.dispose(false);
|
|
1789
1790
|
this.b = [];
|
|
1790
1791
|
this.d = [];
|
|
1791
1792
|
this.i = 0;
|
|
1792
1793
|
}
|
|
1793
|
-
if (this.
|
|
1794
|
+
if (this.I && !this.d[0]) {
|
|
1794
1795
|
this.d[0] = compute(
|
|
1795
1796
|
this.b[0] = new Owner(),
|
|
1796
|
-
this.
|
|
1797
|
+
this.I,
|
|
1797
1798
|
null
|
|
1798
1799
|
);
|
|
1799
1800
|
}
|
|
@@ -1823,7 +1824,7 @@ function updateRepeat() {
|
|
|
1823
1824
|
for (let i2 = 0; i2 < difference; i2++) {
|
|
1824
1825
|
this.d[i2] = compute(
|
|
1825
1826
|
this.b[i2] = new Owner(),
|
|
1826
|
-
() => this.
|
|
1827
|
+
() => this.C(i2 + from),
|
|
1827
1828
|
null
|
|
1828
1829
|
);
|
|
1829
1830
|
}
|
|
@@ -1831,7 +1832,7 @@ function updateRepeat() {
|
|
|
1831
1832
|
for (let i = prevTo; i < to; i++) {
|
|
1832
1833
|
this.d[i - from] = compute(
|
|
1833
1834
|
this.b[i - from] = new Owner(),
|
|
1834
|
-
() => this.
|
|
1835
|
+
() => this.C(i),
|
|
1835
1836
|
null
|
|
1836
1837
|
);
|
|
1837
1838
|
}
|
|
@@ -6,6 +6,7 @@ export declare class CollectionQueue extends Queue {
|
|
|
6
6
|
_nodes: Set<Effect>;
|
|
7
7
|
_disabled: Computation<boolean>;
|
|
8
8
|
constructor(type: number);
|
|
9
|
+
run(type: number): void;
|
|
9
10
|
notify(node: Effect, type: number, flags: number): boolean;
|
|
10
11
|
}
|
|
11
12
|
export declare enum BoundaryMode {
|
|
@@ -15,11 +15,11 @@ export interface IQueue {
|
|
|
15
15
|
export declare class Queue implements IQueue {
|
|
16
16
|
_parent: IQueue | null;
|
|
17
17
|
_running: boolean;
|
|
18
|
-
_queues: [
|
|
18
|
+
_queues: [Effect[], Effect[]];
|
|
19
19
|
_children: IQueue[];
|
|
20
20
|
created: number;
|
|
21
21
|
enqueue<T extends Computation | Effect>(type: number, node: T): void;
|
|
22
|
-
run(type: number):
|
|
22
|
+
run(type: number): void;
|
|
23
23
|
flush(): void;
|
|
24
24
|
addChild(child: IQueue): void;
|
|
25
25
|
removeChild(child: IQueue): void;
|