@gtkx/cli 2.0.0-beta.1 → 2.0.0-beta.10

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 (501) hide show
  1. package/README.md +43 -40
  2. package/bin/gtkx-dev-runner.js +5 -1
  3. package/bin/gtkx.js +5 -1
  4. package/dist/builder.d.ts +1 -0
  5. package/dist/builder.d.ts.map +1 -1
  6. package/dist/builder.js +44 -12
  7. package/dist/builder.js.map +1 -1
  8. package/dist/cli.d.ts +1 -1
  9. package/dist/cli.d.ts.map +1 -1
  10. package/dist/cli.js +14 -2
  11. package/dist/cli.js.map +1 -1
  12. package/dist/codegen/config-dependencies.d.ts +3 -0
  13. package/dist/codegen/config-dependencies.d.ts.map +1 -0
  14. package/dist/codegen/config-dependencies.js +355 -0
  15. package/dist/codegen/config-dependencies.js.map +1 -0
  16. package/dist/codegen/freshness.d.ts.map +1 -1
  17. package/dist/codegen/freshness.js +5 -1
  18. package/dist/codegen/freshness.js.map +1 -1
  19. package/dist/codegen/reference.d.ts.map +1 -1
  20. package/dist/codegen/reference.js +1 -0
  21. package/dist/codegen/reference.js.map +1 -1
  22. package/dist/codegen/run-codegen.d.ts +6 -3
  23. package/dist/codegen/run-codegen.d.ts.map +1 -1
  24. package/dist/codegen/run-codegen.js +42 -18
  25. package/dist/codegen/run-codegen.js.map +1 -1
  26. package/dist/codegen/store-resolver.d.ts +3 -1
  27. package/dist/codegen/store-resolver.d.ts.map +1 -1
  28. package/dist/codegen/store-resolver.js +7 -4
  29. package/dist/codegen/store-resolver.js.map +1 -1
  30. package/dist/commands/build.d.ts +5 -0
  31. package/dist/commands/build.d.ts.map +1 -1
  32. package/dist/commands/build.js +83 -10
  33. package/dist/commands/build.js.map +1 -1
  34. package/dist/commands/cleanup.d.ts +9 -0
  35. package/dist/commands/cleanup.d.ts.map +1 -0
  36. package/dist/commands/cleanup.js +42 -0
  37. package/dist/commands/cleanup.js.map +1 -0
  38. package/dist/commands/codegen.d.ts +1 -0
  39. package/dist/commands/codegen.d.ts.map +1 -1
  40. package/dist/commands/codegen.js +6 -5
  41. package/dist/commands/codegen.js.map +1 -1
  42. package/dist/commands/deploy.d.ts +5 -0
  43. package/dist/commands/deploy.d.ts.map +1 -1
  44. package/dist/commands/deploy.js +10 -2
  45. package/dist/commands/deploy.js.map +1 -1
  46. package/dist/commands/dev.d.ts +9 -0
  47. package/dist/commands/dev.d.ts.map +1 -1
  48. package/dist/commands/dev.js +31 -4
  49. package/dist/commands/dev.js.map +1 -1
  50. package/dist/commands/docs.d.ts.map +1 -1
  51. package/dist/commands/docs.js +1 -0
  52. package/dist/commands/docs.js.map +1 -1
  53. package/dist/deploy/depends.d.ts.map +1 -1
  54. package/dist/deploy/depends.js +24 -2
  55. package/dist/deploy/depends.js.map +1 -1
  56. package/dist/deploy/download.d.ts +7 -3
  57. package/dist/deploy/download.d.ts.map +1 -1
  58. package/dist/deploy/download.js +19 -20
  59. package/dist/deploy/download.js.map +1 -1
  60. package/dist/deploy/freedesktop/metainfo.d.ts.map +1 -1
  61. package/dist/deploy/freedesktop/metainfo.js +41 -2
  62. package/dist/deploy/freedesktop/metainfo.js.map +1 -1
  63. package/dist/deploy/freedesktop/validate.d.ts.map +1 -1
  64. package/dist/deploy/freedesktop/validate.js +58 -14
  65. package/dist/deploy/freedesktop/validate.js.map +1 -1
  66. package/dist/deploy/native-addon.d.ts +5 -0
  67. package/dist/deploy/native-addon.d.ts.map +1 -0
  68. package/dist/deploy/native-addon.js +134 -0
  69. package/dist/deploy/native-addon.js.map +1 -0
  70. package/dist/deploy/nfpm/config.d.ts +3 -2
  71. package/dist/deploy/nfpm/config.d.ts.map +1 -1
  72. package/dist/deploy/nfpm/config.js +7 -4
  73. package/dist/deploy/nfpm/config.js.map +1 -1
  74. package/dist/deploy/nfpm/contents.d.ts.map +1 -1
  75. package/dist/deploy/nfpm/contents.js +8 -0
  76. package/dist/deploy/nfpm/contents.js.map +1 -1
  77. package/dist/deploy/node-runtime/download.js +2 -2
  78. package/dist/deploy/node-runtime/download.js.map +1 -1
  79. package/dist/deploy/node-runtime/elf.d.ts +4 -1
  80. package/dist/deploy/node-runtime/elf.d.ts.map +1 -1
  81. package/dist/deploy/node-runtime/elf.js +34 -5
  82. package/dist/deploy/node-runtime/elf.js.map +1 -1
  83. package/dist/deploy/node-runtime/guard.d.ts.map +1 -1
  84. package/dist/deploy/node-runtime/guard.js +7 -14
  85. package/dist/deploy/node-runtime/guard.js.map +1 -1
  86. package/dist/deploy/node-runtime/index.d.ts +3 -1
  87. package/dist/deploy/node-runtime/index.d.ts.map +1 -1
  88. package/dist/deploy/node-runtime/index.js +103 -10
  89. package/dist/deploy/node-runtime/index.js.map +1 -1
  90. package/dist/deploy/node-runtime/sonames.d.ts +5 -0
  91. package/dist/deploy/node-runtime/sonames.d.ts.map +1 -0
  92. package/dist/deploy/node-runtime/sonames.js +13 -0
  93. package/dist/deploy/node-runtime/sonames.js.map +1 -0
  94. package/dist/deploy/notices/node-runtime.js +2 -2
  95. package/dist/deploy/notices/node-runtime.js.map +1 -1
  96. package/dist/deploy/payload/launcher.d.ts.map +1 -1
  97. package/dist/deploy/payload/launcher.js +14 -1
  98. package/dist/deploy/payload/launcher.js.map +1 -1
  99. package/dist/deploy/payload/stage.d.ts +2 -1
  100. package/dist/deploy/payload/stage.d.ts.map +1 -1
  101. package/dist/deploy/payload/stage.js +46 -5
  102. package/dist/deploy/payload/stage.js.map +1 -1
  103. package/dist/deploy/run-deploy.d.ts +2 -0
  104. package/dist/deploy/run-deploy.d.ts.map +1 -1
  105. package/dist/deploy/run-deploy.js +197 -52
  106. package/dist/deploy/run-deploy.js.map +1 -1
  107. package/dist/deploy/settings/arch.d.ts +9 -3
  108. package/dist/deploy/settings/arch.d.ts.map +1 -1
  109. package/dist/deploy/settings/arch.js +27 -6
  110. package/dist/deploy/settings/arch.js.map +1 -1
  111. package/dist/deploy/settings/build-manifest.d.ts +6 -1
  112. package/dist/deploy/settings/build-manifest.d.ts.map +1 -1
  113. package/dist/deploy/settings/build-manifest.js +15 -4
  114. package/dist/deploy/settings/build-manifest.js.map +1 -1
  115. package/dist/deploy/settings/extra-files.d.ts +1 -1
  116. package/dist/deploy/settings/extra-files.d.ts.map +1 -1
  117. package/dist/deploy/settings/extra-files.js +25 -3
  118. package/dist/deploy/settings/extra-files.js.map +1 -1
  119. package/dist/deploy/settings/index.d.ts +3 -1
  120. package/dist/deploy/settings/index.d.ts.map +1 -1
  121. package/dist/deploy/settings/index.js +4 -2
  122. package/dist/deploy/settings/index.js.map +1 -1
  123. package/dist/deploy/settings/libraries.d.ts.map +1 -1
  124. package/dist/deploy/settings/libraries.js +2 -1
  125. package/dist/deploy/settings/libraries.js.map +1 -1
  126. package/dist/deploy/settings/paths.d.ts +4 -2
  127. package/dist/deploy/settings/paths.d.ts.map +1 -1
  128. package/dist/deploy/settings/paths.js +121 -12
  129. package/dist/deploy/settings/paths.js.map +1 -1
  130. package/dist/deploy/targets/appimage.d.ts.map +1 -1
  131. package/dist/deploy/targets/appimage.js +1 -0
  132. package/dist/deploy/targets/appimage.js.map +1 -1
  133. package/dist/deploy/targets/flatpak-pnpm.js +4 -4
  134. package/dist/deploy/targets/flatpak-pnpm.js.map +1 -1
  135. package/dist/deploy/targets/flatpak-source.d.ts.map +1 -1
  136. package/dist/deploy/targets/flatpak-source.js +13 -2
  137. package/dist/deploy/targets/flatpak-source.js.map +1 -1
  138. package/dist/deploy/targets/flatpak.d.ts.map +1 -1
  139. package/dist/deploy/targets/flatpak.js +1 -0
  140. package/dist/deploy/targets/flatpak.js.map +1 -1
  141. package/dist/deploy/targets/nfpm-target.d.ts.map +1 -1
  142. package/dist/deploy/targets/nfpm-target.js +13 -7
  143. package/dist/deploy/targets/nfpm-target.js.map +1 -1
  144. package/dist/deploy/types.d.ts +5 -2
  145. package/dist/deploy/types.d.ts.map +1 -1
  146. package/dist/deploy/types.js.map +1 -1
  147. package/dist/deploy/vendored/appimagetool.js +2 -2
  148. package/dist/deploy/vendored/appimagetool.js.map +1 -1
  149. package/dist/deploy/vendored/nfpm.js +1 -1
  150. package/dist/deploy/vendored/nfpm.js.map +1 -1
  151. package/dist/dev/catalog-writes.d.ts +8 -0
  152. package/dist/dev/catalog-writes.d.ts.map +1 -0
  153. package/dist/dev/catalog-writes.js +26 -0
  154. package/dist/dev/catalog-writes.js.map +1 -0
  155. package/dist/dev/entry-env.d.ts +2 -1
  156. package/dist/dev/entry-env.d.ts.map +1 -1
  157. package/dist/dev/entry-env.js +2 -1
  158. package/dist/dev/entry-env.js.map +1 -1
  159. package/dist/dev/font-dir.d.ts +3 -0
  160. package/dist/dev/font-dir.d.ts.map +1 -0
  161. package/dist/dev/font-dir.js +9 -0
  162. package/dist/dev/font-dir.js.map +1 -0
  163. package/dist/dev/headless.d.ts +3 -0
  164. package/dist/dev/headless.d.ts.map +1 -0
  165. package/dist/dev/headless.js +35 -0
  166. package/dist/dev/headless.js.map +1 -0
  167. package/dist/dev/runner-deps.d.ts +1 -1
  168. package/dist/dev/runner-deps.d.ts.map +1 -1
  169. package/dist/dev/runner-deps.js +12 -7
  170. package/dist/dev/runner-deps.js.map +1 -1
  171. package/dist/dev/runner-main.d.ts.map +1 -1
  172. package/dist/dev/runner-main.js +10 -3
  173. package/dist/dev/runner-main.js.map +1 -1
  174. package/dist/dev/runner.d.ts +2 -0
  175. package/dist/dev/runner.d.ts.map +1 -1
  176. package/dist/dev/runner.js +26 -7
  177. package/dist/dev/runner.js.map +1 -1
  178. package/dist/dev/supervisor.d.ts +3 -1
  179. package/dist/dev/supervisor.d.ts.map +1 -1
  180. package/dist/dev/supervisor.js +132 -29
  181. package/dist/dev/supervisor.js.map +1 -1
  182. package/dist/dev/vite-dev-server.d.ts +1 -1
  183. package/dist/dev/vite-dev-server.d.ts.map +1 -1
  184. package/dist/dev/vite-dev-server.js +14 -2
  185. package/dist/dev/vite-dev-server.js.map +1 -1
  186. package/dist/dev/watch-ignore.d.ts +3 -0
  187. package/dist/dev/watch-ignore.d.ts.map +1 -0
  188. package/dist/dev/watch-ignore.js +11 -0
  189. package/dist/dev/watch-ignore.js.map +1 -0
  190. package/dist/i18n/catalogs.d.ts +6 -2
  191. package/dist/i18n/catalogs.d.ts.map +1 -1
  192. package/dist/i18n/catalogs.js +10 -7
  193. package/dist/i18n/catalogs.js.map +1 -1
  194. package/dist/i18n/source-messages.d.ts +3 -1
  195. package/dist/i18n/source-messages.d.ts.map +1 -1
  196. package/dist/i18n/source-messages.js +973 -9
  197. package/dist/i18n/source-messages.js.map +1 -1
  198. package/dist/internal/agent-rules.d.ts.map +1 -1
  199. package/dist/internal/agent-rules.js +7 -2
  200. package/dist/internal/agent-rules.js.map +1 -1
  201. package/dist/internal/banner.d.ts +4 -2
  202. package/dist/internal/banner.d.ts.map +1 -1
  203. package/dist/internal/banner.js +19 -5
  204. package/dist/internal/banner.js.map +1 -1
  205. package/dist/internal/build-manifest.d.ts +5 -2
  206. package/dist/internal/build-manifest.d.ts.map +1 -1
  207. package/dist/internal/build-manifest.js +15 -2
  208. package/dist/internal/build-manifest.js.map +1 -1
  209. package/dist/internal/build-output.d.ts +8 -0
  210. package/dist/internal/build-output.d.ts.map +1 -0
  211. package/dist/internal/build-output.js +116 -0
  212. package/dist/internal/build-output.js.map +1 -0
  213. package/dist/internal/cache-root.d.ts +3 -0
  214. package/dist/internal/cache-root.d.ts.map +1 -0
  215. package/dist/internal/cache-root.js +9 -0
  216. package/dist/internal/cache-root.js.map +1 -0
  217. package/dist/internal/compile-cache-store.d.ts +4 -0
  218. package/dist/internal/compile-cache-store.d.ts.map +1 -0
  219. package/dist/internal/compile-cache-store.js +41 -0
  220. package/dist/internal/compile-cache-store.js.map +1 -0
  221. package/dist/internal/compile-cache.d.ts +4 -0
  222. package/dist/internal/compile-cache.d.ts.map +1 -0
  223. package/dist/internal/compile-cache.js +16 -0
  224. package/dist/internal/compile-cache.js.map +1 -0
  225. package/dist/internal/deploy-out-dir.d.ts +4 -0
  226. package/dist/internal/deploy-out-dir.d.ts.map +1 -0
  227. package/dist/internal/deploy-out-dir.js +5 -0
  228. package/dist/internal/deploy-out-dir.js.map +1 -0
  229. package/dist/internal/docs-elements.d.ts +1 -0
  230. package/dist/internal/docs-elements.d.ts.map +1 -1
  231. package/dist/internal/docs-elements.js +5 -4
  232. package/dist/internal/docs-elements.js.map +1 -1
  233. package/dist/internal/entry-arg.d.ts +4 -1
  234. package/dist/internal/entry-arg.d.ts.map +1 -1
  235. package/dist/internal/entry-arg.js +7 -1
  236. package/dist/internal/entry-arg.js.map +1 -1
  237. package/dist/internal/errors.d.ts +2 -1
  238. package/dist/internal/errors.d.ts.map +1 -1
  239. package/dist/internal/errors.js +1 -1
  240. package/dist/internal/errors.js.map +1 -1
  241. package/dist/internal/font-path.d.ts +4 -0
  242. package/dist/internal/font-path.d.ts.map +1 -0
  243. package/dist/internal/font-path.js +12 -0
  244. package/dist/internal/font-path.js.map +1 -0
  245. package/dist/internal/font-staging.d.ts +6 -0
  246. package/dist/internal/font-staging.d.ts.map +1 -0
  247. package/dist/internal/font-staging.js +94 -0
  248. package/dist/internal/font-staging.js.map +1 -0
  249. package/dist/internal/icon-staging.d.ts +3 -0
  250. package/dist/internal/icon-staging.d.ts.map +1 -0
  251. package/dist/internal/icon-staging.js +40 -0
  252. package/dist/internal/icon-staging.js.map +1 -0
  253. package/dist/internal/import-scan.d.ts +4 -0
  254. package/dist/internal/import-scan.d.ts.map +1 -0
  255. package/dist/internal/import-scan.js +138 -0
  256. package/dist/internal/import-scan.js.map +1 -0
  257. package/dist/internal/module-hash.d.ts +3 -0
  258. package/dist/internal/module-hash.d.ts.map +1 -0
  259. package/dist/internal/module-hash.js +19 -0
  260. package/dist/internal/module-hash.js.map +1 -0
  261. package/dist/internal/output-directory.d.ts +15 -0
  262. package/dist/internal/output-directory.d.ts.map +1 -0
  263. package/dist/internal/output-directory.js +490 -0
  264. package/dist/internal/output-directory.js.map +1 -0
  265. package/dist/internal/parent-process.d.ts +12 -0
  266. package/dist/internal/parent-process.d.ts.map +1 -0
  267. package/dist/internal/parent-process.js +74 -0
  268. package/dist/internal/parent-process.js.map +1 -0
  269. package/dist/internal/prepare-project.d.ts +3 -0
  270. package/dist/internal/prepare-project.d.ts.map +1 -1
  271. package/dist/internal/prepare-project.js +9 -3
  272. package/dist/internal/prepare-project.js.map +1 -1
  273. package/dist/internal/react-compiler-cache.d.ts +13 -0
  274. package/dist/internal/react-compiler-cache.d.ts.map +1 -0
  275. package/dist/internal/react-compiler-cache.js +182 -0
  276. package/dist/internal/react-compiler-cache.js.map +1 -0
  277. package/dist/internal/source-imports.d.ts +7 -2
  278. package/dist/internal/source-imports.d.ts.map +1 -1
  279. package/dist/internal/source-imports.js +31 -11
  280. package/dist/internal/source-imports.js.map +1 -1
  281. package/dist/internal/staging-file.d.ts +5 -0
  282. package/dist/internal/staging-file.d.ts.map +1 -0
  283. package/dist/internal/staging-file.js +35 -0
  284. package/dist/internal/staging-file.js.map +1 -0
  285. package/dist/internal/xdg-banner.d.ts +4 -0
  286. package/dist/internal/xdg-banner.d.ts.map +1 -0
  287. package/dist/internal/xdg-banner.js +11 -0
  288. package/dist/internal/xdg-banner.js.map +1 -0
  289. package/dist/internal/xdg-data-dirs.d.ts +2 -1
  290. package/dist/internal/xdg-data-dirs.d.ts.map +1 -1
  291. package/dist/internal/xdg-data-dirs.js +1 -1
  292. package/dist/internal/xdg-data-dirs.js.map +1 -1
  293. package/dist/mcp/client.js +2 -2
  294. package/dist/mcp/client.js.map +1 -1
  295. package/dist/settings/schema.d.ts.map +1 -1
  296. package/dist/settings/schema.js +3 -8
  297. package/dist/settings/schema.js.map +1 -1
  298. package/dist/vite-plugins/asset-extensions.d.ts.map +1 -1
  299. package/dist/vite-plugins/asset-extensions.js +2 -0
  300. package/dist/vite-plugins/asset-extensions.js.map +1 -1
  301. package/dist/vite-plugins/asset-imports.d.ts.map +1 -1
  302. package/dist/vite-plugins/asset-imports.js +20 -6
  303. package/dist/vite-plugins/asset-imports.js.map +1 -1
  304. package/dist/vite-plugins/asset-specifier.d.ts +5 -1
  305. package/dist/vite-plugins/asset-specifier.d.ts.map +1 -1
  306. package/dist/vite-plugins/asset-specifier.js +10 -1
  307. package/dist/vite-plugins/asset-specifier.js.map +1 -1
  308. package/dist/vite-plugins/build-manifest.d.ts +5 -1
  309. package/dist/vite-plugins/build-manifest.d.ts.map +1 -1
  310. package/dist/vite-plugins/build-manifest.js +2 -1
  311. package/dist/vite-plugins/build-manifest.js.map +1 -1
  312. package/dist/vite-plugins/built-url.d.ts.map +1 -1
  313. package/dist/vite-plugins/built-url.js +5 -2
  314. package/dist/vite-plugins/built-url.js.map +1 -1
  315. package/dist/vite-plugins/css.d.ts.map +1 -1
  316. package/dist/vite-plugins/css.js +13 -5
  317. package/dist/vite-plugins/css.js.map +1 -1
  318. package/dist/vite-plugins/ensure-store.d.ts +1 -1
  319. package/dist/vite-plugins/ensure-store.d.ts.map +1 -1
  320. package/dist/vite-plugins/ensure-store.js +2 -2
  321. package/dist/vite-plugins/ensure-store.js.map +1 -1
  322. package/dist/vite-plugins/fast-refresh/refresh-filter.d.ts +6 -1
  323. package/dist/vite-plugins/fast-refresh/refresh-filter.d.ts.map +1 -1
  324. package/dist/vite-plugins/fast-refresh/refresh-filter.js +3 -1
  325. package/dist/vite-plugins/fast-refresh/refresh-filter.js.map +1 -1
  326. package/dist/vite-plugins/fast-refresh/swc-refresh.d.ts.map +1 -1
  327. package/dist/vite-plugins/fast-refresh/swc-refresh.js +23 -14
  328. package/dist/vite-plugins/fast-refresh/swc-refresh.js.map +1 -1
  329. package/dist/vite-plugins/font-name.d.ts +3 -0
  330. package/dist/vite-plugins/font-name.d.ts.map +1 -0
  331. package/dist/vite-plugins/font-name.js +406 -0
  332. package/dist/vite-plugins/font-name.js.map +1 -0
  333. package/dist/vite-plugins/font-worker-env.d.ts +4 -0
  334. package/dist/vite-plugins/font-worker-env.d.ts.map +1 -0
  335. package/dist/vite-plugins/font-worker-env.js +19 -0
  336. package/dist/vite-plugins/font-worker-env.js.map +1 -0
  337. package/dist/vite-plugins/font.d.ts +4 -0
  338. package/dist/vite-plugins/font.d.ts.map +1 -0
  339. package/dist/vite-plugins/font.js +111 -0
  340. package/dist/vite-plugins/font.js.map +1 -0
  341. package/dist/vite-plugins/i18n.d.ts +11 -2
  342. package/dist/vite-plugins/i18n.d.ts.map +1 -1
  343. package/dist/vite-plugins/i18n.js +74 -8
  344. package/dist/vite-plugins/i18n.js.map +1 -1
  345. package/dist/vite-plugins/icon-worker-env.d.ts +4 -0
  346. package/dist/vite-plugins/icon-worker-env.d.ts.map +1 -0
  347. package/dist/vite-plugins/icon-worker-env.js +23 -0
  348. package/dist/vite-plugins/icon-worker-env.js.map +1 -0
  349. package/dist/vite-plugins/icons.d.ts.map +1 -1
  350. package/dist/vite-plugins/icons.js +4 -9
  351. package/dist/vite-plugins/icons.js.map +1 -1
  352. package/dist/vite-plugins/index.d.ts +10 -1
  353. package/dist/vite-plugins/index.d.ts.map +1 -1
  354. package/dist/vite-plugins/index.js +17 -3
  355. package/dist/vite-plugins/index.js.map +1 -1
  356. package/dist/vite-plugins/native.d.ts.map +1 -1
  357. package/dist/vite-plugins/native.js +0 -4
  358. package/dist/vite-plugins/native.js.map +1 -1
  359. package/dist/vite-plugins/react-compiler.d.ts.map +1 -1
  360. package/dist/vite-plugins/react-compiler.js +57 -18
  361. package/dist/vite-plugins/react-compiler.js.map +1 -1
  362. package/dist/vite-plugins/resource-shared.d.ts +3 -1
  363. package/dist/vite-plugins/resource-shared.d.ts.map +1 -1
  364. package/dist/vite-plugins/resource-shared.js +3 -1
  365. package/dist/vite-plugins/resource-shared.js.map +1 -1
  366. package/dist/vite-plugins/resources.d.ts.map +1 -1
  367. package/dist/vite-plugins/resources.js +9 -6
  368. package/dist/vite-plugins/resources.js.map +1 -1
  369. package/dist/vite-plugins/self-contained.d.ts.map +1 -1
  370. package/dist/vite-plugins/self-contained.js +159 -158
  371. package/dist/vite-plugins/self-contained.js.map +1 -1
  372. package/dist/vite-plugins/settings-worker-env.d.ts +1 -1
  373. package/dist/vite-plugins/settings-worker-env.d.ts.map +1 -1
  374. package/dist/vite-plugins/settings-worker-env.js +4 -4
  375. package/dist/vite-plugins/settings-worker-env.js.map +1 -1
  376. package/dist/vite-plugins/settings.d.ts.map +1 -1
  377. package/dist/vite-plugins/settings.js +25 -14
  378. package/dist/vite-plugins/settings.js.map +1 -1
  379. package/dist/vite-plugins/store-links.d.ts.map +1 -1
  380. package/dist/vite-plugins/store-links.js +9 -5
  381. package/dist/vite-plugins/store-links.js.map +1 -1
  382. package/dist/vite-plugins/undeclared-library.d.ts.map +1 -1
  383. package/dist/vite-plugins/undeclared-library.js +18 -15
  384. package/dist/vite-plugins/undeclared-library.js.map +1 -1
  385. package/dist/vite-plugins/worker.d.ts.map +1 -1
  386. package/dist/vite-plugins/worker.js +21 -13
  387. package/dist/vite-plugins/worker.js.map +1 -1
  388. package/dist/vitest-plugin.d.ts +4 -3
  389. package/dist/vitest-plugin.d.ts.map +1 -1
  390. package/dist/vitest-plugin.js +12 -8
  391. package/dist/vitest-plugin.js.map +1 -1
  392. package/env.d.ts +9 -0
  393. package/package.json +18 -13
  394. package/src/builder.ts +45 -12
  395. package/src/cli.ts +15 -2
  396. package/src/codegen/config-dependencies.ts +470 -0
  397. package/src/codegen/freshness.ts +5 -1
  398. package/src/codegen/reference.ts +1 -0
  399. package/src/codegen/run-codegen.ts +51 -21
  400. package/src/codegen/store-resolver.ts +9 -4
  401. package/src/commands/build.ts +13 -2
  402. package/src/commands/cleanup.ts +48 -0
  403. package/src/commands/codegen.ts +6 -5
  404. package/src/commands/deploy.ts +10 -2
  405. package/src/commands/dev.ts +45 -4
  406. package/src/commands/docs.ts +1 -0
  407. package/src/deploy/depends.ts +30 -3
  408. package/src/deploy/download.ts +33 -24
  409. package/src/deploy/freedesktop/metainfo.ts +73 -21
  410. package/src/deploy/freedesktop/validate.ts +80 -15
  411. package/src/deploy/native-addon.ts +183 -0
  412. package/src/deploy/nfpm/config.ts +13 -4
  413. package/src/deploy/nfpm/contents.ts +8 -0
  414. package/src/deploy/node-runtime/download.ts +2 -2
  415. package/src/deploy/node-runtime/elf.ts +46 -5
  416. package/src/deploy/node-runtime/guard.ts +10 -14
  417. package/src/deploy/node-runtime/index.ts +148 -12
  418. package/src/deploy/node-runtime/sonames.ts +17 -0
  419. package/src/deploy/notices/node-runtime.ts +2 -2
  420. package/src/deploy/payload/launcher.ts +20 -1
  421. package/src/deploy/payload/stage.ts +76 -5
  422. package/src/deploy/run-deploy.ts +227 -72
  423. package/src/deploy/settings/arch.ts +40 -8
  424. package/src/deploy/settings/build-manifest.ts +28 -3
  425. package/src/deploy/settings/extra-files.ts +30 -4
  426. package/src/deploy/settings/index.ts +7 -2
  427. package/src/deploy/settings/libraries.ts +2 -1
  428. package/src/deploy/settings/paths.ts +80 -13
  429. package/src/deploy/targets/appimage.ts +1 -0
  430. package/src/deploy/targets/flatpak-pnpm.ts +4 -4
  431. package/src/deploy/targets/flatpak-source.ts +15 -2
  432. package/src/deploy/targets/flatpak.ts +1 -0
  433. package/src/deploy/targets/nfpm-target.ts +14 -6
  434. package/src/deploy/types.ts +5 -1
  435. package/src/deploy/vendored/appimagetool.ts +2 -2
  436. package/src/deploy/vendored/nfpm.ts +1 -1
  437. package/src/dev/catalog-writes.ts +35 -0
  438. package/src/dev/entry-env.ts +2 -1
  439. package/src/dev/font-dir.ts +11 -0
  440. package/src/dev/headless.ts +40 -0
  441. package/src/dev/runner-deps.ts +20 -7
  442. package/src/dev/runner-main.ts +12 -3
  443. package/src/dev/runner.ts +37 -7
  444. package/src/dev/supervisor.ts +183 -32
  445. package/src/dev/vite-dev-server.ts +20 -2
  446. package/src/dev/watch-ignore.ts +16 -0
  447. package/src/i18n/catalogs.ts +21 -8
  448. package/src/i18n/source-messages.ts +1446 -29
  449. package/src/internal/agent-rules.ts +7 -2
  450. package/src/internal/banner.ts +27 -6
  451. package/src/internal/build-manifest.ts +25 -1
  452. package/src/internal/build-output.ts +171 -0
  453. package/src/internal/cache-root.ts +12 -0
  454. package/src/internal/compile-cache-store.ts +50 -0
  455. package/src/internal/compile-cache.ts +20 -0
  456. package/src/internal/deploy-out-dir.ts +8 -0
  457. package/src/internal/docs-elements.ts +10 -4
  458. package/src/internal/entry-arg.ts +8 -1
  459. package/src/internal/errors.ts +1 -1
  460. package/src/internal/font-path.ts +15 -0
  461. package/src/internal/font-staging.ts +131 -0
  462. package/src/internal/icon-staging.ts +58 -0
  463. package/src/internal/import-scan.ts +206 -0
  464. package/src/internal/module-hash.ts +22 -0
  465. package/src/internal/output-directory.ts +699 -0
  466. package/src/internal/parent-process.ts +110 -0
  467. package/src/internal/prepare-project.ts +11 -5
  468. package/src/internal/react-compiler-cache.ts +246 -0
  469. package/src/internal/source-imports.ts +57 -12
  470. package/src/internal/staging-file.ts +42 -0
  471. package/src/internal/xdg-banner.ts +13 -0
  472. package/src/internal/xdg-data-dirs.ts +1 -1
  473. package/src/mcp/client.ts +2 -2
  474. package/src/settings/schema.ts +4 -10
  475. package/src/vite-plugins/asset-extensions.ts +2 -0
  476. package/src/vite-plugins/asset-imports.ts +23 -5
  477. package/src/vite-plugins/asset-specifier.ts +17 -0
  478. package/src/vite-plugins/build-manifest.ts +7 -1
  479. package/src/vite-plugins/built-url.ts +6 -2
  480. package/src/vite-plugins/css.ts +16 -5
  481. package/src/vite-plugins/ensure-store.ts +2 -2
  482. package/src/vite-plugins/fast-refresh/refresh-filter.ts +10 -1
  483. package/src/vite-plugins/fast-refresh/swc-refresh.ts +33 -14
  484. package/src/vite-plugins/font-name.ts +582 -0
  485. package/src/vite-plugins/font-worker-env.ts +25 -0
  486. package/src/vite-plugins/font.ts +180 -0
  487. package/src/vite-plugins/i18n.ts +122 -11
  488. package/src/vite-plugins/icon-worker-env.ts +36 -0
  489. package/src/vite-plugins/icons.ts +4 -10
  490. package/src/vite-plugins/index.ts +34 -9
  491. package/src/vite-plugins/native.ts +0 -5
  492. package/src/vite-plugins/react-compiler.ts +83 -19
  493. package/src/vite-plugins/resource-shared.ts +4 -0
  494. package/src/vite-plugins/resources.ts +11 -5
  495. package/src/vite-plugins/self-contained.ts +184 -185
  496. package/src/vite-plugins/settings-worker-env.ts +4 -4
  497. package/src/vite-plugins/settings.ts +36 -16
  498. package/src/vite-plugins/store-links.ts +10 -5
  499. package/src/vite-plugins/undeclared-library.ts +19 -15
  500. package/src/vite-plugins/worker.ts +31 -15
  501. package/src/vitest-plugin.ts +12 -8
