@nativedesktop/react 0.1.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.
Files changed (35) hide show
  1. package/dist/generated/rpc.js +13 -0
  2. package/dist/index.js +2089 -0
  3. package/dist/jsx-dev-runtime.js +6 -0
  4. package/dist/jsx-runtime.js +20 -0
  5. package/dist/packages/react/src/css-classes-validate.d.ts +3 -0
  6. package/dist/packages/react/src/dev-react.d.ts +23 -0
  7. package/dist/packages/react/src/dialogs.d.ts +54 -0
  8. package/dist/packages/react/src/errors.d.ts +55 -0
  9. package/dist/packages/react/src/generated/intrinsics.d.ts +1360 -0
  10. package/dist/packages/react/src/generated/protocol.d.ts +140 -0
  11. package/dist/packages/react/src/generated/rpc.d.ts +299 -0
  12. package/dist/packages/react/src/generated/schema-meta.d.ts +29 -0
  13. package/dist/packages/react/src/generated/widget-types.d.ts +2 -0
  14. package/dist/packages/react/src/hmr.d.ts +53 -0
  15. package/dist/packages/react/src/hooks.d.ts +4 -0
  16. package/dist/packages/react/src/host-config.d.ts +72 -0
  17. package/dist/packages/react/src/ids.d.ts +4 -0
  18. package/dist/packages/react/src/index.d.ts +26 -0
  19. package/dist/packages/react/src/jsx-dev-runtime.d.ts +2 -0
  20. package/dist/packages/react/src/jsx-runtime.d.ts +2 -0
  21. package/dist/packages/react/src/metrics.d.ts +12 -0
  22. package/dist/packages/react/src/native-component.d.ts +23 -0
  23. package/dist/packages/react/src/ops.d.ts +20 -0
  24. package/dist/packages/react/src/paths.d.ts +4 -0
  25. package/dist/packages/react/src/platform.d.ts +45 -0
  26. package/dist/packages/react/src/renderer.d.ts +12 -0
  27. package/dist/packages/react/src/shell.d.ts +6 -0
  28. package/dist/packages/react/src/store.d.ts +61 -0
  29. package/dist/packages/react/src/style-validate.d.ts +3 -0
  30. package/dist/packages/react/src/system.d.ts +166 -0
  31. package/dist/packages/react/src/toast.d.ts +19 -0
  32. package/dist/packages/react/src/webview.d.ts +5 -0
  33. package/dist/runtime/ndp-binary.d.ts +42 -0
  34. package/dist/runtime/ndp.d.ts +38 -0
  35. package/package.json +56 -0
