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

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,168 @@
1
+ import "node:module";
2
+ const DEFAULT_SECURITY_HEADERS = {
3
+ referrerPolicy: 'strict-origin-when-cross-origin',
4
+ contentTypeOptions: 'nosniff',
5
+ permissionsPolicy: 'camera=(), geolocation=(), microphone=(), payment=(), usb=()'
6
+ };
7
+ const DEFAULT_CORS_ALLOWED_METHODS = [
8
+ 'GET',
9
+ 'HEAD',
10
+ 'POST',
11
+ 'PUT',
12
+ 'PATCH',
13
+ 'DELETE',
14
+ 'OPTIONS'
15
+ ];
16
+ const DEFAULT_CSP_DIRECTIVES = {
17
+ 'base-uri': [
18
+ "'self'"
19
+ ],
20
+ 'connect-src': [
21
+ "'self'",
22
+ 'https:',
23
+ 'http:',
24
+ 'wss:',
25
+ 'ws:'
26
+ ],
27
+ 'default-src': [
28
+ "'self'"
29
+ ],
30
+ 'font-src': [
31
+ "'self'",
32
+ 'data:',
33
+ 'https:',
34
+ 'http:'
35
+ ],
36
+ 'form-action': [
37
+ "'self'"
38
+ ],
39
+ 'frame-ancestors': [
40
+ "'self'"
41
+ ],
42
+ 'img-src': [
43
+ "'self'",
44
+ 'data:',
45
+ 'blob:',
46
+ 'https:',
47
+ 'http:'
48
+ ],
49
+ 'manifest-src': [
50
+ "'self'",
51
+ 'https:',
52
+ 'http:'
53
+ ],
54
+ 'object-src': [
55
+ "'none'"
56
+ ],
57
+ "script-src": [
58
+ "'self'",
59
+ "'unsafe-inline'",
60
+ "'unsafe-eval'",
61
+ 'https:',
62
+ 'http:',
63
+ 'blob:'
64
+ ],
65
+ 'style-src': [
66
+ "'self'",
67
+ "'unsafe-inline'",
68
+ 'https:',
69
+ 'http:'
70
+ ],
71
+ 'worker-src': [
72
+ "'self'",
73
+ 'blob:'
74
+ ]
75
+ };
76
+ const normalizeDirectiveValues = (value)=>{
77
+ const values = Array.isArray(value) ? value : [
78
+ value
79
+ ];
80
+ return [
81
+ ...new Set(values.map((entry)=>entry.trim()).filter(Boolean))
82
+ ];
83
+ };
84
+ const appendDirectiveValues = (directives, name, values)=>{
85
+ if (!values?.length) return;
86
+ directives[name] = normalizeDirectiveValues([
87
+ ...directives[name] ?? [],
88
+ ...values
89
+ ]);
90
+ };
91
+ const createContentSecurityPolicy = (config)=>{
92
+ const mode = config?.mode ?? 'report-only';
93
+ if ('off' === mode) return {
94
+ mode,
95
+ directives: {},
96
+ reason: config?.reason
97
+ };
98
+ const directives = Object.fromEntries(Object.entries(DEFAULT_CSP_DIRECTIVES).map(([name, values])=>[
99
+ name,
100
+ [
101
+ ...values
102
+ ]
103
+ ]));
104
+ for (const [name, value] of Object.entries(config?.directives ?? {}))if (false === value) delete directives[name];
105
+ else directives[name] = normalizeDirectiveValues(value);
106
+ if (config?.frameAncestors === false) delete directives['frame-ancestors'];
107
+ else if (config?.frameAncestors) directives['frame-ancestors'] = normalizeDirectiveValues(config.frameAncestors);
108
+ appendDirectiveValues(directives, "script-src", config?.additionalScriptSrc);
109
+ appendDirectiveValues(directives, 'style-src', config?.additionalStyleSrc);
110
+ appendDirectiveValues(directives, 'connect-src', config?.additionalConnectSrc);
111
+ appendDirectiveValues(directives, 'img-src', config?.additionalImgSrc);
112
+ if (config?.reportUri) directives['report-uri'] = [
113
+ config.reportUri
114
+ ];
115
+ return {
116
+ mode,
117
+ directives,
118
+ reason: config?.reason
119
+ };
120
+ };
121
+ const createNoindexPolicy = (noindex)=>{
122
+ if (false === noindex) return {
123
+ workersDev: false,
124
+ localhost: false,
125
+ previewHostnames: []
126
+ };
127
+ if (true === noindex || void 0 === noindex) return {
128
+ workersDev: true,
129
+ localhost: true,
130
+ previewHostnames: []
131
+ };
132
+ return {
133
+ workersDev: noindex.workersDev ?? true,
134
+ localhost: noindex.localhost ?? true,
135
+ previewHostnames: noindex.previewHostnames ?? [],
136
+ reason: noindex.reason
137
+ };
138
+ };
139
+ const createCloudflareWorkerCorsPolicy = (cors)=>({
140
+ assets: cors?.assets ?? true,
141
+ allowedOrigins: normalizeDirectiveValues(cors?.allowedOrigins ?? []),
142
+ allowedMethods: cors?.allowedMethods?.length ? normalizeDirectiveValues(cors.allowedMethods.map((method)=>method.toUpperCase())) : DEFAULT_CORS_ALLOWED_METHODS,
143
+ allowedHeaders: cors?.allowedHeaders?.length ? normalizeDirectiveValues(cors.allowedHeaders) : [
144
+ '*'
145
+ ],
146
+ reason: cors?.reason
147
+ });
148
+ const createCloudflareWorkerSecurityPolicy = (modernConfig)=>{
149
+ const security = modernConfig.deploy?.worker?.security;
150
+ if (security?.enabled === false) return {
151
+ enabled: false,
152
+ cors: createCloudflareWorkerCorsPolicy(security.cors),
153
+ reason: security.reason
154
+ };
155
+ return {
156
+ enabled: true,
157
+ headers: {
158
+ referrerPolicy: security?.headers?.referrerPolicy ?? DEFAULT_SECURITY_HEADERS.referrerPolicy,
159
+ contentTypeOptions: security?.headers?.contentTypeOptions ?? DEFAULT_SECURITY_HEADERS.contentTypeOptions,
160
+ permissionsPolicy: security?.headers?.permissionsPolicy ?? DEFAULT_SECURITY_HEADERS.permissionsPolicy
161
+ },
162
+ contentSecurityPolicy: createContentSecurityPolicy(security?.contentSecurityPolicy),
163
+ noindex: createNoindexPolicy(security?.noindex),
164
+ cors: createCloudflareWorkerCorsPolicy(security?.cors),
165
+ reason: security?.reason
166
+ };
167
+ };
168
+ export { createCloudflareWorkerSecurityPolicy };
@@ -0,0 +1 @@
1
+ import "node:module";
@@ -0,0 +1,13 @@
1
+ import "node:module";
2
+ import node_path from "node:path";
3
+ const isRecord = (value)=>null !== value && 'object' == typeof value && !Array.isArray(value);
4
+ const normalizeRelativePath = (value, label, scope = 'app output', options = {})=>{
5
+ if ('string' != typeof value) throw new Error(`${label} must be a relative path inside the ${scope}.`);
6
+ const normalized = value.trim().replace(/\\/g, '/').replace(/^\.\/+/u, '').replace(/\/+$/u, '');
7
+ const segments = normalized.split('/');
8
+ const isRootDestination = '.' === normalized;
9
+ if (!normalized || node_path.isAbsolute(normalized) || !options.allowRoot && isRootDestination || segments.includes('..')) throw new Error(`${label} must be a relative path inside the ${scope}.`);
10
+ return normalized;
11
+ };
12
+ const isJsonRecord = (value)=>'object' == typeof value && null !== value && !Array.isArray(value);
13
+ export { isJsonRecord, isRecord, normalizeRelativePath };
@@ -0,0 +1,149 @@
1
+ import "node:module";
2
+ import node_path from "node:path";
3
+ import { fs } from "@modern-js/utils";
4
+ import { readRouteSpec } from "./artifacts.mjs";
5
+ 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";
6
+ import { createI18nWorkerManifest } from "./i18n-worker.mjs";
7
+ import { createCloudflareWorkerSecurityPolicy } from "./security-policies.mjs";
8
+ import { isRecord, normalizeRelativePath } from "./utils.mjs";
9
+ import { createWorkerManifestServiceBindings, createWorkerServiceBindings } from "./wrangler-config.mjs";
10
+ 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}`);
11
+ const createModuleFederationWorkerManifest = async (outputDirectory)=>{
12
+ const manifestPath = node_path.join(outputDirectory, PUBLIC_ASSETS_DIRECTORY, 'mf-manifest.json');
13
+ if (!await fs.pathExists(manifestPath)) return;
14
+ const manifest = await fs.readJson(manifestPath);
15
+ const name = isRecord(manifest) && 'string' == typeof manifest.name ? manifest.name : void 0;
16
+ const manifestExposes = isRecord(manifest) && Array.isArray(manifest.exposes) ? manifest.exposes : [];
17
+ const exposes = manifestExposes.filter(isRecord).flatMap((expose)=>{
18
+ if ('string' != typeof expose.path) return [];
19
+ const assets = isRecord(expose.assets) ? expose.assets : void 0;
20
+ const css = assets && isRecord(assets.css) ? assets.css : void 0;
21
+ return [
22
+ {
23
+ path: expose.path,
24
+ css: [
25
+ ...css && Array.isArray(css.sync) ? css.sync : [],
26
+ ...css && Array.isArray(css.async) ? css.async : []
27
+ ].filter((asset)=>'string' == typeof asset && asset.endsWith('.css'))
28
+ }
29
+ ];
30
+ });
31
+ return name && exposes.length > 0 ? {
32
+ name,
33
+ exposes
34
+ } : void 0;
35
+ };
36
+ const createWorkerManifest = async (outputDirectory, modernConfig, appContext, deliveryUnitStamp)=>{
37
+ const routeSpec = await readRouteSpec(outputDirectory);
38
+ const routes = await Promise.all(routeSpec.routes.map(async (route)=>{
39
+ const worker = 'string' == typeof route.worker ? route.worker : void 0;
40
+ return {
41
+ urlPath: route.urlPath,
42
+ entryName: route.entryName,
43
+ entryPath: route.entryPath,
44
+ isSSR: Boolean(route.isSSR),
45
+ worker,
46
+ workerExists: worker ? await fs.pathExists(node_path.join(outputDirectory, worker)) : false
47
+ };
48
+ }));
49
+ const bffPrefix = modernConfig.bff?.prefix;
50
+ const primaryBffPrefix = Array.isArray(bffPrefix) ? bffPrefix[0] : bffPrefix;
51
+ const isEffectApi = Boolean(modernConfig.bff) && modernConfig.bff?.runtimeFramework !== 'hono';
52
+ const effectApiWorkerExists = await fs.pathExists(node_path.join(outputDirectory, BFF_EFFECT_WORKER_ENTRY));
53
+ const serviceBindings = createWorkerManifestServiceBindings(createWorkerServiceBindings(modernConfig, void 0));
54
+ const moduleFederation = await createModuleFederationWorkerManifest(outputDirectory);
55
+ if (isEffectApi && primaryBffPrefix && !effectApiWorkerExists) throw createMissingEffectBffWorkerError(outputDirectory, BFF_EFFECT_WORKER_ENTRY);
56
+ return {
57
+ version: 1,
58
+ runtime: {
59
+ type: CLOUDFLARE_RUNTIME_TYPE,
60
+ entry: WORKER_ENTRY,
61
+ fetchExport: true,
62
+ nodeListen: false
63
+ },
64
+ assets: {
65
+ binding: ASSETS_BINDING,
66
+ directory: `./${PUBLIC_ASSETS_DIRECTORY}`,
67
+ runWorkerFirst: true
68
+ },
69
+ routeSpec: {
70
+ file: ROUTE_SPEC_OUTPUT,
71
+ routes
72
+ },
73
+ workerBundles: {
74
+ directory: WORKER_BUNDLE_DIRECTORY,
75
+ format: CLOUDFLARE_WORKER_BUNDLE_FORMAT,
76
+ importableFromModuleWorker: true,
77
+ requestHandlerExport: 'requestHandler'
78
+ },
79
+ resources: {
80
+ loadableStats: LOADABLE_STATS_FILE,
81
+ routeManifest: ROUTE_MANIFEST_FILE
82
+ },
83
+ security: createCloudflareWorkerSecurityPolicy(modernConfig),
84
+ ...void 0 === moduleFederation ? {} : {
85
+ moduleFederation
86
+ },
87
+ ...deliveryUnitStamp ? {
88
+ deliveryUnit: deliveryUnitStamp
89
+ } : {},
90
+ i18n: createI18nWorkerManifest(routeSpec, appContext),
91
+ bff: isEffectApi && primaryBffPrefix && effectApiWorkerExists ? {
92
+ dispatcherExport: BFF_EFFECT_WORKER_DISPATCHER_EXPORT,
93
+ runtimeFramework: 'effect',
94
+ prefix: primaryBffPrefix,
95
+ worker: BFF_EFFECT_WORKER_ENTRY
96
+ } : void 0,
97
+ ...void 0 === serviceBindings ? {} : {
98
+ serviceBindings
99
+ }
100
+ };
101
+ };
102
+ const createWorkerModuleLoaders = (manifest)=>{
103
+ const imports = new Map();
104
+ for (const route of manifest.routeSpec.routes)if (route.worker && route.workerExists) {
105
+ const importPath = `../${String(route.worker).replace(/^\/+/u, '')}`;
106
+ imports.set(route.worker, `() => import(${JSON.stringify(importPath)})`);
107
+ }
108
+ if (manifest.bff?.worker) {
109
+ const importPath = `../${String(manifest.bff.worker).replace(/^\/+/u, '')}`;
110
+ imports.set(manifest.bff.worker, `() => import(${JSON.stringify(importPath)})`);
111
+ }
112
+ if (0 === imports.size) return '{}';
113
+ const loaders = [
114
+ ...imports.entries()
115
+ ].map(([worker, loader])=>`${JSON.stringify(worker)}: ${loader}`);
116
+ return `{\n${loaders.join(',\n')}\n}`;
117
+ };
118
+ const getPublicAssetExcludes = (appDirectory, modernConfig)=>[
119
+ ...DEFAULT_SERVER_ONLY_PUBLIC_ASSET_EXCLUDES.filter((directory)=>{
120
+ try {
121
+ return fs.statSync(node_path.join(appDirectory, directory)).isDirectory();
122
+ } catch {
123
+ return false;
124
+ }
125
+ }),
126
+ ...modernConfig.deploy?.worker?.publicAssetExcludes ?? []
127
+ ].map((entry)=>normalizeRelativePath(entry, 'deploy.worker.publicAssetExcludes'));
128
+ const shouldCopyToPublicAssets = (src, distDirectory, publicAssetExcludes)=>{
129
+ const relativePath = node_path.relative(distDirectory, src);
130
+ if (!relativePath) return true;
131
+ const normalizedRelativePath = relativePath.replace(/\\/g, '/');
132
+ const [topLevelDirectory] = normalizedRelativePath.split('/');
133
+ const basename = normalizedRelativePath.split('/').pop() ?? '';
134
+ 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}/`));
135
+ };
136
+ const shouldCopyToWorkerBundle = (src, workerBundleDirectory)=>{
137
+ const relativePath = node_path.relative(workerBundleDirectory, src);
138
+ if (!relativePath) return true;
139
+ const normalizedRelativePath = relativePath.replace(/\\/g, '/');
140
+ const basename = node_path.basename(normalizedRelativePath);
141
+ if (basename.startsWith('.') || normalizedRelativePath.includes('/.')) return false;
142
+ if (fs.statSync(src).isDirectory()) return true;
143
+ return [
144
+ '.cjs',
145
+ '.js',
146
+ '.mjs'
147
+ ].includes(node_path.extname(normalizedRelativePath));
148
+ };
149
+ export { createWorkerManifest, createWorkerModuleLoaders, getPublicAssetExcludes, shouldCopyToPublicAssets, shouldCopyToWorkerBundle };
@@ -0,0 +1,151 @@
1
+ import "node:module";
2
+ import node_path from "node:path";
3
+ import { ASSETS_BINDING, COMPATIBILITY_DATE_PATTERN, DEFAULT_COMPATIBILITY_DATE, PUBLIC_ASSETS_DIRECTORY, REQUIRED_COMPATIBILITY_FLAGS, WORKER_ENTRY } from "./constants.mjs";
4
+ import { isJsonRecord, normalizeRelativePath } from "./utils.mjs";
5
+ const getCompatibilityDate = (modernConfig)=>{
6
+ const configuredDate = modernConfig.deploy?.worker?.compatibilityDate?.trim();
7
+ const compatibilityDate = configuredDate || DEFAULT_COMPATIBILITY_DATE;
8
+ if (!COMPATIBILITY_DATE_PATTERN.test(compatibilityDate)) throw new Error(`deploy.worker.compatibilityDate must use YYYY-MM-DD, received ${JSON.stringify(compatibilityDate)}.`);
9
+ return compatibilityDate;
10
+ };
11
+ const getWorkerName = (appDirectory)=>{
12
+ const basename = node_path.basename(appDirectory);
13
+ return basename.replace(/[^a-zA-Z0-9-_]/g, '-') || 'modern-cloudflare-worker';
14
+ };
15
+ const getConfiguredWorkerName = (appDirectory, modernConfig)=>{
16
+ const configuredName = modernConfig.deploy?.worker?.name?.trim();
17
+ return configuredName || getWorkerName(appDirectory);
18
+ };
19
+ const getConfiguredWrangler = (modernConfig)=>{
20
+ const wrangler = modernConfig.deploy?.worker?.wrangler;
21
+ if (void 0 === wrangler) return {};
22
+ if (!isJsonRecord(wrangler)) throw new Error('deploy.worker.wrangler must be a JSON object.');
23
+ return wrangler;
24
+ };
25
+ const createWranglerCompatibilityFlags = (configuredFlags)=>{
26
+ if (void 0 === configuredFlags) return [
27
+ ...REQUIRED_COMPATIBILITY_FLAGS
28
+ ];
29
+ if (!Array.isArray(configuredFlags) || configuredFlags.some((flag)=>'string' != typeof flag)) throw new Error('deploy.worker.wrangler.compatibility_flags must be an array of strings.');
30
+ return [
31
+ ...new Set([
32
+ ...configuredFlags,
33
+ ...REQUIRED_COMPATIBILITY_FLAGS
34
+ ])
35
+ ];
36
+ };
37
+ const createWranglerAssetsConfig = (configuredAssets)=>{
38
+ if (void 0 !== configuredAssets && !isJsonRecord(configuredAssets)) throw new Error('deploy.worker.wrangler.assets must be an object.');
39
+ return {
40
+ ...isJsonRecord(configuredAssets) ? configuredAssets : {},
41
+ directory: `./${PUBLIC_ASSETS_DIRECTORY}`,
42
+ binding: ASSETS_BINDING,
43
+ run_worker_first: true
44
+ };
45
+ };
46
+ const assertNonEmptyString = (value, label)=>{
47
+ if ('string' != typeof value || 0 === value.trim().length) throw new Error(`${label} must be a non-empty string.`);
48
+ return value.trim();
49
+ };
50
+ const normalizeD1Database = (database, index)=>{
51
+ const binding = assertNonEmptyString(database.binding, `deploy.worker.d1Databases[${index}].binding`);
52
+ const databaseName = assertNonEmptyString(database.databaseName, `deploy.worker.d1Databases[${index}].databaseName`);
53
+ const databaseId = assertNonEmptyString(database.databaseId, `deploy.worker.d1Databases[${index}].databaseId`);
54
+ const migrationsDir = void 0 === database.migrationsDir ? void 0 : normalizeRelativePath(database.migrationsDir, `deploy.worker.d1Databases[${index}].migrationsDir`, 'app root');
55
+ const previewDatabaseId = void 0 === database.previewDatabaseId ? void 0 : assertNonEmptyString(database.previewDatabaseId, `deploy.worker.d1Databases[${index}].previewDatabaseId`);
56
+ return {
57
+ binding,
58
+ database_name: databaseName,
59
+ database_id: databaseId,
60
+ ...void 0 === migrationsDir ? {} : {
61
+ migrations_dir: migrationsDir
62
+ },
63
+ ...void 0 === previewDatabaseId ? {} : {
64
+ preview_database_id: previewDatabaseId
65
+ },
66
+ ...void 0 === database.remote ? {} : {
67
+ remote: database.remote
68
+ }
69
+ };
70
+ };
71
+ const createWranglerD1Databases = (modernConfig, configuredWranglerD1)=>{
72
+ const d1Databases = modernConfig.deploy?.worker?.d1Databases;
73
+ if (void 0 === d1Databases) return configuredWranglerD1;
74
+ if (void 0 !== configuredWranglerD1) throw new Error('Use deploy.worker.d1Databases or deploy.worker.wrangler.d1_databases, not both.');
75
+ if (!Array.isArray(d1Databases)) throw new Error('deploy.worker.d1Databases must be an array.');
76
+ return d1Databases.map(normalizeD1Database);
77
+ };
78
+ const normalizeServiceBinding = (service, index)=>{
79
+ const binding = assertNonEmptyString(service.binding, `deploy.worker.services[${index}].binding`);
80
+ const serviceName = assertNonEmptyString(service.service, `deploy.worker.services[${index}].service`);
81
+ const prefix = void 0 === service.prefix ? void 0 : assertNonEmptyString(service.prefix, `deploy.worker.services[${index}].prefix`);
82
+ if (void 0 !== service.fragments && !Array.isArray(service.fragments)) throw new Error(`deploy.worker.services[${index}].fragments must be an array.`);
83
+ const fragments = void 0 === service.fragments ? void 0 : service.fragments.map((fragment, fragmentIndex)=>({
84
+ remote: assertNonEmptyString(fragment.remote, `deploy.worker.services[${index}].fragments[${fragmentIndex}].remote`),
85
+ expose: assertNonEmptyString(fragment.expose, `deploy.worker.services[${index}].fragments[${fragmentIndex}].expose`),
86
+ boundaryId: assertNonEmptyString(fragment.boundaryId, `deploy.worker.services[${index}].fragments[${fragmentIndex}].boundaryId`),
87
+ path: assertNonEmptyString(fragment.path, `deploy.worker.services[${index}].fragments[${fragmentIndex}].path`)
88
+ }));
89
+ return {
90
+ binding,
91
+ service: serviceName,
92
+ ...void 0 === prefix ? {} : {
93
+ prefix
94
+ },
95
+ ...void 0 === fragments ? {} : {
96
+ fragments
97
+ }
98
+ };
99
+ };
100
+ const createWorkerServiceBindings = (modernConfig, configuredWranglerServices)=>{
101
+ const services = modernConfig.deploy?.worker?.services;
102
+ if (void 0 === services) return configuredWranglerServices;
103
+ if (void 0 !== configuredWranglerServices) throw new Error('Use deploy.worker.services or deploy.worker.wrangler.services, not both.');
104
+ if (!Array.isArray(services)) throw new Error('deploy.worker.services must be an array.');
105
+ return services.map(normalizeServiceBinding);
106
+ };
107
+ const createWranglerServices = (serviceBindings)=>{
108
+ if (!Array.isArray(serviceBindings)) return serviceBindings;
109
+ if (!serviceBindings.every(isJsonRecord)) return serviceBindings;
110
+ return serviceBindings.map((service)=>{
111
+ const { prefix, fragments, ...wranglerService } = service;
112
+ return wranglerService;
113
+ });
114
+ };
115
+ const createWorkerManifestServiceBindings = (serviceBindings)=>{
116
+ if (!Array.isArray(serviceBindings)) return;
117
+ const manifestBindings = serviceBindings.filter((service)=>isJsonRecord(service) && 'string' == typeof service.binding && 'string' == typeof service.service && ('string' == typeof service.prefix || Array.isArray(service.fragments) && service.fragments.length > 0)).map((service)=>({
118
+ binding: service.binding,
119
+ service: service.service,
120
+ interface: 'fetch',
121
+ ...void 0 === service.prefix ? {} : {
122
+ prefix: service.prefix
123
+ },
124
+ ...void 0 === service.fragments ? {} : {
125
+ fragments: service.fragments
126
+ }
127
+ }));
128
+ return manifestBindings.length > 0 ? manifestBindings : void 0;
129
+ };
130
+ const createWranglerConfig = (appDirectory, modernConfig)=>{
131
+ const wrangler = getConfiguredWrangler(modernConfig);
132
+ const d1Databases = createWranglerD1Databases(modernConfig, wrangler.d1_databases);
133
+ const serviceBindings = createWorkerServiceBindings(modernConfig, wrangler.services);
134
+ const wranglerServices = createWranglerServices(serviceBindings);
135
+ return {
136
+ $schema: 'node_modules/wrangler/config-schema.json',
137
+ name: getConfiguredWorkerName(appDirectory, modernConfig),
138
+ compatibility_date: getCompatibilityDate(modernConfig),
139
+ ...wrangler,
140
+ main: WORKER_ENTRY,
141
+ compatibility_flags: createWranglerCompatibilityFlags(wrangler.compatibility_flags),
142
+ assets: createWranglerAssetsConfig(wrangler.assets),
143
+ ...void 0 === d1Databases ? {} : {
144
+ d1_databases: d1Databases
145
+ },
146
+ ...void 0 === wranglerServices ? {} : {
147
+ services: wranglerServices
148
+ }
149
+ };
150
+ };
151
+ export { createWorkerManifestServiceBindings, createWorkerServiceBindings, createWranglerConfig };
@@ -0,0 +1,32 @@
1
+ import "node:module";
2
+ const CLOUDFLARE_WORKER_ENTRY = 'server/index.mjs';
3
+ const CLOUDFLARE_WORKER_MANIFEST = 'server/modern-worker-manifest.json';
4
+ const CLOUDFLARE_WRANGLER_CONFIG_FILE = 'wrangler.json';
5
+ const CLOUDFLARE_OUTPUT_PACKAGE_FILE = 'package.json';
6
+ const CLOUDFLARE_WORKER_PACKAGE_FILE = 'worker/package.json';
7
+ const CLOUDFLARE_ASSETS_BINDING = 'ASSETS';
8
+ const CLOUDFLARE_PUBLIC_ASSETS_DIRECTORY = 'public';
9
+ const CLOUDFLARE_WORKER_BUNDLE_DIRECTORY = 'worker';
10
+ const CLOUDFLARE_RUNTIME_TYPE = 'cloudflare-module-worker';
11
+ const CLOUDFLARE_OUTPUT_PACKAGE_TYPE = 'module';
12
+ const CLOUDFLARE_WORKER_PACKAGE_TYPE = 'commonjs';
13
+ const CLOUDFLARE_WORKER_BUNDLE_FORMAT = 'commonjs';
14
+ const CLOUDFLARE_WORKER_NODE_BUILTINS = [
15
+ 'async_hooks',
16
+ 'buffer',
17
+ 'crypto',
18
+ 'events',
19
+ 'fs/promises',
20
+ 'module',
21
+ 'path',
22
+ 'process',
23
+ 'stream',
24
+ 'string_decoder',
25
+ 'url',
26
+ 'util'
27
+ ];
28
+ const CLOUDFLARE_REQUIRED_COMPATIBILITY_FLAGS = [
29
+ 'nodejs_compat',
30
+ 'global_fetch_strictly_public'
31
+ ];
32
+ export { CLOUDFLARE_ASSETS_BINDING, CLOUDFLARE_OUTPUT_PACKAGE_FILE, CLOUDFLARE_OUTPUT_PACKAGE_TYPE, CLOUDFLARE_PUBLIC_ASSETS_DIRECTORY, CLOUDFLARE_REQUIRED_COMPATIBILITY_FLAGS, CLOUDFLARE_RUNTIME_TYPE, CLOUDFLARE_WORKER_BUNDLE_DIRECTORY, CLOUDFLARE_WORKER_BUNDLE_FORMAT, CLOUDFLARE_WORKER_ENTRY, CLOUDFLARE_WORKER_MANIFEST, CLOUDFLARE_WORKER_NODE_BUILTINS, CLOUDFLARE_WORKER_PACKAGE_FILE, CLOUDFLARE_WORKER_PACKAGE_TYPE, CLOUDFLARE_WRANGLER_CONFIG_FILE };
@@ -0,0 +1,46 @@
1
+ import "node:module";
2
+ import node_path from "node:path";
3
+ import { CLOUDFLARE_ASSETS_BINDING, CLOUDFLARE_OUTPUT_PACKAGE_FILE, CLOUDFLARE_OUTPUT_PACKAGE_TYPE, CLOUDFLARE_PUBLIC_ASSETS_DIRECTORY, CLOUDFLARE_REQUIRED_COMPATIBILITY_FLAGS, CLOUDFLARE_WORKER_BUNDLE_DIRECTORY, CLOUDFLARE_WORKER_ENTRY, CLOUDFLARE_WORKER_MANIFEST, CLOUDFLARE_WORKER_PACKAGE_FILE, CLOUDFLARE_WORKER_PACKAGE_TYPE, CLOUDFLARE_WRANGLER_CONFIG_FILE } from "./cloudflare-output-contract.mjs";
4
+ const resolveOutput = (outputDirectory, relativePath)=>node_path.join(outputDirectory, relativePath);
5
+ function createCloudflareOutputPlan(outputDirectory) {
6
+ return {
7
+ outputDirectory,
8
+ requiredFiles: [
9
+ CLOUDFLARE_WORKER_ENTRY,
10
+ CLOUDFLARE_WORKER_MANIFEST,
11
+ CLOUDFLARE_WRANGLER_CONFIG_FILE,
12
+ CLOUDFLARE_OUTPUT_PACKAGE_FILE
13
+ ],
14
+ publicLeakDirectories: [
15
+ 'server',
16
+ CLOUDFLARE_WORKER_BUNDLE_DIRECTORY
17
+ ],
18
+ paths: {
19
+ workerEntry: resolveOutput(outputDirectory, CLOUDFLARE_WORKER_ENTRY),
20
+ workerManifest: resolveOutput(outputDirectory, CLOUDFLARE_WORKER_MANIFEST),
21
+ wranglerConfig: resolveOutput(outputDirectory, CLOUDFLARE_WRANGLER_CONFIG_FILE),
22
+ outputPackage: resolveOutput(outputDirectory, CLOUDFLARE_OUTPUT_PACKAGE_FILE),
23
+ workerPackage: resolveOutput(outputDirectory, CLOUDFLARE_WORKER_PACKAGE_FILE),
24
+ publicAssets: resolveOutput(outputDirectory, CLOUDFLARE_PUBLIC_ASSETS_DIRECTORY),
25
+ workerBundle: resolveOutput(outputDirectory, CLOUDFLARE_WORKER_BUNDLE_DIRECTORY)
26
+ },
27
+ packages: {
28
+ output: {
29
+ type: CLOUDFLARE_OUTPUT_PACKAGE_TYPE
30
+ },
31
+ worker: {
32
+ type: CLOUDFLARE_WORKER_PACKAGE_TYPE
33
+ }
34
+ },
35
+ wrangler: {
36
+ main: CLOUDFLARE_WORKER_ENTRY,
37
+ assets: {
38
+ binding: CLOUDFLARE_ASSETS_BINDING,
39
+ directory: `./${CLOUDFLARE_PUBLIC_ASSETS_DIRECTORY}`,
40
+ run_worker_first: true
41
+ },
42
+ requiredCompatibilityFlags: CLOUDFLARE_REQUIRED_COMPATIBILITY_FLAGS
43
+ }
44
+ };
45
+ }
46
+ export { createCloudflareOutputPlan };
@@ -0,0 +1,46 @@
1
+ import "node:module";
2
+ import { DELIVERY_UNIT_IDENTITY_FIELDS, deliveryUnitIdentityFieldValue } from "@modern-js/utils/universal";
3
+ import { addIssue, assertEqual } from "./issues.mjs";
4
+ const verifyDeliveryUnitIdentity = (issues, manifest, manifestPath, declared)=>{
5
+ const stamped = manifest?.deliveryUnit;
6
+ const hasStamp = Boolean(stamped) && 'object' == typeof stamped;
7
+ if (declared) {
8
+ if (!hasStamp) return void addIssue(issues, {
9
+ code: 'missing-delivery-unit',
10
+ message: `Cloudflare worker manifest is missing the delivery-unit identity declared by the workspace topology (expected unitId ${declared.unitId}, buildMarker ${declared.buildMarker}).`,
11
+ path: manifestPath
12
+ });
13
+ for (const field of DELIVERY_UNIT_IDENTITY_FIELDS){
14
+ const stampedValue = deliveryUnitIdentityFieldValue(stamped, field);
15
+ assertEqual(issues, stampedValue, declared[field], {
16
+ code: 'delivery-unit-drift',
17
+ message: `Cloudflare worker manifest deliveryUnit.${field} must match the topology delivery-unit record (expected ${declared[field]}, received ${stampedValue ?? 'undefined'}).`,
18
+ path: manifestPath
19
+ });
20
+ }
21
+ }
22
+ if (hasStamp && stamped.surfaces && 'object' == typeof stamped.surfaces) for (const surface of [
23
+ 'ui',
24
+ 'api'
25
+ ]){
26
+ const marker = stamped.surfaces[surface];
27
+ if (!marker || 'object' != typeof marker) {
28
+ addIssue(issues, {
29
+ code: 'missing-delivery-unit',
30
+ message: `Cloudflare worker manifest is missing the ${surface} delivery-unit surface marker.`,
31
+ path: manifestPath
32
+ });
33
+ continue;
34
+ }
35
+ for (const field of DELIVERY_UNIT_IDENTITY_FIELDS){
36
+ const markerValue = deliveryUnitIdentityFieldValue(marker, field);
37
+ const stampedValue = deliveryUnitIdentityFieldValue(stamped, field);
38
+ assertEqual(issues, markerValue, stampedValue, {
39
+ code: 'delivery-unit-drift',
40
+ message: `Cloudflare worker manifest ${surface} surface deliveryUnit.${field} must derive from one delivery-unit record (expected ${stampedValue ?? 'undefined'}, received ${markerValue ?? 'undefined'}).`,
41
+ path: manifestPath
42
+ });
43
+ }
44
+ }
45
+ };
46
+ export { verifyDeliveryUnitIdentity };