@ecopages/core 0.2.0-alpha.53 → 0.2.0-alpha.54

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 (590) hide show
  1. package/README.md +2 -3
  2. package/package.json +97 -182
  3. package/src/adapters/abstract/application-adapter.test.ts +218 -0
  4. package/src/adapters/abstract/application-adapter.ts +379 -0
  5. package/src/adapters/abstract/router-adapter.ts +30 -0
  6. package/src/adapters/abstract/server-adapter.ts +79 -0
  7. package/src/adapters/bun/client-bridge.ts +62 -0
  8. package/src/adapters/bun/create-app.ts +214 -0
  9. package/src/adapters/bun/hmr-manager.test.ts +265 -0
  10. package/src/adapters/bun/hmr-manager.ts +88 -0
  11. package/src/adapters/bun/index.ts +2 -0
  12. package/src/adapters/bun/runtime-host.ts +76 -0
  13. package/src/adapters/bun/server-adapter.ts +605 -0
  14. package/src/adapters/bun/static-preview-host.ts +70 -0
  15. package/src/adapters/create-app.test.ts +10 -0
  16. package/src/adapters/create-app.ts +91 -0
  17. package/src/adapters/index.ts +2 -0
  18. package/src/adapters/node/create-app.test.ts +76 -0
  19. package/src/adapters/node/create-app.ts +116 -0
  20. package/src/adapters/node/http-request-bridge.test.ts +146 -0
  21. package/src/adapters/node/http-request-bridge.ts +176 -0
  22. package/src/adapters/node/node-client-bridge.test.ts +198 -0
  23. package/src/adapters/node/node-client-bridge.ts +79 -0
  24. package/src/adapters/node/node-hmr-manager.test.ts +374 -0
  25. package/src/adapters/node/node-hmr-manager.ts +72 -0
  26. package/src/adapters/node/runtime-host.test.ts +49 -0
  27. package/src/adapters/node/runtime-host.ts +113 -0
  28. package/src/adapters/node/server-adapter-dependencies.ts +28 -0
  29. package/src/adapters/node/server-adapter.test.ts +84 -0
  30. package/src/adapters/node/server-adapter.ts +423 -0
  31. package/src/adapters/node/static-content-server.test.ts +60 -0
  32. package/src/adapters/node/static-content-server.ts +239 -0
  33. package/src/adapters/node/static-preview-host.test.ts +89 -0
  34. package/src/adapters/node/static-preview-host.ts +101 -0
  35. package/src/adapters/shared/api-response.test.ts +97 -0
  36. package/src/adapters/shared/api-response.ts +104 -0
  37. package/src/adapters/shared/application-adapter.ts +199 -0
  38. package/src/adapters/shared/define-api-handler.ts +66 -0
  39. package/src/adapters/shared/explicit-static-render-preparation.ts +58 -0
  40. package/src/adapters/shared/explicit-static-route-matcher.test.ts +381 -0
  41. package/src/adapters/shared/explicit-static-route-matcher.ts +131 -0
  42. package/src/adapters/shared/file-route-middleware-pipeline.test.ts +85 -0
  43. package/src/adapters/shared/file-route-middleware-pipeline.ts +118 -0
  44. package/src/adapters/shared/fs-server-response-factory.test.ts +176 -0
  45. package/src/adapters/shared/fs-server-response-factory.ts +96 -0
  46. package/src/adapters/shared/fs-server-response-matcher.test.ts +311 -0
  47. package/src/adapters/shared/fs-server-response-matcher.ts +240 -0
  48. package/src/adapters/shared/hmr-entrypoint-registrar.ts +149 -0
  49. package/src/adapters/shared/hmr-html-response.ts +54 -0
  50. package/src/adapters/shared/hmr-manager.contract.test.ts +228 -0
  51. package/src/adapters/shared/hmr-manager.dispatch.test.ts +229 -0
  52. package/src/adapters/shared/render-context.test.ts +244 -0
  53. package/src/adapters/shared/render-context.ts +161 -0
  54. package/src/adapters/shared/runtime-app-bootstrap.test.ts +96 -0
  55. package/src/adapters/shared/runtime-app-bootstrap.ts +72 -0
  56. package/src/adapters/shared/runtime-host.ts +11 -0
  57. package/src/adapters/shared/server-adapter.test.ts +130 -0
  58. package/src/adapters/shared/server-adapter.ts +571 -0
  59. package/src/adapters/shared/server-route-handler.test.ts +112 -0
  60. package/src/adapters/shared/server-route-handler.ts +153 -0
  61. package/src/adapters/shared/server-static-builder.test.ts +338 -0
  62. package/src/adapters/shared/server-static-builder.ts +170 -0
  63. package/src/adapters/shared/shared-hmr-manager.ts +298 -0
  64. package/src/adapters/shared/static-preview-host.ts +12 -0
  65. package/src/build/README.md +57 -73
  66. package/src/build/browser-runtime-manifest.test.ts +121 -0
  67. package/src/build/browser-runtime-manifest.ts +105 -0
  68. package/src/build/browser-runtime-plugin-helpers.test.ts +49 -0
  69. package/src/build/browser-runtime-plugin-helpers.ts +37 -0
  70. package/src/build/browser-runtime-plugin.test.ts +256 -0
  71. package/src/build/browser-runtime-plugin.ts +306 -0
  72. package/src/build/build-adapter.test.ts +463 -0
  73. package/src/build/build-adapter.ts +788 -0
  74. package/src/build/build-manifest.ts +79 -0
  75. package/src/build/build-types.ts +83 -0
  76. package/src/build/rolldown-build-adapter.test.ts +352 -0
  77. package/src/build/rolldown-build-adapter.ts +363 -0
  78. package/src/build/rolldown-plugin-bridge.test.ts +256 -0
  79. package/src/build/rolldown-plugin-bridge.ts +309 -0
  80. package/src/build/runtime-build-executor.test.ts +130 -0
  81. package/src/build/runtime-build-executor.ts +37 -0
  82. package/src/build/runtime-build-output-normalizer.ts +137 -0
  83. package/src/build/serialized-build-executor.test.ts +96 -0
  84. package/src/build/serialized-build-executor.ts +90 -0
  85. package/src/build/server-side-css-shim-plugin.ts +77 -0
  86. package/src/cache/index.ts +6 -0
  87. package/src/cache/module-parse-cache.test.ts +73 -0
  88. package/src/cache/module-parse-cache.ts +137 -0
  89. package/src/config/README.md +1 -1
  90. package/src/config/config-builder.test.ts +456 -0
  91. package/src/config/config-builder.ts +728 -0
  92. package/src/config/config-builder.typecheck.test.ts +96 -0
  93. package/src/config/{constants.d.ts → constants.ts} +22 -13
  94. package/src/dev/host-runtime.ts +34 -0
  95. package/src/dev/sc-server.ts +143 -0
  96. package/src/eco/eco.browser.test.ts +43 -0
  97. package/src/eco/eco.browser.ts +137 -0
  98. package/src/eco/eco.test.ts +781 -0
  99. package/src/eco/eco.ts +262 -0
  100. package/src/eco/eco.types.ts +293 -0
  101. package/src/eco/eco.utils.test.ts +219 -0
  102. package/src/eco/eco.utils.ts +5 -0
  103. package/src/eco/global-injector-map.test.ts +42 -0
  104. package/src/eco/global-injector-map.ts +112 -0
  105. package/src/eco/lazy-injector-map.test.ts +66 -0
  106. package/src/eco/lazy-injector-map.ts +120 -0
  107. package/src/eco/module-dependencies.test.ts +30 -0
  108. package/src/eco/module-dependencies.ts +75 -0
  109. package/src/errors/http-error.test.ts +134 -0
  110. package/src/errors/http-error.ts +72 -0
  111. package/src/errors/index.ts +3 -0
  112. package/src/errors/locals-access-error.ts +7 -0
  113. package/src/global/app-logger.ts +4 -0
  114. package/src/global/utils.test.ts +12 -0
  115. package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-HMR-Server-Integration-should-have-HMR-script-injected-in-page-1.png +0 -0
  116. package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-HMR-Server-Integration-should-load-fixture-app-page-1.png +0 -0
  117. package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-WebSocket-Connection-should-connect-to-correct-HMR-endpoint-1.png +0 -0
  118. package/src/hmr/client/hmr-runtime.ts +162 -0
  119. package/src/hmr/hmr-strategy.test.ts +124 -0
  120. package/src/hmr/hmr-strategy.ts +177 -0
  121. package/src/hmr/hmr.postcss.test.e2e.ts +41 -0
  122. package/src/hmr/hmr.test.e2e.ts +66 -0
  123. package/src/hmr/strategies/default-hmr-strategy.ts +60 -0
  124. package/src/hmr/strategies/js-hmr-strategy.test.ts +344 -0
  125. package/src/hmr/strategies/js-hmr-strategy.ts +307 -0
  126. package/src/index.browser.ts +3 -0
  127. package/src/index.ts +15 -0
  128. package/src/integrations/ghtml/ghtml-renderer.test.ts +253 -0
  129. package/src/integrations/ghtml/ghtml-renderer.ts +87 -0
  130. package/src/integrations/ghtml/ghtml.constants.ts +1 -0
  131. package/src/integrations/ghtml/ghtml.plugin.ts +28 -0
  132. package/src/plugins/alias-resolver-cache.test.ts +110 -0
  133. package/src/plugins/alias-resolver-cache.ts +145 -0
  134. package/src/plugins/alias-resolver-plugin.test.ts +41 -0
  135. package/src/plugins/alias-resolver-plugin.ts +75 -0
  136. package/src/plugins/eco-component-meta-plugin.test.ts +421 -0
  137. package/src/plugins/eco-component-meta-plugin.ts +518 -0
  138. package/src/plugins/foreign-jsx-override-plugin.test.ts +65 -0
  139. package/src/plugins/foreign-jsx-override-plugin.ts +76 -0
  140. package/src/plugins/integration-plugin.test.ts +151 -0
  141. package/src/plugins/integration-plugin.ts +344 -0
  142. package/src/plugins/processor.test.ts +148 -0
  143. package/src/plugins/processor.ts +257 -0
  144. package/src/plugins/{runtime-capability.d.ts → runtime-capability.ts} +8 -3
  145. package/src/plugins/source-transform.test.ts +82 -0
  146. package/src/plugins/source-transform.ts +123 -0
  147. package/src/route-renderer/orchestration/component-render-context.ts +338 -0
  148. package/src/route-renderer/orchestration/declared-ownership-graph.ts +62 -0
  149. package/src/route-renderer/orchestration/foreign-subtree-execution.service.ts +431 -0
  150. package/src/route-renderer/orchestration/integration-renderer.test.ts +2251 -0
  151. package/src/route-renderer/orchestration/integration-renderer.ts +1384 -0
  152. package/src/route-renderer/orchestration/ownership-planning.service.ts +97 -0
  153. package/src/route-renderer/orchestration/ownership-validation.service.ts +76 -0
  154. package/src/route-renderer/orchestration/processed-asset-dedupe.ts +29 -0
  155. package/src/route-renderer/orchestration/queued-foreign-subtree-resolution.service.test.ts +435 -0
  156. package/src/route-renderer/orchestration/queued-foreign-subtree-resolution.service.ts +310 -0
  157. package/src/route-renderer/orchestration/render-output.utils.ts +310 -0
  158. package/src/route-renderer/orchestration/route-render-orchestrator.prepare-render-options.test.ts +1365 -0
  159. package/src/route-renderer/orchestration/route-render-orchestrator.test.ts +267 -0
  160. package/src/route-renderer/orchestration/route-render-orchestrator.ts +879 -0
  161. package/src/route-renderer/orchestration/template-serialization.test.ts +110 -0
  162. package/src/route-renderer/orchestration/template-serialization.ts +117 -0
  163. package/src/route-renderer/page-loading/component-dependency-collection.ts +202 -0
  164. package/src/route-renderer/page-loading/declared-asset-collection.ts +153 -0
  165. package/src/route-renderer/page-loading/dependency-resolver.test.ts +761 -0
  166. package/src/route-renderer/page-loading/dependency-resolver.ts +144 -0
  167. package/src/route-renderer/page-loading/ecopages-virtual-imports.ts +75 -0
  168. package/src/route-renderer/page-loading/lazy-entry-collection.ts +167 -0
  169. package/src/route-renderer/page-loading/lazy-trigger-planning.ts +74 -0
  170. package/src/route-renderer/page-loading/module-declaration-aggregation.ts +60 -0
  171. package/src/route-renderer/page-loading/module-declaration-scripts.ts +16 -0
  172. package/src/route-renderer/page-loading/page-dependency-bundling.ts +244 -0
  173. package/src/route-renderer/page-loading/page-module-loader.test.ts +183 -0
  174. package/src/route-renderer/page-loading/page-module-loader.ts +184 -0
  175. package/src/route-renderer/route-renderer.ts +133 -0
  176. package/src/router/client/link-intent.test.browser.ts +51 -0
  177. package/src/router/client/link-intent.ts +92 -0
  178. package/src/router/client/navigation-coordinator.test.ts +237 -0
  179. package/src/router/client/navigation-coordinator.ts +453 -0
  180. package/src/router/server/route-registry.test.ts +176 -0
  181. package/src/router/server/route-registry.ts +382 -0
  182. package/src/services/assets/asset-processing-service/asset-dependency-keys.ts +66 -0
  183. package/src/services/assets/asset-processing-service/asset-processing.service.test.ts +473 -0
  184. package/src/services/assets/asset-processing-service/asset-processing.service.ts +344 -0
  185. package/src/services/assets/asset-processing-service/asset.factory.test.ts +63 -0
  186. package/src/services/assets/asset-processing-service/asset.factory.ts +105 -0
  187. package/src/services/assets/asset-processing-service/assets.types.ts +128 -0
  188. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.test.ts +74 -0
  189. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.ts +98 -0
  190. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.test.ts +67 -0
  191. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.ts +78 -0
  192. package/src/services/assets/asset-processing-service/grouped-content-bundles.ts +104 -0
  193. package/src/services/assets/asset-processing-service/index.ts +6 -0
  194. package/src/services/assets/asset-processing-service/page-package.test.ts +135 -0
  195. package/src/services/assets/asset-processing-service/page-package.ts +103 -0
  196. package/src/services/assets/asset-processing-service/{processor.interface.d.ts → processor.interface.ts} +10 -5
  197. package/src/services/assets/asset-processing-service/processor.registry.ts +18 -0
  198. package/src/services/assets/asset-processing-service/processors/base/base-processor.test.ts +59 -0
  199. package/src/services/assets/asset-processing-service/processors/base/base-processor.ts +83 -0
  200. package/src/services/assets/asset-processing-service/processors/base/base-script-processor.ts +173 -0
  201. package/src/services/assets/asset-processing-service/processors/index.ts +5 -0
  202. package/src/services/assets/asset-processing-service/processors/script/content-script.processor.test.ts +188 -0
  203. package/src/services/assets/asset-processing-service/processors/script/content-script.processor.ts +138 -0
  204. package/src/services/assets/asset-processing-service/processors/script/file-script.processor.test.ts +326 -0
  205. package/src/services/assets/asset-processing-service/processors/script/file-script.processor.ts +116 -0
  206. package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.test.ts +270 -0
  207. package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.ts +145 -0
  208. package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.test.ts +261 -0
  209. package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.ts +72 -0
  210. package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.ts +83 -0
  211. package/src/services/assets/asset-processing-service/ungrouped-dependency-processing.ts +65 -0
  212. package/src/services/assets/browser-bundle.service.test.ts +66 -0
  213. package/src/services/assets/browser-bundle.service.ts +109 -0
  214. package/src/services/cache/cache.types.ts +126 -0
  215. package/src/services/cache/index.ts +18 -0
  216. package/src/services/cache/memory-cache-store.test.ts +225 -0
  217. package/src/services/cache/memory-cache-store.ts +130 -0
  218. package/src/services/cache/page-cache-service.test.ts +175 -0
  219. package/src/services/cache/page-cache-service.ts +202 -0
  220. package/src/services/cache/page-request-cache-coordinator.service.test.ts +79 -0
  221. package/src/services/cache/page-request-cache-coordinator.service.ts +131 -0
  222. package/src/services/html/html-rewriter-provider.service.test.ts +183 -0
  223. package/src/services/html/html-rewriter-provider.service.ts +105 -0
  224. package/src/services/html/html-transformer.service.test.ts +544 -0
  225. package/src/services/html/html-transformer.service.ts +369 -0
  226. package/src/services/invalidation/development-invalidation.service.test.ts +87 -0
  227. package/src/services/invalidation/development-invalidation.service.ts +262 -0
  228. package/src/services/module-loading/app-module-loader.service.ts +9 -0
  229. package/src/services/module-loading/app-server-module-transpiler.service.test.ts +297 -0
  230. package/src/services/module-loading/app-server-module-transpiler.service.ts +168 -0
  231. package/src/services/module-loading/host-module-loader-registry.ts +15 -0
  232. package/src/services/module-loading/{module-loading-types.d.ts → module-loading-types.ts} +1 -0
  233. package/src/services/module-loading/page-module-import.service.test.ts +652 -0
  234. package/src/services/module-loading/page-module-import.service.ts +302 -0
  235. package/src/services/module-loading/server-module-transpiler.service.test.ts +242 -0
  236. package/src/services/module-loading/server-module-transpiler.service.ts +104 -0
  237. package/src/services/module-loading/source-module-support.ts +19 -0
  238. package/src/services/runtime-state/dev-graph.service.ts +217 -0
  239. package/src/services/runtime-state/entrypoint-dependency-graph.service.ts +136 -0
  240. package/src/services/runtime-state/server-invalidation-state.service.ts +68 -0
  241. package/src/services/validation/schema-validation-service.test.ts +223 -0
  242. package/src/services/validation/schema-validation-service.ts +204 -0
  243. package/src/services/validation/{standard-schema.types.d.ts → standard-schema.types.ts} +20 -17
  244. package/src/static-site-generator/static-site-generator.test.ts +408 -0
  245. package/src/static-site-generator/static-site-generator.ts +445 -0
  246. package/src/types/internal-types.ts +243 -0
  247. package/src/types/public-types.ts +1508 -0
  248. package/src/utils/deep-merge.test.ts +114 -0
  249. package/src/utils/deep-merge.ts +47 -0
  250. package/src/utils/hash.ts +5 -0
  251. package/src/utils/html-escaping.ts +9 -0
  252. package/src/utils/invariant.test.ts +22 -0
  253. package/src/utils/invariant.ts +15 -0
  254. package/src/utils/locals-utils.ts +37 -0
  255. package/src/utils/parse-cli-args.test.ts +69 -0
  256. package/src/utils/parse-cli-args.ts +105 -0
  257. package/src/utils/path-utils.module.ts +14 -0
  258. package/src/utils/path-utils.test.ts +15 -0
  259. package/src/utils/resolve-work-dir.ts +45 -0
  260. package/src/utils/runtime.ts +44 -0
  261. package/src/utils/server-utils.module.ts +67 -0
  262. package/src/utils/server-utils.test.ts +38 -0
  263. package/src/watchers/project-watcher.integration.test.ts +337 -0
  264. package/src/watchers/project-watcher.test-helpers.ts +42 -0
  265. package/src/watchers/project-watcher.test.ts +768 -0
  266. package/src/watchers/project-watcher.ts +357 -0
  267. package/src/adapters/abstract/application-adapter.d.ts +0 -194
  268. package/src/adapters/abstract/application-adapter.js +0 -121
  269. package/src/adapters/abstract/router-adapter.d.ts +0 -26
  270. package/src/adapters/abstract/router-adapter.js +0 -5
  271. package/src/adapters/abstract/server-adapter.d.ts +0 -69
  272. package/src/adapters/abstract/server-adapter.js +0 -15
  273. package/src/adapters/bun/client-bridge.d.ts +0 -34
  274. package/src/adapters/bun/client-bridge.js +0 -48
  275. package/src/adapters/bun/create-app.d.ts +0 -60
  276. package/src/adapters/bun/create-app.js +0 -140
  277. package/src/adapters/bun/hmr-manager.d.ts +0 -47
  278. package/src/adapters/bun/hmr-manager.js +0 -58
  279. package/src/adapters/bun/index.d.ts +0 -2
  280. package/src/adapters/bun/index.js +0 -8
  281. package/src/adapters/bun/runtime-host.d.ts +0 -52
  282. package/src/adapters/bun/runtime-host.js +0 -56
  283. package/src/adapters/bun/server-adapter.d.ts +0 -216
  284. package/src/adapters/bun/server-adapter.js +0 -445
  285. package/src/adapters/bun/static-preview-host.d.ts +0 -28
  286. package/src/adapters/bun/static-preview-host.js +0 -45
  287. package/src/adapters/create-app.d.ts +0 -20
  288. package/src/adapters/create-app.js +0 -66
  289. package/src/adapters/index.d.ts +0 -2
  290. package/src/adapters/index.js +0 -8
  291. package/src/adapters/node/create-app.d.ts +0 -24
  292. package/src/adapters/node/create-app.js +0 -92
  293. package/src/adapters/node/http-request-bridge.d.ts +0 -57
  294. package/src/adapters/node/http-request-bridge.js +0 -118
  295. package/src/adapters/node/node-client-bridge.d.ts +0 -26
  296. package/src/adapters/node/node-client-bridge.js +0 -66
  297. package/src/adapters/node/node-hmr-manager.d.ts +0 -52
  298. package/src/adapters/node/node-hmr-manager.js +0 -49
  299. package/src/adapters/node/runtime-host.d.ts +0 -57
  300. package/src/adapters/node/runtime-host.js +0 -92
  301. package/src/adapters/node/server-adapter-dependencies.d.ts +0 -19
  302. package/src/adapters/node/server-adapter-dependencies.js +0 -18
  303. package/src/adapters/node/server-adapter.d.ts +0 -138
  304. package/src/adapters/node/server-adapter.js +0 -315
  305. package/src/adapters/node/static-content-server.d.ts +0 -60
  306. package/src/adapters/node/static-content-server.js +0 -194
  307. package/src/adapters/node/static-preview-host.d.ts +0 -55
  308. package/src/adapters/node/static-preview-host.js +0 -68
  309. package/src/adapters/shared/api-response.d.ts +0 -52
  310. package/src/adapters/shared/api-response.js +0 -96
  311. package/src/adapters/shared/application-adapter.d.ts +0 -18
  312. package/src/adapters/shared/application-adapter.js +0 -90
  313. package/src/adapters/shared/define-api-handler.d.ts +0 -25
  314. package/src/adapters/shared/define-api-handler.js +0 -15
  315. package/src/adapters/shared/explicit-static-render-preparation.d.ts +0 -25
  316. package/src/adapters/shared/explicit-static-render-preparation.js +0 -26
  317. package/src/adapters/shared/explicit-static-route-matcher.d.ts +0 -41
  318. package/src/adapters/shared/explicit-static-route-matcher.js +0 -101
  319. package/src/adapters/shared/file-route-middleware-pipeline.d.ts +0 -62
  320. package/src/adapters/shared/file-route-middleware-pipeline.js +0 -90
  321. package/src/adapters/shared/fs-server-response-factory.d.ts +0 -23
  322. package/src/adapters/shared/fs-server-response-factory.js +0 -81
  323. package/src/adapters/shared/fs-server-response-matcher.d.ts +0 -75
  324. package/src/adapters/shared/fs-server-response-matcher.js +0 -186
  325. package/src/adapters/shared/hmr-entrypoint-registrar.d.ts +0 -55
  326. package/src/adapters/shared/hmr-entrypoint-registrar.js +0 -87
  327. package/src/adapters/shared/hmr-html-response.d.ts +0 -22
  328. package/src/adapters/shared/hmr-html-response.js +0 -33
  329. package/src/adapters/shared/render-context.d.ts +0 -16
  330. package/src/adapters/shared/render-context.js +0 -93
  331. package/src/adapters/shared/runtime-app-bootstrap.d.ts +0 -26
  332. package/src/adapters/shared/runtime-app-bootstrap.js +0 -46
  333. package/src/adapters/shared/runtime-host.d.ts +0 -12
  334. package/src/adapters/shared/runtime-host.js +0 -0
  335. package/src/adapters/shared/server-adapter.d.ts +0 -108
  336. package/src/adapters/shared/server-adapter.js +0 -436
  337. package/src/adapters/shared/server-route-handler.d.ts +0 -89
  338. package/src/adapters/shared/server-route-handler.js +0 -111
  339. package/src/adapters/shared/server-static-builder.d.ts +0 -71
  340. package/src/adapters/shared/server-static-builder.js +0 -100
  341. package/src/adapters/shared/shared-hmr-manager.d.ts +0 -59
  342. package/src/adapters/shared/shared-hmr-manager.js +0 -241
  343. package/src/adapters/shared/static-preview-host.d.ts +0 -10
  344. package/src/adapters/shared/static-preview-host.js +0 -0
  345. package/src/build/browser-runtime-import-rewrite-plugin.d.ts +0 -26
  346. package/src/build/browser-runtime-import-rewrite-plugin.js +0 -165
  347. package/src/build/browser-runtime-manifest.d.ts +0 -31
  348. package/src/build/browser-runtime-manifest.js +0 -61
  349. package/src/build/build-adapter.d.ts +0 -247
  350. package/src/build/build-adapter.js +0 -671
  351. package/src/build/build-manifest.d.ts +0 -33
  352. package/src/build/build-manifest.js +0 -52
  353. package/src/build/build-types.d.ts +0 -57
  354. package/src/build/build-types.js +0 -0
  355. package/src/build/dev-build-coordinator.d.ts +0 -72
  356. package/src/build/dev-build-coordinator.js +0 -154
  357. package/src/build/esbuild-build-adapter.d.ts +0 -79
  358. package/src/build/esbuild-build-adapter.js +0 -521
  359. package/src/build/runtime-build-executor.d.ts +0 -14
  360. package/src/build/runtime-build-executor.js +0 -22
  361. package/src/build/runtime-specifier-alias-plugin.d.ts +0 -15
  362. package/src/build/runtime-specifier-alias-plugin.js +0 -31
  363. package/src/config/config-builder.d.ts +0 -252
  364. package/src/config/config-builder.js +0 -598
  365. package/src/config/constants.js +0 -25
  366. package/src/dev/host-runtime.d.ts +0 -10
  367. package/src/dev/host-runtime.js +0 -24
  368. package/src/dev/sc-server.d.ts +0 -30
  369. package/src/dev/sc-server.js +0 -111
  370. package/src/eco/eco.browser.d.ts +0 -2
  371. package/src/eco/eco.browser.js +0 -88
  372. package/src/eco/eco.d.ts +0 -9
  373. package/src/eco/eco.js +0 -119
  374. package/src/eco/eco.types.d.ts +0 -233
  375. package/src/eco/eco.types.js +0 -0
  376. package/src/eco/eco.utils.d.ts +0 -1
  377. package/src/eco/eco.utils.js +0 -10
  378. package/src/eco/global-injector-map.d.ts +0 -16
  379. package/src/eco/global-injector-map.js +0 -80
  380. package/src/eco/lazy-injector-map.d.ts +0 -8
  381. package/src/eco/lazy-injector-map.js +0 -70
  382. package/src/eco/module-dependencies.d.ts +0 -18
  383. package/src/eco/module-dependencies.js +0 -49
  384. package/src/errors/http-error.d.ts +0 -31
  385. package/src/errors/http-error.js +0 -50
  386. package/src/errors/index.d.ts +0 -3
  387. package/src/errors/index.js +0 -6
  388. package/src/errors/locals-access-error.d.ts +0 -4
  389. package/src/errors/locals-access-error.js +0 -9
  390. package/src/global/app-logger.d.ts +0 -2
  391. package/src/global/app-logger.js +0 -6
  392. package/src/hmr/client/hmr-runtime.d.ts +0 -5
  393. package/src/hmr/client/hmr-runtime.js +0 -117
  394. package/src/hmr/hmr-strategy.d.ts +0 -162
  395. package/src/hmr/hmr-strategy.js +0 -44
  396. package/src/hmr/hmr.postcss.test.e2e.d.ts +0 -1
  397. package/src/hmr/hmr.postcss.test.e2e.js +0 -31
  398. package/src/hmr/hmr.test.e2e.d.ts +0 -1
  399. package/src/hmr/hmr.test.e2e.js +0 -43
  400. package/src/hmr/strategies/default-hmr-strategy.d.ts +0 -43
  401. package/src/hmr/strategies/default-hmr-strategy.js +0 -34
  402. package/src/hmr/strategies/js-hmr-strategy.d.ts +0 -134
  403. package/src/hmr/strategies/js-hmr-strategy.js +0 -173
  404. package/src/index.browser.d.ts +0 -3
  405. package/src/index.browser.js +0 -4
  406. package/src/index.d.ts +0 -6
  407. package/src/index.js +0 -21
  408. package/src/integrations/ghtml/ghtml-renderer.d.ts +0 -16
  409. package/src/integrations/ghtml/ghtml-renderer.js +0 -57
  410. package/src/integrations/ghtml/ghtml.constants.d.ts +0 -1
  411. package/src/integrations/ghtml/ghtml.constants.js +0 -4
  412. package/src/integrations/ghtml/ghtml.plugin.d.ts +0 -16
  413. package/src/integrations/ghtml/ghtml.plugin.js +0 -20
  414. package/src/plugins/alias-resolver-plugin.d.ts +0 -3
  415. package/src/plugins/alias-resolver-plugin.js +0 -61
  416. package/src/plugins/eco-component-meta-plugin.d.ts +0 -108
  417. package/src/plugins/eco-component-meta-plugin.js +0 -175
  418. package/src/plugins/foreign-jsx-override-plugin.d.ts +0 -33
  419. package/src/plugins/foreign-jsx-override-plugin.js +0 -41
  420. package/src/plugins/integration-plugin.d.ts +0 -230
  421. package/src/plugins/integration-plugin.js +0 -201
  422. package/src/plugins/processor.d.ts +0 -97
  423. package/src/plugins/processor.js +0 -141
  424. package/src/plugins/runtime-capability.js +0 -0
  425. package/src/plugins/source-transform.d.ts +0 -46
  426. package/src/plugins/source-transform.js +0 -71
  427. package/src/route-renderer/orchestration/component-render-context.d.ts +0 -97
  428. package/src/route-renderer/orchestration/component-render-context.js +0 -147
  429. package/src/route-renderer/orchestration/declared-ownership-graph.d.ts +0 -18
  430. package/src/route-renderer/orchestration/declared-ownership-graph.js +0 -34
  431. package/src/route-renderer/orchestration/foreign-subtree-execution.service.d.ts +0 -110
  432. package/src/route-renderer/orchestration/foreign-subtree-execution.service.js +0 -233
  433. package/src/route-renderer/orchestration/integration-renderer.d.ts +0 -534
  434. package/src/route-renderer/orchestration/integration-renderer.js +0 -991
  435. package/src/route-renderer/orchestration/ownership-planning.service.d.ts +0 -24
  436. package/src/route-renderer/orchestration/ownership-planning.service.js +0 -63
  437. package/src/route-renderer/orchestration/ownership-validation.service.d.ts +0 -29
  438. package/src/route-renderer/orchestration/ownership-validation.service.js +0 -53
  439. package/src/route-renderer/orchestration/processed-asset-dedupe.d.ts +0 -3
  440. package/src/route-renderer/orchestration/processed-asset-dedupe.js +0 -27
  441. package/src/route-renderer/orchestration/queued-foreign-subtree-resolution.service.d.ts +0 -91
  442. package/src/route-renderer/orchestration/queued-foreign-subtree-resolution.service.js +0 -170
  443. package/src/route-renderer/orchestration/render-output.utils.d.ts +0 -66
  444. package/src/route-renderer/orchestration/render-output.utils.js +0 -171
  445. package/src/route-renderer/orchestration/route-render-orchestrator.d.ts +0 -156
  446. package/src/route-renderer/orchestration/route-render-orchestrator.js +0 -577
  447. package/src/route-renderer/orchestration/template-serialization.d.ts +0 -38
  448. package/src/route-renderer/orchestration/template-serialization.js +0 -45
  449. package/src/route-renderer/page-loading/component-dependency-collection.d.ts +0 -37
  450. package/src/route-renderer/page-loading/component-dependency-collection.js +0 -132
  451. package/src/route-renderer/page-loading/declared-asset-collection.d.ts +0 -24
  452. package/src/route-renderer/page-loading/declared-asset-collection.js +0 -106
  453. package/src/route-renderer/page-loading/dependency-resolver.d.ts +0 -35
  454. package/src/route-renderer/page-loading/dependency-resolver.js +0 -115
  455. package/src/route-renderer/page-loading/ecopages-virtual-imports.d.ts +0 -11
  456. package/src/route-renderer/page-loading/ecopages-virtual-imports.js +0 -57
  457. package/src/route-renderer/page-loading/lazy-entry-collection.d.ts +0 -45
  458. package/src/route-renderer/page-loading/lazy-entry-collection.js +0 -105
  459. package/src/route-renderer/page-loading/lazy-trigger-planning.d.ts +0 -19
  460. package/src/route-renderer/page-loading/lazy-trigger-planning.js +0 -40
  461. package/src/route-renderer/page-loading/module-declaration-aggregation.d.ts +0 -5
  462. package/src/route-renderer/page-loading/module-declaration-aggregation.js +0 -33
  463. package/src/route-renderer/page-loading/module-declaration-scripts.d.ts +0 -3
  464. package/src/route-renderer/page-loading/module-declaration-scripts.js +0 -18
  465. package/src/route-renderer/page-loading/page-dependency-bundling.d.ts +0 -13
  466. package/src/route-renderer/page-loading/page-dependency-bundling.js +0 -137
  467. package/src/route-renderer/page-loading/page-module-loader.d.ts +0 -90
  468. package/src/route-renderer/page-loading/page-module-loader.js +0 -127
  469. package/src/route-renderer/route-renderer.d.ts +0 -69
  470. package/src/route-renderer/route-renderer.js +0 -80
  471. package/src/router/client/link-intent.js +0 -34
  472. package/src/router/client/link-intent.test.browser.d.ts +0 -1
  473. package/src/router/client/link-intent.test.browser.js +0 -43
  474. package/src/router/client/navigation-coordinator.d.ts +0 -169
  475. package/src/router/client/navigation-coordinator.js +0 -215
  476. package/src/router/server/route-registry.d.ts +0 -78
  477. package/src/router/server/route-registry.js +0 -262
  478. package/src/services/assets/asset-processing-service/asset-dependency-keys.d.ts +0 -3
  479. package/src/services/assets/asset-processing-service/asset-dependency-keys.js +0 -56
  480. package/src/services/assets/asset-processing-service/asset-processing.service.d.ts +0 -103
  481. package/src/services/assets/asset-processing-service/asset-processing.service.js +0 -285
  482. package/src/services/assets/asset-processing-service/asset.factory.d.ts +0 -17
  483. package/src/services/assets/asset-processing-service/asset.factory.js +0 -82
  484. package/src/services/assets/asset-processing-service/assets.types.d.ts +0 -103
  485. package/src/services/assets/asset-processing-service/assets.types.js +0 -0
  486. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.d.ts +0 -57
  487. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.js +0 -49
  488. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.d.ts +0 -20
  489. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.js +0 -41
  490. package/src/services/assets/asset-processing-service/grouped-content-bundles.d.ts +0 -30
  491. package/src/services/assets/asset-processing-service/grouped-content-bundles.js +0 -65
  492. package/src/services/assets/asset-processing-service/index.d.ts +0 -6
  493. package/src/services/assets/asset-processing-service/index.js +0 -6
  494. package/src/services/assets/asset-processing-service/page-package.d.ts +0 -6
  495. package/src/services/assets/asset-processing-service/page-package.js +0 -80
  496. package/src/services/assets/asset-processing-service/processor.interface.js +0 -6
  497. package/src/services/assets/asset-processing-service/processor.registry.d.ts +0 -8
  498. package/src/services/assets/asset-processing-service/processor.registry.js +0 -15
  499. package/src/services/assets/asset-processing-service/processors/base/base-processor.d.ts +0 -24
  500. package/src/services/assets/asset-processing-service/processors/base/base-processor.js +0 -65
  501. package/src/services/assets/asset-processing-service/processors/base/base-script-processor.d.ts +0 -22
  502. package/src/services/assets/asset-processing-service/processors/base/base-script-processor.js +0 -136
  503. package/src/services/assets/asset-processing-service/processors/index.d.ts +0 -5
  504. package/src/services/assets/asset-processing-service/processors/index.js +0 -5
  505. package/src/services/assets/asset-processing-service/processors/script/content-script.processor.d.ts +0 -6
  506. package/src/services/assets/asset-processing-service/processors/script/content-script.processor.js +0 -120
  507. package/src/services/assets/asset-processing-service/processors/script/file-script.processor.d.ts +0 -9
  508. package/src/services/assets/asset-processing-service/processors/script/file-script.processor.js +0 -97
  509. package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.d.ts +0 -42
  510. package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.js +0 -126
  511. package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.d.ts +0 -8
  512. package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.js +0 -59
  513. package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.d.ts +0 -9
  514. package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.js +0 -69
  515. package/src/services/assets/asset-processing-service/ungrouped-dependency-processing.d.ts +0 -18
  516. package/src/services/assets/asset-processing-service/ungrouped-dependency-processing.js +0 -45
  517. package/src/services/assets/browser-bundle.service.d.ts +0 -73
  518. package/src/services/assets/browser-bundle.service.js +0 -41
  519. package/src/services/cache/cache.types.d.ts +0 -107
  520. package/src/services/cache/cache.types.js +0 -0
  521. package/src/services/cache/index.d.ts +0 -7
  522. package/src/services/cache/index.js +0 -7
  523. package/src/services/cache/memory-cache-store.d.ts +0 -42
  524. package/src/services/cache/memory-cache-store.js +0 -98
  525. package/src/services/cache/page-cache-service.d.ts +0 -70
  526. package/src/services/cache/page-cache-service.js +0 -152
  527. package/src/services/cache/page-request-cache-coordinator.service.d.ts +0 -75
  528. package/src/services/cache/page-request-cache-coordinator.service.js +0 -109
  529. package/src/services/html/html-rewriter-provider.service.d.ts +0 -40
  530. package/src/services/html/html-rewriter-provider.service.js +0 -68
  531. package/src/services/html/html-transformer.service.d.ts +0 -96
  532. package/src/services/html/html-transformer.service.js +0 -287
  533. package/src/services/invalidation/development-invalidation.service.d.ts +0 -74
  534. package/src/services/invalidation/development-invalidation.service.js +0 -190
  535. package/src/services/module-loading/app-module-loader.service.d.ts +0 -7
  536. package/src/services/module-loading/app-module-loader.service.js +0 -0
  537. package/src/services/module-loading/app-server-module-transpiler.service.d.ts +0 -24
  538. package/src/services/module-loading/app-server-module-transpiler.service.js +0 -151
  539. package/src/services/module-loading/host-module-loader-registry.d.ts +0 -4
  540. package/src/services/module-loading/host-module-loader-registry.js +0 -15
  541. package/src/services/module-loading/module-loading-types.js +0 -0
  542. package/src/services/module-loading/node-bootstrap-plugin.d.ts +0 -38
  543. package/src/services/module-loading/node-bootstrap-plugin.js +0 -215
  544. package/src/services/module-loading/page-module-import.service.d.ts +0 -95
  545. package/src/services/module-loading/page-module-import.service.js +0 -191
  546. package/src/services/module-loading/server-module-transpiler.service.d.ts +0 -63
  547. package/src/services/module-loading/server-module-transpiler.service.js +0 -64
  548. package/src/services/module-loading/source-module-support.d.ts +0 -5
  549. package/src/services/module-loading/source-module-support.js +0 -8
  550. package/src/services/runtime-state/dev-graph.service.d.ts +0 -118
  551. package/src/services/runtime-state/dev-graph.service.js +0 -162
  552. package/src/services/runtime-state/entrypoint-dependency-graph.service.d.ts +0 -41
  553. package/src/services/runtime-state/entrypoint-dependency-graph.service.js +0 -85
  554. package/src/services/runtime-state/server-invalidation-state.service.d.ts +0 -26
  555. package/src/services/runtime-state/server-invalidation-state.service.js +0 -35
  556. package/src/services/validation/schema-validation-service.d.ts +0 -122
  557. package/src/services/validation/schema-validation-service.js +0 -101
  558. package/src/services/validation/standard-schema.types.js +0 -0
  559. package/src/static-site-generator/static-site-generator.d.ts +0 -104
  560. package/src/static-site-generator/static-site-generator.js +0 -316
  561. package/src/types/internal-types.d.ts +0 -232
  562. package/src/types/internal-types.js +0 -0
  563. package/src/types/public-types.d.ts +0 -1307
  564. package/src/types/public-types.js +0 -0
  565. package/src/utils/deep-merge.d.ts +0 -14
  566. package/src/utils/deep-merge.js +0 -32
  567. package/src/utils/hash.d.ts +0 -1
  568. package/src/utils/hash.js +0 -7
  569. package/src/utils/html-escaping.d.ts +0 -7
  570. package/src/utils/html-escaping.js +0 -6
  571. package/src/utils/html.js +0 -4
  572. package/src/utils/invariant.d.ts +0 -5
  573. package/src/utils/invariant.js +0 -11
  574. package/src/utils/locals-utils.d.ts +0 -15
  575. package/src/utils/locals-utils.js +0 -24
  576. package/src/utils/parse-cli-args.d.ts +0 -27
  577. package/src/utils/parse-cli-args.js +0 -62
  578. package/src/utils/path-utils.module.d.ts +0 -5
  579. package/src/utils/path-utils.module.js +0 -14
  580. package/src/utils/resolve-work-dir.d.ts +0 -11
  581. package/src/utils/resolve-work-dir.js +0 -31
  582. package/src/utils/runtime.d.ts +0 -11
  583. package/src/utils/runtime.js +0 -40
  584. package/src/utils/server-utils.module.d.ts +0 -19
  585. package/src/utils/server-utils.module.js +0 -56
  586. package/src/watchers/project-watcher.d.ts +0 -136
  587. package/src/watchers/project-watcher.js +0 -275
  588. package/src/watchers/project-watcher.test-helpers.d.ts +0 -4
  589. package/src/watchers/project-watcher.test-helpers.js +0 -52
  590. /package/src/utils/{html.d.ts → html.ts} +0 -0
