@solidjs/signals 2.0.0-rc.1 → 2.0.0-rc.11
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 +7155 -0
- package/dist/dev.attribution.js +3307 -0
- package/dist/dev.js +5765 -4496
- package/dist/observe/affects.js +129 -0
- package/dist/observe/attribution.js +7 -0
- package/dist/observe/boundaries.js +793 -0
- package/dist/observe/core/action.js +177 -0
- package/dist/observe/core/async.js +849 -0
- package/dist/observe/core/attribution-costs.js +66 -0
- package/dist/observe/core/attribution-feedback.js +280 -0
- package/dist/observe/core/attribution-hooks.js +83 -0
- package/dist/observe/core/attribution-queries.js +43 -0
- package/dist/observe/core/attribution.js +2904 -0
- package/dist/observe/core/constants.js +283 -0
- package/dist/{types-cjs/core/context.d.cts → observe/core/context.js} +37 -12
- package/dist/observe/core/core.js +1999 -0
- package/dist/observe/core/dev.js +343 -0
- package/dist/observe/core/effect.js +200 -0
- package/dist/observe/core/error-hooks.js +71 -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 +45 -0
- package/dist/observe/core/lanes.js +205 -0
- package/dist/observe/core/optimistic.js +669 -0
- package/dist/observe/core/owner.js +353 -0
- package/dist/observe/core/scheduler.js +1561 -0
- package/dist/observe/core/verdict.js +674 -0
- package/dist/observe/index.js +59 -0
- package/dist/observe/map.js +507 -0
- package/dist/observe/signals.js +731 -0
- package/dist/observe/store/index.js +44 -0
- package/dist/observe/store/next/optimistic.js +717 -0
- package/dist/observe/store/next/projection.js +266 -0
- package/dist/observe/store/next/reconcile.js +375 -0
- package/dist/observe/store/next/store.js +2480 -0
- package/dist/observe/store/next/target.js +51 -0
- package/dist/observe/store/store.js +331 -0
- package/dist/observe/store/storePath.js +103 -0
- package/dist/observe/store/utils.js +1070 -0
- package/dist/prod/affects.js +10 -9
- package/dist/prod/attribution.js +45 -0
- package/dist/prod/boundaries.js +388 -178
- package/dist/prod/core/action.js +65 -37
- package/dist/prod/core/async.js +378 -163
- package/dist/prod/core/attribution-hooks.js +3 -0
- package/dist/prod/core/constants.js +186 -1
- package/dist/prod/core/context.js +10 -16
- package/dist/prod/core/core.js +1546 -416
- package/dist/prod/core/dev.js +18 -1
- package/dist/prod/core/effect.js +119 -79
- package/dist/prod/core/error-hooks.js +71 -0
- package/dist/prod/core/error.js +13 -1
- package/dist/prod/core/external.js +4 -4
- package/dist/prod/core/graph.js +105 -54
- package/dist/prod/core/heap.js +72 -65
- package/dist/prod/core/invariants.js +3 -2
- package/dist/prod/core/lanes.js +117 -52
- package/dist/prod/core/optimistic.js +500 -104
- package/dist/prod/core/owner.js +131 -84
- package/dist/prod/core/scheduler.js +1012 -241
- package/dist/prod/core/verdict.js +417 -112
- package/dist/prod/index.js +20 -8
- package/dist/prod/map.js +355 -171
- package/dist/prod/signals.js +363 -32
- package/dist/prod/store/index.js +2 -0
- package/dist/prod/store/next/optimistic.js +530 -197
- package/dist/prod/store/next/projection.js +142 -57
- package/dist/prod/store/next/reconcile.js +149 -103
- package/dist/prod/store/next/store.js +1470 -346
- package/dist/prod/store/next/target.js +40 -9
- package/dist/prod/store/store.js +23 -19
- package/dist/prod/store/utils.js +997 -130
- package/dist/types/attribution.d.ts +19 -0
- package/dist/types/attribution.prod.d.ts +22 -0
- package/dist/types/boundaries.d.ts +78 -5
- package/dist/types/core/action.d.ts +12 -5
- package/dist/types/core/async.d.ts +3 -1
- package/dist/types/core/attribution-costs.d.ts +35 -0
- package/dist/types/core/attribution-feedback.d.ts +133 -0
- package/dist/types/core/attribution-hooks.d.ts +304 -0
- package/dist/types/core/attribution-queries.d.ts +24 -0
- package/dist/types/core/attribution.d.ts +892 -0
- package/dist/types/core/constants.d.ts +179 -0
- package/dist/types/core/core.d.ts +299 -25
- package/dist/types/core/dev.d.ts +421 -8
- package/dist/types/core/effect.d.ts +8 -1
- package/dist/types/core/error-hooks.d.ts +71 -0
- package/dist/types/core/error.d.ts +9 -0
- package/dist/types/core/graph.d.ts +23 -0
- package/dist/types/core/heap.d.ts +5 -3
- package/dist/types/core/index.d.ts +6 -3
- package/dist/types/core/invariants.d.ts +5 -1
- package/dist/types/core/lanes.d.ts +51 -19
- package/dist/types/core/owner.d.ts +15 -3
- package/dist/types/core/scheduler.d.ts +252 -1
- package/dist/types/core/types.d.ts +124 -41
- package/dist/types/index.d.ts +18 -5
- package/dist/types/map.d.ts +2 -0
- package/dist/types/signals.d.ts +145 -13
- package/dist/types/store/index.d.ts +7 -6
- package/dist/types/store/next/optimistic.d.ts +18 -13
- package/dist/types/store/next/projection.d.ts +5 -2
- package/dist/types/store/next/reconcile.d.ts +7 -0
- package/dist/types/store/next/store.d.ts +83 -11
- package/dist/types/store/next/target.d.ts +108 -11
- package/dist/types/store/store.d.ts +20 -11
- package/dist/types/store/utils.d.ts +188 -0
- package/package.json +31 -26
- package/dist/node.cjs +0 -8137
- package/dist/types/store/optimistic.d.ts +0 -45
- package/dist/types/store/projection.d.ts +0 -70
- package/dist/types/store/reconcile.d.ts +0 -46
- 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 -21
- package/dist/types-cjs/core/constants.d.cts +0 -71
- package/dist/types-cjs/core/core.d.cts +0 -156
- package/dist/types-cjs/core/dev.d.cts +0 -64
- package/dist/types-cjs/core/effect.d.cts +0 -30
- package/dist/types-cjs/core/error.d.cts +0 -47
- package/dist/types-cjs/core/external.d.cts +0 -15
- package/dist/types-cjs/core/graph.d.cts +0 -5
- 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 -56
- 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 -172
- package/dist/types-cjs/core/types.d.cts +0 -148
- 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/signals.d.cts +0 -624
- package/dist/types-cjs/store/index.d.cts +0 -19
- package/dist/types-cjs/store/next/optimistic.d.cts +0 -20
- package/dist/types-cjs/store/next/projection.d.cts +0 -24
- package/dist/types-cjs/store/next/reconcile.d.cts +0 -3
- package/dist/types-cjs/store/next/store.d.cts +0 -71
- package/dist/types-cjs/store/next/target.d.cts +0 -99
- package/dist/types-cjs/store/optimistic.d.cts +0 -45
- package/dist/types-cjs/store/projection.d.cts +0 -70
- package/dist/types-cjs/store/reconcile.d.cts +0 -46
- 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/core/action.js
CHANGED
|
@@ -1,14 +1,25 @@
|
|
|
1
|
-
import { globalQueue, activeTransition, currentTransition, schedule, flush } from "./scheduler.js";
|
|
1
|
+
import { setOrigin, globalQueue, activeTransition, currentTransition, schedule, actionStepDepth, flush, enterActionStep, exitActionStep } from "./scheduler.js";
|
|
2
2
|
|
|
3
3
|
import { isThenable } from "./async.js";
|
|
4
4
|
|
|
5
5
|
import "./core.js";
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
/** Invocation order across all actions — the provenance every slice of an
|
|
8
|
+
* action runs under (scheduler `origin`): the flights and overrides its
|
|
9
|
+
* ambient windows issue are stamped with it, so a later action's override
|
|
10
|
+
* can tell this action's late answer from its own (#3331). */ let actionSeq = 0;
|
|
11
|
+
|
|
12
|
+
function restoreTransition(e, t, n) {
|
|
13
|
+
const r = setOrigin(e);
|
|
14
|
+
globalQueue.initTransition(t);
|
|
15
|
+
const i = n();
|
|
16
|
+
// A nested action resuming synchronously (its body yielded a non-thenable)
|
|
17
|
+
// runs this inside the OUTER action's slice: draining here would park the
|
|
18
|
+
// shared transaction and detach the outer body's remaining writes (the
|
|
19
|
+
// flush() rule, scheduler.ts). The outer step's own return drains.
|
|
20
|
+
if (actionStepDepth === 0) flush();
|
|
21
|
+
setOrigin(r);
|
|
22
|
+
return i;
|
|
12
23
|
}
|
|
13
24
|
|
|
14
25
|
/**
|
|
@@ -36,15 +47,22 @@ function restoreTransition(e, r) {
|
|
|
36
47
|
* `yield` is the transaction-safe suspension point: the action waits for a
|
|
37
48
|
* yielded promise and re-enters the transaction before running the code after
|
|
38
49
|
* it. A plain `await` does NOT — the runtime has no hook into an async
|
|
39
|
-
* generator's internal await continuations, so
|
|
40
|
-
*
|
|
41
|
-
* immediately
|
|
42
|
-
*
|
|
50
|
+
* generator's internal await continuations, so code between an `await` and
|
|
51
|
+
* the next `yield` runs OUTSIDE the transaction: writes to fresh signals
|
|
52
|
+
* commit immediately, and anything that creates a reader there — `until()`,
|
|
53
|
+
* `latest()`, a memo or effect, a mount — is created mainline, where a read of
|
|
54
|
+
* this action's held state makes it born held (A29): staged with the
|
|
55
|
+
* transaction and replayed at its commit. For `until()` that commit is the
|
|
56
|
+
* settle its own promise holds open (#3482). `await` is still the ergonomic
|
|
57
|
+
* choice for typed results; just put a bare `yield` before any write or
|
|
58
|
+
* reader creation that follows it — including the expression of the next
|
|
59
|
+
* `yield`, which is evaluated before the step re-enters:
|
|
43
60
|
*
|
|
44
61
|
* ```ts
|
|
45
62
|
* const saved = await api.createTodo(text); // typed result
|
|
46
|
-
* yield; // re-enter the transaction before writing
|
|
63
|
+
* yield; // re-enter the transaction before writing or reading
|
|
47
64
|
* setTodos(t => { ... });
|
|
65
|
+
* yield until(() => todos.some(t => t.id === saved.id));
|
|
48
66
|
* ```
|
|
49
67
|
*
|
|
50
68
|
* (For the same reason, don't call `flush()` inside an action body — it
|
|
@@ -74,36 +92,46 @@ function restoreTransition(e, r) {
|
|
|
74
92
|
* await addTodo("buy milk");
|
|
75
93
|
* ```
|
|
76
94
|
*/ function action(e) {
|
|
77
|
-
return (...
|
|
78
|
-
const i = e(...
|
|
95
|
+
return (...t) => new Promise((n, r) => {
|
|
96
|
+
const i = e(...t);
|
|
97
|
+
const o = ++actionSeq;
|
|
98
|
+
// The first slice's window runs to the scheduled flush, which clears
|
|
99
|
+
// the provenance with the window — no restore here.
|
|
100
|
+
setOrigin(o);
|
|
79
101
|
globalQueue.initTransition();
|
|
80
|
-
let
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
102
|
+
let s = activeTransition;
|
|
103
|
+
s.pe.push(i);
|
|
104
|
+
s.Te = true;
|
|
105
|
+
const done = (e, t, o = false) => {
|
|
106
|
+
s = currentTransition(s);
|
|
107
|
+
const u = s.pe.indexOf(i);
|
|
108
|
+
if (u >= 0) s.pe.splice(u, 1);
|
|
86
109
|
// Re-adopt through initTransition like every other resumption site:
|
|
87
110
|
// a bare setActiveTransition leaves globalQueue._batch as a detached
|
|
88
111
|
// ambient batch, and anything registered before the scheduled flush
|
|
89
112
|
// (held writes on a merging transition, optimistic overrides,
|
|
90
113
|
// affects() marks) lands there with nothing to ever finalize it.
|
|
91
|
-
globalQueue.initTransition(
|
|
114
|
+
globalQueue.initTransition(s);
|
|
92
115
|
schedule();
|
|
93
|
-
|
|
116
|
+
o ? r(t) : n(e);
|
|
94
117
|
};
|
|
95
|
-
const step = (e,
|
|
96
|
-
let
|
|
118
|
+
const step = (e, t) => {
|
|
119
|
+
let n;
|
|
120
|
+
// The body is on the stack between these brackets: flush() is
|
|
121
|
+
// refused inside (FLUSH_IN_ACTION, scheduler.ts).
|
|
122
|
+
enterActionStep();
|
|
97
123
|
try {
|
|
98
|
-
|
|
124
|
+
n = t ? i.throw(e) : i.next(e);
|
|
99
125
|
} catch (e) {
|
|
126
|
+
exitActionStep();
|
|
100
127
|
return done(undefined, e, true);
|
|
101
128
|
}
|
|
129
|
+
exitActionStep();
|
|
102
130
|
// A rejected iterator result (async generators) means the error already
|
|
103
131
|
// escaped the generator body — it is completed, and throwing back in
|
|
104
132
|
// would just reject again forever. Settle instead.
|
|
105
|
-
if (isThenable(
|
|
106
|
-
run(
|
|
133
|
+
if (isThenable(n)) return void n.then(run, e => done(undefined, e, true));
|
|
134
|
+
run(n);
|
|
107
135
|
};
|
|
108
136
|
const run = e => {
|
|
109
137
|
if (e.done) return done(e.value);
|
|
@@ -114,23 +142,23 @@ function restoreTransition(e, r) {
|
|
|
114
142
|
// the action so its iterator never leaks in the transition. The
|
|
115
143
|
// settled flag implements A+ 2.3.3.3.4.1: a throw after the thenable
|
|
116
144
|
// already called a callback is ignored.
|
|
117
|
-
let
|
|
145
|
+
let t = false;
|
|
118
146
|
try {
|
|
119
147
|
if (isThenable(e.value)) return void e.value.then(e => {
|
|
120
|
-
if (
|
|
121
|
-
|
|
122
|
-
restoreTransition(o, () => step(e));
|
|
148
|
+
if (t) return;
|
|
149
|
+
t = true;
|
|
150
|
+
restoreTransition(o, s, () => step(e));
|
|
123
151
|
}, e => {
|
|
124
|
-
if (
|
|
125
|
-
|
|
126
|
-
restoreTransition(o, () => step(e, true));
|
|
152
|
+
if (t) return;
|
|
153
|
+
t = true;
|
|
154
|
+
restoreTransition(o, s, () => step(e, true));
|
|
127
155
|
});
|
|
128
156
|
} catch (e) {
|
|
129
|
-
if (
|
|
130
|
-
|
|
131
|
-
return void restoreTransition(o, () => step(e, true));
|
|
157
|
+
if (t) return;
|
|
158
|
+
t = true;
|
|
159
|
+
return void restoreTransition(o, s, () => step(e, true));
|
|
132
160
|
}
|
|
133
|
-
restoreTransition(o, () => step(e.value));
|
|
161
|
+
restoreTransition(o, s, () => step(e.value));
|
|
134
162
|
};
|
|
135
163
|
step();
|
|
136
164
|
});
|