@ecopages/core 0.2.0-alpha.9 → 0.2.1-beta.0

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 (471) hide show
  1. package/README.md +79 -28
  2. package/package.json +94 -116
  3. package/src/adapters/README.md +2 -2
  4. package/src/adapters/abstract/application-adapter.d.ts +28 -2
  5. package/src/adapters/abstract/application-adapter.js +14 -2
  6. package/src/adapters/abstract/router-adapter.d.ts +1 -1
  7. package/src/adapters/abstract/server-adapter.d.ts +2 -2
  8. package/src/adapters/bun/client-bridge.d.ts +1 -1
  9. package/src/adapters/bun/create-app.d.ts +12 -12
  10. package/src/adapters/bun/create-app.js +64 -41
  11. package/src/adapters/bun/hmr-manager.d.ts +19 -115
  12. package/src/adapters/bun/hmr-manager.js +25 -301
  13. package/src/adapters/bun/index.d.ts +1 -1
  14. package/src/adapters/bun/index.js +2 -2
  15. package/src/adapters/bun/runtime-host.d.ts +52 -0
  16. package/src/adapters/bun/runtime-host.js +56 -0
  17. package/src/adapters/bun/server-adapter.d.ts +100 -32
  18. package/src/adapters/bun/server-adapter.js +142 -65
  19. package/src/adapters/bun/static-preview-host.d.ts +28 -0
  20. package/src/adapters/bun/static-preview-host.js +45 -0
  21. package/src/{create-app.d.ts → adapters/create-app.d.ts} +9 -6
  22. package/src/{create-app.js → adapters/create-app.js} +4 -4
  23. package/src/adapters/index.d.ts +1 -5
  24. package/src/adapters/index.js +1 -7
  25. package/src/adapters/node/create-app.d.ts +15 -12
  26. package/src/adapters/node/create-app.js +34 -85
  27. package/src/adapters/node/http-request-bridge.d.ts +57 -0
  28. package/src/adapters/node/http-request-bridge.js +118 -0
  29. package/src/adapters/node/node-client-bridge.d.ts +1 -1
  30. package/src/adapters/node/node-hmr-manager.d.ts +22 -103
  31. package/src/adapters/node/node-hmr-manager.js +26 -289
  32. package/src/adapters/node/runtime-host.d.ts +57 -0
  33. package/src/adapters/node/runtime-host.js +92 -0
  34. package/src/adapters/node/server-adapter-dependencies.d.ts +19 -0
  35. package/src/adapters/node/server-adapter-dependencies.js +18 -0
  36. package/src/adapters/node/server-adapter.d.ts +19 -42
  37. package/src/adapters/node/server-adapter.js +94 -139
  38. package/src/adapters/node/static-content-server.d.ts +1 -1
  39. package/src/adapters/node/static-content-server.js +1 -1
  40. package/src/adapters/node/static-preview-host.d.ts +55 -0
  41. package/src/adapters/node/static-preview-host.js +68 -0
  42. package/src/adapters/shared/application-adapter.d.ts +1 -1
  43. package/src/adapters/shared/define-api-handler.d.ts +1 -1
  44. package/src/adapters/shared/explicit-static-render-preparation.d.ts +25 -0
  45. package/src/adapters/shared/explicit-static-render-preparation.js +26 -0
  46. package/src/adapters/shared/explicit-static-route-matcher.d.ts +7 -4
  47. package/src/adapters/shared/explicit-static-route-matcher.js +14 -16
  48. package/src/adapters/shared/file-route-middleware-pipeline.d.ts +7 -10
  49. package/src/adapters/shared/file-route-middleware-pipeline.js +2 -11
  50. package/src/adapters/shared/fs-server-response-factory.d.ts +14 -10
  51. package/src/adapters/shared/fs-server-response-factory.js +11 -27
  52. package/src/adapters/shared/fs-server-response-matcher.d.ts +18 -18
  53. package/src/adapters/shared/fs-server-response-matcher.js +72 -46
  54. package/src/adapters/shared/hmr-entrypoint-registrar.js +1 -1
  55. package/src/adapters/shared/hmr-html-response.d.ts +1 -1
  56. package/src/adapters/shared/hmr-html-response.js +4 -3
  57. package/src/adapters/shared/render-context.d.ts +5 -3
  58. package/src/adapters/shared/render-context.js +24 -1
  59. package/src/adapters/shared/runtime-app-bootstrap.d.ts +26 -0
  60. package/src/adapters/shared/runtime-app-bootstrap.js +46 -0
  61. package/src/adapters/shared/runtime-host.d.ts +12 -0
  62. package/src/adapters/shared/server-adapter.d.ts +22 -11
  63. package/src/adapters/shared/server-adapter.js +183 -133
  64. package/src/adapters/shared/server-route-handler.d.ts +5 -5
  65. package/src/adapters/shared/server-route-handler.js +4 -4
  66. package/src/adapters/shared/server-static-builder.d.ts +8 -7
  67. package/src/adapters/shared/server-static-builder.js +6 -5
  68. package/src/adapters/shared/shared-hmr-manager.d.ts +59 -0
  69. package/src/adapters/shared/shared-hmr-manager.js +241 -0
  70. package/src/adapters/shared/static-preview-host.d.ts +10 -0
  71. package/src/build/README.md +57 -67
  72. package/src/build/browser-runtime-manifest.d.ts +31 -0
  73. package/src/build/browser-runtime-manifest.js +61 -0
  74. package/src/build/browser-runtime-plugin-helpers.d.ts +26 -0
  75. package/src/build/browser-runtime-plugin-helpers.js +14 -0
  76. package/src/build/browser-runtime-plugin.d.ts +78 -0
  77. package/src/build/browser-runtime-plugin.js +173 -0
  78. package/src/build/build-adapter.d.ts +384 -63
  79. package/src/build/build-adapter.js +129 -54
  80. package/src/build/build-manifest.d.ts +6 -0
  81. package/src/build/build-manifest.js +21 -2
  82. package/src/build/build-types.d.ts +2 -2
  83. package/src/build/rolldown-adapter-helpers.d.ts +58 -0
  84. package/src/build/rolldown-adapter-helpers.js +265 -0
  85. package/src/build/rolldown-build-adapter.d.ts +28 -0
  86. package/src/build/rolldown-build-adapter.js +65 -0
  87. package/src/build/rolldown-dev-build-adapter.d.ts +82 -0
  88. package/src/build/rolldown-dev-build-adapter.js +166 -0
  89. package/src/build/rolldown-plugin-bridge.d.ts +59 -0
  90. package/src/build/rolldown-plugin-bridge.js +199 -0
  91. package/src/build/runtime-build-executor.d.ts +15 -7
  92. package/src/build/runtime-build-executor.js +8 -9
  93. package/src/build/runtime-build-output-normalizer.d.ts +3 -0
  94. package/src/build/runtime-build-output-normalizer.js +111 -0
  95. package/src/build/serialized-build-executor.d.ts +64 -0
  96. package/src/build/serialized-build-executor.js +63 -0
  97. package/src/build/server-side-css-shim-plugin.d.ts +41 -0
  98. package/src/build/server-side-css-shim-plugin.js +35 -0
  99. package/src/cache/index.d.ts +6 -0
  100. package/src/cache/index.js +6 -0
  101. package/src/cache/module-parse-cache.d.ts +65 -0
  102. package/src/cache/module-parse-cache.js +75 -0
  103. package/src/config/README.md +5 -2
  104. package/src/config/config-builder.d.ts +41 -13
  105. package/src/config/config-builder.js +62 -24
  106. package/src/declarations.d.ts +1 -1
  107. package/src/dev/host-runtime.d.ts +10 -0
  108. package/src/dev/host-runtime.js +24 -0
  109. package/src/dev/sc-server.d.ts +1 -1
  110. package/src/dev/sc-server.js +1 -1
  111. package/src/eco/eco.browser.d.ts +2 -0
  112. package/src/eco/eco.browser.js +88 -0
  113. package/src/eco/eco.js +50 -45
  114. package/src/eco/eco.types.d.ts +60 -8
  115. package/src/eco/eco.utils.d.ts +1 -40
  116. package/src/eco/eco.utils.js +5 -35
  117. package/src/eco/global-injector-map.d.ts +3 -3
  118. package/src/eco/global-injector-map.js +2 -2
  119. package/src/eco/lazy-injector-map.d.ts +2 -2
  120. package/src/errors/index.d.ts +1 -0
  121. package/src/errors/index.js +3 -1
  122. package/src/hmr/client/hmr-runtime.js +9 -1
  123. package/src/hmr/hmr-strategy.d.ts +16 -13
  124. package/src/hmr/hmr-strategy.js +22 -7
  125. package/src/hmr/strategies/default-hmr-strategy.d.ts +2 -2
  126. package/src/hmr/strategies/default-hmr-strategy.js +1 -1
  127. package/src/hmr/strategies/js-hmr-strategy.d.ts +4 -9
  128. package/src/hmr/strategies/js-hmr-strategy.js +5 -10
  129. package/src/index.browser.d.ts +2 -2
  130. package/src/index.browser.js +1 -1
  131. package/src/index.d.ts +3 -2
  132. package/src/index.js +15 -4
  133. package/src/integrations/ghtml/ghtml-renderer.d.ts +2 -1
  134. package/src/integrations/ghtml/ghtml-renderer.js +24 -29
  135. package/src/integrations/ghtml/ghtml.constants.d.ts +1 -0
  136. package/src/integrations/ghtml/ghtml.constants.js +4 -0
  137. package/src/integrations/ghtml/ghtml.plugin.d.ts +2 -6
  138. package/src/integrations/ghtml/ghtml.plugin.js +3 -4
  139. package/src/plugins/README.md +1 -0
  140. package/src/plugins/alias-resolver-cache.d.ts +68 -0
  141. package/src/plugins/alias-resolver-cache.js +106 -0
  142. package/src/plugins/alias-resolver-plugin.d.ts +5 -1
  143. package/src/plugins/alias-resolver-plugin.js +19 -7
  144. package/src/plugins/eco-component-meta-plugin.d.ts +12 -1
  145. package/src/plugins/eco-component-meta-plugin.js +43 -25
  146. package/src/plugins/foreign-jsx-override-plugin.d.ts +33 -0
  147. package/src/plugins/foreign-jsx-override-plugin.js +41 -0
  148. package/src/plugins/integration-plugin.d.ts +136 -42
  149. package/src/plugins/integration-plugin.js +99 -31
  150. package/src/plugins/processor.d.ts +4 -2
  151. package/src/plugins/processor.js +8 -3
  152. package/src/plugins/source-transform.d.ts +46 -0
  153. package/src/plugins/source-transform.js +71 -0
  154. package/src/route-renderer/GRAPH.md +80 -318
  155. package/src/route-renderer/README.md +74 -78
  156. package/src/route-renderer/orchestration/component-render-context.d.ts +97 -0
  157. package/src/route-renderer/orchestration/component-render-context.js +147 -0
  158. package/src/route-renderer/orchestration/declared-ownership-graph.d.ts +18 -0
  159. package/src/route-renderer/orchestration/declared-ownership-graph.js +34 -0
  160. package/src/route-renderer/orchestration/foreign-subtree-execution.service.d.ts +110 -0
  161. package/src/route-renderer/orchestration/foreign-subtree-execution.service.js +233 -0
  162. package/src/route-renderer/orchestration/integration-renderer.d.ts +290 -128
  163. package/src/route-renderer/orchestration/integration-renderer.js +660 -258
  164. package/src/route-renderer/orchestration/ownership-planning.service.d.ts +24 -0
  165. package/src/route-renderer/orchestration/ownership-planning.service.js +63 -0
  166. package/src/route-renderer/orchestration/ownership-validation.service.d.ts +29 -0
  167. package/src/route-renderer/orchestration/ownership-validation.service.js +53 -0
  168. package/src/route-renderer/orchestration/processed-asset-dedupe.d.ts +3 -0
  169. package/src/route-renderer/orchestration/processed-asset-dedupe.js +27 -0
  170. package/src/route-renderer/orchestration/queued-foreign-subtree-resolution.service.d.ts +91 -0
  171. package/src/route-renderer/orchestration/queued-foreign-subtree-resolution.service.js +170 -0
  172. package/src/route-renderer/orchestration/render-output.utils.d.ts +66 -0
  173. package/src/route-renderer/orchestration/render-output.utils.js +171 -0
  174. package/src/route-renderer/orchestration/route-render-orchestrator.d.ts +156 -0
  175. package/src/route-renderer/orchestration/route-render-orchestrator.js +577 -0
  176. package/src/route-renderer/orchestration/template-serialization.d.ts +38 -0
  177. package/src/route-renderer/orchestration/template-serialization.js +45 -0
  178. package/src/route-renderer/page-loading/component-dependency-collection.d.ts +37 -0
  179. package/src/route-renderer/page-loading/component-dependency-collection.js +132 -0
  180. package/src/route-renderer/page-loading/declared-asset-collection.d.ts +24 -0
  181. package/src/route-renderer/page-loading/declared-asset-collection.js +106 -0
  182. package/src/route-renderer/page-loading/dependency-resolver.d.ts +2 -2
  183. package/src/route-renderer/page-loading/dependency-resolver.js +27 -354
  184. package/src/route-renderer/page-loading/ecopages-virtual-imports.d.ts +11 -0
  185. package/src/route-renderer/page-loading/ecopages-virtual-imports.js +57 -0
  186. package/src/route-renderer/page-loading/lazy-entry-collection.d.ts +45 -0
  187. package/src/route-renderer/page-loading/lazy-entry-collection.js +105 -0
  188. package/src/route-renderer/page-loading/lazy-trigger-planning.d.ts +19 -0
  189. package/src/route-renderer/page-loading/lazy-trigger-planning.js +40 -0
  190. package/src/route-renderer/page-loading/module-declaration-aggregation.d.ts +5 -0
  191. package/src/route-renderer/page-loading/module-declaration-aggregation.js +33 -0
  192. package/src/route-renderer/page-loading/module-declaration-scripts.d.ts +3 -0
  193. package/src/route-renderer/page-loading/module-declaration-scripts.js +18 -0
  194. package/src/route-renderer/page-loading/page-dependency-bundling.d.ts +13 -0
  195. package/src/route-renderer/page-loading/page-dependency-bundling.js +137 -0
  196. package/src/route-renderer/page-loading/page-module-loader.d.ts +7 -4
  197. package/src/route-renderer/page-loading/page-module-loader.js +8 -5
  198. package/src/route-renderer/route-renderer.d.ts +31 -23
  199. package/src/route-renderer/route-renderer.js +17 -24
  200. package/src/router/README.md +76 -8
  201. package/src/router/client/navigation-coordinator.d.ts +20 -0
  202. package/src/router/client/navigation-coordinator.js +2 -2
  203. package/src/router/server/route-registry.d.ts +78 -0
  204. package/src/router/server/route-registry.js +262 -0
  205. package/src/services/README.md +1 -2
  206. package/src/services/assets/asset-processing-service/asset-dependency-keys.d.ts +3 -0
  207. package/src/services/assets/asset-processing-service/asset-dependency-keys.js +56 -0
  208. package/src/services/assets/asset-processing-service/asset-processing.service.d.ts +3 -20
  209. package/src/services/assets/asset-processing-service/asset-processing.service.js +52 -98
  210. package/src/services/assets/asset-processing-service/asset.factory.d.ts +1 -1
  211. package/src/services/assets/asset-processing-service/asset.factory.js +2 -2
  212. package/src/services/assets/asset-processing-service/assets.types.d.ts +14 -0
  213. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.d.ts +2 -0
  214. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.js +1 -0
  215. package/src/services/assets/asset-processing-service/grouped-content-bundles.d.ts +30 -0
  216. package/src/services/assets/asset-processing-service/grouped-content-bundles.js +65 -0
  217. package/src/services/assets/asset-processing-service/index.d.ts +6 -5
  218. package/src/services/assets/asset-processing-service/index.js +6 -5
  219. package/src/services/assets/asset-processing-service/page-package.d.ts +6 -0
  220. package/src/services/assets/asset-processing-service/page-package.js +80 -0
  221. package/src/services/assets/asset-processing-service/processor.interface.d.ts +2 -2
  222. package/src/services/assets/asset-processing-service/processor.registry.d.ts +2 -2
  223. package/src/services/assets/asset-processing-service/processors/base/base-processor.d.ts +1 -1
  224. package/src/services/assets/asset-processing-service/processors/base/base-processor.js +3 -2
  225. package/src/services/assets/asset-processing-service/processors/base/base-script-processor.d.ts +10 -5
  226. package/src/services/assets/asset-processing-service/processors/base/base-script-processor.js +69 -5
  227. package/src/services/assets/asset-processing-service/processors/index.d.ts +5 -5
  228. package/src/services/assets/asset-processing-service/processors/index.js +5 -5
  229. package/src/services/assets/asset-processing-service/processors/script/content-script.processor.d.ts +3 -2
  230. package/src/services/assets/asset-processing-service/processors/script/content-script.processor.js +66 -3
  231. package/src/services/assets/asset-processing-service/processors/script/file-script.processor.d.ts +4 -3
  232. package/src/services/assets/asset-processing-service/processors/script/file-script.processor.js +27 -6
  233. package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.d.ts +38 -3
  234. package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.js +57 -6
  235. package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.d.ts +5 -2
  236. package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.js +39 -5
  237. package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.d.ts +2 -2
  238. package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.js +5 -2
  239. package/src/services/assets/asset-processing-service/ungrouped-dependency-processing.d.ts +18 -0
  240. package/src/services/assets/asset-processing-service/ungrouped-dependency-processing.js +45 -0
  241. package/src/services/assets/browser-bundle.service.d.ts +44 -3
  242. package/src/services/assets/browser-bundle.service.js +15 -7
  243. package/src/services/html/html-rewriter-provider.service.d.ts +3 -0
  244. package/src/services/html/html-rewriter-provider.service.js +4 -1
  245. package/src/services/html/html-transformer.service.d.ts +22 -3
  246. package/src/services/html/html-transformer.service.js +101 -35
  247. package/src/services/invalidation/development-invalidation.service.d.ts +1 -1
  248. package/src/services/invalidation/development-invalidation.service.js +1 -0
  249. package/src/services/module-loading/app-module-loader.service.d.ts +7 -0
  250. package/src/services/module-loading/app-module-loader.service.js +0 -0
  251. package/src/services/module-loading/app-server-module-transpiler.service.d.ts +9 -1
  252. package/src/services/module-loading/app-server-module-transpiler.service.js +102 -6
  253. package/src/services/module-loading/host-module-loader-registry.d.ts +4 -0
  254. package/src/services/module-loading/host-module-loader-registry.js +15 -0
  255. package/src/services/module-loading/module-loading-types.d.ts +2 -0
  256. package/src/services/module-loading/module-loading-types.js +0 -0
  257. package/src/services/module-loading/page-module-import.service.d.ts +32 -8
  258. package/src/services/module-loading/page-module-import.service.js +83 -22
  259. package/src/services/module-loading/server-module-transpiler.service.d.ts +8 -14
  260. package/src/services/module-loading/server-module-transpiler.service.js +5 -2
  261. package/src/services/module-loading/source-module-support.d.ts +5 -0
  262. package/src/services/module-loading/source-module-support.js +8 -0
  263. package/src/services/runtime-state/dev-graph.service.d.ts +6 -6
  264. package/src/services/runtime-state/dev-graph.service.js +10 -10
  265. package/src/services/runtime-state/entrypoint-dependency-graph.service.d.ts +1 -1
  266. package/src/services/runtime-state/server-invalidation-state.service.d.ts +1 -1
  267. package/src/static-site-generator/static-site-generator.d.ts +23 -28
  268. package/src/static-site-generator/static-site-generator.js +119 -156
  269. package/src/{internal-types.d.ts → types/internal-types.d.ts} +34 -23
  270. package/src/types/internal-types.js +0 -0
  271. package/src/{public-types.d.ts → types/public-types.d.ts} +195 -37
  272. package/src/types/public-types.js +0 -0
  273. package/src/utils/html-escaping.d.ts +7 -0
  274. package/src/utils/html-escaping.js +6 -0
  275. package/src/utils/locals-utils.d.ts +1 -1
  276. package/src/utils/parse-cli-args.d.ts +4 -1
  277. package/src/utils/parse-cli-args.js +16 -1
  278. package/src/utils/resolve-work-dir.js +1 -1
  279. package/src/watchers/project-watcher.d.ts +4 -4
  280. package/src/watchers/project-watcher.js +35 -41
  281. package/src/watchers/project-watcher.test-helpers.d.ts +2 -2
  282. package/src/watchers/project-watcher.test-helpers.js +5 -5
  283. package/CHANGELOG.md +0 -31
  284. package/src/adapters/abstract/application-adapter.ts +0 -337
  285. package/src/adapters/abstract/router-adapter.ts +0 -30
  286. package/src/adapters/abstract/server-adapter.ts +0 -79
  287. package/src/adapters/bun/client-bridge.ts +0 -62
  288. package/src/adapters/bun/create-app.ts +0 -189
  289. package/src/adapters/bun/hmr-manager.ts +0 -409
  290. package/src/adapters/bun/index.ts +0 -2
  291. package/src/adapters/bun/server-adapter.ts +0 -499
  292. package/src/adapters/bun/server-lifecycle.d.ts +0 -63
  293. package/src/adapters/bun/server-lifecycle.js +0 -92
  294. package/src/adapters/bun/server-lifecycle.ts +0 -124
  295. package/src/adapters/index.ts +0 -6
  296. package/src/adapters/node/bootstrap-dependency-resolver.d.ts +0 -44
  297. package/src/adapters/node/bootstrap-dependency-resolver.js +0 -172
  298. package/src/adapters/node/bootstrap-dependency-resolver.ts +0 -301
  299. package/src/adapters/node/create-app.ts +0 -179
  300. package/src/adapters/node/index.d.ts +0 -6
  301. package/src/adapters/node/index.js +0 -11
  302. package/src/adapters/node/index.ts +0 -16
  303. package/src/adapters/node/node-client-bridge.ts +0 -79
  304. package/src/adapters/node/node-hmr-manager.ts +0 -381
  305. package/src/adapters/node/runtime-adapter.d.ts +0 -46
  306. package/src/adapters/node/runtime-adapter.js +0 -306
  307. package/src/adapters/node/runtime-adapter.ts +0 -439
  308. package/src/adapters/node/server-adapter.ts +0 -488
  309. package/src/adapters/node/static-content-server.ts +0 -239
  310. package/src/adapters/node/write-runtime-manifest.d.ts +0 -26
  311. package/src/adapters/node/write-runtime-manifest.js +0 -12
  312. package/src/adapters/node/write-runtime-manifest.ts +0 -38
  313. package/src/adapters/shared/api-response.ts +0 -104
  314. package/src/adapters/shared/application-adapter.ts +0 -199
  315. package/src/adapters/shared/define-api-handler.ts +0 -66
  316. package/src/adapters/shared/explicit-static-route-matcher.ts +0 -140
  317. package/src/adapters/shared/file-route-middleware-pipeline.ts +0 -127
  318. package/src/adapters/shared/fs-server-response-factory.ts +0 -118
  319. package/src/adapters/shared/fs-server-response-matcher.ts +0 -205
  320. package/src/adapters/shared/hmr-entrypoint-registrar.ts +0 -149
  321. package/src/adapters/shared/hmr-html-response.ts +0 -52
  322. package/src/adapters/shared/render-context.ts +0 -120
  323. package/src/adapters/shared/runtime-bootstrap.d.ts +0 -38
  324. package/src/adapters/shared/runtime-bootstrap.js +0 -43
  325. package/src/adapters/shared/runtime-bootstrap.ts +0 -79
  326. package/src/adapters/shared/server-adapter.ts +0 -489
  327. package/src/adapters/shared/server-route-handler.ts +0 -153
  328. package/src/adapters/shared/server-static-builder.ts +0 -166
  329. package/src/build/build-adapter.ts +0 -361
  330. package/src/build/build-manifest.ts +0 -54
  331. package/src/build/build-types.ts +0 -83
  332. package/src/build/dev-build-coordinator.d.ts +0 -74
  333. package/src/build/dev-build-coordinator.js +0 -161
  334. package/src/build/dev-build-coordinator.ts +0 -221
  335. package/src/build/esbuild-build-adapter.d.ts +0 -72
  336. package/src/build/esbuild-build-adapter.js +0 -422
  337. package/src/build/esbuild-build-adapter.ts +0 -559
  338. package/src/build/runtime-build-executor.ts +0 -34
  339. package/src/build/runtime-specifier-alias-plugin.d.ts +0 -15
  340. package/src/build/runtime-specifier-alias-plugin.js +0 -31
  341. package/src/build/runtime-specifier-alias-plugin.ts +0 -58
  342. package/src/config/config-builder.ts +0 -706
  343. package/src/constants.ts +0 -54
  344. package/src/create-app.ts +0 -87
  345. package/src/dev/sc-server.ts +0 -143
  346. package/src/eco/component-render-context.d.ts +0 -105
  347. package/src/eco/component-render-context.js +0 -87
  348. package/src/eco/component-render-context.ts +0 -224
  349. package/src/eco/eco.ts +0 -242
  350. package/src/eco/eco.types.ts +0 -221
  351. package/src/eco/eco.utils.ts +0 -89
  352. package/src/eco/global-injector-map.ts +0 -112
  353. package/src/eco/lazy-injector-map.ts +0 -120
  354. package/src/eco/module-dependencies.ts +0 -75
  355. package/src/errors/http-error.ts +0 -72
  356. package/src/errors/index.ts +0 -2
  357. package/src/errors/locals-access-error.ts +0 -7
  358. package/src/global/app-logger.ts +0 -4
  359. package/src/hmr/client/hmr-runtime.ts +0 -152
  360. package/src/hmr/hmr-strategy.ts +0 -172
  361. package/src/hmr/hmr.postcss.test.e2e.ts +0 -41
  362. package/src/hmr/hmr.test.e2e.ts +0 -66
  363. package/src/hmr/strategies/default-hmr-strategy.ts +0 -60
  364. package/src/hmr/strategies/js-hmr-strategy.ts +0 -320
  365. package/src/index.browser.ts +0 -3
  366. package/src/index.ts +0 -5
  367. package/src/integrations/ghtml/ghtml-renderer.ts +0 -96
  368. package/src/integrations/ghtml/ghtml.plugin.ts +0 -32
  369. package/src/internal-types.ts +0 -232
  370. package/src/plugins/alias-resolver-plugin.ts +0 -63
  371. package/src/plugins/eco-component-meta-plugin.ts +0 -481
  372. package/src/plugins/integration-plugin.ts +0 -226
  373. package/src/plugins/processor.ts +0 -240
  374. package/src/plugins/runtime-capability.ts +0 -14
  375. package/src/public-types.ts +0 -1317
  376. package/src/route-renderer/component-graph/component-graph-executor.d.ts +0 -32
  377. package/src/route-renderer/component-graph/component-graph-executor.js +0 -31
  378. package/src/route-renderer/component-graph/component-graph-executor.ts +0 -84
  379. package/src/route-renderer/component-graph/component-graph.d.ts +0 -42
  380. package/src/route-renderer/component-graph/component-graph.js +0 -72
  381. package/src/route-renderer/component-graph/component-graph.ts +0 -159
  382. package/src/route-renderer/component-graph/component-marker.d.ts +0 -52
  383. package/src/route-renderer/component-graph/component-marker.js +0 -46
  384. package/src/route-renderer/component-graph/component-marker.ts +0 -117
  385. package/src/route-renderer/component-graph/component-reference.d.ts +0 -10
  386. package/src/route-renderer/component-graph/component-reference.js +0 -19
  387. package/src/route-renderer/component-graph/component-reference.ts +0 -29
  388. package/src/route-renderer/component-graph/marker-graph-resolver.d.ts +0 -77
  389. package/src/route-renderer/component-graph/marker-graph-resolver.js +0 -95
  390. package/src/route-renderer/component-graph/marker-graph-resolver.ts +0 -155
  391. package/src/route-renderer/orchestration/integration-renderer.ts +0 -790
  392. package/src/route-renderer/orchestration/render-execution.service.d.ts +0 -103
  393. package/src/route-renderer/orchestration/render-execution.service.js +0 -121
  394. package/src/route-renderer/orchestration/render-execution.service.ts +0 -230
  395. package/src/route-renderer/orchestration/render-preparation.service.d.ts +0 -121
  396. package/src/route-renderer/orchestration/render-preparation.service.js +0 -332
  397. package/src/route-renderer/orchestration/render-preparation.service.ts +0 -476
  398. package/src/route-renderer/page-loading/dependency-resolver.ts +0 -612
  399. package/src/route-renderer/page-loading/page-module-loader.ts +0 -181
  400. package/src/route-renderer/route-renderer.ts +0 -115
  401. package/src/router/client/link-intent.test.browser.ts +0 -51
  402. package/src/router/client/link-intent.ts +0 -92
  403. package/src/router/client/navigation-coordinator.ts +0 -433
  404. package/src/router/server/fs-router-scanner.d.ts +0 -41
  405. package/src/router/server/fs-router-scanner.js +0 -156
  406. package/src/router/server/fs-router-scanner.ts +0 -219
  407. package/src/router/server/fs-router.d.ts +0 -26
  408. package/src/router/server/fs-router.js +0 -100
  409. package/src/router/server/fs-router.ts +0 -122
  410. package/src/services/assets/asset-processing-service/asset-processing.service.ts +0 -401
  411. package/src/services/assets/asset-processing-service/asset.factory.ts +0 -105
  412. package/src/services/assets/asset-processing-service/assets.types.ts +0 -113
  413. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.ts +0 -95
  414. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.ts +0 -78
  415. package/src/services/assets/asset-processing-service/index.ts +0 -5
  416. package/src/services/assets/asset-processing-service/processor.interface.ts +0 -27
  417. package/src/services/assets/asset-processing-service/processor.registry.ts +0 -18
  418. package/src/services/assets/asset-processing-service/processors/base/base-processor.ts +0 -82
  419. package/src/services/assets/asset-processing-service/processors/base/base-script-processor.ts +0 -95
  420. package/src/services/assets/asset-processing-service/processors/index.ts +0 -5
  421. package/src/services/assets/asset-processing-service/processors/script/content-script.processor.ts +0 -66
  422. package/src/services/assets/asset-processing-service/processors/script/file-script.processor.ts +0 -88
  423. package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.ts +0 -85
  424. package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.ts +0 -27
  425. package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.ts +0 -80
  426. package/src/services/assets/browser-bundle.service.ts +0 -53
  427. package/src/services/cache/cache.types.ts +0 -126
  428. package/src/services/cache/index.ts +0 -18
  429. package/src/services/cache/memory-cache-store.ts +0 -130
  430. package/src/services/cache/page-cache-service.ts +0 -202
  431. package/src/services/cache/page-request-cache-coordinator.service.ts +0 -131
  432. package/src/services/html/html-rewriter-provider.service.ts +0 -103
  433. package/src/services/html/html-transformer.service.ts +0 -279
  434. package/src/services/invalidation/development-invalidation.service.ts +0 -261
  435. package/src/services/module-loading/app-server-module-transpiler.service.ts +0 -52
  436. package/src/services/module-loading/page-module-import.service.ts +0 -200
  437. package/src/services/module-loading/server-loader.service.d.ts +0 -96
  438. package/src/services/module-loading/server-loader.service.js +0 -32
  439. package/src/services/module-loading/server-loader.service.ts +0 -130
  440. package/src/services/module-loading/server-module-transpiler.service.ts +0 -105
  441. package/src/services/runtime-manifest/node-runtime-manifest.service.d.ts +0 -35
  442. package/src/services/runtime-manifest/node-runtime-manifest.service.js +0 -60
  443. package/src/services/runtime-manifest/node-runtime-manifest.service.ts +0 -101
  444. package/src/services/runtime-state/dev-graph.service.ts +0 -217
  445. package/src/services/runtime-state/entrypoint-dependency-graph.service.ts +0 -136
  446. package/src/services/runtime-state/runtime-specifier-registry.service.d.ts +0 -69
  447. package/src/services/runtime-state/runtime-specifier-registry.service.js +0 -37
  448. package/src/services/runtime-state/runtime-specifier-registry.service.ts +0 -96
  449. package/src/services/runtime-state/server-invalidation-state.service.ts +0 -68
  450. package/src/services/validation/schema-validation-service.ts +0 -204
  451. package/src/services/validation/standard-schema.types.ts +0 -68
  452. package/src/static-site-generator/static-site-generator.ts +0 -462
  453. package/src/utils/css.d.ts +0 -1
  454. package/src/utils/css.js +0 -7
  455. package/src/utils/css.ts +0 -5
  456. package/src/utils/deep-merge.ts +0 -47
  457. package/src/utils/hash.ts +0 -5
  458. package/src/utils/html.ts +0 -1
  459. package/src/utils/invariant.ts +0 -15
  460. package/src/utils/locals-utils.ts +0 -37
  461. package/src/utils/parse-cli-args.ts +0 -83
  462. package/src/utils/path-utils.module.ts +0 -14
  463. package/src/utils/resolve-work-dir.ts +0 -45
  464. package/src/utils/runtime.ts +0 -44
  465. package/src/utils/server-utils.module.ts +0 -67
  466. package/src/watchers/project-watcher.test-helpers.ts +0 -41
  467. package/src/watchers/project-watcher.ts +0 -363
  468. /package/src/{internal-types.js → adapters/shared/runtime-host.js} +0 -0
  469. /package/src/{public-types.js → adapters/shared/static-preview-host.js} +0 -0
  470. /package/src/{constants.d.ts → config/constants.d.ts} +0 -0
  471. /package/src/{constants.js → config/constants.js} +0 -0