@@ -0,0 +1,170 @@
1
+ import path from 'node:path';
2
+ import { fileSystem } from '@ecopages/file-system';
3
+ import { DEFAULT_ECOPAGES_HOSTNAME, DEFAULT_ECOPAGES_PORT } from '../../config/constants.ts';
4
+ import { StaticContentServer } from '../../dev/sc-server.ts';
5
+ import { appLogger } from '../../global/app-logger.ts';
6
+ import type { EcoPagesAppConfig } from '../../types/internal-types.ts';
7
+ import type { ApiHandler, StaticRoute } from '../../types/public-types.ts';
8
+ import type { RouteRegistry } from '../../router/server/route-registry.ts';
9
+ import type { StaticSiteGenerator } from '../../static-site-generator/static-site-generator.ts';
10
+ import type { StaticGenerationRendererResolver } from '../../route-renderer/route-renderer.ts';
11
+
12
+ export interface StaticBuildOptions {
13
+ preview?: boolean;
14
+ baseUrl?: string;
15
+ }
16
+
17
+ export interface ServeOptions {
18
+ hostname?: string;
19
+ port?: number | string;
20
+ }
21
+
22
+ export interface ServerStaticBuilderParams {
23
+ appConfig: EcoPagesAppConfig;
24
+ staticSiteGenerator: StaticSiteGenerator;
25
+ serveOptions: ServeOptions;
26
+ apiHandlers?: ApiHandler[];
27
+ logger?: ServerStaticBuilderLogger;
28
+ previewServerFactory?: ServerStaticPreviewServerFactory;
29
+ }
30
+
31
+ /**
32
+ * Minimal logger dependency used by the static builder.
33
+ */
34
+ export interface ServerStaticBuilderLogger {
35
+ warn(message: string, detail?: string): unknown;
36
+ info(message: string): unknown;
37
+ error(message: string): unknown;
38
+ }
39
+
40
+ /**
41
+ * Preview server factory dependency used when static preview mode is enabled.
42
+ */
43
+ export interface ServerStaticPreviewServerFactory {
44
+ createServer(args: { appConfig: EcoPagesAppConfig; options: { port: number } }): {
45
+ server?: {
46
+ port?: number;
47
+ } | null;
48
+ };
49
+ }
50
+
51
+ /**
52
+ * Handles static site generation and previews.
53
+ */
54
+ export class ServerStaticBuilder {
55
+ private readonly appConfig: EcoPagesAppConfig;
56
+ private readonly staticSiteGenerator: StaticSiteGenerator;
57
+ private readonly serveOptions: ServeOptions;
58
+ private readonly apiHandlers: ApiHandler[];
59
+ private readonly logger: ServerStaticBuilderLogger;
60
+ private readonly previewServerFactory: ServerStaticPreviewServerFactory;
61
+
62
+ constructor({
63
+ appConfig,
64
+ staticSiteGenerator,
65
+ serveOptions,
66
+ apiHandlers,
67
+ logger,
68
+ previewServerFactory,
69
+ }: ServerStaticBuilderParams) {
70
+ this.appConfig = appConfig;
71
+ this.staticSiteGenerator = staticSiteGenerator;
72
+ this.serveOptions = serveOptions;
73
+ this.apiHandlers = apiHandlers ?? [];
74
+ this.logger = logger ?? appLogger;
75
+ this.previewServerFactory = previewServerFactory ?? StaticContentServer;
76
+ }
77
+
78
+ private warnApiHandlersUnavailableInStaticMode(): void {
79
+ if (this.apiHandlers.length === 0) {
80
+ return;
81
+ }
82
+
83
+ const uniqueHandlers = Array.from(
84
+ new Set(this.apiHandlers.map((handler) => `${handler.method} ${handler.path}`)),
85
+ );
86
+ const visibleHandlers = uniqueHandlers.slice(0, 5).join(', ');
87
+ const remainingCount = uniqueHandlers.length - Math.min(uniqueHandlers.length, 5);
88
+ const summary = remainingCount > 0 ? `${visibleHandlers}, +${remainingCount} more` : visibleHandlers;
89
+
90
+ this.logger.warn(
91
+ 'Registered API endpoints are not available in static build or preview modes because no server runtime is started. They are excluded from the generated output.\n',
92
+ `➤ ${summary}`,
93
+ );
94
+ }
95
+
96
+ private prepareExportDirectory(): void {
97
+ const exportDir =
98
+ this.appConfig.absolutePaths?.distDir ?? path.join(this.appConfig.rootDir, this.appConfig.distDir);
99
+ fileSystem.ensureDir(exportDir, true);
100
+
101
+ const srcPublicDir = path.join(
102
+ this.appConfig.rootDir,
103
+ this.appConfig.srcDir ?? 'src',
104
+ this.appConfig.publicDir ?? 'public',
105
+ );
106
+ if (fileSystem.exists(srcPublicDir)) {
107
+ fileSystem.copyDir(srcPublicDir, exportDir);
108
+ }
109
+ }
110
+
111
+ private async refreshRuntimeAssets(): Promise<void> {
112
+ for (const processor of this.appConfig.processors.values()) {
113
+ await processor.setup();
114
+ }
115
+
116
+ for (const integration of this.appConfig.integrations) {
117
+ await integration.setup();
118
+ }
119
+ }
120
+
121
+ /**
122
+ * Generates a static build of the site for deployment.
123
+ * @param options.preview - If true, starts a preview server after build
124
+ * @param dependencies.router - The initialized router
125
+ * @param dependencies.routeRendererFactory - The route renderer factory
126
+ * @param dependencies.staticRoutes - Explicit static routes registered via app.static()
127
+ */
128
+ async build(
129
+ options: StaticBuildOptions | undefined,
130
+ dependencies: {
131
+ router: RouteRegistry;
132
+ routeRendererFactory: StaticGenerationRendererResolver;
133
+ staticRoutes?: StaticRoute[];
134
+ },
135
+ ): Promise<void> {
136
+ const { preview = false, baseUrl: explicitBaseUrl } = options ?? {};
137
+
138
+ const baseUrl =
139
+ explicitBaseUrl ??
140
+ `http://${this.serveOptions.hostname || DEFAULT_ECOPAGES_HOSTNAME}:${this.serveOptions.port || DEFAULT_ECOPAGES_PORT}`;
141
+ this.warnApiHandlersUnavailableInStaticMode();
142
+ this.prepareExportDirectory();
143
+ await this.refreshRuntimeAssets();
144
+
145
+ await this.staticSiteGenerator.run({
146
+ router: dependencies.router,
147
+ baseUrl,
148
+ routeRendererFactory: dependencies.routeRendererFactory,
149
+ staticRoutes: dependencies.staticRoutes,
150
+ });
151
+
152
+ if (!preview) {
153
+ this.logger.info('Build completed');
154
+ return;
155
+ }
156
+
157
+ const previewPort = this.serveOptions.port || DEFAULT_ECOPAGES_PORT;
158
+
159
+ const { server } = this.previewServerFactory.createServer({
160
+ appConfig: this.appConfig,
161
+ options: { port: Number(previewPort) },
162
+ });
163
+
164
+ if (server?.port) {
165
+ this.logger.info(`Preview running at http://localhost:${server.port}`);
166
+ } else {
167
+ this.logger.error('Failed to start preview server');
168
+ }
169
+ }
170
+ }
@@ -0,0 +1,298 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ import { RESOLVED_ASSETS_DIR } from '../../config/constants.ts';
5
+ import { getAppBuildExecutor } from '../../build/build-adapter.ts';
6
+ import type { DefaultHmrContext, EcoPagesAppConfig, IHmrManager, IClientBridge } from '../../types/internal-types.ts';
7
+ import type { EcoBuildPlugin } from '../../build/build-types.ts';
8
+ import { fileSystem } from '@ecopages/file-system';
9
+ import { HmrStrategyType, type HmrStrategy } from '../../hmr/hmr-strategy.ts';
10
+ import { DefaultHmrStrategy } from '../../hmr/strategies/default-hmr-strategy.ts';
11
+ import { JsHmrStrategy } from '../../hmr/strategies/js-hmr-strategy.ts';
12
+ import { appLogger } from '../../global/app-logger.ts';
13
+ import type { ClientBridgeEvent } from '../../types/public-types.ts';
14
+ import { HmrEntrypointRegistrar } from './hmr-entrypoint-registrar.ts';
15
+ import { BrowserBundleService } from '../../services/assets/browser-bundle.service.ts';
16
+ import { getAppServerModuleTranspiler } from '../../services/module-loading/app-server-module-transpiler.service.ts';
17
+ import {
18
+ getAppEntrypointDependencyGraph,
19
+ setAppEntrypointDependencyGraph,
20
+ type EntrypointDependencyGraph,
21
+ } from '../../services/runtime-state/entrypoint-dependency-graph.service.ts';
22
+ import type { ServerModuleTranspiler } from '../../services/module-loading/server-module-transpiler.service.ts';
23
+ import { resolveInternalExecutionDir, resolveInternalWorkDir } from '../../utils/resolve-work-dir.ts';
24
+
25
+ type HandleFileChangeOptions = {
26
+ broadcast?: boolean;
27
+ };
28
+
29
+ type SharedHmrManagerParams = {
30
+ appConfig: EcoPagesAppConfig;
31
+ bridge: IClientBridge;
32
+ registrationTimeoutMs?: number;
33
+ };
34
+
35
+ export abstract class SharedHmrManager implements IHmrManager {
36
+ public readonly appConfig: EcoPagesAppConfig;
37
+ protected readonly bridge: IClientBridge;
38
+ protected watchers = new Map<string, fs.FSWatcher>();
39
+ protected watchedFiles = new Map<string, string>();
40
+ protected entrypointRegistrations = new Map<string, Promise<string>>();
41
+ protected distDir: string;
42
+ protected plugins: EcoBuildPlugin[] = [];
43
+ protected enabled = true;
44
+ protected strategies: HmrStrategy[] = [];
45
+ protected readonly entrypointRegistrar: HmrEntrypointRegistrar;
46
+ protected readonly browserBundleService: BrowserBundleService;
47
+ protected readonly entrypointDependencyGraph: EntrypointDependencyGraph;
48
+ protected readonly serverModuleTranspiler: ServerModuleTranspiler;
49
+
50
+ constructor({ appConfig, bridge, registrationTimeoutMs = 4000 }: SharedHmrManagerParams) {
51
+ this.appConfig = appConfig;
52
+ this.bridge = bridge;
53
+ this.distDir = path.join(resolveInternalWorkDir(this.appConfig), RESOLVED_ASSETS_DIR, '_hmr');
54
+ this.entrypointRegistrar = new HmrEntrypointRegistrar({
55
+ srcDir: this.appConfig.absolutePaths.srcDir,
56
+ distDir: this.distDir,
57
+ entrypointRegistrations: this.entrypointRegistrations,
58
+ watchedFiles: this.watchedFiles,
59
+ clearFailedRegistration: (entrypointPath) => this.clearFailedEntrypointRegistration(entrypointPath),
60
+ registrationTimeoutMs,
61
+ });
62
+ this.browserBundleService = new BrowserBundleService(appConfig);
63
+ this.entrypointDependencyGraph = this.createEntrypointDependencyGraph(
64
+ getAppEntrypointDependencyGraph(appConfig),
65
+ );
66
+ setAppEntrypointDependencyGraph(this.appConfig, this.entrypointDependencyGraph);
67
+ this.serverModuleTranspiler = getAppServerModuleTranspiler(this.appConfig);
68
+ this.ensureDistDir();
69
+ this.initializeStrategies();
70
+ }
71
+
72
+ protected abstract createEntrypointDependencyGraph(
73
+ existingEntrypointDependencyGraph: EntrypointDependencyGraph,
74
+ ): EntrypointDependencyGraph;
75
+
76
+ protected shouldSkipMissingFileChange(_filePath: string): boolean {
77
+ return false;
78
+ }
79
+
80
+ protected onRuntimeBundleFailure(error: unknown): void {
81
+ appLogger.error('[HMR] Failed to build runtime script:', error);
82
+ }
83
+
84
+ protected ensureDistDir(): void {
85
+ fileSystem.ensureDir(this.distDir);
86
+ }
87
+
88
+ protected shouldJsStrategyProcessEntrypoint(entrypointPath: string): boolean {
89
+ return !this.strategies.some((strategy) => {
90
+ if (strategy.type !== HmrStrategyType.INTEGRATION || strategy.priority <= HmrStrategyType.SCRIPT) {
91
+ return false;
92
+ }
93
+
94
+ try {
95
+ return strategy.matches(entrypointPath);
96
+ } catch (error) {
97
+ appLogger.error(error);
98
+ return false;
99
+ }
100
+ });
101
+ }
102
+
103
+ protected initializeStrategies(): void {
104
+ const jsContext = {
105
+ getWatchedFiles: () => this.watchedFiles,
106
+ getDistDir: () => this.distDir,
107
+ getPlugins: () => this.plugins,
108
+ getSrcDir: () => this.appConfig.absolutePaths.srcDir,
109
+ getPagesDir: () => this.appConfig.absolutePaths.pagesDir,
110
+ getLayoutsDir: () => this.appConfig.absolutePaths.layoutsDir,
111
+ getTemplateExtensions: () => this.appConfig.templatesExt,
112
+ getBrowserBundleService: () => this.browserBundleService,
113
+ getEntrypointDependencyGraph: () => this.entrypointDependencyGraph,
114
+ shouldProcessEntrypoint: (entrypointPath: string) => this.shouldJsStrategyProcessEntrypoint(entrypointPath),
115
+ };
116
+
117
+ this.strategies = [new JsHmrStrategy(jsContext), new DefaultHmrStrategy()];
118
+ }
119
+
120
+ public registerStrategy(strategy: HmrStrategy): void {
121
+ this.strategies.push(strategy);
122
+ }
123
+
124
+ public setPlugins(plugins: EcoBuildPlugin[]): void {
125
+ this.plugins = [...plugins];
126
+ }
127
+
128
+ public setEnabled(enabled: boolean): void {
129
+ this.enabled = enabled;
130
+ }
131
+
132
+ public isEnabled(): boolean {
133
+ return this.enabled;
134
+ }
135
+
136
+ public async buildRuntime(): Promise<void> {
137
+ const runtimeSource = fileURLToPath(import.meta.resolve('@ecopages/core/hmr/client/hmr-runtime'));
138
+
139
+ try {
140
+ const result = await this.browserBundleService.bundle({
141
+ profile: 'hmr-runtime',
142
+ entrypoints: [runtimeSource],
143
+ outdir: this.distDir,
144
+ naming: '_hmr_runtime.js',
145
+ minify: false,
146
+ plugins: this.plugins,
147
+ });
148
+
149
+ if (!result.success) {
150
+ this.onRuntimeBundleFailure(result.logs);
151
+ }
152
+ } catch (error) {
153
+ this.onRuntimeBundleFailure(error);
154
+ }
155
+ }
156
+
157
+ public getRuntimePath(): string {
158
+ return path.join(this.distDir, '_hmr_runtime.js');
159
+ }
160
+
161
+ public broadcast(event: ClientBridgeEvent) {
162
+ appLogger.debug(
163
+ `[HMR] Broadcasting ${event.type} event, path=${event.path || 'all'}, subscribers=${this.bridge.subscriberCount}`,
164
+ );
165
+ this.bridge.broadcast(event);
166
+ }
167
+
168
+ public async handleFileChange(filePath: string, options: HandleFileChangeOptions = {}): Promise<void> {
169
+ if (this.shouldSkipMissingFileChange(filePath) && !fileSystem.exists(filePath)) {
170
+ appLogger.debug(`[${this.constructor.name}] Skipping missing file change: ${filePath}`);
171
+ this.clearFailedEntrypointRegistration(filePath);
172
+ return;
173
+ }
174
+
175
+ const sorted = [...this.strategies].sort((a, b) => b.priority - a.priority);
176
+ const strategy = sorted.find((candidate) => {
177
+ try {
178
+ return candidate.matches(filePath);
179
+ } catch (error) {
180
+ appLogger.error(error);
181
+ return false;
182
+ }
183
+ });
184
+
185
+ if (!strategy) {
186
+ appLogger.warn(`[HMR] No strategy found for ${filePath}`);
187
+ return;
188
+ }
189
+
190
+ appLogger.debug(`[${this.constructor.name}] Selected strategy: ${strategy.constructor.name}`);
191
+
192
+ const action = await strategy.process(filePath);
193
+ const shouldBroadcast = options.broadcast ?? true;
194
+
195
+ if (shouldBroadcast && action.type === 'broadcast' && action.events) {
196
+ for (const event of action.events) {
197
+ this.broadcast(event);
198
+ }
199
+ }
200
+ }
201
+
202
+ public getOutputUrl(entrypointPath: string): string | undefined {
203
+ return this.watchedFiles.get(entrypointPath);
204
+ }
205
+
206
+ public getWatchedFiles(): Map<string, string> {
207
+ return this.watchedFiles;
208
+ }
209
+
210
+ public getDistDir(): string {
211
+ return this.distDir;
212
+ }
213
+
214
+ public getPlugins(): EcoBuildPlugin[] {
215
+ return this.plugins;
216
+ }
217
+
218
+ public getDefaultContext(): DefaultHmrContext {
219
+ return {
220
+ getWatchedFiles: () => this.watchedFiles,
221
+ getDistDir: () => this.distDir,
222
+ getPlugins: () => this.plugins,
223
+ getSrcDir: () => this.appConfig.absolutePaths.srcDir,
224
+ getLayoutsDir: () => this.appConfig.absolutePaths.layoutsDir,
225
+ getPagesDir: () => this.appConfig.absolutePaths.pagesDir,
226
+ getBuildExecutor: () => getAppBuildExecutor(this.appConfig),
227
+ getBrowserBundleService: () => this.browserBundleService,
228
+ getEntrypointDependencyGraph: () => this.entrypointDependencyGraph,
229
+ importServerModule: async <T>(filePath: string) =>
230
+ await this.serverModuleTranspiler.importModule<T>({
231
+ filePath,
232
+ outdir: path.join(resolveInternalExecutionDir(this.appConfig), '.server-modules'),
233
+ externalPackages: true,
234
+ }),
235
+ };
236
+ }
237
+
238
+ protected clearFailedEntrypointRegistration(entrypointPath: string): void {
239
+ this.watchedFiles.delete(entrypointPath);
240
+ this.entrypointDependencyGraph.clearEntrypointDependencies(entrypointPath);
241
+ }
242
+
243
+ public async registerEntrypoint(entrypointPath: string): Promise<string> {
244
+ return await this.entrypointRegistrar.registerEntrypoint(entrypointPath, {
245
+ emit: async (normalizedEntrypoint) => await this.emitStrictEntrypoint(normalizedEntrypoint),
246
+ getMissingOutputError: (normalizedEntrypoint, outputPath) =>
247
+ new Error(
248
+ `[HMR] Integration failed to emit entrypoint ${normalizedEntrypoint} to ${outputPath}. Page entrypoints must be produced by their owning integration.`,
249
+ ),
250
+ });
251
+ }
252
+
253
+ public async registerScriptEntrypoint(entrypointPath: string): Promise<string> {
254
+ return await this.entrypointRegistrar.registerEntrypoint(entrypointPath, {
255
+ emit: async (normalizedEntrypoint, outputPath) =>
256
+ await this.emitScriptEntrypoint(normalizedEntrypoint, outputPath),
257
+ getMissingOutputError: (normalizedEntrypoint) =>
258
+ new Error(`[HMR] Failed to register script entrypoint: ${normalizedEntrypoint}`),
259
+ });
260
+ }
261
+
262
+ protected async emitStrictEntrypoint(entrypointPath: string): Promise<void> {
263
+ await this.handleFileChange(entrypointPath, { broadcast: false });
264
+ }
265
+
266
+ protected async emitScriptEntrypoint(entrypointPath: string, outputPath: string): Promise<void> {
267
+ const naming = path.relative(this.distDir, outputPath).split(path.sep).join('/');
268
+ const buildResult = await this.browserBundleService.bundle({
269
+ profile: 'hmr-entrypoint',
270
+ entrypoints: [entrypointPath],
271
+ outdir: this.distDir,
272
+ naming,
273
+ minify: false,
274
+ plugins: this.plugins,
275
+ });
276
+
277
+ if (!buildResult.success) {
278
+ appLogger.error(`[HMR] Generic script entrypoint build failed for ${entrypointPath}:`, buildResult.logs);
279
+ return;
280
+ }
281
+
282
+ const entrypointDependencies = buildResult.dependencyGraph?.entrypoints?.[entrypointPath];
283
+ if (entrypointDependencies) {
284
+ this.entrypointDependencyGraph.setEntrypointDependencies(entrypointPath, entrypointDependencies);
285
+ }
286
+ }
287
+
288
+ public stop() {
289
+ this.entrypointRegistrations.clear();
290
+ for (const watcher of this.watchers.values()) {
291
+ watcher.close();
292
+ }
293
+ this.watchers.clear();
294
+ this.watchedFiles.clear();
295
+ this.entrypointDependencyGraph.reset();
296
+ this.plugins = [];
297
+ }
298
+ }
@@ -0,0 +1,12 @@
1
+ import type { EcoPagesAppConfig } from '../../types/internal-types.ts';
2
+
3
+ export interface StaticPreviewHost {
4
+ start(options: StaticPreviewHostStartOptions): Promise<number | null>;
5
+ stop(force?: boolean): Promise<void>;
6
+ }
7
+
8
+ export interface StaticPreviewHostStartOptions {
9
+ appConfig: EcoPagesAppConfig;
10
+ hostname: string;
11
+ port: number;
12
+ }
@@ -1,107 +1,91 @@
1
1
  # Build Layer