@@ -0,0 +1,180 @@
1
+ import type { Plugin, Rollup } from "vite";
2
+ import { readFileSync } from "node:fs";
3
+ import { parseSync } from "vite";
4
+ import type { AssetEmitter } from "./asset-emitter.js";
5
+ import { prependBanner } from "../internal/banner.js";
6
+ import { fontFileName, FONTS_DIR } from "../internal/font-path.js";
7
+ import { stagedFontStatus } from "../internal/font-staging.js";
8
+ import { SOURCE_ID_RE, sourceLanguage } from "../internal/source-imports.js";
9
+ import { xdgDataDirsBanner } from "../internal/xdg-banner.js";
10
+ import { parseFontSpecifier } from "./asset-specifier.js";
11
+ import { fontFamilyNames } from "./font-name.js";
12
+ import { stripQuery } from "./strip-query.js";
13
+ import { createVirtualNamespace } from "./virtual-module.js";
14
+
15
+ type PluginState = {
16
+ isBuild: boolean;
17
+ root: string;
18
+ emitted: Set<string>;
19
+ importers: Map<string, string>;
20
+ };
21
+
22
+ type ResolveContext = Parameters<typeof resolveToVirtual>[0];
23
+ type ResolveRequest = Parameters<typeof resolveToVirtual>[1];
24
+
25
+ type RetainedFontModuleId = {
26
+ id: string;
27
+ moduleSideEffects: true;
28
+ };
29
+
30
+ type LoadContext = AssetEmitter & {
31
+ addWatchFile: (file: string) => void;
32
+ error: (message: string) => never;
33
+ };
34
+
35
+ const FONT_QUERY = "?font";
36
+ const FONT_ID_RE = /\?font$/;
37
+ const VIRTUAL_PREFIX = "\0gtkx-font:";
38
+ const VIRTUAL_ID_RE = new RegExp(`^${VIRTUAL_PREFIX}`);
39
+ const { isVirtual, fromVirtualId, resolveToVirtual } = createVirtualNamespace(VIRTUAL_PREFIX);
40
+
41
+ const unreadableFontError = (filePath: string): string =>
42
+ `Cannot read a font family name from ${filePath}; ?font expects a TrueType, OpenType, ` +
43
+ "TrueType Collection, WOFF, or WOFF2 font";
44
+
45
+ const unstagedFontError = (filePath: string, importer: string): string =>
46
+ `${filePath} was not staged before the toolkit started, so ${importer} would resolve its family to a ` +
47
+ "fallback font. Fonts are staged from ?font imports found in source files under the project root; move " +
48
+ "the import there, or restart to pick it up.";
49
+
50
+ const resolveFontId = async (
51
+ ctx: ResolveContext,
52
+ state: PluginState,
53
+ request: ResolveRequest,
54
+ ): Promise<RetainedFontModuleId | undefined> => {
55
+ if (parseFontSpecifier(request.source) === null) {
56
+ return undefined;
57
+ }
58
+
59
+ const virtualId = await resolveToVirtual(ctx, request);
60
+
61
+ if (virtualId === undefined) {
62
+ return undefined;
63
+ }
64
+
65
+ state.importers.set(virtualId, request.importer ?? state.root);
66
+
67
+ return { id: virtualId, moduleSideEffects: true };
68
+ };
69
+
70
+ const emitFont = (ctx: LoadContext, state: PluginState, filePath: string, content: Buffer): void => {
71
+ const fileName = `${FONTS_DIR}/${fontFileName(filePath, content)}`;
72
+
73
+ if (state.emitted.has(fileName)) {
74
+ return;
75
+ }
76
+
77
+ state.emitted.add(fileName);
78
+ ctx.emitFile({ type: "asset", fileName, source: content });
79
+ };
80
+
81
+ const loadFontModule = (ctx: LoadContext, state: PluginState, id: string): string | undefined => {
82
+ if (!isVirtual(id)) {
83
+ return undefined;
84
+ }
85
+
86
+ const filePath = stripQuery(fromVirtualId(id));
87
+ const content = readFileSync(filePath);
88
+ const [family] = fontFamilyNames(content);
89
+
90
+ if (family === undefined) {
91
+ return ctx.error(unreadableFontError(filePath));
92
+ }
93
+
94
+ ctx.addWatchFile(filePath);
95
+
96
+ if (state.isBuild) {
97
+ emitFont(ctx, state, filePath, content);
98
+ } else if (stagedFontStatus(filePath, content) === "absent") {
99
+ return ctx.error(unstagedFontError(filePath, state.importers.get(id) ?? state.root));
100
+ }
101
+
102
+ return `export default ${JSON.stringify(family)};`;
103
+ };
104
+
105
+ const hasSideEffectFontImport = (code: string, id: string): boolean => {
106
+ const lang = sourceLanguage(stripQuery(id));
107
+
108
+ if (lang === undefined || !code.includes(FONT_QUERY)) {
109
+ return false;
110
+ }
111
+
112
+ const parsed = parseSync(id, code, { lang });
113
+
114
+ if (parsed.errors.length > 0) {
115
+ return false;
116
+ }
117
+
118
+ return parsed.module.staticImports.some(
119
+ (statement) => statement.entries.length === 0 && parseFontSpecifier(statement.moduleRequest.value) !== null,
120
+ );
121
+ };
122
+
123
+ const retainSideEffectFontImport = (
124
+ code: string,
125
+ id: string,
126
+ ): { code: string; moduleSideEffects: true } | null =>
127
+ hasSideEffectFontImport(code, id)
128
+ ? { code, moduleSideEffects: true }
129
+ : null;
130
+
131
+ const fontBanner = (state: PluginState) => (chunk: Rollup.RenderedChunk): string =>
132
+ state.emitted.size === 0 ? "" : xdgDataDirsBanner(chunk);
133
+
134
+ function gtkxFont(): Plugin {
135
+ const state: PluginState = { isBuild: false, root: "", emitted: new Set(), importers: new Map() };
136
+
137
+ return {
138
+ name: "gtkx:font",
139
+ enforce: "pre",
140
+
141
+ configResolved(config) {
142
+ state.isBuild = config.command === "build";
143
+ state.root = config.root;
144
+ },
145
+
146
+ resolveId: {
147
+ filter: { id: FONT_ID_RE },
148
+
149
+ handler(source, importer, options) {
150
+ return resolveFontId(this, state, { source, importer, options });
151
+ },
152
+ },
153
+
154
+ load: {
155
+ filter: { id: VIRTUAL_ID_RE },
156
+
157
+ handler(id) {
158
+ return loadFontModule(this, state, id);
159
+ },
160
+ },
161
+
162
+ transform: {
163
+ filter: { id: SOURCE_ID_RE, code: FONT_QUERY },
164
+
165
+ handler(code, id) {
166
+ return retainSideEffectFontImport(code, id);
167
+ },
168
+ },
169
+
170
+ outputOptions(options) {
171
+ if (!state.isBuild) {
172
+ return;
173
+ }
174
+
175
+ return prependBanner(options, fontBanner(state));
176
+ },
177
+ };
178
+ }
179
+
180
+ export { gtkxFont };
@@ -1,7 +1,7 @@
1
1
  import type { ConfigLoader } from "@gtkx/config";
