@solidjs/signals 2.0.0-rc.2 → 2.0.0-rc.20
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 +6505 -0
- package/dist/dev.attribution.js +3484 -0
- package/dist/dev.js +10227 -9508
- package/dist/observe/affects-marks.js +86 -0
- package/dist/observe/affects.js +112 -0
- package/dist/observe/attribution.js +7 -0
- package/dist/observe/boundaries.js +696 -0
- package/dist/observe/core/action.js +182 -0
- package/dist/observe/core/async.js +824 -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 +3079 -0
- package/dist/observe/core/constants.js +269 -0
- package/dist/observe/core/context.js +63 -0
- package/dist/observe/core/copies.js +10 -0
- package/dist/observe/core/core.js +1707 -0
- package/dist/observe/core/dev.js +394 -0
- package/dist/observe/core/effect.js +193 -0
- package/dist/observe/core/error-hooks.js +71 -0
- package/dist/observe/core/error.js +82 -0
- package/dist/observe/core/external.js +97 -0
- package/dist/observe/core/graph.js +162 -0
- package/dist/observe/core/heap.js +124 -0
- package/dist/observe/core/identities.js +62 -0
- package/dist/observe/core/invariants.js +12 -0
- package/dist/observe/core/lanes.js +972 -0
- package/dist/observe/core/owner.js +371 -0
- package/dist/observe/core/scheduler.js +1157 -0
- package/dist/observe/core/truth.js +47 -0
- package/dist/observe/core/verdict.js +470 -0
- package/dist/observe/deferred.js +186 -0
- package/dist/observe/flatten.js +79 -0
- package/dist/observe/from.js +248 -0
- package/dist/observe/index.js +71 -0
- package/dist/observe/map.js +593 -0
- package/dist/observe/reveal.js +212 -0
- package/dist/observe/signals.js +717 -0
- package/dist/observe/store/affects.js +142 -0
- package/dist/observe/store/edges.js +39 -0
- package/dist/observe/store/hooks.js +16 -0
- package/dist/observe/store/index.js +47 -0
- package/dist/observe/store/optimistic.js +713 -0
- package/dist/observe/store/projection.js +345 -0
- package/dist/observe/store/reconcile.js +281 -0
- package/dist/observe/store/store.js +2127 -0
- package/dist/observe/store/storePath.js +103 -0
- package/dist/observe/store/target.js +46 -0
- package/dist/observe/store/types.js +83 -0
- package/dist/observe/store/utils.js +1063 -0
- package/dist/prod/affects-marks.js +86 -0
- package/dist/prod/affects.js +98 -112
- package/dist/prod/attribution.js +45 -0
- package/dist/prod/boundaries.js +578 -468
- package/dist/prod/core/action.js +92 -59
- package/dist/prod/core/async.js +522 -336
- package/dist/prod/core/attribution-hooks.js +3 -0
- package/dist/prod/core/constants.js +168 -44
- package/dist/prod/core/context.js +12 -16
- package/dist/prod/core/copies.js +10 -0
- package/dist/prod/core/core.js +1345 -627
- package/dist/prod/core/dev.js +123 -1
- package/dist/prod/core/effect.js +113 -80
- package/dist/prod/core/error-hooks.js +71 -0
- package/dist/prod/core/error.js +18 -4
- package/dist/prod/core/external.js +6 -7
- package/dist/prod/core/graph.js +119 -72
- package/dist/prod/core/heap.js +85 -109
- package/dist/prod/core/identities.js +62 -0
- package/dist/prod/core/invariants.js +1 -32
- package/dist/prod/core/lanes.js +931 -132
- package/dist/prod/core/owner.js +192 -129
- package/dist/prod/core/scheduler.js +948 -642
- package/dist/prod/core/truth.js +47 -0
- package/dist/prod/core/verdict.js +409 -420
- package/dist/prod/deferred.js +184 -0
- package/dist/prod/flatten.js +77 -0
- package/dist/prod/from.js +248 -0
- package/dist/prod/index.js +40 -16
- package/dist/prod/map.js +481 -211
- package/dist/prod/reveal.js +212 -0
- package/dist/prod/signals.js +401 -84
- package/dist/prod/store/affects.js +142 -0
- package/dist/prod/store/edges.js +39 -0
- package/dist/prod/store/hooks.js +16 -0
- package/dist/prod/store/index.js +27 -18
- package/dist/prod/store/optimistic.js +707 -0
- package/dist/prod/store/projection.js +331 -0
- package/dist/prod/store/reconcile.js +281 -0
- package/dist/prod/store/store.js +1952 -267
- package/dist/prod/store/storePath.js +1 -1
- package/dist/prod/store/target.js +43 -0
- package/dist/prod/store/types.js +83 -0
- package/dist/prod/store/utils.js +997 -138
- package/dist/types/affects-marks.d.ts +14 -0
- package/dist/types/affects.d.ts +12 -30
- package/dist/types/attribution.d.ts +19 -0
- package/dist/types/attribution.prod.d.ts +22 -0
- package/dist/types/boundaries.d.ts +99 -124
- package/dist/types/carved.d.ts +1 -0
- package/dist/types/core/action.d.ts +23 -9
- package/dist/types/core/async.d.ts +34 -6
- 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 +307 -8
- package/dist/types/core/attribution-queries.d.ts +24 -0
- package/dist/types/core/attribution.d.ts +802 -72
- package/dist/types/core/constants.d.ts +195 -38
- package/dist/types/core/copies.d.ts +54 -0
- package/dist/types/core/core.d.ts +295 -65
- package/dist/types/core/dev.d.ts +509 -22
- package/dist/types/core/effect.d.ts +1 -1
- package/dist/types/core/error-hooks.d.ts +71 -0
- package/dist/types/core/error.d.ts +18 -1
- package/dist/types/core/graph.d.ts +40 -1
- package/dist/types/core/heap.d.ts +5 -5
- package/dist/types/core/identities.d.ts +17 -0
- package/dist/types/core/index.d.ts +11 -7
- package/dist/types/core/invariants.d.ts +1 -26
- package/dist/types/core/lanes.d.ts +74 -43
- package/dist/types/core/owner.d.ts +27 -9
- package/dist/types/core/scheduler.d.ts +353 -102
- package/dist/types/core/truth.d.ts +18 -0
- package/dist/types/core/types.d.ts +97 -71
- package/dist/types/core/verdict.d.ts +35 -0
- package/dist/types/deferred.d.ts +28 -0
- package/dist/types/flatten.d.ts +8 -0
- package/dist/types/from.d.ts +47 -0
- package/dist/types/index.d.ts +33 -7
- package/dist/types/map.d.ts +4 -2
- package/dist/types/reveal.d.ts +19 -0
- package/dist/types/signals.d.ts +196 -45
- package/dist/types/store/affects.d.ts +12 -0
- package/dist/types/store/edges.d.ts +9 -0
- package/dist/types/store/hooks.d.ts +62 -0
- package/dist/types/store/index.d.ts +42 -15
- package/dist/types/store/optimistic.d.ts +24 -45
- package/dist/types/store/projection.d.ts +17 -68
- package/dist/types/store/reconcile.d.ts +3 -46
- package/dist/types/store/store.d.ts +133 -136
- package/dist/types/store/storePath.d.ts +1 -1
- package/dist/types/store/target.d.ts +166 -0
- package/dist/types/store/types.d.ts +105 -0
- package/dist/types/store/utils.d.ts +188 -0
- package/package.json +31 -26
- package/dist/node.cjs +0 -8745
- package/dist/prod/core/optimistic.js +0 -265
- package/dist/prod/store/next/optimistic.js +0 -385
- package/dist/prod/store/next/projection.js +0 -172
- package/dist/prod/store/next/reconcile.js +0 -331
- package/dist/prod/store/next/store.js +0 -1499
- package/dist/prod/store/next/target.js +0 -20
- package/dist/types/core/optimistic.d.ts +0 -6
- package/dist/types/store/next/optimistic.d.ts +0 -20
- package/dist/types/store/next/projection.d.ts +0 -8
- package/dist/types/store/next/reconcile.d.ts +0 -3
- package/dist/types/store/next/store.d.ts +0 -77
- package/dist/types/store/next/target.d.ts +0 -117
- 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/attribution-hooks.d.cts +0 -52
- package/dist/types-cjs/core/attribution.d.cts +0 -186
- package/dist/types-cjs/core/constants.d.cts +0 -97
- package/dist/types-cjs/core/context.d.cts +0 -36
- package/dist/types-cjs/core/core.d.cts +0 -163
- package/dist/types-cjs/core/dev.d.cts +0 -81
- 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 -6
- 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 -180
- package/dist/types-cjs/core/types.d.cts +0 -192
- 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 -8
- package/dist/types-cjs/store/next/reconcile.d.cts +0 -3
- package/dist/types-cjs/store/next/store.d.cts +0 -77
- package/dist/types-cjs/store/next/target.d.cts +0 -117
- 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
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
const REACTIVE_NONE = 0;
|
|
2
|
+
|
|
3
|
+
const REACTIVE_CHECK = 1 << 0;
|
|
4
|
+
|
|
5
|
+
const REACTIVE_DIRTY = 1 << 1;
|
|
6
|
+
|
|
7
|
+
const REACTIVE_RECOMPUTING_DEPS = 1 << 2;
|
|
8
|
+
|
|
9
|
+
const REACTIVE_IN_HEAP = 1 << 3;
|
|
10
|
+
|
|
11
|
+
const REACTIVE_IN_HEAP_HEIGHT = 1 << 4;
|
|
12
|
+
|
|
13
|
+
/** L2 — the node sits on its owner's parked frame (`_x._pendingFirstChild`):
|
|
14
|
+
* it is the displayed frame until the owner's commit disposes it. Set by
|
|
15
|
+
* `markDisposal` over the parked subtree; carried through every per-pass
|
|
16
|
+
* flag wipe (#3543). Scheduling reads it once, at the heap pop: a zombie's
|
|
17
|
+
* recompute is deferred past the seam (`deferZombie`). */ const REACTIVE_ZOMBIE = 1 << 5;
|
|
18
|
+
|
|
19
|
+
const REACTIVE_DISPOSED = 1 << 6;
|
|
20
|
+
|
|
21
|
+
/** L2 — this pass read the future (a tracked read of a CONFIG_HELD node).
|
|
22
|
+
* Lives for the pass only: set by `read`, consumed by `recompute`'s publish
|
|
23
|
+
* (a first pass that read the future is born held, A29), wiped with the
|
|
24
|
+
* pass's other per-pass bits. */ const REACTIVE_JOINED = 1 << 7;
|
|
25
|
+
|
|
26
|
+
const REACTIVE_SNAPSHOT_STALE = 1 << 8;
|
|
27
|
+
|
|
28
|
+
const REACTIVE_LAZY = 1 << 9;
|
|
29
|
+
|
|
30
|
+
const REACTIVE_MANUAL_WRITE = 1 << 10;
|
|
31
|
+
|
|
32
|
+
/** L2, rule 3 — the node's LAST pass was a render effect's read of the
|
|
33
|
+
* future as committed (`frameRead`): the frame shows the committed world
|
|
34
|
+
* beside a future it also derives from, and re-derives at the landing.
|
|
35
|
+
* Survives its own pass's wipe; the next pass's wipe clears it (a pass that
|
|
36
|
+
* re-derived the frame — in the future, or without the held read — owes the
|
|
37
|
+
* landing nothing). The landing consumes it (the transaction's `_reruns`). */ const REACTIVE_FRAME_READ = 1 << 11;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* A dependency write landed while this subscriber was mid-recompute — a
|
|
41
|
+
* nested pull committed beneath one of its reads (#3037). The heap refuses
|
|
42
|
+
* RECOMPUTING nodes, so recompute's tail consumes this latch and reschedules:
|
|
43
|
+
* values the pass read before the nested commit are stale. Only set for
|
|
44
|
+
* links validated this pass (gen-current): a write to an untouched link is
|
|
45
|
+
* either re-read later in the pass (fresh) or trimmed with it (not a dep).
|
|
46
|
+
*/ const REACTIVE_MISSED_WAKE = 1 << 12;
|
|
47
|
+
|
|
48
|
+
/** A `refresh()` asked this node to re-ask its question (A19 exc. 2, A24):
|
|
49
|
+
* consumed by the next pass, which — going pending — classifies its flight
|
|
50
|
+
* quiet (`_x._reask`). */ const REACTIVE_REASK = 1 << 13;
|
|
51
|
+
|
|
52
|
+
/** The pass was served a node's ambient staging — written this flush, not
|
|
53
|
+
* held. If the flush parks, the pass is the frame's with it (the same sync
|
|
54
|
+
* frame as the async): a verdict read cannot break it out. Per pass. */ const REACTIVE_STAGED_READ = 1 << 14;
|
|
55
|
+
|
|
56
|
+
/** The pass entered a verdict window (`isPending`/`latest`). Per pass: a
|
|
57
|
+
* pass that did not keeps CONFIG_VERDICT no longer — the frame-reader
|
|
58
|
+
* posture lasts exactly as long as the probing does. */ const REACTIVE_PROBED = 1 << 15;
|
|
59
|
+
|
|
60
|
+
/** Lanes — the node (a lane's member) was dirtied by the lane's own
|
|
61
|
+
* re-staging (a re-guess, lane work re-derived): its next pass is the
|
|
62
|
+
* lane's from the start (`recompute`), not a stale reader's re-run by an
|
|
63
|
+
* unrelated write (#3460). Consumed by the pass. */ const REACTIVE_LANE_DIRTY = 1 << 16;
|
|
64
|
+
|
|
65
|
+
/** Lanes (plan sec. 28) — the pass read a lane's value as lane work (`enterLane`): a
|
|
66
|
+
* tracked derivation's read of displayed optimism, a verdict read routed
|
|
67
|
+
* into the holder's verdict lane. A pass in a lane's seat that read none of
|
|
68
|
+
* its world has left the lane (`recompute`'s tail). Per pass. */ const REACTIVE_LANE_READ = 1 << 17;
|
|
69
|
+
|
|
70
|
+
/** Lanes (plan sec. 28) — a render effect in the frame's seat was served the screen
|
|
71
|
+
* for a lane's node (`laneRead`: a stale reader of a lane that has not
|
|
72
|
+
* shown). Its pass computing exactly what it last applied has nothing to
|
|
73
|
+
* run — an effect has no comparator, and the guess's notification is not a
|
|
74
|
+
* change it can see. Per pass. */ const REACTIVE_SCREEN_READ = 1 << 18;
|
|
75
|
+
|
|
76
|
+
/** A verdict reader whose probe was answered before the flush had a
|
|
77
|
+
* transaction (verdict.ts `watchVerdict`): the seam re-runs it even if a
|
|
78
|
+
* later read of the same pass routed it into a verdict lane — that was not
|
|
79
|
+
* the probe's answer (lanes.ts). Per pass. */ const REACTIVE_PROBE_UNANSWERED = 1 << 19;
|
|
80
|
+
|
|
81
|
+
/** The pass opened a verdict window of its own (`isPending`/`latest`) — not
|
|
82
|
+
* only read a verdict memo (F-6, core.ts `read`). An async memo whose pass
|
|
83
|
+
* did not is D-25's hold work while its flight is up (verdict.ts
|
|
84
|
+
* `holdWork`). Per pass (1 << 20 is lanes.ts's LEFT_SHOWN). */ const REACTIVE_WINDOW = 1 << 21;
|
|
85
|
+
|
|
86
|
+
// Static configuration bits packed into Owner/Computed/Signal _config.
|
|
87
|
+
const CONFIG_OWNED_WRITE = 1 << 0;
|
|
88
|
+
|
|
89
|
+
const CONFIG_NO_SNAPSHOT = 1 << 1;
|
|
90
|
+
|
|
91
|
+
const CONFIG_TRANSPARENT = 1 << 2;
|
|
92
|
+
|
|
93
|
+
const CONFIG_IN_SNAPSHOT_SCOPE = 1 << 3;
|
|
94
|
+
|
|
95
|
+
const CONFIG_CHILDREN_FORBIDDEN = 1 << 4;
|
|
96
|
+
|
|
97
|
+
const CONFIG_AUTO_DISPOSE = 1 << 5;
|
|
98
|
+
|
|
99
|
+
const CONFIG_SYNC = 1 << 6;
|
|
100
|
+
|
|
101
|
+
// CARVE 3: REACTIVE_ZOMBIE, CONFIG_AUTHORITATIVE_READ, CONFIG_DIRECT_COMMIT,
|
|
102
|
+
// CONFIG_HELD_CHILDREN, CONFIG_INPUTS_PUBLISHED and CONFIG_ADOPTED_UNFLUSHED
|
|
103
|
+
// (transaction holds, zombies, until()'s authoritative view) went with the
|
|
104
|
+
// transactions.
|
|
105
|
+
// L2 (step 2): four bits, all maintained by the node's commit.
|
|
106
|
+
/** The node has a pass awaiting commit: its live children (and `_disposal`)
|
|
107
|
+
* are that pass's and were never shown — a re-pass tears them down on the
|
|
108
|
+
* spot, while the frame parked on `_x._pendingFirstChild` keeps waiting for
|
|
109
|
+
* the commit. Set by `recompute` when it queues the node. */ const CONFIG_STAGED = 1 << 7;
|
|
110
|
+
|
|
111
|
+
/** The node's staged state is in the future: the flush that staged it
|
|
112
|
+
* parked. A write to it, a tracked read of it by a derivation, or a pass
|
|
113
|
+
* over a derivation holding it joins the future (the flush parks). Render
|
|
114
|
+
* effects are the frame, not derivations (rule 3): reading it outside a
|
|
115
|
+
* parking flush they see the committed value and hold nothing, and are
|
|
116
|
+
* re-derived at the landing. Set at the park seam on every staged node. */ const CONFIG_HELD = 1 << 8;
|
|
117
|
+
|
|
118
|
+
/** A member of the uncommitted frame a held pass built (ruling A): set at
|
|
119
|
+
* the park seam on every computed under a staged node (`holdFrame`). Never
|
|
120
|
+
* shown, it has no screen: its reads are its transaction's, whichever flush
|
|
121
|
+
* runs it (`bornInto`, #4010). Cleared by its commit. */ const CONFIG_HELD_FRAME = 1 << 20;
|
|
122
|
+
|
|
123
|
+
/** A15's reveal corollary (#3305): a commit published this flight's inputs
|
|
124
|
+
* beneath it — the node was pending, nothing staged, when it committed — so
|
|
125
|
+
* its committed value is torn against the visible frame. A render effect
|
|
126
|
+
* revealing it cannot be a stale reader: it observes the flight (pends,
|
|
127
|
+
* holds) instead of showing the pre-flight value. Outlives the flight that
|
|
128
|
+
* earned it for as long as the node stays pending, and no longer: the
|
|
129
|
+
* commit that lands a value clears it. */ const CONFIG_INPUTS_PUBLISHED = 1 << 10;
|
|
130
|
+
|
|
131
|
+
/** Lanes (plan sec. 28) — the node has a lane's value (`_x._lane`): a written guess
|
|
132
|
+
* (CONFIG_GUESS) or a lane pass's derivation of one. Its lane is
|
|
133
|
+
* `_x._transaction`. The gate to the lane arm of `read`; `_value` stays the
|
|
134
|
+
* committed truth and `_pendingValue` a transaction's staging throughout —
|
|
135
|
+
* a value's world is where it lives, never a bit. */ const CONFIG_OVERRIDE = 1 << 11;
|
|
136
|
+
|
|
137
|
+
/** A store slot node (`slotSignal`): a leaf, presence, container or deep
|
|
138
|
+
* witness of a store target. One literal, no `_x` at birth; the last-one-out
|
|
139
|
+
* sweep dispatches it to the store's shared release hook (graph.ts) instead
|
|
140
|
+
* of a per-node `_unobserved` closure. */ const CONFIG_SLOT_NODE = 1 << 12;
|
|
141
|
+
|
|
142
|
+
/** A store slot node whose staging is a USER setter's proposal, not its
|
|
143
|
+
* derive's derivation (A34 (3)'s discriminator for derived stores — the
|
|
144
|
+
* leaf twin of REACTIVE_MANUAL_WRITE). Set by the user setter, cleared by
|
|
145
|
+
* the derive's own write to the key. */ const CONFIG_MANUAL_WRITE = 1 << 18;
|
|
146
|
+
|
|
147
|
+
/** D-41: the staged value in `_pendingValue` is an error — an
|
|
148
|
+
* answer of the held frame, published at its landing like a value. */ const CONFIG_STAGED_ERROR = 1 << 21;
|
|
149
|
+
|
|
150
|
+
/** Lanes — the node carries a written guess (`optimisticWrite`): its own
|
|
151
|
+
* source recomputing it, or a plain write landing on it, is the truth
|
|
152
|
+
* (`supersede`). A lane's derived staging is not. */ const CONFIG_GUESS = 1 << 13;
|
|
153
|
+
|
|
154
|
+
/** The node's pass read a verdict (`isPending`/`latest`): a dependency going
|
|
155
|
+
* pending is a question for its next pass — the verdict changed — so the
|
|
156
|
+
* propagation re-derives it instead of marking it pending (as a kept-tail
|
|
157
|
+
* link does, A30). Set at the window, never cleared: a reader that stopped
|
|
158
|
+
* asking re-derives once and goes pending through its own read. The same
|
|
159
|
+
* bit as REACTIVE_PROBED: a pass's probe (or a read of a verdict memo,
|
|
160
|
+
* core.ts `read`) carries into the config at its end without a shift. */ const CONFIG_VERDICT = 1 << 15;
|
|
161
|
+
|
|
162
|
+
/** A dependency's status is a question for this node's pass, not a fact
|
|
163
|
+
* about its current one: the propagation re-derives it instead of marking
|
|
164
|
+
* it, for errors as for pending (as CONFIG_VERDICT). A boundary's output
|
|
165
|
+
* (show the content, or the fallback) and its `on` node (boundaries.ts); a
|
|
166
|
+
* promise over an expression (`resolve`/`until`, signals.ts: the pass reads
|
|
167
|
+
* the error and rejects, or re-asks a pending source). */ const CONFIG_REDERIVE = 1 << 14;
|
|
168
|
+
|
|
169
|
+
/** An answered `createDeferred` node (deferred.ts): held because a
|
|
170
|
+
* downstream hold staged its landing, its re-pass is a lagging question,
|
|
171
|
+
* not an answer, and joins no transaction (D-40). */ const CONFIG_LAGS = 1 << 19;
|
|
172
|
+
|
|
173
|
+
/** The reader wants the truth, not the lane's guess (`until`, signals.ts):
|
|
174
|
+
* a read of displayed optimism serves the base the guess covers, makes the
|
|
175
|
+
* pass no lane's, and the truth landing wakes it even when it confirms the
|
|
176
|
+
* guess (the one case ordinary subscribers are not told — A17's silence). */ const CONFIG_AUTHORITATIVE = 1 << 17;
|
|
177
|
+
|
|
178
|
+
// Presence bits (stage-3 hot-path monomorphism, DESIGN-PATCH-CHANNEL §11b):
|
|
179
|
+
// optional per-node slots (_overrideValue, _pendingSignal/_latestValueComputed,
|
|
180
|
+
// _snapshotValue, _optimisticLane) are NOT part of every node's hidden class —
|
|
181
|
+
// reading a missing property defeats V8's inline caches on the hottest write/
|
|
182
|
+
// notify loops. These bits live on the always-present `_config` so hot paths
|
|
183
|
+
// pay one monomorphic masked read and only touch the optional field when its
|
|
184
|
+
// installer flagged it. Bits are STICKY ("may be set") — the guarded field
|
|
185
|
+
// read remains authoritative.
|
|
186
|
+
const CONFIG_HAS_SNAPSHOT = 1 << 9;
|
|
187
|
+
|
|
188
|
+
/** Fresh-pull reader (awaitable `refresh()`'s waiter effect): a read of a
|
|
189
|
+
* dirty source recomputes it inline even when the height gate defers to the
|
|
190
|
+
* flush. Closes the same-flush ordering race where a waiter created
|
|
191
|
+
* alongside a refresh() mark read the PRE-re-ask value as settled and
|
|
192
|
+
* delivered stale; with the pull, the waiter either parks on the re-ask's
|
|
193
|
+
* pending window (async — woken by the settle walk, which runs on every
|
|
194
|
+
* landing including equal-value ones) or serves its sync answer. resolve()
|
|
195
|
+
* deliberately keeps that race — its contract is "first settled value"
|
|
196
|
+
* (#2930), not "next quiescent state". */ const CONFIG_FRESH_READ = 1 << 16;
|
|
197
|
+
|
|
198
|
+
/** A28 (4): the node was written inside a recompute that ran OUTSIDE a flush
|
|
199
|
+
* (a creation-time compute — boundary machinery, a mapArray's first run). Such
|
|
200
|
+
* a write is promoted at that recompute's end: readers in the same block see
|
|
201
|
+
* it. Cleared when the next flush begins; set only on that rare path. */ const CONFIG_PROMOTED = 1 << 22;
|
|
202
|
+
|
|
203
|
+
/** Observe tiers only: the node is framework plumbing (the `solid-js/refresh`
|
|
204
|
+
* HMR memo between a component's root and its body) — it has no name, is no
|
|
205
|
+
* segment of any owner path, and the attribution engine records nothing about
|
|
206
|
+
* it (creation, re-runs, checks) and does not count it toward another scope's
|
|
207
|
+
* WIDE_SCOPE_DEPS or a write's engine-side HUGE_FAN_OUT, while the nodes it
|
|
208
|
+
* owns stay fully observed.
|
|
209
|
+
* Set from the internal `_plumbing` option at creation; never set in prod. */ const CONFIG_PLUMBING = 1 << 25;
|
|
210
|
+
|
|
211
|
+
/** Observe tiers only: the memo `merge()` creates for a function source — a
|
|
212
|
+
* key bag readers consume key by key, built by the framework (a compiled
|
|
213
|
+
* component spread) with options no user can reach. The attribution engine's
|
|
214
|
+
* UNSTABLE_MEMO_OUTPUT skips it: a fresh-but-equal bag is the idiom
|
|
215
|
+
* (`{...(on() ? { a } : {})}`), and the advice (`equals`) cannot be applied
|
|
216
|
+
* (#4256). Set through `_extraConfig` by observe builds only. */ const CONFIG_KEY_BAG = 1 << 28;
|
|
217
|
+
|
|
218
|
+
/** The frame (rule 3, D-3): a render effect (set at creation, as
|
|
219
|
+
* `EFFECT_RENDER << 23` — keep the two in step), and a boundary's tree and
|
|
220
|
+
* output (boundaries.ts) — structure between the content and the render
|
|
221
|
+
* effect that shows it, not a user derivation of the content. Outside a
|
|
222
|
+
* hold's own flush it reads that hold's values as committed and is
|
|
223
|
+
* re-derived at its landing, and a re-pass of it publishes mainline: it
|
|
224
|
+
* joins nothing, so two mounts under one boundary made in separate flushes
|
|
225
|
+
* keep their holds apart (D-4, S-5 rows 1′–3′, #4283). */ const CONFIG_FRAME = 1 << 23;
|
|
226
|
+
|
|
227
|
+
/** The node's last answering pass registered a flight: an async memo. Kept
|
|
228
|
+
* by the verdict engine alone (verdict.ts `holdWork`), which reads it. */ const CONFIG_ASYNC = 1 << 29;
|
|
229
|
+
|
|
230
|
+
const STATUS_NONE = 0;
|
|
231
|
+
|
|
232
|
+
const STATUS_PENDING = 1 << 0;
|
|
233
|
+
|
|
234
|
+
const STATUS_ERROR = 1 << 1;
|
|
235
|
+
|
|
236
|
+
const STATUS_UNINITIALIZED = 1 << 2;
|
|
237
|
+
|
|
238
|
+
/** An error that answered a node's first read (no value has ever landed):
|
|
239
|
+
* the error, not UNINITIALIZED, is its status while shown, but a re-ask
|
|
240
|
+
* makes it uninitialized-pending again — it still has no value (#4244). */ const STATUS_NO_VALUE = 1 << 3;
|
|
241
|
+
|
|
242
|
+
/** `catchHook`'s answer when the catcher is a boundary re-armed by
|
|
243
|
+
* `on` (truthy, as any catch): what it collects is its own, not the hold's. */ const CAUGHT_REARMED = 2;
|
|
244
|
+
|
|
245
|
+
const EFFECT_RENDER = 1;
|
|
246
|
+
|
|
247
|
+
const EFFECT_USER = 2;
|
|
248
|
+
|
|
249
|
+
const EFFECT_TRACKED = 3;
|
|
250
|
+
|
|
251
|
+
const NOT_PENDING = {};
|
|
252
|
+
|
|
253
|
+
const NO_SNAPSHOT = {};
|
|
254
|
+
|
|
255
|
+
const SUPPORTS_PROXY = typeof Proxy === "function";
|
|
256
|
+
|
|
257
|
+
const defaultContext = {};
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Brand symbol used by `Refreshable<T>` values (projection stores, async
|
|
261
|
+
* memos) to expose their underlying computation to `refresh()`. Not part of
|
|
262
|
+
* the user-facing API.
|
|
263
|
+
*
|
|
264
|
+
* @internal
|
|
265
|
+
*/ const $REFRESH = Symbol("refresh");
|
|
266
|
+
|
|
267
|
+
const NewSet = Set;
|
|
268
|
+
|
|
269
|
+
export { $REFRESH, CAUGHT_REARMED, CONFIG_ASYNC, CONFIG_AUTHORITATIVE, CONFIG_AUTO_DISPOSE, CONFIG_CHILDREN_FORBIDDEN, CONFIG_FRAME, CONFIG_FRESH_READ, CONFIG_GUESS, CONFIG_HAS_SNAPSHOT, CONFIG_HELD, CONFIG_HELD_FRAME, CONFIG_INPUTS_PUBLISHED, CONFIG_IN_SNAPSHOT_SCOPE, CONFIG_KEY_BAG, CONFIG_LAGS, CONFIG_MANUAL_WRITE, CONFIG_NO_SNAPSHOT, CONFIG_OVERRIDE, CONFIG_OWNED_WRITE, CONFIG_PLUMBING, CONFIG_PROMOTED, CONFIG_REDERIVE, CONFIG_SLOT_NODE, CONFIG_STAGED, CONFIG_STAGED_ERROR, CONFIG_SYNC, CONFIG_TRANSPARENT, CONFIG_VERDICT, EFFECT_RENDER, EFFECT_TRACKED, EFFECT_USER, NOT_PENDING, NO_SNAPSHOT, NewSet, REACTIVE_CHECK, REACTIVE_DIRTY, REACTIVE_DISPOSED, REACTIVE_FRAME_READ, REACTIVE_IN_HEAP, REACTIVE_IN_HEAP_HEIGHT, REACTIVE_JOINED, REACTIVE_LANE_DIRTY, REACTIVE_LANE_READ, REACTIVE_LAZY, REACTIVE_MANUAL_WRITE, REACTIVE_MISSED_WAKE, REACTIVE_NONE, REACTIVE_PROBED, REACTIVE_PROBE_UNANSWERED, REACTIVE_REASK, REACTIVE_RECOMPUTING_DEPS, REACTIVE_SCREEN_READ, REACTIVE_SNAPSHOT_STALE, REACTIVE_STAGED_READ, REACTIVE_WINDOW, REACTIVE_ZOMBIE, STATUS_ERROR, STATUS_NONE, STATUS_NO_VALUE, STATUS_PENDING, STATUS_UNINITIALIZED, SUPPORTS_PROXY, defaultContext };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { NoOwnerError, ContextNotFoundError } from "./error.js";
|
|
2
|
+
|
|
3
|
+
import { getOwner } from "./owner.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Context provides a form of dependency injection. It is used to save from needing to pass
|
|
7
|
+
* data as props through intermediate components. This function creates a new context object
|
|
8
|
+
* that can be used with `getContext` and `setContext`.
|
|
9
|
+
*
|
|
10
|
+
* A default value can be provided here which will be used when a specific value is not provided
|
|
11
|
+
* via a `setContext` call.
|
|
12
|
+
*/ function createContext(e, t) {
|
|
13
|
+
return {
|
|
14
|
+
id: Symbol(t),
|
|
15
|
+
defaultValue: e
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Low-level owner-targeted context read. The user-facing read API is
|
|
21
|
+
* `useContext` (in `solid-js`), which wraps this primitive. Exposed here for
|
|
22
|
+
* cross-package wiring (e.g. hydration-aware context plumbing).
|
|
23
|
+
*
|
|
24
|
+
* @throws `NoOwnerError` if there's no owner at the time of call.
|
|
25
|
+
* @throws `ContextNotFoundError` if a context value has not been set yet.
|
|
26
|
+
*
|
|
27
|
+
* @internal
|
|
28
|
+
*/ function getContext(e, t = getOwner()) {
|
|
29
|
+
if (!t) {
|
|
30
|
+
throw new NoOwnerError;
|
|
31
|
+
}
|
|
32
|
+
// `undefined` alone means unset — a provided `null` is a value (no `??`).
|
|
33
|
+
let r = t.A[e.id];
|
|
34
|
+
if (r === undefined) r = e.defaultValue;
|
|
35
|
+
if (r === undefined) {
|
|
36
|
+
// Dev names the context and why it has no value: no provider, or a
|
|
37
|
+
// provider that passed `undefined` (the key is set, to `undefined`).
|
|
38
|
+
throw new ContextNotFoundError;
|
|
39
|
+
}
|
|
40
|
+
return r;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Low-level owner-targeted context write. The user-facing API is
|
|
45
|
+
* `createContext` (in `solid-js`); its provider component wraps this
|
|
46
|
+
* primitive. Exposed here for cross-package wiring.
|
|
47
|
+
*
|
|
48
|
+
* @throws `NoOwnerError` if there's no owner at the time of call.
|
|
49
|
+
*
|
|
50
|
+
* @internal
|
|
51
|
+
*/ function setContext(e, t, r = getOwner()) {
|
|
52
|
+
if (!r) {
|
|
53
|
+
throw new NoOwnerError;
|
|
54
|
+
}
|
|
55
|
+
// We're creating a new object to avoid child context values being exposed to parent owners. If
|
|
56
|
+
// we don't do this, everything will be a singleton and all hell will break lose.
|
|
57
|
+
r.A = {
|
|
58
|
+
...r.A,
|
|
59
|
+
[e.id]: t === undefined ? e.defaultValue : t
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export { createContext, getContext, setContext };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** @internal Runs `fn` with this copy marked as the one running. */
|
|
2
|
+
function runAsSolidCopy(n) {
|
|
3
|
+
return n();
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
/** @internal An ownerless component or context read: warns if another copy is running. */ function checkForeignOwnerless() {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { checkForeignOwnerless, runAsSolidCopy };
|