2
2
 
3
- This directory contains the runtime-neutral build contract used across Ecopages, the Bun-native adapter that currently uses esbuild under the hood, and the explicit host-owned Vite compatibility boundary.
3
+ The build layer is the bundler contract for Ecopages. One bundled adapter is the default; one host-owned boundary marker covers the Vite-host path.
4
4
 
5
- ## Files
6
-
7
- - `build-adapter.ts`: shared build interfaces, explicit Bun-native versus Vite-host ownership helpers, app-owned adapter/executor helpers, and compatibility fallback helpers for older Bun-native call paths.
8
- - `build-types.ts`: plugin bridge types used by integrations and processors.
9
- - `esbuild-build-adapter.ts`: the concrete Bun-native adapter implementation. It is compatibility infrastructure, not strategic architecture.
10
- - `dev-build-coordinator.ts`: development-only orchestration around the temporary Bun-native esbuild backend.
11
- - `*.test.ts`: focused regression coverage for plain builds and development serialization and recovery.
12
-
13
- ## Responsibilities
5
+ ## Mental Model
14
6
 
15
- The build layer is intentionally split into two parts.
7
+ Three concentric shapes, plus a serializer and a plugin injector:
16
8
 
17
- `BuildExecutor` is the runtime-facing contract.
9
+ | Shape | Lives in | Purpose |
10
+ | -------------------------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
11
+ | `BuildAdapter` | `build-adapter.ts` | Low-level backend. Two implementations: the bundled adapter (the real bundler) and `ViteHostBuildAdapter` (a host-owned boundary marker that throws on direct use). |
12
+ | `BuildExecutor` | `build-adapter.ts` | Narrower runtime facade. Only `build` is exposed. Stored on `appConfig.runtime.buildExecutor`. |
13
+ | `SerializedBuildExecutor` | `serialized-build-executor.ts` | FIFO queue around any `BuildExecutor`. Used by the dev watch pipeline. |
14
+ | `withBuildExecutorPlugins` | `build-adapter.ts` | Merges app-owned plugins into every `build` call. The single point of plugin injection. |
18
15
 
