@solidjs/signals 2.0.0-rc.6 → 2.0.0-rc.8
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-shared.js +5243 -0
- package/dist/dev.attribution.js +2333 -0
- package/dist/dev.js +1758 -6621
- package/dist/observe/affects.js +127 -0
- package/dist/observe/attribution.js +1 -0
- package/dist/observe/boundaries.js +586 -0
- package/dist/observe/core/action.js +167 -0
- package/dist/observe/core/async.js +736 -0
- package/dist/observe/core/attribution-hooks.js +60 -0
- package/dist/observe/core/attribution.js +2318 -0
- package/dist/{types-cjs/core/constants.d.cts → observe/core/constants.js} +135 -71
- package/dist/{types-cjs/core/context.d.cts → observe/core/context.js} +37 -12
- package/dist/observe/core/core.js +1289 -0
- package/dist/observe/core/dev.js +232 -0
- package/dist/observe/core/effect.js +179 -0
- package/dist/observe/core/error.js +80 -0
- package/dist/observe/core/external.js +98 -0
- package/dist/observe/core/graph.js +155 -0
- package/dist/observe/core/heap.js +147 -0
- package/dist/observe/core/invariants.js +43 -0
- package/dist/observe/core/lanes.js +168 -0
- package/dist/observe/core/optimistic.js +438 -0
- package/dist/observe/core/owner.js +308 -0
- package/dist/observe/core/scheduler.js +1190 -0
- package/dist/observe/core/verdict.js +551 -0
- package/dist/observe/index.js +55 -0
- package/dist/observe/map.js +482 -0
- package/dist/{types-cjs/signals.d.cts → observe/signals.js} +305 -317
- package/dist/observe/store/index.js +38 -0
- package/dist/observe/store/next/optimistic.js +651 -0
- package/dist/observe/store/next/projection.js +242 -0
- package/dist/observe/store/next/reconcile.js +373 -0
- package/dist/observe/store/next/store.js +2213 -0
- package/dist/observe/store/next/target.js +51 -0
- package/dist/observe/store/store.js +323 -0
- package/dist/observe/store/storePath.js +103 -0
- package/dist/observe/store/utils.js +210 -0
- package/dist/prod/attribution.js +32 -0
- package/dist/prod/boundaries.js +3 -1
- package/dist/prod/core/action.js +52 -32
- package/dist/prod/core/async.js +177 -128
- package/dist/prod/core/attribution-hooks.js +3 -0
- package/dist/prod/core/constants.js +32 -1
- package/dist/prod/core/context.js +10 -16
- package/dist/prod/core/core.js +505 -286
- package/dist/prod/core/dev.js +2 -0
- package/dist/prod/core/effect.js +72 -43
- package/dist/prod/core/external.js +2 -2
- package/dist/prod/core/graph.js +40 -36
- package/dist/prod/core/heap.js +50 -51
- package/dist/prod/core/lanes.js +43 -22
- package/dist/prod/core/optimistic.js +224 -80
- package/dist/prod/core/owner.js +43 -39
- package/dist/prod/core/scheduler.js +347 -232
- package/dist/prod/core/verdict.js +71 -74
- package/dist/prod/index.js +9 -5
- package/dist/prod/map.js +311 -150
- package/dist/prod/signals.js +52 -38
- package/dist/prod/store/next/optimistic.js +127 -131
- package/dist/prod/store/next/projection.js +3 -3
- package/dist/prod/store/next/reconcile.js +149 -294
- package/dist/prod/store/next/store.js +694 -380
- package/dist/prod/store/next/target.js +32 -10
- package/dist/prod/store/store.js +12 -14
- package/dist/prod/store/utils.js +36 -27
- package/dist/types/attribution.d.ts +15 -0
- package/dist/types/attribution.prod.d.ts +13 -0
- package/dist/types/core/async.d.ts +1 -1
- package/dist/types/core/attribution-hooks.d.ts +183 -6
- package/dist/types/core/attribution.d.ts +435 -24
- package/dist/types/core/constants.d.ts +31 -0
- package/dist/types/core/core.d.ts +19 -3
- package/dist/types/core/dev.d.ts +165 -26
- package/dist/types/core/effect.d.ts +8 -1
- package/dist/types/core/heap.d.ts +5 -3
- package/dist/types/core/index.d.ts +2 -1
- package/dist/types/core/invariants.d.ts +1 -1
- package/dist/types/core/lanes.d.ts +17 -0
- package/dist/types/core/scheduler.d.ts +69 -4
- package/dist/types/core/types.d.ts +29 -9
- package/dist/types/index.d.ts +9 -2
- package/dist/types/map.d.ts +2 -0
- package/dist/types/signals.d.ts +10 -0
- package/dist/types/store/index.d.ts +4 -6
- package/dist/types/store/next/optimistic.d.ts +4 -2
- package/dist/types/store/next/reconcile.d.ts +5 -12
- package/dist/types/store/next/store.d.ts +8 -9
- package/dist/types/store/next/target.d.ts +56 -55
- package/dist/types/store/store.d.ts +14 -9
- package/dist/types/store/utils.d.ts +7 -0
- package/package.json +21 -16
- package/dist/node.cjs +0 -11121
- package/dist/prod/store/next/patch-hooks.js +0 -13
- package/dist/prod/store/next/patch.js +0 -614
- package/dist/types/store/next/patch-hooks.d.ts +0 -41
- package/dist/types/store/next/patch.d.ts +0 -91
- package/dist/types-cjs/affects.d.cts +0 -47
- package/dist/types-cjs/boundaries.d.cts +0 -175
- package/dist/types-cjs/core/action.d.cts +0 -64
- package/dist/types-cjs/core/async.d.cts +0 -23
- package/dist/types-cjs/core/attribution-hooks.d.cts +0 -63
- package/dist/types-cjs/core/attribution.d.cts +0 -239
- package/dist/types-cjs/core/core.d.cts +0 -176
- package/dist/types-cjs/core/dev.d.cts +0 -95
- package/dist/types-cjs/core/effect.d.cts +0 -30
- package/dist/types-cjs/core/error.d.cts +0 -56
- package/dist/types-cjs/core/external.d.cts +0 -15
- package/dist/types-cjs/core/graph.d.cts +0 -28
- package/dist/types-cjs/core/heap.d.cts +0 -22
- package/dist/types-cjs/core/index.d.cts +0 -13
- package/dist/types-cjs/core/invariants.d.cts +0 -59
- package/dist/types-cjs/core/lanes.d.cts +0 -44
- package/dist/types-cjs/core/optimistic.d.cts +0 -6
- package/dist/types-cjs/core/owner.d.cts +0 -124
- package/dist/types-cjs/core/scheduler.d.cts +0 -231
- package/dist/types-cjs/core/types.d.cts +0 -204
- package/dist/types-cjs/core/verdict.d.cts +0 -2
- package/dist/types-cjs/index.d.cts +0 -10
- package/dist/types-cjs/map.d.cts +0 -69
- package/dist/types-cjs/package.json +0 -3
- package/dist/types-cjs/store/index.d.cts +0 -21
- package/dist/types-cjs/store/next/optimistic.d.cts +0 -23
- package/dist/types-cjs/store/next/patch-hooks.d.cts +0 -41
- package/dist/types-cjs/store/next/patch.d.cts +0 -91
- package/dist/types-cjs/store/next/projection.d.cts +0 -8
- package/dist/types-cjs/store/next/reconcile.d.cts +0 -17
- package/dist/types-cjs/store/next/store.d.cts +0 -127
- package/dist/types-cjs/store/next/target.d.cts +0 -192
- package/dist/types-cjs/store/store.d.cts +0 -138
- package/dist/types-cjs/store/storePath.d.cts +0 -58
- package/dist/types-cjs/store/utils.d.cts +0 -74
package/dist/prod/signals.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TimeoutError } from "./core/error.js";
|
|
2
2
|
|
|
3
|
-
import { computed, optimisticComputed, setSignal, optimisticSignal, runWithOwner, setMemo, signal,
|
|
3
|
+
import { computed, optimisticComputed, setSignal, optimisticSignal, runWithOwner, setMemo, signal, installAuthoritativeRead, markRefresh, read, untrack } from "./core/core.js";
|
|
4
4
|
|
|
5
5
|
import { cleanup, createRoot, getOwner, dispose, getObserver } from "./core/owner.js";
|
|
6
6
|
|
|
@@ -188,6 +188,16 @@ function createMemo(e, t) {
|
|
|
188
188
|
* Creates a tracked reactive effect where dependency tracking and side effects happen
|
|
189
189
|
* in the same scope.
|
|
190
190
|
*
|
|
191
|
+
* @deprecated Do not use in new code. For a side effect that follows reactive
|
|
192
|
+
* state, use `createEffect(compute, effect)` — it separates tracking from the
|
|
193
|
+
* side effect, knows its dependencies before it runs, and participates in
|
|
194
|
+
* async and transitions. For one-time DOM work after render (measuring,
|
|
195
|
+
* attaching third-party widgets to a ref), use `onSettled`. Tracking from
|
|
196
|
+
* inside the effect phase — the only thing this primitive adds — is retained
|
|
197
|
+
* solely to ease 1.x migration: it runs beside user-effect callbacks after
|
|
198
|
+
* values commit, never holds a transition, and cannot observe a write staged
|
|
199
|
+
* earlier in the same flush by a signal it has not read yet.
|
|
200
|
+
*
|
|
191
201
|
* WARNING: Because tracking and effects happen in the same scope, this primitive
|
|
192
202
|
* may run multiple times for a single change or show tearing (reading inconsistent
|
|
193
203
|
* state). Use only when dynamic subscription patterns require same-scope tracking.
|
|
@@ -256,25 +266,22 @@ function createMemo(e, t) {
|
|
|
256
266
|
// sources stayed live (firing the callback for replaced dependencies), each
|
|
257
267
|
// accumulated arm delivered its own fire, and un-fired arms leaked as live
|
|
258
268
|
// effect nodes until the owner disposed (#2861).
|
|
259
|
-
let
|
|
260
|
-
return
|
|
261
|
-
if (
|
|
262
|
-
dispose(
|
|
263
|
-
|
|
269
|
+
let i;
|
|
270
|
+
return o => {
|
|
271
|
+
if (i) {
|
|
272
|
+
dispose(i);
|
|
273
|
+
i = undefined;
|
|
264
274
|
}
|
|
265
275
|
runWithOwner(r, () => {
|
|
266
|
-
effect(() => (
|
|
267
|
-
|
|
276
|
+
effect(() => (o(), i = getOwner()), t => {
|
|
277
|
+
i = undefined;
|
|
268
278
|
n?.();
|
|
269
279
|
const r = (e.effect || e)?.();
|
|
270
280
|
if (false && r !== undefined && typeof r !== "function") ;
|
|
271
281
|
n = r;
|
|
272
282
|
dispose(t);
|
|
273
283
|
}, e.error, {
|
|
274
|
-
...
|
|
275
|
-
...t,
|
|
276
|
-
name: t?.name ?? "effect"
|
|
277
|
-
} : t,
|
|
284
|
+
...t,
|
|
278
285
|
user: true,
|
|
279
286
|
defer: true
|
|
280
287
|
});
|
|
@@ -318,11 +325,11 @@ function createMemo(e, t) {
|
|
|
318
325
|
// still runs in place (under the transaction's view when created inside
|
|
319
326
|
// an action step), and status/boundary notifications keep their normal
|
|
320
327
|
// route through the inherited queue.
|
|
321
|
-
const
|
|
322
|
-
const
|
|
323
|
-
|
|
328
|
+
const i = getOwner();
|
|
329
|
+
const o = new MicrotaskQueue;
|
|
330
|
+
o.qe = i.C;
|
|
324
331
|
// notify() forwards up the normal chain
|
|
325
|
-
|
|
332
|
+
i.C = o;
|
|
326
333
|
// A user effect rather than a bare computed: computeds are pull-based and
|
|
327
334
|
// are only re-enqueued when a pending source *resolves* — a rejection just
|
|
328
335
|
// marks them errored, so nothing would re-run and the promise would never
|
|
@@ -342,7 +349,7 @@ function createMemo(e, t) {
|
|
|
342
349
|
// stale mainline value and resolves with old data.
|
|
343
350
|
{
|
|
344
351
|
user: true,
|
|
345
|
-
|
|
352
|
+
Pt: CONFIG_DIRECT_COMMIT
|
|
346
353
|
});
|
|
347
354
|
});
|
|
348
355
|
});
|
|
@@ -410,7 +417,14 @@ function createMemo(e, t) {
|
|
|
410
417
|
// own eager compute is untouched: created after a refresh it still settles
|
|
411
418
|
// stale-while-revalidate (#2930) — its contract is "first settled value",
|
|
412
419
|
// not "next quiescent state".
|
|
413
|
-
|
|
420
|
+
|
|
421
|
+
// An authoritative reader is woken through a late-bound hook when the truth
|
|
422
|
+
// lands EQUAL to a standing override (the A17-silent path). Every setter of
|
|
423
|
+
// that reader bit must install it — until() does, and this waiter is the
|
|
424
|
+
// other one (#3303: refresh of an optimistic in an app that never called
|
|
425
|
+
// until() dereferenced the null hook).
|
|
426
|
+
installAuthoritativeRead();
|
|
427
|
+
markRefresh(t);
|
|
414
428
|
const n = new Promise((n, r) => {
|
|
415
429
|
queueMicrotask(() => {
|
|
416
430
|
// No createRoot: the microtask has no ambient owner, so the effect is
|
|
@@ -423,24 +437,24 @@ function createMemo(e, t) {
|
|
|
423
437
|
// Typed as the effect node, not Owner: the capture runs inside the
|
|
424
438
|
// effect's own compute, where the ambient owner IS the effect —
|
|
425
439
|
// exactly what dispose() takes.
|
|
426
|
-
let
|
|
440
|
+
let i = null;
|
|
427
441
|
const make = () => effect(() => {
|
|
428
|
-
if (
|
|
429
|
-
|
|
442
|
+
if (i === null) {
|
|
443
|
+
i = getOwner();
|
|
430
444
|
const e = new MicrotaskQueue;
|
|
431
|
-
e.
|
|
432
|
-
|
|
445
|
+
e.qe = i.C;
|
|
446
|
+
i.C = e;
|
|
433
447
|
}
|
|
434
448
|
return read(t);
|
|
435
449
|
}, t => {
|
|
436
450
|
n(typeof e === "function" ? t : e);
|
|
437
|
-
dispose(
|
|
451
|
+
dispose(i);
|
|
438
452
|
}, e => {
|
|
439
453
|
r(e);
|
|
440
|
-
dispose(
|
|
454
|
+
dispose(i);
|
|
441
455
|
}, {
|
|
442
456
|
user: true,
|
|
443
|
-
|
|
457
|
+
Pt: CONFIG_DIRECT_COMMIT | CONFIG_AUTHORITATIVE_READ | CONFIG_FRESH_READ
|
|
444
458
|
});
|
|
445
459
|
make();
|
|
446
460
|
});
|
|
@@ -515,9 +529,9 @@ function createMemo(e, t) {
|
|
|
515
529
|
// write flips it truthy, that transition merges here and reveals at the
|
|
516
530
|
// joint settle instead of painting the confirmation under live optimism.
|
|
517
531
|
const n = activeTransition;
|
|
518
|
-
return new Promise((r,
|
|
519
|
-
const
|
|
520
|
-
if (
|
|
532
|
+
return new Promise((r, i) => {
|
|
533
|
+
const o = t?.signal;
|
|
534
|
+
if (o?.aborted) return i(o.reason);
|
|
521
535
|
createRoot(c => {
|
|
522
536
|
// Same delivery contract as resolve() (#2930): effect applies ride a
|
|
523
537
|
// microtask so the promise can settle while the transaction the caller
|
|
@@ -525,13 +539,13 @@ function createMemo(e, t) {
|
|
|
525
539
|
// entire point of the hold.
|
|
526
540
|
const s = getOwner();
|
|
527
541
|
const u = new MicrotaskQueue;
|
|
528
|
-
u.
|
|
542
|
+
u.qe = s.C;
|
|
529
543
|
s.C = u;
|
|
530
544
|
let f;
|
|
531
545
|
let a;
|
|
532
546
|
const settle = e => {
|
|
533
547
|
if (f !== undefined) clearTimeout(f);
|
|
534
|
-
if (a !== undefined)
|
|
548
|
+
if (a !== undefined) o.removeEventListener("abort", a);
|
|
535
549
|
e();
|
|
536
550
|
c();
|
|
537
551
|
};
|
|
@@ -547,7 +561,7 @@ function createMemo(e, t) {
|
|
|
547
561
|
// Falsy is "not yet": keep the subscription live and wait for the
|
|
548
562
|
// next evaluation. Only a truthy settled value resolves.
|
|
549
563
|
if (e) settle(() => r(e));
|
|
550
|
-
}, e => settle(() =>
|
|
564
|
+
}, e => settle(() => i(e)),
|
|
551
565
|
// AUTHORITATIVE_READ: overrides invisible to the predicate.
|
|
552
566
|
// DIRECT_COMMIT: truth that stages into the held transaction (a
|
|
553
567
|
// refresh the action issued) must flow through to the microtask
|
|
@@ -555,12 +569,12 @@ function createMemo(e, t) {
|
|
|
555
569
|
// the hold itself is keeping uncommitted.
|
|
556
570
|
{
|
|
557
571
|
user: true,
|
|
558
|
-
|
|
572
|
+
Pt: CONFIG_AUTHORITATIVE_READ | CONFIG_DIRECT_COMMIT
|
|
559
573
|
});
|
|
560
|
-
if (t?.timeout !== undefined) f = setTimeout(() => settle(() =>
|
|
561
|
-
if (
|
|
562
|
-
a = () => settle(() => o
|
|
563
|
-
|
|
574
|
+
if (t?.timeout !== undefined) f = setTimeout(() => settle(() => i(new TimeoutError)), t.timeout);
|
|
575
|
+
if (o !== undefined) {
|
|
576
|
+
a = () => settle(() => i(o.reason));
|
|
577
|
+
o.addEventListener("abort", a, {
|
|
564
578
|
once: true
|
|
565
579
|
});
|
|
566
580
|
}
|
|
@@ -677,7 +691,7 @@ function createOptimistic(e, t) {
|
|
|
677
691
|
* on owner disposal
|
|
678
692
|
*/ function onSettled(e) {
|
|
679
693
|
const t = getOwner();
|
|
680
|
-
t && !(t.T & CONFIG_CHILDREN_FORBIDDEN) ?
|
|
694
|
+
t && !(t.T & CONFIG_CHILDREN_FORBIDDEN) ? trackedEffect(() => untrack(e), undefined) : globalQueue.enqueue(EFFECT_USER, () => {
|
|
681
695
|
// Unowned, out-of-band fire (no owner, or a children-forbidden one this
|
|
682
696
|
// one-shot must not bind to): a returned cleanup has no lifecycle to
|
|
683
697
|
// attach to. Reject it in dev; in production the return is simply
|