@@ -0,0 +1,140 @@
1
+ export declare const NDP_VERSION = 1;
2
+ export type WidgetName = "Window" | "Box" | "Label" | "Button" | "TextInput" | "TextArea" | "Checkbox" | "Radio" | "Select" | "Slider" | "ProgressBar" | "Image" | "ScrollView" | "Separator" | "Spinner" | "TabView" | "Grid" | "ListView" | "WebView" | "NativeView" | "SplitView" | "HeaderBar" | "ToolbarView" | "SearchInput" | "SourceList" | "SourceTree" | "Menubar" | "Menu" | "MenuItem" | "SettingsGroup" | "Row" | "SwitchRow" | "Clamp" | "Switch" | "ToggleButton" | "SegmentedControl" | "NumberInput" | "LinkButton" | "LevelIndicator" | "ColorPicker" | "Banner" | "MenuButton" | "SplitButton" | "Popover" | "Expander" | "StatusPage" | "ToastOverlay" | "DatePicker" | "Table" | "TreeView" | "FontPicker" | "Video" | "TrayItem" | "ShareButton" | "Terminal" | "Paned" | "CommandPalette";
3
+ /** Child runtime identity, carried inside the hello frame. */
4
+ export interface Runtime {
5
+ name: string;
6
+ version: string;
7
+ }
8
+ /** Typed event payload. Exactly one field is set per event name (see widgets.json events[].payload): changed/activate/navigate/titleChanged -> text, toggled/loadingChanged/backAvailable/forwardAvailable -> checked, valueChanged -> value, selectionChanged -> index, clicked -> none, styleError -> key (the offending style key, M5c-D7), positionChanged -> position (Paned's 0..1 divider fraction, a dedicated field rather than reusing `value` — app-panes-and-tabs codes against the literal name `position`). Serialized with emit_null_optional_fields=false, so clicked still wires as "payload":{} — byte-compatible with M4. */
9
+ export interface EventPayload {
10
+ text?: string;
11
+ checked?: boolean;
12
+ value?: number;
13
+ index?: number;
14
+ key?: string;
15
+ nativeName?: string;
16
+ data?: unknown;
17
+ position?: number;
18
+ }
19
+ export type Op = {
20
+ op: "create";
21
+ id: number;
22
+ widget: WidgetName;
23
+ props: Record<string, unknown>;
24
+ } | {
25
+ op: "append";
26
+ parent: number;
27
+ child: number;
28
+ } | {
29
+ op: "insertBefore";
30
+ parent: number;
31
+ child: number;
32
+ before: number | null;
33
+ } | {
34
+ op: "remove";
35
+ id: number;
36
+ } | {
37
+ op: "setText";
38
+ id: number;
39
+ text: string;
40
+ } | {
41
+ op: "update";
42
+ id: number;
43
+ props: Record<string, unknown>;
44
+ } | {
45
+ op: "hide";
46
+ id: number;
47
+ } | {
48
+ op: "unhide";
49
+ id: number;
50
+ };
51
+ export interface HelloMsg {
52
+ type: "hello";
53
+ ndpVersion: number;
54
+ runtime: Runtime;
55
+ }
56
+ /** Handshake reply. `encodings` lists CommitBatch encodings the host accepts, host-preference order (ndp-binary spec §2); the runtime picks the first one it supports. `backend` names the host's active widget backend ("gtk" | "appkit") — the authoritative source for `Platform.backend`, since the OS alone can't distinguish it (GTK runs on macOS too). `hostWidgets`/`hostCommands` are the host build's capability manifest: every intrinsic it knows, and every "<intrinsic>.<command>" it dispatches — the source for hasWidget()/hasCommand(); optional so a runtime can still talk to an older host (both absent = fall back to the runtime's own schema tables). */
57
+ export interface HelloAckMsg {
58
+ type: "helloAck";
59
+ ndpVersion: number;
60
+ encodings: string[];
61
+ backend: string;
62
+ hostWidgets?: string[];
63
+ hostCommands?: string[];
64
+ }
65
+ export interface ErrorMsg {
66
+ type: "error";
67
+ message: string;
68
+ expected: number;
69
+ got: number;
70
+ }
71
+ /** `name` is one of widgets.json's event ndpNames (clicked | changed | activate | toggled | valueChanged | selectionChanged | ...) or styleError. */
72
+ export interface EventMsg {
73
+ type: "event";
74
+ seq: number;
75
+ priority: string;
76
+ nodeId: number;
77
+ name: string;
78
+ payload: EventPayload;
79
+ }
80
+ export interface CommitBatch {
81
+ type: "commitBatch";
82
+ commitId: number;
83
+ generation: number;
84
+ ops: Op[];
85
+ }
86
+ export interface PingMsg {
87
+ type: "ping";
88
+ }
89
+ export interface PongMsg {
90
+ type: "pong";
91
+ }
92
+ /** Best-effort report of an uncaught error. fatal=true means the child exits after sending (the host stashes the text for the crash overlay, M8); fatal=false means the app survived (host prints ND_RUNTIME_ERROR_NONFATAL and must NOT stash, so a stale report never becomes overlay text). */
93
+ export interface RuntimeErrorMsg {
94
+ type: "runtimeError";
95
+ message: string;
96
+ stack: string;
97
+ fatal: boolean;
98
+ }
99
+ /** Dispatches a loaded native plugin's command (M10); gated on the plugin:<plugin>.<command> capability host-side. */
100
+ export interface PluginCommandMsg {
101
+ type: "pluginCommand";
102
+ plugin: string;
103
+ command: string;
104
+ arg: unknown;
105
+ }
106
+ /** Reply to pluginCommand, carrying the plugin's JSON result verbatim (host-validated to be well-formed JSON before splicing). */
107
+ export interface PluginResultMsg {
108
+ type: "pluginResult";
109
+ result: unknown;
110
+ }
111
+ /** Imperative command on a live widget node (M14 WebView: goBack/goForward/reload/stop). `command` must be one of the node's widget's schema-declared commands (widgets.json commands[]); unknown commands are dropped host-side with ND_WARN. Ordered on the same socket as commitBatch, so a command sent after a commit always sees that commit applied. */
112
+ export interface WidgetCommandMsg {
113
+ type: "widgetCommand";
114
+ nodeId: number;
115
+ command: string;
116
+ arg: unknown;
117
+ }
118
+ /** App->host request for a native system capability (dialogs, clipboard, notifications, credentials, recent documents, audio). `id` correlates the eventual systemResponse; `method` is a dotted capability method (e.g. "dialog.openFile"); `params` is its JSON argument object. Gated host-side on the method's core:<group> capability. */
119
+ export interface SystemRequestMsg {
120
+ type: "systemRequest";
121
+ id: number;
122
+ method: string;
123
+ params: unknown;
124
+ }
125
+ /** Reply to a systemRequest, correlated by `id`. On success `ok` is true and `result` carries the method's JSON result; on failure `ok` is false and `errorMessage` carries a message. (The failure field is `errorMessage`, not `error`, because `error` is a Zig keyword the generated host struct can't name.) */
126
+ export interface SystemResponseMsg {
127
+ type: "systemResponse";
128
+ id: number;
129
+ ok: boolean;
130
+ result?: unknown;
131
+ errorMessage?: string;
132
+ }
133
+ /** Host-originated app-level event not tied to a widget node: app activation/deactivation, OS open-url/open-file launch, notification clicks, file drops, and capability event streams. `channel` names the stream; `data` carries its JSON payload. */
134
+ export interface SystemEventMsg {
135
+ type: "systemEvent";
136
+ channel: string;
137
+ data: unknown;
138
+ }
139
+ export type RuntimeToHostMsg = HelloMsg | CommitBatch | PingMsg | RuntimeErrorMsg | PluginCommandMsg | WidgetCommandMsg | SystemRequestMsg;
140
+ export type HostToRuntimeMsg = HelloAckMsg | ErrorMsg | EventMsg | PongMsg | PluginResultMsg | SystemResponseMsg | SystemEventMsg;
@@ -0,0 +1,299 @@
1
+ /** Logical units (not device pixels), relative to the window's top-left corner (coordinateSpace "logical-window-topleft"). */
2
+ export interface Geometry {
3
+ x: number;
4
+ y: number;
5
+ w: number;
6
+ h: number;
7
+ }
8
+ /** SourceList's per-row shape on the wire (M11 SourceList Wave 1) — camelCase iconName, matching the schema prop shape. testID carries SourceTree's per-node testID (null for SourceList rows, which have none). */
9
+ export interface RowJson {
10
+ title: string;
11
+ badge: string | null;
12
+ iconName: string | null;
13
+ testID: string | null;
14
+ }
15
+ /** One tree-snapshot node. itemCount is ListView's row count (M5c-D4), null for every widget that isn't data-driven; rows is SourceList's ordered row data, null for every widget that isn't row-driven. role/enabled/focused/value are the accessibility-tree fields (M16): role is the widget's schema-declared automation role (null when the type declares none); enabled/focused/value come from a live per-node backend probe and default to true/false/null on backends without the probe. */
16
+ export interface JsonNode {
17
+ ref: number;
18
+ type: string;
19
+ testID: string | null;
20
+ text: string | null;
21
+ visible: boolean;
22
+ geometry: Geometry | null;
23
+ children: JsonNode[];
24
+ itemCount: number | null;
25
+ rows: RowJson[] | null;
26
+ role: string | null;
27
+ enabled: boolean;
28
+ focused: boolean;
29
+ value: unknown | null;
30
+ }
31
+ export interface GetTreeResult {
32
+ coordinateSpace: string;
33
+ root: JsonNode;
34
+ }
35
+ export interface ScreenshotResult {
36
+ path: string;
37
+ width: number;
38
+ height: number;
39
+ }
40
+ export interface ClickResult {
41
+ ref: number;
42
+ dispatched: boolean;
43
+ }
44
+ /** ref is the winning match (ranked like resolve: actionable first, key window first, then tree order), so a caller needs no follow-up getTree; count is the number of nodes that satisfied the predicate. */
45
+ export interface WaitForResult {
46
+ matched: boolean;
47
+ ref: number | null;
48
+ count: number;
49
+ }
50
+ export interface SetValueResult {
51
+ ref: number;
52
+ applied: boolean;
53
+ }
54
+ /** text is the full text after the insert. */
55
+ export interface TypeResult {
56
+ ref: number;
57
+ text: string;
58
+ }
59
+ /** x/y are the resulting adjustment values. */
60
+ export interface ScrollResult {
61
+ ref: number;
62
+ x: number;
63
+ y: number;
64
+ }
65
+ /** Exactly one selector: textContains | refVisible | testId. With testId, `state` (default "present", one of present|gone|visible|enabled|disabled|focused) picks the predicate and countAtLeast/valueEquals/valueContains refine it. valueEquals/valueContains compare against the node's a11y value STRING RENDERING (numbers stringified, bools "true"/"false") so one predicate works for TextInput and Slider alike. Every predicate is evaluated host-side on the retained tree plus the live a11y probe, once per ~50ms tick — never a getTree round trip. */
66
+ export interface WaitCondition {
67
+ textContains?: string;
68
+ refVisible?: number;
69
+ testId?: string;
70
+ state?: string;
71
+ countAtLeast?: number;
72
+ valueEquals?: string;
73
+ valueContains?: string;
74
+ }
75
+ export interface ResolveResult {
76
+ ref: number | null;
77
+ refs: number[];
78
+ count: number;
79
+ }
80
+ /** key/main/visible/title come from the live windowState probe on the Window node's handle; tabGroup is the create-time prop (null for plain windows). */
81
+ export interface WindowInfo {
82
+ ref: number;
83
+ title: string | null;
84
+ key: boolean;
85
+ main: boolean;
86
+ visible: boolean;
87
+ tabGroup: string | null;
88
+ }
89
+ export interface WindowsResult {
90
+ windows: WindowInfo[];
91
+ }
92
+ export interface PointerResult {
93
+ dispatched: boolean;
94
+ }
95
+ /** fromX/fromY/toX/toY are the resolved endpoints in logical-window-topleft coordinates. */
96
+ export interface DragResult {
97
+ dispatched: boolean;
98
+ fromX: number;
99
+ fromY: number;
100
+ toX: number;
101
+ toY: number;
102
+ steps: number;
103
+ }
104
+ export interface KeysResult {
105
+ dispatched: boolean;
106
+ }
107
+ /** Full tree snapshot with stable refs, testIDs, text, logical geometry, and accessibility state (role/enabled/focused/value). window (if given) must be a Window node ref and scopes the snapshot to that window's subtree; absent, the root/first window is used and other windows' nodes attach as orphans. */
108
+ export interface GetTreeParams {
109
+ window?: number;
110
+ }
111
+ /** In-process render of the window to a PNG at the given absolute path; window (if given) must match the root ref. */
112
+ export interface ScreenshotParams {
113
+ path: string;
114
+ window?: number;
115
+ }
116
+ /** Actionability-checked semantic click; emits clicked exactly like real user input. On CommandPalette activates the currently-highlighted row. Target by exactly one of ref / testId (window optionally scopes testId resolution). */
117
+ export interface ClickParams {
118
+ ref?: number;
119
+ testId?: string;
120
+ window?: number;
121
+ }
122
+ /** Polls the tree at ~50ms until the condition holds or timeoutMs elapses. window (if given) scopes every predicate to that Window node's subtree. */
123
+ export interface WaitForParams {
124
+ condition: WaitCondition;
125
+ timeoutMs?: number;
126
+ window?: number;
127
+ }
128
+ /** Kind-dispatched: TextInput/TextArea need a string, Checkbox/Radio a bool, Slider a number, Select an integer index. CommandPalette (routed to the presented dialog): a string sets the query text (fires queryChanged), an integer activates the row at that index (fires onActivate), a bool true submits the raw query (fires onSubmit). Target by exactly one of ref / testId. */
129
+ export interface SetValueParams {
130
+ ref?: number;
131
+ testId?: string;
132
+ window?: number;
133
+ value: unknown;
134
+ }
135
+ /** TextInput (and CommandPalette, appending to its query); semantic append via GtkEditable.insertText, never synthetic keysyms. Target by exactly one of ref / testId. */
136
+ export interface TypeParams {
137
+ ref?: number;
138
+ testId?: string;
139
+ window?: number;
140
+ text: string;
141
+ }
142
+ /** ScrollView only — adjusts the wrapping GtkScrolledWindow's adjustments by dx/dy. Target by exactly one of ref / testId. */
143
+ export interface ScrollParams {
144
+ ref?: number;
145
+ testId?: string;
146
+ window?: number;
147
+ dx?: number;
148
+ dy?: number;
149
+ }
150
+ /** Actionability-checked double-click at the widget's center via real input synthesis (macOS: posted NSEvents, drives doubleAction row activation). Unsupported on GTK (-32003). Target by exactly one of ref / testId. */
151
+ export interface DoubleClickParams {
152
+ ref?: number;
153
+ testId?: string;
154
+ window?: number;
155
+ }
156
+ /** Actionability-checked right-click at the widget's center via real input synthesis; opens native context menus where the widget has one (dismiss with keys "escape"). Unsupported on GTK (-32003). Target by exactly one of ref / testId. */
157
+ export interface RightClickParams {
158
+ ref?: number;
159
+ testId?: string;
160
+ window?: number;
161
+ }
162
+ /** Best-effort pointer hover at the widget's center (macOS: posted mouseMoved). Unsupported on GTK (-32003). Target by exactly one of ref / testId. */
163
+ export interface HoverParams {
164
+ ref?: number;
165
+ testId?: string;
166
+ window?: number;
167
+ }
168
+ /** Resolves a testID to the single ACTIONABLE instance. Candidates are ranked: actionable (the checkActionable predicate passes) before not; then key/front window before background. `refs` is every match in tree order, `ref` the winner (null when none is actionable and `actionable` is true). */
169
+ export interface ResolveParams {
170
+ testId: string;
171
+ window?: number;
172
+ actionable?: boolean;
173
+ }
174
+ /** Low-level single pointer phase (down|move|up) at logical-window-topleft coordinates in the target window (default: root window). button is left|right (default left). Caution: a lone down on a tracking control (slider, button) enters the control's mouse-tracking loop until an up arrives — prefer drag for press-move-release sequences. Unsupported on GTK (-32003). */
175
+ export interface PointerParams {
176
+ phase: string;
177
+ x: number;
178
+ y: number;
179
+ button?: string;
180
+ clickCount?: number;
181
+ window?: number;
182
+ }
183
+ /** Press-move-release gesture. Endpoints are widget refs (their centers; fromRef/toRef must share a window) or explicit coordinates (fromX/fromY/toX/toY in the target window, default root). The full down/dragged.../up sequence is posted as one batch so native mouse-tracking loops (slider thumbs, split dividers) consume it like a real drag. Unsupported on GTK (-32003). */
184
+ export interface DragParams {
185
+ fromRef?: number;
186
+ toRef?: number;
187
+ fromX?: number;
188
+ fromY?: number;
189
+ toX?: number;
190
+ toY?: number;
191
+ steps?: number;
192
+ durationMs?: number;
193
+ button?: string;
194
+ window?: number;
195
+ }
196
+ /** Keyboard synthesis into the target window (default: root window). A chord spec like "cmd+shift+n" / "escape" / "tab" presses one combination (driving menu key equivalents); a plain multi-character string like "hello" types each character into the focused widget. Unsupported on GTK (-32003). */
197
+ export interface KeysParams {
198
+ keys: string;
199
+ window?: number;
200
+ }
201
+ export interface RpcMethods {
202
+ getTree: {
203
+ params: GetTreeParams;
204
+ result: GetTreeResult;
205
+ };
206
+ screenshot: {
207
+ params: ScreenshotParams;
208
+ result: ScreenshotResult;
209
+ };
210
+ click: {
211
+ params: ClickParams;
212
+ result: ClickResult;
213
+ };
214
+ waitFor: {
215
+ params: WaitForParams;
216
+ result: WaitForResult;
217
+ };
218
+ setValue: {
219
+ params: SetValueParams;
220
+ result: SetValueResult;
221
+ };
222
+ type: {
223
+ params: TypeParams;
224
+ result: TypeResult;
225
+ };
226
+ scroll: {
227
+ params: ScrollParams;
228
+ result: ScrollResult;
229
+ };
230
+ doubleClick: {
231
+ params: DoubleClickParams;
232
+ result: ClickResult;
233
+ };
234
+ rightClick: {
235
+ params: RightClickParams;
236
+ result: ClickResult;
237
+ };
238
+ hover: {
239
+ params: HoverParams;
240
+ result: ClickResult;
241
+ };
242
+ resolve: {
243
+ params: ResolveParams;
244
+ result: ResolveResult;
245
+ };
246
+ windows: {
247
+ params: undefined;
248
+ result: WindowsResult;
249
+ };
250
+ pointer: {
251
+ params: PointerParams;
252
+ result: PointerResult;
253
+ };
254
+ drag: {
255
+ params: DragParams;
256
+ result: DragResult;
257
+ };
258
+ keys: {
259
+ params: KeysParams;
260
+ result: KeysResult;
261
+ };
262
+ }
263
+ export type RpcMethodName = keyof RpcMethods;
264
+ export type RpcParams<M extends RpcMethodName> = RpcMethods[M]["params"];
265
+ export type RpcResult<M extends RpcMethodName> = RpcMethods[M]["result"];
266
+ export declare const RPC_ERRORS: {
267
+ /** data: {ref, reason: "unknown" | "invisible" | "unmapped" | "offscreen"} */
268
+ readonly notActionable: {
269
+ readonly code: -32001;
270
+ readonly message: "not actionable";
271
+ };
272
+ /** data: {timeoutMs} */
273
+ readonly waitForTimeout: {
274
+ readonly code: -32002;
275
+ readonly message: "waitFor timeout";
276
+ };
277
+ /** pointer/drag/keys/doubleClick/rightClick/hover on a backend without synthetic input (GTK4 removed app-constructible events) */
278
+ readonly inputUnsupported: {
279
+ readonly code: -32003;
280
+ readonly message: "input synthesis unsupported on this backend";
281
+ };
282
+ readonly methodNotFound: {
283
+ readonly code: -32601;
284
+ readonly message: "method not found";
285
+ };
286
+ /** data: {ref} where applicable; message may carry the specific missing/invalid param */
287
+ readonly invalidParams: {
288
+ readonly code: -32602;
289
+ readonly message: "invalid params";
290
+ };
291
+ readonly internalError: {
292
+ readonly code: -32603;
293
+ readonly message: "internal error";
294
+ };
295
+ readonly parseError: {
296
+ readonly code: -32700;
297
+ readonly message: "parse error";
298
+ };
299
+ };
@@ -0,0 +1,29 @@
1
+ export interface WidgetMeta {
2
+ role: string;
3
+ textFrom: string | null;
4
+ childModel: "single" | "multi" | null;
5
+ }
6
+ export declare const widgetMeta: Record<string, WidgetMeta>;
7
+ export declare const intrinsicToName: Record<string, string>;
8
+ export interface WidgetEvent {
9
+ name: string;
10
+ handler: string;
11
+ payload: "none" | "text" | "checked" | "value" | "index" | "data";
12
+ }
13
+ export declare const widgetEvents: Record<string, WidgetEvent[]>;
14
+ export declare const handlerPropNames: Record<string, string[]>;
15
+ /** Imperative commands each widget accepts via the widgetCommand NDP frame
16
+ * (M14) — the runtime validation table behind sendCommand(). */
17
+ export declare const widgetCommands: Record<string, readonly string[]>;
18
+ /** Compile-time command-name map (only widgets with commands appear). */
19
+ export type WidgetCommandNames = {
20
+ "window": "showAlert" | "openFile" | "saveFile" | "showAbout" | "showTabOverview" | "present";
21
+ "webview": "goBack" | "goForward" | "reload" | "stop" | "executeJavaScript" | "setZoom" | "setUserAgent" | "openDevTools";
22
+ "toastoverlay": "showToast" | "dismissToast";
23
+ "terminal": "copy" | "paste" | "selectAll" | "clearSelection" | "focus";
24
+ };
25
+ /** Platform availability (schema `platforms`): null = every platform. A
26
+ * widget listing only some platforms renders natively there and is an
27
+ * invisible no-op placeholder everywhere else — JS may warn but must not
28
+ * treat mounting one on another platform as an error. */
29
+ export declare const widgetPlatforms: Record<string, readonly ("macos" | "linux")[] | null>;
@@ -0,0 +1,2 @@
1
+ export declare const WIDGET_TYPE_RESERVED = 0;
2
+ export declare const WIDGET_TYPE: Record<string, number>;
@@ -0,0 +1,53 @@
1
+ import type { Ndp } from "../../../runtime/ndp.ts";
2
+ import * as RefreshRuntimeFirstEval from "react-refresh/runtime";
3
+ declare global {
4
+ var __nd_refresh_runtime: typeof RefreshRuntimeFirstEval | undefined;
5
+ }
6
+ export interface HmrState {
7
+ ndp: Ndp;
8
+ root: unknown;
9
+ reconciler: {
10
+ updateContainer: (...a: unknown[]) => void;
11
+ };
12
+ bootCount: number;
13
+ }
14
+ declare global {
15
+ var __nd_hmr: HmrState | undefined;
16
+ }
17
+ export declare function getHmrState(): HmrState | undefined;
18
+ export declare function setHmrState(s: HmrState): void;
19
+ export declare function isHot(): boolean;
20
+ interface RefreshableReconciler {
21
+ setRefreshHandler?: (h: unknown) => void;
22
+ injectIntoDevTools?: () => unknown;
23
+ }
24
+ /** Wires react-refresh's runtime into the reconciler.
25
+ * `injectIntoGlobalHook`/`injectIntoDevTools`/`setRefreshHandler`/manual
26
+ * `$RefreshReg$`/`$RefreshSig$` must all be installed before any app React
27
+ * code runs — render() calls this before createContainer, and the app
28
+ * module's import of @nativedesktop/react runs this module first, so
29
+ * ordering holds. Bun's `--hot` does NOT inject `$RefreshReg$`/`$RefreshSig$`,
30
+ * so they are installed manually here. */
31
+ export declare function setupRefresh(reconciler: RefreshableReconciler): void;
32
+ /** Call from the app entry after a hot re-eval re-runs its modules. */
33
+ export declare function performRefresh(): void;
34
+ /** Registers a module's exported components by name — the babel Fast Refresh
35
+ * transform's job, done manually because Bun's `--hot` does not run it.
36
+ * Call once per hot re-eval, before performRefresh(). */
37
+ export declare function registerExports(mod: Record<string, unknown>, moduleId: string): void;
38
+ /** Called by render() on first boot, before the first updateContainer, so a
39
+ * family exists for the NEXT eval's hotUpdateRoot() call to match against. */
40
+ export declare function registerRoot(rootComponentType: unknown): void;
41
+ /** Called by render() on every hot re-eval (never on first boot). Registers
42
+ * the new root element's type under the SAME family key used on the
43
+ * previous eval, then asks react-refresh to patch the live fiber tree in
44
+ * place — this is what makes a hot edit state-preserving instead of a full
45
+ * remount. Must NOT be combined with a normal updateContainer call on the
46
+ * same eval (see above). */
47
+ export declare function hotUpdateRoot(rootComponentType: unknown): void;
48
+ /** Bumps the generation counter (ids.ts) so the next commit's CommitBatch
49
+ * carries a higher generation, triggering the host's generation GC of
50
+ * orphaned widgets. Used for structural / non-refreshable edits that
51
+ * react-refresh cannot preserve state across. */
52
+ export declare function fullReload(): void;
53
+ export {};
@@ -0,0 +1,4 @@
1
+ /** One-time external sync on mount; the returned cleanup runs on unmount.
2
+ * The named wrapper marks the one useEffect shape that has no derived-state
3
+ * replacement, so call sites don't carry a raw `useEffect(fn, [])`. */
4
+ export declare function useMountEffect(effect: () => void | (() => void)): void;
@@ -0,0 +1,72 @@
1
+ import { Batch, NodeRegistry } from "./ops.ts";
2
+ import type { WidgetType } from "./generated/intrinsics.ts";
3
+ export type { WidgetType };
4
+ export interface Instance {
5
+ id: number;
6
+ type: WidgetType;
7
+ props: Record<string, unknown>;
8
+ /** Populated by appendInitialChild during render; only meaningful until the
9
+ * instance's first commit-time attach, at which point emitCreateIfNew
10
+ * flushes it into create+append ops (see note below). */
11
+ children: Instance[];
12
+ }
13
+ export declare let activeBatch: Batch;
14
+ export declare let registry: NodeRegistry;
15
+ export declare function bindCommitTargets(b: Batch, r: NodeRegistry): void;
16
+ export interface Container {
17
+ rootId: number | null;
18
+ }
19
+ export declare function setPriorityFor(kind: "discrete" | "continuous" | "default"): void;
20
+ export declare const hostConfig: {
21
+ supportsMutation: boolean;
22
+ supportsPersistence: boolean;
23
+ supportsHydration: boolean;
24
+ isPrimaryRenderer: boolean;
25
+ noTimeout: -1;
26
+ supportsMicrotasks: boolean;
27
+ scheduleMicrotask: (fn: () => void) => void;
28
+ scheduleTimeout: (fn: (...args: unknown[]) => void, delay?: number) => NodeJS.Timeout;
29
+ cancelTimeout: (id: ReturnType<typeof setTimeout>) => void;
30
+ getRootHostContext: () => {
31
+ root: boolean;
32
+ };
33
+ getChildHostContext: (parent: unknown) => unknown;
34
+ prepareForCommit: () => null;
35
+ resetAfterCommit: () => void;
36
+ clearContainer: () => void;
37
+ preparePortalMount: () => void;
38
+ createInstance(type: WidgetType, props: Record<string, unknown>): Instance;
39
+ createTextInstance(text: string): {
40
+ text: string;
41
+ };
42
+ shouldSetTextContent: (type: WidgetType) => type is "label";
43
+ appendInitialChild(parent: Instance, child: Instance): void;
44
+ finalizeInitialChildren: () => boolean;
45
+ appendChild(parent: Instance, child: Instance): void;
46
+ appendChildToContainer(_container: Container, child: Instance): void;
47
+ insertBefore(parent: Instance, child: Instance, before: Instance): void;
48
+ insertInContainerBefore(_c: Container, child: Instance, _b: Instance): void;
49
+ removeChild(_parent: Instance, child: Instance): void;
50
+ removeChildFromContainer(_c: Container, child: Instance): void;
51
+ commitUpdate(inst: Instance, type: WidgetType, oldProps: Record<string, unknown>, newProps: Record<string, unknown>): void;
52
+ commitTextUpdate(): void;
53
+ hideInstance(inst: Instance): void;
54
+ unhideInstance(inst: Instance): void;
55
+ hideTextInstance(): void;
56
+ unhideTextInstance(): void;
57
+ getPublicInstance: (i: Instance) => Instance;
58
+ detachDeletedInstance(): void;
59
+ maySuspendCommit: () => boolean;
60
+ preloadInstance: () => boolean;
61
+ startSuspendingCommit(): void;
62
+ suspendInstance(): void;
63
+ waitForCommitToBeReady: () => null;
64
+ resolveUpdatePriority: () => number;
65
+ getCurrentUpdatePriority: () => number;
66
+ setCurrentUpdatePriority: (p: number) => void;
67
+ shouldAttemptEagerTransition: () => boolean;
68
+ trackSchedulerEvent(): void;
69
+ resolveEventType: () => null;
70
+ resolveEventTimeStamp: () => number;
71
+ requestPostPaintCallback(): void;
72
+ };
@@ -0,0 +1,4 @@
1
+ export declare function currentGeneration(): number;
2
+ export declare function newGeneration(): void;
3
+ /** Generation-tagged monotonic node id: (generation << 24) | (seq & 0xFFFFFF). */
4
+ export declare function nextNodeId(): number;
@@ -0,0 +1,26 @@
1
+ export { render, sendCommand, sendNativeCommand, createPortal, createPool, moveNode } from "./renderer.ts";
2
+ export type { Pool } from "./renderer.ts";
3
+ export { Platform, hasWidget, hasCommand } from "./platform.ts";
4
+ export type { Backend, OS } from "./platform.ts";
5
+ export { Spacing, ContentMargin } from "./metrics.ts";
6
+ export type { SpacingScale } from "./metrics.ts";
7
+ export { getAppDataDir, ensureAppDataDir } from "./paths.ts";
8
+ export { defineNativeComponent } from "./native-component.ts";
9
+ export type { NativeComponentOptions, NativeComponentProps, NativeComponentRef } from "./native-component.ts";
10
+ export { executeJavaScript, onJavaScriptResult } from "./webview.ts";
11
+ export { showAlert, openFile, saveFile, showAbout, showTabOverview, onAlertResult, onOpenFileResult, onSaveFileResult, } from "./dialogs.ts";
12
+ export type { DialogButton, ShowAlertOptions, AlertResult, OpenFileOptions as WindowOpenFileOptions, OpenFileResult as WindowOpenFileResult, SaveFileOptions as WindowSaveFileOptions, SaveFileResult as WindowSaveFileResult, ShowAboutOptions, } from "./dialogs.ts";
13
+ export { showToast, dismissToast, onToastButtonClicked, onToastDismissed } from "./toast.ts";
14
+ export type { ToastPriority, ShowToastOptions, ToastResult } from "./toast.ts";
15
+ export type { Instance } from "./host-config.ts";
16
+ export type { NdNodeRef, WidgetType, TableColumn, TableRow, TreeNode, SourceTreeAction, SourceTreeNode } from "./generated/intrinsics.ts";
17
+ export { performRefresh, registerExports, fullReload } from "./hmr.ts";
18
+ export { useState, useEffect, useLayoutEffect, useMemo, useCallback, useRef, useContext, useReducer, useTransition, useDeferredValue, useSyncExternalStore, useId, use, startTransition, memo, forwardRef, createContext, Suspense, Fragment, } from "./dev-react.ts";
19
+ export { dialog, clipboard, notifications, recentDocuments, credentials, app, system, audio } from "./system.ts";
20
+ export type { FileFilter, OpenFileOptions, SaveFileOptions, MessageLevel, MessageOptions, NotificationOptions, Appearance, AppearanceInfo, AudioPlayOptions, AudioState, AudioStateEvent, AudioSpectrumEvent, } from "./system.ts";
21
+ export { openExternal, openPath, revealPath } from "./shell.ts";
22
+ export { onUnhandledError, setUnhandledErrorPolicy } from "./errors.ts";
23
+ export type { NdErrorKind, NdErrorContext, NdErrorHandler, UnhandledErrorPolicy } from "./errors.ts";
24
+ export { useMountEffect } from "./hooks.ts";
25
+ export { createStore, useStoreValue } from "./store.ts";
26
+ export type { Store, StoreOptions } from "./store.ts";
@@ -0,0 +1,2 @@
1
+ export { jsxDEV, Fragment } from "react/jsx-dev-runtime";
2
+ export type { JSX } from "./generated/intrinsics.ts";
@@ -0,0 +1,2 @@
1
+ export { jsx, jsxs, Fragment } from "./generated/intrinsics.ts";
2
+ export type { JSX } from "./generated/intrinsics.ts";
@@ -0,0 +1,12 @@
1
+ export interface SpacingScale {
2
+ xs: number;
3
+ sm: number;
4
+ md: number;
5
+ lg: number;
6
+ xl: number;
7
+ }
8
+ export declare const Spacing: SpacingScale;
9
+ /** The platform's standard margin between window edge and content. A live
10
+ * binding (a number export cannot be a getter): read it at render time, not
11
+ * into a module-scope constant. */
12
+ export declare let ContentMargin: number;