19
- - It is the narrow facade stored on `appConfig.runtime.buildExecutor`.
20
- - It answers only how a given app instance should execute builds right now.
21
- - the Bun-native adapter satisfies this contract directly in plain flows.
22
- - `DevBuildCoordinator` also satisfies this contract by wrapping the temporary Bun-native esbuild adapter with development-only serialization and recovery policy.
16
+ Plus one translation bridge:
23
17
 
24
- `EsbuildBuildAdapter` is the current Bun-native backend. It knows how to:
18
+ - `rolldown-plugin-bridge.ts` converts the runtime-agnostic `EcoBuildPlugin[]` array (the contract integrations and processors register) into the bundler's native `Plugin` array. Each `EcoBuildPlugin` becomes its own plugin entry to preserve plugin-priority order.
25
19
 
26
- - load the esbuild module
27
- - translate Ecopages `BuildOptions` into esbuild options
28
- - bridge Ecopages build plugins into esbuild hooks
29
- - normalize build output, logs, and dependency graph metadata
30
- - detect the subset of runtime faults that mean the esbuild worker protocol is corrupted
31
-
32
- `ViteHostBuildAdapter` is a boundary marker, not a real backend. It exists so app/runtime state can represent that Vite owns host-side build execution instead of silently falling back to a framework-owned esbuild path.
20
+ ## Files
33
21
 
