@solidjs/signals 0.0.2 → 0.0.3
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 +37 -24
- package/dist/node.cjs +188 -174
- package/dist/prod.js +188 -175
- package/dist/types/core/index.d.ts +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/map.d.ts +5 -4
- package/dist/types/signals.d.ts +31 -14
- package/dist/types/store/index.d.ts +1 -1
- package/dist/types/store/reconcile.d.ts +1 -1
- package/package.json +7 -2
package/dist/node.cjs
CHANGED
|
@@ -48,30 +48,30 @@ var Owner = class {
|
|
|
48
48
|
// We flatten the owner tree into a linked list so that we don't need a pointer to .firstChild
|
|
49
49
|
// However, the children are actually added in reverse creation order
|
|
50
50
|
// See comment at the top of the file for an example of the _nextSibling traversal
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
r = null;
|
|
52
|
+
m = null;
|
|
53
53
|
o = null;
|
|
54
54
|
a = STATE_CLEAN;
|
|
55
|
-
g = null;
|
|
56
|
-
m = defaultContext;
|
|
57
55
|
h = null;
|
|
56
|
+
n = defaultContext;
|
|
57
|
+
i = null;
|
|
58
58
|
e = null;
|
|
59
59
|
constructor(signal = false) {
|
|
60
60
|
if (currentOwner && !signal)
|
|
61
61
|
currentOwner.append(this);
|
|
62
62
|
}
|
|
63
63
|
append(child) {
|
|
64
|
-
child.
|
|
64
|
+
child.r = this;
|
|
65
65
|
child.o = this;
|
|
66
|
-
if (this.
|
|
67
|
-
this.
|
|
68
|
-
child.
|
|
69
|
-
this.
|
|
70
|
-
if (child.
|
|
71
|
-
child.
|
|
66
|
+
if (this.m)
|
|
67
|
+
this.m.o = child;
|
|
68
|
+
child.m = this.m;
|
|
69
|
+
this.m = child;
|
|
70
|
+
if (child.n !== this.n) {
|
|
71
|
+
child.n = { ...this.n, ...child.n };
|
|
72
72
|
}
|
|
73
|
-
if (this.
|
|
74
|
-
child.
|
|
73
|
+
if (this.i) {
|
|
74
|
+
child.i = !child.i ? this.i : [...child.i, ...this.i];
|
|
75
75
|
}
|
|
76
76
|
if (this.e)
|
|
77
77
|
child.e = this.e;
|
|
@@ -79,51 +79,51 @@ var Owner = class {
|
|
|
79
79
|
dispose(self = true) {
|
|
80
80
|
if (this.a === STATE_DISPOSED)
|
|
81
81
|
return;
|
|
82
|
-
let head = self ? this.o || this.
|
|
83
|
-
while (current && current.
|
|
82
|
+
let head = self ? this.o || this.r : this, current = this.m, next = null;
|
|
83
|
+
while (current && current.r === this) {
|
|
84
84
|
current.dispose(true);
|
|
85
|
-
current.
|
|
86
|
-
next = current.
|
|
87
|
-
current.
|
|
85
|
+
current.x();
|
|
86
|
+
next = current.m;
|
|
87
|
+
current.m = null;
|
|
88
88
|
current = next;
|
|
89
89
|
}
|
|
90
90
|
if (self)
|
|
91
|
-
this.
|
|
91
|
+
this.x();
|
|
92
92
|
if (current)
|
|
93
93
|
current.o = !self ? this : this.o;
|
|
94
94
|
if (head)
|
|
95
|
-
head.
|
|
95
|
+
head.m = current;
|
|
96
96
|
}
|
|
97
|
-
|
|
97
|
+
x() {
|
|
98
98
|
if (this.o)
|
|
99
|
-
this.o.
|
|
100
|
-
this.
|
|
99
|
+
this.o.m = null;
|
|
100
|
+
this.r = null;
|
|
101
101
|
this.o = null;
|
|
102
|
-
this.
|
|
103
|
-
this.
|
|
102
|
+
this.n = defaultContext;
|
|
103
|
+
this.i = null;
|
|
104
104
|
this.a = STATE_DISPOSED;
|
|
105
105
|
this.emptyDisposal();
|
|
106
106
|
}
|
|
107
107
|
emptyDisposal() {
|
|
108
|
-
if (!this.
|
|
108
|
+
if (!this.h)
|
|
109
109
|
return;
|
|
110
|
-
if (Array.isArray(this.
|
|
111
|
-
for (let i = 0; i < this.
|
|
112
|
-
const callable = this.
|
|
110
|
+
if (Array.isArray(this.h)) {
|
|
111
|
+
for (let i = 0; i < this.h.length; i++) {
|
|
112
|
+
const callable = this.h[i];
|
|
113
113
|
callable.call(callable);
|
|
114
114
|
}
|
|
115
115
|
} else {
|
|
116
|
-
this.
|
|
116
|
+
this.h.call(this.h);
|
|
117
117
|
}
|
|
118
|
-
this.
|
|
118
|
+
this.h = null;
|
|
119
119
|
}
|
|
120
120
|
handleError(error) {
|
|
121
|
-
if (!this.
|
|
121
|
+
if (!this.i)
|
|
122
122
|
throw error;
|
|
123
|
-
let i = 0, len = this.
|
|
123
|
+
let i = 0, len = this.i.length;
|
|
124
124
|
for (i = 0; i < len; i++) {
|
|
125
125
|
try {
|
|
126
|
-
this.
|
|
126
|
+
this.i[i](error);
|
|
127
127
|
break;
|
|
128
128
|
} catch (e) {
|
|
129
129
|
error = e;
|
|
@@ -140,7 +140,7 @@ function getContext(context, owner = currentOwner) {
|
|
|
140
140
|
if (!owner) {
|
|
141
141
|
throw new NoOwnerError();
|
|
142
142
|
}
|
|
143
|
-
const value = hasContext(context, owner) ? owner.
|
|
143
|
+
const value = hasContext(context, owner) ? owner.n[context.id] : context.defaultValue;
|
|
144
144
|
if (isUndefined(value)) {
|
|
145
145
|
throw new ContextNotFoundError();
|
|
146
146
|
}
|
|
@@ -150,24 +150,24 @@ function setContext(context, value, owner = currentOwner) {
|
|
|
150
150
|
if (!owner) {
|
|
151
151
|
throw new NoOwnerError();
|
|
152
152
|
}
|
|
153
|
-
owner.
|
|
154
|
-
...owner.
|
|
153
|
+
owner.n = {
|
|
154
|
+
...owner.n,
|
|
155
155
|
[context.id]: isUndefined(value) ? context.defaultValue : value
|
|
156
156
|
};
|
|
157
157
|
}
|
|
158
158
|
function hasContext(context, owner = currentOwner) {
|
|
159
|
-
return !isUndefined(owner == null ? void 0 : owner.
|
|
159
|
+
return !isUndefined(owner == null ? void 0 : owner.n[context.id]);
|
|
160
160
|
}
|
|
161
161
|
function onCleanup(disposable) {
|
|
162
162
|
if (!currentOwner)
|
|
163
163
|
return;
|
|
164
164
|
const node = currentOwner;
|
|
165
|
-
if (!node.
|
|
166
|
-
node.
|
|
167
|
-
} else if (Array.isArray(node.
|
|
168
|
-
node.
|
|
165
|
+
if (!node.h) {
|
|
166
|
+
node.h = disposable;
|
|
167
|
+
} else if (Array.isArray(node.h)) {
|
|
168
|
+
node.h.push(disposable);
|
|
169
169
|
} else {
|
|
170
|
-
node.
|
|
170
|
+
node.h = [node.h, disposable];
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
|
|
@@ -206,7 +206,7 @@ var Computation = class extends Owner {
|
|
|
206
206
|
E = isEqual;
|
|
207
207
|
N;
|
|
208
208
|
/** Whether the computation is an error or has ancestors that are unresolved */
|
|
209
|
-
|
|
209
|
+
j = 0;
|
|
210
210
|
/** Which flags raised by sources are handled, vs. being passed through. */
|
|
211
211
|
A = DEFAULT_FLAGS;
|
|
212
212
|
F = null;
|
|
@@ -224,11 +224,11 @@ var Computation = class extends Owner {
|
|
|
224
224
|
}
|
|
225
225
|
O() {
|
|
226
226
|
if (this.D)
|
|
227
|
-
this.
|
|
227
|
+
this.s();
|
|
228
228
|
if (!this.b || this.b.length)
|
|
229
229
|
track(this);
|
|
230
|
-
newFlags |= this.
|
|
231
|
-
if (this.
|
|
230
|
+
newFlags |= this.j & ~currentMask;
|
|
231
|
+
if (this.j & ERROR_BIT) {
|
|
232
232
|
throw this.d;
|
|
233
233
|
} else {
|
|
234
234
|
return this.d;
|
|
@@ -283,13 +283,13 @@ var Computation = class extends Owner {
|
|
|
283
283
|
const valueChanged = newValue !== UNCHANGED && (!!(flags & ERROR_BIT) || this.E === false || !this.E(this.d, newValue));
|
|
284
284
|
if (valueChanged)
|
|
285
285
|
this.d = newValue;
|
|
286
|
-
const changedFlagsMask = this.
|
|
287
|
-
this.
|
|
286
|
+
const changedFlagsMask = this.j ^ flags, changedFlags = changedFlagsMask & flags;
|
|
287
|
+
this.j = flags;
|
|
288
288
|
this.H = clock + 1;
|
|
289
289
|
if (this.c) {
|
|
290
290
|
for (let i = 0; i < this.c.length; i++) {
|
|
291
291
|
if (valueChanged) {
|
|
292
|
-
this.c[i].
|
|
292
|
+
this.c[i].t(STATE_DIRTY);
|
|
293
293
|
} else if (changedFlagsMask) {
|
|
294
294
|
this.c[i].P(changedFlagsMask, changedFlags);
|
|
295
295
|
}
|
|
@@ -300,13 +300,13 @@ var Computation = class extends Owner {
|
|
|
300
300
|
/**
|
|
301
301
|
* Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK
|
|
302
302
|
*/
|
|
303
|
-
|
|
303
|
+
t(state) {
|
|
304
304
|
if (this.a >= state)
|
|
305
305
|
return;
|
|
306
306
|
this.a = state;
|
|
307
307
|
if (this.c) {
|
|
308
308
|
for (let i = 0; i < this.c.length; i++) {
|
|
309
|
-
this.c[i].
|
|
309
|
+
this.c[i].t(STATE_CHECK);
|
|
310
310
|
}
|
|
311
311
|
}
|
|
312
312
|
}
|
|
@@ -320,17 +320,17 @@ var Computation = class extends Owner {
|
|
|
320
320
|
if (this.a >= STATE_DIRTY)
|
|
321
321
|
return;
|
|
322
322
|
if (mask & this.A) {
|
|
323
|
-
this.
|
|
323
|
+
this.t(STATE_DIRTY);
|
|
324
324
|
return;
|
|
325
325
|
}
|
|
326
326
|
if (this.a >= STATE_CHECK)
|
|
327
327
|
return;
|
|
328
|
-
const prevFlags = this.
|
|
328
|
+
const prevFlags = this.j & mask;
|
|
329
329
|
const deltaFlags = prevFlags ^ newFlags2;
|
|
330
330
|
if (newFlags2 === prevFlags) ; else if (deltaFlags & prevFlags & mask) {
|
|
331
|
-
this.
|
|
331
|
+
this.t(STATE_CHECK);
|
|
332
332
|
} else {
|
|
333
|
-
this.
|
|
333
|
+
this.j ^= deltaFlags;
|
|
334
334
|
if (this.c) {
|
|
335
335
|
for (let i = 0; i < this.c.length; i++) {
|
|
336
336
|
this.c[i].P(mask, newFlags2);
|
|
@@ -339,7 +339,7 @@ var Computation = class extends Owner {
|
|
|
339
339
|
}
|
|
340
340
|
}
|
|
341
341
|
Q(error) {
|
|
342
|
-
this.write(error, this.
|
|
342
|
+
this.write(error, this.j | ERROR_BIT);
|
|
343
343
|
}
|
|
344
344
|
/**
|
|
345
345
|
* This is the core part of the reactivity system, which makes sure that the values are updated
|
|
@@ -348,7 +348,7 @@ var Computation = class extends Owner {
|
|
|
348
348
|
*
|
|
349
349
|
* This function will ensure that the value and states we read from the computation are up to date
|
|
350
350
|
*/
|
|
351
|
-
|
|
351
|
+
s() {
|
|
352
352
|
if (this.a === STATE_DISPOSED) {
|
|
353
353
|
throw new Error("Tried to read a disposed computation");
|
|
354
354
|
}
|
|
@@ -358,8 +358,8 @@ var Computation = class extends Owner {
|
|
|
358
358
|
let observerFlags = 0;
|
|
359
359
|
if (this.a === STATE_CHECK) {
|
|
360
360
|
for (let i = 0; i < this.b.length; i++) {
|
|
361
|
-
this.b[i].
|
|
362
|
-
observerFlags |= this.b[i].
|
|
361
|
+
this.b[i].s();
|
|
362
|
+
observerFlags |= this.b[i].j;
|
|
363
363
|
if (this.a === STATE_DIRTY) {
|
|
364
364
|
break;
|
|
365
365
|
}
|
|
@@ -375,23 +375,23 @@ var Computation = class extends Owner {
|
|
|
375
375
|
/**
|
|
376
376
|
* Remove ourselves from the owner graph and the computation graph
|
|
377
377
|
*/
|
|
378
|
-
|
|
378
|
+
x() {
|
|
379
379
|
if (this.a === STATE_DISPOSED)
|
|
380
380
|
return;
|
|
381
381
|
if (this.b)
|
|
382
382
|
removeSourceObservers(this, 0);
|
|
383
|
-
super.
|
|
383
|
+
super.x();
|
|
384
384
|
}
|
|
385
385
|
};
|
|
386
386
|
function loadingState(node) {
|
|
387
|
-
const prevOwner = setOwner(node.
|
|
387
|
+
const prevOwner = setOwner(node.r);
|
|
388
388
|
const options = void 0;
|
|
389
389
|
const computation = new Computation(
|
|
390
390
|
void 0,
|
|
391
391
|
() => {
|
|
392
392
|
track(node);
|
|
393
|
-
node.
|
|
394
|
-
return !!(node.
|
|
393
|
+
node.s();
|
|
394
|
+
return !!(node.j & LOADING_BIT);
|
|
395
395
|
},
|
|
396
396
|
options
|
|
397
397
|
);
|
|
@@ -400,14 +400,14 @@ function loadingState(node) {
|
|
|
400
400
|
return computation;
|
|
401
401
|
}
|
|
402
402
|
function errorState(node) {
|
|
403
|
-
const prevOwner = setOwner(node.
|
|
403
|
+
const prevOwner = setOwner(node.r);
|
|
404
404
|
const options = void 0;
|
|
405
405
|
const computation = new Computation(
|
|
406
406
|
void 0,
|
|
407
407
|
() => {
|
|
408
408
|
track(node);
|
|
409
|
-
node.
|
|
410
|
-
return !!(node.
|
|
409
|
+
node.s();
|
|
410
|
+
return !!(node.j & ERROR_BIT);
|
|
411
411
|
},
|
|
412
412
|
options
|
|
413
413
|
);
|
|
@@ -550,27 +550,27 @@ function schedule() {
|
|
|
550
550
|
}
|
|
551
551
|
var Queue = class {
|
|
552
552
|
I = false;
|
|
553
|
-
|
|
554
|
-
|
|
553
|
+
u = [[], [], []];
|
|
554
|
+
z = [];
|
|
555
555
|
enqueue(type, node) {
|
|
556
|
-
this.
|
|
556
|
+
this.u[0].push(node);
|
|
557
557
|
if (type)
|
|
558
|
-
this.
|
|
558
|
+
this.u[type].push(node);
|
|
559
559
|
schedule();
|
|
560
560
|
}
|
|
561
561
|
run(type) {
|
|
562
|
-
if (this.
|
|
562
|
+
if (this.u[type].length) {
|
|
563
563
|
if (type === EFFECT_PURE) {
|
|
564
|
-
runPureQueue(this.
|
|
565
|
-
this.
|
|
564
|
+
runPureQueue(this.u[type]);
|
|
565
|
+
this.u[type] = [];
|
|
566
566
|
} else {
|
|
567
|
-
const effects = this.
|
|
568
|
-
this.
|
|
567
|
+
const effects = this.u[type];
|
|
568
|
+
this.u[type] = [];
|
|
569
569
|
runEffectQueue(effects);
|
|
570
570
|
}
|
|
571
571
|
}
|
|
572
|
-
for (let i = 0; i < this.
|
|
573
|
-
this.
|
|
572
|
+
for (let i = 0; i < this.z.length; i++) {
|
|
573
|
+
this.z[i].run(type);
|
|
574
574
|
}
|
|
575
575
|
}
|
|
576
576
|
flush() {
|
|
@@ -587,12 +587,12 @@ var Queue = class {
|
|
|
587
587
|
}
|
|
588
588
|
}
|
|
589
589
|
addChild(child) {
|
|
590
|
-
this.
|
|
590
|
+
this.z.push(child);
|
|
591
591
|
}
|
|
592
592
|
removeChild(child) {
|
|
593
|
-
const index = this.
|
|
593
|
+
const index = this.z.indexOf(child);
|
|
594
594
|
if (index >= 0)
|
|
595
|
-
this.
|
|
595
|
+
this.z.splice(index, 1);
|
|
596
596
|
}
|
|
597
597
|
};
|
|
598
598
|
var globalQueue = new Queue();
|
|
@@ -609,14 +609,14 @@ function createBoundary(fn, queue) {
|
|
|
609
609
|
}
|
|
610
610
|
function runTop(node) {
|
|
611
611
|
const ancestors = [];
|
|
612
|
-
for (let current = node; current !== null; current = current.
|
|
612
|
+
for (let current = node; current !== null; current = current.r) {
|
|
613
613
|
if (current.a !== STATE_CLEAN) {
|
|
614
614
|
ancestors.push(current);
|
|
615
615
|
}
|
|
616
616
|
}
|
|
617
617
|
for (let i = ancestors.length - 1; i >= 0; i--) {
|
|
618
618
|
if (ancestors[i].a !== STATE_DISPOSED)
|
|
619
|
-
ancestors[i].
|
|
619
|
+
ancestors[i].s();
|
|
620
620
|
}
|
|
621
621
|
}
|
|
622
622
|
function runPureQueue(queue) {
|
|
@@ -644,13 +644,13 @@ var Effect = class extends Computation {
|
|
|
644
644
|
this.B = initialValue;
|
|
645
645
|
this.C = (options == null ? void 0 : options.render) ? EFFECT_RENDER : EFFECT_USER;
|
|
646
646
|
this.e = ((_a = getOwner()) == null ? void 0 : _a.e) || globalQueue;
|
|
647
|
-
this.
|
|
647
|
+
this.s();
|
|
648
648
|
this.C === EFFECT_USER ? this.e.enqueue(this.C, this) : this.R();
|
|
649
649
|
}
|
|
650
650
|
write(value, flags = 0) {
|
|
651
651
|
var _a, _b;
|
|
652
|
-
const currentFlags = this.
|
|
653
|
-
this.
|
|
652
|
+
const currentFlags = this.j;
|
|
653
|
+
this.j = flags;
|
|
654
654
|
if ((flags & LOADING_BIT) !== (currentFlags & LOADING_BIT)) {
|
|
655
655
|
(_b = (_a = this.e).T) == null ? void 0 : _b.call(_a, this);
|
|
656
656
|
}
|
|
@@ -660,7 +660,7 @@ var Effect = class extends Computation {
|
|
|
660
660
|
this.K = true;
|
|
661
661
|
return value;
|
|
662
662
|
}
|
|
663
|
-
|
|
663
|
+
t(state) {
|
|
664
664
|
if (this.a >= state)
|
|
665
665
|
return;
|
|
666
666
|
if (this.a === STATE_CLEAN)
|
|
@@ -670,10 +670,10 @@ var Effect = class extends Computation {
|
|
|
670
670
|
Q(error) {
|
|
671
671
|
this.handleError(error);
|
|
672
672
|
}
|
|
673
|
-
|
|
673
|
+
x() {
|
|
674
674
|
this.J = void 0;
|
|
675
675
|
this.B = void 0;
|
|
676
|
-
super.
|
|
676
|
+
super.x();
|
|
677
677
|
}
|
|
678
678
|
R() {
|
|
679
679
|
if (this.K && this.a !== STATE_DISPOSED) {
|
|
@@ -689,38 +689,38 @@ var EagerComputation = class extends Computation {
|
|
|
689
689
|
var _a;
|
|
690
690
|
super(initialValue, compute2, options);
|
|
691
691
|
this.e = ((_a = getOwner()) == null ? void 0 : _a.e) || globalQueue;
|
|
692
|
-
this.
|
|
692
|
+
this.s();
|
|
693
693
|
}
|
|
694
|
-
|
|
694
|
+
t(state) {
|
|
695
695
|
if (this.a >= state)
|
|
696
696
|
return;
|
|
697
697
|
if (this.a === STATE_CLEAN)
|
|
698
698
|
this.e.enqueue(EFFECT_PURE, this);
|
|
699
|
-
super.
|
|
699
|
+
super.t(state);
|
|
700
700
|
}
|
|
701
701
|
};
|
|
702
702
|
|
|
703
703
|
// src/core/suspense.ts
|
|
704
704
|
var SuspenseQueue = class extends Queue {
|
|
705
|
-
|
|
706
|
-
|
|
705
|
+
f = /* @__PURE__ */ new Set();
|
|
706
|
+
p = false;
|
|
707
707
|
L = new Computation(false, null);
|
|
708
708
|
run(type) {
|
|
709
|
-
if (type && this.
|
|
709
|
+
if (type && this.p)
|
|
710
710
|
return;
|
|
711
711
|
super.run(type);
|
|
712
712
|
}
|
|
713
713
|
T(node) {
|
|
714
|
-
if (node.
|
|
715
|
-
this.
|
|
716
|
-
if (!this.
|
|
717
|
-
this.
|
|
714
|
+
if (node.j & LOADING_BIT) {
|
|
715
|
+
this.f.add(node);
|
|
716
|
+
if (!this.p) {
|
|
717
|
+
this.p = true;
|
|
718
718
|
queueMicrotask(() => this.L.write(true));
|
|
719
719
|
}
|
|
720
720
|
} else {
|
|
721
|
-
this.
|
|
722
|
-
if (this.
|
|
723
|
-
this.
|
|
721
|
+
this.f.delete(node);
|
|
722
|
+
if (this.f.size === 0) {
|
|
723
|
+
this.p = false;
|
|
724
724
|
queueMicrotask(() => this.L.write(false));
|
|
725
725
|
}
|
|
726
726
|
}
|
|
@@ -729,7 +729,7 @@ var SuspenseQueue = class extends Queue {
|
|
|
729
729
|
function createSuspense(fn, fallbackFn) {
|
|
730
730
|
const queue = new SuspenseQueue();
|
|
731
731
|
const tree = createBoundary(fn, queue);
|
|
732
|
-
const equality = new Computation(null, () => queue.L.read() || queue.
|
|
732
|
+
const equality = new Computation(null, () => queue.L.read() || queue.p);
|
|
733
733
|
const comp = new Computation(null, () => equality.read() ? untrack(fallbackFn) : tree);
|
|
734
734
|
return comp.read.bind(comp);
|
|
735
735
|
}
|
|
@@ -840,7 +840,7 @@ function runWithOwner(owner, run) {
|
|
|
840
840
|
}
|
|
841
841
|
function catchError(fn, handler) {
|
|
842
842
|
const owner = new Owner();
|
|
843
|
-
owner.
|
|
843
|
+
owner.i = owner.i ? [handler, ...owner.i] : [handler];
|
|
844
844
|
try {
|
|
845
845
|
compute(owner, fn, null);
|
|
846
846
|
} catch (error) {
|
|
@@ -858,15 +858,22 @@ var STORE_NODE = "n";
|
|
|
858
858
|
var STORE_HAS = "h";
|
|
859
859
|
function wrap(value) {
|
|
860
860
|
let p = value[$PROXY];
|
|
861
|
-
if (!p)
|
|
861
|
+
if (!p) {
|
|
862
|
+
let target;
|
|
863
|
+
if (Array.isArray(value)) {
|
|
864
|
+
target = [];
|
|
865
|
+
target.v = value;
|
|
866
|
+
} else
|
|
867
|
+
target = { v: value };
|
|
862
868
|
Object.defineProperty(value, $PROXY, {
|
|
863
|
-
value: p = new Proxy(
|
|
869
|
+
value: p = new Proxy(target, proxyTraps),
|
|
864
870
|
writable: true
|
|
865
871
|
});
|
|
872
|
+
}
|
|
866
873
|
return p;
|
|
867
874
|
}
|
|
868
875
|
function isWrappable(obj) {
|
|
869
|
-
return obj != null && typeof obj === "object";
|
|
876
|
+
return obj != null && typeof obj === "object" && !Object.isFrozen(obj);
|
|
870
877
|
}
|
|
871
878
|
function unwrap(item, deep = true, set) {
|
|
872
879
|
let result, unwrapped, v, prop;
|
|
@@ -918,8 +925,10 @@ function getNode(nodes, property, value, equals = isEqual) {
|
|
|
918
925
|
});
|
|
919
926
|
}
|
|
920
927
|
function proxyDescriptor(target, property) {
|
|
928
|
+
if (property === $PROXY)
|
|
929
|
+
return { value: target[$PROXY], writable: true, configurable: true };
|
|
921
930
|
const desc = Reflect.getOwnPropertyDescriptor(target[STORE_VALUE], property);
|
|
922
|
-
if (!desc || desc.get || !desc.configurable
|
|
931
|
+
if (!desc || desc.get || !desc.configurable)
|
|
923
932
|
return desc;
|
|
924
933
|
delete desc.value;
|
|
925
934
|
delete desc.writable;
|
|
@@ -985,7 +994,10 @@ var proxyTraps = {
|
|
|
985
994
|
return true;
|
|
986
995
|
},
|
|
987
996
|
ownKeys,
|
|
988
|
-
getOwnPropertyDescriptor: proxyDescriptor
|
|
997
|
+
getOwnPropertyDescriptor: proxyDescriptor,
|
|
998
|
+
getPrototypeOf(target) {
|
|
999
|
+
return Object.getPrototypeOf(target[STORE_VALUE]);
|
|
1000
|
+
}
|
|
989
1001
|
};
|
|
990
1002
|
function setProperty(state, property, value, deleting = false) {
|
|
991
1003
|
var _a, _b, _c, _d, _e;
|
|
@@ -1141,6 +1153,7 @@ function reconcile(value, key) {
|
|
|
1141
1153
|
if (keyFn(value) !== keyFn(state))
|
|
1142
1154
|
throw new Error("Cannot reconcile states with different identity");
|
|
1143
1155
|
applyState(value, state, keyFn);
|
|
1156
|
+
return state;
|
|
1144
1157
|
};
|
|
1145
1158
|
}
|
|
1146
1159
|
|
|
@@ -1295,117 +1308,117 @@ function omit(props, ...keys) {
|
|
|
1295
1308
|
// src/map.ts
|
|
1296
1309
|
function mapArray(list, map, options) {
|
|
1297
1310
|
const keyFn = typeof (options == null ? void 0 : options.keyed) === "function" ? options.keyed : void 0;
|
|
1298
|
-
return
|
|
1299
|
-
new
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
j: map.length > 1 ? [] : void 0
|
|
1312
|
-
}),
|
|
1313
|
-
options
|
|
1314
|
-
)
|
|
1315
|
-
);
|
|
1311
|
+
return updateKeyedMap.bind({
|
|
1312
|
+
S: new Owner(),
|
|
1313
|
+
w: 0,
|
|
1314
|
+
U: list,
|
|
1315
|
+
q: [],
|
|
1316
|
+
M: map,
|
|
1317
|
+
k: [],
|
|
1318
|
+
f: [],
|
|
1319
|
+
y: keyFn,
|
|
1320
|
+
g: keyFn || (options == null ? void 0 : options.keyed) === false ? [] : void 0,
|
|
1321
|
+
l: map.length > 1 ? [] : void 0,
|
|
1322
|
+
p: options == null ? void 0 : options.fallback
|
|
1323
|
+
});
|
|
1316
1324
|
}
|
|
1317
1325
|
function updateKeyedMap() {
|
|
1318
1326
|
const newItems = this.U() || [], newLen = newItems.length;
|
|
1319
1327
|
newItems[$TRACK];
|
|
1320
1328
|
runWithOwner(this.S, () => {
|
|
1321
|
-
let i, j, mapper = this.
|
|
1322
|
-
this.
|
|
1323
|
-
this.
|
|
1329
|
+
let i, j, mapper = this.g ? () => {
|
|
1330
|
+
this.g[j] = new Computation(newItems[j], null);
|
|
1331
|
+
this.l[j] = new Computation(j, null);
|
|
1324
1332
|
return this.M(
|
|
1325
|
-
Computation.prototype.read.bind(this.
|
|
1326
|
-
Computation.prototype.read.bind(this.
|
|
1333
|
+
Computation.prototype.read.bind(this.g[j]),
|
|
1334
|
+
Computation.prototype.read.bind(this.l[j])
|
|
1327
1335
|
);
|
|
1328
|
-
} : this.
|
|
1336
|
+
} : this.l ? () => {
|
|
1329
1337
|
const item = newItems[j];
|
|
1330
|
-
this.
|
|
1331
|
-
return this.M(() => item, Computation.prototype.read.bind(this.
|
|
1338
|
+
this.l[j] = new Computation(j, null);
|
|
1339
|
+
return this.M(() => item, Computation.prototype.read.bind(this.l[j]));
|
|
1332
1340
|
} : () => {
|
|
1333
1341
|
const item = newItems[j];
|
|
1334
1342
|
return this.M(() => item);
|
|
1335
1343
|
};
|
|
1336
1344
|
if (newLen === 0) {
|
|
1337
|
-
if (this.
|
|
1345
|
+
if (this.w !== 0) {
|
|
1338
1346
|
this.S.dispose(false);
|
|
1347
|
+
this.f = [];
|
|
1348
|
+
this.q = [];
|
|
1339
1349
|
this.k = [];
|
|
1340
|
-
this.
|
|
1341
|
-
this.
|
|
1342
|
-
this.
|
|
1343
|
-
|
|
1344
|
-
|
|
1350
|
+
this.w = 0;
|
|
1351
|
+
this.g && (this.g = []);
|
|
1352
|
+
this.l && (this.l = []);
|
|
1353
|
+
}
|
|
1354
|
+
if (this.p && !this.k[0]) {
|
|
1355
|
+
this.k[0] = compute(this.f[0] = new Owner(), this.p, null);
|
|
1345
1356
|
}
|
|
1346
|
-
} else if (this.
|
|
1347
|
-
this.
|
|
1357
|
+
} else if (this.w === 0) {
|
|
1358
|
+
if (this.f[0])
|
|
1359
|
+
this.f[0].dispose();
|
|
1360
|
+
this.k = new Array(newLen);
|
|
1348
1361
|
for (j = 0; j < newLen; j++) {
|
|
1349
|
-
this.
|
|
1350
|
-
this.
|
|
1362
|
+
this.q[j] = newItems[j];
|
|
1363
|
+
this.k[j] = compute(this.f[j] = new Owner(), mapper, null);
|
|
1351
1364
|
}
|
|
1352
|
-
this.
|
|
1365
|
+
this.w = newLen;
|
|
1353
1366
|
} else {
|
|
1354
|
-
let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.
|
|
1355
|
-
for (start = 0, end = Math.min(this.
|
|
1356
|
-
if (this.
|
|
1357
|
-
this.
|
|
1367
|
+
let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.g ? new Array(newLen) : void 0, tempIndexes = this.l ? new Array(newLen) : void 0;
|
|
1368
|
+
for (start = 0, end = Math.min(this.w, newLen); start < end && (this.q[start] === newItems[start] || this.g && compare(this.y, this.q[start], newItems[start])); start++) {
|
|
1369
|
+
if (this.g)
|
|
1370
|
+
this.g[start].write(newItems[start]);
|
|
1358
1371
|
}
|
|
1359
|
-
for (end = this.
|
|
1360
|
-
temp[newEnd] = this.
|
|
1361
|
-
tempNodes[newEnd] = this.
|
|
1362
|
-
tempRows && (tempRows[newEnd] = this.
|
|
1363
|
-
tempIndexes && (tempIndexes[newEnd] = this.
|
|
1372
|
+
for (end = this.w - 1, newEnd = newLen - 1; end >= start && newEnd >= start && (this.q[end] === newItems[newEnd] || this.g && compare(this.y, this.q[end], newItems[newEnd])); end--, newEnd--) {
|
|
1373
|
+
temp[newEnd] = this.k[end];
|
|
1374
|
+
tempNodes[newEnd] = this.f[end];
|
|
1375
|
+
tempRows && (tempRows[newEnd] = this.g[end]);
|
|
1376
|
+
tempIndexes && (tempIndexes[newEnd] = this.l[end]);
|
|
1364
1377
|
}
|
|
1365
1378
|
newIndices = /* @__PURE__ */ new Map();
|
|
1366
1379
|
newIndicesNext = new Array(newEnd + 1);
|
|
1367
1380
|
for (j = newEnd; j >= start; j--) {
|
|
1368
1381
|
item = newItems[j];
|
|
1369
|
-
key = this.
|
|
1382
|
+
key = this.y ? this.y(item) : item;
|
|
1370
1383
|
i = newIndices.get(key);
|
|
1371
1384
|
newIndicesNext[j] = i === void 0 ? -1 : i;
|
|
1372
1385
|
newIndices.set(key, j);
|
|
1373
1386
|
}
|
|
1374
1387
|
for (i = start; i <= end; i++) {
|
|
1375
|
-
item = this.
|
|
1376
|
-
key = this.
|
|
1388
|
+
item = this.q[i];
|
|
1389
|
+
key = this.y ? this.y(item) : item;
|
|
1377
1390
|
j = newIndices.get(key);
|
|
1378
1391
|
if (j !== void 0 && j !== -1) {
|
|
1379
|
-
temp[j] = this.
|
|
1380
|
-
tempNodes[j] = this.
|
|
1381
|
-
tempRows && (tempRows[j] = this.
|
|
1382
|
-
tempIndexes && (tempIndexes[j] = this.
|
|
1392
|
+
temp[j] = this.k[i];
|
|
1393
|
+
tempNodes[j] = this.f[i];
|
|
1394
|
+
tempRows && (tempRows[j] = this.g[i]);
|
|
1395
|
+
tempIndexes && (tempIndexes[j] = this.l[i]);
|
|
1383
1396
|
j = newIndicesNext[j];
|
|
1384
1397
|
newIndices.set(key, j);
|
|
1385
1398
|
} else
|
|
1386
|
-
this.
|
|
1399
|
+
this.f[i].dispose();
|
|
1387
1400
|
}
|
|
1388
1401
|
for (j = start; j < newLen; j++) {
|
|
1389
1402
|
if (j in temp) {
|
|
1390
|
-
this.
|
|
1391
|
-
this.
|
|
1403
|
+
this.k[j] = temp[j];
|
|
1404
|
+
this.f[j] = tempNodes[j];
|
|
1392
1405
|
if (tempRows) {
|
|
1393
|
-
this.
|
|
1394
|
-
this.
|
|
1406
|
+
this.g[j] = tempRows[j];
|
|
1407
|
+
this.g[j].write(newItems[j]);
|
|
1395
1408
|
}
|
|
1396
1409
|
if (tempIndexes) {
|
|
1397
|
-
this.
|
|
1398
|
-
this.
|
|
1410
|
+
this.l[j] = tempIndexes[j];
|
|
1411
|
+
this.l[j].write(j);
|
|
1399
1412
|
}
|
|
1400
1413
|
} else {
|
|
1401
|
-
this.
|
|
1414
|
+
this.k[j] = compute(this.f[j] = new Owner(), mapper, null);
|
|
1402
1415
|
}
|
|
1403
1416
|
}
|
|
1404
|
-
this.
|
|
1405
|
-
this.
|
|
1417
|
+
this.k = this.k.slice(0, this.w = newLen);
|
|
1418
|
+
this.q = newItems.slice(0);
|
|
1406
1419
|
}
|
|
1407
1420
|
});
|
|
1408
|
-
return this.
|
|
1421
|
+
return this.k;
|
|
1409
1422
|
}
|
|
1410
1423
|
function compare(key, a, b) {
|
|
1411
1424
|
return key ? key(a) === key(b) : true;
|
|
@@ -1421,6 +1434,7 @@ exports.NoOwnerError = NoOwnerError;
|
|
|
1421
1434
|
exports.NotReadyError = NotReadyError;
|
|
1422
1435
|
exports.Owner = Owner;
|
|
1423
1436
|
exports.Queue = Queue;
|
|
1437
|
+
exports.SUPPORTS_PROXY = SUPPORTS_PROXY;
|
|
1424
1438
|
exports.catchError = catchError;
|
|
1425
1439
|
exports.createAsync = createAsync;
|
|
1426
1440
|
exports.createBoundary = createBoundary;
|