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

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