@gtkx/cli 1.6.0 → 2.0.0-beta.2

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 (309) hide show
  1. package/README.md +5 -5
  2. package/dist/builder.d.ts +1 -0
  3. package/dist/builder.d.ts.map +1 -1
  4. package/dist/builder.js +17 -5
  5. package/dist/builder.js.map +1 -1
  6. package/dist/cli.js +2 -0
  7. package/dist/cli.js.map +1 -1
  8. package/dist/codegen/freshness.d.ts.map +1 -1
  9. package/dist/codegen/freshness.js +45 -16
  10. package/dist/codegen/freshness.js.map +1 -1
  11. package/dist/codegen/reference.d.ts.map +1 -1
  12. package/dist/codegen/reference.js +1 -7
  13. package/dist/codegen/reference.js.map +1 -1
  14. package/dist/codegen/report.d.ts.map +1 -1
  15. package/dist/codegen/report.js +5 -16
  16. package/dist/codegen/report.js.map +1 -1
  17. package/dist/codegen/run-codegen.d.ts +7 -7
  18. package/dist/codegen/run-codegen.d.ts.map +1 -1
  19. package/dist/codegen/run-codegen.js +35 -107
  20. package/dist/codegen/run-codegen.js.map +1 -1
  21. package/dist/codegen/store-resolver.d.ts +1 -2
  22. package/dist/codegen/store-resolver.d.ts.map +1 -1
  23. package/dist/codegen/store-resolver.js +10 -19
  24. package/dist/codegen/store-resolver.js.map +1 -1
  25. package/dist/commands/build.d.ts +5 -0
  26. package/dist/commands/build.d.ts.map +1 -1
  27. package/dist/commands/build.js +83 -10
  28. package/dist/commands/build.js.map +1 -1
  29. package/dist/commands/codegen.d.ts +1 -0
  30. package/dist/commands/codegen.d.ts.map +1 -1
  31. package/dist/commands/codegen.js +6 -5
  32. package/dist/commands/codegen.js.map +1 -1
  33. package/dist/commands/deploy.d.ts +1 -0
  34. package/dist/commands/deploy.d.ts.map +1 -1
  35. package/dist/commands/deploy.js +4 -2
  36. package/dist/commands/deploy.js.map +1 -1
  37. package/dist/commands/dev.d.ts +8 -0
  38. package/dist/commands/dev.d.ts.map +1 -1
  39. package/dist/commands/dev.js +19 -1
  40. package/dist/commands/dev.js.map +1 -1
  41. package/dist/commands/docs.d.ts.map +1 -1
  42. package/dist/commands/docs.js +5 -15
  43. package/dist/commands/docs.js.map +1 -1
  44. package/dist/deploy/freedesktop/copyright.d.ts.map +1 -1
  45. package/dist/deploy/freedesktop/copyright.js +2 -13
  46. package/dist/deploy/freedesktop/copyright.js.map +1 -1
  47. package/dist/deploy/freedesktop/metainfo.d.ts.map +1 -1
  48. package/dist/deploy/freedesktop/metainfo.js +41 -2
  49. package/dist/deploy/freedesktop/metainfo.js.map +1 -1
  50. package/dist/deploy/freedesktop/xml.d.ts.map +1 -1
  51. package/dist/deploy/freedesktop/xml.js +21 -25
  52. package/dist/deploy/freedesktop/xml.js.map +1 -1
  53. package/dist/deploy/nfpm/config.d.ts.map +1 -1
  54. package/dist/deploy/nfpm/config.js +5 -2
  55. package/dist/deploy/nfpm/config.js.map +1 -1
  56. package/dist/deploy/nfpm/contents.d.ts.map +1 -1
  57. package/dist/deploy/nfpm/contents.js +8 -0
  58. package/dist/deploy/nfpm/contents.js.map +1 -1
  59. package/dist/deploy/node-runtime/elf.d.ts +2 -1
  60. package/dist/deploy/node-runtime/elf.d.ts.map +1 -1
  61. package/dist/deploy/node-runtime/elf.js +32 -5
  62. package/dist/deploy/node-runtime/elf.js.map +1 -1
  63. package/dist/deploy/node-runtime/index.d.ts +2 -1
  64. package/dist/deploy/node-runtime/index.d.ts.map +1 -1
  65. package/dist/deploy/node-runtime/index.js +73 -4
  66. package/dist/deploy/node-runtime/index.js.map +1 -1
  67. package/dist/deploy/node-runtime/license.d.ts.map +1 -1
  68. package/dist/deploy/node-runtime/license.js +2 -9
  69. package/dist/deploy/node-runtime/license.js.map +1 -1
  70. package/dist/deploy/notices/node-runtime.js +2 -2
  71. package/dist/deploy/notices/node-runtime.js.map +1 -1
  72. package/dist/deploy/notices/packages.d.ts.map +1 -1
  73. package/dist/deploy/notices/packages.js +3 -10
  74. package/dist/deploy/notices/packages.js.map +1 -1
  75. package/dist/deploy/payload/copy-tree.d.ts.map +1 -1
  76. package/dist/deploy/payload/copy-tree.js +3 -3
  77. package/dist/deploy/payload/copy-tree.js.map +1 -1
  78. package/dist/deploy/payload/launcher.d.ts.map +1 -1
  79. package/dist/deploy/payload/launcher.js +14 -1
  80. package/dist/deploy/payload/launcher.js.map +1 -1
  81. package/dist/deploy/payload/stage.d.ts.map +1 -1
  82. package/dist/deploy/payload/stage.js +2 -4
  83. package/dist/deploy/payload/stage.js.map +1 -1
  84. package/dist/deploy/run-deploy.d.ts +1 -0
  85. package/dist/deploy/run-deploy.d.ts.map +1 -1
  86. package/dist/deploy/run-deploy.js +100 -14
  87. package/dist/deploy/run-deploy.js.map +1 -1
  88. package/dist/deploy/settings/build-manifest.d.ts +6 -1
  89. package/dist/deploy/settings/build-manifest.d.ts.map +1 -1
  90. package/dist/deploy/settings/build-manifest.js +17 -17
  91. package/dist/deploy/settings/build-manifest.js.map +1 -1
  92. package/dist/deploy/settings/extra-files.d.ts +1 -1
  93. package/dist/deploy/settings/extra-files.d.ts.map +1 -1
  94. package/dist/deploy/settings/extra-files.js +22 -1
  95. package/dist/deploy/settings/extra-files.js.map +1 -1
  96. package/dist/deploy/settings/index.d.ts +1 -0
  97. package/dist/deploy/settings/index.d.ts.map +1 -1
  98. package/dist/deploy/settings/index.js +2 -1
  99. package/dist/deploy/settings/index.js.map +1 -1
  100. package/dist/deploy/settings/libraries.d.ts.map +1 -1
  101. package/dist/deploy/settings/libraries.js +2 -19
  102. package/dist/deploy/settings/libraries.js.map +1 -1
  103. package/dist/deploy/settings/paths.d.ts +2 -2
  104. package/dist/deploy/settings/paths.d.ts.map +1 -1
  105. package/dist/deploy/settings/paths.js +110 -12
  106. package/dist/deploy/settings/paths.js.map +1 -1
  107. package/dist/deploy/settings/screenshots.d.ts.map +1 -1
  108. package/dist/deploy/settings/screenshots.js +6 -31
  109. package/dist/deploy/settings/screenshots.js.map +1 -1
  110. package/dist/deploy/targets/flatpak-pnpm.js +4 -4
  111. package/dist/deploy/targets/flatpak-pnpm.js.map +1 -1
  112. package/dist/deploy/targets/flatpak-source.d.ts.map +1 -1
  113. package/dist/deploy/targets/flatpak-source.js +15 -6
  114. package/dist/deploy/targets/flatpak-source.js.map +1 -1
  115. package/dist/deploy/targets/flatpak-sources.js +1 -1
  116. package/dist/deploy/targets/flatpak-sources.js.map +1 -1
  117. package/dist/deploy/types.d.ts +1 -0
  118. package/dist/deploy/types.d.ts.map +1 -1
  119. package/dist/deploy/types.js.map +1 -1
  120. package/dist/dev/headless.d.ts +3 -0
  121. package/dist/dev/headless.d.ts.map +1 -0
  122. package/dist/dev/headless.js +35 -0
  123. package/dist/dev/headless.js.map +1 -0
  124. package/dist/dev/runner-deps.js +1 -1
  125. package/dist/dev/runner-deps.js.map +1 -1
  126. package/dist/dev/runner-main.d.ts.map +1 -1
  127. package/dist/dev/runner-main.js +1 -2
  128. package/dist/dev/runner-main.js.map +1 -1
  129. package/dist/dev/schema-dir.d.ts +1 -1
  130. package/dist/dev/schema-dir.d.ts.map +1 -1
  131. package/dist/dev/schema-dir.js +2 -4
  132. package/dist/dev/schema-dir.js.map +1 -1
  133. package/dist/i18n/catalogs.d.ts.map +1 -1
  134. package/dist/i18n/catalogs.js +2 -1
  135. package/dist/i18n/catalogs.js.map +1 -1
  136. package/dist/i18n/metadata-templates.d.ts.map +1 -1
  137. package/dist/i18n/metadata-templates.js +2 -1
  138. package/dist/i18n/metadata-templates.js.map +1 -1
  139. package/dist/i18n/source-messages.d.ts +3 -21
  140. package/dist/i18n/source-messages.d.ts.map +1 -1
  141. package/dist/i18n/source-messages.js +900 -85
  142. package/dist/i18n/source-messages.js.map +1 -1
  143. package/dist/i18n/types.d.ts +6 -7
  144. package/dist/i18n/types.d.ts.map +1 -1
  145. package/dist/i18n/types.js +83 -96
  146. package/dist/i18n/types.js.map +1 -1
  147. package/dist/internal/build-manifest.d.ts +5 -2
  148. package/dist/internal/build-manifest.d.ts.map +1 -1
  149. package/dist/internal/build-manifest.js +15 -2
  150. package/dist/internal/build-manifest.js.map +1 -1
  151. package/dist/internal/build-output.d.ts +8 -0
  152. package/dist/internal/build-output.d.ts.map +1 -0
  153. package/dist/internal/build-output.js +69 -0
  154. package/dist/internal/build-output.js.map +1 -0
  155. package/dist/internal/docs-elements.js +2 -2
  156. package/dist/internal/docs-elements.js.map +1 -1
  157. package/dist/internal/entry-arg.d.ts +4 -1
  158. package/dist/internal/entry-arg.d.ts.map +1 -1
  159. package/dist/internal/entry-arg.js +7 -1
  160. package/dist/internal/entry-arg.js.map +1 -1
  161. package/dist/internal/icon-path.d.ts.map +1 -1
  162. package/dist/internal/icon-path.js +5 -16
  163. package/dist/internal/icon-path.js.map +1 -1
  164. package/dist/internal/output-directory.d.ts +15 -0
  165. package/dist/internal/output-directory.d.ts.map +1 -0
  166. package/dist/internal/output-directory.js +490 -0
  167. package/dist/internal/output-directory.js.map +1 -0
  168. package/dist/internal/prepare-project.d.ts +2 -0
  169. package/dist/internal/prepare-project.d.ts.map +1 -1
  170. package/dist/internal/prepare-project.js +3 -3
  171. package/dist/internal/prepare-project.js.map +1 -1
  172. package/dist/internal/source-imports.d.ts.map +1 -1
  173. package/dist/internal/source-imports.js +10 -41
  174. package/dist/internal/source-imports.js.map +1 -1
  175. package/dist/mcp/client.js +2 -2
  176. package/dist/mcp/client.js.map +1 -1
  177. package/dist/settings/render.d.ts +0 -1
  178. package/dist/settings/render.d.ts.map +1 -1
  179. package/dist/settings/render.js +1 -11
  180. package/dist/settings/render.js.map +1 -1
  181. package/dist/settings/schema.d.ts +2 -2
  182. package/dist/settings/schema.d.ts.map +1 -1
  183. package/dist/settings/schema.js +21 -62
  184. package/dist/settings/schema.js.map +1 -1
  185. package/dist/vite-plugins/asset-imports.d.ts +1 -2
  186. package/dist/vite-plugins/asset-imports.d.ts.map +1 -1
  187. package/dist/vite-plugins/asset-imports.js +19 -32
  188. package/dist/vite-plugins/asset-imports.js.map +1 -1
  189. package/dist/vite-plugins/asset-specifier.d.ts +1 -3
  190. package/dist/vite-plugins/asset-specifier.d.ts.map +1 -1
  191. package/dist/vite-plugins/asset-specifier.js +1 -4
  192. package/dist/vite-plugins/asset-specifier.js.map +1 -1
  193. package/dist/vite-plugins/build-manifest.d.ts +5 -1
  194. package/dist/vite-plugins/build-manifest.d.ts.map +1 -1
  195. package/dist/vite-plugins/build-manifest.js +2 -1
  196. package/dist/vite-plugins/build-manifest.js.map +1 -1
  197. package/dist/vite-plugins/i18n.d.ts.map +1 -1
  198. package/dist/vite-plugins/i18n.js +59 -6
  199. package/dist/vite-plugins/i18n.js.map +1 -1
  200. package/dist/vite-plugins/index.d.ts +8 -1
  201. package/dist/vite-plugins/index.d.ts.map +1 -1
  202. package/dist/vite-plugins/index.js +8 -6
  203. package/dist/vite-plugins/index.js.map +1 -1
  204. package/dist/vite-plugins/resources.d.ts.map +1 -1
  205. package/dist/vite-plugins/resources.js +32 -97
  206. package/dist/vite-plugins/resources.js.map +1 -1
  207. package/dist/vite-plugins/self-contained.d.ts.map +1 -1
  208. package/dist/vite-plugins/self-contained.js +159 -158
  209. package/dist/vite-plugins/self-contained.js.map +1 -1
  210. package/dist/vite-plugins/settings-worker-env.d.ts.map +1 -1
  211. package/dist/vite-plugins/settings-worker-env.js +2 -4
  212. package/dist/vite-plugins/settings-worker-env.js.map +1 -1
  213. package/dist/vite-plugins/settings.d.ts +1 -2
  214. package/dist/vite-plugins/settings.d.ts.map +1 -1
  215. package/dist/vite-plugins/settings.js +8 -14
  216. package/dist/vite-plugins/settings.js.map +1 -1
  217. package/dist/vite-plugins/undeclared-library.d.ts.map +1 -1
  218. package/dist/vite-plugins/undeclared-library.js +10 -13
  219. package/dist/vite-plugins/undeclared-library.js.map +1 -1
  220. package/dist/vite-plugins/worker.d.ts.map +1 -1
  221. package/dist/vite-plugins/worker.js +0 -1
  222. package/dist/vite-plugins/worker.js.map +1 -1
  223. package/package.json +21 -15
  224. package/src/builder.ts +18 -5
  225. package/src/cli.ts +3 -0
  226. package/src/codegen/freshness.ts +66 -17
  227. package/src/codegen/reference.ts +1 -8
  228. package/src/codegen/report.ts +5 -21
  229. package/src/codegen/run-codegen.ts +42 -151
  230. package/src/codegen/store-resolver.ts +10 -26
  231. package/src/commands/build.ts +13 -2
  232. package/src/commands/codegen.ts +6 -5
  233. package/src/commands/deploy.ts +4 -2
  234. package/src/commands/dev.ts +20 -1
  235. package/src/commands/docs.ts +5 -17
  236. package/src/deploy/freedesktop/copyright.ts +2 -14
  237. package/src/deploy/freedesktop/metainfo.ts +73 -21
  238. package/src/deploy/freedesktop/xml.ts +24 -32
  239. package/src/deploy/nfpm/config.ts +5 -2
  240. package/src/deploy/nfpm/contents.ts +8 -0
  241. package/src/deploy/node-runtime/elf.ts +43 -5
  242. package/src/deploy/node-runtime/index.ts +105 -5
  243. package/src/deploy/node-runtime/license.ts +2 -8
  244. package/src/deploy/notices/node-runtime.ts +2 -2
  245. package/src/deploy/notices/packages.ts +3 -11
  246. package/src/deploy/payload/copy-tree.ts +3 -4
  247. package/src/deploy/payload/launcher.ts +20 -1
  248. package/src/deploy/payload/stage.ts +3 -7
  249. package/src/deploy/run-deploy.ts +56 -16
  250. package/src/deploy/settings/build-manifest.ts +30 -17
  251. package/src/deploy/settings/extra-files.ts +26 -2
  252. package/src/deploy/settings/index.ts +3 -1
  253. package/src/deploy/settings/libraries.ts +1 -22
  254. package/src/deploy/settings/paths.ts +68 -13
  255. package/src/deploy/settings/screenshots.ts +8 -46
  256. package/src/deploy/targets/flatpak-pnpm.ts +4 -4
  257. package/src/deploy/targets/flatpak-source.ts +17 -6
  258. package/src/deploy/targets/flatpak-sources.ts +1 -1
  259. package/src/deploy/types.ts +1 -0
  260. package/src/dev/headless.ts +40 -0
  261. package/src/dev/runner-deps.ts +1 -1
  262. package/src/dev/runner-main.ts +1 -2
  263. package/src/dev/schema-dir.ts +2 -4
  264. package/src/i18n/catalogs.ts +2 -1
  265. package/src/i18n/metadata-templates.ts +2 -1
  266. package/src/i18n/source-messages.ts +1442 -262
  267. package/src/i18n/types.ts +97 -131
  268. package/src/internal/build-manifest.ts +25 -1
  269. package/src/internal/build-output.ts +99 -0
  270. package/src/internal/docs-elements.ts +2 -2
  271. package/src/internal/entry-arg.ts +8 -1
  272. package/src/internal/icon-path.ts +6 -19
  273. package/src/internal/output-directory.ts +699 -0
  274. package/src/internal/prepare-project.ts +5 -5
  275. package/src/internal/source-imports.ts +14 -50
  276. package/src/mcp/client.ts +2 -2
  277. package/src/settings/render.ts +1 -13
  278. package/src/settings/schema.ts +19 -81
  279. package/src/vite-plugins/asset-imports.ts +20 -44
  280. package/src/vite-plugins/asset-specifier.ts +0 -5
  281. package/src/vite-plugins/build-manifest.ts +7 -1
  282. package/src/vite-plugins/i18n.ts +87 -5
  283. package/src/vite-plugins/index.ts +16 -11
  284. package/src/vite-plugins/resources.ts +37 -140
  285. package/src/vite-plugins/self-contained.ts +184 -185
  286. package/src/vite-plugins/settings-worker-env.ts +2 -4
  287. package/src/vite-plugins/settings.ts +11 -20
  288. package/src/vite-plugins/undeclared-library.ts +14 -20
  289. package/src/vite-plugins/worker.ts +0 -1
  290. package/dist/i18n/binding-extractor.d.ts +0 -30
  291. package/dist/i18n/binding-extractor.d.ts.map +0 -1
  292. package/dist/i18n/binding-extractor.js +0 -1324
  293. package/dist/i18n/binding-extractor.js.map +0 -1
  294. package/dist/i18n/extractor-plugin.d.ts +0 -8
  295. package/dist/i18n/extractor-plugin.d.ts.map +0 -1
  296. package/dist/i18n/extractor-plugin.js +0 -247
  297. package/dist/i18n/extractor-plugin.js.map +0 -1
  298. package/dist/internal/data-dir.d.ts +0 -4
  299. package/dist/internal/data-dir.d.ts.map +0 -1
  300. package/dist/internal/data-dir.js +0 -52
  301. package/dist/internal/data-dir.js.map +0 -1
  302. package/dist/vite-plugins/animated.d.ts +0 -5
  303. package/dist/vite-plugins/animated.d.ts.map +0 -1
  304. package/dist/vite-plugins/animated.js +0 -325
  305. package/dist/vite-plugins/animated.js.map +0 -1
  306. package/src/i18n/binding-extractor.ts +0 -1969
  307. package/src/i18n/extractor-plugin.ts +0 -413
  308. package/src/internal/data-dir.ts +0 -70
  309. package/src/vite-plugins/animated.ts +0 -486
