@gtkx/react 0.9.4 → 0.10.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 (182) hide show
  1. package/README.md +55 -67
  2. package/dist/errors.d.ts +3 -3
  3. package/dist/errors.js +8 -8
  4. package/dist/factory.d.ts +3 -5
  5. package/dist/factory.js +18 -71
  6. package/dist/fiber-root.d.ts +1 -1
  7. package/dist/fiber-root.js +1 -2
  8. package/dist/generated/internal.d.ts +3 -6
  9. package/dist/generated/internal.js +10386 -13577
  10. package/dist/generated/jsx.d.ts +914 -808
  11. package/dist/generated/jsx.js +123 -358
  12. package/dist/generated/registry.d.ts +4 -0
  13. package/dist/generated/registry.js +13 -0
  14. package/dist/host-config.d.ts +7 -4
  15. package/dist/host-config.js +53 -18
  16. package/dist/index.d.ts +2 -22
  17. package/dist/index.js +2 -40
  18. package/dist/jsx.d.ts +719 -0
  19. package/dist/jsx.js +392 -0
  20. package/dist/node.d.ts +15 -32
  21. package/dist/node.js +20 -240
  22. package/dist/nodes/action-row-child.d.ts +21 -0
  23. package/dist/nodes/action-row-child.js +69 -0
  24. package/dist/nodes/action-row.js +33 -0
  25. package/dist/nodes/application.d.ts +1 -0
  26. package/dist/nodes/application.js +38 -0
  27. package/dist/nodes/autowrapped.d.ts +1 -0
  28. package/dist/nodes/autowrapped.js +109 -0
  29. package/dist/nodes/column-view-column.d.ts +16 -0
  30. package/dist/nodes/column-view-column.js +54 -0
  31. package/dist/nodes/column-view.d.ts +0 -59
  32. package/dist/nodes/column-view.js +107 -226
  33. package/dist/nodes/fixed-child.d.ts +1 -0
  34. package/dist/nodes/fixed-child.js +45 -0
  35. package/dist/nodes/grid-child.d.ts +1 -0
  36. package/dist/nodes/grid-child.js +54 -0
  37. package/dist/nodes/index.d.ts +34 -0
  38. package/dist/nodes/index.js +34 -0
  39. package/dist/nodes/internal/list-item-renderer.d.ts +18 -0
  40. package/dist/nodes/internal/list-item-renderer.js +67 -0
  41. package/dist/nodes/internal/list-store.d.ts +16 -0
  42. package/dist/nodes/internal/list-store.js +69 -0
  43. package/dist/nodes/internal/predicates.d.ts +26 -0
  44. package/dist/nodes/internal/predicates.js +36 -0
  45. package/dist/nodes/internal/signal-store.d.ts +9 -0
  46. package/dist/nodes/internal/signal-store.js +54 -0
  47. package/dist/nodes/internal/simple-list-store.d.ts +14 -0
  48. package/dist/nodes/internal/simple-list-store.js +60 -0
  49. package/dist/nodes/internal/tree-list-item-renderer.d.ts +18 -0
  50. package/dist/nodes/internal/tree-list-item-renderer.js +90 -0
  51. package/dist/nodes/internal/tree-store.d.ts +28 -0
  52. package/dist/nodes/internal/tree-store.js +153 -0
  53. package/dist/nodes/internal/utils.d.ts +3 -0
  54. package/dist/nodes/internal/utils.js +20 -0
  55. package/dist/nodes/list-item.d.ts +12 -0
  56. package/dist/nodes/list-item.js +24 -0
  57. package/dist/nodes/list-view.d.ts +0 -22
  58. package/dist/nodes/list-view.js +45 -38
  59. package/dist/nodes/menu.d.ts +6 -106
  60. package/dist/nodes/menu.js +16 -268
  61. package/dist/nodes/models/list.d.ts +24 -0
  62. package/dist/nodes/models/list.js +102 -0
  63. package/dist/nodes/models/menu.d.ts +45 -0
  64. package/dist/nodes/models/menu.js +265 -0
  65. package/dist/nodes/models/tree-list.d.ts +28 -0
  66. package/dist/nodes/models/tree-list.js +141 -0
  67. package/dist/nodes/navigation-page.d.ts +21 -0
  68. package/dist/nodes/navigation-page.js +95 -0
  69. package/dist/nodes/navigation-view.d.ts +1 -0
  70. package/dist/nodes/navigation-view.js +29 -0
  71. package/dist/nodes/notebook-page-tab.d.ts +15 -0
  72. package/dist/nodes/notebook-page-tab.js +42 -0
  73. package/dist/nodes/notebook-page.d.ts +23 -0
  74. package/dist/nodes/notebook-page.js +106 -0
  75. package/dist/nodes/notebook.d.ts +0 -32
  76. package/dist/nodes/notebook.js +20 -113
  77. package/dist/nodes/overlay-child.d.ts +1 -0
  78. package/dist/nodes/overlay-child.js +30 -0
  79. package/dist/nodes/pack-child.d.ts +21 -0
  80. package/dist/nodes/pack-child.js +68 -0
  81. package/dist/nodes/pack.d.ts +1 -0
  82. package/dist/nodes/pack.js +33 -0
  83. package/dist/nodes/popover-menu.d.ts +1 -0
  84. package/dist/nodes/popover-menu.js +58 -0
  85. package/dist/nodes/simple-list-item.d.ts +9 -0
  86. package/dist/nodes/simple-list-item.js +9 -0
  87. package/dist/nodes/simple-list-view.d.ts +1 -0
  88. package/dist/nodes/simple-list-view.js +75 -0
  89. package/dist/nodes/slot.d.ts +18 -10
  90. package/dist/nodes/slot.js +83 -51
  91. package/dist/nodes/stack-page.d.ts +1 -0
  92. package/dist/nodes/stack-page.js +80 -0
  93. package/dist/nodes/stack.d.ts +1 -22
  94. package/dist/nodes/stack.js +21 -60
  95. package/dist/nodes/toast-overlay.d.ts +1 -0
  96. package/dist/nodes/toast-overlay.js +35 -0
  97. package/dist/nodes/toast.d.ts +17 -0
  98. package/dist/nodes/toast.js +77 -0
  99. package/dist/nodes/toolbar-child.d.ts +9 -0
  100. package/dist/nodes/toolbar-child.js +33 -0
  101. package/dist/nodes/toolbar.d.ts +1 -0
  102. package/dist/nodes/toolbar.js +42 -0
  103. package/dist/nodes/tree-list-item.d.ts +20 -0
  104. package/dist/nodes/tree-list-item.js +102 -0
  105. package/dist/nodes/tree-list-view.d.ts +1 -0
  106. package/dist/nodes/tree-list-view.js +57 -0
  107. package/dist/nodes/virtual.d.ts +13 -0
  108. package/dist/nodes/virtual.js +21 -0
  109. package/dist/nodes/widget.d.ts +17 -3
  110. package/dist/nodes/widget.js +258 -2
  111. package/dist/nodes/window.d.ts +1 -12
  112. package/dist/nodes/window.js +66 -27
  113. package/dist/portal.d.ts +18 -13
  114. package/dist/portal.js +17 -14
  115. package/dist/reconciler.d.ts +0 -4
  116. package/dist/reconciler.js +1 -9
  117. package/dist/registry.d.ts +8 -0
  118. package/dist/registry.js +5 -0
  119. package/dist/render.d.ts +108 -12
  120. package/dist/render.js +140 -16
  121. package/dist/scheduler.d.ts +4 -0
  122. package/dist/scheduler.js +10 -0
  123. package/dist/types.d.ts +3 -136
  124. package/package.json +6 -6
  125. package/dist/batch.d.ts +0 -5
  126. package/dist/batch.js +0 -31
  127. package/dist/codegen/jsx-generator.d.ts +0 -56
  128. package/dist/codegen/jsx-generator.js +0 -959
  129. package/dist/containers.d.ts +0 -58
  130. package/dist/nodes/about-dialog.d.ts +0 -8
  131. package/dist/nodes/about-dialog.js +0 -16
  132. package/dist/nodes/action-bar.d.ts +0 -5
  133. package/dist/nodes/action-bar.js +0 -6
  134. package/dist/nodes/combo-row.d.ts +0 -5
  135. package/dist/nodes/combo-row.js +0 -6
  136. package/dist/nodes/drop-down.d.ts +0 -9
  137. package/dist/nodes/drop-down.js +0 -12
  138. package/dist/nodes/flow-box.d.ts +0 -10
  139. package/dist/nodes/flow-box.js +0 -41
  140. package/dist/nodes/grid.d.ts +0 -30
  141. package/dist/nodes/grid.js +0 -84
  142. package/dist/nodes/header-bar.d.ts +0 -43
  143. package/dist/nodes/header-bar.js +0 -116
  144. package/dist/nodes/indexed-child-container.d.ts +0 -16
  145. package/dist/nodes/indexed-child-container.js +0 -22
  146. package/dist/nodes/list-box.d.ts +0 -10
  147. package/dist/nodes/list-box.js +0 -48
  148. package/dist/nodes/list-item-factory.d.ts +0 -19
  149. package/dist/nodes/list-item-factory.js +0 -58
  150. package/dist/nodes/overlay.d.ts +0 -11
  151. package/dist/nodes/overlay.js +0 -50
  152. package/dist/nodes/paged-stack.d.ts +0 -31
  153. package/dist/nodes/paged-stack.js +0 -95
  154. package/dist/nodes/root.d.ts +0 -8
  155. package/dist/nodes/root.js +0 -13
  156. package/dist/nodes/selectable-list.d.ts +0 -45
  157. package/dist/nodes/selectable-list.js +0 -260
  158. package/dist/nodes/stack-page-props.d.ts +0 -11
  159. package/dist/nodes/stack-page-props.js +0 -23
  160. package/dist/nodes/string-list-container.d.ts +0 -34
  161. package/dist/nodes/string-list-container.js +0 -118
  162. package/dist/nodes/string-list-item.d.ts +0 -19
  163. package/dist/nodes/string-list-item.js +0 -50
  164. package/dist/nodes/string-list-store.d.ts +0 -13
  165. package/dist/nodes/string-list-store.js +0 -44
  166. package/dist/nodes/text-view.d.ts +0 -8
  167. package/dist/nodes/text-view.js +0 -16
  168. package/dist/nodes/toggle-button.d.ts +0 -14
  169. package/dist/nodes/toggle-button.js +0 -39
  170. package/dist/nodes/toolbar-view.d.ts +0 -14
  171. package/dist/nodes/toolbar-view.js +0 -78
  172. package/dist/nodes/view-stack.d.ts +0 -9
  173. package/dist/nodes/view-stack.js +0 -28
  174. package/dist/nodes/virtual-item.d.ts +0 -19
  175. package/dist/nodes/virtual-item.js +0 -48
  176. package/dist/nodes/virtual-slot.d.ts +0 -25
  177. package/dist/nodes/virtual-slot.js +0 -57
  178. package/dist/predicates.d.ts +0 -29
  179. package/dist/predicates.js +0 -37
  180. package/dist/props.d.ts +0 -7
  181. package/dist/props.js +0 -12
  182. /package/dist/{containers.js → nodes/action-row.d.ts} +0 -0
