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

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 (238) hide show
  1. package/dist/builder.d.ts +1 -0
  2. package/dist/builder.d.ts.map +1 -1
  3. package/dist/builder.js +17 -5
  4. package/dist/builder.js.map +1 -1
  5. package/dist/cli.d.ts +1 -1
  6. package/dist/cli.d.ts.map +1 -1
  7. package/dist/cli.js +9 -1
  8. package/dist/cli.js.map +1 -1
  9. package/dist/codegen/reference.d.ts.map +1 -1
  10. package/dist/codegen/reference.js +1 -0
  11. package/dist/codegen/reference.js.map +1 -1
  12. package/dist/codegen/run-codegen.d.ts +4 -2
  13. package/dist/codegen/run-codegen.d.ts.map +1 -1
  14. package/dist/codegen/run-codegen.js +15 -16
  15. package/dist/codegen/run-codegen.js.map +1 -1
  16. package/dist/codegen/store-resolver.d.ts +2 -1
  17. package/dist/codegen/store-resolver.d.ts.map +1 -1
  18. package/dist/codegen/store-resolver.js +4 -3
  19. package/dist/codegen/store-resolver.js.map +1 -1
  20. package/dist/commands/build.d.ts +5 -0
  21. package/dist/commands/build.d.ts.map +1 -1
  22. package/dist/commands/build.js +83 -10
  23. package/dist/commands/build.js.map +1 -1
  24. package/dist/commands/codegen.d.ts +1 -0
  25. package/dist/commands/codegen.d.ts.map +1 -1
  26. package/dist/commands/codegen.js +6 -5
  27. package/dist/commands/codegen.js.map +1 -1
  28. package/dist/commands/deploy.d.ts +1 -0
  29. package/dist/commands/deploy.d.ts.map +1 -1
  30. package/dist/commands/deploy.js +4 -2
  31. package/dist/commands/deploy.js.map +1 -1
  32. package/dist/commands/dev.d.ts +9 -0
  33. package/dist/commands/dev.d.ts.map +1 -1
  34. package/dist/commands/dev.js +29 -4
  35. package/dist/commands/dev.js.map +1 -1
  36. package/dist/commands/docs.d.ts.map +1 -1
  37. package/dist/commands/docs.js +1 -0
  38. package/dist/commands/docs.js.map +1 -1
  39. package/dist/deploy/freedesktop/metainfo.d.ts.map +1 -1
  40. package/dist/deploy/freedesktop/metainfo.js +41 -2
  41. package/dist/deploy/freedesktop/metainfo.js.map +1 -1
  42. package/dist/deploy/freedesktop/validate.d.ts.map +1 -1
  43. package/dist/deploy/freedesktop/validate.js +10 -4
  44. package/dist/deploy/freedesktop/validate.js.map +1 -1
  45. package/dist/deploy/nfpm/config.d.ts +3 -2
  46. package/dist/deploy/nfpm/config.d.ts.map +1 -1
  47. package/dist/deploy/nfpm/config.js +7 -4
  48. package/dist/deploy/nfpm/config.js.map +1 -1
  49. package/dist/deploy/nfpm/contents.d.ts.map +1 -1
  50. package/dist/deploy/nfpm/contents.js +8 -0
  51. package/dist/deploy/nfpm/contents.js.map +1 -1
  52. package/dist/deploy/node-runtime/elf.d.ts +2 -1
  53. package/dist/deploy/node-runtime/elf.d.ts.map +1 -1
  54. package/dist/deploy/node-runtime/elf.js +32 -5
  55. package/dist/deploy/node-runtime/elf.js.map +1 -1
  56. package/dist/deploy/node-runtime/index.d.ts +2 -1
  57. package/dist/deploy/node-runtime/index.d.ts.map +1 -1
  58. package/dist/deploy/node-runtime/index.js +75 -5
  59. package/dist/deploy/node-runtime/index.js.map +1 -1
  60. package/dist/deploy/notices/node-runtime.js +2 -2
  61. package/dist/deploy/notices/node-runtime.js.map +1 -1
  62. package/dist/deploy/payload/launcher.d.ts.map +1 -1
  63. package/dist/deploy/payload/launcher.js +14 -1
  64. package/dist/deploy/payload/launcher.js.map +1 -1
  65. package/dist/deploy/payload/stage.js +1 -1
  66. package/dist/deploy/payload/stage.js.map +1 -1
  67. package/dist/deploy/run-deploy.d.ts +1 -0
  68. package/dist/deploy/run-deploy.d.ts.map +1 -1
  69. package/dist/deploy/run-deploy.js +100 -14
  70. package/dist/deploy/run-deploy.js.map +1 -1
  71. package/dist/deploy/settings/build-manifest.d.ts +6 -1
  72. package/dist/deploy/settings/build-manifest.d.ts.map +1 -1
  73. package/dist/deploy/settings/build-manifest.js +15 -4
  74. package/dist/deploy/settings/build-manifest.js.map +1 -1
  75. package/dist/deploy/settings/extra-files.d.ts +1 -1
  76. package/dist/deploy/settings/extra-files.d.ts.map +1 -1
  77. package/dist/deploy/settings/extra-files.js +22 -1
  78. package/dist/deploy/settings/extra-files.js.map +1 -1
  79. package/dist/deploy/settings/index.d.ts +1 -0
  80. package/dist/deploy/settings/index.d.ts.map +1 -1
  81. package/dist/deploy/settings/index.js +2 -1
  82. package/dist/deploy/settings/index.js.map +1 -1
  83. package/dist/deploy/settings/paths.d.ts +2 -1
  84. package/dist/deploy/settings/paths.d.ts.map +1 -1
  85. package/dist/deploy/settings/paths.js +113 -5
  86. package/dist/deploy/settings/paths.js.map +1 -1
  87. package/dist/deploy/targets/flatpak-source.d.ts.map +1 -1
  88. package/dist/deploy/targets/flatpak-source.js +11 -2
  89. package/dist/deploy/targets/flatpak-source.js.map +1 -1
  90. package/dist/deploy/targets/nfpm-target.d.ts.map +1 -1
  91. package/dist/deploy/targets/nfpm-target.js +12 -7
  92. package/dist/deploy/targets/nfpm-target.js.map +1 -1
  93. package/dist/deploy/types.d.ts +1 -0
  94. package/dist/deploy/types.d.ts.map +1 -1
  95. package/dist/deploy/types.js.map +1 -1
  96. package/dist/dev/entry-env.d.ts +2 -1
  97. package/dist/dev/entry-env.d.ts.map +1 -1
  98. package/dist/dev/entry-env.js +2 -1
  99. package/dist/dev/entry-env.js.map +1 -1
  100. package/dist/dev/headless.d.ts +3 -0
  101. package/dist/dev/headless.d.ts.map +1 -0
  102. package/dist/dev/headless.js +35 -0
  103. package/dist/dev/headless.js.map +1 -0
  104. package/dist/dev/runner-deps.d.ts +1 -1
  105. package/dist/dev/runner-deps.d.ts.map +1 -1
  106. package/dist/dev/runner-deps.js +3 -3
  107. package/dist/dev/runner-deps.js.map +1 -1
  108. package/dist/dev/runner-main.d.ts.map +1 -1
  109. package/dist/dev/runner-main.js +8 -3
  110. package/dist/dev/runner-main.js.map +1 -1
  111. package/dist/dev/supervisor.d.ts +1 -0
  112. package/dist/dev/supervisor.d.ts.map +1 -1
  113. package/dist/dev/supervisor.js +4 -3
  114. package/dist/dev/supervisor.js.map +1 -1
  115. package/dist/i18n/catalogs.d.ts.map +1 -1
  116. package/dist/i18n/catalogs.js +1 -0
  117. package/dist/i18n/catalogs.js.map +1 -1
  118. package/dist/i18n/source-messages.d.ts.map +1 -1
  119. package/dist/i18n/source-messages.js +960 -8
  120. package/dist/i18n/source-messages.js.map +1 -1
  121. package/dist/internal/build-manifest.d.ts +5 -2
  122. package/dist/internal/build-manifest.d.ts.map +1 -1
  123. package/dist/internal/build-manifest.js +15 -2
  124. package/dist/internal/build-manifest.js.map +1 -1
  125. package/dist/internal/build-output.d.ts +8 -0
  126. package/dist/internal/build-output.d.ts.map +1 -0
  127. package/dist/internal/build-output.js +79 -0
  128. package/dist/internal/build-output.js.map +1 -0
  129. package/dist/internal/docs-elements.d.ts +1 -0
  130. package/dist/internal/docs-elements.d.ts.map +1 -1
  131. package/dist/internal/docs-elements.js +5 -4
  132. package/dist/internal/docs-elements.js.map +1 -1
  133. package/dist/internal/entry-arg.d.ts +4 -1
  134. package/dist/internal/entry-arg.d.ts.map +1 -1
  135. package/dist/internal/entry-arg.js +7 -1
  136. package/dist/internal/entry-arg.js.map +1 -1
  137. package/dist/internal/errors.d.ts +2 -1
  138. package/dist/internal/errors.d.ts.map +1 -1
  139. package/dist/internal/errors.js +1 -1
  140. package/dist/internal/errors.js.map +1 -1
  141. package/dist/internal/output-directory.d.ts +15 -0
  142. package/dist/internal/output-directory.d.ts.map +1 -0
  143. package/dist/internal/output-directory.js +490 -0
  144. package/dist/internal/output-directory.js.map +1 -0
  145. package/dist/internal/parent-process.d.ts +12 -0
  146. package/dist/internal/parent-process.d.ts.map +1 -0
  147. package/dist/internal/parent-process.js +74 -0
  148. package/dist/internal/parent-process.js.map +1 -0
  149. package/dist/internal/prepare-project.d.ts +2 -0
  150. package/dist/internal/prepare-project.d.ts.map +1 -1
  151. package/dist/internal/prepare-project.js +3 -3
  152. package/dist/internal/prepare-project.js.map +1 -1
  153. package/dist/internal/source-imports.js +1 -1
  154. package/dist/internal/source-imports.js.map +1 -1
  155. package/dist/mcp/client.js +2 -2
  156. package/dist/mcp/client.js.map +1 -1
  157. package/dist/vite-plugins/build-manifest.d.ts +5 -1
  158. package/dist/vite-plugins/build-manifest.d.ts.map +1 -1
  159. package/dist/vite-plugins/build-manifest.js +2 -1
  160. package/dist/vite-plugins/build-manifest.js.map +1 -1
  161. package/dist/vite-plugins/ensure-store.d.ts +1 -1
  162. package/dist/vite-plugins/ensure-store.d.ts.map +1 -1
  163. package/dist/vite-plugins/ensure-store.js +2 -2
  164. package/dist/vite-plugins/ensure-store.js.map +1 -1
  165. package/dist/vite-plugins/i18n.d.ts.map +1 -1
  166. package/dist/vite-plugins/i18n.js +58 -6
  167. package/dist/vite-plugins/i18n.js.map +1 -1
  168. package/dist/vite-plugins/index.d.ts +8 -1
  169. package/dist/vite-plugins/index.d.ts.map +1 -1
  170. package/dist/vite-plugins/index.js +6 -2
  171. package/dist/vite-plugins/index.js.map +1 -1
  172. package/dist/vite-plugins/native.d.ts.map +1 -1
  173. package/dist/vite-plugins/native.js +0 -4
  174. package/dist/vite-plugins/native.js.map +1 -1
  175. package/dist/vite-plugins/self-contained.d.ts.map +1 -1
  176. package/dist/vite-plugins/self-contained.js +159 -158
  177. package/dist/vite-plugins/self-contained.js.map +1 -1
  178. package/dist/vite-plugins/settings-worker-env.d.ts +1 -1
  179. package/dist/vite-plugins/settings-worker-env.d.ts.map +1 -1
  180. package/dist/vite-plugins/settings-worker-env.js +2 -2
  181. package/dist/vite-plugins/settings-worker-env.js.map +1 -1
  182. package/dist/vitest-plugin.d.ts +2 -1
  183. package/dist/vitest-plugin.d.ts.map +1 -1
  184. package/dist/vitest-plugin.js +6 -6
  185. package/dist/vitest-plugin.js.map +1 -1
  186. package/package.json +10 -9
  187. package/src/builder.ts +18 -5
  188. package/src/cli.ts +9 -1
  189. package/src/codegen/reference.ts +1 -0
  190. package/src/codegen/run-codegen.ts +17 -19
  191. package/src/codegen/store-resolver.ts +5 -3
  192. package/src/commands/build.ts +13 -2
  193. package/src/commands/codegen.ts +6 -5
  194. package/src/commands/deploy.ts +4 -2
  195. package/src/commands/dev.ts +38 -4
  196. package/src/commands/docs.ts +1 -0
  197. package/src/deploy/freedesktop/metainfo.ts +73 -21
  198. package/src/deploy/freedesktop/validate.ts +12 -4
  199. package/src/deploy/nfpm/config.ts +13 -4
  200. package/src/deploy/nfpm/contents.ts +8 -0
  201. package/src/deploy/node-runtime/elf.ts +43 -5
  202. package/src/deploy/node-runtime/index.ts +107 -6
  203. package/src/deploy/notices/node-runtime.ts +2 -2
  204. package/src/deploy/payload/launcher.ts +20 -1
  205. package/src/deploy/payload/stage.ts +1 -1
  206. package/src/deploy/run-deploy.ts +56 -16
  207. package/src/deploy/settings/build-manifest.ts +28 -3
  208. package/src/deploy/settings/extra-files.ts +26 -2
  209. package/src/deploy/settings/index.ts +3 -1
  210. package/src/deploy/settings/paths.ts +70 -5
  211. package/src/deploy/targets/flatpak-source.ts +13 -2
  212. package/src/deploy/targets/nfpm-target.ts +13 -6
  213. package/src/deploy/types.ts +1 -0
  214. package/src/dev/entry-env.ts +2 -1
  215. package/src/dev/headless.ts +40 -0
  216. package/src/dev/runner-deps.ts +3 -3
  217. package/src/dev/runner-main.ts +10 -3
  218. package/src/dev/supervisor.ts +6 -3
  219. package/src/i18n/catalogs.ts +1 -0
  220. package/src/i18n/source-messages.ts +1429 -28
  221. package/src/internal/build-manifest.ts +25 -1
  222. package/src/internal/build-output.ts +113 -0
  223. package/src/internal/docs-elements.ts +10 -4
  224. package/src/internal/entry-arg.ts +8 -1
  225. package/src/internal/errors.ts +1 -1
  226. package/src/internal/output-directory.ts +699 -0
  227. package/src/internal/parent-process.ts +110 -0
  228. package/src/internal/prepare-project.ts +5 -5
  229. package/src/internal/source-imports.ts +1 -1
  230. package/src/mcp/client.ts +2 -2
  231. package/src/vite-plugins/build-manifest.ts +7 -1
  232. package/src/vite-plugins/ensure-store.ts +2 -2
  233. package/src/vite-plugins/i18n.ts +83 -5
  234. package/src/vite-plugins/index.ts +14 -7
  235. package/src/vite-plugins/native.ts +0 -5
  236. package/src/vite-plugins/self-contained.ts +184 -185
  237. package/src/vite-plugins/settings-worker-env.ts +2 -2
  238. package/src/vitest-plugin.ts +6 -6
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output-directory.js","sourceRoot":"","sources":["../../src/internal/output-directory.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,WAAW,EACX,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,SAAS,EACT,MAAM,GACT,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AA0C/E,MAAM,YAAY,GAAG,CAAC,KAAc,EAAE,IAAY,EAAW,EAAE,CAC3D,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC;AAE1F,MAAM,eAAe,GAAG,CAAC,IAAY,EAAiB,EAAE;IACpD,IAAI,UAAU,GAAkB,IAAI,CAAC;IAErC,IAAI,CAAC;QACD,UAAU,GAAG,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,QAAQ,GAAG,SAAS,CAAC,UAAU,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;QAE9F,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;YAClC,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,OAAO,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAC5C,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,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AAO;QACH,MAAM;QACN,UAAU,EAAE,IAAI;QAChB,UAAU,EAAE,QAAQ;QACpB,YAAY,EAAE,OAAO,CAAC,IAAI,CAAC;QAC3B,MAAM;QACN,UAAU;QACV,QAAQ;QACR,IAAI;KACP,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,sBAAsB,GAAG,CAC3B,QAAgB,EAChB,IAAY,EACZ,UAA8B,EACP,EAAE;IACzB,MAAM,SAAS,GAAG,0BAA0B,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAC7D,MAAM,KAAK,GAAG,0BAA0B,CAAC,SAAS,CAAC,CAAC;IACpD,MAAM,WAAW,GAAG,gCAAgC,CAAC,EAAE,GAAG,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;IAE9E,IAAI,CAAC;QACD,IAAI,SAAS,CAAC,QAAQ,KAAK,IAAI,IAAI,UAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC;YAChE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC;QAC/C,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,kBAAkB,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IAC3C,CAAC;IAED,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;IAE9B,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AAChC,CAAC,CAAC;AAEF,OAAO,EAEH,sBAAsB,EACtB,eAAe,GAClB,CAAC","sourcesContent":["import {\n closeSync,\n constants,\n fstatSync,\n lstatSync,\n mkdirSync,\n mkdtempSync,\n openSync,\n readdirSync,\n readFileSync,\n realpathSync,\n renameSync,\n rmdirSync,\n rmSync,\n} from \"node:fs\";\nimport { basename, dirname, isAbsolute, join, relative, sep } from \"node:path\";\n\ntype DirectoryIdentity = { device: bigint; inode: bigint };\ntype DirectoryLease = { identity: DirectoryIdentity; path: string; release: () => void };\ntype DirectoryValidator = (path: string) => boolean;\ntype QuarantineDirectory = { displayPath: string; path: string; remove: () => void; release: () => void };\ntype CommitOutputRequest = {\n freshIdentity: DirectoryIdentity;\n preservedNames: ReadonlySet<string>;\n previous: string | null;\n quarantine: QuarantineDirectory;\n target: string;\n};\ntype InstallFreshOutputRequest = Omit<CommitOutputRequest, \"freshIdentity\" | \"previous\"> & {\n fresh: string;\n previous: string;\n};\ntype RenameOperation = { destination: string; source: string };\ntype RecoverCommitRequest = InstallFreshOutputRequest & {\n backup: string;\n error: unknown;\n operations: RenameOperation[];\n};\ntype OverlayEntryRequest = RenameOperation & { backup: string; operations: RenameOperation[] };\ntype OutputDirectoryTransaction = Disposable & {\n commit: (preservedNames?: ReadonlySet<string>, isFresh?: DirectoryValidator) => void;\n path: string;\n};\ntype PreparedOutputDirectory = { status: \"prepared\"; transaction: OutputDirectoryTransaction } | { status: \"unsafe\" };\ntype PreparationResources = {\n parent: DirectoryLease;\n previous: string | null;\n publicParent: string;\n publicPath: string;\n publicRoot: string;\n quarantine: QuarantineDirectory;\n root: DirectoryLease;\n target: string;\n};\ntype TransactionRequest = PreparationResources & { fresh: DirectoryLease };\ntype TransactionState = \"committed\" | \"prepared\" | \"retained\" | \"rolled-back\";\n\nconst hasErrorCode = (value: unknown, code: string): boolean =>\n typeof value === \"object\" && value !== null && \"code\" in value && value.code === code;\n\nconst readRegularFile = (path: string): string | null => {\n let descriptor: number | null = null;\n\n try {\n descriptor = openSync(path, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);\n\n if (!fstatSync(descriptor).isFile()) {\n return null;\n }\n\n return readFileSync(descriptor, \"utf8\");\n } catch {\n return null;\n } finally {\n if (descriptor !== null) {\n closeSync(descriptor);\n }\n }\n};\n\nconst openDirectoryLease = (path: string): DirectoryLease | null => {\n let descriptor: number | null = null;\n\n try {\n descriptor = openSync(path, constants.O_RDONLY | constants.O_DIRECTORY | constants.O_NOFOLLOW);\n const stats = fstatSync(descriptor, { bigint: true });\n let retainedDescriptor: number | null = descriptor;\n\n return {\n identity: { device: stats.dev, inode: stats.ino },\n path: join(\"/proc/self/fd\", String(descriptor)),\n release: () => {\n if (retainedDescriptor === null) {\n return;\n }\n\n const releasedDescriptor = retainedDescriptor;\n retainedDescriptor = null;\n closeSync(releasedDescriptor);\n },\n };\n } catch {\n if (descriptor !== null) {\n closeSync(descriptor);\n }\n\n return null;\n }\n};\n\nconst readDirectoryIdentity = (path: string): DirectoryIdentity | null => {\n const lease = openDirectoryLease(path);\n\n if (lease === null) {\n return null;\n }\n\n lease.release();\n\n return lease.identity;\n};\n\nconst hasDirectoryIdentity = (path: string, expected: DirectoryIdentity): boolean => {\n const actual = readDirectoryIdentity(path);\n\n return actual !== null && actual.device === expected.device && actual.inode === expected.inode;\n};\n\nconst hasResolvedDirectoryIdentity = (path: string, expected: DirectoryIdentity): boolean => {\n try {\n return hasDirectoryIdentity(realpathSync(path), expected);\n } catch {\n return false;\n }\n};\n\nconst capturePath = (source: string, destination: string): \"captured\" | \"missing\" => {\n try {\n renameSync(source, destination);\n\n return \"captured\";\n } catch (error) {\n if (hasErrorCode(error, \"ENOENT\")) {\n return \"missing\";\n }\n\n throw error;\n }\n};\n\nconst createQuarantineDirectory = (parent: DirectoryLease, displayParent: string): QuarantineDirectory => {\n const created = mkdtempSync(join(parent.path, \".gtkx-output-\"));\n const name = basename(created);\n const entry = join(parent.path, name);\n const lease = openDirectoryLease(entry);\n\n if (lease === null) {\n rmdirSync(entry);\n throw new Error(\"Could not secure the output quarantine directory\");\n }\n\n return {\n displayPath: join(displayParent, name),\n path: lease.path,\n release: lease.release,\n remove: () => {\n if (!hasDirectoryIdentity(entry, lease.identity)) {\n throw new Error(`The output quarantine changed; retained files are in ${join(displayParent, name)}`);\n }\n\n rmdirSync(entry);\n },\n };\n};\n\nconst releaseTransactionLeases = (\n fresh: DirectoryLease,\n quarantine: QuarantineDirectory,\n parent: DirectoryLease,\n root: DirectoryLease,\n): void => {\n try {\n fresh.release();\n } finally {\n try {\n quarantine.release();\n } finally {\n try {\n parent.release();\n } finally {\n root.release();\n }\n }\n }\n};\n\nconst releasePreparationLeases = (\n quarantine: QuarantineDirectory,\n parent: DirectoryLease,\n root: DirectoryLease,\n): void => {\n try {\n quarantine.release();\n } finally {\n try {\n parent.release();\n } finally {\n root.release();\n }\n }\n};\n\nconst movePath = (source: string, destination: string, operations: RenameOperation[]): void => {\n renameSync(source, destination);\n operations.push({ source, destination });\n};\n\nconst moveNames = (source: string, destination: string, names: string[], operations: RenameOperation[]): void => {\n for (const name of names) {\n movePath(join(source, name), join(destination, name), operations);\n }\n};\n\nconst reverseOperations = (operations: RenameOperation[]): void => {\n for (const operation of operations.toReversed()) {\n renameSync(operation.destination, operation.source);\n }\n};\n\nconst overlayDirectory = (\n source: string,\n destination: string,\n backup: string,\n operations: RenameOperation[],\n): void => {\n for (const name of readdirSync(source)) {\n overlayEntry({\n source: join(source, name),\n destination: join(destination, name),\n backup: join(backup, name),\n operations,\n });\n }\n};\n\nconst overlayEntry = (request: OverlayEntryRequest): void => {\n const destinationStats = lstatSync(request.destination, { throwIfNoEntry: false });\n\n if (destinationStats === undefined) {\n movePath(request.source, request.destination, request.operations);\n\n return;\n }\n\n const sourceStats = lstatSync(request.source);\n\n if (sourceStats.isDirectory() && destinationStats.isDirectory()) {\n overlayDirectory(request.source, request.destination, request.backup, request.operations);\n\n return;\n }\n\n if (!sourceStats.isFile() || !destinationStats.isFile()) {\n throw new Error(\"Cannot merge conflicting preserved output entries\");\n }\n\n mkdirSync(dirname(request.backup), { recursive: true });\n movePath(request.destination, request.backup, request.operations);\n movePath(request.source, request.destination, request.operations);\n};\n\nconst restoreUnexpectedOutput = (\n unexpected: string,\n target: string,\n quarantine: QuarantineDirectory,\n previous: string | null,\n): never => {\n try {\n renameSync(unexpected, target);\n\n if (previous === null) {\n quarantine.remove();\n }\n } catch (error) {\n throw new Error(`Output recovery failed; retained files are in ${quarantine.displayPath}`, { cause: error });\n }\n\n throw new Error(\n `Output changed during the operation; the previous output is retained in ${quarantine.displayPath}`,\n );\n};\n\nconst recoverUnsecuredPublicPath = (\n target: string,\n quarantine: QuarantineDirectory,\n previous: string | null,\n error: unknown,\n): never => {\n const unsecured = join(quarantine.path, \"unsecured\");\n const publicCapture = capturePath(target, unsecured);\n\n try {\n if (previous !== null) {\n renameSync(previous, target);\n } else if (publicCapture === \"captured\") {\n renameSync(unsecured, target);\n }\n\n if (previous === null || publicCapture === \"missing\") {\n quarantine.remove();\n }\n } catch (recoveryError) {\n throw new AggregateError(\n [error, recoveryError],\n `Could not recover the output directory; retained files are in ${quarantine.displayPath}`,\n { cause: recoveryError },\n );\n }\n\n throw new Error(`Could not secure the output directory; retained files are in ${quarantine.displayPath}`, {\n cause: error,\n });\n};\n\nconst recoverFailedCapture = (quarantine: QuarantineDirectory, error: unknown): never => {\n try {\n quarantine.remove();\n } catch (recoveryError) {\n throw new AggregateError(\n [error, recoveryError],\n `Could not clean the output quarantine; retained files are in ${quarantine.displayPath}`,\n { cause: recoveryError },\n );\n }\n\n throw error;\n};\n\nconst rollbackOutputDirectory = (\n target: string,\n quarantine: QuarantineDirectory,\n previous: string | null,\n freshIdentity: DirectoryIdentity,\n): void => {\n const failed = join(quarantine.path, \"failed\");\n const freshCapture = capturePath(target, failed);\n\n if (freshCapture === \"captured\" && !hasDirectoryIdentity(failed, freshIdentity)) {\n restoreUnexpectedOutput(failed, target, quarantine, previous);\n }\n\n if (previous !== null) {\n renameSync(previous, target);\n }\n\n if (freshCapture === \"captured\") {\n rmSync(failed, { recursive: true, force: true, maxRetries: 5 });\n }\n\n quarantine.remove();\n};\n\nconst restoreMissingFreshOutput = (\n target: string,\n quarantine: QuarantineDirectory,\n previous: string | null,\n): never => {\n try {\n if (previous !== null) {\n renameSync(previous, target);\n }\n\n quarantine.remove();\n } catch (error) {\n throw new Error(`The fresh output disappeared; retained files are in ${quarantine.displayPath}`, {\n cause: error,\n });\n }\n\n throw new Error(\"The fresh output directory disappeared before it could be committed\");\n};\n\nconst captureVerifiedFreshOutput = (\n target: string,\n quarantine: QuarantineDirectory,\n previous: string | null,\n freshIdentity: DirectoryIdentity,\n): string => {\n const fresh = join(quarantine.path, \"fresh\");\n\n if (capturePath(target, fresh) === \"missing\") {\n restoreMissingFreshOutput(target, quarantine, previous);\n }\n\n if (!hasDirectoryIdentity(fresh, freshIdentity)) {\n restoreUnexpectedOutput(fresh, target, quarantine, previous);\n }\n\n return fresh;\n};\n\nconst recoverCommit = (request: RecoverCommitRequest): never => {\n const { backup, error, fresh, operations, previous, quarantine, target } = request;\n\n try {\n reverseOperations(operations);\n renameSync(previous, target);\n rmSync(fresh, { recursive: true, force: true, maxRetries: 5 });\n rmSync(backup, { recursive: true, force: true, maxRetries: 5 });\n quarantine.remove();\n } catch (recoveryError) {\n throw new AggregateError(\n [error, recoveryError],\n `Could not restore the previous output; retained files are in ${quarantine.displayPath}`,\n { cause: recoveryError },\n );\n }\n\n throw error;\n};\n\nconst installFreshOutput = (request: InstallFreshOutputRequest): void => {\n const { fresh, preservedNames, previous, quarantine, target } = request;\n const backup = join(quarantine.path, \"backup\");\n const operations: RenameOperation[] = [];\n\n try {\n const oldNames = readdirSync(previous).filter((name) => !preservedNames.has(name));\n const freshNames = readdirSync(fresh);\n const ordinaryFreshNames = freshNames.filter((name) => !preservedNames.has(name));\n const preservedFreshNames = freshNames.filter((name) => preservedNames.has(name));\n mkdirSync(backup);\n moveNames(previous, backup, oldNames, operations);\n moveNames(fresh, previous, ordinaryFreshNames, operations);\n\n for (const name of preservedFreshNames) {\n overlayEntry({\n source: join(fresh, name),\n destination: join(previous, name),\n backup: join(backup, name),\n operations,\n });\n }\n\n renameSync(previous, target);\n } catch (error) {\n recoverCommit({ ...request, backup, operations, error });\n }\n\n rmSync(fresh, { recursive: true, force: true, maxRetries: 5 });\n rmSync(backup, { recursive: true, force: true, maxRetries: 5 });\n quarantine.remove();\n};\n\nconst commitOutputDirectory = (request: CommitOutputRequest): void => {\n const { freshIdentity, preservedNames, previous, quarantine, target } = request;\n const fresh = captureVerifiedFreshOutput(target, quarantine, previous, freshIdentity);\n\n if (previous === null) {\n renameSync(fresh, target);\n quarantine.remove();\n\n return;\n }\n\n installFreshOutput({ target, quarantine, previous, fresh, preservedNames });\n};\n\nconst assertFreshOutput = (path: string, isFresh: DirectoryValidator | undefined): void => {\n if (isFresh !== undefined && !isFresh(path)) {\n throw new Error(\"The build did not write to the secured output directory\");\n }\n};\n\nconst createOutputDirectoryTransaction = (request: TransactionRequest): OutputDirectoryTransaction => {\n const { fresh, parent, previous, publicParent, publicPath, publicRoot, quarantine, root, target } = request;\n let state: TransactionState = \"prepared\";\n\n const commit = (\n preservedNames: ReadonlySet<string> = new Set(),\n isFresh?: DirectoryValidator,\n ): void => {\n if (state !== \"prepared\") {\n throw new Error(\"The output directory transaction has already finished\");\n }\n\n if (\n !hasResolvedDirectoryIdentity(publicRoot, root.identity) ||\n !hasResolvedDirectoryIdentity(publicParent, parent.identity)\n ) {\n throw new Error(`The output parent changed; previous output is retained in ${quarantine.displayPath}`);\n }\n\n assertFreshOutput(target, isFresh);\n state = \"retained\";\n\n try {\n commitOutputDirectory({\n target,\n quarantine,\n previous,\n freshIdentity: fresh.identity,\n preservedNames,\n });\n state = \"committed\";\n } finally {\n releaseTransactionLeases(fresh, quarantine, parent, root);\n }\n };\n\n const rollback = (): void => {\n if (state !== \"prepared\") {\n return;\n }\n\n state = \"retained\";\n\n try {\n rollbackOutputDirectory(target, quarantine, previous, fresh.identity);\n state = \"rolled-back\";\n } finally {\n releaseTransactionLeases(fresh, quarantine, parent, root);\n }\n };\n\n return { path: publicPath, commit, [Symbol.dispose]: rollback };\n};\n\nconst rollbackAfterError = (transaction: OutputDirectoryTransaction, error: unknown): never => {\n try {\n transaction[Symbol.dispose]();\n } catch (rollbackError) {\n throw new AggregateError(\n [error, rollbackError],\n \"Could not roll back the output directory transaction\",\n { cause: rollbackError },\n );\n }\n\n throw error;\n};\n\nconst requireFreshDirectoryLease = (resources: PreparationResources): DirectoryLease => {\n const { parent, previous, quarantine, root, target } = resources;\n const lease = openDirectoryLease(target);\n\n if (lease !== null) {\n return lease;\n }\n\n try {\n return recoverUnsecuredPublicPath(\n target,\n quarantine,\n previous,\n new Error(\"Could not record the fresh output directory identity\"),\n );\n } finally {\n releasePreparationLeases(quarantine, parent, root);\n }\n};\n\nconst requireDirectoryLease = (path: string, message: string): DirectoryLease => {\n const lease = openDirectoryLease(path);\n\n if (lease === null) {\n throw new Error(message);\n }\n\n return lease;\n};\n\nconst createChildDirectoryLease = (parent: DirectoryLease, name: string): DirectoryLease => {\n const path = join(parent.path, name);\n\n try {\n mkdirSync(path);\n } catch (error) {\n if (!hasErrorCode(error, \"EEXIST\")) {\n throw error;\n }\n }\n\n return requireDirectoryLease(path, \"Could not secure the output parent directory\");\n};\n\nconst openOutputParent = (root: DirectoryLease, rootPath: string, outputPath: string): DirectoryLease => {\n const relativeParent = relative(rootPath, dirname(outputPath));\n\n if (relativeParent === \"..\" || isAbsolute(relativeParent) || relativeParent.startsWith(`..${sep}`)) {\n throw new Error(\"The output directory must be below the project root\");\n }\n\n let parent = requireDirectoryLease(`${root.path}/.`, \"Could not secure the project root directory\");\n const segments = relativeParent.split(sep);\n\n try {\n for (const segment of segments) {\n if (segment.length === 0) {\n continue;\n }\n\n const child = createChildDirectoryLease(parent, segment);\n parent.release();\n parent = child;\n }\n\n return parent;\n } catch (error) {\n parent.release();\n throw error;\n }\n};\n\nconst createPreparationResources = (rootPath: string, path: string): PreparationResources => {\n const canonicalRoot = realpathSync(rootPath);\n const root = requireDirectoryLease(canonicalRoot, \"Could not secure the project root directory\");\n let parent: DirectoryLease;\n\n try {\n parent = openOutputParent(root, rootPath, path);\n } catch (error) {\n root.release();\n throw error;\n }\n\n let quarantine: QuarantineDirectory;\n\n try {\n quarantine = createQuarantineDirectory(root, canonicalRoot);\n } catch (error) {\n parent.release();\n root.release();\n throw error;\n }\n\n const target = join(parent.path, basename(path));\n const captured = join(quarantine.path, \"previous\");\n let previous: string | null = null;\n\n try {\n previous = capturePath(target, captured) === \"captured\" ? captured : null;\n } catch (error) {\n try {\n recoverFailedCapture(quarantine, error);\n } finally {\n releasePreparationLeases(quarantine, parent, root);\n }\n }\n\n try {\n mkdirSync(target);\n } catch (error) {\n try {\n recoverUnsecuredPublicPath(target, quarantine, previous, error);\n } finally {\n releasePreparationLeases(quarantine, parent, root);\n }\n }\n\n return {\n target,\n publicPath: path,\n publicRoot: rootPath,\n publicParent: dirname(path),\n parent,\n quarantine,\n previous,\n root,\n };\n};\n\nconst prepareOutputDirectory = (\n rootPath: string,\n path: string,\n isReusable: DirectoryValidator,\n): PreparedOutputDirectory => {\n const resources = createPreparationResources(rootPath, path);\n const fresh = requireFreshDirectoryLease(resources);\n const transaction = createOutputDirectoryTransaction({ ...resources, fresh });\n\n try {\n if (resources.previous === null || isReusable(resources.previous)) {\n return { status: \"prepared\", transaction };\n }\n } catch (error) {\n rollbackAfterError(transaction, error);\n }\n\n transaction[Symbol.dispose]();\n\n return { status: \"unsafe\" };\n};\n\nexport {\n type OutputDirectoryTransaction,\n prepareOutputDirectory,\n readRegularFile,\n};\n"]}
@@ -0,0 +1,12 @@
1
+ type ProcessIdentity = {
2
+ pid: number;
3
+ parentId: number;
4
+ processGroupId: number;
5
+ startTime: string;
6
+ state: string;
7
+ };
8
+ type ProcessGroupOwner = Pick<ProcessIdentity, "pid" | "startTime">;
9
+ declare const initialParentId: number;
10
+ declare const getInitialProcessGroupOwner: () => ProcessGroupOwner | undefined;
11
+ export { getInitialProcessGroupOwner, initialParentId };
12
+ //# sourceMappingURL=parent-process.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parent-process.d.ts","sourceRoot":"","sources":["../../src/internal/parent-process.ts"],"names":[],"mappings":"AAEA,KAAK,eAAe,GAAG;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,KAAK,iBAAiB,GAAG,IAAI,CAAC,eAAe,EAAE,KAAK,GAAG,WAAW,CAAC,CAAC;AAIpE,QAAA,MAAM,eAAe,QAAe,CAAC;AAuFrC,QAAA,MAAM,2BAA2B,QAAO,iBAAiB,GAAG,SAM3D,CAAC;AAEF,OAAO,EAAE,2BAA2B,EAAE,eAAe,EAAE,CAAC"}
@@ -0,0 +1,74 @@
1
+ import { readFileSync } from "node:fs";
2
+ const initialParentId = process.ppid;
3
+ const STOPPED_PROCESS_STATES = new Set(["Z", "X", "x"]);
4
+ const processIdentity = (pid) => {
5
+ const stat = readFileSync(`/proc/${String(pid)}/stat`, "utf8");
6
+ const fields = stat.slice(stat.lastIndexOf(") ") + 2).split(" ");
7
+ const state = fields[0];
8
+ const parentId = Number(fields[1]);
9
+ const processGroupId = Number(fields[2]);
10
+ const startTime = fields[19];
11
+ if (state === undefined ||
12
+ startTime === undefined ||
13
+ !Number.isSafeInteger(parentId) ||
14
+ !Number.isSafeInteger(processGroupId)) {
15
+ throw new Error(`Failed to identify process ${String(pid)}`);
16
+ }
17
+ return { pid, parentId, processGroupId, startTime, state };
18
+ };
19
+ const ancestorFor = (process, ancestorId) => {
20
+ let current = process;
21
+ while (current.parentId > 1) {
22
+ const parent = processIdentity(current.parentId);
23
+ if (parent.pid === ancestorId) {
24
+ return parent;
25
+ }
26
+ current = parent;
27
+ }
28
+ return undefined;
29
+ };
30
+ const processGroupOwner = (process) => {
31
+ if (process.processGroupId !== process.pid || STOPPED_PROCESS_STATES.has(process.state)) {
32
+ throw new Error(`Failed to identify process group ${String(process.pid)}`);
33
+ }
34
+ return { pid: process.pid, startTime: process.startTime };
35
+ };
36
+ const processGroupOwnerFor = (process) => {
37
+ if (process.processGroupId === process.pid) {
38
+ return undefined;
39
+ }
40
+ const groupLeader = processGroupOwner(processIdentity(process.processGroupId));
41
+ const owner = ancestorFor(process, groupLeader.pid);
42
+ if (owner !== undefined) {
43
+ return groupLeader;
44
+ }
45
+ const currentGroupLeader = processGroupOwner(processIdentity(groupLeader.pid));
46
+ if (currentGroupLeader.startTime !== groupLeader.startTime) {
47
+ throw new Error(`Failed to identify process group ${String(groupLeader.pid)}`);
48
+ }
49
+ return undefined;
50
+ };
51
+ const captureProcessGroupOwner = () => {
52
+ try {
53
+ const initialProcess = processIdentity(process.pid);
54
+ if (initialProcess.parentId !== initialParentId) {
55
+ throw new Error("The process that launched GTKX exited during startup");
56
+ }
57
+ return { isCaptured: true, owner: processGroupOwnerFor(initialProcess) };
58
+ }
59
+ catch (error) {
60
+ return {
61
+ isCaptured: false,
62
+ error: error instanceof Error ? error : new Error("Failed to identify the process that launched GTKX"),
63
+ };
64
+ }
65
+ };
66
+ const capturedProcessGroupOwner = captureProcessGroupOwner();
67
+ const getInitialProcessGroupOwner = () => {
68
+ if (!capturedProcessGroupOwner.isCaptured) {
69
+ throw capturedProcessGroupOwner.error;
70
+ }
71
+ return capturedProcessGroupOwner.owner;
72
+ };
73
+ export { getInitialProcessGroupOwner, initialParentId };
74
+ //# sourceMappingURL=parent-process.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parent-process.js","sourceRoot":"","sources":["../../src/internal/parent-process.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAcvC,MAAM,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;AACrC,MAAM,sBAAsB,GAAgB,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAErE,MAAM,eAAe,GAAG,CAAC,GAAW,EAAmB,EAAE;IACrD,MAAM,IAAI,GAAG,YAAY,CAAC,SAAS,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC/D,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,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AC,cAAc,CAAC,EAAE,CAAC;IAC7E,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACb,OAAO;YACH,UAAU,EAAE,KAAK;YACjB,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,mDAAmD,CAAC;SACzG,CAAC;IACN,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,yBAAyB,GAAG,wBAAwB,EAAE,CAAC;AAE7D,MAAM,2BAA2B,GAAG,GAAkC,EAAE;IACpE,IAAI,CAAC,yBAAyB,CAAC,UAAU,EAAE,CAAC;QACxC,MAAM,yBAAyB,CAAC,KAAK,CAAC;IAC1C,CAAC;IAED,OAAO,yBAAyB,CAAC,KAAK,CAAC;AAC3C,CAAC,CAAC;AAEF,OAAO,EAAE,2BAA2B,EAAE,eAAe,EAAE,CAAC","sourcesContent":["import { readFileSync } from \"node:fs\";\n\ntype ProcessIdentity = {\n pid: number;\n parentId: number;\n processGroupId: number;\n startTime: string;\n state: string;\n};\n\ntype ProcessGroupOwner = Pick<ProcessIdentity, \"pid\" | \"startTime\">;\ntype ProcessGroupOwnerCapture = { isCaptured: true; owner: ProcessGroupOwner | undefined } |\n { isCaptured: false; error: Error };\n\nconst initialParentId = process.ppid;\nconst STOPPED_PROCESS_STATES: Set<string> = new Set([\"Z\", \"X\", \"x\"]);\n\nconst processIdentity = (pid: number): ProcessIdentity => {\n const stat = readFileSync(`/proc/${String(pid)}/stat`, \"utf8\");\n const fields = stat.slice(stat.lastIndexOf(\") \") + 2).split(\" \");\n const state = fields[0];\n const parentId = Number(fields[1]);\n const processGroupId = Number(fields[2]);\n const startTime = fields[19];\n\n if (\n state === undefined ||\n startTime === undefined ||\n !Number.isSafeInteger(parentId) ||\n !Number.isSafeInteger(processGroupId)\n ) {\n throw new Error(`Failed to identify process ${String(pid)}`);\n }\n\n return { pid, parentId, processGroupId, startTime, state };\n};\n\nconst ancestorFor = (process: ProcessIdentity, ancestorId: number): ProcessIdentity | undefined => {\n let current = process;\n\n while (current.parentId > 1) {\n const parent = processIdentity(current.parentId);\n\n if (parent.pid === ancestorId) {\n return parent;\n }\n\n current = parent;\n }\n\n return undefined;\n};\n\nconst processGroupOwner = (process: ProcessIdentity): ProcessGroupOwner => {\n if (process.processGroupId !== process.pid || STOPPED_PROCESS_STATES.has(process.state)) {\n throw new Error(`Failed to identify process group ${String(process.pid)}`);\n }\n\n return { pid: process.pid, startTime: process.startTime };\n};\n\nconst processGroupOwnerFor = (process: ProcessIdentity): ProcessGroupOwner | undefined => {\n if (process.processGroupId === process.pid) {\n return undefined;\n }\n\n const groupLeader = processGroupOwner(processIdentity(process.processGroupId));\n const owner = ancestorFor(process, groupLeader.pid);\n\n if (owner !== undefined) {\n return groupLeader;\n }\n\n const currentGroupLeader = processGroupOwner(processIdentity(groupLeader.pid));\n\n if (currentGroupLeader.startTime !== groupLeader.startTime) {\n throw new Error(`Failed to identify process group ${String(groupLeader.pid)}`);\n }\n\n return undefined;\n};\n\nconst captureProcessGroupOwner = (): ProcessGroupOwnerCapture => {\n try {\n const initialProcess = processIdentity(process.pid);\n\n if (initialProcess.parentId !== initialParentId) {\n throw new Error(\"The process that launched GTKX exited during startup\");\n }\n\n return { isCaptured: true, owner: processGroupOwnerFor(initialProcess) };\n } catch (error) {\n return {\n isCaptured: false,\n error: error instanceof Error ? error : new Error(\"Failed to identify the process that launched GTKX\"),\n };\n }\n};\n\nconst capturedProcessGroupOwner = captureProcessGroupOwner();\n\nconst getInitialProcessGroupOwner = (): ProcessGroupOwner | undefined => {\n if (!capturedProcessGroupOwner.isCaptured) {\n throw capturedProcessGroupOwner.error;\n }\n\n return capturedProcessGroupOwner.owner;\n};\n\nexport { getInitialProcessGroupOwner, initialParentId };\n"]}
@@ -2,10 +2,12 @@ import { type CodegenContext } from "../codegen/store-resolver.js";
2
2
  type ProjectArgs = {
3
3
  entry?: string;
4
4
  cwd?: string;
5
+ config?: string;
5
6
  };