@@ -0,0 +1,241 @@
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.js";
5
+ import { getAppBuildExecutor } from "../../build/build-adapter.js";
6
+ import { fileSystem } from "@ecopages/file-system";
7
+ import { HmrStrategyType } from "../../hmr/hmr-strategy.js";
8
+ import { DefaultHmrStrategy } from "../../hmr/strategies/default-hmr-strategy.js";
9
+ import { JsHmrStrategy } from "../../hmr/strategies/js-hmr-strategy.js";
10
+ import { appLogger } from "../../global/app-logger.js";
11
+ import { HmrEntrypointRegistrar } from "./hmr-entrypoint-registrar.js";
12
+ import { BrowserBundleService } from "../../services/assets/browser-bundle.service.js";
13
+ import { getAppServerModuleTranspiler } from "../../services/module-loading/app-server-module-transpiler.service.js";
14
+ import {
15
+ getAppEntrypointDependencyGraph,
16
+ setAppEntrypointDependencyGraph
17
+ } from "../../services/runtime-state/entrypoint-dependency-graph.service.js";
18
+ import { resolveInternalExecutionDir, resolveInternalWorkDir } from "../../utils/resolve-work-dir.js";
19
+ class SharedHmrManager {
20
+ appConfig;
21
+ bridge;
22
+ watchers = /* @__PURE__ */ new Map();
23
+ watchedFiles = /* @__PURE__ */ new Map();
24
+ entrypointRegistrations = /* @__PURE__ */ new Map();
25
+ distDir;
26
+ plugins = [];
27
+ enabled = true;
28
+ strategies = [];
29
+ entrypointRegistrar;
30
+ browserBundleService;
31
+ entrypointDependencyGraph;
32
+ serverModuleTranspiler;
33
+ constructor({ appConfig, bridge, registrationTimeoutMs = 4e3 }) {
34
+ this.appConfig = appConfig;
35
+ this.bridge = bridge;
36
+ this.distDir = path.join(resolveInternalWorkDir(this.appConfig), RESOLVED_ASSETS_DIR, "_hmr");
37
+ this.entrypointRegistrar = new HmrEntrypointRegistrar({
38
+ srcDir: this.appConfig.absolutePaths.srcDir,
39
+ distDir: this.distDir,
40
+ entrypointRegistrations: this.entrypointRegistrations,
41
+ watchedFiles: this.watchedFiles,
42
+ clearFailedRegistration: (entrypointPath) => this.clearFailedEntrypointRegistration(entrypointPath),
43
+ registrationTimeoutMs
44
+ });
45
+ this.browserBundleService = new BrowserBundleService(appConfig);
46
+ this.entrypointDependencyGraph = this.createEntrypointDependencyGraph(
47
+ getAppEntrypointDependencyGraph(appConfig)
48
+ );
49
+ setAppEntrypointDependencyGraph(this.appConfig, this.entrypointDependencyGraph);
50
+ this.serverModuleTranspiler = getAppServerModuleTranspiler(this.appConfig);
51
+ this.ensureDistDir();
52
+ this.initializeStrategies();
53
+ }
54
+ shouldSkipMissingFileChange(_filePath) {
55
+ return false;
56
+ }
57
+ onRuntimeBundleFailure(error) {
58
+ appLogger.error("[HMR] Failed to build runtime script:", error);
59
+ }
60
+ ensureDistDir() {
61
+ fileSystem.ensureDir(this.distDir);
62
+ }
63
+ shouldJsStrategyProcessEntrypoint(entrypointPath) {
64
+ return !this.strategies.some((strategy) => {
65
+ if (strategy.type !== HmrStrategyType.INTEGRATION || strategy.priority <= HmrStrategyType.SCRIPT) {
66
+ return false;
67
+ }
68
+ try {
69
+ return strategy.matches(entrypointPath);
70
+ } catch (error) {
71
+ appLogger.error(error);
72
+ return false;
73
+ }
74
+ });
75
+ }
76
+ initializeStrategies() {
77
+ const jsContext = {
78
+ getWatchedFiles: () => this.watchedFiles,
79
+ getDistDir: () => this.distDir,
80
+ getPlugins: () => this.plugins,
81
+ getSrcDir: () => this.appConfig.absolutePaths.srcDir,
82
+ getPagesDir: () => this.appConfig.absolutePaths.pagesDir,
83
+ getLayoutsDir: () => this.appConfig.absolutePaths.layoutsDir,
84
+ getTemplateExtensions: () => this.appConfig.templatesExt,
85
+ getBrowserBundleService: () => this.browserBundleService,
86
+ getEntrypointDependencyGraph: () => this.entrypointDependencyGraph,
87
+ shouldProcessEntrypoint: (entrypointPath) => this.shouldJsStrategyProcessEntrypoint(entrypointPath)
88
+ };
89
+ this.strategies = [new JsHmrStrategy(jsContext), new DefaultHmrStrategy()];
90
+ }
91
+ registerStrategy(strategy) {
92
+ this.strategies.push(strategy);
93
+ }
94
+ setPlugins(plugins) {
95
+ this.plugins = [...plugins];
96
+ }
97
+ setEnabled(enabled) {
98
+ this.enabled = enabled;
99
+ }
100
+ isEnabled() {
101
+ return this.enabled;
102
+ }
103
+ async buildRuntime() {
104
+ const runtimeSource = fileURLToPath(import.meta.resolve("@ecopages/core/hmr/client/hmr-runtime"));
105
+ try {
106
+ const result = await this.browserBundleService.bundle({
107
+ profile: "hmr-runtime",
108
+ entrypoints: [runtimeSource],
109
+ outdir: this.distDir,
110
+ naming: "_hmr_runtime.js",
111
+ minify: false,
112
+ plugins: this.plugins
113
+ });
114
+ if (!result.success) {
115
+ this.onRuntimeBundleFailure(result.logs);
116
+ }
117
+ } catch (error) {
118
+ this.onRuntimeBundleFailure(error);
119
+ }
120
+ }
121
+ getRuntimePath() {
122
+ return path.join(this.distDir, "_hmr_runtime.js");
123
+ }
124
+ broadcast(event) {
125
+ appLogger.debug(
126
+ `[HMR] Broadcasting ${event.type} event, path=${event.path || "all"}, subscribers=${this.bridge.subscriberCount}`
127
+ );
128
+ this.bridge.broadcast(event);
129
+ }
130
+ async handleFileChange(filePath, options = {}) {
131
+ if (this.shouldSkipMissingFileChange(filePath) && !fileSystem.exists(filePath)) {
132
+ appLogger.debug(`[${this.constructor.name}] Skipping missing file change: ${filePath}`);
133
+ this.clearFailedEntrypointRegistration(filePath);
134
+ return;
135
+ }
136
+ const sorted = [...this.strategies].sort((a, b) => b.priority - a.priority);
137
+ const strategy = sorted.find((candidate) => {
138
+ try {
139
+ return candidate.matches(filePath);
140
+ } catch (error) {
141
+ appLogger.error(error);
142
+ return false;
143
+ }
144
+ });
145
+ if (!strategy) {
146
+ appLogger.warn(`[HMR] No strategy found for ${filePath}`);
147
+ return;
148
+ }
149
+ appLogger.debug(`[${this.constructor.name}] Selected strategy: ${strategy.constructor.name}`);
150
+ const action = await strategy.process(filePath);
151
+ const shouldBroadcast = options.broadcast ?? true;
152
+ if (shouldBroadcast && action.type === "broadcast" && action.events) {
153
+ for (const event of action.events) {
154
+ this.broadcast(event);
155
+ }
156
+ }
157
+ }
158
+ getOutputUrl(entrypointPath) {
159
+ return this.watchedFiles.get(entrypointPath);
160
+ }
161
+ getWatchedFiles() {
162
+ return this.watchedFiles;
163
+ }
164
+ getDistDir() {
165
+ return this.distDir;
166
+ }
167
+ getPlugins() {
168
+ return this.plugins;
169
+ }
170
+ getDefaultContext() {
171
+ return {
172
+ getWatchedFiles: () => this.watchedFiles,
173
+ getDistDir: () => this.distDir,
174
+ getPlugins: () => this.plugins,
175
+ getSrcDir: () => this.appConfig.absolutePaths.srcDir,
176
+ getLayoutsDir: () => this.appConfig.absolutePaths.layoutsDir,
177
+ getPagesDir: () => this.appConfig.absolutePaths.pagesDir,
178
+ getBuildExecutor: () => getAppBuildExecutor(this.appConfig),
179
+ getBrowserBundleService: () => this.browserBundleService,
180
+ getEntrypointDependencyGraph: () => this.entrypointDependencyGraph,
181
+ importServerModule: async (filePath) => await this.serverModuleTranspiler.importModule({
182
+ filePath,
183
+ outdir: path.join(resolveInternalExecutionDir(this.appConfig), ".server-modules"),
184
+ externalPackages: true
185
+ })
186
+ };
187
+ }
188
+ clearFailedEntrypointRegistration(entrypointPath) {
189
+ this.watchedFiles.delete(entrypointPath);
190
+ this.entrypointDependencyGraph.clearEntrypointDependencies(entrypointPath);
191
+ }
192
+ async registerEntrypoint(entrypointPath) {
193
+ return await this.entrypointRegistrar.registerEntrypoint(entrypointPath, {
194
+ emit: async (normalizedEntrypoint) => await this.emitStrictEntrypoint(normalizedEntrypoint),
195
+ getMissingOutputError: (normalizedEntrypoint, outputPath) => new Error(
196
+ `[HMR] Integration failed to emit entrypoint ${normalizedEntrypoint} to ${outputPath}. Page entrypoints must be produced by their owning integration.`
197
+ )
198
+ });
199
+ }
200
+ async registerScriptEntrypoint(entrypointPath) {
201
+ return await this.entrypointRegistrar.registerEntrypoint(entrypointPath, {
202
+ emit: async (normalizedEntrypoint, outputPath) => await this.emitScriptEntrypoint(normalizedEntrypoint, outputPath),
203
+ getMissingOutputError: (normalizedEntrypoint) => new Error(`[HMR] Failed to register script entrypoint: ${normalizedEntrypoint}`)
204
+ });
205
+ }
206
+ async emitStrictEntrypoint(entrypointPath) {
207
+ await this.handleFileChange(entrypointPath, { broadcast: false });
208
+ }
209
+ async emitScriptEntrypoint(entrypointPath, outputPath) {
210
+ const naming = path.relative(this.distDir, outputPath).split(path.sep).join("/");
211
+ const buildResult = await this.browserBundleService.bundle({
212
+ profile: "hmr-entrypoint",
213
+ entrypoints: [entrypointPath],
214
+ outdir: this.distDir,
215
+ naming,
216
+ minify: false,
217
+ plugins: this.plugins
218
+ });
219
+ if (!buildResult.success) {
220
+ appLogger.error(`[HMR] Generic script entrypoint build failed for ${entrypointPath}:`, buildResult.logs);
221
+ return;
222
+ }
223
+ const entrypointDependencies = buildResult.dependencyGraph?.entrypoints?.[entrypointPath];
224
+ if (entrypointDependencies) {
225
+ this.entrypointDependencyGraph.setEntrypointDependencies(entrypointPath, entrypointDependencies);
226
+ }
227
+ }
228
+ stop() {
229
+ this.entrypointRegistrations.clear();
230
+ for (const watcher of this.watchers.values()) {
231
+ watcher.close();
232
+ }
233
+ this.watchers.clear();
234
+ this.watchedFiles.clear();
235
+ this.entrypointDependencyGraph.reset();
236
+ this.plugins = [];
237
+ }
238
+ }
239
+ export {
240
+ SharedHmrManager
241
+ };
@@ -0,0 +1,10 @@
1
+ import type { EcoPagesAppConfig } from '../../types/internal-types.js';
2
+ export interface StaticPreviewHost {
3
+ start(options: StaticPreviewHostStartOptions): Promise<number | null>;
4
+ stop(force?: boolean): Promise<void>;
5
+ }
6
+ export interface StaticPreviewHostStartOptions {
7
+ appConfig: EcoPagesAppConfig;
8
+ hostname: string;
9
+ port: number;
10
+ }
@@ -1,101 +1,91 @@
1
1
  # Build Layer
