@bleedingdev/modern-js-app-tools 3.5.0-ultramodern.5 → 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,150 @@
1
+ import node_path from "node:path";
2
+ import { ASSETS_BINDING, COMPATIBILITY_DATE_PATTERN, DEFAULT_COMPATIBILITY_DATE, PUBLIC_ASSETS_DIRECTORY, REQUIRED_COMPATIBILITY_FLAGS, WORKER_ENTRY } from "./constants.mjs";
3
+ import { isJsonRecord, normalizeRelativePath } from "./utils.mjs";
4
+ const getCompatibilityDate = (modernConfig)=>{
5
+ const configuredDate = modernConfig.deploy?.worker?.compatibilityDate?.trim();
6
+ const compatibilityDate = configuredDate || DEFAULT_COMPATIBILITY_DATE;
7
+ if (!COMPATIBILITY_DATE_PATTERN.test(compatibilityDate)) throw new Error(`deploy.worker.compatibilityDate must use YYYY-MM-DD, received ${JSON.stringify(compatibilityDate)}.`);
8
+ return compatibilityDate;
9
+ };
10
+ const getWorkerName = (appDirectory)=>{
11
+ const basename = node_path.basename(appDirectory);
12
+ return basename.replace(/[^a-zA-Z0-9-_]/g, '-') || 'modern-cloudflare-worker';
13
+ };
14
+ const getConfiguredWorkerName = (appDirectory, modernConfig)=>{
15
+ const configuredName = modernConfig.deploy?.worker?.name?.trim();
16
+ return configuredName || getWorkerName(appDirectory);
17
+ };
18
+ const getConfiguredWrangler = (modernConfig)=>{
19
+ const wrangler = modernConfig.deploy?.worker?.wrangler;
20
+ if (void 0 === wrangler) return {};
21
+ if (!isJsonRecord(wrangler)) throw new Error('deploy.worker.wrangler must be a JSON object.');
22
+ return wrangler;
23
+ };
24
+ const createWranglerCompatibilityFlags = (configuredFlags)=>{
25
+ if (void 0 === configuredFlags) return [
26
+ ...REQUIRED_COMPATIBILITY_FLAGS
27
+ ];
28
+ if (!Array.isArray(configuredFlags) || configuredFlags.some((flag)=>'string' != typeof flag)) throw new Error('deploy.worker.wrangler.compatibility_flags must be an array of strings.');
29
+ return [
30
+ ...new Set([
31
+ ...configuredFlags,
32
+ ...REQUIRED_COMPATIBILITY_FLAGS
33
+ ])
34
+ ];
35
+ };
36
+ const createWranglerAssetsConfig = (configuredAssets)=>{
37
+ if (void 0 !== configuredAssets && !isJsonRecord(configuredAssets)) throw new Error('deploy.worker.wrangler.assets must be an object.');
38
+ return {
39
+ ...isJsonRecord(configuredAssets) ? configuredAssets : {},
40
+ directory: `./${PUBLIC_ASSETS_DIRECTORY}`,
41
+ binding: ASSETS_BINDING,
42
+ run_worker_first: true
43
+ };
44
+ };
45
+ const assertNonEmptyString = (value, label)=>{
46
+ if ('string' != typeof value || 0 === value.trim().length) throw new Error(`${label} must be a non-empty string.`);
47
+ return value.trim();
48
+ };
49
+ const normalizeD1Database = (database, index)=>{
50
+ const binding = assertNonEmptyString(database.binding, `deploy.worker.d1Databases[${index}].binding`);
51
+ const databaseName = assertNonEmptyString(database.databaseName, `deploy.worker.d1Databases[${index}].databaseName`);
52
+ const databaseId = assertNonEmptyString(database.databaseId, `deploy.worker.d1Databases[${index}].databaseId`);
53
+ const migrationsDir = void 0 === database.migrationsDir ? void 0 : normalizeRelativePath(database.migrationsDir, `deploy.worker.d1Databases[${index}].migrationsDir`, 'app root');
54
+ const previewDatabaseId = void 0 === database.previewDatabaseId ? void 0 : assertNonEmptyString(database.previewDatabaseId, `deploy.worker.d1Databases[${index}].previewDatabaseId`);
55
+ return {
56
+ binding,
57
+ database_name: databaseName,
58
+ database_id: databaseId,
59
+ ...void 0 === migrationsDir ? {} : {
60
+ migrations_dir: migrationsDir
61
+ },
62
+ ...void 0 === previewDatabaseId ? {} : {
63
+ preview_database_id: previewDatabaseId
64
+ },
65
+ ...void 0 === database.remote ? {} : {
66
+ remote: database.remote
67
+ }
68
+ };
69
+ };
70
+ const createWranglerD1Databases = (modernConfig, configuredWranglerD1)=>{
71
+ const d1Databases = modernConfig.deploy?.worker?.d1Databases;
72
+ if (void 0 === d1Databases) return configuredWranglerD1;
73
+ if (void 0 !== configuredWranglerD1) throw new Error('Use deploy.worker.d1Databases or deploy.worker.wrangler.d1_databases, not both.');
74
+ if (!Array.isArray(d1Databases)) throw new Error('deploy.worker.d1Databases must be an array.');
75
+ return d1Databases.map(normalizeD1Database);
76
+ };
77
+ const normalizeServiceBinding = (service, index)=>{
78
+ const binding = assertNonEmptyString(service.binding, `deploy.worker.services[${index}].binding`);
79
+ const serviceName = assertNonEmptyString(service.service, `deploy.worker.services[${index}].service`);
80
+ const prefix = void 0 === service.prefix ? void 0 : assertNonEmptyString(service.prefix, `deploy.worker.services[${index}].prefix`);
81
+ if (void 0 !== service.fragments && !Array.isArray(service.fragments)) throw new Error(`deploy.worker.services[${index}].fragments must be an array.`);
82
+ const fragments = void 0 === service.fragments ? void 0 : service.fragments.map((fragment, fragmentIndex)=>({
83
+ remote: assertNonEmptyString(fragment.remote, `deploy.worker.services[${index}].fragments[${fragmentIndex}].remote`),
84
+ expose: assertNonEmptyString(fragment.expose, `deploy.worker.services[${index}].fragments[${fragmentIndex}].expose`),
85
+ boundaryId: assertNonEmptyString(fragment.boundaryId, `deploy.worker.services[${index}].fragments[${fragmentIndex}].boundaryId`),
86
+ path: assertNonEmptyString(fragment.path, `deploy.worker.services[${index}].fragments[${fragmentIndex}].path`)
87
+ }));
88
+ return {
89
+ binding,
90
+ service: serviceName,
91
+ ...void 0 === prefix ? {} : {
92
+ prefix
93
+ },
94
+ ...void 0 === fragments ? {} : {
95
+ fragments
96
+ }
97
+ };
98
+ };
99
+ const createWorkerServiceBindings = (modernConfig, configuredWranglerServices)=>{
100
+ const services = modernConfig.deploy?.worker?.services;
101
+ if (void 0 === services) return configuredWranglerServices;
102
+ if (void 0 !== configuredWranglerServices) throw new Error('Use deploy.worker.services or deploy.worker.wrangler.services, not both.');
103
+ if (!Array.isArray(services)) throw new Error('deploy.worker.services must be an array.');
104
+ return services.map(normalizeServiceBinding);
105
+ };
106
+ const createWranglerServices = (serviceBindings)=>{
107
+ if (!Array.isArray(serviceBindings)) return serviceBindings;
108
+ if (!serviceBindings.every(isJsonRecord)) return serviceBindings;
109
+ return serviceBindings.map((service)=>{
110
+ const { prefix, fragments, ...wranglerService } = service;
111
+ return wranglerService;
112
+ });
113
+ };
114
+ const createWorkerManifestServiceBindings = (serviceBindings)=>{
115
+ if (!Array.isArray(serviceBindings)) return;
116
+ 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)=>({
117
+ binding: service.binding,
118
+ service: service.service,
119
+ interface: 'fetch',
120
+ ...void 0 === service.prefix ? {} : {
121
+ prefix: service.prefix
122
+ },
123
+ ...void 0 === service.fragments ? {} : {
124
+ fragments: service.fragments
125
+ }
126
+ }));
127
+ return manifestBindings.length > 0 ? manifestBindings : void 0;
128
+ };
129
+ const createWranglerConfig = (appDirectory, modernConfig)=>{
130
+ const wrangler = getConfiguredWrangler(modernConfig);
131
+ const d1Databases = createWranglerD1Databases(modernConfig, wrangler.d1_databases);
132
+ const serviceBindings = createWorkerServiceBindings(modernConfig, wrangler.services);
133
+ const wranglerServices = createWranglerServices(serviceBindings);
134
+ return {
135
+ $schema: 'node_modules/wrangler/config-schema.json',
136
+ name: getConfiguredWorkerName(appDirectory, modernConfig),
137
+ compatibility_date: getCompatibilityDate(modernConfig),
138
+ ...wrangler,
139
+ main: WORKER_ENTRY,
140
+ compatibility_flags: createWranglerCompatibilityFlags(wrangler.compatibility_flags),
141
+ assets: createWranglerAssetsConfig(wrangler.assets),
142
+ ...void 0 === d1Databases ? {} : {
143
+ d1_databases: d1Databases
144
+ },
145
+ ...void 0 === wranglerServices ? {} : {
146
+ services: wranglerServices
147
+ }
148
+ };
149
+ };
150
+ export { createWorkerManifestServiceBindings, createWorkerServiceBindings, createWranglerConfig };
@@ -0,0 +1,31 @@
1
+ const CLOUDFLARE_WORKER_ENTRY = 'server/index.mjs';
2
+ const CLOUDFLARE_WORKER_MANIFEST = 'server/modern-worker-manifest.json';
3
+ const CLOUDFLARE_WRANGLER_CONFIG_FILE = 'wrangler.json';
4
+ const CLOUDFLARE_OUTPUT_PACKAGE_FILE = 'package.json';
5
+ const CLOUDFLARE_WORKER_PACKAGE_FILE = 'worker/package.json';
6
+ const CLOUDFLARE_ASSETS_BINDING = 'ASSETS';
7
+ const CLOUDFLARE_PUBLIC_ASSETS_DIRECTORY = 'public';
8
+ const CLOUDFLARE_WORKER_BUNDLE_DIRECTORY = 'worker';
9
+ const CLOUDFLARE_RUNTIME_TYPE = 'cloudflare-module-worker';
10
+ const CLOUDFLARE_OUTPUT_PACKAGE_TYPE = 'module';
11
+ const CLOUDFLARE_WORKER_PACKAGE_TYPE = 'commonjs';
12
+ const CLOUDFLARE_WORKER_BUNDLE_FORMAT = 'commonjs';
13
+ const CLOUDFLARE_WORKER_NODE_BUILTINS = [
14
+ 'async_hooks',
15
+ 'buffer',
16
+ 'crypto',
17
+ 'events',
18
+ 'fs/promises',
19
+ 'module',
20
+ 'path',
21
+ 'process',
22
+ 'stream',
23
+ 'string_decoder',
24
+ 'url',
25
+ 'util'
26
+ ];
27
+ const CLOUDFLARE_REQUIRED_COMPATIBILITY_FLAGS = [
28
+ 'nodejs_compat',
29
+ 'global_fetch_strictly_public'
30
+ ];
31
+ 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,45 @@
1
+ import node_path from "node:path";
2
+ 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";
3
+ const resolveOutput = (outputDirectory, relativePath)=>node_path.join(outputDirectory, relativePath);
4
+ function createCloudflareOutputPlan(outputDirectory) {
5
+ return {
6
+ outputDirectory,
7
+ requiredFiles: [
8
+ CLOUDFLARE_WORKER_ENTRY,
9
+ CLOUDFLARE_WORKER_MANIFEST,
10
+ CLOUDFLARE_WRANGLER_CONFIG_FILE,
11
+ CLOUDFLARE_OUTPUT_PACKAGE_FILE
12
+ ],
13
+ publicLeakDirectories: [
14
+ 'server',
15
+ CLOUDFLARE_WORKER_BUNDLE_DIRECTORY
16
+ ],
17
+ paths: {
18
+ workerEntry: resolveOutput(outputDirectory, CLOUDFLARE_WORKER_ENTRY),
19
+ workerManifest: resolveOutput(outputDirectory, CLOUDFLARE_WORKER_MANIFEST),
20
+ wranglerConfig: resolveOutput(outputDirectory, CLOUDFLARE_WRANGLER_CONFIG_FILE),
21
+ outputPackage: resolveOutput(outputDirectory, CLOUDFLARE_OUTPUT_PACKAGE_FILE),
22
+ workerPackage: resolveOutput(outputDirectory, CLOUDFLARE_WORKER_PACKAGE_FILE),
23
+ publicAssets: resolveOutput(outputDirectory, CLOUDFLARE_PUBLIC_ASSETS_DIRECTORY),
24
+ workerBundle: resolveOutput(outputDirectory, CLOUDFLARE_WORKER_BUNDLE_DIRECTORY)
25
+ },
26
+ packages: {
27
+ output: {
28
+ type: CLOUDFLARE_OUTPUT_PACKAGE_TYPE
29
+ },
30
+ worker: {
31
+ type: CLOUDFLARE_WORKER_PACKAGE_TYPE
32
+ }
33
+ },
34
+ wrangler: {
35
+ main: CLOUDFLARE_WORKER_ENTRY,
36
+ assets: {
37
+ binding: CLOUDFLARE_ASSETS_BINDING,
38
+ directory: `./${CLOUDFLARE_PUBLIC_ASSETS_DIRECTORY}`,
39
+ run_worker_first: true
40
+ },
41
+ requiredCompatibilityFlags: CLOUDFLARE_REQUIRED_COMPATIBILITY_FLAGS
42
+ }
43
+ };
44
+ }
45
+ export { createCloudflareOutputPlan };
@@ -0,0 +1,45 @@
1
+ import { DELIVERY_UNIT_IDENTITY_FIELDS, deliveryUnitIdentityFieldValue } from "@modern-js/utils/universal";
2
+ import { addIssue, assertEqual } from "./issues.mjs";
3
+ const verifyDeliveryUnitIdentity = (issues, manifest, manifestPath, declared)=>{
4
+ const stamped = manifest?.deliveryUnit;
5
+ const hasStamp = Boolean(stamped) && 'object' == typeof stamped;
6
+ if (declared) {
7
+ if (!hasStamp) return void addIssue(issues, {
8
+ code: 'missing-delivery-unit',
9
+ message: `Cloudflare worker manifest is missing the delivery-unit identity declared by the workspace topology (expected unitId ${declared.unitId}, buildMarker ${declared.buildMarker}).`,
10
+ path: manifestPath
11
+ });
12
+ for (const field of DELIVERY_UNIT_IDENTITY_FIELDS){
13
+ const stampedValue = deliveryUnitIdentityFieldValue(stamped, field);
14
+ assertEqual(issues, stampedValue, declared[field], {
15
+ code: 'delivery-unit-drift',
16
+ message: `Cloudflare worker manifest deliveryUnit.${field} must match the topology delivery-unit record (expected ${declared[field]}, received ${stampedValue ?? 'undefined'}).`,
17
+ path: manifestPath
18
+ });
19
+ }
20
+ }
21
+ if (hasStamp && stamped.surfaces && 'object' == typeof stamped.surfaces) for (const surface of [
22
+ 'ui',
23
+ 'api'
24
+ ]){
25
+ const marker = stamped.surfaces[surface];
26
+ if (!marker || 'object' != typeof marker) {
27
+ addIssue(issues, {
28
+ code: 'missing-delivery-unit',
29
+ message: `Cloudflare worker manifest is missing the ${surface} delivery-unit surface marker.`,
30
+ path: manifestPath
31
+ });
32
+ continue;
33
+ }
34
+ for (const field of DELIVERY_UNIT_IDENTITY_FIELDS){
35
+ const markerValue = deliveryUnitIdentityFieldValue(marker, field);
36
+ const stampedValue = deliveryUnitIdentityFieldValue(stamped, field);
37
+ assertEqual(issues, markerValue, stampedValue, {
38
+ code: 'delivery-unit-drift',
39
+ message: `Cloudflare worker manifest ${surface} surface deliveryUnit.${field} must derive from one delivery-unit record (expected ${stampedValue ?? 'undefined'}, received ${markerValue ?? 'undefined'}).`,
40
+ path: manifestPath
41
+ });
42
+ }
43
+ }
44
+ };
45
+ export { verifyDeliveryUnitIdentity };
@@ -0,0 +1,133 @@
1
+ import promises from "node:fs/promises";
2
+ import node_path from "node:path";
3
+ import { createCloudflareOutputPlan } from "../cloudflare-output-plan.mjs";
4
+ import { verifyDeliveryUnitIdentity } from "./identity.mjs";
5
+ import { addIssue, assertEqual, assertFlag } from "./issues.mjs";
6
+ import { verifyManifestShape } from "./manifest.mjs";
7
+ import { getEffectBffWorker, getWorkerBundleReferences, missingWorkerBundleMessage, resolveWorkerBundleReference, verifyWorkerBundleReferences, verifyWorkerImport } from "./worker-bundles.mjs";
8
+ const pathExists = async (filePath)=>{
9
+ try {
10
+ await promises.access(filePath);
11
+ return true;
12
+ } catch {
13
+ return false;
14
+ }
15
+ };
16
+ const readJson = async (filePath)=>JSON.parse(await promises.readFile(filePath, 'utf-8'));
17
+ const verifyCloudflareOutput = async (options)=>{
18
+ const outputDirectory = node_path.resolve(options.outputDirectory);
19
+ const issues = [];
20
+ const outputPlan = createCloudflareOutputPlan(outputDirectory);
21
+ for (const relativePath of outputPlan.requiredFiles){
22
+ const filePath = node_path.join(outputDirectory, relativePath);
23
+ if (!await pathExists(filePath)) addIssue(issues, {
24
+ code: 'missing-file',
25
+ message: `Cloudflare output is missing ${relativePath}.`,
26
+ path: filePath
27
+ });
28
+ }
29
+ const manifestPath = outputPlan.paths.workerManifest;
30
+ const wranglerPath = outputPlan.paths.wranglerConfig;
31
+ const packagePath = outputPlan.paths.outputPackage;
32
+ const workerPackagePath = outputPlan.paths.workerPackage;
33
+ const manifest = await pathExists(manifestPath) ? await readJson(manifestPath) : void 0;
34
+ const wrangler = await pathExists(wranglerPath) ? await readJson(wranglerPath) : void 0;
35
+ const outputPackage = await pathExists(packagePath) ? await readJson(packagePath) : void 0;
36
+ const workerPackage = await pathExists(workerPackagePath) ? await readJson(workerPackagePath) : void 0;
37
+ if (manifest) {
38
+ verifyManifestShape(issues, manifest, manifestPath);
39
+ verifyDeliveryUnitIdentity(issues, manifest, manifestPath, options.deliveryUnit);
40
+ const workerReferences = getWorkerBundleReferences(manifest);
41
+ const providedWorkerPackages = new Set(workerPackage?.dependencies && 'object' == typeof workerPackage.dependencies ? Object.keys(workerPackage.dependencies) : []);
42
+ if (workerReferences.length > 0 && !await pathExists(workerPackagePath)) addIssue(issues, {
43
+ code: 'missing-file',
44
+ message: 'Cloudflare output is missing worker/package.json for referenced worker bundles.',
45
+ path: workerPackagePath
46
+ });
47
+ if (manifest.bff?.runtimeFramework === 'effect' && !getEffectBffWorker(manifest)) addIssue(issues, {
48
+ code: 'missing-worker-bundle',
49
+ message: 'Cloudflare Effect BFF manifest points to a missing worker bundle.'
50
+ });
51
+ for (const workerReference of workerReferences){
52
+ const resolvedWorker = resolveWorkerBundleReference(issues, outputDirectory, workerReference, manifestPath);
53
+ if (!resolvedWorker) continue;
54
+ const workerExists = await pathExists(resolvedWorker.path);
55
+ if (!workerExists) addIssue(issues, {
56
+ code: 'missing-worker-bundle',
57
+ message: missingWorkerBundleMessage(workerReference),
58
+ path: resolvedWorker.path
59
+ });
60
+ if (workerExists) {
61
+ const workerSource = await promises.readFile(resolvedWorker.path, 'utf-8');
62
+ await verifyWorkerBundleReferences(issues, resolvedWorker, workerSource, {
63
+ providedPackages: providedWorkerPackages,
64
+ workerRoot: outputPlan.paths.workerBundle
65
+ });
66
+ if ('effect-bff' === resolvedWorker.kind && (workerSource.includes(';entityKind;') || workerSource.includes(';entityKind,entityKind;'))) addIssue(issues, {
67
+ code: 'invalid-worker-bundle',
68
+ message: 'Cloudflare Effect BFF worker bundle contains invalid Drizzle entityKind marker references.',
69
+ path: resolvedWorker.path
70
+ });
71
+ }
72
+ }
73
+ }
74
+ if (wrangler) {
75
+ assertEqual(issues, wrangler.main, outputPlan.wrangler.main, {
76
+ code: 'invalid-wrangler',
77
+ message: `wrangler.json main must be ${outputPlan.wrangler.main}.`,
78
+ path: wranglerPath
79
+ });
80
+ assertEqual(issues, wrangler.assets?.binding, outputPlan.wrangler.assets.binding, {
81
+ code: 'invalid-wrangler',
82
+ message: 'wrangler.json assets.binding must be ASSETS.',
83
+ path: wranglerPath
84
+ });
85
+ assertEqual(issues, wrangler.assets?.directory, outputPlan.wrangler.assets.directory, {
86
+ code: 'invalid-wrangler',
87
+ message: 'wrangler.json assets.directory must be ./public.',
88
+ path: wranglerPath
89
+ });
90
+ assertEqual(issues, wrangler.assets?.run_worker_first, outputPlan.wrangler.assets.run_worker_first, {
91
+ code: 'invalid-wrangler',
92
+ message: 'wrangler.json assets.run_worker_first must be true.',
93
+ path: wranglerPath
94
+ });
95
+ for (const flag of outputPlan.wrangler.requiredCompatibilityFlags)assertFlag(issues, wrangler.compatibility_flags, flag, {
96
+ code: 'invalid-wrangler',
97
+ message: `wrangler.json compatibility_flags must include ${flag}.`,
98
+ path: wranglerPath
99
+ });
100
+ }
101
+ if (outputPackage) assertEqual(issues, outputPackage.type, outputPlan.packages.output.type, {
102
+ code: 'invalid-package',
103
+ message: '.output/package.json must declare type module.',
104
+ path: packagePath
105
+ });
106
+ if (workerPackage) assertEqual(issues, workerPackage.type, outputPlan.packages.worker.type, {
107
+ code: 'invalid-package',
108
+ message: '.output/worker/package.json must declare type commonjs.',
109
+ path: workerPackagePath
110
+ });
111
+ for (const leakedPath of outputPlan.publicLeakDirectories){
112
+ const publicPath = node_path.join(outputPlan.paths.publicAssets, leakedPath);
113
+ if (await pathExists(publicPath)) addIssue(issues, {
114
+ code: 'public-output-leak',
115
+ message: `Framework-owned ${leakedPath} output leaked into public assets.`,
116
+ path: publicPath
117
+ });
118
+ }
119
+ if (false !== options.importWorker && await pathExists(outputPlan.paths.workerEntry)) await verifyWorkerImport(issues, outputPlan.paths.workerEntry);
120
+ return {
121
+ ok: 0 === issues.length,
122
+ issues
123
+ };
124
+ };
125
+ const assertCloudflareOutput = async (options)=>{
126
+ const result = await verifyCloudflareOutput(options);
127
+ if (!result.ok) throw new Error([
128
+ 'Cloudflare output verification failed:',
129
+ ...result.issues.map((issue)=>`- ${issue.code}: ${issue.message}${issue.path ? ` (${issue.path})` : ''}`)
130
+ ].join('\n'));
131
+ };
132
+ export { verifyCloudflareOutputMutationPolicy } from "./mutation-policy.mjs";
133
+ export { assertCloudflareOutput, verifyCloudflareOutput };
@@ -0,0 +1,10 @@
1
+ const addIssue = (issues, issue)=>{
2
+ issues.push(issue);
3
+ };
4
+ const assertEqual = (issues, actual, expected, issue)=>{
5
+ if (actual !== expected) addIssue(issues, issue);
6
+ };
7
+ const assertFlag = (issues, flags, flag, issue)=>{
8
+ if (!Array.isArray(flags) || !flags.includes(flag)) addIssue(issues, issue);
9
+ };
10
+ export { addIssue, assertEqual, assertFlag };
@@ -0,0 +1,51 @@
1
+ import { BFF_EFFECT_WORKER_DISPATCHER_EXPORT } from "../cloudflare/constants.mjs";
2
+ import { CLOUDFLARE_ASSETS_BINDING, CLOUDFLARE_PUBLIC_ASSETS_DIRECTORY, CLOUDFLARE_RUNTIME_TYPE, CLOUDFLARE_WORKER_ENTRY } from "../cloudflare-output-contract.mjs";
3
+ import { addIssue, assertEqual } from "./issues.mjs";
4
+ const verifyManifestShape = (issues, manifest, manifestPath)=>{
5
+ assertEqual(issues, manifest.runtime?.type, CLOUDFLARE_RUNTIME_TYPE, {
6
+ code: 'invalid-manifest',
7
+ message: 'Cloudflare output manifest runtime.type must be cloudflare-module-worker.',
8
+ path: manifestPath
9
+ });
10
+ assertEqual(issues, manifest.runtime?.entry, CLOUDFLARE_WORKER_ENTRY, {
11
+ code: 'invalid-manifest',
12
+ message: `Cloudflare output manifest runtime.entry must be ${CLOUDFLARE_WORKER_ENTRY}.`,
13
+ path: manifestPath
14
+ });
15
+ assertEqual(issues, manifest.runtime?.fetchExport, true, {
16
+ code: 'invalid-manifest',
17
+ message: 'Cloudflare output manifest runtime.fetchExport must be true.',
18
+ path: manifestPath
19
+ });
20
+ assertEqual(issues, manifest.runtime?.nodeListen, false, {
21
+ code: 'invalid-manifest',
22
+ message: 'Cloudflare output manifest runtime.nodeListen must be false.',
23
+ path: manifestPath
24
+ });
25
+ assertEqual(issues, manifest.assets?.binding, CLOUDFLARE_ASSETS_BINDING, {
26
+ code: 'invalid-manifest',
27
+ message: 'Cloudflare output manifest assets.binding must be ASSETS.',
28
+ path: manifestPath
29
+ });
30
+ assertEqual(issues, manifest.assets?.directory, `./${CLOUDFLARE_PUBLIC_ASSETS_DIRECTORY}`, {
31
+ code: 'invalid-manifest',
32
+ message: 'Cloudflare output manifest assets.directory must be ./public.',
33
+ path: manifestPath
34
+ });
35
+ assertEqual(issues, manifest.assets?.runWorkerFirst, true, {
36
+ code: 'invalid-manifest',
37
+ message: 'Cloudflare output manifest assets.runWorkerFirst must be true.',
38
+ path: manifestPath
39
+ });
40
+ if (!Array.isArray(manifest.routeSpec?.routes)) addIssue(issues, {
41
+ code: 'invalid-manifest',
42
+ message: 'Cloudflare output manifest routeSpec.routes must be array.',
43
+ path: manifestPath
44
+ });
45
+ if (manifest.bff?.runtimeFramework === 'effect') assertEqual(issues, manifest.bff.dispatcherExport, BFF_EFFECT_WORKER_DISPATCHER_EXPORT, {
46
+ code: 'invalid-manifest',
47
+ message: `Cloudflare Effect BFF manifest dispatcherExport must be ${BFF_EFFECT_WORKER_DISPATCHER_EXPORT}.`,
48
+ path: manifestPath
49
+ });
50
+ };
51
+ export { verifyManifestShape };
@@ -0,0 +1,99 @@
1
+ import promises from "node:fs/promises";
2
+ import node_path from "node:path";
3
+ import { addIssue } from "./issues.mjs";
4
+ const SOURCE_SCAN_FILE_PATTERN = /\.(?:[cm]?[jt]s|json)$/u;
5
+ const SOURCE_SCAN_IGNORED_DIRECTORY_NAMES = new Set([
6
+ '.codex',
7
+ '.fastcontext',
8
+ '.git',
9
+ '.mf',
10
+ '.modernjs',
11
+ '.output',
12
+ 'coverage',
13
+ 'dist',
14
+ 'dist-cloudflare',
15
+ 'node_modules',
16
+ 'repos',
17
+ 'topology'
18
+ ]);
19
+ const FORBIDDEN_MUTATION_PATTERNS = [
20
+ {
21
+ code: 'forbidden-mutation-pattern',
22
+ message: "Generated Cloudflare server worker output must not be rewritten by app scripts.",
23
+ pattern: /\.output\/server\/index\.mjs/u
24
+ },
25
+ {
26
+ code: 'forbidden-mutation-pattern',
27
+ message: "Generated Cloudflare server worker output must not be rewritten by app scripts.",
28
+ pattern: /path\.(?:join|resolve)\(\s*['"`]\.output['"`]\s*,\s*['"`]server['"`]\s*,\s*['"`]index\.mjs['"`]\s*\)/u
29
+ },
30
+ {
31
+ code: 'forbidden-mutation-pattern',
32
+ message: "Generated Cloudflare BFF worker bundles must not be rewritten by app scripts.",
33
+ pattern: /\.output\/worker\/[^'"`]*\.(?:mjs|cjs|js)/u
34
+ },
35
+ {
36
+ code: 'forbidden-mutation-pattern',
37
+ message: "Generated Cloudflare BFF worker bundles must not be rewritten by app scripts.",
38
+ pattern: /path\.(?:join|resolve)\(\s*['"`]\.output['"`]\s*,\s*['"`]worker['"`]\s*,\s*['"`][^'"`]+\.(?:mjs|cjs|js)['"`]\s*\)/u
39
+ },
40
+ {
41
+ code: 'forbidden-mutation-pattern',
42
+ message: "Drizzle entityKind worker bundle markers must be fixed in the framework toolchain, not post-build scripts.",
43
+ pattern: /replaceAll\(\s*['"`];entityKind(?:,entityKind)?;/u
44
+ },
45
+ {
46
+ code: 'forbidden-mutation-pattern',
47
+ message: "Effect BFF Cloudflare dispatch must not depend on duck-typed runtime helper probing in app scripts.",
48
+ pattern: /(?:typeof\s+[^;\n]*dispatchEffectBffRequest|['"`]dispatchEffectBffRequest['"`]\s+in\s+|\.dispatchEffectBffRequest\b)/u
49
+ },
50
+ {
51
+ code: 'forbidden-mutation-pattern',
52
+ message: "Effect BFF Cloudflare dispatch must not branch on handler.length in app scripts.",
53
+ pattern: /\bhandler\s*\.\s*length\b/u
54
+ }
55
+ ];
56
+ const pathExists = async (filePath)=>{
57
+ try {
58
+ await promises.access(filePath);
59
+ return true;
60
+ } catch {
61
+ return false;
62
+ }
63
+ };
64
+ const walkFiles = async (root)=>{
65
+ if (!await pathExists(root)) return [];
66
+ const entries = await promises.readdir(root, {
67
+ withFileTypes: true
68
+ });
69
+ const files = [];
70
+ for (const entry of entries){
71
+ if (SOURCE_SCAN_IGNORED_DIRECTORY_NAMES.has(entry.name)) continue;
72
+ const entryPath = node_path.join(root, entry.name);
73
+ if (entry.isDirectory()) {
74
+ files.push(...await walkFiles(entryPath));
75
+ continue;
76
+ }
77
+ if (SOURCE_SCAN_FILE_PATTERN.test(entry.name)) files.push(entryPath);
78
+ }
79
+ return files;
80
+ };
81
+ const verifyCloudflareOutputMutationPolicy = async (options)=>{
82
+ const issues = [];
83
+ const excludedFiles = new Set((options.excludePaths ?? []).map((entry)=>node_path.resolve(entry)));
84
+ const files = (await Promise.all(options.scanRoots.map((scanRoot)=>walkFiles(node_path.resolve(scanRoot))))).flat();
85
+ for (const file of files){
86
+ if (excludedFiles.has(file)) continue;
87
+ const source = await promises.readFile(file, 'utf-8');
88
+ for (const forbidden of FORBIDDEN_MUTATION_PATTERNS)if (forbidden.pattern.test(source)) addIssue(issues, {
89
+ code: forbidden.code,
90
+ message: forbidden.message,
91
+ path: file
92
+ });
93
+ }
94
+ return {
95
+ ok: 0 === issues.length,
96
+ issues
97
+ };
98
+ };
99
+ export { verifyCloudflareOutputMutationPolicy, walkFiles };