@solidnative-dev/renderer 0.0.0-stage → 0.1.0-beta.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/LICENSE +21 -0
- package/README.md +228 -2
- package/dist/index.d.ts +80 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +316 -0
- package/dist/index.js.map +1 -0
- package/dist/jsx-runtime.d.ts +14 -0
- package/dist/jsx-runtime.d.ts.map +1 -0
- package/dist/jsx-runtime.js +2 -0
- package/dist/jsx-runtime.js.map +1 -0
- package/dist/native-root.d.ts +183 -0
- package/dist/native-root.d.ts.map +1 -0
- package/dist/native-root.js +2159 -0
- package/dist/native-root.js.map +1 -0
- package/dist/values.d.ts +10 -0
- package/dist/values.d.ts.map +1 -0
- package/dist/values.js +105 -0
- package/dist/values.js.map +1 -0
- package/package.json +48 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Solid Native contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,229 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@solidnative-dev/renderer`
|
|
2
2
|
|
|
3
|
-
This
|
|
3
|
+
This package implements the Solid 2 `@solidjs/universal` integration and the
|
|
4
|
+
transactional logical node graph. A `NativeRoot` owns one host surface, hides
|
|
5
|
+
opaque node handles from application refs, routes native events through Solid
|
|
6
|
+
2's unowned event boundary, and serializes commits for synchronous or
|
|
7
|
+
asynchronous hosts.
|
|
8
|
+
|
|
9
|
+
## Responsibilities
|
|
10
|
+
|
|
11
|
+
- Implement the universal renderer node operations
|
|
12
|
+
- Maintain the logical JavaScript parent/child/sibling graph
|
|
13
|
+
- Normalize intrinsic elements, props, styles, refs, and events
|
|
14
|
+
- Tie roots, listeners, resources, and native nodes to Solid ownership
|
|
15
|
+
- Collect and coalesce mutations per native surface
|
|
16
|
+
- Commit on Solid flush boundaries
|
|
17
|
+
- Expose explicit synchronous boundaries for supported measurement/focus cases
|
|
18
|
+
- Validate text nesting and component descriptors
|
|
19
|
+
|
|
20
|
+
## Implemented foundation
|
|
21
|
+
|
|
22
|
+
- Solid 2 RC universal renderer operations and JSX runtime types
|
|
23
|
+
- Per-surface logical parent/child/sibling graphs with host-hidden sentinels
|
|
24
|
+
- Transport-safe props, style flattening, event-prop separation, and refs
|
|
25
|
+
- Coalesced property/text mutations and serialized atomic commits
|
|
26
|
+
- Direct, capture, and bubbling event delivery at mapped commit priorities
|
|
27
|
+
- Solid 2-compatible unowned event invocation, so ordinary component-local
|
|
28
|
+
signals can be written without weakening owned-computation diagnostics
|
|
29
|
+
- Explicit async measurement and command boundaries; commands drain in their
|
|
30
|
+
own transactions after any structural work, even when a native event races
|
|
31
|
+
an asynchronous host commit
|
|
32
|
+
- A host-owned `focusAccessibility()` ref operation that targets the current
|
|
33
|
+
Fabric shadow node without exposing React tags or conflating input focus
|
|
34
|
+
- Commands revalidate the root immediately before dispatch, so teardown cancels
|
|
35
|
+
work that lost a race with disposal without targeting a retired native handle
|
|
36
|
+
or poisoning surface cleanup
|
|
37
|
+
- Measurements revalidate both before and after the host read; teardown waits
|
|
38
|
+
for an already-started asynchronous read before deleting its node, while the
|
|
39
|
+
caller receives no geometry from a disposed surface
|
|
40
|
+
- Root flushes wait for commands scheduled by framework-owned reactive effects,
|
|
41
|
+
so controlled native state has a deterministic completion boundary
|
|
42
|
+
- Opt-in causal telemetry linking native events and imperative work to commits
|
|
43
|
+
- Owner-captured platform-event handlers for non-Fabric native subscriptions
|
|
44
|
+
- Owner-bound causal scopes for explicitly linking background settlements to
|
|
45
|
+
the exact Solid/Fabric commit they produce
|
|
46
|
+
- Opt-in causal computation boundaries that batch selected reactive native
|
|
47
|
+
output into one operation per commit
|
|
48
|
+
- Native commands capture an active named owner/computation synchronously, so
|
|
49
|
+
their later isolated commit retains its Solid cause across async dispatch
|
|
50
|
+
- Root commit and telemetry diagnostic observers isolate both synchronous
|
|
51
|
+
throws and rejected return values without replacing the underlying failure
|
|
52
|
+
- `mountAsync` makes root construction transactional: after surface acquisition,
|
|
53
|
+
allocation, initial-prop normalization, event/lifecycle subscription, and
|
|
54
|
+
initial Solid render failures are not rejected until native rollback
|
|
55
|
+
completes. The synchronous `mount` API also starts rollback before preserving
|
|
56
|
+
the original render failure, but cannot expose asynchronous cleanup completion
|
|
57
|
+
to its caller. Application disposal always attempts native teardown even when
|
|
58
|
+
a Solid owner or host subscription cleanup throws. Every distinct unsubscribe,
|
|
59
|
+
commit, and surface-stop failure is retained instead of letting an earlier
|
|
60
|
+
cleanup step bypass or hide a later one
|
|
61
|
+
- Solid 2 error recovery can retain a previously mounted native subtree after
|
|
62
|
+
its fallback replaces it. Detached host identities are deleted promptly,
|
|
63
|
+
while their logical tree is preserved and rematerialized with fresh handles
|
|
64
|
+
if Solid later retries it; retained event routes are restored with the tree
|
|
65
|
+
- Deterministic disposal and surface cleanup
|
|
66
|
+
|
|
67
|
+
Background promises do not have an implicit global async context. Create a
|
|
68
|
+
scope inside a Solid owner, then re-enter it around each synchronous reactive
|
|
69
|
+
settlement that should cause native work:
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
const refresh = createCausalScope("profile.refresh");
|
|
73
|
+
|
|
74
|
+
void loadProfile().then(
|
|
75
|
+
(profile) => {
|
|
76
|
+
refresh.run(() => setProfile(profile));
|
|
77
|
+
refresh.finish();
|
|
78
|
+
},
|
|
79
|
+
(error) => refresh.fail(error),
|
|
80
|
+
);
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
The scope records its static identifier, never the profile value or error
|
|
84
|
+
message. Unfinished scopes are cancelled when their Solid owner is disposed.
|
|
85
|
+
|
|
86
|
+
When a component must start separate tasks from future callbacks, capture the
|
|
87
|
+
root-scoped factory during component setup rather than creating one task eagerly:
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
const createTask = useNativeCausalScopeFactory();
|
|
91
|
+
|
|
92
|
+
const startRefresh = () => {
|
|
93
|
+
const refresh = createTask("profile.refresh");
|
|
94
|
+
void loadProfile().then(
|
|
95
|
+
(profile) => {
|
|
96
|
+
refresh.run(() => setProfile(profile));
|
|
97
|
+
refresh.finish();
|
|
98
|
+
},
|
|
99
|
+
(error) => refresh.fail(error),
|
|
100
|
+
);
|
|
101
|
+
};
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
The task takes its parent cause when the factory is invoked, so a later Fabric
|
|
105
|
+
press can become its exact cause. Factory-created tasks are rooted and cancelled
|
|
106
|
+
when the native root is disposed, but the caller owns earlier finish, failure,
|
|
107
|
+
replacement, and cancellation policy.
|
|
108
|
+
|
|
109
|
+
TurboModule and other platform subscriptions do not enter through Fabric's
|
|
110
|
+
node event router. `createCausalPlatformEventHandler` captures the current root
|
|
111
|
+
and optional named owner, then gives each delivery a bounded
|
|
112
|
+
`solid-native.event` operation with the declared priority:
|
|
113
|
+
|
|
114
|
+
```ts
|
|
115
|
+
const onAppState = createCausalPlatformEventHandler(
|
|
116
|
+
"platform.app-state.change",
|
|
117
|
+
setAppState,
|
|
118
|
+
);
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
The operation records its static name, source, priority, and coalescing policy,
|
|
122
|
+
never callback arguments. Synchronous Solid writes inherit the event cause;
|
|
123
|
+
returned promises follow the same settlement rule as Fabric handlers. Invalid
|
|
124
|
+
names and options fail during owner setup rather than after a native callback.
|
|
125
|
+
|
|
126
|
+
Some native APIs require a synchronous result even when application policy
|
|
127
|
+
settles later. `retainCausalPlatformEvent` preserves that result while exposing
|
|
128
|
+
one delivery-scoped controller for the later write:
|
|
129
|
+
|
|
130
|
+
```ts
|
|
131
|
+
const onBack = createCausalPlatformEventHandler(
|
|
132
|
+
"platform.hardware-back.press",
|
|
133
|
+
() =>
|
|
134
|
+
retainCausalPlatformEvent(true, (event) => {
|
|
135
|
+
void confirmNavigation().then(
|
|
136
|
+
(allowed) => {
|
|
137
|
+
try {
|
|
138
|
+
event.run(() => setNavigationAllowed(allowed));
|
|
139
|
+
event.finish();
|
|
140
|
+
} catch (error) {
|
|
141
|
+
event.fail(error);
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
(error) => event.fail(error),
|
|
145
|
+
);
|
|
146
|
+
}),
|
|
147
|
+
{ priority: "discrete" },
|
|
148
|
+
);
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
The native caller still receives `true` synchronously. Only writes inside
|
|
152
|
+
`event.run` inherit the delivery and its priority. The controller closes once,
|
|
153
|
+
records only an error class on failure, and is cancelled if its root is
|
|
154
|
+
disposed; no ambient context crosses the promise.
|
|
155
|
+
|
|
156
|
+
Fabric handlers that must defer their actual mutation use the parallel
|
|
157
|
+
`retainCausalNativeEvent`. The handler returns its retained envelope
|
|
158
|
+
synchronously; later `event.run` calls preserve the original Fabric event and
|
|
159
|
+
its scheduling priority until `finish`, `fail`, or root cancellation. Native
|
|
160
|
+
stack dismissal uses this boundary so an iOS interactive pop remains the cause
|
|
161
|
+
of the asynchronous history reconciliation instead of becoming an unowned
|
|
162
|
+
normal update.
|
|
163
|
+
|
|
164
|
+
Selected Solid subtrees can also opt into an owner-level causal boundary:
|
|
165
|
+
|
|
166
|
+
```tsx
|
|
167
|
+
<CausalOwner name="profile.screen">
|
|
168
|
+
<ProfileScreen />
|
|
169
|
+
</CausalOwner>
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
The boundary starts one `solid-native.owner` operation for that Solid lifetime.
|
|
173
|
+
Native commits caused inside the subtree link to it, while sibling work does
|
|
174
|
+
not. The boundary records only the validated static name; it does not inspect
|
|
175
|
+
signals, props, text, or reactive reads. Nested boundaries preserve their owner
|
|
176
|
+
ancestry through causal IDs.
|
|
177
|
+
|
|
178
|
+
Selected reactive output can be named more narrowly than its owning component:
|
|
179
|
+
|
|
180
|
+
```tsx
|
|
181
|
+
<CausalComputation name="profile.status.output">
|
|
182
|
+
<Text>{status()}</Text>
|
|
183
|
+
</CausalComputation>
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
The boundary carries a static annotation through Solid's universal renderer to
|
|
187
|
+
the native nodes it creates. Mutations are coalesced into one
|
|
188
|
+
`solid-native.computation` operation per pending commit, and the commit retains
|
|
189
|
+
the computation alongside any owner, event, or task causes. It does not observe
|
|
190
|
+
the signal dependency, status value, text, props, or reactive reads. Nested
|
|
191
|
+
computation boundaries retain causal ancestry. If Solid cleans up a conditional
|
|
192
|
+
boundary before removing its native children, those teardown mutations inherit
|
|
193
|
+
the nearest still-active parent boundary rather than reopening the finished
|
|
194
|
+
computation. Its duration covers the native output batch from the first host
|
|
195
|
+
mutation until transaction drain; it is not a measurement of the underlying
|
|
196
|
+
reactive computation's CPU time.
|
|
197
|
+
|
|
198
|
+
In a Solid development build, the same static identifier also names the
|
|
199
|
+
universal render effects created inside the boundary. Solid's attribution
|
|
200
|
+
engine can therefore report a chain such as named signal write → named memo →
|
|
201
|
+
`profile.status.output`, while Solid Native independently links
|
|
202
|
+
`profile.status.output` → host commit → Fabric mount/frame. The shared name is
|
|
203
|
+
a deterministic correlation key, not an exact per-rerun causal token; the two
|
|
204
|
+
channels intentionally retain different data and lifetimes.
|
|
205
|
+
|
|
206
|
+
Measurements dispatched through a node retain its active owner/computation in
|
|
207
|
+
addition to any synchronous native-event call-site cause. The geometry read
|
|
208
|
+
still crosses the existing flush and disposal barriers, while telemetry records
|
|
209
|
+
only sequencing metadata—not coordinates or dimensions.
|
|
210
|
+
|
|
211
|
+
Commands dispatched through a node capture its active owner/computation before
|
|
212
|
+
the renderer crosses the microtask boundary required to isolate native side
|
|
213
|
+
effects. The command operation cites that named Solid output, and its
|
|
214
|
+
command-only commit cites the command. Telemetry records the static command
|
|
215
|
+
name, never its arguments. Priority crosses the same boundary, so commands
|
|
216
|
+
requested during discrete native input remain user-blocking after async
|
|
217
|
+
dispatch; ordinary programmatic commands retain normal priority. A native
|
|
218
|
+
event and a node's owner/computation annotation are independent command causes:
|
|
219
|
+
when both exist, neither replaces the other.
|
|
220
|
+
|
|
221
|
+
Use `mount` for application startup; its returned disposer can be awaited.
|
|
222
|
+
Concurrent or later disposal calls return the same promise, so every caller
|
|
223
|
+
observes the actual surface-stop completion or the same teardown failure. The
|
|
224
|
+
standard `render` export exists for compiler compatibility.
|
|
225
|
+
|
|
226
|
+
The Fabric direct-shadow-node path is now physical-device-verified in the
|
|
227
|
+
runtime package, including JSI transactions, events, measurement, and teardown.
|
|
228
|
+
Broader native components and JavaScript-owned surface creation come next. No
|
|
229
|
+
Fabric or React types belong in this package.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { type RendererEffectOptions } from "@solidjs/universal";
|
|
2
|
+
import { type Element as SolidElement } from "solid-js";
|
|
3
|
+
import { type NativeApplication, type NativeCausalEventRetention, type NativeCausalPlatformEventOptions, type NativeCausalRetainedResult, type NativeCausalScope, type NativeNode, type NativeRootOptions } from "./native-root.js";
|
|
4
|
+
export { NativeNode, NativeRoot, type NativeApplication, type NativeCausalComputation, type NativeCausalComputationState, type NativeCausalEventRetention, type NativeCausalEventRetentionState, type NativeCausalPlatformEventOptions, type NativeCausalOwner, type NativeCausalOwnerState, type NativeCausalScope, type NativeCausalScopeState, type NativeCausalRetainedResult, type NativeEventHandler, type NativeNodeKind, type NativeRootOptions, type NativeRootTreeSnapshotOptions, type NativeSyntheticEvent, compareNativeNodeOrder, nativeNodeHandle, nativeNodeRoot, } from "./native-root.js";
|
|
5
|
+
export type { NativeHost, SolidNativeHost, } from "@solidnative-dev/host-contract";
|
|
6
|
+
export type { CausalTelemetry, TreeDebugSnapshot, } from "@solidnative-dev/observability";
|
|
7
|
+
export { Errored, For, Loading, Match, Repeat, Reveal, Show, Switch, createSignal, } from "solid-js";
|
|
8
|
+
/**
|
|
9
|
+
* Starts a bounded task operation and cancels it with the current Solid owner.
|
|
10
|
+
* Re-enter the returned scope around each synchronous reactive settlement.
|
|
11
|
+
*/
|
|
12
|
+
export declare function createCausalScope(name: string): NativeCausalScope;
|
|
13
|
+
export type NativeCausalScopeFactory = (name: string) => NativeCausalScope;
|
|
14
|
+
/** Captures the current native root for causal tasks started by later events. */
|
|
15
|
+
export declare function useNativeCausalScopeFactory(): NativeCausalScopeFactory;
|
|
16
|
+
/**
|
|
17
|
+
* Preserves a synchronous platform callback result while explicitly retaining
|
|
18
|
+
* that delivery for a bounded asynchronous settlement.
|
|
19
|
+
*/
|
|
20
|
+
export declare function retainCausalPlatformEvent<TResult>(result: TResult, retain: (event: NativeCausalEventRetention) => void): NativeCausalRetainedResult<TResult>;
|
|
21
|
+
/**
|
|
22
|
+
* Keeps one Fabric event causally active across an explicit asynchronous
|
|
23
|
+
* settlement. Calls to `event.run` preserve the original event's cause and
|
|
24
|
+
* priority; the retention is cancelled if its native root stops first.
|
|
25
|
+
*/
|
|
26
|
+
export declare function retainCausalNativeEvent<TResult>(result: TResult, retain: (event: NativeCausalEventRetention) => void): NativeCausalRetainedResult<TResult>;
|
|
27
|
+
/**
|
|
28
|
+
* Wraps one non-Fabric native subscription callback in a privacy-safe causal
|
|
29
|
+
* event. Synchronous Solid writes inherit its cause and commit priority; a
|
|
30
|
+
* returned promise follows the same settlement rule as a Fabric event.
|
|
31
|
+
*/
|
|
32
|
+
export declare function createCausalPlatformEventHandler<TArgs extends readonly unknown[], TResult>(name: string, handler: (...args: TArgs) => NativeCausalRetainedResult<TResult>, options?: NativeCausalPlatformEventOptions): (...args: TArgs) => TResult;
|
|
33
|
+
export declare function createCausalPlatformEventHandler<TArgs extends readonly unknown[], TResult>(name: string, handler: (...args: TArgs) => TResult, options?: NativeCausalPlatformEventOptions): (...args: TArgs) => TResult;
|
|
34
|
+
export interface CausalOwnerProps {
|
|
35
|
+
readonly name: string;
|
|
36
|
+
readonly children?: SolidElement;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Names one selected Solid owner subtree for privacy-safe causal inspection.
|
|
40
|
+
* Native mutations created beneath it link their commits to this owner.
|
|
41
|
+
*/
|
|
42
|
+
export declare function CausalOwner(props: CausalOwnerProps): SolidElement;
|
|
43
|
+
export interface CausalComputationProps {
|
|
44
|
+
readonly name: string;
|
|
45
|
+
readonly children?: SolidElement;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Names selected reactive native output without observing dependencies or
|
|
49
|
+
* values. Host mutations beneath the boundary link to a computation batch.
|
|
50
|
+
*/
|
|
51
|
+
export declare function CausalComputation(props: CausalComputationProps): SolidElement;
|
|
52
|
+
/**
|
|
53
|
+
* Creates a universal render effect carrying the active native-output name.
|
|
54
|
+
* Solid's development attribution can therefore use the same stable name as
|
|
55
|
+
* the renderer's value-free causal telemetry.
|
|
56
|
+
*/
|
|
57
|
+
export declare function effect<T>(compute: (previous?: T) => T, apply: (value: T, previous?: T) => void, options?: RendererEffectOptions): void;
|
|
58
|
+
/** Inserts reactive output while carrying an active causal computation name. */
|
|
59
|
+
export declare function insert<T>(parent: NativeNode, accessor: (() => T) | T, marker?: NativeNode | null, initial?: unknown, options?: RendererEffectOptions): NativeNode;
|
|
60
|
+
/**
|
|
61
|
+
* Applies component props through `@solidjs/universal`'s native spread helper,
|
|
62
|
+
* forwarding the active causal computation name for Solid 2 attribution.
|
|
63
|
+
*/
|
|
64
|
+
export declare function spread<T extends object>(node: NativeNode, props: T | (() => T) | (T | (() => T) | null | undefined)[] | null | undefined, skipChildren?: boolean, options?: RendererEffectOptions): void;
|
|
65
|
+
export declare const applyRef: (r: ((element: NativeNode) => void) | ((element: NativeNode) => void)[], element: NativeNode) => void, createComponent: <T>(Comp: (props: T) => NativeNode, props: T) => NativeNode, createElement: (tag: string, staticProps?: Record<string, unknown>) => NativeNode, createTextNode: (value: string) => NativeNode, insertNode: (parent: NativeNode, node: NativeNode, anchor?: NativeNode | undefined) => void, memo: <T>(fn: () => T, equal: boolean) => () => T, mergeProps: (...sources: unknown[]) => unknown, ref: (fn: () => ((element: NativeNode) => void) | ((element: NativeNode) => void)[], element: NativeNode) => void, setProp: <T>(node: NativeNode, name: string, value: T, prev?: T | undefined) => T;
|
|
66
|
+
export declare function render(code: () => unknown, container: NativeNode): () => void;
|
|
67
|
+
/** @internal Component facades use this to sequence platform-owned teardown. */
|
|
68
|
+
export declare function flushNativeNodeMount(node: NativeNode): Promise<void>;
|
|
69
|
+
/** @internal Component facades use this for platform lifecycle normalization. */
|
|
70
|
+
export declare function nativeNodePlatform(node: NativeNode): string;
|
|
71
|
+
/** @internal Component facades use this to release private detached trees. */
|
|
72
|
+
export declare function releaseDetachedNativeNode(node: NativeNode): void;
|
|
73
|
+
export declare function mount(code: () => unknown, host: import("@solidnative-dev/host-contract").NativeHost, options: NativeRootOptions): NativeApplication;
|
|
74
|
+
/**
|
|
75
|
+
* Mounts a root while retaining an asynchronous cleanup boundary for initial
|
|
76
|
+
* render failures. Native application bootstraps should prefer this form so a
|
|
77
|
+
* claimed platform surface cannot outlive a failed Solid owner graph.
|
|
78
|
+
*/
|
|
79
|
+
export declare function mountAsync(code: () => unknown, host: import("@solidnative-dev/host-contract").NativeHost, options: NativeRootOptions): Promise<NativeApplication>;
|
|
80
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import { createRenderer } from "@solidjs/universal";
|
|
2
|
+
import { OBSERVE, createComponent as solidCreateComponent, createContext, getOwner, onCleanup, useContext, } from "solid-js";
|
|
3
|
+
import { NativeRoot, assertNativeCausalName, createNativeRoot, createNativeRootAsync, createNativeCausalRetainedResult, createDetachedNativeSentinel, createDetachedNativeText, nativeNodeFirstChild, nativeNodeNextSibling, nativeNodeParent, compareNativeNodeOrder, nativeNodeRoot, runWithNativeNodeCausalContext, } from "./native-root.js";
|
|
4
|
+
export { NativeNode, NativeRoot, compareNativeNodeOrder, nativeNodeHandle, nativeNodeRoot, } from "./native-root.js";
|
|
5
|
+
export { Errored, For, Loading, Match, Repeat, Reveal, Show, Switch, createSignal, } from "solid-js";
|
|
6
|
+
const NativeRootContext = createContext();
|
|
7
|
+
const NativeCausalOwnerContext = createContext(null);
|
|
8
|
+
const NativeCausalComputationContext = createContext(null);
|
|
9
|
+
function currentRoot() {
|
|
10
|
+
const root = useContext(NativeRootContext);
|
|
11
|
+
return root;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Starts a bounded task operation and cancels it with the current Solid owner.
|
|
15
|
+
* Re-enter the returned scope around each synchronous reactive settlement.
|
|
16
|
+
*/
|
|
17
|
+
export function createCausalScope(name) {
|
|
18
|
+
const scope = currentRoot().createCausalScope(name);
|
|
19
|
+
onCleanup(() => scope.cancel());
|
|
20
|
+
return scope;
|
|
21
|
+
}
|
|
22
|
+
/** Captures the current native root for causal tasks started by later events. */
|
|
23
|
+
export function useNativeCausalScopeFactory() {
|
|
24
|
+
const root = currentRoot();
|
|
25
|
+
return (name) => root.createCausalScope(name);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Preserves a synchronous platform callback result while explicitly retaining
|
|
29
|
+
* that delivery for a bounded asynchronous settlement.
|
|
30
|
+
*/
|
|
31
|
+
export function retainCausalPlatformEvent(result, retain) {
|
|
32
|
+
return createNativeCausalRetainedResult(result, retain);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Keeps one Fabric event causally active across an explicit asynchronous
|
|
36
|
+
* settlement. Calls to `event.run` preserve the original event's cause and
|
|
37
|
+
* priority; the retention is cancelled if its native root stops first.
|
|
38
|
+
*/
|
|
39
|
+
export function retainCausalNativeEvent(result, retain) {
|
|
40
|
+
return createNativeCausalRetainedResult(result, retain);
|
|
41
|
+
}
|
|
42
|
+
export function createCausalPlatformEventHandler(name, handler, options = {}) {
|
|
43
|
+
if (typeof handler !== "function") {
|
|
44
|
+
throw new TypeError("Native causal event handler must be a function.");
|
|
45
|
+
}
|
|
46
|
+
assertNativeCausalName("event", name);
|
|
47
|
+
const priority = options.priority ?? "default";
|
|
48
|
+
if (priority !== "default" &&
|
|
49
|
+
priority !== "continuous" &&
|
|
50
|
+
priority !== "discrete") {
|
|
51
|
+
throw new TypeError("Native causal event priority must be default, continuous, or discrete.");
|
|
52
|
+
}
|
|
53
|
+
const coalescible = options.coalescible ?? false;
|
|
54
|
+
if (typeof coalescible !== "boolean") {
|
|
55
|
+
throw new TypeError("Native causal event coalescible must be a boolean.");
|
|
56
|
+
}
|
|
57
|
+
const normalizedOptions = Object.freeze({ coalescible, priority });
|
|
58
|
+
const root = currentRoot();
|
|
59
|
+
const owner = currentCausalOwner();
|
|
60
|
+
return (...args) => {
|
|
61
|
+
const invoke = () => root.runCausalPlatformEvent(name, normalizedOptions, () => handler(...args));
|
|
62
|
+
return owner === undefined ? invoke() : owner.run(invoke);
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
const CausalOwnerProvider = NativeCausalOwnerContext;
|
|
66
|
+
/**
|
|
67
|
+
* Names one selected Solid owner subtree for privacy-safe causal inspection.
|
|
68
|
+
* Native mutations created beneath it link their commits to this owner.
|
|
69
|
+
*/
|
|
70
|
+
export function CausalOwner(props) {
|
|
71
|
+
const root = currentRoot();
|
|
72
|
+
const parent = useContext(NativeCausalOwnerContext);
|
|
73
|
+
const owner = parent === null
|
|
74
|
+
? root.createCausalOwner(props.name)
|
|
75
|
+
: parent.run(() => root.createCausalOwner(props.name));
|
|
76
|
+
onCleanup(() => owner.finish());
|
|
77
|
+
return solidCreateComponent(CausalOwnerProvider, {
|
|
78
|
+
value: owner,
|
|
79
|
+
get children() {
|
|
80
|
+
return props.children;
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function currentCausalOwner() {
|
|
85
|
+
if (getOwner() === null)
|
|
86
|
+
return undefined;
|
|
87
|
+
return useContext(NativeCausalOwnerContext) ?? undefined;
|
|
88
|
+
}
|
|
89
|
+
const CausalComputationProvider = NativeCausalComputationContext;
|
|
90
|
+
/**
|
|
91
|
+
* Names selected reactive native output without observing dependencies or
|
|
92
|
+
* values. Host mutations beneath the boundary link to a computation batch.
|
|
93
|
+
*/
|
|
94
|
+
export function CausalComputation(props) {
|
|
95
|
+
const root = currentRoot();
|
|
96
|
+
const parent = useContext(NativeCausalComputationContext) ?? undefined;
|
|
97
|
+
const computation = root.createCausalComputation(props.name, parent);
|
|
98
|
+
onCleanup(() => computation.finish());
|
|
99
|
+
return solidCreateComponent(CausalComputationProvider, {
|
|
100
|
+
value: computation,
|
|
101
|
+
get children() {
|
|
102
|
+
return props.children;
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
function currentCausalComputation() {
|
|
107
|
+
if (getOwner() === null)
|
|
108
|
+
return undefined;
|
|
109
|
+
return useContext(NativeCausalComputationContext) ?? undefined;
|
|
110
|
+
}
|
|
111
|
+
function runWithCausalAnnotations(owner, computation, callback) {
|
|
112
|
+
const run = () => computation === undefined ? callback() : computation.run(callback);
|
|
113
|
+
return owner === undefined ? run() : owner.run(run);
|
|
114
|
+
}
|
|
115
|
+
const universal = createRenderer({
|
|
116
|
+
createElement(component, staticProps) {
|
|
117
|
+
const root = currentRoot();
|
|
118
|
+
const causalOwner = currentCausalOwner();
|
|
119
|
+
const causalComputation = currentCausalComputation();
|
|
120
|
+
const create = () => root.createElement(component, staticProps, causalOwner, causalComputation);
|
|
121
|
+
const element = runWithCausalAnnotations(causalOwner, causalComputation, create);
|
|
122
|
+
if (getOwner() !== null) {
|
|
123
|
+
onCleanup(() => root.reclaimDetachedElementOnOwnerCleanup(element));
|
|
124
|
+
}
|
|
125
|
+
return element;
|
|
126
|
+
},
|
|
127
|
+
createTextNode(value) {
|
|
128
|
+
return createDetachedNativeText(String(value));
|
|
129
|
+
},
|
|
130
|
+
createSentinel() {
|
|
131
|
+
return createDetachedNativeSentinel();
|
|
132
|
+
},
|
|
133
|
+
replaceText(node, value) {
|
|
134
|
+
runWithNativeNodeCausalContext(node, undefined, () => nativeNodeRoot(node).replaceText(node, String(value)));
|
|
135
|
+
},
|
|
136
|
+
isTextNode(node) {
|
|
137
|
+
return node.kind === "text";
|
|
138
|
+
},
|
|
139
|
+
setProperty(node, name, value) {
|
|
140
|
+
runWithNativeNodeCausalContext(node, undefined, () => nativeNodeRoot(node).setProperty(node, name, value));
|
|
141
|
+
},
|
|
142
|
+
insertNode(parent, node, anchor) {
|
|
143
|
+
runWithNativeNodeCausalContext(node, parent, () => nativeNodeRoot(parent).insertNode(parent, node, anchor));
|
|
144
|
+
},
|
|
145
|
+
removeNode(parent, node) {
|
|
146
|
+
runWithNativeNodeCausalContext(node, parent, () => nativeNodeRoot(parent).removeNode(parent, node));
|
|
147
|
+
},
|
|
148
|
+
cleanupNodes(parent, nodes) {
|
|
149
|
+
const root = nativeNodeRoot(parent);
|
|
150
|
+
for (const node of nodes) {
|
|
151
|
+
runWithNativeNodeCausalContext(node, parent, () => {
|
|
152
|
+
if (nativeNodeParent(node) === parent)
|
|
153
|
+
root.removeNode(parent, node);
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
getParentNode: nativeNodeParent,
|
|
158
|
+
getFirstChild: nativeNodeFirstChild,
|
|
159
|
+
getNextSibling: nativeNodeNextSibling,
|
|
160
|
+
});
|
|
161
|
+
function currentCausalEffectOptions() {
|
|
162
|
+
if (OBSERVE === undefined)
|
|
163
|
+
return undefined;
|
|
164
|
+
const computation = currentCausalComputation();
|
|
165
|
+
return computation === undefined ? undefined : { name: computation.name };
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Creates a universal render effect carrying the active native-output name.
|
|
169
|
+
* Solid's development attribution can therefore use the same stable name as
|
|
170
|
+
* the renderer's value-free causal telemetry.
|
|
171
|
+
*/
|
|
172
|
+
export function effect(compute, apply, options) {
|
|
173
|
+
universal.effect(compute, apply, options ?? currentCausalEffectOptions());
|
|
174
|
+
}
|
|
175
|
+
/** Inserts reactive output while carrying an active causal computation name. */
|
|
176
|
+
export function insert(parent, accessor, marker, initial, options) {
|
|
177
|
+
return universal.insert(parent, accessor, marker, initial, options ?? currentCausalEffectOptions());
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Applies component props through `@solidjs/universal`'s native spread helper,
|
|
181
|
+
* forwarding the active causal computation name for Solid 2 attribution.
|
|
182
|
+
*/
|
|
183
|
+
export function spread(node, props, skipChildren = false, options) {
|
|
184
|
+
universal.spread(node, props, skipChildren, options ?? currentCausalEffectOptions());
|
|
185
|
+
}
|
|
186
|
+
export const { applyRef, createComponent, createElement, createTextNode, insertNode, memo, mergeProps, ref, setProp, } = universal;
|
|
187
|
+
const RootProvider = NativeRootContext;
|
|
188
|
+
function renderIntoRoot(code, root) {
|
|
189
|
+
let setupFailed = false;
|
|
190
|
+
let setupError;
|
|
191
|
+
try {
|
|
192
|
+
return universal.render(() => solidCreateComponent(RootProvider, {
|
|
193
|
+
value: root,
|
|
194
|
+
get children() {
|
|
195
|
+
try {
|
|
196
|
+
return code();
|
|
197
|
+
}
|
|
198
|
+
catch (error) {
|
|
199
|
+
setupFailed = true;
|
|
200
|
+
setupError = error;
|
|
201
|
+
throw error;
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
}), root.container);
|
|
205
|
+
}
|
|
206
|
+
catch (error) {
|
|
207
|
+
if (!setupFailed ||
|
|
208
|
+
error === setupError ||
|
|
209
|
+
(error instanceof Error && error.cause === setupError)) {
|
|
210
|
+
throw error;
|
|
211
|
+
}
|
|
212
|
+
// Universal's rollback can replace the original setup error if a reactive
|
|
213
|
+
// owner cleanup throws while unwinding. Preserve the setup failure.
|
|
214
|
+
throw setupError;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
function createNativeApplication(root, disposeSolid) {
|
|
218
|
+
let disposal;
|
|
219
|
+
return {
|
|
220
|
+
root,
|
|
221
|
+
dispose() {
|
|
222
|
+
disposal ??= (async () => {
|
|
223
|
+
let solidCleanupFailed = false;
|
|
224
|
+
let solidCleanupError;
|
|
225
|
+
try {
|
|
226
|
+
disposeSolid();
|
|
227
|
+
}
|
|
228
|
+
catch (error) {
|
|
229
|
+
solidCleanupFailed = true;
|
|
230
|
+
solidCleanupError = error;
|
|
231
|
+
}
|
|
232
|
+
try {
|
|
233
|
+
await root.dispose();
|
|
234
|
+
}
|
|
235
|
+
catch (nativeCleanupError) {
|
|
236
|
+
if (solidCleanupFailed) {
|
|
237
|
+
// A rejected native operation can be observed once while Solid
|
|
238
|
+
// disposes its owner and again while NativeRoot drains the same
|
|
239
|
+
// failed commit. Preserve that operation's established identity
|
|
240
|
+
// instead of presenting one failure as two independent causes.
|
|
241
|
+
if (solidCleanupError === nativeCleanupError) {
|
|
242
|
+
throw nativeCleanupError;
|
|
243
|
+
}
|
|
244
|
+
throw new AggregateError([solidCleanupError, nativeCleanupError], "Solid owner cleanup and native surface teardown both failed.");
|
|
245
|
+
}
|
|
246
|
+
throw nativeCleanupError;
|
|
247
|
+
}
|
|
248
|
+
if (solidCleanupFailed)
|
|
249
|
+
throw solidCleanupError;
|
|
250
|
+
})();
|
|
251
|
+
return disposal;
|
|
252
|
+
},
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
export function render(code, container) {
|
|
256
|
+
const root = nativeNodeRoot(container);
|
|
257
|
+
const disposeSolid = renderIntoRoot(code, root);
|
|
258
|
+
return () => {
|
|
259
|
+
disposeSolid();
|
|
260
|
+
void root.dispose();
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
/** @internal Component facades use this to sequence platform-owned teardown. */
|
|
264
|
+
export async function flushNativeNodeMount(node) {
|
|
265
|
+
// A component may request this barrier from an effect apply phase. Let the
|
|
266
|
+
// active Solid drain finish before NativeRoot flushes reactive work again.
|
|
267
|
+
await Promise.resolve();
|
|
268
|
+
await nativeNodeRoot(node).flushMounted();
|
|
269
|
+
}
|
|
270
|
+
/** @internal Component facades use this for platform lifecycle normalization. */
|
|
271
|
+
export function nativeNodePlatform(node) {
|
|
272
|
+
return nativeNodeRoot(node).host.platform;
|
|
273
|
+
}
|
|
274
|
+
/** @internal Component facades use this to release private detached trees. */
|
|
275
|
+
export function releaseDetachedNativeNode(node) {
|
|
276
|
+
nativeNodeRoot(node).releaseDetachedNode(node);
|
|
277
|
+
}
|
|
278
|
+
export function mount(code, host, options) {
|
|
279
|
+
const root = createNativeRoot(host, options);
|
|
280
|
+
try {
|
|
281
|
+
const disposeSolid = renderIntoRoot(code, root);
|
|
282
|
+
return createNativeApplication(root, disposeSolid);
|
|
283
|
+
}
|
|
284
|
+
catch (mountError) {
|
|
285
|
+
// Preserve the synchronous API and original render failure, but do not
|
|
286
|
+
// strand a surface that was already acquired. Callers that need to await
|
|
287
|
+
// rollback should use mountAsync.
|
|
288
|
+
void root.dispose().catch(() => undefined);
|
|
289
|
+
throw mountError;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Mounts a root while retaining an asynchronous cleanup boundary for initial
|
|
294
|
+
* render failures. Native application bootstraps should prefer this form so a
|
|
295
|
+
* claimed platform surface cannot outlive a failed Solid owner graph.
|
|
296
|
+
*/
|
|
297
|
+
export async function mountAsync(code, host, options) {
|
|
298
|
+
const root = await createNativeRootAsync(host, options);
|
|
299
|
+
let disposeSolid;
|
|
300
|
+
try {
|
|
301
|
+
disposeSolid = renderIntoRoot(code, root);
|
|
302
|
+
}
|
|
303
|
+
catch (mountError) {
|
|
304
|
+
try {
|
|
305
|
+
await root.dispose();
|
|
306
|
+
}
|
|
307
|
+
catch (nativeCleanupError) {
|
|
308
|
+
if (mountError === nativeCleanupError)
|
|
309
|
+
throw mountError;
|
|
310
|
+
throw new AggregateError([mountError, nativeCleanupError], "Solid application mount and native surface cleanup both failed.");
|
|
311
|
+
}
|
|
312
|
+
throw mountError;
|
|
313
|
+
}
|
|
314
|
+
return createNativeApplication(root, disposeSolid);
|
|
315
|
+
}
|
|
316
|
+
//# sourceMappingURL=index.js.map
|