@ecopages/core 0.2.0-alpha.8 → 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
@@ -1,13 +1,11 @@
1
1
  import type { Server, WebSocketHandler } from 'bun';
2
- import type { EcoPagesAppConfig } from '../../internal-types.js';
3
- import type { ApiHandler, ErrorHandler, StaticRoute } from '../../public-types.js';
2
+ import type { EcoPagesAppConfig } from '../../types/internal-types.js';
3
+ import type { ApiHandler, ErrorHandler, StaticRoute } from '../../types/public-types.js';
4
4
  import { SharedServerAdapter } from '../shared/server-adapter.js';
5
5
  import type { ServerAdapterResult } from '../abstract/server-adapter.js';
6
- import { ServerRouteHandler, type ServerRouteHandlerParams } from '../shared/server-route-handler.js';
7
- import { ServerStaticBuilder, type ServerStaticBuilderParams } from '../shared/server-static-builder';
8
- import { ClientBridge } from './client-bridge';
9
- import { HmrManager } from './hmr-manager';
10
- import { ServerLifecycle } from './server-lifecycle.js';
6
+ import type { StaticPreviewHost } from '../shared/static-preview-host.js';
7
+ import { ClientBridge } from './client-bridge.js';
8
+ import { HmrManager } from './hmr-manager.js';
11
9
  type BunServerInstance = Server<unknown>;
12
10
  type BunNativeServeOptions = Bun.Serve.Options<unknown>;
13
11
  export type BunServerRoutes = Bun.Serve.Routes<unknown, string>;
@@ -18,6 +16,15 @@ export type BunServeOptions = Omit<BunNativeServeOptions, 'fetch'> & {
18
16
  fetch?: (this: BunServerInstance, request: Request, server: BunServerInstance) => Promise<void | Response>;
19
17
  websocket?: WebSocketHandler<unknown>;
20
18
  };
