@ykdz/template 0.1.0-experimental.0 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (817) hide show
  1. package/dist/application.d.ts +18 -48
  2. package/dist/application.js +164 -111
  3. package/dist/input-schemas.d.ts +0 -14
  4. package/dist/input-schemas.js +0 -11
  5. package/dist/input-validation.js +3 -30
  6. package/dist/main.js +79 -180
  7. package/dist/preset-catalog.d.ts +410 -29
  8. package/dist/preset-catalog.js +4 -30
  9. package/dist/result-schemas.d.ts +64 -65
  10. package/dist/result-schemas.js +8 -8
  11. package/node_modules/@ykdz/default-content-authoring/dist/contracts.d.ts +240 -0
  12. package/node_modules/@ykdz/default-content-authoring/dist/environment-needs.d.ts +16 -0
  13. package/node_modules/@ykdz/default-content-authoring/dist/preset-root-contribution.d.ts +36 -0
  14. package/node_modules/@ykdz/default-content-authoring/dist/preset-root-contribution.js +1 -0
  15. package/node_modules/@ykdz/default-content-authoring/dist/reference-package.d.ts +65 -0
  16. package/node_modules/@ykdz/default-content-authoring/dist/reference-package.js +742 -0
  17. package/node_modules/@ykdz/default-content-authoring/package.json +59 -0
  18. package/node_modules/@ykdz/preset-rust-bin/native/package.json +2 -0
  19. package/node_modules/@ykdz/preset-rust-bin/native/template-dist/definition.d.ts +2 -40
  20. package/node_modules/@ykdz/preset-rust-bin/native/template-dist/definition.d.ts.map +1 -1
  21. package/node_modules/@ykdz/preset-rust-bin/native/template-dist/definition.js +3 -2
  22. package/node_modules/@ykdz/preset-ts-cli/native/package.json +4 -0
  23. package/node_modules/@ykdz/preset-ts-cli/native/template-dist/definition.d.ts +2 -15
  24. package/node_modules/@ykdz/preset-ts-cli/native/template-dist/definition.d.ts.map +1 -1
  25. package/node_modules/@ykdz/preset-ts-lib/native/package.json +3 -0
  26. package/node_modules/@ykdz/preset-ts-lib/native/template-dist/definition.d.ts +2 -15
  27. package/node_modules/@ykdz/preset-ts-lib/native/template-dist/definition.d.ts.map +1 -1
  28. package/node_modules/@ykdz/preset-vike-app/native/package.json +3 -0
  29. package/node_modules/@ykdz/preset-vike-app/native/template-dist/definition.d.ts +40 -23
  30. package/node_modules/@ykdz/preset-vike-app/native/template-dist/definition.d.ts.map +1 -1
  31. package/node_modules/@ykdz/preset-vike-app/native/template-dist/definition.js +19 -36
  32. package/node_modules/@ykdz/preset-vike-app/native/template-dist/deployment.d.ts +54 -17
  33. package/node_modules/@ykdz/preset-vike-app/native/template-dist/deployment.d.ts.map +1 -1
  34. package/node_modules/@ykdz/preset-vike-app/native/template-dist/deployment.js +393 -207
  35. package/node_modules/@ykdz/preset-vike-app/package.json +2 -1
  36. package/node_modules/@ykdz/preset-vue-app/native/package.json +2 -0
  37. package/node_modules/@ykdz/preset-vue-app/native/template-dist/definition.d.ts +2 -15
  38. package/node_modules/@ykdz/preset-vue-app/native/template-dist/definition.d.ts.map +1 -1
  39. package/node_modules/@ykdz/preset-vue-hono-app/native/package.json +4 -0
  40. package/node_modules/@ykdz/preset-vue-hono-app/native/template-dist/definition.d.ts +49 -23
  41. package/node_modules/@ykdz/preset-vue-hono-app/native/template-dist/definition.d.ts.map +1 -1
  42. package/node_modules/@ykdz/preset-vue-hono-app/native/template-dist/definition.js +31 -102
  43. package/node_modules/@ykdz/preset-vue-hono-app/native/template-dist/joint-e2e.d.ts +42 -0
  44. package/node_modules/@ykdz/preset-vue-hono-app/native/template-dist/joint-e2e.d.ts.map +1 -0
  45. package/node_modules/@ykdz/preset-vue-hono-app/native/template-dist/joint-e2e.js +173 -0
  46. package/node_modules/@ykdz/reference-hono-api/native/package.json +3 -1
  47. package/node_modules/@ykdz/reference-hono-api/native/template-dist/definition.d.ts +1 -1
  48. package/node_modules/@ykdz/reference-hono-api/native/template-dist/definition.js +51 -18
  49. package/node_modules/@ykdz/reference-hono-api/native/tsconfig.json +1 -1
  50. package/node_modules/@ykdz/reference-hono-api/native/turbo.json +2 -2
  51. package/node_modules/@ykdz/reference-hono-api/package.json +3 -2
  52. package/node_modules/@ykdz/reference-npm-publication/native/README.md +14 -6
  53. package/node_modules/@ykdz/reference-npm-publication/native/package.json +2 -2
  54. package/node_modules/@ykdz/reference-npm-publication/native/resources/release.yml +4 -1
  55. package/node_modules/@ykdz/reference-npm-publication/native/template-dist/definition.d.ts +8 -4
  56. package/node_modules/@ykdz/reference-npm-publication/native/template-dist/definition.d.ts.map +1 -1
  57. package/node_modules/@ykdz/reference-npm-publication/native/template-dist/definition.js +68 -21
  58. package/node_modules/@ykdz/reference-npm-publication/package.json +1 -2
  59. package/node_modules/@ykdz/reference-rust-bin/native/package.json +13 -3
  60. package/node_modules/@ykdz/reference-rust-bin/native/resources/gitignore +5 -0
  61. package/node_modules/@ykdz/reference-rust-bin/native/resources/npmignore +1 -0
  62. package/node_modules/@ykdz/reference-rust-bin/native/template-dist/definition.d.ts +86 -12
  63. package/node_modules/@ykdz/reference-rust-bin/native/template-dist/definition.d.ts.map +1 -1
  64. package/node_modules/@ykdz/reference-rust-bin/native/template-dist/definition.js +227 -106
  65. package/node_modules/@ykdz/reference-rust-bin/native/template-dist/environment.d.ts +6 -0
  66. package/node_modules/@ykdz/reference-rust-bin/native/template-dist/environment.d.ts.map +1 -0
  67. package/node_modules/@ykdz/reference-rust-bin/native/template-dist/environment.js +44 -0
  68. package/node_modules/@ykdz/reference-rust-bin/native/template-dist/rust-package-projection.d.ts +19 -0
  69. package/node_modules/@ykdz/reference-rust-bin/native/template-dist/rust-package-projection.d.ts.map +1 -0
  70. package/node_modules/@ykdz/reference-rust-bin/native/template-dist/rust-package-projection.js +65 -0
  71. package/node_modules/@ykdz/reference-rust-bin/native/template-dist/rust-toolchain-projection.d.ts +15 -0
  72. package/node_modules/@ykdz/reference-rust-bin/native/template-dist/rust-toolchain-projection.d.ts.map +1 -0
  73. package/node_modules/@ykdz/reference-rust-bin/native/template-dist/rust-toolchain-projection.js +44 -0
  74. package/node_modules/@ykdz/reference-rust-bin/native/turbo.json +3 -1
  75. package/node_modules/@ykdz/reference-rust-bin/package.json +6 -1
  76. package/node_modules/@ykdz/reference-tooling-config/native/package.json +4 -5
  77. package/node_modules/@ykdz/reference-tooling-config/native/template/workspace/oxfmt.config.ts +1 -0
  78. package/node_modules/@ykdz/{template-workspace/resources → reference-tooling-config/native/template/workspace}/oxlint.config.ts +1 -1
  79. package/node_modules/@ykdz/reference-tooling-config/native/template-dist/definition.d.ts +1 -27
  80. package/node_modules/@ykdz/reference-tooling-config/native/template-dist/definition.js +53 -11
  81. package/node_modules/@ykdz/reference-tooling-config/native/tsconfig.json +1 -1
  82. package/node_modules/@ykdz/reference-tooling-config/native/turbo.json +5 -4
  83. package/node_modules/@ykdz/reference-tooling-config/package.json +5 -1
  84. package/node_modules/@ykdz/reference-ts-cli/native/package.json +7 -6
  85. package/node_modules/@ykdz/reference-ts-cli/native/resources/gitignore +5 -0
  86. package/node_modules/@ykdz/reference-ts-cli/native/resources/npmignore +1 -0
  87. package/node_modules/@ykdz/reference-ts-cli/native/src/cli-command-identity.ts +18 -0
  88. package/node_modules/@ykdz/reference-ts-cli/native/src/cli.ts +1 -1
  89. package/node_modules/@ykdz/reference-ts-cli/native/src/main.ts +1 -1
  90. package/node_modules/@ykdz/reference-ts-cli/native/template-dist/definition.d.ts +8 -6
  91. package/node_modules/@ykdz/reference-ts-cli/native/template-dist/definition.d.ts.map +1 -1
  92. package/node_modules/@ykdz/reference-ts-cli/native/template-dist/definition.js +119 -59
  93. package/node_modules/@ykdz/reference-ts-cli/native/template-dist/package-manifest.d.ts +7 -0
  94. package/node_modules/@ykdz/reference-ts-cli/native/template-dist/package-manifest.d.ts.map +1 -0
  95. package/node_modules/@ykdz/reference-ts-cli/native/template-dist/package-manifest.js +28 -0
  96. package/node_modules/@ykdz/reference-ts-cli/native/test/e2e/journeys/lookup.journey.ts +1 -1
  97. package/node_modules/@ykdz/reference-ts-cli/native/test/integration/command.test.ts +1 -1
  98. package/node_modules/@ykdz/reference-ts-cli/native/test/unit/cli-command-identity.test.ts +7 -55
  99. package/node_modules/@ykdz/reference-ts-cli/native/tsconfig.build.json +1 -1
  100. package/node_modules/@ykdz/reference-ts-cli/native/tsconfig.node.json +8 -2
  101. package/node_modules/@ykdz/reference-ts-cli/native/turbo.json +11 -3
  102. package/node_modules/@ykdz/reference-ts-cli/package.json +3 -2
  103. package/node_modules/@ykdz/reference-ts-lib/native/package.json +6 -1
  104. package/node_modules/@ykdz/reference-ts-lib/native/resources/gitignore +3 -0
  105. package/node_modules/@ykdz/reference-ts-lib/native/resources/npmignore +1 -0
  106. package/node_modules/@ykdz/reference-ts-lib/native/template-dist/definition.d.ts +1 -1
  107. package/node_modules/@ykdz/reference-ts-lib/native/template-dist/definition.js +70 -26
  108. package/node_modules/@ykdz/reference-ts-lib/native/tsconfig.node.json +1 -1
  109. package/node_modules/@ykdz/reference-ts-lib/native/turbo.json +3 -1
  110. package/node_modules/@ykdz/reference-ts-lib/package.json +3 -2
  111. package/node_modules/@ykdz/reference-vike-db/native/package.json +3 -1
  112. package/node_modules/@ykdz/reference-vike-db/native/template-dist/definition.d.ts +1 -1
  113. package/node_modules/@ykdz/reference-vike-db/native/template-dist/definition.js +70 -23
  114. package/node_modules/@ykdz/reference-vike-db/native/tsconfig.node.json +1 -1
  115. package/node_modules/@ykdz/reference-vike-db/native/turbo.json +3 -3
  116. package/node_modules/@ykdz/reference-vike-db/package.json +4 -2
  117. package/node_modules/@ykdz/reference-vike-migrations/native/package.json +3 -1
  118. package/node_modules/@ykdz/reference-vike-migrations/native/template-dist/definition.d.ts +2 -1
  119. package/node_modules/@ykdz/reference-vike-migrations/native/template-dist/definition.js +78 -23
  120. package/node_modules/@ykdz/reference-vike-migrations/native/tsconfig.json +1 -1
  121. package/node_modules/@ykdz/reference-vike-migrations/native/turbo.json +3 -3
  122. package/node_modules/@ykdz/reference-vike-migrations/package.json +4 -2
  123. package/node_modules/@ykdz/reference-vike-web/native/package.json +3 -1
  124. package/node_modules/@ykdz/reference-vike-web/native/template-dist/definition.d.ts +2 -1
  125. package/node_modules/@ykdz/reference-vike-web/native/template-dist/definition.js +137 -38
  126. package/node_modules/@ykdz/reference-vike-web/native/tsconfig.app.json +1 -1
  127. package/node_modules/@ykdz/reference-vike-web/native/tsconfig.node.json +1 -1
  128. package/node_modules/@ykdz/reference-vike-web/native/turbo.json +8 -4
  129. package/node_modules/@ykdz/reference-vike-web/package.json +4 -3
  130. package/node_modules/@ykdz/reference-vue-app/native/package.json +3 -1
  131. package/node_modules/@ykdz/reference-vue-app/native/template-dist/definition.d.ts +1 -1
  132. package/node_modules/@ykdz/reference-vue-app/native/template-dist/definition.js +72 -32
  133. package/node_modules/@ykdz/reference-vue-app/native/tsconfig.app.json +1 -1
  134. package/node_modules/@ykdz/reference-vue-app/native/tsconfig.node.json +1 -1
  135. package/node_modules/@ykdz/reference-vue-app/native/turbo.json +2 -2
  136. package/node_modules/@ykdz/reference-vue-app/package.json +3 -3
  137. package/node_modules/@ykdz/reference-vue-hono-web/native/package.json +3 -1
  138. package/node_modules/@ykdz/reference-vue-hono-web/native/template-dist/definition.d.ts +3 -1
  139. package/node_modules/@ykdz/reference-vue-hono-web/native/template-dist/definition.js +78 -28
  140. package/node_modules/@ykdz/reference-vue-hono-web/native/tsconfig.app.json +1 -1
  141. package/node_modules/@ykdz/reference-vue-hono-web/native/tsconfig.node.json +1 -1
  142. package/node_modules/@ykdz/reference-vue-hono-web/native/turbo.json +2 -2
  143. package/node_modules/@ykdz/reference-vue-hono-web/package.json +4 -3
  144. package/node_modules/@ykdz/reference-workspace-root/native/package.json +59 -0
  145. package/node_modules/@ykdz/{template-workspace/assets → reference-workspace-root/native/template/files}/turbo.json +0 -24
  146. package/node_modules/@ykdz/reference-workspace-root/native/template-dist/definition.d.ts +10 -0
  147. package/node_modules/@ykdz/reference-workspace-root/native/template-dist/definition.d.ts.map +1 -0
  148. package/node_modules/@ykdz/reference-workspace-root/native/template-dist/definition.js +140 -0
  149. package/node_modules/@ykdz/{template-workspace/dist → reference-workspace-root/native/template-dist}/editor-customization.d.ts +2 -1
  150. package/node_modules/@ykdz/reference-workspace-root/native/template-dist/editor-customization.d.ts.map +1 -0
  151. package/node_modules/@ykdz/reference-workspace-root/native/template-dist/environment-sources.d.ts +6 -0
  152. package/node_modules/@ykdz/reference-workspace-root/native/template-dist/environment-sources.d.ts.map +1 -0
  153. package/node_modules/@ykdz/reference-workspace-root/native/template-dist/environment-sources.js +10 -0
  154. package/node_modules/@ykdz/reference-workspace-root/native/template-dist/environment.d.ts +36 -0
  155. package/node_modules/@ykdz/reference-workspace-root/native/template-dist/environment.d.ts.map +1 -0
  156. package/node_modules/@ykdz/{template-workspace/dist/development-environment.js → reference-workspace-root/native/template-dist/environment.js} +20 -51
  157. package/node_modules/@ykdz/{template-workspace/dist → reference-workspace-root/native/template-dist}/project-github.d.ts +15 -8
  158. package/node_modules/@ykdz/reference-workspace-root/native/template-dist/project-github.d.ts.map +1 -0
  159. package/node_modules/@ykdz/{template-workspace/dist → reference-workspace-root/native/template-dist}/project-github.js +15 -19
  160. package/node_modules/@ykdz/reference-workspace-root/native/tsconfig.config.json +10 -0
  161. package/node_modules/@ykdz/reference-workspace-root/native/tsconfig.json +7 -0
  162. package/node_modules/@ykdz/reference-workspace-root/native/tsconfig.scripts.json +8 -0
  163. package/node_modules/@ykdz/reference-workspace-root/package.json +33 -0
  164. package/node_modules/@ykdz/template-content/dist/index.d.ts +10 -10
  165. package/node_modules/@ykdz/template-content/dist/index.js +3 -3
  166. package/node_modules/@ykdz/template-content/package.json +2 -1
  167. package/node_modules/@ykdz/template-content-provider-51cfac9642dc43a4/dist/index.d.ts +3 -45
  168. package/node_modules/@ykdz/template-content-provider-51cfac9642dc43a4/dist/index.js +18 -23
  169. package/node_modules/@ykdz/template-content-provider-51cfac9642dc43a4/package.json +2 -2
  170. package/node_modules/@ykdz/template-core/dist/composition.d.ts +49 -0
  171. package/node_modules/@ykdz/template-core/dist/composition.js +1 -0
  172. package/node_modules/@ykdz/template-core/dist/content-identity.d.ts +10 -0
  173. package/node_modules/@ykdz/template-core/dist/content-identity.js +21 -2
  174. package/node_modules/@ykdz/template-core/dist/generation-record.d.ts +46 -15
  175. package/node_modules/@ykdz/template-core/dist/generation-record.js +98 -29
  176. package/node_modules/@ykdz/template-core/dist/json.d.ts +8 -0
  177. package/node_modules/@ykdz/template-core/dist/json.js +62 -0
  178. package/node_modules/@ykdz/template-core/dist/package-contribution.d.ts +29 -12
  179. package/node_modules/@ykdz/template-core/dist/package-contribution.js +164 -33
  180. package/node_modules/@ykdz/template-core/dist/preset-definition.d.ts +6 -33
  181. package/node_modules/@ykdz/template-core/dist/preset-definition.js +23 -6
  182. package/node_modules/@ykdz/template-core/dist/project-blueprint.d.ts +37 -27
  183. package/node_modules/@ykdz/template-core/dist/project-blueprint.js +126 -125
  184. package/node_modules/@ykdz/template-core/dist/project-projection.d.ts +91 -33
  185. package/node_modules/@ykdz/template-core/dist/project-projection.js +639 -323
  186. package/node_modules/@ykdz/template-core/dist/reference-package.d.ts +101 -0
  187. package/node_modules/@ykdz/template-core/dist/reference-package.js +14 -0
  188. package/node_modules/@ykdz/template-core/dist/template-source.d.ts +10 -0
  189. package/node_modules/@ykdz/template-core/dist/template-source.js +31 -0
  190. package/node_modules/@ykdz/template-core/package.json +2 -3
  191. package/node_modules/@ykdz/template-environment/dist/development-container-tool-layer.d.ts +2 -3
  192. package/node_modules/@ykdz/template-environment/dist/development-container-tool-layer.js +2 -6
  193. package/node_modules/@ykdz/template-environment/package.json +1 -1
  194. package/node_modules/@ykdz/template-generator/dist/content-source.d.ts +25 -3
  195. package/node_modules/@ykdz/template-generator/dist/content-source.js +28 -27
  196. package/node_modules/@ykdz/template-generator/dist/index.d.ts +191 -60
  197. package/node_modules/@ykdz/template-generator/dist/index.js +1868 -1000
  198. package/node_modules/@ykdz/template-generator/dist/owner-local-reference.d.ts +8 -0
  199. package/node_modules/@ykdz/template-generator/dist/owner-local-reference.js +80 -0
  200. package/node_modules/@ykdz/template-workspace/dist/application-requirements.d.ts +13 -3
  201. package/node_modules/@ykdz/template-workspace/dist/application-requirements.js +34 -0
  202. package/node_modules/@ykdz/template-workspace/dist/ci-diagnostic-artifact.d.ts +1 -6
  203. package/node_modules/@ykdz/template-workspace/dist/default-composition.d.ts +109 -0
  204. package/node_modules/@ykdz/template-workspace/dist/default-composition.js +1353 -0
  205. package/node_modules/@ykdz/template-workspace/dist/default-generation.d.ts +618 -0
  206. package/node_modules/@ykdz/template-workspace/dist/default-generation.js +638 -0
  207. package/node_modules/@ykdz/template-workspace/dist/default-package-identity.js +23 -19
  208. package/node_modules/@ykdz/template-workspace/dist/project-requirements.d.ts +23 -9
  209. package/node_modules/@ykdz/template-workspace/dist/project-requirements.js +16 -1
  210. package/node_modules/@ykdz/template-workspace/dist/rust-toolchain-facts.d.ts +13 -7
  211. package/node_modules/@ykdz/template-workspace/dist/rust-toolchain-facts.js +35 -21
  212. package/node_modules/@ykdz/template-workspace/dist/shared-root-files.d.ts +7 -67
  213. package/node_modules/@ykdz/template-workspace/dist/shared-root-files.js +18 -50
  214. package/node_modules/@ykdz/template-workspace/dist/workspace-policy-snapshot.d.ts +0 -1
  215. package/node_modules/@ykdz/template-workspace/dist/workspace-policy-snapshot.js +0 -10
  216. package/node_modules/@ykdz/template-workspace/package.json +14 -55
  217. package/node_modules/@ykdz/template-workspace-authoring/dist/content-artifact.d.ts +38 -2
  218. package/node_modules/@ykdz/template-workspace-authoring/dist/content-artifact.js +95 -44
  219. package/node_modules/@ykdz/template-workspace-authoring/package.json +2 -1
  220. package/node_modules/@ykdz/tooling-config/base.json +15 -0
  221. package/node_modules/@ykdz/tooling-config/node.json +13 -0
  222. package/node_modules/@ykdz/tooling-config/oxfmt.config.ts +3 -0
  223. package/node_modules/@ykdz/tooling-config/oxlint.config.ts +8 -0
  224. package/node_modules/@ykdz/tooling-config/package.json +36 -0
  225. package/package.json +14 -6
  226. package/node_modules/@typescript/typescript-linux-x64/LICENSE +0 -55
  227. package/node_modules/@typescript/typescript-linux-x64/NOTICE.txt +0 -436
  228. package/node_modules/@typescript/typescript-linux-x64/README.md +0 -3
  229. package/node_modules/@typescript/typescript-linux-x64/lib/lib.d.ts +0 -20
  230. package/node_modules/@typescript/typescript-linux-x64/lib/lib.decorators.d.ts +0 -382
  231. package/node_modules/@typescript/typescript-linux-x64/lib/lib.decorators.legacy.d.ts +0 -20
  232. package/node_modules/@typescript/typescript-linux-x64/lib/lib.dom.asynciterable.d.ts +0 -18
  233. package/node_modules/@typescript/typescript-linux-x64/lib/lib.dom.d.ts +0 -45125
  234. package/node_modules/@typescript/typescript-linux-x64/lib/lib.dom.iterable.d.ts +0 -18
  235. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2015.collection.d.ts +0 -159
  236. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2015.core.d.ts +0 -595
  237. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2015.d.ts +0 -26
  238. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2015.generator.d.ts +0 -75
  239. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2015.iterable.d.ts +0 -603
  240. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2015.promise.d.ts +0 -79
  241. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2015.proxy.d.ts +0 -126
  242. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2015.reflect.d.ts +0 -142
  243. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2015.symbol.d.ts +0 -44
  244. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2015.symbol.wellknown.d.ts +0 -324
  245. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2016.array.include.d.ts +0 -114
  246. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2016.d.ts +0 -19
  247. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2016.full.d.ts +0 -21
  248. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2016.intl.d.ts +0 -29
  249. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2017.arraybuffer.d.ts +0 -19
  250. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2017.d.ts +0 -24
  251. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2017.date.d.ts +0 -29
  252. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2017.full.d.ts +0 -21
  253. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2017.intl.d.ts +0 -42
  254. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2017.object.d.ts +0 -47
  255. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2017.sharedmemory.d.ts +0 -133
  256. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2017.string.d.ts +0 -47
  257. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2017.typedarrays.d.ts +0 -51
  258. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2018.asyncgenerator.d.ts +0 -75
  259. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2018.asynciterable.d.ts +0 -51
  260. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2018.d.ts +0 -22
  261. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2018.full.d.ts +0 -22
  262. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2018.intl.d.ts +0 -81
  263. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2018.promise.d.ts +0 -28
  264. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2018.regexp.d.ts +0 -35
  265. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2019.array.d.ts +0 -77
  266. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2019.d.ts +0 -22
  267. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2019.full.d.ts +0 -22
  268. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2019.intl.d.ts +0 -21
  269. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2019.object.d.ts +0 -31
  270. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2019.string.d.ts +0 -35
  271. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2019.symbol.d.ts +0 -22
  272. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2020.bigint.d.ts +0 -763
  273. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2020.d.ts +0 -25
  274. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2020.date.d.ts +0 -40
  275. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2020.full.d.ts +0 -22
  276. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2020.intl.d.ts +0 -472
  277. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2020.number.d.ts +0 -26
  278. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2020.promise.d.ts +0 -45
  279. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2020.sharedmemory.d.ts +0 -97
  280. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2020.string.d.ts +0 -42
  281. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2020.symbol.wellknown.d.ts +0 -39
  282. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2021.d.ts +0 -21
  283. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2021.full.d.ts +0 -22
  284. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2021.intl.d.ts +0 -164
  285. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2021.promise.d.ts +0 -46
  286. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2021.string.d.ts +0 -31
  287. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2021.weakref.d.ts +0 -76
  288. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2022.array.d.ts +0 -119
  289. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2022.d.ts +0 -23
  290. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2022.error.d.ts +0 -73
  291. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2022.full.d.ts +0 -22
  292. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2022.intl.d.ts +0 -143
  293. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2022.object.d.ts +0 -24
  294. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2022.regexp.d.ts +0 -37
  295. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2022.string.d.ts +0 -23
  296. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2023.array.d.ts +0 -922
  297. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2023.collection.d.ts +0 -19
  298. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2023.d.ts +0 -20
  299. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2023.full.d.ts +0 -22
  300. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2023.intl.d.ts +0 -62
  301. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2024.arraybuffer.d.ts +0 -63
  302. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2024.collection.d.ts +0 -27
  303. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2024.d.ts +0 -24
  304. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2024.full.d.ts +0 -22
  305. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2024.object.d.ts +0 -27
  306. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2024.promise.d.ts +0 -33
  307. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2024.regexp.d.ts +0 -23
  308. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2024.sharedmemory.d.ts +0 -66
  309. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2024.string.d.ts +0 -27
  310. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2025.collection.d.ts +0 -94
  311. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2025.d.ts +0 -23
  312. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2025.float16.d.ts +0 -443
  313. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2025.full.d.ts +0 -22
  314. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2025.intl.d.ts +0 -200
  315. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2025.iterator.d.ts +0 -146
  316. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2025.promise.d.ts +0 -32
  317. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es2025.regexp.d.ts +0 -30
  318. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es5.d.ts +0 -4599
  319. package/node_modules/@typescript/typescript-linux-x64/lib/lib.es6.d.ts +0 -21
  320. package/node_modules/@typescript/typescript-linux-x64/lib/lib.esnext.array.d.ts +0 -33
  321. package/node_modules/@typescript/typescript-linux-x64/lib/lib.esnext.collection.d.ts +0 -47
  322. package/node_modules/@typescript/typescript-linux-x64/lib/lib.esnext.d.ts +0 -27
  323. package/node_modules/@typescript/typescript-linux-x64/lib/lib.esnext.date.d.ts +0 -21
  324. package/node_modules/@typescript/typescript-linux-x64/lib/lib.esnext.decorators.d.ts +0 -26
  325. package/node_modules/@typescript/typescript-linux-x64/lib/lib.esnext.disposable.d.ts +0 -191
  326. package/node_modules/@typescript/typescript-linux-x64/lib/lib.esnext.error.d.ts +0 -22
  327. package/node_modules/@typescript/typescript-linux-x64/lib/lib.esnext.full.d.ts +0 -22
  328. package/node_modules/@typescript/typescript-linux-x64/lib/lib.esnext.intl.d.ts +0 -107
  329. package/node_modules/@typescript/typescript-linux-x64/lib/lib.esnext.sharedmemory.d.ts +0 -23
  330. package/node_modules/@typescript/typescript-linux-x64/lib/lib.esnext.temporal.d.ts +0 -485
  331. package/node_modules/@typescript/typescript-linux-x64/lib/lib.esnext.typedarrays.d.ts +0 -90
  332. package/node_modules/@typescript/typescript-linux-x64/lib/lib.scripthost.d.ts +0 -320
  333. package/node_modules/@typescript/typescript-linux-x64/lib/lib.webworker.asynciterable.d.ts +0 -18
  334. package/node_modules/@typescript/typescript-linux-x64/lib/lib.webworker.d.ts +0 -15606
  335. package/node_modules/@typescript/typescript-linux-x64/lib/lib.webworker.importscripts.d.ts +0 -21
  336. package/node_modules/@typescript/typescript-linux-x64/lib/lib.webworker.iterable.d.ts +0 -18
  337. package/node_modules/@typescript/typescript-linux-x64/lib/tsc +0 -0
  338. package/node_modules/@typescript/typescript-linux-x64/lib/tsc.sig +0 -11
  339. package/node_modules/@typescript/typescript-linux-x64/package.json +0 -45
  340. package/node_modules/@ykdz/reference-npm-publication/native/template-dist/target.d.ts +0 -13
  341. package/node_modules/@ykdz/reference-npm-publication/native/template-dist/target.d.ts.map +0 -1
  342. package/node_modules/@ykdz/reference-npm-publication/native/template-dist/target.js +0 -30
  343. package/node_modules/@ykdz/reference-npm-publication/native/template-dist/workspace.d.ts +0 -11
  344. package/node_modules/@ykdz/reference-npm-publication/native/template-dist/workspace.d.ts.map +0 -1
  345. package/node_modules/@ykdz/reference-npm-publication/native/template-dist/workspace.js +0 -51
  346. package/node_modules/@ykdz/reference-rust-bin/native/tsconfig.json +0 -8
  347. package/node_modules/@ykdz/reference-ts-cli/native/src/publication/cli-command-identity.ts +0 -88
  348. package/node_modules/@ykdz/template-content/dist/template-members.d.ts +0 -9
  349. package/node_modules/@ykdz/template-content/dist/template-members.js +0 -16
  350. package/node_modules/@ykdz/template-core/dist/renderer-policy-snapshot.d.ts +0 -1
  351. package/node_modules/@ykdz/template-core/dist/renderer-policy-snapshot.js +0 -2
  352. package/node_modules/@ykdz/template-core/dist/renderer.d.ts +0 -101
  353. package/node_modules/@ykdz/template-core/dist/renderer.js +0 -386
  354. package/node_modules/@ykdz/template-core/dist/workspace-strategy.d.ts +0 -188
  355. package/node_modules/@ykdz/template-core/dist/workspace-strategy.js +0 -1
  356. package/node_modules/@ykdz/template-workspace/assets/tsconfig.config.json +0 -6
  357. package/node_modules/@ykdz/template-workspace/assets/tsconfig.json +0 -7
  358. package/node_modules/@ykdz/template-workspace/dist/default-environment-sources.d.ts +0 -5
  359. package/node_modules/@ykdz/template-workspace/dist/default-environment-sources.js +0 -8
  360. package/node_modules/@ykdz/template-workspace/dist/default-environment.d.ts +0 -9
  361. package/node_modules/@ykdz/template-workspace/dist/default-environment.js +0 -5
  362. package/node_modules/@ykdz/template-workspace/dist/default-workspace-strategy.d.ts +0 -89
  363. package/node_modules/@ykdz/template-workspace/dist/default-workspace-strategy.js +0 -967
  364. package/node_modules/@ykdz/template-workspace/dist/development-container.d.ts +0 -3
  365. package/node_modules/@ykdz/template-workspace/dist/development-container.js +0 -36
  366. package/node_modules/@ykdz/template-workspace/dist/development-environment.d.ts +0 -36
  367. package/node_modules/@ykdz/template-workspace/dist/environment-needs.d.ts +0 -51
  368. package/node_modules/@ykdz/template-workspace/dist/generation-context.d.ts +0 -14
  369. package/node_modules/@ykdz/template-workspace/dist/package-addition-facts.d.ts +0 -21
  370. package/node_modules/@ykdz/template-workspace/dist/package-addition-facts.js +0 -90
  371. package/node_modules/@ykdz/template-workspace/dist/package-contribution.d.ts +0 -64
  372. package/node_modules/@ykdz/template-workspace/dist/package-contribution.js +0 -65
  373. package/node_modules/@ykdz/template-workspace/dist/project-linking.d.ts +0 -48
  374. package/node_modules/@ykdz/template-workspace/dist/project-linking.js +0 -218
  375. package/node_modules/@ykdz/template-workspace/dist/reference-package.d.ts +0 -146
  376. package/node_modules/@ykdz/template-workspace/dist/reference-package.js +0 -521
  377. package/node_modules/@ykdz/template-workspace/dist/root-projection.d.ts +0 -29
  378. package/node_modules/@ykdz/template-workspace/dist/root-projection.js +0 -144
  379. package/node_modules/@ykdz/template-workspace/dist/rust-target-projection.d.ts +0 -35
  380. package/node_modules/@ykdz/template-workspace/dist/rust-target-projection.js +0 -74
  381. package/node_modules/@ykdz/template-workspace/dist/workspace-resources.d.ts +0 -23
  382. package/node_modules/@ykdz/template-workspace/dist/workspace-resources.js +0 -83
  383. package/node_modules/@ykdz/template-workspace/resources/oxfmt.config.ts +0 -1
  384. package/node_modules/typescript-7/LICENSE +0 -55
  385. package/node_modules/typescript-7/NOTICE.txt +0 -436
  386. package/node_modules/typescript-7/README.md +0 -49
  387. package/node_modules/typescript-7/bin/tsc +0 -2
  388. package/node_modules/typescript-7/dist/api/async/api.d.ts +0 -529
  389. package/node_modules/typescript-7/dist/api/async/api.d.ts.map +0 -1
  390. package/node_modules/typescript-7/dist/api/async/api.js +0 -1657
  391. package/node_modules/typescript-7/dist/api/async/api.js.map +0 -1
  392. package/node_modules/typescript-7/dist/api/async/client.d.ts +0 -39
  393. package/node_modules/typescript-7/dist/api/async/client.d.ts.map +0 -1
  394. package/node_modules/typescript-7/dist/api/async/client.js +0 -211
  395. package/node_modules/typescript-7/dist/api/async/client.js.map +0 -1
  396. package/node_modules/typescript-7/dist/api/async/types.d.ts +0 -310
  397. package/node_modules/typescript-7/dist/api/async/types.d.ts.map +0 -1
  398. package/node_modules/typescript-7/dist/api/async/types.js +0 -2
  399. package/node_modules/typescript-7/dist/api/async/types.js.map +0 -1
  400. package/node_modules/typescript-7/dist/api/compilerOptions.d.ts +0 -109
  401. package/node_modules/typescript-7/dist/api/compilerOptions.d.ts.map +0 -1
  402. package/node_modules/typescript-7/dist/api/compilerOptions.js +0 -2
  403. package/node_modules/typescript-7/dist/api/compilerOptions.js.map +0 -1
  404. package/node_modules/typescript-7/dist/api/fs.d.ts +0 -23
  405. package/node_modules/typescript-7/dist/api/fs.d.ts.map +0 -1
  406. package/node_modules/typescript-7/dist/api/fs.js +0 -109
  407. package/node_modules/typescript-7/dist/api/fs.js.map +0 -1
  408. package/node_modules/typescript-7/dist/api/node/encoder.d.ts +0 -15
  409. package/node_modules/typescript-7/dist/api/node/encoder.d.ts.map +0 -1
  410. package/node_modules/typescript-7/dist/api/node/encoder.generated.d.ts +0 -5
  411. package/node_modules/typescript-7/dist/api/node/encoder.generated.d.ts.map +0 -1
  412. package/node_modules/typescript-7/dist/api/node/encoder.generated.js +0 -74
  413. package/node_modules/typescript-7/dist/api/node/encoder.generated.js.map +0 -1
  414. package/node_modules/typescript-7/dist/api/node/encoder.js +0 -287
  415. package/node_modules/typescript-7/dist/api/node/encoder.js.map +0 -1
  416. package/node_modules/typescript-7/dist/api/node/msgpack.d.ts +0 -32
  417. package/node_modules/typescript-7/dist/api/node/msgpack.d.ts.map +0 -1
  418. package/node_modules/typescript-7/dist/api/node/msgpack.js +0 -213
  419. package/node_modules/typescript-7/dist/api/node/msgpack.js.map +0 -1
  420. package/node_modules/typescript-7/dist/api/node/node.d.ts +0 -76
  421. package/node_modules/typescript-7/dist/api/node/node.d.ts.map +0 -1
  422. package/node_modules/typescript-7/dist/api/node/node.generated.d.ts +0 -182
  423. package/node_modules/typescript-7/dist/api/node/node.generated.d.ts.map +0 -1
  424. package/node_modules/typescript-7/dist/api/node/node.generated.js +0 -835
  425. package/node_modules/typescript-7/dist/api/node/node.generated.js.map +0 -1
  426. package/node_modules/typescript-7/dist/api/node/node.infrastructure.d.ts +0 -62
  427. package/node_modules/typescript-7/dist/api/node/node.infrastructure.d.ts.map +0 -1
  428. package/node_modules/typescript-7/dist/api/node/node.infrastructure.js +0 -122
  429. package/node_modules/typescript-7/dist/api/node/node.infrastructure.js.map +0 -1
  430. package/node_modules/typescript-7/dist/api/node/node.js +0 -298
  431. package/node_modules/typescript-7/dist/api/node/node.js.map +0 -1
  432. package/node_modules/typescript-7/dist/api/node/protocol.d.ts +0 -29
  433. package/node_modules/typescript-7/dist/api/node/protocol.d.ts.map +0 -1
  434. package/node_modules/typescript-7/dist/api/node/protocol.generated.d.ts +0 -4
  435. package/node_modules/typescript-7/dist/api/node/protocol.generated.d.ts.map +0 -1
  436. package/node_modules/typescript-7/dist/api/node/protocol.generated.js +0 -241
  437. package/node_modules/typescript-7/dist/api/node/protocol.generated.js.map +0 -1
  438. package/node_modules/typescript-7/dist/api/node/protocol.js +0 -30
  439. package/node_modules/typescript-7/dist/api/node/protocol.js.map +0 -1
  440. package/node_modules/typescript-7/dist/api/node/wtf8.d.ts +0 -6
  441. package/node_modules/typescript-7/dist/api/node/wtf8.d.ts.map +0 -1
  442. package/node_modules/typescript-7/dist/api/node/wtf8.js +0 -61
  443. package/node_modules/typescript-7/dist/api/node/wtf8.js.map +0 -1
  444. package/node_modules/typescript-7/dist/api/options.d.ts +0 -32
  445. package/node_modules/typescript-7/dist/api/options.d.ts.map +0 -1
  446. package/node_modules/typescript-7/dist/api/options.js +0 -11
  447. package/node_modules/typescript-7/dist/api/options.js.map +0 -1
  448. package/node_modules/typescript-7/dist/api/path.d.ts +0 -110
  449. package/node_modules/typescript-7/dist/api/path.d.ts.map +0 -1
  450. package/node_modules/typescript-7/dist/api/path.js +0 -508
  451. package/node_modules/typescript-7/dist/api/path.js.map +0 -1
  452. package/node_modules/typescript-7/dist/api/proto.d.ts +0 -239
  453. package/node_modules/typescript-7/dist/api/proto.d.ts.map +0 -1
  454. package/node_modules/typescript-7/dist/api/proto.js +0 -37
  455. package/node_modules/typescript-7/dist/api/proto.js.map +0 -1
  456. package/node_modules/typescript-7/dist/api/sourceFileCache.d.ts +0 -79
  457. package/node_modules/typescript-7/dist/api/sourceFileCache.d.ts.map +0 -1
  458. package/node_modules/typescript-7/dist/api/sourceFileCache.js +0 -169
  459. package/node_modules/typescript-7/dist/api/sourceFileCache.js.map +0 -1
  460. package/node_modules/typescript-7/dist/api/sync/api.d.ts +0 -529
  461. package/node_modules/typescript-7/dist/api/sync/api.d.ts.map +0 -1
  462. package/node_modules/typescript-7/dist/api/sync/api.js +0 -1665
  463. package/node_modules/typescript-7/dist/api/sync/api.js.map +0 -1
  464. package/node_modules/typescript-7/dist/api/sync/client.d.ts +0 -30
  465. package/node_modules/typescript-7/dist/api/sync/client.d.ts.map +0 -1
  466. package/node_modules/typescript-7/dist/api/sync/client.js +0 -124
  467. package/node_modules/typescript-7/dist/api/sync/client.js.map +0 -1
  468. package/node_modules/typescript-7/dist/api/sync/types.d.ts +0 -310
  469. package/node_modules/typescript-7/dist/api/sync/types.d.ts.map +0 -1
  470. package/node_modules/typescript-7/dist/api/sync/types.js +0 -2
  471. package/node_modules/typescript-7/dist/api/sync/types.js.map +0 -1
  472. package/node_modules/typescript-7/dist/api/syncChannel.d.ts +0 -114
  473. package/node_modules/typescript-7/dist/api/syncChannel.d.ts.map +0 -1
  474. package/node_modules/typescript-7/dist/api/syncChannel.js +0 -508
  475. package/node_modules/typescript-7/dist/api/syncChannel.js.map +0 -1
  476. package/node_modules/typescript-7/dist/api/timing.d.ts +0 -175
  477. package/node_modules/typescript-7/dist/api/timing.d.ts.map +0 -1
  478. package/node_modules/typescript-7/dist/api/timing.js +0 -149
  479. package/node_modules/typescript-7/dist/api/timing.js.map +0 -1
  480. package/node_modules/typescript-7/dist/ast/ast.d.ts +0 -100
  481. package/node_modules/typescript-7/dist/ast/ast.d.ts.map +0 -1
  482. package/node_modules/typescript-7/dist/ast/ast.generated.d.ts +0 -1161
  483. package/node_modules/typescript-7/dist/ast/ast.generated.d.ts.map +0 -1
  484. package/node_modules/typescript-7/dist/ast/ast.generated.js +0 -4
  485. package/node_modules/typescript-7/dist/ast/ast.generated.js.map +0 -1
  486. package/node_modules/typescript-7/dist/ast/ast.js +0 -7
  487. package/node_modules/typescript-7/dist/ast/ast.js.map +0 -1
  488. package/node_modules/typescript-7/dist/ast/astnav.d.ts +0 -19
  489. package/node_modules/typescript-7/dist/ast/astnav.d.ts.map +0 -1
  490. package/node_modules/typescript-7/dist/ast/astnav.js +0 -596
  491. package/node_modules/typescript-7/dist/ast/astnav.js.map +0 -1
  492. package/node_modules/typescript-7/dist/ast/clone.d.ts +0 -16
  493. package/node_modules/typescript-7/dist/ast/clone.d.ts.map +0 -1
  494. package/node_modules/typescript-7/dist/ast/clone.js +0 -104
  495. package/node_modules/typescript-7/dist/ast/clone.js.map +0 -1
  496. package/node_modules/typescript-7/dist/ast/factory.generated.d.ts +0 -520
  497. package/node_modules/typescript-7/dist/ast/factory.generated.d.ts.map +0 -1
  498. package/node_modules/typescript-7/dist/ast/factory.generated.js +0 -3057
  499. package/node_modules/typescript-7/dist/ast/factory.generated.js.map +0 -1
  500. package/node_modules/typescript-7/dist/ast/index.d.ts +0 -20
  501. package/node_modules/typescript-7/dist/ast/index.d.ts.map +0 -1
  502. package/node_modules/typescript-7/dist/ast/index.js +0 -20
  503. package/node_modules/typescript-7/dist/ast/index.js.map +0 -1
  504. package/node_modules/typescript-7/dist/ast/is.d.ts +0 -35
  505. package/node_modules/typescript-7/dist/ast/is.d.ts.map +0 -1
  506. package/node_modules/typescript-7/dist/ast/is.generated.d.ts +0 -329
  507. package/node_modules/typescript-7/dist/ast/is.generated.d.ts.map +0 -1
  508. package/node_modules/typescript-7/dist/ast/is.generated.js +0 -1103
  509. package/node_modules/typescript-7/dist/ast/is.generated.js.map +0 -1
  510. package/node_modules/typescript-7/dist/ast/is.js +0 -233
  511. package/node_modules/typescript-7/dist/ast/is.js.map +0 -1
  512. package/node_modules/typescript-7/dist/ast/jsdoc.d.ts +0 -11
  513. package/node_modules/typescript-7/dist/ast/jsdoc.d.ts.map +0 -1
  514. package/node_modules/typescript-7/dist/ast/jsdoc.js +0 -202
  515. package/node_modules/typescript-7/dist/ast/jsdoc.js.map +0 -1
  516. package/node_modules/typescript-7/dist/ast/scanner.d.ts +0 -97
  517. package/node_modules/typescript-7/dist/ast/scanner.d.ts.map +0 -1
  518. package/node_modules/typescript-7/dist/ast/scanner.js +0 -2230
  519. package/node_modules/typescript-7/dist/ast/scanner.js.map +0 -1
  520. package/node_modules/typescript-7/dist/ast/utils.d.ts +0 -17
  521. package/node_modules/typescript-7/dist/ast/utils.d.ts.map +0 -1
  522. package/node_modules/typescript-7/dist/ast/utils.js +0 -67
  523. package/node_modules/typescript-7/dist/ast/utils.js.map +0 -1
  524. package/node_modules/typescript-7/dist/ast/visitor.d.ts +0 -14
  525. package/node_modules/typescript-7/dist/ast/visitor.d.ts.map +0 -1
  526. package/node_modules/typescript-7/dist/ast/visitor.generated.d.ts +0 -50
  527. package/node_modules/typescript-7/dist/ast/visitor.generated.d.ts.map +0 -1
  528. package/node_modules/typescript-7/dist/ast/visitor.generated.js +0 -978
  529. package/node_modules/typescript-7/dist/ast/visitor.generated.js.map +0 -1
  530. package/node_modules/typescript-7/dist/ast/visitor.js +0 -47
  531. package/node_modules/typescript-7/dist/ast/visitor.js.map +0 -1
  532. package/node_modules/typescript-7/dist/enums/characterCodes.d.ts +0 -2
  533. package/node_modules/typescript-7/dist/enums/characterCodes.d.ts.map +0 -1
  534. package/node_modules/typescript-7/dist/enums/characterCodes.enum.d.ts +0 -129
  535. package/node_modules/typescript-7/dist/enums/characterCodes.enum.d.ts.map +0 -1
  536. package/node_modules/typescript-7/dist/enums/characterCodes.enum.js +0 -132
  537. package/node_modules/typescript-7/dist/enums/characterCodes.enum.js.map +0 -1
  538. package/node_modules/typescript-7/dist/enums/characterCodes.js +0 -130
  539. package/node_modules/typescript-7/dist/enums/characterCodes.js.map +0 -1
  540. package/node_modules/typescript-7/dist/enums/commentDirectiveType.d.ts +0 -2
  541. package/node_modules/typescript-7/dist/enums/commentDirectiveType.d.ts.map +0 -1
  542. package/node_modules/typescript-7/dist/enums/commentDirectiveType.enum.d.ts +0 -5
  543. package/node_modules/typescript-7/dist/enums/commentDirectiveType.enum.d.ts.map +0 -1
  544. package/node_modules/typescript-7/dist/enums/commentDirectiveType.enum.js +0 -6
  545. package/node_modules/typescript-7/dist/enums/commentDirectiveType.enum.js.map +0 -1
  546. package/node_modules/typescript-7/dist/enums/commentDirectiveType.js +0 -6
  547. package/node_modules/typescript-7/dist/enums/commentDirectiveType.js.map +0 -1
  548. package/node_modules/typescript-7/dist/enums/completionItemKind.d.ts +0 -2
  549. package/node_modules/typescript-7/dist/enums/completionItemKind.d.ts.map +0 -1
  550. package/node_modules/typescript-7/dist/enums/completionItemKind.enum.d.ts +0 -28
  551. package/node_modules/typescript-7/dist/enums/completionItemKind.enum.d.ts.map +0 -1
  552. package/node_modules/typescript-7/dist/enums/completionItemKind.enum.js +0 -30
  553. package/node_modules/typescript-7/dist/enums/completionItemKind.enum.js.map +0 -1
  554. package/node_modules/typescript-7/dist/enums/completionItemKind.js +0 -30
  555. package/node_modules/typescript-7/dist/enums/completionItemKind.js.map +0 -1
  556. package/node_modules/typescript-7/dist/enums/diagnosticCategory.d.ts +0 -2
  557. package/node_modules/typescript-7/dist/enums/diagnosticCategory.d.ts.map +0 -1
  558. package/node_modules/typescript-7/dist/enums/diagnosticCategory.enum.d.ts +0 -7
  559. package/node_modules/typescript-7/dist/enums/diagnosticCategory.enum.d.ts.map +0 -1
  560. package/node_modules/typescript-7/dist/enums/diagnosticCategory.enum.js +0 -9
  561. package/node_modules/typescript-7/dist/enums/diagnosticCategory.enum.js.map +0 -1
  562. package/node_modules/typescript-7/dist/enums/diagnosticCategory.js +0 -9
  563. package/node_modules/typescript-7/dist/enums/diagnosticCategory.js.map +0 -1
  564. package/node_modules/typescript-7/dist/enums/elementFlags.d.ts +0 -2
  565. package/node_modules/typescript-7/dist/enums/elementFlags.d.ts.map +0 -1
  566. package/node_modules/typescript-7/dist/enums/elementFlags.enum.d.ts +0 -12
  567. package/node_modules/typescript-7/dist/enums/elementFlags.enum.d.ts.map +0 -1
  568. package/node_modules/typescript-7/dist/enums/elementFlags.enum.js +0 -14
  569. package/node_modules/typescript-7/dist/enums/elementFlags.enum.js.map +0 -1
  570. package/node_modules/typescript-7/dist/enums/elementFlags.js +0 -14
  571. package/node_modules/typescript-7/dist/enums/elementFlags.js.map +0 -1
  572. package/node_modules/typescript-7/dist/enums/internalSymbolName.d.ts +0 -2
  573. package/node_modules/typescript-7/dist/enums/internalSymbolName.d.ts.map +0 -1
  574. package/node_modules/typescript-7/dist/enums/internalSymbolName.enum.d.ts +0 -23
  575. package/node_modules/typescript-7/dist/enums/internalSymbolName.enum.d.ts.map +0 -1
  576. package/node_modules/typescript-7/dist/enums/internalSymbolName.enum.js +0 -25
  577. package/node_modules/typescript-7/dist/enums/internalSymbolName.enum.js.map +0 -1
  578. package/node_modules/typescript-7/dist/enums/internalSymbolName.js +0 -25
  579. package/node_modules/typescript-7/dist/enums/internalSymbolName.js.map +0 -1
  580. package/node_modules/typescript-7/dist/enums/jsxEmit.d.ts +0 -2
  581. package/node_modules/typescript-7/dist/enums/jsxEmit.d.ts.map +0 -1
  582. package/node_modules/typescript-7/dist/enums/jsxEmit.enum.d.ts +0 -9
  583. package/node_modules/typescript-7/dist/enums/jsxEmit.enum.d.ts.map +0 -1
  584. package/node_modules/typescript-7/dist/enums/jsxEmit.enum.js +0 -11
  585. package/node_modules/typescript-7/dist/enums/jsxEmit.enum.js.map +0 -1
  586. package/node_modules/typescript-7/dist/enums/jsxEmit.js +0 -11
  587. package/node_modules/typescript-7/dist/enums/jsxEmit.js.map +0 -1
  588. package/node_modules/typescript-7/dist/enums/languageVariant.d.ts +0 -2
  589. package/node_modules/typescript-7/dist/enums/languageVariant.d.ts.map +0 -1
  590. package/node_modules/typescript-7/dist/enums/languageVariant.enum.d.ts +0 -5
  591. package/node_modules/typescript-7/dist/enums/languageVariant.enum.d.ts.map +0 -1
  592. package/node_modules/typescript-7/dist/enums/languageVariant.enum.js +0 -6
  593. package/node_modules/typescript-7/dist/enums/languageVariant.enum.js.map +0 -1
  594. package/node_modules/typescript-7/dist/enums/languageVariant.js +0 -6
  595. package/node_modules/typescript-7/dist/enums/languageVariant.js.map +0 -1
  596. package/node_modules/typescript-7/dist/enums/modifierFlags.d.ts +0 -2
  597. package/node_modules/typescript-7/dist/enums/modifierFlags.d.ts.map +0 -1
  598. package/node_modules/typescript-7/dist/enums/modifierFlags.enum.d.ts +0 -42
  599. package/node_modules/typescript-7/dist/enums/modifierFlags.enum.d.ts.map +0 -1
  600. package/node_modules/typescript-7/dist/enums/modifierFlags.enum.js +0 -44
  601. package/node_modules/typescript-7/dist/enums/modifierFlags.enum.js.map +0 -1
  602. package/node_modules/typescript-7/dist/enums/modifierFlags.js +0 -44
  603. package/node_modules/typescript-7/dist/enums/modifierFlags.js.map +0 -1
  604. package/node_modules/typescript-7/dist/enums/moduleDetectionKind.d.ts +0 -2
  605. package/node_modules/typescript-7/dist/enums/moduleDetectionKind.d.ts.map +0 -1
  606. package/node_modules/typescript-7/dist/enums/moduleDetectionKind.enum.d.ts +0 -7
  607. package/node_modules/typescript-7/dist/enums/moduleDetectionKind.enum.d.ts.map +0 -1
  608. package/node_modules/typescript-7/dist/enums/moduleDetectionKind.enum.js +0 -9
  609. package/node_modules/typescript-7/dist/enums/moduleDetectionKind.enum.js.map +0 -1
  610. package/node_modules/typescript-7/dist/enums/moduleDetectionKind.js +0 -9
  611. package/node_modules/typescript-7/dist/enums/moduleDetectionKind.js.map +0 -1
  612. package/node_modules/typescript-7/dist/enums/moduleKind.d.ts +0 -2
  613. package/node_modules/typescript-7/dist/enums/moduleKind.d.ts.map +0 -1
  614. package/node_modules/typescript-7/dist/enums/moduleKind.enum.d.ts +0 -17
  615. package/node_modules/typescript-7/dist/enums/moduleKind.enum.d.ts.map +0 -1
  616. package/node_modules/typescript-7/dist/enums/moduleKind.enum.js +0 -19
  617. package/node_modules/typescript-7/dist/enums/moduleKind.enum.js.map +0 -1
  618. package/node_modules/typescript-7/dist/enums/moduleKind.js +0 -19
  619. package/node_modules/typescript-7/dist/enums/moduleKind.js.map +0 -1
  620. package/node_modules/typescript-7/dist/enums/moduleResolutionKind.d.ts +0 -2
  621. package/node_modules/typescript-7/dist/enums/moduleResolutionKind.d.ts.map +0 -1
  622. package/node_modules/typescript-7/dist/enums/moduleResolutionKind.enum.d.ts +0 -9
  623. package/node_modules/typescript-7/dist/enums/moduleResolutionKind.enum.d.ts.map +0 -1
  624. package/node_modules/typescript-7/dist/enums/moduleResolutionKind.enum.js +0 -11
  625. package/node_modules/typescript-7/dist/enums/moduleResolutionKind.enum.js.map +0 -1
  626. package/node_modules/typescript-7/dist/enums/moduleResolutionKind.js +0 -11
  627. package/node_modules/typescript-7/dist/enums/moduleResolutionKind.js.map +0 -1
  628. package/node_modules/typescript-7/dist/enums/newLineKind.d.ts +0 -2
  629. package/node_modules/typescript-7/dist/enums/newLineKind.d.ts.map +0 -1
  630. package/node_modules/typescript-7/dist/enums/newLineKind.enum.d.ts +0 -6
  631. package/node_modules/typescript-7/dist/enums/newLineKind.enum.d.ts.map +0 -1
  632. package/node_modules/typescript-7/dist/enums/newLineKind.enum.js +0 -8
  633. package/node_modules/typescript-7/dist/enums/newLineKind.enum.js.map +0 -1
  634. package/node_modules/typescript-7/dist/enums/newLineKind.js +0 -8
  635. package/node_modules/typescript-7/dist/enums/newLineKind.js.map +0 -1
  636. package/node_modules/typescript-7/dist/enums/nodeBuilderFlags.d.ts +0 -2
  637. package/node_modules/typescript-7/dist/enums/nodeBuilderFlags.d.ts.map +0 -1
  638. package/node_modules/typescript-7/dist/enums/nodeBuilderFlags.enum.d.ts +0 -36
  639. package/node_modules/typescript-7/dist/enums/nodeBuilderFlags.enum.d.ts.map +0 -1
  640. package/node_modules/typescript-7/dist/enums/nodeBuilderFlags.enum.js +0 -38
  641. package/node_modules/typescript-7/dist/enums/nodeBuilderFlags.enum.js.map +0 -1
  642. package/node_modules/typescript-7/dist/enums/nodeBuilderFlags.js +0 -38
  643. package/node_modules/typescript-7/dist/enums/nodeBuilderFlags.js.map +0 -1
  644. package/node_modules/typescript-7/dist/enums/nodeFlags.d.ts +0 -2
  645. package/node_modules/typescript-7/dist/enums/nodeFlags.d.ts.map +0 -1
  646. package/node_modules/typescript-7/dist/enums/nodeFlags.enum.d.ts +0 -44
  647. package/node_modules/typescript-7/dist/enums/nodeFlags.enum.d.ts.map +0 -1
  648. package/node_modules/typescript-7/dist/enums/nodeFlags.enum.js +0 -46
  649. package/node_modules/typescript-7/dist/enums/nodeFlags.enum.js.map +0 -1
  650. package/node_modules/typescript-7/dist/enums/nodeFlags.js +0 -46
  651. package/node_modules/typescript-7/dist/enums/nodeFlags.js.map +0 -1
  652. package/node_modules/typescript-7/dist/enums/objectFlags.d.ts +0 -2
  653. package/node_modules/typescript-7/dist/enums/objectFlags.d.ts.map +0 -1
  654. package/node_modules/typescript-7/dist/enums/objectFlags.enum.d.ts +0 -50
  655. package/node_modules/typescript-7/dist/enums/objectFlags.enum.d.ts.map +0 -1
  656. package/node_modules/typescript-7/dist/enums/objectFlags.enum.js +0 -52
  657. package/node_modules/typescript-7/dist/enums/objectFlags.enum.js.map +0 -1
  658. package/node_modules/typescript-7/dist/enums/objectFlags.js +0 -52
  659. package/node_modules/typescript-7/dist/enums/objectFlags.js.map +0 -1
  660. package/node_modules/typescript-7/dist/enums/outerExpressionKinds.d.ts +0 -2
  661. package/node_modules/typescript-7/dist/enums/outerExpressionKinds.d.ts.map +0 -1
  662. package/node_modules/typescript-7/dist/enums/outerExpressionKinds.enum.d.ts +0 -16
  663. package/node_modules/typescript-7/dist/enums/outerExpressionKinds.enum.d.ts.map +0 -1
  664. package/node_modules/typescript-7/dist/enums/outerExpressionKinds.enum.js +0 -18
  665. package/node_modules/typescript-7/dist/enums/outerExpressionKinds.enum.js.map +0 -1
  666. package/node_modules/typescript-7/dist/enums/outerExpressionKinds.js +0 -18
  667. package/node_modules/typescript-7/dist/enums/outerExpressionKinds.js.map +0 -1
  668. package/node_modules/typescript-7/dist/enums/regularExpressionFlags.d.ts +0 -2
  669. package/node_modules/typescript-7/dist/enums/regularExpressionFlags.d.ts.map +0 -1
  670. package/node_modules/typescript-7/dist/enums/regularExpressionFlags.enum.d.ts +0 -13
  671. package/node_modules/typescript-7/dist/enums/regularExpressionFlags.enum.d.ts.map +0 -1
  672. package/node_modules/typescript-7/dist/enums/regularExpressionFlags.enum.js +0 -14
  673. package/node_modules/typescript-7/dist/enums/regularExpressionFlags.enum.js.map +0 -1
  674. package/node_modules/typescript-7/dist/enums/regularExpressionFlags.js +0 -14
  675. package/node_modules/typescript-7/dist/enums/regularExpressionFlags.js.map +0 -1
  676. package/node_modules/typescript-7/dist/enums/scriptKind.d.ts +0 -2
  677. package/node_modules/typescript-7/dist/enums/scriptKind.d.ts.map +0 -1
  678. package/node_modules/typescript-7/dist/enums/scriptKind.enum.d.ts +0 -11
  679. package/node_modules/typescript-7/dist/enums/scriptKind.enum.d.ts.map +0 -1
  680. package/node_modules/typescript-7/dist/enums/scriptKind.enum.js +0 -12
  681. package/node_modules/typescript-7/dist/enums/scriptKind.enum.js.map +0 -1
  682. package/node_modules/typescript-7/dist/enums/scriptKind.js +0 -12
  683. package/node_modules/typescript-7/dist/enums/scriptKind.js.map +0 -1
  684. package/node_modules/typescript-7/dist/enums/scriptTarget.d.ts +0 -2
  685. package/node_modules/typescript-7/dist/enums/scriptTarget.d.ts.map +0 -1
  686. package/node_modules/typescript-7/dist/enums/scriptTarget.enum.d.ts +0 -17
  687. package/node_modules/typescript-7/dist/enums/scriptTarget.enum.d.ts.map +0 -1
  688. package/node_modules/typescript-7/dist/enums/scriptTarget.enum.js +0 -18
  689. package/node_modules/typescript-7/dist/enums/scriptTarget.enum.js.map +0 -1
  690. package/node_modules/typescript-7/dist/enums/scriptTarget.js +0 -18
  691. package/node_modules/typescript-7/dist/enums/scriptTarget.js.map +0 -1
  692. package/node_modules/typescript-7/dist/enums/signatureFlags.d.ts +0 -2
  693. package/node_modules/typescript-7/dist/enums/signatureFlags.d.ts.map +0 -1
  694. package/node_modules/typescript-7/dist/enums/signatureFlags.enum.d.ts +0 -15
  695. package/node_modules/typescript-7/dist/enums/signatureFlags.enum.d.ts.map +0 -1
  696. package/node_modules/typescript-7/dist/enums/signatureFlags.enum.js +0 -17
  697. package/node_modules/typescript-7/dist/enums/signatureFlags.enum.js.map +0 -1
  698. package/node_modules/typescript-7/dist/enums/signatureFlags.js +0 -17
  699. package/node_modules/typescript-7/dist/enums/signatureFlags.js.map +0 -1
  700. package/node_modules/typescript-7/dist/enums/signatureKind.d.ts +0 -2
  701. package/node_modules/typescript-7/dist/enums/signatureKind.d.ts.map +0 -1
  702. package/node_modules/typescript-7/dist/enums/signatureKind.enum.d.ts +0 -5
  703. package/node_modules/typescript-7/dist/enums/signatureKind.enum.d.ts.map +0 -1
  704. package/node_modules/typescript-7/dist/enums/signatureKind.enum.js +0 -7
  705. package/node_modules/typescript-7/dist/enums/signatureKind.enum.js.map +0 -1
  706. package/node_modules/typescript-7/dist/enums/signatureKind.js +0 -7
  707. package/node_modules/typescript-7/dist/enums/signatureKind.js.map +0 -1
  708. package/node_modules/typescript-7/dist/enums/symbolFlags.d.ts +0 -2
  709. package/node_modules/typescript-7/dist/enums/symbolFlags.d.ts.map +0 -1
  710. package/node_modules/typescript-7/dist/enums/symbolFlags.enum.d.ts +0 -71
  711. package/node_modules/typescript-7/dist/enums/symbolFlags.enum.d.ts.map +0 -1
  712. package/node_modules/typescript-7/dist/enums/symbolFlags.enum.js +0 -73
  713. package/node_modules/typescript-7/dist/enums/symbolFlags.enum.js.map +0 -1
  714. package/node_modules/typescript-7/dist/enums/symbolFlags.js +0 -73
  715. package/node_modules/typescript-7/dist/enums/symbolFlags.js.map +0 -1
  716. package/node_modules/typescript-7/dist/enums/syntaxKind.d.ts +0 -2
  717. package/node_modules/typescript-7/dist/enums/syntaxKind.d.ts.map +0 -1
  718. package/node_modules/typescript-7/dist/enums/syntaxKind.enum.d.ts +0 -389
  719. package/node_modules/typescript-7/dist/enums/syntaxKind.enum.d.ts.map +0 -1
  720. package/node_modules/typescript-7/dist/enums/syntaxKind.enum.js +0 -391
  721. package/node_modules/typescript-7/dist/enums/syntaxKind.enum.js.map +0 -1
  722. package/node_modules/typescript-7/dist/enums/syntaxKind.js +0 -391
  723. package/node_modules/typescript-7/dist/enums/syntaxKind.js.map +0 -1
  724. package/node_modules/typescript-7/dist/enums/tokenFlags.d.ts +0 -2
  725. package/node_modules/typescript-7/dist/enums/tokenFlags.d.ts.map +0 -1
  726. package/node_modules/typescript-7/dist/enums/tokenFlags.enum.d.ts +0 -30
  727. package/node_modules/typescript-7/dist/enums/tokenFlags.enum.d.ts.map +0 -1
  728. package/node_modules/typescript-7/dist/enums/tokenFlags.enum.js +0 -32
  729. package/node_modules/typescript-7/dist/enums/tokenFlags.enum.js.map +0 -1
  730. package/node_modules/typescript-7/dist/enums/tokenFlags.js +0 -32
  731. package/node_modules/typescript-7/dist/enums/tokenFlags.js.map +0 -1
  732. package/node_modules/typescript-7/dist/enums/typeFlags.d.ts +0 -2
  733. package/node_modules/typescript-7/dist/enums/typeFlags.d.ts.map +0 -1
  734. package/node_modules/typescript-7/dist/enums/typeFlags.enum.d.ts +0 -76
  735. package/node_modules/typescript-7/dist/enums/typeFlags.enum.d.ts.map +0 -1
  736. package/node_modules/typescript-7/dist/enums/typeFlags.enum.js +0 -78
  737. package/node_modules/typescript-7/dist/enums/typeFlags.enum.js.map +0 -1
  738. package/node_modules/typescript-7/dist/enums/typeFlags.js +0 -78
  739. package/node_modules/typescript-7/dist/enums/typeFlags.js.map +0 -1
  740. package/node_modules/typescript-7/dist/enums/typePredicateKind.d.ts +0 -2
  741. package/node_modules/typescript-7/dist/enums/typePredicateKind.d.ts.map +0 -1
  742. package/node_modules/typescript-7/dist/enums/typePredicateKind.enum.d.ts +0 -7
  743. package/node_modules/typescript-7/dist/enums/typePredicateKind.enum.d.ts.map +0 -1
  744. package/node_modules/typescript-7/dist/enums/typePredicateKind.enum.js +0 -9
  745. package/node_modules/typescript-7/dist/enums/typePredicateKind.enum.js.map +0 -1
  746. package/node_modules/typescript-7/dist/enums/typePredicateKind.js +0 -9
  747. package/node_modules/typescript-7/dist/enums/typePredicateKind.js.map +0 -1
  748. package/node_modules/typescript-7/dist/internal/utils.d.ts +0 -23
  749. package/node_modules/typescript-7/dist/internal/utils.d.ts.map +0 -1
  750. package/node_modules/typescript-7/dist/internal/utils.js +0 -25
  751. package/node_modules/typescript-7/dist/internal/utils.js.map +0 -1
  752. package/node_modules/typescript-7/lib/getExePath.d.ts +0 -2
  753. package/node_modules/typescript-7/lib/getExePath.js +0 -70
  754. package/node_modules/typescript-7/lib/tsc.js +0 -28
  755. package/node_modules/typescript-7/lib/version.cjs +0 -3
  756. package/node_modules/typescript-7/lib/version.d.cts +0 -2
  757. package/node_modules/typescript-7/package.json +0 -87
  758. package/node_modules/typescript-7/vendor/vscode-jsonrpc/License.txt +0 -11
  759. package/node_modules/typescript-7/vendor/vscode-jsonrpc/README.md +0 -54
  760. package/node_modules/typescript-7/vendor/vscode-jsonrpc/lib/browser/main.d.ts +0 -17
  761. package/node_modules/typescript-7/vendor/vscode-jsonrpc/lib/browser/main.js +0 -83
  762. package/node_modules/typescript-7/vendor/vscode-jsonrpc/lib/browser/ril.d.ts +0 -22
  763. package/node_modules/typescript-7/vendor/vscode-jsonrpc/lib/browser/ril.js +0 -210
  764. package/node_modules/typescript-7/vendor/vscode-jsonrpc/lib/common/api.d.ts +0 -14
  765. package/node_modules/typescript-7/vendor/vscode-jsonrpc/lib/common/api.js +0 -87
  766. package/node_modules/typescript-7/vendor/vscode-jsonrpc/lib/common/cancellation.d.ts +0 -32
  767. package/node_modules/typescript-7/vendor/vscode-jsonrpc/lib/common/cancellation.js +0 -132
  768. package/node_modules/typescript-7/vendor/vscode-jsonrpc/lib/common/connection.d.ts +0 -367
  769. package/node_modules/typescript-7/vendor/vscode-jsonrpc/lib/common/connection.js +0 -1271
  770. package/node_modules/typescript-7/vendor/vscode-jsonrpc/lib/common/disposable.d.ts +0 -9
  771. package/node_modules/typescript-7/vendor/vscode-jsonrpc/lib/common/disposable.js +0 -16
  772. package/node_modules/typescript-7/vendor/vscode-jsonrpc/lib/common/encoding.d.ts +0 -52
  773. package/node_modules/typescript-7/vendor/vscode-jsonrpc/lib/common/encoding.js +0 -70
  774. package/node_modules/typescript-7/vendor/vscode-jsonrpc/lib/common/events.d.ts +0 -39
  775. package/node_modules/typescript-7/vendor/vscode-jsonrpc/lib/common/events.js +0 -135
  776. package/node_modules/typescript-7/vendor/vscode-jsonrpc/lib/common/is.d.ts +0 -7
  777. package/node_modules/typescript-7/vendor/vscode-jsonrpc/lib/common/is.js +0 -34
  778. package/node_modules/typescript-7/vendor/vscode-jsonrpc/lib/common/linkedMap.d.ts +0 -55
  779. package/node_modules/typescript-7/vendor/vscode-jsonrpc/lib/common/linkedMap.js +0 -412
  780. package/node_modules/typescript-7/vendor/vscode-jsonrpc/lib/common/messageBuffer.d.ts +0 -18
  781. package/node_modules/typescript-7/vendor/vscode-jsonrpc/lib/common/messageBuffer.js +0 -155
  782. package/node_modules/typescript-7/vendor/vscode-jsonrpc/lib/common/messageReader.d.ts +0 -77
  783. package/node_modules/typescript-7/vendor/vscode-jsonrpc/lib/common/messageReader.js +0 -246
  784. package/node_modules/typescript-7/vendor/vscode-jsonrpc/lib/common/messageWriter.d.ts +0 -60
  785. package/node_modules/typescript-7/vendor/vscode-jsonrpc/lib/common/messageWriter.js +0 -157
  786. package/node_modules/typescript-7/vendor/vscode-jsonrpc/lib/common/messages.d.ts +0 -369
  787. package/node_modules/typescript-7/vendor/vscode-jsonrpc/lib/common/messages.js +0 -436
  788. package/node_modules/typescript-7/vendor/vscode-jsonrpc/lib/common/ral.d.ts +0 -74
  789. package/node_modules/typescript-7/vendor/vscode-jsonrpc/lib/common/ral.js +0 -23
  790. package/node_modules/typescript-7/vendor/vscode-jsonrpc/lib/common/semaphore.d.ts +0 -10
  791. package/node_modules/typescript-7/vendor/vscode-jsonrpc/lib/common/semaphore.js +0 -74
  792. package/node_modules/typescript-7/vendor/vscode-jsonrpc/lib/common/sharedArrayCancellation.d.ts +0 -15
  793. package/node_modules/typescript-7/vendor/vscode-jsonrpc/lib/common/sharedArrayCancellation.js +0 -77
  794. package/node_modules/typescript-7/vendor/vscode-jsonrpc/lib/node/main.d.ts +0 -58
  795. package/node_modules/typescript-7/vendor/vscode-jsonrpc/lib/node/main.js +0 -289
  796. package/node_modules/typescript-7/vendor/vscode-jsonrpc/lib/node/ril.d.ts +0 -12
  797. package/node_modules/typescript-7/vendor/vscode-jsonrpc/lib/node/ril.js +0 -163
  798. package/node_modules/typescript-7/vendor/vscode-jsonrpc/package.json +0 -54
  799. package/node_modules/typescript-7/vendor/vscode-jsonrpc/typings/thenable.d.ts +0 -5
  800. /package/node_modules/@ykdz/{template-workspace/dist/generation-context.js → default-content-authoring/dist/contracts.js} +0 -0
  801. /package/node_modules/@ykdz/{template-workspace → default-content-authoring}/dist/environment-needs.js +0 -0
  802. /package/node_modules/@ykdz/{template-workspace/dist/default-package-role.d.ts → default-content-authoring/dist/package-role.d.ts} +0 -0
  803. /package/node_modules/@ykdz/{template-workspace/dist/default-package-role.js → default-content-authoring/dist/package-role.js} +0 -0
  804. /package/node_modules/@ykdz/{template-workspace/assets/environment → reference-rust-bin/native/resources}/devcontainer/rust.Dockerfile +0 -0
  805. /package/node_modules/@ykdz/{template-workspace/assets → reference-workspace-root/native/resources}/agent-instructions.md +0 -0
  806. /package/node_modules/@ykdz/{template-workspace/assets → reference-workspace-root/native/resources}/environment/base.Dockerfile +0 -0
  807. /package/node_modules/@ykdz/{template-workspace/assets → reference-workspace-root/native/resources}/environment/devcontainer/browser-test.Dockerfile +0 -0
  808. /package/node_modules/@ykdz/{template-workspace/assets → reference-workspace-root/native/resources}/environment/devcontainer/github-cli.Dockerfile +0 -0
  809. /package/node_modules/@ykdz/{template-workspace/assets → reference-workspace-root/native/resources}/environment/devcontainer/shellcheck.Dockerfile +0 -0
  810. /package/node_modules/@ykdz/{template-workspace/assets → reference-workspace-root/native/resources}/environment/devcontainer/workspace-template.json +0 -0
  811. /package/node_modules/@ykdz/{template-workspace/assets → reference-workspace-root/native/resources}/environment/editor-customization/capabilities.json +0 -0
  812. /package/node_modules/@ykdz/{template-workspace/assets → reference-workspace-root/native/resources}/github/check.yml +0 -0
  813. /package/node_modules/@ykdz/{template-workspace/assets → reference-workspace-root/native/resources}/github/dependabot.yml +0 -0
  814. /package/node_modules/@ykdz/{template-workspace/assets → reference-workspace-root/native/resources}/gitignore +0 -0
  815. /package/node_modules/@ykdz/{template-workspace/assets → reference-workspace-root/native/resources}/next-steps.md +0 -0
  816. /package/node_modules/@ykdz/{template-workspace → reference-workspace-root/native}/scripts/task-gates.ts +0 -0
  817. /package/node_modules/@ykdz/{template-workspace/dist → reference-workspace-root/native/template-dist}/editor-customization.js +0 -0
