@gtkx/cli 1.0.0-rc.3 → 1.0.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 (170) hide show
  1. package/README.md +8 -9
  2. package/dist/builder.d.ts +1 -1
  3. package/dist/builder.d.ts.map +1 -1
  4. package/dist/builder.js +2 -1
  5. package/dist/builder.js.map +1 -1
  6. package/dist/cli.js +4 -2
  7. package/dist/cli.js.map +1 -1
  8. package/dist/codegen/freshness.d.ts.map +1 -1
  9. package/dist/codegen/freshness.js +3 -6
  10. package/dist/codegen/freshness.js.map +1 -1
  11. package/dist/codegen/run-codegen.d.ts +4 -4
  12. package/dist/codegen/run-codegen.d.ts.map +1 -1
  13. package/dist/codegen/run-codegen.js +15 -14
  14. package/dist/codegen/run-codegen.js.map +1 -1
  15. package/dist/codegen/store-resolver.d.ts +1 -3
  16. package/dist/codegen/store-resolver.d.ts.map +1 -1
  17. package/dist/codegen/store-resolver.js +13 -32
  18. package/dist/codegen/store-resolver.js.map +1 -1
  19. package/dist/commands/build.js +1 -1
  20. package/dist/commands/build.js.map +1 -1
  21. package/dist/commands/codegen.js +1 -1
  22. package/dist/commands/codegen.js.map +1 -1
  23. package/dist/commands/dev.d.ts.map +1 -1
  24. package/dist/commands/dev.js +4 -2
  25. package/dist/commands/dev.js.map +1 -1
  26. package/dist/commands/docs.js +13 -13
  27. package/dist/commands/docs.js.map +1 -1
  28. package/dist/dev/entry-env.d.ts +3 -0
  29. package/dist/dev/entry-env.d.ts.map +1 -0
  30. package/dist/dev/entry-env.js +3 -0
  31. package/dist/dev/entry-env.js.map +1 -0
  32. package/dist/dev/runner-deps.d.ts.map +1 -1
  33. package/dist/dev/runner-deps.js +1 -0
  34. package/dist/dev/runner-deps.js.map +1 -1
  35. package/dist/dev/runner-main.d.ts.map +1 -1
  36. package/dist/dev/runner-main.js +3 -3
  37. package/dist/dev/runner-main.js.map +1 -1
  38. package/dist/dev/runner.d.ts +1 -0
  39. package/dist/dev/runner.d.ts.map +1 -1
  40. package/dist/dev/runner.js +22 -12
  41. package/dist/dev/runner.js.map +1 -1
  42. package/dist/dev/supervisor.d.ts +10 -3
  43. package/dist/dev/supervisor.d.ts.map +1 -1
  44. package/dist/dev/supervisor.js +37 -18
  45. package/dist/dev/supervisor.js.map +1 -1
  46. package/dist/internal/application-args.d.ts +6 -0
  47. package/dist/internal/application-args.d.ts.map +1 -0
  48. package/dist/internal/application-args.js +10 -0
  49. package/dist/internal/application-args.js.map +1 -0
  50. package/dist/internal/errors.d.ts +1 -2
  51. package/dist/internal/errors.d.ts.map +1 -1
  52. package/dist/internal/errors.js +1 -1
  53. package/dist/internal/errors.js.map +1 -1
  54. package/dist/internal/run-cli-tool.d.ts +10 -0
  55. package/dist/internal/run-cli-tool.d.ts.map +1 -0
  56. package/dist/internal/run-cli-tool.js +15 -0
  57. package/dist/internal/run-cli-tool.js.map +1 -0
  58. package/dist/internal.d.ts +3 -0
  59. package/dist/internal.d.ts.map +1 -0
  60. package/dist/internal.js +3 -0
  61. package/dist/internal.js.map +1 -0
  62. package/dist/mcp/client.d.ts +1 -1
  63. package/dist/mcp/client.d.ts.map +1 -1
  64. package/dist/mcp/client.js.map +1 -1
  65. package/dist/mcp/handlers.d.ts +1 -1
  66. package/dist/mcp/handlers.d.ts.map +1 -1
  67. package/dist/mcp/handlers.js +79 -42
  68. package/dist/mcp/handlers.js.map +1 -1
  69. package/dist/mcp/index.d.ts.map +1 -1
  70. package/dist/mcp/index.js +1 -0
  71. package/dist/mcp/index.js.map +1 -1
  72. package/dist/mcp/serialize-widget.d.ts +2 -2
  73. package/dist/mcp/serialize-widget.d.ts.map +1 -1
  74. package/dist/mcp/serialize-widget.js +47 -17
  75. package/dist/mcp/serialize-widget.js.map +1 -1
  76. package/dist/mcp/widget-properties.d.ts +6 -0
  77. package/dist/mcp/widget-properties.d.ts.map +1 -0
  78. package/dist/mcp/widget-properties.js +102 -0
  79. package/dist/mcp/widget-properties.js.map +1 -0
  80. package/dist/refresh-runtime.d.ts +0 -10
  81. package/dist/refresh-runtime.d.ts.map +1 -1
  82. package/dist/refresh-runtime.js +0 -17
  83. package/dist/refresh-runtime.js.map +1 -1
  84. package/dist/settings/compile.d.ts.map +1 -1
  85. package/dist/settings/compile.js +8 -12
  86. package/dist/settings/compile.js.map +1 -1
  87. package/dist/settings/schema.d.ts +1 -1
  88. package/dist/settings/schema.d.ts.map +1 -1
  89. package/dist/settings/schema.js +1 -1
  90. package/dist/settings/schema.js.map +1 -1
  91. package/dist/vite-plugins/asset-emitter.d.ts +9 -0
  92. package/dist/vite-plugins/asset-emitter.d.ts.map +1 -0
  93. package/dist/vite-plugins/asset-emitter.js +2 -0
  94. package/dist/vite-plugins/asset-emitter.js.map +1 -0
  95. package/dist/vite-plugins/asset-extensions.d.ts +1 -2
  96. package/dist/vite-plugins/asset-extensions.d.ts.map +1 -1
  97. package/dist/vite-plugins/asset-extensions.js +1 -1
  98. package/dist/vite-plugins/asset-extensions.js.map +1 -1
  99. package/dist/vite-plugins/built-url.d.ts.map +1 -1
  100. package/dist/vite-plugins/built-url.js +14 -10
  101. package/dist/vite-plugins/built-url.js.map +1 -1
  102. package/dist/vite-plugins/ensure-store.d.ts +4 -0
  103. package/dist/vite-plugins/ensure-store.d.ts.map +1 -0
  104. package/dist/vite-plugins/ensure-store.js +10 -0
  105. package/dist/vite-plugins/ensure-store.js.map +1 -0
  106. package/dist/vite-plugins/icons.d.ts.map +1 -1
  107. package/dist/vite-plugins/icons.js.map +1 -1
  108. package/dist/vite-plugins/react-compiler.d.ts +1 -1
  109. package/dist/vite-plugins/react-compiler.d.ts.map +1 -1
  110. package/dist/vite-plugins/react-compiler.js.map +1 -1
  111. package/dist/vite-plugins/resources.d.ts +1 -1
  112. package/dist/vite-plugins/resources.d.ts.map +1 -1
  113. package/dist/vite-plugins/resources.js +6 -15
  114. package/dist/vite-plugins/resources.js.map +1 -1
  115. package/dist/vite-plugins/settings.js.map +1 -1
  116. package/dist/vite-plugins/undeclared-library.d.ts +1 -1
  117. package/dist/vite-plugins/undeclared-library.d.ts.map +1 -1
  118. package/dist/vite-plugins/undeclared-library.js.map +1 -1
  119. package/dist/vite-plugins/worker.d.ts +4 -0
  120. package/dist/vite-plugins/worker.d.ts.map +1 -0
  121. package/dist/vite-plugins/worker.js +136 -0
  122. package/dist/vite-plugins/worker.js.map +1 -0
  123. package/dist/vitest-plugin.d.ts +4 -3
  124. package/dist/vitest-plugin.d.ts.map +1 -1
  125. package/dist/vitest-plugin.js +11 -4
  126. package/dist/vitest-plugin.js.map +1 -1
  127. package/env.d.ts +25 -0
  128. package/package.json +17 -13
  129. package/src/builder.ts +3 -2
  130. package/src/cli.ts +4 -2
  131. package/src/codegen/freshness.ts +3 -8
  132. package/src/codegen/run-codegen.ts +19 -19
  133. package/src/codegen/store-resolver.ts +14 -40
  134. package/src/commands/build.ts +1 -1
  135. package/src/commands/codegen.ts +1 -1
  136. package/src/commands/dev.ts +4 -2
  137. package/src/commands/docs.ts +15 -15
  138. package/src/dev/entry-env.ts +3 -0
  139. package/src/dev/runner-deps.ts +1 -0
  140. package/src/dev/runner-main.ts +3 -4
  141. package/src/dev/runner.ts +44 -13
  142. package/src/dev/supervisor.ts +70 -27
  143. package/src/internal/application-args.ts +13 -0
  144. package/src/internal/errors.ts +1 -1
  145. package/src/internal/run-cli-tool.ts +22 -0
  146. package/src/internal.ts +2 -0
  147. package/src/mcp/client.ts +1 -1
  148. package/src/mcp/handlers.ts +124 -57
  149. package/src/mcp/index.ts +1 -0
  150. package/src/mcp/serialize-widget.ts +71 -21
  151. package/src/mcp/widget-properties.ts +153 -0
  152. package/src/refresh-runtime.ts +0 -17
  153. package/src/settings/compile.ts +8 -11
  154. package/src/settings/schema.ts +2 -2
  155. package/src/vite-plugins/asset-emitter.ts +5 -0
  156. package/src/vite-plugins/asset-extensions.ts +1 -1
  157. package/src/vite-plugins/built-url.ts +19 -13
  158. package/src/vite-plugins/ensure-store.ts +14 -0
  159. package/src/vite-plugins/icons.ts +2 -5
  160. package/src/vite-plugins/react-compiler.ts +3 -2
  161. package/src/vite-plugins/resources.ts +10 -19
  162. package/src/vite-plugins/settings.ts +2 -2
  163. package/src/vite-plugins/undeclared-library.ts +1 -1
  164. package/src/vite-plugins/worker.ts +235 -0
  165. package/src/vitest-plugin.ts +12 -4
  166. package/dist/internal/resolve-cli-tool.d.ts +0 -3
  167. package/dist/internal/resolve-cli-tool.d.ts.map +0 -1
  168. package/dist/internal/resolve-cli-tool.js +0 -27
  169. package/dist/internal/resolve-cli-tool.js.map +0 -1
  170. package/src/internal/resolve-cli-tool.ts +0 -37