34
- `DevBuildCoordinator` is the development policy layer. It exists because one app/runtime can have many build callers during dev mode, including:
22
+ - `build-adapter.ts`: types, factories, app-owned helpers, `withBuildExecutorPlugins`.
23
+ - `build-types.ts`: the `EcoBuildPlugin` contract used by integrations and processors.
24
+ - `rolldown-build-adapter.ts`: the production `BuildAdapter`. Wraps the bundler and exposes a normalized `BuildResult` (outputs, dependency graph, logs).
25
+ - `rolldown-plugin-bridge.ts`: `EcoBuildPlugin[]` → bundler-plugin translation.
26
+ - `serialized-build-executor.ts`: FIFO queue primitive.
27
+ - `runtime-build-executor.ts`: dev-watch entrypoint that wraps the app-owned adapter in a `SerializedBuildExecutor + withBuildExecutorPlugins` chain.
28
+ - `*.test.ts`: regression coverage.
35
29
 
36
- - page module imports
37
- - HMR entrypoint builds
38
- - script and asset processors
39
- - React integration build paths
30
+ ## Default Flow
40
31
 
41
- Those callers must not race each other against one long-lived esbuild worker. The coordinator therefore owns temporary compatibility policy for the Bun-native path:
32
+ `ConfigBuilder.build()` creates one app-owned adapter, manifest, executor, dev graph, and runtime registry. The executor it stores is the raw `BuildAdapter`; the plugin-wrap step lives in the runtime path.
42
33
 