2
2
 
3
- This directory contains the runtime-neutral build contract used across Ecopages and the esbuild-backed implementation that currently powers the default fallback adapter.
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
5
+ ## Mental Model
6
6
 
7
- - `build-adapter.ts`: shared build interfaces, result types, app-owned adapter/executor helpers, the exported `defaultBuildAdapter` fallback, and the top-level `build()` / `getTranspileOptions()` pipeline functions.
8
- - `build-types.ts`: plugin bridge types used by integrations and processors.
9
- - `esbuild-build-adapter.ts`: the concrete esbuild backend.
10
- - `dev-build-coordinator.ts`: development-only orchestration around the shared esbuild backend.
11
- - `*.test.ts`: focused regression coverage for plain builds and development serialization and recovery.
7
+ Three concentric shapes, plus a serializer and a plugin injector:
12
8
 
13
- ## Responsibilities
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. |
14
15
 
15
- The build layer is intentionally split into two parts.
16
+ Plus one translation bridge:
16
17
 
17
- `BuildExecutor` is the runtime-facing contract.
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.
18
19
 
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
- - `EsbuildBuildAdapter` satisfies this contract directly in plain flows.
22
- - `DevBuildCoordinator` also satisfies this contract by wrapping the shared esbuild adapter with development-only serialization and recovery policy.
20
+ ## Files
23
21
 
