@solidjs/signals 2.0.0-beta.13 → 2.0.0-beta.14
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/README.md +2 -3
- package/dist/dev.js +81 -23
- package/dist/node.cjs +712 -665
- package/dist/prod.js +481 -434
- package/dist/types/core/core.d.ts +4 -8
- package/dist/types/store/index.d.ts +1 -1
- package/dist/types/store/store.d.ts +6 -2
- package/dist/types-cjs/core/core.d.cts +4 -8
- package/dist/types-cjs/store/index.d.cts +1 -1
- package/dist/types-cjs/store/store.d.cts +6 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -107,9 +107,8 @@ const data = createMemo(async () => {
|
|
|
107
107
|
return response.json();
|
|
108
108
|
});
|
|
109
109
|
|
|
110
|
-
// Check async state
|
|
111
|
-
isPending(data); // true while
|
|
112
|
-
isPending(data, true); // follows the Loading path for render guards
|
|
110
|
+
// Check async state for this read
|
|
111
|
+
isPending(data); // true while this read touches pending async work
|
|
113
112
|
latest(data); // last resolved value
|
|
114
113
|
```
|
|
115
114
|
|
package/dist/dev.js
CHANGED
|
@@ -1469,7 +1469,7 @@ let foundPending = false;
|
|
|
1469
1469
|
let latestReadActive = false;
|
|
1470
1470
|
let context = null;
|
|
1471
1471
|
let currentOptimisticLane = null;
|
|
1472
|
-
let
|
|
1472
|
+
let pendingCheckSources = null;
|
|
1473
1473
|
let snapshotCaptureActive = false;
|
|
1474
1474
|
let snapshotSources = null;
|
|
1475
1475
|
function ownerInSnapshotScope(owner) {
|
|
@@ -1931,15 +1931,23 @@ function read(el) {
|
|
|
1931
1931
|
const firewall = el._firewall;
|
|
1932
1932
|
const prevCheck = pendingCheckActive;
|
|
1933
1933
|
pendingCheckActive = false;
|
|
1934
|
+
let c = context;
|
|
1935
|
+
if (c?._root) c = c._parentComputed;
|
|
1934
1936
|
const owner = firewall || el;
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
if (
|
|
1942
|
-
|
|
1937
|
+
const pendingComputed = el;
|
|
1938
|
+
if (typeof pendingComputed._fn === "function") {
|
|
1939
|
+
const comp = el;
|
|
1940
|
+
if (comp._flags & REACTIVE_LAZY) {
|
|
1941
|
+
comp._flags &= ~REACTIVE_LAZY;
|
|
1942
|
+
recompute(comp, true);
|
|
1943
|
+
} else if (comp._flags & REACTIVE_DISPOSED) {
|
|
1944
|
+
recompute(comp, true);
|
|
1945
|
+
} else {
|
|
1946
|
+
updateIfNecessary(comp);
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
if (c && owner._statusFlags & STATUS_PENDING && owner._statusFlags & STATUS_UNINITIALIZED) {
|
|
1950
|
+
if (tracking && el !== c) link(el, c);
|
|
1943
1951
|
pendingCheckActive = prevCheck;
|
|
1944
1952
|
throw owner._error;
|
|
1945
1953
|
}
|
|
@@ -1950,17 +1958,14 @@ function read(el) {
|
|
|
1950
1958
|
) {
|
|
1951
1959
|
foundPending = true;
|
|
1952
1960
|
}
|
|
1953
|
-
|
|
1954
|
-
|
|
1961
|
+
collectPendingSources(el);
|
|
1962
|
+
collectPendingSources(firewall);
|
|
1955
1963
|
if (c && tracking) link(el, c);
|
|
1956
|
-
read(getPendingSignal(el));
|
|
1957
|
-
read(getPendingSignal(firewall));
|
|
1958
1964
|
} else {
|
|
1959
|
-
|
|
1960
|
-
if (firewall
|
|
1965
|
+
collectPendingSources(el);
|
|
1966
|
+
if (firewall) collectPendingSources(firewall);
|
|
1961
1967
|
}
|
|
1962
1968
|
pendingCheckActive = prevCheck;
|
|
1963
|
-
return el._value;
|
|
1964
1969
|
}
|
|
1965
1970
|
let c = context;
|
|
1966
1971
|
if (c?._root) c = c._parentComputed;
|
|
@@ -2236,9 +2241,20 @@ function getPendingSignal(el) {
|
|
|
2236
2241
|
}
|
|
2237
2242
|
return el._pendingSignal;
|
|
2238
2243
|
}
|
|
2244
|
+
function collectPendingSources(el) {
|
|
2245
|
+
pendingCheckSources?.add(el);
|
|
2246
|
+
const owner = el._firewall || el;
|
|
2247
|
+
if (owner !== el) pendingCheckSources?.add(owner);
|
|
2248
|
+
}
|
|
2239
2249
|
function computePendingState(el) {
|
|
2240
2250
|
const comp = el;
|
|
2241
2251
|
const firewall = el._firewall;
|
|
2252
|
+
if (el._parentSource) {
|
|
2253
|
+
const parent = el._parentSource;
|
|
2254
|
+
if (parent._statusFlags & STATUS_PENDING && !(parent._statusFlags & STATUS_UNINITIALIZED))
|
|
2255
|
+
return true;
|
|
2256
|
+
return el._pendingValue !== NOT_PENDING && !(comp._statusFlags & STATUS_UNINITIALIZED);
|
|
2257
|
+
}
|
|
2242
2258
|
if (firewall && el._pendingValue !== NOT_PENDING) {
|
|
2243
2259
|
return !firewall._inFlight && !(firewall._statusFlags & STATUS_PENDING);
|
|
2244
2260
|
}
|
|
@@ -2309,24 +2325,41 @@ function latest(fn) {
|
|
|
2309
2325
|
latestReadActive = prevLatest;
|
|
2310
2326
|
}
|
|
2311
2327
|
}
|
|
2312
|
-
function isPending(fn
|
|
2328
|
+
function isPending(fn) {
|
|
2313
2329
|
const prevPendingCheck = pendingCheckActive;
|
|
2314
|
-
const prevPendingCheckLoadingPath = pendingCheckLoadingPath;
|
|
2315
2330
|
const prevFoundPending = foundPending;
|
|
2316
|
-
const
|
|
2331
|
+
const prevPendingCheckSources = pendingCheckSources;
|
|
2317
2332
|
pendingCheckActive = true;
|
|
2318
|
-
pendingCheckLoadingPath = checkLoading;
|
|
2319
2333
|
foundPending = false;
|
|
2334
|
+
pendingCheckSources = new Set();
|
|
2335
|
+
const collectPending = () => {
|
|
2336
|
+
pendingCheckActive = false;
|
|
2337
|
+
const prevStrictRead = strictRead;
|
|
2338
|
+
strictRead = false;
|
|
2339
|
+
try {
|
|
2340
|
+
pendingCheckSources.forEach(source => {
|
|
2341
|
+
if (read(getPendingSignal(source))) foundPending = true;
|
|
2342
|
+
});
|
|
2343
|
+
} finally {
|
|
2344
|
+
strictRead = prevStrictRead;
|
|
2345
|
+
pendingCheckActive = true;
|
|
2346
|
+
}
|
|
2347
|
+
};
|
|
2320
2348
|
try {
|
|
2321
2349
|
fn();
|
|
2350
|
+
collectPending();
|
|
2322
2351
|
return foundPending;
|
|
2323
2352
|
} catch (e) {
|
|
2324
|
-
|
|
2353
|
+
collectPending();
|
|
2354
|
+
if (e instanceof NotReadyError) {
|
|
2355
|
+
if (foundPending && !(e.source?._statusFlags & STATUS_UNINITIALIZED)) return true;
|
|
2356
|
+
if (context) throw e;
|
|
2357
|
+
}
|
|
2325
2358
|
return foundPending;
|
|
2326
2359
|
} finally {
|
|
2327
2360
|
pendingCheckActive = prevPendingCheck;
|
|
2328
|
-
pendingCheckLoadingPath = prevPendingCheckLoadingPath;
|
|
2329
2361
|
foundPending = prevFoundPending;
|
|
2362
|
+
pendingCheckSources = prevPendingCheckSources;
|
|
2330
2363
|
}
|
|
2331
2364
|
}
|
|
2332
2365
|
function refresh(target) {
|
|
@@ -3159,6 +3192,26 @@ function writeOnly(proxy) {
|
|
|
3159
3192
|
function unwrapStoreValue(value) {
|
|
3160
3193
|
return value?.[$TARGET]?.[STORE_VALUE] ?? value;
|
|
3161
3194
|
}
|
|
3195
|
+
function isPrototypePollutionKey$1(property) {
|
|
3196
|
+
return property === "__proto__" || property === "constructor" || property === "prototype";
|
|
3197
|
+
}
|
|
3198
|
+
function hasOwnStoreProperty(target, property) {
|
|
3199
|
+
const optimisticOverride = target[STORE_OPTIMISTIC_OVERRIDE];
|
|
3200
|
+
if (
|
|
3201
|
+
optimisticOverride &&
|
|
3202
|
+
Object.prototype.hasOwnProperty.call(optimisticOverride, property) &&
|
|
3203
|
+
optimisticOverride[property] !== $DELETED
|
|
3204
|
+
)
|
|
3205
|
+
return true;
|
|
3206
|
+
const override = target[STORE_OVERRIDE];
|
|
3207
|
+
if (
|
|
3208
|
+
override &&
|
|
3209
|
+
Object.prototype.hasOwnProperty.call(override, property) &&
|
|
3210
|
+
override[property] !== $DELETED
|
|
3211
|
+
)
|
|
3212
|
+
return true;
|
|
3213
|
+
return Object.prototype.hasOwnProperty.call(unwrapStoreValue(target[STORE_VALUE]), property);
|
|
3214
|
+
}
|
|
3162
3215
|
function hasInheritedAccessor(source, property) {
|
|
3163
3216
|
let current = Object.getPrototypeOf(source);
|
|
3164
3217
|
while (current && current !== Object.prototype) {
|
|
@@ -3350,6 +3403,8 @@ const storeTraps = {
|
|
|
3350
3403
|
}
|
|
3351
3404
|
}
|
|
3352
3405
|
if (writeOnly(receiver)) {
|
|
3406
|
+
if (isPrototypePollutionKey$1(property) && !hasOwnStoreProperty(target, property))
|
|
3407
|
+
return undefined;
|
|
3353
3408
|
let value =
|
|
3354
3409
|
tracked && (overridden || !proxySource)
|
|
3355
3410
|
? tracked._overrideValue !== undefined && tracked._overrideValue !== NOT_PENDING
|
|
@@ -3427,6 +3482,7 @@ const storeTraps = {
|
|
|
3427
3482
|
return has;
|
|
3428
3483
|
},
|
|
3429
3484
|
set(target, property, rawValue) {
|
|
3485
|
+
if (property === "__proto__") return true;
|
|
3430
3486
|
const store = target[$PROXY];
|
|
3431
3487
|
if (writeOnly(store)) {
|
|
3432
3488
|
untrack(() => {
|
|
@@ -3488,6 +3544,7 @@ const storeTraps = {
|
|
|
3488
3544
|
return true;
|
|
3489
3545
|
},
|
|
3490
3546
|
defineProperty(target, property, descriptor) {
|
|
3547
|
+
if (property === "__proto__") return true;
|
|
3491
3548
|
const store = target[$PROXY];
|
|
3492
3549
|
if (writeOnly(store)) {
|
|
3493
3550
|
untrack(() => {
|
|
@@ -3514,6 +3571,7 @@ const storeTraps = {
|
|
|
3514
3571
|
return true;
|
|
3515
3572
|
},
|
|
3516
3573
|
deleteProperty(target, property) {
|
|
3574
|
+
if (property === "__proto__") return true;
|
|
3517
3575
|
const optDeleted = target[STORE_OPTIMISTIC_OVERRIDE]?.[property] === $DELETED;
|
|
3518
3576
|
const regDeleted = target[STORE_OVERRIDE]?.[property] === $DELETED;
|
|
3519
3577
|
if (writeOnly(target[$PROXY]) && !optDeleted && !regDeleted) {
|
|
@@ -4225,7 +4283,7 @@ function createBoundChildren(owner, fn, queue, mask) {
|
|
|
4225
4283
|
cleanup(() => parentQueue.removeChild(owner._queue));
|
|
4226
4284
|
return runWithOwner(owner, () => {
|
|
4227
4285
|
const c = computed(fn);
|
|
4228
|
-
return boundaryComputed(() =>
|
|
4286
|
+
return boundaryComputed(() => flatten(read(c)), mask);
|
|
4229
4287
|
});
|
|
4230
4288
|
}
|
|
4231
4289
|
const ON_INIT = Symbol();
|