@gtkx/react 0.1.33 → 0.1.35
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 +8 -8
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/node.js +3 -7
- package/dist/reconciler.d.ts +0 -4
- package/dist/reconciler.js +7 -16
- package/dist/render.js +0 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -119,10 +119,12 @@ import { AccessibleRole } from "@gtkx/ffi/gtk";
|
|
|
119
119
|
import { App } from "./app.js";
|
|
120
120
|
|
|
121
121
|
// Clean up after each test
|
|
122
|
-
afterEach(() =>
|
|
122
|
+
afterEach(async () => {
|
|
123
|
+
await cleanup();
|
|
124
|
+
});
|
|
123
125
|
|
|
124
126
|
test("increments count when clicking button", async () => {
|
|
125
|
-
render(<App />);
|
|
127
|
+
await render(<App />);
|
|
126
128
|
|
|
127
129
|
const button = await screen.findByRole(AccessibleRole.BUTTON, {
|
|
128
130
|
name: "Increment",
|
|
@@ -132,8 +134,8 @@ test("increments count when clicking button", async () => {
|
|
|
132
134
|
await screen.findByText("Count: 1");
|
|
133
135
|
});
|
|
134
136
|
|
|
135
|
-
test("can also use fireEvent for
|
|
136
|
-
render(<App />);
|
|
137
|
+
test("can also use fireEvent for low-level events", async () => {
|
|
138
|
+
await render(<App />);
|
|
137
139
|
|
|
138
140
|
const button = await screen.findByRole(AccessibleRole.BUTTON, {
|
|
139
141
|
name: "Increment",
|
|
@@ -146,10 +148,8 @@ test("can also use fireEvent for synchronous events", async () => {
|
|
|
146
148
|
|
|
147
149
|
### Available APIs
|
|
148
150
|
|
|
149
|
-
**Queries** - Find elements in the rendered tree:
|
|
150
|
-
- `
|
|
151
|
-
- `queryBy*` / `queryAllBy*` - Returns null/empty array if not found
|
|
152
|
-
- `findBy*` / `findAllBy*` - Async, waits for element
|
|
151
|
+
**Queries** - Find elements in the rendered tree (all async):
|
|
152
|
+
- `findBy*` / `findAllBy*` - Waits for element to appear
|
|
153
153
|
|
|
154
154
|
Query types: `ByRole`, `ByText`, `ByLabelText`, `ByTestId`
|
|
155
155
|
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/node.js
CHANGED
|
@@ -154,13 +154,9 @@ export class Node {
|
|
|
154
154
|
if (getterName) {
|
|
155
155
|
const getter = widget[getterName];
|
|
156
156
|
if (typeof getter === "function") {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
catch {
|
|
163
|
-
}
|
|
157
|
+
const currentValue = getter.call(widget);
|
|
158
|
+
if (currentValue === value)
|
|
159
|
+
return;
|
|
164
160
|
}
|
|
165
161
|
}
|
|
166
162
|
setter.call(widget, value);
|
package/dist/reconciler.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Application } from "@gtkx/ffi/gtk";
|
|
2
1
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
3
2
|
import ReactReconciler from "react-reconciler";
|
|
4
3
|
import type { Node } from "./node.js";
|
|
@@ -10,10 +9,7 @@ type FormInstance = never;
|
|
|
10
9
|
type ReconcilerInstance = ReactReconciler.Reconciler<Container, Node, TextInstance, SuspenseInstance, FormInstance, PublicInstance>;
|
|
11
10
|
declare class Reconciler {
|
|
12
11
|
private instance;
|
|
13
|
-
private app;
|
|
14
12
|
constructor();
|
|
15
|
-
getApp(): Application;
|
|
16
|
-
setApp(app: Application): void;
|
|
17
13
|
getInstance(): ReconcilerInstance;
|
|
18
14
|
private createHostConfig;
|
|
19
15
|
private createReconcilerContext;
|
package/dist/reconciler.js
CHANGED
|
@@ -1,22 +1,13 @@
|
|
|
1
|
+
import { getCurrentApp } from "@gtkx/ffi";
|
|
1
2
|
import * as Gtk from "@gtkx/ffi/gtk";
|
|
2
3
|
import React from "react";
|
|
3
4
|
import ReactReconciler from "react-reconciler";
|
|
4
5
|
import { createNode } from "./factory.js";
|
|
5
6
|
class Reconciler {
|
|
6
7
|
instance;
|
|
7
|
-
app = null;
|
|
8
8
|
constructor() {
|
|
9
9
|
this.instance = ReactReconciler(this.createHostConfig());
|
|
10
10
|
}
|
|
11
|
-
getApp() {
|
|
12
|
-
if (!this.app) {
|
|
13
|
-
throw new Error("Tried to get GTK Application before it was set.");
|
|
14
|
-
}
|
|
15
|
-
return this.app;
|
|
16
|
-
}
|
|
17
|
-
setApp(app) {
|
|
18
|
-
this.app = app;
|
|
19
|
-
}
|
|
20
11
|
getInstance() {
|
|
21
12
|
return this.instance;
|
|
22
13
|
}
|
|
@@ -30,15 +21,15 @@ class Reconciler {
|
|
|
30
21
|
getRootHostContext: () => ({}),
|
|
31
22
|
getChildHostContext: (parentHostContext) => parentHostContext,
|
|
32
23
|
shouldSetTextContent: () => false,
|
|
33
|
-
createInstance: (type, props) => createNode(type, props,
|
|
34
|
-
createTextInstance: (text) => createNode("Label.Root", { label: text },
|
|
24
|
+
createInstance: (type, props) => createNode(type, props, getCurrentApp()),
|
|
25
|
+
createTextInstance: (text) => createNode("Label.Root", { label: text }, getCurrentApp()),
|
|
35
26
|
appendInitialChild: (parent, child) => parent.appendChild(child),
|
|
36
27
|
finalizeInitialChildren: () => true,
|
|
37
28
|
commitUpdate: (instance, _type, oldProps, newProps) => {
|
|
38
29
|
instance.updateProps(oldProps, newProps);
|
|
39
30
|
},
|
|
40
31
|
commitMount: (instance) => {
|
|
41
|
-
instance.mount(
|
|
32
|
+
instance.mount(getCurrentApp());
|
|
42
33
|
},
|
|
43
34
|
appendChild: (parent, child) => parent.appendChild(child),
|
|
44
35
|
removeChild: (parent, child) => parent.removeChild(child),
|
|
@@ -81,7 +72,7 @@ class Reconciler {
|
|
|
81
72
|
prepareScopeUpdate: () => { },
|
|
82
73
|
getInstanceFromScope: () => null,
|
|
83
74
|
detachDeletedInstance: (instance) => {
|
|
84
|
-
instance.dispose(
|
|
75
|
+
instance.dispose(getCurrentApp());
|
|
85
76
|
},
|
|
86
77
|
resetFormInstance: () => { },
|
|
87
78
|
requestPostPaintCallback: () => { },
|
|
@@ -102,9 +93,9 @@ class Reconciler {
|
|
|
102
93
|
}
|
|
103
94
|
createNodeFromContainer(container) {
|
|
104
95
|
if (container instanceof Gtk.Widget) {
|
|
105
|
-
return createNode(container.constructor.name, {},
|
|
96
|
+
return createNode(container.constructor.name, {}, getCurrentApp(), container);
|
|
106
97
|
}
|
|
107
|
-
return createNode("Application", {},
|
|
98
|
+
return createNode("Application", {}, getCurrentApp(), container);
|
|
108
99
|
}
|
|
109
100
|
}
|
|
110
101
|
export const reconciler = new Reconciler();
|
package/dist/render.js
CHANGED
|
@@ -4,7 +4,6 @@ export let container = null;
|
|
|
4
4
|
export const render = (element, appId, flags) => {
|
|
5
5
|
const app = start(appId, flags);
|
|
6
6
|
const instance = reconciler.getInstance();
|
|
7
|
-
reconciler.setApp(app);
|
|
8
7
|
container = instance.createContainer(app, 0, null, false, null, "", (error, info) => {
|
|
9
8
|
console.error("Uncaught error in GTKX application:", error, info);
|
|
10
9
|
}, (_error, _info) => { }, (_error, _info) => { }, () => { }, null);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gtkx/react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.35",
|
|
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.35"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@gtkx/gir": "0.1.
|
|
42
|
+
"@gtkx/gir": "0.1.35"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"react": "^19"
|