24
- `EsbuildBuildAdapter` is the backend. It knows how to:
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.
25
29
 
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
30
+ ## Default Flow
31
31
 
32
- `DevBuildCoordinator` is the development policy layer. It exists because one app/runtime can have many build callers during dev mode, including:
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.
33
33
 
34
- - page module imports
35
- - HMR entrypoint builds
36
- - script and asset processors
37
- - React integration build paths
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:
38
35
 
39
- Those callers must not race each other against one long-lived esbuild worker. The coordinator therefore owns:
36
+ ```
37
+ BuildExecutor
38
+ └─ SerializedBuildExecutor // FIFO queue
39
+ └─ withBuildExecutorPlugins // injects app plugins
40
+ └─ BuildAdapter (bundled adapter or Vite-host)
41
+ ```
40
42
 
41
- - serialized access to the shared adapter in development
42
- - recycling warm Node-target esbuild sessions between builds
43
- - recovery from known esbuild worker protocol faults
43
+ Every dev-watch caller reads `appConfig.runtime.buildExecutor` and gets the merged plugin set without further ceremony.
44
44
 
45
- ## Default Flow
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()`.
46
46
 
47
- Each `EcoPagesAppConfig` owns a build adapter, build manifest, and `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.
47
+ ## Vite-Host Boundary
48
48
 
