@gtkx/cli 0.21.0 → 1.0.0-rc.1
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 +173 -0
- package/bin/gtkx-dev-runner.js +9 -0
- package/dist/builder.d.ts +2 -50
- package/dist/builder.d.ts.map +1 -1
- package/dist/builder.js +22 -56
- package/dist/builder.js.map +1 -1
- package/dist/cli.d.ts +1 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +11 -124
- package/dist/cli.js.map +1 -1
- package/dist/codegen/freshness.d.ts +11 -0
- package/dist/codegen/freshness.d.ts.map +1 -0
- package/dist/codegen/freshness.js +42 -0
- package/dist/codegen/freshness.js.map +1 -0
- package/dist/codegen/report.d.ts +3 -0
- package/dist/codegen/report.d.ts.map +1 -0
- package/dist/codegen/report.js +16 -0
- package/dist/codegen/report.js.map +1 -0
- package/dist/codegen/run-codegen.d.ts +35 -0
- package/dist/codegen/run-codegen.d.ts.map +1 -0
- package/dist/codegen/run-codegen.js +133 -0
- package/dist/codegen/run-codegen.js.map +1 -0
- package/dist/codegen/store-resolver.d.ts +21 -0
- package/dist/codegen/store-resolver.d.ts.map +1 -0
- package/dist/codegen/store-resolver.js +52 -0
- package/dist/codegen/store-resolver.js.map +1 -0
- package/dist/commands/build.d.ts +9 -0
- package/dist/commands/build.d.ts.map +1 -0
- package/dist/commands/build.js +33 -0
- package/dist/commands/build.js.map +1 -0
- package/dist/commands/codegen.d.ts +9 -0
- package/dist/commands/codegen.d.ts.map +1 -0
- package/dist/commands/codegen.js +40 -0
- package/dist/commands/codegen.js.map +1 -0
- package/dist/commands/dev.d.ts +5 -0
- package/dist/commands/dev.d.ts.map +1 -0
- package/dist/commands/dev.js +21 -0
- package/dist/commands/dev.js.map +1 -0
- package/dist/commands/docs.d.ts +19 -0
- package/dist/commands/docs.d.ts.map +1 -0
- package/dist/commands/docs.js +59 -0
- package/dist/commands/docs.js.map +1 -0
- package/dist/dev/icon-dir.d.ts +2 -0
- package/dist/dev/icon-dir.d.ts.map +1 -0
- package/dist/dev/icon-dir.js +13 -0
- package/dist/dev/icon-dir.js.map +1 -0
- package/dist/dev/refresh-tracker.d.ts +6 -0
- package/dist/dev/refresh-tracker.d.ts.map +1 -0
- package/dist/dev/refresh-tracker.js +18 -0
- package/dist/dev/refresh-tracker.js.map +1 -0
- package/dist/dev/runner-deps.d.ts +3 -0
- package/dist/dev/runner-deps.d.ts.map +1 -0
- package/dist/dev/runner-deps.js +39 -0
- package/dist/dev/runner-deps.js.map +1 -0
- package/dist/dev/runner-main.d.ts +2 -0
- package/dist/dev/runner-main.d.ts.map +1 -0
- package/dist/dev/runner-main.js +28 -0
- package/dist/dev/runner-main.js.map +1 -0
- package/dist/dev/runner.d.ts +23 -0
- package/dist/dev/runner.d.ts.map +1 -0
- package/dist/dev/runner.js +88 -0
- package/dist/dev/runner.js.map +1 -0
- package/dist/dev/schema-dir.d.ts +2 -0
- package/dist/dev/schema-dir.d.ts.map +1 -0
- package/dist/dev/schema-dir.js +10 -0
- package/dist/dev/schema-dir.js.map +1 -0
- package/dist/dev/supervisor.d.ts +17 -0
- package/dist/dev/supervisor.d.ts.map +1 -0
- package/dist/dev/supervisor.js +142 -0
- package/dist/dev/supervisor.js.map +1 -0
- package/dist/dev/vite-dev-server.d.ts +21 -0
- package/dist/dev/vite-dev-server.d.ts.map +1 -0
- package/dist/dev/vite-dev-server.js +12 -0
- package/dist/dev/vite-dev-server.js.map +1 -0
- package/dist/internal/banner.d.ts +3 -0
- package/dist/internal/banner.d.ts.map +1 -0
- package/dist/internal/banner.js +8 -0
- package/dist/internal/banner.js.map +1 -0
- package/dist/internal/data-dir.d.ts +3 -0
- package/dist/internal/data-dir.d.ts.map +1 -0
- package/dist/internal/data-dir.js +37 -0
- package/dist/internal/data-dir.js.map +1 -0
- package/dist/internal/entry-arg.d.ts +19 -0
- package/dist/internal/entry-arg.d.ts.map +1 -0
- package/dist/internal/entry-arg.js +33 -0
- package/dist/internal/entry-arg.js.map +1 -0
- package/dist/internal/errors.d.ts +4 -0
- package/dist/internal/errors.d.ts.map +1 -0
- package/dist/internal/errors.js +27 -0
- package/dist/internal/errors.js.map +1 -0
- package/dist/internal/list-files.d.ts +6 -0
- package/dist/internal/list-files.d.ts.map +1 -0
- package/dist/internal/list-files.js +13 -0
- package/dist/internal/list-files.js.map +1 -0
- package/dist/internal/resolve-cli-tool.d.ts +2 -0
- package/dist/internal/resolve-cli-tool.d.ts.map +1 -0
- package/dist/internal/resolve-cli-tool.js +20 -0
- package/dist/internal/resolve-cli-tool.js.map +1 -0
- package/dist/internal/staging-dir.d.ts +3 -0
- package/dist/internal/staging-dir.d.ts.map +1 -0
- package/dist/internal/staging-dir.js +16 -0
- package/dist/internal/staging-dir.js.map +1 -0
- package/dist/internal/xdg-data-dirs.d.ts +2 -0
- package/dist/internal/xdg-data-dirs.d.ts.map +1 -0
- package/dist/internal/xdg-data-dirs.js +8 -0
- package/dist/internal/xdg-data-dirs.js.map +1 -0
- package/dist/mcp/client.d.ts +23 -0
- package/dist/mcp/client.d.ts.map +1 -0
- package/dist/mcp/client.js +157 -0
- package/dist/mcp/client.js.map +1 -0
- package/dist/mcp/handlers.d.ts +8 -0
- package/dist/mcp/handlers.d.ts.map +1 -0
- package/dist/mcp/handlers.js +119 -0
- package/dist/mcp/handlers.js.map +1 -0
- package/dist/mcp/index.d.ts +4 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +17 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/serialize-widget.d.ts +10 -0
- package/dist/mcp/serialize-widget.d.ts.map +1 -0
- package/dist/mcp/serialize-widget.js +20 -0
- package/dist/mcp/serialize-widget.js.map +1 -0
- package/dist/mcp/testing-loader.d.ts +6 -0
- package/dist/mcp/testing-loader.d.ts.map +1 -0
- package/dist/mcp/testing-loader.js +25 -0
- package/dist/mcp/testing-loader.js.map +1 -0
- package/dist/mcp/widget-registry.d.ts +13 -0
- package/dist/mcp/widget-registry.d.ts.map +1 -0
- package/dist/mcp/widget-registry.js +38 -0
- package/dist/mcp/widget-registry.js.map +1 -0
- package/dist/refresh-runtime.d.ts +10 -20
- package/dist/refresh-runtime.d.ts.map +1 -1
- package/dist/refresh-runtime.js +12 -36
- package/dist/refresh-runtime.js.map +1 -1
- package/dist/settings/compile.d.ts +2 -0
- package/dist/settings/compile.d.ts.map +1 -0
- package/dist/settings/compile.js +19 -0
- package/dist/settings/compile.js.map +1 -0
- package/dist/settings/parser.d.ts +23 -0
- package/dist/settings/parser.d.ts.map +1 -0
- package/dist/settings/parser.js +117 -0
- package/dist/settings/parser.js.map +1 -0
- package/dist/settings/render.d.ts +4 -0
- package/dist/settings/render.d.ts.map +1 -0
- package/dist/settings/render.js +148 -0
- package/dist/settings/render.js.map +1 -0
- package/dist/settings/schema.d.ts +13 -0
- package/dist/settings/schema.d.ts.map +1 -0
- package/dist/settings/schema.js +103 -0
- package/dist/settings/schema.js.map +1 -0
- package/dist/vite-plugins/asset-extensions.d.ts +4 -0
- package/dist/vite-plugins/asset-extensions.d.ts.map +1 -0
- package/dist/vite-plugins/asset-extensions.js +27 -0
- package/dist/vite-plugins/asset-extensions.js.map +1 -0
- package/dist/vite-plugins/built-url.d.ts +3 -0
- package/dist/vite-plugins/built-url.d.ts.map +1 -0
- package/dist/{vite-plugin-gtkx-built-url.js → vite-plugins/built-url.js} +4 -17
- package/dist/vite-plugins/built-url.js.map +1 -0
- package/dist/vite-plugins/css.d.ts +3 -0
- package/dist/vite-plugins/css.d.ts.map +1 -0
- package/dist/vite-plugins/css.js +30 -0
- package/dist/vite-plugins/css.js.map +1 -0
- package/dist/vite-plugins/fast-refresh/refresh-filter.d.ts +7 -0
- package/dist/vite-plugins/fast-refresh/refresh-filter.d.ts.map +1 -0
- package/dist/vite-plugins/fast-refresh/refresh-filter.js +15 -0
- package/dist/vite-plugins/fast-refresh/refresh-filter.js.map +1 -0
- package/dist/vite-plugins/fast-refresh/swc-refresh.d.ts +5 -0
- package/dist/vite-plugins/fast-refresh/swc-refresh.d.ts.map +1 -0
- package/dist/vite-plugins/fast-refresh/swc-refresh.js +66 -0
- package/dist/vite-plugins/fast-refresh/swc-refresh.js.map +1 -0
- package/dist/vite-plugins/icons.d.ts +3 -0
- package/dist/vite-plugins/icons.d.ts.map +1 -0
- package/dist/vite-plugins/icons.js +47 -0
- package/dist/vite-plugins/icons.js.map +1 -0
- package/dist/vite-plugins/index.d.ts +3 -0
- package/dist/vite-plugins/index.d.ts.map +1 -0
- package/dist/vite-plugins/index.js +21 -0
- package/dist/vite-plugins/index.js.map +1 -0
- package/dist/vite-plugins/native.d.ts +3 -0
- package/dist/vite-plugins/native.d.ts.map +1 -0
- package/dist/vite-plugins/native.js +60 -0
- package/dist/vite-plugins/native.js.map +1 -0
- package/dist/vite-plugins/react-compiler.d.ts +4 -0
- package/dist/vite-plugins/react-compiler.d.ts.map +1 -0
- package/dist/vite-plugins/react-compiler.js +56 -0
- package/dist/vite-plugins/react-compiler.js.map +1 -0
- package/dist/vite-plugins/react-dom-prebundle.d.ts +3 -0
- package/dist/vite-plugins/react-dom-prebundle.d.ts.map +1 -0
- package/dist/vite-plugins/react-dom-prebundle.js +11 -0
- package/dist/vite-plugins/react-dom-prebundle.js.map +1 -0
- package/dist/vite-plugins/resource-init-module.d.ts +5 -0
- package/dist/vite-plugins/resource-init-module.d.ts.map +1 -0
- package/dist/vite-plugins/resource-init-module.js +50 -0
- package/dist/vite-plugins/resource-init-module.js.map +1 -0
- package/dist/vite-plugins/resource-shared.d.ts +6 -0
- package/dist/vite-plugins/resource-shared.d.ts.map +1 -0
- package/dist/vite-plugins/resource-shared.js +21 -0
- package/dist/vite-plugins/resource-shared.js.map +1 -0
- package/dist/vite-plugins/resources.d.ts +4 -0
- package/dist/vite-plugins/resources.d.ts.map +1 -0
- package/dist/vite-plugins/resources.js +220 -0
- package/dist/vite-plugins/resources.js.map +1 -0
- package/dist/vite-plugins/settings-worker-env.d.ts +3 -0
- package/dist/vite-plugins/settings-worker-env.d.ts.map +1 -0
- package/dist/vite-plugins/settings-worker-env.js +21 -0
- package/dist/vite-plugins/settings-worker-env.js.map +1 -0
- package/dist/vite-plugins/settings.d.ts +3 -0
- package/dist/vite-plugins/settings.d.ts.map +1 -0
- package/dist/vite-plugins/settings.js +190 -0
- package/dist/vite-plugins/settings.js.map +1 -0
- package/dist/vite-plugins/undeclared-library.d.ts +3 -0
- package/dist/vite-plugins/undeclared-library.d.ts.map +1 -0
- package/dist/vite-plugins/undeclared-library.js +47 -0
- package/dist/vite-plugins/undeclared-library.js.map +1 -0
- package/dist/vite-plugins/virtual-module.d.ts +22 -0
- package/dist/vite-plugins/virtual-module.d.ts.map +1 -0
- package/dist/vite-plugins/virtual-module.js +18 -0
- package/dist/vite-plugins/virtual-module.js.map +1 -0
- package/dist/vitest-plugin.d.ts +10 -0
- package/dist/vitest-plugin.d.ts.map +1 -0
- package/dist/vitest-plugin.js +12 -0
- package/dist/vitest-plugin.js.map +1 -0
- package/env.d.ts +131 -8
- package/package.json +32 -38
- package/src/babel-modules.d.ts +13 -0
- package/src/builder.ts +28 -84
- package/src/cli.ts +22 -0
- package/src/codegen/freshness.ts +52 -0
- package/src/codegen/report.ts +20 -0
- package/src/codegen/run-codegen.ts +185 -0
- package/src/codegen/store-resolver.ts +75 -0
- package/src/commands/build.ts +37 -0
- package/src/commands/codegen.ts +44 -0
- package/src/commands/dev.ts +25 -0
- package/src/commands/docs.ts +66 -0
- package/src/dev/icon-dir.ts +11 -0
- package/src/dev/refresh-tracker.ts +21 -0
- package/src/dev/runner-deps.ts +42 -0
- package/src/dev/runner-main.ts +33 -0
- package/src/dev/runner.ts +126 -0
- package/src/dev/schema-dir.ts +11 -0
- package/src/dev/supervisor.ts +178 -0
- package/src/dev/vite-dev-server.ts +34 -0
- package/src/internal/banner.ts +9 -0
- package/src/internal/data-dir.ts +39 -0
- package/src/internal/entry-arg.ts +38 -0
- package/src/internal/errors.ts +28 -0
- package/src/internal/list-files.ts +17 -0
- package/src/internal/resolve-cli-tool.ts +21 -0
- package/src/internal/staging-dir.ts +16 -0
- package/src/internal/xdg-data-dirs.ts +7 -0
- package/src/mcp/client.ts +177 -0
- package/src/mcp/handlers.ts +156 -0
- package/src/mcp/index.ts +22 -0
- package/src/mcp/serialize-widget.ts +34 -0
- package/src/mcp/testing-loader.ts +32 -0
- package/src/mcp/widget-registry.ts +43 -0
- package/src/refresh-runtime.ts +12 -41
- package/src/settings/compile.ts +19 -0
- package/src/settings/parser.ts +154 -0
- package/src/settings/render.ts +167 -0
- package/src/settings/schema.ts +115 -0
- package/src/vite-plugins/asset-extensions.ts +28 -0
- package/src/{vite-plugin-gtkx-built-url.ts → vite-plugins/built-url.ts} +3 -16
- package/src/vite-plugins/css.ts +38 -0
- package/src/vite-plugins/fast-refresh/refresh-filter.ts +18 -0
- package/src/vite-plugins/fast-refresh/swc-refresh.ts +79 -0
- package/src/vite-plugins/icons.ts +58 -0
- package/src/vite-plugins/index.ts +22 -0
- package/src/vite-plugins/native.ts +74 -0
- package/src/vite-plugins/react-compiler.ts +70 -0
- package/src/vite-plugins/react-dom-prebundle.ts +14 -0
- package/src/vite-plugins/resource-init-module.ts +54 -0
- package/src/vite-plugins/resource-shared.ts +27 -0
- package/src/vite-plugins/resources.ts +272 -0
- package/src/vite-plugins/settings-worker-env.ts +25 -0
- package/src/vite-plugins/settings.ts +221 -0
- package/src/vite-plugins/undeclared-library.ts +69 -0
- package/src/vite-plugins/virtual-module.ts +37 -0
- package/src/vitest-plugin.ts +14 -0
- package/dist/create.d.ts +0 -55
- package/dist/create.d.ts.map +0 -1
- package/dist/create.js +0 -236
- package/dist/create.js.map +0 -1
- package/dist/dev-server.d.ts +0 -37
- package/dist/dev-server.d.ts.map +0 -1
- package/dist/dev-server.js +0 -130
- package/dist/dev-server.js.map +0 -1
- package/dist/index.d.ts +0 -4
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -4
- package/dist/index.js.map +0 -1
- package/dist/mcp-client.d.ts +0 -31
- package/dist/mcp-client.d.ts.map +0 -1
- package/dist/mcp-client.js +0 -430
- package/dist/mcp-client.js.map +0 -1
- package/dist/templates.d.ts +0 -9
- package/dist/templates.d.ts.map +0 -1
- package/dist/templates.js +0 -16
- package/dist/templates.js.map +0 -1
- package/dist/vite-plugin-gtkx-assets.d.ts +0 -20
- package/dist/vite-plugin-gtkx-assets.d.ts.map +0 -1
- package/dist/vite-plugin-gtkx-assets.js +0 -57
- package/dist/vite-plugin-gtkx-assets.js.map +0 -1
- package/dist/vite-plugin-gtkx-built-url.d.ts +0 -18
- package/dist/vite-plugin-gtkx-built-url.d.ts.map +0 -1
- package/dist/vite-plugin-gtkx-built-url.js.map +0 -1
- package/dist/vite-plugin-gtkx-gsettings.d.ts +0 -28
- package/dist/vite-plugin-gtkx-gsettings.d.ts.map +0 -1
- package/dist/vite-plugin-gtkx-gsettings.js +0 -147
- package/dist/vite-plugin-gtkx-gsettings.js.map +0 -1
- package/dist/vite-plugin-gtkx-native.d.ts +0 -14
- package/dist/vite-plugin-gtkx-native.d.ts.map +0 -1
- package/dist/vite-plugin-gtkx-native.js +0 -53
- package/dist/vite-plugin-gtkx-native.js.map +0 -1
- package/dist/vite-plugin-gtkx-refresh.d.ts +0 -8
- package/dist/vite-plugin-gtkx-refresh.d.ts.map +0 -1
- package/dist/vite-plugin-gtkx-refresh.js +0 -37
- package/dist/vite-plugin-gtkx-refresh.js.map +0 -1
- package/dist/vite-plugin-swc-ssr-refresh.d.ts +0 -8
- package/dist/vite-plugin-swc-ssr-refresh.d.ts.map +0 -1
- package/dist/vite-plugin-swc-ssr-refresh.js +0 -46
- package/dist/vite-plugin-swc-ssr-refresh.js.map +0 -1
- package/src/cli.tsx +0 -154
- package/src/create.ts +0 -326
- package/src/dev-server.tsx +0 -162
- package/src/index.ts +0 -3
- package/src/mcp-client.ts +0 -518
- package/src/templates.ts +0 -26
- package/src/vite-plugin-gtkx-assets.ts +0 -69
- package/src/vite-plugin-gtkx-gsettings.ts +0 -168
- package/src/vite-plugin-gtkx-native.ts +0 -64
- package/src/vite-plugin-gtkx-refresh.ts +0 -54
- package/src/vite-plugin-swc-ssr-refresh.ts +0 -61
- package/templates/claude/EXAMPLES.md.ejs +0 -744
- package/templates/claude/SKILL.md.ejs +0 -93
- package/templates/claude/WIDGETS.md.ejs +0 -820
- package/templates/config/vitest.config.ts.ejs +0 -11
- package/templates/gitignore.ejs +0 -4
- package/templates/package.json.ejs +0 -16
- package/templates/src/app.tsx.ejs +0 -32
- package/templates/src/dev.tsx.ejs +0 -5
- package/templates/src/gtkx-env.d.ts.ejs +0 -1
- package/templates/src/index.tsx.ejs +0 -5
- package/templates/tests/app.test.tsx.ejs +0 -16
- package/templates/tsconfig.json.ejs +0 -14
package/README.md
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/gtkx-org/gtkx/main/logo.svg" alt="GTKX" width="100" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">GTKX</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
The React framework for Linux.<br />
|
|
9
|
+
Build GTK4 and Adwaita apps in TypeScript, with React components and hooks driving GNOME's own widgets. What you ship is a GNOME app.
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
<p align="center">
|
|
13
|
+
<a href="https://www.npmjs.com/package/create-gtkx"><img src="https://img.shields.io/npm/v/create-gtkx?color=cb3837&logo=npm&label=create-gtkx" alt="npm version" /></a>
|
|
14
|
+
<a href="https://www.npmjs.com/package/create-gtkx"><img src="https://img.shields.io/npm/dm/create-gtkx?color=cb3837&logo=npm&label=downloads" alt="npm downloads" /></a>
|
|
15
|
+
<img src="https://img.shields.io/badge/node-%E2%89%A524-339933?logo=node.js&logoColor=white" alt="Node >= 24" />
|
|
16
|
+
<a href="https://github.com/gtkx-org/gtkx/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MPL--2.0-blue.svg" alt="License: MPL-2.0" /></a>
|
|
17
|
+
<a href="https://github.com/gtkx-org/gtkx/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/gtkx-org/gtkx/ci.yml?branch=main&logo=github&label=CI" alt="CI status" /></a>
|
|
18
|
+
<img src="https://img.shields.io/badge/TypeScript-strict-3178c6?logo=typescript&logoColor=white" alt="TypeScript" />
|
|
19
|
+
</p>
|
|
20
|
+
|
|
21
|
+
<p align="center">
|
|
22
|
+
<a href="https://gtkx.dev">Homepage</a> ·
|
|
23
|
+
<a href="https://gtkx.dev/guide/why-gtkx">Documentation</a> ·
|
|
24
|
+
<a href="https://github.com/gtkx-org/gtkx/tree/main/examples">Examples</a> ·
|
|
25
|
+
<a href="https://github.com/gtkx-org/gtkx/blob/main/CONTRIBUTING.md">Contributing</a>
|
|
26
|
+
</p>
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
GTKX generates fully typed bindings for the entire GTK4 and Adwaita surface directly from GObject-Introspection. On top of those bindings you get the React programming model: components and hooks driving GObject instances, with Fast Refresh while you develop.
|
|
31
|
+
|
|
32
|
+
<p align="center">
|
|
33
|
+
<img src="https://raw.githubusercontent.com/gtkx-org/gtkx/main/examples/tutorial/assets/screenshot.png" alt="The Tasks app: an Adwaita window with a sidebar of smart views and colored lists on the left, and a boxed task list on the right." />
|
|
34
|
+
</p>
|
|
35
|
+
|
|
36
|
+
<p align="center">
|
|
37
|
+
<em>The Tasks app you build in the <a href="https://gtkx.dev/tutorial/">tutorial</a>.</em>
|
|
38
|
+
</p>
|
|
39
|
+
|
|
40
|
+
## Demo
|
|
41
|
+
|
|
42
|
+
The intrinsic elements in this snippet render GTK4 widgets, and ordinary React hooks and events drive them:
|
|
43
|
+
|
|
44
|
+
```tsx
|
|
45
|
+
import * as Gtk from "@gtkx/gi/gtk";
|
|
46
|
+
import { GtkApplication, GtkApplicationWindow, GtkBox, GtkButton, GtkLabel } from "@gtkx/jsx/gtk";
|
|
47
|
+
import { createRoot, quit } from "@gtkx/react";
|
|
48
|
+
import { useState } from "react";
|
|
49
|
+
|
|
50
|
+
const Counter = () => {
|
|
51
|
+
const [count, setCount] = useState(0);
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<GtkApplicationWindow
|
|
55
|
+
title="Hello GTKX"
|
|
56
|
+
defaultWidth={400}
|
|
57
|
+
defaultHeight={300}
|
|
58
|
+
onCloseRequest={quit}
|
|
59
|
+
>
|
|
60
|
+
<GtkBox
|
|
61
|
+
orientation={Gtk.Orientation.VERTICAL}
|
|
62
|
+
spacing={20}
|
|
63
|
+
marginTop={40}
|
|
64
|
+
marginBottom={40}
|
|
65
|
+
marginStart={40}
|
|
66
|
+
marginEnd={40}
|
|
67
|
+
valign={Gtk.Align.CENTER}
|
|
68
|
+
halign={Gtk.Align.CENTER}
|
|
69
|
+
>
|
|
70
|
+
<GtkLabel cssClasses={["title-1"]}>Welcome to GTKX!</GtkLabel>
|
|
71
|
+
<GtkLabel cssClasses={["title-2"]}>{`Count: ${count}`}</GtkLabel>
|
|
72
|
+
<GtkButton
|
|
73
|
+
label="Increment"
|
|
74
|
+
onClicked={() => setCount((c) => c + 1)}
|
|
75
|
+
cssClasses={["suggested-action", "pill"]}
|
|
76
|
+
/>
|
|
77
|
+
</GtkBox>
|
|
78
|
+
</GtkApplicationWindow>
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const App = () => (
|
|
83
|
+
<GtkApplication>
|
|
84
|
+
<Counter />
|
|
85
|
+
</GtkApplication>
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
createRoot().render(<App />);
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
This is the [`hello-world`](https://github.com/gtkx-org/gtkx/tree/main/examples/hello-world) example, with `app.tsx` and `index.tsx` combined into a single snippet. `@gtkx/gi` and `@gtkx/jsx` are per-project bindings generated by the CLI, not packages you install from npm.
|
|
92
|
+
|
|
93
|
+
## Why GTKX
|
|
94
|
+
|
|
95
|
+
### A declarative layer for the GNOME stack
|
|
96
|
+
|
|
97
|
+
GTK4 is mature, and GtkBuilder XML can lay out a static interface, but nothing re-renders that interface when your application state changes, and nothing hot-reloads it as you work. GTKX adds that missing layer, and the tooling around it, on top of the stack you already know:
|
|
98
|
+
|
|
99
|
+
- a React reconciler that exposes every GObject as a JSX element,
|
|
100
|
+
- a CLI for scaffolding, development, and production builds,
|
|
101
|
+
- a dev server with Fast Refresh that patches your running UI in place,
|
|
102
|
+
- CSS-in-JS styling and high-level list, grid, and dialog components,
|
|
103
|
+
- a Testing Library-style API for querying and driving your widgets in tests,
|
|
104
|
+
- and a Model Context Protocol (MCP) server that exposes your live app to AI agents.
|
|
105
|
+
|
|
106
|
+
### The full GNOME API surface
|
|
107
|
+
|
|
108
|
+
React Native and similar frameworks hide the native toolkit so one API can run everywhere. GTKX exposes it: GTK4, Adwaita, and any other GObject-Introspection library on your system. Linux-only by design.
|
|
109
|
+
|
|
110
|
+
### Why Node.js, and why generated bindings
|
|
111
|
+
|
|
112
|
+
GTKX runs on Node.js, which puts native modules, the npm ecosystem, and the tooling built for Node.js APIs within reach. GJS is GNOME's own runtime, built on SpiderMonkey rather than V8; node-gtk runs on Node.js but is lightly maintained, on the older nan/V8 ABI rather than N-API, and still centered on GTK3. The [why-gtkx guide](https://gtkx.dev/guide/why-gtkx) covers the comparison in full.
|
|
113
|
+
|
|
114
|
+
GTKX generates the TypeScript types and the native FFI calls from the same GObject-Introspection data, so the types cannot drift from the calls they back. Codegen covers the whole GTK4 and Adwaita surface.
|
|
115
|
+
|
|
116
|
+
At runtime, the native Rust core calls straight into the system GTK4, Adwaita, and GLib libraries through libffi, without loading libgirepository at all.
|
|
117
|
+
|
|
118
|
+
## Quick start
|
|
119
|
+
|
|
120
|
+
GTKX is Linux-only and needs Node.js 24 or later. See [Requirements](#requirements).
|
|
121
|
+
|
|
122
|
+
Scaffold a new app with the `create-gtkx` initializer:
|
|
123
|
+
|
|
124
|
+
```sh
|
|
125
|
+
npm create gtkx@rc
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
The same command works with other package managers: `pnpm create gtkx@rc` or `yarn create gtkx@rc`.
|
|
129
|
+
|
|
130
|
+
Then run your new app:
|
|
131
|
+
|
|
132
|
+
```sh
|
|
133
|
+
cd my-app
|
|
134
|
+
npm run dev
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
To go further, follow the [tutorial](https://gtkx.dev/tutorial/).
|
|
138
|
+
|
|
139
|
+
## Documentation
|
|
140
|
+
|
|
141
|
+
The documentation at **[gtkx.dev](https://gtkx.dev)** includes a step-by-step tutorial that builds a complete GNOME app, from scaffolding to packaging and shipping, plus guides and a full API reference.
|
|
142
|
+
|
|
143
|
+
**[Read the docs →](https://gtkx.dev/guide/why-gtkx)**
|
|
144
|
+
|
|
145
|
+
## Requirements
|
|
146
|
+
|
|
147
|
+
GTKX is Linux-only. You need:
|
|
148
|
+
|
|
149
|
+
- Linux with the GTK4 (4.20 or later), Adwaita (1.8 or later), and GLib development libraries
|
|
150
|
+
- Node.js 24 or later
|
|
151
|
+
|
|
152
|
+
The `@gtkx/native` addon ships prebuilt for x64 and arm64 glibc Linux; other targets need to build it from the GTKX repository, which requires a Rust toolchain.
|
|
153
|
+
|
|
154
|
+
## Examples
|
|
155
|
+
|
|
156
|
+
Explore the [example apps](https://github.com/gtkx-org/gtkx/tree/main/examples):
|
|
157
|
+
|
|
158
|
+
- [`hello-world`](https://github.com/gtkx-org/gtkx/tree/main/examples/hello-world): the counter above.
|
|
159
|
+
- [`gtk-demo`](https://github.com/gtkx-org/gtkx/tree/main/examples/gtk-demo): a React port of the official GTK4 widget showcase, covering lists, dialogs, gestures, CSS, and OpenGL.
|
|
160
|
+
- [`browser`](https://github.com/gtkx-org/gtkx/tree/main/examples/browser): a WebKitWebView-based web browser.
|
|
161
|
+
- [`tutorial`](https://github.com/gtkx-org/gtkx/tree/main/examples/tutorial): the Tasks app the documentation builds.
|
|
162
|
+
|
|
163
|
+
## Status
|
|
164
|
+
|
|
165
|
+
GTKX 1.0 is at the release candidate stage.
|
|
166
|
+
|
|
167
|
+
## Contributing
|
|
168
|
+
|
|
169
|
+
Contributions are welcome. See [CONTRIBUTING.md](https://github.com/gtkx-org/gtkx/blob/main/CONTRIBUTING.md), the [Code of Conduct](https://github.com/gtkx-org/gtkx/blob/main/CODE_OF_CONDUCT.md), and the [security policy](https://github.com/gtkx-org/gtkx/blob/main/SECURITY.md). Building the repo needs Node.js 24 or later, pnpm, and a Rust toolchain.
|
|
170
|
+
|
|
171
|
+
## License
|
|
172
|
+
|
|
173
|
+
GTKX is licensed under [MPL-2.0](https://github.com/gtkx-org/gtkx/blob/main/LICENSE).
|
package/dist/builder.d.ts
CHANGED
|
@@ -1,56 +1,8 @@
|
|
|
1
1
|
import { type InlineConfig } from "vite";
|
|
2
|
-
/**
|
|
3
|
-
* Options for building a GTKX application for production.
|
|
4
|
-
*/
|
|
5
2
|
export type BuildOptions = {
|
|
6
|
-
/** Path to the entry file (e.g., "src/index.tsx") */
|
|
7
3
|
entry: string;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* executable directory.
|
|
11
|
-
*
|
|
12
|
-
* When set, asset imports resolve to
|
|
13
|
-
* `path.join(path.dirname(process.execPath), assetBase, filename)`.
|
|
14
|
-
* This is useful for FHS-compliant packaging where assets live under
|
|
15
|
-
* a `share/` directory rather than next to the binary.
|
|
16
|
-
*
|
|
17
|
-
* When omitted, assets resolve relative to the bundle via
|
|
18
|
-
* `import.meta.url`, which works when assets are co-located with
|
|
19
|
-
* the executable (e.g., in `bin/assets/`).
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* ```ts
|
|
23
|
-
* await build({
|
|
24
|
-
* entry: "./src/index.tsx",
|
|
25
|
-
* assetBase: "../share/my-app",
|
|
26
|
-
* });
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
assetBase?: string;
|
|
30
|
-
/** Additional Vite configuration */
|
|
31
|
-
vite?: InlineConfig;
|
|
4
|
+
assetBase?: string | undefined;
|
|
5
|
+
vite?: InlineConfig | undefined;
|
|
32
6
|
};
|
|
33
|
-
/**
|
|
34
|
-
* Builds a GTKX application for production using Vite's SSR build mode.
|
|
35
|
-
*
|
|
36
|
-
* Produces a single minified ESM bundle at `dist/bundle.js` with all
|
|
37
|
-
* dependencies inlined. The native `.node` binary is copied into the
|
|
38
|
-
* output directory as `gtkx.node`, making the bundle fully self-contained
|
|
39
|
-
* with no `node_modules` dependency at runtime.
|
|
40
|
-
*
|
|
41
|
-
* @param options - Build configuration including entry point and Vite options
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* ```ts
|
|
45
|
-
* import { build } from "@gtkx/cli";
|
|
46
|
-
*
|
|
47
|
-
* await build({
|
|
48
|
-
* entry: "./src/index.tsx",
|
|
49
|
-
* vite: { root: process.cwd() },
|
|
50
|
-
* });
|
|
51
|
-
* ```
|
|
52
|
-
*
|
|
53
|
-
* @see {@link BuildOptions} for configuration options
|
|
54
|
-
*/
|
|
55
7
|
export declare const build: (options: BuildOptions) => Promise<void>;
|
|
56
8
|
//# sourceMappingURL=builder.d.ts.map
|
package/dist/builder.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,
|
|
1
|
+
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAmC,MAAM,MAAM,CAAC;AAO1E,MAAM,MAAM,YAAY,GAAG;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,IAAI,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;CACnC,CAAC;AAcF,eAAO,MAAM,KAAK,YAAmB,YAAY,KAAG,OAAO,CAAC,IAAI,CAoB/D,CAAC"}
|
package/dist/builder.js
CHANGED
|
@@ -1,69 +1,35 @@
|
|
|
1
|
-
import { build as viteBuild } from "vite";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
* ```ts
|
|
18
|
-
* import { build } from "@gtkx/cli";
|
|
19
|
-
*
|
|
20
|
-
* await build({
|
|
21
|
-
* entry: "./src/index.tsx",
|
|
22
|
-
* vite: { root: process.cwd() },
|
|
23
|
-
* });
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
* @see {@link BuildOptions} for configuration options
|
|
27
|
-
*/
|
|
1
|
+
import { mergeConfig, build as viteBuild } from "vite";
|
|
2
|
+
import { gtkxBuiltUrl } from "./vite-plugins/built-url.js";
|
|
3
|
+
import { gtkxVitePlugins } from "./vite-plugins/index.js";
|
|
4
|
+
import { gtkxNative } from "./vite-plugins/native.js";
|
|
5
|
+
const BUILD_MODE = "production";
|
|
6
|
+
const buildDefaults = {
|
|
7
|
+
build: {
|
|
8
|
+
ssrEmitAssets: true,
|
|
9
|
+
outDir: "dist",
|
|
10
|
+
minify: true,
|
|
11
|
+
cssMinify: false,
|
|
12
|
+
},
|
|
13
|
+
define: {
|
|
14
|
+
"process.env.NODE_ENV": JSON.stringify(BUILD_MODE),
|
|
15
|
+
},
|
|
16
|
+
};
|
|
28
17
|
export const build = async (options) => {
|
|
29
18
|
const { entry, assetBase, vite: viteConfig } = options;
|
|
30
19
|
const root = viteConfig?.root ?? process.cwd();
|
|
31
|
-
|
|
32
|
-
...
|
|
33
|
-
plugins: [
|
|
34
|
-
...(viteConfig?.plugins ?? []),
|
|
35
|
-
gtkxGSettings(),
|
|
36
|
-
gtkxAssets(),
|
|
37
|
-
gtkxBuiltUrl(assetBase),
|
|
38
|
-
gtkxNative(root),
|
|
39
|
-
],
|
|
20
|
+
const forced = {
|
|
21
|
+
plugins: [...gtkxVitePlugins(BUILD_MODE), gtkxBuiltUrl(assetBase), gtkxNative(root)],
|
|
40
22
|
build: {
|
|
41
|
-
...viteConfig?.build,
|
|
42
23
|
ssr: entry,
|
|
43
|
-
ssrEmitAssets: true,
|
|
44
24
|
assetsInlineLimit: 0,
|
|
45
|
-
|
|
46
|
-
minify: true,
|
|
47
|
-
cssMinify: false,
|
|
48
|
-
rollupOptions: {
|
|
49
|
-
...viteConfig?.build?.rollupOptions,
|
|
25
|
+
rolldownOptions: {
|
|
50
26
|
output: {
|
|
51
|
-
...(viteConfig?.build?.rollupOptions?.output ?? {}),
|
|
52
27
|
entryFileNames: "bundle.js",
|
|
53
28
|
},
|
|
54
29
|
},
|
|
55
30
|
},
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
},
|
|
60
|
-
ssr: {
|
|
61
|
-
...viteConfig?.ssr,
|
|
62
|
-
noExternal: true,
|
|
63
|
-
},
|
|
64
|
-
experimental: {
|
|
65
|
-
...viteConfig?.experimental,
|
|
66
|
-
},
|
|
67
|
-
});
|
|
31
|
+
};
|
|
32
|
+
const merged = mergeConfig(mergeConfig(buildDefaults, viteConfig ?? {}), forced);
|
|
33
|
+
await viteBuild({ ...merged, ssr: { ...merged.ssr, noExternal: true } });
|
|
68
34
|
};
|
|
69
35
|
//# sourceMappingURL=builder.js.map
|
package/dist/builder.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.js","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"builder.js","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,WAAW,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,MAAM,UAAU,GAAG,YAAY,CAAC;AAQhC,MAAM,aAAa,GAAiB;IAChC,KAAK,EAAE;QACH,aAAa,EAAE,IAAI;QACnB,MAAM,EAAE,MAAM;QACd,MAAM,EAAE,IAAI;QACZ,SAAS,EAAE,KAAK;KACnB;IACD,MAAM,EAAE;QACJ,sBAAsB,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC;KACrD;CACJ,CAAC;AAEF,MAAM,CAAC,MAAM,KAAK,GAAG,KAAK,EAAE,OAAqB,EAAiB,EAAE;IAChE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;IACvD,MAAM,IAAI,GAAG,UAAU,EAAE,IAAI,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAE/C,MAAM,MAAM,GAAiB;QACzB,OAAO,EAAE,CAAC,GAAG,eAAe,CAAC,UAAU,CAAC,EAAE,YAAY,CAAC,SAAS,CAAC,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;QACpF,KAAK,EAAE;YACH,GAAG,EAAE,KAAK;YACV,iBAAiB,EAAE,CAAC;YACpB,eAAe,EAAE;gBACb,MAAM,EAAE;oBACJ,cAAc,EAAE,WAAW;iBAC9B;aACJ;SACJ;KACJ,CAAC;IAEF,MAAM,MAAM,GAAG,WAAW,CAAC,WAAW,CAAC,aAAa,EAAE,UAAU,IAAI,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;IAEjF,MAAM,SAAS,CAAC,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,EAAE,GAAG,MAAM,CAAC,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;AAC7E,CAAC,CAAC","sourcesContent":["import { type InlineConfig, mergeConfig, build as viteBuild } from \"vite\";\nimport { gtkxBuiltUrl } from \"./vite-plugins/built-url.js\";\nimport { gtkxVitePlugins } from \"./vite-plugins/index.js\";\nimport { gtkxNative } from \"./vite-plugins/native.js\";\n\nconst BUILD_MODE = \"production\";\n\nexport type BuildOptions = {\n entry: string;\n assetBase?: string | undefined;\n vite?: InlineConfig | undefined;\n};\n\nconst buildDefaults: InlineConfig = {\n build: {\n ssrEmitAssets: true,\n outDir: \"dist\",\n minify: true,\n cssMinify: false,\n },\n define: {\n \"process.env.NODE_ENV\": JSON.stringify(BUILD_MODE),\n },\n};\n\nexport const build = async (options: BuildOptions): Promise<void> => {\n const { entry, assetBase, vite: viteConfig } = options;\n const root = viteConfig?.root ?? process.cwd();\n\n const forced: InlineConfig = {\n plugins: [...gtkxVitePlugins(BUILD_MODE), gtkxBuiltUrl(assetBase), gtkxNative(root)],\n build: {\n ssr: entry,\n assetsInlineLimit: 0,\n rolldownOptions: {\n output: {\n entryFileNames: \"bundle.js\",\n },\n },\n },\n };\n\n const merged = mergeConfig(mergeConfig(buildDefaults, viteConfig ?? {}), forced);\n\n await viteBuild({ ...merged, ssr: { ...merged.ssr, noExternal: true } });\n};\n"]}
|
package/dist/cli.d.ts
CHANGED
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,IAAI,qDAaf,CAAC"}
|
package/dist/cli.js
CHANGED
|
@@ -1,133 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import "./refresh-runtime.js";
|
|
4
|
-
import { createRequire } from "node:module";
|
|
5
|
-
import { resolve } from "node:path";
|
|
6
|
-
import { events } from "@gtkx/ffi";
|
|
7
|
-
import { render } from "@gtkx/react";
|
|
1
|
+
import { packageVersion } from "@gtkx/utils";
|
|
8
2
|
import { defineCommand, runMain } from "citty";
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import { startMcpClient, stopMcpClient } from "./mcp-client.js";
|
|
13
|
-
const require = createRequire(import.meta.url);
|
|
14
|
-
const { version } = require("../package.json");
|
|
15
|
-
const dev = defineCommand({
|
|
16
|
-
meta: {
|
|
17
|
-
name: "dev",
|
|
18
|
-
description: "Start development server with HMR",
|
|
19
|
-
},
|
|
20
|
-
args: {
|
|
21
|
-
entry: {
|
|
22
|
-
type: "positional",
|
|
23
|
-
description: "Entry file (e.g., src/app.tsx)",
|
|
24
|
-
required: true,
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
async run({ args }) {
|
|
28
|
-
const entryPath = resolve(process.cwd(), args.entry);
|
|
29
|
-
console.log(`[gtkx] Starting dev server for ${entryPath}`);
|
|
30
|
-
const server = await createDevServer({
|
|
31
|
-
entry: entryPath,
|
|
32
|
-
vite: {
|
|
33
|
-
root: process.cwd(),
|
|
34
|
-
},
|
|
35
|
-
});
|
|
36
|
-
const mod = (await server.ssrLoadModule(entryPath));
|
|
37
|
-
const App = mod.default;
|
|
38
|
-
const appId = mod.appId ?? "org.gtkx.dev";
|
|
39
|
-
const appFlags = mod.appFlags;
|
|
40
|
-
if (typeof App !== "function") {
|
|
41
|
-
console.error("[gtkx] Entry file must export a default function component");
|
|
42
|
-
process.exit(1);
|
|
43
|
-
}
|
|
44
|
-
console.log(`[gtkx] Rendering app with ID: ${appId}`);
|
|
45
|
-
render(_jsx(App, {}), appId, appFlags);
|
|
46
|
-
await startMcpClient(appId);
|
|
47
|
-
events.on("stop", () => {
|
|
48
|
-
stopMcpClient();
|
|
49
|
-
});
|
|
50
|
-
console.log("[gtkx] HMR enabled - watching for changes...");
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
const buildCmd = defineCommand({
|
|
54
|
-
meta: {
|
|
55
|
-
name: "build",
|
|
56
|
-
description: "Build application for production",
|
|
57
|
-
},
|
|
58
|
-
args: {
|
|
59
|
-
entry: {
|
|
60
|
-
type: "positional",
|
|
61
|
-
description: "Entry file (default: src/index.tsx)",
|
|
62
|
-
required: false,
|
|
63
|
-
},
|
|
64
|
-
"asset-base": {
|
|
65
|
-
type: "string",
|
|
66
|
-
description: "Asset base path relative to executable directory (e.g., ../share/my-app)",
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
async run({ args }) {
|
|
70
|
-
const entry = resolve(process.cwd(), args.entry ?? "src/index.tsx");
|
|
71
|
-
console.log(`[gtkx] Building ${entry}`);
|
|
72
|
-
await build({
|
|
73
|
-
entry,
|
|
74
|
-
assetBase: args["asset-base"],
|
|
75
|
-
vite: {
|
|
76
|
-
root: process.cwd(),
|
|
77
|
-
},
|
|
78
|
-
});
|
|
79
|
-
console.log("[gtkx] Build complete: dist/bundle.js");
|
|
80
|
-
},
|
|
81
|
-
});
|
|
82
|
-
const create = defineCommand({
|
|
83
|
-
meta: {
|
|
84
|
-
name: "create",
|
|
85
|
-
description: "Create a new GTKX application",
|
|
86
|
-
},
|
|
87
|
-
args: {
|
|
88
|
-
name: {
|
|
89
|
-
type: "positional",
|
|
90
|
-
description: "Project name",
|
|
91
|
-
required: false,
|
|
92
|
-
},
|
|
93
|
-
"app-id": {
|
|
94
|
-
type: "string",
|
|
95
|
-
description: "App ID (e.g., com.example.myapp)",
|
|
96
|
-
},
|
|
97
|
-
pm: {
|
|
98
|
-
type: "string",
|
|
99
|
-
description: "Package manager (pnpm, npm, yarn)",
|
|
100
|
-
},
|
|
101
|
-
testing: {
|
|
102
|
-
type: "string",
|
|
103
|
-
description: "Testing setup (vitest, none)",
|
|
104
|
-
},
|
|
105
|
-
"claude-skills": {
|
|
106
|
-
type: "boolean",
|
|
107
|
-
description: "Include Claude Code skills for AI assistance",
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
async run({ args }) {
|
|
111
|
-
await createApp({
|
|
112
|
-
name: args.name,
|
|
113
|
-
appId: args["app-id"],
|
|
114
|
-
packageManager: args.pm,
|
|
115
|
-
testing: args.testing,
|
|
116
|
-
claudeSkills: args["claude-skills"],
|
|
117
|
-
});
|
|
118
|
-
},
|
|
119
|
-
});
|
|
120
|
-
const main = defineCommand({
|
|
3
|
+
import { withErrorBoundary } from "./internal/errors.js";
|
|
4
|
+
const version = packageVersion(import.meta.url);
|
|
5
|
+
export const main = defineCommand({
|
|
121
6
|
meta: {
|
|
122
7
|
name: "gtkx",
|
|
123
8
|
version,
|
|
124
|
-
description: "CLI for GTKX
|
|
9
|
+
description: "CLI for GTKX: create and develop GTK4 React applications",
|
|
125
10
|
},
|
|
126
11
|
subCommands: {
|
|
127
|
-
dev,
|
|
128
|
-
build:
|
|
129
|
-
|
|
12
|
+
dev: () => import("./commands/dev.js").then((m) => withErrorBoundary(m.dev)),
|
|
13
|
+
build: () => import("./commands/build.js").then((m) => withErrorBoundary(m.build)),
|
|
14
|
+
codegen: () => import("./commands/codegen.js").then((m) => withErrorBoundary(m.codegen)),
|
|
15
|
+
docs: () => import("./commands/docs.js").then((m) => withErrorBoundary(m.docs)),
|
|
16
|
+
create: () => import("create-gtkx").then((m) => withErrorBoundary(m.createCommand)),
|
|
130
17
|
},
|
|
131
18
|
});
|
|
132
|
-
runMain(main);
|
|
19
|
+
await runMain(main);
|
|
133
20
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,MAAM,OAAO,GAAG,cAAc,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;AAEhD,MAAM,CAAC,MAAM,IAAI,GAAG,aAAa,CAAC;IAC9B,IAAI,EAAE;QACF,IAAI,EAAE,MAAM;QACZ,OAAO;QACP,WAAW,EAAE,0DAA0D;KAC1E;IACD,WAAW,EAAE;QACT,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QAC5E,KAAK,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAClF,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QACxF,IAAI,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAC/E,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC;KACtF;CACJ,CAAC,CAAC;AAEH,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC","sourcesContent":["import { packageVersion } from \"@gtkx/utils\";\nimport { defineCommand, runMain } from \"citty\";\nimport { withErrorBoundary } from \"./internal/errors.js\";\n\nconst version = packageVersion(import.meta.url);\n\nexport const main = defineCommand({\n meta: {\n name: \"gtkx\",\n version,\n description: \"CLI for GTKX: create and develop GTK4 React applications\",\n },\n subCommands: {\n dev: () => import(\"./commands/dev.js\").then((m) => withErrorBoundary(m.dev)),\n build: () => import(\"./commands/build.js\").then((m) => withErrorBoundary(m.build)),\n codegen: () => import(\"./commands/codegen.js\").then((m) => withErrorBoundary(m.codegen)),\n docs: () => import(\"./commands/docs.js\").then((m) => withErrorBoundary(m.docs)),\n create: () => import(\"create-gtkx\").then((m) => withErrorBoundary(m.createCommand)),\n },\n});\n\nawait runMain(main);\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Config, ElementProp } from "@gtkx/config";
|
|
2
|
+
import { type CodegenStore } from "./store-resolver.js";
|
|
3
|
+
export type CodegenInputs = {
|
|
4
|
+
girPath: string[];
|
|
5
|
+
libraries: string[];
|
|
6
|
+
elementProps: Record<string, ElementProp[]>;
|
|
7
|
+
store: CodegenStore;
|
|
8
|
+
};
|
|
9
|
+
export declare const resolveCodegenInputs: (cwd: string, config: Config) => CodegenInputs;
|
|
10
|
+
export declare const isCodegenStale: (inputs: CodegenInputs) => boolean;
|
|
11
|
+
//# sourceMappingURL=freshness.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"freshness.d.ts","sourceRoot":"","sources":["../../src/codegen/freshness.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,KAAK,YAAY,EAAuB,MAAM,qBAAqB,CAAC;AAE7E,MAAM,MAAM,aAAa,GAAG;IACxB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC;IAC5C,KAAK,EAAE,YAAY,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,oBAAoB,QAAS,MAAM,UAAU,MAAM,KAAG,aAKlE,CAAC;AAaF,eAAO,MAAM,cAAc,WAAY,aAAa,KAAG,OAoBtD,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { resolveGirPath, resolveLibraries } from "@gtkx/codegen";
|
|
4
|
+
import { resolveCodegenStore } from "./store-resolver.js";
|
|
5
|
+
export const resolveCodegenInputs = (cwd, config) => {
|
|
6
|
+
const girPath = resolveGirPath(config.girPath);
|
|
7
|
+
const libraries = resolveLibraries(config.libraries, girPath);
|
|
8
|
+
const store = resolveCodegenStore(cwd);
|
|
9
|
+
return { girPath, libraries, elementProps: config.elementProps ?? {}, store };
|
|
10
|
+
};
|
|
11
|
+
const REACT_GENERATED_MODULES = ["metadata.js", join("gtk", "gtk.js")];
|
|
12
|
+
const namespaceBarrelPath = (giStoreDir, library) => {
|
|
13
|
+
const separator = library.indexOf("-");
|
|
14
|
+
const namespace = (separator === -1 ? library : library.slice(0, separator)).toLowerCase();
|
|
15
|
+
return join(giStoreDir, namespace, "index.js");
|
|
16
|
+
};
|
|
17
|
+
const giStoreLinksResolve = (giStoreDir) => existsSync(join(giStoreDir, "node_modules", "@gtkx", "gi", "package.json"));
|
|
18
|
+
export const isCodegenStale = (inputs) => {
|
|
19
|
+
try {
|
|
20
|
+
const { store, libraries } = inputs;
|
|
21
|
+
if (!existsSync(store.giLinkDir) || !existsSync(store.giStoreDir)) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
if (!giStoreLinksResolve(store.giStoreDir)) {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
if (libraries.some((library) => !existsSync(namespaceBarrelPath(store.giStoreDir, library)))) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
if (store.react !== null) {
|
|
31
|
+
if (!existsSync(store.jsxLinkDir))
|
|
32
|
+
return true;
|
|
33
|
+
if (REACT_GENERATED_MODULES.some((module) => !existsSync(join(store.jsxStoreDir, module))))
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=freshness.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"freshness.js","sourceRoot":"","sources":["../../src/codegen/freshness.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjE,OAAO,EAAqB,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAS7E,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,GAAW,EAAE,MAAc,EAAiB,EAAE;IAC/E,MAAM,OAAO,GAAG,cAAc,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC/C,MAAM,SAAS,GAAG,gBAAgB,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAC9D,MAAM,KAAK,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;IACvC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,CAAC,YAAY,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC;AAClF,CAAC,CAAC;AAEF,MAAM,uBAAuB,GAAa,CAAC,aAAa,EAAE,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;AAEjF,MAAM,mBAAmB,GAAG,CAAC,UAAkB,EAAE,OAAe,EAAU,EAAE;IACxE,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACvC,MAAM,SAAS,GAAG,CAAC,SAAS,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IAC3F,OAAO,IAAI,CAAC,UAAU,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;AACnD,CAAC,CAAC;AAEF,MAAM,mBAAmB,GAAG,CAAC,UAAkB,EAAW,EAAE,CACxD,UAAU,CAAC,IAAI,CAAC,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC;AAEhF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAqB,EAAW,EAAE;IAC7D,IAAI,CAAC;QACD,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC;QACpC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC;YAChE,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC;YACzC,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,mBAAmB,CAAC,KAAK,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;YAC3F,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,IAAI,KAAK,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;YACvB,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC;gBAAE,OAAO,IAAI,CAAC;YAC/C,IAAI,uBAAuB,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC;gBAAE,OAAO,IAAI,CAAC;QAC5G,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,IAAI,CAAC;IAChB,CAAC;AACL,CAAC,CAAC","sourcesContent":["import { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { resolveGirPath, resolveLibraries } from \"@gtkx/codegen\";\nimport type { Config, ElementProp } from \"@gtkx/config\";\nimport { type CodegenStore, resolveCodegenStore } from \"./store-resolver.js\";\n\nexport type CodegenInputs = {\n girPath: string[];\n libraries: string[];\n elementProps: Record<string, ElementProp[]>;\n store: CodegenStore;\n};\n\nexport const resolveCodegenInputs = (cwd: string, config: Config): CodegenInputs => {\n const girPath = resolveGirPath(config.girPath);\n const libraries = resolveLibraries(config.libraries, girPath);\n const store = resolveCodegenStore(cwd);\n return { girPath, libraries, elementProps: config.elementProps ?? {}, store };\n};\n\nconst REACT_GENERATED_MODULES: string[] = [\"metadata.js\", join(\"gtk\", \"gtk.js\")];\n\nconst namespaceBarrelPath = (giStoreDir: string, library: string): string => {\n const separator = library.indexOf(\"-\");\n const namespace = (separator === -1 ? library : library.slice(0, separator)).toLowerCase();\n return join(giStoreDir, namespace, \"index.js\");\n};\n\nconst giStoreLinksResolve = (giStoreDir: string): boolean =>\n existsSync(join(giStoreDir, \"node_modules\", \"@gtkx\", \"gi\", \"package.json\"));\n\nexport const isCodegenStale = (inputs: CodegenInputs): boolean => {\n try {\n const { store, libraries } = inputs;\n if (!existsSync(store.giLinkDir) || !existsSync(store.giStoreDir)) {\n return true;\n }\n if (!giStoreLinksResolve(store.giStoreDir)) {\n return true;\n }\n if (libraries.some((library) => !existsSync(namespaceBarrelPath(store.giStoreDir, library)))) {\n return true;\n }\n if (store.react !== null) {\n if (!existsSync(store.jsxLinkDir)) return true;\n if (REACT_GENERATED_MODULES.some((module) => !existsSync(join(store.jsxStoreDir, module)))) return true;\n }\n return false;\n } catch {\n return true;\n }\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../src/codegen/report.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAIzD,eAAO,MAAM,mBAAmB,WAAY,gBAAgB,WAAW,MAAM,KAAG,MAAM,EAerF,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const PREFIX = "codegen: ";
|
|
2
|
+
export const formatCodegenResult = (result, totalMs) => {
|
|
3
|
+
const details = [];
|
|
4
|
+
if (result.configFile) {
|
|
5
|
+
details.push(`config=${result.configFile}`);
|
|
6
|
+
}
|
|
7
|
+
if (result.libraries) {
|
|
8
|
+
details.push(`libraries=${result.libraries.join(", ")}`);
|
|
9
|
+
}
|
|
10
|
+
if (result.girPath) {
|
|
11
|
+
details.push(`girPath=${result.girPath.join(":")}`);
|
|
12
|
+
}
|
|
13
|
+
details.push(`${result.namespaces} namespaces, ${result.intrinsicElements} intrinsic elements in ${result.duration}ms (total ${totalMs}ms)`);
|
|
14
|
+
return details.map((detail) => PREFIX + detail);
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=report.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.js","sourceRoot":"","sources":["../../src/codegen/report.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,GAAG,WAAW,CAAC;AAE3B,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,MAAwB,EAAE,OAAe,EAAY,EAAE;IACvF,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QACpB,OAAO,CAAC,IAAI,CAAC,UAAU,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC;IAChD,CAAC;IACD,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;QACnB,OAAO,CAAC,IAAI,CAAC,aAAa,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC7D,CAAC;IACD,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACjB,OAAO,CAAC,IAAI,CAAC,WAAW,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACxD,CAAC;IACD,OAAO,CAAC,IAAI,CACR,GAAG,MAAM,CAAC,UAAU,gBAAgB,MAAM,CAAC,iBAAiB,0BAA0B,MAAM,CAAC,QAAQ,aAAa,OAAO,KAAK,CACjI,CAAC;IACF,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;AACpD,CAAC,CAAC","sourcesContent":["import type { RunCodegenResult } from \"./run-codegen.js\";\n\nconst PREFIX = \"codegen: \";\n\nexport const formatCodegenResult = (result: RunCodegenResult, totalMs: number): string[] => {\n const details: string[] = [];\n if (result.configFile) {\n details.push(`config=${result.configFile}`);\n }\n if (result.libraries) {\n details.push(`libraries=${result.libraries.join(\", \")}`);\n }\n if (result.girPath) {\n details.push(`girPath=${result.girPath.join(\":\")}`);\n }\n details.push(\n `${result.namespaces} namespaces, ${result.intrinsicElements} intrinsic elements in ${result.duration}ms (total ${totalMs}ms)`,\n );\n return details.map((detail) => PREFIX + detail);\n};\n"]}
|