package/env.d.ts CHANGED
@@ -2,98 +2,123 @@
2
2
  /// <reference types="@gtkx/react/env" />
3
3
 
4
4
  declare module "*.aac" {
5
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
5
6
  export const path: string;
6
7
  }
7
8
 
8
9
  declare module "*.avif" {
10
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
9
11
  export const path: string;
10
12
  }
11
13
 
12
14
  declare module "*.eot" {
15
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
13
16
  export const path: string;
14
17
  }
15
18
 
16
19
  declare module "*.flac" {
20
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
17
21
  export const path: string;
18
22
  }
19
23
 
20
24
  declare module "*.gif" {
25
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
21
26
  export const path: string;
22
27
  }
23
28
 
24
29
  declare module "*.ico" {
30
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
25
31
  export const path: string;
26
32
  }
27
33
 
28
34
  declare module "*.jpeg" {
35
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
29
36
  export const path: string;
30
37
  }
31
38
 
32
39
  declare module "*.jpg" {
40
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
33
41
  export const path: string;
34
42
  }
35
43
 
36
44
  declare module "*.mp3" {
45
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
37
46
  export const path: string;
38
47
  }
39
48
 
40
49
  declare module "*.mp4" {
50
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
41
51
  export const path: string;
42
52
  }
43
53
 