49
- When a Node or Bun server adapter starts in watch mode, it replaces that executor with a per-app `DevBuildCoordinator`. Build consumers then either call the executor directly or pass it explicitly to the top-level `build()` helper.
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.
50
50
 
51
- 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:
52
52
 
53
- 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.
54
56
 
55
- ## Orchestration Diagram
57
+ ## Plugin Authoring
56
58
 
57
- ```mermaid
58
- flowchart TD
59
- Config["ConfigBuilder.build()"] --> DefaultExec["appConfig.runtime.buildExecutor = createAppBuildExecutor(app adapter, manifest)"]
60
- Adapter["Server adapter initialize() in watch mode"] --> DevExec["appConfig.runtime.buildExecutor = DevBuildCoordinator"]
61
- Caller["Any build caller with app/runtime context"] --> Build["executor.build(options) or build(options, executor)"]
62
- Build --> Executor["BuildExecutor"]
63
- Executor --> Coordinator["DevBuildCoordinator.build()"]
64
- Coordinator --> Backend["EsbuildBuildAdapter.buildOrThrow()"]
65
- Executor -->|plain flow| Direct["EsbuildBuildAdapter.build()"]
66
- Backend --> Result["BuildResult"]
67
- Direct --> Result["BuildResult"]
68
- Result --> Browser["Browser consumes emitted bundle directly"]
69
- ```
59
+ `EcoBuildPlugin` is the runtime-agnostic contract integrations and processors register. The shape:
70
60
 