43
- - serialized access to the shared adapter in development
44
- - recycling warm Node-target esbuild sessions between builds
45
- - recovery from known esbuild worker protocol faults
34
+ When a server adapter initializes, it calls `installAppRuntimeBuildExecutor(appConfig)`. That function reads the existing executor (or falls back to the app-owned adapter) and stores a fresh wrapper:
46
35
 
47
- ## Default Flow
36
+ ```
37
+ BuildExecutor
38
+ └─ SerializedBuildExecutor // FIFO queue
39
+ └─ withBuildExecutorPlugins // injects app plugins
40
+ └─ BuildAdapter (bundled adapter or Vite-host)
41
+ ```
48
42
 
49
- Each `EcoPagesAppConfig` owns explicit build ownership, a build adapter, a build manifest, and a `buildExecutor` in `appConfig.runtime`. `ConfigBuilder.build()` now creates that app-owned build state up front so later runtime startup can reuse it rather than mutating a shared adapter.
43
+ Every dev-watch caller reads `appConfig.runtime.buildExecutor` and gets the merged plugin set without further ceremony.
50
44
 
51
- When a Bun server adapter starts in watch mode, it replaces that executor with a per-app `DevBuildCoordinator`. Vite-hosted flows should not use that coordinator; the host owns watch, graph, and HMR policy there. Build consumers then either call the executor directly or pass it explicitly to the top-level `build()` helper.
45
+ The exported `defaultBuildAdapter` and the top-level `build()` / `getTranspileOptions()` helpers are non-app-aware escape hatches. New runtime code should prefer `getAppBuildAdapter()`, `getAppBuildExecutor()`, and `getAppTranspileOptions()`.
52
46
 