2
2
  import type { Plugin, ResolvedConfig } from "vite";
3
3
  import { createConfigLoader } from "@gtkx/config/internal";
4
- import { toPosixPath } from "@gtkx/utils";
4
+ import { isPathWithin, logger, toPosixPath } from "@gtkx/utils";
5
5
  import { existsSync, mkdirSync } from "node:fs";
6
6
  import { createRequire } from "node:module";
7
7
  import { dirname, join, posix, relative, resolve } from "node:path";
@@ -11,16 +11,31 @@ import {
11
11
  LOCALE_DIRNAME,
12
12
  resolveCatalogProject,
13
13
  synchronizeCatalogs,
14
+ type WrittenCatalog,
14
15
  } from "../i18n/catalogs.js";
15
- import { extractSourceCatalog } from "../i18n/source-messages.js";
16
- import { discoverSourceFiles } from "../internal/source-imports.js";
16
+ import { extractSourceCatalog, SourceExtractionError } from "../i18n/source-messages.js";
17
+ import { emitI18nTypes } from "../i18n/types.js";
18
+ import { discoverSourceFiles, sourceLanguage } from "../internal/source-imports.js";
17
19
  import { stripQuery } from "./strip-query.js";
18
20
 
21
+ type CatalogWriteListener = (catalogs: WrittenCatalog[]) => void;
22
+
23
+ type I18nPluginOptions = {
24
+ entryPath: string;
25
+ loadConfig?: ConfigLoader | undefined;
26
+ onCatalogsWritten?: CatalogWriteListener | undefined;
27
+ shouldPreserveMetadataMessages?: boolean | undefined;
28
+ shouldRecoverExtractionErrors?: boolean | undefined;
29
+ };
30
+
19
31
  type I18nState = {
20
32
  entryPath: string;
21
33
  i18nRoot: string;
22
34
  outDir: string;
23
35
  project: CatalogProject | null;
36
+ extraction: Promise<void>;
37
+ hotUpdateTimestamp: number | null;
38
+ onCatalogsWritten: CatalogWriteListener;
24
39
  };
