@bleedingdev/modern-js-app-tools 3.5.0-ultramodern.6 → 3.5.0-ultramodern.76

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,335 @@
1
+ import { createHash } from "node:crypto";
2
+ import promises from "node:fs/promises";
3
+ import node_path from "node:path";
4
+ import { canonicalSerializeMicroVerticalReleaseEnvelope, digestMicroVerticalReleaseEnvelopePayload, releaseEnvelopePayload } from "./canonical.mjs";
5
+ import { MICROVERTICAL_RELEASE_ENVELOPE_KIND, MICROVERTICAL_RELEASE_ENVELOPE_SCHEMA_VERSION, MICROVERTICAL_RELEASE_TARGETS } from "./types.mjs";
6
+ const SHA256_PATTERN = /^[a-f0-9]{64}$/u;
7
+ const SOURCE_REVISION_PATTERN = /^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u;
8
+ const TARGETS = new Set(MICROVERTICAL_RELEASE_TARGETS);
9
+ const isRecord = (value)=>'object' == typeof value && null !== value && !Array.isArray(value);
10
+ const assertRecord = (value, location)=>{
11
+ if (!isRecord(value)) throw new Error(`${location} must be an object.`);
12
+ return value;
13
+ };
14
+ const assertExactKeys = (value, expected, location)=>{
15
+ const expectedKeys = new Set(expected);
16
+ for (const key of Object.keys(value))if (!expectedKeys.has(key)) throw new Error(`${location} contains unknown field "${key}".`);
17
+ for (const key of expected)if (!(key in value)) throw new Error(`${location}.${key} is required.`);
18
+ };
19
+ const assertNonEmptyString = (value, location)=>{
20
+ if ('string' != typeof value || 0 === value.trim().length) throw new Error(`${location} must be a non-empty string.`);
21
+ if (value !== value.trim()) throw new Error(`${location} must not contain surrounding whitespace.`);
22
+ return value;
23
+ };
24
+ const assertTarget = (value, location = 'target')=>{
25
+ const target = assertNonEmptyString(value, location);
26
+ if (!TARGETS.has(target)) throw new Error(`${location} must be one of: ${MICROVERTICAL_RELEASE_TARGETS.join(', ')}.`);
27
+ return target;
28
+ };
29
+ const assertReleaseIdentity = (value, location = 'identity')=>{
30
+ const identity = assertRecord(value, location);
31
+ assertExactKeys(identity, [
32
+ 'unitId',
33
+ 'buildMarker',
34
+ 'sourceRevision',
35
+ 'releaseVersion'
36
+ ], location);
37
+ const sourceRevision = assertNonEmptyString(identity.sourceRevision, `${location}.sourceRevision`);
38
+ if (!SOURCE_REVISION_PATTERN.test(sourceRevision)) throw new Error(`${location}.sourceRevision must be an exact lowercase 40- or 64-character Git object ID; "${sourceRevision}" is not promotable.`);
39
+ return {
40
+ unitId: assertNonEmptyString(identity.unitId, `${location}.unitId`),
41
+ buildMarker: assertNonEmptyString(identity.buildMarker, `${location}.buildMarker`),
42
+ sourceRevision,
43
+ releaseVersion: assertNonEmptyString(identity.releaseVersion, `${location}.releaseVersion`)
44
+ };
45
+ };
46
+ const assertNormalizedLogicalPath = (value, location)=>{
47
+ const logicalPath = assertNonEmptyString(value, location);
48
+ if (logicalPath.includes('\\') || node_path.posix.isAbsolute(logicalPath) || node_path.posix.normalize(logicalPath) !== logicalPath || '.' === logicalPath || logicalPath.split('/').some((segment)=>'..' === segment || '.' === segment)) throw new Error(`${location} must be a normalized relative POSIX path.`);
49
+ return logicalPath;
50
+ };
51
+ const isPathInside = (root, candidate)=>{
52
+ const relative = node_path.relative(root, candidate);
53
+ return '' === relative || !relative.startsWith(`..${node_path.sep}`) && '..' !== relative && !node_path.isAbsolute(relative);
54
+ };
55
+ const assertArtifactInput = (value, location)=>{
56
+ const artifact = assertRecord(value, location);
57
+ assertExactKeys(artifact, [
58
+ 'logicalPath',
59
+ 'runtime'
60
+ ], location);
61
+ return {
62
+ logicalPath: assertNormalizedLogicalPath(artifact.logicalPath, `${location}.logicalPath`),
63
+ runtime: assertNonEmptyString(artifact.runtime, `${location}.runtime`)
64
+ };
65
+ };
66
+ const readFinalArtifact = async (artifactRoot, input, resolvedLogicalPath = input.logicalPath)=>{
67
+ const artifactInput = {
68
+ logicalPath: input.logicalPath,
69
+ runtime: input.runtime
70
+ };
71
+ const logicalPath = assertNormalizedLogicalPath(resolvedLogicalPath, `staged path for ${input.logicalPath}`);
72
+ const resolvedRoot = node_path.resolve(artifactRoot);
73
+ const logicalSegments = logicalPath.split('/');
74
+ const lexicalPath = node_path.resolve(resolvedRoot, ...logicalSegments);
75
+ if (!isPathInside(resolvedRoot, lexicalPath)) throw new Error(`Artifact logicalPath "${logicalPath}" resolves outside artifactRoot.`);
76
+ const realRoot = await promises.realpath(resolvedRoot);
77
+ for(let index = 0; index < logicalSegments.length - 1; index++){
78
+ const linkLogicalPath = logicalSegments.slice(0, index + 1).join('/');
79
+ const candidate = node_path.join(resolvedRoot, ...logicalSegments.slice(0, index + 1));
80
+ let candidateStat;
81
+ try {
82
+ candidateStat = await promises.lstat(candidate);
83
+ } catch {
84
+ throw new Error(`Artifact "${logicalPath}" does not exist.`);
85
+ }
86
+ if (candidateStat.isSymbolicLink()) throw new Error(`Artifact "${logicalPath}" traverses symbolic-link ancestor "${linkLogicalPath}"; bind the symbolic link itself.`);
87
+ }
88
+ let lexicalStat;
89
+ try {
90
+ lexicalStat = await promises.lstat(lexicalPath);
91
+ } catch {
92
+ throw new Error(`Artifact "${logicalPath}" does not exist.`);
93
+ }
94
+ if (lexicalStat.isSymbolicLink()) {
95
+ let realTarget;
96
+ try {
97
+ realTarget = await promises.realpath(lexicalPath);
98
+ } catch {
99
+ throw new Error(`Artifact symbolic link "${logicalPath}" cannot be resolved.`);
100
+ }
101
+ if (!isPathInside(realRoot, realTarget)) throw new Error(`Artifact logicalPath "${logicalPath}" resolves outside artifactRoot.`);
102
+ const targetStat = await promises.stat(realTarget);
103
+ const targetKind = targetStat.isFile() ? 'file' : targetStat.isDirectory() ? 'directory' : void 0;
104
+ if (!targetKind) throw new Error(`Artifact symbolic link "${logicalPath}" must resolve to a file or directory.`);
105
+ const targetLogicalPath = node_path.relative(realRoot, realTarget).split(node_path.sep).join('/');
106
+ if ('release' === targetLogicalPath || targetLogicalPath.startsWith('release/')) throw new Error(`Artifact symbolic link "${logicalPath}" targets private release metadata.`);
107
+ if ('directory' === targetKind && isPathInside(realTarget, await promises.realpath(node_path.dirname(lexicalPath)))) throw new Error(`Artifact symbolic link "${logicalPath}" targets an ancestor directory.`);
108
+ return {
109
+ ...artifactInput,
110
+ kind: 'symbolic-link',
111
+ linkTarget: await promises.readlink(lexicalPath),
112
+ targetKind,
113
+ targetLogicalPath
114
+ };
115
+ }
116
+ if (!lexicalStat.isFile()) throw new Error(`Artifact "${logicalPath}" must be a file or symlink.`);
117
+ const realPath = await promises.realpath(lexicalPath);
118
+ if (!isPathInside(realRoot, realPath)) throw new Error(`Artifact logicalPath "${logicalPath}" resolves outside artifactRoot.`);
119
+ const bytes = await promises.readFile(realPath);
120
+ return {
121
+ ...artifactInput,
122
+ kind: 'file',
123
+ byteLength: bytes.byteLength,
124
+ sha256: createHash('sha256').update(bytes).digest('hex')
125
+ };
126
+ };
127
+ const assertReleaseArtifact = (value, location)=>{
128
+ const artifact = assertRecord(value, location);
129
+ const kind = assertNonEmptyString(artifact.kind, `${location}.kind`);
130
+ const input = {
131
+ logicalPath: artifact.logicalPath,
132
+ runtime: artifact.runtime
133
+ };
134
+ if ('file' === kind) {
135
+ assertExactKeys(artifact, [
136
+ 'kind',
137
+ 'logicalPath',
138
+ 'runtime',
139
+ 'byteLength',
140
+ 'sha256'
141
+ ], location);
142
+ const byteLength = artifact.byteLength;
143
+ if ('number' != typeof byteLength || !Number.isSafeInteger(byteLength) || byteLength < 0) throw new Error(`${location}.byteLength must be a non-negative integer.`);
144
+ const sha256 = assertNonEmptyString(artifact.sha256, `${location}.sha256`);
145
+ if (!SHA256_PATTERN.test(sha256)) throw new Error(`${location}.sha256 must be a lowercase SHA-256 digest.`);
146
+ return {
147
+ ...assertArtifactInput(input, location),
148
+ kind,
149
+ byteLength,
150
+ sha256
151
+ };
152
+ }
153
+ if ('symbolic-link' === kind) {
154
+ assertExactKeys(artifact, [
155
+ 'kind',
156
+ 'logicalPath',
157
+ 'runtime',
158
+ 'linkTarget',
159
+ 'targetKind',
160
+ 'targetLogicalPath'
161
+ ], location);
162
+ const targetKind = assertNonEmptyString(artifact.targetKind, `${location}.targetKind`);
163
+ if ('directory' !== targetKind && 'file' !== targetKind) throw new Error(`${location}.targetKind must be "directory" or "file".`);
164
+ return {
165
+ ...assertArtifactInput(input, location),
166
+ kind,
167
+ linkTarget: assertNonEmptyString(artifact.linkTarget, `${location}.linkTarget`),
168
+ targetKind,
169
+ targetLogicalPath: assertNormalizedLogicalPath(artifact.targetLogicalPath, `${location}.targetLogicalPath`)
170
+ };
171
+ }
172
+ throw new Error(`${location}.kind must be "file" or "symbolic-link".`);
173
+ };
174
+ const assertUniqueSortedArtifacts = (artifacts, location)=>{
175
+ const paths = artifacts.map((artifact)=>artifact.logicalPath);
176
+ const unique = new Set(paths);
177
+ if (unique.size !== paths.length) {
178
+ const duplicate = paths.find((logicalPath, index)=>paths.indexOf(logicalPath) !== index);
179
+ throw new Error(`Duplicate artifact logicalPath "${duplicate}".`);
180
+ }
181
+ const sorted = [
182
+ ...paths
183
+ ].sort((left, right)=>left.localeCompare(right));
184
+ if (paths.some((logicalPath, index)=>logicalPath !== sorted[index])) throw new Error(`${location} must be sorted by logicalPath.`);
185
+ };
186
+ const assertSurfacePaths = (value, location)=>{
187
+ if (!Array.isArray(value) || 0 === value.length) throw new Error(`${location} must contain at least one artifact path.`);
188
+ const paths = value.map((item, index)=>assertNormalizedLogicalPath(item, `${location}[${index}]`));
189
+ const sorted = [
190
+ ...paths
191
+ ].sort((left, right)=>left.localeCompare(right));
192
+ if (paths.some((logicalPath, index)=>logicalPath !== sorted[index])) throw new Error(`${location} must be sorted by logicalPath.`);
193
+ if (new Set(paths).size !== paths.length) throw new Error(`${location} must not contain duplicate artifact paths.`);
194
+ return paths;
195
+ };
196
+ const assertSurfaces = (value)=>{
197
+ const surfaces = assertRecord(value, 'surfaces');
198
+ assertExactKeys(surfaces, [
199
+ 'uiClient',
200
+ 'ssr',
201
+ 'apiBackend',
202
+ 'backendFederation'
203
+ ], 'surfaces');
204
+ const backendFederation = assertRecord(surfaces.backendFederation, 'surfaces.backendFederation');
205
+ assertExactKeys(backendFederation, [
206
+ 'manifest',
207
+ 'container'
208
+ ], 'surfaces.backendFederation');
209
+ return {
210
+ uiClient: assertSurfacePaths(surfaces.uiClient, 'surfaces.uiClient'),
211
+ ssr: assertSurfacePaths(surfaces.ssr, 'surfaces.ssr'),
212
+ apiBackend: assertSurfacePaths(surfaces.apiBackend, 'surfaces.apiBackend'),
213
+ backendFederation: {
214
+ manifest: assertNormalizedLogicalPath(backendFederation.manifest, 'surfaces.backendFederation.manifest'),
215
+ container: assertNormalizedLogicalPath(backendFederation.container, 'surfaces.backendFederation.container')
216
+ }
217
+ };
218
+ };
219
+ const assertSurfaceReferences = (artifacts, surfaces)=>{
220
+ const artifactPaths = new Set(artifacts.map((artifact)=>artifact.logicalPath));
221
+ for (const [surface, paths] of Object.entries({
222
+ uiClient: surfaces.uiClient,
223
+ ssr: surfaces.ssr,
224
+ apiBackend: surfaces.apiBackend,
225
+ 'backendFederation.manifest': [
226
+ surfaces.backendFederation.manifest
227
+ ],
228
+ 'backendFederation.container': [
229
+ surfaces.backendFederation.container
230
+ ]
231
+ }))for (const logicalPath of paths)if (!artifactPaths.has(logicalPath)) throw new Error(`surfaces.${surface} references unbound artifact "${logicalPath}".`);
232
+ };
233
+ const assertTargetSurfaceContract = (target, artifacts, surfaces)=>{
234
+ const byPath = new Map(artifacts.map((artifact)=>[
235
+ artifact.logicalPath,
236
+ artifact
237
+ ]));
238
+ const assertRuntime = (paths, expected, surface)=>{
239
+ for (const logicalPath of paths){
240
+ const artifact = byPath.get(logicalPath);
241
+ if (artifact?.runtime !== expected) throw new Error(`${target} ${surface} artifact "${logicalPath}" must use runtime "${expected}"; received "${String(artifact?.runtime)}".`);
242
+ if ('kind' in artifact && 'file' !== artifact.kind) throw new Error(`${target} ${surface} artifact "${logicalPath}" must be a file.`);
243
+ }
244
+ };
245
+ assertRuntime(surfaces.uiClient, 'browser', 'UI/client');
246
+ assertRuntime(surfaces.ssr, 'node' === target ? 'nodejs' : 'workerd', 'SSR');
247
+ assertRuntime(surfaces.apiBackend, 'node' === target ? 'nodejs' : 'workerd-effect', 'API/backend');
248
+ assertRuntime([
249
+ surfaces.backendFederation.manifest
250
+ ], 'module-federation-manifest', 'backend federation manifest');
251
+ assertRuntime([
252
+ surfaces.backendFederation.container
253
+ ], 'node' === target ? 'nodejs' : 'commonjs-module', 'backend federation container');
254
+ };
255
+ const deepFreeze = (value)=>{
256
+ if (null !== value && 'object' == typeof value && !Object.isFrozen(value)) {
257
+ Object.freeze(value);
258
+ for (const child of Object.values(value))deepFreeze(child);
259
+ }
260
+ return value;
261
+ };
262
+ const assertEnvelope = (value)=>{
263
+ const envelope = assertRecord(value, 'envelope');
264
+ assertExactKeys(envelope, [
265
+ 'schemaVersion',
266
+ 'kind',
267
+ 'target',
268
+ 'identity',
269
+ 'artifacts',
270
+ 'surfaces',
271
+ 'envelopeDigest'
272
+ ], 'envelope');
273
+ if (envelope.schemaVersion !== MICROVERTICAL_RELEASE_ENVELOPE_SCHEMA_VERSION) throw new Error(`envelope.schemaVersion must be ${MICROVERTICAL_RELEASE_ENVELOPE_SCHEMA_VERSION}.`);
274
+ if (envelope.kind !== MICROVERTICAL_RELEASE_ENVELOPE_KIND) throw new Error(`envelope.kind must be "${MICROVERTICAL_RELEASE_ENVELOPE_KIND}".`);
275
+ if (!Array.isArray(envelope.artifacts) || 0 === envelope.artifacts.length) throw new Error('envelope.artifacts must contain at least one artifact.');
276
+ const artifacts = envelope.artifacts.map((artifact, index)=>assertReleaseArtifact(artifact, `envelope.artifacts[${index}]`));
277
+ assertUniqueSortedArtifacts(artifacts, 'envelope.artifacts');
278
+ const target = assertTarget(envelope.target, 'envelope.target');
279
+ const surfaces = assertSurfaces(envelope.surfaces);
280
+ assertSurfaceReferences(artifacts, surfaces);
281
+ assertTargetSurfaceContract(target, artifacts, surfaces);
282
+ const parsed = {
283
+ schemaVersion: MICROVERTICAL_RELEASE_ENVELOPE_SCHEMA_VERSION,
284
+ kind: MICROVERTICAL_RELEASE_ENVELOPE_KIND,
285
+ target,
286
+ identity: assertReleaseIdentity(envelope.identity, 'envelope.identity'),
287
+ artifacts,
288
+ surfaces,
289
+ envelopeDigest: assertNonEmptyString(envelope.envelopeDigest, 'envelope.envelopeDigest')
290
+ };
291
+ if (!SHA256_PATTERN.test(parsed.envelopeDigest)) throw new Error('envelope.envelopeDigest must be a lowercase SHA-256 digest.');
292
+ const expectedDigest = digestMicroVerticalReleaseEnvelopePayload(releaseEnvelopePayload(parsed));
293
+ if (parsed.envelopeDigest !== expectedDigest) throw new Error('envelope.envelopeDigest does not match canonical payload.');
294
+ return parsed;
295
+ };
296
+ const createMicroVerticalReleaseEnvelope = async (input)=>{
297
+ const artifactRoot = await promises.realpath(node_path.resolve(input.artifactRoot));
298
+ const target = assertTarget(input.target);
299
+ const identity = assertReleaseIdentity(input.identity);
300
+ if (!Array.isArray(input.artifacts) || 0 === input.artifacts.length) throw new Error('artifacts must contain at least one artifact.');
301
+ const inputs = input.artifacts.map((artifact, index)=>assertArtifactInput(artifact, `artifacts[${index}]`));
302
+ const sortedInputs = [
303
+ ...inputs
304
+ ].sort((left, right)=>left.logicalPath.localeCompare(right.logicalPath));
305
+ assertUniqueSortedArtifacts(sortedInputs, 'artifacts');
306
+ const surfaces = assertSurfaces(input.surfaces);
307
+ assertSurfaceReferences(sortedInputs, surfaces);
308
+ assertTargetSurfaceContract(target, sortedInputs, surfaces);
309
+ const artifacts = await Promise.all(sortedInputs.map((artifact)=>readFinalArtifact(artifactRoot, artifact)));
310
+ assertTargetSurfaceContract(target, artifacts, surfaces);
311
+ const payload = {
312
+ schemaVersion: MICROVERTICAL_RELEASE_ENVELOPE_SCHEMA_VERSION,
313
+ kind: MICROVERTICAL_RELEASE_ENVELOPE_KIND,
314
+ target,
315
+ identity,
316
+ artifacts,
317
+ surfaces
318
+ };
319
+ return deepFreeze({
320
+ ...payload,
321
+ envelopeDigest: digestMicroVerticalReleaseEnvelopePayload(payload)
322
+ });
323
+ };
324
+ const verifyMicroVerticalReleaseEnvelope = async (value, options)=>{
325
+ const envelope = assertEnvelope(value);
326
+ if (void 0 !== options.expectedTarget && envelope.target !== options.expectedTarget) throw new Error(`envelope.target must be "${options.expectedTarget}" for this staging target; received "${envelope.target}".`);
327
+ const artifactRoot = await promises.realpath(node_path.resolve(options.artifactRoot));
328
+ for (const artifact of envelope.artifacts){
329
+ const finalArtifact = await readFinalArtifact(artifactRoot, artifact, options.logicalPathForArtifact?.(artifact) ?? artifact.logicalPath);
330
+ const matches = finalArtifact.kind === artifact.kind && ('file' === artifact.kind && 'file' === finalArtifact.kind ? finalArtifact.byteLength === artifact.byteLength && finalArtifact.sha256 === artifact.sha256 : 'symbolic-link' === artifact.kind && 'symbolic-link' === finalArtifact.kind && finalArtifact.linkTarget === artifact.linkTarget && finalArtifact.targetKind === artifact.targetKind && finalArtifact.targetLogicalPath === artifact.targetLogicalPath);
331
+ if (!matches) throw new Error('file' === artifact.kind && 'file' === finalArtifact.kind ? `Artifact "${artifact.logicalPath}" digest does not match final artifact bytes.` : `Artifact "${artifact.logicalPath}" does not match its final filesystem binding.`);
332
+ }
333
+ return deepFreeze(envelope);
334
+ };
335
+ export { MICROVERTICAL_RELEASE_ENVELOPE_KIND, MICROVERTICAL_RELEASE_ENVELOPE_SCHEMA_VERSION, MICROVERTICAL_RELEASE_TARGETS, canonicalSerializeMicroVerticalReleaseEnvelope, createMicroVerticalReleaseEnvelope, verifyMicroVerticalReleaseEnvelope };
@@ -0,0 +1,7 @@
1
+ const MICROVERTICAL_RELEASE_ENVELOPE_SCHEMA_VERSION = 3;
2
+ const MICROVERTICAL_RELEASE_ENVELOPE_KIND = 'ultramodern-target-microvertical-release-envelope';
3
+ const MICROVERTICAL_RELEASE_TARGETS = [
4
+ 'node',
5
+ 'cloudflare'
6
+ ];
7
+ export { MICROVERTICAL_RELEASE_ENVELOPE_KIND, MICROVERTICAL_RELEASE_ENVELOPE_SCHEMA_VERSION, MICROVERTICAL_RELEASE_TARGETS };
@@ -0,0 +1,66 @@
1
+ import { execFileSync } from "node:child_process";
2
+ import { createHash } from "node:crypto";
3
+ const BUILD_MARKER_NAMESPACE = 'ultramodern-delivery-unit-release-build-marker:v1';
4
+ const PROMOTABLE_SOURCE_REVISION_PATTERN = /^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u;
5
+ const gitOutput = (workspaceRoot, args)=>{
6
+ try {
7
+ return execFileSync('git', [
8
+ '-C',
9
+ workspaceRoot,
10
+ ...args
11
+ ], {
12
+ encoding: 'utf8',
13
+ stdio: [
14
+ 'ignore',
15
+ 'pipe',
16
+ 'ignore'
17
+ ]
18
+ }).trim();
19
+ } catch {
20
+ return;
21
+ }
22
+ };
23
+ const createUltramodernReleaseBuildMarker = ({ generationBuildMarker, sourceRevision, unitId })=>createHash('sha256').update(`${BUILD_MARKER_NAMESPACE}:${unitId}:${generationBuildMarker}:${sourceRevision}`).digest('hex').slice(0, 16);
24
+ const resolveUltramodernSourceRevision = (workspaceRoot = process.cwd(), configuredSourceRevision)=>{
25
+ const configuredArgumentValue = configuredSourceRevision?.trim();
26
+ const configuredEnvironmentValue = process.env.ULTRAMODERN_SOURCE_REVISION?.trim();
27
+ const configuredArgument = configuredArgumentValue && 'workspace' !== configuredArgumentValue ? configuredArgumentValue : void 0;
28
+ const configuredEnvironment = configuredEnvironmentValue && 'workspace' !== configuredEnvironmentValue ? configuredEnvironmentValue : void 0;
29
+ if (configuredArgument && configuredEnvironment && configuredArgument !== configuredEnvironment) throw new Error(`Configured source revision ${configuredArgument} does not match environment source revision ${configuredEnvironment}.`);
30
+ const configured = configuredArgument ?? configuredEnvironment;
31
+ const gitRoot = gitOutput(workspaceRoot, [
32
+ 'rev-parse',
33
+ '--show-toplevel'
34
+ ]);
35
+ if (!gitRoot) {
36
+ if (!configured) return 'workspace';
37
+ if (!PROMOTABLE_SOURCE_REVISION_PATTERN.test(configured)) throw new Error(`Configured source revision ${configured} must be an exact lowercase 40- or 64-character Git object ID.`);
38
+ return configured;
39
+ }
40
+ const revision = gitOutput(gitRoot, [
41
+ 'rev-parse',
42
+ 'HEAD'
43
+ ]);
44
+ const status = gitOutput(gitRoot, [
45
+ 'status',
46
+ '--porcelain=v1',
47
+ '--untracked-files=all'
48
+ ]);
49
+ if (!revision || void 0 === status || status.length > 0) return 'workspace';
50
+ if (!PROMOTABLE_SOURCE_REVISION_PATTERN.test(revision)) return 'workspace';
51
+ if (configured && configured !== revision) throw new Error(`Configured source revision ${configured} does not match clean Git HEAD ${revision}.`);
52
+ return revision;
53
+ };
54
+ const resolveUltramodernReleaseIdentity = ({ generationBuildMarker, sourceRevision: configuredSourceRevision, unitId, workspaceRoot })=>{
55
+ const explicitSourceRevision = configuredSourceRevision?.trim();
56
+ const sourceRevision = resolveUltramodernSourceRevision(workspaceRoot, explicitSourceRevision);
57
+ return {
58
+ buildMarker: 'workspace' === sourceRevision ? generationBuildMarker : createUltramodernReleaseBuildMarker({
59
+ generationBuildMarker,
60
+ sourceRevision,
61
+ unitId
62
+ }),
63
+ sourceRevision
64
+ };
65
+ };
66
+ export { createUltramodernReleaseBuildMarker, resolveUltramodernReleaseIdentity, resolveUltramodernSourceRevision };
@@ -4,6 +4,7 @@ import node_fs from "node:fs";
4
4
  import node_path from "node:path";
