@bleedingdev/modern-js-app-tools 3.5.0-ultramodern.9 → 3.5.0-ultramodern.91

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 (258) hide show
  1. package/bin/modern.js +0 -0
  2. package/dist/cjs/builder/generator/getBuilderEnvironments.js +13 -16
  3. package/dist/cjs/builder/shared/builderPlugins/adapterPrecompress.js +13 -4
  4. package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +14 -11
  5. package/dist/cjs/builder/shared/bundlerPlugins/CssExtractRuntimePlugin.js +72 -0
  6. package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +28 -11
  7. package/dist/cjs/builder/shared/bundlerPlugins/index.js +13 -6
  8. package/dist/cjs/builder/shared/lazyCompilation.js +2 -10
  9. package/dist/cjs/commands/index.js +0 -4
  10. package/dist/cjs/config/build-environment.js +268 -0
  11. package/dist/cjs/config/index.js +11 -4
  12. package/dist/cjs/config/public.js +46 -0
  13. package/dist/cjs/index.js +39 -62
  14. package/dist/cjs/plugins/analyze/getServerRoutes.js +19 -0
  15. package/dist/cjs/plugins/analyze/index.js +20 -12
  16. package/dist/cjs/plugins/backend-federation/codegen.js +255 -0
  17. package/dist/cjs/plugins/backend-federation/config.js +204 -0
  18. package/dist/cjs/plugins/backend-federation/emit.js +148 -0
  19. package/dist/cjs/plugins/backendFederationBuild.js +53 -0
  20. package/dist/cjs/plugins/deploy/index.js +4 -4
  21. package/dist/cjs/plugins/deploy/platforms/cloudflare/artifacts.js +127 -0
  22. package/dist/cjs/plugins/deploy/platforms/cloudflare/constants.js +141 -0
  23. package/dist/cjs/plugins/deploy/platforms/cloudflare/delivery-unit.js +139 -0
  24. package/dist/cjs/plugins/deploy/platforms/cloudflare/i18n-worker.js +135 -0
  25. package/dist/cjs/plugins/deploy/platforms/cloudflare/index.js +150 -0
  26. package/dist/cjs/plugins/deploy/platforms/cloudflare/security-policies.js +205 -0
  27. package/dist/cjs/plugins/deploy/platforms/cloudflare/types.js +18 -0
  28. package/dist/cjs/plugins/deploy/platforms/cloudflare/utils.js +66 -0
  29. package/dist/cjs/plugins/deploy/platforms/cloudflare/worker-manifest.js +208 -0
  30. package/dist/cjs/plugins/deploy/platforms/cloudflare/wrangler-config.js +204 -0
  31. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-contract.js +108 -0
  32. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-plan.js +93 -0
  33. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/identity.js +83 -0
  34. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/index.js +188 -0
  35. package/dist/cjs/{baseline.js → plugins/deploy/platforms/cloudflare-output-verifier/issues.js} +19 -10
  36. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/manifest.js +89 -0
  37. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.js +151 -0
  38. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.js +302 -0
  39. package/dist/cjs/plugins/deploy/platforms/node.js +20 -2
  40. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.mjs +250 -0
  41. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.mjs +191 -0
  42. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.mjs +514 -0
  43. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.mjs +1012 -0
  44. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.mjs +363 -0
  45. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.006-fetch-handler.mjs +93 -0
  46. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-worker-fs-promises.mjs +8 -4
  47. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-worker-loadable-server.mjs +251 -155
  48. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-worker-path.mjs +78 -39
  49. package/dist/cjs/plugins/deploy/platforms/templates/netlify-entry.cjs +62 -41
  50. package/dist/cjs/plugins/deploy/platforms/templates/netlify-entry.mjs +63 -41
  51. package/dist/cjs/plugins/deploy/platforms/templates/node-entry.cjs +52 -35
  52. package/dist/cjs/plugins/deploy/platforms/templates/node-entry.mjs +53 -35
  53. package/dist/cjs/plugins/deploy/platforms/templates/vercel-entry.cjs +61 -41
  54. package/dist/cjs/plugins/deploy/platforms/templates/vercel-entry.mjs +61 -40
  55. package/dist/cjs/plugins/deploy/utils/npmAliases.js +226 -0
  56. package/dist/cjs/plugins/ultramodernReleaseEnvelope.js +100 -0
  57. package/dist/cjs/presetUltramodern.js +33 -2
  58. package/dist/cjs/ultramodern-release-envelope/canonical.js +68 -0
  59. package/dist/cjs/ultramodern-release-envelope/framework-output.js +597 -0
  60. package/dist/cjs/ultramodern-release-envelope/index.js +399 -0
  61. package/dist/cjs/ultramodern-release-envelope/types.js +51 -0
  62. package/dist/cjs/ultramodern-release-identity.js +110 -0
  63. package/dist/esm/builder/generator/getBuilderEnvironments.mjs +12 -15
  64. package/dist/esm/builder/shared/builderPlugins/adapterPrecompress.mjs +13 -4
  65. package/dist/esm/builder/shared/builderPlugins/adapterSSR.mjs +15 -12
  66. package/dist/esm/builder/shared/bundlerPlugins/CssExtractRuntimePlugin.mjs +30 -0
  67. package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.mjs +24 -10
  68. package/dist/esm/builder/shared/bundlerPlugins/index.mjs +1 -0
  69. package/dist/esm/builder/shared/lazyCompilation.mjs +1 -3
  70. package/dist/esm/commands/index.mjs +0 -1
  71. package/dist/esm/config/build-environment.mjs +224 -0
  72. package/dist/esm/config/index.mjs +1 -0
  73. package/dist/esm/config/public.mjs +1 -0
  74. package/dist/esm/index.mjs +5 -4
  75. package/dist/esm/plugins/analyze/getHtmlTemplate.mjs +2 -2
  76. package/dist/esm/plugins/analyze/getServerRoutes.mjs +17 -1
  77. package/dist/esm/plugins/analyze/index.mjs +20 -12
  78. package/dist/esm/plugins/analyze/isDefaultExportFunction.mjs +2 -2
  79. package/dist/esm/plugins/backend-federation/codegen.mjs +204 -0
  80. package/dist/esm/plugins/backend-federation/config.mjs +128 -0
  81. package/dist/esm/plugins/backend-federation/emit.mjs +97 -0
  82. package/dist/esm/plugins/backendFederationBuild.mjs +1 -0
  83. package/dist/esm/plugins/deploy/index.mjs +1 -1
  84. package/dist/esm/plugins/deploy/platforms/cloudflare/artifacts.mjs +64 -0
  85. package/dist/esm/plugins/deploy/platforms/cloudflare/constants.mjs +34 -0
  86. package/dist/esm/plugins/deploy/platforms/cloudflare/delivery-unit.mjs +88 -0
  87. package/dist/esm/plugins/deploy/platforms/cloudflare/i18n-worker.mjs +97 -0
  88. package/dist/esm/plugins/deploy/platforms/cloudflare/index.mjs +102 -0
  89. package/dist/esm/plugins/deploy/platforms/cloudflare/security-policies.mjs +167 -0
  90. package/dist/esm/plugins/deploy/platforms/cloudflare/types.mjs +0 -0
  91. package/dist/esm/plugins/deploy/platforms/cloudflare/utils.mjs +12 -0
  92. package/dist/esm/plugins/deploy/platforms/cloudflare/worker-manifest.mjs +148 -0
  93. package/dist/esm/plugins/deploy/platforms/cloudflare/wrangler-config.mjs +150 -0
  94. package/dist/esm/plugins/deploy/platforms/cloudflare-output-contract.mjs +31 -0
  95. package/dist/esm/plugins/deploy/platforms/cloudflare-output-plan.mjs +45 -0
  96. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/identity.mjs +45 -0
  97. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/index.mjs +133 -0
  98. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/issues.mjs +10 -0
  99. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/manifest.mjs +51 -0
  100. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.mjs +99 -0
  101. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.mjs +238 -0
  102. package/dist/esm/plugins/deploy/platforms/node.mjs +20 -2
  103. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.mjs +250 -0
  104. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.mjs +191 -0
  105. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.mjs +514 -0
  106. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.mjs +1012 -0
  107. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.mjs +363 -0
  108. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.006-fetch-handler.mjs +93 -0
  109. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-worker-fs-promises.mjs +8 -4
  110. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-worker-loadable-server.mjs +251 -155
  111. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-worker-path.mjs +78 -39
  112. package/dist/esm/plugins/deploy/platforms/templates/netlify-entry.cjs +62 -41
  113. package/dist/esm/plugins/deploy/platforms/templates/netlify-entry.mjs +63 -41
  114. package/dist/esm/plugins/deploy/platforms/templates/node-entry.cjs +52 -35
  115. package/dist/esm/plugins/deploy/platforms/templates/node-entry.mjs +53 -35
  116. package/dist/esm/plugins/deploy/platforms/templates/vercel-entry.cjs +61 -41
  117. package/dist/esm/plugins/deploy/platforms/templates/vercel-entry.mjs +61 -40
  118. package/dist/esm/plugins/deploy/utils/npmAliases.mjs +174 -0
  119. package/dist/esm/plugins/ultramodernReleaseEnvelope.mjs +52 -0
  120. package/dist/esm/presetUltramodern.mjs +33 -2
  121. package/dist/esm/ultramodern-release-envelope/canonical.mjs +21 -0
  122. package/dist/esm/ultramodern-release-envelope/framework-output.mjs +524 -0
  123. package/dist/esm/ultramodern-release-envelope/index.mjs +335 -0
  124. package/dist/esm/ultramodern-release-envelope/types.mjs +7 -0
  125. package/dist/esm/ultramodern-release-identity.mjs +66 -0
  126. package/dist/esm-node/builder/generator/getBuilderEnvironments.mjs +12 -15
  127. package/dist/esm-node/builder/shared/builderPlugins/adapterPrecompress.mjs +13 -4
  128. package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.mjs +15 -12
  129. package/dist/esm-node/builder/shared/bundlerPlugins/CssExtractRuntimePlugin.mjs +31 -0
  130. package/dist/esm-node/builder/shared/bundlerPlugins/RouterPlugin.mjs +24 -10
  131. package/dist/esm-node/builder/shared/bundlerPlugins/index.mjs +1 -0
  132. package/dist/esm-node/builder/shared/lazyCompilation.mjs +1 -3
  133. package/dist/esm-node/commands/index.mjs +0 -1
  134. package/dist/esm-node/config/build-environment.mjs +225 -0
  135. package/dist/esm-node/config/index.mjs +1 -0
  136. package/dist/esm-node/config/public.mjs +2 -0
  137. package/dist/esm-node/index.mjs +5 -4
  138. package/dist/esm-node/plugins/analyze/getHtmlTemplate.mjs +2 -2
  139. package/dist/esm-node/plugins/analyze/getServerRoutes.mjs +17 -1
  140. package/dist/esm-node/plugins/analyze/index.mjs +20 -12
  141. package/dist/esm-node/plugins/analyze/isDefaultExportFunction.mjs +2 -2
  142. package/dist/esm-node/plugins/backend-federation/codegen.mjs +205 -0
  143. package/dist/esm-node/plugins/backend-federation/config.mjs +129 -0
  144. package/dist/esm-node/plugins/backend-federation/emit.mjs +98 -0
  145. package/dist/esm-node/plugins/backendFederationBuild.mjs +2 -0
  146. package/dist/esm-node/plugins/deploy/index.mjs +1 -1
  147. package/dist/esm-node/plugins/deploy/platforms/cloudflare/artifacts.mjs +65 -0
  148. package/dist/esm-node/plugins/deploy/platforms/cloudflare/constants.mjs +35 -0
  149. package/dist/esm-node/plugins/deploy/platforms/cloudflare/delivery-unit.mjs +89 -0
  150. package/dist/esm-node/plugins/deploy/platforms/cloudflare/i18n-worker.mjs +98 -0
  151. package/dist/esm-node/plugins/deploy/platforms/cloudflare/index.mjs +103 -0
  152. package/dist/esm-node/plugins/deploy/platforms/cloudflare/security-policies.mjs +168 -0
  153. package/dist/esm-node/plugins/deploy/platforms/cloudflare/types.mjs +1 -0
  154. package/dist/esm-node/plugins/deploy/platforms/cloudflare/utils.mjs +13 -0
  155. package/dist/esm-node/plugins/deploy/platforms/cloudflare/worker-manifest.mjs +149 -0
  156. package/dist/esm-node/plugins/deploy/platforms/cloudflare/wrangler-config.mjs +151 -0
  157. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-contract.mjs +32 -0
  158. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-plan.mjs +46 -0
  159. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/identity.mjs +46 -0
  160. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/index.mjs +134 -0
  161. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/issues.mjs +11 -0
  162. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/manifest.mjs +52 -0
  163. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.mjs +100 -0
  164. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.mjs +239 -0
  165. package/dist/esm-node/plugins/deploy/platforms/node.mjs +20 -2
  166. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.mjs +250 -0
  167. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.mjs +191 -0
  168. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.mjs +514 -0
  169. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.mjs +1012 -0
  170. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.mjs +363 -0
  171. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.006-fetch-handler.mjs +93 -0
  172. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-worker-fs-promises.mjs +8 -4
  173. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-worker-loadable-server.mjs +251 -155
  174. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-worker-path.mjs +78 -39
  175. package/dist/esm-node/plugins/deploy/platforms/templates/netlify-entry.cjs +62 -41
  176. package/dist/esm-node/plugins/deploy/platforms/templates/netlify-entry.mjs +63 -41
  177. package/dist/esm-node/plugins/deploy/platforms/templates/node-entry.cjs +52 -35
  178. package/dist/esm-node/plugins/deploy/platforms/templates/node-entry.mjs +53 -35
  179. package/dist/esm-node/plugins/deploy/platforms/templates/vercel-entry.cjs +61 -41
  180. package/dist/esm-node/plugins/deploy/platforms/templates/vercel-entry.mjs +61 -40
  181. package/dist/esm-node/plugins/deploy/utils/npmAliases.mjs +175 -0
  182. package/dist/esm-node/plugins/ultramodernReleaseEnvelope.mjs +53 -0
  183. package/dist/esm-node/presetUltramodern.mjs +33 -2
  184. package/dist/esm-node/ultramodern-release-envelope/canonical.mjs +22 -0
  185. package/dist/esm-node/ultramodern-release-envelope/framework-output.mjs +525 -0
  186. package/dist/esm-node/ultramodern-release-envelope/index.mjs +336 -0
  187. package/dist/esm-node/ultramodern-release-envelope/types.mjs +8 -0
  188. package/dist/esm-node/ultramodern-release-identity.mjs +67 -0
  189. package/dist/types/builder/generator/createCopyPattern.d.ts +7 -5
  190. package/dist/types/builder/shared/bundlerPlugins/CssExtractRuntimePlugin.d.ts +6 -0
  191. package/dist/types/builder/shared/bundlerPlugins/RouterPlugin.d.ts +1 -0
  192. package/dist/types/builder/shared/bundlerPlugins/index.d.ts +1 -0
  193. package/dist/types/builder/shared/lazyCompilation.d.ts +2 -4
  194. package/dist/types/commands/index.d.ts +0 -1
  195. package/dist/types/config/build-environment.d.ts +22 -0
  196. package/dist/types/config/index.d.ts +1 -0
  197. package/dist/types/config/public.d.ts +2 -0
  198. package/dist/types/index.d.ts +0 -2
  199. package/dist/types/plugins/analyze/getServerRoutes.d.ts +1 -0
  200. package/dist/types/plugins/backend-federation/codegen.d.ts +83 -0
  201. package/dist/types/plugins/backend-federation/config.d.ts +103 -0
  202. package/dist/types/plugins/backend-federation/emit.d.ts +13 -0
  203. package/dist/types/plugins/backendFederationBuild.d.ts +2 -0
  204. package/dist/types/plugins/deploy/platforms/cloudflare/artifacts.d.ts +15 -0
  205. package/dist/types/plugins/deploy/platforms/cloudflare/constants.d.ts +24 -0
  206. package/dist/types/plugins/deploy/platforms/cloudflare/delivery-unit.d.ts +23 -0
  207. package/dist/types/plugins/deploy/platforms/cloudflare/i18n-worker.d.ts +22 -0
  208. package/dist/types/plugins/deploy/platforms/{cloudflare.d.ts → cloudflare/index.d.ts} +1 -1
  209. package/dist/types/plugins/deploy/platforms/cloudflare/security-policies.d.ts +51 -0
  210. package/dist/types/plugins/deploy/platforms/cloudflare/types.d.ts +5 -0
  211. package/dist/types/plugins/deploy/platforms/cloudflare/utils.d.ts +6 -0
  212. package/dist/types/plugins/deploy/platforms/cloudflare/worker-manifest.d.ts +122 -0
  213. package/dist/types/plugins/deploy/platforms/cloudflare/wrangler-config.d.ts +46 -0
  214. package/dist/types/plugins/deploy/platforms/cloudflare-output-contract.d.ts +14 -0
  215. package/dist/types/plugins/deploy/platforms/cloudflare-output-plan.d.ts +34 -0
  216. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/identity.d.ts +4 -0
  217. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/index.d.ts +18 -0
  218. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/issues.d.ts +14 -0
  219. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/manifest.d.ts +2 -0
  220. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.d.ts +14 -0
  221. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.d.ts +20 -0
  222. package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.d.mts +1 -0
  223. package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.d.mts +1 -0
  224. package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.d.mts +1 -0
  225. package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.d.mts +1 -0
  226. package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.d.mts +1 -0
  227. package/dist/types/plugins/deploy/utils/npmAliases.d.ts +14 -0
  228. package/dist/types/plugins/ultramodernReleaseEnvelope.d.ts +3 -0
  229. package/dist/types/presetUltramodern.d.ts +10 -0
  230. package/dist/types/run/index.d.ts +1 -1
  231. package/dist/types/types/config/cloudflareDeploy.d.ts +41 -0
  232. package/dist/types/types/config/deploy.d.ts +15 -2
  233. package/dist/types/ultramodern-release-envelope/canonical.d.ts +5 -0
  234. package/dist/types/ultramodern-release-envelope/framework-output.d.ts +31 -0
  235. package/dist/types/ultramodern-release-envelope/index.d.ts +6 -0
  236. package/dist/types/ultramodern-release-envelope/types.d.ts +62 -0
  237. package/dist/types/ultramodern-release-identity.d.ts +16 -0
  238. package/lib/types.d.ts +2 -3
  239. package/package.json +38 -23
  240. package/rslib.config.mts +11 -12
  241. package/dist/cjs/commands/runtime.js +0 -196
  242. package/dist/cjs/plugins/deploy/platforms/cloudflare.js +0 -540
  243. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.mjs +0 -576
  244. package/dist/cjs/ultramodern/designSystem.js +0 -123
  245. package/dist/esm/baseline.mjs +0 -4
  246. package/dist/esm/commands/runtime.mjs +0 -146
  247. package/dist/esm/plugins/deploy/platforms/cloudflare.mjs +0 -492
  248. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.mjs +0 -576
  249. package/dist/esm/ultramodern/designSystem.mjs +0 -73
  250. package/dist/esm-node/baseline.mjs +0 -5
  251. package/dist/esm-node/commands/runtime.mjs +0 -147
  252. package/dist/esm-node/plugins/deploy/platforms/cloudflare.mjs +0 -493
  253. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.mjs +0 -576
  254. package/dist/esm-node/ultramodern/designSystem.mjs +0 -74
  255. package/dist/types/baseline.d.ts +0 -16
  256. package/dist/types/commands/runtime.d.ts +0 -12
  257. package/dist/types/ultramodern/designSystem.d.ts +0 -54
  258. /package/dist/types/plugins/deploy/platforms/templates/{cloudflare-entry.d.mts → cloudflare-entry.006-fetch-handler.d.mts} +0 -0