package/README.md CHANGED
@@ -1,47 +1,43 @@
1
1
  <p align="center">
2
- <img src="https://raw.githubusercontent.com/eugeniodepalo/gtkx/HEAD/logo.svg" alt="GTKX Logo" width="128" height="128">
2
+ <img src="https://raw.githubusercontent.com/eugeniodepalo/gtkx/main/logo.svg" alt="GTKX" width="80" height="80">
3
3
  </p>
4
4
 
5
5
  <h1 align="center">GTKX</h1>
6
6
 
7
7
  <p align="center">
8
- <strong>Build native GTK4 desktop apps with React</strong>
8
+ <strong>Build native GTK4 desktop applications with React and TypeScript.</strong>
9
9
  </p>
10
10
 
11
11
  <p align="center">
12
- <a href="https://eugeniodepalo.github.io/gtkx">Documentation</a> ·
13
- <a href="#quick-start">Quick Start</a> ·
14
- <a href="#examples">Examples</a> ·
15
- <a href="#contributing">Contributing</a>
12
+ <a href="https://www.npmjs.com/package/@gtkx/react"><img src="https://img.shields.io/npm/v/@gtkx/react.svg" alt="npm version"></a>
13
+ <a href="https://github.com/eugeniodepalo/gtkx/actions"><img src="https://img.shields.io/github/actions/workflow/status/eugeniodepalo/gtkx/ci.yml" alt="CI"></a>
14
+ <a href="https://github.com/eugeniodepalo/gtkx/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MPL--2.0-blue.svg" alt="License"></a>
15
+ <a href="https://github.com/eugeniodepalo/gtkx/discussions"><img src="https://img.shields.io/badge/discussions-GitHub-blue" alt="GitHub Discussions"></a>
16
16
  </p>