25
40
 
26
41
  const BOOTSTRAP_SPECIFIER = "@gtkx/i18n/bootstrap";
@@ -94,6 +109,7 @@ const buildCatalogs = (state: I18nState): void => {
94
109
  const extractProjectMessages = async (
95
110
  state: I18nState,
96
111
  shouldPreserveMetadataMessages: boolean,
112
+ shouldSynchronizeCatalogs: boolean,
97
113
  ): Promise<void> => {
98
114
  const project = state.project;
99
115
 
@@ -104,15 +120,98 @@ const extractProjectMessages = async (
104
120
  const srcDir = join(project.root, "src");
105
121
  const sourceFiles = discoverSourceFiles(existsSync(srcDir) ? srcDir : project.root);
106
122
  await extractSourceCatalog(project, sourceFiles, shouldPreserveMetadataMessages);
107
- synchronizeCatalogs(project);
123
+
124
+ if (shouldSynchronizeCatalogs) {
125
+ state.onCatalogsWritten(synchronizeCatalogs(project));
126
+ }
127
+
128
+ await emitI18nTypes(project.root);
129
+ };
130
+
131
+ const settleExtraction = async (pending: Promise<void>): Promise<void> => {
132
+ try {
133
+ await pending;
134
+ } catch {
135
+ return;
136
+ }
137
+ };
138
+
139
+ const queueExtraction = (
140
+ state: I18nState,
141
+ shouldPreserveMetadataMessages: boolean,
142
+ shouldSynchronizeCatalogs: boolean,
143
+ ): Promise<void> => {
144
+ const prior = state.extraction;
145
+ const pending = (async (): Promise<void> => {
146
+ await settleExtraction(prior);
147
+ await extractProjectMessages(
148
+ state,
149
+ shouldPreserveMetadataMessages,
150
+ shouldSynchronizeCatalogs,
151
+ );
152
+ })();
153
+
154
+ state.extraction = pending;
155
+
156
+ return pending;
108
157
  };
109
158
 
110
- const gtkxI18n = (
111
- entryPath: string,
112
- loadConfig: ConfigLoader = createConfigLoader(),
159
+ const isProjectSource = (state: I18nState, path: string): boolean => {
160
+ const project = state.project;
161
+
162
+ if (project === null || sourceLanguage(path) === undefined) {
163
+ return false;
164
+ }
165
+
166
+ const srcDir = join(project.root, "src");
167
+ const sourceRoot = existsSync(srcDir) ? srcDir : project.root;
168
+
169
+ return isPathWithin(sourceRoot, path);
170
+ };
171
+
172
+ const refreshProjectMessages = async (
173
+ state: I18nState,
174
+ shouldPreserveMetadataMessages: boolean,
175
+ shouldSynchronizeCatalogs = false,
176
+ ): Promise<void> => {
177
+ try {
178
+ await queueExtraction(state, shouldPreserveMetadataMessages, shouldSynchronizeCatalogs);
179
+ } catch (error) {
180
+ logger.error(error instanceof Error ? error.message : String(error));
181
+ }
182
+ };
183
+
184
+ const recoverInitialSourceExtraction = async (
185
+ state: I18nState,
186
+ shouldPreserveMetadataMessages: boolean,
187
+ ): Promise<void> => {
188
+ try {
189
+ await queueExtraction(state, shouldPreserveMetadataMessages, true);
190
+ } catch (error) {
191
+ if (!(error instanceof SourceExtractionError)) {
192
+ throw error;
193
+ }
194
+
195
+ logger.error(error.message);
196
+ }
197
+ };
198
+
199
+ const gtkxI18n = ({
200
+ entryPath,
201
+ loadConfig = createConfigLoader(),
202
+ onCatalogsWritten = (): void => undefined,
113
203
  shouldPreserveMetadataMessages = true,
114
- ): Plugin => {
115
- const state: I18nState = { entryPath, i18nRoot: "", outDir: "", project: null };
204
+ shouldRecoverExtractionErrors = false,
205
+ }: I18nPluginOptions): Plugin => {
206
+ const state: I18nState = {
207
+ entryPath,
208
+ extraction: Promise.resolve(),
209
+ hotUpdateTimestamp: null,
210
+ i18nRoot: "",
211
+ outDir: "",
212
+ project: null,
213
+ onCatalogsWritten,
214
+ };
116
215
 
117
216
  return {
118
217
  name: "gtkx:i18n",
@@ -120,7 +219,19 @@ const gtkxI18n = (
120
219
 
121
220
  configResolved: (config) => applyResolvedConfig(state, config, loadConfig),
122
221
 
123
- buildStart: () => extractProjectMessages(state, shouldPreserveMetadataMessages),
222
+ buildStart: () => shouldRecoverExtractionErrors
223
+ ? recoverInitialSourceExtraction(state, shouldPreserveMetadataMessages)
224
+ : queueExtraction(state, shouldPreserveMetadataMessages, true),
225
+
226
+ hotUpdate(options) {
227
+ if (!isProjectSource(state, options.file) || state.hotUpdateTimestamp === options.timestamp) {
228
+ return;
229
+ }
230
+
231
+ state.hotUpdateTimestamp = options.timestamp;
232
+
233
+ return refreshProjectMessages(state, shouldPreserveMetadataMessages);
234
+ },
124
235
 
125
236
  transform(code, id) {
126
237
  if (isI18nLocaleModule(state, id)) {
@@ -144,4 +255,4 @@ const gtkxI18n = (
144
255
  };
145
256
  };
146
257
 
147
- export { gtkxI18n };
258
+ export { type CatalogWriteListener, gtkxI18n };
@@ -0,0 +1,36 @@
1
+ import type { UserConfig } from "vite";
2
+ import type { Plugin } from "vitest/config";
3
+ import { createConfigLoader, viteProjectRoot } from "@gtkx/config/internal";
4
+ import { stageProjectIcons } from "../internal/icon-staging.js";
5
+ import { prependXdgDataDir } from "../internal/xdg-data-dirs.js";
6
+
7
+ function gtkxIconWorkerEnv(configFile?: string): Plugin {
8
+ const loadConfig = createConfigLoader({ configFile });
9
+
10
+ return {
11
+ name: "gtkx:icon-worker-env",
12
+ enforce: "pre",
13
+
14
+ async config(config: UserConfig) {
15
+ const loaded = await loadConfig.load(viteProjectRoot(config));
16
+
17
+ const shareDir = stageProjectIcons(
18
+ loaded.root,
19
+ loaded.config.applicationId,
20
+ loaded.config.applicationIcon,
21
+ );
22
+
23
+ if (shareDir === null) {
24
+ return;
25
+ }
26
+
27
+ const existing = config.test?.env?.XDG_DATA_DIRS ?? process.env.XDG_DATA_DIRS;
28
+
29
+ return {
30
+ test: { env: { XDG_DATA_DIRS: prependXdgDataDir(shareDir, existing) } },
31
+ };
32
+ },
33
+ };
34
+ }
35
+
36
+ export { gtkxIconWorkerEnv };
@@ -1,6 +1,6 @@
1
1
  import type { ConfigLoader } from "@gtkx/config";
2
2
  import type { Plugin, UserConfig } from "vite";
3
- import { createConfigLoader } from "@gtkx/config/internal";
3
+ import { createConfigLoader, viteProjectRoot } from "@gtkx/config/internal";
4
4
  import { info } from "@gtkx/utils";
5
5
  import { readFileSync } from "node:fs";
6
6
  import { join } from "node:path";
@@ -12,6 +12,7 @@ import {
12
12
  type ResolvedApplicationIcon,
13
13
  } from "../internal/icon-path.js";
14
14
  import { type ListedFile, listFilesRecursive } from "../internal/list-files.js";
15
+ import { xdgDataDirsBanner } from "../internal/xdg-banner.js";
15
16
 
16
17
  type PluginState = {
17
18
  applicationId: string;
@@ -20,13 +21,6 @@ type PluginState = {
20
21
 
21
22
  const ICONS_DIR = "icons";
22
23
 
23
- const XDG_ENV_BANNER = [
24
- "process.env.XDG_DATA_DIRS = [",
25
- " decodeURIComponent(new URL(\".\", import.meta.url).pathname),",
26
- " process.env.XDG_DATA_DIRS || \"/usr/local/share:/usr/share\",",
27
- "].join(\":\");",
28
- ].join("\n");
29
-
30
24
  const findIconFiles = (state: PluginState): ListedFile[] => {
31
25
  if (state.source.kind === "theme") {
32
26
  return listFilesRecursive(state.source.path);
@@ -43,7 +37,7 @@ const findIconFiles = (state: PluginState): ListedFile[] => {
43
37
  };
44
38
 
45
39
  const applyUserConfig = async (state: PluginState, config: UserConfig, loadConfig: ConfigLoader): Promise<void> => {
46
- const { config: gtkxConfig, root } = await loadConfig.load(config.root ?? process.cwd());
40
+ const { config: gtkxConfig, root } = await loadConfig.load(viteProjectRoot(config));
47
41
  state.applicationId = gtkxConfig.applicationId;
48
42
  state.source = resolveApplicationIcon(root, gtkxConfig.applicationId, gtkxConfig.applicationIcon);
49
43
  };
@@ -78,7 +72,7 @@ function gtkxIcons(loadConfig: ConfigLoader = createConfigLoader()): Plugin {
78
72
  return;
79
73
  }
80
74
 
81
- return prependBanner(options, XDG_ENV_BANNER);
75
+ return prependBanner(options, xdgDataDirsBanner);
82
76
  },
83
77
 
84
78
  buildEnd() {
@@ -5,7 +5,8 @@ import type { BuildManifestCollector } from "../internal/build-manifest.js";
5
5
  import { gtkxAssetImports } from "./asset-imports.js";
6
6
  import { gtkxBuiltUrl } from "./built-url.js";
7
7
  import { gtkxCss } from "./css.js";
8
- import { gtkxI18n } from "./i18n.js";
8
+ import { gtkxFont } from "./font.js";
9
+ import { type CatalogWriteListener, gtkxI18n } from "./i18n.js";
9
10
  import { gtkxIcons } from "./icons.js";
10
11
  import { gtkxReactCompiler } from "./react-compiler.js";
11
12
  import { gtkxResources } from "./resources.js";
@@ -13,23 +14,47 @@ import { gtkxSettings } from "./settings.js";
13
14
  import { gtkxStoreLinks } from "./store-links.js";
14
15
  import { gtkxUndeclaredLibrary } from "./undeclared-library.js";
15
16
 
16
- const gtkxVitePlugins = (
17
- mode?: string,
18
- entryPath?: string,
19
- buildManifest?: BuildManifestCollector,
20
- shouldPreserveI18nMetadata = true,
21
- ): Plugin[] => {
22
- const loadConfig = createConfigLoader(mode === undefined ? {} : { mode });
17
+ type GtkxVitePluginOptions = {
18
+ buildManifest?: BuildManifestCollector | undefined;
19
+ configFile?: string | undefined;
20
+ entryPath?: string | undefined;
21
+ mode?: string | undefined;
22
+ onCatalogsWritten?: CatalogWriteListener | undefined;
23
+ shouldPreserveI18nMetadata?: boolean | undefined;
24
+ };
25
+
26
+ const gtkxVitePlugins = (options: GtkxVitePluginOptions = {}): Plugin[] => {
27
+ const {
28
+ buildManifest,
29
+ configFile,
30
+ entryPath,
31
+ mode,
32
+ onCatalogsWritten,
33
+ shouldPreserveI18nMetadata = true,
34
+ } = options;
35
+ const loadConfig = createConfigLoader({
36
+ ...(mode !== undefined && { mode }),
37
+ ...(configFile !== undefined && { configFile }),
38
+ });
23
39
 
24
40
  return [
25
41
  createConfigPlugin({ name: "gtkx:config", loadConfig }),
26
- ...(entryPath === undefined ? [] : [gtkxI18n(entryPath, loadConfig, shouldPreserveI18nMetadata)]),
42
+ ...(entryPath === undefined
43
+ ? []
44
+ : [gtkxI18n({
45
+ entryPath,
46
+ loadConfig,
47
+ onCatalogsWritten,
48
+ shouldPreserveMetadataMessages: shouldPreserveI18nMetadata,
49
+ shouldRecoverExtractionErrors: mode === "development",
50
+ })]),
27
51
  gtkxStoreLinks(),
28
52
  gtkxUndeclaredLibrary(loadConfig),
29
53
  gtkxSettings(buildManifest),
30
54
  gtkxIcons(loadConfig),
31
55
  gtkxAssetImports(),
32
56
  gtkxBuiltUrl(),
57
+ gtkxFont(),
33
58
  gtkxResources(loadConfig, entryPath),
34
59
  gtkxCss(),
35
60
  gtkxReactCompiler(loadConfig),
@@ -5,7 +5,6 @@ import { arch, platform } from "node:os";
5
5
  import { dirname, join } from "node:path";
6
6
  import { stripQuery } from "./strip-query.js";
7
7
 
8
- const EMITTED_BINDING_SPECIFIER = "./gtkx.node";
9
8
  const BINDING_FILENAME = "gtkx.node";
10
9
 
11
10
  function resolveBinaryPath(projectRequire: ReturnType<typeof createRequire>, currentArch: string): string {
@@ -97,10 +96,6 @@ function gtkxNative(root: string): Plugin {
97
96
  });
98
97
  },
99
98
 
100
- resolveId(id) {
101
- return id === EMITTED_BINDING_SPECIFIER ? { id, external: true } : null;
102
- },
103
-
104
99
  transform(code, id) {
105
100
  return transformLoader(code, id, loaderPath(), bindingReferenceId);
106
101
  },
@@ -1,21 +1,45 @@
1
1
  import type { ConfigLoader } from "@gtkx/config";
2
2
  import type { ResolvedReactCompilerOptions } from "@gtkx/config/internal";
3
3
  import type { Plugin, ResolvedConfig, UserConfig } from "vite";
4
- import { transformAsync } from "@babel/core";
5
- import babelPresetTypescriptNs from "@babel/preset-typescript";
6
- import { createConfigLoader } from "@gtkx/config/internal";
7
- import babelPluginReactCompilerNs from "babel-plugin-react-compiler";
4
+ import { createConfigLoader, viteProjectRoot } from "@gtkx/config/internal";
5
+ import {
6
+ type CompilerOutput,
7
+ createReactCompilerCache,
8
+ type ReactCompilerCache,
9
+ } from "../internal/react-compiler-cache.js";
8
10
 
9
11
  type ReactCompilerState = {
10
- root: string;
12
+ cache: ReactCompilerCache | null;
11
13
  options: ResolvedReactCompilerOptions | null;
14
+ root: string;
12
15
  };
13
16
 
14
- const babelPresetTypescript = babelPresetTypescriptNs.default ?? babelPresetTypescriptNs;
15
- const babelPluginReactCompiler = babelPluginReactCompilerNs.default ?? babelPluginReactCompilerNs;
17
+ type BabelToolchain = Awaited<ReturnType<typeof loadBabelToolchain>>;
18
+
16
19
  const SOURCE_EXTENSION = /\.[jt]sx?$/;
17
20
  const TYPESCRIPT_EXTENSION = /\.tsx?$/;
18
21
  const NODE_MODULES = /(?:^|\/)node_modules\//;
22
+ const MEMOIZABLE_SOURCE = /use[A-Z0-9]|use memo|use forget/;
23
+ const JSX_MARK = "<";
24
+ const PLAIN_TYPESCRIPT = ".ts";
25
+ const ALL_FUNCTIONS = "all";
26
+ const babel: { toolchain: Promise<BabelToolchain> | undefined } = { toolchain: undefined };
27
+
28
+ const loadBabelToolchain = async () => {
29
+ const [core, preset, plugin] = await Promise.all([
30
+ import("@babel/core"),
31
+ import("@babel/preset-typescript"),
32
+ import("babel-plugin-react-compiler"),
33
+ ]);
34
+
35
+ return {
36
+ presetTypescript: preset.default.default ?? preset.default,
37
+ reactCompiler: plugin.default.default ?? plugin.default,
38
+ transformAsync: core.transformAsync,
39
+ };
40
+ };
41
+
42
+ const babelToolchain = (): Promise<BabelToolchain> => (babel.toolchain ??= loadBabelToolchain());
19
43
 
20
44
  const isProjectSource = (root: string, id: string): boolean => {
21
45
  if (!SOURCE_EXTENSION.test(id)) {
@@ -33,15 +57,25 @@ const isProjectSource = (root: string, id: string): boolean => {
33
57
  return true;
34
58
  };
35
59
 
60
+ const isMemoizable = (code: string, id: string, options: ResolvedReactCompilerOptions): boolean => {
61
+ if (options.compilationMode === ALL_FUNCTIONS || MEMOIZABLE_SOURCE.test(code)) {
62
+ return true;
63
+ }
64
+
65
+ return !id.endsWith(PLAIN_TYPESCRIPT) && code.includes(JSX_MARK);
66
+ };
67
+
36
68
  const compileSource = async (code: string, id: string, options: ResolvedReactCompilerOptions) => {
37
- const result = await transformAsync(code, {
69
+ const toolchain = await babelToolchain();
70
+
71
+ const result = await toolchain.transformAsync(code, {
38
72
  filename: id,
39
73
  babelrc: false,
40
74
  configFile: false,
41
75
  sourceMaps: true,
42
- parserOpts: { plugins: id.endsWith(".ts") ? [] : ["jsx"] },
43
- presets: TYPESCRIPT_EXTENSION.test(id) ? [babelPresetTypescript] : [],
44
- plugins: [[babelPluginReactCompiler, options]],
76
+ parserOpts: { plugins: id.endsWith(PLAIN_TYPESCRIPT) ? [] : ["jsx"] },
77
+ presets: TYPESCRIPT_EXTENSION.test(id) ? [toolchain.presetTypescript] : [],
78
+ plugins: [[toolchain.reactCompiler, options]],
45
79
  });
46
80
 
47
81
  if (!result?.code) {
@@ -51,10 +85,33 @@ const compileSource = async (code: string, id: string, options: ResolvedReactCom
51
85
  return result.map == null ? { code: result.code } : { code: result.code, map: JSON.stringify(result.map) };
52
86
  };
53
87
 
88
+ const cachedSource = async (
89
+ cache: ReactCompilerCache,
90
+ code: string,
91
+ id: string,
92
+ options: ResolvedReactCompilerOptions,
93
+ ): Promise<CompilerOutput | undefined> => {
94
+ const key = cache.keyFor(code, id);
95
+ const cached = cache.read(key);
96
+
97
+ if (cached !== undefined) {
98
+ return cached;
99
+ }
100
+
101
+ const compiled = await compileSource(code, id, options);
102
+
103
+ if (compiled !== undefined) {
104
+ cache.write(key, compiled);
105
+ }
106
+
107
+ return compiled;
108
+ };
109
+
54
110
  function gtkxReactCompiler(loadConfig: ConfigLoader = createConfigLoader()): Plugin {
55
111
  const state: ReactCompilerState = {
56
- root: "",
112
+ cache: null,
57
113
  options: null,
114
+ root: "",
58
115
  };
59
116
 
60
117
  return {
@@ -62,22 +119,29 @@ function gtkxReactCompiler(loadConfig: ConfigLoader = createConfigLoader()): Plu
62
119
  enforce: "pre",
63
120
 
64
121
  async config(config: UserConfig) {
65
- const resolved = await loadConfig.resolve(config.root ?? process.cwd());
122
+ const resolved = await loadConfig.resolve(viteProjectRoot(config));
66
123
  state.options = resolved.reactCompiler;
67
124
  },
68
125
 
69
126
  configResolved(config: ResolvedConfig) {
70
127
  state.root = config.root;
128
+ state.cache = state.options === null ? null : createReactCompilerCache(config.cacheDir, state.options);
71
129
  },
72
130
 
73
- async transform(code, id) {
74
- const options = state.options;
131
+ transform: {
132
+ filter: { id: { include: SOURCE_EXTENSION, exclude: NODE_MODULES } },
133
+
134
+ async handler(code, id) {
135
+ const options = state.options;
136
+
137
+ if (options === null || !isProjectSource(state.root, id) || !isMemoizable(code, id, options)) {
138
+ return;
139
+ }
75
140
 
76
- if (options === null || !isProjectSource(state.root, id)) {
77
- return;
78
- }
141
+ const cache = state.cache;
79
142
 
80
- return compileSource(code, id, options);
143
+ return cache === null ? compileSource(code, id, options) : cachedSource(cache, code, id, options);
144
+ },
81
145
  },
82
146
  };
83
147
  }