5
5
  import { SERVICE_WORKER_ENVIRONMENT_NAME } from "@modern-js/builder";
6
6
  import { isProd, isSSR, isServiceWorker, isUseRsc, isUseSSRBundle } from "@modern-js/utils";
7
+ import { CLOUDFLARE_WORKER_NODE_BUILTINS } from "../../plugins/deploy/platforms/cloudflare-output-contract.mjs";
7
8
  import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
8
9
  import { dirname as __rspack_dirname } from "node:path";
9
10
  var __rspack_import_meta_dirname__ = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
@@ -19,20 +20,6 @@ const JS_OR_TS_EXTS = [
19
20
  '.cjs',
20
21
  '.cts'
21
22
  ];
22
- const CLOUDFLARE_WORKER_NODE_BUILTINS = [
23
- 'async_hooks',
24
- 'buffer',
25
- 'crypto',
26
- 'events',
27
- 'fs/promises',
28
- 'module',
29
- 'path',
30
- 'process',
31
- 'stream',
32
- 'string_decoder',
33
- 'url',
34
- 'util'
35
- ];
36
23
  const CLOUDFLARE_WORKER_COMPAT_TEMPLATE_DIR = node_path.resolve(__rspack_import_meta_dirname__, '../../plugins/deploy/platforms/templates');
