signalium 2.4.0 → 3.0.0
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/CHANGELOG.md +195 -0
- package/dist/cjs/development/component-shared-Cug2Y5YZ.js +33 -0
- package/dist/cjs/development/component-shared-Cug2Y5YZ.js.map +1 -0
- package/dist/cjs/development/{debug-ouT0N0E4.js → debug-C46WDxhL.js} +47 -195
- package/dist/cjs/development/debug-C46WDxhL.js.map +1 -0
- package/dist/cjs/development/debug.js +1 -1
- package/dist/cjs/development/index.js +3 -2
- package/dist/cjs/development/index.js.map +1 -1
- package/dist/cjs/development/react/index.js +255 -87
- package/dist/cjs/development/react/index.js.map +1 -1
- package/dist/cjs/development/react/index.server.js +14 -0
- package/dist/cjs/development/react/index.server.js.map +1 -0
- package/dist/cjs/development/react/server.js +37 -0
- package/dist/cjs/development/react/server.js.map +1 -0
- package/dist/cjs/development/{snapshot-BPJ-qw6l.js → snapshot-48aGePMZ.js} +2 -2
- package/dist/cjs/development/{snapshot-BPJ-qw6l.js.map → snapshot-48aGePMZ.js.map} +1 -1
- package/dist/cjs/development/transform/index.js +5 -1
- package/dist/cjs/development/transform/index.js.map +1 -1
- package/dist/cjs/development/utils.js +6 -6
- package/dist/cjs/development/utils.js.map +1 -1
- package/dist/cjs/production/component-shared-D0J85PUi.js +33 -0
- package/dist/cjs/production/component-shared-D0J85PUi.js.map +1 -0
- package/dist/cjs/production/{contexts-DtQMtXO7.js → contexts-CM3QLfV8.js} +47 -198
- package/dist/cjs/production/contexts-CM3QLfV8.js.map +1 -0
- package/dist/cjs/production/debug.js +1 -1
- package/dist/cjs/production/index.js +3 -2
- package/dist/cjs/production/index.js.map +1 -1
- package/dist/cjs/production/react/index.js +241 -89
- package/dist/cjs/production/react/index.js.map +1 -1
- package/dist/cjs/production/react/index.server.js +14 -0
- package/dist/cjs/production/react/index.server.js.map +1 -0
- package/dist/cjs/production/react/server.js +37 -0
- package/dist/cjs/production/react/server.js.map +1 -0
- package/dist/cjs/production/{snapshot-Dw62eSpw.js → snapshot-BCESZVAP.js} +2 -2
- package/dist/cjs/production/{snapshot-Dw62eSpw.js.map → snapshot-BCESZVAP.js.map} +1 -1
- package/dist/cjs/production/transform/index.js +5 -1
- package/dist/cjs/production/transform/index.js.map +1 -1
- package/dist/cjs/production/utils.js +6 -6
- package/dist/cjs/production/utils.js.map +1 -1
- package/dist/esm/development/component-shared-CLSmdnGU.js +34 -0
- package/dist/esm/development/component-shared-CLSmdnGU.js.map +1 -0
- package/dist/esm/development/{debug-DaK9qsbI.js → debug-BTLbgTPK.js} +79 -227
- package/dist/esm/development/debug-BTLbgTPK.js.map +1 -0
- package/dist/esm/development/debug.js +9 -9
- package/dist/esm/development/index.js +14 -13
- package/dist/esm/development/react/index.js +229 -77
- package/dist/esm/development/react/index.js.map +1 -1
- package/dist/esm/development/react/index.server.js +14 -0
- package/dist/esm/development/react/index.server.js.map +1 -0
- package/dist/esm/development/react/server.js +20 -0
- package/dist/esm/development/react/server.js.map +1 -0
- package/dist/esm/development/{snapshot-D8ZJEbwO.js → snapshot-Ca_rQa4c.js} +2 -2
- package/dist/esm/development/{snapshot-D8ZJEbwO.js.map → snapshot-Ca_rQa4c.js.map} +1 -1
- package/dist/esm/development/transform/index.js +5 -1
- package/dist/esm/development/transform/index.js.map +1 -1
- package/dist/esm/development/utils.js +11 -11
- package/dist/esm/development/utils.js.map +1 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/internals/async.d.ts +3 -3
- package/dist/esm/internals/async.d.ts.map +1 -1
- package/dist/esm/internals/contexts.d.ts +10 -6
- package/dist/esm/internals/contexts.d.ts.map +1 -1
- package/dist/esm/internals/core-api.d.ts +2 -2
- package/dist/esm/internals/core-api.d.ts.map +1 -1
- package/dist/esm/internals/get.d.ts.map +1 -1
- package/dist/esm/internals/reactive.d.ts +3 -9
- package/dist/esm/internals/reactive.d.ts.map +1 -1
- package/dist/esm/internals/scheduling.d.ts +0 -2
- package/dist/esm/internals/scheduling.d.ts.map +1 -1
- package/dist/esm/internals/watch.d.ts +3 -4
- package/dist/esm/internals/watch.d.ts.map +1 -1
- package/dist/esm/production/component-shared-Dva0S5e3.js +34 -0
- package/dist/esm/production/component-shared-Dva0S5e3.js.map +1 -0
- package/dist/esm/production/{contexts-US_h2nBi.js → contexts-FxCndlvf.js} +71 -222
- package/dist/esm/production/contexts-FxCndlvf.js.map +1 -0
- package/dist/esm/production/debug.js +1 -1
- package/dist/esm/production/index.js +14 -13
- package/dist/esm/production/react/index.js +216 -80
- package/dist/esm/production/react/index.js.map +1 -1
- package/dist/esm/production/react/index.server.js +14 -0
- package/dist/esm/production/react/index.server.js.map +1 -0
- package/dist/esm/production/react/server.js +20 -0
- package/dist/esm/production/react/server.js.map +1 -0
- package/dist/esm/production/{snapshot-CfJGJCvW.js → snapshot-TYiTYPGB.js} +2 -2
- package/dist/esm/production/{snapshot-CfJGJCvW.js.map → snapshot-TYiTYPGB.js.map} +1 -1
- package/dist/esm/production/transform/index.js +5 -1
- package/dist/esm/production/transform/index.js.map +1 -1
- package/dist/esm/production/utils.js +11 -11
- package/dist/esm/production/utils.js.map +1 -1
- package/dist/esm/react/async-component.d.ts +42 -0
- package/dist/esm/react/async-component.d.ts.map +1 -0
- package/dist/esm/react/component-server.d.ts +4 -0
- package/dist/esm/react/component-server.d.ts.map +1 -0
- package/dist/esm/react/component-shared.d.ts +21 -0
- package/dist/esm/react/component-shared.d.ts.map +1 -0
- package/dist/esm/react/component.d.ts +5 -1
- package/dist/esm/react/component.d.ts.map +1 -1
- package/dist/esm/react/index.d.ts +3 -4
- package/dist/esm/react/index.d.ts.map +1 -1
- package/dist/esm/react/index.server.d.ts +8 -0
- package/dist/esm/react/index.server.d.ts.map +1 -0
- package/dist/esm/react/pause-signals-context.d.ts +18 -0
- package/dist/esm/react/pause-signals-context.d.ts.map +1 -0
- package/dist/esm/react/server.d.ts +12 -0
- package/dist/esm/react/server.d.ts.map +1 -0
- package/dist/esm/react/use-reactive.d.ts +34 -7
- package/dist/esm/react/use-reactive.d.ts.map +1 -1
- package/dist/esm/transform/async.d.ts.map +1 -1
- package/dist/esm/transform/callback.d.ts.map +1 -1
- package/dist/esm/transform/use-reactive.d.ts.map +1 -1
- package/dist/esm/types.d.ts +33 -10
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/utils.d.ts +2 -2
- package/dist/esm/utils.d.ts.map +1 -1
- package/package.json +35 -4
- package/react-server.js +15 -0
- package/dist/cjs/development/debug-ouT0N0E4.js.map +0 -1
- package/dist/cjs/production/contexts-DtQMtXO7.js.map +0 -1
- package/dist/esm/development/debug-DaK9qsbI.js.map +0 -1
- package/dist/esm/internals/weakref.d.ts +0 -3
- package/dist/esm/internals/weakref.d.ts.map +0 -1
- package/dist/esm/production/contexts-US_h2nBi.js.map +0 -1
- package/dist/esm/react/suspend-signals-context.d.ts +0 -3
- package/dist/esm/react/suspend-signals-context.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,200 @@
|
|
|
1
1
|
# signalium
|
|
2
2
|
|
|
3
|
+
## 3.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 97a1d00: Add async component support with Suspense + RSC/SSR integration.
|
|
8
|
+
|
|
9
|
+
- `component(async (props) => { await ... })` on the client: the Signalium Babel preset
|
|
10
|
+
rewrites the async body to a generator, and a synchronous replay driver throws pending
|
|
11
|
+
thenables for `<Suspense>` while re-injecting settled values on replay. Reactive reads
|
|
12
|
+
inside the component participate in the signal graph like any other `compute`.
|
|
13
|
+
- New `signalium/react` `react-server` export condition: in RSC bundles, `component()`
|
|
14
|
+
returns a real `async function` (for generator authoring) or a thin sync wrapper, with
|
|
15
|
+
no React hook imports — safe for the server module graph.
|
|
16
|
+
- New `signalium/react/server` entry exposing `setupRscRequestScope()`, which installs a
|
|
17
|
+
per-request `SignalScope` via `React.cache` so server-side `reactive()` / `task()` /
|
|
18
|
+
`relay()` don't leak across requests.
|
|
19
|
+
- New core API `setRequestScopeGetter(get)` that frameworks/tests can use to supply a
|
|
20
|
+
per-request scope; consulted by `getCurrentScope` after `CURRENT_SCOPE` and the current
|
|
21
|
+
consumer's scope.
|
|
22
|
+
- Babel async transform now tracks `component` imported from `signalium/react` alongside
|
|
23
|
+
`reactive` / `reactiveMethod` / `relay` / `task`, so `component(async ...)` is rewritten
|
|
24
|
+
to a generator without extra configuration.
|
|
25
|
+
|
|
26
|
+
Breaking: `react` peer dependency is now `>=19.0.0` (required for `React.cache` and
|
|
27
|
+
React 19's thenable handling in `<Suspense>`).
|
|
28
|
+
|
|
29
|
+
- 9fa0d88: `ReactivePromise<T>` is now the discriminated union by default.
|
|
30
|
+
|
|
31
|
+
The exported `ReactivePromise<T>` _type_ is now
|
|
32
|
+
`PendingReactivePromise<T> | ReadyReactivePromise<T>` — the same shape that was
|
|
33
|
+
previously named `DiscriminatedReactivePromise<T>`. This means `if (p.isReady)`
|
|
34
|
+
narrows `p.value` to `T` (no `| undefined`) directly, with no extra type
|
|
35
|
+
gymnastics.
|
|
36
|
+
|
|
37
|
+
The exported `ReactivePromise` _value_ (the class for `instanceof`, `new`, and
|
|
38
|
+
the static methods `all` / `race` / `any` / `allSettled` / `resolve` / `reject`
|
|
39
|
+
/ `withResolvers`, plus the identifier emitted by the Babel preset's promise
|
|
40
|
+
methods transform) is unchanged at runtime. It's now typed as a constructor
|
|
41
|
+
interface (the same pattern lib.es5.d.ts uses for the global `Promise`), so:
|
|
42
|
+
|
|
43
|
+
- `new ReactivePromise<T>()` returns `ReactivePromise<T>` (the union)
|
|
44
|
+
- `value instanceof ReactivePromise` narrows to the union
|
|
45
|
+
- `ReactivePromise.resolve(x)`, `.all([...])`, etc. return the union
|
|
46
|
+
|
|
47
|
+
### Breaking changes
|
|
48
|
+
|
|
49
|
+
- `DiscriminatedReactivePromise<T>` is removed. Replace every reference with
|
|
50
|
+
`ReactivePromise<T>`. The two types are now identical, so the migration is a
|
|
51
|
+
rename.
|
|
52
|
+
- The previous wide `ReactivePromise<T>` interface (with `value: T | undefined`
|
|
53
|
+
and `isReady: boolean`) is no longer exported. If you had code that explicitly
|
|
54
|
+
asked for that wide shape, switch to discriminating on `isReady` (or accept
|
|
55
|
+
`PendingReactivePromise<T>` / `ReadyReactivePromise<T>` directly).
|
|
56
|
+
|
|
57
|
+
### Why
|
|
58
|
+
|
|
59
|
+
The previous split between a non-discriminated `ReactivePromise<T>` (the class
|
|
60
|
+
instance type) and a separate `DiscriminatedReactivePromise<T>` union (what
|
|
61
|
+
`useReactive`, `relay()`, async `reactive()`, etc. actually returned) was a
|
|
62
|
+
frequent source of confusion. The names suggested they were different shapes
|
|
63
|
+
when in practice users almost always wanted the discriminated form. Merging
|
|
64
|
+
them removes a footgun and matches the runtime behavior.
|
|
65
|
+
|
|
66
|
+
- 46facb0: `useReactive` is now thunk-only and deep-by-default.
|
|
67
|
+
|
|
68
|
+
### New API surface
|
|
69
|
+
|
|
70
|
+
- `useReactive(() => expr)` — deep-by-default. Returns a structurally-shared
|
|
71
|
+
snapshot of the reactive value, so referential equality at the React boundary
|
|
72
|
+
Just Works (memoized children keep the same props when unchanged subtrees are
|
|
73
|
+
re-read). This is the behavior of the old `useReactiveDeep`.
|
|
74
|
+
- `useReactiveShallow(() => expr)` — new named export. Minimal wrapper:
|
|
75
|
+
returns the reactive value by reference without any structural cloning or
|
|
76
|
+
`ReactivePromise` entanglement. Re-renders only when the underlying
|
|
77
|
+
`ReactiveSignal` itself re-runs (e.g. the thunk produces a new reference).
|
|
78
|
+
Use it when you need to preserve class identity on a synchronously-changing
|
|
79
|
+
value. If you need promise state transitions at the React boundary, use
|
|
80
|
+
`useReactive` — its structural snapshot reads the promise's flags and
|
|
81
|
+
automatically re-renders on each transition.
|
|
82
|
+
- `useReactiveDeep(() => expr)` — kept as a deprecated alias that forwards to
|
|
83
|
+
`useReactive` and logs a one-time `console.warn` in dev. Will be removed in
|
|
84
|
+
the next major.
|
|
85
|
+
|
|
86
|
+
### Breaking changes
|
|
87
|
+
|
|
88
|
+
- The non-thunk overloads are removed:
|
|
89
|
+
- `useReactive(signal)` → `useReactive(() => signal.value)`
|
|
90
|
+
- `useReactive(promise)` → `useReactive(() => promise)` for a plain
|
|
91
|
+
snapshot that updates on every promise state transition.
|
|
92
|
+
- `useReactive(reactiveFn, arg1, arg2)` → `useReactive(() => reactiveFn(arg1, arg2))`
|
|
93
|
+
- `useReactiveDeep(reactiveFn, arg1)` → `useReactive(() => reactiveFn(arg1))`
|
|
94
|
+
- Calling `useReactive` / `useReactiveShallow` / `useReactiveDeep` inside a
|
|
95
|
+
reactive function (e.g. inside `reactive(...)` or a `component()` render
|
|
96
|
+
body) now throws in dev (the guard is tree-shaken from production builds).
|
|
97
|
+
These hooks are the bridge from plain React components into the signal
|
|
98
|
+
graph — inside reactive code you should call your signals and
|
|
99
|
+
`reactive()`-returned functions directly, since the surrounding compute
|
|
100
|
+
already participates in the graph. This replaces the previous behavior of
|
|
101
|
+
silently forking and invoking the thunk.
|
|
102
|
+
- The internal `addListener` on `ReactiveSignal` no longer schedules an
|
|
103
|
+
initial pull when the signal is registered as a suspended listener. This
|
|
104
|
+
fixes a case where a component mounted inside a suspended provider would
|
|
105
|
+
render twice on mount.
|
|
106
|
+
|
|
107
|
+
### Recommended migration
|
|
108
|
+
|
|
109
|
+
1. Land this version and enable (or keep) the Signalium Babel preset. The
|
|
110
|
+
preset wraps thunks in `useCallback(fn, [captures])` so identity stays
|
|
111
|
+
stable across renders and the same `ReactiveSignal` is reused.
|
|
112
|
+
2. Rewrite `useReactive(signal)` / `useReactive(fn, ...args)` call sites as
|
|
113
|
+
thunks. A safe blanket replacement is `useReactive(() => oldArg)` /
|
|
114
|
+
`useReactive(() => oldFn(...oldArgs))`.
|
|
115
|
+
3. If you were relying on `ReactivePromise` class identity (e.g. `instanceof`
|
|
116
|
+
checks or passing through `React.memo` by reference), switch those sites to
|
|
117
|
+
`useReactiveShallow`.
|
|
118
|
+
4. Rename `useReactiveDeep` call sites to `useReactive` at your leisure — they
|
|
119
|
+
behave identically but the old name will be removed in the next major.
|
|
120
|
+
|
|
121
|
+
### Philosophy
|
|
122
|
+
|
|
123
|
+
`useReactive` is the bridge from plain React components into the signal graph.
|
|
124
|
+
Every call site is a hook, so there's per-render bookkeeping overhead. Prefer
|
|
125
|
+
`component(fn)` (from `signalium/react`) for components that are meaningfully
|
|
126
|
+
reactive — the whole render body becomes one `ReactiveSignal`'s `compute`,
|
|
127
|
+
which avoids the hook overhead entirely.
|
|
128
|
+
|
|
129
|
+
- 5031ce1: Switch to native `WeakRef` for scope-cached signals, remove suspension from the core graph, and introduce `PauseSignalsProvider`.
|
|
130
|
+
|
|
131
|
+
### Native WeakRef GC
|
|
132
|
+
|
|
133
|
+
`SignalScope` now stores signals as `WeakRef` entries instead of strong references with manual GC sweeps. Signals stay alive as long as something holds a strong reference (the `deps` chain, a React component closure, a local variable, etc.). When nothing references a signal, the JS garbage collector reclaims it naturally.
|
|
134
|
+
|
|
135
|
+
Removed:
|
|
136
|
+
|
|
137
|
+
- The `WeakRef` polyfill (`weakref.ts`) — environments without native `WeakRef` are no longer supported.
|
|
138
|
+
- The manual GC sweep system (`markForGc`, `removeFromGc`, `sweepGc`, `gcCandidates`, `scheduleGcSweep`, `scheduleIdleCallback`).
|
|
139
|
+
- `reset()` on `ReactiveSignal` — signals are no longer eagerly torn down on unwatch. Their value and dep graph are preserved for reuse if re-watched before GC collects them.
|
|
140
|
+
|
|
141
|
+
### Suspension removed from core
|
|
142
|
+
|
|
143
|
+
The core signal graph has zero suspension concepts. Removed:
|
|
144
|
+
|
|
145
|
+
- `suspendCount` field and `_isSuspended` getter on `ReactiveSignal`
|
|
146
|
+
- `setSuspended()` method and `isSuspendedListener` flag
|
|
147
|
+
- `watchSuspendedSignal`, `unwatchSuspendedSignal`, `suspendSignal`, `resumeSignal`
|
|
148
|
+
- The `parentIsSuspended` parameter on `watchSignal` / `unwatchSignal`
|
|
149
|
+
- The `isSuspending` branch in `deactivateSignal`
|
|
150
|
+
|
|
151
|
+
### `PauseSignalsProvider` (replaces `SuspendSignalsProvider`)
|
|
152
|
+
|
|
153
|
+
`SuspendSignalsProvider` is replaced by `PauseSignalsProvider` to avoid confusion with React Suspense.
|
|
154
|
+
|
|
155
|
+
`PauseSignalsProvider` uses a stable `PauseSignalsManager` context (not a changing boolean), so toggling the `value` prop does not re-render descendants. React hooks register their signals during render; the manager calls `watchSignal` / `unwatchSignal` directly to pause and resume the signal graph. Signals mounted inside an already-paused provider skip activation entirely.
|
|
156
|
+
|
|
157
|
+
### Breaking changes
|
|
158
|
+
|
|
159
|
+
- `SuspendSignalsProvider` → `PauseSignalsProvider`
|
|
160
|
+
- `useSignalsSuspended()` is removed from the public API.
|
|
161
|
+
- `setSuspended()` is removed from the `Watcher` interface.
|
|
162
|
+
- Environments without native `WeakRef` are no longer supported.
|
|
163
|
+
|
|
164
|
+
### Minor Changes
|
|
165
|
+
|
|
166
|
+
- 500514d: Remove the implicit `console.error('[signalium] Unhandled async error...')`
|
|
167
|
+
that fired whenever a `ReactivePromise` (including `relay()` and `task()`)
|
|
168
|
+
transitioned to a rejected state.
|
|
169
|
+
|
|
170
|
+
The log was misleading in practice: it ran synchronously inside `_setError`,
|
|
171
|
+
before any reactive consumer or async `component()` had a chance to react. So
|
|
172
|
+
it printed "Unhandled" for rejections that were in fact handled — declaratively
|
|
173
|
+
via `isRejected` / `error` reads, by `await` in an async `component()` (which
|
|
174
|
+
re-throws into a React error boundary), or by an explicit `.catch()` on the
|
|
175
|
+
`ReactivePromise` surface. There's no general definition of "handled" in a
|
|
176
|
+
reactive graph, so any single heuristic was going to mislabel some path.
|
|
177
|
+
|
|
178
|
+
Rejected `ReactivePromise`s are now silent at the library layer. Existing
|
|
179
|
+
ways to observe a rejection are unchanged:
|
|
180
|
+
|
|
181
|
+
- Read `isRejected` / `error` on the `ReactivePromise` (or its
|
|
182
|
+
`useReactive` snapshot) and branch in your reactive code.
|
|
183
|
+
- `await` / `yield` the `ReactivePromise` from an async `component()`; the
|
|
184
|
+
replay driver throws `error` into the nearest React error boundary on
|
|
185
|
+
rejection (and throws a thenable for `<Suspense>` while pending).
|
|
186
|
+
- `.catch()` / `.then(null, fn)` on the `ReactivePromise` — it still
|
|
187
|
+
implements the `Promise` surface.
|
|
188
|
+
|
|
189
|
+
A first-class global hook for unhandled reactive rejections is intentionally
|
|
190
|
+
deferred: defining "handled" in a way that doesn't mislabel the cases above
|
|
191
|
+
needs more design and isn't required for v3.
|
|
192
|
+
|
|
193
|
+
If you were relying on the log for debugging, attach your own logging in a
|
|
194
|
+
declarative branch (e.g. inside a `reactive()` that reads `isRejected` /
|
|
195
|
+
`error`) or rethrow from an async `component()` so the error reaches a React
|
|
196
|
+
error boundary.
|
|
197
|
+
|
|
3
198
|
## 2.4.0
|
|
4
199
|
|
|
5
200
|
### Minor Changes
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const debug = require("./debug-C46WDxhL.js");
|
|
3
|
+
function isGeneratorFunction(fn) {
|
|
4
|
+
return typeof fn === "function" && fn.constructor?.name === "GeneratorFunction";
|
|
5
|
+
}
|
|
6
|
+
function isAsyncFunctionWithoutTransform(fn) {
|
|
7
|
+
return typeof fn === "function" && fn.constructor?.name === "AsyncFunction";
|
|
8
|
+
}
|
|
9
|
+
function createServerAsyncComponentWrapper(fn) {
|
|
10
|
+
return async function(props) {
|
|
11
|
+
const scope = debug.getCurrentScope();
|
|
12
|
+
const owned = debug.createReactiveSignal({ compute: () => null, equals: () => true, isRelay: false, tracer: void 0 }, [], void 0, scope);
|
|
13
|
+
return debug.generatorResultToPromiseWithConsumer(fn(props), owned);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function createServerSyncComponentWrapper(fn) {
|
|
17
|
+
return function(props) {
|
|
18
|
+
const scope = debug.getCurrentScope();
|
|
19
|
+
const owned = debug.createReactiveSignal({ compute: () => null, equals: () => true, isRelay: false, tracer: void 0 }, [], void 0, scope);
|
|
20
|
+
const prevConsumer = debug.getCurrentConsumer();
|
|
21
|
+
try {
|
|
22
|
+
debug.setCurrentConsumer(owned);
|
|
23
|
+
return fn(props);
|
|
24
|
+
} finally {
|
|
25
|
+
debug.setCurrentConsumer(prevConsumer);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
exports.createServerAsyncComponentWrapper = createServerAsyncComponentWrapper;
|
|
30
|
+
exports.createServerSyncComponentWrapper = createServerSyncComponentWrapper;
|
|
31
|
+
exports.isAsyncFunctionWithoutTransform = isAsyncFunctionWithoutTransform;
|
|
32
|
+
exports.isGeneratorFunction = isGeneratorFunction;
|
|
33
|
+
//# sourceMappingURL=component-shared-Cug2Y5YZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-shared-Cug2Y5YZ.js","sources":["../../../.tsc-out/react/component-shared.js"],"sourcesContent":["import { getCurrentConsumer, setCurrentConsumer } from '../internals/consumer.js';\nimport { getCurrentScope } from '../internals/contexts.js';\nimport { createReactiveSignal } from '../internals/reactive.js';\nimport { generatorResultToPromiseWithConsumer } from '../internals/generators.js';\nexport function isGeneratorFunction(fn) {\n return (typeof fn === 'function' && fn.constructor?.name === 'GeneratorFunction');\n}\nexport function isAsyncFunctionWithoutTransform(fn) {\n return typeof fn === 'function' && fn.constructor?.name === 'AsyncFunction';\n}\n/**\n * Wrap a Babel-transformed async generator in a real `async function` that drives it\n * with {@link generatorResultToPromiseWithConsumer}. Used on the server (RSC + SSR)\n * where hooks-based Suspense replay is not appropriate.\n */\nexport function createServerAsyncComponentWrapper(fn) {\n return async function (props) {\n const scope = getCurrentScope();\n const owned = createReactiveSignal({ compute: () => null, equals: () => true, isRelay: false, tracer: undefined }, [], undefined, scope);\n return generatorResultToPromiseWithConsumer(fn(props), owned);\n };\n}\n/**\n * Wrap a sync render function with consumer/scope tracking. Used by the server\n * `component()` for non-generator definitions.\n */\nexport function createServerSyncComponentWrapper(fn) {\n return function (props) {\n const scope = getCurrentScope();\n const owned = createReactiveSignal({ compute: () => null, equals: () => true, isRelay: false, tracer: undefined }, [], undefined, scope);\n const prevConsumer = getCurrentConsumer();\n try {\n setCurrentConsumer(owned);\n return fn(props);\n }\n finally {\n setCurrentConsumer(prevConsumer);\n }\n };\n}\n"],"names":["getCurrentScope","createReactiveSignal","generatorResultToPromiseWithConsumer","getCurrentConsumer","setCurrentConsumer"],"mappings":";;AAIO,SAAS,oBAAoB,IAAI;AACpC,SAAQ,OAAO,OAAO,cAAc,GAAG,aAAa,SAAS;AACjE;AACO,SAAS,gCAAgC,IAAI;AAChD,SAAO,OAAO,OAAO,cAAc,GAAG,aAAa,SAAS;AAChE;AAMO,SAAS,kCAAkC,IAAI;AAClD,SAAO,eAAgB,OAAO;AAC1B,UAAM,QAAQA,MAAAA,gBAAe;AAC7B,UAAM,QAAQC,MAAAA,qBAAqB,EAAE,SAAS,MAAM,MAAM,QAAQ,MAAM,MAAM,SAAS,OAAO,QAAQ,OAAS,GAAI,CAAA,GAAI,QAAW,KAAK;AACvI,WAAOC,2CAAqC,GAAG,KAAK,GAAG,KAAK;AAAA,EAChE;AACJ;AAKO,SAAS,iCAAiC,IAAI;AACjD,SAAO,SAAU,OAAO;AACpB,UAAM,QAAQF,MAAAA,gBAAe;AAC7B,UAAM,QAAQC,MAAAA,qBAAqB,EAAE,SAAS,MAAM,MAAM,QAAQ,MAAM,MAAM,SAAS,OAAO,QAAQ,OAAS,GAAI,CAAA,GAAI,QAAW,KAAK;AACvI,UAAM,eAAeE,MAAAA,mBAAkB;AACvC,QAAI;AACAC,YAAAA,mBAAmB,KAAK;AACxB,aAAO,GAAG,KAAK;AAAA,IACnB,UACR;AACYA,YAAAA,mBAAmB,YAAY;AAAA,IACnC;AAAA,EACJ;AACJ;;;;;"}
|