@solidjs/signals 2.0.0-rc.13 → 2.0.0-rc.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/dist/dev-shared.js +2000 -3768
- package/dist/dev.attribution.js +132 -79
- package/dist/dev.js +7226 -8488
- package/dist/observe/affects.js +125 -104
- package/dist/observe/boundaries.js +458 -665
- package/dist/observe/core/action.js +63 -66
- package/dist/observe/core/async.js +240 -383
- package/dist/observe/core/attribution-queries.js +1 -1
- package/dist/observe/core/attribution.js +240 -183
- package/dist/observe/core/constants.js +115 -187
- package/dist/observe/core/context.js +3 -3
- package/dist/observe/core/core.js +840 -1438
- package/dist/observe/core/dev.js +3 -3
- package/dist/observe/core/effect.js +75 -86
- package/dist/observe/core/external.js +5 -5
- package/dist/observe/core/graph.js +61 -70
- package/dist/observe/core/heap.js +75 -98
- package/dist/observe/core/invariants.js +1 -34
- package/dist/observe/core/lanes.js +704 -181
- package/dist/observe/core/owner.js +80 -101
- package/dist/observe/core/scheduler.js +708 -1351
- package/dist/observe/core/verdict.js +302 -621
- package/dist/observe/flatten.js +79 -0
- package/dist/observe/index.js +15 -13
- package/dist/observe/map.js +232 -235
- package/dist/observe/reveal.js +212 -0
- package/dist/observe/signals.js +133 -215
- package/dist/observe/store/affects.js +135 -0
- package/dist/observe/store/index.js +29 -24
- package/dist/observe/store/optimistic.js +538 -0
- package/dist/observe/store/projection.js +302 -0
- package/dist/observe/store/reconcile.js +257 -0
- package/dist/observe/store/store.js +1945 -277
- package/dist/observe/store/storePath.js +1 -1
- package/dist/{prod/store/next → observe/store}/target.js +17 -18
- package/dist/observe/store/types.js +73 -0
- package/dist/observe/store/utils.js +1 -13
- package/dist/prod/affects.js +127 -106
- package/dist/prod/boundaries.js +442 -654
- package/dist/prod/core/action.js +71 -74
- package/dist/prod/core/async.js +307 -442
- package/dist/prod/core/constants.js +112 -186
- package/dist/prod/core/context.js +3 -3
- package/dist/prod/core/core.js +852 -1458
- package/dist/prod/core/effect.js +88 -99
- package/dist/prod/core/external.js +5 -5
- package/dist/prod/core/graph.js +61 -70
- package/dist/prod/core/heap.js +75 -98
- package/dist/prod/core/invariants.js +1 -32
- package/dist/prod/core/lanes.js +666 -181
- package/dist/prod/core/owner.js +75 -96
- package/dist/prod/core/scheduler.js +677 -1332
- package/dist/prod/core/verdict.js +297 -621
- package/dist/prod/flatten.js +77 -0
- package/dist/prod/index.js +15 -13
- package/dist/prod/map.js +143 -146
- package/dist/prod/reveal.js +212 -0
- package/dist/prod/signals.js +144 -226
- package/dist/prod/store/affects.js +135 -0
- package/dist/prod/store/index.js +28 -19
- package/dist/prod/store/optimistic.js +533 -0
- package/dist/prod/store/projection.js +295 -0
- package/dist/prod/store/reconcile.js +257 -0
- package/dist/prod/store/store.js +1840 -272
- package/dist/prod/store/storePath.js +1 -1
- package/dist/{observe/store/next → prod/store}/target.js +13 -17
- package/dist/prod/store/types.js +73 -0
- package/dist/prod/store/utils.js +1 -11
- package/dist/types/affects.d.ts +11 -30
- package/dist/types/boundaries.d.ts +62 -176
- package/dist/types/carved.d.ts +1 -0
- package/dist/types/core/action.d.ts +5 -6
- package/dist/types/core/async.d.ts +10 -5
- package/dist/types/core/attribution-hooks.d.ts +20 -1
- package/dist/types/core/attribution.d.ts +20 -9
- package/dist/types/core/constants.d.ts +125 -180
- package/dist/types/core/core.d.ts +104 -264
- package/dist/types/core/dev.d.ts +2 -2
- package/dist/types/core/effect.d.ts +0 -7
- package/dist/types/core/graph.d.ts +7 -1
- package/dist/types/core/heap.d.ts +5 -7
- package/dist/types/core/index.d.ts +5 -5
- package/dist/types/core/invariants.d.ts +0 -29
- package/dist/types/core/lanes.d.ts +65 -87
- package/dist/types/core/owner.d.ts +3 -3
- package/dist/types/core/scheduler.d.ts +249 -331
- package/dist/types/core/types.d.ts +51 -85
- package/dist/types/core/verdict.d.ts +3 -0
- package/dist/types/flatten.d.ts +8 -0
- package/dist/types/index.d.ts +6 -4
- package/dist/types/reveal.d.ts +19 -0
- package/dist/types/signals.d.ts +35 -91
- package/dist/types/store/affects.d.ts +1 -0
- package/dist/types/store/index.d.ts +35 -15
- package/dist/types/store/optimistic.d.ts +23 -0
- package/dist/types/store/projection.d.ts +18 -0
- package/dist/types/store/reconcile.d.ts +3 -0
- package/dist/types/store/store.d.ts +165 -143
- package/dist/types/store/storePath.d.ts +1 -1
- package/dist/types/store/target.d.ts +151 -0
- package/dist/types/store/types.d.ts +84 -0
- package/package.json +1 -1
- package/dist/observe/core/optimistic.js +0 -669
- package/dist/observe/store/next/optimistic.js +0 -717
- package/dist/observe/store/next/projection.js +0 -266
- package/dist/observe/store/next/reconcile.js +0 -375
- package/dist/observe/store/next/store.js +0 -2608
- package/dist/prod/core/optimistic.js +0 -658
- package/dist/prod/store/next/optimistic.js +0 -710
- package/dist/prod/store/next/projection.js +0 -257
- package/dist/prod/store/next/reconcile.js +0 -373
- package/dist/prod/store/next/store.js +0 -2484
- package/dist/types/core/optimistic.d.ts +0 -6
- package/dist/types/store/next/optimistic.d.ts +0 -25
- package/dist/types/store/next/projection.d.ts +0 -27
- package/dist/types/store/next/reconcile.d.ts +0 -10
- package/dist/types/store/next/store.d.ts +0 -145
- package/dist/types/store/next/target.d.ts +0 -196
|
@@ -1,28 +1,30 @@
|
|
|
1
|
-
import { setOrigin, globalQueue, activeTransition, currentTransition, schedule, actionStepDepth, flush, enterActionStep, exitActionStep } from "./scheduler.js";
|
|
2
|
-
|
|
3
1
|
import { isThenable } from "./async.js";
|
|
4
2
|
|
|
5
3
|
import "./core.js";
|
|
6
4
|
|
|
7
5
|
import "./dev.js";
|
|
8
6
|
|
|
9
|
-
import {
|
|
7
|
+
import { joinFuture, newTransaction, enterAction, exitAction, resolveTx, schedule, actionDepth, flush, nextQuestion, setQuestion, question } from "./scheduler.js";
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
* action runs under (scheduler `origin`): the flights and overrides its
|
|
13
|
-
* ambient windows issue are stamped with it, so a later action's override
|
|
14
|
-
* can tell this action's late answer from its own (#3331). */ let actionSeq = 0;
|
|
9
|
+
import { attrHooks } from "./attribution-hooks.js";
|
|
15
10
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
11
|
+
/** A slice of the body runs in the action's transaction: the flush that
|
|
12
|
+
* carries its writes parks into it (`joinFuture` — merging whatever the tick
|
|
13
|
+
* already joined: O1, an action that opens in a tick owns it; a second
|
|
14
|
+
* action in the tick, or one called from the body, merges into the first).
|
|
15
|
+
* A resumed slice drains at once: the seam parks what it wrote (the action
|
|
16
|
+
* holds the transaction open) or, the body having returned, lands it. A
|
|
17
|
+
* nested action resuming synchronously inside the outer body does not drain
|
|
18
|
+
* — that would park the outer's remaining writes' frame mid-slice; the outer
|
|
19
|
+
* step's own return does. */ function inTransaction(t, n, e) {
|
|
20
|
+
// The slice and its flush ask this action's question (A18 provenance):
|
|
21
|
+
// the guesses it writes and the flights it starts are stamped with it.
|
|
22
|
+
const o = question;
|
|
23
|
+
setQuestion(n);
|
|
24
|
+
joinFuture(t);
|
|
25
|
+
const i = e();
|
|
26
|
+
if (actionDepth === 0) flush();
|
|
27
|
+
setQuestion(o);
|
|
26
28
|
return i;
|
|
27
29
|
}
|
|
28
30
|
|
|
@@ -44,9 +46,9 @@ function restoreTransition(t, e, r) {
|
|
|
44
46
|
* submission tracking layered on top. The shared name is deliberate.
|
|
45
47
|
*
|
|
46
48
|
* Wraps a generator function so each invocation runs as a single transaction
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
49
|
+
* that holds every signal/store write between yields. The surrounding UI sees
|
|
50
|
+
* one atomic update when the action completes; nothing is committed until
|
|
51
|
+
* every action in the transaction has returned.
|
|
50
52
|
*
|
|
51
53
|
* `yield` is the transaction-safe suspension point: the action waits for a
|
|
52
54
|
* yielded promise and re-enters the transaction before running the code after
|
|
@@ -56,8 +58,7 @@ function restoreTransition(t, e, r) {
|
|
|
56
58
|
* commit immediately, and anything that creates a reader there — `until()`,
|
|
57
59
|
* `latest()`, a memo or effect, a mount — is created mainline, where a read of
|
|
58
60
|
* this action's held state makes it born held (A29): staged with the
|
|
59
|
-
* transaction and replayed at its commit.
|
|
60
|
-
* settle its own promise holds open (#3482). `await` is still the ergonomic
|
|
61
|
+
* transaction and replayed at its commit. `await` is still the ergonomic
|
|
61
62
|
* choice for typed results; just put a bare `yield` before any write or
|
|
62
63
|
* reader creation that follows it — including the expression of the next
|
|
63
64
|
* `yield`, which is evaluated before the step re-enters:
|
|
@@ -70,7 +71,7 @@ function restoreTransition(t, e, r) {
|
|
|
70
71
|
* ```
|
|
71
72
|
*
|
|
72
73
|
* (For the same reason, don't call `flush()` inside an action body — it
|
|
73
|
-
*
|
|
74
|
+
* cannot reveal the held writes and is refused.)
|
|
74
75
|
*
|
|
75
76
|
* Each call returns a `Promise` that resolves with the generator's return
|
|
76
77
|
* value, or rejects if it throws. Pair with `createOptimistic` /
|
|
@@ -96,52 +97,42 @@ function restoreTransition(t, e, r) {
|
|
|
96
97
|
* await addTodo("buy milk");
|
|
97
98
|
* ```
|
|
98
99
|
*/ function action(t) {
|
|
99
|
-
return (...
|
|
100
|
-
const i = t(...
|
|
101
|
-
|
|
102
|
-
//
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const done = (t, e, o = false) => {
|
|
110
|
-
s = currentTransition(s);
|
|
111
|
-
const u = s.tt.indexOf(i);
|
|
112
|
-
if (u >= 0) s.tt.splice(u, 1);
|
|
113
|
-
// Re-adopt through initTransition like every other resumption site:
|
|
114
|
-
// a bare setActiveTransition leaves globalQueue._batch as a detached
|
|
115
|
-
// ambient batch, and anything registered before the scheduled flush
|
|
116
|
-
// (held writes on a merging transition, optimistic overrides,
|
|
117
|
-
// affects() marks) lands there with nothing to ever finalize it.
|
|
118
|
-
globalQueue.initTransition(s);
|
|
100
|
+
return (...n) => new Promise((e, o) => {
|
|
101
|
+
const i = t(...n);
|
|
102
|
+
// The action's transaction, held open until the body returns. The
|
|
103
|
+
// first slice's writes are carried by the tick's scheduled flush.
|
|
104
|
+
const r = newTransaction(false);
|
|
105
|
+
r.tt = 1;
|
|
106
|
+
r.nt = true;
|
|
107
|
+
const s = nextQuestion();
|
|
108
|
+
const done = (t, n, i = false) => {
|
|
109
|
+
resolveTx(r).tt--;
|
|
119
110
|
schedule();
|
|
120
|
-
|
|
111
|
+
i ? o(n) : e(t);
|
|
121
112
|
};
|
|
122
|
-
const step = (
|
|
123
|
-
let
|
|
113
|
+
const step = (n, e) => {
|
|
114
|
+
let o;
|
|
124
115
|
// Attribution hooks bracket the synchronous slice of generator body
|
|
125
116
|
// this step runs (up to the next yield): writes inside are the
|
|
126
117
|
// action's. Both sites sit outside the try (attribution-hooks.ts).
|
|
127
118
|
if (attrHooks !== null) attrHooks.actionStepStart(i, t.name || undefined);
|
|
128
119
|
// The body is on the stack between these brackets: flush() is
|
|
129
120
|
// refused inside (FLUSH_IN_ACTION, scheduler.ts).
|
|
130
|
-
|
|
121
|
+
enterAction();
|
|
131
122
|
try {
|
|
132
|
-
|
|
123
|
+
o = e ? i.throw(n) : i.next(n);
|
|
133
124
|
} catch (t) {
|
|
134
|
-
|
|
125
|
+
exitAction();
|
|
135
126
|
if (attrHooks !== null) attrHooks.actionStepEnd(i);
|
|
136
127
|
return done(undefined, t, true);
|
|
137
128
|
}
|
|
138
|
-
|
|
129
|
+
exitAction();
|
|
139
130
|
if (attrHooks !== null) attrHooks.actionStepEnd(i);
|
|
140
131
|
// A rejected iterator result (async generators) means the error already
|
|
141
132
|
// escaped the generator body — it is completed, and throwing back in
|
|
142
133
|
// would just reject again forever. Settle instead.
|
|
143
|
-
if (isThenable(
|
|
144
|
-
run(
|
|
134
|
+
if (isThenable(o)) return void o.then(run, t => done(undefined, t, true));
|
|
135
|
+
run(o);
|
|
145
136
|
};
|
|
146
137
|
const run = t => {
|
|
147
138
|
if (t.done) return done(t.value);
|
|
@@ -149,28 +140,34 @@ function restoreTransition(t, e, r) {
|
|
|
149
140
|
// getter, or a `then()` method that throws — #2918). Match `await`
|
|
150
141
|
// semantics: the failure is thrown back into the generator at the
|
|
151
142
|
// yield point (catchable there); if uncaught, step()'s guard settles
|
|
152
|
-
// the action
|
|
153
|
-
//
|
|
154
|
-
|
|
155
|
-
let e = false;
|
|
143
|
+
// the action. The settled flag implements A+ 2.3.3.3.4.1: a throw
|
|
144
|
+
// after the thenable already called a callback is ignored.
|
|
145
|
+
let n = false;
|
|
156
146
|
try {
|
|
157
147
|
if (isThenable(t.value)) return void t.value.then(t => {
|
|
158
|
-
if (
|
|
159
|
-
|
|
160
|
-
|
|
148
|
+
if (n) return;
|
|
149
|
+
n = true;
|
|
150
|
+
inTransaction(r, s, () => step(t));
|
|
161
151
|
}, t => {
|
|
162
|
-
if (
|
|
163
|
-
|
|
164
|
-
|
|
152
|
+
if (n) return;
|
|
153
|
+
n = true;
|
|
154
|
+
inTransaction(r, s, () => step(t, true));
|
|
165
155
|
});
|
|
166
156
|
} catch (t) {
|
|
167
|
-
if (
|
|
168
|
-
|
|
169
|
-
return void
|
|
157
|
+
if (n) return;
|
|
158
|
+
n = true;
|
|
159
|
+
return void inTransaction(r, s, () => step(t, true));
|
|
170
160
|
}
|
|
171
|
-
|
|
161
|
+
inTransaction(r, s, () => step(t.value));
|
|
172
162
|
};
|
|
163
|
+
// The first slice's writes are carried by the tick's scheduled flush;
|
|
164
|
+
// the slice itself asks the action's question (its guesses are stamped
|
|
165
|
+
// at the write).
|
|
166
|
+
joinFuture(r);
|
|
167
|
+
const u = question;
|
|
168
|
+
setQuestion(s);
|
|
173
169
|
step();
|
|
170
|
+
setQuestion(u);
|
|
174
171
|
});
|
|
175
172
|
}
|
|
176
173
|
|