17
17
 
18
18
  ---
19
19
 
20
- GTKX lets you build native Linux desktop applications using React and TypeScript. Write familiar React code that renders as native GTK4 widgets—no Electron, no web views.
21
-
22
- ## Features
23
-
24
- - **React** — Hooks, state, props, and components you already know
25
- - **HMR** — Edit code and see changes instantly via Vite
26
- - **Native** — Direct FFI bindings to GTK4 via Rust and libffi
27
- - **CLI** — `npx @gtkx/cli@latest create` scaffolds a ready-to-go project
28
- - **CSS-in-JS** — Emotion-style `css` template literals for GTK styling
29
- - **Testing** — Testing Library-style `screen`, `userEvent`, and queries
20
+ GTKX lets you write Linux desktop applications using React. Your components render as native GTK4 widgets through a Rust FFI bridge—no webviews, no Electron, just native performance with the developer experience you already know.
30
21
 
31
22
  ## Quick Start
32
23
 
33
24
  ```bash
34
- npx @gtkx/cli@latest create my-app
25
+ npx @gtkx/cli create my-app
35
26
  cd my-app
36
27
  npm run dev
37
28
  ```
38
29
 
39
- Edit your code and see changes instantly—no restart needed.
40
-
41
- ### Example
30
+ ## Example
42
31
 
