@gtkx/react 0.5.1 → 0.6.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/README.md +6 -28
- package/dist/codegen/jsx-generator.d.ts +15 -9
- package/dist/codegen/jsx-generator.js +215 -94
- package/dist/factory.js +5 -0
- package/dist/generated/internal.js +9291 -3379
- package/dist/generated/jsx.d.ts +12954 -4396
- package/dist/generated/jsx.js +3672 -171
- package/dist/node.js +25 -7
- package/dist/nodes/header-bar.d.ts +19 -0
- package/dist/nodes/header-bar.js +45 -0
- package/dist/nodes/toolbar-view.d.ts +19 -0
- package/dist/nodes/toolbar-view.js +81 -0
- package/dist/nodes/window.js +11 -2
- package/dist/portal.d.ts +1 -1
- package/dist/portal.js +1 -1
- package/dist/predicates.d.ts +7 -0
- package/dist/predicates.js +4 -0
- package/dist/reconciler.js +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -49,7 +49,7 @@ import {
|
|
|
49
49
|
Label,
|
|
50
50
|
quit,
|
|
51
51
|
} from "@gtkx/react";
|
|
52
|
-
import
|
|
52
|
+
import * as Gtk from "@gtkx/ffi/gtk";
|
|
53
53
|
import { useState } from "react";
|
|
54
54
|
|
|
55
55
|
const App = () => {
|
|
@@ -57,8 +57,8 @@ const App = () => {
|
|
|
57
57
|
|
|
58
58
|
return (
|
|
59
59
|
<ApplicationWindow title="Counter" onCloseRequest={quit}>
|
|
60
|
-
<Box orientation={Orientation.VERTICAL} spacing={12}>
|
|
61
|
-
<Label
|
|
60
|
+
<Box orientation={Gtk.Orientation.VERTICAL} spacing={12}>
|
|
61
|
+
<Label label={`Count: ${count}`} />
|
|
62
62
|
<Button label="Increment" onClicked={() => setCount((c) => c + 1)} />
|
|
63
63
|
</Box>
|
|
64
64
|
</ApplicationWindow>
|
|
@@ -90,45 +90,23 @@ GTK also provides built-in classes like `suggested-action`, `destructive-action`
|
|
|
90
90
|
|
|
91
91
|
```tsx
|
|
92
92
|
import { cleanup, render, screen, userEvent } from "@gtkx/testing";
|
|
93
|
-
import
|
|
93
|
+
import * as Gtk from "@gtkx/ffi/gtk";
|
|
94
94
|
|
|
95
95
|
afterEach(() => cleanup());
|
|
96
96
|
|
|
97
97
|
test("increments count", async () => {
|
|
98
98
|
await render(<App />);
|
|
99
99
|
|
|
100
|
-
const button = await screen.findByRole(AccessibleRole.BUTTON, {
|
|
100
|
+
const button = await screen.findByRole(Gtk.AccessibleRole.BUTTON, {
|
|
101
101
|
name: "Increment",
|
|
102
102
|
});
|
|
103
|
+
|
|
103
104
|
await userEvent.click(button);
|
|
104
105
|
|
|
105
106
|
await screen.findByText("Count: 1");
|
|
106
107
|
});
|
|
107
108
|
```
|
|
108
109
|
|
|
109
|
-
Queries: `findByRole`, `findByText`, `findByLabelText`, `findByTestId`
|
|
110
|
-
|
|
111
|
-
User events: `click`, `dblClick`, `type`, `clear`, `tab`, `selectOptions`
|
|
112
|
-
|
|
113
|
-
## Examples
|
|
114
|
-
|
|
115
|
-
| Example | Description |
|
|
116
|
-
| ------------------------------- | ------------------- |
|
|
117
|
-
| [gtk4-demo](examples/gtk4-demo) | Widget showcase |
|
|
118
|
-
| [todo](examples/todo) | Todo app with tests |
|
|
119
|
-
|
|
120
|
-
## Packages
|
|
121
|
-
|
|
122
|
-
| Package | Description |
|
|
123
|
-
| --------------------------------- | ------------------------------------- |
|
|
124
|
-
| [@gtkx/cli](packages/cli) | CLI with HMR dev server |
|
|
125
|
-
| [@gtkx/react](packages/react) | React reconciler and JSX components |
|
|
126
|
-
| [@gtkx/ffi](packages/ffi) | TypeScript bindings for GTK4/GLib/GIO |
|
|
127
|
-
| [@gtkx/native](packages/native) | Rust native module (libffi bridge) |
|
|
128
|
-
| [@gtkx/css](packages/css) | CSS-in-JS styling |
|
|
129
|
-
| [@gtkx/testing](packages/testing) | Testing utilities |
|
|
130
|
-
| [@gtkx/gir](packages/gir) | GObject Introspection parser |
|
|
131
|
-
|
|
132
110
|
## Requirements
|
|
133
111
|
|
|
134
112
|
- Node.js 20+
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GirClass, GirNamespace, TypeMapper } from "@gtkx/gir";
|
|
1
|
+
import type { GirClass, GirNamespace, TypeMapper, TypeRegistry } from "@gtkx/gir";
|
|
2
2
|
/**
|
|
3
3
|
* Configuration options for the JSX type generator.
|
|
4
4
|
*/
|
|
@@ -21,26 +21,29 @@ interface JsxGeneratorResult {
|
|
|
21
21
|
*/
|
|
22
22
|
export declare class JsxGenerator {
|
|
23
23
|
private typeMapper;
|
|
24
|
-
private
|
|
24
|
+
private typeRegistry;
|
|
25
25
|
private classMap;
|
|
26
|
+
private options;
|
|
26
27
|
private interfaceMap;
|
|
27
|
-
private
|
|
28
|
-
private usedExternalNamespaces;
|
|
28
|
+
private usedNamespaces;
|
|
29
29
|
private widgetPropertyNames;
|
|
30
30
|
private widgetSignalNames;
|
|
31
|
+
private currentNamespace;
|
|
32
|
+
private widgetNamespaceMap;
|
|
31
33
|
/**
|
|
32
34
|
* Creates a new JSX generator.
|
|
33
35
|
* @param typeMapper - TypeMapper for converting GIR types to TypeScript
|
|
36
|
+
* @param typeRegistry - TypeRegistry for cross-namespace type resolution
|
|
37
|
+
* @param classMap - Combined class map with fully qualified names
|
|
34
38
|
* @param options - Generator configuration options
|
|
35
39
|
*/
|
|
36
|
-
constructor(typeMapper: TypeMapper, options?: JsxGeneratorOptions);
|
|
40
|
+
constructor(typeMapper: TypeMapper, typeRegistry: TypeRegistry, classMap: Map<string, GirClass>, options?: JsxGeneratorOptions);
|
|
37
41
|
/**
|
|
38
|
-
* Generates JSX type definitions for all widgets in
|
|
39
|
-
* @param
|
|
40
|
-
* @param classMap - Map of class names to class definitions
|
|
42
|
+
* Generates JSX type definitions for all widgets in the given namespaces.
|
|
43
|
+
* @param namespaces - The parsed GIR namespaces (GTK must be first)
|
|
41
44
|
* @returns Generated TypeScript code as public jsx.ts and internal.ts files
|
|
42
45
|
*/
|
|
43
|
-
generate(
|
|
46
|
+
generate(namespaces: GirNamespace[]): Promise<JsxGeneratorResult>;
|
|
44
47
|
private generateImports;
|
|
45
48
|
private generateInternalImports;
|
|
46
49
|
private generateCommonTypes;
|
|
@@ -49,6 +52,7 @@ export declare class JsxGenerator {
|
|
|
49
52
|
private findWidgets;
|
|
50
53
|
private analyzeContainerCapabilities;
|
|
51
54
|
private generateWidgetPropsInterfaces;
|
|
55
|
+
private getWidgetExportName;
|
|
52
56
|
private generateWidgetProps;
|
|
53
57
|
private getParentPropsName;
|
|
54
58
|
private getRequiredConstructorParams;
|
|
@@ -56,12 +60,14 @@ export declare class JsxGenerator {
|
|
|
56
60
|
private generateConstructorArgsMetadata;
|
|
57
61
|
private generatePropSettersMap;
|
|
58
62
|
private generateSetterGetterMap;
|
|
63
|
+
private collectParentMethodNames;
|
|
59
64
|
private collectAllProperties;
|
|
60
65
|
private getAncestorInterfaces;
|
|
61
66
|
private findInheritedProperty;
|
|
62
67
|
private generateSignalHandler;
|
|
63
68
|
private getSignalParamFfiType;
|
|
64
69
|
private addNamespacePrefix;
|
|
70
|
+
private toJsxPropertyType;
|
|
65
71
|
private buildSignalHandlerType;
|
|
66
72
|
private generateExports;
|
|
67
73
|
private generateApplicationMenuComponents;
|