@solidjs/signals 2.0.0-rc.7 → 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 +1229 -6834
- 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} +129 -73
- 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} +295 -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/core/action.js +52 -32
- package/dist/prod/core/async.js +171 -127
- package/dist/prod/core/constants.js +24 -1
- package/dist/prod/core/context.js +3 -3
- package/dist/prod/core/core.js +434 -291
- package/dist/prod/core/effect.js +54 -34
- package/dist/prod/core/external.js +2 -2
- package/dist/prod/core/graph.js +32 -32
- package/dist/prod/core/heap.js +49 -44
- package/dist/prod/core/lanes.js +45 -38
- package/dist/prod/core/optimistic.js +207 -73
- package/dist/prod/core/owner.js +43 -39
- package/dist/prod/core/scheduler.js +319 -190
- package/dist/prod/core/verdict.js +67 -67
- package/dist/prod/index.js +9 -3
- package/dist/prod/map.js +292 -141
- package/dist/prod/signals.js +7 -10
- package/dist/prod/store/next/optimistic.js +140 -125
- package/dist/prod/store/next/projection.js +3 -3
- package/dist/prod/store/next/reconcile.js +87 -84
- package/dist/prod/store/next/store.js +524 -280
- 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 +119 -6
- package/dist/types/core/attribution.d.ts +208 -53
- package/dist/types/core/constants.d.ts +23 -0
- package/dist/types/core/core.d.ts +7 -0
- package/dist/types/core/dev.d.ts +124 -26
- package/dist/types/core/effect.d.ts +8 -1
- package/dist/types/core/index.d.ts +2 -1
- package/dist/types/core/lanes.d.ts +8 -1
- package/dist/types/core/scheduler.d.ts +60 -0
- 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/store/index.d.ts +1 -0
- package/dist/types/store/next/store.d.ts +5 -0
- package/dist/types/store/next/target.d.ts +36 -9
- package/dist/types/store/utils.d.ts +7 -0
- package/package.json +21 -17
- package/dist/node.cjs +0 -10541
- package/dist/node.dev.cjs +0 -13724
- 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 -127
- package/dist/types-cjs/core/attribution.d.cts +0 -495
- package/dist/types-cjs/core/core.d.cts +0 -185
- package/dist/types-cjs/core/dev.d.cts +0 -136
- 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 -24
- 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 -54
- 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 -236
- 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 -18
- package/dist/types-cjs/store/next/optimistic.d.cts +0 -25
- package/dist/types-cjs/store/next/projection.d.cts +0 -8
- package/dist/types-cjs/store/next/reconcile.d.cts +0 -10
- package/dist/types-cjs/store/next/store.d.cts +0 -121
- package/dist/types-cjs/store/next/target.d.cts +0 -166
- package/dist/types-cjs/store/store.d.cts +0 -143
- package/dist/types-cjs/store/storePath.d.cts +0 -58
- package/dist/types-cjs/store/utils.d.cts +0 -74
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const EMPTY = Object.freeze([]);
|
|
2
|
+
|
|
3
|
+
const noop = () => {};
|
|
4
|
+
|
|
5
|
+
const attribution = {
|
|
6
|
+
enable: noop,
|
|
7
|
+
disable: noop,
|
|
8
|
+
subscribe: () => noop,
|
|
9
|
+
history: () => EMPTY,
|
|
10
|
+
why: () => [],
|
|
11
|
+
subscriptions: () => [],
|
|
12
|
+
costs: () => ({
|
|
13
|
+
scopes: [],
|
|
14
|
+
writes: []
|
|
15
|
+
}),
|
|
16
|
+
waterfalls: () => EMPTY,
|
|
17
|
+
holds: () => EMPTY,
|
|
18
|
+
navigations: () => EMPTY,
|
|
19
|
+
interactions: () => EMPTY,
|
|
20
|
+
feedback: () => ({
|
|
21
|
+
sources: [],
|
|
22
|
+
interactions: [],
|
|
23
|
+
navigations: [],
|
|
24
|
+
flights: [],
|
|
25
|
+
fallbacks: []
|
|
26
|
+
}),
|
|
27
|
+
markFlight: noop,
|
|
28
|
+
format: () => "",
|
|
29
|
+
formatOrigin: () => ""
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { attribution };
|
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
|
/**
|
|
@@ -74,36 +85,45 @@ function restoreTransition(e, r) {
|
|
|
74
85
|
* await addTodo("buy milk");
|
|
75
86
|
* ```
|
|
76
87
|
*/ function action(e) {
|
|
77
|
-
return (...
|
|
78
|
-
const i = e(...
|
|
88
|
+
return (...t) => new Promise((n, r) => {
|
|
89
|
+
const i = e(...t);
|
|
90
|
+
const o = ++actionSeq;
|
|
91
|
+
// The first slice's window runs to the scheduled flush, which clears
|
|
92
|
+
// the provenance with the window — no restore here.
|
|
93
|
+
setOrigin(o);
|
|
79
94
|
globalQueue.initTransition();
|
|
80
|
-
let
|
|
81
|
-
|
|
82
|
-
const done = (e,
|
|
83
|
-
|
|
84
|
-
const
|
|
85
|
-
if (
|
|
95
|
+
let s = activeTransition;
|
|
96
|
+
s.ue.push(i);
|
|
97
|
+
const done = (e, t, o = false) => {
|
|
98
|
+
s = currentTransition(s);
|
|
99
|
+
const u = s.ue.indexOf(i);
|
|
100
|
+
if (u >= 0) s.ue.splice(u, 1);
|
|
86
101
|
// Re-adopt through initTransition like every other resumption site:
|
|
87
102
|
// a bare setActiveTransition leaves globalQueue._batch as a detached
|
|
88
103
|
// ambient batch, and anything registered before the scheduled flush
|
|
89
104
|
// (held writes on a merging transition, optimistic overrides,
|
|
90
105
|
// affects() marks) lands there with nothing to ever finalize it.
|
|
91
|
-
globalQueue.initTransition(
|
|
106
|
+
globalQueue.initTransition(s);
|
|
92
107
|
schedule();
|
|
93
|
-
|
|
108
|
+
o ? r(t) : n(e);
|
|
94
109
|
};
|
|
95
|
-
const step = (e,
|
|
96
|
-
let
|
|
110
|
+
const step = (e, t) => {
|
|
111
|
+
let n;
|
|
112
|
+
// The body is on the stack between these brackets: flush() is
|
|
113
|
+
// refused inside (FLUSH_IN_ACTION, scheduler.ts).
|
|
114
|
+
enterActionStep();
|
|
97
115
|
try {
|
|
98
|
-
|
|
116
|
+
n = t ? i.throw(e) : i.next(e);
|
|
99
117
|
} catch (e) {
|
|
118
|
+
exitActionStep();
|
|
100
119
|
return done(undefined, e, true);
|
|
101
120
|
}
|
|
121
|
+
exitActionStep();
|
|
102
122
|
// A rejected iterator result (async generators) means the error already
|
|
103
123
|
// escaped the generator body — it is completed, and throwing back in
|
|
104
124
|
// would just reject again forever. Settle instead.
|
|
105
|
-
if (isThenable(
|
|
106
|
-
run(
|
|
125
|
+
if (isThenable(n)) return void n.then(run, e => done(undefined, e, true));
|
|
126
|
+
run(n);
|
|
107
127
|
};
|
|
108
128
|
const run = e => {
|
|
109
129
|
if (e.done) return done(e.value);
|
|
@@ -114,23 +134,23 @@ function restoreTransition(e, r) {
|
|
|
114
134
|
// the action so its iterator never leaks in the transition. The
|
|
115
135
|
// settled flag implements A+ 2.3.3.3.4.1: a throw after the thenable
|
|
116
136
|
// already called a callback is ignored.
|
|
117
|
-
let
|
|
137
|
+
let t = false;
|
|
118
138
|
try {
|
|
119
139
|
if (isThenable(e.value)) return void e.value.then(e => {
|
|
120
|
-
if (
|
|
121
|
-
|
|
122
|
-
restoreTransition(o, () => step(e));
|
|
140
|
+
if (t) return;
|
|
141
|
+
t = true;
|
|
142
|
+
restoreTransition(o, s, () => step(e));
|
|
123
143
|
}, e => {
|
|
124
|
-
if (
|
|
125
|
-
|
|
126
|
-
restoreTransition(o, () => step(e, true));
|
|
144
|
+
if (t) return;
|
|
145
|
+
t = true;
|
|
146
|
+
restoreTransition(o, s, () => step(e, true));
|
|
127
147
|
});
|
|
128
148
|
} catch (e) {
|
|
129
|
-
if (
|
|
130
|
-
|
|
131
|
-
return void restoreTransition(o, () => step(e, true));
|
|
149
|
+
if (t) return;
|
|
150
|
+
t = true;
|
|
151
|
+
return void restoreTransition(o, s, () => step(e, true));
|
|
132
152
|
}
|
|
133
|
-
restoreTransition(o, () => step(e.value));
|
|
153
|
+
restoreTransition(o, s, () => step(e.value));
|
|
134
154
|
};
|
|
135
155
|
step();
|
|
136
156
|
});
|