43
32
  ```tsx
44
- import { render, ApplicationWindow, Box, Button, quit } from "@gtkx/react";
33
+ import {
34
+ GtkApplicationWindow,
35
+ GtkBox,
36
+ GtkButton,
37
+ GtkLabel,
38
+ quit,
39
+ render,
40
+ } from "@gtkx/react";
45
41
  import * as Gtk from "@gtkx/ffi/gtk";
46
42
  import { useState } from "react";
47
43
 
@@ -49,67 +45,59 @@ const App = () => {
49
45
  const [count, setCount] = useState(0);
50
46
 
51
47
  return (
52
- <ApplicationWindow title="Counter" onCloseRequest={quit}>
53
- <Box orientation={Gtk.Orientation.VERTICAL} spacing={12}>
54
- {`Count: ${count}`}
55
- <Button label="Increment" onClicked={() => setCount((c) => c + 1)} />
56
- </Box>
57
- </ApplicationWindow>
48
+ <GtkApplicationWindow
49
+ title="Counter"
50
+ defaultWidth={300}
51
+ defaultHeight={200}
52
+ onCloseRequest={quit}
53
+ >
54
+ <GtkBox
55
+ orientation={Gtk.Orientation.VERTICAL}
56
+ spacing={20}
57
+ valign={Gtk.Align.CENTER}
58
+ >
59
+ <GtkLabel label={`Count: ${count}`} cssClasses={["title-1"]} />
60
+ <GtkButton label="Increment" onClicked={() => setCount((c) => c + 1)} />
61
+ </GtkBox>
62
+ </GtkApplicationWindow>
58
63
  );
59
64
  };
60
65
 
61
- render(<App />, "org.example.Counter");
66
+ render(<App />, "com.example.counter");
62
67
  ```
63
68
 