71
- ## Recovery Model
61
+ - `name: string`
62
+ - `setup(build: EcoBuildPluginBuilder): void | Promise<void>`
72
63
 
73
- 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:
74
65
 
75
- 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.
76
69
 
77
- 1. Reset the serialized queue so future builds are not stuck behind a wedged promise.
78
- 2. Stop the current esbuild service instance.
79
- 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.
80
71
 
81
- 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.
82
73
 
83
- ## Why Explicit App Ownership
74
+ ## BuildOptions Caveats
84
75
 
85
- There are many build callsites across core and integrations. The coordinator still needs to stay centralized, 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:
86
77
 
87
- 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.
88
81
 
89
- - each app/runtime owns its own build executor
90
- - development policy stays in one place (`DevBuildCoordinator`)
91
- - callers with app context use that executor explicitly instead of consulting global state
92
- - tests can still instantiate `EsbuildBuildAdapter` or `DevBuildCoordinator` directly when they want the raw 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.
93
83
 
94
84
  ## Testing Strategy
95
85
 
96
- The build tests are split by concern.
97
-
98
- - `build-adapter.test.ts` verifies plain backend behavior and plugin bridging.
99
- - `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.
100
90
 
101
- 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.
@@ -0,0 +1,31 @@
1
+ export type BrowserRuntimeMode = 'development' | 'production';
2
+ export type BrowserRuntimeAssetDeclaration = {
3
+ /** Bare or virtual specifier used by authored/generated browser modules. */
4
+ specifier: string;
5
+ /** Integration, processor, or core subsystem that owns this runtime asset. */
6
+ owner: string;
7
+ /** Source import path used to build or resolve the runtime asset. */
8
+ importPath: string;
9
+ /** Concrete browser URL emitted or served for this runtime asset. */
10
+ publicPath: string;
11
+ /** Runtime mode this declaration applies to. Omit when the URL is mode-independent. */
12
+ mode?: BrowserRuntimeMode;
13
+ /** Specifiers that should be treated as external while building this runtime asset. */
14
+ externals?: readonly string[];
15
+ };
16
+ export type BrowserRuntimeAsset = BrowserRuntimeAssetDeclaration & {
17
+ externals: readonly string[];
18
+ };
19
+ export type BrowserRuntimeManifest = {
20
+ assets: readonly BrowserRuntimeAsset[];
21
+ bySpecifier: ReadonlyMap<string, BrowserRuntimeAsset>;
22
+ };
23
+ export declare class BrowserRuntimeManifestConflictError extends Error {
24
+ readonly specifier: string;
25
+ readonly existing: BrowserRuntimeAsset;
26
+ readonly incoming: BrowserRuntimeAsset;
27
+ constructor(specifier: string, existing: BrowserRuntimeAsset, incoming: BrowserRuntimeAsset);
28
+ }
29
+ export declare function createBrowserRuntimeManifest(declarations?: readonly BrowserRuntimeAssetDeclaration[]): BrowserRuntimeManifest;
30
+ export declare function mergeBrowserRuntimeManifests(...manifests: Array<BrowserRuntimeManifest | undefined>): BrowserRuntimeManifest;
31
+ export declare function getBrowserRuntimeSpecifierMap(manifest: BrowserRuntimeManifest): ReadonlyMap<string, string>;
@@ -0,0 +1,61 @@
1
+ class BrowserRuntimeManifestConflictError extends Error {
2
+ specifier;
3
+ existing;
4
+ incoming;
5
+ constructor(specifier, existing, incoming) {
6
+ super(
7
+ `Browser runtime asset conflict for ${specifier}: ${existing.owner} maps to ${existing.publicPath}, ${incoming.owner} maps to ${incoming.publicPath}`
8
+ );
9
+ this.name = "BrowserRuntimeManifestConflictError";
10
+ this.specifier = specifier;
11
+ this.existing = existing;
12
+ this.incoming = incoming;
13
+ }
14
+ }
15
+ function normalizeDeclaration(declaration) {
16
+ return {
17
+ ...declaration,
18
+ externals: declaration.externals ?? []
19
+ };
20
+ }
21
+ function hasCompatibleRuntimeAsset(existing, incoming) {
22
+ return existing.owner === incoming.owner && existing.importPath === incoming.importPath && existing.publicPath === incoming.publicPath && existing.mode === incoming.mode && arrayEquals(existing.externals, incoming.externals);
23
+ }
24
+ function arrayEquals(left, right) {
25
+ if (left.length !== right.length) {
26
+ return false;
27
+ }
28
+ return left.every((value, index) => value === right[index]);
29
+ }
30
+ function createBrowserRuntimeManifest(declarations = []) {
31
+ const assets = [];
32
+ const bySpecifier = /* @__PURE__ */ new Map();
33
+ for (const declaration of declarations) {
34
+ const asset = normalizeDeclaration(declaration);
35
+ const existing = bySpecifier.get(asset.specifier);
36
+ if (existing) {
37
+ if (!hasCompatibleRuntimeAsset(existing, asset)) {
38
+ throw new BrowserRuntimeManifestConflictError(asset.specifier, existing, asset);
39
+ }
40
+ continue;
41
+ }
42
+ assets.push(asset);
43
+ bySpecifier.set(asset.specifier, asset);
44
+ }
45
+ return {
46
+ assets,
47
+ bySpecifier
48
+ };
49
+ }
50
+ function mergeBrowserRuntimeManifests(...manifests) {
51
+ return createBrowserRuntimeManifest(manifests.flatMap((manifest) => manifest?.assets ?? []));
52
+ }
53
+ function getBrowserRuntimeSpecifierMap(manifest) {
54
+ return new Map(manifest.assets.map((asset) => [asset.specifier, asset.publicPath]));
55
+ }
56
+ export {
57
+ BrowserRuntimeManifestConflictError,
58
+ createBrowserRuntimeManifest,
59
+ getBrowserRuntimeSpecifierMap,
60
+ mergeBrowserRuntimeManifests
61
+ };
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Shared helpers for the browser-runtime plugin.
3
+ *
4
+ * @remarks
5
+ * `createBrowserRuntimePlugin` needs to:
6
+ *
7
+ * 1. Escape each specifier for inclusion in a regex filter.
8
+ * 2. Build a `RegExp` whose alternation matches any of those specifiers.
9
+ *
10
+ * These utilities are extracted here so the plugin does not duplicate
11
+ * the same code path.
12
+ */
13
+ /**
14
+ * Escapes a literal specifier for inclusion in a regular expression.
15
+ *
16
+ * Only the regex metacharacters are escaped: `. * + ? ^ $ { } ( ) | [ ] \`
17
+ */
18
+ export declare function escapeRegExp(value: string): string;
19
+ /**
20
+ * Builds a `RegExp` whose alternation matches any of the keys in
21
+ * `specifierMap`.
22
+ *
23
+ * Returns `null` for an empty map so callers can short-circuit and
24
+ * avoid registering a no-op `onResolve` / `onLoad` filter.
25
+ */
26
+ export declare function buildSpecifierFilter(specifierMap: ReadonlyMap<string, string>): RegExp | null;
@@ -0,0 +1,14 @@
1
+ function escapeRegExp(value) {
2
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
3
+ }
4
+ function buildSpecifierFilter(specifierMap) {
5
+ if (specifierMap.size === 0) {
6
+ return null;
7
+ }
8
+ const alternation = Array.from(specifierMap.keys()).map(escapeRegExp).join("|");
9
+ return new RegExp(`^(${alternation})$`);
10
+ }
11
+ export {
12
+ buildSpecifierFilter,
13
+ escapeRegExp
14
+ };
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Unified browser-runtime plugin factory.
3
+ *
4
+ * @remarks
5
+ * Single factory that exposes the union of behaviors for the browser
6
+ * runtime:
7
+ *
8
+ * - `onResolve` for manifest specifiers → mapped public URL, marked external
9
+ * - `onResolve` for paths starting with `/` whose target is in the manifest's
10
+ * public path set → marked external
11
+ * - `onLoad` for JS/TS files → AST-walking import/export rewrite against the
12
+ * manifest specifier set, with a `code.includes(specifier)` fast path
13
+ *
14
+ * The plugin object carries the manifest's `specifier → publicPath` map
15
+ * under `BROWSER_RUNTIME_IMPORT_REWRITE_MAP` so
16
+ * `collectBrowserRuntimeImportRewriteMap` and the post-build rewriter can
17
+ * read it without re-walking the manifest.
18
+ *
19
+ * This is the single source of truth for browser-runtime plugin behavior.
20
+ * Per-bundler bridges can treat it as a single plugin.
21
+ */
22
+ import type { EcoBuildPlugin } from './build-types.js';
23
+ import { type BrowserRuntimeManifest } from './browser-runtime-manifest.js';
24
+ /**
25
+ * Symbol used to attach the manifest's `specifier → publicPath` map to a
26
+ * plugin instance. Consumers read it via `getBrowserRuntimeImportRewriteMap`
27
+ * or `collectBrowserRuntimeImportRewriteMap`.
28
+ */
29
+ export declare const BROWSER_RUNTIME_IMPORT_REWRITE_MAP: unique symbol;
30
+ /**
31
+ * Default name used by `createBrowserRuntimePlugin` when the caller
32
+ * does not provide one.
33
+ */
34
+ export declare const DEFAULT_BROWSER_RUNTIME_PLUGIN_NAME = "browser-runtime-plugin";
35
+ export type CreateBrowserRuntimePluginOptions = {
36
+ /** Manifest whose specifier → publicPath entries drive the plugin. */
37
+ manifest: BrowserRuntimeManifest;
38
+ /** Stable build plugin name used for deduplication and selective exclusion. */
39
+ name?: string;
40
+ /**
41
+ * Whether alias `onResolve` results should be marked `external`.
42
+ * Default `true`. Pass `false` to let the bundler try to bundle the
43
+ * mapped URL.
44
+ */
45
+ external?: boolean;
46
+ /**
47
+ * Enable source-level AST import/export rewrite via the `onLoad`
48
+ * hook. Default `true`. Set `false` for alias-only consumers
49
+ * (e.g. `react`/`react-dom` externals in vendor assets).
50
+ */
51
+ rewriteImports?: boolean;
52
+ /**
53
+ * Register an `onResolve` for paths starting with `/` whose target
54
+ * is in the manifest's public path set. Marks them external so the
55
+ * bundler does not try to resolve them as source modules. Default
56
+ * `true`.
57
+ */
58
+ matchPublicPaths?: boolean;
59
+ };
60
+ /**
61
+ * Rewrites static ESM import/export specifiers and string-literal dynamic imports
62
+ * from manifest-owned runtime specifiers to concrete browser public URLs.
63
+ *
64
+ * Exposed for the post-build rewriter and for tests.
65
+ */
66
+ export declare function rewriteBrowserRuntimeImports(code: string, specifierMap: ReadonlyMap<string, string>, filePath?: string): string;
67
+ export declare function getBrowserRuntimeImportRewriteMap(plugin: EcoBuildPlugin): ReadonlyMap<string, string> | undefined;
68
+ export declare function collectBrowserRuntimeImportRewriteMap(plugins: EcoBuildPlugin[] | undefined): ReadonlyMap<string, string>;
69
+ /**
70
+ * Creates a build plugin that exposes the union of browser-runtime
71
+ * manifest behaviors (alias resolution, public-path matching, and source
72
+ * import/export rewrite). See {@link CreateBrowserRuntimePluginOptions}
73
+ * for per-behavior toggles.
74
+ *
75
+ * Returns `null` for an empty manifest so callers can short-circuit
76
+ * registration without sprinkling `if (plugin)` everywhere.
77
+ */
78
+ export declare function createBrowserRuntimePlugin(options: CreateBrowserRuntimePluginOptions): EcoBuildPlugin | null;