53
- The exported `defaultBuildAdapter` and top-level `getTranspileOptions()` helper are compatibility fallbacks only. New runtime code should prefer app-owned access through `getAppBuildAdapter()`, `getAppBuildExecutor()`, and `getAppTranspileOptions()`.
47
+ ## Vite-Host Boundary
54
48
 
55
- The same rule applies to source-module loading: host-owned import behavior must be injected through abstract runtime state rather than imported directly into core services.
49
+ `ViteHostBuildAdapter` is not a real backend. It exists so `appConfig.runtime.buildAdapter` can carry the `'vite-host'` ownership without falling back to a framework-owned bundler path. Every method throws a clear `Vite-hosted builds are owned by the host runtime. Core cannot …` error so misrouted calls fail loudly.
56
50
 
57
- Plugins are part of app-owned manifest or per-build input now. The source build contract no longer exposes adapter-level plugin registration, which keeps build composition scoped to an app/runtime instance instead of leaking across instances.
51
+ Vite-based apps (or any future host runtime) should:
58
52
 
59
- HMR callers follow the same ownership model. Integration-specific runtime aliasing stays with the integration that owns those specifiers, rather than in generic core HMR bundling.
53
+ 1. Construct a `ViteHostBuildAdapter` via `createViteHostBuildAdapter()` and install it on the app config with `setAppBuildAdapter`.
54
+ 2. Run their own build pipeline outside the core.
55
+ 3. Reuse the core's `BuildExecutor`-shaped surface where possible so call-sites stay backend-neutral.
60
56
 