37
24
  function findExistingFile(candidates) {
38
25
  return candidates.find((candidate)=>node_fs.existsSync(candidate));
@@ -263,7 +250,17 @@ function getBuilderEnvironments(normalizedConfig, appContext, tempBuilderConfig)
263
250
  });
264
251
  chain.output.module(true).library({
265
252
  type: 'module'
266
- }).chunkFormat('module').chunkLoading('import').workerChunkLoading('import');
253
+ }).publicPath('/').chunkFormat('module').chunkLoading('import').workerChunkLoading('import');
254
+ chain.optimization.usedExports(false).providedExports(true).innerGraph(false).sideEffects(false);
255
+ for (const condition of [
256
+ 'workerd',
257
+ 'worker',
258
+ 'webpack',
259
+ isProd() ? 'production' : 'development',
260
+ 'import',
261
+ 'require',
262
+ 'module'
263
+ ])chain.resolve.conditionNames.add(condition);
267
264
  chain.plugins.delete('plugin-module-federation');
268
265
  if (tanstackRouterSsrServerFile) {
269
266
  chain.resolve.alias.set('@tanstack/router-core/ssr/server$', tanstackRouterSsrServerFile);
@@ -31,10 +31,19 @@ const mergeCompressionOptions = (base, next)=>{
31
31
  ...base,
32
32
  ...next
33
33
  };
34
- if (base.compressionOptions || next.compressionOptions) merged.compressionOptions = {
35
- ...base.compressionOptions,
36
- ...next.compressionOptions
37
- };
34
+ if (base.compressionOptions || next.compressionOptions) {
35
+ const baseCompressionOptions = base.compressionOptions;
36
+ const nextCompressionOptions = next.compressionOptions;
37
+ const mergedCompressionOptions = {
38
+ ...baseCompressionOptions,
39
+ ...nextCompressionOptions
40
+ };
41
+ if (baseCompressionOptions?.params || nextCompressionOptions?.params) mergedCompressionOptions.params = {
42
+ ...baseCompressionOptions?.params,
43
+ ...nextCompressionOptions?.params
44
+ };
45
+ merged.compressionOptions = mergedCompressionOptions;
46
+ }
38
47
  return merged;
39
48
  };