@@ -2,7 +2,7 @@ import { info } from "@gtkx/utils";
2
2
  import { defineCommand } from "citty";
3
3
  import { formatCodegenResult } from "../codegen/report.js";
4
4
  import { ensureGenerated, isCodegenDisabled, runCodegen } from "../codegen/run-codegen.js";
5
- import { cwdArg, resolveCwd } from "../internal/entry-arg.js";
5
+ import { configArg, cwdArg, resolveCwd } from "../internal/entry-arg.js";
6
6
  const FORCED_WHILE_DISABLED_MESSAGE = "codegen is disabled for this project, so --force has no store to regenerate here. " +
7
7
  "Remove `codegen: false` from gtkx.config.ts, or run `gtkx codegen --force` where the installed " +
8
8
  "binding store is generated.";
@@ -17,24 +17,25 @@ const codegen = defineCommand({
17
17
  description: "Wipe the generated store and regenerate unconditionally (recover a corrupted store)",
18
18
  default: false,
19
19
  },
20
+ ...configArg,
20
21
  ...cwdArg,
21
22
  },
22
23
  async run({ args }) {
23
24
  const cwd = resolveCwd(args);
24
- const isDisabled = await isCodegenDisabled(cwd);
25
+ const isDisabled = await isCodegenDisabled(cwd, undefined, args.config);
25
26
  checkForce(isDisabled, args.force);
26
27
  if (isDisabled) {
27
- await runCodegen({ cwd });
28
+ await runCodegen({ cwd, configFile: args.config });
28
29
  info("codegen: disabled for this project; reusing an installed binding store");
29
30
  return;
30
31
  }
31
32
  if (!args.force) {
32
- const isRan = await ensureGenerated(cwd);
33
+ const isRan = await ensureGenerated(cwd, { configFile: args.config });
33
34
  info(isRan ? "codegen: regenerated stale bindings" : "codegen: bindings up to date");
34
35
  return;
35
36
  }
36
37
  const startedAt = Date.now();
37
- const result = await runCodegen({ cwd, isForced: true });
38
+ const result = await runCodegen({ cwd, configFile: args.config, isForced: true });
38
39
  const lines = formatCodegenResult(result, Date.now() - startedAt);
39
40
  for (const line of lines) {
40
41
  info(line);
@@ -1 +1 @@
1
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AAC,CAAC;YAErF,OAAO;QACX,CAAC;QAED,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC7B,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QACzD,MAAM,KAAK,GAAG,mBAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC,CAAC;QAElE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACvB,IAAI,CAAC,IAAI,CAAC,CAAC;QACf,CAAC;IACL,CAAC;CACJ,CAAC,CAAC;AAEH,MAAM,UAAU,GAAG,CAAC,UAAmB,EAAE,QAAiB,EAAQ,EAAE;IAChE,IAAI,UAAU,IAAI,QAAQ,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACnD,CAAC;AACL,CAAC,CAAC;AAEF,OAAO,EAAE,OAAO,EAAE,CAAC","sourcesContent":["import { info } from \"@gtkx/utils\";\nimport { defineCommand } from \"citty\";\nimport { formatCodegenResult } from \"../codegen/report.js\";\nimport { ensureGenerated, isCodegenDisabled, runCodegen } from \"../codegen/run-codegen.js\";\nimport { cwdArg, resolveCwd } from \"../internal/entry-arg.js\";\n\nconst FORCED_WHILE_DISABLED_MESSAGE =\n \"codegen is disabled for this project, so --force has no store to regenerate here. \" +\n \"Remove `codegen: false` from gtkx.config.ts, or run `gtkx codegen --force` where the installed \" +\n \"binding store is generated.\";\n\nconst codegen = defineCommand({\n meta: {\n name: \"codegen\",\n description: \"Generate project bindings, translation catalogs, and TypeScript declarations\",\n },\n args: {\n force: {\n type: \"boolean\",\n description: \"Wipe the generated store and regenerate unconditionally (recover a corrupted store)\",\n default: false,\n },\n ...cwdArg,\n },\n async run({ args }) {\n const cwd = resolveCwd(args);\n const isDisabled = await isCodegenDisabled(cwd);\n checkForce(isDisabled, args.force);\n\n if (isDisabled) {\n await runCodegen({ cwd });\n info(\"codegen: disabled for this project; reusing an installed binding store\");\n\n return;\n }\n\n if (!args.force) {\n const isRan = await ensureGenerated(cwd);\n info(isRan ? \"codegen: regenerated stale bindings\" : \"codegen: bindings up to date\");\n\n return;\n }\n\n const startedAt = Date.now();\n const result = await runCodegen({ cwd, isForced: true });\n const lines = formatCodegenResult(result, Date.now() - startedAt);\n\n for (const line of lines) {\n info(line);\n }\n },\n});\n\nconst checkForce = (isDisabled: boolean, isForced: boolean): void => {\n if (isDisabled && isForced) {\n throw new Error(FORCED_WHILE_DISABLED_MESSAGE);\n }\n};\n\nexport { codegen };\n"]}
1
+ {"version":3,"file":"codegen.js","sourceRoot":"","sources":["../../src/commands/codegen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC3F,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEzE,MAAM,6BAA6B,GAC/B,oFAAoF;IACpF,iGAAiG;IACjG,6BAA6B,CAAC;AAElC,MAAM,OAAO,GAAG,aAAa,CAAC;IAC1B,IAAI,EAAE;QACF,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,8EAA8E;KAC9F;IACD,IAAI,EAAE;QACF,KAAK,EAAE;YACH,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,qFAAqF;YAClG,OAAO,EAAE,KAAK;SACjB;QACD,GAAG,SAAS;QACZ,GAAG,MAAM;KACZ;IACD,KAAK,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE;QACd,MAAM,GAAG,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;QAC7B,MAAM,UAAU,GAAG,MAAM,i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x/utils\";\nimport { defineCommand } from \"citty\";\nimport { formatCodegenResult } from \"../codegen/report.js\";\nimport { ensureGenerated, isCodegenDisabled, runCodegen } from \"../codegen/run-codegen.js\";\nimport { configArg, cwdArg, resolveCwd } from \"../internal/entry-arg.js\";\n\nconst FORCED_WHILE_DISABLED_MESSAGE =\n \"codegen is disabled for this project, so --force has no store to regenerate here. \" +\n \"Remove `codegen: false` from gtkx.config.ts, or run `gtkx codegen --force` where the installed \" +\n \"binding store is generated.\";\n\nconst codegen = defineCommand({\n meta: {\n name: \"codegen\",\n description: \"Generate project bindings, translation catalogs, and TypeScript declarations\",\n },\n args: {\n force: {\n type: \"boolean\",\n description: \"Wipe the generated store and regenerate unconditionally (recover a corrupted store)\",\n default: false,\n },\n ...configArg,\n ...cwdArg,\n },\n async run({ args }) {\n const cwd = resolveCwd(args);\n const isDisabled = await isCodegenDisabled(cwd, undefined, args.config);\n checkForce(isDisabled, args.force);\n\n if (isDisabled) {\n await runCodegen({ cwd, configFile: args.config });\n info(\"codegen: disabled for this project; reusing an installed binding store\");\n\n return;\n }\n\n if (!args.force) {\n const isRan = await ensureGenerated(cwd, { configFile: args.config });\n info(isRan ? \"codegen: regenerated stale bindings\" : \"codegen: bindings up to date\");\n\n return;\n }\n\n const startedAt = Date.now();\n const result = await runCodegen({ cwd, configFile: args.config, isForced: true });\n const lines = formatCodegenResult(result, Date.now() - startedAt);\n\n for (const line of lines) {\n info(line);\n }\n },\n});\n\nconst checkForce = (isDisabled: boolean, isForced: boolean): void => {\n if (isDisabled && isForced) {\n throw new Error(FORCED_WHILE_DISABLED_MESSAGE);\n }\n};\n\nexport { codegen };\n"]}
@@ -15,6 +15,7 @@ declare const deploy: import("citty").CommandDef<{
15
15
  readonly type: "boolean";
16
16
  readonly description: "Package what is already in dist/ instead of rebuilding";
17
17
  };