44
54
  declare module "*.ogg" {
55
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
45
56
  export const path: string;
46
57
  }
47
58
 
48
59
  declare module "*.otf" {
60
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
49
61
  export const path: string;
50
62
  }
51
63
 
52
64
  declare module "*.png" {
65
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
53
66
  export const path: string;
54
67
  }
55
68
 
56
69
  declare module "*.svg" {
70
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
57
71
  export const path: string;
58
72
  }
59
73
 
60
74
  declare module "*.ttf" {
75
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
61
76
  export const path: string;
62
77
  }
63
78
 
64
79
  declare module "*.wav" {
80
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
65
81
  export const path: string;
66
82
  }
67
83
 
68
84
  declare module "*.webm" {
85
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
69
86
  export const path: string;
70
87
  }
71
88
 
72
89
  declare module "*.webp" {
90
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
73
91
  export const path: string;
74
92
  }
75
93
 
76
94
  declare module "*.woff" {
95
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
77
96
  export const path: string;
78
97
  }
79
98
 
80
99
  declare module "*.woff2" {
100
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
81
101
  export const path: string;
82
102
  }
83
103
 
84
104
  declare module "*.data" {
105
+ /** `resource://` URI of the bundled asset, accepted anywhere GTK takes a URI. */
85
106
  const resourceUri: string;
107
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
86
108
  export const path: string;
87
109
  export default resourceUri;
88
110
  }
89
111
 
90
112
  declare module "*.gpa" {
113
+ /** `resource://` URI of the bundled asset, accepted anywhere GTK takes a URI. */
91
114
  const resourceUri: string;
115
+ /** GResource path of the bundled asset, for use with the `Gio.resources*` lookup functions. */
92
116
  export const path: string;
93
117
  export default resourceUri;
94
118
  }
95
119
 
