create-gtkx 0.21.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.
Files changed (55) hide show
  1. package/LICENSE +373 -0
  2. package/bin/create-gtkx.js +5 -0
  3. package/dist/cli.d.ts +24 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +19 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/command.d.ts +65 -0
  8. package/dist/command.d.ts.map +1 -0
  9. package/dist/command.js +69 -0
  10. package/dist/command.js.map +1 -0
  11. package/dist/create.d.ts +3 -0
  12. package/dist/create.d.ts.map +1 -0
  13. package/dist/create.js +7 -0
  14. package/dist/create.js.map +1 -0
  15. package/dist/deps.d.ts +3 -0
  16. package/dist/deps.d.ts.map +1 -0
  17. package/dist/deps.js +51 -0
  18. package/dist/deps.js.map +1 -0
  19. package/dist/index.d.ts +5 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +4 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/options.d.ts +25 -0
  24. package/dist/options.d.ts.map +1 -0
  25. package/dist/options.js +13 -0
  26. package/dist/options.js.map +1 -0
  27. package/dist/scaffolder.d.ts +51 -0
  28. package/dist/scaffolder.d.ts.map +1 -0
  29. package/dist/scaffolder.js +191 -0
  30. package/dist/scaffolder.js.map +1 -0
  31. package/dist/templates.d.ts +11 -0
  32. package/dist/templates.d.ts.map +1 -0
  33. package/dist/templates.js +25 -0
  34. package/dist/templates.js.map +1 -0
  35. package/package.json +65 -0
  36. package/src/cli.ts +21 -0
  37. package/src/command.ts +87 -0
  38. package/src/create.ts +7 -0
  39. package/src/deps.ts +51 -0
  40. package/src/index.ts +4 -0
  41. package/src/options.ts +24 -0
  42. package/src/scaffolder.ts +306 -0
  43. package/src/templates.ts +42 -0
  44. package/templates/claude/EXAMPLES.md.ejs +790 -0
  45. package/templates/claude/SKILL.md.ejs +126 -0
  46. package/templates/claude/WIDGETS.md.ejs +934 -0
  47. package/templates/config/vitest.config.ts.ejs +11 -0
  48. package/templates/gitignore.ejs +4 -0
  49. package/templates/gtkx.config.ts.ejs +6 -0
  50. package/templates/package.json.ejs +16 -0
  51. package/templates/src/app.tsx.ejs +48 -0
  52. package/templates/src/gtkx-env.d.ts.ejs +2 -0
  53. package/templates/src/index.tsx.ejs +4 -0
  54. package/templates/tests/app.test.tsx.ejs +16 -0
  55. package/templates/tsconfig.json.ejs +14 -0
