@gtkx/react 0.1.45 → 0.1.47
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 +1 -1
- package/dist/codegen/jsx-generator.d.ts +22 -0
- package/dist/codegen/jsx-generator.js +155 -17
- package/dist/fiber-root.d.ts +5 -0
- package/dist/fiber-root.js +5 -0
- package/dist/generated/jsx.d.ts +10279 -9
- package/dist/generated/jsx.js +9498 -9
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/node.js +5 -2
- package/dist/nodes/text-view.js +1 -0
- package/dist/portal.d.ts +18 -0
- package/dist/portal.js +18 -0
- package/dist/reconciler.d.ts +9 -0
- package/dist/reconciler.js +9 -0
- package/dist/render.d.ts +19 -0
- package/dist/render.js +19 -0
- package/dist/types.d.ts +9 -0
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -3,4 +3,9 @@ export * from "./generated/jsx.js";
|
|
|
3
3
|
export { createPortal } from "./portal.js";
|
|
4
4
|
export { reconciler } from "./reconciler.js";
|
|
5
5
|
export { render } from "./render.js";
|
|
6
|
+
/**
|
|
7
|
+
* Quits the GTK application and cleans up resources.
|
|
8
|
+
* Unmounts the React tree and stops the GTK main loop.
|
|
9
|
+
* @returns Always returns true (useful for signal handlers)
|
|
10
|
+
*/
|
|
6
11
|
export declare const quit: () => boolean;
|
package/dist/index.js
CHANGED
|
@@ -6,6 +6,11 @@ export { render } from "./render.js";
|
|
|
6
6
|
import { stop } from "@gtkx/ffi";
|
|
7
7
|
import { reconciler } from "./reconciler.js";
|
|
8
8
|
import { container } from "./render.js";
|
|
9
|
+
/**
|
|
10
|
+
* Quits the GTK application and cleans up resources.
|
|
11
|
+
* Unmounts the React tree and stops the GTK main loop.
|
|
12
|
+
* @returns Always returns true (useful for signal handlers)
|
|
13
|
+
*/
|
|
9
14
|
export const quit = () => {
|
|
10
15
|
if (container) {
|
|
11
16
|
reconciler.getInstance().updateContainer(null, container, null, () => {
|
package/dist/node.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as GObject from "@gtkx/ffi/gobject";
|
|
2
2
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
3
|
-
import { CONSTRUCTOR_PARAMS, SETTER_GETTERS } from "./generated/jsx.js";
|
|
3
|
+
import { CONSTRUCTOR_PARAMS, PROP_SETTERS, SETTER_GETTERS } from "./generated/jsx.js";
|
|
4
4
|
import { isAppendable, isRemovable, isSingleChild } from "./predicates.js";
|
|
5
5
|
const extractConstructorArgs = (type, props) => {
|
|
6
6
|
const params = CONSTRUCTOR_PARAMS[type];
|
|
@@ -29,6 +29,7 @@ export class Node {
|
|
|
29
29
|
}
|
|
30
30
|
createWidget(type, props, app) {
|
|
31
31
|
const normalizedType = type.split(".")[0] || type;
|
|
32
|
+
// biome-ignore lint/performance/noDynamicNamespaceImportAccess: dynamic widget creation
|
|
32
33
|
const WidgetClass = Gtk[normalizedType];
|
|
33
34
|
if (!WidgetClass) {
|
|
34
35
|
throw new Error(`Unknown GTK widget type: ${normalizedType}`);
|
|
@@ -146,7 +147,9 @@ export class Node {
|
|
|
146
147
|
this.signalHandlers.set(eventName, handlerId);
|
|
147
148
|
}
|
|
148
149
|
setProperty(widget, key, value) {
|
|
149
|
-
const setterName =
|
|
150
|
+
const setterName = PROP_SETTERS[this.widgetType]?.[key];
|
|
151
|
+
if (!setterName)
|
|
152
|
+
return;
|
|
150
153
|
const setter = widget[setterName];
|
|
151
154
|
if (typeof setter !== "function")
|
|
152
155
|
return;
|
package/dist/nodes/text-view.js
CHANGED
|
@@ -26,6 +26,7 @@ export class TextViewNode extends Node {
|
|
|
26
26
|
if (typeof props.text === "string") {
|
|
27
27
|
setBufferText(this.buffer, props.text);
|
|
28
28
|
}
|
|
29
|
+
// Connect after a microtask to avoid signal firing during widget construction
|
|
29
30
|
queueMicrotask(() => this.connectBufferSignal());
|
|
30
31
|
}
|
|
31
32
|
connectBufferSignal() {
|
package/dist/portal.d.ts
CHANGED
|
@@ -1,2 +1,20 @@
|
|
|
1
1
|
import type { ReactNode, ReactPortal } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a portal that renders children into a different GTK widget container.
|
|
4
|
+
*
|
|
5
|
+
* Similar to ReactDOM.createPortal, this allows you to render a subtree into
|
|
6
|
+
* a different part of the widget tree.
|
|
7
|
+
*
|
|
8
|
+
* When called without a container argument, the portal renders at the root level.
|
|
9
|
+
* This is useful for dialogs which don't need a parent container.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* // Render dialog at root level (no container needed)
|
|
14
|
+
* {createPortal(<AboutDialog programName="My App" />)}
|
|
15
|
+
*
|
|
16
|
+
* // Render into a specific container
|
|
17
|
+
* {createPortal(<Label.Root label="This is in the Box" />, boxRef.current)}
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
2
20
|
export declare const createPortal: (children: ReactNode, container?: unknown, key?: string | null) => ReactPortal;
|
package/dist/portal.js
CHANGED
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
import { ROOT_NODE_CONTAINER } from "./factory.js";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a portal that renders children into a different GTK widget container.
|
|
4
|
+
*
|
|
5
|
+
* Similar to ReactDOM.createPortal, this allows you to render a subtree into
|
|
6
|
+
* a different part of the widget tree.
|
|
7
|
+
*
|
|
8
|
+
* When called without a container argument, the portal renders at the root level.
|
|
9
|
+
* This is useful for dialogs which don't need a parent container.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* // Render dialog at root level (no container needed)
|
|
14
|
+
* {createPortal(<AboutDialog programName="My App" />)}
|
|
15
|
+
*
|
|
16
|
+
* // Render into a specific container
|
|
17
|
+
* {createPortal(<Label.Root label="This is in the Box" />, boxRef.current)}
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
2
20
|
export const createPortal = (children, container, key) => {
|
|
3
21
|
return {
|
|
4
22
|
$$typeof: Symbol.for("react.portal"),
|
package/dist/reconciler.d.ts
CHANGED
|
@@ -8,13 +8,22 @@ type SuspenseInstance = never;
|
|
|
8
8
|
type PublicInstance = Gtk.Widget;
|
|
9
9
|
type FormInstance = never;
|
|
10
10
|
type ReconcilerInstance = ReactReconciler.Reconciler<Container, Node, TextInstance, SuspenseInstance, FormInstance, PublicInstance>;
|
|
11
|
+
/**
|
|
12
|
+
* GTKX React reconciler class.
|
|
13
|
+
*/
|
|
11
14
|
declare class Reconciler {
|
|
12
15
|
private instance;
|
|
16
|
+
/** Creates a new GTK reconciler instance. */
|
|
13
17
|
constructor();
|
|
18
|
+
/**
|
|
19
|
+
* Gets the underlying React reconciler instance.
|
|
20
|
+
* @returns The react-reconciler instance
|
|
21
|
+
*/
|
|
14
22
|
getInstance(): ReconcilerInstance;
|
|
15
23
|
private createHostConfig;
|
|
16
24
|
private createReconcilerContext;
|
|
17
25
|
private createNodeFromContainer;
|
|
18
26
|
}
|
|
27
|
+
/** The singleton GTKX React reconciler instance. */
|
|
19
28
|
export declare const reconciler: Reconciler;
|
|
20
29
|
export {};
|
package/dist/reconciler.js
CHANGED
|
@@ -3,11 +3,19 @@ import React from "react";
|
|
|
3
3
|
import ReactReconciler from "react-reconciler";
|
|
4
4
|
import { beginCommit, endCommit } from "./batch.js";
|
|
5
5
|
import { createNode } from "./factory.js";
|
|
6
|
+
/**
|
|
7
|
+
* GTKX React reconciler class.
|
|
8
|
+
*/
|
|
6
9
|
class Reconciler {
|
|
7
10
|
instance;
|
|
11
|
+
/** Creates a new GTK reconciler instance. */
|
|
8
12
|
constructor() {
|
|
9
13
|
this.instance = ReactReconciler(this.createHostConfig());
|
|
10
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Gets the underlying React reconciler instance.
|
|
17
|
+
* @returns The react-reconciler instance
|
|
18
|
+
*/
|
|
11
19
|
getInstance() {
|
|
12
20
|
return this.instance;
|
|
13
21
|
}
|
|
@@ -100,4 +108,5 @@ class Reconciler {
|
|
|
100
108
|
return createNode(container.constructor.name, {}, getCurrentApp(), container);
|
|
101
109
|
}
|
|
102
110
|
}
|
|
111
|
+
/** The singleton GTKX React reconciler instance. */
|
|
103
112
|
export const reconciler = new Reconciler();
|
package/dist/render.d.ts
CHANGED
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
import type { ApplicationFlags } from "@gtkx/ffi/gio";
|
|
2
2
|
import type { ReactNode } from "react";
|
|
3
|
+
/** The root container for the React reconciler. */
|
|
3
4
|
export declare let container: unknown;
|
|
5
|
+
/**
|
|
6
|
+
* Renders a React element tree as a GTK application.
|
|
7
|
+
* This is the main entry point for GTKX applications.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* render(
|
|
12
|
+
* <ApplicationWindow title="My App">
|
|
13
|
+
* Hello, GTKX!
|
|
14
|
+
* </ApplicationWindow>,
|
|
15
|
+
* "com.example.myapp"
|
|
16
|
+
* );
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @param element - The root React element to render
|
|
20
|
+
* @param appId - The application ID (e.g., "com.example.myapp")
|
|
21
|
+
* @param flags - Optional GIO application flags
|
|
22
|
+
*/
|
|
4
23
|
export declare const render: (element: ReactNode, appId: string, flags?: ApplicationFlags) => void;
|
package/dist/render.js
CHANGED
|
@@ -1,7 +1,26 @@
|
|
|
1
1
|
import { start } from "@gtkx/ffi";
|
|
2
2
|
import { ROOT_NODE_CONTAINER } from "./factory.js";
|
|
3
3
|
import { reconciler } from "./reconciler.js";
|
|
4
|
+
/** The root container for the React reconciler. */
|
|
4
5
|
export let container = null;
|
|
6
|
+
/**
|
|
7
|
+
* Renders a React element tree as a GTK application.
|
|
8
|
+
* This is the main entry point for GTKX applications.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* render(
|
|
13
|
+
* <ApplicationWindow title="My App">
|
|
14
|
+
* Hello, GTKX!
|
|
15
|
+
* </ApplicationWindow>,
|
|
16
|
+
* "com.example.myapp"
|
|
17
|
+
* );
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @param element - The root React element to render
|
|
21
|
+
* @param appId - The application ID (e.g., "com.example.myapp")
|
|
22
|
+
* @param flags - Optional GIO application flags
|
|
23
|
+
*/
|
|
5
24
|
export const render = (element, appId, flags) => {
|
|
6
25
|
start(appId, flags);
|
|
7
26
|
const instance = reconciler.getInstance();
|
package/dist/types.d.ts
CHANGED
|
@@ -11,6 +11,10 @@ export interface GridChildProps extends SlotProps {
|
|
|
11
11
|
columnSpan?: number;
|
|
12
12
|
rowSpan?: number;
|
|
13
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Render function for ListView/GridView items.
|
|
16
|
+
* Called with null during setup (for loading state) and with the actual item during bind.
|
|
17
|
+
*/
|
|
14
18
|
export type RenderItemFn<T> = (item: T | null) => ReactElement;
|
|
15
19
|
export interface ListViewRenderProps<T = unknown> {
|
|
16
20
|
renderItem: RenderItemFn<T>;
|
|
@@ -20,6 +24,11 @@ export interface ColumnViewColumnProps {
|
|
|
20
24
|
expand?: boolean;
|
|
21
25
|
resizable?: boolean;
|
|
22
26
|
fixedWidth?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Render function for column cells.
|
|
29
|
+
* Called with null during setup (for loading state) and with the actual item during bind.
|
|
30
|
+
* Always annotate your callback parameter type to include null, e.g.: `(item: MyItem | null) => ...`
|
|
31
|
+
*/
|
|
23
32
|
renderCell: (item: any) => ReactElement;
|
|
24
33
|
}
|
|
25
34
|
export interface NotebookPageProps extends SlotProps {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gtkx/react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.47",
|
|
4
4
|
"description": "Build GTK4 desktop applications with React and TypeScript",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gtk",
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"react-reconciler": "0.33.0",
|
|
39
|
-
"@gtkx/ffi": "0.1.
|
|
39
|
+
"@gtkx/ffi": "0.1.47"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@gtkx/gir": "0.1.
|
|
42
|
+
"@gtkx/gir": "0.1.47"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"react": "^19"
|