64
- ## Styling
65
-
66
- ```tsx
67
- import { css } from "@gtkx/css";
68
- import { Button } from "@gtkx/react";
69
-
70
- const primary = css`
71
- padding: 16px 32px;
72
- border-radius: 24px;
73
- background: linear-gradient(135deg, #3584e4, #9141ac);
74
- color: white;
75
- `;
76
-
77
- <Button label="Click me" cssClasses={[primary]} />;
78
- ```
79
-
80
- ## Testing
81
-
82
- ```tsx
83
- import { cleanup, render, screen, userEvent } from "@gtkx/testing";
84
- import * as Gtk from "@gtkx/ffi/gtk";
85
-
86
- afterEach(() => cleanup());
69
+ ## Features
87
70
 
88
- test("increments count", async () => {
89
- await render(<App />);
71
+ - **React 19** — Hooks, concurrent features, and the component model you know
72
+ - **Native GTK4 widgets** — Real native controls, not web components in a webview
73
+ - **Adwaita support** — Modern GNOME styling with Libadwaita components
74
+ - **Hot Module Replacement** — Fast refresh during development
75
+ - **TypeScript first** — Full type safety with auto-generated bindings
76
+ - **CSS-in-JS styling** — Familiar styling patterns adapted for GTK
77
+ - **Testing utilities** — Component testing similar to Testing Library
90
78
 
91
- const button = await screen.findByRole(Gtk.AccessibleRole.BUTTON, {
92
- name: "Increment",
93
- });
79
+ ## Examples
94
80
 
95
- await userEvent.click(button);
81
+ Explore complete applications in the [`examples/`](./examples) directory:
96
82
 
97
- await screen.findByText("Count: 1");
98
- });
99
- ```
83
+ - **[gtk-demo](./examples/gtk-demo)** — Full replica of the official GTK demo app
84
+ - **[hello-world](./examples/hello-world)** — Minimal application showing a counter
85
+ - **[todo](./examples/todo)** — Full-featured todo application with Adwaita styling and testing
86
+ - **[deploying](./examples/deploying)** — Example of packaging and distributing a GTKX app
100
87
 
101
- ## Requirements
88
+ ## Documentation
102
89
 
103
- - Node.js 20+ (Deno support experimental)
104
- - GTK4 Runtime (`gtk4` on Fedora, `libgtk-4-1` on Ubuntu)
90
+ Visit [https://eugeniodepalo.github.io/gtkx](https://eugeniodepalo.github.io/gtkx/) for the full documentation.
105
91
 
106
92
  ## Contributing
107
93
 
108
- We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
94
+ Contributions are welcome! Please see the [contributing guidelines](./CONTRIBUTING.md) and check out the [good first issues](https://github.com/eugeniodepalo/gtkx/labels/good%20first%20issue).
95
+
96
+ ## Community
109
97
 
110
- - [Report a bug](https://github.com/eugeniodepalo/gtkx/issues/new?template=bug_report.md)
111
- - [Request a feature](https://github.com/eugeniodepalo/gtkx/issues/new?template=feature_request.md)
98
+ - [GitHub Discussions](https://github.com/eugeniodepalo/gtkx/discussions) — Questions, ideas, and general discussion
99
+ - [Issue Tracker](https://github.com/eugeniodepalo/gtkx/issues) — Bug reports and feature requests
112
100
 
113
101
  ## License
114
102
 
115
- [MPL-2.0](LICENSE)
103
+ [MPL-2.0](./LICENSE)
package/dist/errors.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- export declare class GTKXError extends Error {
1
+ export declare class GtkxError extends Error {
2
2
  widgetType?: string | undefined;
3
3
  componentStack?: string | undefined;
4
4
  constructor(message: string, widgetType?: string | undefined, componentStack?: string | undefined);
5
5
  toString(): string;
6
6
  }
7
- export declare function formatRenderError(error: unknown, widgetType?: string): GTKXError;
8
- export declare function formatBoundaryError(error: unknown): GTKXError;
7
+ export declare function formatRenderError(error: unknown, widgetType?: string): GtkxError;
8
+ export declare function formatBoundaryError(error: unknown): GtkxError;
package/dist/errors.js CHANGED
@@ -1,17 +1,17 @@
1
- export class GTKXError extends Error {
1
+ export class GtkxError extends Error {
2
2
  widgetType;
3
3
  componentStack;
4
4
  constructor(message, widgetType, componentStack) {
5
5
  super(message);
6
6
  this.widgetType = widgetType;
7
7
  this.componentStack = componentStack;
8
- this.name = "GTKXError";
8
+ this.name = "GtkxError";
9
9
  if (Error.captureStackTrace) {
10
- Error.captureStackTrace(this, GTKXError);
10
+ Error.captureStackTrace(this, GtkxError);
11
11
  }
12
12
  }
13
13
  toString() {
14
- const parts = [`GTKXError: ${this.message}`];
14
+ const parts = [`GtkxError: ${this.message}`];
15
15
  if (this.widgetType) {
16
16
  parts.push(`Widget Type: ${this.widgetType}`);
17
17
  }
@@ -22,17 +22,17 @@ export class GTKXError extends Error {
22
22
  }
23
23
  }
24
24
  export function formatRenderError(error, widgetType) {
25
- if (error instanceof GTKXError) {
25
+ if (error instanceof GtkxError) {
26
26
  return error;
27
27
  }
28
28
  const message = error instanceof Error ? error.message : String(error);
29
29
  const formattedMessage = widgetType ? `Failed to render ${widgetType}: ${message}` : `Render error: ${message}`;
30
- return new GTKXError(formattedMessage, widgetType);
30
+ return new GtkxError(formattedMessage, widgetType);
31
31
  }
32
32
  export function formatBoundaryError(error) {
33
- if (error instanceof GTKXError) {
33
+ if (error instanceof GtkxError) {
34
34
  return error;
35
35
  }
36
36
  const message = error instanceof Error ? error.message : String(error);
37
- return new GTKXError(`Error caught by boundary: ${message}`);
37
+ return new GtkxError(`Error caught by boundary: ${message}`);
38
38
  }
package/dist/factory.d.ts CHANGED
@@ -1,6 +1,4 @@
1
- import type * as Gtk from "@gtkx/ffi/gtk";
2
1
  import type { Node } from "./node.js";
3
- import { type ROOT_NODE_CONTAINER } from "./nodes/root.js";
4
- export type Props = Record<string, unknown>;
5
- export { ROOT_NODE_CONTAINER } from "./nodes/root.js";
6
- export declare const createNode: (type: string, props: Props, widget?: Gtk.Widget | typeof ROOT_NODE_CONTAINER) => Node;
2
+ import type { Container, Props } from "./types.js";
3
+ import "./nodes/index.js";
4
+ export declare const createNode: (typeName: string, props: Props, existingContainer?: Container, rootContainer?: Container) => Node;
package/dist/factory.js CHANGED
@@ -1,75 +1,22 @@
1
- import { AboutDialogNode } from "./nodes/about-dialog.js";
2
- import { ActionBarNode } from "./nodes/action-bar.js";
3
- import { ColumnViewColumnNode, ColumnViewItemNode, ColumnViewNode } from "./nodes/column-view.js";
4
- import { ComboRowNode } from "./nodes/combo-row.js";
5
- import { DropDownItemNode, DropDownNode } from "./nodes/drop-down.js";
6
- import { FlowBoxNode } from "./nodes/flow-box.js";
7
- import { GridChildNode, GridNode } from "./nodes/grid.js";
8
- import { AdwHeaderBarNode, HeaderBarNode, PackEndNode, PackStartNode } from "./nodes/header-bar.js";
9
- import { ListBoxNode } from "./nodes/list-box.js";
10
- import { ListItemNode, ListViewNode } from "./nodes/list-view.js";
11
- import { ApplicationMenuNode, MenuItemNode, MenuSectionNode, MenuSubmenuNode, PopoverMenuBarNode, PopoverMenuRootNode, } from "./nodes/menu.js";
12
- import { NotebookNode, NotebookPageNode } from "./nodes/notebook.js";
13
- import { OverlayNode } from "./nodes/overlay.js";
14
- import { RootNode } from "./nodes/root.js";
15
- import { SlotNode } from "./nodes/slot.js";
16
- import { StackNode, StackPageNode } from "./nodes/stack.js";
17
- import { TextViewNode } from "./nodes/text-view.js";
18
- import { ToggleButtonNode } from "./nodes/toggle-button.js";
19
- import { ToolbarViewSlotNode } from "./nodes/toolbar-view.js";
20
- import { ViewStackNode } from "./nodes/view-stack.js";
21
- import { WidgetNode } from "./nodes/widget.js";
22
- import { WindowNode } from "./nodes/window.js";
23
- export { ROOT_NODE_CONTAINER } from "./nodes/root.js";
24
- const VIRTUAL_NODES = [
25
- ColumnViewColumnNode,
26
- ColumnViewItemNode,
27
- ListItemNode,
28
- DropDownItemNode,
29
- GridChildNode,
30
- NotebookPageNode,
31
- StackPageNode,
32
- MenuItemNode,
33
- MenuSectionNode,
34
- MenuSubmenuNode,
35
- ToolbarViewSlotNode,
36
- PackStartNode,
37
- PackEndNode,
38
- SlotNode,
39
- ];
40
- const SPECIALIZED_NODES = [
41
- WindowNode,
42
- AboutDialogNode,
43
- TextViewNode,
44
- ToggleButtonNode,
45
- ApplicationMenuNode,
46
- PopoverMenuRootNode,
47
- PopoverMenuBarNode,
48
- ];
49
- const CONTAINER_NODES = [
50
- ActionBarNode,
51
- FlowBoxNode,
52
- ListBoxNode,
53
- DropDownNode,
54
- ComboRowNode,
55
- GridNode,
56
- OverlayNode,
57
- ColumnViewNode,
58
- ListViewNode,
59
- NotebookNode,
60
- StackNode,
61
- ViewStackNode,
62
- AdwHeaderBarNode,
63
- HeaderBarNode,
64
- ];
65
- const NODE_CLASSES = [RootNode, ...VIRTUAL_NODES, ...SPECIALIZED_NODES, ...CONTAINER_NODES, WidgetNode];
66
- export const createNode = (type, props, widget) => {
1
+ import { NAMESPACE_REGISTRY } from "./generated/registry.js";
2
+ import { NODE_CLASSES } from "./registry.js";
3
+ import "./nodes/index.js";
4
+ const resolveContainerClass = (type) => {
5
+ for (const [prefix, namespace] of NAMESPACE_REGISTRY) {
6
+ if (type.startsWith(prefix)) {
7
+ const className = type.slice(prefix.length);
8
+ return namespace[className];
9
+ }
10
+ }
11
+ };
12
+ export const createNode = (typeName, props, existingContainer, rootContainer) => {
13
+ const containerClass = resolveContainerClass(typeName);
67
14
  for (const NodeClass of NODE_CLASSES) {
68
- if (NodeClass.matches(type, widget)) {
69
- const node = new NodeClass(type, widget);
70
- node.initialize(props);
71
- return node;
15
+ if (NodeClass.matches(typeName, existingContainer ?? containerClass)) {
16
+ const container = existingContainer ??
17
+ (containerClass && NodeClass.createContainer(props, containerClass, rootContainer));
18
+ return new NodeClass(typeName, props, container, rootContainer);
72
19
  }
73
20
  }
74
- throw new Error(`No matching node class for type: ${type}`);
21
+ throw new Error(`Unable to find node class for type '${typeName}'`);
75
22
  };
@@ -1,3 +1,3 @@
1
1
  import type * as Gtk from "@gtkx/ffi/gtk";
2
2
  import type Reconciler from "react-reconciler";
3
- export declare const createFiberRoot: (container?: Gtk.Widget) => Reconciler.FiberRoot;
3
+ export declare const createFiberRoot: (container: Gtk.Widget) => Reconciler.FiberRoot;
@@ -1,6 +1,5 @@
1
- import { ROOT_NODE_CONTAINER } from "./factory.js";
2
1
  import { reconciler } from "./reconciler.js";
3
2
  export const createFiberRoot = (container) => {
4
3
  const instance = reconciler.getInstance();
5
- return instance.createContainer(container ?? ROOT_NODE_CONTAINER, 0, null, false, null, "", (error) => console.error("Fiber root render error:", error), () => { }, () => { }, () => { }, null);
4
+ return instance.createContainer(container, 0, null, false, null, "", (error) => console.error("Fiber root render error:", error), () => { }, () => { }, () => { }, null);
6
5
  };
@@ -1,7 +1,4 @@
1
1
  /** Internal metadata for the reconciler. Not part of the public API. */
2
- export declare const CONSTRUCTOR_PARAMS: Record<string, {
3
- name: string;
4
- hasDefault: boolean;
5
- }[]>;
6
- export declare const PROP_SETTERS: Record<string, Record<string, string>>;
7
- export declare const SETTER_GETTERS: Record<string, Record<string, string>>;
2
+ export declare const CONSTRUCTOR_PROPS: Record<string, string[]>;
3
+ export declare const PROPS: Record<string, Record<string, [string | null, string]>>;
4
+ export declare const SIGNALS: Record<string, Set<string>>;