96
120
  declare module "*.css?url" {
121
+ /** Filesystem path of the emitted stylesheet, imported without installing it on the default display. */
97
122
  const path: string;
98
123
  export default path;
99
124
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gtkx/cli",
3
- "version": "1.0.0-rc.3",
3
+ "version": "1.0.0",
4
4
  "description": "Command-line tool and Vite plugin stack that scaffolds, develops, builds, and documents GTKX applications",
5
5
  "keywords": [
6
6
  "gtkx",
@@ -29,6 +29,11 @@
29
29
  "author": "Eugenio Depalo <eugeniodepalo@gmail.com>",
30
30
  "type": "module",
31
31
  "exports": {
32
+ "./env": "./env.d.ts",
33
+ "./internal": {
34
+ "types": "./dist/internal.d.ts",
35
+ "default": "./dist/internal.js"
36
+ },
32
37
  "./package.json": "./package.json",
33
38
  "./refresh-runtime": {
34
39
  "types": "./dist/refresh-runtime.d.ts",
@@ -37,8 +42,7 @@
37
42
  "./vitest-plugin": {
38
43
  "types": "./dist/vitest-plugin.d.ts",
39
44
  "default": "./dist/vitest-plugin.js"
40
- },
41
- "./env": "./env.d.ts"
45
+ }
42
46
  },
43
47
  "bin": {
44
48
  "gtkx": "bin/gtkx.js"
@@ -56,25 +60,25 @@
56
60
  "dependencies": {
57
61
  "@babel/core": "^8.0.1",
58
62
  "@babel/preset-typescript": "^8.0.1",
59
- "@swc/core": "^1.15.46",
63
+ "@swc/core": "^1.15.47",
60
64
  "babel-plugin-react-compiler": "^1.0.0",
61
65
  "citty": "^0.2.2",
62
66
  "fast-xml-parser": "^5.10.1",
63
67
  "react-refresh": "^0.18.0",
64
- "vite": "^8.1.5",
65
- "@gtkx/config": "1.0.0-rc.3",
66
- "@gtkx/mcp": "1.0.0-rc.3",
67
- "@gtkx/codegen": "1.0.0-rc.3",
68
- "@gtkx/runtime": "1.0.0-rc.3",
69
- "@gtkx/utils": "1.0.0-rc.3",
70
- "@gtkx/vitest": "1.0.0-rc.3",
71
- "create-gtkx": "1.0.0-rc.3"
68
+ "vite": "^8.2.1",
69
+ "@gtkx/config": "1.0.0",
70
+ "@gtkx/codegen": "1.0.0",
71
+ "@gtkx/mcp": "1.0.0",
72
+ "@gtkx/runtime": "1.0.0",
73
+ "@gtkx/utils": "1.0.0",
74
+ "@gtkx/vitest": "1.0.0",
75
+ "create-gtkx": "1.0.0"
72
76
  },
73
77
  "devDependencies": {
74
78
  "@types/babel__core": "^7.20.5",
75
79
  "@types/react-refresh": "^0.14.7",
76
80
  "vitest": "^4.1.10",
77
- "@gtkx/testing": "1.0.0-rc.3"
81
+ "@gtkx/testing": "1.0.0"
78
82
  },
79
83
  "peerDependencies": {
80
84
  "react": "^19"
package/src/builder.ts CHANGED
@@ -2,6 +2,7 @@ import { type InlineConfig, mergeConfig, build as viteBuild } from "vite";
2
2
  import { gtkxBuiltUrl } from "./vite-plugins/built-url.js";
3
3
  import { gtkxVitePlugins } from "./vite-plugins/index.js";
4
4
  import { gtkxNative } from "./vite-plugins/native.js";
5
+ import { gtkxWorker } from "./vite-plugins/worker.js";
5
6
 
6
7
  type BuildOptions = {
7
8
  entry: string;
@@ -28,7 +29,7 @@ const build = async (options: BuildOptions): Promise<void> => {
28
29
  const root = viteConfig?.root ?? process.cwd();
29
30
 
30
31
  const forced: InlineConfig = {
31
- plugins: [...gtkxVitePlugins(BUILD_MODE), gtkxBuiltUrl(assetBase), gtkxNative(root)],
32
+ plugins: [...gtkxVitePlugins(BUILD_MODE), gtkxWorker(), gtkxBuiltUrl(assetBase), gtkxNative(root)],
32
33
  build: {
33
34
  ssr: entry,
34
35
  assetsInlineLimit: 0,
@@ -44,4 +45,4 @@ const build = async (options: BuildOptions): Promise<void> => {
44
45
  await viteBuild({ ...merged, ssr: { ...merged.ssr, noExternal: true } });
45
46
  };
46
47
 
47
- export { build, type BuildOptions };
48
+ export { build };
package/src/cli.ts CHANGED
@@ -1,8 +1,10 @@
1
1
  import { packageVersion } from "@gtkx/utils";
2
2
  import { defineCommand, runMain } from "citty";
3
+ import { splitApplicationArgs } from "./internal/application-args.js";
3
4
  import { withErrorBoundary } from "./internal/errors.js";
4
5
 
5
- const version = packageVersion(import.meta.url);
6
+ const version = packageVersion(import.meta.url, "../package.json");
7
+ const { cliArgs } = splitApplicationArgs(process.argv.slice(2));
6
8
 
7
9
  const main = defineCommand({
8
10
  meta: {
@@ -39,4 +41,4 @@ const main = defineCommand({
39
41
  },
40
42
  });
41
43
 
42
- await runMain(main);
44
+ await runMain(main, { rawArgs: cliArgs });
@@ -27,15 +27,10 @@ const namespaceBarrelPath = (giStoreDir: string, library: string): string => {
27
27
  return join(giStoreDir, namespace, "index.js");
28
28
  };
29
29
 
30
- const isStoreResolvable = (storeDir: string, packageName: string): boolean =>
31
- existsSync(join(storeDir, "node_modules", "@gtkx", packageName, "package.json"));
30
+ const hasManifest = (storeDir: string): boolean => existsSync(join(storeDir, "package.json"));
32
31
 
33
32
  const isGiStoreStale = (store: CodegenStore, libraries: string[]): boolean => {
34
- if (!existsSync(store.giLinkDir) || !existsSync(store.giStoreDir)) {
35
- return true;
36
- }
37
-
38
- if (!isStoreResolvable(store.giStoreDir, "gi")) {
33
+ if (!existsSync(store.giLinkDir) || !hasManifest(store.giStoreDir)) {
39
34
  return true;
40
35
  }
41
36
 
@@ -47,7 +42,7 @@ const isReactStoreStale = (store: CodegenStore): boolean => {
47
42
  return false;
48
43
  }
49
44
 
50
- if (!existsSync(store.jsxLinkDir) || !isStoreResolvable(store.jsxStoreDir, "jsx")) {
45
+ if (!existsSync(store.jsxLinkDir) || !hasManifest(store.jsxStoreDir)) {
51
46
  return true;
52
47
  }
53
48
 
@@ -4,7 +4,7 @@ import {
4
4
  resolveElementComponents,
5
5
  resolveElementProps,
6
6
  resolveLazyElements,
7
- resolveOmitProps,
7
+ resolveOmittedProps,
8
8
  } from "@gtkx/config/internal";
9
9
  import { info } from "@gtkx/utils";
10
10
  import { rmSync } from "node:fs";
@@ -17,7 +17,7 @@ import { type CodegenStore, resolveCodegenContext } from "./store-resolver.js";
17
17
  type RunCodegenOptions = {
18
18
  cwd?: string;
19
19
  mode?: string | undefined;
20
- force?: boolean;
20
+ isForced?: boolean;
21
21
  inputs?: CodegenInputs;
22
22
  resolved?: LoadedConfig;
23
23
  };
@@ -28,7 +28,7 @@ type LoadedConfig = {
28
28
  };
29
29
 
30
30
  type RunCodegenResult = {
31
- regenerated: boolean;
31
+ isRegenerated: boolean;
32
32
  namespaces: number;
33
33
  intrinsicElements: number;
34
34
  duration: number;
@@ -44,7 +44,7 @@ type CodegenOptionsInput = {
44
44
  elements: Config["elements"];
45
45
  };
46
46
 
47
- type PreparedCodegen = CodegenInputs & { force: boolean };
47
+ type PreparedCodegen = CodegenInputs & { isForced: boolean };
48
48
 
49
49
  type RunOptionsInput = {
50
50
  root: string;
@@ -89,11 +89,11 @@ const codegenOptions = ({ store, libraries, girPath, elements }: CodegenOptionsI
89
89
  userComponents: resolveElementComponents(elements),
90
90
  userProps: resolveElementProps(elements),
91
91
  userLazyElements: resolveLazyElements(elements),
92
- userOmitProps: resolveOmitProps(elements),
92
+ userOmittedProps: resolveOmittedProps(elements),
93
93
  });
94
94
 
95
95
  const disabledCodegenResult = (configFile: string): RunCodegenResult => ({
96
- regenerated: false,
96
+ isRegenerated: false,
97
97
  namespaces: 0,
98
98
  intrinsicElements: 0,
99
99
  duration: 0,
@@ -118,9 +118,9 @@ const prepareCodegen = (options: RunCodegenOptions, cwd: string, config: Config)
118
118
  throw new Error(GIR_PATH_MISSING_MESSAGE);
119
119
  }
120
120
 
121
- const isForce = options.force === true || isCodegenStale({ girPath, libraries, store });
121
+ const isForced = options.isForced === true || isCodegenStale({ girPath, libraries, store });
122
122
 
123
- return { girPath, libraries, store, force: isForce };
123
+ return { girPath, libraries, store, isForced };
124
124
  };
125
125
 
126
126
  const runCodegen = async (options: RunCodegenOptions = {}): Promise<RunCodegenResult> => {
@@ -133,9 +133,9 @@ const runCodegen = async (options: RunCodegenOptions = {}): Promise<RunCodegenRe
133
133
  return disabledCodegenResult(configFile);
134
134
  }
135
135
 
136
- const { girPath, libraries, store, force } = prepareCodegen(options, cwd, config);
136
+ const { girPath, libraries, store, isForced } = prepareCodegen(options, cwd, config);
137
137
 
138
- if (options.force) {
138
+ if (options.isForced) {
139
139
  clearGeneratedStores(store);
140
140
  }
141
141
 
@@ -146,11 +146,11 @@ const runCodegen = async (options: RunCodegenOptions = {}): Promise<RunCodegenRe
146
146
  girPath,
147
147
  elements: config.elements,
148
148
  }),
149
- force,
149
+ isForced,
150
150
  });
151
151
 
152
152
  return {
153
- regenerated: result.regenerated,
153
+ isRegenerated: result.isRegenerated,
154
154
  namespaces: result.namespaces,
155
155
  intrinsicElements: result.intrinsicElements,
156
156
  duration: result.duration,
@@ -182,8 +182,8 @@ const resolveInputsOrNull = (cwd: string, config: Config): CodegenInputs | null
182
182
  }
183
183
  };
184
184
 
185
- const maybeAnnounceStale = (announce: boolean | undefined, inputs: CodegenInputs | null): void => {
186
- if (!announce) {
185
+ const maybeAnnounceStale = (shouldAnnounce: boolean | undefined, inputs: CodegenInputs | null): void => {
186
+ if (!shouldAnnounce) {
187
187
  return;
188
188
  }
189
189
 
@@ -200,11 +200,12 @@ const getRunOptions = ({ root, mode, inputs, resolved }: RunOptionsInput): RunCo
200
200
  return { cwd: root, mode, inputs, resolved };
201
201
  };
202
202
 
203
+ /* eslint-disable-next-line unicorn/consistent-boolean-name -- the boolean reports whether codegen ran */
203
204
  const ensureGenerated = async (
204
205
  cwd: string,
205
- options: { announce?: boolean; mode?: string } = {},
206
+ options: { shouldAnnounce?: boolean; mode?: string } = {},
206
207
  ): Promise<boolean> => {
207
- if (options.announce && process.env.GTKX_DISABLE_PREFLIGHT === "1") {
208
+ if (options.shouldAnnounce && process.env.GTKX_DISABLE_PREFLIGHT === "1") {
208
209
  return false;
209
210
  }
210
211
 
@@ -218,11 +219,11 @@ const ensureGenerated = async (
218
219
  }
219
220
 
220
221
  const inputs = resolveInputsOrNull(context.root, context.config);
221
- maybeAnnounceStale(options.announce, inputs);
222
+ maybeAnnounceStale(options.shouldAnnounce, inputs);
222
223
  const resolved = { config: context.config, configFile: context.configFile };
223
224
  const result = await runCodegen(getRunOptions({ root: context.root, mode: options.mode, inputs, resolved }));
224
225
 
225
- return result.regenerated;
226
+ return result.isRegenerated;
226
227
  };
227
228
 
228
229
  const resolveConfigWatch = async (
@@ -245,6 +246,5 @@ export {
245
246
  syncSchemaEnv,
246
247
  ensureGenerated,
247
248
  resolveConfigWatch,
248
- type RunCodegenOptions,
249
249
  type RunCodegenResult,
250
250
  };
@@ -1,3 +1,4 @@
1
+ import { resolveStore } from "@gtkx/codegen";
1
2
  import { type Config, loadConfig } from "@gtkx/config";
2
3
  import { existsSync, readFileSync, realpathSync } from "node:fs";
3
4
  import { createRequire } from "node:module";
@@ -32,24 +33,6 @@ const readVersion = (packageJsonPath: string): string => {
32
33
  return parsed.version ?? "0.0.0";
33
34
  };
34
35
 
35
- const readSubexports = (packageDir: string): string[] => {
36
- const parsed = JSON.parse(readFileSync(join(packageDir, "package.json"), "utf8")) as {
37
- exports?: Record<string, unknown>;
38
- };
39
-
40
- return Object.keys(parsed.exports ?? {})
41
- .filter((key) => key.startsWith("./") && key !== "./package.json")
42
- .map((key) => key.slice(2));
43
- };
44
-
45
- /** Resolves the `@gtkx/react` subexport names for a project without requiring runtime/native to be installed. */
46
- const resolveReactSubexports = (dir: string): string[] => {
47
- const require = createRequire(pathToFileURL(join(dir, "__gtkx_resolver__.js")).href);
48
- const react = resolvePackage(require, dir, "@gtkx/react");
49
-
50
- return react === null ? [] : readSubexports(react.dir);
51
- };
52
-
53
36
  const resolvePackage = (require: NodeJS.Require, dir: string, packageName: string): ResolvedPackage | null => {
54
37
  try {
55
38
  const real = realpathSync(require.resolve(`${packageName}/package.json`));
@@ -69,36 +52,27 @@ const resolvePackage = (require: NodeJS.Require, dir: string, packageName: strin
69
52
  }
70
53
  };
71
54
 
55
+ const siblingStore = (giDir: string): string => join(dirname(giDir), "jsx");
56
+
72
57
  const resolveCodegenStore = (dir: string): CodegenStore => {
73
58
  const require = createRequire(pathToFileURL(join(dir, "__gtkx_resolver__.js")).href);
74
- const runtime = resolvePackage(require, dir, "@gtkx/runtime");
75
-
76
- if (runtime === null) {
77
- throw new Error("Cannot resolve @gtkx/runtime from the project; is it installed?");
78
- }
79
-
80
- const native = resolvePackage(require, dir, "@gtkx/native");
81
59
 
82
- if (native === null) {
60
+ if (resolvePackage(require, dir, "@gtkx/native") === null) {
83
61
  throw new Error("Cannot resolve @gtkx/native from the project; is it installed?");
84
62
  }
85
63
 
86
- const react = resolvePackage(require, dir, "@gtkx/react");
87
- const reactRuntime = resolvePackage(require, dir, "react");
88
- const nodeModules = join(dir, "node_modules");
64
+ const store = resolveStore(dir);
65
+ const hasReactRuntime = resolvePackage(require, dir, "react") !== null;
89
66
 
90
67
  return {
91
- giStoreDir: join(nodeModules, ".gtkx", "gi"),
92
- giLinkDir: join(nodeModules, "@gtkx", "gi"),
93
- jsxStoreDir: join(nodeModules, ".gtkx", "jsx"),
94
- jsxLinkDir: join(nodeModules, "@gtkx", "jsx"),
95
- runtimeVersion: runtime.version,
68
+ giStoreDir: store.gi.storeDir,
69
+ giLinkDir: store.gi.linkDir,
70
+ jsxStoreDir: store.jsx?.storeDir ?? siblingStore(store.gi.storeDir),
71
+ jsxLinkDir: store.jsx?.linkDir ?? siblingStore(store.gi.linkDir),
72
+ runtimeVersion: store.gi.version,
96
73
  react:
97
- react !== null && reactRuntime !== null
98
- ? {
99
- version: react.version,
100
- subexports: readSubexports(react.dir),
101
- }
74
+ hasReactRuntime && store.jsx !== null
75
+ ? { version: store.jsx.version, subexports: store.reactSubexports }
102
76
  : null,
103
77
  };
104
78
  };
@@ -109,4 +83,4 @@ const resolveCodegenContext = async (cwd: string, mode?: string): Promise<Codege
109
83
  return { root: cwd, config, configFile };
110
84
  };
111
85
 
112
- export { resolveReactSubexports, resolveCodegenStore, resolveCodegenContext, type CodegenStore, type CodegenContext };
86
+ export { resolveCodegenStore, resolveCodegenContext, type CodegenStore };
@@ -21,7 +21,7 @@ const build = defineCommand({
21
21
  async run({ args }) {
22
22
  const { cwd, entry } = resolveEntry(args);
23
23
  info(`Building ${entry}`);
24
- await ensureGenerated(cwd, { announce: true, mode: BUILD_MODE });
24
+ await ensureGenerated(cwd, { shouldAnnounce: true, mode: BUILD_MODE });
25
25
 
26
26
  await buildApp({
27
27
  entry,
@@ -36,7 +36,7 @@ const codegen = defineCommand({
36
36
  }
37
37
 
38
38
  const startedAt = Date.now();
39
- const result = await runCodegen({ cwd, force: true });
39
+ const result = await runCodegen({ cwd, isForced: true });
40
40
  syncSchemaEnv(cwd);
41
41
  const lines = formatCodegenResult(result, Date.now() - startedAt);
42
42
 
@@ -1,6 +1,7 @@
1
1
  import { defineCommand } from "citty";
2
2
  import { ensureGenerated, resolveConfigWatch } from "../codegen/run-codegen.js";
3
3
  import { type DevWatch, runDevSupervisor } from "../dev/supervisor.js";
4
+ import { splitApplicationArgs } from "../internal/application-args.js";
4
5
  import { entryArg, resolveEntry } from "../internal/entry-arg.js";
5
6
 
6
7
  const DEV_MODE = "development";
@@ -15,9 +16,10 @@ const dev = defineCommand({
15
16
  },
16
17
  async run({ args }) {
17
18
  const { cwd, entry: entryPath } = resolveEntry(args);
18
- await ensureGenerated(cwd, { announce: true, mode: DEV_MODE });
19
+ await ensureGenerated(cwd, { shouldAnnounce: true, mode: DEV_MODE });
19
20
  const watch: DevWatch | undefined = await resolveConfigWatch(cwd, DEV_MODE);
20
- await runDevSupervisor(entryPath, cwd, watch);
21
+ const { applicationArgs } = splitApplicationArgs(process.argv.slice(2));
22
+ await runDevSupervisor({ entryPath, cwd, args: applicationArgs, watch });
21
23
  },
22
24
  });
23
25
 
@@ -1,19 +1,19 @@
1
1
  import {
2
2
  type ElementProps,
3
- mergeOmitProps,
3
+ mergeOmittedProps,
4
4
  type OmittedProps,
5
5
  readBuiltinElements,
6
6
  resolveGirPath,
7
7
  resolveLibraries,
8
- writeDocs,
8
+ resolveStore,
9
9
  } from "@gtkx/codegen";
10
+ import { writeDocs } from "@gtkx/codegen/internal";
10
11
  import { loadConfig } from "@gtkx/config";
11
- import { resolveOmitProps } from "@gtkx/config/internal";
12
+ import { resolveOmittedProps } from "@gtkx/config/internal";
12
13
  import { info } from "@gtkx/utils";
13
14
  import { defineCommand } from "citty";
14
15
  import { existsSync } from "node:fs";
15
- import { join, resolve } from "node:path";
16
- import { resolveReactSubexports } from "../codegen/store-resolver.js";
16
+ import { resolve } from "node:path";
17
17
  import { cwdArg, resolveCwd } from "../internal/entry-arg.js";
18
18
 
19
19
  const docs = defineCommand({
@@ -66,17 +66,17 @@ const docs = defineCommand({
66
66
  const outDir = resolve(cwd, args.out);
67
67
  const builtin = await resolveDocsElements(cwd);
68
68
 
69
- const { regenerated, namespaces } = writeDocs({
69
+ const { isRegenerated, namespaces } = writeDocs({
70
70
  libraries,
71
71
  girPath,
72
72
  outDir,
73
73
  basePath: args["base-path"],
74
74
  props: builtin.props,
75
- omitProps: mergeOmitProps(builtin.omitProps, resolveOmitProps(config.elements)),
76
- force: args.force,
75
+ omittedProps: mergeOmittedProps(builtin.omittedProps, resolveOmittedProps(config.elements)),
76
+ isForced: args.force,
77
77
  });
78
78
 
79
- if (!regenerated) {
79
+ if (!isRegenerated) {
80
80
  info(`docs: pages in ${outDir} are up to date`);
81
81
 
82
82
  return;
@@ -91,16 +91,16 @@ const docs = defineCommand({
91
91
  },
92
92
  });
93
93
 
94
- const resolveDocsElements = async (cwd: string): Promise<{ props: ElementProps; omitProps: OmittedProps }> => {
95
- const giStoreDir = join(cwd, "node_modules", ".gtkx", "gi");
94
+ const resolveDocsElements = async (cwd: string): Promise<{ props: ElementProps; omittedProps: OmittedProps }> => {
95
+ const { gi, reactSubexports } = resolveStore(cwd);
96
96
 
97
- if (!existsSync(giStoreDir)) {
98
- return { props: {}, omitProps: {} };
97
+ if (!existsSync(gi.storeDir)) {
98
+ return { props: {}, omittedProps: {} };
99
99
  }
100
100
 
101
- const { props, omitProps } = await readBuiltinElements(resolveReactSubexports(cwd), giStoreDir);
101
+ const { props, omittedProps } = await readBuiltinElements(reactSubexports, gi.storeDir);
102
102
 
103
- return { props, omitProps };
103
+ return { props, omittedProps };
104
104
  };
105
105
 
106
106
  export { docs };
@@ -0,0 +1,3 @@
1
+ const DEV_ENTRY_ENV = "GTKX_DEV_ENTRY";
2
+
3
+ export { DEV_ENTRY_ENV };
@@ -45,6 +45,7 @@ const defaultDevRunnerDeps = (): DevRunnerDeps => ({
45
45
  watchApplicationShutdown: (onShutdown) => {
46
46
  Gio.Application.getDefault()?.on("shutdown", onShutdown);
47
47
  },
48
+ isApplicationRegistered: () => Gio.Application.getDefault()?.getIsRegistered() === true,
48
49
  installShutdownHandlers: (onSignal) => {
49
50
  installGracefulShutdown({ onSignal });
50
51
  },
@@ -1,12 +1,11 @@
1
1
  import { error } from "@gtkx/utils";
2
2
  import { resolve } from "node:path";
3
3
  import { resolveDataDir } from "../internal/data-dir.js";
4
+ import { DEV_ENTRY_ENV } from "./entry-env.js";
4
5
  import { prepareDevIconDir } from "./icon-dir.js";
5
6
  import { createDevRunner } from "./runner.js";
6
7
  import { prepareDevSchemaDir } from "./schema-dir.js";
7
8
 
8
- const ENTRY_ARG_INDEX = 2;
9
-
10
9
  const main = async (): Promise<void> => {
11
10
  if (process.channel) {
12
11
  process.once("disconnect", () => {
@@ -15,10 +14,10 @@ const main = async (): Promise<void> => {
15
14
  }
16
15
 
17
16
  const cwd = process.cwd();
18
- const entryArg = process.argv[ENTRY_ARG_INDEX];
17
+ const entryArg = process.env[DEV_ENTRY_ENV];
19
18
 
20
19
  if (!entryArg) {
21
- error("Missing entry argument");
20
+ error(`Missing ${DEV_ENTRY_ENV}`);
22
21
  process.exit(1);
23
22
  }
24
23