@@ -1,1147 +1,2015 @@
1
1
  import { createHash } from "node:crypto";
2
- import { readFile } from "node:fs/promises";
2
+ import { lstat, readFile } from "node:fs/promises";
3
3
  import path from "node:path";
4
4
  import { isDeepStrictEqual } from "node:util";
5
5
  import { assertContentIdentity, contentIdentityKey, contentIdentityLabel, createContentIndex, } from "@ykdz/template-core/content-identity";
6
- import { assertPackageContribution, } from "@ykdz/template-core/package-contribution";
7
- import { assertProjectBlueprint, } from "@ykdz/template-core/project-blueprint";
8
- import { reconcileAndApplyProjectProjections, materializeProjectProjection, } from "@ykdz/template-core/project-projection";
9
- import { renderNewProject } from "@ykdz/template-core/renderer";
10
- import { parseGenerationRecordStructure } from "@ykdz/template-core/workspace-strategy";
11
- export { generationRecordSchema } from "@ykdz/template-core/workspace-strategy";
12
- function packageIdentity(definition) {
6
+ import { assertGenerationRecordMatchesBlueprint, parseGenerationRecordStructure, } from "@ykdz/template-core/generation-record";
7
+ import { assertJsonValue, printCanonicalJson, } from "@ykdz/template-core/json";
8
+ import { projectPackageContributions, } from "@ykdz/template-core/package-contribution";
9
+ import { assertProjectBlueprint, ProjectBlueprintValidationError, } from "@ykdz/template-core/project-blueprint";
10
+ import { commitProjectProjectionPlan, planProjectProjections, readProjectProjectionCurrent, } from "@ykdz/template-core/project-projection";
11
+ import { resolveReferenceDependencyIdentity } from "./owner-local-reference.js";
12
+ export { generationRecordSchema, parseGenerationRecordStructure, } from "@ykdz/template-core/generation-record";
13
+ export const generatorMetadataPaths = Object.freeze({
14
+ blueprint: ".template/blueprint.json",
15
+ generationRecord: ".template/generation.json",
16
+ });
17
+ export { resolveReferenceDependencyIdentity } from "./owner-local-reference.js";
18
+ function isRecord(value) {
19
+ return typeof value === "object" && value !== null && !Array.isArray(value);
20
+ }
21
+ function packageId(value) {
22
+ const digest = createHash("sha256")
23
+ .update(printCanonicalJson(value))
24
+ .digest("hex");
25
+ return `package-${digest}`;
26
+ }
27
+ function selectionId(value) {
28
+ const digest = createHash("sha256")
29
+ .update(printCanonicalJson(value))
30
+ .digest("hex");
31
+ return `selection-${digest}`;
32
+ }
33
+ function comparePaths(left, right) {
34
+ return left < right ? -1 : left > right ? 1 : 0;
35
+ }
36
+ function mergeProjectionSources(...groups) {
37
+ const sources = new Map();
38
+ for (const group of groups) {
39
+ for (const source of group ?? []) {
40
+ if (!sources.has(source.identity)) {
41
+ sources.set(source.identity, { ...source });
42
+ }
43
+ }
44
+ }
45
+ return [...sources.values()];
46
+ }
47
+ function projectionPath(packagePath, relativePath) {
48
+ return packagePath === "." ? relativePath : `${packagePath}/${relativePath}`;
49
+ }
50
+ function errorMessage(error) {
51
+ return error instanceof Error ? error.message : String(error);
52
+ }
53
+ function dependencyIdentityCacheKey(consumer, dependencyKey) {
54
+ return JSON.stringify([contentIdentityKey(consumer), dependencyKey]);
55
+ }
56
+ function conflictReason(conflicts) {
57
+ return conflicts.map((conflict) => conflict.reason).join("\n");
58
+ }
59
+ function preserveProjectionPaths(before, after) {
60
+ const entries = new Map(after.entries.map((entry) => [entry.path, entry]));
61
+ for (const entry of before.entries) {
62
+ if (!entries.has(entry.path))
63
+ entries.set(entry.path, entry);
64
+ }
65
+ const reconciliation = new Map(after.reconciliation.map((policy) => [policy.path, policy]));
66
+ for (const policy of before.reconciliation) {
67
+ if (!reconciliation.has(policy.path)) {
68
+ reconciliation.set(policy.path, policy);
69
+ }
70
+ }
13
71
  return {
14
- name: definition.name,
15
- path: definition.path,
16
- role: definition.role,
72
+ entries: [...entries.values()].toSorted((left, right) => comparePaths(left.path, right.path)),
73
+ reconciliation: [...reconciliation.values()].toSorted((left, right) => comparePaths(left.path, right.path)),
17
74
  };
18
75
  }
19
- function isRecord(value) {
20
- return typeof value === "object" && value !== null && !Array.isArray(value);
76
+ function isCanonicalRelativeFilePath(value) {
77
+ return (value.length > 0 &&
78
+ !value.includes("\0") &&
79
+ !value.includes("\\") &&
80
+ !value.startsWith("/") &&
81
+ value !== "." &&
82
+ value
83
+ .split("/")
84
+ .every((part) => part.length > 0 && part !== "." && part !== ".."));
21
85
  }
22
- function isPresetDefinition(value) {
23
- return isRecord(value) && value.kind === "preset" && isRecord(value.nodes);
86
+ function isNestedDirectory(parent, child) {
87
+ return parent === "." ? child !== "." : child.startsWith(`${parent}/`);
24
88
  }
25
- function isLoadedPreset(value) {
26
- return (isRecord(value) &&
27
- value.kind === "preset" &&
28
- isRecord(value.definition) &&
29
- isPresetDefinition(value.definition));
89
+ function packageDefinition(value) {
90
+ assertProjectBlueprint({
91
+ schemaVersion: 4,
92
+ packages: [{ packageDefinitionId: `package-${"0".repeat(64)}`, ...value }],
93
+ packageLinkIntents: [],
94
+ });
95
+ return { ...value };
96
+ }
97
+ function preparationSnapshot(value) {
98
+ if (!isRecord(value) || !Array.isArray(value.resources)) {
99
+ throw new Error("参考包准备结果必须是资源快照");
100
+ }
101
+ const paths = new Set();
102
+ const resources = value.resources.map((resource) => {
103
+ if (!isRecord(resource) ||
104
+ typeof resource.path !== "string" ||
105
+ !isCanonicalRelativeFilePath(resource.path) ||
106
+ !(resource.content instanceof Uint8Array) ||
107
+ !Number.isInteger(resource.mode) ||
108
+ resource.mode < 0 ||
109
+ (resource.mode & ~0o111) !== 0) {
110
+ throw new Error("参考包准备结果包含无效资源文件");
111
+ }
112
+ if (paths.has(resource.path)) {
113
+ throw new Error(`参考包准备结果包含重复资源:${resource.path}`);
114
+ }
115
+ paths.add(resource.path);
116
+ return {
117
+ path: resource.path,
118
+ content: resource.content.slice(),
119
+ mode: resource.mode,
120
+ };
121
+ });
122
+ return {
123
+ resources,
124
+ facts: structuredClone(value.facts),
125
+ };
126
+ }
127
+ function clonePreparation(value) {
128
+ return {
129
+ resources: value.resources.map((resource) => ({
130
+ path: resource.path,
131
+ content: resource.content.slice(),
132
+ mode: resource.mode,
133
+ })),
134
+ facts: structuredClone(value.facts),
135
+ };
136
+ }
137
+ function requireParsedCreationInput(content, value) {
138
+ if (value === undefined)
139
+ return undefined;
140
+ const parsed = content.definition.parseCreationInput(value);
141
+ assertJsonValue(parsed, "包创建输入");
142
+ return parsed;
30
143
  }
31
144
  function mergeCreationInput(defaults, supplied) {
32
145
  if (defaults === undefined)
33
146
  return supplied;
34
147
  if (supplied === undefined)
35
148
  return defaults;
149
+ if (!isRecord(defaults) || !isRecord(supplied)) {
150
+ throw new Error("预设创建输入只能通过对象进行补充");
151
+ }
36
152
  return { ...defaults, ...supplied };
37
153
  }
38
- function fail(phase, error, diagnostic) {
39
- return {
40
- status: "operation-failure",
41
- phase,
42
- error: {
43
- message: error instanceof Error ? error.message : String(error),
44
- ...(diagnostic === undefined ? {} : { diagnostic }),
45
- },
154
+ function excludedPackagePaths(definition, selectedPaths) {
155
+ return selectedPaths
156
+ .filter((candidate) => isNestedDirectory(definition.path, candidate))
157
+ .map((candidate) => definition.path === "."
158
+ ? candidate
159
+ : candidate.slice(definition.path.length + 1));
160
+ }
161
+ function packageNodePaths(roots) {
162
+ const paths = [];
163
+ const visited = new Set();
164
+ const visit = (root) => {
165
+ if (visited.has(root))
166
+ return;
167
+ visited.add(root);
168
+ paths.push(root.definition.path);
169
+ for (const dependency of root.dependencies) {
170
+ visit(dependency.package);
171
+ }
46
172
  };
173
+ for (const root of roots)
174
+ visit(root);
175
+ return paths;
47
176
  }
48
- class AdditionPlanningFailure extends Error {
49
- constructor(error) {
50
- super(error instanceof Error ? error.message : String(error), {
51
- cause: error,
177
+ function assertAcyclicPackageDrafts(roots, explicitlySelectedSharedReferences) {
178
+ const visiting = new Set();
179
+ const completed = new Map();
180
+ const packageIdFor = (node, parentId, dependencyKey) => {
181
+ if (node.restored !== undefined) {
182
+ return node.restored.packageDefinitionId;
183
+ }
184
+ const identityKey = contentIdentityKey(node.content.identity);
185
+ const shared = node.content.definition.instance === "shared";
186
+ const explicitRoot = shared ? undefined : node.explicitRoot;
187
+ const createdBy = explicitRoot?.createdBy ??
188
+ (shared
189
+ ? explicitlySelectedSharedReferences.get(identityKey)
190
+ : undefined) ??
191
+ (parentId === undefined ? "initialization" : "shared-dependency");
192
+ const discriminator = shared
193
+ ? "shared-reference"
194
+ : explicitRoot === undefined
195
+ ? parentId === undefined || dependencyKey === undefined
196
+ ? undefined
197
+ : `${parentId}:${dependencyKey}`
198
+ : `${explicitRoot.selectionId}:${explicitRoot.nodeIdentity}`;
199
+ if (discriminator === undefined) {
200
+ throw new Error("参考包实例缺少明确的创建地址");
201
+ }
202
+ return packageId({
203
+ contentIdentity: node.content.identity,
204
+ definition: node.definition,
205
+ creationInput: node.creationInput ?? null,
206
+ createdBy,
207
+ discriminator,
52
208
  });
53
- }
54
- }
55
- function readJson(value, label) {
56
- if (!isRecord(value))
57
- throw new Error(label + " must be an object");
58
- return value;
59
- }
60
- function presetSelectionKey(identity) {
61
- return contentIdentityKey(identity);
62
- }
63
- function parsePresetSelections(value) {
64
- if (!Array.isArray(value))
65
- throw new Error("生成记录的预设选择无效");
66
- const seen = new Set();
67
- return value.map((item) => {
68
- const selection = readJson(item, "生成记录预设选择");
69
- assertContentIdentity(selection);
70
- const key = presetSelectionKey(selection);
71
- if (seen.has(key))
72
- throw new Error("生成记录的预设选择重复");
73
- seen.add(key);
74
- return { ...selection };
75
- });
76
- }
77
- export function parseGenerationRecord(value) {
78
- const record = parseGenerationRecordStructure(value);
79
- const nodeInstances = record.nodeInstances;
80
- const packageIds = new Set();
81
- for (const packageRecord of record.packages) {
82
- assertContentIdentity(packageRecord.contentIdentity);
83
- if (packageIds.has(packageRecord.packageDefinitionId)) {
84
- throw new Error("生成记录包含重复包实例:" + packageRecord.packageDefinitionId);
85
- }
86
- packageIds.add(packageRecord.packageDefinitionId);
87
- }
88
- for (const packageRecord of record.packages) {
89
- for (const [identity, packageDefinitionId] of Object.entries(packageRecord.bindings)) {
90
- if (identity.length === 0 || !packageIds.has(packageDefinitionId)) {
91
- throw new Error(`生成记录中的内容 ${contentIdentityLabel(packageRecord.contentIdentity)} 包含无效实例绑定:${identity}`);
209
+ };
210
+ const visit = (node, parentId, dependencyKey) => {
211
+ const id = packageIdFor(node, parentId, dependencyKey);
212
+ if (visiting.has(id)) {
213
+ throw new Error("预设节点依赖形成循环");
214
+ }
215
+ const edges = node.dependencies.map((dependency) => ({
216
+ key: dependency.key,
217
+ packageId: packageIdFor(dependency.package, id, dependency.key),
218
+ }));
219
+ const previousEdges = completed.get(id);
220
+ if (previousEdges !== undefined) {
221
+ if (!isDeepStrictEqual(previousEdges, edges)) {
222
+ throw new Error("共享参考包的依赖绑定不一致");
92
223
  }
224
+ return;
93
225
  }
94
- }
95
- for (const [nodeIdentity, packageDefinitionId] of Object.entries(nodeInstances)) {
96
- if (nodeIdentity.length === 0 ||
97
- typeof packageDefinitionId !== "string" ||
98
- !packageIds.has(packageDefinitionId)) {
99
- throw new Error("生成记录的节点实例映射无效");
226
+ visiting.add(id);
227
+ for (const dependency of node.dependencies) {
228
+ visit(dependency.package, id, dependency.key);
100
229
  }
101
- }
102
- const presetSelections = parsePresetSelections(record.presetSelections);
103
- return {
104
- schemaVersion: 4,
105
- strategyIdentity: record.strategyIdentity,
106
- strategyState: record.strategyState,
107
- packages: record.packages,
108
- nodeInstances: nodeInstances,
109
- presetSelections,
230
+ visiting.delete(id);
231
+ completed.set(id, edges);
110
232
  };
233
+ for (const root of roots)
234
+ visit(root);
111
235
  }
112
- function packageId(options) {
113
- const facts = {
114
- domain: "ykdz.template.generator.package-instance.v1",
115
- contentIdentity: options.contentIdentity,
116
- createdBy: options.createdBy,
117
- definition: options.definition,
118
- };
119
- let nonce = 0;
120
- for (;;) {
121
- const value = nonce === 0
122
- ? facts
123
- : { facts, occupied: [...options.occupied].toSorted(), nonce };
124
- const candidate = "package-" +
125
- createHash("sha256").update(JSON.stringify(value)).digest("hex");
126
- if (!options.occupied.has(candidate)) {
127
- return candidate;
128
- }
129
- nonce += 1;
236
+ function requireUniqueNodes(roots) {
237
+ const seen = new Set();
238
+ for (const root of roots) {
239
+ if (!/^[a-z][a-z0-9-]*$/u.test(root.nodeIdentity)) {
240
+ throw new Error(`选择节点标识无效:${root.nodeIdentity}`);
241
+ }
242
+ if (seen.has(root.nodeIdentity)) {
243
+ throw new Error(`选择节点标识必须唯一:${root.nodeIdentity}`);
244
+ }
245
+ seen.add(root.nodeIdentity);
130
246
  }
131
247
  }
132
248
  export function createGenerator(options) {
249
+ assertContentIdentity(options.composition.identity);
133
250
  const contentIndex = createContentIndex(options.content);
134
- const contentMembers = contentIndex.members.filter((member) => member.kind === "reference");
135
- const presetMembers = contentIndex.members.filter(isLoadedPreset);
136
- const contentByIdentity = new Map(contentMembers.map((content) => [
137
- contentIdentityKey(content.identity),
138
- content,
139
- ]));
140
- const preparations = new WeakMap();
141
- const preparedDefinitions = new WeakSet();
142
- const prepareContent = (content) => {
143
- const definition = content.definition;
144
- if (preparedDefinitions.has(definition))
145
- return preparations.get(definition);
146
- const preparation = definition.prepare?.();
147
- preparations.set(definition, preparation);
148
- preparedDefinitions.add(definition);
149
- return preparation;
251
+ const composition = options.composition;
252
+ const emptyProjectProjection = {
253
+ entries: [],
254
+ reconciliation: [],
150
255
  };
151
- const presetsByIdentity = new Map();
152
- for (const presetMember of presetMembers) {
153
- const preset = presetMember.definition;
154
- const identityKey = contentIdentityKey(presetMember.identity);
155
- if (presetsByIdentity.has(identityKey)) {
156
- throw new Error(`预设规范身份重复:${contentIdentityLabel(presetMember.identity)}`);
157
- }
158
- presetsByIdentity.set(identityKey, presetMember);
159
- for (const node of Object.values(preset.nodes)) {
160
- try {
161
- contentIndex.fromDefinition(node.reference, "reference", {
162
- namespace: presetMember.identity.namespace,
256
+ const pendingPlans = new WeakMap();
257
+ const readMetadataFact = async (targetRoot, metadataPath) => {
258
+ const filePath = path.join(targetRoot, metadataPath);
259
+ try {
260
+ const stat = await lstat(filePath);
261
+ if (!stat.isFile()) {
262
+ return {
263
+ path: metadataPath,
264
+ kind: stat.isDirectory()
265
+ ? "directory"
266
+ : stat.isSymbolicLink()
267
+ ? "symbolic-link"
268
+ : "other",
269
+ };
270
+ }
271
+ return {
272
+ path: metadataPath,
273
+ kind: "file",
274
+ content: new Uint8Array(await readFile(filePath)),
275
+ mode: stat.mode & 0o111,
276
+ };
277
+ }
278
+ catch (error) {
279
+ if (error instanceof Error &&
280
+ "code" in error &&
281
+ (error.code === "ENOENT" || error.code === "ENOTDIR")) {
282
+ return { path: metadataPath, kind: "missing" };
283
+ }
284
+ throw error;
285
+ }
286
+ };
287
+ const readRestoredProject = async (targetRoot) => {
288
+ const paths = [
289
+ generatorMetadataPaths.blueprint,
290
+ generatorMetadataPaths.generationRecord,
291
+ ];
292
+ const readFacts = await Promise.all(paths.map((metadataPath) => readMetadataFact(targetRoot, metadataPath)));
293
+ const [blueprintFact, generationRecordFact] = readFacts;
294
+ if (blueprintFact?.kind !== "file" ||
295
+ generationRecordFact?.kind !== "file") {
296
+ throw new Error("目标项目缺少可读取的 schema4 蓝图或 schema6 生成记录");
297
+ }
298
+ let blueprintValue;
299
+ let generationRecordValue;
300
+ try {
301
+ blueprintValue = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(blueprintFact.content));
302
+ generationRecordValue = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(generationRecordFact.content));
303
+ }
304
+ catch (error) {
305
+ throw new Error(`生成元数据不是有效 JSON:${errorMessage(error)}`, {
306
+ cause: error,
307
+ });
308
+ }
309
+ const blueprint = assertProjectBlueprint(blueprintValue);
310
+ const generationRecord = parseGenerationRecordStructure(generationRecordValue);
311
+ assertGenerationRecordMatchesBlueprint(generationRecord, blueprint);
312
+ return { restored: { blueprint, generationRecord }, readFacts };
313
+ };
314
+ const resolveReference = (selector) => contentIndex.resolve(selector, "reference");
315
+ const normalizeDependencyIdentity = (consumer, dependency, cache) => {
316
+ const cacheKey = dependencyIdentityCacheKey(consumer.identity, dependency.key);
317
+ const cached = cache.get(cacheKey);
318
+ if (cached !== undefined)
319
+ return cached.contentIdentity;
320
+ const identity = resolveReferenceDependencyIdentity({
321
+ consumerIdentity: consumer.identity,
322
+ dependency,
323
+ members: contentIndex.members,
324
+ });
325
+ cache.set(cacheKey, {
326
+ consumerContentIdentity: consumer.identity,
327
+ key: dependency.key,
328
+ contentIdentity: identity,
329
+ });
330
+ return identity;
331
+ };
332
+ const createPackageNodeDraft = (request) => {
333
+ const identityKey = contentIdentityKey(request.content.identity);
334
+ const sharedKey = request.content.definition.instance === "shared"
335
+ ? identityKey
336
+ : undefined;
337
+ const cached = sharedKey === undefined
338
+ ? undefined
339
+ : request.sharedDrafts?.get(sharedKey);
340
+ if (cached !== undefined) {
341
+ if (!isDeepStrictEqual(cached.definition, request.definition) ||
342
+ !isDeepStrictEqual(cached.creationInput ?? null, request.creationInput ?? null)) {
343
+ throw new Error(`共享参考包的创建事实不一致:${contentIdentityLabel(request.content.identity)}`);
344
+ }
345
+ return {
346
+ ...cached,
347
+ nodeIdentity: request.nodeIdentity,
348
+ layout: request.layout,
349
+ ...(request.explicitRoot === undefined
350
+ ? {}
351
+ : { explicitRoot: request.explicitRoot }),
352
+ dependencies: [...cached.dependencies],
353
+ };
354
+ }
355
+ const draft = {
356
+ content: request.content,
357
+ definition: request.definition,
358
+ creationInput: request.creationInput,
359
+ layout: request.layout,
360
+ nodeIdentity: request.nodeIdentity,
361
+ ...(request.explicitRoot === undefined
362
+ ? {}
363
+ : { explicitRoot: request.explicitRoot }),
364
+ ...(request.restored === undefined ? {} : { restored: request.restored }),
365
+ dependencies: [],
366
+ };
367
+ if (sharedKey !== undefined)
368
+ request.sharedDrafts?.set(sharedKey, draft);
369
+ return draft;
370
+ };
371
+ const populatePackageNodeDraft = (options) => {
372
+ const { draft } = options;
373
+ const identityKey = contentIdentityKey(draft.content.identity);
374
+ if (options.ancestry.includes(identityKey)) {
375
+ throw new Error(`参考包依赖形成循环:${[...options.ancestry, identityKey].join(" → ")}`);
376
+ }
377
+ const dependencies = draft.content.definition.dependencies ?? [];
378
+ const dependencyKeys = new Set();
379
+ const bindings = options.dependencyBindings ?? {};
380
+ const bindingEntries = Object.entries(bindings);
381
+ for (const [key, target] of bindingEntries) {
382
+ if (key.trim().length === 0) {
383
+ throw new Error(`选择节点依赖绑定无效:${draft.nodeIdentity}/${key}`);
384
+ }
385
+ if (typeof target === "string") {
386
+ if (target.trim().length === 0 ||
387
+ !options.explicitTargets?.has(target)) {
388
+ throw new Error(`选择节点依赖绑定目标不存在:${draft.nodeIdentity}/${key}`);
389
+ }
390
+ }
391
+ else if (!isRecord(target) ||
392
+ typeof target.packageDefinitionId !== "string" ||
393
+ target.packageDefinitionId.trim().length === 0 ||
394
+ !options.restoredTargets?.has(target.packageDefinitionId)) {
395
+ throw new Error(`选择节点依赖绑定目标不存在:${draft.nodeIdentity}/${key}`);
396
+ }
397
+ }
398
+ const populated = [];
399
+ const restoredDependencies = draft.restored === undefined
400
+ ? new Map()
401
+ : new Map(draft.dependencies.map((dependency) => [
402
+ dependency.key,
403
+ dependency.package,
404
+ ]));
405
+ for (const dependency of dependencies) {
406
+ if (dependency.key.trim().length === 0 ||
407
+ dependencyKeys.has(dependency.key)) {
408
+ throw new Error(`参考包依赖键不能为空且不能重复:${dependency.key}`);
409
+ }
410
+ dependencyKeys.add(dependency.key);
411
+ const providerIdentity = normalizeDependencyIdentity(draft.content, dependency, options.dependencyIdentities);
412
+ const restoredDependency = restoredDependencies.get(dependency.key);
413
+ const bindingTarget = bindings[dependency.key];
414
+ if (bindingTarget !== undefined) {
415
+ const selectedTarget = typeof bindingTarget === "string"
416
+ ? options.explicitTargets?.get(bindingTarget)
417
+ : options.restoredTargets?.get(bindingTarget.packageDefinitionId);
418
+ if (selectedTarget === undefined) {
419
+ throw new Error(`选择节点依赖绑定目标不存在:${draft.nodeIdentity}/${dependency.key}`);
420
+ }
421
+ if (contentIdentityKey(selectedTarget.content.identity) !==
422
+ contentIdentityKey(providerIdentity)) {
423
+ throw new Error(`选择节点依赖绑定身份不一致:${draft.nodeIdentity}/${dependency.key}`);
424
+ }
425
+ if (dependency.creationInput !== undefined) {
426
+ const expectedInput = requireParsedCreationInput(selectedTarget.content, dependency.creationInput);
427
+ if (!isDeepStrictEqual(selectedTarget.creationInput ?? null, expectedInput ?? null)) {
428
+ throw new Error(`选择节点依赖创建输入不一致:${draft.nodeIdentity}/${dependency.key}`);
429
+ }
430
+ }
431
+ const selectedTargetNode = selectedTarget.explicitRoot;
432
+ const existingSelection = options.existingSelection;
433
+ const selectedTargetId = selectedTarget.restored?.packageDefinitionId ??
434
+ (selectedTargetNode !== undefined &&
435
+ existingSelection !== undefined &&
436
+ selectedTargetNode.selectionId === existingSelection.selectionId
437
+ ? existingSelection.recordedNodeIds?.[selectedTargetNode.nodeIdentity]
438
+ : undefined);
439
+ if (restoredDependency !== undefined &&
440
+ selectedTargetId !== restoredDependency.restored?.packageDefinitionId) {
441
+ throw new Error(`生成记录中的依赖绑定不一致:${draft.nodeIdentity} → ${dependency.key}`);
442
+ }
443
+ populated.push({
444
+ key: dependency.key,
445
+ package: restoredDependency ?? selectedTarget,
163
446
  });
447
+ continue;
448
+ }
449
+ if (restoredDependency !== undefined) {
450
+ if (contentIdentityKey(restoredDependency.content.identity) !==
451
+ contentIdentityKey(providerIdentity)) {
452
+ throw new Error(`生成记录包含无效依赖绑定:${draft.nodeIdentity} → ${dependency.key}`);
453
+ }
454
+ if (dependency.creationInput !== undefined) {
455
+ const expectedInput = requireParsedCreationInput(restoredDependency.content, dependency.creationInput);
456
+ if (!isDeepStrictEqual(restoredDependency.creationInput ?? null, expectedInput ?? null)) {
457
+ throw new Error(`生成记录中的依赖创建事实不一致:${draft.nodeIdentity} → ${dependency.key}`);
458
+ }
459
+ }
460
+ populated.push({ key: dependency.key, package: restoredDependency });
461
+ continue;
462
+ }
463
+ const provider = resolveReference(providerIdentity);
464
+ const providerCreationInput = requireParsedCreationInput(provider, dependency.creationInput);
465
+ const providerDefinition = packageDefinition(provider.definition.createDefinition({
466
+ conventions: options.conventions,
467
+ creationInput: providerCreationInput,
468
+ }));
469
+ const providerNode = createPackageNodeDraft({
470
+ content: provider,
471
+ nodeIdentity: `${draft.nodeIdentity}-${dependency.key}`,
472
+ creationInput: providerCreationInput,
473
+ definition: providerDefinition,
474
+ layout: undefined,
475
+ sharedDrafts: options.sharedDrafts,
476
+ });
477
+ populatePackageNodeDraft({
478
+ draft: providerNode,
479
+ conventions: options.conventions,
480
+ ancestry: [...options.ancestry, identityKey],
481
+ sharedDrafts: options.sharedDrafts,
482
+ dependencyIdentities: options.dependencyIdentities,
483
+ ...(options.existingSelection === undefined
484
+ ? {}
485
+ : { existingSelection: options.existingSelection }),
486
+ });
487
+ populated.push({ key: dependency.key, package: providerNode });
488
+ }
489
+ if (draft.restored !== undefined) {
490
+ for (const dependency of draft.dependencies) {
491
+ if (!dependencyKeys.has(dependency.key))
492
+ populated.push(dependency);
164
493
  }
165
- catch (error) {
166
- throw new Error(`预设${contentIdentityLabel(presetMember.identity)}引用未装载的来源定义:${error instanceof Error ? error.message : String(error)}`, { cause: error });
494
+ }
495
+ for (const [key] of bindingEntries) {
496
+ if (!dependencyKeys.has(key)) {
497
+ throw new Error(`选择节点依赖绑定键不存在:${draft.nodeIdentity}/${key}`);
167
498
  }
168
499
  }
169
- }
170
- function requireContent(selector) {
171
- return contentIndex.resolve(selector, "reference");
172
- }
173
- function resolvePreset(selector) {
174
- const member = isPresetDefinition(selector)
175
- ? contentIndex.fromDefinition(selector, "preset")
176
- : contentIndex.resolve(selector, "preset");
177
- return member;
178
- }
179
- function expandPreset(options_) {
180
- const preset = options_.preset.definition;
181
- if (!preset.operations.includes(options_.operation)) {
182
- throw new Error(`预设不支持${options_.operation}操作`);
183
- }
184
- const nodes = Object.entries(preset.nodes);
185
- if ((options_.creationInput !== undefined ||
186
- options_.configuration !== undefined) &&
187
- nodes.length !== 1) {
188
- throw new Error("多节点预设不能接收单一包创建输入");
189
- }
190
- return nodes.map(([nodeIdentity, node]) => {
191
- const creationInput = mergeCreationInput(node.creationInput?.[options_.operation], options_.creationInput);
192
- const reference = contentIndex.fromDefinition(node.reference, "reference", { namespace: options_.preset.identity.namespace });
500
+ draft.dependencies = populated;
501
+ };
502
+ const preparePackageNode = async (draft, selectedPaths, preparedDrafts) => {
503
+ const existing = preparedDrafts.get(draft);
504
+ if (existing !== undefined)
505
+ return existing;
506
+ const pending = (async () => {
507
+ const preparedDependencies = [];
508
+ for (const dependency of draft.dependencies) {
509
+ preparedDependencies.push({
510
+ key: dependency.key,
511
+ package: await preparePackageNode(dependency.package, selectedPaths, preparedDrafts),
512
+ });
513
+ }
514
+ const prepared = preparationSnapshot(await draft.content.definition.prepare({
515
+ excludedPackagePaths: excludedPackagePaths(draft.definition, selectedPaths),
516
+ }));
193
517
  return {
194
- nodeIdentity,
195
- contentIdentity: reference.identity,
196
- ...(node.layout === undefined ? {} : { layout: node.layout }),
197
- ...(creationInput === undefined ? {} : { creationInput }),
198
- configuration: options_.configuration === undefined
199
- ? node.configuration?.[options_.operation]
200
- : options_.configuration,
518
+ content: draft.content,
519
+ preparation: prepared,
520
+ definition: draft.definition,
521
+ creationInput: draft.creationInput,
522
+ layout: draft.layout,
523
+ nodeIdentity: draft.nodeIdentity,
524
+ ...(draft.explicitRoot === undefined
525
+ ? {}
526
+ : { explicitRoot: draft.explicitRoot }),
527
+ ...(draft.restored === undefined ? {} : { restored: draft.restored }),
528
+ dependencies: preparedDependencies,
201
529
  };
202
- });
203
- }
204
- function findByPackageId(records, id) {
205
- const record = records.find((candidate) => candidate.packageDefinitionId === id);
206
- if (record === undefined) {
207
- throw new Error("生成记录引用了不存在的包实例:" + id);
530
+ })();
531
+ preparedDrafts.set(draft, pending);
532
+ return pending;
533
+ };
534
+ const restoredSelectionDrafts = (restored, dependencyIdentities = new Map()) => {
535
+ const { generationRecord, blueprint } = restored;
536
+ for (const requirement of restored.normalizedDependencies ?? []) {
537
+ const key = dependencyIdentityCacheKey(requirement.consumerContentIdentity, requirement.key);
538
+ const existing = dependencyIdentities.get(key);
539
+ if (existing !== undefined &&
540
+ contentIdentityKey(existing.contentIdentity) !==
541
+ contentIdentityKey(requirement.contentIdentity)) {
542
+ throw new Error("缓存的内容依赖身份不一致");
543
+ }
544
+ dependencyIdentities.set(key, requirement);
208
545
  }
209
- return record;
210
- }
211
- function normalizeConfiguration(content, input) {
212
- if (content.definition.normalizeConfiguration !== undefined)
213
- return content.definition.normalizeConfiguration(input) ?? null;
214
- if (input !== undefined && input !== null)
215
- throw new Error(`内容 ${contentIdentityLabel(content.identity)} 不支持实例配置`);
216
- return null;
217
- }
218
- function resolvePackageStates(records, blueprint) {
546
+ if (contentIdentityKey(generationRecord.composition.identity) !==
547
+ contentIdentityKey(composition.identity)) {
548
+ throw new Error("目标项目使用了不兼容的组合定义");
549
+ }
550
+ assertGenerationRecordMatchesBlueprint(generationRecord, blueprint);
551
+ const conventions = composition.parseConventions(generationRecord.composition.conventions);
552
+ assertJsonValue(conventions, "组合约定");
553
+ if (!isDeepStrictEqual(conventions, generationRecord.composition.conventions)) {
554
+ throw new Error("生成记录中的组合约定不符合当前组合定义");
555
+ }
556
+ const recordsById = new Map(generationRecord.packages.map((item) => [item.packageDefinitionId, item]));
219
557
  const definitionsById = new Map(blueprint.packages.map((definition) => [
220
558
  definition.packageDefinitionId,
221
559
  definition,
222
560
  ]));
223
- if (definitionsById.size !== records.length) {
224
- throw new Error("生成记录与蓝图的包实例数量不一致");
561
+ const contentsById = new Map();
562
+ const inputsById = new Map();
563
+ const draftsById = new Map();
564
+ const sharedIdentities = new Set();
565
+ for (const item of generationRecord.packages) {
566
+ const content = resolveReference(item.contentIdentity);
567
+ const definition = definitionsById.get(item.packageDefinitionId);
568
+ if (definition === undefined) {
569
+ throw new Error(`项目蓝图缺少包实例:${item.packageDefinitionId}`);
570
+ }
571
+ const creationInput = item.creationInput === null
572
+ ? undefined
573
+ : requireParsedCreationInput(content, item.creationInput);
574
+ if (!isDeepStrictEqual(creationInput ?? null, item.creationInput)) {
575
+ throw new Error(`生成记录中的创建事实不规范:${item.packageDefinitionId}`);
576
+ }
577
+ contentsById.set(item.packageDefinitionId, content);
578
+ inputsById.set(item.packageDefinitionId, creationInput);
579
+ if (content.definition.instance === "shared") {
580
+ const identity = contentIdentityKey(content.identity);
581
+ if (sharedIdentities.has(identity)) {
582
+ throw new Error(`共享参考包必须只有一个实例:${contentIdentityLabel(content.identity)}`);
583
+ }
584
+ sharedIdentities.add(identity);
585
+ }
225
586
  }
226
- for (const definition of blueprint.packages) {
227
- if (!records.some((record) => record.packageDefinitionId === definition.packageDefinitionId)) {
228
- throw new Error(`蓝图包实例缺少生成记录事实:${definition.packageDefinitionId}`);
587
+ const explicitBindingsByConsumer = new Map();
588
+ for (const selection of generationRecord.selections) {
589
+ if (selection.presetIdentity === null)
590
+ continue;
591
+ const preset = contentIndex.resolve(selection.presetIdentity, "preset");
592
+ const definition = preset.definition;
593
+ if (!isRecord(definition) ||
594
+ definition.kind !== "preset" ||
595
+ !isRecord(definition.nodes)) {
596
+ throw new Error(`预设定义无效:${contentIdentityLabel(preset.identity)}`);
229
597
  }
598
+ const presetNodes = Object.entries(definition.nodes);
599
+ if (presetNodes.length !== Object.keys(selection.nodes).length ||
600
+ presetNodes.some(([nodeIdentity]) => !Object.hasOwn(selection.nodes, nodeIdentity))) {
601
+ throw new Error(`生成记录中的预设选择与当前定义不一致:${contentIdentityLabel(preset.identity)}`);
602
+ }
603
+ for (const [nodeIdentity, rawNode] of presetNodes) {
604
+ if (!isRecord(rawNode) || !isRecord(rawNode.reference)) {
605
+ throw new Error(`预设节点定义无效:${nodeIdentity}`);
606
+ }
607
+ const consumerId = selection.nodes[nodeIdentity];
608
+ const consumerRecord = consumerId === undefined ? undefined : recordsById.get(consumerId);
609
+ const consumer = consumerId === undefined ? undefined : contentsById.get(consumerId);
610
+ const expected = resolveReference({
611
+ alias: String(rawNode.reference.alias),
612
+ namespace: preset.identity.namespace,
613
+ });
614
+ if (consumerId === undefined ||
615
+ consumerRecord === undefined ||
616
+ consumer === undefined ||
617
+ contentIdentityKey(consumer.identity) !==
618
+ contentIdentityKey(expected.identity)) {
619
+ throw new Error(`生成记录中的预设节点引用不一致:${nodeIdentity}`);
620
+ }
621
+ const rawBindings = rawNode.dependencyBindings;
622
+ if (rawBindings === undefined)
623
+ continue;
624
+ if (!isRecord(rawBindings)) {
625
+ throw new Error(`预设节点依赖绑定无效:${nodeIdentity}`);
626
+ }
627
+ const declarations = consumer.definition.dependencies ?? [];
628
+ const declaredKeys = new Set(declarations.map(({ key }) => key));
629
+ for (const [key, targetNodeIdentity] of Object.entries(rawBindings)) {
630
+ if (key.trim().length === 0 ||
631
+ typeof targetNodeIdentity !== "string" ||
632
+ targetNodeIdentity.trim().length === 0) {
633
+ throw new Error(`预设节点依赖绑定无效:${nodeIdentity}/${key}`);
634
+ }
635
+ if (!declaredKeys.has(key)) {
636
+ throw new Error(`预设节点依赖绑定键不存在:${nodeIdentity}/${key}`);
637
+ }
638
+ const providerId = selection.nodes[targetNodeIdentity];
639
+ const providerRecord = providerId === undefined ? undefined : recordsById.get(providerId);
640
+ const provider = providerId === undefined ? undefined : contentsById.get(providerId);
641
+ const dependency = declarations.find((item) => item.key === key);
642
+ if (providerId === undefined ||
643
+ providerRecord === undefined ||
644
+ provider === undefined ||
645
+ dependency === undefined) {
646
+ throw new Error(`预设节点依赖绑定目标不存在:${nodeIdentity}/${key}`);
647
+ }
648
+ const expectedIdentity = normalizeDependencyIdentity(consumer, dependency, dependencyIdentities);
649
+ if (contentIdentityKey(provider.identity) !==
650
+ contentIdentityKey(expectedIdentity) ||
651
+ consumerRecord.dependencyBindings[key] !== providerId) {
652
+ throw new Error(`生成记录中的预设节点依赖绑定不一致:${consumerId} → ${key}`);
653
+ }
654
+ const bindings = explicitBindingsByConsumer.get(consumerId) ?? new Map();
655
+ const existingProviderId = bindings.get(key);
656
+ if (existingProviderId !== undefined &&
657
+ existingProviderId !== providerId) {
658
+ throw new Error(`生成记录中的预设节点依赖绑定不一致:${consumerId} → ${key}`);
659
+ }
660
+ bindings.set(key, providerId);
661
+ explicitBindingsByConsumer.set(consumerId, bindings);
662
+ }
663
+ }
664
+ }
665
+ const visiting = new Set();
666
+ const buildDraft = (id) => {
667
+ const existing = draftsById.get(id);
668
+ if (existing !== undefined)
669
+ return existing;
670
+ if (visiting.has(id))
671
+ throw new Error("生成记录依赖包含循环");
672
+ const item = recordsById.get(id);
673
+ const persistedDefinition = definitionsById.get(id);
674
+ const content = contentsById.get(id);
675
+ if (item === undefined ||
676
+ persistedDefinition === undefined ||
677
+ content === undefined) {
678
+ throw new Error(`生成记录引用了未知包实例:${id}`);
679
+ }
680
+ visiting.add(id);
681
+ const declarations = content.definition.dependencies ?? [];
682
+ const declaredKeys = new Set();
683
+ for (const dependency of declarations) {
684
+ if (dependency.key.trim().length === 0 ||
685
+ declaredKeys.has(dependency.key)) {
686
+ throw new Error(`参考包依赖键不能为空且不能重复:${dependency.key}`);
687
+ }
688
+ declaredKeys.add(dependency.key);
689
+ }
690
+ const recordedBindings = Object.entries(item.dependencyBindings);
691
+ if (recordedBindings.some(([key]) => key.trim().length === 0)) {
692
+ throw new Error(`生成记录中的依赖绑定与当前参考包不一致:${id}`);
693
+ }
694
+ const recordedKeys = new Set(recordedBindings.map(([key]) => key));
695
+ if (declarations.some(({ key }) => !recordedKeys.has(key))) {
696
+ throw new Error(`生成记录中的依赖绑定与当前参考包不一致:${id}`);
697
+ }
698
+ const dependencies = recordedBindings.map(([key, providerId]) => {
699
+ const providerRecord = providerId === undefined ? undefined : recordsById.get(providerId);
700
+ const providerContent = providerId === undefined ? undefined : contentsById.get(providerId);
701
+ if (providerId === undefined ||
702
+ providerRecord === undefined ||
703
+ providerContent === undefined) {
704
+ throw new Error(`生成记录包含无效依赖绑定:${id} → ${key}`);
705
+ }
706
+ const dependency = declarations.find((item) => item.key === key);
707
+ if (dependency !== undefined) {
708
+ const consumer = contentsById.get(id);
709
+ if (consumer === undefined) {
710
+ throw new Error(`生成记录引用了未知内容实例:${id}`);
711
+ }
712
+ const declaredIdentity = normalizeDependencyIdentity(consumer, dependency, dependencyIdentities);
713
+ if (contentIdentityKey(providerContent.identity) !==
714
+ contentIdentityKey(declaredIdentity)) {
715
+ throw new Error(`生成记录包含无效依赖绑定:${id} → ${key}`);
716
+ }
717
+ const explicitProviderId = explicitBindingsByConsumer
718
+ .get(id)
719
+ ?.get(key);
720
+ if (explicitProviderId !== undefined &&
721
+ providerId !== explicitProviderId) {
722
+ throw new Error(`生成记录中的预设节点依赖绑定不一致:${id} → ${key}`);
723
+ }
724
+ const expectedInput = requireParsedCreationInput(providerContent, dependency.creationInput);
725
+ if (dependency.creationInput !== undefined &&
726
+ !isDeepStrictEqual(inputsById.get(providerId) ?? null, expectedInput ?? null)) {
727
+ throw new Error(`生成记录中的依赖创建事实不一致:${id} → ${key}`);
728
+ }
729
+ }
730
+ return { key, package: buildDraft(providerId) };
731
+ });
732
+ visiting.delete(id);
733
+ const { packageDefinitionId: _id, ...definition } = persistedDefinition;
734
+ const draft = {
735
+ content,
736
+ definition,
737
+ creationInput: inputsById.get(id),
738
+ layout: undefined,
739
+ nodeIdentity: `restored-${id}`,
740
+ restored: {
741
+ packageDefinitionId: id,
742
+ createdBy: item.createdBy,
743
+ },
744
+ dependencies,
745
+ };
746
+ draftsById.set(id, draft);
747
+ return draft;
748
+ };
749
+ const reachable = new Set();
750
+ const collectReachable = (id) => {
751
+ if (reachable.has(id))
752
+ return;
753
+ reachable.add(id);
754
+ const item = recordsById.get(id);
755
+ if (item === undefined)
756
+ throw new Error(`未知包实例:${id}`);
757
+ for (const providerId of Object.values(item.dependencyBindings)) {
758
+ collectReachable(providerId);
759
+ }
760
+ };
761
+ const result = generationRecord.selections.map((selection) => {
762
+ const nodeEntries = Object.entries(selection.nodes);
763
+ requireUniqueNodes(nodeEntries.map(([nodeIdentity]) => ({ nodeIdentity })));
764
+ if (selection.presetIdentity !== null) {
765
+ const preset = contentIndex.resolve(selection.presetIdentity, "preset");
766
+ const definition = preset.definition;
767
+ if (!isRecord(definition) ||
768
+ definition.kind !== "preset" ||
769
+ !isRecord(definition.nodes)) {
770
+ throw new Error(`预设定义无效:${contentIdentityLabel(preset.identity)}`);
771
+ }
772
+ const presetNodes = Object.entries(definition.nodes);
773
+ if (presetNodes.length !== nodeEntries.length ||
774
+ presetNodes.some(([nodeIdentity]) => !Object.hasOwn(selection.nodes, nodeIdentity))) {
775
+ throw new Error(`生成记录中的预设选择与当前定义不一致:${contentIdentityLabel(preset.identity)}`);
776
+ }
777
+ for (const [nodeIdentity, node] of presetNodes) {
778
+ if (!isRecord(node) || !isRecord(node.reference)) {
779
+ throw new Error(`预设节点定义无效:${nodeIdentity}`);
780
+ }
781
+ const rootRecord = recordsById.get(selection.nodes[nodeIdentity]);
782
+ const rootContent = rootRecord === undefined
783
+ ? undefined
784
+ : contentsById.get(rootRecord.packageDefinitionId);
785
+ const expected = resolveReference({
786
+ alias: String(node.reference.alias),
787
+ namespace: preset.identity.namespace,
788
+ });
789
+ if (rootContent === undefined ||
790
+ contentIdentityKey(rootContent.identity) !==
791
+ contentIdentityKey(expected.identity)) {
792
+ throw new Error(`生成记录中的预设节点引用不一致:${nodeIdentity}`);
793
+ }
794
+ }
795
+ }
796
+ const roots = nodeEntries.map(([nodeIdentity, id]) => {
797
+ collectReachable(id);
798
+ return { ...buildDraft(id), nodeIdentity };
799
+ });
800
+ // 规范化 JSON 会按键名排序 nodes,无法从记录恢复原始根数组顺序。
801
+ return {
802
+ presetIdentity: selection.presetIdentity,
803
+ selectionId: selection.selectionId,
804
+ recordedNodeIds: selection.nodes,
805
+ roots,
806
+ };
807
+ });
808
+ if (reachable.size !== recordsById.size) {
809
+ throw new Error("生成记录包含未被选择引用的包实例");
810
+ }
811
+ return result;
812
+ };
813
+ async function prepareProjectInternal(prepareOptions) {
814
+ const parsedConventions = prepareOptions.restored
815
+ ? composition.parseConventions(prepareOptions.restored.generationRecord.composition.conventions)
816
+ : composition.parseConventions(prepareOptions.conventions);
817
+ const conventions = parsedConventions;
818
+ assertJsonValue(conventions, "组合约定");
819
+ if (prepareOptions.restored &&
820
+ !isDeepStrictEqual(conventions, prepareOptions.restored.generationRecord.composition.conventions)) {
821
+ throw new Error("生成记录中的组合约定不符合当前组合定义");
822
+ }
823
+ const dependencyIdentities = prepareOptions.dependencyIdentities ??
824
+ new Map();
825
+ const selectionDrafts = prepareOptions.restored
826
+ ? restoredSelectionDrafts(prepareOptions.restored, dependencyIdentities)
827
+ : [];
828
+ const restoredTargetsById = new Map();
829
+ const indexRestoredTargets = (roots) => {
830
+ for (const root of roots) {
831
+ if (root.restored !== undefined) {
832
+ restoredTargetsById.set(root.restored.packageDefinitionId, root);
833
+ }
834
+ indexRestoredTargets(root.dependencies.map(({ package: item }) => item));
835
+ }
836
+ };
837
+ for (const selectionDraft of selectionDrafts) {
838
+ indexRestoredTargets(selectionDraft.roots);
839
+ }
840
+ const sharedDrafts = new Map();
841
+ const indexSharedDrafts = (roots) => {
842
+ for (const root of roots) {
843
+ if (root.content.definition.instance === "shared") {
844
+ sharedDrafts.set(contentIdentityKey(root.content.identity), root);
845
+ }
846
+ indexSharedDrafts(root.dependencies.map((item) => item.package));
847
+ }
848
+ };
849
+ for (const selectionDraft of selectionDrafts) {
850
+ indexSharedDrafts(selectionDraft.roots);
851
+ }
852
+ const operation = prepareOptions.operation;
853
+ const createdBy = operation === "init" ? "initialization" : "addition";
854
+ const identifyDraftSelection = (presetIdentity, roots) => selectionId({
855
+ compositionIdentity: composition.identity,
856
+ presetIdentity,
857
+ roots: roots.map((root) => ({
858
+ nodeIdentity: root.nodeIdentity,
859
+ contentIdentity: root.content.identity,
860
+ creationInput: root.creationInput ?? null,
861
+ definition: root.definition,
862
+ })),
863
+ });
864
+ const selectionRootFacts = (root, existingSelection) => {
865
+ const declaredKeys = new Set((root.content.definition.dependencies ?? []).map(({ key }) => key));
866
+ return {
867
+ nodeIdentity: root.nodeIdentity,
868
+ identity: contentIdentityKey(root.content.identity),
869
+ creationInput: root.creationInput ?? null,
870
+ definition: root.definition,
871
+ dependencies: root.dependencies
872
+ .filter(({ key }) => declaredKeys.has(key))
873
+ .map(({ key, package: dependency }) => {
874
+ if (dependency.restored !== undefined) {
875
+ return {
876
+ key,
877
+ target: {
878
+ packageDefinitionId: dependency.restored.packageDefinitionId,
879
+ },
880
+ };
881
+ }
882
+ if (dependency.explicitRoot !== undefined) {
883
+ const packageDefinitionId = dependency.explicitRoot.selectionId ===
884
+ existingSelection.selectionId
885
+ ? existingSelection.recordedNodeIds?.[dependency.explicitRoot.nodeIdentity]
886
+ : undefined;
887
+ return {
888
+ key,
889
+ target: packageDefinitionId === undefined
890
+ ? {
891
+ selectionId: dependency.explicitRoot.selectionId,
892
+ nodeIdentity: dependency.explicitRoot.nodeIdentity,
893
+ }
894
+ : { packageDefinitionId },
895
+ };
896
+ }
897
+ const existingRoot = existingSelection.roots.find((candidate) => candidate.nodeIdentity === root.nodeIdentity);
898
+ const existingDependency = existingRoot?.dependencies.find((candidate) => candidate.key === key)?.package;
899
+ const recordedPackageDefinitionId = existingDependency?.restored?.packageDefinitionId;
900
+ if (existingDependency !== undefined &&
901
+ recordedPackageDefinitionId !== undefined &&
902
+ contentIdentityKey(existingDependency.content.identity) ===
903
+ contentIdentityKey(dependency.content.identity) &&
904
+ isDeepStrictEqual(existingDependency.creationInput ?? null, dependency.creationInput ?? null) &&
905
+ isDeepStrictEqual(existingDependency.definition, dependency.definition)) {
906
+ return {
907
+ key,
908
+ target: { packageDefinitionId: recordedPackageDefinitionId },
909
+ };
910
+ }
911
+ return {
912
+ key,
913
+ target: {
914
+ identity: contentIdentityKey(dependency.content.identity),
915
+ creationInput: dependency.creationInput ?? null,
916
+ definition: dependency.definition,
917
+ },
918
+ };
919
+ })
920
+ .toSorted((left, right) => left.key < right.key ? -1 : left.key > right.key ? 1 : 0),
921
+ };
922
+ };
923
+ const appendSelection = (group) => {
924
+ const existing = selectionDrafts.find((candidate) => candidate.selectionId === group.selectionId);
925
+ if (existing !== undefined) {
926
+ const existingRoots = existing.roots
927
+ .map((root) => selectionRootFacts(root, existing))
928
+ .toSorted((left, right) => left.nodeIdentity < right.nodeIdentity
929
+ ? -1
930
+ : left.nodeIdentity > right.nodeIdentity
931
+ ? 1
932
+ : 0);
933
+ const requestedRoots = group.roots
934
+ .map((root) => selectionRootFacts(root, existing))
935
+ .toSorted((left, right) => left.nodeIdentity < right.nodeIdentity
936
+ ? -1
937
+ : left.nodeIdentity > right.nodeIdentity
938
+ ? 1
939
+ : 0);
940
+ const existingPresetIdentity = existing.presetIdentity === null
941
+ ? null
942
+ : contentIdentityKey(existing.presetIdentity);
943
+ const requestedPresetIdentity = group.presetIdentity === null
944
+ ? null
945
+ : contentIdentityKey(group.presetIdentity);
946
+ if (existingPresetIdentity === requestedPresetIdentity) {
947
+ if (!isDeepStrictEqual(existingRoots, requestedRoots)) {
948
+ throw new Error("相同选择标识对应不同的包创建事实");
949
+ }
950
+ return;
951
+ }
952
+ throw new Error("生成记录包含重复选择标识");
953
+ }
954
+ selectionDrafts.push(group);
955
+ };
956
+ const selection = prepareOptions.selection;
957
+ const directRoots = selection?.roots ?? [];
958
+ if (directRoots.length > 0) {
959
+ const selectedRoots = directRoots.map((root) => ({
960
+ content: resolveReference(root.contentIdentity),
961
+ nodeIdentity: root.nodeIdentity,
962
+ rawCreationInput: root.creationInput,
963
+ layout: root.layout,
964
+ dependencyBindings: root.dependencyBindings,
965
+ }));
966
+ const preparedRoots = selectedRoots.map((root) => {
967
+ const creationInput = requireParsedCreationInput(root.content, root.rawCreationInput);
968
+ return {
969
+ ...root,
970
+ creationInput,
971
+ definition: packageDefinition(root.content.definition.createDefinition({
972
+ conventions,
973
+ creationInput,
974
+ ...(root.layout === undefined ? {} : { layout: root.layout }),
975
+ })),
976
+ };
977
+ });
978
+ const id = identifyDraftSelection(null, preparedRoots);
979
+ const matchedSelection = selectionDrafts.find((candidate) => candidate.selectionId === id);
980
+ const existingSelection = matchedSelection?.selectionId === undefined
981
+ ? undefined
982
+ : {
983
+ selectionId: matchedSelection.selectionId,
984
+ ...(matchedSelection.recordedNodeIds === undefined
985
+ ? {}
986
+ : { recordedNodeIds: matchedSelection.recordedNodeIds }),
987
+ };
988
+ const roots = preparedRoots.map((root) => {
989
+ const explicitRoot = root.content.definition.instance === "independent"
990
+ ? {
991
+ selectionId: id,
992
+ nodeIdentity: root.nodeIdentity,
993
+ createdBy,
994
+ }
995
+ : undefined;
996
+ return createPackageNodeDraft({
997
+ ...root,
998
+ sharedDrafts,
999
+ ...(explicitRoot === undefined ? {} : { explicitRoot }),
1000
+ });
1001
+ });
1002
+ requireUniqueNodes(roots);
1003
+ const rootsByIdentity = new Map(roots.map((root) => [root.nodeIdentity, root]));
1004
+ for (const root of roots) {
1005
+ const dependencyBindings = directRoots.find(({ nodeIdentity }) => nodeIdentity === root.nodeIdentity)?.dependencyBindings;
1006
+ if (dependencyBindings !== undefined && !isRecord(dependencyBindings)) {
1007
+ throw new Error(`选择节点依赖绑定无效:${root.nodeIdentity}`);
1008
+ }
1009
+ populatePackageNodeDraft({
1010
+ draft: root,
1011
+ conventions,
1012
+ ancestry: [],
1013
+ sharedDrafts,
1014
+ dependencyIdentities,
1015
+ explicitTargets: rootsByIdentity,
1016
+ restoredTargets: restoredTargetsById,
1017
+ ...(existingSelection === undefined ? {} : { existingSelection }),
1018
+ ...(dependencyBindings === undefined ? {} : { dependencyBindings }),
1019
+ });
1020
+ }
1021
+ appendSelection({
1022
+ presetIdentity: null,
1023
+ selectionId: id,
1024
+ createdBy: operation === "init" ? "initialization" : "addition",
1025
+ roots,
1026
+ });
1027
+ }
1028
+ for (const presetRequest of selection?.presets ?? []) {
1029
+ const presetMember = contentIndex.resolve(presetRequest.contentIdentity, "preset");
1030
+ const preset = presetMember.definition;
1031
+ if (!isRecord(preset) ||
1032
+ preset.kind !== "preset" ||
1033
+ !isRecord(preset.nodes)) {
1034
+ throw new Error(`预设定义无效:${contentIdentityLabel(presetMember.identity)}`);
1035
+ }
1036
+ const definition = preset;
1037
+ if (!definition.operations.includes(operation)) {
1038
+ throw new Error(`预设不支持${operation === "init" ? "初始化" : "加包"}:${contentIdentityLabel(presetMember.identity)}`);
1039
+ }
1040
+ const entries = Object.entries(definition.nodes);
1041
+ if (entries.length === 0)
1042
+ throw new Error("预设必须至少选择一个软件包节点");
1043
+ if (presetRequest.creationInput !== undefined && entries.length !== 1) {
1044
+ throw new Error("多节点预设不能接收单个软件包创建输入");
1045
+ }
1046
+ const presetRoots = [];
1047
+ for (const [nodeIdentity, node] of entries) {
1048
+ const selectedInput = mergeCreationInput(node.creationInput?.[operation], presetRequest.creationInput);
1049
+ const content = resolveReference({
1050
+ alias: node.reference.alias,
1051
+ namespace: presetMember.identity.namespace,
1052
+ });
1053
+ presetRoots.push({
1054
+ content,
1055
+ nodeIdentity,
1056
+ rawCreationInput: selectedInput,
1057
+ ...(node.layout === undefined ? {} : { layout: node.layout }),
1058
+ });
1059
+ }
1060
+ const preparedRoots = presetRoots.map((root) => {
1061
+ const creationInput = requireParsedCreationInput(root.content, root.rawCreationInput);
1062
+ return {
1063
+ ...root,
1064
+ creationInput,
1065
+ definition: packageDefinition(root.content.definition.createDefinition({
1066
+ conventions,
1067
+ creationInput,
1068
+ ...(root.layout === undefined ? {} : { layout: root.layout }),
1069
+ })),
1070
+ };
1071
+ });
1072
+ const id = identifyDraftSelection(presetMember.identity, preparedRoots);
1073
+ const matchedSelection = selectionDrafts.find((candidate) => candidate.selectionId === id);
1074
+ const existingSelection = matchedSelection?.selectionId === undefined
1075
+ ? undefined
1076
+ : {
1077
+ selectionId: matchedSelection.selectionId,
1078
+ ...(matchedSelection.recordedNodeIds === undefined
1079
+ ? {}
1080
+ : { recordedNodeIds: matchedSelection.recordedNodeIds }),
1081
+ };
1082
+ const rootsByIdentity = new Map();
1083
+ const roots = preparedRoots.map((root) => {
1084
+ const declaration = preset.nodes[root.nodeIdentity];
1085
+ const dependencyBindings = declaration !== undefined && isRecord(declaration)
1086
+ ? declaration.dependencyBindings
1087
+ : undefined;
1088
+ if (dependencyBindings !== undefined && !isRecord(dependencyBindings)) {
1089
+ throw new Error(`预设节点依赖绑定无效:${root.nodeIdentity}`);
1090
+ }
1091
+ const explicitRoot = root.content.definition.instance === "independent"
1092
+ ? {
1093
+ selectionId: id,
1094
+ nodeIdentity: root.nodeIdentity,
1095
+ createdBy,
1096
+ }
1097
+ : undefined;
1098
+ const draft = createPackageNodeDraft({
1099
+ ...root,
1100
+ sharedDrafts,
1101
+ ...(explicitRoot === undefined ? {} : { explicitRoot }),
1102
+ });
1103
+ rootsByIdentity.set(root.nodeIdentity, draft);
1104
+ return draft;
1105
+ });
1106
+ requireUniqueNodes(roots);
1107
+ for (const root of roots) {
1108
+ const declaration = preset.nodes[root.nodeIdentity];
1109
+ const dependencyBindings = declaration !== undefined && isRecord(declaration)
1110
+ ? declaration.dependencyBindings
1111
+ : undefined;
1112
+ populatePackageNodeDraft({
1113
+ draft: root,
1114
+ conventions,
1115
+ ancestry: [],
1116
+ sharedDrafts,
1117
+ dependencyIdentities,
1118
+ explicitTargets: rootsByIdentity,
1119
+ ...(existingSelection === undefined ? {} : { existingSelection }),
1120
+ ...(dependencyBindings === undefined ? {} : { dependencyBindings }),
1121
+ });
1122
+ }
1123
+ appendSelection({
1124
+ presetIdentity: presetMember.identity,
1125
+ selectionId: id,
1126
+ createdBy: operation === "init" ? "initialization" : "addition",
1127
+ roots,
1128
+ });
1129
+ }
1130
+ if (selectionDrafts.length === 0) {
1131
+ throw new Error(prepareOptions.restored
1132
+ ? "生成记录至少需要一个选择"
1133
+ : operation === "init"
1134
+ ? "初始化至少需要选择一个参考包或预设"
1135
+ : "加包至少需要选择一个参考包或预设");
1136
+ }
1137
+ const explicitlySelectedSharedReferences = new Map();
1138
+ for (const selectionDraft of selectionDrafts) {
1139
+ if (selectionDraft.createdBy === undefined)
1140
+ continue;
1141
+ for (const root of selectionDraft.roots) {
1142
+ if (root.content.definition.instance === "shared") {
1143
+ explicitlySelectedSharedReferences.set(contentIdentityKey(root.content.identity), selectionDraft.createdBy);
1144
+ }
1145
+ }
1146
+ }
1147
+ assertAcyclicPackageDrafts(selectionDrafts.flatMap((item) => item.roots), explicitlySelectedSharedReferences);
1148
+ const selectedPaths = [
1149
+ ...new Set(selectionDrafts.flatMap((selection) => packageNodePaths(selection.roots))),
1150
+ ];
1151
+ const selections = [];
1152
+ const preparedDrafts = new WeakMap();
1153
+ for (const selection of selectionDrafts) {
1154
+ const roots = [];
1155
+ for (const root of selection.roots) {
1156
+ roots.push(await preparePackageNode(root, selectedPaths, preparedDrafts));
1157
+ }
1158
+ selections.push({
1159
+ presetIdentity: selection.presetIdentity,
1160
+ ...(selection.selectionId === undefined
1161
+ ? {}
1162
+ : { selectionId: selection.selectionId }),
1163
+ ...(selection.recordedNodeIds === undefined
1164
+ ? {}
1165
+ : { recordedNodeIds: selection.recordedNodeIds }),
1166
+ ...(selection.createdBy === undefined
1167
+ ? {}
1168
+ : { createdBy: selection.createdBy }),
1169
+ roots,
1170
+ });
230
1171
  }
231
- return records.map((record) => {
232
- const definition = definitionsById.get(record.packageDefinitionId);
1172
+ return {
1173
+ conventions,
1174
+ composition: options.composition,
1175
+ selections,
1176
+ operationFacts: prepareOptions.operationFacts,
1177
+ ...(prepareOptions.restored === undefined
1178
+ ? {}
1179
+ : { restored: prepareOptions.restored }),
1180
+ };
1181
+ }
1182
+ async function prepareProject(prepareOptions) {
1183
+ return prepareProjectInternal({ ...prepareOptions, operation: "init" });
1184
+ }
1185
+ async function restoreProject(restoreOptions) {
1186
+ const targetRoot = path.resolve(restoreOptions.repositoryRoot);
1187
+ const { restored, readFacts } = await readRestoredProject(targetRoot);
1188
+ const dependencyIdentities = new Map();
1189
+ restoredSelectionDrafts(restored, dependencyIdentities);
1190
+ const normalizedDependencies = [...dependencyIdentities.values()];
1191
+ const definitionsById = new Map(restored.blueprint.packages.map((definition) => [
1192
+ definition.packageDefinitionId,
1193
+ definition,
1194
+ ]));
1195
+ const packages = restored.generationRecord.packages.map((item) => {
1196
+ const definition = definitionsById.get(item.packageDefinitionId);
233
1197
  if (definition === undefined) {
234
- throw new Error(`蓝图缺少内容 ${contentIdentityLabel(record.contentIdentity)} 对应的包实例:${record.packageDefinitionId}`);
1198
+ throw new Error(`项目蓝图缺少包实例:${item.packageDefinitionId}`);
235
1199
  }
236
- const configuration = normalizeConfiguration(requireContent(record.contentIdentity), record.configuration);
237
- if (!isDeepStrictEqual(configuration, record.configuration))
238
- throw new Error(`生成记录包含未规范化的实例配置:${definition.path}`);
239
- return { ...record, definition };
1200
+ return {
1201
+ ...item,
1202
+ definition,
1203
+ };
1204
+ });
1205
+ return {
1206
+ ...restored,
1207
+ targetRoot,
1208
+ packages,
1209
+ selections: restored.generationRecord.selections,
1210
+ readFacts,
1211
+ normalizedDependencies,
1212
+ };
1213
+ }
1214
+ const additionSelection = (selection) => "preset" in selection
1215
+ ? {
1216
+ presets: [
1217
+ {
1218
+ contentIdentity: selection.preset,
1219
+ ...(selection.creationInput === undefined
1220
+ ? {}
1221
+ : { creationInput: selection.creationInput }),
1222
+ },
1223
+ ],
1224
+ }
1225
+ : {
1226
+ roots: [
1227
+ {
1228
+ nodeIdentity: selection.nodeIdentity ?? "addition",
1229
+ contentIdentity: selection.contentIdentity,
1230
+ ...(selection.creationInput === undefined
1231
+ ? {}
1232
+ : { creationInput: selection.creationInput }),
1233
+ ...(selection.layout === undefined
1234
+ ? {}
1235
+ : { layout: selection.layout }),
1236
+ ...(selection.dependencyBindings === undefined
1237
+ ? {}
1238
+ : { dependencyBindings: selection.dependencyBindings }),
1239
+ },
1240
+ ],
1241
+ };
1242
+ async function prepareAddProject(prepareOptions) {
1243
+ const restored = {
1244
+ blueprint: prepareOptions.restored.blueprint,
1245
+ generationRecord: prepareOptions.restored.generationRecord,
1246
+ normalizedDependencies: prepareOptions.restored.normalizedDependencies,
1247
+ };
1248
+ const dependencyIdentities = new Map(restored.normalizedDependencies?.map((requirement) => [
1249
+ dependencyIdentityCacheKey(requirement.consumerContentIdentity, requirement.key),
1250
+ requirement,
1251
+ ]));
1252
+ const common = {
1253
+ restored,
1254
+ operation: "add",
1255
+ operationFacts: prepareOptions.operationFacts,
1256
+ dependencyIdentities,
1257
+ };
1258
+ const before = await prepareProjectInternal(common);
1259
+ const after = await prepareProjectInternal({
1260
+ ...common,
1261
+ selection: additionSelection(prepareOptions.selection),
240
1262
  });
1263
+ return {
1264
+ restored: prepareOptions.restored,
1265
+ before,
1266
+ after,
1267
+ readFacts: prepareOptions.restored.readFacts,
1268
+ };
241
1269
  }
242
- function requiredDependencyIdentities(records) {
243
- const dependenciesByPackageId = new Map();
244
- for (const record of records) {
245
- const content = requireContent(record.contentIdentity);
246
- dependenciesByPackageId.set(record.definition.packageDefinitionId, options.strategy.dependencies({
247
- content,
248
- contentByIdentity,
249
- configuration: record.configuration,
250
- ...(record.creationInput === null
251
- ? {}
252
- : { creationInput: record.creationInput }),
253
- }));
1270
+ function computeProject(preparedProject) {
1271
+ if (preparedProject.composition !== composition) {
1272
+ throw new Error("准备结果属于另一个组合定义");
254
1273
  }
255
- return dependenciesByPackageId;
256
- }
257
- function validateRequiredBindings(records, dependenciesByPackageId = requiredDependencyIdentities(records), providers = records) {
258
- for (const record of records) {
259
- const dependencies = dependenciesByPackageId.get(record.definition.packageDefinitionId);
260
- if (dependencies === undefined) {
261
- throw new Error("生成记录缺少已准备的内容依赖:" +
262
- contentIdentityLabel(record.contentIdentity));
263
- }
264
- for (const dependency of dependencies) {
265
- const dependencyKey = contentIdentityKey(dependency);
266
- const packageDefinitionId = record.bindings[dependencyKey];
267
- if (packageDefinitionId === undefined) {
268
- throw new Error(`生成记录中的内容 ${contentIdentityLabel(record.contentIdentity)} 缺少必要实例绑定:${contentIdentityLabel(dependency)}`);
269
- }
270
- const provider = findByPackageId(providers, packageDefinitionId);
271
- if (contentIdentityKey(provider.contentIdentity) !== dependencyKey) {
272
- throw new Error(`生成记录中的内容 ${contentIdentityLabel(record.contentIdentity)} 将依赖绑定到错误实例:${contentIdentityLabel(dependency)}`);
1274
+ const nodes = [];
1275
+ const sharedNodes = new Map();
1276
+ const nodesById = new Map();
1277
+ const nodesByPrepared = new WeakMap();
1278
+ const wiringNodes = new Set();
1279
+ const selectionRecords = [];
1280
+ const explicitlySelectedSharedReferences = new Map();
1281
+ for (const selection of preparedProject.selections) {
1282
+ if (selection.createdBy === undefined)
1283
+ continue;
1284
+ for (const root of selection.roots) {
1285
+ if (root.content.definition.instance === "shared") {
1286
+ explicitlySelectedSharedReferences.set(contentIdentityKey(root.content.identity), selection.createdBy);
273
1287
  }
274
1288
  }
275
1289
  }
276
- }
277
- function validateNodeInstances(records, nodeInstances) {
278
- const mappedIds = new Set(Object.values(nodeInstances));
279
- for (const record of records) {
280
- if (record.createdBy === "initialization" &&
281
- !mappedIds.has(record.packageDefinitionId)) {
282
- throw new Error(`生成记录中的内容 ${contentIdentityLabel(record.contentIdentity)} 缺少必要节点实例映射:${record.packageDefinitionId}`);
1290
+ const makeNode = (prepared, createdBy, discriminator) => {
1291
+ const preparedNode = nodesByPrepared.get(prepared);
1292
+ if (preparedNode !== undefined)
1293
+ return preparedNode;
1294
+ const identityKey = contentIdentityKey(prepared.content.identity);
1295
+ const restoredId = prepared.restored?.packageDefinitionId;
1296
+ if (restoredId !== undefined) {
1297
+ const restored = nodesById.get(restoredId);
1298
+ if (restored !== undefined) {
1299
+ if (contentIdentityKey(restored.content.identity) !== identityKey ||
1300
+ !isDeepStrictEqual(restored.definition, {
1301
+ ...prepared.definition,
1302
+ packageDefinitionId: restoredId,
1303
+ }) ||
1304
+ !isDeepStrictEqual(restored.creationInput, prepared.creationInput ?? null) ||
1305
+ !isDeepStrictEqual(restored.preparation, prepared.preparation)) {
1306
+ throw new Error(`生成记录中的包实例事实不一致:${restoredId}`);
1307
+ }
1308
+ nodesByPrepared.set(prepared, restored);
1309
+ return restored;
1310
+ }
283
1311
  }
284
- }
285
- }
286
- function validatePresetSelections(selections) {
287
- for (const selection of selections) {
288
- if (!presetsByIdentity.has(presetSelectionKey(selection))) {
289
- throw new Error(`生成记录所选预设不可用:${contentIdentityLabel(selection)}`);
1312
+ const sharedKey = prepared.content.definition.instance === "shared"
1313
+ ? identityKey
1314
+ : undefined;
1315
+ if (sharedKey !== undefined) {
1316
+ const existing = sharedNodes.get(sharedKey);
1317
+ if (existing !== undefined) {
1318
+ if (!isDeepStrictEqual({
1319
+ name: existing.definition.name,
1320
+ path: existing.definition.path,
1321
+ role: existing.definition.role,
1322
+ }, prepared.definition) ||
1323
+ !isDeepStrictEqual(existing.creationInput, prepared.creationInput ?? null) ||
1324
+ !isDeepStrictEqual(existing.preparation, prepared.preparation)) {
1325
+ throw new Error(`共享参考包的创建事实不一致:${contentIdentityLabel(prepared.content.identity)}`);
1326
+ }
1327
+ if (restoredId !== undefined && existing.id !== restoredId) {
1328
+ throw new Error(`共享实例标识与生成记录不一致:${restoredId}`);
1329
+ }
1330
+ if (wiringNodes.has(existing)) {
1331
+ throw new Error("预设节点依赖形成循环");
1332
+ }
1333
+ wiringNodes.add(existing);
1334
+ const proposedDependencies = prepared.dependencies.map((dependency) => ({
1335
+ key: dependency.key,
1336
+ package: makeNode(dependency.package, "shared-dependency", `${existing.id}:${dependency.key}`),
1337
+ }));
1338
+ wiringNodes.delete(existing);
1339
+ if (proposedDependencies.length !== existing.dependencies.size ||
1340
+ proposedDependencies.some(({ key, package: provider }) => existing.dependencies.get(key)?.id !== provider.id)) {
1341
+ throw new Error("共享参考包的依赖绑定不一致");
1342
+ }
1343
+ nodesByPrepared.set(prepared, existing);
1344
+ return existing;
1345
+ }
290
1346
  }
291
- }
292
- }
293
- function resolveNodeInstances(records, nodeInstances) {
294
- return new Map(Object.entries(nodeInstances).map(([nodeIdentity, packageDefinitionId]) => [
295
- nodeIdentity,
296
- findByPackageId(records, packageDefinitionId).definition,
297
- ]));
298
- }
299
- function nodesFromRecords(records) {
300
- return records.map((record) => {
301
- return {
302
- content: requireContent(record.contentIdentity),
303
- definition: record.definition,
304
- createdBy: record.createdBy,
305
- configuration: record.configuration,
306
- preparation: preparations.get(requireContent(record.contentIdentity).definition),
307
- preparationComplete: preparedDefinitions.has(requireContent(record.contentIdentity).definition),
308
- ...(record.creationInput === null
309
- ? {}
310
- : { creationInput: record.creationInput }),
311
- providers: new Map(),
312
- record,
1347
+ const explicitRoot = sharedKey === undefined ? prepared.explicitRoot : undefined;
1348
+ const effectiveCreatedBy = prepared.restored?.createdBy ??
1349
+ (sharedKey === undefined
1350
+ ? undefined
1351
+ : explicitlySelectedSharedReferences.get(sharedKey)) ??
1352
+ explicitRoot?.createdBy ??
1353
+ createdBy;
1354
+ const definition = {
1355
+ ...prepared.definition,
1356
+ packageDefinitionId: restoredId ??
1357
+ packageId({
1358
+ contentIdentity: prepared.content.identity,
1359
+ definition: prepared.definition,
1360
+ creationInput: prepared.creationInput ?? null,
1361
+ createdBy: effectiveCreatedBy,
1362
+ discriminator: sharedKey !== undefined
1363
+ ? "shared-reference"
1364
+ : explicitRoot === undefined
1365
+ ? discriminator
1366
+ : `${explicitRoot.selectionId}:${explicitRoot.nodeIdentity}`,
1367
+ }),
313
1368
  };
314
- });
315
- }
316
- function createContribution(node, context, allRecords, nodeInstances) {
317
- if (node.contribution !== undefined)
318
- return node.contribution;
319
- const providerDefinitions = new Map();
320
- const bindings = node.record?.bindings;
321
- if (bindings !== undefined) {
322
- for (const [identity, id] of Object.entries(bindings)) {
323
- const record = findByPackageId(allRecords, id);
324
- providerDefinitions.set(identity, record.definition);
1369
+ const node = {
1370
+ id: definition.packageDefinitionId,
1371
+ content: prepared.content,
1372
+ definition,
1373
+ createdBy: effectiveCreatedBy,
1374
+ creationInput: prepared.creationInput ?? null,
1375
+ preparation: prepared.preparation,
1376
+ dependencies: new Map(),
1377
+ };
1378
+ nodes.push(node);
1379
+ nodesById.set(node.id, node);
1380
+ nodesByPrepared.set(prepared, node);
1381
+ if (sharedKey !== undefined)
1382
+ sharedNodes.set(sharedKey, node);
1383
+ wiringNodes.add(node);
1384
+ for (const dependency of prepared.dependencies) {
1385
+ const provider = makeNode(dependency.package, "shared-dependency", `${definition.packageDefinitionId}:${dependency.key}`);
1386
+ node.dependencies.set(dependency.key, provider);
325
1387
  }
326
- }
327
- else {
328
- for (const [identity, provider] of node.providers) {
329
- if (provider.record === undefined) {
330
- throw new Error("内容闭包的包实例尚未登记:" + identity);
1388
+ wiringNodes.delete(node);
1389
+ return node;
1390
+ };
1391
+ for (const selection of preparedProject.selections) {
1392
+ const id = selection.selectionId ??
1393
+ selectionId({
1394
+ compositionIdentity: composition.identity,
1395
+ presetIdentity: selection.presetIdentity,
1396
+ roots: selection.roots.map((root) => ({
1397
+ nodeIdentity: root.nodeIdentity,
1398
+ contentIdentity: root.content.identity,
1399
+ creationInput: root.creationInput ?? null,
1400
+ definition: root.definition,
1401
+ })),
1402
+ });
1403
+ const nodeIds = {};
1404
+ for (const root of selection.roots) {
1405
+ const node = makeNode(root, selection.createdBy ?? "initialization", `${id}:${root.nodeIdentity}`);
1406
+ const expected = selection.recordedNodeIds?.[root.nodeIdentity];
1407
+ if (expected !== undefined && expected !== node.id) {
1408
+ throw new Error(`生成记录中的选择节点实例不一致:${root.nodeIdentity}`);
331
1409
  }
332
- providerDefinitions.set(identity, provider.definition);
1410
+ nodeIds[root.nodeIdentity] = node.id;
333
1411
  }
1412
+ if (selection.recordedNodeIds !== undefined &&
1413
+ Object.keys(selection.recordedNodeIds).length !==
1414
+ Object.keys(nodeIds).length) {
1415
+ throw new Error(`生成记录中的选择节点数量不一致:${id}`);
1416
+ }
1417
+ selectionRecords.push({
1418
+ selectionId: id,
1419
+ presetIdentity: selection.presetIdentity,
1420
+ nodes: nodeIds,
1421
+ });
334
1422
  }
335
- const nativeBindings = options.strategy.bindings({
336
- content: node.content,
337
- contentByIdentity,
338
- providers: providerDefinitions,
339
- });
340
- const contributionOptions = {
341
- context,
342
- configuration: node.configuration,
1423
+ if (preparedProject.restored !== undefined) {
1424
+ const recordedOrder = new Map(preparedProject.restored.generationRecord.packages.map((item, index) => [item.packageDefinitionId, index]));
1425
+ nodes.sort((left, right) => (recordedOrder.get(left.id) ?? Number.MAX_SAFE_INTEGER) -
1426
+ (recordedOrder.get(right.id) ?? Number.MAX_SAFE_INTEGER));
1427
+ }
1428
+ const packageRecords = nodes.map((node) => ({
1429
+ packageDefinitionId: node.id,
1430
+ contentIdentity: node.content.identity,
1431
+ createdBy: node.createdBy,
1432
+ creationInput: node.creationInput,
1433
+ dependencyBindings: Object.fromEntries([...node.dependencies.entries()].map(([key, provider]) => [
1434
+ key,
1435
+ provider.id,
1436
+ ])),
1437
+ }));
1438
+ const packages = nodes.map((node) => ({
1439
+ packageDefinitionId: node.id,
1440
+ contentIdentity: node.content.identity,
343
1441
  definition: node.definition,
344
- bindings: nativeBindings,
345
1442
  createdBy: node.createdBy,
346
- nodeInstances,
347
- ...(node.preparationComplete ? { preparation: node.preparation } : {}),
348
- ...(node.creationInput === undefined
349
- ? {}
350
- : { creationInput: node.creationInput }),
1443
+ creationInput: node.creationInput,
1444
+ dependencyBindings: Object.fromEntries([...node.dependencies.entries()].map(([key, provider]) => [
1445
+ key,
1446
+ provider.id,
1447
+ ])),
1448
+ }));
1449
+ const bindingsFor = (node) => {
1450
+ const bindings = new Map();
1451
+ for (const { key } of node.content.definition.dependencies ?? []) {
1452
+ const provider = node.dependencies.get(key);
1453
+ if (provider === undefined) {
1454
+ throw new Error(`参考包依赖尚未绑定:${node.id} → ${key}`);
1455
+ }
1456
+ if (provider.contribution === undefined) {
1457
+ throw new Error(`依赖包尚未求值:${provider.id}`);
1458
+ }
1459
+ bindings.set(key, {
1460
+ packageDefinitionId: provider.id,
1461
+ contentIdentity: provider.content.identity,
1462
+ definition: provider.definition,
1463
+ facts: structuredClone(provider.contribution.facts),
1464
+ });
1465
+ }
1466
+ return bindings;
351
1467
  };
352
- const contribution = node.content.definition.contribute(contributionOptions);
353
- const contributionDefinition = contribution.definition;
354
- if (contributionDefinition.name !== node.definition.name ||
355
- contributionDefinition.path !== node.definition.path ||
356
- contributionDefinition.role !== node.definition.role ||
357
- ("packageDefinitionId" in contributionDefinition &&
358
- contributionDefinition.packageDefinitionId !==
359
- node.record?.packageDefinitionId)) {
360
- throw new Error(`内容 ${contentIdentityLabel(node.content.identity)} 返回的包定义与已分配实例不一致:${node.definition.path}`);
361
- }
362
- assertPackageContribution({
363
- definition: node.definition,
364
- operations: contribution.operations,
365
- }, {
366
- definitionName: contentIdentityLabel(node.content.identity),
367
- planner: "内容贡献",
368
- });
369
- node.contribution = contribution;
370
- return node.contribution;
371
- }
372
- function storedRecord(state, records, nodeInstances, presetSelections) {
373
- return {
1468
+ const provisionalBlueprint = assertProjectBlueprint({
374
1469
  schemaVersion: 4,
375
- strategyIdentity: options.strategy.identity,
376
- strategyState: state,
377
- packages: records.map(({ definition: _definition, ...record }) => record),
378
- nodeInstances,
379
- presetSelections,
380
- };
381
- }
382
- function selectedPreset(preset) {
383
- return preset.identity;
384
- }
385
- function mergePresetSelections(existing, added) {
386
- const selections = new Map();
387
- for (const selection of [...existing, ...added]) {
388
- selections.set(presetSelectionKey(selection), selection);
1470
+ packages: nodes.map((node) => node.definition),
1471
+ packageLinkIntents: [],
1472
+ });
1473
+ const resolution = composition.resolve({
1474
+ conventions: preparedProject.conventions,
1475
+ blueprint: provisionalBlueprint,
1476
+ selections: selectionRecords,
1477
+ packages,
1478
+ operationFacts: preparedProject.operationFacts,
1479
+ });
1480
+ for (const id of resolution.packageInputs.keys()) {
1481
+ if (!nodes.some((node) => node.id === id)) {
1482
+ throw new Error(`组合输入引用了未知软件包实例:${id}`);
1483
+ }
389
1484
  }
390
- return [...selections.values()];
391
- }
392
- async function validatePresetUpdate(targetRoot, context, contributions, nodeInstances, presetSelections) {
393
- for (const selection of presetSelections) {
394
- const presetMember = presetsByIdentity.get(presetSelectionKey(selection));
395
- if (presetMember === undefined) {
396
- throw new Error(`生成记录所选预设不可用:${contentIdentityLabel(selection)}`);
1485
+ const blueprint = assertProjectBlueprint({
1486
+ ...provisionalBlueprint,
1487
+ packageLinkIntents: resolution.packageLinkIntents ?? [],
1488
+ });
1489
+ if (preparedProject.restored !== undefined) {
1490
+ const existingIds = new Set(preparedProject.restored.generationRecord.packages.map((item) => item.packageDefinitionId));
1491
+ const existingBlueprintPackages = blueprint.packages.filter((item) => existingIds.has(item.packageDefinitionId));
1492
+ const recordedBlueprintPackages = preparedProject.restored.blueprint.packages.filter((item) => existingIds.has(item.packageDefinitionId));
1493
+ if (!isDeepStrictEqual(existingBlueprintPackages, recordedBlueprintPackages)) {
1494
+ throw new Error("回放后的包定义与持久蓝图不一致");
1495
+ }
1496
+ const existingLinks = blueprint.packageLinkIntents.filter(({ consumerId, providerId }) => existingIds.has(consumerId) && existingIds.has(providerId));
1497
+ if (!isDeepStrictEqual(existingLinks, preparedProject.restored.blueprint.packageLinkIntents)) {
1498
+ throw new Error("回放后的显式包连接与持久蓝图不一致");
397
1499
  }
398
- await presetMember.definition.validateUpdate?.({
399
- targetRoot,
400
- context,
401
- contributions,
402
- nodeInstances,
403
- });
404
1500
  }
405
- }
406
- function computePresetProjectContributions(context, contributions, nodeInstances, presetSelections) {
407
- return presetSelections.flatMap((selection) => {
408
- const presetMember = presetsByIdentity.get(presetSelectionKey(selection));
409
- if (presetMember === undefined) {
410
- throw new Error(`生成记录所选预设不可用:${contentIdentityLabel(selection)}`);
1501
+ const visiting = new Set();
1502
+ const complete = new Set();
1503
+ const evaluate = (node) => {
1504
+ if (node.contribution !== undefined)
1505
+ return node.contribution;
1506
+ if (visiting.has(node.id))
1507
+ throw new Error("软件包依赖图包含循环");
1508
+ visiting.add(node.id);
1509
+ for (const provider of node.dependencies.values()) {
1510
+ evaluate(provider);
411
1511
  }
412
- if (presetMember.definition.project === undefined)
413
- return [];
414
- return presetMember.definition.project({
415
- context,
416
- contributions,
417
- nodeInstances,
1512
+ const contentPreparation = clonePreparation(node.preparation);
1513
+ const contribution = node.content.definition.evaluate({
1514
+ packageDefinitionId: node.id,
1515
+ definition: node.definition,
1516
+ createdBy: node.createdBy,
1517
+ creationInput: node.creationInput,
1518
+ prepared: contentPreparation,
1519
+ bindings: bindingsFor(node),
1520
+ conventions: structuredClone(preparedProject.conventions),
1521
+ stableCommon: structuredClone(resolution.stableCommon),
1522
+ packageInput: structuredClone(resolution.packageInputs.get(node.id)),
418
1523
  });
1524
+ if (contribution.packageDefinitionId !== node.id) {
1525
+ throw new Error(`包贡献返回了错误的软件包实例标识:${node.id}`);
1526
+ }
1527
+ node.contribution = contribution;
1528
+ visiting.delete(node.id);
1529
+ complete.add(node.id);
1530
+ return contribution;
1531
+ };
1532
+ for (const node of nodes)
1533
+ evaluate(node);
1534
+ if (complete.size !== nodes.length)
1535
+ throw new Error("部分软件包贡献尚未求值");
1536
+ const compositionPackages = nodes.map((node) => ({
1537
+ package: packages.find((item) => item.packageDefinitionId === node.id),
1538
+ bindings: bindingsFor(node),
1539
+ contribution: node.contribution,
1540
+ }));
1541
+ const combined = composition.combine({
1542
+ conventions: preparedProject.conventions,
1543
+ stableCommon: structuredClone(resolution.stableCommon),
1544
+ blueprint,
1545
+ selections: selectionRecords,
1546
+ packages: compositionPackages,
419
1547
  });
420
- }
421
- function project(context, state, blueprint, records, contributions, nodeInstances, presetSelections) {
422
- const resolvedNodeInstances = resolveNodeInstances(records, nodeInstances);
423
- const presetProjectContributions = computePresetProjectContributions(context, contributions, resolvedNodeInstances, presetSelections);
424
- const projection = options.strategy.project({
425
- context,
426
- state,
1548
+ const projection = projectPackageContributions({
427
1549
  blueprint,
428
- packages: records,
429
- contributions,
430
- nodeInstances: resolvedNodeInstances,
431
- presetProjectContributions,
1550
+ contributions: nodes.map((node) => node.contribution),
1551
+ ...(combined.files === undefined
1552
+ ? {}
1553
+ : { compositionFiles: combined.files }),
1554
+ ...(combined.reconciliation === undefined
1555
+ ? {}
1556
+ : { compositionReconciliation: combined.reconciliation }),
432
1557
  });
433
- const projectedBlueprint = assertProjectBlueprint(projection.blueprint ?? blueprint);
434
- const allocatedDefinitions = new Map(records.map((record) => [record.packageDefinitionId, record.definition]));
435
- if (projectedBlueprint.packages.length !== allocatedDefinitions.size) {
436
- throw new Error("策略蓝图必须引用完整且唯一的已分配包实例");
437
- }
438
- for (const projectedDefinition of projectedBlueprint.packages) {
439
- const allocated = allocatedDefinitions.get(projectedDefinition.packageDefinitionId);
440
- if (allocated === undefined ||
441
- allocated.name !== projectedDefinition.name ||
442
- allocated.path !== projectedDefinition.path ||
443
- allocated.role !== projectedDefinition.role) {
444
- throw new Error("策略蓝图中的包定义必须与生成器分配的包实例一致:" +
445
- projectedDefinition.path);
1558
+ const sourcesByPackage = new Map(nodes.map((node) => [
1559
+ node.id,
1560
+ {
1561
+ identity: `content:${contentIdentityKey(node.content.identity)}:${node.id}`,
1562
+ label: `${contentIdentityLabel(node.content.identity)}(${node.definition.path})`,
1563
+ },
1564
+ ]));
1565
+ const packageSources = [...sourcesByPackage.values()];
1566
+ const compositionSource = {
1567
+ identity: `composition:${contentIdentityKey(composition.identity)}`,
1568
+ label: `组合${contentIdentityLabel(composition.identity)}`,
1569
+ };
1570
+ const sourcesByPath = new Map();
1571
+ const addPathSources = (targetPath, sources) => {
1572
+ const existing = sourcesByPath.get(targetPath) ?? [];
1573
+ const definedSources = sources.filter((source) => source !== undefined);
1574
+ sourcesByPath.set(targetPath, mergeProjectionSources(existing, definedSources));
1575
+ };
1576
+ for (const node of nodes) {
1577
+ const source = sourcesByPackage.get(node.id);
1578
+ for (const file of node.contribution.files) {
1579
+ addPathSources(projectionPath(node.definition.path, file.path), [
1580
+ source,
1581
+ ]);
1582
+ }
1583
+ for (const policy of node.contribution.reconciliation ?? []) {
1584
+ addPathSources(projectionPath(node.definition.path, policy.path), [
1585
+ source,
1586
+ ]);
446
1587
  }
447
- allocatedDefinitions.delete(projectedDefinition.packageDefinitionId);
448
1588
  }
449
- if (allocatedDefinitions.size > 0) {
450
- throw new Error("策略蓝图遗漏了已分配的包实例");
1589
+ const combinedSources = [compositionSource, ...packageSources];
1590
+ for (const item of combined.files ?? []) {
1591
+ const definition = blueprint.packages.find((candidate) => candidate.packageDefinitionId === item.packageDefinitionId);
1592
+ addPathSources(projectionPath(definition.path, item.file.path), combinedSources);
1593
+ }
1594
+ for (const item of combined.reconciliation ?? []) {
1595
+ const definition = blueprint.packages.find((candidate) => candidate.packageDefinitionId === item.packageDefinitionId);
1596
+ addPathSources(projectionPath(definition.path, item.reconciliation.path), combinedSources);
451
1597
  }
452
- const generationRecord = storedRecord(state, records, nodeInstances, presetSelections);
1598
+ const annotatedProjection = {
1599
+ entries: projection.entries.map((entry) => {
1600
+ const sources = mergeProjectionSources(entry.sources, sourcesByPath.get(entry.path));
1601
+ return sources.length === 0 ? entry : { ...entry, sources };
1602
+ }),
1603
+ reconciliation: projection.reconciliation.map((policy) => {
1604
+ const sources = mergeProjectionSources(policy.sources, sourcesByPath.get(policy.path));
1605
+ return sources.length === 0 ? policy : { ...policy, sources };
1606
+ }),
1607
+ };
1608
+ const metadataSources = mergeProjectionSources(packageSources, [
1609
+ compositionSource,
1610
+ ]);
1611
+ const generationRecord = {
1612
+ schemaVersion: 6,
1613
+ composition: {
1614
+ identity: composition.identity,
1615
+ conventions: preparedProject.conventions,
1616
+ },
1617
+ packages: packageRecords,
1618
+ selections: selectionRecords,
1619
+ };
1620
+ assertGenerationRecordMatchesBlueprint(generationRecord, blueprint);
1621
+ const metadataEntries = [
1622
+ {
1623
+ path: generatorMetadataPaths.blueprint,
1624
+ kind: "file",
1625
+ content: printCanonicalJson(blueprint),
1626
+ mode: 0,
1627
+ sources: metadataSources,
1628
+ },
1629
+ {
1630
+ path: generatorMetadataPaths.generationRecord,
1631
+ kind: "file",
1632
+ content: printCanonicalJson(generationRecord),
1633
+ mode: 0,
1634
+ sources: metadataSources,
1635
+ },
1636
+ ];
1637
+ const metadataReconciliation = metadataEntries.map((entry) => ({
1638
+ path: entry.path,
1639
+ driver: "canonical",
1640
+ ...(entry.sources === undefined ? {} : { sources: entry.sources }),
1641
+ }));
1642
+ const finalProjection = {
1643
+ entries: [...annotatedProjection.entries, ...metadataEntries].toSorted((left, right) => comparePaths(left.path, right.path)),
1644
+ reconciliation: [
1645
+ ...annotatedProjection.reconciliation,
1646
+ ...metadataReconciliation,
1647
+ ].toSorted((left, right) => comparePaths(left.path, right.path)),
1648
+ };
453
1649
  return {
454
- ...projection,
455
- blueprint: projectedBlueprint,
456
- operations: [
457
- ...projection.operations,
458
- {
459
- kind: "writeJson",
460
- to: ".template/generation.json",
461
- value: generationRecord,
462
- },
463
- ],
1650
+ blueprint,
464
1651
  generationRecord,
1652
+ projection: finalProjection,
1653
+ packages: nodes.map((node) => ({
1654
+ package: packages.find((item) => item.packageDefinitionId === node.id),
1655
+ bindings: bindingsFor(node),
1656
+ contribution: node.contribution,
1657
+ })),
1658
+ ownerFacts: combined.facts,
465
1659
  };
466
1660
  }
467
- function expandDependencies(options_) {
468
- const newNodes = new Map();
469
- const visiting = new Set();
470
- const expanded = new Set();
471
- const visit = (node) => {
472
- const identity = contentIdentityKey(node.content.identity);
473
- const key = identity + "\u0000" + node.definition.path;
474
- if (visiting.has(key)) {
475
- throw new Error("显式内容依赖形成循环:" +
476
- contentIdentityLabel(node.content.identity));
477
- }
478
- if (expanded.has(key))
479
- return;
480
- visiting.add(key);
481
- if (node.record === undefined)
482
- newNodes.set(key, node);
483
- node.preparation = prepareContent(node.content);
484
- node.preparationComplete = true;
485
- const dependencies = options.strategy.dependencies({
486
- content: node.content,
487
- contentByIdentity,
488
- configuration: node.configuration,
489
- ...(node.creationInput === undefined
490
- ? {}
491
- : { creationInput: node.creationInput }),
1661
+ async function planInit(initOptions) {
1662
+ let prepared;
1663
+ try {
1664
+ prepared = await prepareProject({
1665
+ selection: initOptions.selection,
1666
+ conventions: initOptions.conventions,
1667
+ operationFacts: initOptions.operationFacts,
492
1668
  });
493
- for (const dependencyIdentity of dependencies) {
494
- const dependencyKey = contentIdentityKey(dependencyIdentity);
495
- const dependency = requireContent(dependencyIdentity);
496
- const candidates = [...options_.existing, ...newNodes.values()].filter((candidate) => contentIdentityKey(candidate.content.identity) === dependencyKey);
497
- const boundId = node.record?.bindings[dependencyKey];
498
- const bound = boundId === undefined
499
- ? undefined
500
- : candidates.find((candidate) => candidate.record?.packageDefinitionId === boundId);
501
- if (bound === undefined && candidates.length > 1) {
502
- throw new Error("依赖内容有多个持久实例,无法唯一绑定:" +
503
- contentIdentityLabel(dependencyIdentity));
504
- }
505
- let provider = bound ?? candidates[0];
506
- if (provider === undefined) {
507
- if (dependency.definition.instance !== "shared") {
508
- throw new Error("缺少明确的独立依赖实例:" +
509
- contentIdentityLabel(dependencyIdentity));
510
- }
511
- const definition = options.strategy.createDefinition({
512
- context: options_.context,
513
- content: dependency,
514
- });
515
- const occupied = [...options_.existing, ...newNodes.values()].find((candidate) => candidate.definition.name === definition.name ||
516
- candidate.definition.path === definition.path);
517
- if (occupied !== undefined) {
518
- throw new Error("共享依赖默认身份已被占用:" + definition.path);
519
- }
520
- provider = {
521
- content: dependency,
522
- definition,
523
- createdBy: "shared-dependency",
524
- configuration: normalizeConfiguration(dependency, undefined),
525
- providers: new Map(),
526
- };
527
- newNodes.set(dependencyKey + "\u0000" + definition.path, provider);
528
- }
529
- node.providers.set(dependencyKey, provider);
530
- visit(provider);
531
- }
532
- visiting.delete(key);
533
- expanded.add(key);
534
- };
535
- const explicitByContent = new Set();
536
- const explicitByPath = new Set();
537
- const explicitByNode = new Set();
538
- for (const root of options_.roots) {
539
- const identity = contentIdentityKey(root.content.identity);
540
- const key = identity + "\u0000" + root.definition.path;
541
- if (explicitByNode.has(root.nodeIdentity ?? "")) {
542
- throw new Error("显式初始化节点身份重复:" + root.nodeIdentity);
543
- }
544
- explicitByNode.add(root.nodeIdentity ?? "");
545
- if (root.content.definition.instance === "independent" &&
546
- explicitByContent.has(identity)) {
547
- throw new Error("同一独立内容不能重复作为显式根:" +
548
- contentIdentityLabel(root.content.identity));
549
- }
550
- explicitByContent.add(identity);
551
- if (explicitByPath.has(root.definition.path)) {
552
- throw new Error("显式初始化根路径重复:" + root.definition.path);
553
- }
554
- explicitByPath.add(root.definition.path);
555
- if (root.record === undefined)
556
- newNodes.set(key, root);
557
1669
  }
558
- for (const root of options_.roots)
559
- visit(root);
560
- const nodes = [...newNodes.values()];
561
- for (const node of nodes) {
562
- const persisted = {
563
- ...node.definition,
564
- packageDefinitionId: packageId({
565
- contentIdentity: node.content.identity,
566
- createdBy: node.createdBy,
567
- definition: node.definition,
568
- occupied: options_.occupiedIds,
569
- }),
570
- };
571
- options_.occupiedIds.add(persisted.packageDefinitionId);
572
- node.definition = persisted;
573
- node.record = {
574
- contentIdentity: node.content.identity,
575
- createdBy: node.createdBy,
576
- packageDefinitionId: persisted.packageDefinitionId,
577
- creationInput: node.creationInput ?? null,
578
- configuration: node.configuration,
579
- bindings: {},
1670
+ catch (error) {
1671
+ return {
1672
+ status: "operation-failure",
1673
+ phase: "preparation",
1674
+ error: { message: errorMessage(error) },
580
1675
  };
581
1676
  }
582
- for (const node of new Set([...nodes, ...options_.roots])) {
583
- const bindings = Object.fromEntries([...node.providers].map(([identity, provider]) => {
584
- if (provider.record === undefined) {
585
- throw new Error("内容闭包绑定缺少包实例:" + identity);
586
- }
587
- return [identity, provider.record.packageDefinitionId];
588
- }));
589
- node.record = { ...node.record, bindings };
590
- }
591
- return nodes;
592
- }
593
- function persistedContributions(nodes, context, records, nodeInstances) {
594
- return nodes.map((node) => createContribution(node, context, records, nodeInstances));
595
- }
596
- async function init(initOptions) {
1677
+ let computed;
597
1678
  try {
598
- const selectedPresets = [];
599
- for (const root of initOptions.selection.roots) {
600
- if (!("preset" in root))
601
- continue;
602
- selectedPresets.push(selectedPreset(resolvePreset(root.preset)));
603
- }
604
- const presetSelections = mergePresetSelections([], selectedPresets);
605
- const selectionRoots = initOptions.selection.roots.flatMap((root) => "preset" in root
606
- ? expandPreset({
607
- preset: resolvePreset(root.preset),
608
- operation: "init",
609
- configuration: root.configuration,
610
- ...(root.creationInput === undefined
1679
+ computed = computeProject(prepared);
1680
+ }
1681
+ catch (error) {
1682
+ const packageIdentityIssues = error instanceof ProjectBlueprintValidationError
1683
+ ? error.packageIdentityIssues
1684
+ : [];
1685
+ return {
1686
+ status: "operation-failure",
1687
+ phase: "calculation",
1688
+ error: {
1689
+ message: errorMessage(error),
1690
+ ...(packageIdentityIssues.length === 0
611
1691
  ? {}
612
- : { creationInput: root.creationInput }),
613
- })
614
- : [
615
- {
616
- ...root,
617
- contentIdentity: requireContent(root.contentIdentity).identity,
618
- },
619
- ]);
620
- if (selectionRoots.length === 0) {
621
- throw new Error("初始化至少需要一个显式内容根");
622
- }
623
- const rootsByIdentity = new Set();
624
- for (const root of selectionRoots) {
625
- if (root.nodeIdentity.length === 0) {
626
- throw new Error("显式初始化节点身份不能为空");
627
- }
628
- if (rootsByIdentity.has(root.nodeIdentity)) {
629
- throw new Error("显式初始化节点身份重复:" + root.nodeIdentity);
630
- }
631
- rootsByIdentity.add(root.nodeIdentity);
632
- requireContent(root.contentIdentity);
633
- }
634
- const prepared = options.strategy.initialize({
1692
+ : { packageIdentityIssues }),
1693
+ },
1694
+ };
1695
+ }
1696
+ try {
1697
+ const sources = mergeProjectionSources(...computed.projection.entries.map((entry) => entry.sources), ...computed.projection.reconciliation.map((policy) => policy.sources));
1698
+ const preconditions = [
1699
+ {
1700
+ path: ".",
1701
+ kind: "directory-empty-or-missing",
1702
+ reason: "初始化要求目标目录为空或不存在",
1703
+ ...(sources.length === 0 ? {} : { sources }),
1704
+ },
1705
+ ];
1706
+ const current = await readProjectProjectionCurrent({
635
1707
  targetRoot: initOptions.targetRoot,
636
- input: initOptions.strategyInput,
637
- selection: selectionRoots,
638
- contentByIdentity,
1708
+ before: emptyProjectProjection,
1709
+ after: computed.projection,
1710
+ preconditions,
639
1711
  });
640
- const roots = selectionRoots.map((root) => {
641
- const content = requireContent(root.contentIdentity);
642
- const definition = options.strategy.createDefinition({
643
- context: prepared.context,
644
- content,
645
- ...(root.layout === undefined ? {} : { layout: root.layout }),
646
- ...(root.creationInput === undefined
647
- ? {}
648
- : { creationInput: root.creationInput }),
649
- });
1712
+ const planning = planProjectProjections({
1713
+ before: emptyProjectProjection,
1714
+ current,
1715
+ after: computed.projection,
1716
+ preconditions,
1717
+ });
1718
+ if (!planning.ok) {
650
1719
  return {
651
- content,
652
- definition,
653
- nodeIdentity: root.nodeIdentity,
654
- createdBy: "initialization",
655
- configuration: normalizeConfiguration(content, root.configuration),
656
- ...(root.creationInput === undefined
657
- ? {}
658
- : { creationInput: root.creationInput }),
659
- providers: new Map(),
1720
+ status: "conflict",
1721
+ reason: conflictReason(planning.conflicts),
1722
+ conflicts: planning.conflicts,
1723
+ actions: [],
660
1724
  };
661
- });
662
- const nodes = expandDependencies({
663
- roots,
664
- existing: [],
665
- context: prepared.context,
666
- occupiedIds: new Set(),
667
- });
668
- const records = nodes.flatMap((node) => node.record === undefined ? [] : [node.record]);
669
- const nodeInstances = Object.fromEntries(roots.map((root) => {
670
- if (root.record === undefined) {
671
- throw new Error("显式初始化节点没有持久实例:" + root.nodeIdentity);
672
- }
673
- return [root.nodeIdentity, root.record.packageDefinitionId];
674
- }));
675
- const blueprint = assertProjectBlueprint({
676
- schemaVersion: 3,
677
- packages: nodes.map((node) => node.definition),
678
- });
679
- const packageStates = resolvePackageStates(records, blueprint);
680
- validateRequiredBindings(packageStates);
681
- validateNodeInstances(packageStates, nodeInstances);
682
- const contributions = persistedContributions(nodes, prepared.context, packageStates, resolveNodeInstances(packageStates, nodeInstances));
683
- const projectPlan = project(prepared.context, prepared.state, blueprint, packageStates, contributions, nodeInstances, presetSelections);
684
- await materializeProjectProjection({
685
- operations: projectPlan.operations,
686
- reconciliation: projectPlan.reconciliation,
687
- });
688
- if (!initOptions.dryRun) {
689
- try {
690
- await renderNewProject({
691
- targetRoot: path.resolve(initOptions.targetRoot),
692
- operations: [...projectPlan.operations],
693
- });
694
- }
695
- catch (error) {
696
- return fail("render", error);
697
- }
698
1725
  }
1726
+ pendingPlans.set(planning.plan, {
1727
+ targetRoot: current.targetRoot,
1728
+ computed,
1729
+ });
699
1730
  return {
700
- status: "success",
701
- dryRun: initOptions.dryRun ?? false,
702
- blueprint: projectPlan.blueprint,
703
- generationRecord: projectPlan.generationRecord,
704
- projection: projectPlan,
705
- actions: [],
1731
+ status: "planned",
1732
+ plan: planning.plan,
1733
+ blueprint: computed.blueprint,
1734
+ generationRecord: computed.generationRecord,
1735
+ projection: computed.projection,
1736
+ ownerFacts: computed.ownerFacts,
1737
+ actions: planning.plan.actions,
706
1738
  };
707
1739
  }
708
1740
  catch (error) {
709
- return fail("planning", error);
1741
+ return {
1742
+ status: "operation-failure",
1743
+ phase: "planning",
1744
+ error: { message: errorMessage(error) },
1745
+ };
710
1746
  }
711
1747
  }
712
- async function restoreRepository(repositoryRoot) {
713
- const blueprintValue = JSON.parse(await readFile(path.join(repositoryRoot, ".template/blueprint.json"), "utf8"));
714
- const blueprint = assertProjectBlueprint(blueprintValue);
715
- const record = parseGenerationRecord(JSON.parse(await readFile(path.join(repositoryRoot, ".template/generation.json"), "utf8")));
716
- if (record.strategyIdentity !== options.strategy.identity) {
717
- throw new Error("目标仓库使用了不兼容的工作区策略");
718
- }
719
- const state = options.strategy.parseState(record.strategyState);
720
- const packageStates = resolvePackageStates(record.packages, blueprint);
721
- validateNodeInstances(packageStates, record.nodeInstances);
722
- validatePresetSelections(record.presetSelections);
723
- return { blueprint, record, state, packageStates };
724
- }
725
- async function add(addOptions) {
1748
+ async function planComputedAdd(options) {
1749
+ const { preparation, before } = options;
1750
+ let after;
726
1751
  try {
727
- const repositoryRoot = path.resolve(addOptions.repositoryRoot);
728
- let blueprint;
729
- let record;
730
- let packageStates;
731
- let state;
732
- try {
733
- ({ blueprint, record, state, packageStates } =
734
- await restoreRepository(repositoryRoot));
1752
+ if (!isDeepStrictEqual(before.generationRecord, preparation.restored.generationRecord) ||
1753
+ !isDeepStrictEqual(before.blueprint, preparation.restored.blueprint)) {
1754
+ throw new Error("Before 计算结果与恢复的项目记录不一致");
735
1755
  }
736
- catch (error) {
737
- return fail("metadata", error, options.strategy.diagnoseFailure?.(error));
738
- }
739
- let requiredDependencies;
740
- try {
741
- for (const packageRecord of packageStates) {
742
- prepareContent(requireContent(packageRecord.contentIdentity));
1756
+ const afterPackages = new Map(options.after.generationRecord.packages.map((item) => [
1757
+ item.packageDefinitionId,
1758
+ item,
1759
+ ]));
1760
+ const afterDefinitions = new Map(options.after.blueprint.packages.map((item) => [
1761
+ item.packageDefinitionId,
1762
+ item,
1763
+ ]));
1764
+ for (const item of before.generationRecord.packages) {
1765
+ if (!isDeepStrictEqual(afterPackages.get(item.packageDefinitionId), item)) {
1766
+ throw new Error(`After 未保留既有包实例事实:${item.packageDefinitionId}`);
743
1767
  }
744
- requiredDependencies = requiredDependencyIdentities(packageStates);
745
- }
746
- catch (error) {
747
- return fail("planning", error);
748
- }
749
- try {
750
- validateRequiredBindings(packageStates, requiredDependencies);
751
- }
752
- catch (error) {
753
- return fail("metadata", error, options.strategy.diagnoseFailure?.(error));
754
- }
755
- const additionRoots = "preset" in addOptions
756
- ? expandPreset({
757
- preset: resolvePreset(addOptions.preset),
758
- operation: "add",
759
- configuration: addOptions.configuration,
760
- ...(addOptions.creationInput === undefined
761
- ? {}
762
- : { creationInput: addOptions.creationInput }),
763
- })
764
- : [
765
- {
766
- nodeIdentity: "addition",
767
- configuration: addOptions.configuration,
768
- contentIdentity: addOptions.contentIdentity,
769
- ...(addOptions.creationInput === undefined
770
- ? {}
771
- : { creationInput: addOptions.creationInput }),
772
- },
773
- ];
774
- if (additionRoots.length !== 1) {
775
- throw new Error("加包预设必须恰好包含一个节点");
776
- }
777
- const selectionRoot = additionRoots[0];
778
- if (selectionRoot === undefined) {
779
- throw new Error("加包预设必须恰好包含一个节点");
780
1768
  }
781
- const selected = requireContent(selectionRoot.contentIdentity);
782
- const creationInput = selectionRoot.creationInput;
783
- const configuration = normalizeConfiguration(selected, selectionRoot.configuration);
784
- const addedPresetMember = "preset" in addOptions ? resolvePreset(addOptions.preset) : undefined;
785
- const addedPreset = addedPresetMember === undefined
786
- ? undefined
787
- : selectedPreset(addedPresetMember);
788
- const addedProjectPreset = addedPresetMember?.definition.project === undefined
789
- ? undefined
790
- : addedPreset;
791
- const existingNodes = nodesFromRecords(packageStates);
792
- const currentNodeInstances = resolveNodeInstances(packageStates, record.nodeInstances);
793
- try {
794
- prepareContent(selected);
795
- }
796
- catch (error) {
797
- return fail("planning", error);
798
- }
799
- let context;
800
- try {
801
- context = await options.strategy.prepareUpdate({
802
- targetRoot: repositoryRoot,
803
- state,
804
- content: selected,
805
- contentByIdentity,
806
- configuration,
807
- packages: packageStates,
808
- nodeInstances: currentNodeInstances,
809
- ...(creationInput === undefined ? {} : { creationInput }),
810
- });
811
- }
812
- catch (error) {
813
- return fail("metadata", error, options.strategy.diagnoseFailure?.(error));
814
- }
815
- const existingContributions = existingNodes.map((node) => createContribution(node, context, packageStates, currentNodeInstances));
816
- const definition = options.strategy.createDefinition({
817
- context,
818
- content: selected,
819
- ...(selectionRoot.layout === undefined
820
- ? {}
821
- : { layout: selectionRoot.layout }),
822
- ...(creationInput === undefined ? {} : { creationInput }),
823
- });
824
- const requested = {
825
- content: selected,
826
- definition,
827
- createdBy: "addition",
828
- configuration,
829
- ...(addedProjectPreset !== undefined
830
- ? { nodeIdentity: selectionRoot.nodeIdentity }
831
- : {}),
832
- ...(creationInput === undefined ? {} : { creationInput }),
833
- providers: new Map(),
834
- };
835
- let preparedAddition;
836
- const prepareAdditionNodes = () => {
837
- if (preparedAddition !== undefined)
838
- return preparedAddition;
839
- try {
840
- const nodes = expandDependencies({
841
- roots: [requested],
842
- existing: existingNodes,
843
- context,
844
- occupiedIds: new Set(record.packages.map((item) => item.packageDefinitionId)),
845
- });
846
- const records = nodes.flatMap((node) => node.record === undefined ? [] : [node.record]);
847
- const allRecords = [...record.packages, ...records];
848
- const afterBlueprint = {
849
- ...blueprint,
850
- packages: [
851
- ...blueprint.packages,
852
- ...nodes.map((node) => node.definition),
853
- ],
854
- };
855
- const packages = resolvePackageStates(allRecords, afterBlueprint);
856
- const addedPackageIds = new Set(records.map((item) => item.packageDefinitionId));
857
- const addedPackages = packages.filter((item) => addedPackageIds.has(item.packageDefinitionId));
858
- validateRequiredBindings(addedPackages, requiredDependencyIdentities(addedPackages), packages);
859
- const nodeInstanceIds = {
860
- ...record.nodeInstances,
861
- };
862
- if (addedProjectPreset !== undefined &&
863
- !Object.hasOwn(nodeInstanceIds, selectionRoot.nodeIdentity)) {
864
- const addedRoot = nodes.find((node) => node.nodeIdentity === selectionRoot.nodeIdentity);
865
- if (addedRoot?.record === undefined) {
866
- throw new Error("加包预设节点没有持久实例:" + selectionRoot.nodeIdentity);
867
- }
868
- nodeInstanceIds[selectionRoot.nodeIdentity] =
869
- addedRoot.record.packageDefinitionId;
870
- }
871
- const nodeInstances = resolveNodeInstances(packages, nodeInstanceIds);
872
- preparedAddition = {
873
- nodes,
874
- records,
875
- packages,
876
- blueprint: afterBlueprint,
877
- nodeInstances,
878
- contributions: persistedContributions(nodes, context, packages, nodeInstances),
879
- };
880
- return preparedAddition;
881
- }
882
- catch (error) {
883
- throw new AdditionPlanningFailure(error);
884
- }
885
- };
886
- try {
887
- await validatePresetUpdate(repositoryRoot, context, existingContributions, currentNodeInstances, record.presetSelections);
888
- const currentPresetProjectContributions = computePresetProjectContributions(context, existingContributions, currentNodeInstances, record.presetSelections);
889
- const validation = await options.strategy.validateAddition?.({
890
- targetRoot: repositoryRoot,
891
- blueprint,
892
- content: selected,
893
- definition,
894
- ...(creationInput === undefined ? {} : { creationInput }),
895
- packages: packageStates,
896
- contributions: existingContributions,
897
- getAdditionContributions: () => prepareAdditionNodes().contributions,
898
- nodeInstances: currentNodeInstances,
899
- presetProjectContributions: currentPresetProjectContributions,
900
- });
901
- if (validation?.status === "input-invalid")
902
- return validation;
903
- if (validation?.status === "conflict") {
904
- return {
905
- status: "conflict",
906
- dryRun: addOptions.dryRun ?? false,
907
- reason: "工作区策略报告了包加法冲突。",
908
- conflicts: [],
909
- ownerConflict: validation.conflict,
910
- actions: [],
911
- };
1769
+ for (const item of before.blueprint.packages) {
1770
+ if (!isDeepStrictEqual(afterDefinitions.get(item.packageDefinitionId), item)) {
1771
+ throw new Error(`After 未保留既有包定义:${item.packageDefinitionId}`);
912
1772
  }
913
1773
  }
914
- catch (error) {
915
- if (error instanceof AdditionPlanningFailure) {
916
- return fail("planning", error);
1774
+ for (const selection of before.generationRecord.selections) {
1775
+ if (!isDeepStrictEqual(options.after.generationRecord.selections.find((item) => item.selectionId === selection.selectionId), selection)) {
1776
+ throw new Error(`After 未保留既有内容选择:${selection.selectionId}`);
917
1777
  }
918
- return fail("metadata", error, options.strategy.diagnoseFailure?.(error));
919
1778
  }
920
- const conflicting = blueprint.packages.find((candidate) => candidate.name === definition.name ||
921
- candidate.path === definition.path);
922
- if (conflicting !== undefined) {
923
- const prior = packageStates.find((item) => item.packageDefinitionId === conflicting.packageDefinitionId);
924
- if (prior !== undefined &&
925
- contentIdentityKey(prior.contentIdentity) ===
926
- contentIdentityKey(selected.identity) &&
927
- prior.definition.name === definition.name &&
928
- prior.definition.path === definition.path &&
929
- isDeepStrictEqual(prior.configuration, configuration) &&
930
- isDeepStrictEqual(prior.creationInput ?? undefined, selectionRoot.creationInput)) {
931
- return {
932
- status: "success",
933
- dryRun: addOptions.dryRun ?? false,
934
- blueprint,
935
- generationRecord: record,
936
- projection: null,
937
- actions: [],
938
- };
939
- }
940
- const samePackageIdentity = prior !== undefined &&
941
- contentIdentityKey(prior.contentIdentity) ===
942
- contentIdentityKey(selected.identity) &&
943
- prior.definition.name === definition.name &&
944
- prior.definition.path === definition.path;
945
- return {
946
- status: "conflict",
947
- dryRun: addOptions.dryRun ?? false,
948
- reason: samePackageIdentity
949
- ? "已存在的包实例不能接受不同的加包输入。"
950
- : "目标包名称或路径已被其他实例占用。",
951
- conflicts: [],
952
- identityConflict: {
953
- existing: packageIdentity(conflicting),
954
- requested: packageIdentity(definition),
955
- },
956
- actions: [],
957
- };
1779
+ if (!isDeepStrictEqual(options.after.generationRecord.composition, before.generationRecord.composition)) {
1780
+ throw new Error("After 未保留既有组合事实");
958
1781
  }
959
- const prepared = prepareAdditionNodes();
960
- const additions = prepared.nodes;
961
- const allRecords = prepared.packages;
962
- const afterBlueprint = assertProjectBlueprint(prepared.blueprint);
963
- const afterNodeInstanceIds = {
964
- ...record.nodeInstances,
1782
+ after = {
1783
+ ...options.after,
1784
+ projection: preserveProjectionPaths(before.projection, options.after.projection),
965
1785
  };
966
- if (addedProjectPreset !== undefined) {
967
- if (Object.hasOwn(record.nodeInstances, selectionRoot.nodeIdentity)) {
968
- throw new Error("加包预设节点身份已存在:" + selectionRoot.nodeIdentity);
969
- }
970
- const addedRoot = additions.find((node) => node.nodeIdentity === selectionRoot.nodeIdentity);
971
- if (addedRoot?.record === undefined) {
972
- throw new Error("加包预设节点没有持久实例:" + selectionRoot.nodeIdentity);
973
- }
974
- afterNodeInstanceIds[selectionRoot.nodeIdentity] =
975
- addedRoot.record.packageDefinitionId;
976
- }
977
- const afterPresetSelections = mergePresetSelections(record.presetSelections, addedPreset === undefined ? [] : [addedPreset]);
978
- const beforeContributions = persistedContributions(existingNodes, context, packageStates, currentNodeInstances);
979
- const afterNodes = [...existingNodes, ...additions];
980
- const afterContributions = persistedContributions(afterNodes, context, allRecords, resolveNodeInstances(allRecords, afterNodeInstanceIds));
981
- const before = project(context, state, blueprint, packageStates, beforeContributions, record.nodeInstances, record.presetSelections);
982
- const after = project(context, state, afterBlueprint, allRecords, afterContributions, afterNodeInstanceIds, afterPresetSelections);
983
- const projectedBlueprint = after.blueprint;
984
- const preconditions = additions.map((node) => ({
985
- path: node.definition.path,
1786
+ }
1787
+ catch (error) {
1788
+ return {
1789
+ status: "operation-failure",
1790
+ phase: "calculation",
1791
+ error: { message: errorMessage(error) },
1792
+ };
1793
+ }
1794
+ try {
1795
+ const existingIds = new Set(before.blueprint.packages.map((item) => item.packageDefinitionId));
1796
+ const newPackages = after.blueprint.packages.filter((item) => !existingIds.has(item.packageDefinitionId));
1797
+ const sourcesById = new Map(after.packages.map(({ package: item }) => [
1798
+ item.packageDefinitionId,
1799
+ {
1800
+ identity: `content:${contentIdentityKey(item.contentIdentity)}:${item.packageDefinitionId}`,
1801
+ label: `${contentIdentityLabel(item.contentIdentity)}(${item.definition.path})`,
1802
+ },
1803
+ ]));
1804
+ const preconditions = newPackages
1805
+ .filter((item) => item.path !== ".")
1806
+ .map((item) => ({
1807
+ path: item.path,
986
1808
  kind: "must-not-exist",
987
- reason: "新包路径已存在:" + node.definition.path,
1809
+ reason: `新包路径必须不存在:${item.path}`,
1810
+ ...(sourcesById.get(item.packageDefinitionId) === undefined
1811
+ ? {}
1812
+ : { sources: [sourcesById.get(item.packageDefinitionId)] }),
988
1813
  }));
989
- const reconciliation = await reconcileAndApplyProjectProjections({
990
- targetRoot: repositoryRoot,
991
- before: {
992
- operations: before.operations,
993
- reconciliation: before.reconciliation,
994
- },
995
- after: {
996
- operations: after.operations,
997
- reconciliation: after.reconciliation,
998
- },
1814
+ const current = await readProjectProjectionCurrent({
1815
+ targetRoot: preparation.restored.targetRoot,
1816
+ before: before.projection,
1817
+ after: after.projection,
999
1818
  preconditions,
1000
- ...(addOptions.dryRun === undefined
1001
- ? {}
1002
- : { dryRun: addOptions.dryRun }),
1003
1819
  });
1004
- if (!reconciliation.ok) {
1820
+ const planning = planProjectProjections({
1821
+ before: before.projection,
1822
+ current,
1823
+ after: after.projection,
1824
+ preconditions,
1825
+ readFacts: [...preparation.readFacts, ...(options.readFacts ?? [])],
1826
+ });
1827
+ if (!planning.ok) {
1005
1828
  return {
1006
1829
  status: "conflict",
1007
- dryRun: addOptions.dryRun ?? false,
1008
- reason: "目标工作区的现行内容与新增投影发生冲突。",
1009
- conflicts: reconciliation.conflicts,
1830
+ reason: conflictReason(planning.conflicts),
1831
+ conflicts: planning.conflicts,
1010
1832
  actions: [],
1011
1833
  };
1012
1834
  }
1835
+ pendingPlans.set(planning.plan, {
1836
+ targetRoot: current.targetRoot,
1837
+ computed: after,
1838
+ });
1013
1839
  return {
1014
- status: "success",
1015
- dryRun: addOptions.dryRun ?? false,
1016
- blueprint: projectedBlueprint,
1840
+ status: "planned",
1841
+ plan: planning.plan,
1842
+ blueprint: after.blueprint,
1017
1843
  generationRecord: after.generationRecord,
1018
- projection: after,
1019
- actions: reconciliation.actions,
1844
+ projection: after.projection,
1845
+ ownerFacts: after.ownerFacts,
1846
+ actions: planning.plan.actions,
1020
1847
  };
1021
1848
  }
1022
1849
  catch (error) {
1023
- return fail(error instanceof AdditionPlanningFailure
1024
- ? "planning"
1025
- : "reconciliation", error);
1850
+ return {
1851
+ status: "operation-failure",
1852
+ phase: "planning",
1853
+ error: { message: errorMessage(error) },
1854
+ };
1026
1855
  }
1027
1856
  }
1028
- async function configure(configureOptions) {
1029
- const repositoryRoot = path.resolve(configureOptions.repositoryRoot);
1857
+ async function planAdd(addOptions) {
1858
+ const targetRoot = path.resolve(addOptions.repositoryRoot);
1030
1859
  let restored;
1031
1860
  try {
1032
- restored = await restoreRepository(repositoryRoot);
1861
+ restored = await restoreProject({ repositoryRoot: targetRoot });
1033
1862
  }
1034
1863
  catch (error) {
1035
- return fail("metadata", error, options.strategy.diagnoseFailure?.(error));
1036
- }
1037
- const { blueprint, record, state, packageStates } = restored;
1038
- const target = packageStates.find((item) => item.packageDefinitionId === configureOptions.packageDefinitionId);
1039
- if (target === undefined)
1040
1864
  return {
1041
- status: "input-invalid",
1042
- issues: [{ code: "UNKNOWN_GENERATED_INSTANCE" }],
1865
+ status: "operation-failure",
1866
+ phase: "metadata",
1867
+ error: { message: errorMessage(error) },
1043
1868
  };
1869
+ }
1870
+ let preparation;
1044
1871
  try {
1045
- for (const item of packageStates)
1046
- prepareContent(requireContent(item.contentIdentity));
1047
- validateRequiredBindings(packageStates);
1872
+ preparation = await prepareAddProject({
1873
+ restored,
1874
+ selection: addOptions,
1875
+ operationFacts: addOptions.operationFacts,
1876
+ });
1048
1877
  }
1049
1878
  catch (error) {
1050
- return fail("metadata", error, options.strategy.diagnoseFailure?.(error));
1879
+ return {
1880
+ status: "operation-failure",
1881
+ phase: "preparation",
1882
+ error: { message: errorMessage(error) },
1883
+ };
1051
1884
  }
1052
- let phase = "planning";
1885
+ let before;
1886
+ let after;
1053
1887
  try {
1054
- const selected = requireContent(target.contentIdentity);
1055
- const configuration = normalizeConfiguration(selected, configureOptions.configuration);
1056
- if (isDeepStrictEqual(target.configuration, configuration)) {
1057
- return {
1058
- status: "success",
1059
- dryRun: configureOptions.dryRun ?? false,
1060
- blueprint,
1061
- generationRecord: record,
1062
- projection: null,
1063
- actions: [],
1064
- };
1065
- }
1066
- const currentNodeInstances = resolveNodeInstances(packageStates, record.nodeInstances);
1067
- const context = await options.strategy.prepareUpdate({
1068
- targetRoot: repositoryRoot,
1069
- state,
1070
- content: selected,
1071
- contentByIdentity,
1072
- configuration,
1073
- packages: packageStates,
1074
- nodeInstances: currentNodeInstances,
1075
- ...(target.creationInput === null
1076
- ? {}
1077
- : { creationInput: target.creationInput }),
1078
- });
1079
- const beforeNodes = nodesFromRecords(packageStates);
1080
- const beforeContributions = persistedContributions(beforeNodes, context, packageStates, currentNodeInstances);
1081
- await validatePresetUpdate(repositoryRoot, context, beforeContributions, currentNodeInstances, record.presetSelections);
1082
- const before = project(context, state, blueprint, packageStates, beforeContributions, record.nodeInstances, record.presetSelections);
1083
- const afterNodes = nodesFromRecords(packageStates.map((item) => item.packageDefinitionId === target.packageDefinitionId
1084
- ? { ...item, configuration }
1085
- : item));
1086
- const changed = afterNodes.find((node) => node.record?.packageDefinitionId === target.packageDefinitionId);
1087
- const additions = expandDependencies({
1088
- roots: [changed],
1089
- existing: afterNodes,
1090
- context,
1091
- occupiedIds: new Set(record.packages.map((item) => item.packageDefinitionId)),
1092
- });
1093
- const allNodes = [...afterNodes, ...additions];
1094
- const afterBlueprint = assertProjectBlueprint({
1095
- ...blueprint,
1096
- packages: [
1097
- ...blueprint.packages,
1098
- ...additions.map((node) => node.definition),
1099
- ],
1100
- });
1101
- const afterPackages = resolvePackageStates(allNodes.map((node) => node.record), afterBlueprint);
1102
- validateRequiredBindings(afterPackages);
1103
- const afterNodeInstances = resolveNodeInstances(afterPackages, record.nodeInstances);
1104
- const after = project(context, state, afterBlueprint, afterPackages, persistedContributions(allNodes, context, afterPackages, afterNodeInstances), record.nodeInstances, record.presetSelections);
1105
- phase = "reconciliation";
1106
- const reconciliation = await reconcileAndApplyProjectProjections({
1107
- targetRoot: repositoryRoot,
1108
- before: {
1109
- operations: before.operations,
1110
- reconciliation: before.reconciliation,
1888
+ before = computeProject(preparation.before);
1889
+ after = computeProject(preparation.after);
1890
+ }
1891
+ catch (error) {
1892
+ const packageIdentityIssues = error instanceof ProjectBlueprintValidationError
1893
+ ? error.packageIdentityIssues
1894
+ : [];
1895
+ return {
1896
+ status: "operation-failure",
1897
+ phase: "calculation",
1898
+ error: {
1899
+ message: errorMessage(error),
1900
+ ...(packageIdentityIssues.length === 0
1901
+ ? {}
1902
+ : { packageIdentityIssues }),
1111
1903
  },
1112
- after: {
1113
- operations: after.operations,
1114
- reconciliation: after.reconciliation,
1904
+ };
1905
+ }
1906
+ return planComputedAdd({
1907
+ preparation,
1908
+ before,
1909
+ after,
1910
+ ...(addOptions.readFacts === undefined
1911
+ ? {}
1912
+ : { readFacts: addOptions.readFacts }),
1913
+ });
1914
+ }
1915
+ async function commitPlan(plan) {
1916
+ const pending = pendingPlans.get(plan);
1917
+ if (pending === undefined) {
1918
+ return {
1919
+ status: "operation-failure",
1920
+ phase: "commit",
1921
+ error: {
1922
+ message: "提交计划必须由当前生成器的 planInit、planAdd 或 planComputedAdd 创建",
1115
1923
  },
1116
- preconditions: additions.map((node) => ({
1117
- path: node.definition.path,
1118
- kind: "must-not-exist",
1119
- reason: "新共享依赖路径已存在:" + node.definition.path,
1120
- })),
1121
- ...(configureOptions.dryRun === undefined
1122
- ? {}
1123
- : { dryRun: configureOptions.dryRun }),
1924
+ };
1925
+ }
1926
+ try {
1927
+ const committed = await commitProjectProjectionPlan({
1928
+ targetRoot: pending.targetRoot,
1929
+ plan,
1124
1930
  });
1125
- if (!reconciliation.ok)
1931
+ if (!committed.ok) {
1126
1932
  return {
1127
1933
  status: "conflict",
1128
- dryRun: configureOptions.dryRun ?? false,
1129
- reason: "目标工作区的现行内容与配置投影发生冲突。",
1130
- conflicts: reconciliation.conflicts,
1934
+ dryRun: false,
1935
+ reason: conflictReason(committed.conflicts),
1936
+ conflicts: committed.conflicts,
1131
1937
  actions: [],
1132
1938
  };
1939
+ }
1133
1940
  return {
1134
1941
  status: "success",
1135
- dryRun: configureOptions.dryRun ?? false,
1136
- blueprint: after.blueprint,
1137
- generationRecord: after.generationRecord,
1138
- projection: after,
1139
- actions: reconciliation.actions,
1942
+ dryRun: false,
1943
+ blueprint: pending.computed.blueprint,
1944
+ generationRecord: pending.computed.generationRecord,
1945
+ projection: pending.computed.projection,
1946
+ ownerFacts: pending.computed.ownerFacts,
1947
+ actions: committed.actions,
1140
1948
  };
1141
1949
  }
1142
1950
  catch (error) {
1143
- return fail(phase, error, options.strategy.diagnoseFailure?.(error));
1951
+ return {
1952
+ status: "operation-failure",
1953
+ phase: "commit",
1954
+ error: { message: errorMessage(error) },
1955
+ };
1956
+ }
1957
+ }
1958
+ async function init(initOptions) {
1959
+ const dryRun = initOptions.dryRun ?? false;
1960
+ const planned = await planInit({
1961
+ targetRoot: initOptions.targetRoot,
1962
+ selection: initOptions.selection,
1963
+ conventions: initOptions.conventions,
1964
+ operationFacts: initOptions.operationFacts,
1965
+ });
1966
+ if (planned.status === "operation-failure")
1967
+ return planned;
1968
+ if (planned.status === "conflict") {
1969
+ return { ...planned, dryRun, actions: [] };
1970
+ }
1971
+ if (!dryRun)
1972
+ return commitPlan(planned.plan);
1973
+ return {
1974
+ status: "success",
1975
+ dryRun: true,
1976
+ blueprint: planned.blueprint,
1977
+ generationRecord: planned.generationRecord,
1978
+ projection: planned.projection,
1979
+ ownerFacts: planned.ownerFacts,
1980
+ actions: planned.actions,
1981
+ };
1982
+ }
1983
+ async function add(addOptions) {
1984
+ const { dryRun = false, ...planningOptions } = addOptions;
1985
+ const planned = await planAdd(planningOptions);
1986
+ if (planned.status === "operation-failure")
1987
+ return planned;
1988
+ if (planned.status === "conflict") {
1989
+ return { ...planned, dryRun, actions: [] };
1144
1990
  }
1991
+ if (!dryRun)
1992
+ return commitPlan(planned.plan);
1993
+ return {
1994
+ status: "success",
1995
+ dryRun: true,
1996
+ blueprint: planned.blueprint,
1997
+ generationRecord: planned.generationRecord,
1998
+ projection: planned.projection,
1999
+ ownerFacts: planned.ownerFacts,
2000
+ actions: planned.actions,
2001
+ };
1145
2002
  }
1146
- return { init, add, configure };
2003
+ return {
2004
+ init,
2005
+ add,
2006
+ planInit,
2007
+ planAdd,
2008
+ planComputedAdd,
2009
+ commitPlan,
2010
+ restoreProject,
2011
+ prepareAddProject,
2012
+ prepareProject,
2013
+ computeProject,
2014
+ };
1147
2015
  }