@@ -0,0 +1,126 @@
1
+ ---
2
+ name: developing-gtkx-apps
3
+ description: Build GTK4 desktop applications with GTKX React framework. Use when creating React components that render as native GTK widgets, working with GTK4/Libadwaita UI, handling signals, virtual lists, menus, or building Linux desktop UIs.
4
+ ---
5
+
6
+ # Developing GTKX Applications
7
+
8
+ GTKX renders React components as native GTK4 widgets through a Rust FFI bridge.
9
+
10
+ ## Quick Start
11
+
12
+ ```tsx
13
+ // src/index.tsx
14
+ import { applicationId } from "virtual:gtkx-config";
15
+ import * as Gtk from "@gtkx/gi/gtk";
16
+ import { GtkApplication, GtkApplicationWindow, GtkBox, GtkButton, GtkLabel } from "@gtkx/jsx/gtk";
17
+ import { createRoot, quit } from "@gtkx/react";
18
+
19
+ const App = () => (
20
+ <GtkApplication applicationId={applicationId}>
21
+ <GtkApplicationWindow
22
+ title="My App"
23
+ defaultWidth={800}
24
+ defaultHeight={600}
25
+ onCloseRequest={() => {
26
+ quit();
27
+ return true;
28
+ }}
29
+ >
30
+ <GtkBox orientation={Gtk.Orientation.VERTICAL} spacing={12}>
31
+ <GtkLabel label="Hello, GTKX!" />
32
+ <GtkButton label="Quit" onClicked={quit} />
33
+ </GtkBox>
34
+ </GtkApplicationWindow>
35
+ </GtkApplication>
36
+ );
37
+
38
+ createRoot().render(<App />);
39
+ ```
40
+
41
+ The application id is passed explicitly; the `virtual:gtkx-config` module exposes each field of the resolved `gtkx.config.ts` as a named constant, so the `applicationId` declared there reaches the application through the prop. `createRoot().render()` is called once at module top-level — analogous to `createRoot` in `react-dom`. In dev, `gtkx dev` restarts the Node process whenever a non-component file changes, so this top-level call only ever runs once per process life.
42
+
43
+ ## Essential Patterns
44
+
45
+ ### Layout
46
+
47
+ ```tsx
48
+ <GtkBox orientation={Gtk.Orientation.VERTICAL} spacing={12}>
49
+ <GtkLabel label="Title" />
50
+ <GtkButton label="Click" onClicked={handleClick} />
51
+ </GtkBox>
52
+ ```
53
+
54
+ ### Controlled Input
55
+
56
+ ```tsx
57
+ const [text, setText] = useState("");
58
+ <GtkEntry text={text} onChanged={(e) => setText(e.getText())} />
59
+ ```
60
+
61
+ ### Signals
62
+
63
+ GTK signals map to `on<SignalName>` props: `clicked` → `onClicked`, `toggled` → `onToggled`.
64
+
65
+ ### Widget Slots
66
+
67
+ Some widgets place children in specific slots. A slot is a plain prop on the widget element that accepts a React element; the value replaces the slot's single child:
68
+
69
+ ```tsx
70
+ <GtkPaned startChild={<Sidebar />} endChild={<Content />} />
71
+ ```
72
+
73
+ A project can expose additional widget-typed properties as slots through the `slots` map in `gtkx.config.ts`.
74
+
75
+ ### Container Slots (HeaderBar, ActionBar, ToolbarView, ActionRow, ExpanderRow)
76
+
77
+ Packing slots are also plain props on the widget element (`packStart=`, `packEnd=`, `addTopBar=`, `addPrefix=`, …); each child is appended via the parent method the prop is named after (wrap several in a fragment):
78
+
79
+ ```tsx
80
+ <GtkHeaderBar
81
+ packStart={<GtkButton iconName="go-previous-symbolic" />}
82
+ packEnd={<GtkMenuButton iconName="open-menu-symbolic" />}
83
+ />
84
+ ```
85
+
86
+ A project can expose additional append methods as container slots through the `containerProps` map in `gtkx.config.ts`.
87
+
88
+ ### Animations
89
+
90
+ Animations are first-class components, picked by physics model: `AdwSpringAnimation` (damping/stiffness/mass) or `AdwTimedAnimation` (duration/easing). Import the name from `@gtkx/animate`.
91
+
92
+ ```tsx
93
+ <AdwSpringAnimation
94
+ initial={{ opacity: 0, scale: 0.8 }}
95
+ animate={{ opacity: 1, scale: 1 }}
96
+ damping={0.8}
97
+ stiffness={200}
98
+ animateOnMount
99
+ >
100
+ <GtkLabel label="Animated!" />
101
+ </AdwSpringAnimation>
102
+ ```
103
+
104
+ ```tsx
105
+ <AdwTimedAnimation
106
+ initial={{ opacity: 0 }}
107
+ animate={{ opacity: 1 }}
108
+ duration={300}
109
+ easing={Adw.Easing.EASE_OUT_CUBIC}
110
+ animateOnMount
111
+ >
112
+ <GtkLabel label="Fade in" />
113
+ </AdwTimedAnimation>
114
+ ```
115
+
116
+ ## Key Constraints
117
+
118
+ - GTK is single-threaded: all widget operations on main thread
119
+ - GtkEntry requires two-way binding with `onChanged`
120
+ - Virtual lists need stable object references (immutable data patterns)
121
+ - Use `quit` from `@gtkx/react` to close the application
122
+
123
+ ## References
124
+
125
+ For complete widget API, see [WIDGETS.md](WIDGETS.md).
126
+ For code patterns and examples, see [EXAMPLES.md](EXAMPLES.md).