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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (258) hide show
  1. package/bin/modern.js +0 -0
  2. package/dist/cjs/builder/generator/getBuilderEnvironments.js +13 -16
  3. package/dist/cjs/builder/shared/builderPlugins/adapterPrecompress.js +13 -4
  4. package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +14 -11
  5. package/dist/cjs/builder/shared/bundlerPlugins/CssExtractRuntimePlugin.js +72 -0
  6. package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +28 -11
  7. package/dist/cjs/builder/shared/bundlerPlugins/index.js +13 -6
  8. package/dist/cjs/builder/shared/lazyCompilation.js +2 -10
  9. package/dist/cjs/commands/index.js +0 -4
  10. package/dist/cjs/config/build-environment.js +268 -0
  11. package/dist/cjs/config/index.js +11 -4
  12. package/dist/cjs/config/public.js +46 -0
  13. package/dist/cjs/index.js +39 -62
  14. package/dist/cjs/plugins/analyze/getServerRoutes.js +19 -0
  15. package/dist/cjs/plugins/analyze/index.js +20 -12
  16. package/dist/cjs/plugins/backend-federation/codegen.js +255 -0
  17. package/dist/cjs/plugins/backend-federation/config.js +204 -0
  18. package/dist/cjs/plugins/backend-federation/emit.js +148 -0
  19. package/dist/cjs/plugins/backendFederationBuild.js +53 -0
  20. package/dist/cjs/plugins/deploy/index.js +4 -4
  21. package/dist/cjs/plugins/deploy/platforms/cloudflare/artifacts.js +127 -0
  22. package/dist/cjs/plugins/deploy/platforms/cloudflare/constants.js +141 -0
  23. package/dist/cjs/plugins/deploy/platforms/cloudflare/delivery-unit.js +139 -0
  24. package/dist/cjs/plugins/deploy/platforms/cloudflare/i18n-worker.js +135 -0
  25. package/dist/cjs/plugins/deploy/platforms/cloudflare/index.js +150 -0
  26. package/dist/cjs/plugins/deploy/platforms/cloudflare/security-policies.js +205 -0
  27. package/dist/cjs/plugins/deploy/platforms/cloudflare/types.js +18 -0
  28. package/dist/cjs/plugins/deploy/platforms/cloudflare/utils.js +66 -0
  29. package/dist/cjs/plugins/deploy/platforms/cloudflare/worker-manifest.js +208 -0
  30. package/dist/cjs/plugins/deploy/platforms/cloudflare/wrangler-config.js +204 -0
  31. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-contract.js +108 -0
  32. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-plan.js +93 -0
  33. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/identity.js +83 -0
  34. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/index.js +188 -0
  35. package/dist/cjs/{baseline.js → plugins/deploy/platforms/cloudflare-output-verifier/issues.js} +19 -10
  36. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/manifest.js +89 -0
  37. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.js +151 -0
  38. package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.js +302 -0
  39. package/dist/cjs/plugins/deploy/platforms/node.js +20 -2
  40. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.mjs +250 -0
  41. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.mjs +191 -0
  42. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.mjs +514 -0
  43. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.mjs +1012 -0
  44. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.mjs +363 -0
  45. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.006-fetch-handler.mjs +93 -0
  46. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-worker-fs-promises.mjs +8 -4
  47. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-worker-loadable-server.mjs +251 -155
  48. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-worker-path.mjs +78 -39
  49. package/dist/cjs/plugins/deploy/platforms/templates/netlify-entry.cjs +62 -41
  50. package/dist/cjs/plugins/deploy/platforms/templates/netlify-entry.mjs +63 -41
  51. package/dist/cjs/plugins/deploy/platforms/templates/node-entry.cjs +52 -35
  52. package/dist/cjs/plugins/deploy/platforms/templates/node-entry.mjs +53 -35
  53. package/dist/cjs/plugins/deploy/platforms/templates/vercel-entry.cjs +61 -41
  54. package/dist/cjs/plugins/deploy/platforms/templates/vercel-entry.mjs +61 -40
  55. package/dist/cjs/plugins/deploy/utils/npmAliases.js +226 -0
  56. package/dist/cjs/plugins/ultramodernReleaseEnvelope.js +100 -0
  57. package/dist/cjs/presetUltramodern.js +33 -2
  58. package/dist/cjs/ultramodern-release-envelope/canonical.js +68 -0
  59. package/dist/cjs/ultramodern-release-envelope/framework-output.js +597 -0
  60. package/dist/cjs/ultramodern-release-envelope/index.js +399 -0
  61. package/dist/cjs/ultramodern-release-envelope/types.js +51 -0
  62. package/dist/cjs/ultramodern-release-identity.js +110 -0
  63. package/dist/esm/builder/generator/getBuilderEnvironments.mjs +12 -15
  64. package/dist/esm/builder/shared/builderPlugins/adapterPrecompress.mjs +13 -4
  65. package/dist/esm/builder/shared/builderPlugins/adapterSSR.mjs +15 -12
  66. package/dist/esm/builder/shared/bundlerPlugins/CssExtractRuntimePlugin.mjs +30 -0
  67. package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.mjs +24 -10
  68. package/dist/esm/builder/shared/bundlerPlugins/index.mjs +1 -0
  69. package/dist/esm/builder/shared/lazyCompilation.mjs +1 -3
  70. package/dist/esm/commands/index.mjs +0 -1
  71. package/dist/esm/config/build-environment.mjs +224 -0
  72. package/dist/esm/config/index.mjs +1 -0
  73. package/dist/esm/config/public.mjs +1 -0
  74. package/dist/esm/index.mjs +5 -4
  75. package/dist/esm/plugins/analyze/getHtmlTemplate.mjs +2 -2
  76. package/dist/esm/plugins/analyze/getServerRoutes.mjs +17 -1
  77. package/dist/esm/plugins/analyze/index.mjs +20 -12
  78. package/dist/esm/plugins/analyze/isDefaultExportFunction.mjs +2 -2
  79. package/dist/esm/plugins/backend-federation/codegen.mjs +204 -0
  80. package/dist/esm/plugins/backend-federation/config.mjs +128 -0
  81. package/dist/esm/plugins/backend-federation/emit.mjs +97 -0
  82. package/dist/esm/plugins/backendFederationBuild.mjs +1 -0
  83. package/dist/esm/plugins/deploy/index.mjs +1 -1
  84. package/dist/esm/plugins/deploy/platforms/cloudflare/artifacts.mjs +64 -0
  85. package/dist/esm/plugins/deploy/platforms/cloudflare/constants.mjs +34 -0
  86. package/dist/esm/plugins/deploy/platforms/cloudflare/delivery-unit.mjs +88 -0
  87. package/dist/esm/plugins/deploy/platforms/cloudflare/i18n-worker.mjs +97 -0
  88. package/dist/esm/plugins/deploy/platforms/cloudflare/index.mjs +102 -0
  89. package/dist/esm/plugins/deploy/platforms/cloudflare/security-policies.mjs +167 -0
  90. package/dist/esm/plugins/deploy/platforms/cloudflare/types.mjs +0 -0
  91. package/dist/esm/plugins/deploy/platforms/cloudflare/utils.mjs +12 -0
  92. package/dist/esm/plugins/deploy/platforms/cloudflare/worker-manifest.mjs +148 -0
  93. package/dist/esm/plugins/deploy/platforms/cloudflare/wrangler-config.mjs +150 -0
  94. package/dist/esm/plugins/deploy/platforms/cloudflare-output-contract.mjs +31 -0
  95. package/dist/esm/plugins/deploy/platforms/cloudflare-output-plan.mjs +45 -0
  96. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/identity.mjs +45 -0
  97. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/index.mjs +133 -0
  98. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/issues.mjs +10 -0
  99. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/manifest.mjs +51 -0
  100. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.mjs +99 -0
  101. package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.mjs +238 -0
  102. package/dist/esm/plugins/deploy/platforms/node.mjs +20 -2
  103. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.mjs +250 -0
  104. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.mjs +191 -0
  105. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.mjs +514 -0
  106. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.mjs +1012 -0
  107. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.mjs +363 -0
  108. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.006-fetch-handler.mjs +93 -0
  109. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-worker-fs-promises.mjs +8 -4
  110. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-worker-loadable-server.mjs +251 -155
  111. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-worker-path.mjs +78 -39
  112. package/dist/esm/plugins/deploy/platforms/templates/netlify-entry.cjs +62 -41
  113. package/dist/esm/plugins/deploy/platforms/templates/netlify-entry.mjs +63 -41
  114. package/dist/esm/plugins/deploy/platforms/templates/node-entry.cjs +52 -35
  115. package/dist/esm/plugins/deploy/platforms/templates/node-entry.mjs +53 -35
  116. package/dist/esm/plugins/deploy/platforms/templates/vercel-entry.cjs +61 -41
  117. package/dist/esm/plugins/deploy/platforms/templates/vercel-entry.mjs +61 -40
  118. package/dist/esm/plugins/deploy/utils/npmAliases.mjs +174 -0
  119. package/dist/esm/plugins/ultramodernReleaseEnvelope.mjs +52 -0
  120. package/dist/esm/presetUltramodern.mjs +33 -2
  121. package/dist/esm/ultramodern-release-envelope/canonical.mjs +21 -0
  122. package/dist/esm/ultramodern-release-envelope/framework-output.mjs +524 -0
  123. package/dist/esm/ultramodern-release-envelope/index.mjs +335 -0
  124. package/dist/esm/ultramodern-release-envelope/types.mjs +7 -0
  125. package/dist/esm/ultramodern-release-identity.mjs +66 -0
  126. package/dist/esm-node/builder/generator/getBuilderEnvironments.mjs +12 -15
  127. package/dist/esm-node/builder/shared/builderPlugins/adapterPrecompress.mjs +13 -4
  128. package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.mjs +15 -12
  129. package/dist/esm-node/builder/shared/bundlerPlugins/CssExtractRuntimePlugin.mjs +31 -0
  130. package/dist/esm-node/builder/shared/bundlerPlugins/RouterPlugin.mjs +24 -10
  131. package/dist/esm-node/builder/shared/bundlerPlugins/index.mjs +1 -0
  132. package/dist/esm-node/builder/shared/lazyCompilation.mjs +1 -3
  133. package/dist/esm-node/commands/index.mjs +0 -1
  134. package/dist/esm-node/config/build-environment.mjs +225 -0
  135. package/dist/esm-node/config/index.mjs +1 -0
  136. package/dist/esm-node/config/public.mjs +2 -0
  137. package/dist/esm-node/index.mjs +5 -4
  138. package/dist/esm-node/plugins/analyze/getHtmlTemplate.mjs +2 -2
  139. package/dist/esm-node/plugins/analyze/getServerRoutes.mjs +17 -1
  140. package/dist/esm-node/plugins/analyze/index.mjs +20 -12
  141. package/dist/esm-node/plugins/analyze/isDefaultExportFunction.mjs +2 -2
  142. package/dist/esm-node/plugins/backend-federation/codegen.mjs +205 -0
  143. package/dist/esm-node/plugins/backend-federation/config.mjs +129 -0
  144. package/dist/esm-node/plugins/backend-federation/emit.mjs +98 -0
  145. package/dist/esm-node/plugins/backendFederationBuild.mjs +2 -0
  146. package/dist/esm-node/plugins/deploy/index.mjs +1 -1
  147. package/dist/esm-node/plugins/deploy/platforms/cloudflare/artifacts.mjs +65 -0
  148. package/dist/esm-node/plugins/deploy/platforms/cloudflare/constants.mjs +35 -0
  149. package/dist/esm-node/plugins/deploy/platforms/cloudflare/delivery-unit.mjs +89 -0
  150. package/dist/esm-node/plugins/deploy/platforms/cloudflare/i18n-worker.mjs +98 -0
  151. package/dist/esm-node/plugins/deploy/platforms/cloudflare/index.mjs +103 -0
  152. package/dist/esm-node/plugins/deploy/platforms/cloudflare/security-policies.mjs +168 -0
  153. package/dist/esm-node/plugins/deploy/platforms/cloudflare/types.mjs +1 -0
  154. package/dist/esm-node/plugins/deploy/platforms/cloudflare/utils.mjs +13 -0
  155. package/dist/esm-node/plugins/deploy/platforms/cloudflare/worker-manifest.mjs +149 -0
  156. package/dist/esm-node/plugins/deploy/platforms/cloudflare/wrangler-config.mjs +151 -0
  157. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-contract.mjs +32 -0
  158. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-plan.mjs +46 -0
  159. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/identity.mjs +46 -0
  160. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/index.mjs +134 -0
  161. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/issues.mjs +11 -0
  162. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/manifest.mjs +52 -0
  163. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.mjs +100 -0
  164. package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.mjs +239 -0
  165. package/dist/esm-node/plugins/deploy/platforms/node.mjs +20 -2
  166. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.mjs +250 -0
  167. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.mjs +191 -0
  168. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.mjs +514 -0
  169. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.mjs +1012 -0
  170. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.mjs +363 -0
  171. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.006-fetch-handler.mjs +93 -0
  172. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-worker-fs-promises.mjs +8 -4
  173. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-worker-loadable-server.mjs +251 -155
  174. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-worker-path.mjs +78 -39
  175. package/dist/esm-node/plugins/deploy/platforms/templates/netlify-entry.cjs +62 -41
  176. package/dist/esm-node/plugins/deploy/platforms/templates/netlify-entry.mjs +63 -41
  177. package/dist/esm-node/plugins/deploy/platforms/templates/node-entry.cjs +52 -35
  178. package/dist/esm-node/plugins/deploy/platforms/templates/node-entry.mjs +53 -35
  179. package/dist/esm-node/plugins/deploy/platforms/templates/vercel-entry.cjs +61 -41
  180. package/dist/esm-node/plugins/deploy/platforms/templates/vercel-entry.mjs +61 -40
  181. package/dist/esm-node/plugins/deploy/utils/npmAliases.mjs +175 -0
  182. package/dist/esm-node/plugins/ultramodernReleaseEnvelope.mjs +53 -0
  183. package/dist/esm-node/presetUltramodern.mjs +33 -2
  184. package/dist/esm-node/ultramodern-release-envelope/canonical.mjs +22 -0
  185. package/dist/esm-node/ultramodern-release-envelope/framework-output.mjs +525 -0
  186. package/dist/esm-node/ultramodern-release-envelope/index.mjs +336 -0
  187. package/dist/esm-node/ultramodern-release-envelope/types.mjs +8 -0
  188. package/dist/esm-node/ultramodern-release-identity.mjs +67 -0
  189. package/dist/types/builder/generator/createCopyPattern.d.ts +7 -5
  190. package/dist/types/builder/shared/bundlerPlugins/CssExtractRuntimePlugin.d.ts +6 -0
  191. package/dist/types/builder/shared/bundlerPlugins/RouterPlugin.d.ts +1 -0
  192. package/dist/types/builder/shared/bundlerPlugins/index.d.ts +1 -0
  193. package/dist/types/builder/shared/lazyCompilation.d.ts +2 -4
  194. package/dist/types/commands/index.d.ts +0 -1
  195. package/dist/types/config/build-environment.d.ts +22 -0
  196. package/dist/types/config/index.d.ts +1 -0
  197. package/dist/types/config/public.d.ts +2 -0
  198. package/dist/types/index.d.ts +0 -2
  199. package/dist/types/plugins/analyze/getServerRoutes.d.ts +1 -0
  200. package/dist/types/plugins/backend-federation/codegen.d.ts +83 -0
  201. package/dist/types/plugins/backend-federation/config.d.ts +103 -0
  202. package/dist/types/plugins/backend-federation/emit.d.ts +13 -0
  203. package/dist/types/plugins/backendFederationBuild.d.ts +2 -0
  204. package/dist/types/plugins/deploy/platforms/cloudflare/artifacts.d.ts +15 -0
  205. package/dist/types/plugins/deploy/platforms/cloudflare/constants.d.ts +24 -0
  206. package/dist/types/plugins/deploy/platforms/cloudflare/delivery-unit.d.ts +23 -0
  207. package/dist/types/plugins/deploy/platforms/cloudflare/i18n-worker.d.ts +22 -0
  208. package/dist/types/plugins/deploy/platforms/{cloudflare.d.ts → cloudflare/index.d.ts} +1 -1
  209. package/dist/types/plugins/deploy/platforms/cloudflare/security-policies.d.ts +51 -0
  210. package/dist/types/plugins/deploy/platforms/cloudflare/types.d.ts +5 -0
  211. package/dist/types/plugins/deploy/platforms/cloudflare/utils.d.ts +6 -0
  212. package/dist/types/plugins/deploy/platforms/cloudflare/worker-manifest.d.ts +122 -0
  213. package/dist/types/plugins/deploy/platforms/cloudflare/wrangler-config.d.ts +46 -0
  214. package/dist/types/plugins/deploy/platforms/cloudflare-output-contract.d.ts +14 -0
  215. package/dist/types/plugins/deploy/platforms/cloudflare-output-plan.d.ts +34 -0
  216. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/identity.d.ts +4 -0
  217. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/index.d.ts +18 -0
  218. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/issues.d.ts +14 -0
  219. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/manifest.d.ts +2 -0
  220. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/mutation-policy.d.ts +14 -0
  221. package/dist/types/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.d.ts +20 -0
  222. package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.d.mts +1 -0
  223. package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.002-assets-routes.d.mts +1 -0
  224. package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.003-i18n-locales.d.mts +1 -0
  225. package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.004-rendering-css.d.mts +1 -0
  226. package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.005-worker-dispatch.d.mts +1 -0
  227. package/dist/types/plugins/deploy/utils/npmAliases.d.ts +14 -0
  228. package/dist/types/plugins/ultramodernReleaseEnvelope.d.ts +3 -0
  229. package/dist/types/presetUltramodern.d.ts +10 -0
  230. package/dist/types/run/index.d.ts +1 -1
  231. package/dist/types/types/config/cloudflareDeploy.d.ts +41 -0
  232. package/dist/types/types/config/deploy.d.ts +15 -2
  233. package/dist/types/ultramodern-release-envelope/canonical.d.ts +5 -0
  234. package/dist/types/ultramodern-release-envelope/framework-output.d.ts +31 -0
  235. package/dist/types/ultramodern-release-envelope/index.d.ts +6 -0
  236. package/dist/types/ultramodern-release-envelope/types.d.ts +62 -0
  237. package/dist/types/ultramodern-release-identity.d.ts +16 -0
  238. package/lib/types.d.ts +2 -3
  239. package/package.json +38 -23
  240. package/rslib.config.mts +11 -12
  241. package/dist/cjs/commands/runtime.js +0 -196
  242. package/dist/cjs/plugins/deploy/platforms/cloudflare.js +0 -540
  243. package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.mjs +0 -576
  244. package/dist/cjs/ultramodern/designSystem.js +0 -123
  245. package/dist/esm/baseline.mjs +0 -4
  246. package/dist/esm/commands/runtime.mjs +0 -146
  247. package/dist/esm/plugins/deploy/platforms/cloudflare.mjs +0 -492
  248. package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.mjs +0 -576
  249. package/dist/esm/ultramodern/designSystem.mjs +0 -73
  250. package/dist/esm-node/baseline.mjs +0 -5
  251. package/dist/esm-node/commands/runtime.mjs +0 -147
  252. package/dist/esm-node/plugins/deploy/platforms/cloudflare.mjs +0 -493
  253. package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.mjs +0 -576
  254. package/dist/esm-node/ultramodern/designSystem.mjs +0 -74
  255. package/dist/types/baseline.d.ts +0 -16
  256. package/dist/types/commands/runtime.d.ts +0 -12
  257. package/dist/types/ultramodern/designSystem.d.ts +0 -54
  258. /package/dist/types/plugins/deploy/platforms/templates/{cloudflare-entry.d.mts → cloudflare-entry.006-fetch-handler.d.mts} +0 -0
