@gtkx/react 0.11.1 → 0.12.1
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/dist/generated/jsx.d.ts +9298 -355
- package/dist/generated/jsx.js +8943 -0
- package/dist/host-config.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/jsx.d.ts +6 -6
- package/dist/nodes/internal/list-item-renderer.js +5 -5
- package/dist/nodes/internal/signal-store.js +3 -3
- package/dist/nodes/internal/tree-list-item-renderer.js +5 -5
- package/dist/nodes/slot.d.ts +2 -1
- package/dist/reconciler.d.ts +24 -0
- package/dist/reconciler.js +24 -0
- package/dist/render.d.ts +9 -0
- package/dist/render.js +11 -0
- package/package.json +3 -3
package/dist/host-config.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { beginBatch, endBatch,
|
|
1
|
+
import { beginBatch, endBatch, getNativeId } from "@gtkx/ffi";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { createNode } from "./factory.js";
|
|
4
4
|
import { signalStore } from "./nodes/internal/signal-store.js";
|
|
@@ -8,7 +8,7 @@ if (!globalThis.__GTKX_CONTAINER_NODE_CACHE__) {
|
|
|
8
8
|
}
|
|
9
9
|
const containerNodeCache = globalThis.__GTKX_CONTAINER_NODE_CACHE__;
|
|
10
10
|
const getOrCreateContainerNode = (container) => {
|
|
11
|
-
const id =
|
|
11
|
+
const id = getNativeId(container.handle);
|
|
12
12
|
let node = containerNodeCache.get(id);
|
|
13
13
|
if (!node) {
|
|
14
14
|
const type = container.constructor.glibTypeName;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export * from "./jsx.js";
|
|
2
2
|
export { createPortal } from "./portal.js";
|
|
3
3
|
export { reconciler } from "./reconciler.js";
|
|
4
|
-
export { ApplicationContext, quit, render, setHotReloading, update, useApplication } from "./render.js";
|
|
4
|
+
export { ApplicationContext, getApplication, quit, render, setHotReloading, update, useApplication, } from "./render.js";
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export * from "./jsx.js";
|
|
2
2
|
export { createPortal } from "./portal.js";
|
|
3
3
|
export { reconciler } from "./reconciler.js";
|
|
4
|
-
export { ApplicationContext, quit, render, setHotReloading, update, useApplication } from "./render.js";
|
|
4
|
+
export { ApplicationContext, getApplication, quit, render, setHotReloading, update, useApplication, } from "./render.js";
|
package/dist/jsx.d.ts
CHANGED
|
@@ -84,7 +84,7 @@ export type StringListItemProps = {
|
|
|
84
84
|
*
|
|
85
85
|
* @see {@link GridChild} for usage
|
|
86
86
|
*/
|
|
87
|
-
export type GridChildProps = SlotProps & {
|
|
87
|
+
export type GridChildProps = Omit<SlotProps, "id"> & {
|
|
88
88
|
/** Column index (0-based) */
|
|
89
89
|
column?: number;
|
|
90
90
|
/** Row index (0-based) */
|
|
@@ -99,7 +99,7 @@ export type GridChildProps = SlotProps & {
|
|
|
99
99
|
*
|
|
100
100
|
* @see {@link FixedChild} for usage
|
|
101
101
|
*/
|
|
102
|
-
export type FixedChildProps = SlotProps & {
|
|
102
|
+
export type FixedChildProps = Omit<SlotProps, "id"> & {
|
|
103
103
|
/** X coordinate in pixels */
|
|
104
104
|
x?: number;
|
|
105
105
|
/** Y coordinate in pixels */
|
|
@@ -153,7 +153,7 @@ export type ColumnViewRootProps<C extends string = string> = {
|
|
|
153
153
|
/**
|
|
154
154
|
* Props for notebook (tabbed) pages.
|
|
155
155
|
*/
|
|
156
|
-
export type NotebookPageProps = SlotProps & {
|
|
156
|
+
export type NotebookPageProps = Omit<SlotProps, "id"> & {
|
|
157
157
|
/** Tab label text (optional when using Notebook.PageTab) */
|
|
158
158
|
label?: string;
|
|
159
159
|
};
|
|
@@ -164,7 +164,7 @@ export type NotebookPageTabProps = SlotProps;
|
|
|
164
164
|
/**
|
|
165
165
|
* Props for the root Stack component.
|
|
166
166
|
*/
|
|
167
|
-
export type StackRootProps = SlotProps & {
|
|
167
|
+
export type StackRootProps = Omit<SlotProps, "id"> & {
|
|
168
168
|
/** Name of the currently visible child page */
|
|
169
169
|
visibleChildName?: string;
|
|
170
170
|
};
|
|
@@ -173,7 +173,7 @@ export type StackRootProps = SlotProps & {
|
|
|
173
173
|
*
|
|
174
174
|
* @see {@link StackPage} for usage
|
|
175
175
|
*/
|
|
176
|
-
export type StackPageProps = SlotProps & {
|
|
176
|
+
export type StackPageProps = Omit<SlotProps, "id"> & {
|
|
177
177
|
/** Unique name for this page (used with visibleChildName) */
|
|
178
178
|
name?: string;
|
|
179
179
|
/** Display title shown in stack switchers */
|
|
@@ -227,7 +227,7 @@ export type MenuSubmenuProps = {
|
|
|
227
227
|
/**
|
|
228
228
|
* Props for children within an Overlay container.
|
|
229
229
|
*/
|
|
230
|
-
export type OverlayChildProps = SlotProps & {
|
|
230
|
+
export type OverlayChildProps = Omit<SlotProps, "id"> & {
|
|
231
231
|
/** Whether to include this child in size measurement */
|
|
232
232
|
measure?: boolean;
|
|
233
233
|
/** Whether to clip this overlay child to the main child bounds */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getNativeId } from "@gtkx/ffi";
|
|
2
2
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
3
3
|
import { createFiberRoot } from "../../fiber-root.js";
|
|
4
4
|
import { reconciler } from "../../reconciler.js";
|
|
@@ -29,7 +29,7 @@ export class ListItemRenderer {
|
|
|
29
29
|
}
|
|
30
30
|
initialize() {
|
|
31
31
|
signalStore.set(this, this.factory, "setup", (_self, listItem) => {
|
|
32
|
-
const ptr =
|
|
32
|
+
const ptr = getNativeId(listItem.handle);
|
|
33
33
|
const box = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
|
|
34
34
|
listItem.setChild(box);
|
|
35
35
|
const fiberRoot = createFiberRoot(box);
|
|
@@ -38,7 +38,7 @@ export class ListItemRenderer {
|
|
|
38
38
|
reconciler.getInstance().updateContainer(element, fiberRoot, null, () => { });
|
|
39
39
|
});
|
|
40
40
|
signalStore.set(this, this.factory, "bind", (_self, listItem) => {
|
|
41
|
-
const ptr =
|
|
41
|
+
const ptr = getNativeId(listItem.handle);
|
|
42
42
|
const fiberRoot = this.fiberRoots.get(ptr);
|
|
43
43
|
if (!fiberRoot)
|
|
44
44
|
return;
|
|
@@ -50,14 +50,14 @@ export class ListItemRenderer {
|
|
|
50
50
|
reconciler.getInstance().updateContainer(element, fiberRoot, null, () => { });
|
|
51
51
|
});
|
|
52
52
|
signalStore.set(this, this.factory, "unbind", (_self, listItem) => {
|
|
53
|
-
const ptr =
|
|
53
|
+
const ptr = getNativeId(listItem.handle);
|
|
54
54
|
const fiberRoot = this.fiberRoots.get(ptr);
|
|
55
55
|
if (!fiberRoot)
|
|
56
56
|
return;
|
|
57
57
|
reconciler.getInstance().updateContainer(null, fiberRoot, null, () => { });
|
|
58
58
|
});
|
|
59
59
|
signalStore.set(this, this.factory, "teardown", (_self, listItem) => {
|
|
60
|
-
const ptr =
|
|
60
|
+
const ptr = getNativeId(listItem.handle);
|
|
61
61
|
const fiberRoot = this.fiberRoots.get(ptr);
|
|
62
62
|
if (fiberRoot) {
|
|
63
63
|
reconciler.getInstance().updateContainer(null, fiberRoot, null, () => { });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getNativeId } from "@gtkx/ffi";
|
|
2
2
|
import * as GObject from "@gtkx/ffi/gobject";
|
|
3
3
|
const LIFECYCLE_SIGNALS = new Set([
|
|
4
4
|
"realize",
|
|
@@ -27,7 +27,7 @@ class SignalStore {
|
|
|
27
27
|
return map;
|
|
28
28
|
}
|
|
29
29
|
disconnect(owner, obj, signal) {
|
|
30
|
-
const objectId =
|
|
30
|
+
const objectId = getNativeId(obj.handle);
|
|
31
31
|
const key = `${objectId}:${signal}`;
|
|
32
32
|
const ownerMap = this.ownerHandlers.get(owner);
|
|
33
33
|
const existing = ownerMap?.get(key);
|
|
@@ -37,7 +37,7 @@ class SignalStore {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
connect(owner, obj, signal, handler) {
|
|
40
|
-
const objectId =
|
|
40
|
+
const objectId = getNativeId(obj.handle);
|
|
41
41
|
const key = `${objectId}:${signal}`;
|
|
42
42
|
const handlerId = obj.connect(signal, handler);
|
|
43
43
|
this.getOwnerMap(owner).set(key, { obj, handlerId });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getNativeId } from "@gtkx/ffi";
|
|
2
2
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
3
3
|
import { createFiberRoot } from "../../fiber-root.js";
|
|
4
4
|
import { reconciler } from "../../reconciler.js";
|
|
@@ -29,7 +29,7 @@ export class TreeListItemRenderer {
|
|
|
29
29
|
}
|
|
30
30
|
initialize() {
|
|
31
31
|
signalStore.set(this, this.factory, "setup", (_self, listItem) => {
|
|
32
|
-
const ptr =
|
|
32
|
+
const ptr = getNativeId(listItem.handle);
|
|
33
33
|
const expander = new Gtk.TreeExpander();
|
|
34
34
|
const box = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
|
|
35
35
|
expander.setChild(box);
|
|
@@ -40,7 +40,7 @@ export class TreeListItemRenderer {
|
|
|
40
40
|
reconciler.getInstance().updateContainer(element, fiberRoot, null, () => { });
|
|
41
41
|
});
|
|
42
42
|
signalStore.set(this, this.factory, "bind", (_self, listItem) => {
|
|
43
|
-
const ptr =
|
|
43
|
+
const ptr = getNativeId(listItem.handle);
|
|
44
44
|
const fiberRoot = this.fiberRoots.get(ptr);
|
|
45
45
|
if (!fiberRoot)
|
|
46
46
|
return;
|
|
@@ -71,7 +71,7 @@ export class TreeListItemRenderer {
|
|
|
71
71
|
reconciler.getInstance().updateContainer(element, fiberRoot, null, () => { });
|
|
72
72
|
});
|
|
73
73
|
signalStore.set(this, this.factory, "unbind", (_self, listItem) => {
|
|
74
|
-
const ptr =
|
|
74
|
+
const ptr = getNativeId(listItem.handle);
|
|
75
75
|
const fiberRoot = this.fiberRoots.get(ptr);
|
|
76
76
|
if (!fiberRoot)
|
|
77
77
|
return;
|
|
@@ -82,7 +82,7 @@ export class TreeListItemRenderer {
|
|
|
82
82
|
reconciler.getInstance().updateContainer(null, fiberRoot, null, () => { });
|
|
83
83
|
});
|
|
84
84
|
signalStore.set(this, this.factory, "teardown", (_self, listItem) => {
|
|
85
|
-
const ptr =
|
|
85
|
+
const ptr = getNativeId(listItem.handle);
|
|
86
86
|
const fiberRoot = this.fiberRoots.get(ptr);
|
|
87
87
|
if (fiberRoot) {
|
|
88
88
|
reconciler.getInstance().updateContainer(null, fiberRoot, null, () => { });
|
package/dist/nodes/slot.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type * as Gtk from "@gtkx/ffi/gtk";
|
|
2
2
|
import type { SlotProps } from "../jsx.js";
|
|
3
3
|
import type { Node } from "../node.js";
|
|
4
|
+
import type { Props } from "../types.js";
|
|
4
5
|
import { VirtualNode } from "./virtual.js";
|
|
5
6
|
type SlotNodeProps = Omit<SlotProps, "children">;
|
|
6
|
-
export declare class SlotNode<P extends
|
|
7
|
+
export declare class SlotNode<P extends Props = SlotNodeProps> extends VirtualNode<P> {
|
|
7
8
|
static priority: number;
|
|
8
9
|
static matches(type: string): boolean;
|
|
9
10
|
parent?: Gtk.Widget;
|
package/dist/reconciler.d.ts
CHANGED
|
@@ -1,9 +1,33 @@
|
|
|
1
1
|
import { type ReconcilerInstance } from "./host-config.js";
|
|
2
|
+
/**
|
|
3
|
+
* Manages the React reconciler instance for GTKX.
|
|
4
|
+
*
|
|
5
|
+
* This class wraps the React Reconciler and handles initialization
|
|
6
|
+
* including DevTools integration for development environments.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
2
10
|
declare class Reconciler {
|
|
3
11
|
private instance;
|
|
4
12
|
constructor();
|
|
13
|
+
/**
|
|
14
|
+
* Returns the underlying React Reconciler instance.
|
|
15
|
+
*
|
|
16
|
+
* @returns The React Reconciler instance for direct reconciler operations
|
|
17
|
+
*/
|
|
5
18
|
getInstance(): ReconcilerInstance;
|
|
6
19
|
private injectDevTools;
|
|
7
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* The GTKX React reconciler instance.
|
|
23
|
+
*
|
|
24
|
+
* Provides low-level access to the React reconciler for advanced use cases.
|
|
25
|
+
* Most applications should use {@link render} instead.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```tsx
|
|
29
|
+
* const instance = reconciler.getInstance();
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
8
32
|
export declare const reconciler: Reconciler;
|
|
9
33
|
export {};
|
package/dist/reconciler.js
CHANGED
|
@@ -1,12 +1,25 @@
|
|
|
1
1
|
import ReactReconciler from "react-reconciler";
|
|
2
2
|
import packageJson from "../package.json" with { type: "json" };
|
|
3
3
|
import { createHostConfig } from "./host-config.js";
|
|
4
|
+
/**
|
|
5
|
+
* Manages the React reconciler instance for GTKX.
|
|
6
|
+
*
|
|
7
|
+
* This class wraps the React Reconciler and handles initialization
|
|
8
|
+
* including DevTools integration for development environments.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
4
12
|
class Reconciler {
|
|
5
13
|
instance;
|
|
6
14
|
constructor() {
|
|
7
15
|
this.instance = ReactReconciler(createHostConfig());
|
|
8
16
|
this.injectDevTools();
|
|
9
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Returns the underlying React Reconciler instance.
|
|
20
|
+
*
|
|
21
|
+
* @returns The React Reconciler instance for direct reconciler operations
|
|
22
|
+
*/
|
|
10
23
|
getInstance() {
|
|
11
24
|
return this.instance;
|
|
12
25
|
}
|
|
@@ -20,4 +33,15 @@ class Reconciler {
|
|
|
20
33
|
});
|
|
21
34
|
}
|
|
22
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* The GTKX React reconciler instance.
|
|
38
|
+
*
|
|
39
|
+
* Provides low-level access to the React reconciler for advanced use cases.
|
|
40
|
+
* Most applications should use {@link render} instead.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```tsx
|
|
44
|
+
* const instance = reconciler.getInstance();
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
23
47
|
export const reconciler = new Reconciler();
|
package/dist/render.d.ts
CHANGED
|
@@ -35,6 +35,15 @@ export declare const ApplicationContext: React.Context<Gtk.Application | null>;
|
|
|
35
35
|
* @see {@link ApplicationContext} for the underlying context
|
|
36
36
|
*/
|
|
37
37
|
export declare const useApplication: () => Gtk.Application;
|
|
38
|
+
/**
|
|
39
|
+
* Returns the current GTK Application instance.
|
|
40
|
+
*
|
|
41
|
+
* Returns null if no application has been rendered yet.
|
|
42
|
+
* Used by tools that need access to the running application.
|
|
43
|
+
*
|
|
44
|
+
* @returns The current GTK Application or null
|
|
45
|
+
*/
|
|
46
|
+
export declare const getApplication: () => Gtk.Application | null;
|
|
38
47
|
/**
|
|
39
48
|
* Sets the hot reloading state.
|
|
40
49
|
*
|
package/dist/render.js
CHANGED
|
@@ -46,6 +46,17 @@ export const useApplication = () => {
|
|
|
46
46
|
let container = null;
|
|
47
47
|
let app = null;
|
|
48
48
|
let isHotReloading = false;
|
|
49
|
+
/**
|
|
50
|
+
* Returns the current GTK Application instance.
|
|
51
|
+
*
|
|
52
|
+
* Returns null if no application has been rendered yet.
|
|
53
|
+
* Used by tools that need access to the running application.
|
|
54
|
+
*
|
|
55
|
+
* @returns The current GTK Application or null
|
|
56
|
+
*/
|
|
57
|
+
export const getApplication = () => {
|
|
58
|
+
return app;
|
|
59
|
+
};
|
|
49
60
|
/**
|
|
50
61
|
* Sets the hot reloading state.
|
|
51
62
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gtkx/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"description": "Build GTK4 desktop applications with React and TypeScript",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gtkx",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"react-reconciler": "^0.33.0",
|
|
40
|
-
"@gtkx/ffi": "0.
|
|
41
|
-
"@gtkx/gir": "0.
|
|
40
|
+
"@gtkx/ffi": "0.12.1",
|
|
41
|
+
"@gtkx/gir": "0.12.1"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/react-reconciler": "^0.32.3"
|