@gtkx/react 0.11.0 → 0.12.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/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/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/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 +4 -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";
|
|
@@ -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/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,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gtkx/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "Build GTK4 desktop applications with React and TypeScript",
|
|
5
5
|
"keywords": [
|
|
6
|
+
"gtkx",
|
|
6
7
|
"gtk",
|
|
7
8
|
"gtk4",
|
|
8
9
|
"react",
|
|
@@ -36,8 +37,8 @@
|
|
|
36
37
|
],
|
|
37
38
|
"dependencies": {
|
|
38
39
|
"react-reconciler": "^0.33.0",
|
|
39
|
-
"@gtkx/ffi": "0.
|
|
40
|
-
"@gtkx/gir": "0.
|
|
40
|
+
"@gtkx/ffi": "0.12.0",
|
|
41
|
+
"@gtkx/gir": "0.12.0"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
44
|
"@types/react-reconciler": "^0.32.3"
|