40
49
  const resolveCodecOptions = (codecConfig, createDefaultOptions)=>{
@@ -4,7 +4,7 @@ import { SERVICE_WORKER_ENVIRONMENT_NAME, isHtmlDisabled } from "@modern-js/buil
4
4
  import { fs, isUseRsc, isUseSSRBundle } from "@modern-js/utils";
5
5
  import { mergeRsbuildConfig } from "@rsbuild/core";
6
6
  import { getServerCombinedModuleFile } from "../../../plugins/analyze/utils.mjs";
7
- import { HtmlAsyncChunkPlugin, RouterPlugin } from "../bundlerPlugins/index.mjs";
7
+ import { CssExtractRuntimePlugin, HtmlAsyncChunkPlugin, RouterPlugin } from "../bundlerPlugins/index.mjs";
8
8
  import * as __rspack_external_path from "path";
9
9
  const builderPluginAdapterSSR = (options)=>({
10
10
  name: 'builder-plugin-adapter-modern-ssr',
@@ -65,17 +65,20 @@ function applyRouterPlugin(chain, pluginName, options, HtmlBundlerPlugin) {
65
65
  const workerSSR = Boolean(normalizedConfig.deploy.worker?.ssr);
66
66
  const { enableInlineRouteManifests, disableInlineRouteManifests } = normalizedConfig.output;
67
67
  const inlineRouteManifests = disableInlineRouteManifests ? !disableInlineRouteManifests : enableInlineRouteManifests;
68
- if (existNestedRoutes || workerSSR) chain.plugin(pluginName).use(RouterPlugin, [
69
- {
70
- HtmlBundlerPlugin,
71
- enableInlineRouteManifests: inlineRouteManifests,
72
- staticJsDir: normalizedConfig.output?.distPath?.js,
73
- disableFilenameHash: normalizedConfig.output?.filenameHash === false,
74
- scriptLoading: normalizedConfig.html?.scriptLoading,
75
- nonce: normalizedConfig.security?.nonce,
76
- useRsc: isUseRsc(normalizedConfig)
77
- }
78
- ]);
68
+ if (existNestedRoutes || workerSSR) {
69
+ chain.plugin(`${pluginName}-css-extract-runtime`).use(CssExtractRuntimePlugin);
70
+ chain.plugin(pluginName).use(RouterPlugin, [
71
+ {
72
+ HtmlBundlerPlugin,
73
+ enableInlineRouteManifests: inlineRouteManifests,
74
+ staticJsDir: normalizedConfig.output?.distPath?.js,
75
+ disableFilenameHash: normalizedConfig.output?.filenameHash === false,
76
+ scriptLoading: normalizedConfig.html?.scriptLoading,
77
+ nonce: normalizedConfig.security?.nonce,
78
+ useRsc: isUseRsc(normalizedConfig)
79
+ }
80
+ ]);
81
+ }
79
82
  }
80
83
  function applyFilterEntriesBySSRConfig({ isProd, chain, appNormalizedConfig }) {
81
84
  const { server: serverConfig, output: outputConfig } = appNormalizedConfig;
@@ -0,0 +1,31 @@
1
+ import "node:module";
2
+ const PLUGIN_NAME = 'ModernjsCssExtractRuntimePlugin';
3
+ const CSS_LOADING_RUNTIME_MODULE = 'webpack/runtime/css loading';
4
+ const CSS_EXTRACT_STYLESHEET_MATCH = '\t\tif (tag.rel === "stylesheet" && (dataHref === href || dataHref === fullhref)) return tag;';
5
+ const CSS_EXTRACT_STYLESHEET_MATCH_WITH_NORMALIZED_URL = `\t\tvar absoluteHref = tag.href;
6
+ \t\tvar absoluteFullHref = new URL(fullhref, document.baseURI).href;
7
+ \t\tif (tag.rel === "stylesheet" && (dataHref === href || dataHref === fullhref || absoluteHref === absoluteFullHref)) return tag;`;
8
+ const isAutomaticPublicPath = (publicPath)=>'auto' === publicPath || 'auto/' === publicPath;
9
+ const normalizeCssExtractRuntimeStylesheetLookup = (source)=>{
10
+ if (!source.includes('__webpack_require__.miniCssF')) return source;
11
+ const occurrences = source.split(CSS_EXTRACT_STYLESHEET_MATCH).length - 1;
12
+ if (1 !== occurrences) throw new Error(`Unsupported CssExtractRspackPlugin runtime shape: expected one stylesheet lookup, found ${occurrences}.`);
13
+ return source.replace(CSS_EXTRACT_STYLESHEET_MATCH, CSS_EXTRACT_STYLESHEET_MATCH_WITH_NORMALIZED_URL);
14
+ };
15
+ class CssExtractRuntimePlugin {
16
+ apply(compiler) {
17
+ if (!isAutomaticPublicPath(compiler.options.output.publicPath)) return;
18
+ compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation)=>{
19
+ compilation.hooks.runtimeModule.tap(PLUGIN_NAME, (runtimeModule)=>{
20
+ if (runtimeModule.identifier() !== CSS_LOADING_RUNTIME_MODULE) return;
21
+ const runtimeSource = runtimeModule.source?.source;
22
+ if ('string' != typeof runtimeSource) return;
23
+ runtimeModule.source.source = normalizeCssExtractRuntimeStylesheetLookup(runtimeSource);
24
+ });
25
+ });
26
+ }
27
+ constructor(){
28
+ this.name = PLUGIN_NAME;
29
+ }
30
+ }
31
+ export { CssExtractRuntimePlugin, normalizeCssExtractRuntimeStylesheetLookup };
@@ -5,6 +5,13 @@ import { ROUTE_MANIFEST } from "@modern-js/utils/universal/constants";
5
5
  import { createHash } from "crypto";
6
6
  const PLUGIN_NAME = 'ModernjsRoutePlugin';
7
7
  const generateContentHash = (content)=>createHash('md5').update(content).digest('hex').slice(0, 8);
8
+ const isAutomaticPublicPath = (publicPath)=>'auto' === publicPath || 'auto/' === publicPath;
9
+ const normalizeAutomaticHtmlAsset = (asset)=>asset.startsWith('auto/') ? `/${asset.slice(5)}` : asset;
10
+ const normalizeRouterAssetPublicPath = (publicPath)=>{
11
+ if (!publicPath) return '';
12
+ if (isAutomaticPublicPath(publicPath)) return '/';
13
+ return publicPath.endsWith('/') ? publicPath : `${publicPath}/`;
14
+ };
8
15
  class RouterPlugin {
9
16
  isTargetNodeOrWebWorker(target) {
10
17
  if ('node' === target || Array.isArray(target) && target.includes('node')) return true;
@@ -30,15 +37,21 @@ class RouterPlugin {
30
37
  const { rspack } = compiler;
31
38
  const { Compilation, sources } = rspack;
32
39
  const { RawSource } = sources;
33
- const normalizePath = (path)=>{
34
- if (!path.endsWith('/')) return `${path}/`;
35
- return path;
36
- };
37
40
  const chunksToHtmlName = new Map();
38
41
  const ROUTE_MANIFEST_HOLDER = "route-manifest";
39
42
  const placeholder = `<!--<?- ${ROUTE_MANIFEST_HOLDER} ?>-->`;
40
43
  compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation)=>{
41
- this.HtmlBundlerPlugin.getCompilationHooks(compilation).beforeEmit.tapAsync('RouterManifestPlugin', (data, callback)=>{
44
+ const htmlPluginHooks = this.HtmlBundlerPlugin.getCompilationHooks(compilation);
45
+ htmlPluginHooks.beforeAssetTagGeneration.tapAsync('RouterManifestPlugin', (data, callback)=>{
46
+ if (isAutomaticPublicPath(compiler.options.output.publicPath)) {
47
+ data.assets.publicPath = '/';
48
+ data.assets.js = data.assets.js.map(normalizeAutomaticHtmlAsset);
49
+ data.assets.css = data.assets.css.map(normalizeAutomaticHtmlAsset);
50
+ if (data.assets.favicon) data.assets.favicon = normalizeAutomaticHtmlAsset(data.assets.favicon);
51
+ }
52
+ callback(null, data);
53
+ });
54
+ htmlPluginHooks.beforeEmit.tapAsync('RouterManifestPlugin', (data, callback)=>{
42
55
  const { outputName } = data;
43
56
  const { chunks } = data.plugin.options;
44
57
  chunksToHtmlName.set(chunks, outputName);
@@ -58,6 +71,7 @@ class RouterPlugin {
58
71
  ids: true
59
72
  });
60
73
  const { publicPath, chunks = [], namedChunkGroups } = stats;
74
+ const assetPublicPath = normalizeRouterAssetPublicPath(publicPath);
61
75
  const routeAssets = {};
62
76
  if (!namedChunkGroups) return;
63
77
  const prevManifestAsset = compilation.getAsset(ROUTE_MANIFEST_FILE);
@@ -79,7 +93,7 @@ class RouterPlugin {
79
93
  const child = stack.pop();
80
94
  if (visited.has(child)) continue;
81
95
  visited.add(child);
82
- for (const chunk of child.chunks)for (const file of chunk.files)if (/\.css$/.test(file)) cssFiles.add(publicPath ? normalizePath(publicPath) + file : file);
96
+ for (const chunk of child.chunks)for (const file of chunk.files)if (/\.css$/.test(file)) cssFiles.add(assetPublicPath + file);
83
97
  for (const c of child.childrenIterable)stack.push(c);
84
98
  }
85
99
  return Array.from(cssFiles);
@@ -89,7 +103,7 @@ class RouterPlugin {
89
103
  if (name.startsWith('async-')) asyncEntryNames.push(name);
90
104
  const assets = chunkGroup.assets.map((asset)=>{
91
105
  const filename = asset.name;
92
- return publicPath ? normalizePath(publicPath) + filename : filename;
106
+ return assetPublicPath + filename;
93
107
  });
94
108
  const directCssAssets = assets.filter((asset)=>/\.css$/.test(asset));
95
109
  const descendantCssAssets = collectDescendantCssAssets(name).filter((asset)=>!directCssAssets.includes(asset));
@@ -144,7 +158,7 @@ class RouterPlugin {
144
158
  window.${ROUTE_MANIFEST} = ${JSON.stringify(manifest, (k, v)=>{
145
159
  if (('assets' === k || 'referenceCssAssets' === k) && Array.isArray(v)) {
146
160
  if (!useRsc) return;
147
- return v.map((item)=>item.replace(publicPath, ''));
161
+ return v.map((item)=>assetPublicPath ? item.replace(assetPublicPath, '') : item);
148
162
  }
149
163
  return v;
150
164
  })};
@@ -161,7 +175,7 @@ class RouterPlugin {
161
175
  if (oldHtml) if (enableInlineRouteManifests) compilation.updateAsset(htmlName, new RawSource(oldHtml.source().toString().replace(placeholder, `<script ${nonceAttr}>${injectedContent}</script>`)), void 0);
162
176
  else {
163
177
  const scriptPath = `${staticJsDir}/${ROUTE_MANIFEST_HOLDER}-${entryName}${disableFilenameHash ? '.js' : `.${generateContentHash(injectedContent)}.js`}`;
164
- const scriptUrl = `${publicPath}${scriptPath}`;
178
+ const scriptUrl = `${assetPublicPath}${scriptPath}`;
165
179
  const scriptLoadingAttr = 'defer' === scriptLoading ? scriptLoading : 'module' === scriptLoading ? 'type="module"' : '';
166
180
  const script = `<script ${scriptLoadingAttr} ${nonceAttr} src="${scriptUrl}"></script>`;
167
181
  compilation.updateAsset(htmlName, new RawSource(oldHtml.source().toString().replace(placeholder, script)), void 0);
@@ -184,4 +198,4 @@ class RouterPlugin {
184
198
  this.useRsc = useRsc;
185
199
  }
186
200
  }
187
- export { RouterPlugin };
201
+ export { RouterPlugin, normalizeRouterAssetPublicPath };
@@ -1,4 +1,5 @@
1
1
  import "node:module";
2
+ export * from "./CssExtractRuntimePlugin.mjs";
2
3
  export * from "./HtmlAsyncChunkPlugin.mjs";
3
4
  export * from "./HtmlBottomTemplate.mjs";
4
5
  export * from "./RouterPlugin.mjs";