6
7
  type PreparedProject = {
7
8
  cwd: string;
8
9
  entry: string;
10
+ configFile: string;
9
11
  };
10
12
  type ResolvedProject = PreparedProject & {
11
13
  context: CodegenContext;
@@ -1 +1 @@
1
- {"version":3,"file":"prepare-project.d.ts","sourceRoot":"","sources":["../../src/internal/prepare-project.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,cAAc,EAAyB,MAAM,8BAA8B,CAAC;AAG1F,KAAK,WAAW,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AACpD,KAAK,eAAe,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AACtD,KAAK,eAAe,GAAG,eAAe,GAAG;IAAE,OAAO,EAAE,cAAc,CAAA;CAAE,CAAC;AAErE,QAAA,MAAM,cAAc,GAAU,MAAM,WAAW,EAAE,MAAM,MAAM,KAAG,OAAO,CAAC,eAAe,CAKtF,CAAC;AAEF,QAAA,MAAM,cAAc,GAAU,MAAM,WAAW,EAAE,MAAM,MAAM,KAAG,OAAO,CAAC,eAAe,CAKtF,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,CAAC"}
1
+ {"version":3,"file":"prepare-project.d.ts","sourceRoot":"","sources":["../../src/internal/prepare-project.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,cAAc,EAAyB,MAAM,8BAA8B,CAAC;AAG1F,KAAK,WAAW,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AACrE,KAAK,eAAe,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC;AAC1E,KAAK,eAAe,GAAG,eAAe,GAAG;IAAE,OAAO,EAAE,cAAc,CAAA;CAAE,CAAC;AAErE,QAAA,MAAM,cAAc,GAAU,MAAM,WAAW,EAAE,MAAM,MAAM,KAAG,OAAO,CAAC,eAAe,CAKtF,CAAC;AAEF,QAAA,MAAM,cAAc,GAAU,MAAM,WAAW,EAAE,MAAM,MAAM,KAAG,OAAO,CAAC,eAAe,CAKtF,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,CAAC"}
@@ -3,13 +3,13 @@ import { resolveCodegenContext } from "../codegen/store-resolver.js";
3
3
  import { resolveCwd, resolveEntry } from "./entry-arg.js";
4
4
  const resolveProject = async (args, mode) => {
5
5
  const cwd = resolveCwd(args);
6
- const context = await resolveCodegenContext(cwd, mode);
7
- return { cwd, entry: resolveEntry(cwd, args.entry), context };
6
+ const context = await resolveCodegenContext(cwd, mode, args.config);
7
+ return { cwd, entry: resolveEntry(cwd, args.entry), configFile: context.configFile, context };
8
8
  };
9
9
  const prepareProject = async (args, mode) => {
10
10
  const { cwd, entry, context } = await resolveProject(args, mode);
11
11
  await ensureGeneratedIn(context, { shouldAnnounce: true, mode });
12
- return { cwd, entry };
12
+ return { cwd, entry, configFile: context.configFile };
13
13
  };
14
14
  export { prepareProject, resolveProject };
15
15
  //# sourceMappingURL=prepare-project.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"prepare-project.js","sourceRoot":"","sources":["../../src/internal/prepare-project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAuB,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAC1F,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAM1D,MAAM,cAAc,GAAG,KAAK,EAAE,IAAiB,EAAE,IAAY,EAA4B,EAAE;IACvF,MAAM,GAAG,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IAC7B,MAAM,OAAO,GAAG,MAAM,qBAAqB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAEvD,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,YAAY,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC;AAClE,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,KAAK,EAAE,IAAiB,EAAE,IAAY,EAA4B,EAAE;IACvF,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,MAAM,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACjE,MAAM,iBAAiB,CAAC,OAAO,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAEjE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;AAC1B,CAAC,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,CAAC","sourcesContent":["import { ensureGeneratedIn } from \"../codegen/run-codegen.js\";\nimport { type CodegenContext, resolveCodegenContext } from \"../codegen/store-resolver.js\";\nimport { resolveCwd, resolveEntry } from \"./entry-arg.js\";\n\ntype ProjectArgs = { entry?: string; cwd?: string };\ntype PreparedProject = { cwd: string; entry: string };\ntype ResolvedProject = PreparedProject & { context: CodegenContext };\n\nconst resolveProject = async (args: ProjectArgs, mode: string): Promise<ResolvedProject> => {\n const cwd = resolveCwd(args);\n const context = await resolveCodegenContext(cwd, mode);\n\n return { cwd, entry: resolveEntry(cwd, args.entry), context };\n};\n\nconst prepareProject = async (args: ProjectArgs, mode: string): Promise<PreparedProject> => {\n const { cwd, entry, context } = await resolveProject(args, mode);\n await ensureGeneratedIn(context, { shouldAnnounce: true, mode });\n\n return { cwd, entry };\n};\n\nexport { prepareProject, resolveProject };\n"]}
1
+ {"version":3,"file":"prepare-project.js","sourceRoot":"","sources":["../../src/internal/prepare-project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAuB,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAC1F,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAM1D,MAAM,cAAc,GAAG,KAAK,EAAE,IAAiB,EAAE,IAAY,EAA4B,EAAE;IACvF,MAAM,GAAG,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IAC7B,MAAM,OAAO,GAAG,MAAM,qBAAqB,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IAEpE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,YAAY,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,OAAO,EAAE,CAAC;AAClG,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,KAAK,EAAE,IAAiB,EAAE,IAAY,EAA4B,EAAE;IACvF,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,MAAM,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACjE,MAAM,iBAAiB,CAAC,OAAO,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAEjE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC;AAC1D,CAAC,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,CAAC","sourcesContent":["import { ensureGeneratedIn } from \"../codegen/run-codegen.js\";\nimport { type CodegenContext, resolveCodegenContext } from \"../codegen/store-resolver.js\";\nimport { resolveCwd, resolveEntry } from \"./entry-arg.js\";\n\ntype ProjectArgs = { entry?: string; cwd?: string; config?: string };\ntype PreparedProject = { cwd: string; entry: string; configFile: string };\ntype ResolvedProject = PreparedProject & { context: CodegenContext };\n\nconst resolveProject = async (args: ProjectArgs, mode: string): Promise<ResolvedProject> => {\n const cwd = resolveCwd(args);\n const context = await resolveCodegenContext(cwd, mode, args.config);\n\n return { cwd, entry: resolveEntry(cwd, args.entry), configFile: context.configFile, context };\n};\n\nconst prepareProject = async (args: ProjectArgs, mode: string): Promise<PreparedProject> => {\n const { cwd, entry, context } = await resolveProject(args, mode);\n await ensureGeneratedIn(context, { shouldAnnounce: true, mode });\n\n return { cwd, entry, configFile: context.configFile };\n};\n\nexport { prepareProject, resolveProject };\n"]}
@@ -18,7 +18,7 @@ const sourceLanguage = (path) => {
18
18
  };
19
19
  const discoverSourceFiles = (dir) => sortStringsBy(globSync("**/{*,.*}", {
20
20
  cwd: dir,
21
- exclude: ["**/{build,coverage,dist,node_modules,out-tsc}/**"],
21
+ exclude: ["**/{build,coverage,dist,node_modules,out-tsc}/**", "**/.gtkx-output-*/**"],
22
22
  withFileTypes: true,
23
23
  })
24
24
  .filter((entry) => entry.isFile())
@@ -1 +1 @@
1
- {"version":3,"file":"source-imports.js","sourceRoot":"","sources":["../../src/internal/source-imports.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAU1C,MAAM,gBAAgB,GAAgC,IAAI,GAAG,CAAC;IAC1D,CAAC,KAAK,EAAE,KAAK,CAAC;IACd,CAAC,MAAM,EAAE,KAAK,CAAC;IACf,CAAC,MAAM,EAAE,KAAK,CAAC;IACf,CAAC,MAAM,EAAE,IAAI,CAAC;IACd,CAAC,KAAK,EAAE,IAAI,CAAC;IACb,CAAC,MAAM,EAAE,KAAK,CAAC;CAClB,CAAC,CAAC;AAEH,MAAM,cAAc,GAAG,CAAC,IAAY,EAA8B,EAAE;IAChE,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,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AAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;AAC/E,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,CAAC,IAAY,EAAyB,EAAE,CAAC,kBAAkB,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC;AAE9G,MAAM,qBAAqB,GAAG,CAAC,IAAY,EAAyB,EAAE,CAClE,kBAAkB,CAAC,IAAI,EAAE,0BAA0B,CAAC,CAAC;AAEzD,MAAM,SAAS,GAAG,CAAC,IAAY,EAAkB,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;AAC/E,MAAM,SAAS,GAAG,CAAC,KAAmB,EAAU,EAAE,CAAC,GAAG,KAAK,CAAC,QAAQ,KAAK,KAAK,CAAC,MAAM,EAAE,CAAC;AAExF,MAAM,qBAAqB,GAAG,CAAC,GAAW,EAAkB,EAAE;IAC1D,MAAM,KAAK,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;IACvC,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IAEzD,OAAO,aAAa,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;AAC7C,CAAC,CAAC;AAEF,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,qBAAqB,EAAqB,cAAc,EAAE,CAAC","sourcesContent":["import type { ESTree, ParseResult, ParserOptions } from \"vite\";\nimport { sortStringsBy } from \"@gtkx/utils\";\nimport { globSync, readFileSync } from \"node:fs\";\nimport { extname, join } from \"node:path\";\nimport { parseSync, Visitor } from \"vite\";\n\ntype SourceImport = {\n importer: string;\n source: string;\n};\n\ntype SourceLanguage = NonNullable<ParserOptions[\"lang\"]>;\ntype ParsedModule = ParseResult[\"module\"];\n\nconst SOURCE_LANGUAGES: Map<string, SourceLanguage> = new Map([\n [\".js\", \"jsx\"],\n [\".jsx\", \"jsx\"],\n [\".mjs\", \"jsx\"],\n [\".mts\", \"ts\"],\n [\".ts\", \"ts\"],\n [\".tsx\", \"tsx\"],\n]);\n\nconst sourceLanguage = (path: string): SourceLanguage | undefined => {\n if (path.endsWith(\".d.ts\") || path.endsWith(\".d.mts\")) {\n return undefined;\n }\n\n return SOURCE_LANGUAGES.get(extname(path).toLowerCase());\n};\n\nconst discoverSourceFiles = (dir: string): string[] =>\n sortStringsBy(\n globSync(\"**/{*,.*}\", {\n cwd: dir,\n exclude: [\"**/{build,coverage,dist,node_modules,out-tsc}/**\"],\n withFileTypes: true,\n })\n .filter((entry) => entry.isFile())\n .map((entry) => join(entry.parentPath, entry.name))\n .filter((path) => sourceLanguage(path) !== undefined),\n (path) => path,\n );\n\nconst staticImportSources = (module: ParsedModule): string[] => [\n ...module.staticImports.map((statement) => statement.moduleRequest.value),\n ...module.staticExports.flatMap((statement) =>\n statement.entries\n .map((entry) => entry.moduleRequest?.value)\n .filter((source): source is string => source !== undefined),\n ),\n];\n\nconst staticRuntimeImportSources = (module: ParsedModule): string[] => [\n ...module.staticImports\n .filter((statement) => statement.entries.length === 0 || statement.entries.some((entry) => !entry.isType))\n .map((statement) => statement.moduleRequest.value),\n ...module.staticExports.flatMap((statement) =>\n statement.entries\n .filter((entry) => !entry.isType)\n .map((entry) => entry.moduleRequest?.value)\n .filter((source): source is string => source !== undefined),\n ),\n];\n\nconst templateImportSource = (node: ESTree.TemplateLiteral): string | null => {\n const [quasi] = node.quasis;\n\n return quasi === undefined || node.expressions.length > 0 ? null : quasi.value.cooked;\n};\n\nconst literalImportSource = (node: ESTree.Expression): string | null => {\n if (node.type === \"TemplateLiteral\") {\n return templateImportSource(node);\n }\n\n return node.type === \"Literal\" && typeof node.value === \"string\" ? node.value : null;\n};\n\nconst collectDynamicImportSources = (program: ESTree.Program, found: string[]): void => {\n new Visitor({\n ImportExpression: (node) => {\n const source = literalImportSource(node.source);\n\n if (source !== null) {\n found.push(source);\n }\n },\n }).visit(program);\n};\n\nconst parseImportsInWith = (\n path: string,\n staticSources: (module: ParsedModule) => string[],\n): SourceImport[] | null => {\n const lang = sourceLanguage(path);\n\n if (lang === undefined) {\n return [];\n }\n\n let parsed: ParseResult;\n\n try {\n parsed = parseSync(path, readFileSync(path, \"utf8\"), { lang });\n } catch {\n return null;\n }\n\n if (parsed.errors.length > 0) {\n return null;\n }\n\n const sources = staticSources(parsed.module);\n collectDynamicImportSources(parsed.program, sources);\n\n return [...new Set(sources)].map((source) => ({ importer: path, source }));\n};\n\nconst parseImportsIn = (path: string): SourceImport[] | null => parseImportsInWith(path, staticImportSources);\n\nconst parseRuntimeImportsIn = (path: string): SourceImport[] | null =>\n parseImportsInWith(path, staticRuntimeImportSources);\n\nconst importsIn = (path: string): SourceImport[] => parseImportsIn(path) ?? [];\nconst importKey = (entry: SourceImport): string => `${entry.importer}\\0${entry.source}`;\n\nconst discoverSourceImports = (dir: string): SourceImport[] => {\n const files = discoverSourceFiles(dir);\n const imports = files.flatMap((path) => importsIn(path));\n\n return sortStringsBy(imports, importKey);\n};\n\nexport { discoverSourceFiles, discoverSourceImports, parseRuntimeImportsIn, type SourceImport, sourceLanguage };\n"]}
1
+ {"version":3,"file":"source-imports.js","sourceRoot":"","sources":["../../src/internal/source-imports.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAU1C,MAAM,gBAAgB,GAAgC,IAAI,GAAG,CAAC;IAC1D,CAAC,KAAK,EAAE,KAAK,CAAC;IACd,CAAC,MAAM,EAAE,KAAK,CAAC;IACf,CAAC,MAAM,EAAE,KAAK,CAAC;IACf,CAAC,MAAM,EAAE,IAAI,CAAC;IACd,CAAC,KAAK,EAAE,IAAI,CAAC;IACb,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,OAAO,CAAC,CAAC;IAErD,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;AAC/E,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,CAAC,IAAY,EAAyB,EAAE,CAAC,kBAAkB,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC;AAE9G,MAAM,qBAAqB,GAAG,CAAC,IAAY,EAAyB,EAAE,CAClE,kBAAkB,CAAC,IAAI,EAAE,0BAA0B,CAAC,CAAC;AAEzD,MAAM,SAAS,GAAG,CAAC,IAAY,EAAkB,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;AAC/E,MAAM,SAAS,GAAG,CAAC,KAAmB,EAAU,EAAE,CAAC,GAAG,KAAK,CAAC,QAAQ,KAAK,KAAK,CAAC,MAAM,EAAE,CAAC;AAExF,MAAM,qBAAqB,GAAG,CAAC,GAAW,EAAkB,EAAE;IAC1D,MAAM,KAAK,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;IACvC,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;IAEzD,OAAO,aAAa,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;AAC7C,CAAC,CAAC;AAEF,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,qBAAqB,EAAqB,cAAc,EAAE,CAAC","sourcesContent":["import type { ESTree, ParseResult, ParserOptions } from \"vite\";\nimport { sortStringsBy } from \"@gtkx/utils\";\nimport { globSync, readFileSync } from \"node:fs\";\nimport { extname, join } from \"node:path\";\nimport { parseSync, Visitor } from \"vite\";\n\ntype SourceImport = {\n importer: string;\n source: string;\n};\n\ntype SourceLanguage = NonNullable<ParserOptions[\"lang\"]>;\ntype ParsedModule = ParseResult[\"module\"];\n\nconst SOURCE_LANGUAGES: Map<string, SourceLanguage> = new Map([\n [\".js\", \"jsx\"],\n [\".jsx\", \"jsx\"],\n [\".mjs\", \"jsx\"],\n [\".mts\", \"ts\"],\n [\".ts\", \"ts\"],\n [\".tsx\", \"tsx\"],\n]);\n\nconst sourceLanguage = (path: string): SourceLanguage | undefined => {\n if (path.endsWith(\".d.ts\") || path.endsWith(\".d.mts\")) {\n return undefined;\n }\n\n return SOURCE_LANGUAGES.get(extname(path).toLowerCase());\n};\n\nconst discoverSourceFiles = (dir: string): string[] =>\n sortStringsBy(\n globSync(\"**/{*,.*}\", {\n cwd: dir,\n exclude: [\"**/{build,coverage,dist,node_modules,out-tsc}/**\", \"**/.gtkx-output-*/**\"],\n withFileTypes: true,\n })\n .filter((entry) => entry.isFile())\n .map((entry) => join(entry.parentPath, entry.name))\n .filter((path) => sourceLanguage(path) !== undefined),\n (path) => path,\n );\n\nconst staticImportSources = (module: ParsedModule): string[] => [\n ...module.staticImports.map((statement) => statement.moduleRequest.value),\n ...module.staticExports.flatMap((statement) =>\n statement.entries\n .map((entry) => entry.moduleRequest?.value)\n .filter((source): source is string => source !== undefined),\n ),\n];\n\nconst staticRuntimeImportSources = (module: ParsedModule): string[] => [\n ...module.staticImports\n .filter((statement) => statement.entries.length === 0 || statement.entries.some((entry) => !entry.isType))\n .map((statement) => statement.moduleRequest.value),\n ...module.staticExports.flatMap((statement) =>\n statement.entries\n .filter((entry) => !entry.isType)\n .map((entry) => entry.moduleRequest?.value)\n .filter((source): source is string => source !== undefined),\n ),\n];\n\nconst templateImportSource = (node: ESTree.TemplateLiteral): string | null => {\n const [quasi] = node.quasis;\n\n return quasi === undefined || node.expressions.length > 0 ? null : quasi.value.cooked;\n};\n\nconst literalImportSource = (node: ESTree.Expression): string | null => {\n if (node.type === \"TemplateLiteral\") {\n return templateImportSource(node);\n }\n\n return node.type === \"Literal\" && typeof node.value === \"string\" ? node.value : null;\n};\n\nconst collectDynamicImportSources = (program: ESTree.Program, found: string[]): void => {\n new Visitor({\n ImportExpression: (node) => {\n const source = literalImportSource(node.source);\n\n if (source !== null) {\n found.push(source);\n }\n },\n }).visit(program);\n};\n\nconst parseImportsInWith = (\n path: string,\n staticSources: (module: ParsedModule) => string[],\n): SourceImport[] | null => {\n const lang = sourceLanguage(path);\n\n if (lang === undefined) {\n return [];\n }\n\n let parsed: ParseResult;\n\n try {\n parsed = parseSync(path, readFileSync(path, \"utf8\"), { lang });\n } catch {\n return null;\n }\n\n if (parsed.errors.length > 0) {\n return null;\n }\n\n const sources = staticSources(parsed.module);\n collectDynamicImportSources(parsed.program, sources);\n\n return [...new Set(sources)].map((source) => ({ importer: path, source }));\n};\n\nconst parseImportsIn = (path: string): SourceImport[] | null => parseImportsInWith(path, staticImportSources);\n\nconst parseRuntimeImportsIn = (path: string): SourceImport[] | null =>\n parseImportsInWith(path, staticRuntimeImportSources);\n\nconst importsIn = (path: string): SourceImport[] => parseImportsIn(path) ?? [];\nconst importKey = (entry: SourceImport): string => `${entry.importer}\\0${entry.source}`;\n\nconst discoverSourceImports = (dir: string): SourceImport[] => {\n const files = discoverSourceFiles(dir);\n const imports = files.flatMap((path) => importsIn(path));\n\n return sortStringsBy(imports, importKey);\n};\n\nexport { discoverSourceFiles, discoverSourceImports, parseRuntimeImportsIn, type SourceImport, sourceLanguage };\n"]}
@@ -1,6 +1,6 @@
1
1
  import * as Gio from "@gtkx/gi/gio";
2
2
  import * as Gtk from "@gtkx/gi/gtk";
3
- import { DEFAULT_SOCKET_PATH, isConnectionClosedError, ProtocolConnection, } from "@gtkx/mcp/internal";
3
+ import { isConnectionClosedError, ProtocolConnection, resolveMcpSocketPath, } from "@gtkx/mcp/internal";
4
4
  import { error, errorMessage, info, normalizeError } from "@gtkx/utils";
5
5
  import * as net from "node:net";
6
6
  import { dispatch } from "./handlers.js";
@@ -37,7 +37,7 @@ class McpClient {
37
37
  pendingConnectReject = null;
38
38
  registry = new WidgetRegistry();
39
39
  constructor(options) {
40
- this.socketPath = options.socketPath ?? DEFAULT_SOCKET_PATH;
40
+ this.socketPath = resolveMcpSocketPath(options.socketPath);
41
41
  this.applicationId = options.applicationId;
42
42
  }
43
43
  handleClose() {
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/mcp/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EACH,mBAAmB,EACnB,uBAAuB,EAEvB,kBAAkB,GAErB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAiBtD,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAChC,MAAM,mBAAmB,GAAG,MAAM,CAAC;AACnC,MAAM,sBAAsB,GAAgB,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC;AAEvG,MAAM,cAAc,GAAG,CAAC,SAA2B,EAAkB,EAAE;IACnE,IAAI,SAAS,GAAG,KAAK,CAAC;IAEtB,MAAM,MAAM,GAAG,CAAC,MAAkB,EAAQ,EAAE;QACxC,IAAI,SAAS,EAAE,CAAC;YACZ,OAAO;QACX,CAAC;QAED,SAAS,GAAG,IAAI,CAAC;QACjB,MAAM,EAAE,CAAC;IACb,CAAC,CAAC;IAEF,OAAO;QACH,OAAO,EAAE,GAAG,EAAE;YACV,MAAM,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QAC1C,CAAC;QACD,IAA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\n isConnectionClosedError,\n type JSONRPCRequest,\n ProtocolConnection,\n type Result,\n} from \"@gtkx/mcp/internal\";\nimport { error, errorMessage, info, normalizeError } from \"@gtkx/utils\";\nimport * as net from \"node:net\";\nimport { dispatch } from \"./handlers.js\";\nimport { WidgetRegistry } from \"./widget-registry.js\";\n\ntype McpClientOptions = {\n socketPath?: string;\n applicationId: string;\n};\n\ntype ConnectCallbacks = {\n onSuccess?: (() => void) | undefined;\n onError?: ((error: Error) => void) | undefined;\n};\n\ntype ConnectSettler = {\n succeed: () => void;\n fail: (error: Error) => void;\n};\n\nconst RECONNECT_DELAY_MS = 2000;\nconst REGISTER_TIMEOUT_MS = 30_000;\nconst DISCONNECT_ERROR_CODES: Set<string> = new Set([\"ENOENT\", \"ECONNREFUSED\", \"EPIPE\", \"ECONNRESET\"]);\n\nconst connectSettler = (callbacks: ConnectCallbacks): ConnectSettler => {\n let isSettled = false;\n\n const settle = (notify: () => void): void => {\n if (isSettled) {\n return;\n }\n\n isSettled = true;\n notify();\n };\n\n return {\n succeed: () => {\n settle(() => callbacks.onSuccess?.());\n },\n fail: (failure) => {\n settle(() => callbacks.onError?.(failure));\n },\n };\n};\n\nclass McpClient {\n private socket: net.Socket | null = null;\n private connection: ProtocolConnection | null = null;\n private socketPath: string;\n private applicationId: string;\n private reconnectTimer: NodeJS.Timeout | null = null;\n private hasConnected = false;\n private isStopping = false;\n private pendingConnectReject: ((error: Error) => void) | null = null;\n private registry = new WidgetRegistry();\n\n constructor(options: McpClientOptions) {\n this.socketPath = options.socketPath ?? DEFAULT_SOCKET_PATH;\n this.applicationId = options.applicationId;\n }\n\n private handleClose(): void {\n if (this.hasConnected) {\n info(\"Disconnected from MCP server\");\n this.hasConnected = false;\n }\n\n this.socket = null;\n this.connection = null;\n this.scheduleReconnect();\n }\n\n private handleSocketError(socketError: Error): void {\n const code = (socketError as NodeJS.ErrnoException).code;\n\n if (isConnectionClosedError(socketError) || (code !== undefined && DISCONNECT_ERROR_CODES.has(code))) {\n this.scheduleReconnect();\n } else {\n error(\"Socket error:\", socketError.message);\n }\n }\n\n private async registerWithServer(settle: ConnectSettler): Promise<void> {\n try {\n await this.register();\n info(\"Registered with MCP server\");\n settle.succeed();\n } catch (registerError) {\n error(\"Failed to register with MCP server:\", errorMessage(registerError));\n settle.fail(normalizeError(registerError));\n }\n }\n\n private attemptConnect(callbacks: ConnectCallbacks = {}): void {\n const settle = connectSettler(callbacks);\n\n const socket = net.createConnection(this.socketPath, () => {\n info(`Connected to MCP server at ${this.socketPath}`);\n this.hasConnected = true;\n void this.registerWithServer(settle);\n });\n\n const connection = ProtocolConnection.fromSocket(socket, {\n onClose: () => {\n this.handleClose();\n },\n onError: (socketError) => {\n this.handleSocketError(socketError);\n settle.fail(socketError);\n },\n });\n\n connection.fallbackRequestHandler = (request) => this.handleRequest(request);\n this.socket = socket;\n this.connection = connection;\n }\n\n private scheduleReconnect(): void {\n if (this.reconnectTimer || this.isStopping) {\n return;\n }\n\n this.reconnectTimer = setTimeout(() => {\n this.reconnectTimer = null;\n this.attemptConnect();\n }, RECONNECT_DELAY_MS);\n }\n\n private register(): Promise<unknown> {\n if (!this.connection) {\n return Promise.reject(new Error(\"Connection not initialized\"));\n }\n\n return this.connection.send(\n \"app.register\",\n {\n applicationId: this.applicationId,\n pid: process.pid,\n projectRoot: process.cwd(),\n },\n REGISTER_TIMEOUT_MS,\n );\n }\n\n private handleRequest(request: JSONRPCRequest): Promise<Result> {\n const defaultApp = Gio.Application.getDefault();\n\n if (!(defaultApp instanceof Gtk.Application)) {\n throw new TypeError(\"Application not initialized\");\n }\n\n this.registry.refresh();\n\n return dispatch(request.method, request.params, { app: defaultApp, registry: this.registry });\n }\n\n async connect(): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n this.pendingConnectReject = reject;\n\n this.attemptConnect({\n onSuccess: () => {\n this.pendingConnectReject = null;\n resolve();\n },\n onError: (connectError) => {\n this.pendingConnectReject = null;\n reject(connectError);\n },\n });\n });\n }\n\n disconnect(): void {\n this.isStopping = true;\n\n if (this.pendingConnectReject) {\n this.pendingConnectReject(new Error(\"Client disconnected before connection registered\"));\n this.pendingConnectReject = null;\n }\n\n if (this.reconnectTimer) {\n clearTimeout(this.reconnectTimer);\n this.reconnectTimer = null;\n }\n\n if (this.socket) {\n void Promise.allSettled([this.connection?.send(\"app.unregister\")]);\n this.socket.destroy();\n this.socket = null;\n }\n\n this.connection = null;\n this.hasConnected = false;\n }\n}\n\nexport { McpClient };\n"]}
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/mcp/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EACH,uBAAuB,EAEvB,kBAAkB,EAClB,oBAAoB,GAEvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAiBtD,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAChC,MAAM,mBAAmB,GAAG,MAAM,CAAC;AACnC,MAAM,sBAAsB,GAAgB,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC;AAEvG,MAAM,cAAc,GAAG,CAAC,SAA2B,EAAkB,EAAE;IACnE,IAAI,SAAS,GAAG,KAAK,CAAC;IAEtB,MAAM,MAAM,GAAG,CAAC,MAAkB,EAAQ,EAAE;QACxC,IAAI,SAAS,EAAE,CAAC;YACZ,OAAO;QACX,CAAC;QAED,SAAS,GAAG,IAAI,CAAC;QACjB,MAAM,EAAE,CAAC;IACb,CAAC,CAAC;IAEF,OAAO;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;AAED,OAAO,EAAE,SAAS,EAAE,CAAC","sourcesContent":["import * as Gio from \"@gtkx/gi/gio\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport {\n isConnectionClosedError,\n type JSONRPCRequest,\n ProtocolConnection,\n resolveMcpSocketPath,\n type Result,\n} from \"@gtkx/mcp/internal\";\nimport { error, errorMessage, info, normalizeError } from \"@gtkx/utils\";\nimport * as net from \"node:net\";\nimport { dispatch } from \"./handlers.js\";\nimport { WidgetRegistry } from \"./widget-registry.js\";\n\ntype McpClientOptions = {\n socketPath?: string;\n applicationId: string;\n};\n\ntype ConnectCallbacks = {\n onSuccess?: (() => void) | undefined;\n onError?: ((error: Error) => void) | undefined;\n};\n\ntype ConnectSettler = {\n succeed: () => void;\n fail: (error: Error) => void;\n};\n\nconst RECONNECT_DELAY_MS = 2000;\nconst REGISTER_TIMEOUT_MS = 30_000;\nconst DISCONNECT_ERROR_CODES: Set<string> = new Set([\"ENOENT\", \"ECONNREFUSED\", \"EPIPE\", \"ECONNRESET\"]);\n\nconst connectSettler = (callbacks: ConnectCallbacks): ConnectSettler => {\n let isSettled = false;\n\n const settle = (notify: () => void): void => {\n if (isSettled) {\n return;\n }\n\n isSettled = true;\n notify();\n };\n\n return {\n succeed: () => {\n settle(() => callbacks.onSuccess?.());\n },\n fail: (failure) => {\n settle(() => callbacks.onError?.(failure));\n },\n };\n};\n\nclass McpClient {\n private socket: net.Socket | null = null;\n private connection: ProtocolConnection | null = null;\n private socketPath: string;\n private applicationId: string;\n private reconnectTimer: NodeJS.Timeout | null = null;\n private hasConnected = false;\n private isStopping = false;\n private pendingConnectReject: ((error: Error) => void) | null = null;\n private registry = new WidgetRegistry();\n\n constructor(options: McpClientOptions) {\n this.socketPath = resolveMcpSocketPath(options.socketPath);\n this.applicationId = options.applicationId;\n }\n\n private handleClose(): void {\n if (this.hasConnected) {\n info(\"Disconnected from MCP server\");\n this.hasConnected = false;\n }\n\n this.socket = null;\n this.connection = null;\n this.scheduleReconnect();\n }\n\n private handleSocketError(socketError: Error): void {\n const code = (socketError as NodeJS.ErrnoException).code;\n\n if (isConnectionClosedError(socketError) || (code !== undefined && DISCONNECT_ERROR_CODES.has(code))) {\n this.scheduleReconnect();\n } else {\n error(\"Socket error:\", socketError.message);\n }\n }\n\n private async registerWithServer(settle: ConnectSettler): Promise<void> {\n try {\n await this.register();\n info(\"Registered with MCP server\");\n settle.succeed();\n } catch (registerError) {\n error(\"Failed to register with MCP server:\", errorMessage(registerError));\n settle.fail(normalizeError(registerError));\n }\n }\n\n private attemptConnect(callbacks: ConnectCallbacks = {}): void {\n const settle = connectSettler(callbacks);\n\n const socket = net.createConnection(this.socketPath, () => {\n info(`Connected to MCP server at ${this.socketPath}`);\n this.hasConnected = true;\n void this.registerWithServer(settle);\n });\n\n const connection = ProtocolConnection.fromSocket(socket, {\n onClose: () => {\n this.handleClose();\n },\n onError: (socketError) => {\n this.handleSocketError(socketError);\n settle.fail(socketError);\n },\n });\n\n connection.fallbackRequestHandler = (request) => this.handleRequest(request);\n this.socket = socket;\n this.connection = connection;\n }\n\n private scheduleReconnect(): void {\n if (this.reconnectTimer || this.isStopping) {\n return;\n }\n\n this.reconnectTimer = setTimeout(() => {\n this.reconnectTimer = null;\n this.attemptConnect();\n }, RECONNECT_DELAY_MS);\n }\n\n private register(): Promise<unknown> {\n if (!this.connection) {\n return Promise.reject(new Error(\"Connection not initialized\"));\n }\n\n return this.connection.send(\n \"app.register\",\n {\n applicationId: this.applicationId,\n pid: process.pid,\n projectRoot: process.cwd(),\n },\n REGISTER_TIMEOUT_MS,\n );\n }\n\n private handleRequest(request: JSONRPCRequest): Promise<Result> {\n const defaultApp = Gio.Application.getDefault();\n\n if (!(defaultApp instanceof Gtk.Application)) {\n throw new TypeError(\"Application not initialized\");\n }\n\n this.registry.refresh();\n\n return dispatch(request.method, request.params, { app: defaultApp, registry: this.registry });\n }\n\n async connect(): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n this.pendingConnectReject = reject;\n\n this.attemptConnect({\n onSuccess: () => {\n this.pendingConnectReject = null;\n resolve();\n },\n onError: (connectError) => {\n this.pendingConnectReject = null;\n reject(connectError);\n },\n });\n });\n }\n\n disconnect(): void {\n this.isStopping = true;\n\n if (this.pendingConnectReject) {\n this.pendingConnectReject(new Error(\"Client disconnected before connection registered\"));\n this.pendingConnectReject = null;\n }\n\n if (this.reconnectTimer) {\n clearTimeout(this.reconnectTimer);\n this.reconnectTimer = null;\n }\n\n if (this.socket) {\n void Promise.allSettled([this.connection?.send(\"app.unregister\")]);\n this.socket.destroy();\n this.socket = null;\n }\n\n this.connection = null;\n this.hasConnected = false;\n }\n}\n\nexport { McpClient };\n"]}
@@ -1,5 +1,9 @@
1
1
  import type { Plugin } from "vite";
2
2
  import { type BuildManifestCollector } from "../internal/build-manifest.js";
3
- declare function gtkxBuildManifest(root: string, collector: BuildManifestCollector): Plugin;
3
+ type BuildConfigIdentity = {
4
+ configFile: string;
5
+ configDigest: string;
6
+ };
7
+ declare function gtkxBuildManifest(root: string, collector: BuildManifestCollector, identity: BuildConfigIdentity): Plugin;
4
8
  export { gtkxBuildManifest };
5
9
  //# sourceMappingURL=build-manifest.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"build-manifest.d.ts","sourceRoot":"","sources":["../../src/vite-plugins/build-manifest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAInC,OAAO,EAKH,KAAK,sBAAsB,EAE9B,MAAM,+BAA+B,CAAC;AAgEvC,iBAAS,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,sBAAsB,GAAG,MAAM,CA4BlF;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
1
+ {"version":3,"file":"build-manifest.d.ts","sourceRoot":"","sources":["../../src/vite-plugins/build-manifest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAInC,OAAO,EAKH,KAAK,sBAAsB,EAE9B,MAAM,+BAA+B,CAAC;AAYvC,KAAK,mBAAmB,GAAG;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;CACxB,CAAC;AAsDF,iBAAS,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,sBAAsB,EAAE,QAAQ,EAAE,mBAAmB,GAAG,MAAM,CA6BjH;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
@@ -41,7 +41,7 @@ const packagesFor = (outDir, ids) => {
41
41
  return sortStringsBy(unique.values(), packageKey).map((entry) => relativeTo(outDir, entry));
42
42
  };
43
43
  const renderManifest = (manifest) => `${JSON.stringify(manifest, null, JSON_INDENT)}\n`;
44
- function gtkxBuildManifest(root, collector) {
44
+ function gtkxBuildManifest(root, collector, identity) {
45
45
  const state = { outDir: join(root, DEFAULT_OUT_DIR) };
46
46
  return {
47
47
  name: "gtkx:build-manifest",
@@ -54,6 +54,7 @@ function gtkxBuildManifest(root, collector) {
54
54
  const manifest = {
55
55
  generator: BUILD_MANIFEST_GENERATOR,
56
56
  formatVersion: BUILD_MANIFEST_FORMAT_VERSION,
57
+ ...identity,
57
58
  schemas: collector.schemas,
58
59
  packages: packagesFor(state.outDir, ids),
59
60
  };
@@ -1 +1 @@
1
- {"version":3,"file":"build-manifest.js","sourceRoot":"","sources":["../../src/vite-plugins/build-manifest.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EACH,uBAAuB,EACvB,6BAA6B,EAC7B,wBAAwB,GAI3B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAW9C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E,MAAM,EAAE,IAAI,CAAC,IAAI,EAAE,eAAe,CAAC,EAAE,CAAC;IAErE,OAAO;QACH,IAAI,EAAE,qBAAqB;QAC3B,KAAK,EAAE,OAAO;QAEd,cAAc,CAAC,MAAM;YACjB,KAAK,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC7D,CAAC;QAED,cAAc,CAAC,QAAQ,EAAE,MAAM;YAC3B,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YAEzG,MAAM,QAAQ,GAAkB;gBAC5B,SAAS,EAAE,wBAAwB;gBACnC,aAAa,EAAE,6BAA6B;gBAC5C,OAAO,EAAE,SAAS,CAAC,OAAO;gBAC1B,QAAQ,EAAE,WAAW,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC;aAC3C,CAAC;YAEF,IAAI,CAAC,QAAQ,CAAC;gBACV,IAAI,EAAE,OAAO;gBACb,QAAQ,EAAE,uBAAuB;gBACjC,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC;aACnC,CAAC,CAAC;QACP,CAAC;KACJ,CAAC;AACN,CAAC;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC","sourcesContent":["import type { Plugin } from \"vite\";\nimport { isRecord, sortStringsBy } from \"@gtkx/utils\";\nimport { readFileSync } from \"node:fs\";\nimport { dirname, join, relative, resolve } from \"node:path\";\nimport {\n BUILD_MANIFEST_FILENAME,\n BUILD_MANIFEST_FORMAT_VERSION,\n BUILD_MANIFEST_GENERATOR,\n type BuildManifest,\n type BuildManifestCollector,\n type RecordedPackage,\n} from \"../internal/build-manifest.js\";\nimport { stripQuery } from \"./strip-query.js\";\n\ntype PackageIdentity = {\n name: string;\n version: string | null;\n};\n\ntype ManifestState = {\n outDir: string;\n};\n\nconst PACKAGE_MANIFEST_FILENAME = \"package.json\";\nconst DEFAULT_OUT_DIR = \"dist\";\nconst JSON_INDENT = 4;\n\nconst identityIn = (dir: string): PackageIdentity | null => {\n try {\n const parsed: unknown = JSON.parse(readFileSync(join(dir, PACKAGE_MANIFEST_FILENAME), \"utf8\"));\n\n if (!isRecord(parsed) || typeof parsed.name !== \"string\") {\n return null;\n }\n\n return { name: parsed.name, version: typeof parsed.version === \"string\" ? parsed.version : null };\n } catch {\n return null;\n }\n};\n\nconst packageIn = (dir: string): RecordedPackage | null => {\n const identity = identityIn(dir);\n\n if (identity !== null) {\n return { ...identity, dir };\n }\n\n const parent = dirname(dir);\n\n return parent === dir ? null : packageIn(parent);\n};\n\nconst packageForModule = (id: string): RecordedPackage | null => {\n const path = stripQuery(id);\n\n return path.startsWith(\"/\") ? packageIn(dirname(path)) : null;\n};\n\nconst packageKey = (entry: RecordedPackage): string => `${entry.name}@${entry.version ?? \"\"}`;\n\nconst relativeTo = (outDir: string, entry: RecordedPackage): RecordedPackage => ({\n ...entry,\n dir: relative(outDir, entry.dir),\n});\n\nconst packagesFor = (outDir: string, ids: string[]): RecordedPackage[] => {\n const found = ids.map((id) => packageForModule(id)).filter((entry) => entry !== null);\n const unique: Map<string, RecordedPackage> = new Map(found.map((entry) => [packageKey(entry), entry]));\n\n return sortStringsBy(unique.values(), packageKey).map((entry) => relativeTo(outDir, entry));\n};\n\nconst renderManifest = (manifest: BuildManifest): string => `${JSON.stringify(manifest, null, JSON_INDENT)}\\n`;\n\nfunction gtkxBuildManifest(root: string, collector: BuildManifestCollector): Plugin {\n const state: ManifestState = { outDir: join(root, DEFAULT_OUT_DIR) };\n\n return {\n name: \"gtkx:build-manifest\",\n apply: \"build\",\n\n configResolved(config) {\n state.outDir = resolve(config.root, config.build.outDir);\n },\n\n generateBundle(_options, bundle) {\n const ids = Object.values(bundle).flatMap((output) => (output.type === \"chunk\" ? output.moduleIds : []));\n\n const manifest: BuildManifest = {\n generator: BUILD_MANIFEST_GENERATOR,\n formatVersion: BUILD_MANIFEST_FORMAT_VERSION,\n schemas: collector.schemas,\n packages: packagesFor(state.outDir, ids),\n };\n\n this.emitFile({\n type: \"asset\",\n fileName: BUILD_MANIFEST_FILENAME,\n source: renderManifest(manifest),\n });\n },\n };\n}\n\nexport { gtkxBuildManifest };\n"]}
1
+ {"version":3,"file":"build-manifest.js","sourceRoot":"","sources":["../../src/vite-plugins/build-manifest.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EACH,uBAAuB,EACvB,6BAA6B,EAC7B,wBAAwB,GAI3B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAgB9C,MAAM,yBAAyB,GAAG,cAAc,CAAC;AACjD,MAAM,eAAe,GAAG,MAAM,CAAC;AAC/B,MAAM,WAAW,GAAG,CAAC,CAAC;AAEtB,MAAM,UAAU,GAAG,CAAC,GAAW,EAA0B,EAAE;IACvD,IAAI,CAAC;QACD,MAAM,MAAM,GAAY,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,EAAE,yBAAyB,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;QAE/F,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACvD,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,MAAM,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AC,EAAE,CAAC,CAAC,CAAC;YAEzG,MAAM,QAAQ,GAAkB;gBAC5B,SAAS,EAAE,wBAAwB;gBACnC,aAAa,EAAE,6BAA6B;gBAC5C,GAAG,QAAQ;gBACX,OAAO,EAAE,SAAS,CAAC,OAAO;gBAC1B,QAAQ,EAAE,WAAW,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC;aAC3C,CAAC;YAEF,IAAI,CAAC,QAAQ,CAAC;gBACV,IAAI,EAAE,OAAO;gBACb,QAAQ,EAAE,uBAAuB;gBACjC,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC;aACnC,CAAC,CAAC;QACP,CAAC;KACJ,CAAC;AACN,CAAC;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC","sourcesContent":["import type { Plugin } from \"vite\";\nimport { isRecord, sortStringsBy } from \"@gtkx/utils\";\nimport { readFileSync } from \"node:fs\";\nimport { dirname, join, relative, resolve } from \"node:path\";\nimport {\n BUILD_MANIFEST_FILENAME,\n BUILD_MANIFEST_FORMAT_VERSION,\n BUILD_MANIFEST_GENERATOR,\n type BuildManifest,\n type BuildManifestCollector,\n type RecordedPackage,\n} from \"../internal/build-manifest.js\";\nimport { stripQuery } from \"./strip-query.js\";\n\ntype PackageIdentity = {\n name: string;\n version: string | null;\n};\n\ntype ManifestState = {\n outDir: string;\n};\n\ntype BuildConfigIdentity = {\n configFile: string;\n configDigest: string;\n};\n\nconst PACKAGE_MANIFEST_FILENAME = \"package.json\";\nconst DEFAULT_OUT_DIR = \"dist\";\nconst JSON_INDENT = 4;\n\nconst identityIn = (dir: string): PackageIdentity | null => {\n try {\n const parsed: unknown = JSON.parse(readFileSync(join(dir, PACKAGE_MANIFEST_FILENAME), \"utf8\"));\n\n if (!isRecord(parsed) || typeof parsed.name !== \"string\") {\n return null;\n }\n\n return { name: parsed.name, version: typeof parsed.version === \"string\" ? parsed.version : null };\n } catch {\n return null;\n }\n};\n\nconst packageIn = (dir: string): RecordedPackage | null => {\n const identity = identityIn(dir);\n\n if (identity !== null) {\n return { ...identity, dir };\n }\n\n const parent = dirname(dir);\n\n return parent === dir ? null : packageIn(parent);\n};\n\nconst packageForModule = (id: string): RecordedPackage | null => {\n const path = stripQuery(id);\n\n return path.startsWith(\"/\") ? packageIn(dirname(path)) : null;\n};\n\nconst packageKey = (entry: RecordedPackage): string => `${entry.name}@${entry.version ?? \"\"}`;\n\nconst relativeTo = (outDir: string, entry: RecordedPackage): RecordedPackage => ({\n ...entry,\n dir: relative(outDir, entry.dir),\n});\n\nconst packagesFor = (outDir: string, ids: string[]): RecordedPackage[] => {\n const found = ids.map((id) => packageForModule(id)).filter((entry) => entry !== null);\n const unique: Map<string, RecordedPackage> = new Map(found.map((entry) => [packageKey(entry), entry]));\n\n return sortStringsBy(unique.values(), packageKey).map((entry) => relativeTo(outDir, entry));\n};\n\nconst renderManifest = (manifest: BuildManifest): string => `${JSON.stringify(manifest, null, JSON_INDENT)}\\n`;\n\nfunction gtkxBuildManifest(root: string, collector: BuildManifestCollector, identity: BuildConfigIdentity): Plugin {\n const state: ManifestState = { outDir: join(root, DEFAULT_OUT_DIR) };\n\n return {\n name: \"gtkx:build-manifest\",\n apply: \"build\",\n\n configResolved(config) {\n state.outDir = resolve(config.root, config.build.outDir);\n },\n\n generateBundle(_options, bundle) {\n const ids = Object.values(bundle).flatMap((output) => (output.type === \"chunk\" ? output.moduleIds : []));\n\n const manifest: BuildManifest = {\n generator: BUILD_MANIFEST_GENERATOR,\n formatVersion: BUILD_MANIFEST_FORMAT_VERSION,\n ...identity,\n schemas: collector.schemas,\n packages: packagesFor(state.outDir, ids),\n };\n\n this.emitFile({\n type: \"asset\",\n fileName: BUILD_MANIFEST_FILENAME,\n source: renderManifest(manifest),\n });\n },\n };\n}\n\nexport { gtkxBuildManifest };\n"]}
@@ -1,4 +1,4 @@
1
1
  import type { Plugin } from "vite";
2
- declare const gtkxEnsureStore: () => Plugin;
2
+ declare const gtkxEnsureStore: (configFile?: string) => Plugin;
3
3
  export { gtkxEnsureStore };
4
4
  //# sourceMappingURL=ensure-store.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ensure-store.d.ts","sourceRoot":"","sources":["../../src/vite-plugins/ensure-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAKnC,QAAA,MAAM,eAAe,QAAO,MAM1B,CAAC;AAEH,OAAO,EAAE,eAAe,EAAE,CAAC"}
1
+ {"version":3,"file":"ensure-store.d.ts","sourceRoot":"","sources":["../../src/vite-plugins/ensure-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAKnC,QAAA,MAAM,eAAe,GAAI,aAAa,MAAM,KAAG,MAM7C,CAAC;AAEH,OAAO,EAAE,eAAe,EAAE,CAAC"}
@@ -1,9 +1,9 @@
1
1
  import { ensureGenerated } from "../codegen/run-codegen.js";
2
2
  const TEST_MODE = "test";
3
- const gtkxEnsureStore = () => ({
3
+ const gtkxEnsureStore = (configFile) => ({
4
4
  name: "gtkx:ensure-store",
5
5
  async config() {
6
- await ensureGenerated(process.cwd(), { shouldAnnounce: true, mode: TEST_MODE });
6
+ await ensureGenerated(process.cwd(), { shouldAnnounce: true, mode: TEST_MODE, configFile });
7
7
  },
8
8
  });
9
9
  export { gtkxEnsureStore };
@@ -1 +1 @@
1
- {"version":3,"file":"ensure-store.js","sourceRoot":"","sources":["../../src/vite-plugins/ensure-store.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE5D,MAAM,SAAS,GAAG,MAAM,CAAC;AAEzB,MAAM,eAAe,GAAG,GAAW,EAAE,CAAC,CAAC;IACnC,IAAI,EAAE,mBAAmB;IAEzB,KAAK,CAAC,MAAM;QACR,MAAM,eAAe,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;IACpF,CAAC;CACJ,CAAC,CAAC;AAEH,OAAO,EAAE,eAAe,EAAE,CAAC","sourcesContent":["import type { Plugin } from \"vite\";\nimport { ensureGenerated } from \"../codegen/run-codegen.js\";\n\nconst TEST_MODE = \"test\";\n\nconst gtkxEnsureStore = (): Plugin => ({\n name: \"gtkx:ensure-store\",\n\n async config() {\n await ensureGenerated(process.cwd(), { shouldAnnounce: true, mode: TEST_MODE });\n },\n});\n\nexport { gtkxEnsureStore };\n"]}
1
+ {"version":3,"file":"ensure-store.js","sourceRoot":"","sources":["../../src/vite-plugins/ensure-store.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE5D,MAAM,SAAS,GAAG,MAAM,CAAC;AAEzB,MAAM,eAAe,GAAG,CAAC,UAAmB,EAAU,EAAE,CAAC,CAAC;IACtD,IAAI,EAAE,mBAAmB;IAEzB,KAAK,CAAC,MAAM;QACR,MAAM,eAAe,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC,CAAC;IAChG,CAAC;CACJ,CAAC,CAAC;AAEH,OAAO,EAAE,eAAe,EAAE,CAAC","sourcesContent":["import type { Plugin } from \"vite\";\nimport { ensureGenerated } from \"../codegen/run-codegen.js\";\n\nconst TEST_MODE = \"test\";\n\nconst gtkxEnsureStore = (configFile?: string): Plugin => ({\n name: \"gtkx:ensure-store\",\n\n async config() {\n await ensureGenerated(process.cwd(), { shouldAnnounce: true, mode: TEST_MODE, configFile });\n },\n});\n\nexport { gtkxEnsureStore };\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/vite-plugins/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,MAAM,EAAkB,MAAM,MAAM,CAAC;AA4GnD,QAAA,MAAM,QAAQ,GACV,WAAW,MAAM,EACjB,aAAY,YAAmC,EAC/C,wCAAqC,KACtC,MA+BF,CAAC;AAEF,OAAO,EAAE,QAAQ,EAAE,CAAC"}
1
+ {"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../src/vite-plugins/i18n.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,MAAM,EAAkB,MAAM,MAAM,CAAC;AAyKnD,QAAA,MAAM,QAAQ,GACV,WAAW,MAAM,EACjB,aAAY,YAAmC,EAC/C,wCAAqC,KACtC,MAgDF,CAAC;AAEF,OAAO,EAAE,QAAQ,EAAE,CAAC"}
@@ -1,11 +1,12 @@
1
1
  import { createConfigLoader } from "@gtkx/config/internal";
2
- import { toPosixPath } from "@gtkx/utils";
2
+ import { isPathWithin, logger, toPosixPath } from "@gtkx/utils";
3
3
  import { existsSync, mkdirSync } from "node:fs";
4
4
  import { createRequire } from "node:module";
5
5
  import { dirname, join, posix, relative, resolve } from "node:path";
6
6
  import { compileCatalogs, LOCALE_DIRNAME, resolveCatalogProject, synchronizeCatalogs, } from "../i18n/catalogs.js";
7
7
  import { extractSourceCatalog } from "../i18n/source-messages.js";
8
- import { discoverSourceFiles } from "../internal/source-imports.js";
8
+ import { emitI18nTypes } from "../i18n/types.js";
9
+ import { discoverSourceFiles, sourceLanguage } from "../internal/source-imports.js";
9
10
  import { stripQuery } from "./strip-query.js";
10
11
  const BOOTSTRAP_SPECIFIER = "@gtkx/i18n/bootstrap";
11
12
  const LOCALE_URL_PLACEHOLDER = "__GTKX_BUNDLE_LOCALE_DIR__";
@@ -51,7 +52,7 @@ const buildCatalogs = (state) => {
51
52
  mkdirSync(state.outDir, { recursive: true });
52
53
  compileCatalogs(project, resolve(state.outDir, LOCALE_DIRNAME));
53
54
  };
54
- const extractProjectMessages = async (state, shouldPreserveMetadataMessages) => {
55
+ const extractProjectMessages = async (state, shouldPreserveMetadataMessages, shouldSynchronizeCatalogs) => {
55
56
  const project = state.project;
56
57
  if (project === null) {
57
58
  return;
@@ -59,15 +60,66 @@ const extractProjectMessages = async (state, shouldPreserveMetadataMessages) =>
59
60
  const srcDir = join(project.root, "src");
60
61
  const sourceFiles = discoverSourceFiles(existsSync(srcDir) ? srcDir : project.root);
61
62
  await extractSourceCatalog(project, sourceFiles, shouldPreserveMetadataMessages);
62
- synchronizeCatalogs(project);
63
+ if (shouldSynchronizeCatalogs) {
64
+ synchronizeCatalogs(project);
65
+ }
66
+ await emitI18nTypes(project.root);
67
+ };
68
+ const settleExtraction = async (pending) => {
69
+ try {
70
+ await pending;
71
+ }
72
+ catch {
73
+ return;
74
+ }
75
+ };
76
+ const queueExtraction = (state, shouldPreserveMetadataMessages, shouldSynchronizeCatalogs) => {
77
+ const prior = state.extraction;
78
+ const pending = (async () => {
79
+ await settleExtraction(prior);
80
+ await extractProjectMessages(state, shouldPreserveMetadataMessages, shouldSynchronizeCatalogs);
81
+ })();
82
+ state.extraction = pending;
83
+ return pending;
84
+ };
85
+ const isProjectSource = (state, path) => {
86
+ const project = state.project;
87
+ if (project === null || sourceLanguage(path) === undefined) {
88
+ return false;
89
+ }
90
+ const srcDir = join(project.root, "src");
91
+ const sourceRoot = existsSync(srcDir) ? srcDir : project.root;
92
+ return isPathWithin(sourceRoot, path);
93
+ };
94
+ const refreshProjectMessages = async (state, shouldPreserveMetadataMessages) => {
95
+ try {
96
+ await queueExtraction(state, shouldPreserveMetadataMessages, false);
97
+ }
98
+ catch (error) {
99
+ logger.error(error instanceof Error ? error.message : String(error));
100
+ }
63
101
  };
64
102
  const gtkxI18n = (entryPath, loadConfig = createConfigLoader(), shouldPreserveMetadataMessages = true) => {
65
- const state = { entryPath, i18nRoot: "", outDir: "", project: null };
103
+ const state = {
104
+ entryPath,
105
+ extraction: Promise.resolve(),
106
+ hotUpdateTimestamp: null,
107
+ i18nRoot: "",
108
+ outDir: "",
109
+ project: null,
110
+ };
66
111
  return {
67
112
  name: "gtkx:i18n",
68
113
  enforce: "pre",
69
114
  configResolved: (config) => applyResolvedConfig(state, config, loadConfig),
70
- buildStart: () => extractProjectMessages(state, shouldPreserveMetadataMessages),
115
+ buildStart: () => queueExtraction(state, shouldPreserveMetadataMessages, true),
116
+ hotUpdate(options) {
117
+ if (!isProjectSource(state, options.file) || state.hotUpdateTimestamp === options.timestamp) {
118
+ return;
119
+ }
120
+ state.hotUpdateTimestamp = options.timestamp;
121
+ return refreshProjectMessages(state, shouldPreserveMetadataMessages);
122
+ },
71
123
  transform(code, id) {
72
124
  if (isI18nLocaleModule(state, id)) {
73
125
  return markLocaleUrl(code);