@ecopages/core 0.2.0-alpha.9 → 0.2.0-beta.1

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 (473) hide show
  1. package/README.md +79 -28
  2. package/package.json +104 -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 +32 -8
  67. package/src/adapters/shared/server-static-builder.js +69 -6
  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-entry-file.d.ts +72 -0
  279. package/src/utils/resolve-entry-file.js +41 -0
  280. package/src/utils/resolve-work-dir.js +1 -1
  281. package/src/watchers/project-watcher.d.ts +4 -4
  282. package/src/watchers/project-watcher.js +35 -41
  283. package/src/watchers/project-watcher.test-helpers.d.ts +2 -2
  284. package/src/watchers/project-watcher.test-helpers.js +5 -5
  285. package/CHANGELOG.md +0 -31
  286. package/src/adapters/abstract/application-adapter.ts +0 -337
  287. package/src/adapters/abstract/router-adapter.ts +0 -30
  288. package/src/adapters/abstract/server-adapter.ts +0 -79
  289. package/src/adapters/bun/client-bridge.ts +0 -62
  290. package/src/adapters/bun/create-app.ts +0 -189
  291. package/src/adapters/bun/hmr-manager.ts +0 -409
  292. package/src/adapters/bun/index.ts +0 -2
  293. package/src/adapters/bun/server-adapter.ts +0 -499
  294. package/src/adapters/bun/server-lifecycle.d.ts +0 -63
  295. package/src/adapters/bun/server-lifecycle.js +0 -92
  296. package/src/adapters/bun/server-lifecycle.ts +0 -124
  297. package/src/adapters/index.ts +0 -6
  298. package/src/adapters/node/bootstrap-dependency-resolver.d.ts +0 -44
  299. package/src/adapters/node/bootstrap-dependency-resolver.js +0 -172
  300. package/src/adapters/node/bootstrap-dependency-resolver.ts +0 -301
  301. package/src/adapters/node/create-app.ts +0 -179
  302. package/src/adapters/node/index.d.ts +0 -6
  303. package/src/adapters/node/index.js +0 -11
  304. package/src/adapters/node/index.ts +0 -16
  305. package/src/adapters/node/node-client-bridge.ts +0 -79
  306. package/src/adapters/node/node-hmr-manager.ts +0 -381
  307. package/src/adapters/node/runtime-adapter.d.ts +0 -46
  308. package/src/adapters/node/runtime-adapter.js +0 -306
  309. package/src/adapters/node/runtime-adapter.ts +0 -439
  310. package/src/adapters/node/server-adapter.ts +0 -488
  311. package/src/adapters/node/static-content-server.ts +0 -239
  312. package/src/adapters/node/write-runtime-manifest.d.ts +0 -26
  313. package/src/adapters/node/write-runtime-manifest.js +0 -12
  314. package/src/adapters/node/write-runtime-manifest.ts +0 -38
  315. package/src/adapters/shared/api-response.ts +0 -104
  316. package/src/adapters/shared/application-adapter.ts +0 -199
  317. package/src/adapters/shared/define-api-handler.ts +0 -66
  318. package/src/adapters/shared/explicit-static-route-matcher.ts +0 -140
  319. package/src/adapters/shared/file-route-middleware-pipeline.ts +0 -127
  320. package/src/adapters/shared/fs-server-response-factory.ts +0 -118
  321. package/src/adapters/shared/fs-server-response-matcher.ts +0 -205
  322. package/src/adapters/shared/hmr-entrypoint-registrar.ts +0 -149
  323. package/src/adapters/shared/hmr-html-response.ts +0 -52
  324. package/src/adapters/shared/render-context.ts +0 -120
  325. package/src/adapters/shared/runtime-bootstrap.d.ts +0 -38
  326. package/src/adapters/shared/runtime-bootstrap.js +0 -43
  327. package/src/adapters/shared/runtime-bootstrap.ts +0 -79
  328. package/src/adapters/shared/server-adapter.ts +0 -489
  329. package/src/adapters/shared/server-route-handler.ts +0 -153
  330. package/src/adapters/shared/server-static-builder.ts +0 -166
  331. package/src/build/build-adapter.ts +0 -361
  332. package/src/build/build-manifest.ts +0 -54
  333. package/src/build/build-types.ts +0 -83
  334. package/src/build/dev-build-coordinator.d.ts +0 -74
  335. package/src/build/dev-build-coordinator.js +0 -161
  336. package/src/build/dev-build-coordinator.ts +0 -221
  337. package/src/build/esbuild-build-adapter.d.ts +0 -72
  338. package/src/build/esbuild-build-adapter.js +0 -422
  339. package/src/build/esbuild-build-adapter.ts +0 -559
  340. package/src/build/runtime-build-executor.ts +0 -34
  341. package/src/build/runtime-specifier-alias-plugin.d.ts +0 -15
  342. package/src/build/runtime-specifier-alias-plugin.js +0 -31
  343. package/src/build/runtime-specifier-alias-plugin.ts +0 -58
  344. package/src/config/config-builder.ts +0 -706
  345. package/src/constants.ts +0 -54
  346. package/src/create-app.ts +0 -87
  347. package/src/dev/sc-server.ts +0 -143
  348. package/src/eco/component-render-context.d.ts +0 -105
  349. package/src/eco/component-render-context.js +0 -87
  350. package/src/eco/component-render-context.ts +0 -224
  351. package/src/eco/eco.ts +0 -242
  352. package/src/eco/eco.types.ts +0 -221
  353. package/src/eco/eco.utils.ts +0 -89
  354. package/src/eco/global-injector-map.ts +0 -112
  355. package/src/eco/lazy-injector-map.ts +0 -120
  356. package/src/eco/module-dependencies.ts +0 -75
  357. package/src/errors/http-error.ts +0 -72
  358. package/src/errors/index.ts +0 -2
  359. package/src/errors/locals-access-error.ts +0 -7
  360. package/src/global/app-logger.ts +0 -4
  361. package/src/hmr/client/hmr-runtime.ts +0 -152
  362. package/src/hmr/hmr-strategy.ts +0 -172
  363. package/src/hmr/hmr.postcss.test.e2e.ts +0 -41
  364. package/src/hmr/hmr.test.e2e.ts +0 -66
  365. package/src/hmr/strategies/default-hmr-strategy.ts +0 -60
  366. package/src/hmr/strategies/js-hmr-strategy.ts +0 -320
  367. package/src/index.browser.ts +0 -3
  368. package/src/index.ts +0 -5
  369. package/src/integrations/ghtml/ghtml-renderer.ts +0 -96
  370. package/src/integrations/ghtml/ghtml.plugin.ts +0 -32
  371. package/src/internal-types.ts +0 -232
  372. package/src/plugins/alias-resolver-plugin.ts +0 -63
  373. package/src/plugins/eco-component-meta-plugin.ts +0 -481
  374. package/src/plugins/integration-plugin.ts +0 -226
  375. package/src/plugins/processor.ts +0 -240
  376. package/src/plugins/runtime-capability.ts +0 -14
  377. package/src/public-types.ts +0 -1317
  378. package/src/route-renderer/component-graph/component-graph-executor.d.ts +0 -32
  379. package/src/route-renderer/component-graph/component-graph-executor.js +0 -31
  380. package/src/route-renderer/component-graph/component-graph-executor.ts +0 -84
  381. package/src/route-renderer/component-graph/component-graph.d.ts +0 -42
  382. package/src/route-renderer/component-graph/component-graph.js +0 -72
  383. package/src/route-renderer/component-graph/component-graph.ts +0 -159
  384. package/src/route-renderer/component-graph/component-marker.d.ts +0 -52
  385. package/src/route-renderer/component-graph/component-marker.js +0 -46
  386. package/src/route-renderer/component-graph/component-marker.ts +0 -117
  387. package/src/route-renderer/component-graph/component-reference.d.ts +0 -10
  388. package/src/route-renderer/component-graph/component-reference.js +0 -19
  389. package/src/route-renderer/component-graph/component-reference.ts +0 -29
  390. package/src/route-renderer/component-graph/marker-graph-resolver.d.ts +0 -77
  391. package/src/route-renderer/component-graph/marker-graph-resolver.js +0 -95
  392. package/src/route-renderer/component-graph/marker-graph-resolver.ts +0 -155
  393. package/src/route-renderer/orchestration/integration-renderer.ts +0 -790
  394. package/src/route-renderer/orchestration/render-execution.service.d.ts +0 -103
  395. package/src/route-renderer/orchestration/render-execution.service.js +0 -121
  396. package/src/route-renderer/orchestration/render-execution.service.ts +0 -230
  397. package/src/route-renderer/orchestration/render-preparation.service.d.ts +0 -121
  398. package/src/route-renderer/orchestration/render-preparation.service.js +0 -332
  399. package/src/route-renderer/orchestration/render-preparation.service.ts +0 -476
  400. package/src/route-renderer/page-loading/dependency-resolver.ts +0 -612
  401. package/src/route-renderer/page-loading/page-module-loader.ts +0 -181
  402. package/src/route-renderer/route-renderer.ts +0 -115
  403. package/src/router/client/link-intent.test.browser.ts +0 -51
  404. package/src/router/client/link-intent.ts +0 -92
  405. package/src/router/client/navigation-coordinator.ts +0 -433
  406. package/src/router/server/fs-router-scanner.d.ts +0 -41
  407. package/src/router/server/fs-router-scanner.js +0 -156
  408. package/src/router/server/fs-router-scanner.ts +0 -219
  409. package/src/router/server/fs-router.d.ts +0 -26
  410. package/src/router/server/fs-router.js +0 -100
  411. package/src/router/server/fs-router.ts +0 -122
  412. package/src/services/assets/asset-processing-service/asset-processing.service.ts +0 -401
  413. package/src/services/assets/asset-processing-service/asset.factory.ts +0 -105
  414. package/src/services/assets/asset-processing-service/assets.types.ts +0 -113
  415. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.ts +0 -95
  416. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.ts +0 -78
  417. package/src/services/assets/asset-processing-service/index.ts +0 -5
  418. package/src/services/assets/asset-processing-service/processor.interface.ts +0 -27
  419. package/src/services/assets/asset-processing-service/processor.registry.ts +0 -18
  420. package/src/services/assets/asset-processing-service/processors/base/base-processor.ts +0 -82
  421. package/src/services/assets/asset-processing-service/processors/base/base-script-processor.ts +0 -95
  422. package/src/services/assets/asset-processing-service/processors/index.ts +0 -5
  423. package/src/services/assets/asset-processing-service/processors/script/content-script.processor.ts +0 -66
  424. package/src/services/assets/asset-processing-service/processors/script/file-script.processor.ts +0 -88
  425. package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.ts +0 -85
  426. package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.ts +0 -27
  427. package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.ts +0 -80
  428. package/src/services/assets/browser-bundle.service.ts +0 -53
  429. package/src/services/cache/cache.types.ts +0 -126
  430. package/src/services/cache/index.ts +0 -18
  431. package/src/services/cache/memory-cache-store.ts +0 -130
  432. package/src/services/cache/page-cache-service.ts +0 -202
  433. package/src/services/cache/page-request-cache-coordinator.service.ts +0 -131
  434. package/src/services/html/html-rewriter-provider.service.ts +0 -103
  435. package/src/services/html/html-transformer.service.ts +0 -279
  436. package/src/services/invalidation/development-invalidation.service.ts +0 -261
  437. package/src/services/module-loading/app-server-module-transpiler.service.ts +0 -52
  438. package/src/services/module-loading/page-module-import.service.ts +0 -200
  439. package/src/services/module-loading/server-loader.service.d.ts +0 -96
  440. package/src/services/module-loading/server-loader.service.js +0 -32
  441. package/src/services/module-loading/server-loader.service.ts +0 -130
  442. package/src/services/module-loading/server-module-transpiler.service.ts +0 -105
  443. package/src/services/runtime-manifest/node-runtime-manifest.service.d.ts +0 -35
  444. package/src/services/runtime-manifest/node-runtime-manifest.service.js +0 -60
  445. package/src/services/runtime-manifest/node-runtime-manifest.service.ts +0 -101
  446. package/src/services/runtime-state/dev-graph.service.ts +0 -217
  447. package/src/services/runtime-state/entrypoint-dependency-graph.service.ts +0 -136
  448. package/src/services/runtime-state/runtime-specifier-registry.service.d.ts +0 -69
  449. package/src/services/runtime-state/runtime-specifier-registry.service.js +0 -37
  450. package/src/services/runtime-state/runtime-specifier-registry.service.ts +0 -96
  451. package/src/services/runtime-state/server-invalidation-state.service.ts +0 -68
  452. package/src/services/validation/schema-validation-service.ts +0 -204
  453. package/src/services/validation/standard-schema.types.ts +0 -68
  454. package/src/static-site-generator/static-site-generator.ts +0 -462
  455. package/src/utils/css.d.ts +0 -1
  456. package/src/utils/css.js +0 -7
  457. package/src/utils/css.ts +0 -5
  458. package/src/utils/deep-merge.ts +0 -47
  459. package/src/utils/hash.ts +0 -5
  460. package/src/utils/html.ts +0 -1
  461. package/src/utils/invariant.ts +0 -15
  462. package/src/utils/locals-utils.ts +0 -37
  463. package/src/utils/parse-cli-args.ts +0 -83
  464. package/src/utils/path-utils.module.ts +0 -14
  465. package/src/utils/resolve-work-dir.ts +0 -45
  466. package/src/utils/runtime.ts +0 -44
  467. package/src/utils/server-utils.module.ts +0 -67
  468. package/src/watchers/project-watcher.test-helpers.ts +0 -41
  469. package/src/watchers/project-watcher.ts +0 -363
  470. /package/src/{internal-types.js → adapters/shared/runtime-host.js} +0 -0
  471. /package/src/{public-types.js → adapters/shared/static-preview-host.js} +0 -0
  472. /package/src/{constants.d.ts → config/constants.d.ts} +0 -0
  473. /package/src/{constants.js → config/constants.js} +0 -0
