@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
package/dist/prod/core/action.js
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
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
|
-
|
|
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;
|
|
5
|
+
import { joinFuture, newTransaction, enterAction, exitAction, resolveTx, schedule, actionDepth, flush, nextQuestion, setQuestion, question } from "./scheduler.js";
|
|
11
6
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
7
|
+
/** A slice of the body runs in the action's transaction: the flush that
|
|
8
|
+
* carries its writes parks into it (`joinFuture` — merging whatever the tick
|
|
9
|
+
* already joined: O1, an action that opens in a tick owns it; a second
|
|
10
|
+
* action in the tick, or one called from the body, merges into the first).
|
|
11
|
+
* A resumed slice drains at once: the seam parks what it wrote (the action
|
|
12
|
+
* holds the transaction open) or, the body having returned, lands it. A
|
|
13
|
+
* nested action resuming synchronously inside the outer body does not drain
|
|
14
|
+
* — that would park the outer's remaining writes' frame mid-slice; the outer
|
|
15
|
+
* step's own return does. */ function inTransaction(t, n, e) {
|
|
16
|
+
// The slice and its flush ask this action's question (A18 provenance):
|
|
17
|
+
// the guesses it writes and the flights it starts are stamped with it.
|
|
18
|
+
const i = question;
|
|
19
|
+
setQuestion(n);
|
|
20
|
+
joinFuture(t);
|
|
21
|
+
const o = e();
|
|
22
|
+
if (actionDepth === 0) flush();
|
|
23
|
+
setQuestion(i);
|
|
24
|
+
return o;
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
/**
|
|
@@ -40,9 +42,9 @@ function restoreTransition(e, t, n) {
|
|
|
40
42
|
* submission tracking layered on top. The shared name is deliberate.
|
|
41
43
|
*
|
|
42
44
|
* Wraps a generator function so each invocation runs as a single transaction
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
45
|
+
* that holds every signal/store write between yields. The surrounding UI sees
|
|
46
|
+
* one atomic update when the action completes; nothing is committed until
|
|
47
|
+
* every action in the transaction has returned.
|
|
46
48
|
*
|
|
47
49
|
* `yield` is the transaction-safe suspension point: the action waits for a
|
|
48
50
|
* yielded promise and re-enters the transaction before running the code after
|
|
@@ -52,8 +54,7 @@ function restoreTransition(e, t, n) {
|
|
|
52
54
|
* commit immediately, and anything that creates a reader there — `until()`,
|
|
53
55
|
* `latest()`, a memo or effect, a mount — is created mainline, where a read of
|
|
54
56
|
* this action's held state makes it born held (A29): staged with the
|
|
55
|
-
* transaction and replayed at its commit.
|
|
56
|
-
* settle its own promise holds open (#3482). `await` is still the ergonomic
|
|
57
|
+
* transaction and replayed at its commit. `await` is still the ergonomic
|
|
57
58
|
* choice for typed results; just put a bare `yield` before any write or
|
|
58
59
|
* reader creation that follows it — including the expression of the next
|
|
59
60
|
* `yield`, which is evaluated before the step re-enters:
|
|
@@ -66,7 +67,7 @@ function restoreTransition(e, t, n) {
|
|
|
66
67
|
* ```
|
|
67
68
|
*
|
|
68
69
|
* (For the same reason, don't call `flush()` inside an action body — it
|
|
69
|
-
*
|
|
70
|
+
* cannot reveal the held writes and is refused.)
|
|
70
71
|
*
|
|
71
72
|
* Each call returns a `Promise` that resolves with the generator's return
|
|
72
73
|
* value, or rejects if it throws. Pair with `createOptimistic` /
|
|
@@ -91,76 +92,72 @@ function restoreTransition(e, t, n) {
|
|
|
91
92
|
*
|
|
92
93
|
* await addTodo("buy milk");
|
|
93
94
|
* ```
|
|
94
|
-
*/ function action(
|
|
95
|
-
return (...
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
//
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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);
|
|
109
|
-
// Re-adopt through initTransition like every other resumption site:
|
|
110
|
-
// a bare setActiveTransition leaves globalQueue._batch as a detached
|
|
111
|
-
// ambient batch, and anything registered before the scheduled flush
|
|
112
|
-
// (held writes on a merging transition, optimistic overrides,
|
|
113
|
-
// affects() marks) lands there with nothing to ever finalize it.
|
|
114
|
-
globalQueue.initTransition(s);
|
|
95
|
+
*/ function action(t) {
|
|
96
|
+
return (...n) => new Promise((e, i) => {
|
|
97
|
+
const o = t(...n);
|
|
98
|
+
// The action's transaction, held open until the body returns. The
|
|
99
|
+
// first slice's writes are carried by the tick's scheduled flush.
|
|
100
|
+
const r = newTransaction(false);
|
|
101
|
+
r.tt = 1;
|
|
102
|
+
r.nt = true;
|
|
103
|
+
const s = nextQuestion();
|
|
104
|
+
const done = (t, n, o = false) => {
|
|
105
|
+
resolveTx(r).tt--;
|
|
115
106
|
schedule();
|
|
116
|
-
o ?
|
|
107
|
+
o ? i(n) : e(t);
|
|
117
108
|
};
|
|
118
|
-
const step = (
|
|
119
|
-
let
|
|
109
|
+
const step = (t, n) => {
|
|
110
|
+
let e;
|
|
120
111
|
// The body is on the stack between these brackets: flush() is
|
|
121
112
|
// refused inside (FLUSH_IN_ACTION, scheduler.ts).
|
|
122
|
-
|
|
113
|
+
enterAction();
|
|
123
114
|
try {
|
|
124
|
-
|
|
125
|
-
} catch (
|
|
126
|
-
|
|
127
|
-
return done(undefined,
|
|
115
|
+
e = n ? o.throw(t) : o.next(t);
|
|
116
|
+
} catch (t) {
|
|
117
|
+
exitAction();
|
|
118
|
+
return done(undefined, t, true);
|
|
128
119
|
}
|
|
129
|
-
|
|
120
|
+
exitAction();
|
|
130
121
|
// A rejected iterator result (async generators) means the error already
|
|
131
122
|
// escaped the generator body — it is completed, and throwing back in
|
|
132
123
|
// would just reject again forever. Settle instead.
|
|
133
|
-
if (isThenable(
|
|
134
|
-
run(
|
|
124
|
+
if (isThenable(e)) return void e.then(run, t => done(undefined, t, true));
|
|
125
|
+
run(e);
|
|
135
126
|
};
|
|
136
|
-
const run =
|
|
137
|
-
if (
|
|
127
|
+
const run = t => {
|
|
128
|
+
if (t.done) return done(t.value);
|
|
138
129
|
// Thenable assimilation can itself throw synchronously (a `then`
|
|
139
130
|
// getter, or a `then()` method that throws — #2918). Match `await`
|
|
140
131
|
// semantics: the failure is thrown back into the generator at the
|
|
141
132
|
// yield point (catchable there); if uncaught, step()'s guard settles
|
|
142
|
-
// the action
|
|
143
|
-
//
|
|
144
|
-
|
|
145
|
-
let t = false;
|
|
133
|
+
// the action. The settled flag implements A+ 2.3.3.3.4.1: a throw
|
|
134
|
+
// after the thenable already called a callback is ignored.
|
|
135
|
+
let n = false;
|
|
146
136
|
try {
|
|
147
|
-
if (isThenable(
|
|
148
|
-
if (
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
},
|
|
152
|
-
if (
|
|
153
|
-
|
|
154
|
-
|
|
137
|
+
if (isThenable(t.value)) return void t.value.then(t => {
|
|
138
|
+
if (n) return;
|
|
139
|
+
n = true;
|
|
140
|
+
inTransaction(r, s, () => step(t));
|
|
141
|
+
}, t => {
|
|
142
|
+
if (n) return;
|
|
143
|
+
n = true;
|
|
144
|
+
inTransaction(r, s, () => step(t, true));
|
|
155
145
|
});
|
|
156
|
-
} catch (
|
|
157
|
-
if (
|
|
158
|
-
|
|
159
|
-
return void
|
|
146
|
+
} catch (t) {
|
|
147
|
+
if (n) return;
|
|
148
|
+
n = true;
|
|
149
|
+
return void inTransaction(r, s, () => step(t, true));
|
|
160
150
|
}
|
|
161
|
-
|
|
151
|
+
inTransaction(r, s, () => step(t.value));
|
|
162
152
|
};
|
|
153
|
+
// The first slice's writes are carried by the tick's scheduled flush;
|
|
154
|
+
// the slice itself asks the action's question (its guesses are stamped
|
|
155
|
+
// at the write).
|
|
156
|
+
joinFuture(r);
|
|
157
|
+
const u = question;
|
|
158
|
+
setQuestion(s);
|
|
163
159
|
step();
|
|
160
|
+
setQuestion(u);
|
|
164
161
|
});
|
|
165
162
|
}
|
|
166
163
|
|