@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/node.cjs
CHANGED
|
@@ -45,66 +45,62 @@ function schedule() {
|
|
|
45
45
|
if (scheduled)
|
|
46
46
|
return;
|
|
47
47
|
scheduled = true;
|
|
48
|
-
if (!globalQueue.
|
|
48
|
+
if (!globalQueue.J)
|
|
49
49
|
queueMicrotask(flushSync);
|
|
50
50
|
}
|
|
51
|
+
var pureQueue = [];
|
|
51
52
|
var Queue = class {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
o = null;
|
|
54
|
+
J = false;
|
|
55
|
+
K = [[], []];
|
|
56
|
+
E = [];
|
|
56
57
|
created = clock;
|
|
57
58
|
enqueue(type, node) {
|
|
58
|
-
|
|
59
|
+
pureQueue.push(node);
|
|
59
60
|
if (type)
|
|
60
|
-
this.
|
|
61
|
+
this.K[type - 1].push(node);
|
|
61
62
|
schedule();
|
|
62
63
|
}
|
|
63
64
|
run(type) {
|
|
64
|
-
if (
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
65
|
+
if (type === EFFECT_PURE) {
|
|
66
|
+
pureQueue.length && runPureQueue(pureQueue);
|
|
67
|
+
pureQueue = [];
|
|
68
|
+
return;
|
|
69
|
+
} else if (this.K[type - 1].length) {
|
|
70
|
+
const effects = this.K[type - 1];
|
|
71
|
+
this.K[type - 1] = [];
|
|
72
|
+
runEffectQueue(effects);
|
|
73
73
|
}
|
|
74
|
-
let
|
|
75
|
-
|
|
76
|
-
rerun = this.F[i].run(type) || rerun;
|
|
74
|
+
for (let i = 0; i < this.E.length; i++) {
|
|
75
|
+
this.E[i].run(type);
|
|
77
76
|
}
|
|
78
|
-
if (type === EFFECT_PURE)
|
|
79
|
-
return rerun || !!this.s[type].length;
|
|
80
77
|
}
|
|
81
78
|
flush() {
|
|
82
|
-
if (this.
|
|
79
|
+
if (this.J)
|
|
83
80
|
return;
|
|
84
|
-
this.
|
|
81
|
+
this.J = true;
|
|
85
82
|
try {
|
|
86
|
-
|
|
87
|
-
}
|
|
83
|
+
this.run(EFFECT_PURE);
|
|
88
84
|
incrementClock();
|
|
89
85
|
scheduled = false;
|
|
90
86
|
this.run(EFFECT_RENDER);
|
|
91
87
|
this.run(EFFECT_USER);
|
|
92
88
|
} finally {
|
|
93
|
-
this.
|
|
89
|
+
this.J = false;
|
|
94
90
|
}
|
|
95
91
|
}
|
|
96
92
|
addChild(child) {
|
|
97
|
-
this.
|
|
98
|
-
child.
|
|
93
|
+
this.E.push(child);
|
|
94
|
+
child.o = this;
|
|
99
95
|
}
|
|
100
96
|
removeChild(child) {
|
|
101
|
-
const index = this.
|
|
97
|
+
const index = this.E.indexOf(child);
|
|
102
98
|
if (index >= 0)
|
|
103
|
-
this.
|
|
99
|
+
this.E.splice(index, 1);
|
|
104
100
|
}
|
|
105
101
|
notify(...args) {
|
|
106
|
-
if (this.
|
|
107
|
-
return this.
|
|
102
|
+
if (this.o)
|
|
103
|
+
return this.o.notify(...args);
|
|
108
104
|
return false;
|
|
109
105
|
}
|
|
110
106
|
};
|
|
@@ -116,7 +112,7 @@ function flushSync() {
|
|
|
116
112
|
}
|
|
117
113
|
function runTop(node) {
|
|
118
114
|
const ancestors = [];
|
|
119
|
-
for (let current = node; current !== null; current = current.
|
|
115
|
+
for (let current = node; current !== null; current = current.o) {
|
|
120
116
|
if (current.a !== STATE_CLEAN) {
|
|
121
117
|
ancestors.push(current);
|
|
122
118
|
}
|
|
@@ -181,32 +177,32 @@ var Owner = class {
|
|
|
181
177
|
// We flatten the owner tree into a linked list so that we don't need a pointer to .firstChild
|
|
182
178
|
// However, the children are actually added in reverse creation order
|
|
183
179
|
// See comment at the top of the file for an example of the _nextSibling traversal
|
|
184
|
-
|
|
180
|
+
o = null;
|
|
185
181
|
m = null;
|
|
186
|
-
|
|
182
|
+
s = null;
|
|
187
183
|
a = STATE_CLEAN;
|
|
188
184
|
l = null;
|
|
189
|
-
|
|
185
|
+
p = defaultContext;
|
|
190
186
|
h = globalQueue;
|
|
191
187
|
W = 0;
|
|
192
188
|
id = null;
|
|
193
189
|
constructor(id = null, skipAppend = false) {
|
|
194
190
|
this.id = id;
|
|
195
191
|
if (currentOwner) {
|
|
196
|
-
if (
|
|
192
|
+
if (id == null && currentOwner.id != null)
|
|
197
193
|
this.id = currentOwner.getNextChildId();
|
|
198
194
|
!skipAppend && currentOwner.append(this);
|
|
199
195
|
}
|
|
200
196
|
}
|
|
201
197
|
append(child) {
|
|
202
|
-
child.
|
|
203
|
-
child.
|
|
198
|
+
child.o = this;
|
|
199
|
+
child.s = this;
|
|
204
200
|
if (this.m)
|
|
205
|
-
this.m.
|
|
201
|
+
this.m.s = child;
|
|
206
202
|
child.m = this.m;
|
|
207
203
|
this.m = child;
|
|
208
|
-
if (child.
|
|
209
|
-
child.
|
|
204
|
+
if (child.p !== this.p) {
|
|
205
|
+
child.p = { ...this.p, ...child.p };
|
|
210
206
|
}
|
|
211
207
|
if (this.h)
|
|
212
208
|
child.h = this.h;
|
|
@@ -214,8 +210,8 @@ var Owner = class {
|
|
|
214
210
|
dispose(self = true) {
|
|
215
211
|
if (this.a === STATE_DISPOSED)
|
|
216
212
|
return;
|
|
217
|
-
let head = self ? this.
|
|
218
|
-
while (current && current.
|
|
213
|
+
let head = self ? this.s || this.o : this, current = this.m, next = null;
|
|
214
|
+
while (current && current.o === this) {
|
|
219
215
|
current.dispose(true);
|
|
220
216
|
current.y();
|
|
221
217
|
next = current.m;
|
|
@@ -226,16 +222,16 @@ var Owner = class {
|
|
|
226
222
|
if (self)
|
|
227
223
|
this.y();
|
|
228
224
|
if (current)
|
|
229
|
-
current.
|
|
225
|
+
current.s = !self ? this : this.s;
|
|
230
226
|
if (head)
|
|
231
227
|
head.m = current;
|
|
232
228
|
}
|
|
233
229
|
y() {
|
|
234
|
-
if (this.
|
|
235
|
-
this.
|
|
236
|
-
this.
|
|
237
|
-
this.
|
|
238
|
-
this.
|
|
230
|
+
if (this.s)
|
|
231
|
+
this.s.m = null;
|
|
232
|
+
this.o = null;
|
|
233
|
+
this.s = null;
|
|
234
|
+
this.p = defaultContext;
|
|
239
235
|
this.a = STATE_DISPOSED;
|
|
240
236
|
this.emptyDisposal();
|
|
241
237
|
}
|
|
@@ -253,7 +249,7 @@ var Owner = class {
|
|
|
253
249
|
this.l = null;
|
|
254
250
|
}
|
|
255
251
|
getNextChildId() {
|
|
256
|
-
if (this.id)
|
|
252
|
+
if (this.id != null)
|
|
257
253
|
return formatId(this.id, this.W++);
|
|
258
254
|
throw new Error("Cannot get child id from owner without an id");
|
|
259
255
|
}
|
|
@@ -265,7 +261,7 @@ function getContext(context, owner = currentOwner) {
|
|
|
265
261
|
if (!owner) {
|
|
266
262
|
throw new NoOwnerError();
|
|
267
263
|
}
|
|
268
|
-
const value = hasContext(context, owner) ? owner.
|
|
264
|
+
const value = hasContext(context, owner) ? owner.p[context.id] : context.defaultValue;
|
|
269
265
|
if (isUndefined(value)) {
|
|
270
266
|
throw new ContextNotFoundError();
|
|
271
267
|
}
|
|
@@ -275,13 +271,13 @@ function setContext(context, value, owner = currentOwner) {
|
|
|
275
271
|
if (!owner) {
|
|
276
272
|
throw new NoOwnerError();
|
|
277
273
|
}
|
|
278
|
-
owner.
|
|
279
|
-
...owner.
|
|
274
|
+
owner.p = {
|
|
275
|
+
...owner.p,
|
|
280
276
|
[context.id]: isUndefined(value) ? context.defaultValue : value
|
|
281
277
|
};
|
|
282
278
|
}
|
|
283
279
|
function hasContext(context, owner = currentOwner) {
|
|
284
|
-
return !isUndefined(owner == null ? void 0 : owner.
|
|
280
|
+
return !isUndefined(owner == null ? void 0 : owner.p[context.id]);
|
|
285
281
|
}
|
|
286
282
|
function onCleanup(fn) {
|
|
287
283
|
if (!currentOwner)
|
|
@@ -323,7 +319,7 @@ var Computation = class extends Owner {
|
|
|
323
319
|
c = null;
|
|
324
320
|
e = null;
|
|
325
321
|
g;
|
|
326
|
-
|
|
322
|
+
F;
|
|
327
323
|
z;
|
|
328
324
|
// Used in __DEV__ mode, hopefully removed in production
|
|
329
325
|
ba;
|
|
@@ -336,7 +332,7 @@ var Computation = class extends Owner {
|
|
|
336
332
|
/** Which flags raised by sources are handled, vs. being passed through. */
|
|
337
333
|
T = DEFAULT_FLAGS;
|
|
338
334
|
A = -1;
|
|
339
|
-
|
|
335
|
+
w = false;
|
|
340
336
|
constructor(initialValue, compute2, options) {
|
|
341
337
|
super(null, compute2 === null);
|
|
342
338
|
this.z = compute2;
|
|
@@ -358,7 +354,7 @@ var Computation = class extends Owner {
|
|
|
358
354
|
track(this);
|
|
359
355
|
newFlags |= this.f & ~currentMask;
|
|
360
356
|
if (this.f & ERROR_BIT) {
|
|
361
|
-
throw this.
|
|
357
|
+
throw this.F;
|
|
362
358
|
} else {
|
|
363
359
|
return this.g;
|
|
364
360
|
}
|
|
@@ -398,7 +394,7 @@ var Computation = class extends Owner {
|
|
|
398
394
|
const valueChanged = newValue !== UNCHANGED && (!!(this.f & UNINITIALIZED_BIT) || this.f & LOADING_BIT & ~flags || this.S === false || !this.S(this.g, newValue));
|
|
399
395
|
if (valueChanged) {
|
|
400
396
|
this.g = newValue;
|
|
401
|
-
this.
|
|
397
|
+
this.F = void 0;
|
|
402
398
|
}
|
|
403
399
|
const changedFlagsMask = this.f ^ flags, changedFlags = changedFlagsMask & flags;
|
|
404
400
|
this.f = flags;
|
|
@@ -418,9 +414,9 @@ var Computation = class extends Owner {
|
|
|
418
414
|
* Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK
|
|
419
415
|
*/
|
|
420
416
|
r(state, skipQueue) {
|
|
421
|
-
if (this.a >= state && !this.
|
|
417
|
+
if (this.a >= state && !this.w)
|
|
422
418
|
return;
|
|
423
|
-
this.
|
|
419
|
+
this.w = !!skipQueue;
|
|
424
420
|
this.a = state;
|
|
425
421
|
if (this.e) {
|
|
426
422
|
for (let i = 0; i < this.e.length; i++) {
|
|
@@ -457,7 +453,7 @@ var Computation = class extends Owner {
|
|
|
457
453
|
}
|
|
458
454
|
}
|
|
459
455
|
L(error) {
|
|
460
|
-
this.
|
|
456
|
+
this.F = error;
|
|
461
457
|
this.write(UNCHANGED, this.f & ~LOADING_BIT | ERROR_BIT | UNINITIALIZED_BIT);
|
|
462
458
|
}
|
|
463
459
|
/**
|
|
@@ -759,27 +755,27 @@ function flattenArray(children, results = [], options) {
|
|
|
759
755
|
var Effect = class extends Computation {
|
|
760
756
|
M;
|
|
761
757
|
N;
|
|
762
|
-
|
|
758
|
+
B;
|
|
763
759
|
U = false;
|
|
764
760
|
O;
|
|
765
|
-
|
|
761
|
+
t;
|
|
766
762
|
constructor(initialValue, compute2, effect, error, options) {
|
|
767
763
|
super(initialValue, compute2, options);
|
|
768
764
|
this.M = effect;
|
|
769
765
|
this.N = error;
|
|
770
766
|
this.O = initialValue;
|
|
771
|
-
this.
|
|
772
|
-
if (this.
|
|
767
|
+
this.t = (options == null ? void 0 : options.render) ? EFFECT_RENDER : EFFECT_USER;
|
|
768
|
+
if (this.t === EFFECT_RENDER) {
|
|
773
769
|
this.z = (p) => getClock() > this.h.created && !(this.f & ERROR_BIT) ? latest(() => compute2(p)) : compute2(p);
|
|
774
770
|
}
|
|
775
771
|
this.x();
|
|
776
|
-
!(options == null ? void 0 : options.defer) && (this.
|
|
772
|
+
!(options == null ? void 0 : options.defer) && (this.t === EFFECT_USER ? this.h.enqueue(this.t, this) : this.V());
|
|
777
773
|
}
|
|
778
774
|
write(value, flags = 0) {
|
|
779
775
|
if (this.a == STATE_DIRTY) {
|
|
780
776
|
this.f;
|
|
781
777
|
this.f = flags;
|
|
782
|
-
if (this.
|
|
778
|
+
if (this.t === EFFECT_RENDER) {
|
|
783
779
|
this.h.notify(this, LOADING_BIT | ERROR_BIT, flags);
|
|
784
780
|
}
|
|
785
781
|
}
|
|
@@ -793,18 +789,18 @@ var Effect = class extends Computation {
|
|
|
793
789
|
if (this.a >= state || skipQueue)
|
|
794
790
|
return;
|
|
795
791
|
if (this.a === STATE_CLEAN)
|
|
796
|
-
this.h.enqueue(this.
|
|
792
|
+
this.h.enqueue(this.t, this);
|
|
797
793
|
this.a = state;
|
|
798
794
|
}
|
|
799
795
|
L(error) {
|
|
800
796
|
var _a;
|
|
801
|
-
this.
|
|
802
|
-
(_a = this.
|
|
797
|
+
this.F = error;
|
|
798
|
+
(_a = this.B) == null ? void 0 : _a.call(this);
|
|
803
799
|
this.h.notify(this, LOADING_BIT, 0);
|
|
804
800
|
this.f = ERROR_BIT;
|
|
805
|
-
if (this.
|
|
801
|
+
if (this.t === EFFECT_USER) {
|
|
806
802
|
try {
|
|
807
|
-
return this.N ? this.
|
|
803
|
+
return this.N ? this.B = this.N(error) : console.error(new EffectError(this.M, error));
|
|
808
804
|
} catch (e) {
|
|
809
805
|
error = e;
|
|
810
806
|
}
|
|
@@ -819,16 +815,16 @@ var Effect = class extends Computation {
|
|
|
819
815
|
this.M = void 0;
|
|
820
816
|
this.O = void 0;
|
|
821
817
|
this.N = void 0;
|
|
822
|
-
(_a = this.
|
|
823
|
-
this.
|
|
818
|
+
(_a = this.B) == null ? void 0 : _a.call(this);
|
|
819
|
+
this.B = void 0;
|
|
824
820
|
super.y();
|
|
825
821
|
}
|
|
826
822
|
V() {
|
|
827
823
|
var _a;
|
|
828
824
|
if (this.U && this.a !== STATE_DISPOSED) {
|
|
829
|
-
(_a = this.
|
|
825
|
+
(_a = this.B) == null ? void 0 : _a.call(this);
|
|
830
826
|
try {
|
|
831
|
-
this.
|
|
827
|
+
this.B = this.M(this.g, this.O);
|
|
832
828
|
} catch (e) {
|
|
833
829
|
if (!this.h.notify(this, ERROR_BIT, ERROR_BIT))
|
|
834
830
|
throw e;
|
|
@@ -845,9 +841,9 @@ var EagerComputation = class extends Computation {
|
|
|
845
841
|
!(options == null ? void 0 : options.defer) && this.x();
|
|
846
842
|
}
|
|
847
843
|
r(state, skipQueue) {
|
|
848
|
-
if (this.a >= state && !this.
|
|
844
|
+
if (this.a >= state && !this.w)
|
|
849
845
|
return;
|
|
850
|
-
if (this.a === STATE_CLEAN &&
|
|
846
|
+
if (!skipQueue && (this.a === STATE_CLEAN || this.a === STATE_CHECK && this.w))
|
|
851
847
|
this.h.enqueue(EFFECT_PURE, this);
|
|
852
848
|
super.r(state, skipQueue);
|
|
853
849
|
}
|
|
@@ -857,28 +853,28 @@ var ProjectionComputation = class extends Computation {
|
|
|
857
853
|
super(void 0, compute2);
|
|
858
854
|
}
|
|
859
855
|
r(state, skipQueue) {
|
|
860
|
-
if (this.a >= state && !this.
|
|
856
|
+
if (this.a >= state && !this.w)
|
|
861
857
|
return;
|
|
862
|
-
if (!skipQueue && (this.a === STATE_CLEAN || this.a === STATE_CHECK && this.
|
|
858
|
+
if (!skipQueue && (this.a === STATE_CLEAN || this.a === STATE_CHECK && this.w))
|
|
863
859
|
this.h.enqueue(EFFECT_PURE, this);
|
|
864
860
|
super.r(state, true);
|
|
865
|
-
this.
|
|
861
|
+
this.w = !!skipQueue;
|
|
866
862
|
}
|
|
867
863
|
};
|
|
868
864
|
|
|
869
865
|
// src/core/boundaries.ts
|
|
870
866
|
var BoundaryComputation = class extends EagerComputation {
|
|
871
|
-
|
|
867
|
+
G;
|
|
872
868
|
constructor(compute2, propagationMask) {
|
|
873
869
|
super(void 0, compute2, { defer: true });
|
|
874
|
-
this.
|
|
870
|
+
this.G = propagationMask;
|
|
875
871
|
}
|
|
876
872
|
write(value, flags) {
|
|
877
|
-
super.write(value, flags & ~this.
|
|
878
|
-
if (this.
|
|
873
|
+
super.write(value, flags & ~this.G);
|
|
874
|
+
if (this.G & LOADING_BIT && !(this.f & UNINITIALIZED_BIT)) {
|
|
879
875
|
flags &= ~LOADING_BIT;
|
|
880
876
|
}
|
|
881
|
-
this.h.notify(this, this.
|
|
877
|
+
this.h.notify(this, this.G, flags);
|
|
882
878
|
return this.g;
|
|
883
879
|
}
|
|
884
880
|
};
|
|
@@ -896,20 +892,20 @@ function createBoundChildren(owner, fn, queue, mask) {
|
|
|
896
892
|
);
|
|
897
893
|
}
|
|
898
894
|
var ConditionalQueue = class extends Queue {
|
|
899
|
-
|
|
895
|
+
n;
|
|
900
896
|
P = /* @__PURE__ */ new Set();
|
|
901
897
|
Q = /* @__PURE__ */ new Set();
|
|
902
898
|
constructor(disabled) {
|
|
903
899
|
super();
|
|
904
|
-
this.
|
|
900
|
+
this.n = disabled;
|
|
905
901
|
}
|
|
906
902
|
run(type) {
|
|
907
|
-
if (type
|
|
903
|
+
if (!type || this.n.read())
|
|
908
904
|
return;
|
|
909
905
|
return super.run(type);
|
|
910
906
|
}
|
|
911
907
|
notify(node, type, flags) {
|
|
912
|
-
if (this.
|
|
908
|
+
if (this.n.read()) {
|
|
913
909
|
if (type === LOADING_BIT) {
|
|
914
910
|
flags & LOADING_BIT ? this.Q.add(node) : this.Q.delete(node);
|
|
915
911
|
}
|
|
@@ -924,22 +920,27 @@ var ConditionalQueue = class extends Queue {
|
|
|
924
920
|
var CollectionQueue = class extends Queue {
|
|
925
921
|
R;
|
|
926
922
|
b = /* @__PURE__ */ new Set();
|
|
927
|
-
|
|
923
|
+
n = new Computation(false, null);
|
|
928
924
|
constructor(type) {
|
|
929
925
|
super();
|
|
930
926
|
this.R = type;
|
|
931
927
|
}
|
|
928
|
+
run(type) {
|
|
929
|
+
if (!type || this.n.read())
|
|
930
|
+
return;
|
|
931
|
+
return super.run(type);
|
|
932
|
+
}
|
|
932
933
|
notify(node, type, flags) {
|
|
933
934
|
if (!(type & this.R))
|
|
934
935
|
return super.notify(node, type, flags);
|
|
935
936
|
if (flags & this.R) {
|
|
936
937
|
this.b.add(node);
|
|
937
938
|
if (this.b.size === 1)
|
|
938
|
-
this.
|
|
939
|
+
this.n.write(true);
|
|
939
940
|
} else {
|
|
940
941
|
this.b.delete(node);
|
|
941
942
|
if (this.b.size === 0)
|
|
942
|
-
this.
|
|
943
|
+
this.n.write(false);
|
|
943
944
|
}
|
|
944
945
|
type &= ~this.R;
|
|
945
946
|
return type ? super.notify(node, type, flags) : true;
|
|
@@ -950,8 +951,8 @@ function createBoundary(fn, condition) {
|
|
|
950
951
|
const queue = new ConditionalQueue(new Computation(void 0, () => condition() === "hidden" /* HIDDEN */));
|
|
951
952
|
const tree = createBoundChildren(owner, fn, queue, 0);
|
|
952
953
|
new EagerComputation(void 0, () => {
|
|
953
|
-
const disabled = queue.
|
|
954
|
-
tree.
|
|
954
|
+
const disabled = queue.n.read();
|
|
955
|
+
tree.G = disabled ? ERROR_BIT | LOADING_BIT : 0;
|
|
955
956
|
if (!disabled) {
|
|
956
957
|
queue.Q.forEach((node) => queue.notify(node, LOADING_BIT, LOADING_BIT));
|
|
957
958
|
queue.P.forEach((node) => queue.notify(node, ERROR_BIT, ERROR_BIT));
|
|
@@ -959,16 +960,16 @@ function createBoundary(fn, condition) {
|
|
|
959
960
|
queue.P.clear();
|
|
960
961
|
}
|
|
961
962
|
});
|
|
962
|
-
return () => queue.
|
|
963
|
+
return () => queue.n.read() ? void 0 : tree.read();
|
|
963
964
|
}
|
|
964
965
|
function createCollectionBoundary(type, fn, fallback) {
|
|
965
966
|
const owner = new Owner();
|
|
966
967
|
const queue = new CollectionQueue(type);
|
|
967
968
|
const tree = createBoundChildren(owner, fn, queue, type);
|
|
968
969
|
const decision = new Computation(void 0, () => {
|
|
969
|
-
if (!queue.
|
|
970
|
+
if (!queue.n.read()) {
|
|
970
971
|
const resolved = tree.read();
|
|
971
|
-
if (!queue.
|
|
972
|
+
if (!queue.n.read())
|
|
972
973
|
return resolved;
|
|
973
974
|
}
|
|
974
975
|
return fallback(queue);
|
|
@@ -982,12 +983,12 @@ function createErrorBoundary(fn, fallback) {
|
|
|
982
983
|
return createCollectionBoundary(
|
|
983
984
|
ERROR_BIT,
|
|
984
985
|
fn,
|
|
985
|
-
(queue) => fallback(queue.b.values().next().value.
|
|
986
|
+
(queue) => fallback(queue.b.values().next().value.F, () => {
|
|
986
987
|
var _a;
|
|
987
988
|
incrementClock();
|
|
988
989
|
for (let node of queue.b) {
|
|
989
990
|
node.a = STATE_DIRTY;
|
|
990
|
-
(_a = node.h) == null ? void 0 : _a.enqueue(node.
|
|
991
|
+
(_a = node.h) == null ? void 0 : _a.enqueue(node.t, node);
|
|
991
992
|
}
|
|
992
993
|
})
|
|
993
994
|
);
|
|
@@ -1024,7 +1025,7 @@ function createMemo(compute2, value, options) {
|
|
|
1024
1025
|
return resolvedValue;
|
|
1025
1026
|
}
|
|
1026
1027
|
resolvedValue = node.wait();
|
|
1027
|
-
if (!((_a = node.c) == null ? void 0 : _a.length) && ((_b = node.m) == null ? void 0 : _b.
|
|
1028
|
+
if (!((_a = node.c) == null ? void 0 : _a.length) && ((_b = node.m) == null ? void 0 : _b.o) !== node) {
|
|
1028
1029
|
node.dispose();
|
|
1029
1030
|
node = void 0;
|
|
1030
1031
|
}
|
|
@@ -1662,52 +1663,52 @@ function omit(props, ...keys) {
|
|
|
1662
1663
|
function mapArray(list, map, options) {
|
|
1663
1664
|
const keyFn = typeof (options == null ? void 0 : options.keyed) === "function" ? options.keyed : void 0;
|
|
1664
1665
|
return updateKeyedMap.bind({
|
|
1665
|
-
|
|
1666
|
+
H: new Owner(),
|
|
1666
1667
|
i: 0,
|
|
1667
1668
|
_: list,
|
|
1668
|
-
|
|
1669
|
-
|
|
1669
|
+
u: [],
|
|
1670
|
+
C: map,
|
|
1670
1671
|
d: [],
|
|
1671
1672
|
b: [],
|
|
1672
|
-
|
|
1673
|
+
D: keyFn,
|
|
1673
1674
|
j: keyFn || (options == null ? void 0 : options.keyed) === false ? [] : void 0,
|
|
1674
1675
|
k: map.length > 1 ? [] : void 0,
|
|
1675
|
-
|
|
1676
|
+
I: options == null ? void 0 : options.fallback
|
|
1676
1677
|
});
|
|
1677
1678
|
}
|
|
1678
1679
|
function updateKeyedMap() {
|
|
1679
1680
|
const newItems = this._() || [], newLen = newItems.length;
|
|
1680
1681
|
newItems[$TRACK];
|
|
1681
|
-
runWithOwner(this.
|
|
1682
|
+
runWithOwner(this.H, () => {
|
|
1682
1683
|
let i, j, mapper = this.j ? () => {
|
|
1683
1684
|
this.j[j] = new Computation(newItems[j], null);
|
|
1684
1685
|
this.k && (this.k[j] = new Computation(j, null));
|
|
1685
|
-
return this.
|
|
1686
|
+
return this.C(
|
|
1686
1687
|
Computation.prototype.read.bind(this.j[j]),
|
|
1687
1688
|
this.k ? Computation.prototype.read.bind(this.k[j]) : void 0
|
|
1688
1689
|
);
|
|
1689
1690
|
} : this.k ? () => {
|
|
1690
1691
|
const item = newItems[j];
|
|
1691
1692
|
this.k[j] = new Computation(j, null);
|
|
1692
|
-
return this.
|
|
1693
|
+
return this.C(() => item, Computation.prototype.read.bind(this.k[j]));
|
|
1693
1694
|
} : () => {
|
|
1694
1695
|
const item = newItems[j];
|
|
1695
|
-
return this.
|
|
1696
|
+
return this.C(() => item);
|
|
1696
1697
|
};
|
|
1697
1698
|
if (newLen === 0) {
|
|
1698
1699
|
if (this.i !== 0) {
|
|
1699
|
-
this.
|
|
1700
|
+
this.H.dispose(false);
|
|
1700
1701
|
this.b = [];
|
|
1701
|
-
this.
|
|
1702
|
+
this.u = [];
|
|
1702
1703
|
this.d = [];
|
|
1703
1704
|
this.i = 0;
|
|
1704
1705
|
this.j && (this.j = []);
|
|
1705
1706
|
this.k && (this.k = []);
|
|
1706
1707
|
}
|
|
1707
|
-
if (this.
|
|
1708
|
+
if (this.I && !this.d[0]) {
|
|
1708
1709
|
this.d[0] = compute(
|
|
1709
1710
|
this.b[0] = new Owner(),
|
|
1710
|
-
this.
|
|
1711
|
+
this.I,
|
|
1711
1712
|
null
|
|
1712
1713
|
);
|
|
1713
1714
|
}
|
|
@@ -1716,17 +1717,17 @@ function updateKeyedMap() {
|
|
|
1716
1717
|
this.b[0].dispose();
|
|
1717
1718
|
this.d = new Array(newLen);
|
|
1718
1719
|
for (j = 0; j < newLen; j++) {
|
|
1719
|
-
this.
|
|
1720
|
+
this.u[j] = newItems[j];
|
|
1720
1721
|
this.d[j] = compute(this.b[j] = new Owner(), mapper, null);
|
|
1721
1722
|
}
|
|
1722
1723
|
this.i = newLen;
|
|
1723
1724
|
} else {
|
|
1724
1725
|
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;
|
|
1725
|
-
for (start = 0, end = Math.min(this.i, newLen); start < end && (this.
|
|
1726
|
+
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++) {
|
|
1726
1727
|
if (this.j)
|
|
1727
1728
|
this.j[start].write(newItems[start]);
|
|
1728
1729
|
}
|
|
1729
|
-
for (end = this.i - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.
|
|
1730
|
+
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--) {
|
|
1730
1731
|
temp[newEnd] = this.d[end];
|
|
1731
1732
|
tempNodes[newEnd] = this.b[end];
|
|
1732
1733
|
tempRows && (tempRows[newEnd] = this.j[end]);
|
|
@@ -1736,14 +1737,14 @@ function updateKeyedMap() {
|
|
|
1736
1737
|
newIndicesNext = new Array(newEnd + 1);
|
|
1737
1738
|
for (j = newEnd; j >= start; j--) {
|
|
1738
1739
|
item = newItems[j];
|
|
1739
|
-
key = this.
|
|
1740
|
+
key = this.D ? this.D(item) : item;
|
|
1740
1741
|
i = newIndices.get(key);
|
|
1741
1742
|
newIndicesNext[j] = i === void 0 ? -1 : i;
|
|
1742
1743
|
newIndices.set(key, j);
|
|
1743
1744
|
}
|
|
1744
1745
|
for (i = start; i <= end; i++) {
|
|
1745
|
-
item = this.
|
|
1746
|
-
key = this.
|
|
1746
|
+
item = this.u[i];
|
|
1747
|
+
key = this.D ? this.D(item) : item;
|
|
1747
1748
|
j = newIndices.get(key);
|
|
1748
1749
|
if (j !== void 0 && j !== -1) {
|
|
1749
1750
|
temp[j] = this.d[i];
|
|
@@ -1772,40 +1773,40 @@ function updateKeyedMap() {
|
|
|
1772
1773
|
}
|
|
1773
1774
|
}
|
|
1774
1775
|
this.d = this.d.slice(0, this.i = newLen);
|
|
1775
|
-
this.
|
|
1776
|
+
this.u = newItems.slice(0);
|
|
1776
1777
|
}
|
|
1777
1778
|
});
|
|
1778
1779
|
return this.d;
|
|
1779
1780
|
}
|
|
1780
1781
|
function repeat(count, map, options) {
|
|
1781
1782
|
return updateRepeat.bind({
|
|
1782
|
-
|
|
1783
|
+
H: new Owner(),
|
|
1783
1784
|
i: 0,
|
|
1784
1785
|
q: 0,
|
|
1785
1786
|
$: count,
|
|
1786
|
-
|
|
1787
|
+
C: map,
|
|
1787
1788
|
b: [],
|
|
1788
1789
|
d: [],
|
|
1789
1790
|
aa: options == null ? void 0 : options.from,
|
|
1790
|
-
|
|
1791
|
+
I: options == null ? void 0 : options.fallback
|
|
1791
1792
|
});
|
|
1792
1793
|
}
|
|
1793
1794
|
function updateRepeat() {
|
|
1794
1795
|
var _a;
|
|
1795
1796
|
const newLen = this.$();
|
|
1796
1797
|
const from = ((_a = this.aa) == null ? void 0 : _a.call(this)) || 0;
|
|
1797
|
-
runWithOwner(this.
|
|
1798
|
+
runWithOwner(this.H, () => {
|
|
1798
1799
|
if (newLen === 0) {
|
|
1799
1800
|
if (this.i !== 0) {
|
|
1800
|
-
this.
|
|
1801
|
+
this.H.dispose(false);
|
|
1801
1802
|
this.b = [];
|
|
1802
1803
|
this.d = [];
|
|
1803
1804
|
this.i = 0;
|
|
1804
1805
|
}
|
|
1805
|
-
if (this.
|
|
1806
|
+
if (this.I && !this.d[0]) {
|
|
1806
1807
|
this.d[0] = compute(
|
|
1807
1808
|
this.b[0] = new Owner(),
|
|
1808
|
-
this.
|
|
1809
|
+
this.I,
|
|
1809
1810
|
null
|
|
1810
1811
|
);
|
|
1811
1812
|
}
|
|
@@ -1835,7 +1836,7 @@ function updateRepeat() {
|
|
|
1835
1836
|
for (let i2 = 0; i2 < difference; i2++) {
|
|
1836
1837
|
this.d[i2] = compute(
|
|
1837
1838
|
this.b[i2] = new Owner(),
|
|
1838
|
-
() => this.
|
|
1839
|
+
() => this.C(i2 + from),
|
|
1839
1840
|
null
|
|
1840
1841
|
);
|
|
1841
1842
|
}
|
|
@@ -1843,7 +1844,7 @@ function updateRepeat() {
|
|
|
1843
1844
|
for (let i = prevTo; i < to; i++) {
|
|
1844
1845
|
this.d[i - from] = compute(
|
|
1845
1846
|
this.b[i - from] = new Owner(),
|
|
1846
|
-
() => this.
|
|
1847
|
+
() => this.C(i),
|
|
1847
1848
|
null
|
|
1848
1849
|
);
|
|
1849
1850
|
}
|