@gtkx/react 0.1.14 → 0.1.16
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/nodes/widget.d.ts +4 -0
- package/dist/nodes/widget.js +9 -0
- package/dist/portal.d.ts +1 -0
- package/dist/portal.js +2 -2
- package/dist/reconciler.d.ts +3 -1
- package/dist/reconciler.js +14 -3
- package/dist/render.js +2 -1
- package/package.json +4 -4
package/dist/nodes/widget.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
2
|
import type { Props } from "../factory.js";
|
|
3
3
|
import { Node } from "../node.js";
|
|
4
|
+
export declare class WidgetWrapper extends Node<Gtk.Widget> {
|
|
5
|
+
constructor(widget: Gtk.Widget);
|
|
6
|
+
protected isVirtual(): boolean;
|
|
7
|
+
}
|
|
4
8
|
export declare class WidgetNode extends Node<Gtk.Widget> {
|
|
5
9
|
static matches(_type: string): boolean;
|
|
6
10
|
attachToParent(parent: Node): void;
|
package/dist/nodes/widget.js
CHANGED
|
@@ -14,6 +14,15 @@ const COMBINED_PROPS = [
|
|
|
14
14
|
},
|
|
15
15
|
},
|
|
16
16
|
];
|
|
17
|
+
export class WidgetWrapper extends Node {
|
|
18
|
+
constructor(widget) {
|
|
19
|
+
super("", {});
|
|
20
|
+
this.widget = widget;
|
|
21
|
+
}
|
|
22
|
+
isVirtual() {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
17
26
|
export class WidgetNode extends Node {
|
|
18
27
|
static matches(_type) {
|
|
19
28
|
return true;
|
package/dist/portal.d.ts
CHANGED
package/dist/portal.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const
|
|
1
|
+
export const ROOT_CONTAINER = Symbol("ROOT_CONTAINER");
|
|
2
2
|
export const createPortal = (children, container, key) => {
|
|
3
3
|
return {
|
|
4
4
|
$$typeof: Symbol.for("react.portal"),
|
|
5
5
|
key: key ?? null,
|
|
6
6
|
children,
|
|
7
|
-
containerInfo: container ??
|
|
7
|
+
containerInfo: container ?? ROOT_CONTAINER,
|
|
8
8
|
implementation: null,
|
|
9
9
|
};
|
|
10
10
|
};
|
package/dist/reconciler.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import type * as Gtk from "@gtkx/ffi/gtk";
|
|
|
2
2
|
import type { Application } from "@gtkx/ffi/gtk";
|
|
3
3
|
import Reconciler from "react-reconciler";
|
|
4
4
|
import type { Node } from "./node.js";
|
|
5
|
+
import { ROOT_CONTAINER } from "./portal.js";
|
|
6
|
+
type Container = Gtk.Widget | typeof ROOT_CONTAINER;
|
|
5
7
|
type TextInstance = Node;
|
|
6
8
|
export declare class GtkReconciler {
|
|
7
9
|
private reconciler;
|
|
@@ -13,7 +15,7 @@ export declare class GtkReconciler {
|
|
|
13
15
|
private createHostConfig;
|
|
14
16
|
private createReconcilerContext;
|
|
15
17
|
}
|
|
16
|
-
export declare const reconciler: Reconciler.Reconciler<
|
|
18
|
+
export declare const reconciler: Reconciler.Reconciler<Container, Node<Gtk.Widget | undefined>, TextInstance, never, never, Gtk.Widget>;
|
|
17
19
|
export declare const setCurrentApp: (app: Application) => void;
|
|
18
20
|
export declare const getCurrentApp: () => Application | null;
|
|
19
21
|
export {};
|
package/dist/reconciler.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import Reconciler from "react-reconciler";
|
|
3
3
|
import { createNode } from "./factory.js";
|
|
4
|
+
import { WidgetWrapper } from "./nodes/widget.js";
|
|
5
|
+
import { ROOT_CONTAINER } from "./portal.js";
|
|
4
6
|
export class GtkReconciler {
|
|
5
7
|
reconciler;
|
|
6
8
|
currentApp = null;
|
|
@@ -39,9 +41,18 @@ export class GtkReconciler {
|
|
|
39
41
|
appendChild: (parent, child) => parent.appendChild(child),
|
|
40
42
|
removeChild: (parent, child) => parent.removeChild(child),
|
|
41
43
|
insertBefore: (parent, child, beforeChild) => parent.insertBefore(child, beforeChild),
|
|
42
|
-
removeChildFromContainer: (
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
removeChildFromContainer: (container, child) => {
|
|
45
|
+
if (container !== ROOT_CONTAINER)
|
|
46
|
+
child.detachFromParent(new WidgetWrapper(container));
|
|
47
|
+
},
|
|
48
|
+
appendChildToContainer: (container, child) => {
|
|
49
|
+
if (container !== ROOT_CONTAINER)
|
|
50
|
+
child.attachToParent(new WidgetWrapper(container));
|
|
51
|
+
},
|
|
52
|
+
insertInContainerBefore: (container, child, _beforeChild) => {
|
|
53
|
+
if (container !== ROOT_CONTAINER)
|
|
54
|
+
child.attachToParent(new WidgetWrapper(container));
|
|
55
|
+
},
|
|
45
56
|
prepareForCommit: () => null,
|
|
46
57
|
resetAfterCommit: () => { },
|
|
47
58
|
commitTextUpdate: (textInstance, oldText, newText) => {
|
package/dist/render.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { start } from "@gtkx/ffi";
|
|
2
|
+
import { ROOT_CONTAINER } from "./portal.js";
|
|
2
3
|
import { reconciler, setCurrentApp } from "./reconciler.js";
|
|
3
4
|
export let container = null;
|
|
4
5
|
export const render = (element, appId, flags) => {
|
|
5
6
|
const app = start(appId, flags);
|
|
6
7
|
setCurrentApp(app);
|
|
7
|
-
container = reconciler.createContainer(
|
|
8
|
+
container = reconciler.createContainer(ROOT_CONTAINER, 0, null, false, false, "", (error, info) => {
|
|
8
9
|
console.error("React reconciler error:", error, info);
|
|
9
10
|
}, null, null, null, null);
|
|
10
11
|
reconciler.updateContainer(element, container, null, () => { });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gtkx/react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"description": "Build GTK4 desktop applications with React and TypeScript",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gtk",
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"react-reconciler": "0.33.0",
|
|
40
|
-
"@gtkx/ffi": "0.1.
|
|
40
|
+
"@gtkx/ffi": "0.1.16"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@gtkx/gir": "0.1.
|
|
43
|
+
"@gtkx/gir": "0.1.16"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"react": "19"
|
|
@@ -48,6 +48,6 @@
|
|
|
48
48
|
"scripts": {
|
|
49
49
|
"build": "tsc -b",
|
|
50
50
|
"codegen": "tsx scripts/codegen.ts",
|
|
51
|
-
"test": "
|
|
51
|
+
"test": "vitest run"
|
|
52
52
|
}
|
|
53
53
|
}
|