@@ -0,0 +1,97 @@
1
+ import { isRecord } from "./utils.mjs";
2
+ const I18N_SERVER_PLUGIN_NAME = 'plugin-i18n/server';
3
+ const DEFAULT_I18NEXT_DETECTION_OPTIONS = {
4
+ order: [
5
+ 'querystring',
6
+ 'cookie',
7
+ 'localStorage',
8
+ 'header',
9
+ 'navigator',
10
+ 'htmlTag',
11
+ 'path',
12
+ 'subdomain'
13
+ ],
14
+ lookupQuerystring: 'lng',
15
+ lookupCookie: 'i18next',
16
+ lookupHeader: 'accept-language'
17
+ };
18
+ const SERVER_SIDE_I18N_DETECTORS = new Set([
19
+ 'querystring',
20
+ 'cookie',
21
+ 'header'
22
+ ]);
23
+ const toStringArray = (value)=>Array.isArray(value) ? value.filter((entry)=>'string' == typeof entry) : [];
24
+ const getI18nServerPlugin = (appContext)=>appContext.serverPlugins?.find((plugin)=>plugin.name.includes(I18N_SERVER_PLUGIN_NAME));
25
+ const removeLocaleDetectionByEntry = (config)=>{
26
+ const { localeDetectionByEntry: _localeDetectionByEntry, ...rest } = config;
27
+ return rest;
28
+ };
29
+ const getEntryLocaleDetection = (entryName, localeDetection)=>{
30
+ const byEntry = isRecord(localeDetection.localeDetectionByEntry) ? localeDetection.localeDetectionByEntry : void 0;
31
+ const entryConfig = byEntry?.[entryName];
32
+ const globalConfig = removeLocaleDetectionByEntry(localeDetection);
33
+ return isRecord(entryConfig) ? {
34
+ ...globalConfig,
35
+ ...entryConfig
36
+ } : globalConfig;
37
+ };
38
+ const normalizeI18nDetection = (detection)=>{
39
+ const configured = isRecord(detection) ? detection : {};
40
+ const rawOrder = Array.isArray(configured.order) ? configured.order : DEFAULT_I18NEXT_DETECTION_OPTIONS.order;
41
+ const order = rawOrder.filter((entry)=>'string' == typeof entry && SERVER_SIDE_I18N_DETECTORS.has(entry));
42
+ return {
43
+ order: order.length > 0 ? order : [
44
+ 'querystring',
45
+ 'cookie',
46
+ 'header'
47
+ ],
48
+ lookupQuerystring: 'string' == typeof configured.lookupQuerystring && configured.lookupQuerystring ? configured.lookupQuerystring : DEFAULT_I18NEXT_DETECTION_OPTIONS.lookupQuerystring,
49
+ lookupCookie: 'string' == typeof configured.lookupCookie && configured.lookupCookie ? configured.lookupCookie : DEFAULT_I18NEXT_DETECTION_OPTIONS.lookupCookie,
50
+ lookupHeader: 'string' == typeof configured.lookupHeader && configured.lookupHeader ? configured.lookupHeader : DEFAULT_I18NEXT_DETECTION_OPTIONS.lookupHeader
51
+ };
52
+ };
53
+ const normalizeLocalisedUrls = (localisedUrls)=>{
54
+ if (!isRecord(localisedUrls) || 0 === Object.keys(localisedUrls).length) return;
55
+ const normalized = {};
56
+ for (const [canonicalPath, languageMap] of Object.entries(localisedUrls)){
57
+ if (!isRecord(languageMap)) continue;
58
+ const normalizedLanguageMap = Object.fromEntries(Object.entries(languageMap).filter((entry)=>'string' == typeof entry[1] && entry[1].length > 0));
59
+ if (Object.keys(normalizedLanguageMap).length > 0) normalized[canonicalPath] = normalizedLanguageMap;
60
+ }
61
+ return Object.keys(normalized).length > 0 ? normalized : void 0;
62
+ };
63
+ const normalizeWorkerI18nEntry = (entryName, localeDetection, staticRoutePrefixes)=>{
64
+ const entryConfig = getEntryLocaleDetection(entryName, localeDetection);
65
+ const languages = toStringArray(entryConfig.languages);
66
+ if (true !== entryConfig.localePathRedirect || 0 === languages.length) return;
67
+ const fallbackLanguage = 'string' == typeof entryConfig.fallbackLanguage && entryConfig.fallbackLanguage ? entryConfig.fallbackLanguage : 'en';
68
+ const ignoreRedirectRoutes = Array.isArray(entryConfig.ignoreRedirectRoutes) ? toStringArray(entryConfig.ignoreRedirectRoutes) : [];
69
+ const localisedUrls = normalizeLocalisedUrls(entryConfig.localisedUrls);
70
+ return {
71
+ i18nextDetector: false !== entryConfig.i18nextDetector,
72
+ languages,
73
+ fallbackLanguage,
74
+ detection: normalizeI18nDetection(entryConfig.detection),
75
+ ignoreRedirectRoutes,
76
+ staticRoutePrefixes,
77
+ ...localisedUrls ? {
78
+ localisedUrls
79
+ } : {}
80
+ };
81
+ };
82
+ const createI18nWorkerManifest = (routeSpec, appContext)=>{
83
+ const i18nServerPlugin = getI18nServerPlugin(appContext);
84
+ const localeDetection = i18nServerPlugin?.options?.localeDetection;
85
+ if (!isRecord(localeDetection)) return;
86
+ const staticRoutePrefixes = toStringArray(i18nServerPlugin?.options?.staticRoutePrefixes);
87
+ const entries = {};
88
+ for (const route of routeSpec.routes){
89
+ if ('string' != typeof route.entryName || entries[route.entryName]) continue;
90
+ const entry = normalizeWorkerI18nEntry(route.entryName, localeDetection, staticRoutePrefixes);
91
+ if (entry) entries[route.entryName] = entry;
92
+ }
93
+ return Object.keys(entries).length > 0 ? {
94
+ entries
95
+ } : void 0;
96
+ };
97
+ export { createI18nWorkerManifest };
@@ -0,0 +1,102 @@
1
+ import node_path from "node:path";
2
+ import { fs } from "@modern-js/utils";
3
+ import { MICROVERTICAL_RELEASE_ENVELOPE_PATH, emitCloudflareStagedReleaseEnvelope, emitFrameworkMicroVerticalReleaseEnvelope, stageCloudflareReleaseEnvelope, verifyBuildOutputReleaseEnvelope, verifyCloudflareReleaseEnvelopeStaging } from "../../../../ultramodern-release-envelope/framework-output.mjs";
4
+ import { readTemplate } from "../../utils/index.mjs";
5
+ import { createCloudflareOutputPlan } from "../cloudflare-output-plan.mjs";
6
+ import { assertCloudflareOutput } from "../cloudflare-output-verifier/index.mjs";
7
+ import { copyCloudflareArtifacts, copyCloudflareD1Migrations, copyCloudflarePublicAssets, getCloudflareArtifacts, getCloudflarePublicAssets } from "./artifacts.mjs";
8
+ import { ROUTE_SPEC_FILE, ROUTE_SPEC_OUTPUT, WORKER_BUNDLE_DIRECTORY } from "./constants.mjs";
9
+ import { resolveTopologyDeliveryUnit, resolveWorkerDeliveryUnitStamp } from "./delivery-unit.mjs";
10
+ import { createWorkerManifest, createWorkerModuleLoaders, getPublicAssetExcludes, shouldCopyToPublicAssets, shouldCopyToWorkerBundle } from "./worker-manifest.mjs";
11
+ import { createWranglerConfig } from "./wrangler-config.mjs";
12
+ const CLOUDFLARE_ENTRY_TEMPLATE_FRAGMENTS = [
13
+ 'cloudflare-entry.001-bootstrap-security.mjs',
14
+ 'cloudflare-entry.002-assets-routes.mjs',
15
+ 'cloudflare-entry.003-i18n-locales.mjs',
16
+ 'cloudflare-entry.004-rendering-css.mjs',
17
+ 'cloudflare-entry.005-worker-dispatch.mjs',
18
+ 'cloudflare-entry.006-fetch-handler.mjs'
19
+ ];
20
+ const readCloudflareEntryTemplate = async ()=>(await Promise.all(CLOUDFLARE_ENTRY_TEMPLATE_FRAGMENTS.map((fragment)=>readTemplate(fragment)))).join('');
21
+ const createCloudflarePreset = ({ appContext, modernConfig })=>{
22
+ const { apiOnly, appDirectory, distDirectory } = appContext;
23
+ const outputDirectory = node_path.join(appDirectory, '.output');
24
+ const outputPlan = createCloudflareOutputPlan(outputDirectory);
25
+ const publicDirectory = outputPlan.paths.publicAssets;
26
+ const workerEntryPath = outputPlan.paths.workerEntry;
27
+ const workerManifestPath = outputPlan.paths.workerManifest;
28
+ const routeSpecOutputPath = node_path.join(outputDirectory, ROUTE_SPEC_OUTPUT);
29
+ const wranglerConfigPath = outputPlan.paths.wranglerConfig;
30
+ const cloudflareArtifacts = getCloudflareArtifacts(modernConfig);
31
+ const publicAssetExcludes = getPublicAssetExcludes(appDirectory, modernConfig);
32
+ let hasReleaseEnvelope = false;
33
+ return {
34
+ async prepare () {
35
+ await fs.remove(outputDirectory);
36
+ },
37
+ async writeOutput () {
38
+ if (await fs.pathExists(node_path.join(distDirectory, MICROVERTICAL_RELEASE_ENVELOPE_PATH))) await emitFrameworkMicroVerticalReleaseEnvelope({
39
+ apiOnly,
40
+ distDirectory,
41
+ target: 'cloudflare'
42
+ });
43
+ await verifyBuildOutputReleaseEnvelope(distDirectory, 'cloudflare');
44
+ await fs.copy(distDirectory, publicDirectory, {
45
+ filter: (src)=>{
46
+ const relativePath = node_path.relative(distDirectory, src).replace(/\\/gu, '/');
47
+ return 'release' !== relativePath && !relativePath.startsWith('release/') && 'public' !== relativePath && !relativePath.startsWith('public/') && shouldCopyToPublicAssets(src, distDirectory, publicAssetExcludes);
48
+ }
49
+ });
50
+ const generatedPublicDirectory = node_path.join(distDirectory, 'public');
51
+ if (await fs.pathExists(generatedPublicDirectory)) await fs.copy(generatedPublicDirectory, publicDirectory);
52
+ await fs.ensureDir(node_path.dirname(workerEntryPath));
53
+ await fs.ensureDir(node_path.dirname(workerManifestPath));
54
+ const routeSpecSourcePath = node_path.join(distDirectory, ROUTE_SPEC_FILE);
55
+ if (await fs.pathExists(routeSpecSourcePath)) await fs.copy(routeSpecSourcePath, routeSpecOutputPath);
56
+ const workerBundleSourceDirectory = node_path.join(distDirectory, WORKER_BUNDLE_DIRECTORY);
57
+ const workerBundleOutputDirectory = outputPlan.paths.workerBundle;
58
+ if (await fs.pathExists(workerBundleSourceDirectory)) {
59
+ await fs.copy(workerBundleSourceDirectory, workerBundleOutputDirectory, {
60
+ filter: (src)=>shouldCopyToWorkerBundle(src, workerBundleSourceDirectory)
61
+ });
62
+ await fs.writeJSON(outputPlan.paths.workerPackage, outputPlan.packages.worker);
63
+ }
64
+ await copyCloudflareArtifacts(appDirectory, outputDirectory, cloudflareArtifacts);
65
+ await copyCloudflarePublicAssets(appDirectory, publicDirectory, getCloudflarePublicAssets(modernConfig));
66
+ await copyCloudflareD1Migrations(appDirectory, outputDirectory, modernConfig);
67
+ await fs.writeJSON(wranglerConfigPath, createWranglerConfig(appDirectory, modernConfig), {
68
+ spaces: 2
69
+ });
70
+ const deliveryUnitStamp = await resolveWorkerDeliveryUnitStamp(appDirectory);
71
+ await fs.writeJSON(workerManifestPath, await createWorkerManifest(outputDirectory, modernConfig, appContext, deliveryUnitStamp), {
72
+ spaces: 2
73
+ });
74
+ await fs.writeJSON(outputPlan.paths.outputPackage, outputPlan.packages.output);
75
+ hasReleaseEnvelope = Boolean(await stageCloudflareReleaseEnvelope({
76
+ distDirectory,
77
+ outputDirectory
78
+ }));
79
+ },
80
+ async genEntry () {
81
+ const template = await readCloudflareEntryTemplate();
82
+ const manifest = await fs.readJSON(workerManifestPath);
83
+ await fs.writeFile(workerEntryPath, template.replace('p_workerManifest', JSON.stringify(manifest, null, 2)).replace('p_workerModuleLoaders', createWorkerModuleLoaders(manifest)));
84
+ const topologyDeliveryUnit = await resolveTopologyDeliveryUnit(appDirectory);
85
+ await assertCloudflareOutput({
86
+ outputDirectory,
87
+ importWorker: false,
88
+ ...topologyDeliveryUnit ? {
89
+ deliveryUnit: topologyDeliveryUnit
90
+ } : {}
91
+ });
92
+ if (hasReleaseEnvelope) {
93
+ await emitCloudflareStagedReleaseEnvelope({
94
+ distDirectory,
95
+ outputDirectory
96
+ });
97
+ await verifyCloudflareReleaseEnvelopeStaging(outputDirectory);
98
+ } else if (await fs.pathExists(node_path.join(outputDirectory, MICROVERTICAL_RELEASE_ENVELOPE_PATH))) throw new Error('[ultramodern-release-envelope] Cloudflare staging contains an envelope not selected from this MicroVertical build.');
99
+ }
100
+ };
101
+ };
102
+ export { createCloudflarePreset };
@@ -0,0 +1,167 @@
1
+ const DEFAULT_SECURITY_HEADERS = {
2
+ referrerPolicy: 'strict-origin-when-cross-origin',
3
+ contentTypeOptions: 'nosniff',
4
+ permissionsPolicy: 'camera=(), geolocation=(), microphone=(), payment=(), usb=()'
5
+ };
6
+ const DEFAULT_CORS_ALLOWED_METHODS = [
7
+ 'GET',
8
+ 'HEAD',
9
+ 'POST',
10
+ 'PUT',
11
+ 'PATCH',
12
+ 'DELETE',
13
+ 'OPTIONS'
14
+ ];
15
+ const DEFAULT_CSP_DIRECTIVES = {
16
+ 'base-uri': [
17
+ "'self'"
18
+ ],
19
+ 'connect-src': [
20
+ "'self'",
21
+ 'https:',
22
+ 'http:',
23
+ 'wss:',
24
+ 'ws:'
25
+ ],
26
+ 'default-src': [
27
+ "'self'"
28
+ ],
29
+ 'font-src': [
30
+ "'self'",
31
+ 'data:',
32
+ 'https:',
33
+ 'http:'
34
+ ],
35
+ 'form-action': [
36
+ "'self'"
37
+ ],
38
+ 'frame-ancestors': [
39
+ "'self'"
40
+ ],
41
+ 'img-src': [
42
+ "'self'",
43
+ 'data:',
44
+ 'blob:',
45
+ 'https:',
46
+ 'http:'
47
+ ],
48
+ 'manifest-src': [
49
+ "'self'",
50
+ 'https:',
51
+ 'http:'
52
+ ],
53
+ 'object-src': [
54
+ "'none'"
55
+ ],
56
+ "script-src": [
57
+ "'self'",
58
+ "'unsafe-inline'",
59
+ "'unsafe-eval'",
60
+ 'https:',
61
+ 'http:',
62
+ 'blob:'
63
+ ],
64
+ 'style-src': [
65
+ "'self'",
66
+ "'unsafe-inline'",
67
+ 'https:',
68
+ 'http:'
69
+ ],
70
+ 'worker-src': [
71
+ "'self'",
72
+ 'blob:'
73
+ ]
74
+ };
75
+ const normalizeDirectiveValues = (value)=>{
76
+ const values = Array.isArray(value) ? value : [
77
+ value
78
+ ];
79
+ return [
80
+ ...new Set(values.map((entry)=>entry.trim()).filter(Boolean))
81
+ ];
82
+ };
83
+ const appendDirectiveValues = (directives, name, values)=>{
84
+ if (!values?.length) return;
85
+ directives[name] = normalizeDirectiveValues([
86
+ ...directives[name] ?? [],
87
+ ...values
88
+ ]);
89
+ };
90
+ const createContentSecurityPolicy = (config)=>{
91
+ const mode = config?.mode ?? 'report-only';
92
+ if ('off' === mode) return {
93
+ mode,
94
+ directives: {},
95
+ reason: config?.reason
96
+ };
97
+ const directives = Object.fromEntries(Object.entries(DEFAULT_CSP_DIRECTIVES).map(([name, values])=>[
98
+ name,
99
+ [
100
+ ...values
101
+ ]
102
+ ]));
103
+ for (const [name, value] of Object.entries(config?.directives ?? {}))if (false === value) delete directives[name];
104
+ else directives[name] = normalizeDirectiveValues(value);
105
+ if (config?.frameAncestors === false) delete directives['frame-ancestors'];
106
+ else if (config?.frameAncestors) directives['frame-ancestors'] = normalizeDirectiveValues(config.frameAncestors);
107
+ appendDirectiveValues(directives, "script-src", config?.additionalScriptSrc);
108
+ appendDirectiveValues(directives, 'style-src', config?.additionalStyleSrc);
109
+ appendDirectiveValues(directives, 'connect-src', config?.additionalConnectSrc);
110
+ appendDirectiveValues(directives, 'img-src', config?.additionalImgSrc);
111
+ if (config?.reportUri) directives['report-uri'] = [
112
+ config.reportUri
113
+ ];
114
+ return {
115
+ mode,
116
+ directives,
117
+ reason: config?.reason
118
+ };
119
+ };
120
+ const createNoindexPolicy = (noindex)=>{
121
+ if (false === noindex) return {
122
+ workersDev: false,
123
+ localhost: false,
124
+ previewHostnames: []
125
+ };
126
+ if (true === noindex || void 0 === noindex) return {
127
+ workersDev: true,
128
+ localhost: true,
129
+ previewHostnames: []
130
+ };
131
+ return {
132
+ workersDev: noindex.workersDev ?? true,
133
+ localhost: noindex.localhost ?? true,
134
+ previewHostnames: noindex.previewHostnames ?? [],
135
+ reason: noindex.reason
136
+ };
137
+ };
138
+ const createCloudflareWorkerCorsPolicy = (cors)=>({
139
+ assets: cors?.assets ?? true,
140
+ allowedOrigins: normalizeDirectiveValues(cors?.allowedOrigins ?? []),
141
+ allowedMethods: cors?.allowedMethods?.length ? normalizeDirectiveValues(cors.allowedMethods.map((method)=>method.toUpperCase())) : DEFAULT_CORS_ALLOWED_METHODS,
142
+ allowedHeaders: cors?.allowedHeaders?.length ? normalizeDirectiveValues(cors.allowedHeaders) : [
143
+ '*'
144
+ ],
145
+ reason: cors?.reason
146
+ });
147
+ const createCloudflareWorkerSecurityPolicy = (modernConfig)=>{
148
+ const security = modernConfig.deploy?.worker?.security;
149
+ if (security?.enabled === false) return {
150
+ enabled: false,
151
+ cors: createCloudflareWorkerCorsPolicy(security.cors),
152
+ reason: security.reason
153
+ };
154
+ return {
155
+ enabled: true,
156
+ headers: {
157
+ referrerPolicy: security?.headers?.referrerPolicy ?? DEFAULT_SECURITY_HEADERS.referrerPolicy,
158
+ contentTypeOptions: security?.headers?.contentTypeOptions ?? DEFAULT_SECURITY_HEADERS.contentTypeOptions,
159
+ permissionsPolicy: security?.headers?.permissionsPolicy ?? DEFAULT_SECURITY_HEADERS.permissionsPolicy
160
+ },
161
+ contentSecurityPolicy: createContentSecurityPolicy(security?.contentSecurityPolicy),
162
+ noindex: createNoindexPolicy(security?.noindex),
163
+ cors: createCloudflareWorkerCorsPolicy(security?.cors),
164
+ reason: security?.reason
165
+ };
166
+ };
167
+ export { createCloudflareWorkerSecurityPolicy };
@@ -0,0 +1,12 @@
1
+ import node_path from "node:path";
2
+ const isRecord = (value)=>null !== value && 'object' == typeof value && !Array.isArray(value);
3
+ const normalizeRelativePath = (value, label, scope = 'app output', options = {})=>{
4
+ if ('string' != typeof value) throw new Error(`${label} must be a relative path inside the ${scope}.`);
5
+ const normalized = value.trim().replace(/\\/g, '/').replace(/^\.\/+/u, '').replace(/\/+$/u, '');
6
+ const segments = normalized.split('/');
7
+ const isRootDestination = '.' === normalized;
8
+ if (!normalized || node_path.isAbsolute(normalized) || !options.allowRoot && isRootDestination || segments.includes('..')) throw new Error(`${label} must be a relative path inside the ${scope}.`);
9
+ return normalized;
10
+ };
11
+ const isJsonRecord = (value)=>'object' == typeof value && null !== value && !Array.isArray(value);
12
+ export { isJsonRecord, isRecord, normalizeRelativePath };
@@ -0,0 +1,148 @@
1
+ import node_path from "node:path";
2
+ import { fs } from "@modern-js/utils";
3
+ import { readRouteSpec } from "./artifacts.mjs";
4
+ import { ASSETS_BINDING, BFF_EFFECT_WORKER_DISPATCHER_EXPORT, BFF_EFFECT_WORKER_ENTRY, CLOUDFLARE_RUNTIME_TYPE, CLOUDFLARE_WORKER_BUNDLE_FORMAT, DEFAULT_SERVER_ONLY_PUBLIC_ASSET_EXCLUDES, EFFECT_BFF_CLOUDFLARE_IMPORT_GUIDANCE, LOADABLE_STATS_FILE, PUBLIC_ASSETS_DIRECTORY, ROUTE_MANIFEST_FILE, ROUTE_SPEC_FILE, ROUTE_SPEC_OUTPUT, SERVER_BUNDLE_DIRECTORY, WORKER_BUNDLE_DIRECTORY, WORKER_ENTRY } from "./constants.mjs";
5
+ import { createI18nWorkerManifest } from "./i18n-worker.mjs";
6
+ import { createCloudflareWorkerSecurityPolicy } from "./security-policies.mjs";
7
+ import { isRecord, normalizeRelativePath } from "./utils.mjs";
8
+ import { createWorkerManifestServiceBindings, createWorkerServiceBindings } from "./wrangler-config.mjs";
9
+ const createMissingEffectBffWorkerError = (outputDirectory, worker)=>new Error(`Cloudflare Effect API runtime is configured, but the BFF worker bundle is missing: ${node_path.join(outputDirectory, worker)}. ${EFFECT_BFF_CLOUDFLARE_IMPORT_GUIDANCE}`);
10
+ const createModuleFederationWorkerManifest = async (outputDirectory)=>{
11
+ const manifestPath = node_path.join(outputDirectory, PUBLIC_ASSETS_DIRECTORY, 'mf-manifest.json');
12
+ if (!await fs.pathExists(manifestPath)) return;
13
+ const manifest = await fs.readJson(manifestPath);
14
+ const name = isRecord(manifest) && 'string' == typeof manifest.name ? manifest.name : void 0;
15
+ const manifestExposes = isRecord(manifest) && Array.isArray(manifest.exposes) ? manifest.exposes : [];
16
+ const exposes = manifestExposes.filter(isRecord).flatMap((expose)=>{
17
+ if ('string' != typeof expose.path) return [];
18
+ const assets = isRecord(expose.assets) ? expose.assets : void 0;
19
+ const css = assets && isRecord(assets.css) ? assets.css : void 0;
20
+ return [
21
+ {
22
+ path: expose.path,
23
+ css: [
24
+ ...css && Array.isArray(css.sync) ? css.sync : [],
25
+ ...css && Array.isArray(css.async) ? css.async : []
26
+ ].filter((asset)=>'string' == typeof asset && asset.endsWith('.css'))
27
+ }
28
+ ];
29
+ });
30
+ return name && exposes.length > 0 ? {
31
+ name,
32
+ exposes
33
+ } : void 0;
34
+ };
35
+ const createWorkerManifest = async (outputDirectory, modernConfig, appContext, deliveryUnitStamp)=>{
36
+ const routeSpec = await readRouteSpec(outputDirectory);
37
+ const routes = await Promise.all(routeSpec.routes.map(async (route)=>{
38
+ const worker = 'string' == typeof route.worker ? route.worker : void 0;
39
+ return {
40
+ urlPath: route.urlPath,
41
+ entryName: route.entryName,
42
+ entryPath: route.entryPath,
43
+ isSSR: Boolean(route.isSSR),
44
+ worker,
45
+ workerExists: worker ? await fs.pathExists(node_path.join(outputDirectory, worker)) : false
46
+ };
47
+ }));
48
+ const bffPrefix = modernConfig.bff?.prefix;
49
+ const primaryBffPrefix = Array.isArray(bffPrefix) ? bffPrefix[0] : bffPrefix;
50
+ const isEffectApi = Boolean(modernConfig.bff) && modernConfig.bff?.runtimeFramework !== 'hono';
51
+ const effectApiWorkerExists = await fs.pathExists(node_path.join(outputDirectory, BFF_EFFECT_WORKER_ENTRY));
52
+ const serviceBindings = createWorkerManifestServiceBindings(createWorkerServiceBindings(modernConfig, void 0));
53
+ const moduleFederation = await createModuleFederationWorkerManifest(outputDirectory);
54
+ if (isEffectApi && primaryBffPrefix && !effectApiWorkerExists) throw createMissingEffectBffWorkerError(outputDirectory, BFF_EFFECT_WORKER_ENTRY);
55
+ return {
56
+ version: 1,
57
+ runtime: {
58
+ type: CLOUDFLARE_RUNTIME_TYPE,
59
+ entry: WORKER_ENTRY,
60
+ fetchExport: true,
61
+ nodeListen: false
62
+ },
63
+ assets: {
64
+ binding: ASSETS_BINDING,
65
+ directory: `./${PUBLIC_ASSETS_DIRECTORY}`,
66
+ runWorkerFirst: true
67
+ },
68
+ routeSpec: {
69
+ file: ROUTE_SPEC_OUTPUT,
70
+ routes
71
+ },
72
+ workerBundles: {
73
+ directory: WORKER_BUNDLE_DIRECTORY,
74
+ format: CLOUDFLARE_WORKER_BUNDLE_FORMAT,
75
+ importableFromModuleWorker: true,
76
+ requestHandlerExport: 'requestHandler'
77
+ },
78
+ resources: {
79
+ loadableStats: LOADABLE_STATS_FILE,
80
+ routeManifest: ROUTE_MANIFEST_FILE
81
+ },
82
+ security: createCloudflareWorkerSecurityPolicy(modernConfig),
83
+ ...void 0 === moduleFederation ? {} : {
84
+ moduleFederation
85
+ },
86
+ ...deliveryUnitStamp ? {
87
+ deliveryUnit: deliveryUnitStamp
88
+ } : {},
89
+ i18n: createI18nWorkerManifest(routeSpec, appContext),
90
+ bff: isEffectApi && primaryBffPrefix && effectApiWorkerExists ? {
91
+ dispatcherExport: BFF_EFFECT_WORKER_DISPATCHER_EXPORT,
92
+ runtimeFramework: 'effect',
93
+ prefix: primaryBffPrefix,
94
+ worker: BFF_EFFECT_WORKER_ENTRY
95
+ } : void 0,
96
+ ...void 0 === serviceBindings ? {} : {
97
+ serviceBindings
98
+ }
99
+ };
100
+ };
101
+ const createWorkerModuleLoaders = (manifest)=>{
102
+ const imports = new Map();
103
+ for (const route of manifest.routeSpec.routes)if (route.worker && route.workerExists) {
104
+ const importPath = `../${String(route.worker).replace(/^\/+/u, '')}`;
105
+ imports.set(route.worker, `() => import(${JSON.stringify(importPath)})`);
106
+ }
107
+ if (manifest.bff?.worker) {
108
+ const importPath = `../${String(manifest.bff.worker).replace(/^\/+/u, '')}`;
109
+ imports.set(manifest.bff.worker, `() => import(${JSON.stringify(importPath)})`);
110
+ }
111
+ if (0 === imports.size) return '{}';
112
+ const loaders = [
113
+ ...imports.entries()
114
+ ].map(([worker, loader])=>`${JSON.stringify(worker)}: ${loader}`);
115
+ return `{\n${loaders.join(',\n')}\n}`;
116
+ };
117
+ const getPublicAssetExcludes = (appDirectory, modernConfig)=>[
118
+ ...DEFAULT_SERVER_ONLY_PUBLIC_ASSET_EXCLUDES.filter((directory)=>{
119
+ try {
120
+ return fs.statSync(node_path.join(appDirectory, directory)).isDirectory();
121
+ } catch {
122
+ return false;
123
+ }
124
+ }),
125
+ ...modernConfig.deploy?.worker?.publicAssetExcludes ?? []
126
+ ].map((entry)=>normalizeRelativePath(entry, 'deploy.worker.publicAssetExcludes'));
127
+ const shouldCopyToPublicAssets = (src, distDirectory, publicAssetExcludes)=>{
128
+ const relativePath = node_path.relative(distDirectory, src);
129
+ if (!relativePath) return true;
130
+ const normalizedRelativePath = relativePath.replace(/\\/g, '/');
131
+ const [topLevelDirectory] = normalizedRelativePath.split('/');
132
+ const basename = normalizedRelativePath.split('/').pop() ?? '';
133
+ return normalizedRelativePath !== ROUTE_SPEC_FILE && topLevelDirectory !== WORKER_BUNDLE_DIRECTORY && topLevelDirectory !== SERVER_BUNDLE_DIRECTORY && '.env' !== basename && !basename.startsWith('.env.') && !publicAssetExcludes.some((exclude)=>normalizedRelativePath === exclude || normalizedRelativePath.startsWith(`${exclude}/`));
134
+ };
135
+ const shouldCopyToWorkerBundle = (src, workerBundleDirectory)=>{
136
+ const relativePath = node_path.relative(workerBundleDirectory, src);
137
+ if (!relativePath) return true;
138
+ const normalizedRelativePath = relativePath.replace(/\\/g, '/');
139
+ const basename = node_path.basename(normalizedRelativePath);
140
+ if (basename.startsWith('.') || normalizedRelativePath.includes('/.')) return false;
141
+ if (fs.statSync(src).isDirectory()) return true;
142
+ return [
143
+ '.cjs',
144
+ '.js',
145
+ '.mjs'
146
+ ].includes(node_path.extname(normalizedRelativePath));
147
+ };
148
+ export { createWorkerManifest, createWorkerModuleLoaders, getPublicAssetExcludes, shouldCopyToPublicAssets, shouldCopyToWorkerBundle };