@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.
- package/README.md +55 -67
- package/dist/errors.d.ts +3 -3
- package/dist/errors.js +8 -8
- package/dist/factory.d.ts +3 -5
- package/dist/factory.js +18 -71
- package/dist/fiber-root.d.ts +1 -1
- package/dist/fiber-root.js +1 -2
- package/dist/generated/internal.d.ts +3 -6
- package/dist/generated/internal.js +10386 -13577
- package/dist/generated/jsx.d.ts +914 -808
- package/dist/generated/jsx.js +123 -358
- package/dist/generated/registry.d.ts +4 -0
- package/dist/generated/registry.js +13 -0
- package/dist/host-config.d.ts +7 -4
- package/dist/host-config.js +53 -18
- package/dist/index.d.ts +2 -22
- package/dist/index.js +2 -40
- package/dist/jsx.d.ts +719 -0
- package/dist/jsx.js +392 -0
- package/dist/node.d.ts +15 -32
- package/dist/node.js +20 -240
- package/dist/nodes/action-row-child.d.ts +21 -0
- package/dist/nodes/action-row-child.js +69 -0
- package/dist/nodes/action-row.js +33 -0
- package/dist/nodes/application.d.ts +1 -0
- package/dist/nodes/application.js +38 -0
- package/dist/nodes/autowrapped.d.ts +1 -0
- package/dist/nodes/autowrapped.js +109 -0
- package/dist/nodes/column-view-column.d.ts +16 -0
- package/dist/nodes/column-view-column.js +54 -0
- package/dist/nodes/column-view.d.ts +0 -59
- package/dist/nodes/column-view.js +107 -226
- package/dist/nodes/fixed-child.d.ts +1 -0
- package/dist/nodes/fixed-child.js +45 -0
- package/dist/nodes/grid-child.d.ts +1 -0
- package/dist/nodes/grid-child.js +54 -0
- package/dist/nodes/index.d.ts +34 -0
- package/dist/nodes/index.js +34 -0
- package/dist/nodes/internal/list-item-renderer.d.ts +18 -0
- package/dist/nodes/internal/list-item-renderer.js +67 -0
- package/dist/nodes/internal/list-store.d.ts +16 -0
- package/dist/nodes/internal/list-store.js +69 -0
- package/dist/nodes/internal/predicates.d.ts +26 -0
- package/dist/nodes/internal/predicates.js +36 -0
- package/dist/nodes/internal/signal-store.d.ts +9 -0
- package/dist/nodes/internal/signal-store.js +54 -0
- package/dist/nodes/internal/simple-list-store.d.ts +14 -0
- package/dist/nodes/internal/simple-list-store.js +60 -0
- package/dist/nodes/internal/tree-list-item-renderer.d.ts +18 -0
- package/dist/nodes/internal/tree-list-item-renderer.js +90 -0
- package/dist/nodes/internal/tree-store.d.ts +28 -0
- package/dist/nodes/internal/tree-store.js +153 -0
- package/dist/nodes/internal/utils.d.ts +3 -0
- package/dist/nodes/internal/utils.js +20 -0
- package/dist/nodes/list-item.d.ts +12 -0
- package/dist/nodes/list-item.js +24 -0
- package/dist/nodes/list-view.d.ts +0 -22
- package/dist/nodes/list-view.js +45 -38
- package/dist/nodes/menu.d.ts +6 -106
- package/dist/nodes/menu.js +16 -268
- package/dist/nodes/models/list.d.ts +24 -0
- package/dist/nodes/models/list.js +102 -0
- package/dist/nodes/models/menu.d.ts +45 -0
- package/dist/nodes/models/menu.js +265 -0
- package/dist/nodes/models/tree-list.d.ts +28 -0
- package/dist/nodes/models/tree-list.js +141 -0
- package/dist/nodes/navigation-page.d.ts +21 -0
- package/dist/nodes/navigation-page.js +95 -0
- package/dist/nodes/navigation-view.d.ts +1 -0
- package/dist/nodes/navigation-view.js +29 -0
- package/dist/nodes/notebook-page-tab.d.ts +15 -0
- package/dist/nodes/notebook-page-tab.js +42 -0
- package/dist/nodes/notebook-page.d.ts +23 -0
- package/dist/nodes/notebook-page.js +106 -0
- package/dist/nodes/notebook.d.ts +0 -32
- package/dist/nodes/notebook.js +20 -113
- package/dist/nodes/overlay-child.d.ts +1 -0
- package/dist/nodes/overlay-child.js +30 -0
- package/dist/nodes/pack-child.d.ts +21 -0
- package/dist/nodes/pack-child.js +68 -0
- package/dist/nodes/pack.d.ts +1 -0
- package/dist/nodes/pack.js +33 -0
- package/dist/nodes/popover-menu.d.ts +1 -0
- package/dist/nodes/popover-menu.js +58 -0
- package/dist/nodes/simple-list-item.d.ts +9 -0
- package/dist/nodes/simple-list-item.js +9 -0
- package/dist/nodes/simple-list-view.d.ts +1 -0
- package/dist/nodes/simple-list-view.js +75 -0
- package/dist/nodes/slot.d.ts +18 -10
- package/dist/nodes/slot.js +83 -51
- package/dist/nodes/stack-page.d.ts +1 -0
- package/dist/nodes/stack-page.js +80 -0
- package/dist/nodes/stack.d.ts +1 -22
- package/dist/nodes/stack.js +21 -60
- package/dist/nodes/toast-overlay.d.ts +1 -0
- package/dist/nodes/toast-overlay.js +35 -0
- package/dist/nodes/toast.d.ts +17 -0
- package/dist/nodes/toast.js +77 -0
- package/dist/nodes/toolbar-child.d.ts +9 -0
- package/dist/nodes/toolbar-child.js +33 -0
- package/dist/nodes/toolbar.d.ts +1 -0
- package/dist/nodes/toolbar.js +42 -0
- package/dist/nodes/tree-list-item.d.ts +20 -0
- package/dist/nodes/tree-list-item.js +102 -0
- package/dist/nodes/tree-list-view.d.ts +1 -0
- package/dist/nodes/tree-list-view.js +57 -0
- package/dist/nodes/virtual.d.ts +13 -0
- package/dist/nodes/virtual.js +21 -0
- package/dist/nodes/widget.d.ts +17 -3
- package/dist/nodes/widget.js +258 -2
- package/dist/nodes/window.d.ts +1 -12
- package/dist/nodes/window.js +66 -27
- package/dist/portal.d.ts +18 -13
- package/dist/portal.js +17 -14
- package/dist/reconciler.d.ts +0 -4
- package/dist/reconciler.js +1 -9
- package/dist/registry.d.ts +8 -0
- package/dist/registry.js +5 -0
- package/dist/render.d.ts +108 -12
- package/dist/render.js +140 -16
- package/dist/scheduler.d.ts +4 -0
- package/dist/scheduler.js +10 -0
- package/dist/types.d.ts +3 -136
- package/package.json +6 -6
- package/dist/batch.d.ts +0 -5
- package/dist/batch.js +0 -31
- package/dist/codegen/jsx-generator.d.ts +0 -56
- package/dist/codegen/jsx-generator.js +0 -959
- package/dist/containers.d.ts +0 -58
- package/dist/nodes/about-dialog.d.ts +0 -8
- package/dist/nodes/about-dialog.js +0 -16
- package/dist/nodes/action-bar.d.ts +0 -5
- package/dist/nodes/action-bar.js +0 -6
- package/dist/nodes/combo-row.d.ts +0 -5
- package/dist/nodes/combo-row.js +0 -6
- package/dist/nodes/drop-down.d.ts +0 -9
- package/dist/nodes/drop-down.js +0 -12
- package/dist/nodes/flow-box.d.ts +0 -10
- package/dist/nodes/flow-box.js +0 -41
- package/dist/nodes/grid.d.ts +0 -30
- package/dist/nodes/grid.js +0 -84
- package/dist/nodes/header-bar.d.ts +0 -43
- package/dist/nodes/header-bar.js +0 -116
- package/dist/nodes/indexed-child-container.d.ts +0 -16
- package/dist/nodes/indexed-child-container.js +0 -22
- package/dist/nodes/list-box.d.ts +0 -10
- package/dist/nodes/list-box.js +0 -48
- package/dist/nodes/list-item-factory.d.ts +0 -19
- package/dist/nodes/list-item-factory.js +0 -58
- package/dist/nodes/overlay.d.ts +0 -11
- package/dist/nodes/overlay.js +0 -50
- package/dist/nodes/paged-stack.d.ts +0 -31
- package/dist/nodes/paged-stack.js +0 -95
- package/dist/nodes/root.d.ts +0 -8
- package/dist/nodes/root.js +0 -13
- package/dist/nodes/selectable-list.d.ts +0 -45
- package/dist/nodes/selectable-list.js +0 -260
- package/dist/nodes/stack-page-props.d.ts +0 -11
- package/dist/nodes/stack-page-props.js +0 -23
- package/dist/nodes/string-list-container.d.ts +0 -34
- package/dist/nodes/string-list-container.js +0 -118
- package/dist/nodes/string-list-item.d.ts +0 -19
- package/dist/nodes/string-list-item.js +0 -50
- package/dist/nodes/string-list-store.d.ts +0 -13
- package/dist/nodes/string-list-store.js +0 -44
- package/dist/nodes/text-view.d.ts +0 -8
- package/dist/nodes/text-view.js +0 -16
- package/dist/nodes/toggle-button.d.ts +0 -14
- package/dist/nodes/toggle-button.js +0 -39
- package/dist/nodes/toolbar-view.d.ts +0 -14
- package/dist/nodes/toolbar-view.js +0 -78
- package/dist/nodes/view-stack.d.ts +0 -9
- package/dist/nodes/view-stack.js +0 -28
- package/dist/nodes/virtual-item.d.ts +0 -19
- package/dist/nodes/virtual-item.js +0 -48
- package/dist/nodes/virtual-slot.d.ts +0 -25
- package/dist/nodes/virtual-slot.js +0 -57
- package/dist/predicates.d.ts +0 -29
- package/dist/predicates.js +0 -37
- package/dist/props.d.ts +0 -7
- package/dist/props.js +0 -12
- /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/
|
|
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
|
|
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://
|
|
13
|
-
<a href="
|
|
14
|
-
<a href="
|
|
15
|
-
<a href="
|
|
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
|
|
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
|
|
25
|
+
npx @gtkx/cli create my-app
|
|
35
26
|
cd my-app
|
|
36
27
|
npm run dev
|
|
37
28
|
```
|
|
38
29
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
### Example
|
|
30
|
+
## Example
|
|
42
31
|
|
|
43
32
|
```tsx
|
|
44
|
-
import {
|
|
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
|
-
<
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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 />, "
|
|
66
|
+
render(<App />, "com.example.counter");
|
|
62
67
|
```
|
|
63
68
|
|
|
64
|
-
##
|
|
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
|
-
|
|
89
|
-
|
|
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
|
-
|
|
92
|
-
name: "Increment",
|
|
93
|
-
});
|
|
79
|
+
## Examples
|
|
94
80
|
|
|
95
|
-
|
|
81
|
+
Explore complete applications in the [`examples/`](./examples) directory:
|
|
96
82
|
|
|
97
|
-
|
|
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
|
-
##
|
|
88
|
+
## Documentation
|
|
102
89
|
|
|
103
|
-
|
|
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
|
-
|
|
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
|
-
- [
|
|
111
|
-
- [
|
|
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
|
|
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):
|
|
8
|
-
export declare function formatBoundaryError(error: unknown):
|
|
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
|
|
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 = "
|
|
8
|
+
this.name = "GtkxError";
|
|
9
9
|
if (Error.captureStackTrace) {
|
|
10
|
-
Error.captureStackTrace(this,
|
|
10
|
+
Error.captureStackTrace(this, GtkxError);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
toString() {
|
|
14
|
-
const parts = [`
|
|
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
|
|
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
|
|
30
|
+
return new GtkxError(formattedMessage, widgetType);
|
|
31
31
|
}
|
|
32
32
|
export function formatBoundaryError(error) {
|
|
33
|
-
if (error instanceof
|
|
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
|
|
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 {
|
|
4
|
-
|
|
5
|
-
export
|
|
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 {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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(
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
return
|
|
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(`
|
|
21
|
+
throw new Error(`Unable to find node class for type '${typeName}'`);
|
|
75
22
|
};
|
package/dist/fiber-root.d.ts
CHANGED
package/dist/fiber-root.js
CHANGED
|
@@ -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
|
|
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
|
|
3
|
-
|
|
4
|
-
|
|
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>>;
|