@@ -0,0 +1,524 @@
1
+ import promises from "node:fs/promises";
2
+ import node_path from "node:path";
3
+ import { parse } from "@babel/parser";
4
+ import { BACKEND_FEDERATION_MANIFEST_FILE, BACKEND_FEDERATION_REMOTE_ENTRY_FILE, ULTRAMODERN_BUILD_ARTIFACT_FILE, isUltramodernBuildArtifact } from "@modern-js/utils/universal";
5
+ import { canonicalSerializeMicroVerticalReleaseEnvelope, createMicroVerticalReleaseEnvelope, verifyMicroVerticalReleaseEnvelope } from "./index.mjs";
6
+ const MICROVERTICAL_RELEASE_ENVELOPE_PATH = 'release/microvertical-release-envelope.json';
7
+ const COMPILED_MODULE_PATTERN = /\.(?:c|m)?js$/u;
8
+ const EFFECT_BFF_WORKER_PATTERN = /^worker\/__modern_bff_effect\.(?:c|m)?js$/u;
9
+ const isRecord = (value)=>'object' == typeof value && null !== value && !Array.isArray(value);
10
+ const isAstNode = (value)=>isRecord(value) && 'string' == typeof value.type;
11
+ const visitAst = (node, visitor)=>{
12
+ visitor(node);
13
+ for (const value of Object.values(node))if (isAstNode(value)) visitAst(value, visitor);
14
+ else if (Array.isArray(value)) {
15
+ for (const item of value)if (isAstNode(item)) visitAst(item, visitor);
16
+ }
17
+ };
18
+ const compiledModuleIdentityValues = (source)=>{
19
+ const values = new Set();
20
+ const ast = parse(source, {
21
+ sourceType: 'unambiguous'
22
+ });
23
+ visitAst(ast.program, (node)=>{
24
+ if ('StringLiteral' === node.type && 'string' == typeof node.value) values.add(node.value);
25
+ else if ('TemplateElement' === node.type && isRecord(node.value) && 'string' == typeof node.value.cooked) values.add(node.value.cooked);
26
+ });
27
+ return values;
28
+ };
29
+ const assertEveryCompiledIdentityCarrier = async (distDirectory, logicalPaths, identity, surface)=>{
30
+ const compiledLogicalPaths = logicalPaths.filter((pathname)=>COMPILED_MODULE_PATTERN.test(pathname));
31
+ if (0 === compiledLogicalPaths.length) throw new Error(`[ultramodern-release-envelope] ${surface} has no compiled execution module carrying release identity.`);
32
+ for (const logicalPath of compiledLogicalPaths){
33
+ const source = await promises.readFile(node_path.join(distDirectory, logicalPath), {
34
+ encoding: 'utf8'
35
+ });
36
+ const values = compiledModuleIdentityValues(source);
37
+ if (!values.has(identity.buildMarker) || !values.has(identity.sourceRevision) || !values.has(identity.releaseVersion)) throw new Error(`[ultramodern-release-envelope] ${surface} execution module ${logicalPath} does not carry exact buildMarker ${identity.buildMarker}, sourceRevision ${identity.sourceRevision}, and releaseVersion ${identity.releaseVersion}.`);
38
+ }
39
+ };
40
+ const flattenStrings = (value)=>'string' == typeof value ? [
41
+ value
42
+ ] : Array.isArray(value) ? value.flatMap(flattenStrings) : [];
43
+ const collectNestedStrings = (value, key)=>{
44
+ if (Array.isArray(value)) return value.flatMap((item)=>collectNestedStrings(item, key));
45
+ if (!isRecord(value)) return [];
46
+ return Object.entries(value).flatMap(([entryKey, entryValue])=>[
47
+ ...entryKey === key ? flattenStrings(entryValue) : [],
48
+ ...collectNestedStrings(entryValue, key)
49
+ ]);
50
+ };
51
+ const manifestReferencedClientModules = async (distDirectory, files, manifestLogicalPath = 'mf-manifest.json')=>{
52
+ const manifest = await readJson(node_path.join(distDirectory, manifestLogicalPath));
53
+ const references = [
54
+ ...collectNestedStrings(manifest, 'path'),
55
+ ...collectNestedStrings(manifest, 'name'),
56
+ ...collectNestedStrings(manifest, 'sync'),
57
+ ...collectNestedStrings(manifest, 'async')
58
+ ];
59
+ const normalizedReferences = new Set(references.filter((value)=>'string' == typeof value).map((value)=>value.replace(/^https?:\/\/[^/]+/u, '')).map((value)=>value.replace(/^\/+/u, '')));
60
+ return files.filter((logicalPath)=>COMPILED_MODULE_PATTERN.test(logicalPath) && [
61
+ ...normalizedReferences
62
+ ].some((reference)=>reference === logicalPath || reference.endsWith(`/${logicalPath}`) || logicalPath.endsWith(`/${reference}`)));
63
+ };
64
+ const routeReferencedSsrModules = async (distDirectory, files, target, routeSpecLogicalPath = 'route.json')=>{
65
+ const routeSpec = await readJson(node_path.join(distDirectory, routeSpecLogicalPath));
66
+ const field = 'node' === target ? 'bundle' : 'worker';
67
+ const references = collectNestedStrings(routeSpec, field).map((value)=>value.replace(/^\/+/u, ''));
68
+ return files.filter((logicalPath)=>COMPILED_MODULE_PATTERN.test(logicalPath) && references.includes(logicalPath));
69
+ };
70
+ const readJson = async (filePath)=>JSON.parse(await promises.readFile(filePath, 'utf8'));
71
+ const isFilesystemPathInside = (root, candidate)=>{
72
+ const relative = node_path.relative(root, candidate);
73
+ return '' === relative || !relative.startsWith(`..${node_path.sep}`) && '..' !== relative && !node_path.isAbsolute(relative);
74
+ };
75
+ const isMissingPathError = (error)=>isRecord(error) && 'ENOENT' === error.code;
76
+ const resolveSafeReleaseEnvelopePath = async ({ artifactRoot, createDirectory })=>{
77
+ const resolvedRoot = node_path.resolve(artifactRoot);
78
+ const realRoot = await promises.realpath(resolvedRoot);
79
+ const releaseDirectory = node_path.join(resolvedRoot, 'release');
80
+ let releaseStat;
81
+ try {
82
+ releaseStat = await promises.lstat(releaseDirectory);
83
+ } catch (error) {
84
+ if (!isMissingPathError(error)) throw error;
85
+ if (!createDirectory) return;
86
+ await promises.mkdir(releaseDirectory);
87
+ releaseStat = await promises.lstat(releaseDirectory);
88
+ }
89
+ if (releaseStat.isSymbolicLink() || !releaseStat.isDirectory()) throw new Error('[ultramodern-release-envelope] release must be a real directory inside artifactRoot, not a symlink or file.');
90
+ const realReleaseDirectory = await promises.realpath(releaseDirectory);
91
+ if (!isFilesystemPathInside(realRoot, realReleaseDirectory)) throw new Error('[ultramodern-release-envelope] release directory resolves outside artifactRoot.');
92
+ const envelopePath = node_path.join(releaseDirectory, node_path.basename(MICROVERTICAL_RELEASE_ENVELOPE_PATH));
93
+ try {
94
+ const envelopeStat = await promises.lstat(envelopePath);
95
+ if (envelopeStat.isSymbolicLink() || !envelopeStat.isFile()) throw new Error('[ultramodern-release-envelope] release envelope must be a real file inside artifactRoot, not a symlink or directory.');
96
+ const realEnvelopePath = await promises.realpath(envelopePath);
97
+ if (!isFilesystemPathInside(realRoot, realEnvelopePath)) throw new Error('[ultramodern-release-envelope] release envelope resolves outside artifactRoot.');
98
+ } catch (error) {
99
+ if (!isMissingPathError(error)) throw error;
100
+ if (!createDirectory) return;
101
+ }
102
+ return envelopePath;
103
+ };
104
+ const writeReleaseEnvelope = async (artifactRoot, envelope)=>{
105
+ const envelopePath = await resolveSafeReleaseEnvelopePath({
106
+ artifactRoot,
107
+ createDirectory: true
108
+ });
109
+ if (!envelopePath) throw new Error('[ultramodern-release-envelope] could not resolve release envelope path.');
110
+ await promises.writeFile(envelopePath, `${canonicalSerializeMicroVerticalReleaseEnvelope(envelope)}\n`);
111
+ };
112
+ const readBuildArtifact = async (distDirectory)=>{
113
+ const artifactPath = node_path.join(distDirectory, ULTRAMODERN_BUILD_ARTIFACT_FILE);
114
+ const artifact = await readJson(artifactPath);
115
+ if (!isUltramodernBuildArtifact(artifact)) throw new Error(`[ultramodern-release-envelope] ${ULTRAMODERN_BUILD_ARTIFACT_FILE} is missing or invalid.`);
116
+ if ('workspace' === artifact.deliveryUnit.sourceRevision) throw new Error('[ultramodern-release-envelope] sourceRevision "workspace" cannot produce a promotable full-stack envelope.');
117
+ return artifact;
118
+ };
119
+ const assertIdentityBlock = (value, identity, location, includeReleaseVersion)=>{
120
+ if (!isRecord(value)) throw new Error(`[ultramodern-release-envelope] ${location} is missing delivery identity.`);
121
+ const expected = {
122
+ unitId: identity.unitId,
123
+ buildMarker: identity.buildMarker,
124
+ sourceRevision: identity.sourceRevision,
125
+ ...includeReleaseVersion ? {
126
+ version: identity.releaseVersion
127
+ } : void 0
128
+ };
129
+ for (const [field, expectedValue] of Object.entries(expected))if (value[field] !== expectedValue) throw new Error(`[ultramodern-release-envelope] ${location}.${field} must match ${expectedValue}; received ${String(value[field])}.`);
130
+ };
131
+ const readBackendManifest = async (distDirectory, identity)=>{
132
+ const manifest = await readJson(node_path.join(distDirectory, BACKEND_FEDERATION_MANIFEST_FILE));
133
+ if (!isRecord(manifest) || !isRecord(manifest.backendFederation)) throw new Error('[ultramodern-release-envelope] backend federation manifest is missing backendFederation metadata.');
134
+ assertIdentityBlock(manifest.backendFederation.deliveryUnit, identity, 'backendFederation.deliveryUnit', true);
135
+ const versionBoundary = manifest.backendFederation.versionBoundary;
136
+ assertIdentityBlock(isRecord(versionBoundary) ? versionBoundary.deliveryUnit : void 0, identity, 'backendFederation.versionBoundary.deliveryUnit', false);
137
+ };
138
+ const collectFiles = async (root)=>{
139
+ const resolvedRoot = node_path.resolve(root);
140
+ const realRoot = await promises.realpath(resolvedRoot);
141
+ const collectDirectory = async (relativeDirectory)=>{
142
+ const directory = node_path.join(resolvedRoot, ...relativeDirectory.split('/').filter(Boolean));
143
+ const entries = await promises.readdir(directory, {
144
+ withFileTypes: true
145
+ });
146
+ const files = [];
147
+ for (const entry of entries){
148
+ const logicalPath = node_path.posix.join(relativeDirectory, entry.name);
149
+ if ('release' === logicalPath || logicalPath.startsWith('release/')) continue;
150
+ if (entry.isDirectory()) {
151
+ files.push(...await collectDirectory(logicalPath));
152
+ continue;
153
+ }
154
+ if (entry.isFile()) {
155
+ files.push(logicalPath);
156
+ continue;
157
+ }
158
+ if (!entry.isSymbolicLink()) continue;
159
+ const lexicalPath = node_path.join(resolvedRoot, ...logicalPath.split('/'));
160
+ let realPath;
161
+ try {
162
+ realPath = await promises.realpath(lexicalPath);
163
+ } catch {
164
+ throw new Error(`[ultramodern-release-envelope] symbolic link ${logicalPath} cannot be resolved.`);
165
+ }
166
+ if (!isFilesystemPathInside(realRoot, realPath)) throw new Error(`[ultramodern-release-envelope] symbolic link ${logicalPath} resolves outside artifactRoot.`);
167
+ const targetStat = await promises.stat(realPath);
168
+ if (!targetStat.isFile() && !targetStat.isDirectory()) throw new Error(`[ultramodern-release-envelope] symbolic link ${logicalPath} must resolve to a file or directory.`);
169
+ const targetLogicalPath = node_path.relative(realRoot, realPath).split(node_path.sep).join('/');
170
+ if ('release' === targetLogicalPath || targetLogicalPath.startsWith('release/')) throw new Error(`[ultramodern-release-envelope] symbolic link ${logicalPath} targets private release metadata.`);
171
+ if (targetStat.isDirectory() && isFilesystemPathInside(realPath, await promises.realpath(node_path.dirname(lexicalPath)))) throw new Error(`[ultramodern-release-envelope] symbolic link ${logicalPath} targets an ancestor directory.`);
172
+ files.push(logicalPath);
173
+ }
174
+ return files;
175
+ };
176
+ return (await collectDirectory('')).sort();
177
+ };
178
+ const releaseArtifact = (logicalPath, runtime)=>({
179
+ logicalPath,
180
+ runtime
181
+ });
182
+ const createReleaseArtifactInputs = async (distDirectory, identity, target)=>{
183
+ const files = await collectFiles(distDirectory);
184
+ if ('node' === target && files.some((logicalPath)=>EFFECT_BFF_WORKER_PATTERN.test(logicalPath))) throw new Error('[ultramodern-release-envelope] Node target conflicts with a Cloudflare Effect API/BFF worker artifact; resolve the canonical deploy target instead of emitting a Node envelope for Cloudflare output.');
185
+ const uiClientPaths = files.filter((logicalPath)=>{
186
+ const topLevel = logicalPath.split('/')[0];
187
+ return 'static' === topLevel || 'html' === topLevel || 'public' === topLevel || [
188
+ 'index.html',
189
+ 'mf-manifest.json',
190
+ 'mf-stats.json',
191
+ 'remoteEntry.js',
192
+ 'routes-manifest.json',
193
+ 'loadable-stats.json'
194
+ ].includes(logicalPath);
195
+ });
196
+ const ssrPaths = 'node' === target ? files.filter((logicalPath)=>logicalPath.startsWith('bundles/') && COMPILED_MODULE_PATTERN.test(logicalPath)) : files.filter((logicalPath)=>logicalPath.startsWith('worker/') && COMPILED_MODULE_PATTERN.test(logicalPath) && !EFFECT_BFF_WORKER_PATTERN.test(logicalPath));
197
+ const nodeApiEntryPaths = files.filter((logicalPath)=>logicalPath.startsWith('api/') && COMPILED_MODULE_PATTERN.test(logicalPath));
198
+ const apiBackendPaths = 'node' === target ? files.filter((logicalPath)=>(logicalPath.startsWith('api/') || logicalPath.startsWith('shared/')) && COMPILED_MODULE_PATTERN.test(logicalPath)) : files.filter((logicalPath)=>EFFECT_BFF_WORKER_PATTERN.test(logicalPath));
199
+ if (0 === uiClientPaths.length) throw new Error(`[ultramodern-release-envelope] ${target} full-stack MicroVertical has no UI/client artifacts.`);
200
+ if (0 === ssrPaths.length) throw new Error(`[ultramodern-release-envelope] ${target} full-stack MicroVertical has no ${'node' === target ? 'Node' : 'workerd'} SSR artifacts.`);
201
+ if ('node' === target && 0 === nodeApiEntryPaths.length || 0 === apiBackendPaths.length) throw new Error(`[ultramodern-release-envelope] ${target} full-stack MicroVertical has no actual ${'node' === target ? 'compiled Node Effect API artifact' : 'Effect API/BFF worker artifact'}.`);
202
+ const clientExecutionPaths = await manifestReferencedClientModules(distDirectory, files);
203
+ if (0 === clientExecutionPaths.length) throw new Error('[ultramodern-release-envelope] UI/client manifest references no compiled execution module.');
204
+ const ssrExecutionPaths = await routeReferencedSsrModules(distDirectory, files, target);
205
+ await assertEveryCompiledIdentityCarrier(distDirectory, clientExecutionPaths, identity, 'manifest-referenced UI/client');
206
+ await assertEveryCompiledIdentityCarrier(distDirectory, ssrExecutionPaths, identity, 'node' === target ? 'route-referenced Node SSR' : 'route-referenced Cloudflare SSR');
207
+ await assertEveryCompiledIdentityCarrier(distDirectory, ssrPaths, identity, 'node' === target ? 'compiled Node SSR closure' : 'compiled Cloudflare SSR/workerd closure');
208
+ await assertEveryCompiledIdentityCarrier(distDirectory, 'node' === target ? nodeApiEntryPaths : apiBackendPaths, identity, 'node' === target ? 'Node API/backend' : 'Cloudflare API/backend');
209
+ await assertEveryCompiledIdentityCarrier(distDirectory, [
210
+ BACKEND_FEDERATION_REMOTE_ENTRY_FILE
211
+ ], identity, 'backend Module Federation container');
212
+ const runtimeByPath = new Map();
213
+ const add = (paths, runtime)=>{
214
+ for (const logicalPath of paths){
215
+ const existing = runtimeByPath.get(logicalPath);
216
+ if (existing && existing !== runtime) throw new Error(`[ultramodern-release-envelope] artifact "${logicalPath}" cannot carry conflicting runtimes "${existing}" and "${runtime}".`);
217
+ runtimeByPath.set(logicalPath, runtime);
218
+ }
219
+ };
220
+ add(uiClientPaths, 'browser');
221
+ add(ssrPaths, 'node' === target ? 'nodejs' : 'workerd');
222
+ add(apiBackendPaths, 'node' === target ? 'nodejs' : 'workerd-effect');
223
+ add([
224
+ BACKEND_FEDERATION_MANIFEST_FILE
225
+ ], 'module-federation-manifest');
226
+ add([
227
+ BACKEND_FEDERATION_REMOTE_ENTRY_FILE
228
+ ], 'node' === target ? 'nodejs' : 'commonjs-module');
229
+ const surfaces = {
230
+ uiClient: [
231
+ ...uiClientPaths
232
+ ].sort((left, right)=>left.localeCompare(right)),
233
+ ssr: [
234
+ ...ssrPaths
235
+ ].sort((left, right)=>left.localeCompare(right)),
236
+ apiBackend: [
237
+ ...apiBackendPaths
238
+ ].sort((left, right)=>left.localeCompare(right)),
239
+ backendFederation: {
240
+ manifest: BACKEND_FEDERATION_MANIFEST_FILE,
241
+ container: BACKEND_FEDERATION_REMOTE_ENTRY_FILE
242
+ }
243
+ };
244
+ const artifacts = [
245
+ ...runtimeByPath
246
+ ].map(([logicalPath, runtime])=>releaseArtifact(logicalPath, runtime)).sort((left, right)=>left.logicalPath.localeCompare(right.logicalPath));
247
+ return {
248
+ artifacts,
249
+ surfaces
250
+ };
251
+ };
252
+ const pathExists = async (filePath)=>{
253
+ try {
254
+ await promises.access(filePath);
255
+ return true;
256
+ } catch {
257
+ return false;
258
+ }
259
+ };
260
+ const emitFrameworkMicroVerticalReleaseEnvelope = async ({ apiOnly, distDirectory, target })=>{
261
+ if (apiOnly) return;
262
+ const backendManifestPath = node_path.join(distDirectory, BACKEND_FEDERATION_MANIFEST_FILE);
263
+ const backendContainerPath = node_path.join(distDirectory, BACKEND_FEDERATION_REMOTE_ENTRY_FILE);
264
+ const [hasBackendManifest, hasBackendContainer] = await Promise.all([
265
+ pathExists(backendManifestPath),
266
+ pathExists(backendContainerPath)
267
+ ]);
268
+ if (!hasBackendManifest && !hasBackendContainer) return;
269
+ if (!hasBackendManifest || !hasBackendContainer) throw new Error('[ultramodern-release-envelope] full-stack MicroVertical backend federation manifest and container must be emitted together.');
270
+ const buildArtifact = await readBuildArtifact(distDirectory);
271
+ const identity = {
272
+ unitId: buildArtifact.deliveryUnit.unitId,
273
+ buildMarker: buildArtifact.deliveryUnit.buildMarker,
274
+ sourceRevision: buildArtifact.deliveryUnit.sourceRevision,
275
+ releaseVersion: buildArtifact.deliveryUnit.version
276
+ };
277
+ await readBackendManifest(distDirectory, identity);
278
+ const { artifacts, surfaces } = await createReleaseArtifactInputs(distDirectory, identity, target);
279
+ const envelope = await createMicroVerticalReleaseEnvelope({
280
+ artifactRoot: distDirectory,
281
+ target,
282
+ identity,
283
+ artifacts,
284
+ surfaces
285
+ });
286
+ await writeReleaseEnvelope(distDirectory, envelope);
287
+ return envelope;
288
+ };
289
+ const readFrameworkMicroVerticalReleaseEnvelope = async ({ artifactRoot, expectedTarget, logicalPathForArtifact, required = false })=>{
290
+ const envelopePath = await resolveSafeReleaseEnvelopePath({
291
+ artifactRoot,
292
+ createDirectory: false
293
+ });
294
+ if (!envelopePath) {
295
+ if (required) throw new Error(`[ultramodern-release-envelope] required envelope is missing at ${MICROVERTICAL_RELEASE_ENVELOPE_PATH}.`);
296
+ return;
297
+ }
298
+ return verifyMicroVerticalReleaseEnvelope(await readJson(envelopePath), {
299
+ artifactRoot,
300
+ ...expectedTarget ? {
301
+ expectedTarget
302
+ } : {},
303
+ ...logicalPathForArtifact ? {
304
+ logicalPathForArtifact
305
+ } : {}
306
+ });
307
+ };
308
+ const verifyBuildOutputReleaseEnvelope = async (distDirectory, expectedTarget)=>{
309
+ const [hasEnvelope, hasBuildArtifact, hasBackendManifest, hasBackendEntry] = await Promise.all([
310
+ pathExists(node_path.join(distDirectory, MICROVERTICAL_RELEASE_ENVELOPE_PATH)),
311
+ pathExists(node_path.join(distDirectory, ULTRAMODERN_BUILD_ARTIFACT_FILE)),
312
+ pathExists(node_path.join(distDirectory, BACKEND_FEDERATION_MANIFEST_FILE)),
313
+ pathExists(node_path.join(distDirectory, BACKEND_FEDERATION_REMOTE_ENTRY_FILE))
314
+ ]);
315
+ const isFullStackMicroVertical = hasBuildArtifact && (hasBackendManifest || hasBackendEntry);
316
+ return readFrameworkMicroVerticalReleaseEnvelope({
317
+ artifactRoot: distDirectory,
318
+ ...expectedTarget ? {
319
+ expectedTarget
320
+ } : {},
321
+ required: hasEnvelope || isFullStackMicroVertical
322
+ });
323
+ };
324
+ const verifyNodeReleaseEnvelopeStaging = async ({ outputDirectory })=>readFrameworkMicroVerticalReleaseEnvelope({
325
+ artifactRoot: outputDirectory,
326
+ expectedTarget: 'node',
327
+ required: true
328
+ });
329
+ const createNodeStagedReleaseArtifactInputs = async (outputDirectory, identity)=>{
330
+ const files = await collectFiles(outputDirectory);
331
+ for (const requiredPath of [
332
+ 'index.js',
333
+ 'package.json',
334
+ BACKEND_FEDERATION_MANIFEST_FILE,
335
+ BACKEND_FEDERATION_REMOTE_ENTRY_FILE
336
+ ])if (!files.includes(requiredPath)) throw new Error(`[ultramodern-release-envelope] final Node staging is missing ${requiredPath}.`);
337
+ const backendFederationPaths = new Set([
338
+ BACKEND_FEDERATION_MANIFEST_FILE,
339
+ BACKEND_FEDERATION_REMOTE_ENTRY_FILE
340
+ ]);
341
+ const uiClientPaths = files.filter((logicalPath)=>{
342
+ const topLevel = logicalPath.split('/')[0];
343
+ return 'static' === topLevel || 'html' === topLevel || 'public' === topLevel || [
344
+ 'index.html',
345
+ 'mf-manifest.json',
346
+ 'mf-stats.json',
347
+ 'remoteEntry.js',
348
+ 'routes-manifest.json',
349
+ 'loadable-stats.json'
350
+ ].includes(logicalPath);
351
+ });
352
+ const ssrPaths = files.filter((logicalPath)=>'index.js' === logicalPath || logicalPath.startsWith('bundles/') && COMPILED_MODULE_PATTERN.test(logicalPath));
353
+ const apiBackendPaths = files.filter((logicalPath)=>(logicalPath.startsWith('api/') || logicalPath.startsWith('shared/')) && COMPILED_MODULE_PATTERN.test(logicalPath));
354
+ for (const [surface, paths] of [
355
+ [
356
+ 'UI/client',
357
+ uiClientPaths
358
+ ],
359
+ [
360
+ 'Node SSR',
361
+ ssrPaths
362
+ ],
363
+ [
364
+ 'Node API/backend',
365
+ apiBackendPaths
366
+ ]
367
+ ])if (0 === paths.length) throw new Error(`[ultramodern-release-envelope] final Node staging has no ${surface} artifacts.`);
368
+ const clientExecutionPaths = await manifestReferencedClientModules(outputDirectory, files);
369
+ const ssrExecutionPaths = await routeReferencedSsrModules(outputDirectory, files, 'node');
370
+ await assertEveryCompiledIdentityCarrier(outputDirectory, clientExecutionPaths, identity, 'final manifest-referenced Node UI/client');
371
+ await assertEveryCompiledIdentityCarrier(outputDirectory, ssrExecutionPaths, identity, 'final route-referenced Node SSR');
372
+ await assertEveryCompiledIdentityCarrier(outputDirectory, ssrPaths.filter((logicalPath)=>'index.js' !== logicalPath), identity, 'final compiled Node SSR closure');
373
+ await assertEveryCompiledIdentityCarrier(outputDirectory, apiBackendPaths.filter((logicalPath)=>logicalPath.startsWith('api/')), identity, 'final Node API/backend');
374
+ await assertEveryCompiledIdentityCarrier(outputDirectory, [
375
+ BACKEND_FEDERATION_REMOTE_ENTRY_FILE
376
+ ], identity, 'final Node backend Module Federation container');
377
+ const runtimeByPath = new Map(files.filter((logicalPath)=>!backendFederationPaths.has(logicalPath)).map((logicalPath)=>[
378
+ logicalPath,
379
+ 'nodejs-deployment'
380
+ ]));
381
+ for (const logicalPath of uiClientPaths)runtimeByPath.set(logicalPath, 'browser');
382
+ for (const logicalPath of ssrPaths)runtimeByPath.set(logicalPath, 'nodejs');
383
+ for (const logicalPath of apiBackendPaths)runtimeByPath.set(logicalPath, 'nodejs');
384
+ runtimeByPath.set(BACKEND_FEDERATION_MANIFEST_FILE, 'module-federation-manifest');
385
+ runtimeByPath.set(BACKEND_FEDERATION_REMOTE_ENTRY_FILE, 'nodejs');
386
+ return {
387
+ artifacts: [
388
+ ...runtimeByPath
389
+ ].map(([logicalPath, runtime])=>releaseArtifact(logicalPath, runtime)).sort((left, right)=>left.logicalPath.localeCompare(right.logicalPath)),
390
+ surfaces: {
391
+ uiClient: [
392
+ ...uiClientPaths
393
+ ].sort((left, right)=>left.localeCompare(right)),
394
+ ssr: [
395
+ ...ssrPaths
396
+ ].sort((left, right)=>left.localeCompare(right)),
397
+ apiBackend: [
398
+ ...apiBackendPaths
399
+ ].sort((left, right)=>left.localeCompare(right)),
400
+ backendFederation: {
401
+ manifest: BACKEND_FEDERATION_MANIFEST_FILE,
402
+ container: BACKEND_FEDERATION_REMOTE_ENTRY_FILE
403
+ }
404
+ }
405
+ };
406
+ };
407
+ const emitNodeStagedReleaseEnvelope = async ({ distDirectory, outputDirectory })=>{
408
+ const source = await verifyBuildOutputReleaseEnvelope(distDirectory, 'node');
409
+ if (!source) return;
410
+ const { artifacts, surfaces } = await createNodeStagedReleaseArtifactInputs(outputDirectory, source.identity);
411
+ const staged = await createMicroVerticalReleaseEnvelope({
412
+ artifactRoot: outputDirectory,
413
+ target: 'node',
414
+ identity: source.identity,
415
+ artifacts,
416
+ surfaces
417
+ });
418
+ await writeReleaseEnvelope(outputDirectory, staged);
419
+ return staged;
420
+ };
421
+ const stageCloudflareReleaseEnvelope = async ({ distDirectory, outputDirectory })=>{
422
+ const source = await verifyBuildOutputReleaseEnvelope(distDirectory, 'cloudflare');
423
+ if (!source) return;
424
+ const stagedEnvelopePath = node_path.join(outputDirectory, MICROVERTICAL_RELEASE_ENVELOPE_PATH);
425
+ if (await pathExists(stagedEnvelopePath)) throw new Error('[ultramodern-release-envelope] Cloudflare staging contains a stale envelope before final output generation.');
426
+ return source;
427
+ };
428
+ const createCloudflareStagedReleaseArtifactInputs = async (outputDirectory, identity)=>{
429
+ const files = await collectFiles(outputDirectory);
430
+ for (const requiredPath of [
431
+ 'server/index.mjs',
432
+ 'server/modern-worker-manifest.json',
433
+ 'wrangler.json',
434
+ 'package.json',
435
+ 'worker/package.json'
436
+ ])if (!files.includes(requiredPath)) throw new Error(`[ultramodern-release-envelope] final Cloudflare staging is missing ${requiredPath}.`);
437
+ if (files.some((logicalPath)=>'public/release' === logicalPath || logicalPath.startsWith('public/release/'))) throw new Error('[ultramodern-release-envelope] final Cloudflare envelope must remain private and cannot be staged under public/release.');
438
+ const backendManifestPath = `public/${BACKEND_FEDERATION_MANIFEST_FILE}`;
439
+ const backendContainerPath = `public/${BACKEND_FEDERATION_REMOTE_ENTRY_FILE}`;
440
+ const apiBackendPaths = files.filter((logicalPath)=>EFFECT_BFF_WORKER_PATTERN.test(logicalPath));
441
+ const ssrPaths = files.filter((logicalPath)=>(logicalPath.startsWith('server/') || logicalPath.startsWith('worker/')) && COMPILED_MODULE_PATTERN.test(logicalPath) && !EFFECT_BFF_WORKER_PATTERN.test(logicalPath));
442
+ const uiClientPaths = files.filter((logicalPath)=>logicalPath.startsWith('public/') && logicalPath !== backendManifestPath && logicalPath !== backendContainerPath);
443
+ for (const [surface, paths] of [
444
+ [
445
+ 'UI/client',
446
+ uiClientPaths
447
+ ],
448
+ [
449
+ 'Cloudflare SSR',
450
+ ssrPaths
451
+ ],
452
+ [
453
+ 'Cloudflare API/backend',
454
+ apiBackendPaths
455
+ ]
456
+ ])if (0 === paths.length) throw new Error(`[ultramodern-release-envelope] final Cloudflare staging has no ${surface} artifacts.`);
457
+ for (const logicalPath of [
458
+ backendManifestPath,
459
+ backendContainerPath
460
+ ])if (!files.includes(logicalPath)) throw new Error(`[ultramodern-release-envelope] final Cloudflare staging is missing ${logicalPath}.`);
461
+ const clientExecutionPaths = await manifestReferencedClientModules(outputDirectory, files, 'public/mf-manifest.json');
462
+ const ssrExecutionPaths = await routeReferencedSsrModules(outputDirectory, files, 'cloudflare', 'server/route.json');
463
+ await assertEveryCompiledIdentityCarrier(outputDirectory, clientExecutionPaths, identity, 'final manifest-referenced Cloudflare UI/client');
464
+ await assertEveryCompiledIdentityCarrier(outputDirectory, ssrExecutionPaths, identity, 'final route-referenced Cloudflare SSR');
465
+ await assertEveryCompiledIdentityCarrier(outputDirectory, ssrPaths.filter((logicalPath)=>logicalPath.startsWith('worker/')), identity, 'final compiled Cloudflare SSR/workerd closure');
466
+ await assertEveryCompiledIdentityCarrier(outputDirectory, apiBackendPaths, identity, 'final Cloudflare API/backend');
467
+ await assertEveryCompiledIdentityCarrier(outputDirectory, [
468
+ backendContainerPath
469
+ ], identity, 'final Cloudflare backend Module Federation container');
470
+ const runtimeByPath = new Map();
471
+ for (const logicalPath of files)runtimeByPath.set(logicalPath, 'cloudflare-deployment');
472
+ const add = (paths, runtime)=>{
473
+ for (const logicalPath of paths)runtimeByPath.set(logicalPath, runtime);
474
+ };
475
+ add(uiClientPaths, 'browser');
476
+ add(ssrPaths, 'workerd');
477
+ add(apiBackendPaths, 'workerd-effect');
478
+ add([
479
+ backendManifestPath
480
+ ], 'module-federation-manifest');
481
+ add([
482
+ backendContainerPath
483
+ ], 'commonjs-module');
484
+ return {
485
+ artifacts: [
486
+ ...runtimeByPath
487
+ ].map(([logicalPath, runtime])=>releaseArtifact(logicalPath, runtime)).sort((left, right)=>left.logicalPath.localeCompare(right.logicalPath)),
488
+ surfaces: {
489
+ uiClient: [
490
+ ...uiClientPaths
491
+ ].sort((left, right)=>left.localeCompare(right)),
492
+ ssr: [
493
+ ...ssrPaths
494
+ ].sort((left, right)=>left.localeCompare(right)),
495
+ apiBackend: [
496
+ ...apiBackendPaths
497
+ ].sort((left, right)=>left.localeCompare(right)),
498
+ backendFederation: {
499
+ manifest: backendManifestPath,
500
+ container: backendContainerPath
501
+ }
502
+ }
503
+ };
504
+ };
505
+ const emitCloudflareStagedReleaseEnvelope = async ({ distDirectory, outputDirectory })=>{
506
+ const source = await verifyBuildOutputReleaseEnvelope(distDirectory, 'cloudflare');
507
+ if (!source) return;
508
+ const { artifacts, surfaces } = await createCloudflareStagedReleaseArtifactInputs(outputDirectory, source.identity);
509
+ const staged = await createMicroVerticalReleaseEnvelope({
510
+ artifactRoot: outputDirectory,
511
+ target: 'cloudflare',
512
+ identity: source.identity,
513
+ artifacts,
514
+ surfaces
515
+ });
516
+ await writeReleaseEnvelope(outputDirectory, staged);
517
+ return staged;
518
+ };
519
+ const verifyCloudflareReleaseEnvelopeStaging = async (outputDirectory)=>readFrameworkMicroVerticalReleaseEnvelope({
520
+ artifactRoot: outputDirectory,
521
+ expectedTarget: 'cloudflare',
522
+ required: true
523
+ });
524
+ export { MICROVERTICAL_RELEASE_ENVELOPE_PATH, emitCloudflareStagedReleaseEnvelope, emitFrameworkMicroVerticalReleaseEnvelope, emitNodeStagedReleaseEnvelope, readFrameworkMicroVerticalReleaseEnvelope, stageCloudflareReleaseEnvelope, verifyBuildOutputReleaseEnvelope, verifyCloudflareReleaseEnvelopeStaging, verifyNodeReleaseEnvelopeStaging };