18
+ readonly config: import("citty").StringArgDef;
18
19
  readonly entry: import("citty").PositionalArgDef;
19
20
  readonly cwd: import("citty").StringArgDef;
20
21
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"AAQA,QAAA,MAAM,MAAM;;;;;;;;;;;;;;;;;;;EAoCV,CAAC;AAEH,OAAO,EAAE,MAAM,EAAE,CAAC"}
1
+ {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"AAQA,QAAA,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;EAsCV,CAAC;AAEH,OAAO,EAAE,MAAM,EAAE,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { defineCommand } from "citty";
2
2
  import { KNOWN_NAMES } from "../deploy/registry.js";
3
3
  import { runDeploy } from "../deploy/run-deploy.js";
4
- import { entryArg } from "../internal/entry-arg.js";
4
+ import { configArg, entryArg } from "../internal/entry-arg.js";
5
5
  import { resolveProject } from "../internal/prepare-project.js";
6
6
  const DEPLOY_MODE = "production";
7
7
  const deploy = defineCommand({
@@ -11,6 +11,7 @@ const deploy = defineCommand({
11
11
  },
12
12
  args: {
13
13
  ...entryArg,
14
+ ...configArg,
14
15
  target: {
15
16
  type: "string",
16
17
  description: `Comma-separated package formats to build (${KNOWN_NAMES})`,
@@ -29,10 +30,11 @@ const deploy = defineCommand({
29
30
  },
30
31
  },
31
32
  async run({ args }) {
32
- const { cwd, entry } = await resolveProject(args, DEPLOY_MODE);
33
+ const { cwd, entry, configFile } = await resolveProject(args, DEPLOY_MODE);
33
34
  await runDeploy({
34
35
  entry,
35
36
  cwd,
37
+ configFile,
36
38
  targets: args.target,
37
39
  outDir: args.out,
38
40
  shouldPrintManifests: args["print-manifests"] === true,
@@ -1 +1 @@
1
- {"version":3,"file":"deploy.js","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAEhE,MAAM,WAAW,GAAG,YAAY,CAAC;AAEjC,MAAM,MAAM,GAAG,aAAa,CAAC;IACzB,IAAI,EAAE;QACF,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,0CAA0C;KAC1D;IACD,IAAI,EAAE;QACF,GAAG,QAAQ;QACX,MAAM,EAAE;YACJ,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,6CAA6C,WAAW,GAAG;SAC3E;QACD,GAAG,EAAE;YACD,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,gEAAgE;SAChF;QACD,iBAAiB,EAAE;YACf,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,yEAAyE;SACzF;QACD,YAAY,EAAE;YACV,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,wDAAwD;SACxE;KACJ;IACD,KAAK,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE;QACd,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,MAAM,cAAc,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QAE/D,MAAM,SAAS,CAAC;YACZ,KAAK;YACL,GAAG;YACH,OAAO,EAAE,IAAI,CAAC,MAAM;YACpB,MAAM,EAAE,IAAI,CAAC,GAAG;YAChB,oBAAoB,EAAE,IAAI,CAAC,iBAAiB,CAAC,KAAK,IAAI;YACtD,eAAe,EAAE,IAAI,CAAC,YAAY,CAAC,KAAK,IAAI;SAC/C,CAAC,CAAC;IACP,CAAC;CACJ,CAAC,CAAC;AAEH,OAAO,EAAE,MAAM,EAAE,CAAC","sourcesContent":["import { defineCommand } from \"citty\";\nimport { KNOWN_NAMES } from \"../deploy/registry.js\";\nimport { runDeploy } from \"../deploy/run-deploy.js\";\nimport { entryArg } from \"../internal/entry-arg.js\";\nimport { resolveProject } from \"../internal/prepare-project.js\";\n\nconst DEPLOY_MODE = \"production\";\n\nconst deploy = defineCommand({\n meta: {\n name: \"deploy\",\n description: \"Package the application for distribution\",\n },\n args: {\n ...entryArg,\n target: {\n type: \"string\",\n description: `Comma-separated package formats to build (${KNOWN_NAMES})`,\n },\n out: {\n type: \"string\",\n description: \"Output directory relative to the project root (default: build)\",\n },\n \"print-manifests\": {\n type: \"boolean\",\n description: \"Write the generated manifests and metadata, then stop without packaging\",\n },\n \"skip-build\": {\n type: \"boolean\",\n description: \"Package what is already in dist/ instead of rebuilding\",\n },\n },\n async run({ args }) {\n const { cwd, entry } = await resolveProject(args, DEPLOY_MODE);\n\n await runDeploy({\n entry,\n cwd,\n targets: args.target,\n outDir: args.out,\n shouldPrintManifests: args[\"print-manifests\"] === true,\n shouldSkipBuild: args[\"skip-build\"] === true,\n });\n },\n});\n\nexport { deploy };\n"]}
1
+ {"version":3,"file":"deploy.js","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAEhE,MAAM,WAAW,GAAG,YAAY,CAAC;AAEjC,MAAM,MAAM,GAAG,aAAa,CAAC;IACzB,IAAI,EAAE;QACF,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,0CAA0C;KAC1D;IACD,IAAI,EAAE;QACF,GAAG,QAAQ;QACX,GAAG,SAAS;QACZ,MAAM,EAAE;YACJ,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,6CAA6C,WAAW,GAAG;SAC3E;QACD,GAAG,EAAE;YACD,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,gEAAgE;SAChF;QACD,iBAAiB,EAAE;YACf,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,yEAAyE;SACzF;QACD,YAAY,EAAE;YACV,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,wDAAwD;SACxE;KACJ;IACD,KAAK,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE;QACd,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,MAAM,cAAc,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QAE3E,MAAM,SAAS,CAAC;YACZ,KAAK;YACL,GAAG;YACH,UAAU;YACV,OAAO,EAAE,IAAI,CAAC,MAAM;YACpB,MAAM,EAAE,IAAI,CAAC,GAAG;YAChB,oBAAoB,EAAE,IAAI,CAAC,iBAAiB,CAAC,KAAK,IAAI;YACtD,eAAe,EAAE,IAAI,CAAC,YAAY,CAAC,KAAK,IAAI;SAC/C,CAAC,CAAC;IACP,CAAC;CACJ,CAAC,CAAC;AAEH,OAAO,EAAE,MAAM,EAAE,CAAC","sourcesContent":["import { defineCommand } from \"citty\";\nimport { KNOWN_NAMES } from \"../deploy/registry.js\";\nimport { runDeploy } from \"../deploy/run-deploy.js\";\nimport { configArg, entryArg } from \"../internal/entry-arg.js\";\nimport { resolveProject } from \"../internal/prepare-project.js\";\n\nconst DEPLOY_MODE = \"production\";\n\nconst deploy = defineCommand({\n meta: {\n name: \"deploy\",\n description: \"Package the application for distribution\",\n },\n args: {\n ...entryArg,\n ...configArg,\n target: {\n type: \"string\",\n description: `Comma-separated package formats to build (${KNOWN_NAMES})`,\n },\n out: {\n type: \"string\",\n description: \"Output directory relative to the project root (default: build)\",\n },\n \"print-manifests\": {\n type: \"boolean\",\n description: \"Write the generated manifests and metadata, then stop without packaging\",\n },\n \"skip-build\": {\n type: \"boolean\",\n description: \"Package what is already in dist/ instead of rebuilding\",\n },\n },\n async run({ args }) {\n const { cwd, entry, configFile } = await resolveProject(args, DEPLOY_MODE);\n\n await runDeploy({\n entry,\n cwd,\n configFile,\n targets: args.target,\n outDir: args.out,\n shouldPrintManifests: args[\"print-manifests\"] === true,\n shouldSkipBuild: args[\"skip-build\"] === true,\n });\n },\n});\n\nexport { deploy };\n"]}
@@ -1,4 +1,12 @@
1
1
  declare const dev: import("citty").CommandDef<{
2
+ readonly headless: {
3
+ readonly type: "boolean";
4
+ readonly description: "Run on an isolated headless Wayland display";
5
+ };
6
+ readonly size: {
7
+ readonly type: "string";
8
+ readonly description: "Headless display size as WIDTHxHEIGHT";
9
+ };
2
10
  readonly entry: import("citty").PositionalArgDef;
3
11
  readonly cwd: import("citty").StringArgDef;
4
12
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AASA,QAAA,MAAM,GAAG;;;EAcP,CAAC;AAEH,OAAO,EAAE,GAAG,EAAE,CAAC"}
1
+ {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AAUA,QAAA,MAAM,GAAG;;;;;;;;;;;EAgCP,CAAC;AAEH,OAAO,EAAE,GAAG,EAAE,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { defineCommand } from "citty";
2
2
  import { resolveConfigWatch } from "../codegen/run-codegen.js";
3
+ import { startHeadlessDevDisplay } from "../dev/headless.js";
3
4
  import { runDevSupervisor } from "../dev/supervisor.js";
4
5
  import { splitApplicationArgs } from "../internal/application-args.js";
5
6
  import { entryArg } from "../internal/entry-arg.js";
@@ -12,12 +13,29 @@ const dev = defineCommand({
12
13
  },
13
14
  args: {
14
15
  ...entryArg,
16
+ headless: {
17
+ type: "boolean",
18
+ description: "Run on an isolated headless Wayland display",
19
+ },
20
+ size: {
21
+ type: "string",
22
+ description: "Headless display size as WIDTHxHEIGHT",
23
+ },
15
24
  },
16
25
  async run({ args }) {
26
+ if (args.size !== undefined && !args.headless) {
27
+ throw new Error("--size requires --headless");
28
+ }
17
29
  const { cwd, entry: entryPath } = await prepareProject(args, DEV_MODE);
18
30
  const watch = await resolveConfigWatch(cwd, DEV_MODE);
19
31
  const { applicationArgs } = splitApplicationArgs(process.argv.slice(2));
20
- await runDevSupervisor({ entryPath, cwd, args: applicationArgs, watch });
32
+ const stopHeadless = args.headless ? await startHeadlessDevDisplay(args.size) : undefined;
33
+ try {
34
+ await runDevSupervisor({ entryPath, cwd, args: applicationArgs, watch });
35
+ }
36
+ finally {
37
+ stopHeadless?.();
38
+ }
21
39
  },
22
40
  });
23
41
  export { dev };
@@ -1 +1 @@
1
- {"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAiB,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAEhE,MAAM,QAAQ,GAAG,aAAa,CAAC;AAE/B,MAAM,GAAG,GAAG,aAAa,CAAC;IACtB,IAAI,EAAE;QACF,IAAI,EAAE,KAAK;QACX,WAAW,EAAE,mCAAmC;KACnD;IACD,IAAI,EAAE;QACF,GAAG,QAAQ;KACd;IACD,KAAK,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE;QACd,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,MAAM,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QACvE,MAAM,KAAK,GAAyB,MAAM,kBAAkB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QAC5E,MAAM,EAAE,eAAe,EAAE,GAAG,oBAAoB,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACxE,MAAM,gBAAgB,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC,CAAC;IAC7E,CAAC;CACJ,CAAC,CAAC;AAEH,OAAO,EAAE,GAAG,EAAE,CAAC","sourcesContent":["import { defineCommand } from \"citty\";\nimport { resolveConfigWatch } from \"../codegen/run-codegen.js\";\nimport { type DevWatch, runDevSupervisor } from \"../dev/supervisor.js\";\nimport { splitApplicationArgs } from \"../internal/application-args.js\";\nimport { entryArg } from \"../internal/entry-arg.js\";\nimport { prepareProject } from \"../internal/prepare-project.js\";\n\nconst DEV_MODE = \"development\";\n\nconst dev = defineCommand({\n meta: {\n name: \"dev\",\n description: \"Start development server with HMR\",\n },\n args: {\n ...entryArg,\n },\n async run({ args }) {\n const { cwd, entry: entryPath } = await prepareProject(args, DEV_MODE);\n const watch: DevWatch | undefined = await resolveConfigWatch(cwd, DEV_MODE);\n const { applicationArgs } = splitApplicationArgs(process.argv.slice(2));\n await runDevSupervisor({ entryPath, cwd, args: applicationArgs, watch });\n },\n});\n\nexport { dev };\n"]}
1
+ {"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAiB,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAEhE,MAAM,QAAQ,GAAG,aAAa,CAAC;AAE/B,MAAM,GAAG,GAAG,aAAa,CAAC;IACtB,IAAI,EAAE;QACF,IAAI,EAAE,KAAK;QACX,WAAW,EAAE,mCAAmC;KACnD;IACD,IAAI,EAAE;QACF,GAAG,QAAQ;QACX,QAAQ,EAAE;YACN,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,6CAA6C;SAC7D;QACD,IAAI,EAAE;YACF,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,uCAAuC;SACvD;KACJ;IACD,KAAK,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE;QACd,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC5C,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAClD,CAAC;QAED,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,MAAM,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QACvE,MAAM,KAAK,GAAyB,MAAM,kBAAkB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QAC5E,MAAM,EAAE,eAAe,EAAE,GAAG,oBAAoB,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACxE,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAE1F,IAAI,CAAC;YACD,MAAM,gBAAgB,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,CAAC,CAAC;QAC7E,CAAC;gBAAS,CAAC;YACP,YAAY,EAAE,EAAE,CAAC;QACrB,CAAC;IACL,CAAC;CACJ,CAAC,CAAC;AAEH,OAAO,EAAE,GAAG,EAAE,CAAC","sourcesContent":["import { defineCommand } from \"citty\";\nimport { resolveConfigWatch } from \"../codegen/run-codegen.js\";\nimport { startHeadlessDevDisplay } from \"../dev/headless.js\";\nimport { type DevWatch, runDevSupervisor } from \"../dev/supervisor.js\";\nimport { splitApplicationArgs } from \"../internal/application-args.js\";\nimport { entryArg } from \"../internal/entry-arg.js\";\nimport { prepareProject } from \"../internal/prepare-project.js\";\n\nconst DEV_MODE = \"development\";\n\nconst dev = defineCommand({\n meta: {\n name: \"dev\",\n description: \"Start development server with HMR\",\n },\n args: {\n ...entryArg,\n headless: {\n type: \"boolean\",\n description: \"Run on an isolated headless Wayland display\",\n },\n size: {\n type: \"string\",\n description: \"Headless display size as WIDTHxHEIGHT\",\n },\n },\n async run({ args }) {\n if (args.size !== undefined && !args.headless) {\n throw new Error(\"--size requires --headless\");\n }\n\n const { cwd, entry: entryPath } = await prepareProject(args, DEV_MODE);\n const watch: DevWatch | undefined = await resolveConfigWatch(cwd, DEV_MODE);\n const { applicationArgs } = splitApplicationArgs(process.argv.slice(2));\n const stopHeadless = args.headless ? await startHeadlessDevDisplay(args.size) : undefined;\n\n try {\n await runDevSupervisor({ entryPath, cwd, args: applicationArgs, watch });\n } finally {\n stopHeadless?.();\n }\n },\n});\n\nexport { dev };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../src/commands/docs.ts"],"names":[],"mappings":"AAUA,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;EAmFR,CAAC;AAiCH,OAAO,EAAE,IAAI,EAAE,CAAC"}
1
+ {"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../src/commands/docs.ts"],"names":[],"mappings":"AAUA,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;EA6ER,CAAC;AA2BH,OAAO,EAAE,IAAI,EAAE,CAAC"}
@@ -1,10 +1,10 @@
1
1
  import { mergeOmittedProps, resolveGirPath, resolveLibraries } from "@gtkx/codegen";
2
2
  import { writeDocs } from "@gtkx/codegen/internal";
3
3
  import { loadConfig } from "@gtkx/config";
4
- import { resolveFuture, resolveOmittedProps } from "@gtkx/config/internal";
5
- import { info } from "@gtkx/utils";
4
+ import { resolveOmittedProps } from "@gtkx/config/internal";
5
+ import { info, isPathInside } from "@gtkx/utils";
6
6
  import { defineCommand } from "citty";
7
- import { isAbsolute, relative, resolve, sep } from "node:path";
7
+ import { resolve } from "node:path";
8
8
  import { resolveDocsElements } from "../internal/docs-elements.js";
9
9
  import { cwdArg, resolveCwd } from "../internal/entry-arg.js";
10
10
  const docs = defineCommand({
@@ -45,8 +45,7 @@ const docs = defineCommand({
45
45
  "(Linux: `sudo dnf install gobject-introspection-devel` or " +
46
46
  "`sudo apt install libgirepository1.0-dev`), or set `girPath` in gtkx.config.ts.");
47
47
  }
48
- const future = resolveFuture(config.future);
49
- const libraries = resolveLibraries(config.libraries, girPath, future.isAdwaitaDefault);
48
+ const libraries = resolveLibraries(config.libraries);
50
49
  const startedAt = Date.now();
51
50
  const outDir = resolveOutDir(cwd, args.out);
52
51
  const builtin = await resolveDocsElements(cwd);
@@ -58,11 +57,6 @@ const docs = defineCommand({
58
57
  props: builtin.props,
59
58
  omittedProps: mergeOmittedProps(builtin.omittedProps, resolveOmittedProps(config.elements)),
60
59
  isForced: args.force,
61
- isByteArrayTyped: future.isByteArrayTyped,
62
- isValueUnwrapped: future.isValueUnwrapped,
63
- isFinishTrimmed: future.isFinishTrimmed,
64
- isInoutInPlace: future.isInoutInPlace,
65
- isTreeShaken: future.isTreeShaken,
66
60
  });
67
61
  if (!isRegenerated) {
68
62
  info(`docs: pages in ${outDir} are up to date`);
@@ -73,10 +67,6 @@ const docs = defineCommand({
73
67
  `to ${outDir} in ${String(Date.now() - startedAt)}ms`);
74
68
  },
75
69
  });
76
- const isBelow = (parent, child) => {
77
- const path = relative(parent, child);
78
- return path !== "" && path !== ".." && !path.startsWith(`..${sep}`) && !isAbsolute(path);
79
- };
80
70
  const outDirReason = (cwd, out, outDir) => {
81
71
  if (out.trim() === "") {
82
72
  return "it was empty, which names the project root itself";
@@ -88,7 +78,7 @@ const outDirReason = (cwd, out, outDir) => {
88
78
  };
89
79
  const resolveOutDir = (cwd, out) => {
90
80
  const outDir = out.trim() === "" ? cwd : resolve(cwd, out);
91
- if (isBelow(cwd, outDir)) {
81
+ if (isPathInside(cwd, outDir)) {
92
82
  return outDir;
93
83
  }
94
84
  throw new Error(`--out must name a directory below the project root ${cwd}, and ${outDirReason(cwd, out, outDir)}. ` +
@@ -1 +1 @@
1
- {"version":3,"file":"docs.js","sourceRoot":"","sources":["../../src/commands/docs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACpF,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE9D,MAAM,IAAI,GAAG,aAAa,CAAC;IACvB,IAAI,EAAE;QACF,IAAI,EAAE,MAAM;QACZ,WAAW,EACP,wGAAwG;KAC/G;IACD,IAAI,EAAE;QACF,GAAG,EAAE;YACD,IAAI,EAAE,QAAQ;YACd,WAAW,EACP,8FAA8F;gBAC9F,8DAA8D;YAClE,OAAO,EAAE,gBAAgB;SAC5B;QACD,WAAW,EAAE;YACT,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,sDAAsD;YACnE,OAAO,EAAE,YAAY;SACxB;QACD,KAAK,EAAE;YACH,IAAI,EAAE,SAAS;YACf,WAAW,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C;IAED,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;QACjB,OAAO,kCAAkC,CAAC;IAC9C,CAAC;IAED,OAAO,GAAG,MAAM,gBAAgB,CAAC;AACrC,CAAC,CAAC;AAEF,MAAM,aAAa,GAAG,CAAC,GAAW,EAAE,GAAW,EAAU,EAAE;IACvD,MAAM,MAAM,GAAG,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAE3D,IAAI,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,CAAC;QACvB,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,MAAM,IAAI,KAAK,CACX,sDAAsD,GAAG,SAAS,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,IAAI;QACpG,2CAA2C,CAC9C,CAAC;AACN,CAAC,CAAC;AAEF,OAAO,EAAE,IAAI,EAAE,CAAC","sourcesContent":["import { mergeOmittedProps, resolveGirPath, resolveLibraries } from \"@gtkx/codegen\";\nimport { writeDocs } from \"@gtkx/codegen/internal\";\nimport { loadConfig } from \"@gtkx/config\";\nimport { resolveFuture, resolveOmittedProps } from \"@gtkx/config/internal\";\nimport { info } from \"@gtkx/utils\";\nimport { defineCommand } from \"citty\";\nimport { isAbsolute, relative, resolve, sep } from \"node:path\";\nimport { resolveDocsElements } from \"../internal/docs-elements.js\";\nimport { cwdArg, resolveCwd } from \"../internal/entry-arg.js\";\n\nconst docs = defineCommand({\n meta: {\n name: \"docs\",\n description:\n \"Generate markdown reference pages for the JSX elements of the GIR libraries declared in gtkx.config.ts\",\n },\n args: {\n out: {\n type: \"string\",\n description:\n \"Output directory for the generated markdown pages, below the project root. It must be empty \" +\n \"or hold an earlier `gtkx docs` run, whose pages are replaced\",\n default: \"docs/reference\",\n },\n \"base-path\": {\n type: \"string\",\n description: \"URL base path used for links between generated pages\",\n default: \"/reference\",\n },\n force: {\n type: \"boolean\",\n description:\n \"Regenerate even when the pages are up to date with the GIR libraries, the base path, \" +\n \"and the element props the project configures\",\n default: false,\n },\n ...cwdArg,\n },\n async run({ args }) {\n const cwd = resolveCwd(args);\n const { config } = await loadConfig(cwd);\n\n if (config.codegen === false) {\n throw new Error(\n \"codegen is disabled for this project, so there are no GIR libraries to document. \" +\n \"Remove `codegen: false` from gtkx.config.ts to use `gtkx docs`.\",\n );\n }\n\n const girPath = resolveGirPath(config.girPath);\n\n if (girPath.length === 0) {\n throw new Error(\n \"No GIR search paths available. Install gobject-introspection \" +\n \"(Linux: `sudo dnf install gobject-introspection-devel` or \" +\n \"`sudo apt install libgirepository1.0-dev`), or set `girPath` in gtkx.config.ts.\",\n );\n }\n\n const future = resolveFuture(config.future);\n const libraries = resolveLibraries(config.libraries, girPath, future.isAdwaitaDefault);\n const startedAt = Date.now();\n const outDir = resolveOutDir(cwd, args.out);\n const builtin = await resolveDocsElements(cwd);\n\n const { isRegenerated, namespaces } = writeDocs({\n libraries,\n girPath,\n outDir,\n basePath: args[\"base-path\"],\n props: builtin.props,\n omittedProps: mergeOmittedProps(builtin.omittedProps, resolveOmittedProps(config.elements)),\n isForced: args.force,\n isByteArrayTyped: future.isByteArrayTyped,\n isValueUnwrapped: future.isValueUnwrapped,\n isFinishTrimmed: future.isFinishTrimmed,\n isInoutInPlace: future.isInoutInPlace,\n isTreeShaken: future.isTreeShaken,\n });\n\n if (!isRegenerated) {\n info(`docs: pages in ${outDir} are up to date`);\n\n return;\n }\n\n const count = namespaces.reduce((total, namespace) => total + namespace.elements.length, 0);\n\n info(\n `docs: wrote ${String(count)} element pages across ${String(namespaces.length)} namespaces ` +\n `to ${outDir} in ${String(Date.now() - startedAt)}ms`,\n );\n },\n});\n\nconst isBelow = (parent: string, child: string): boolean => {\n const path = relative(parent, child);\n\n return path !== \"\" && path !== \"..\" && !path.startsWith(`..${sep}`) && !isAbsolute(path);\n};\n\nconst outDirReason = (cwd: string, out: string, outDir: string): string => {\n if (out.trim() === \"\") {\n return \"it was empty, which names the project root itself\";\n }\n\n if (outDir === cwd) {\n return \"it names the project root itself\";\n }\n\n return `${outDir} is outside it`;\n};\n\nconst resolveOutDir = (cwd: string, out: string): string => {\n const outDir = out.trim() === \"\" ? cwd : resolve(cwd, out);\n\n if (isBelow(cwd, outDir)) {\n return outDir;\n }\n\n throw new Error(\n `--out must name a directory below the project root ${cwd}, and ${outDirReason(cwd, out, outDir)}. ` +\n \"Pass a path such as --out=docs/reference.\",\n );\n};\n\nexport { docs };\n"]}
1
+ {"version":3,"file":"docs.js","sourceRoot":"","sources":["../../src/commands/docs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACpF,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE9D,MAAM,IAAI,GAAG,aAAa,CAAC;IACvB,IAAI,EAAE;QACF,IAAI,EAAE,MAAM;QACZ,WAAW,EACP,wGAAwG;KAC/G;IACD,IAAI,EAAE;QACF,GAAG,EAAE;YACD,IAAI,EAAE,QAAQ;YACd,WAAW,EACP,8FAA8F;gBAC9F,8DAA8D;YAClE,OAAO,EAAE,gBAAgB;SAC5B;QACD,WAAW,EAAE;YACT,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,sDAAsD;YACnE,OA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AAM,CAAC,IAAI;QACpG,2CAA2C,CAC9C,CAAC;AACN,CAAC,CAAC;AAEF,OAAO,EAAE,IAAI,EAAE,CAAC","sourcesContent":["import { mergeOmittedProps, resolveGirPath, resolveLibraries } from \"@gtkx/codegen\";\nimport { writeDocs } from \"@gtkx/codegen/internal\";\nimport { loadConfig } from \"@gtkx/config\";\nimport { resolveOmittedProps } from \"@gtkx/config/internal\";\nimport { info, isPathInside } from \"@gtkx/utils\";\nimport { defineCommand } from \"citty\";\nimport { resolve } from \"node:path\";\nimport { resolveDocsElements } from \"../internal/docs-elements.js\";\nimport { cwdArg, resolveCwd } from \"../internal/entry-arg.js\";\n\nconst docs = defineCommand({\n meta: {\n name: \"docs\",\n description:\n \"Generate markdown reference pages for the JSX elements of the GIR libraries declared in gtkx.config.ts\",\n },\n args: {\n out: {\n type: \"string\",\n description:\n \"Output directory for the generated markdown pages, below the project root. It must be empty \" +\n \"or hold an earlier `gtkx docs` run, whose pages are replaced\",\n default: \"docs/reference\",\n },\n \"base-path\": {\n type: \"string\",\n description: \"URL base path used for links between generated pages\",\n default: \"/reference\",\n },\n force: {\n type: \"boolean\",\n description:\n \"Regenerate even when the pages are up to date with the GIR libraries, the base path, \" +\n \"and the element props the project configures\",\n default: false,\n },\n ...cwdArg,\n },\n async run({ args }) {\n const cwd = resolveCwd(args);\n const { config } = await loadConfig(cwd);\n\n if (config.codegen === false) {\n throw new Error(\n \"codegen is disabled for this project, so there are no GIR libraries to document. \" +\n \"Remove `codegen: false` from gtkx.config.ts to use `gtkx docs`.\",\n );\n }\n\n const girPath = resolveGirPath(config.girPath);\n\n if (girPath.length === 0) {\n throw new Error(\n \"No GIR search paths available. Install gobject-introspection \" +\n \"(Linux: `sudo dnf install gobject-introspection-devel` or \" +\n \"`sudo apt install libgirepository1.0-dev`), or set `girPath` in gtkx.config.ts.\",\n );\n }\n\n const libraries = resolveLibraries(config.libraries);\n const startedAt = Date.now();\n const outDir = resolveOutDir(cwd, args.out);\n const builtin = await resolveDocsElements(cwd);\n\n const { isRegenerated, namespaces } = writeDocs({\n libraries,\n girPath,\n outDir,\n basePath: args[\"base-path\"],\n props: builtin.props,\n omittedProps: mergeOmittedProps(builtin.omittedProps, resolveOmittedProps(config.elements)),\n isForced: args.force,\n });\n\n if (!isRegenerated) {\n info(`docs: pages in ${outDir} are up to date`);\n\n return;\n }\n\n const count = namespaces.reduce((total, namespace) => total + namespace.elements.length, 0);\n\n info(\n `docs: wrote ${String(count)} element pages across ${String(namespaces.length)} namespaces ` +\n `to ${outDir} in ${String(Date.now() - startedAt)}ms`,\n );\n },\n});\n\nconst outDirReason = (cwd: string, out: string, outDir: string): string => {\n if (out.trim() === \"\") {\n return \"it was empty, which names the project root itself\";\n }\n\n if (outDir === cwd) {\n return \"it names the project root itself\";\n }\n\n return `${outDir} is outside it`;\n};\n\nconst resolveOutDir = (cwd: string, out: string): string => {\n const outDir = out.trim() === \"\" ? cwd : resolve(cwd, out);\n\n if (isPathInside(cwd, outDir)) {\n return outDir;\n }\n\n throw new Error(\n `--out must name a directory below the project root ${cwd}, and ${outDirReason(cwd, out, outDir)}. ` +\n \"Pass a path such as --out=docs/reference.\",\n );\n};\n\nexport { docs };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"copyright.d.ts","sourceRoot":"","sources":["../../../src/deploy/freedesktop/copyright.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAU,aAAa,EAAE,MAAM,aAAa,CAAC;AA+JzE,QAAA,MAAM,eAAe,GAAI,UAAU,cAAc,EAAE,UAAU,aAAa,EAAE,KAAG,MAa9E,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,CAAC"}
1
+ {"version":3,"file":"copyright.d.ts","sourceRoot":"","sources":["../../../src/deploy/freedesktop/copyright.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAU,aAAa,EAAE,MAAM,aAAa,CAAC;AAoJzE,QAAA,MAAM,eAAe,GAAI,UAAU,cAAc,EAAE,UAAU,aAAa,EAAE,KAAG,MAa9E,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,CAAC"}
@@ -1,5 +1,5 @@
1
- import { readFileSync } from "node:fs";
2
1
  import { BUNDLE_FILENAME } from "../../vite-plugins/esm-extension.js";
2
+ import { readLicenseText } from "../notices/text.js";
3
3
  const FORMAT_URL = "https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/";
4
4
  const CONTINUATION_BLANK = " .";
5
5
  const UNKNOWN_COPYRIGHT = "unknown";
@@ -17,17 +17,6 @@ const foldedField = (name, lines) => {
17
17
  const [first, ...rest] = lines;
18
18
  return first === undefined ? [] : [`${name}: ${first}`, ...rest.map((line) => indentLine(line))];
19
19
  };
20
- const licenseText = (licenseFile) => {
21
- if (licenseFile === null) {
22
- return null;
23
- }
24
- try {
25
- return readFileSync(licenseFile, "utf8").trimEnd();
26
- }
27
- catch {
28
- return null;
29
- }
30
- };
31
20
  const shortName = (license) => license
32
21
  .replaceAll(SPDX_GROUPING, " ")
33
22
  .replaceAll(SPDX_OPERATOR, (operator) => operator.toLowerCase())
@@ -110,7 +99,7 @@ const applicationStanza = (settings, text) => [
110
99
  "",
111
100
  ];
112
101
  const renderCopyright = (settings, sections) => {
113
- const own = licenseText(settings.paths.licenseFile);
102
+ const own = settings.paths.licenseFile === null ? null : readLicenseText(settings.paths.licenseFile);
114
103
  const reproduced = new Set(own === null ? [] : [own]);
115
104
  const stanzas = filePatterns(sections).flatMap((files) => fileStanza({ settings, files, sections: sectionsFor(sections, files), reproduced }));
116
105
  return [
@@ -1 +1 @@
1
- {"version":3,"file":"copyright.js","sourceRoot":"","sources":["../../../src/deploy/freedesktop/copyright.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAStE,MAAM,UAAU,GAAG,oEAAoE,CAAC;AACxF,MAAM,kBAAkB,GAAG,IAAI,CAAC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AC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAEnE,MAAM,OAAO,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CACrD,UAAU,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC;IAEzF,OAAO;QACH,GAAG,WAAW,CAAC,QAAQ,EAAE,QAAQ,CAAC;QAClC,EAAE;QACF,GAAG,iBAAiB,CAAC,QAAQ,EAAE,GAAG,CAAC;QACnC,GAAG,OAAO;KACb,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjB,CAAC,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,CAAC","sourcesContent":["import { readFileSync } from \"node:fs\";\nimport type { DeploySettings, Notice, NoticeSection } from \"../types.js\";\nimport { BUNDLE_FILENAME } from \"../../vite-plugins/esm-extension.js\";\n\ntype FileStanza = {\n settings: DeploySettings;\n files: string;\n sections: NoticeSection[];\n reproduced: Set<string>;\n};\n\nconst FORMAT_URL = \"https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/\";\nconst CONTINUATION_BLANK = \" .\";\nconst UNKNOWN_COPYRIGHT = \"unknown\";\nconst UNKNOWN_LICENSE = \"unknown\";\nconst LICENSE_SEPARATOR = \" and \";\nconst SPDX_GROUPING = /[()]/g;\nconst SPDX_OPERATOR = /\\b(?:AND|OR|WITH)\\b/g;\nconst REPEATED_SPACE = / {2,}/g;\nconst OUTSIDE_NAME = /[^\\w.+-]+/g;\nconst NAME_JOINER = \"-\";\nconst NAME_TOKEN = /^[\\w.+-]+$/;\nconst NAME_CONNECTIVE = / (?:or|with) /;\n\nconst indentLine = (line: string): string => (line.trim().length === 0 ? CONTINUATION_BLANK : ` ${line}`);\n\nconst foldedField = (name: string, lines: string[]): string[] => {\n const [first, ...rest] = lines;\n\n return first === undefined ? [] : [`${name}: ${first}`, ...rest.map((line) => indentLine(line))];\n};\n\nconst licenseText = (licenseFile: string | null): string | null => {\n if (licenseFile === null) {\n return null;\n }\n\n try {\n return readFileSync(licenseFile, \"utf8\").trimEnd();\n } catch {\n return null;\n }\n};\n\nconst shortName = (license: string): string =>\n license\n .replaceAll(SPDX_GROUPING, \" \")\n .replaceAll(SPDX_OPERATOR, (operator) => operator.toLowerCase())\n .replaceAll(REPEATED_SPACE, \" \")\n .trim();\n\nconst isShortName = (part: string): boolean =>\n part.split(NAME_CONNECTIVE).every((token) => NAME_TOKEN.test(token));\n\nconst namePart = (part: string): string =>\n isShortName(part) ? part : part.split(OUTSIDE_NAME).filter((token) => token.length > 0).join(NAME_JOINER);\n\nconst shortNames = (license: string): string[] =>\n shortName(license).split(LICENSE_SEPARATOR).map((part) => namePart(part)).filter((part) => part.length > 0);\n\nconst licenseNames = (notices: Notice[]): string => {\n const names = [...new Set(notices.flatMap((notice) => shortNames(notice.license)))];\n\n return names.length === 0 ? UNKNOWN_LICENSE : names.join(LICENSE_SEPARATOR);\n};\n\nconst compactNotice = (notice: Notice): string => {\n const label = `${notice.subject} (${licenseNames([notice])})`;\n\n return notice.source === null ? label : `${label}: ${notice.source}`;\n};\n\nconst noticeBody = (notice: Notice, reproduced: Set<string>): string[] => {\n const head = [\n \"\",\n `${notice.subject} (${licenseNames([notice])})`,\n ...(notice.source === null ? [] : [`Source: ${notice.source}`]),\n ];\n\n if (notice.text === null || reproduced.has(notice.text)) {\n return head;\n }\n\n reproduced.add(notice.text);\n\n return [...head, \"\", ...notice.text.split(\"\\n\")];\n};\n\nconst copyrightNames = (notices: Notice[]): string[] => {\n const lines = [...new Set(notices.flatMap((notice) => notice.copyright))];\n\n return lines.length === 0 ? [UNKNOWN_COPYRIGHT] : lines;\n};\n\nconst stanzaComment = (sections: NoticeSection[]): string[] =>\n sections.flatMap((section, index) => [...(index === 0 ? [] : [\"\"]), section.title, ...section.summary]);\n\nconst sectionComment = (section: NoticeSection): string[] => [\n section.title,\n \"\",\n ...section.summary,\n \"\",\n ...section.notices.map((notice) => compactNotice(notice)),\n];\n\nconst bundlePath = (settings: DeploySettings): string => `lib/${settings.binaryName}/${BUNDLE_FILENAME}`;\n\nconst applicationNotice = (settings: DeploySettings): Notice => ({\n subject: settings.name,\n license: settings.license,\n source: settings.homepage,\n copyright: [settings.copyright],\n text: null,\n});\n\nconst stanzaNotices = (settings: DeploySettings, files: string, sections: NoticeSection[]): Notice[] => {\n const own = files === bundlePath(settings) ? [applicationNotice(settings)] : [];\n\n return [...own, ...sections.flatMap((section) => section.notices)];\n};\n\nconst fileStanza = ({ settings, files, sections, reproduced }: FileStanza): string[] => {\n const notices = stanzaNotices(settings, files, sections);\n const texts = notices.flatMap((notice) => noticeBody(notice, reproduced));\n\n return [\n `Files: ${files}`,\n ...foldedField(\"Comment\", stanzaComment(sections)),\n ...foldedField(\"Copyright\", copyrightNames(notices)),\n ...foldedField(\"License\", [licenseNames(notices), ...texts]),\n \"\",\n ];\n};\n\nconst filePatterns = (sections: NoticeSection[]): string[] =>\n [...new Set(sections.flatMap((section) => section.files))];\n\nconst sectionsFor = (sections: NoticeSection[], files: string): NoticeSection[] =>\n sections.filter((section) => section.files.includes(files));\n\nconst headerComment = (sections: NoticeSection[]): string[] =>\n sections.filter((section) => section.files.length === 0).flatMap((section) => sectionComment(section));\n\nconst headerLines = (settings: DeploySettings, sections: NoticeSection[]): string[] => [\n `Format: ${FORMAT_URL}`,\n `Upstream-Name: ${settings.name}`,\n ...(settings.homepage === null ? [] : [`Source: ${settings.homepage}`]),\n ...foldedField(\"Comment\", headerComment(sections)),\n];\n\nconst applicationStanza = (settings: DeploySettings, text: string | null): string[] => [\n \"Files: *\",\n `Copyright: ${settings.copyright}`,\n ...foldedField(\"License\", [\n licenseNames([applicationNotice(settings)]),\n ...(text === null ? [] : text.split(\"\\n\")),\n ]),\n \"\",\n];\n\nconst renderCopyright = (settings: DeploySettings, sections: NoticeSection[]): string => {\n const own = licenseText(settings.paths.licenseFile);\n const reproduced: Set<string> = new Set(own === null ? [] : [own]);\n\n const stanzas = filePatterns(sections).flatMap((files) =>\n fileStanza({ settings, files, sections: sectionsFor(sections, files), reproduced }));\n\n return [\n ...headerLines(settings, sections),\n \"\",\n ...applicationStanza(settings, own),\n ...stanzas,\n ].join(\"\\n\");\n};\n\nexport { renderCopyright };\n"]}
1
+ {"version":3,"file":"copyright.js","sourceRoot":"","sources":["../../../src/deploy/freedesktop/copyright.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AASrD,MAAM,UAAU,GAAG,oEAAoE,CAAC;AACxF,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAChC,MAAM,iBAAiB,GAAG,SAAS,CAAC;AACpC,MAAM,eAAe,GAAG,SAAS,CAAC;AAClC,MAAM,iBAAiB,GAAG,OAAO,CAAC;AAClC,MAAM,aAAa,GAAG,OAAO,CAAC;AAC9B,MAAM,aAAa,GAAG,sBAAsB,CAAC;AAC7C,MAAM,cAAc,GAAG,QAAQ,CAAC;AAChC,MAAM,YAAY,GAAG,YAAY,CAAC;AAClC,MAAM,WAAW,GAAG,GAAG,CAAC;AACxB,MAAM,UAAU,GAAG,YAAY,CAAC;AAChC,MAAM,eAAe,GAAG,eAAe,CAAC;AAExC,MAAM,UAAU,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;AAE1G,MAAM,WAAW,GAAG,CAAC,IAAY,EAAE,KAAe,EAAY,EAAE;IAC5D,MAAM,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,GAAG,KAAK,CAAC;IAE/B,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EA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wB,EAAE,QAAyB,EAAU,EAAE;IACpF,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,WAAW,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,eAAe,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IACrG,MAAM,UAAU,GAAgB,IAAI,GAAG,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAEnE,MAAM,OAAO,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CACrD,UAAU,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC;IAEzF,OAAO;QACH,GAAG,WAAW,CAAC,QAAQ,EAAE,QAAQ,CAAC;QAClC,EAAE;QACF,GAAG,iBAAiB,CAAC,QAAQ,EAAE,GAAG,CAAC;QACnC,GAAG,OAAO;KACb,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjB,CAAC,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,CAAC","sourcesContent":["import type { DeploySettings, Notice, NoticeSection } from \"../types.js\";\nimport { BUNDLE_FILENAME } from \"../../vite-plugins/esm-extension.js\";\nimport { readLicenseText } from \"../notices/text.js\";\n\ntype FileStanza = {\n settings: DeploySettings;\n files: string;\n sections: NoticeSection[];\n reproduced: Set<string>;\n};\n\nconst FORMAT_URL = \"https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/\";\nconst CONTINUATION_BLANK = \" .\";\nconst UNKNOWN_COPYRIGHT = \"unknown\";\nconst UNKNOWN_LICENSE = \"unknown\";\nconst LICENSE_SEPARATOR = \" and \";\nconst SPDX_GROUPING = /[()]/g;\nconst SPDX_OPERATOR = /\\b(?:AND|OR|WITH)\\b/g;\nconst REPEATED_SPACE = / {2,}/g;\nconst OUTSIDE_NAME = /[^\\w.+-]+/g;\nconst NAME_JOINER = \"-\";\nconst NAME_TOKEN = /^[\\w.+-]+$/;\nconst NAME_CONNECTIVE = / (?:or|with) /;\n\nconst indentLine = (line: string): string => (line.trim().length === 0 ? CONTINUATION_BLANK : ` ${line}`);\n\nconst foldedField = (name: string, lines: string[]): string[] => {\n const [first, ...rest] = lines;\n\n return first === undefined ? [] : [`${name}: ${first}`, ...rest.map((line) => indentLine(line))];\n};\n\nconst shortName = (license: string): string =>\n license\n .replaceAll(SPDX_GROUPING, \" \")\n .replaceAll(SPDX_OPERATOR, (operator) => operator.toLowerCase())\n .replaceAll(REPEATED_SPACE, \" \")\n .trim();\n\nconst isShortName = (part: string): boolean =>\n part.split(NAME_CONNECTIVE).every((token) => NAME_TOKEN.test(token));\n\nconst namePart = (part: string): string =>\n isShortName(part) ? part : part.split(OUTSIDE_NAME).filter((token) => token.length > 0).join(NAME_JOINER);\n\nconst shortNames = (license: string): string[] =>\n shortName(license).split(LICENSE_SEPARATOR).map((part) => namePart(part)).filter((part) => part.length > 0);\n\nconst licenseNames = (notices: Notice[]): string => {\n const names = [...new Set(notices.flatMap((notice) => shortNames(notice.license)))];\n\n return names.length === 0 ? UNKNOWN_LICENSE : names.join(LICENSE_SEPARATOR);\n};\n\nconst compactNotice = (notice: Notice): string => {\n const label = `${notice.subject} (${licenseNames([notice])})`;\n\n return notice.source === null ? label : `${label}: ${notice.source}`;\n};\n\nconst noticeBody = (notice: Notice, reproduced: Set<string>): string[] => {\n const head = [\n \"\",\n `${notice.subject} (${licenseNames([notice])})`,\n ...(notice.source === null ? [] : [`Source: ${notice.source}`]),\n ];\n\n if (notice.text === null || reproduced.has(notice.text)) {\n return head;\n }\n\n reproduced.add(notice.text);\n\n return [...head, \"\", ...notice.text.split(\"\\n\")];\n};\n\nconst copyrightNames = (notices: Notice[]): string[] => {\n const lines = [...new Set(notices.flatMap((notice) => notice.copyright))];\n\n return lines.length === 0 ? [UNKNOWN_COPYRIGHT] : lines;\n};\n\nconst stanzaComment = (sections: NoticeSection[]): string[] =>\n sections.flatMap((section, index) => [...(index === 0 ? [] : [\"\"]), section.title, ...section.summary]);\n\nconst sectionComment = (section: NoticeSection): string[] => [\n section.title,\n \"\",\n ...section.summary,\n \"\",\n ...section.notices.map((notice) => compactNotice(notice)),\n];\n\nconst bundlePath = (settings: DeploySettings): string => `lib/${settings.binaryName}/${BUNDLE_FILENAME}`;\n\nconst applicationNotice = (settings: DeploySettings): Notice => ({\n subject: settings.name,\n license: settings.license,\n source: settings.homepage,\n copyright: [settings.copyright],\n text: null,\n});\n\nconst stanzaNotices = (settings: DeploySettings, files: string, sections: NoticeSection[]): Notice[] => {\n const own = files === bundlePath(settings) ? [applicationNotice(settings)] : [];\n\n return [...own, ...sections.flatMap((section) => section.notices)];\n};\n\nconst fileStanza = ({ settings, files, sections, reproduced }: FileStanza): string[] => {\n const notices = stanzaNotices(settings, files, sections);\n const texts = notices.flatMap((notice) => noticeBody(notice, reproduced));\n\n return [\n `Files: ${files}`,\n ...foldedField(\"Comment\", stanzaComment(sections)),\n ...foldedField(\"Copyright\", copyrightNames(notices)),\n ...foldedField(\"License\", [licenseNames(notices), ...texts]),\n \"\",\n ];\n};\n\nconst filePatterns = (sections: NoticeSection[]): string[] =>\n [...new Set(sections.flatMap((section) => section.files))];\n\nconst sectionsFor = (sections: NoticeSection[], files: string): NoticeSection[] =>\n sections.filter((section) => section.files.includes(files));\n\nconst headerComment = (sections: NoticeSection[]): string[] =>\n sections.filter((section) => section.files.length === 0).flatMap((section) => sectionComment(section));\n\nconst headerLines = (settings: DeploySettings, sections: NoticeSection[]): string[] => [\n `Format: ${FORMAT_URL}`,\n `Upstream-Name: ${settings.name}`,\n ...(settings.homepage === null ? [] : [`Source: ${settings.homepage}`]),\n ...foldedField(\"Comment\", headerComment(sections)),\n];\n\nconst applicationStanza = (settings: DeploySettings, text: string | null): string[] => [\n \"Files: *\",\n `Copyright: ${settings.copyright}`,\n ...foldedField(\"License\", [\n licenseNames([applicationNotice(settings)]),\n ...(text === null ? [] : text.split(\"\\n\")),\n ]),\n \"\",\n];\n\nconst renderCopyright = (settings: DeploySettings, sections: NoticeSection[]): string => {\n const own = settings.paths.licenseFile === null ? null : readLicenseText(settings.paths.licenseFile);\n const reproduced: Set<string> = new Set(own === null ? [] : [own]);\n\n const stanzas = filePatterns(sections).flatMap((files) =>\n fileStanza({ settings, files, sections: sectionsFor(sections, files), reproduced }));\n\n return [\n ...headerLines(settings, sections),\n \"\",\n ...applicationStanza(settings, own),\n ...stanzas,\n ].join(\"\\n\");\n};\n\nexport { renderCopyright };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"metainfo.d.ts","sourceRoot":"","sources":["../../../src/deploy/freedesktop/metainfo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAuBlD,QAAA,MAAM,cAAc,GAAI,UAAU,cAAc,KAAG,MAoB9C,CAAC;AAEN,OAAO,EAAE,cAAc,EAAE,CAAC"}
1
+ {"version":3,"file":"metainfo.d.ts","sourceRoot":"","sources":["../../../src/deploy/freedesktop/metainfo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AA2FlD,QAAA,MAAM,cAAc,GAAI,UAAU,cAAc,KAAG,MAIlD,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,CAAC"}
@@ -2,12 +2,47 @@ import { brandingSection, contentRatingSection, descriptionSection, developerSec
2
2
  import { element, renderDocument, text } from "./xml.js";
3
3
  const COMPONENT_TYPE = "desktop-application";
4
4
  const DESKTOP_SUFFIX = ".desktop";
5
+ const COMPONENT_CLOSE = "</component>\n";
6
+ const PROVIDES_CLOSE = " </provides>\n";
7
+ const PROVIDES_FRAGMENT = /^<provides\s*>([\s\S]*)<\/provides>$/;
8
+ const normalizeExtraFragment = (fragment, index) => {
9
+ const normalized = fragment.trim();
10
+ if (normalized.length === 0) {
11
+ throw new Error(`Cannot render deploy.metainfoExtra entry ${String(index + 1)}: it is empty`);
12
+ }
13
+ return normalized;
14
+ };
15
+ const indentFragment = (fragment, depth) => {
16
+ const indentation = " ".repeat(depth * 4);
17
+ return fragment.split(/\r?\n/).map((line) => `${indentation}${line}`).join("\n");
18
+ };
19
+ const appendExtraFragments = (document, fragments) => {
20
+ if (fragments.length === 0) {
21
+ return document;
22
+ }
23
+ let merged = document;
24
+ const componentFragments = [];
25
+ for (const [index, rawFragment] of fragments.entries()) {
26
+ const fragment = normalizeExtraFragment(rawFragment, index);
27
+ const provides = PROVIDES_FRAGMENT.exec(fragment)?.[1]?.trim();
28
+ if (provides === undefined) {
29
+ componentFragments.push(fragment);
30
+ continue;
31
+ }
32
+ merged = merged.replace(PROVIDES_CLOSE, () => `${indentFragment(provides, 2)}\n${PROVIDES_CLOSE}`);
33
+ }
34
+ if (componentFragments.length === 0) {
35
+ return merged;
36
+ }
37
+ const extra = componentFragments.map((fragment) => indentFragment(fragment, 1)).join("\n");
38
+ return merged.replace(COMPONENT_CLOSE, () => `${extra}\n${COMPONENT_CLOSE}`);
39
+ };
5
40
  const launchable = (applicationId) => ({
6
41
  tag: "launchable",
7
42
  attributes: { type: "desktop-id" },
8
43
  text: `${applicationId}${DESKTOP_SUFFIX}`,
9
44
  });
10
- const renderMetainfo = (settings) => renderDocument(element("component", { type: COMPONENT_TYPE }, [
45
+ const metainfoRoot = (settings) => element("component", { type: COMPONENT_TYPE }, [
11
46
  text("id", settings.applicationId),
12
47
  text("name", settings.name),
13
48
  text("summary", settings.summary),
@@ -24,6 +59,10 @@ const renderMetainfo = (settings) => renderDocument(element("component", { type:
24
59
  ...releasesSection(settings),
25
60
  ...contentRatingSection(settings),
26
61
  ...brandingSection(settings),
27
- ]));
62
+ ]);
63
+ const renderMetainfo = (settings) => {
64
+ const document = renderDocument(metainfoRoot(settings));
65
+ return appendExtraFragments(document, settings.deploy.metainfoExtra ?? []);
66
+ };
28
67
  export { renderMetainfo };
29
68
  //# sourceMappingURL=metainfo.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"metainfo.js","sourceRoot":"","sources":["../../../src/deploy/freedesktop/metainfo.ts"],"names":[],"mappings":"AACA,OAAO,EACH,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,WAAW,EACX,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,WAAW,GACd,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,IAAI,EAAgB,MAAM,UAAU,CAAC;AAEvE,MAAM,cAAc,GAAG,qBAAqB,CAAC;AAC7C,MAAM,cAAc,GAAG,UAAU,CAAC;AAElC,MAAM,UAAU,GAAG,CAAC,aAAqB,EAAW,EAAE,CAAC,CAAC;IACpD,GAAG,EAAE,YAAY;IACjB,UAAU,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE;IAClC,IAAI,EAAE,GAAG,aAAa,GAAG,cAAc,EAAE;CAC5C,CAAC,CAAC;AAEH,MAAM,cAAc,GAAG,CAAC,QAAwB,EAAU,EAAE,CACxD,cAAc,CACV,OAAO,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,EAAE;IAC3C,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,aAAa,CAAC;IAClC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC;IAC3B,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,OAAO,CAAC;IACjC,IAAI,CAAC,kBAAkB,EAAE,QAAQ,CAAC,eAAe,CAAC;IAClD,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAC,OAAO,CAAC;IACzC,GAAG,gBAAgB,CAAC,QAAQ,CAAC;IAC7B,GAAG,kBAAkB,CAAC,QAAQ,CAAC;IAC/B,UAAU,CAAC,QAAQ,CAAC,aAAa,CAAC;IAClC,GAAG,eAAe,CAAC,QAAQ,CAAC;IAC5B,GAAG,WAAW,CAAC,YAAY,EAAE,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC;IAC7D,GAAG,WAAW,CAAC,UAAU,EAAE,SAAS,EAAE,QAAQ,CAAC,QAAQ,CAAC;IACxD,GAAG,WAAW,CAAC,QAAQ,CAAC;IACxB,GAAG,kBAAkB,CAAC,QAAQ,CAAC;IAC/B,GAAG,eAAe,CAAC,QAAQ,CAAC;IAC5B,GAAG,oBAAoB,CAAC,QAAQ,CAAC;IACjC,GAAG,eAAe,CAAC,QAAQ,CAAC;CAC/B,CAAC,CACL,CAAC;AAEN,OAAO,EAAE,cAAc,EAAE,CAAC","sourcesContent":["import type { DeploySettings } from \"../types.js\";\nimport {\n brandingSection,\n contentRatingSection,\n descriptionSection,\n developerSection,\n listSection,\n providesSection,\n releasesSection,\n screenshotsSection,\n urlsSection,\n} from \"./metainfo-sections.js\";\nimport { element, renderDocument, text, type XmlNode } from \"./xml.js\";\n\nconst COMPONENT_TYPE = \"desktop-application\";\nconst DESKTOP_SUFFIX = \".desktop\";\n\nconst launchable = (applicationId: string): XmlNode => ({\n tag: \"launchable\",\n attributes: { type: \"desktop-id\" },\n text: `${applicationId}${DESKTOP_SUFFIX}`,\n});\n\nconst renderMetainfo = (settings: DeploySettings): string =>\n renderDocument(\n element(\"component\", { type: COMPONENT_TYPE }, [\n text(\"id\", settings.applicationId),\n text(\"name\", settings.name),\n text(\"summary\", settings.summary),\n text(\"metadata_license\", settings.metadataLicense),\n text(\"project_license\", settings.license),\n ...developerSection(settings),\n ...descriptionSection(settings),\n launchable(settings.applicationId),\n ...providesSection(settings),\n ...listSection(\"categories\", \"category\", settings.categories),\n ...listSection(\"keywords\", \"keyword\", settings.keywords),\n ...urlsSection(settings),\n ...screenshotsSection(settings),\n ...releasesSection(settings),\n ...contentRatingSection(settings),\n ...brandingSection(settings),\n ]),\n );\n\nexport { renderMetainfo };\n"]}
1
+ {"version":3,"file":"metainfo.js","sourceRoot":"","sources":["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\"../types.js\";\nimport {\n brandingSection,\n contentRatingSection,\n descriptionSection,\n developerSection,\n listSection,\n providesSection,\n releasesSection,\n screenshotsSection,\n urlsSection,\n} from \"./metainfo-sections.js\";\nimport { element, renderDocument, text, type XmlNode } from \"./xml.js\";\n\nconst COMPONENT_TYPE = \"desktop-application\";\nconst DESKTOP_SUFFIX = \".desktop\";\nconst COMPONENT_CLOSE = \"</component>\\n\";\nconst PROVIDES_CLOSE = \" </provides>\\n\";\nconst PROVIDES_FRAGMENT = /^<provides\\s*>([\\s\\S]*)<\\/provides>$/;\n\nconst normalizeExtraFragment = (fragment: string, index: number): string => {\n const normalized = fragment.trim();\n\n if (normalized.length === 0) {\n throw new Error(`Cannot render deploy.metainfoExtra entry ${String(index + 1)}: it is empty`);\n }\n\n return normalized;\n};\n\nconst indentFragment = (fragment: string, depth: number): string => {\n const indentation = \" \".repeat(depth * 4);\n\n return fragment.split(/\\r?\\n/).map((line) => `${indentation}${line}`).join(\"\\n\");\n};\n\nconst appendExtraFragments = (document: string, fragments: string[]): string => {\n if (fragments.length === 0) {\n return document;\n }\n\n let merged = document;\n const componentFragments: string[] = [];\n\n for (const [index, rawFragment] of fragments.entries()) {\n const fragment = normalizeExtraFragment(rawFragment, index);\n const provides = PROVIDES_FRAGMENT.exec(fragment)?.[1]?.trim();\n\n if (provides === undefined) {\n componentFragments.push(fragment);\n continue;\n }\n\n merged = merged.replace(PROVIDES_CLOSE, () => `${indentFragment(provides, 2)}\\n${PROVIDES_CLOSE}`);\n }\n\n if (componentFragments.length === 0) {\n return merged;\n }\n\n const extra = componentFragments.map((fragment) => indentFragment(fragment, 1)).join(\"\\n\");\n\n return merged.replace(COMPONENT_CLOSE, () => `${extra}\\n${COMPONENT_CLOSE}`);\n};\n\nconst launchable = (applicationId: string): XmlNode => ({\n tag: \"launchable\",\n attributes: { type: \"desktop-id\" },\n text: `${applicationId}${DESKTOP_SUFFIX}`,\n});\n\nconst metainfoRoot = (settings: DeploySettings): XmlNode =>\n element(\"component\", { type: COMPONENT_TYPE }, [\n text(\"id\", settings.applicationId),\n text(\"name\", settings.name),\n text(\"summary\", settings.summary),\n text(\"metadata_license\", settings.metadataLicense),\n text(\"project_license\", settings.license),\n ...developerSection(settings),\n ...descriptionSection(settings),\n launchable(settings.applicationId),\n ...providesSection(settings),\n ...listSection(\"categories\", \"category\", settings.categories),\n ...listSection(\"keywords\", \"keyword\", settings.keywords),\n ...urlsSection(settings),\n ...screenshotsSection(settings),\n ...releasesSection(settings),\n ...contentRatingSection(settings),\n ...brandingSection(settings),\n ]);\n\nconst renderMetainfo = (settings: DeploySettings): string => {\n const document = renderDocument(metainfoRoot(settings));\n\n return appendExtraFragments(document, settings.deploy.metainfoExtra ?? []);\n};\n\nexport { renderMetainfo };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"xml.d.ts","sourceRoot":"","sources":["../../../src/deploy/freedesktop/xml.ts"],"names":[],"mappings":"AAAA,KAAK,OAAO,GAAG;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAoBF,QAAA,MAAM,OAAO,GAAI,KAAK,MAAM,EAAE,YAAY,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,UAAU,OAAO,EAAE,KAAG,OAItF,CAAC;AAEH,QAAA,MAAM,IAAI,GAAI,KAAK,MAAM,EAAE,OAAO,MAAM,KAAG,OAAiC,CAAC;AAmB7E,QAAA,MAAM,cAAc,GAAI,MAAM,OAAO,KAAG,MAAkE,CAAC;AAE3G,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,KAAK,OAAO,EAAE,CAAC"}
1
+ {"version":3,"file":"xml.d.ts","sourceRoot":"","sources":["../../../src/deploy/freedesktop/xml.ts"],"names":[],"mappings":"AAEA,KAAK,OAAO,GAAG;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAuBF,QAAA,MAAM,OAAO,GAAI,KAAK,MAAM,EAAE,YAAY,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,UAAU,OAAO,EAAE,KAAG,OAItF,CAAC;AAEH,QAAA,MAAM,IAAI,GAAI,KAAK,MAAM,EAAE,OAAO,MAAM,KAAG,OAAiC,CAAC;AAE7E,QAAA,MAAM,cAAc,GAAI,MAAM,OAAO,KAAG,MAI9B,CAAC;AAEX,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,KAAK,OAAO,EAAE,CAAC"}
@@ -1,33 +1,29 @@
1
- const XML_DECLARATION = '<?xml version="1.0" encoding="UTF-8"?>';
2
- const INDENT = " ".repeat(4);
3
- const ESCAPES = {
4
- '"': "&quot;",
5
- "&": "&amp;",
6
- "<": "&lt;",
7
- ">": "&gt;",
8
- };
9
- const escapeXml = (value) => value.replaceAll(/["&<>]/g, (character) => ESCAPES[character] ?? character);
10
- const renderAttributes = (attributes) => Object.entries(attributes ?? {})
11
- .map(([key, value]) => ` ${key}="${escapeXml(value)}"`)
12
- .join("");
1
+ import XMLBuilder from "fast-xml-builder";
2
+ const XML_ENCODING = ["UTF", "8"].join("-");
3
+ const builder = new XMLBuilder({
4
+ format: true,
5
+ ignoreAttributes: false,
6
+ indentBy: " ".repeat(4),
7
+ preserveOrder: true,
8
+ suppressEmptyNode: true,
9
+ });
10
+ const orderedNode = (node) => ({
11
+ [node.tag]: node.text === undefined
12
+ ? (node.children ?? []).map((child) => orderedNode(child))
13
+ : [{ "#text": node.text }],
14
+ ...(node.attributes && {
15
+ ":@": Object.fromEntries(Object.entries(node.attributes).map(([key, value]) => [`@_${key}`, value])),
16
+ }),
17
+ });
13
18
  const element = (tag, attributes, children) => ({
14
19
  tag,
15
20
  attributes,
16
21
  children,
17
22
  });
18
23
  const text = (tag, value) => ({ tag, text: value });
19
- const renderNode = (node, depth) => {
20
- const padding = INDENT.repeat(depth);
21
- const open = `${padding}<${node.tag}${renderAttributes(node.attributes)}`;
22
- if (node.text !== undefined) {
23
- return [`${open}>${escapeXml(node.text)}</${node.tag}>`];
24
- }
25
- const children = node.children ?? [];
26
- if (children.length === 0) {
27
- return [`${open}/>`];
28
- }
29
- return [`${open}>`, ...children.flatMap((child) => renderNode(child, depth + 1)), `${padding}</${node.tag}>`];
30
- };
31
- const renderDocument = (root) => [XML_DECLARATION, ...renderNode(root, 0), ""].join("\n");
24
+ const renderDocument = (root) => `${builder.build([
25
+ { "?xml": [{ "#text": "" }], ":@": { "@_version": "1.0", "@_encoding": XML_ENCODING } },
26
+ orderedNode(root),
27
+ ])}\n`;
32
28
  export { element, renderDocument, text };
33
29
  //# sourceMappingURL=xml.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"xml.js","sourceRoot":"","sources":["../../../src/deploy/freedesktop/xml.ts"],"names":[],"mappings":"AAOA,MAAM,eAAe,GAAG,wCAAwC,CAAC;AACjE,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAE7B,MAAM,OAAO,GAA2B;IACpC,GAAG,EAAE,QAAQ;IACb,GAAG,EAAE,OAAO;IACZ,GAAG,EAAE,MAAM;IACX,GAAG,EAAE,MAAM;CACd,CAAC;AAEF,MAAM,SAAS,GAAG,CAAC,KAAa,EAAU,EAAE,CACxC,KAAK,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC,CAAC;AAEhF,MAAM,gBAAgB,GAAG,CAAC,UAA8C,EAAU,EAAE,CAChF,MAAM,CAAC,OAAO,CAAC,UAAU,IAAI,E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CAAC,GAAG,GAAG,CAAC,CAAC;AAClH,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,CAAC,IAAa,EAAU,EAAE,CAAC,CAAC,eAAe,EAAE,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAE3G,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,IAAI,EAAgB,CAAC","sourcesContent":["type XmlNode = {\n tag: string;\n attributes?: Record<string, string>;\n children?: XmlNode[];\n text?: string;\n};\n\nconst XML_DECLARATION = '<?xml version=\"1.0\" encoding=\"UTF-8\"?>';\nconst INDENT = \" \".repeat(4);\n\nconst ESCAPES: Record<string, string> = {\n '\"': \"&quot;\",\n \"&\": \"&amp;\",\n \"<\": \"&lt;\",\n \">\": \"&gt;\",\n};\n\nconst escapeXml = (value: string): string =>\n value.replaceAll(/[\"&<>]/g, (character) => ESCAPES[character] ?? character);\n\nconst renderAttributes = (attributes: Record<string, string> | undefined): string =>\n Object.entries(attributes ?? {})\n .map(([key, value]) => ` ${key}=\"${escapeXml(value)}\"`)\n .join(\"\");\n\nconst element = (tag: string, attributes: Record<string, string>, children: XmlNode[]): XmlNode => ({\n tag,\n attributes,\n children,\n});\n\nconst text = (tag: string, value: string): XmlNode => ({ tag, text: value });\n\nconst renderNode = (node: XmlNode, depth: number): string[] => {\n const padding = INDENT.repeat(depth);\n const open = `${padding}<${node.tag}${renderAttributes(node.attributes)}`;\n\n if (node.text !== undefined) {\n return [`${open}>${escapeXml(node.text)}</${node.tag}>`];\n }\n\n const children = node.children ?? [];\n\n if (children.length === 0) {\n return [`${open}/>`];\n }\n\n return [`${open}>`, ...children.flatMap((child) => renderNode(child, depth + 1)), `${padding}</${node.tag}>`];\n};\n\nconst renderDocument = (root: XmlNode): string => [XML_DECLARATION, ...renderNode(root, 0), \"\"].join(\"\\n\");\n\nexport { element, renderDocument, text, type XmlNode };\n"]}
1
+ {"version":3,"file":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a,EAAW,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;AAE7E,MAAM,cAAc,GAAG,CAAC,IAAa,EAAU,EAAE,CAC7C,GAAG,OAAO,CAAC,KAAK,CAAC;IACb,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,EAAE;IACvF,WAAW,CAAC,IAAI,CAAC;CACpB,CAAC,IAAI,CAAC;AAEX,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,IAAI,EAAgB,CAAC","sourcesContent":["import XMLBuilder from \"fast-xml-builder\";\n\ntype XmlNode = {\n tag: string;\n attributes?: Record<string, string>;\n children?: XmlNode[];\n text?: string;\n};\n\ntype OrderedNode = Record<string, unknown>;\n\nconst XML_ENCODING = [\"UTF\", \"8\"].join(\"-\");\n\nconst builder = new XMLBuilder({\n format: true,\n ignoreAttributes: false,\n indentBy: \" \".repeat(4),\n preserveOrder: true,\n suppressEmptyNode: true,\n});\n\nconst orderedNode = (node: XmlNode): OrderedNode => ({\n [node.tag]: node.text === undefined\n ? (node.children ?? []).map((child) => orderedNode(child))\n : [{ \"#text\": node.text }],\n ...(node.attributes && {\n \":@\": Object.fromEntries(Object.entries(node.attributes).map(([key, value]) => [`@_${key}`, value])),\n }),\n});\n\nconst element = (tag: string, attributes: Record<string, string>, children: XmlNode[]): XmlNode => ({\n tag,\n attributes,\n children,\n});\n\nconst text = (tag: string, value: string): XmlNode => ({ tag, text: value });\n\nconst renderDocument = (root: XmlNode): string =>\n `${builder.build([\n { \"?xml\": [{ \"#text\": \"\" }], \":@\": { \"@_version\": \"1.0\", \"@_encoding\": XML_ENCODING } },\n orderedNode(root),\n ])}\\n`;\n\nexport { element, renderDocument, text, type XmlNode };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/deploy/nfpm/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAc,MAAM,aAAa,CAAC;AAK7E,OAAO,EAAE,KAAK,OAAO,EAAkB,MAAM,eAAe,CAAC;AAE7D,KAAK,YAAY,GAAG,KAAK,GAAG,KAAK,CAAC;AAClC,KAAK,UAAU,GAAG,OAAO,CAAC;AAmG1B,QAAA,MAAM,cAAc,GAAI,UAAU,cAAc,EAAE,UAAU,YAAY,KAAG,MACV,CAAC;AAgBlE,QAAA,MAAM,gBAAgB,GAAI,SAAS,aAAa,EAAE,UAAU,YAAY,KAAG,UA0B1E,CAAC;AAEF,OAAO,EAAE,KAAK,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,CAAC"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/deploy/nfpm/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAc,MAAM,aAAa,CAAC;AAM7E,OAAO,EAAE,KAAK,OAAO,EAAkB,MAAM,eAAe,CAAC;AAE7D,KAAK,YAAY,GAAG,KAAK,GAAG,KAAK,CAAC;AAClC,KAAK,UAAU,GAAG,OAAO,CAAC;AAmG1B,QAAA,MAAM,cAAc,GAAI,UAAU,cAAc,EAAE,UAAU,YAAY,KAAG,MACV,CAAC;AAgBlE,QAAA,MAAM,gBAAgB,GAAI,SAAS,aAAa,EAAE,UAAU,YAAY,KAAG,UA4B1E,CAAC;AAEF,OAAO,EAAE,KAAK,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,CAAC"}