61
- ## Orchestration Diagram
57
+ ## Plugin Authoring
62
58
 
63
- ```mermaid
64
- flowchart TD
65
- Config["ConfigBuilder.build()"] --> DefaultExec["appConfig.runtime.buildExecutor = createAppBuildExecutor(app adapter, manifest)"]
66
- Adapter["Server adapter initialize() in watch mode"] --> DevExec["appConfig.runtime.buildExecutor = DevBuildCoordinator"]
67
- Caller["Any build caller with app/runtime context"] --> Build["executor.build(options) or build(options, executor)"]
68
- Build --> Executor["BuildExecutor"]
69
- Executor --> Coordinator["DevBuildCoordinator.build()"]
70
- Coordinator --> Backend["EsbuildBuildAdapter.buildOrThrow()"]
71
- Executor -->|plain flow| Direct["EsbuildBuildAdapter.build()"]
72
- Backend --> Result["BuildResult"]
73
- Direct --> Result["BuildResult"]
74
- Result --> Browser["Browser consumes emitted bundle directly"]
75
- ```
59
+ `EcoBuildPlugin` is the runtime-agnostic contract integrations and processors register. The shape:
76
60
 
77
- ## Recovery Model
61
+ - `name: string`
62
+ - `setup(build: EcoBuildPluginBuilder): void | Promise<void>`
78
63
 
79
- The recovery path is narrow on purpose. The coordinator only treats an error as recoverable when `EsbuildBuildAdapter.isEsbuildProtocolError()` matches one of the known worker-protocol failure signatures.
64
+ `EcoBuildPluginBuilder` exposes three hooks:
80
65
 
81
- When that happens, recovery does three things in order:
66
+ - `onResolve({ filter, namespace? }, callback)` the bundler's `resolveId` mapped to the shared plugin shape.
67
+ - `onLoad({ filter, namespace? }, callback)` — the bundler's `load` mapped the same way.
68
+ - `module(specifier, callback)` — declares a virtual module by name, with bundler-side namespace encoding.
82
69
 
83
- 1. Reset the serialized queue so future builds are not stuck behind a wedged promise.
84
- 2. Stop the current esbuild service instance.
85
- 3. Increment the esbuild module generation so the next import gets a fresh worker instance.
70
+ Namespace handling: the shared plugin contract scopes handlers with a `namespace` string; the bundler encodes namespaces into the module id. The bridge prepends `<namespace>:` to resolved ids and matches filters against that prefix, then strips it before forwarding back to callbacks. Plugin code keeps the same `path` shape it had on the shared contract.
86
71
 
87
- After that reset, the coordinator retries the failed build once.
72
+ Plugin ordering: the bundler's `resolveId` and `load` are "first" hooks. The bridge translates each `EcoBuildPlugin` into its own plugin and preserves the array order, so position determines priority: index 0 wins first, the last index is the lowest priority. Security-critical plugins (e.g. `ecopages-client-graph-boundary`) should be placed before general-purpose loaders in the array.
88
73
 
89
- ## Why Explicit App Ownership
74
+ ## BuildOptions Caveats
90
75
 
91
- There are many build callsites across core and integrations. The coordinator still needs to stay centralized for the remaining Bun-native compatibility path, but process-global installation hid the real dependency and tied behavior to startup order.
76
+ `BuildOptions` is modeled on the bundler's options shape. Most fields map cleanly. The exceptions:
92
77
 
93
- The explicit app-owned executor model keeps the design honest:
78
+ - `splitting` — accepted but currently ignored. The bundler splits by default. The per-chunk naming is fixed to `[name]-[hash]`. If you need to disable splitting or rename chunks, the adapter will need a new option.
79
+ - `bundle` — accepted but ignored. The bundler always bundles.
80
+ - `outbase` — accepted but ignored. The adapter derives the base from `options.root` directly.
94
81
 
95
- - each app/runtime owns its own build executor
96
- - development policy stays in one place (`DevBuildCoordinator`) for the remaining Bun-native path only
97
- - callers with app context use that executor explicitly instead of consulting global state
98
- - tests can still instantiate `EsbuildBuildAdapter`, `ViteHostBuildAdapter`, or `DevBuildCoordinator` directly when they want the raw ownership boundary or compatibility backend only
82
+ These fields are kept in the type so existing call-sites compile. The proper fix is a more focused `BuildOptions` schema in a follow-up.
99
83
 
100
84
  ## Testing Strategy
101
85
 
102
- The build tests are split by concern.
103
-
104
- - `build-adapter.test.ts` verifies plain backend behavior and plugin bridging.
105
- - `build-adapter-serialization.test.ts` verifies development orchestration behavior such as serialization, warm-session recycling, and protocol-fault recovery.
86
+ - `rolldown-build-adapter.test.ts` covers the adapter's `build`, `resolve`, `getTranspileOptions`, and dependency-graph extraction end-to-end.
87
+ - `rolldown-plugin-bridge.test.ts` covers the `EcoBuildPlugin[]` → plugin translation in isolation.
88
+ - `build-adapter.test.ts` covers the app-owned helpers, the `BuildOwnership` routing, the `withBuildExecutorPlugins` injection, and the default-fallback behaviour.
89
+ - `runtime-build-executor.test.ts` covers the dev-watch wrapper: serialization, plugin injection, and the Vite-host rejection path.
106
90
 
107
- If you change the build orchestration rules, update the coordinator tests first. If you change esbuild option mapping or plugin behavior, update the backend tests first.
91
+ If you change option mapping or plugin-bridge semantics, update the adapter and bridge tests first. If you change the app-owned helper contracts, update `build-adapter.test.ts` first.