@solidjs/signals 0.10.2 → 0.10.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 +13 -3
- package/dist/node.cjs +201 -195
- package/dist/prod.js +169 -163
- package/dist/types/core/owner.d.ts +4 -2
- package/dist/types/core/types.d.ts +2 -0
- package/dist/types/signals.d.ts +2 -0
- package/package.json +2 -2
package/dist/prod.js
CHANGED
|
@@ -833,7 +833,9 @@ function runDisposal(e, t) {
|
|
|
833
833
|
t ? (e.we = null) : (e.be = null);
|
|
834
834
|
}
|
|
835
835
|
function getNextChildId(e) {
|
|
836
|
-
|
|
836
|
+
let t = e;
|
|
837
|
+
while (t.Ve && t.i) t = t.i;
|
|
838
|
+
if (t.id != null) return formatId(t.id, t.ve++);
|
|
837
839
|
throw new Error("Cannot get child id from owner without an id");
|
|
838
840
|
}
|
|
839
841
|
function formatId(e, t) {
|
|
@@ -857,33 +859,35 @@ function onCleanup(e) {
|
|
|
857
859
|
}
|
|
858
860
|
function createOwner(e) {
|
|
859
861
|
const t = context;
|
|
860
|
-
const n =
|
|
861
|
-
|
|
862
|
+
const n = e?.transparent ?? false;
|
|
863
|
+
const i = {
|
|
864
|
+
id: e?.id ?? (n ? t?.id : t?.id != null ? getNextChildId(t) : undefined),
|
|
865
|
+
Ve: n || undefined,
|
|
862
866
|
t: true,
|
|
863
867
|
u: t?.t ? t.u : t,
|
|
864
868
|
Ce: null,
|
|
865
869
|
Ne: null,
|
|
866
870
|
be: null,
|
|
867
871
|
se: t?.se ?? globalQueue,
|
|
868
|
-
|
|
872
|
+
me: t?.me || defaultContext,
|
|
869
873
|
ve: 0,
|
|
870
874
|
we: null,
|
|
871
875
|
De: null,
|
|
872
876
|
i: t,
|
|
873
877
|
dispose(e = true) {
|
|
874
|
-
disposeChildren(
|
|
878
|
+
disposeChildren(i, e);
|
|
875
879
|
}
|
|
876
880
|
};
|
|
877
881
|
if (t) {
|
|
878
882
|
const e = t.Ce;
|
|
879
883
|
if (e === null) {
|
|
880
|
-
t.Ce =
|
|
884
|
+
t.Ce = i;
|
|
881
885
|
} else {
|
|
882
|
-
|
|
883
|
-
t.Ce =
|
|
886
|
+
i.Ne = e;
|
|
887
|
+
t.Ce = i;
|
|
884
888
|
}
|
|
885
889
|
}
|
|
886
|
-
return
|
|
890
|
+
return i;
|
|
887
891
|
}
|
|
888
892
|
function createRoot(e, t) {
|
|
889
893
|
const n = createOwner(t);
|
|
@@ -893,15 +897,15 @@ function unlinkSubs(e) {
|
|
|
893
897
|
const t = e.V;
|
|
894
898
|
const n = e.D;
|
|
895
899
|
const i = e.p;
|
|
896
|
-
const r = e.
|
|
897
|
-
if (i !== null) i.
|
|
898
|
-
else t.
|
|
900
|
+
const r = e.Le;
|
|
901
|
+
if (i !== null) i.Le = r;
|
|
902
|
+
else t.ke = r;
|
|
899
903
|
if (r !== null) r.p = i;
|
|
900
904
|
else {
|
|
901
905
|
t.I = i;
|
|
902
906
|
if (i === null) {
|
|
903
|
-
t.
|
|
904
|
-
t.L && !t.
|
|
907
|
+
t.Ue?.();
|
|
908
|
+
t.L && !t.We && unobserved(t);
|
|
905
909
|
}
|
|
906
910
|
}
|
|
907
911
|
return n;
|
|
@@ -927,9 +931,9 @@ function link(e, t) {
|
|
|
927
931
|
return;
|
|
928
932
|
}
|
|
929
933
|
}
|
|
930
|
-
const o = e.
|
|
934
|
+
const o = e.ke;
|
|
931
935
|
if (o !== null && o.h === t && (!r || isValidLink(o, t))) return;
|
|
932
|
-
const s = (t.ye = e.
|
|
936
|
+
const s = (t.ye = e.ke = { V: e, h: t, D: i, Le: o, p: null });
|
|
933
937
|
if (n !== null) n.D = s;
|
|
934
938
|
else t.N = s;
|
|
935
939
|
if (o !== null) o.p = s;
|
|
@@ -1074,14 +1078,16 @@ function updateIfNecessary(e) {
|
|
|
1074
1078
|
e.S = REACTIVE_NONE;
|
|
1075
1079
|
}
|
|
1076
1080
|
function computed(e, t, n) {
|
|
1077
|
-
const i =
|
|
1078
|
-
|
|
1081
|
+
const i = n?.transparent ?? false;
|
|
1082
|
+
const r = {
|
|
1083
|
+
id: n?.id ?? (i ? context?.id : context?.id != null ? getNextChildId(context) : undefined),
|
|
1084
|
+
Ve: i || undefined,
|
|
1079
1085
|
_e: n?.equals != null ? n.equals : isEqual,
|
|
1080
|
-
|
|
1081
|
-
|
|
1086
|
+
xe: !!n?.pureWrite,
|
|
1087
|
+
Ue: n?.unobserved,
|
|
1082
1088
|
be: null,
|
|
1083
1089
|
se: context?.se ?? globalQueue,
|
|
1084
|
-
|
|
1090
|
+
me: context?.me ?? defaultContext,
|
|
1085
1091
|
ve: 0,
|
|
1086
1092
|
L: e,
|
|
1087
1093
|
le: t,
|
|
@@ -1092,7 +1098,7 @@ function computed(e, t, n) {
|
|
|
1092
1098
|
N: null,
|
|
1093
1099
|
ye: null,
|
|
1094
1100
|
I: null,
|
|
1095
|
-
|
|
1101
|
+
ke: null,
|
|
1096
1102
|
i: context,
|
|
1097
1103
|
Ne: null,
|
|
1098
1104
|
Ce: null,
|
|
@@ -1105,29 +1111,29 @@ function computed(e, t, n) {
|
|
|
1105
1111
|
Se: null,
|
|
1106
1112
|
ne: null
|
|
1107
1113
|
};
|
|
1108
|
-
|
|
1109
|
-
const
|
|
1114
|
+
r.T = r;
|
|
1115
|
+
const o = context?.t ? context.u : context;
|
|
1110
1116
|
if (context) {
|
|
1111
1117
|
const e = context.Ce;
|
|
1112
1118
|
if (e === null) {
|
|
1113
|
-
context.Ce =
|
|
1119
|
+
context.Ce = r;
|
|
1114
1120
|
} else {
|
|
1115
|
-
|
|
1116
|
-
context.Ce =
|
|
1121
|
+
r.Ne = e;
|
|
1122
|
+
context.Ce = r;
|
|
1117
1123
|
}
|
|
1118
1124
|
}
|
|
1119
|
-
if (
|
|
1120
|
-
!n?.lazy && recompute(
|
|
1121
|
-
return
|
|
1125
|
+
if (o) r.o = o.o + 1;
|
|
1126
|
+
!n?.lazy && recompute(r, true);
|
|
1127
|
+
return r;
|
|
1122
1128
|
}
|
|
1123
1129
|
function signal(e, t, n = null) {
|
|
1124
1130
|
const i = {
|
|
1125
1131
|
_e: t?.equals != null ? t.equals : isEqual,
|
|
1126
|
-
|
|
1127
|
-
|
|
1132
|
+
xe: !!t?.pureWrite,
|
|
1133
|
+
Ue: t?.unobserved,
|
|
1128
1134
|
le: e,
|
|
1129
1135
|
I: null,
|
|
1130
|
-
|
|
1136
|
+
ke: null,
|
|
1131
1137
|
J: clock,
|
|
1132
1138
|
m: n,
|
|
1133
1139
|
P: n?.A || null,
|
|
@@ -1402,7 +1408,7 @@ function getContext(e, t = getOwner()) {
|
|
|
1402
1408
|
if (!t) {
|
|
1403
1409
|
throw new NoOwnerError();
|
|
1404
1410
|
}
|
|
1405
|
-
const n = hasContext(e, t) ? t.
|
|
1411
|
+
const n = hasContext(e, t) ? t.me[e.id] : e.defaultValue;
|
|
1406
1412
|
if (isUndefined(n)) {
|
|
1407
1413
|
throw new ContextNotFoundError();
|
|
1408
1414
|
}
|
|
@@ -1412,10 +1418,10 @@ function setContext(e, t, n = getOwner()) {
|
|
|
1412
1418
|
if (!n) {
|
|
1413
1419
|
throw new NoOwnerError();
|
|
1414
1420
|
}
|
|
1415
|
-
n.
|
|
1421
|
+
n.me = { ...n.me, [e.id]: isUndefined(t) ? e.defaultValue : t };
|
|
1416
1422
|
}
|
|
1417
1423
|
function hasContext(e, t) {
|
|
1418
|
-
return !isUndefined(t?.
|
|
1424
|
+
return !isUndefined(t?.me[e.id]);
|
|
1419
1425
|
}
|
|
1420
1426
|
function isUndefined(e) {
|
|
1421
1427
|
return typeof e === "undefined";
|
|
@@ -1699,7 +1705,7 @@ function createProjectionInternal(e, t = {}, n) {
|
|
|
1699
1705
|
r !== i && r !== undefined && reconcile(r, n?.key || "id", n?.all)(o);
|
|
1700
1706
|
});
|
|
1701
1707
|
});
|
|
1702
|
-
i.
|
|
1708
|
+
i.We = true;
|
|
1703
1709
|
return { store: o, node: i };
|
|
1704
1710
|
}
|
|
1705
1711
|
function createProjection(e, t = {}, n) {
|
|
@@ -2167,7 +2173,7 @@ function createOptimisticProjectionInternal(e, t = {}, n) {
|
|
|
2167
2173
|
setProjectionWriteActive(false);
|
|
2168
2174
|
}
|
|
2169
2175
|
});
|
|
2170
|
-
i.
|
|
2176
|
+
i.We = true;
|
|
2171
2177
|
}
|
|
2172
2178
|
return { store: o, node: i };
|
|
2173
2179
|
}
|
|
@@ -2351,68 +2357,68 @@ function mapArray(e, t, n) {
|
|
|
2351
2357
|
const i = typeof n?.keyed === "function" ? n.keyed : undefined;
|
|
2352
2358
|
return createMemo(
|
|
2353
2359
|
updateKeyedMap.bind({
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
He: [],
|
|
2360
|
+
Me: createOwner(),
|
|
2361
|
+
Fe: 0,
|
|
2362
|
+
Ge: e,
|
|
2363
|
+
$e: [],
|
|
2364
|
+
He: t,
|
|
2360
2365
|
je: [],
|
|
2361
|
-
Ke:
|
|
2362
|
-
Ye: i
|
|
2363
|
-
Be:
|
|
2364
|
-
Xe:
|
|
2366
|
+
Ke: [],
|
|
2367
|
+
Ye: i,
|
|
2368
|
+
Be: i || n?.keyed === false ? [] : undefined,
|
|
2369
|
+
Xe: t.length > 1 ? [] : undefined,
|
|
2370
|
+
qe: n?.fallback
|
|
2365
2371
|
})
|
|
2366
2372
|
);
|
|
2367
2373
|
}
|
|
2368
2374
|
const pureOptions = { pureWrite: true };
|
|
2369
2375
|
function updateKeyedMap() {
|
|
2370
|
-
const e = this.
|
|
2376
|
+
const e = this.Ge() || [],
|
|
2371
2377
|
t = e.length;
|
|
2372
2378
|
e[$TRACK];
|
|
2373
|
-
runWithOwner(this.
|
|
2379
|
+
runWithOwner(this.Me, () => {
|
|
2374
2380
|
let n,
|
|
2375
2381
|
i,
|
|
2376
|
-
r = this.
|
|
2382
|
+
r = this.Be
|
|
2377
2383
|
? () => {
|
|
2378
|
-
this.
|
|
2379
|
-
this.
|
|
2380
|
-
return this
|
|
2381
|
-
read.bind(null, this.
|
|
2382
|
-
this.
|
|
2384
|
+
this.Be[i] = signal(e[i], pureOptions);
|
|
2385
|
+
this.Xe && (this.Xe[i] = signal(i, pureOptions));
|
|
2386
|
+
return this.He(
|
|
2387
|
+
read.bind(null, this.Be[i]),
|
|
2388
|
+
this.Xe ? read.bind(null, this.Xe[i]) : undefined
|
|
2383
2389
|
);
|
|
2384
2390
|
}
|
|
2385
|
-
: this.
|
|
2391
|
+
: this.Xe
|
|
2386
2392
|
? () => {
|
|
2387
2393
|
const t = e[i];
|
|
2388
|
-
this.
|
|
2389
|
-
return this
|
|
2394
|
+
this.Xe[i] = signal(i, pureOptions);
|
|
2395
|
+
return this.He(() => t, read.bind(null, this.Xe[i]));
|
|
2390
2396
|
}
|
|
2391
2397
|
: () => {
|
|
2392
2398
|
const t = e[i];
|
|
2393
|
-
return this
|
|
2399
|
+
return this.He(() => t);
|
|
2394
2400
|
};
|
|
2395
2401
|
if (t === 0) {
|
|
2396
|
-
if (this.
|
|
2397
|
-
this.
|
|
2402
|
+
if (this.Fe !== 0) {
|
|
2403
|
+
this.Me.dispose(false);
|
|
2404
|
+
this.Ke = [];
|
|
2405
|
+
this.$e = [];
|
|
2398
2406
|
this.je = [];
|
|
2399
|
-
this.
|
|
2400
|
-
this.He = [];
|
|
2401
|
-
this.Me = 0;
|
|
2402
|
-
this.Ye && (this.Ye = []);
|
|
2407
|
+
this.Fe = 0;
|
|
2403
2408
|
this.Be && (this.Be = []);
|
|
2409
|
+
this.Xe && (this.Xe = []);
|
|
2404
2410
|
}
|
|
2405
|
-
if (this.
|
|
2406
|
-
this.
|
|
2411
|
+
if (this.qe && !this.je[0]) {
|
|
2412
|
+
this.je[0] = runWithOwner((this.Ke[0] = createOwner()), this.qe);
|
|
2407
2413
|
}
|
|
2408
|
-
} else if (this.
|
|
2409
|
-
if (this.
|
|
2410
|
-
this.
|
|
2414
|
+
} else if (this.Fe === 0) {
|
|
2415
|
+
if (this.Ke[0]) this.Ke[0].dispose();
|
|
2416
|
+
this.je = new Array(t);
|
|
2411
2417
|
for (i = 0; i < t; i++) {
|
|
2412
|
-
this
|
|
2413
|
-
this.
|
|
2418
|
+
this.$e[i] = e[i];
|
|
2419
|
+
this.je[i] = runWithOwner((this.Ke[i] = createOwner()), r);
|
|
2414
2420
|
}
|
|
2415
|
-
this.
|
|
2421
|
+
this.Fe = t;
|
|
2416
2422
|
} else {
|
|
2417
2423
|
let o,
|
|
2418
2424
|
s,
|
|
@@ -2423,130 +2429,130 @@ function updateKeyedMap() {
|
|
|
2423
2429
|
f,
|
|
2424
2430
|
E = new Array(t),
|
|
2425
2431
|
T = new Array(t),
|
|
2426
|
-
d = this.
|
|
2427
|
-
R = this.
|
|
2432
|
+
d = this.Be ? new Array(t) : undefined,
|
|
2433
|
+
R = this.Xe ? new Array(t) : undefined;
|
|
2428
2434
|
for (
|
|
2429
|
-
o = 0, s = Math.min(this.
|
|
2430
|
-
o < s && (this
|
|
2435
|
+
o = 0, s = Math.min(this.Fe, t);
|
|
2436
|
+
o < s && (this.$e[o] === e[o] || (this.Be && compare(this.Ye, this.$e[o], e[o])));
|
|
2431
2437
|
o++
|
|
2432
2438
|
) {
|
|
2433
|
-
if (this.
|
|
2439
|
+
if (this.Be) setSignal(this.Be[o], e[o]);
|
|
2434
2440
|
}
|
|
2435
2441
|
for (
|
|
2436
|
-
s = this.
|
|
2442
|
+
s = this.Fe - 1, u = t - 1;
|
|
2437
2443
|
s >= o &&
|
|
2438
2444
|
u >= o &&
|
|
2439
|
-
(this
|
|
2445
|
+
(this.$e[s] === e[u] || (this.Be && compare(this.Ye, this.$e[s], e[u])));
|
|
2440
2446
|
s--, u--
|
|
2441
2447
|
) {
|
|
2442
|
-
E[u] = this.
|
|
2443
|
-
T[u] = this.
|
|
2444
|
-
d && (d[u] = this.
|
|
2445
|
-
R && (R[u] = this.
|
|
2448
|
+
E[u] = this.je[s];
|
|
2449
|
+
T[u] = this.Ke[s];
|
|
2450
|
+
d && (d[u] = this.Be[s]);
|
|
2451
|
+
R && (R[u] = this.Xe[s]);
|
|
2446
2452
|
}
|
|
2447
2453
|
a = new Map();
|
|
2448
2454
|
f = new Array(u + 1);
|
|
2449
2455
|
for (i = u; i >= o; i--) {
|
|
2450
2456
|
c = e[i];
|
|
2451
|
-
l = this.
|
|
2457
|
+
l = this.Ye ? this.Ye(c) : c;
|
|
2452
2458
|
n = a.get(l);
|
|
2453
2459
|
f[i] = n === undefined ? -1 : n;
|
|
2454
2460
|
a.set(l, i);
|
|
2455
2461
|
}
|
|
2456
2462
|
for (n = o; n <= s; n++) {
|
|
2457
|
-
c = this
|
|
2458
|
-
l = this.
|
|
2463
|
+
c = this.$e[n];
|
|
2464
|
+
l = this.Ye ? this.Ye(c) : c;
|
|
2459
2465
|
i = a.get(l);
|
|
2460
2466
|
if (i !== undefined && i !== -1) {
|
|
2461
|
-
E[i] = this.
|
|
2462
|
-
T[i] = this.
|
|
2463
|
-
d && (d[i] = this.
|
|
2464
|
-
R && (R[i] = this.
|
|
2467
|
+
E[i] = this.je[n];
|
|
2468
|
+
T[i] = this.Ke[n];
|
|
2469
|
+
d && (d[i] = this.Be[n]);
|
|
2470
|
+
R && (R[i] = this.Xe[n]);
|
|
2465
2471
|
i = f[i];
|
|
2466
2472
|
a.set(l, i);
|
|
2467
|
-
} else this.
|
|
2473
|
+
} else this.Ke[n].dispose();
|
|
2468
2474
|
}
|
|
2469
2475
|
for (i = o; i < t; i++) {
|
|
2470
2476
|
if (i in E) {
|
|
2471
|
-
this.
|
|
2472
|
-
this.
|
|
2477
|
+
this.je[i] = E[i];
|
|
2478
|
+
this.Ke[i] = T[i];
|
|
2473
2479
|
if (d) {
|
|
2474
|
-
this.
|
|
2475
|
-
setSignal(this.
|
|
2480
|
+
this.Be[i] = d[i];
|
|
2481
|
+
setSignal(this.Be[i], e[i]);
|
|
2476
2482
|
}
|
|
2477
2483
|
if (R) {
|
|
2478
|
-
this.
|
|
2479
|
-
setSignal(this.
|
|
2484
|
+
this.Xe[i] = R[i];
|
|
2485
|
+
setSignal(this.Xe[i], i);
|
|
2480
2486
|
}
|
|
2481
2487
|
} else {
|
|
2482
|
-
this.
|
|
2488
|
+
this.je[i] = runWithOwner((this.Ke[i] = createOwner()), r);
|
|
2483
2489
|
}
|
|
2484
2490
|
}
|
|
2485
|
-
this.
|
|
2486
|
-
this
|
|
2491
|
+
this.je = this.je.slice(0, (this.Fe = t));
|
|
2492
|
+
this.$e = e.slice(0);
|
|
2487
2493
|
}
|
|
2488
2494
|
});
|
|
2489
|
-
return this.
|
|
2495
|
+
return this.je;
|
|
2490
2496
|
}
|
|
2491
2497
|
function repeat(e, t, n) {
|
|
2492
2498
|
return updateRepeat.bind({
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2499
|
+
Me: createOwner(),
|
|
2500
|
+
Fe: 0,
|
|
2501
|
+
ze: 0,
|
|
2502
|
+
Ze: e,
|
|
2503
|
+
He: t,
|
|
2504
|
+
Ke: [],
|
|
2498
2505
|
je: [],
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
Xe: n?.fallback
|
|
2506
|
+
Je: n?.from,
|
|
2507
|
+
qe: n?.fallback
|
|
2502
2508
|
});
|
|
2503
2509
|
}
|
|
2504
2510
|
function updateRepeat() {
|
|
2505
|
-
const e = this.
|
|
2506
|
-
const t = this.
|
|
2507
|
-
runWithOwner(this.
|
|
2511
|
+
const e = this.Ze();
|
|
2512
|
+
const t = this.Je?.() || 0;
|
|
2513
|
+
runWithOwner(this.Me, () => {
|
|
2508
2514
|
if (e === 0) {
|
|
2509
|
-
if (this.
|
|
2510
|
-
this.
|
|
2515
|
+
if (this.Fe !== 0) {
|
|
2516
|
+
this.Me.dispose(false);
|
|
2517
|
+
this.Ke = [];
|
|
2511
2518
|
this.je = [];
|
|
2512
|
-
this.
|
|
2513
|
-
this.Me = 0;
|
|
2519
|
+
this.Fe = 0;
|
|
2514
2520
|
}
|
|
2515
|
-
if (this.
|
|
2516
|
-
this.
|
|
2521
|
+
if (this.qe && !this.je[0]) {
|
|
2522
|
+
this.je[0] = runWithOwner((this.Ke[0] = createOwner()), this.qe);
|
|
2517
2523
|
}
|
|
2518
2524
|
return;
|
|
2519
2525
|
}
|
|
2520
2526
|
const n = t + e;
|
|
2521
|
-
const i = this.
|
|
2522
|
-
if (this.
|
|
2523
|
-
for (let e = n; e < i; e++) this.
|
|
2524
|
-
if (this.
|
|
2525
|
-
let e = this.
|
|
2526
|
-
while (e < t && e < this.
|
|
2527
|
-
this.
|
|
2528
|
-
this.
|
|
2529
|
-
} else if (this.
|
|
2530
|
-
let n = i - this.
|
|
2531
|
-
let r = this.
|
|
2532
|
-
this.
|
|
2527
|
+
const i = this.ze + this.Fe;
|
|
2528
|
+
if (this.Fe === 0 && this.Ke[0]) this.Ke[0].dispose();
|
|
2529
|
+
for (let e = n; e < i; e++) this.Ke[e - this.ze].dispose();
|
|
2530
|
+
if (this.ze < t) {
|
|
2531
|
+
let e = this.ze;
|
|
2532
|
+
while (e < t && e < this.Fe) this.Ke[e++].dispose();
|
|
2533
|
+
this.Ke.splice(0, t - this.ze);
|
|
2534
|
+
this.je.splice(0, t - this.ze);
|
|
2535
|
+
} else if (this.ze > t) {
|
|
2536
|
+
let n = i - this.ze - 1;
|
|
2537
|
+
let r = this.ze - t;
|
|
2538
|
+
this.Ke.length = this.je.length = e;
|
|
2533
2539
|
while (n >= r) {
|
|
2540
|
+
this.Ke[n] = this.Ke[n - r];
|
|
2534
2541
|
this.je[n] = this.je[n - r];
|
|
2535
|
-
this.He[n] = this.He[n - r];
|
|
2536
2542
|
n--;
|
|
2537
2543
|
}
|
|
2538
2544
|
for (let e = 0; e < r; e++) {
|
|
2539
|
-
this.
|
|
2545
|
+
this.je[e] = runWithOwner((this.Ke[e] = createOwner()), () => this.He(e + t));
|
|
2540
2546
|
}
|
|
2541
2547
|
}
|
|
2542
2548
|
for (let e = i; e < n; e++) {
|
|
2543
|
-
this.
|
|
2549
|
+
this.je[e - t] = runWithOwner((this.Ke[e - t] = createOwner()), () => this.He(e));
|
|
2544
2550
|
}
|
|
2545
|
-
this.
|
|
2546
|
-
this.
|
|
2547
|
-
this.
|
|
2551
|
+
this.je = this.je.slice(0, e);
|
|
2552
|
+
this.ze = t;
|
|
2553
|
+
this.Fe = e;
|
|
2548
2554
|
});
|
|
2549
|
-
return this.
|
|
2555
|
+
return this.je;
|
|
2550
2556
|
}
|
|
2551
2557
|
function compare(e, t, n) {
|
|
2552
2558
|
return e ? e(t) === e(n) : true;
|
|
@@ -2556,11 +2562,11 @@ function boundaryComputed(e, t) {
|
|
|
2556
2562
|
n.pe = (e, t) => {
|
|
2557
2563
|
const i = e !== undefined ? e : n.ae;
|
|
2558
2564
|
const r = t !== undefined ? t : n.q;
|
|
2559
|
-
n.ae &= ~n.
|
|
2560
|
-
n.se.notify(n, n.
|
|
2565
|
+
n.ae &= ~n.et;
|
|
2566
|
+
n.se.notify(n, n.et, i, r);
|
|
2561
2567
|
};
|
|
2562
|
-
n.
|
|
2563
|
-
n.
|
|
2568
|
+
n.et = t;
|
|
2569
|
+
n.We = true;
|
|
2564
2570
|
recompute(n, true);
|
|
2565
2571
|
return n;
|
|
2566
2572
|
}
|
|
@@ -2574,36 +2580,36 @@ function createBoundChildren(e, t, n, i) {
|
|
|
2574
2580
|
});
|
|
2575
2581
|
}
|
|
2576
2582
|
class CollectionQueue extends Queue {
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2583
|
+
tt;
|
|
2584
|
+
nt = new Set();
|
|
2585
|
+
it = signal(false, { pureWrite: true });
|
|
2586
|
+
rt = false;
|
|
2581
2587
|
constructor(e) {
|
|
2582
2588
|
super();
|
|
2583
|
-
this.
|
|
2589
|
+
this.tt = e;
|
|
2584
2590
|
}
|
|
2585
2591
|
run(e) {
|
|
2586
|
-
if (!e || read(this.
|
|
2592
|
+
if (!e || read(this.it)) return;
|
|
2587
2593
|
return super.run(e);
|
|
2588
2594
|
}
|
|
2589
2595
|
notify(e, t, n, i) {
|
|
2590
|
-
if (!(t & this.
|
|
2591
|
-
if (n & this.
|
|
2596
|
+
if (!(t & this.tt) || (this.tt & STATUS_PENDING && this.rt)) return super.notify(e, t, n, i);
|
|
2597
|
+
if (n & this.tt) {
|
|
2592
2598
|
const t = i?.source || e.q?.source;
|
|
2593
2599
|
if (t) {
|
|
2594
|
-
const e = this.
|
|
2595
|
-
this.
|
|
2596
|
-
if (e) setSignal(this.
|
|
2600
|
+
const e = this.nt.size === 0;
|
|
2601
|
+
this.nt.add(t);
|
|
2602
|
+
if (e) setSignal(this.it, true);
|
|
2597
2603
|
}
|
|
2598
2604
|
}
|
|
2599
|
-
t &= ~this.
|
|
2605
|
+
t &= ~this.tt;
|
|
2600
2606
|
return t ? super.notify(e, t, n, i) : true;
|
|
2601
2607
|
}
|
|
2602
2608
|
checkSources() {
|
|
2603
|
-
for (const e of this.
|
|
2604
|
-
if (!(e.ae & this.
|
|
2609
|
+
for (const e of this.nt) {
|
|
2610
|
+
if (!(e.ae & this.tt)) this.nt.delete(e);
|
|
2605
2611
|
}
|
|
2606
|
-
if (!this.
|
|
2612
|
+
if (!this.nt.size) setSignal(this.it, false);
|
|
2607
2613
|
}
|
|
2608
2614
|
}
|
|
2609
2615
|
function createCollectionBoundary(e, t, n) {
|
|
@@ -2611,10 +2617,10 @@ function createCollectionBoundary(e, t, n) {
|
|
|
2611
2617
|
const r = new CollectionQueue(e);
|
|
2612
2618
|
const o = createBoundChildren(i, t, r, e);
|
|
2613
2619
|
const s = computed(() => {
|
|
2614
|
-
if (!read(r.
|
|
2620
|
+
if (!read(r.it)) {
|
|
2615
2621
|
const e = read(o);
|
|
2616
|
-
if (!untrack(() => read(r.
|
|
2617
|
-
r.
|
|
2622
|
+
if (!untrack(() => read(r.it))) {
|
|
2623
|
+
r.rt = true;
|
|
2618
2624
|
return e;
|
|
2619
2625
|
}
|
|
2620
2626
|
}
|
|
@@ -2627,10 +2633,10 @@ function createLoadBoundary(e, t) {
|
|
|
2627
2633
|
}
|
|
2628
2634
|
function createErrorBoundary(e, t) {
|
|
2629
2635
|
return createCollectionBoundary(STATUS_ERROR, e, e => {
|
|
2630
|
-
let n = e.
|
|
2636
|
+
let n = e.nt.values().next().value;
|
|
2631
2637
|
const i = n.q?.cause ?? n.q;
|
|
2632
2638
|
return t(i, () => {
|
|
2633
|
-
for (const t of e.
|
|
2639
|
+
for (const t of e.nt) recompute(t);
|
|
2634
2640
|
schedule();
|
|
2635
2641
|
});
|
|
2636
2642
|
});
|
|
@@ -7,7 +7,8 @@ export declare function getObserver(): Owner | null;
|
|
|
7
7
|
export declare function getOwner(): Owner | null;
|
|
8
8
|
export declare function onCleanup(fn: Disposable): Disposable;
|
|
9
9
|
export declare function createOwner(options?: {
|
|
10
|
-
id
|
|
10
|
+
id?: string;
|
|
11
|
+
transparent?: boolean;
|
|
11
12
|
}): Root;
|
|
12
13
|
/**
|
|
13
14
|
* Creates a new non-tracked reactive context with manual disposal
|
|
@@ -18,5 +19,6 @@ export declare function createOwner(options?: {
|
|
|
18
19
|
* @description https://docs.solidjs.com/reference/reactive-utilities/create-root
|
|
19
20
|
*/
|
|
20
21
|
export declare function createRoot<T>(init: ((dispose: () => void) => T) | (() => T), options?: {
|
|
21
|
-
id
|
|
22
|
+
id?: string;
|
|
23
|
+
transparent?: boolean;
|
|
22
24
|
}): T;
|
|
@@ -14,6 +14,7 @@ export interface Link {
|
|
|
14
14
|
export interface NodeOptions<T> {
|
|
15
15
|
id?: string;
|
|
16
16
|
name?: string;
|
|
17
|
+
transparent?: boolean;
|
|
17
18
|
equals?: ((prev: T, next: T) => boolean) | false;
|
|
18
19
|
pureWrite?: boolean;
|
|
19
20
|
unobserved?: () => void;
|
|
@@ -43,6 +44,7 @@ export interface FirewallSignal<T> extends RawSignal<T> {
|
|
|
43
44
|
export type Signal<T> = RawSignal<T> | FirewallSignal<T>;
|
|
44
45
|
export interface Owner {
|
|
45
46
|
id?: string;
|
|
47
|
+
_transparent?: boolean;
|
|
46
48
|
_disposal: Disposable | Disposable[] | null;
|
|
47
49
|
_parent: Owner | null;
|
|
48
50
|
_context: Record<symbol | string, unknown>;
|
package/dist/types/signals.d.ts
CHANGED
|
@@ -40,6 +40,8 @@ export interface MemoOptions<T> {
|
|
|
40
40
|
id?: string;
|
|
41
41
|
/** Debug name (dev mode only) */
|
|
42
42
|
name?: string;
|
|
43
|
+
/** When true, the owner is invisible to the ID scheme -- inherits parent ID and doesn't consume a childCount slot */
|
|
44
|
+
transparent?: boolean;
|
|
43
45
|
/** Custom equality function, or `false` to always notify subscribers */
|
|
44
46
|
equals?: false | ((prev: T, next: T) => boolean);
|
|
45
47
|
/** Callback invoked when the computed loses all subscribers */
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidjs/signals",
|
|
3
|
-
"version": "0.10.
|
|
4
|
-
"description": "SolidJS' standalone
|
|
3
|
+
"version": "0.10.3",
|
|
4
|
+
"description": "SolidJS' standalone reactivity implementation",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|