@solidnative-dev/host-contract 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 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,42 @@
1
- # Temporary Holding Version
1
+ # `@solidnative-dev/host-contract`
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ This package contains the backend-neutral `NativeHost` type model between any
4
+ framework renderer and a native host. It is intentionally private and
5
+ provisional; `SolidNativeHost` remains only as a deprecated compatibility alias.
6
+
7
+ The contract models:
8
+
9
+ - Multiple native surfaces
10
+ - Opaque node handles
11
+ - Ordered and prioritized commit transactions
12
+ - Optional causal context and revision-aware commit-mount/frame lifecycle events
13
+ - Element/text creation, updates, insertion, removal, deletion, and commands
14
+ - Native events and measurement
15
+ - Backend capabilities and component descriptors
16
+
17
+ The React Native/Fabric adapter and in-memory test backend should both implement this contract. Any type that requires importing React, Fiber, or Fabric internals belongs in a backend package instead.
18
+
19
+ Host capability and component validation also belongs here rather than in a
20
+ framework runtime. Adapters can reject an incompatible backend before creating
21
+ a native surface:
22
+
23
+ ```ts
24
+ import {
25
+ assertCompatibleHost,
26
+ inspectHost,
27
+ } from "@solidnative-dev/host-contract";
28
+
29
+ const report = inspectHost(host, {
30
+ components: ["RootView", "Text"],
31
+ capabilities: ["bubblingEvents", "commitMountEvents"],
32
+ });
33
+
34
+ if (report.compatible) {
35
+ const fingerprint = assertCompatibleHost(host);
36
+ }
37
+ ```
38
+
39
+ `inspectHost` returns a deterministic, portable fingerprint and issue list.
40
+ `assertCompatibleHost` returns that fingerprint or throws a structured
41
+ `IncompatibleHostError`. The Solid runtime re-exports the same functions for
42
+ source compatibility and applies them before mounting a Solid root.
@@ -0,0 +1,196 @@
1
+ export declare const HOST_CONTRACT_VERSION: 1;
2
+ export type SurfaceId = number;
3
+ export type NodeHandle = number;
4
+ export type CommitSequence = number;
5
+ export type HostPrimitive = string | number | boolean | null;
6
+ export type HostValue = HostPrimitive | readonly HostValue[] | {
7
+ readonly [key: string]: HostValue;
8
+ };
9
+ export type HostProps = Readonly<Record<string, HostValue>>;
10
+ export type CommitPriority = "immediate" | "user-blocking" | "normal" | "background";
11
+ export declare const HOST_CAUSAL_OPERATION_ID_MAX_LENGTH = 128;
12
+ export interface HostCausalContext {
13
+ /** Opaque, process-local correlation ID. It must not contain user data. */
14
+ readonly operationId: string;
15
+ }
16
+ export interface SurfaceOptions {
17
+ readonly name: string;
18
+ readonly initialProps?: HostProps;
19
+ }
20
+ export interface HostCapabilities {
21
+ readonly contractVersion: typeof HOST_CONTRACT_VERSION;
22
+ readonly synchronousMeasurement: boolean;
23
+ readonly bubblingEvents: boolean;
24
+ readonly nativeScreens: boolean;
25
+ readonly uiWorklets: boolean;
26
+ /**
27
+ * The host exposes renderer-visible reusable node identities. Platform-owned
28
+ * pooling beneath ordinary create/delete mutations does not set this flag.
29
+ */
30
+ readonly viewRecycling: boolean;
31
+ readonly commitMountEvents: boolean;
32
+ }
33
+ export type HostMutation = {
34
+ readonly type: "create-element";
35
+ readonly node: NodeHandle;
36
+ readonly component: string;
37
+ readonly props: HostProps;
38
+ } | {
39
+ readonly type: "create-text";
40
+ readonly node: NodeHandle;
41
+ readonly text: string;
42
+ } | {
43
+ readonly type: "update-props";
44
+ readonly node: NodeHandle;
45
+ readonly props: HostProps;
46
+ readonly removedProps: readonly string[];
47
+ } | {
48
+ readonly type: "update-text";
49
+ readonly node: NodeHandle;
50
+ readonly text: string;
51
+ } | {
52
+ readonly type: "update-event-listeners";
53
+ readonly node: NodeHandle;
54
+ /** Sorted, unique semantic event names currently observed by JavaScript. */
55
+ readonly events: readonly string[];
56
+ } | {
57
+ readonly type: "insert-child";
58
+ readonly parent: NodeHandle;
59
+ readonly child: NodeHandle;
60
+ readonly before?: NodeHandle;
61
+ } | {
62
+ readonly type: "remove-child";
63
+ readonly parent: NodeHandle;
64
+ readonly child: NodeHandle;
65
+ } | {
66
+ readonly type: "delete-node";
67
+ readonly node: NodeHandle;
68
+ } | {
69
+ readonly type: "command";
70
+ readonly node: NodeHandle;
71
+ readonly command: string;
72
+ readonly args: readonly HostValue[];
73
+ };
74
+ export interface HostCommit {
75
+ readonly surface: SurfaceId;
76
+ readonly sequence: CommitSequence;
77
+ readonly priority: CommitPriority;
78
+ readonly mutations: readonly HostMutation[];
79
+ readonly causalContext?: HostCausalContext;
80
+ }
81
+ export interface HostCommitResult {
82
+ readonly surface: SurfaceId;
83
+ readonly sequence: CommitSequence;
84
+ /** True once the transaction has entered the backend's mounting pipeline. */
85
+ readonly mounted: boolean;
86
+ /** Exact backend revision when this commit produced one. */
87
+ readonly hostRevision?: number;
88
+ }
89
+ export interface HostCommitMountedEvent {
90
+ readonly type: "commit-mounted";
91
+ readonly surface: SurfaceId;
92
+ readonly sequence: CommitSequence;
93
+ readonly hostRevision: number;
94
+ /** Milliseconds since the Unix epoch at backend commit ingress. */
95
+ readonly commitStartedAt: number;
96
+ /** Milliseconds since the Unix epoch when the platform mount completed. */
97
+ readonly mountedAt: number;
98
+ /** Monotonic elapsed milliseconds from commit ingress through mount. */
99
+ readonly mountLatency: number;
100
+ readonly causalContext?: HostCausalContext;
101
+ }
102
+ /**
103
+ * The first platform display callback observed after a mounted revision.
104
+ * This is a next-vsync boundary, not proof that the compositor presented
105
+ * particular pixels on screen.
106
+ */
107
+ export interface HostCommitFrameEvent {
108
+ readonly type: "commit-frame";
109
+ readonly surface: SurfaceId;
110
+ readonly sequence: CommitSequence;
111
+ readonly hostRevision: number;
112
+ /** Milliseconds since the Unix epoch when the platform mount completed. */
113
+ readonly mountedAt: number;
114
+ /** Milliseconds since the Unix epoch at the next platform frame callback. */
115
+ readonly frameStartedAt: number;
116
+ /** Monotonic elapsed milliseconds from commit ingress to the frame callback. */
117
+ readonly frameLatency: number;
118
+ /** Monotonic elapsed milliseconds from mount completion to the frame callback. */
119
+ readonly mountToFrameLatency: number;
120
+ readonly causalContext?: HostCausalContext;
121
+ }
122
+ export type HostLifecycleEvent = HostCommitMountedEvent | HostCommitFrameEvent;
123
+ export type HostLifecycleListener = (event: HostLifecycleEvent) => void;
124
+ export type NativeEventPriority = "discrete" | "continuous" | "default";
125
+ export interface NativeEvent {
126
+ readonly surface: SurfaceId;
127
+ readonly target: NodeHandle;
128
+ readonly observedSequence: CommitSequence;
129
+ readonly name: string;
130
+ readonly timestamp: number;
131
+ readonly priority: NativeEventPriority;
132
+ readonly bubbles: boolean;
133
+ readonly coalescible: boolean;
134
+ readonly payload: HostValue;
135
+ }
136
+ export interface NativeMeasurement {
137
+ readonly x: number;
138
+ readonly y: number;
139
+ readonly width: number;
140
+ readonly height: number;
141
+ readonly pageX: number;
142
+ readonly pageY: number;
143
+ readonly observedSequence: CommitSequence;
144
+ }
145
+ export interface NativeComponentDescriptor {
146
+ readonly name: string;
147
+ readonly acceptsRawText: boolean;
148
+ readonly bubblingEvents: readonly string[];
149
+ readonly directEvents: readonly string[];
150
+ readonly commands: Readonly<Record<string, readonly string[]>>;
151
+ }
152
+ export type NativeEventListener = (event: NativeEvent) => void;
153
+ export interface NativeHost {
154
+ /** Stable platform identifier used by portable facades with native lifecycle differences. */
155
+ readonly platform: string;
156
+ readonly capabilities: HostCapabilities;
157
+ createSurface(options: SurfaceOptions): SurfaceId;
158
+ destroySurface(surface: SurfaceId): void | Promise<void>;
159
+ allocateNode(surface: SurfaceId): NodeHandle;
160
+ commit(transaction: HostCommit): HostCommitResult | Promise<HostCommitResult>;
161
+ measure(surface: SurfaceId, node: NodeHandle, afterSequence?: CommitSequence): NativeMeasurement | Promise<NativeMeasurement>;
162
+ subscribe(listener: NativeEventListener): () => void;
163
+ subscribeLifecycle?(listener: HostLifecycleListener): () => void;
164
+ getComponentDescriptor(name: string): NativeComponentDescriptor | undefined;
165
+ }
166
+ export type HostCapabilityName = Exclude<keyof HostCapabilities, "contractVersion">;
167
+ export interface HostRequirements {
168
+ readonly components?: readonly string[];
169
+ readonly capabilities?: readonly HostCapabilityName[];
170
+ }
171
+ export interface NativeHostFingerprint {
172
+ readonly contractVersion: number;
173
+ readonly platform: string;
174
+ readonly capabilities: HostCapabilities;
175
+ readonly availableComponents: readonly string[];
176
+ }
177
+ /** @deprecated Use the framework-neutral `NativeHostFingerprint` name. */
178
+ export type RuntimeFingerprint = NativeHostFingerprint;
179
+ export interface HostValidationReport {
180
+ readonly compatible: boolean;
181
+ readonly issues: readonly string[];
182
+ readonly fingerprint: NativeHostFingerprint;
183
+ }
184
+ export declare class IncompatibleHostError extends Error {
185
+ readonly report: HostValidationReport;
186
+ constructor(report: HostValidationReport);
187
+ }
188
+ /**
189
+ * Inspects a host without starting a surface so framework adapters can fail
190
+ * before allocating native application state.
191
+ */
192
+ export declare function inspectHost(host: NativeHost, requirements?: HostRequirements): HostValidationReport;
193
+ export declare function assertCompatibleHost(host: NativeHost, requirements?: HostRequirements): NativeHostFingerprint;
194
+ /** @deprecated Use the framework-neutral `NativeHost` name. */
195
+ export type SolidNativeHost = NativeHost;
196
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,EAAG,CAAU,CAAC;AAEhD,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAC/B,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAChC,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC;AAEpC,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAC7D,MAAM,MAAM,SAAS,GACnB,aAAa,GAAG,SAAS,SAAS,EAAE,GAAG;IAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAE/E,MAAM,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;AAE5D,MAAM,MAAM,cAAc,GACxB,WAAW,GAAG,eAAe,GAAG,QAAQ,GAAG,YAAY,CAAC;AAE1D,eAAO,MAAM,mCAAmC,MAAM,CAAC;AAEvD,MAAM,WAAW,iBAAiB;IAChC,2EAA2E;IAC3E,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,CAAC;CACnC;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,eAAe,EAAE,OAAO,qBAAqB,CAAC;IACvD,QAAQ,CAAC,sBAAsB,EAAE,OAAO,CAAC;IACzC,QAAQ,CAAC,cAAc,EAAE,OA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,oBAAoB;CAKzC;AAED;;;GAGG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,UAAU,EAChB,YAAY,GAAE,gBAAqB,GAClC,oBAAoB,CAuCtB;AAED,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,UAAU,EAChB,YAAY,GAAE,gBAAqB,GAClC,qBAAqB,CAIvB;AAED,+DAA+D;AAC/D,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,54 @@
1
+ export const HOST_CONTRACT_VERSION = 1;
2
+ export const HOST_CAUSAL_OPERATION_ID_MAX_LENGTH = 128;
3
+ export class IncompatibleHostError extends Error {
4
+ report;
5
+ constructor(report) {
6
+ super(`Incompatible native host: ${report.issues.join(" ")}`);
7
+ this.name = "IncompatibleHostError";
8
+ this.report = report;
9
+ }
10
+ }
11
+ /**
12
+ * Inspects a host without starting a surface so framework adapters can fail
13
+ * before allocating native application state.
14
+ */
15
+ export function inspectHost(host, requirements = {}) {
16
+ const requestedComponents = [
17
+ ...new Set(requirements.components ?? []),
18
+ ].sort();
19
+ const availableComponents = requestedComponents.filter((component) => host.getComponentDescriptor(component) !== undefined);
20
+ const issues = [];
21
+ if (typeof host.platform !== "string" || host.platform.length === 0) {
22
+ issues.push("The host platform identifier is unavailable.");
23
+ }
24
+ if (host.capabilities.contractVersion !== HOST_CONTRACT_VERSION) {
25
+ issues.push(`Expected host contract ${HOST_CONTRACT_VERSION}, received ${String(host.capabilities.contractVersion)}.`);
26
+ }
27
+ for (const capability of requirements.capabilities ?? []) {
28
+ if (!host.capabilities[capability]) {
29
+ issues.push(`Required capability ${capability} is unavailable.`);
30
+ }
31
+ }
32
+ for (const component of requestedComponents) {
33
+ if (!availableComponents.includes(component)) {
34
+ issues.push(`Required native component ${component} is unavailable.`);
35
+ }
36
+ }
37
+ return {
38
+ compatible: issues.length === 0,
39
+ issues,
40
+ fingerprint: {
41
+ contractVersion: host.capabilities.contractVersion,
42
+ platform: host.platform,
43
+ capabilities: { ...host.capabilities },
44
+ availableComponents,
45
+ },
46
+ };
47
+ }
48
+ export function assertCompatibleHost(host, requirements = {}) {
49
+ const report = inspectHost(host, requirements);
50
+ if (!report.compatible)
51
+ throw new IncompatibleHostError(report);
52
+ return report.fingerprint;
53
+ }
54
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAU,CAAC;AAehD,MAAM,CAAC,MAAM,mCAAmC,GAAG,GAAG,CAAC;AAuNvD,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IACrC,MAAM,CAAuB;IAEtC,YAAY,MAA4B;QACtC,KAAK,CAAC,6BAA6B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC9D,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;QACpC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CACzB,IAAgB,EAChB,eAAiC,EAAE;IAEnC,MAAM,mBAAmB,GAAG;QAC1B,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,UAAU,IAAI,EAAE,CAAC;KAC1C,CAAC,IAAI,EAAE,CAAC;IACT,MAAM,mBAAmB,GAAG,mBAAmB,CAAC,MAAM,CACpD,CAAC,SAAS,EAAE,EAAE,CAAC,IAAI,CAAC,sBAAsB,CAAC,SAAS,CAAC,KAAK,SAAS,CACpE,CAAC;IACF,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,IAAI,OAAO,IAAI,CAAC,QAAQ,KAAK,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACpE,MAAM,CAAC,IAAI,CAAC,8CAA8C,CAAC,CAAC;IAC9D,CAAC;IAED,IAAI,IAAI,C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.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0-beta.0",
4
+ "type": "module",
5
+ "description": "Provisional backend-neutral host contract for Solid Native.",
6
+ "license": "MIT",
7
+ "homepage": "https://solidnative.dev",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/solid-native/solid-native.git",
11
+ "directory": "packages/host-contract"
12
+ },
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
16
+ "engines": {
17
+ "node": "^22.13.0 || ^24.3.0 || >=26.0.0"
18
+ },
19
+ "exports": {
20
+ ".": {
21
+ "types": "./dist/index.d.ts",
22
+ "default": "./dist/index.js"
23
+ }
24
+ },
25
+ "files": [
26
+ "dist"
27
+ ],
28
+ "scripts": {
29
+ "build": "tsc -p tsconfig.json",
30
+ "check": "tsc -p tsconfig.json --noEmit",
31
+ "test": "pnpm build && node --test test/*.test.mjs"
32
+ }
6
33
  }