19
+ /**
20
+ * Construction parameters for the Bun server adapter.
21
+ *
22
+ * @remarks
23
+ * Callers normally provide only the app-facing fields such as routes, handlers,
24
+ * and `serveOptions`. The transport collaborators remain optional here because
25
+ * `createBunServerAdapter()` fills in Bun-specific defaults before the concrete
26
+ * adapter instance is created.
27
+ */
21
28
  export interface BunServerAdapterParams {
22
29
  appConfig: EcoPagesAppConfig;
23
30
  runtimeOrigin: string;
@@ -28,11 +35,9 @@ export interface BunServerAdapterParams {
28
35
  options?: {
29
36
  watch?: boolean;
30
37
  };
31
- lifecycle?: ServerLifecycle;
32
- staticBuilderFactory?: (params: ServerStaticBuilderParams) => ServerStaticBuilder;
33
- routeHandlerFactory?: (params: ServerRouteHandlerParams) => ServerRouteHandler;
34
38
  hmrManager?: HmrManager;
35
39
  bridge?: ClientBridge;
40
+ previewHost?: StaticPreviewHost;
36
41
  }
37
42
  export interface BunServerAdapterResult extends ServerAdapterResult {
38
43
  getServerOptions: (options?: {
@@ -44,6 +49,16 @@ export interface BunServerAdapterResult extends ServerAdapterResult {
44
49
  completeInitialization: (server?: BunServerInstance | null) => Promise<void>;
45
50
  handleRequest: (request: Request) => Promise<Response>;
46
51
  }
52
+ /**
53
+ * Bun transport adapter that wires shared Ecopages request handling onto a live
54
+ * `Bun.serve()` runtime.
55
+ *
56
+ * @remarks
57
+ * The adapter owns Bun-specific concerns that do not exist in the shared server
58
+ * abstraction: websocket-backed HMR transport, runtime plugin registration, and
59
+ * preview-host startup for static builds. Routing, rendering, and response
60
+ * composition still delegate to the shared server adapter base.
61
+ */
47
62
  export declare class BunServerAdapter extends SharedServerAdapter<BunServerAdapterParams, BunServerAdapterResult> {
48
63
  appConfig: EcoPagesAppConfig;
49
64
  options: BunServerAdapterParams['options'];
@@ -52,24 +67,37 @@ export declare class BunServerAdapter extends SharedServerAdapter<BunServerAdapt
52
67
  protected staticRoutes: StaticRoute[];
53
68
  protected errorHandler?: ErrorHandler;
54
69
  private bridge;
55
- private lifecycle;
56
70
  hmrManager: HmrManager;
57
71
  private initializationPromise;
58
72
  private fullyInitialized;
59
73
  serverInstance: BunServerInstance | null;
60
- private readonly lifecycleFactory?;
61
- private readonly staticBuilderFactory?;
62
- private readonly routeHandlerFactory?;
63
- private readonly hmrManagerFactory?;
64
- private readonly bridgeFactory?;
65
- constructor({ appConfig, runtimeOrigin, serveOptions, apiHandlers, staticRoutes, errorHandler, options, lifecycle, staticBuilderFactory, routeHandlerFactory, hmrManager, bridge, }: BunServerAdapterParams);
66
- /**
67
- * Determines if HMR script should be injected.
68
- * Only injects in watch mode when HMR manager is enabled.
74
+ private readonly previewHost;
75
+ /**
76
+ * Creates a Bun server adapter with already-resolved runtime collaborators.
77
+ *
78
+ * @remarks
79
+ * The public params interface keeps `hmrManager`, `bridge`, and `previewHost`
80
+ * optional so factory callers can omit them. By the time the concrete adapter
81
+ * is constructed, those collaborators are mandatory because the adapter cannot
82
+ * initialize Bun HMR or preview flows without them.
83
+ */
84
+ constructor({ appConfig, runtimeOrigin, serveOptions, apiHandlers, staticRoutes, errorHandler, options, hmrManager, bridge, previewHost, }: BunServerAdapterParams & {
85
+ hmrManager: HmrManager;
86
+ bridge: ClientBridge;
87
+ previewHost: StaticPreviewHost;
88
+ });
89
+ /**
90
+ * Returns whether adapter-level HTML responses still need HMR runtime injection.
91
+ *
92
+ * @remarks
93
+ * Filesystem-routed pages are wrapped later in the shared route layer. This
94
+ * adapter-level check exists for explicit API handlers that return HTML and
95
+ * would otherwise bypass the route wrapper entirely.
69
96
  */
70
97
  private shouldInjectHmrScript;
71
98
  /**
72
- * Checks if a response contains HTML content.
99
+ * Delegates the HTML-response test to the shared response helper used by both
100
+ * adapters.
73
101
  */
74
102
  private isHtmlResponse;
75
103
  /**
@@ -78,20 +106,37 @@ export declare class BunServerAdapter extends SharedServerAdapter<BunServerAdapt
78
106
  */
79
107
  private maybeInjectHmrScript;
80
108
  /**
81
- * Initializes the server adapter's core components.
82
- * Delegates to ServerLifecycle for setup.
109
+ * Initializes the server adapter's core runtime components.
83
110
  */
84
111
  initialize(): Promise<void>;
85
112
  /**
86
- * Refreshes the router routes during watch mode.
113
+ * Copies the source `public` directory into the runtime output and ensures the
114
+ * HMR assets directory exists before any runtime bundles are emitted.
115
+ */
116
+ private prepareRuntimePublicDir;
117
+ /**
118
+ * Registers runtime plugins and propagates the final HMR manager into each
119
+ * integration.
120
+ *
121
+ * @remarks
122
+ * This is where Bun's runtime-plugin registration path meets the integration
123
+ * lifecycle. A failure here leaves the runtime partially bootstrapped, so the
124
+ * method logs the underlying error and rethrows instead of trying to limp on.
125
+ */
126
+ private initializeRuntimePlugins;
127
+ /**
128
+ * Rebuilds the shared routing state and hot-reloads the live Bun server when a
129
+ * watched route file changes.
87
130
  */
88
131
  private refreshRouterRoutes;
89
132
  private watch;
90
133
  /**
91
- * Retrieves the current server options, optionally enabling HMR.
92
- * If HMR is enabled, modifies fetch to handle WebSocket upgrades and serve HMR runtime.
93
- * Ensures original fetch logic is preserved and called for non-HMR requests.
94
- * @param options.enableHmr Whether to enable Hot Module Replacement
134
+ * Builds the `Bun.serve()` options for the current adapter state.
135
+ *
136
+ * @remarks
137
+ * The HMR-enabled variant wraps the base fetch handler so one Bun server can
138
+ * serve normal requests, accept HMR websocket upgrades, and expose the HMR
139
+ * runtime asset without splitting responsibility across separate listeners.
95
140
  */
96
141
  getServerOptions({ enableHmr }?: {
97
142
  enableHmr?: boolean | undefined;
@@ -104,8 +149,12 @@ export declare class BunServerAdapter extends SharedServerAdapter<BunServerAdapt
104
149
  */
105
150
  private retrieveBodyFromRequest;
106
151
  /**
107
- * Creates complete server configuration with request handling.
108
- * @returns Server options ready for Bun.serve()
152
+ * Composes the base Bun server settings that all runtime modes build from.
153
+ *
154
+ * @remarks
155
+ * This method centralizes the Bun-specific error boundary. It preserves the
156
+ * shared route pipeline while still allowing adapter-level custom error-handler
157
+ * execution and `HttpError` passthrough.
109
158
  */
110
159
  private buildServerSettings;
111
160
  /**
@@ -122,7 +171,12 @@ export declare class BunServerAdapter extends SharedServerAdapter<BunServerAdapt
122
171
  */
123
172
  completeInitialization(server?: BunServerInstance | null): Promise<void>;
124
173
  /**
125
- * Performs complete server setup including routing, watchers, and HMR.
174
+ * Performs the one-time post-bind initialization path for Bun servers.
175
+ *
176
+ * @remarks
177
+ * This is intentionally split from `initialize()` because shared route handling
178
+ * and file watching need the live server instance to exist before Bun can
179
+ * reload updated route handlers in place.
126
180
  */
127
181
  private _performInitialization;
128
182
  /**
@@ -132,6 +186,13 @@ export declare class BunServerAdapter extends SharedServerAdapter<BunServerAdapt
132
186
  createAdapter(): Promise<BunServerAdapterResult>;
133
187
  /**
134
188
  * Handles HTTP requests by passing them securely to the shared core router adapter.
189
+ *
190
+ * @remarks
191
+ * Filesystem page responses are wrapped by `ServerRouteHandler`. This
192
+ * adapter-level pass only covers HTML returned by explicit API handlers,
193
+ * which bypass that route-layer wrapper and would otherwise miss the
194
+ * dev HMR runtime — so the HMR script injection happens here, after
195
+ * the shared handler runs.
135
196
  */
136
197
  handleRequest(request: Request): Promise<Response>;
137
198
  /**
@@ -149,7 +210,14 @@ export declare class BunServerAdapter extends SharedServerAdapter<BunServerAdapt
149
210
  private handleNoMatch;
150
211
  }
151
212
  /**
152
- * Factory function to create a Bun server adapter
213
+ * Creates the Bun server adapter and fills in the runtime-specific collaborators
214
+ * that Bun callers usually leave implicit.
215
+ *
216
+ * @remarks
217
+ * This is the canonical entry point for Bun server-adapter construction. It
218
+ * guarantees that the concrete adapter receives a Bun websocket bridge, HMR
219
+ * manager, and preview host even though those dependencies are optional on the
220
+ * public params type.
153
221
  */
154
222
  export declare function createBunServerAdapter(params: BunServerAdapterParams): Promise<BunServerAdapterResult>;
155
223
  export {};
@@ -1,34 +1,44 @@
1
+ import path from "node:path";
2
+ import { DEFAULT_ECOPAGES_HOSTNAME, DEFAULT_ECOPAGES_PORT } from "../../config/constants.js";
3
+ import { RESOLVED_ASSETS_DIR } from "../../config/constants.js";
1
4
  import { appLogger } from "../../global/app-logger.js";
2
5
  import { HttpError } from "../../errors/http-error.js";
3
6
  import { createRequire } from "../../utils/locals-utils.js";
4
7
  import { fileSystem } from "@ecopages/file-system";
8
+ import { getAppBrowserBuildPlugins, setupAppRuntimePlugins } from "../../build/build-adapter.js";
9
+ import { installAppRuntimeBuildExecutor } from "../../build/runtime-build-executor.js";
10
+ import { StaticSiteGenerator } from "../../static-site-generator/static-site-generator.js";
11
+ import { ProjectWatcher } from "../../watchers/project-watcher.js";
5
12
  import { SharedServerAdapter } from "../shared/server-adapter.js";
6
13
  import { ApiResponseBuilder } from "../shared/api-response.js";
7
- import { installSharedRuntimeBuildExecutor } from "../shared/runtime-bootstrap.js";
8
- import { ServerRouteHandler } from "../shared/server-route-handler.js";
9
- import { ServerStaticBuilder } from "../shared/server-static-builder";
14
+ import { ServerStaticBuilder } from "../shared/server-static-builder.js";
10
15
  import {
11
16
  injectHmrRuntimeIntoHtmlResponse,
12
17
  isHtmlResponse,
13
18
  shouldInjectHmrHtmlResponse
14
- } from "../shared/hmr-html-response";
15
- import { ClientBridge } from "./client-bridge";
16
- import { HmrManager } from "./hmr-manager";
17
- import { ServerLifecycle } from "./server-lifecycle.js";
19
+ } from "../shared/hmr-html-response.js";
20
+ import { resolveServeRuntimeOrigin } from "../shared/runtime-app-bootstrap.js";
21
+ import { ClientBridge } from "./client-bridge.js";
22
+ import { HmrManager } from "./hmr-manager.js";
23
+ import { BunStaticPreviewHost } from "./static-preview-host.js";
18
24
  class BunServerAdapter extends SharedServerAdapter {
19
25
  apiHandlers;
20
26
  staticRoutes;
21
27
  errorHandler;
22
28
  bridge;
23
- lifecycle;
24
29
  hmrManager;
25
30
  initializationPromise = null;
26
31
  fullyInitialized = false;
27
- lifecycleFactory;
28
- staticBuilderFactory;
29
- routeHandlerFactory;
30
- hmrManagerFactory;
31
- bridgeFactory;
32
+ previewHost;
33
+ /**
34
+ * Creates a Bun server adapter with already-resolved runtime collaborators.
35
+ *
36
+ * @remarks
37
+ * The public params interface keeps `hmrManager`, `bridge`, and `previewHost`
38
+ * optional so factory callers can omit them. By the time the concrete adapter
39
+ * is constructed, those collaborators are mandatory because the adapter cannot
40
+ * initialize Bun HMR or preview flows without them.
41
+ */
32
42
  constructor({
33
43
  appConfig,
34
44
  runtimeOrigin,
@@ -37,31 +47,32 @@ class BunServerAdapter extends SharedServerAdapter {
37
47
  staticRoutes,
38
48
  errorHandler,
39
49
  options,
40
- lifecycle,
41
- staticBuilderFactory,
42
- routeHandlerFactory,
43
50
  hmrManager,
44
- bridge
51
+ bridge,
52
+ previewHost
45
53
  }) {
46
54
  super({ appConfig, runtimeOrigin, serveOptions, options });
47
55
  this.apiHandlers = apiHandlers || [];
48
56
  this.staticRoutes = staticRoutes || [];
49
57
  this.errorHandler = errorHandler;
50
- this.lifecycleFactory = lifecycle;
51
- this.staticBuilderFactory = staticBuilderFactory;
52
- this.routeHandlerFactory = routeHandlerFactory;
53
- this.hmrManagerFactory = hmrManager;
54
- this.bridgeFactory = bridge;
58
+ this.bridge = bridge;
59
+ this.hmrManager = hmrManager;
60
+ this.previewHost = previewHost;
55
61
  }
56
62
  /**
57
- * Determines if HMR script should be injected.
58
- * Only injects in watch mode when HMR manager is enabled.
63
+ * Returns whether adapter-level HTML responses still need HMR runtime injection.
64
+ *
65
+ * @remarks
66
+ * Filesystem-routed pages are wrapped later in the shared route layer. This
67
+ * adapter-level check exists for explicit API handlers that return HTML and
68
+ * would otherwise bypass the route wrapper entirely.
59
69
  */
60
70
  shouldInjectHmrScript() {
61
71
  return shouldInjectHmrHtmlResponse(this.options?.watch === true, this.hmrManager);
62
72
  }
63
73
  /**
64
- * Checks if a response contains HTML content.
74
+ * Delegates the HTML-response test to the shared response helper used by both
75
+ * adapters.
65
76
  */
66
77
  isHtmlResponse(response) {
67
78
  return isHtmlResponse(response);
@@ -77,33 +88,66 @@ class BunServerAdapter extends SharedServerAdapter {
77
88
  return response;
78
89
  }
79
90
  /**
80
- * Initializes the server adapter's core components.
81
- * Delegates to ServerLifecycle for setup.
91
+ * Initializes the server adapter's core runtime components.
82
92
  */
83
93
  async initialize() {
84
- installSharedRuntimeBuildExecutor(this.appConfig, {
85
- development: this.options?.watch === true
86
- });
87
- this.bridge = this.bridgeFactory ?? new ClientBridge();
88
- this.hmrManager = this.hmrManagerFactory ?? new HmrManager({ appConfig: this.appConfig, bridge: this.bridge });
89
- this.lifecycle = this.lifecycleFactory ?? new ServerLifecycle({
90
- appConfig: this.appConfig,
91
- runtimeOrigin: this.runtimeOrigin,
92
- hmrManager: this.hmrManager,
93
- bridge: this.bridge
94
- });
95
- this.staticSiteGenerator = await this.lifecycle.initialize();
94
+ installAppRuntimeBuildExecutor(this.appConfig);
95
+ this.staticSiteGenerator = new StaticSiteGenerator({ appConfig: this.appConfig });
96
+ await this.hmrManager.buildRuntime();
97
+ this.prepareRuntimePublicDir();
96
98
  const staticBuilderOptions = {
97
99
  appConfig: this.appConfig,
98
100
  staticSiteGenerator: this.staticSiteGenerator,
99
101
  serveOptions: this.serveOptions,
100
102
  apiHandlers: this.apiHandlers
101
103
  };
102
- this.staticBuilder = this.staticBuilderFactory ? this.staticBuilderFactory(staticBuilderOptions) : new ServerStaticBuilder(staticBuilderOptions);
103
- await this.lifecycle.initializePlugins({ watch: this.options?.watch });
104
+ this.staticBuilder = new ServerStaticBuilder(staticBuilderOptions);
105
+ await this.initializeRuntimePlugins({ watch: this.options?.watch });
106
+ }
107
+ /**
108
+ * Copies the source `public` directory into the runtime output and ensures the
109
+ * HMR assets directory exists before any runtime bundles are emitted.
110
+ */
111
+ prepareRuntimePublicDir() {
112
+ const srcPublicDir = path.join(this.appConfig.rootDir, this.appConfig.srcDir, this.appConfig.publicDir);
113
+ if (fileSystem.exists(srcPublicDir)) {
114
+ fileSystem.copyDir(srcPublicDir, path.join(this.appConfig.rootDir, this.appConfig.distDir));
115
+ }
116
+ fileSystem.ensureDir(path.join(this.appConfig.absolutePaths.distDir, RESOLVED_ASSETS_DIR));
117
+ }
118
+ /**
119
+ * Registers runtime plugins and propagates the final HMR manager into each
120
+ * integration.
121
+ *
122
+ * @remarks
123
+ * This is where Bun's runtime-plugin registration path meets the integration
124
+ * lifecycle. A failure here leaves the runtime partially bootstrapped, so the
125
+ * method logs the underlying error and rethrows instead of trying to limp on.
126
+ */
127
+ async initializeRuntimePlugins(options) {
128
+ try {
129
+ this.hmrManager.setEnabled(Boolean(options?.watch));
130
+ await setupAppRuntimePlugins({
131
+ appConfig: this.appConfig,
132
+ runtimeOrigin: this.runtimeOrigin,
133
+ hmrManager: this.hmrManager,
134
+ onRuntimePlugin: (plugin) => {
135
+ Bun.plugin(plugin);
136
+ }
137
+ });
138
+ const browserBuildPlugins = getAppBrowserBuildPlugins(this.appConfig);
139
+ this.hmrManager.setPlugins(browserBuildPlugins);
140
+ for (const integration of this.appConfig.integrations) {
141
+ integration.setHmrManager(this.hmrManager);
142
+ }
143
+ } catch (error) {
144
+ appLogger.error(`Failed to initialize plugins: ${error instanceof Error ? error.message : String(error)}`);
145
+ throw error;
146
+ }
104
147
  }
105
148
  /**
106
- * Refreshes the router routes during watch mode.
149
+ * Rebuilds the shared routing state and hot-reloads the live Bun server when a
150
+ * watched route file changes.
107
151
  */
108
152
  async refreshRouterRoutes() {
109
153
  if (!this.serverInstance || typeof this.serverInstance.reload !== "function") {
@@ -125,15 +169,21 @@ class BunServerAdapter extends SharedServerAdapter {
125
169
  })();
126
170
  }
127
171
  async watch() {
128
- await this.lifecycle.startWatching({
129
- refreshRouterRoutesCallback: this.refreshRouterRoutes.bind(this)
172
+ const watcher = new ProjectWatcher({
173
+ config: this.appConfig,
174
+ refreshRouterRoutesCallback: this.refreshRouterRoutes.bind(this),
175
+ hmrManager: this.hmrManager,
176
+ bridge: this.bridge
130
177
  });
178
+ await watcher.createWatcherSubscription();
131
179
  }
132
180
  /**
133
- * Retrieves the current server options, optionally enabling HMR.
134
- * If HMR is enabled, modifies fetch to handle WebSocket upgrades and serve HMR runtime.
135
- * Ensures original fetch logic is preserved and called for non-HMR requests.
136
- * @param options.enableHmr Whether to enable Hot Module Replacement
181
+ * Builds the `Bun.serve()` options for the current adapter state.
182
+ *
183
+ * @remarks
184
+ * The HMR-enabled variant wraps the base fetch handler so one Bun server can
185
+ * serve normal requests, accept HMR websocket upgrades, and expose the HMR
186
+ * runtime asset without splitting responsibility across separate listeners.
137
187
  */
138
188
  getServerOptions({ enableHmr = false } = {}) {
139
189
  appLogger.debug(`[BunServerAdapter] getServerOptions called with enableHmr: ${enableHmr}`);
@@ -189,8 +239,12 @@ class BunServerAdapter extends SharedServerAdapter {
189
239
  return void 0;
190
240
  }
191
241
  /**
192
- * Creates complete server configuration with request handling.
193
- * @returns Server options ready for Bun.serve()
242
+ * Composes the base Bun server settings that all runtime modes build from.
243
+ *
244
+ * @remarks
245
+ * This method centralizes the Bun-specific error boundary. It preserves the
246
+ * shared route pipeline while still allowing adapter-level custom error-handler
247
+ * execution and `HttpError` passthrough.
194
248
  */
195
249
  buildServerSettings() {
196
250
  const serverOptions = { ...this.serveOptions };
@@ -252,11 +306,29 @@ class BunServerAdapter extends SharedServerAdapter {
252
306
  hmrManager: this.hmrManager
253
307
  });
254
308
  }
255
- await this.staticBuilder.build(options, {
256
- router: this.router,
257
- routeRendererFactory: this.routeRendererFactory,
258
- staticRoutes: this.staticRoutes
309
+ const buildRuntimeOrigin = this.serverInstance ? `http://${this.serverInstance.hostname || DEFAULT_ECOPAGES_HOSTNAME}:${this.serverInstance.port || DEFAULT_ECOPAGES_PORT}` : void 0;
310
+ await this.staticBuilder.build(
311
+ { ...options, preview: false, baseUrl: buildRuntimeOrigin },
312
+ {
313
+ router: this.router,
314
+ routeRendererFactory: this.routeRendererFactory,
315
+ staticRoutes: this.staticRoutes
316
+ }
317
+ );
318
+ if (!options?.preview) {
319
+ return;
320
+ }
321
+ const previewHostname = this.serveOptions.hostname || DEFAULT_ECOPAGES_HOSTNAME;
322
+ const previewPort = Number(this.serveOptions.port || DEFAULT_ECOPAGES_PORT);
323
+ const activePreviewPort = await this.previewHost.start({
324
+ appConfig: this.appConfig,
325
+ hostname: String(previewHostname),
326
+ port: previewPort
259
327
  });
328
+ if (activePreviewPort) {
329
+ appLogger.info(`Preview running at http://${previewHostname}:${activePreviewPort}`);
330
+ return;
331
+ }
260
332
  }
261
333
  /**
262
334
  * Initializes the server with dynamic routes after server creation.
@@ -276,7 +348,12 @@ class BunServerAdapter extends SharedServerAdapter {
276
348
  return this.initializationPromise;
277
349
  }
278
350
  /**
279
- * Performs complete server setup including routing, watchers, and HMR.
351
+ * Performs the one-time post-bind initialization path for Bun servers.
352
+ *
353
+ * @remarks
354
+ * This is intentionally split from `initialize()` because shared route handling
355
+ * and file watching need the live server instance to exist before Bun can
356
+ * reload updated route handlers in place.
280
357
  */
281
358
  async _performInitialization(server) {
282
359
  this.serverInstance = server;
@@ -308,6 +385,13 @@ class BunServerAdapter extends SharedServerAdapter {
308
385
  }
309
386
  /**
310
387
  * Handles HTTP requests by passing them securely to the shared core router adapter.
388
+ *
389
+ * @remarks
390
+ * Filesystem page responses are wrapped by `ServerRouteHandler`. This
391
+ * adapter-level pass only covers HTML returned by explicit API handlers,
392
+ * which bypass that route-layer wrapper and would otherwise miss the
393
+ * dev HMR runtime — so the HMR script injection happens here, after
394
+ * the shared handler runs.
311
395
  */
312
396
  async handleRequest(request) {
313
397
  const response = await this.handleSharedRequest(request, {
@@ -347,23 +431,16 @@ class BunServerAdapter extends SharedServerAdapter {
347
431
  }
348
432
  }
349
433
  async function createBunServerAdapter(params) {
350
- const runtimeOrigin = params.runtimeOrigin ?? `http://${params.serveOptions.hostname || "localhost"}:${params.serveOptions.port || 3e3}`;
434
+ const runtimeOrigin = params.runtimeOrigin ?? resolveServeRuntimeOrigin(params.serveOptions);
351
435
  const bridge = params.bridge ?? new ClientBridge();
352
436
  const hmrManager = params.hmrManager ?? new HmrManager({ appConfig: params.appConfig, bridge });
353
- const lifecycle = params.lifecycle ?? new ServerLifecycle({
354
- appConfig: params.appConfig,
355
- runtimeOrigin,
356
- hmrManager,
357
- bridge
358
- });
437
+ const previewHost = params.previewHost ?? new BunStaticPreviewHost();
359
438
  const adapter = new BunServerAdapter({
360
439
  ...params,
361
440
  runtimeOrigin,
362
441
  bridge,
363
442
  hmrManager,
364
- lifecycle,
365
- staticBuilderFactory: params.staticBuilderFactory ?? ((opts) => new ServerStaticBuilder(opts)),
366
- routeHandlerFactory: params.routeHandlerFactory ?? ((p) => new ServerRouteHandler(p))
443
+ previewHost
367
444
  });
368
445
  return adapter.createAdapter();
369
446
  }
@@ -0,0 +1,28 @@
1
+ import type { EcoPagesAppConfig } from '../../types/internal-types.js';
2
+ import type { StaticPreviewHost, StaticPreviewHostStartOptions } from '../shared/static-preview-host.js';
3
+ type BunStaticPreviewServer = {
4
+ server: {
5
+ port?: number;
6
+ } | null;
7
+ stop(): void;
8
+ };
9
+ type BunStaticPreviewServerFactory = {
10
+ createServer(args: {
11
+ appConfig: EcoPagesAppConfig;
12
+ options: {
13
+ port: number;
14
+ };
15
+ }): BunStaticPreviewServer;
16
+ };
17
+ type BunStaticPreviewLogger = {
18
+ error(message: string): unknown;
19
+ };
20
+ export declare class BunStaticPreviewHost implements StaticPreviewHost {
21
+ private readonly previewServerFactory;
22
+ private readonly logger;
23
+ private previewServer;
24
+ constructor(previewServerFactory?: BunStaticPreviewServerFactory, logger?: BunStaticPreviewLogger);
25
+ start(options: StaticPreviewHostStartOptions): Promise<number | null>;
26
+ stop(): Promise<void>;
27
+ }
28
+ export {};
@@ -0,0 +1,45 @@
1
+ import { StaticContentServer } from "../../dev/sc-server.js";
2
+ import { appLogger } from "../../global/app-logger.js";
3
+ class BunStaticPreviewHost {
4
+ constructor(previewServerFactory = StaticContentServer, logger = appLogger) {
5
+ this.previewServerFactory = previewServerFactory;
6
+ this.logger = logger;
7
+ }
8
+ previewServerFactory;
9
+ logger;
10
+ previewServer = null;
11
+ async start(options) {
12
+ await this.stop();
13
+ await new Promise((resolve) => setTimeout(resolve, 100));
14
+ for (let attempt = 0; attempt < 20; attempt += 1) {
15
+ try {
16
+ this.previewServer = this.previewServerFactory.createServer({
17
+ appConfig: options.appConfig,
18
+ options: { port: options.port }
19
+ });
20
+ const previewPort = this.previewServer.server?.port;
21
+ if (previewPort) {
22
+ return previewPort;
23
+ }
24
+ break;
25
+ } catch (error) {
26
+ const errorMessage = error instanceof Error ? error.message : String(error);
27
+ const errorCode = typeof error === "object" && error !== null && "code" in error ? String(error.code) : void 0;
28
+ const isPortReleaseRace = errorCode === "EADDRINUSE" || errorMessage.includes("EADDRINUSE");
29
+ if (!isPortReleaseRace || attempt === 19) {
30
+ throw error;
31
+ }
32
+ await new Promise((resolve) => setTimeout(resolve, 100));
33
+ }
34
+ }
35
+ this.logger.error("Failed to start preview server");
36
+ return null;
37
+ }
38
+ async stop() {
39
+ this.previewServer?.stop();
40
+ this.previewServer = null;
41
+ }
42
+ }
43
+ export {
44
+ BunStaticPreviewHost
45
+ };
@@ -1,9 +1,12 @@
1
- import type { EcopagesAppOptions as BunOptions } from './adapters/bun/create-app.js';
2
- import type { EcopagesAppOptions as NodeOptions } from './adapters/node/create-app.js';
3
- import { AbstractApplicationAdapter } from './adapters/abstract/application-adapter.js';
4
- import { SharedApplicationAdapter } from './adapters/shared/application-adapter.js';
5
- export type EcopagesAppOptions = BunOptions | NodeOptions;
6
- export type UniversalEcopagesApp = AbstractApplicationAdapter<EcopagesAppOptions, any, Request>;
1
+ import type { EcoPagesAppConfig } from '../types/internal-types.js';
2
+ import { AbstractApplicationAdapter } from './abstract/application-adapter.js';
3
+ import type { ApplicationAdapterOptions } from './abstract/application-adapter.js';
4
+ import { SharedApplicationAdapter } from './shared/application-adapter.js';
5
+ export interface EcopagesAppOptions extends ApplicationAdapterOptions {
6
+ appConfig: EcoPagesAppConfig;
7
+ serverOptions?: Record<string, any>;
8
+ }
9
+ export type UniversalEcopagesApp = AbstractApplicationAdapter<EcopagesAppOptions, unknown, Request>;
7
10
  export declare function createApp<WebSocketData = undefined>(options: EcopagesAppOptions): Promise<UniversalEcopagesApp>;
8
11
  export declare class EcopagesApp extends SharedApplicationAdapter<EcopagesAppOptions, unknown, Request> {
9
12
  private readonly appOptions;
@@ -1,12 +1,12 @@
1
- import { AbstractApplicationAdapter } from "./adapters/abstract/application-adapter.js";
2
- import { SharedApplicationAdapter } from "./adapters/shared/application-adapter.js";
1
+ import { AbstractApplicationAdapter } from "./abstract/application-adapter.js";
2
+ import { SharedApplicationAdapter } from "./shared/application-adapter.js";
3
+ import { createApp as createBunApp } from "./bun/create-app.js";
4
+ import { createNodeApp } from "./node/create-app.js";
3
5
  async function createRuntimeApp(options) {
4
6
  const bun = globalThis.Bun;
5
7
  if (bun) {
6
- const { createApp: createBunApp } = await import("./adapters/bun/create-app.js");
7
8
  return await createBunApp(options);
8
9
  }
9
- const { createNodeApp } = await import("./adapters/node/create-app.js");
10
10
  return await createNodeApp(options);
11
11
  }
12
12
  async function createApp(options) {
@@ -1,6 +1,2 @@
1
- export { EcopagesApp, createApp } from './bun/create-app.js';
1
+ export { EcopagesApp, createApp } from './create-app.js';
2
2
  export { defineApiHandler, defineGroupHandler, type GroupHandler } from './shared/define-api-handler.js';
3
- export { NodeServerAdapter, createNodeServerAdapter } from './node/server-adapter.js';
4
- export { EcopagesApp as NodeAdapterEcopagesApp, createNodeApp } from './node/create-app.js';
5
- export type { NodeServerAdapterParams, NodeServerAdapterResult } from './node/server-adapter.js';
6
- export type { EcopagesAppOptions as NodeEcopagesAppOptions } from './node/create-app.js';