@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/prod.js
CHANGED
|
@@ -46,30 +46,30 @@ var Owner = class {
|
|
|
46
46
|
// We flatten the owner tree into a linked list so that we don't need a pointer to .firstChild
|
|
47
47
|
// However, the children are actually added in reverse creation order
|
|
48
48
|
// See comment at the top of the file for an example of the _nextSibling traversal
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
r = null;
|
|
50
|
+
m = null;
|
|
51
51
|
o = null;
|
|
52
52
|
a = STATE_CLEAN;
|
|
53
|
-
g = null;
|
|
54
|
-
m = defaultContext;
|
|
55
53
|
h = null;
|
|
54
|
+
n = defaultContext;
|
|
55
|
+
i = null;
|
|
56
56
|
e = null;
|
|
57
57
|
constructor(signal = false) {
|
|
58
58
|
if (currentOwner && !signal)
|
|
59
59
|
currentOwner.append(this);
|
|
60
60
|
}
|
|
61
61
|
append(child) {
|
|
62
|
-
child.
|
|
62
|
+
child.r = this;
|
|
63
63
|
child.o = this;
|
|
64
|
-
if (this.
|
|
65
|
-
this.
|
|
66
|
-
child.
|
|
67
|
-
this.
|
|
68
|
-
if (child.
|
|
69
|
-
child.
|
|
64
|
+
if (this.m)
|
|
65
|
+
this.m.o = child;
|
|
66
|
+
child.m = this.m;
|
|
67
|
+
this.m = child;
|
|
68
|
+
if (child.n !== this.n) {
|
|
69
|
+
child.n = { ...this.n, ...child.n };
|
|
70
70
|
}
|
|
71
|
-
if (this.
|
|
72
|
-
child.
|
|
71
|
+
if (this.i) {
|
|
72
|
+
child.i = !child.i ? this.i : [...child.i, ...this.i];
|
|
73
73
|
}
|
|
74
74
|
if (this.e)
|
|
75
75
|
child.e = this.e;
|
|
@@ -77,51 +77,51 @@ var Owner = class {
|
|
|
77
77
|
dispose(self = true) {
|
|
78
78
|
if (this.a === STATE_DISPOSED)
|
|
79
79
|
return;
|
|
80
|
-
let head = self ? this.o || this.
|
|
81
|
-
while (current && current.
|
|
80
|
+
let head = self ? this.o || this.r : this, current = this.m, next = null;
|
|
81
|
+
while (current && current.r === this) {
|
|
82
82
|
current.dispose(true);
|
|
83
|
-
current.
|
|
84
|
-
next = current.
|
|
85
|
-
current.
|
|
83
|
+
current.x();
|
|
84
|
+
next = current.m;
|
|
85
|
+
current.m = null;
|
|
86
86
|
current = next;
|
|
87
87
|
}
|
|
88
88
|
if (self)
|
|
89
|
-
this.
|
|
89
|
+
this.x();
|
|
90
90
|
if (current)
|
|
91
91
|
current.o = !self ? this : this.o;
|
|
92
92
|
if (head)
|
|
93
|
-
head.
|
|
93
|
+
head.m = current;
|
|
94
94
|
}
|
|
95
|
-
|
|
95
|
+
x() {
|
|
96
96
|
if (this.o)
|
|
97
|
-
this.o.
|
|
98
|
-
this.
|
|
97
|
+
this.o.m = null;
|
|
98
|
+
this.r = null;
|
|
99
99
|
this.o = null;
|
|
100
|
-
this.
|
|
101
|
-
this.
|
|
100
|
+
this.n = defaultContext;
|
|
101
|
+
this.i = null;
|
|
102
102
|
this.a = STATE_DISPOSED;
|
|
103
103
|
this.emptyDisposal();
|
|
104
104
|
}
|
|
105
105
|
emptyDisposal() {
|
|
106
|
-
if (!this.
|
|
106
|
+
if (!this.h)
|
|
107
107
|
return;
|
|
108
|
-
if (Array.isArray(this.
|
|
109
|
-
for (let i = 0; i < this.
|
|
110
|
-
const callable = this.
|
|
108
|
+
if (Array.isArray(this.h)) {
|
|
109
|
+
for (let i = 0; i < this.h.length; i++) {
|
|
110
|
+
const callable = this.h[i];
|
|
111
111
|
callable.call(callable);
|
|
112
112
|
}
|
|
113
113
|
} else {
|
|
114
|
-
this.
|
|
114
|
+
this.h.call(this.h);
|
|
115
115
|
}
|
|
116
|
-
this.
|
|
116
|
+
this.h = null;
|
|
117
117
|
}
|
|
118
118
|
handleError(error) {
|
|
119
|
-
if (!this.
|
|
119
|
+
if (!this.i)
|
|
120
120
|
throw error;
|
|
121
|
-
let i = 0, len = this.
|
|
121
|
+
let i = 0, len = this.i.length;
|
|
122
122
|
for (i = 0; i < len; i++) {
|
|
123
123
|
try {
|
|
124
|
-
this.
|
|
124
|
+
this.i[i](error);
|
|
125
125
|
break;
|
|
126
126
|
} catch (e) {
|
|
127
127
|
error = e;
|
|
@@ -138,7 +138,7 @@ function getContext(context, owner = currentOwner) {
|
|
|
138
138
|
if (!owner) {
|
|
139
139
|
throw new NoOwnerError();
|
|
140
140
|
}
|
|
141
|
-
const value = hasContext(context, owner) ? owner.
|
|
141
|
+
const value = hasContext(context, owner) ? owner.n[context.id] : context.defaultValue;
|
|
142
142
|
if (isUndefined(value)) {
|
|
143
143
|
throw new ContextNotFoundError();
|
|
144
144
|
}
|
|
@@ -148,24 +148,24 @@ function setContext(context, value, owner = currentOwner) {
|
|
|
148
148
|
if (!owner) {
|
|
149
149
|
throw new NoOwnerError();
|
|
150
150
|
}
|
|
151
|
-
owner.
|
|
152
|
-
...owner.
|
|
151
|
+
owner.n = {
|
|
152
|
+
...owner.n,
|
|
153
153
|
[context.id]: isUndefined(value) ? context.defaultValue : value
|
|
154
154
|
};
|
|
155
155
|
}
|
|
156
156
|
function hasContext(context, owner = currentOwner) {
|
|
157
|
-
return !isUndefined(owner?.
|
|
157
|
+
return !isUndefined(owner?.n[context.id]);
|
|
158
158
|
}
|
|
159
159
|
function onCleanup(disposable) {
|
|
160
160
|
if (!currentOwner)
|
|
161
161
|
return;
|
|
162
162
|
const node = currentOwner;
|
|
163
|
-
if (!node.
|
|
164
|
-
node.
|
|
165
|
-
} else if (Array.isArray(node.
|
|
166
|
-
node.
|
|
163
|
+
if (!node.h) {
|
|
164
|
+
node.h = disposable;
|
|
165
|
+
} else if (Array.isArray(node.h)) {
|
|
166
|
+
node.h.push(disposable);
|
|
167
167
|
} else {
|
|
168
|
-
node.
|
|
168
|
+
node.h = [node.h, disposable];
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
|
|
@@ -204,7 +204,7 @@ var Computation = class extends Owner {
|
|
|
204
204
|
E = isEqual;
|
|
205
205
|
N;
|
|
206
206
|
/** Whether the computation is an error or has ancestors that are unresolved */
|
|
207
|
-
|
|
207
|
+
j = 0;
|
|
208
208
|
/** Which flags raised by sources are handled, vs. being passed through. */
|
|
209
209
|
A = DEFAULT_FLAGS;
|
|
210
210
|
F = null;
|
|
@@ -222,11 +222,11 @@ var Computation = class extends Owner {
|
|
|
222
222
|
}
|
|
223
223
|
O() {
|
|
224
224
|
if (this.D)
|
|
225
|
-
this.
|
|
225
|
+
this.s();
|
|
226
226
|
if (!this.b || this.b.length)
|
|
227
227
|
track(this);
|
|
228
|
-
newFlags |= this.
|
|
229
|
-
if (this.
|
|
228
|
+
newFlags |= this.j & ~currentMask;
|
|
229
|
+
if (this.j & ERROR_BIT) {
|
|
230
230
|
throw this.d;
|
|
231
231
|
} else {
|
|
232
232
|
return this.d;
|
|
@@ -281,13 +281,13 @@ var Computation = class extends Owner {
|
|
|
281
281
|
const valueChanged = newValue !== UNCHANGED && (!!(flags & ERROR_BIT) || this.E === false || !this.E(this.d, newValue));
|
|
282
282
|
if (valueChanged)
|
|
283
283
|
this.d = newValue;
|
|
284
|
-
const changedFlagsMask = this.
|
|
285
|
-
this.
|
|
284
|
+
const changedFlagsMask = this.j ^ flags, changedFlags = changedFlagsMask & flags;
|
|
285
|
+
this.j = flags;
|
|
286
286
|
this.H = clock + 1;
|
|
287
287
|
if (this.c) {
|
|
288
288
|
for (let i = 0; i < this.c.length; i++) {
|
|
289
289
|
if (valueChanged) {
|
|
290
|
-
this.c[i].
|
|
290
|
+
this.c[i].t(STATE_DIRTY);
|
|
291
291
|
} else if (changedFlagsMask) {
|
|
292
292
|
this.c[i].P(changedFlagsMask, changedFlags);
|
|
293
293
|
}
|
|
@@ -298,13 +298,13 @@ var Computation = class extends Owner {
|
|
|
298
298
|
/**
|
|
299
299
|
* Set the current node's state, and recursively mark all of this node's observers as STATE_CHECK
|
|
300
300
|
*/
|
|
301
|
-
|
|
301
|
+
t(state) {
|
|
302
302
|
if (this.a >= state)
|
|
303
303
|
return;
|
|
304
304
|
this.a = state;
|
|
305
305
|
if (this.c) {
|
|
306
306
|
for (let i = 0; i < this.c.length; i++) {
|
|
307
|
-
this.c[i].
|
|
307
|
+
this.c[i].t(STATE_CHECK);
|
|
308
308
|
}
|
|
309
309
|
}
|
|
310
310
|
}
|
|
@@ -318,17 +318,17 @@ var Computation = class extends Owner {
|
|
|
318
318
|
if (this.a >= STATE_DIRTY)
|
|
319
319
|
return;
|
|
320
320
|
if (mask & this.A) {
|
|
321
|
-
this.
|
|
321
|
+
this.t(STATE_DIRTY);
|
|
322
322
|
return;
|
|
323
323
|
}
|
|
324
324
|
if (this.a >= STATE_CHECK)
|
|
325
325
|
return;
|
|
326
|
-
const prevFlags = this.
|
|
326
|
+
const prevFlags = this.j & mask;
|
|
327
327
|
const deltaFlags = prevFlags ^ newFlags2;
|
|
328
328
|
if (newFlags2 === prevFlags) ; else if (deltaFlags & prevFlags & mask) {
|
|
329
|
-
this.
|
|
329
|
+
this.t(STATE_CHECK);
|
|
330
330
|
} else {
|
|
331
|
-
this.
|
|
331
|
+
this.j ^= deltaFlags;
|
|
332
332
|
if (this.c) {
|
|
333
333
|
for (let i = 0; i < this.c.length; i++) {
|
|
334
334
|
this.c[i].P(mask, newFlags2);
|
|
@@ -337,7 +337,7 @@ var Computation = class extends Owner {
|
|
|
337
337
|
}
|
|
338
338
|
}
|
|
339
339
|
Q(error) {
|
|
340
|
-
this.write(error, this.
|
|
340
|
+
this.write(error, this.j | ERROR_BIT);
|
|
341
341
|
}
|
|
342
342
|
/**
|
|
343
343
|
* This is the core part of the reactivity system, which makes sure that the values are updated
|
|
@@ -346,7 +346,7 @@ var Computation = class extends Owner {
|
|
|
346
346
|
*
|
|
347
347
|
* This function will ensure that the value and states we read from the computation are up to date
|
|
348
348
|
*/
|
|
349
|
-
|
|
349
|
+
s() {
|
|
350
350
|
if (this.a === STATE_DISPOSED) {
|
|
351
351
|
throw new Error("Tried to read a disposed computation");
|
|
352
352
|
}
|
|
@@ -356,8 +356,8 @@ var Computation = class extends Owner {
|
|
|
356
356
|
let observerFlags = 0;
|
|
357
357
|
if (this.a === STATE_CHECK) {
|
|
358
358
|
for (let i = 0; i < this.b.length; i++) {
|
|
359
|
-
this.b[i].
|
|
360
|
-
observerFlags |= this.b[i].
|
|
359
|
+
this.b[i].s();
|
|
360
|
+
observerFlags |= this.b[i].j;
|
|
361
361
|
if (this.a === STATE_DIRTY) {
|
|
362
362
|
break;
|
|
363
363
|
}
|
|
@@ -373,23 +373,23 @@ var Computation = class extends Owner {
|
|
|
373
373
|
/**
|
|
374
374
|
* Remove ourselves from the owner graph and the computation graph
|
|
375
375
|
*/
|
|
376
|
-
|
|
376
|
+
x() {
|
|
377
377
|
if (this.a === STATE_DISPOSED)
|
|
378
378
|
return;
|
|
379
379
|
if (this.b)
|
|
380
380
|
removeSourceObservers(this, 0);
|
|
381
|
-
super.
|
|
381
|
+
super.x();
|
|
382
382
|
}
|
|
383
383
|
};
|
|
384
384
|
function loadingState(node) {
|
|
385
|
-
const prevOwner = setOwner(node.
|
|
385
|
+
const prevOwner = setOwner(node.r);
|
|
386
386
|
const options = void 0;
|
|
387
387
|
const computation = new Computation(
|
|
388
388
|
void 0,
|
|
389
389
|
() => {
|
|
390
390
|
track(node);
|
|
391
|
-
node.
|
|
392
|
-
return !!(node.
|
|
391
|
+
node.s();
|
|
392
|
+
return !!(node.j & LOADING_BIT);
|
|
393
393
|
},
|
|
394
394
|
options
|
|
395
395
|
);
|
|
@@ -398,14 +398,14 @@ function loadingState(node) {
|
|
|
398
398
|
return computation;
|
|
399
399
|
}
|
|
400
400
|
function errorState(node) {
|
|
401
|
-
const prevOwner = setOwner(node.
|
|
401
|
+
const prevOwner = setOwner(node.r);
|
|
402
402
|
const options = void 0;
|
|
403
403
|
const computation = new Computation(
|
|
404
404
|
void 0,
|
|
405
405
|
() => {
|
|
406
406
|
track(node);
|
|
407
|
-
node.
|
|
408
|
-
return !!(node.
|
|
407
|
+
node.s();
|
|
408
|
+
return !!(node.j & ERROR_BIT);
|
|
409
409
|
},
|
|
410
410
|
options
|
|
411
411
|
);
|
|
@@ -547,27 +547,27 @@ function schedule() {
|
|
|
547
547
|
}
|
|
548
548
|
var Queue = class {
|
|
549
549
|
I = false;
|
|
550
|
-
|
|
551
|
-
|
|
550
|
+
u = [[], [], []];
|
|
551
|
+
z = [];
|
|
552
552
|
enqueue(type, node) {
|
|
553
|
-
this.
|
|
553
|
+
this.u[0].push(node);
|
|
554
554
|
if (type)
|
|
555
|
-
this.
|
|
555
|
+
this.u[type].push(node);
|
|
556
556
|
schedule();
|
|
557
557
|
}
|
|
558
558
|
run(type) {
|
|
559
|
-
if (this.
|
|
559
|
+
if (this.u[type].length) {
|
|
560
560
|
if (type === EFFECT_PURE) {
|
|
561
|
-
runPureQueue(this.
|
|
562
|
-
this.
|
|
561
|
+
runPureQueue(this.u[type]);
|
|
562
|
+
this.u[type] = [];
|
|
563
563
|
} else {
|
|
564
|
-
const effects = this.
|
|
565
|
-
this.
|
|
564
|
+
const effects = this.u[type];
|
|
565
|
+
this.u[type] = [];
|
|
566
566
|
runEffectQueue(effects);
|
|
567
567
|
}
|
|
568
568
|
}
|
|
569
|
-
for (let i = 0; i < this.
|
|
570
|
-
this.
|
|
569
|
+
for (let i = 0; i < this.z.length; i++) {
|
|
570
|
+
this.z[i].run(type);
|
|
571
571
|
}
|
|
572
572
|
}
|
|
573
573
|
flush() {
|
|
@@ -584,12 +584,12 @@ var Queue = class {
|
|
|
584
584
|
}
|
|
585
585
|
}
|
|
586
586
|
addChild(child) {
|
|
587
|
-
this.
|
|
587
|
+
this.z.push(child);
|
|
588
588
|
}
|
|
589
589
|
removeChild(child) {
|
|
590
|
-
const index = this.
|
|
590
|
+
const index = this.z.indexOf(child);
|
|
591
591
|
if (index >= 0)
|
|
592
|
-
this.
|
|
592
|
+
this.z.splice(index, 1);
|
|
593
593
|
}
|
|
594
594
|
};
|
|
595
595
|
var globalQueue = new Queue();
|
|
@@ -606,14 +606,14 @@ function createBoundary(fn, queue) {
|
|
|
606
606
|
}
|
|
607
607
|
function runTop(node) {
|
|
608
608
|
const ancestors = [];
|
|
609
|
-
for (let current = node; current !== null; current = current.
|
|
609
|
+
for (let current = node; current !== null; current = current.r) {
|
|
610
610
|
if (current.a !== STATE_CLEAN) {
|
|
611
611
|
ancestors.push(current);
|
|
612
612
|
}
|
|
613
613
|
}
|
|
614
614
|
for (let i = ancestors.length - 1; i >= 0; i--) {
|
|
615
615
|
if (ancestors[i].a !== STATE_DISPOSED)
|
|
616
|
-
ancestors[i].
|
|
616
|
+
ancestors[i].s();
|
|
617
617
|
}
|
|
618
618
|
}
|
|
619
619
|
function runPureQueue(queue) {
|
|
@@ -640,12 +640,12 @@ var Effect = class extends Computation {
|
|
|
640
640
|
this.B = initialValue;
|
|
641
641
|
this.C = options?.render ? EFFECT_RENDER : EFFECT_USER;
|
|
642
642
|
this.e = getOwner()?.e || globalQueue;
|
|
643
|
-
this.
|
|
643
|
+
this.s();
|
|
644
644
|
this.C === EFFECT_USER ? this.e.enqueue(this.C, this) : this.R();
|
|
645
645
|
}
|
|
646
646
|
write(value, flags = 0) {
|
|
647
|
-
const currentFlags = this.
|
|
648
|
-
this.
|
|
647
|
+
const currentFlags = this.j;
|
|
648
|
+
this.j = flags;
|
|
649
649
|
if ((flags & LOADING_BIT) !== (currentFlags & LOADING_BIT)) {
|
|
650
650
|
this.e.T?.(this);
|
|
651
651
|
}
|
|
@@ -655,7 +655,7 @@ var Effect = class extends Computation {
|
|
|
655
655
|
this.K = true;
|
|
656
656
|
return value;
|
|
657
657
|
}
|
|
658
|
-
|
|
658
|
+
t(state) {
|
|
659
659
|
if (this.a >= state)
|
|
660
660
|
return;
|
|
661
661
|
if (this.a === STATE_CLEAN)
|
|
@@ -665,10 +665,10 @@ var Effect = class extends Computation {
|
|
|
665
665
|
Q(error) {
|
|
666
666
|
this.handleError(error);
|
|
667
667
|
}
|
|
668
|
-
|
|
668
|
+
x() {
|
|
669
669
|
this.J = void 0;
|
|
670
670
|
this.B = void 0;
|
|
671
|
-
super.
|
|
671
|
+
super.x();
|
|
672
672
|
}
|
|
673
673
|
R() {
|
|
674
674
|
if (this.K && this.a !== STATE_DISPOSED) {
|
|
@@ -683,38 +683,38 @@ var EagerComputation = class extends Computation {
|
|
|
683
683
|
constructor(initialValue, compute2, options) {
|
|
684
684
|
super(initialValue, compute2, options);
|
|
685
685
|
this.e = getOwner()?.e || globalQueue;
|
|
686
|
-
this.
|
|
686
|
+
this.s();
|
|
687
687
|
}
|
|
688
|
-
|
|
688
|
+
t(state) {
|
|
689
689
|
if (this.a >= state)
|
|
690
690
|
return;
|
|
691
691
|
if (this.a === STATE_CLEAN)
|
|
692
692
|
this.e.enqueue(EFFECT_PURE, this);
|
|
693
|
-
super.
|
|
693
|
+
super.t(state);
|
|
694
694
|
}
|
|
695
695
|
};
|
|
696
696
|
|
|
697
697
|
// src/core/suspense.ts
|
|
698
698
|
var SuspenseQueue = class extends Queue {
|
|
699
|
-
|
|
700
|
-
|
|
699
|
+
f = /* @__PURE__ */ new Set();
|
|
700
|
+
p = false;
|
|
701
701
|
L = new Computation(false, null);
|
|
702
702
|
run(type) {
|
|
703
|
-
if (type && this.
|
|
703
|
+
if (type && this.p)
|
|
704
704
|
return;
|
|
705
705
|
super.run(type);
|
|
706
706
|
}
|
|
707
707
|
T(node) {
|
|
708
|
-
if (node.
|
|
709
|
-
this.
|
|
710
|
-
if (!this.
|
|
711
|
-
this.
|
|
708
|
+
if (node.j & LOADING_BIT) {
|
|
709
|
+
this.f.add(node);
|
|
710
|
+
if (!this.p) {
|
|
711
|
+
this.p = true;
|
|
712
712
|
queueMicrotask(() => this.L.write(true));
|
|
713
713
|
}
|
|
714
714
|
} else {
|
|
715
|
-
this.
|
|
716
|
-
if (this.
|
|
717
|
-
this.
|
|
715
|
+
this.f.delete(node);
|
|
716
|
+
if (this.f.size === 0) {
|
|
717
|
+
this.p = false;
|
|
718
718
|
queueMicrotask(() => this.L.write(false));
|
|
719
719
|
}
|
|
720
720
|
}
|
|
@@ -723,7 +723,7 @@ var SuspenseQueue = class extends Queue {
|
|
|
723
723
|
function createSuspense(fn, fallbackFn) {
|
|
724
724
|
const queue = new SuspenseQueue();
|
|
725
725
|
const tree = createBoundary(fn, queue);
|
|
726
|
-
const equality = new Computation(null, () => queue.L.read() || queue.
|
|
726
|
+
const equality = new Computation(null, () => queue.L.read() || queue.p);
|
|
727
727
|
const comp = new Computation(null, () => equality.read() ? untrack(fallbackFn) : tree);
|
|
728
728
|
return comp.read.bind(comp);
|
|
729
729
|
}
|
|
@@ -833,7 +833,7 @@ function runWithOwner(owner, run) {
|
|
|
833
833
|
}
|
|
834
834
|
function catchError(fn, handler) {
|
|
835
835
|
const owner = new Owner();
|
|
836
|
-
owner.
|
|
836
|
+
owner.i = owner.i ? [handler, ...owner.i] : [handler];
|
|
837
837
|
try {
|
|
838
838
|
compute(owner, fn, null);
|
|
839
839
|
} catch (error) {
|
|
@@ -851,15 +851,22 @@ var STORE_NODE = "n";
|
|
|
851
851
|
var STORE_HAS = "h";
|
|
852
852
|
function wrap(value) {
|
|
853
853
|
let p = value[$PROXY];
|
|
854
|
-
if (!p)
|
|
854
|
+
if (!p) {
|
|
855
|
+
let target;
|
|
856
|
+
if (Array.isArray(value)) {
|
|
857
|
+
target = [];
|
|
858
|
+
target.v = value;
|
|
859
|
+
} else
|
|
860
|
+
target = { v: value };
|
|
855
861
|
Object.defineProperty(value, $PROXY, {
|
|
856
|
-
value: p = new Proxy(
|
|
862
|
+
value: p = new Proxy(target, proxyTraps),
|
|
857
863
|
writable: true
|
|
858
864
|
});
|
|
865
|
+
}
|
|
859
866
|
return p;
|
|
860
867
|
}
|
|
861
868
|
function isWrappable(obj) {
|
|
862
|
-
return obj != null && typeof obj === "object";
|
|
869
|
+
return obj != null && typeof obj === "object" && !Object.isFrozen(obj);
|
|
863
870
|
}
|
|
864
871
|
function unwrap(item, deep = true, set) {
|
|
865
872
|
let result, unwrapped, v, prop;
|
|
@@ -911,8 +918,10 @@ function getNode(nodes, property, value, equals = isEqual) {
|
|
|
911
918
|
});
|
|
912
919
|
}
|
|
913
920
|
function proxyDescriptor(target, property) {
|
|
921
|
+
if (property === $PROXY)
|
|
922
|
+
return { value: target[$PROXY], writable: true, configurable: true };
|
|
914
923
|
const desc = Reflect.getOwnPropertyDescriptor(target[STORE_VALUE], property);
|
|
915
|
-
if (!desc || desc.get || !desc.configurable
|
|
924
|
+
if (!desc || desc.get || !desc.configurable)
|
|
916
925
|
return desc;
|
|
917
926
|
delete desc.value;
|
|
918
927
|
delete desc.writable;
|
|
@@ -978,7 +987,10 @@ var proxyTraps = {
|
|
|
978
987
|
return true;
|
|
979
988
|
},
|
|
980
989
|
ownKeys,
|
|
981
|
-
getOwnPropertyDescriptor: proxyDescriptor
|
|
990
|
+
getOwnPropertyDescriptor: proxyDescriptor,
|
|
991
|
+
getPrototypeOf(target) {
|
|
992
|
+
return Object.getPrototypeOf(target[STORE_VALUE]);
|
|
993
|
+
}
|
|
982
994
|
};
|
|
983
995
|
function setProperty(state, property, value, deleting = false) {
|
|
984
996
|
const prev = state[property];
|
|
@@ -1132,6 +1144,7 @@ function reconcile(value, key) {
|
|
|
1132
1144
|
if (keyFn(value) !== keyFn(state))
|
|
1133
1145
|
throw new Error("Cannot reconcile states with different identity");
|
|
1134
1146
|
applyState(value, state, keyFn);
|
|
1147
|
+
return state;
|
|
1135
1148
|
};
|
|
1136
1149
|
}
|
|
1137
1150
|
|
|
@@ -1286,120 +1299,120 @@ function omit(props, ...keys) {
|
|
|
1286
1299
|
// src/map.ts
|
|
1287
1300
|
function mapArray(list, map, options) {
|
|
1288
1301
|
const keyFn = typeof options?.keyed === "function" ? options.keyed : void 0;
|
|
1289
|
-
return
|
|
1290
|
-
new
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
j: map.length > 1 ? [] : void 0
|
|
1303
|
-
}),
|
|
1304
|
-
options
|
|
1305
|
-
)
|
|
1306
|
-
);
|
|
1302
|
+
return updateKeyedMap.bind({
|
|
1303
|
+
S: new Owner(),
|
|
1304
|
+
w: 0,
|
|
1305
|
+
U: list,
|
|
1306
|
+
q: [],
|
|
1307
|
+
M: map,
|
|
1308
|
+
k: [],
|
|
1309
|
+
f: [],
|
|
1310
|
+
y: keyFn,
|
|
1311
|
+
g: keyFn || options?.keyed === false ? [] : void 0,
|
|
1312
|
+
l: map.length > 1 ? [] : void 0,
|
|
1313
|
+
p: options?.fallback
|
|
1314
|
+
});
|
|
1307
1315
|
}
|
|
1308
1316
|
function updateKeyedMap() {
|
|
1309
1317
|
const newItems = this.U() || [], newLen = newItems.length;
|
|
1310
1318
|
newItems[$TRACK];
|
|
1311
1319
|
runWithOwner(this.S, () => {
|
|
1312
|
-
let i, j, mapper = this.
|
|
1313
|
-
this.
|
|
1314
|
-
this.
|
|
1320
|
+
let i, j, mapper = this.g ? () => {
|
|
1321
|
+
this.g[j] = new Computation(newItems[j], null);
|
|
1322
|
+
this.l[j] = new Computation(j, null);
|
|
1315
1323
|
return this.M(
|
|
1316
|
-
Computation.prototype.read.bind(this.
|
|
1317
|
-
Computation.prototype.read.bind(this.
|
|
1324
|
+
Computation.prototype.read.bind(this.g[j]),
|
|
1325
|
+
Computation.prototype.read.bind(this.l[j])
|
|
1318
1326
|
);
|
|
1319
|
-
} : this.
|
|
1327
|
+
} : this.l ? () => {
|
|
1320
1328
|
const item = newItems[j];
|
|
1321
|
-
this.
|
|
1322
|
-
return this.M(() => item, Computation.prototype.read.bind(this.
|
|
1329
|
+
this.l[j] = new Computation(j, null);
|
|
1330
|
+
return this.M(() => item, Computation.prototype.read.bind(this.l[j]));
|
|
1323
1331
|
} : () => {
|
|
1324
1332
|
const item = newItems[j];
|
|
1325
1333
|
return this.M(() => item);
|
|
1326
1334
|
};
|
|
1327
1335
|
if (newLen === 0) {
|
|
1328
|
-
if (this.
|
|
1336
|
+
if (this.w !== 0) {
|
|
1329
1337
|
this.S.dispose(false);
|
|
1338
|
+
this.f = [];
|
|
1339
|
+
this.q = [];
|
|
1330
1340
|
this.k = [];
|
|
1331
|
-
this.
|
|
1332
|
-
this.
|
|
1333
|
-
this.
|
|
1334
|
-
|
|
1335
|
-
|
|
1341
|
+
this.w = 0;
|
|
1342
|
+
this.g && (this.g = []);
|
|
1343
|
+
this.l && (this.l = []);
|
|
1344
|
+
}
|
|
1345
|
+
if (this.p && !this.k[0]) {
|
|
1346
|
+
this.k[0] = compute(this.f[0] = new Owner(), this.p, null);
|
|
1336
1347
|
}
|
|
1337
|
-
} else if (this.
|
|
1338
|
-
this.
|
|
1348
|
+
} else if (this.w === 0) {
|
|
1349
|
+
if (this.f[0])
|
|
1350
|
+
this.f[0].dispose();
|
|
1351
|
+
this.k = new Array(newLen);
|
|
1339
1352
|
for (j = 0; j < newLen; j++) {
|
|
1340
|
-
this.
|
|
1341
|
-
this.
|
|
1353
|
+
this.q[j] = newItems[j];
|
|
1354
|
+
this.k[j] = compute(this.f[j] = new Owner(), mapper, null);
|
|
1342
1355
|
}
|
|
1343
|
-
this.
|
|
1356
|
+
this.w = newLen;
|
|
1344
1357
|
} else {
|
|
1345
|
-
let start, end, newEnd, item, key, newIndices, newIndicesNext, temp = new Array(newLen), tempNodes = new Array(newLen), tempRows = this.
|
|
1346
|
-
for (start = 0, end = Math.min(this.
|
|
1347
|
-
if (this.
|
|
1348
|
-
this.
|
|
1358
|
+
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;
|
|
1359
|
+
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++) {
|
|
1360
|
+
if (this.g)
|
|
1361
|
+
this.g[start].write(newItems[start]);
|
|
1349
1362
|
}
|
|
1350
|
-
for (end = this.
|
|
1351
|
-
temp[newEnd] = this.
|
|
1352
|
-
tempNodes[newEnd] = this.
|
|
1353
|
-
tempRows && (tempRows[newEnd] = this.
|
|
1354
|
-
tempIndexes && (tempIndexes[newEnd] = this.
|
|
1363
|
+
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--) {
|
|
1364
|
+
temp[newEnd] = this.k[end];
|
|
1365
|
+
tempNodes[newEnd] = this.f[end];
|
|
1366
|
+
tempRows && (tempRows[newEnd] = this.g[end]);
|
|
1367
|
+
tempIndexes && (tempIndexes[newEnd] = this.l[end]);
|
|
1355
1368
|
}
|
|
1356
1369
|
newIndices = /* @__PURE__ */ new Map();
|
|
1357
1370
|
newIndicesNext = new Array(newEnd + 1);
|
|
1358
1371
|
for (j = newEnd; j >= start; j--) {
|
|
1359
1372
|
item = newItems[j];
|
|
1360
|
-
key = this.
|
|
1373
|
+
key = this.y ? this.y(item) : item;
|
|
1361
1374
|
i = newIndices.get(key);
|
|
1362
1375
|
newIndicesNext[j] = i === void 0 ? -1 : i;
|
|
1363
1376
|
newIndices.set(key, j);
|
|
1364
1377
|
}
|
|
1365
1378
|
for (i = start; i <= end; i++) {
|
|
1366
|
-
item = this.
|
|
1367
|
-
key = this.
|
|
1379
|
+
item = this.q[i];
|
|
1380
|
+
key = this.y ? this.y(item) : item;
|
|
1368
1381
|
j = newIndices.get(key);
|
|
1369
1382
|
if (j !== void 0 && j !== -1) {
|
|
1370
|
-
temp[j] = this.
|
|
1371
|
-
tempNodes[j] = this.
|
|
1372
|
-
tempRows && (tempRows[j] = this.
|
|
1373
|
-
tempIndexes && (tempIndexes[j] = this.
|
|
1383
|
+
temp[j] = this.k[i];
|
|
1384
|
+
tempNodes[j] = this.f[i];
|
|
1385
|
+
tempRows && (tempRows[j] = this.g[i]);
|
|
1386
|
+
tempIndexes && (tempIndexes[j] = this.l[i]);
|
|
1374
1387
|
j = newIndicesNext[j];
|
|
1375
1388
|
newIndices.set(key, j);
|
|
1376
1389
|
} else
|
|
1377
|
-
this.
|
|
1390
|
+
this.f[i].dispose();
|
|
1378
1391
|
}
|
|
1379
1392
|
for (j = start; j < newLen; j++) {
|
|
1380
1393
|
if (j in temp) {
|
|
1381
|
-
this.
|
|
1382
|
-
this.
|
|
1394
|
+
this.k[j] = temp[j];
|
|
1395
|
+
this.f[j] = tempNodes[j];
|
|
1383
1396
|
if (tempRows) {
|
|
1384
|
-
this.
|
|
1385
|
-
this.
|
|
1397
|
+
this.g[j] = tempRows[j];
|
|
1398
|
+
this.g[j].write(newItems[j]);
|
|
1386
1399
|
}
|
|
1387
1400
|
if (tempIndexes) {
|
|
1388
|
-
this.
|
|
1389
|
-
this.
|
|
1401
|
+
this.l[j] = tempIndexes[j];
|
|
1402
|
+
this.l[j].write(j);
|
|
1390
1403
|
}
|
|
1391
1404
|
} else {
|
|
1392
|
-
this.
|
|
1405
|
+
this.k[j] = compute(this.f[j] = new Owner(), mapper, null);
|
|
1393
1406
|
}
|
|
1394
1407
|
}
|
|
1395
|
-
this.
|
|
1396
|
-
this.
|
|
1408
|
+
this.k = this.k.slice(0, this.w = newLen);
|
|
1409
|
+
this.q = newItems.slice(0);
|
|
1397
1410
|
}
|
|
1398
1411
|
});
|
|
1399
|
-
return this.
|
|
1412
|
+
return this.k;
|
|
1400
1413
|
}
|
|
1401
1414
|
function compare(key, a, b) {
|
|
1402
1415
|
return key ? key(a) === key(b) : true;
|
|
1403
1416
|
}
|
|
1404
1417
|
|
|
1405
|
-
export { $PROXY, $RAW, $TARGET, $TRACK, Computation, ContextNotFoundError, NoOwnerError, NotReadyError, Owner, Queue, catchError, createAsync, createBoundary, createContext, createEffect, createMemo, createProjection, createRenderEffect, createRoot, createSignal, createStore, createSuspense, flushSync, getContext, getObserver, getOwner, hasContext, hasUpdated, isEqual, isPending, isWrappable, latest, mapArray, merge, omit, onCleanup, reconcile, runWithOwner, setContext, untrack, unwrap };
|
|
1418
|
+
export { $PROXY, $RAW, $TARGET, $TRACK, Computation, ContextNotFoundError, NoOwnerError, NotReadyError, Owner, Queue, SUPPORTS_PROXY, catchError, createAsync, createBoundary, createContext, createEffect, createMemo, createProjection, createRenderEffect, createRoot, createSignal, createStore, createSuspense, flushSync, getContext, getObserver, getOwner, hasContext, hasUpdated, isEqual, isPending, isWrappable, latest, mapArray, merge, omit, onCleanup, reconcile, runWithOwner, setContext, untrack, unwrap };
|