@@ -1,7 +1,10 @@
1
1
  import path from "node:path";
2
2
  import { fileSystem } from "@ecopages/file-system";
3
- import { StaticContentServer } from "../../dev/sc-server";
4
- import { appLogger } from "../../global/app-logger";
3
+ import { DEFAULT_ECOPAGES_HOSTNAME, DEFAULT_ECOPAGES_PORT } from "../../config/constants.js";
4
+ import { StaticContentServer } from "../../dev/sc-server.js";
5
+ import { appLogger } from "../../global/app-logger.js";
6
+ import { getAppBuildAdapter } from "../../build/build-adapter.js";
7
+ import { resolveEntryFile, SERVER_BUNDLE_DIR, SERVER_BUNDLE_FILENAME } from "../../utils/resolve-entry-file.js";
5
8
  class ServerStaticBuilder {
6
9
  appConfig;
7
10
  staticSiteGenerator;
@@ -9,13 +12,15 @@ class ServerStaticBuilder {
9
12
  apiHandlers;
10
13
  logger;
11
14
  previewServerFactory;
15
+ entryFile;
12
16
  constructor({
13
17
  appConfig,
14
18
  staticSiteGenerator,
15
19
  serveOptions,
16
20
  apiHandlers,
17
21
  logger,
18
- previewServerFactory
22
+ previewServerFactory,
23
+ entryFile
19
24
  }) {
20
25
  this.appConfig = appConfig;
21
26
  this.staticSiteGenerator = staticSiteGenerator;
@@ -23,6 +28,7 @@ class ServerStaticBuilder {
23
28
  this.apiHandlers = apiHandlers ?? [];
24
29
  this.logger = logger ?? appLogger;
25
30
  this.previewServerFactory = previewServerFactory ?? StaticContentServer;
31
+ this.entryFile = resolveEntryFile({ entryFile });
26
32
  }
27
33
  warnApiHandlersUnavailableInStaticMode() {
28
34
  if (this.apiHandlers.length === 0) {
@@ -59,6 +65,62 @@ class ServerStaticBuilder {
59
65
  await integration.setup();
60
66
  }
61
67
  }
68
+ /**
69
+ * Bundles the server entry file for production use.
70
+ *
71
+ * @remarks
72
+ * When the project has API endpoints, the entry file must be bundled
73
+ * into a single JS file so the production server can start without
74
+ * on-the-fly TypeScript transpilation. The bundle is output to
75
+ * `dist/{SERVER_BUNDLE_DIR}/{SERVER_BUNDLE_FILENAME}` and used by
76
+ * `ecopages start` in production.
77
+ *
78
+ * Package imports remain external so native addons and runtime-owned
79
+ * dependencies continue to load through the app's installed
80
+ * `node_modules` tree. Only the app entry graph is bundled.
81
+ *
82
+ * Skips silently when no API endpoints are registered (static-only site).
83
+ * Throws if the build adapter is unavailable, is owned by a host
84
+ * runtime, or bundling fails.
85
+ *
86
+ * @throws If the build adapter is unavailable, is host-owned, or bundling fails.
87
+ */
88
+ async bundleServerEntry() {
89
+ if (this.apiHandlers.length === 0) {
90
+ return;
91
+ }
92
+ const buildAdapter = getAppBuildAdapter(this.appConfig);
93
+ if (buildAdapter.ownership === "vite-host") {
94
+ throw new Error(
95
+ 'Cannot bundle the server entry file: build ownership is "vite-host". The host runtime is expected to produce its own server bundle.'
96
+ );
97
+ }
98
+ const entryPath = path.isAbsolute(this.entryFile) ? this.entryFile : path.join(this.appConfig.rootDir, this.entryFile);
99
+ if (!fileSystem.exists(entryPath)) {
100
+ throw new Error(
101
+ `Cannot bundle server entry: file "${this.entryFile}" not found in "${this.appConfig.rootDir}".`
102
+ );
103
+ }
104
+ const distDir = this.appConfig.absolutePaths?.distDir ?? path.join(this.appConfig.rootDir, this.appConfig.distDir);
105
+ const serverOutdir = path.join(distDir, SERVER_BUNDLE_DIR);
106
+ this.logger.info("Bundling server entry file...");
107
+ const result = await buildAdapter.build({
108
+ entrypoints: [entryPath],
109
+ outdir: serverOutdir,
110
+ naming: SERVER_BUNDLE_FILENAME,
111
+ target: "node",
112
+ format: "esm",
113
+ sourcemap: "hidden",
114
+ externalPackages: true,
115
+ root: this.appConfig.rootDir
116
+ });
117
+ if (!result.success) {
118
+ const errorMessages = result.logs.map((log) => log.message).join("\n");
119
+ throw new Error(`Failed to bundle server entry file:
120
+ ${errorMessages}`);
121
+ }
122
+ this.logger.info("Server entry file bundled successfully");
123
+ }
62
124
  /**
63
125
  * Generates a static build of the site for deployment.
64
126
  * @param options.preview - If true, starts a preview server after build
@@ -67,11 +129,12 @@ class ServerStaticBuilder {
67
129
  * @param dependencies.staticRoutes - Explicit static routes registered via app.static()
68
130
  */
69
131
  async build(options, dependencies) {
70
- const { preview = false } = options ?? {};
71
- const baseUrl = `http://${this.serveOptions.hostname || "localhost"}:${this.serveOptions.port || 3e3}`;
132
+ const { preview = false, baseUrl: explicitBaseUrl } = options ?? {};
133
+ const baseUrl = explicitBaseUrl ?? `http://${this.serveOptions.hostname || DEFAULT_ECOPAGES_HOSTNAME}:${this.serveOptions.port || DEFAULT_ECOPAGES_PORT}`;
72
134
  this.warnApiHandlersUnavailableInStaticMode();
73
135
  this.prepareExportDirectory();
74
136
  await this.refreshRuntimeAssets();
137
+ await this.bundleServerEntry();
75
138
  await this.staticSiteGenerator.run({
76
139
  router: dependencies.router,
77
140
  baseUrl,
@@ -82,7 +145,7 @@ class ServerStaticBuilder {
82
145
  this.logger.info("Build completed");
83
146
  return;
84
147
  }
85
- const previewPort = this.serveOptions.port || 3e3;
148
+ const previewPort = this.serveOptions.port || DEFAULT_ECOPAGES_PORT;
86
149
  const { server } = this.previewServerFactory.createServer({
87
150
  appConfig: this.appConfig,
88
151
  options: { port: Number(previewPort) }
@@ -0,0 +1,59 @@
1
+ import fs from 'node:fs';
2
+ import type { DefaultHmrContext, EcoPagesAppConfig, IHmrManager, IClientBridge } from '../../types/internal-types.js';
3
+ import type { EcoBuildPlugin } from '../../build/build-types.js';
4
+ import { type HmrStrategy } from '../../hmr/hmr-strategy.js';
5
+ import type { ClientBridgeEvent } from '../../types/public-types.js';
6
+ import { HmrEntrypointRegistrar } from './hmr-entrypoint-registrar.js';
7
+ import { BrowserBundleService } from '../../services/assets/browser-bundle.service.js';
8
+ import { type EntrypointDependencyGraph } from '../../services/runtime-state/entrypoint-dependency-graph.service.js';
9
+ import type { ServerModuleTranspiler } from '../../services/module-loading/server-module-transpiler.service.js';
10
+ type HandleFileChangeOptions = {
11
+ broadcast?: boolean;
12
+ };
13
+ type SharedHmrManagerParams = {
14
+ appConfig: EcoPagesAppConfig;
15
+ bridge: IClientBridge;
16
+ registrationTimeoutMs?: number;
17
+ };
18
+ export declare abstract class SharedHmrManager implements IHmrManager {
19
+ readonly appConfig: EcoPagesAppConfig;
20
+ protected readonly bridge: IClientBridge;
21
+ protected watchers: Map<string, fs.FSWatcher>;
22
+ protected watchedFiles: Map<string, string>;
23
+ protected entrypointRegistrations: Map<string, Promise<string>>;
24
+ protected distDir: string;
25
+ protected plugins: EcoBuildPlugin[];
26
+ protected enabled: boolean;
27
+ protected strategies: HmrStrategy[];
28
+ protected readonly entrypointRegistrar: HmrEntrypointRegistrar;
29
+ protected readonly browserBundleService: BrowserBundleService;
30
+ protected readonly entrypointDependencyGraph: EntrypointDependencyGraph;
31
+ protected readonly serverModuleTranspiler: ServerModuleTranspiler;
32
+ constructor({ appConfig, bridge, registrationTimeoutMs }: SharedHmrManagerParams);
33
+ protected abstract createEntrypointDependencyGraph(existingEntrypointDependencyGraph: EntrypointDependencyGraph): EntrypointDependencyGraph;
34
+ protected shouldSkipMissingFileChange(_filePath: string): boolean;
35
+ protected onRuntimeBundleFailure(error: unknown): void;
36
+ protected ensureDistDir(): void;
37
+ protected shouldJsStrategyProcessEntrypoint(entrypointPath: string): boolean;
38
+ protected initializeStrategies(): void;
39
+ registerStrategy(strategy: HmrStrategy): void;
40
+ setPlugins(plugins: EcoBuildPlugin[]): void;
41
+ setEnabled(enabled: boolean): void;
42
+ isEnabled(): boolean;
43
+ buildRuntime(): Promise<void>;
44
+ getRuntimePath(): string;
45
+ broadcast(event: ClientBridgeEvent): void;
46
+ handleFileChange(filePath: string, options?: HandleFileChangeOptions): Promise<void>;
47
+ getOutputUrl(entrypointPath: string): string | undefined;
48
+ getWatchedFiles(): Map<string, string>;
49
+ getDistDir(): string;
50
+ getPlugins(): EcoBuildPlugin[];
51
+ getDefaultContext(): DefaultHmrContext;
52
+ protected clearFailedEntrypointRegistration(entrypointPath: string): void;
53
+ registerEntrypoint(entrypointPath: string): Promise<string>;
54
+ registerScriptEntrypoint(entrypointPath: string): Promise<string>;
55
+ protected emitStrictEntrypoint(entrypointPath: string): Promise<void>;
56
+ protected emitScriptEntrypoint(entrypointPath: string, outputPath: string): Promise<void>;
57
+ stop(): void;
58
+ }
59
+ export {};
@@ -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>;