@ecopages/core 0.2.0-alpha.1 → 0.2.0-alpha.11

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 (372) hide show
  1. package/CHANGELOG.md +16 -64
  2. package/README.md +210 -13
  3. package/package.json +88 -62
  4. package/src/adapters/README.md +39 -0
  5. package/src/adapters/abstract/application-adapter.d.ts +28 -2
  6. package/src/adapters/abstract/application-adapter.js +14 -2
  7. package/src/adapters/abstract/router-adapter.d.ts +1 -1
  8. package/src/adapters/abstract/server-adapter.d.ts +2 -2
  9. package/src/adapters/bun/client-bridge.d.ts +1 -1
  10. package/src/adapters/bun/create-app.d.ts +4 -12
  11. package/src/adapters/bun/create-app.js +4 -5
  12. package/src/adapters/bun/hmr-manager.d.ts +80 -21
  13. package/src/adapters/bun/hmr-manager.js +163 -56
  14. package/src/adapters/bun/index.d.ts +2 -3
  15. package/src/adapters/bun/index.js +3 -3
  16. package/src/adapters/bun/server-adapter.d.ts +5 -5
  17. package/src/adapters/bun/server-adapter.js +40 -34
  18. package/src/adapters/bun/server-lifecycle.d.ts +28 -17
  19. package/src/adapters/bun/server-lifecycle.js +34 -62
  20. package/src/{create-app.d.ts → adapters/create-app.d.ts} +9 -6
  21. package/src/{create-app.js → adapters/create-app.js} +4 -4
  22. package/src/adapters/index.d.ts +2 -6
  23. package/src/adapters/index.js +2 -8
  24. package/src/adapters/node/create-app.d.ts +6 -9
  25. package/src/adapters/node/create-app.js +12 -6
  26. package/src/adapters/node/node-client-bridge.d.ts +1 -1
  27. package/src/adapters/node/node-hmr-manager.d.ts +89 -18
  28. package/src/adapters/node/node-hmr-manager.js +180 -89
  29. package/src/adapters/node/server-adapter.d.ts +4 -33
  30. package/src/adapters/node/server-adapter.js +39 -100
  31. package/src/adapters/node/static-content-server.d.ts +37 -1
  32. package/src/adapters/node/static-content-server.js +29 -1
  33. package/src/adapters/shared/application-adapter.d.ts +1 -1
  34. package/src/{define-api-handler.d.ts → adapters/shared/define-api-handler.d.ts} +1 -1
  35. package/src/adapters/shared/explicit-static-route-matcher.d.ts +2 -2
  36. package/src/adapters/shared/explicit-static-route-matcher.js +4 -1
  37. package/src/adapters/shared/file-route-middleware-pipeline.d.ts +1 -1
  38. package/src/adapters/shared/file-route-middleware-pipeline.js +1 -0
  39. package/src/adapters/shared/fs-server-response-factory.d.ts +2 -2
  40. package/src/adapters/shared/fs-server-response-factory.js +1 -1
  41. package/src/adapters/shared/fs-server-response-matcher.d.ts +9 -5
  42. package/src/adapters/shared/fs-server-response-matcher.js +13 -8
  43. package/src/adapters/shared/hmr-entrypoint-registrar.d.ts +55 -0
  44. package/src/adapters/shared/hmr-entrypoint-registrar.js +87 -0
  45. package/src/adapters/shared/hmr-html-response.d.ts +22 -0
  46. package/src/adapters/shared/hmr-html-response.js +32 -0
  47. package/src/adapters/shared/render-context.d.ts +2 -1
  48. package/src/adapters/shared/render-context.js +6 -3
  49. package/src/adapters/shared/runtime-bootstrap.d.ts +38 -0
  50. package/src/adapters/shared/runtime-bootstrap.js +43 -0
  51. package/src/adapters/shared/server-adapter.d.ts +13 -3
  52. package/src/adapters/shared/server-adapter.js +42 -5
  53. package/src/adapters/shared/server-route-handler.d.ts +4 -4
  54. package/src/adapters/shared/server-route-handler.js +6 -15
  55. package/src/adapters/shared/server-static-builder.d.ts +38 -6
  56. package/src/adapters/shared/server-static-builder.js +64 -10
  57. package/src/build/README.md +107 -0
  58. package/src/build/build-adapter.d.ts +160 -3
  59. package/src/build/build-adapter.js +494 -16
  60. package/src/build/build-manifest.d.ts +27 -0
  61. package/src/build/build-manifest.js +30 -0
  62. package/src/build/dev-build-coordinator.d.ts +72 -0
  63. package/src/build/dev-build-coordinator.js +154 -0
  64. package/src/build/esbuild-build-adapter.d.ts +15 -6
  65. package/src/build/esbuild-build-adapter.js +189 -74
  66. package/src/build/runtime-build-executor.d.ts +14 -0
  67. package/src/build/runtime-build-executor.js +22 -0
  68. package/src/build/runtime-specifier-alias-plugin.d.ts +15 -0
  69. package/src/build/runtime-specifier-alias-plugin.js +35 -0
  70. package/src/build/runtime-specifier-aliases.d.ts +5 -0
  71. package/src/build/runtime-specifier-aliases.js +95 -0
  72. package/src/config/README.md +36 -0
  73. package/src/config/config-builder.d.ts +52 -18
  74. package/src/config/config-builder.js +258 -48
  75. package/src/{constants.d.ts → config/constants.d.ts} +13 -0
  76. package/src/{constants.js → config/constants.js} +4 -0
  77. package/src/declarations.d.ts +19 -14
  78. package/src/dev/sc-server.d.ts +1 -1
  79. package/src/dev/sc-server.js +1 -1
  80. package/src/eco/README.md +70 -16
  81. package/src/eco/component-render-context.d.ts +2 -2
  82. package/src/eco/component-render-context.js +33 -16
  83. package/src/eco/eco.browser.d.ts +2 -0
  84. package/src/eco/eco.browser.js +83 -0
  85. package/src/eco/eco.js +91 -16
  86. package/src/eco/eco.types.d.ts +12 -4
  87. package/src/eco/eco.utils.d.ts +1 -1
  88. package/src/eco/global-injector-map.d.ts +1 -1
  89. package/src/eco/lazy-injector-map.d.ts +1 -1
  90. package/src/hmr/README.md +26 -0
  91. package/src/hmr/client/hmr-runtime.d.ts +1 -6
  92. package/src/hmr/client/hmr-runtime.js +30 -7
  93. package/src/hmr/hmr-strategy.d.ts +8 -7
  94. package/src/hmr/hmr-strategy.js +22 -7
  95. package/src/hmr/hmr.postcss.test.e2e.d.ts +1 -0
  96. package/src/hmr/hmr.postcss.test.e2e.js +31 -0
  97. package/src/hmr/hmr.test.e2e.js +26 -33
  98. package/src/hmr/strategies/default-hmr-strategy.d.ts +2 -2
  99. package/src/hmr/strategies/default-hmr-strategy.js +1 -1
  100. package/src/hmr/strategies/js-hmr-strategy.d.ts +46 -43
  101. package/src/hmr/strategies/js-hmr-strategy.js +72 -73
  102. package/src/index.browser.d.ts +2 -2
  103. package/src/index.browser.js +1 -1
  104. package/src/index.d.ts +4 -3
  105. package/src/index.js +16 -5
  106. package/src/integrations/ghtml/ghtml-renderer.d.ts +2 -2
  107. package/src/integrations/ghtml/ghtml-renderer.js +3 -1
  108. package/src/integrations/ghtml/ghtml.plugin.d.ts +2 -2
  109. package/src/integrations/ghtml/ghtml.plugin.js +2 -2
  110. package/src/plugins/README.md +35 -0
  111. package/src/plugins/alias-resolver-plugin.js +17 -3
  112. package/src/plugins/eco-component-meta-plugin.d.ts +14 -1
  113. package/src/plugins/eco-component-meta-plugin.js +27 -21
  114. package/src/plugins/integration-plugin.d.ts +48 -9
  115. package/src/plugins/integration-plugin.js +39 -2
  116. package/src/plugins/processor.d.ts +15 -2
  117. package/src/plugins/processor.js +16 -2
  118. package/src/plugins/runtime-capability.d.ts +9 -0
  119. package/src/plugins/source-transform.d.ts +46 -0
  120. package/src/plugins/source-transform.js +71 -0
  121. package/src/route-renderer/GRAPH.md +18 -22
  122. package/src/route-renderer/README.md +15 -26
  123. package/src/route-renderer/{component-graph-executor.d.ts → component-graph/component-graph-executor.d.ts} +3 -2
  124. package/src/route-renderer/{component-graph-executor.js → component-graph/component-graph-executor.js} +2 -3
  125. package/src/route-renderer/{component-graph.d.ts → component-graph/component-graph.d.ts} +13 -2
  126. package/src/route-renderer/{component-graph.js → component-graph/component-graph.js} +26 -4
  127. package/src/route-renderer/component-graph/component-reference.d.ts +11 -0
  128. package/src/route-renderer/component-graph/component-reference.js +39 -0
  129. package/src/route-renderer/{marker-graph-resolver.d.ts → component-graph/marker-graph-resolver.d.ts} +9 -6
  130. package/src/route-renderer/{marker-graph-resolver.js → component-graph/marker-graph-resolver.js} +36 -12
  131. package/src/route-renderer/{integration-renderer.d.ts → orchestration/integration-renderer.d.ts} +65 -13
  132. package/src/route-renderer/{integration-renderer.js → orchestration/integration-renderer.js} +206 -30
  133. package/src/route-renderer/{render-execution.service.d.ts → orchestration/render-execution.service.d.ts} +42 -6
  134. package/src/route-renderer/orchestration/render-execution.service.js +191 -0
  135. package/src/route-renderer/{render-preparation.service.d.ts → orchestration/render-preparation.service.d.ts} +13 -4
  136. package/src/route-renderer/{render-preparation.service.js → orchestration/render-preparation.service.js} +95 -5
  137. package/src/route-renderer/{dependency-resolver.d.ts → page-loading/dependency-resolver.d.ts} +15 -4
  138. package/src/route-renderer/{dependency-resolver.js → page-loading/dependency-resolver.js} +18 -4
  139. package/src/route-renderer/page-loading/page-module-loader.d.ts +89 -0
  140. package/src/route-renderer/{page-module-loader.js → page-loading/page-module-loader.js} +38 -14
  141. package/src/route-renderer/route-renderer.d.ts +41 -4
  142. package/src/route-renderer/route-renderer.js +32 -3
  143. package/src/router/README.md +97 -0
  144. package/src/router/client/link-intent.d.ts +53 -0
  145. package/src/router/client/link-intent.js +34 -0
  146. package/src/router/client/link-intent.test.browser.d.ts +1 -0
  147. package/src/router/client/link-intent.test.browser.js +43 -0
  148. package/src/router/client/navigation-coordinator.d.ts +149 -0
  149. package/src/router/client/navigation-coordinator.js +215 -0
  150. package/src/router/{fs-router-scanner.d.ts → server/fs-router-scanner.d.ts} +3 -3
  151. package/src/router/{fs-router-scanner.js → server/fs-router-scanner.js} +8 -7
  152. package/src/router/{fs-router.d.ts → server/fs-router.d.ts} +1 -1
  153. package/src/router/{fs-router.js → server/fs-router.js} +1 -1
  154. package/src/services/README.md +29 -0
  155. package/src/services/assets/asset-processing-service/asset-processing.service.d.ts +120 -0
  156. package/src/services/{asset-processing-service → assets/asset-processing-service}/asset-processing.service.js +91 -10
  157. package/src/services/{asset-processing-service → assets/asset-processing-service}/asset.factory.d.ts +1 -1
  158. package/src/services/{asset-processing-service → assets/asset-processing-service}/asset.factory.js +2 -2
  159. package/src/services/{asset-processing-service → assets/asset-processing-service}/assets.types.d.ts +2 -1
  160. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.d.ts +55 -0
  161. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.js +48 -0
  162. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.d.ts +20 -0
  163. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.js +41 -0
  164. package/src/services/assets/asset-processing-service/index.d.ts +5 -0
  165. package/src/services/assets/asset-processing-service/index.js +5 -0
  166. package/src/services/{asset-processing-service → assets/asset-processing-service}/processor.interface.d.ts +2 -2
  167. package/src/services/{asset-processing-service → assets/asset-processing-service}/processor.registry.d.ts +2 -2
  168. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/base/base-processor.d.ts +1 -1
  169. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/base/base-processor.js +9 -4
  170. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/base/base-script-processor.d.ts +5 -4
  171. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/base/base-script-processor.js +15 -23
  172. package/src/services/assets/asset-processing-service/processors/index.d.ts +5 -0
  173. package/src/services/assets/asset-processing-service/processors/index.js +5 -0
  174. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/content-script.processor.d.ts +2 -2
  175. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/content-script.processor.js +1 -1
  176. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/file-script.processor.d.ts +4 -3
  177. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/file-script.processor.js +16 -4
  178. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/node-module-script.processor.d.ts +3 -3
  179. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/node-module-script.processor.js +6 -5
  180. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/stylesheet/content-stylesheet.processor.d.ts +2 -2
  181. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/stylesheet/content-stylesheet.processor.js +1 -1
  182. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/stylesheet/file-stylesheet.processor.d.ts +2 -2
  183. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/stylesheet/file-stylesheet.processor.js +5 -2
  184. package/src/services/assets/browser-bundle.service.d.ts +32 -0
  185. package/src/services/assets/browser-bundle.service.js +33 -0
  186. package/src/services/{page-request-cache-coordinator.service.d.ts → cache/page-request-cache-coordinator.service.d.ts} +2 -2
  187. package/src/services/{page-request-cache-coordinator.service.js → cache/page-request-cache-coordinator.service.js} +3 -1
  188. package/src/services/html/html-rewriter-provider.service.d.ts +37 -0
  189. package/src/services/html/html-rewriter-provider.service.js +68 -0
  190. package/src/services/html/html-transformer.service.d.ts +77 -0
  191. package/src/services/html/html-transformer.service.js +215 -0
  192. package/src/services/invalidation/development-invalidation.service.d.ts +74 -0
  193. package/src/services/invalidation/development-invalidation.service.js +190 -0
  194. package/src/services/module-loading/app-module-loader.service.d.ts +25 -0
  195. package/src/services/module-loading/app-module-loader.service.js +31 -0
  196. package/src/services/module-loading/app-server-module-transpiler.service.d.ts +24 -0
  197. package/src/services/module-loading/app-server-module-transpiler.service.js +109 -0
  198. package/src/services/module-loading/host-module-loader-registry.d.ts +4 -0
  199. package/src/services/module-loading/host-module-loader-registry.js +15 -0
  200. package/src/services/module-loading/module-loading-types.d.ts +2 -0
  201. package/src/services/module-loading/node-bootstrap-plugin.d.ts +22 -0
  202. package/src/services/module-loading/node-bootstrap-plugin.js +179 -0
  203. package/src/services/module-loading/page-module-import.service.d.ts +75 -0
  204. package/src/services/module-loading/page-module-import.service.js +161 -0
  205. package/src/services/module-loading/server-module-transpiler.service.d.ts +72 -0
  206. package/src/services/module-loading/server-module-transpiler.service.js +64 -0
  207. package/src/services/runtime-state/dev-graph.service.d.ts +118 -0
  208. package/src/services/runtime-state/dev-graph.service.js +162 -0
  209. package/src/services/runtime-state/entrypoint-dependency-graph.service.d.ts +41 -0
  210. package/src/services/runtime-state/entrypoint-dependency-graph.service.js +85 -0
  211. package/src/services/runtime-state/runtime-specifier-registry.service.d.ts +69 -0
  212. package/src/services/runtime-state/runtime-specifier-registry.service.js +37 -0
  213. package/src/services/runtime-state/server-invalidation-state.service.d.ts +26 -0
  214. package/src/services/runtime-state/server-invalidation-state.service.js +35 -0
  215. package/src/services/{schema-validation-service.d.ts → validation/schema-validation-service.d.ts} +1 -1
  216. package/src/static-site-generator/README.md +26 -0
  217. package/src/static-site-generator/static-site-generator.d.ts +55 -3
  218. package/src/static-site-generator/static-site-generator.js +86 -5
  219. package/src/{internal-types.d.ts → types/internal-types.d.ts} +53 -22
  220. package/src/types/internal-types.js +0 -0
  221. package/src/{public-types.d.ts → types/public-types.d.ts} +73 -17
  222. package/src/types/public-types.js +0 -0
  223. package/src/utils/locals-utils.d.ts +1 -1
  224. package/src/utils/parse-cli-args.d.ts +4 -1
  225. package/src/utils/parse-cli-args.js +16 -1
  226. package/src/utils/resolve-work-dir.d.ts +11 -0
  227. package/src/utils/resolve-work-dir.js +31 -0
  228. package/src/watchers/project-watcher.d.ts +40 -24
  229. package/src/watchers/project-watcher.js +105 -68
  230. package/src/watchers/project-watcher.test-helpers.d.ts +2 -2
  231. package/src/watchers/project-watcher.test-helpers.js +1 -0
  232. package/src/adapters/abstract/application-adapter.ts +0 -337
  233. package/src/adapters/abstract/router-adapter.ts +0 -30
  234. package/src/adapters/abstract/server-adapter.ts +0 -79
  235. package/src/adapters/bun/client-bridge.ts +0 -62
  236. package/src/adapters/bun/create-app.ts +0 -189
  237. package/src/adapters/bun/define-api-handler.d.ts +0 -61
  238. package/src/adapters/bun/define-api-handler.ts +0 -114
  239. package/src/adapters/bun/hmr-manager.ts +0 -281
  240. package/src/adapters/bun/index.ts +0 -3
  241. package/src/adapters/bun/server-adapter.ts +0 -492
  242. package/src/adapters/bun/server-lifecycle.ts +0 -154
  243. package/src/adapters/index.ts +0 -6
  244. package/src/adapters/node/create-app.ts +0 -179
  245. package/src/adapters/node/index.d.ts +0 -4
  246. package/src/adapters/node/index.js +0 -8
  247. package/src/adapters/node/index.ts +0 -9
  248. package/src/adapters/node/node-client-bridge.ts +0 -79
  249. package/src/adapters/node/node-hmr-manager.ts +0 -271
  250. package/src/adapters/node/server-adapter.ts +0 -561
  251. package/src/adapters/node/static-content-server.ts +0 -203
  252. package/src/adapters/shared/api-response.ts +0 -104
  253. package/src/adapters/shared/application-adapter.ts +0 -199
  254. package/src/adapters/shared/explicit-static-route-matcher.ts +0 -134
  255. package/src/adapters/shared/file-route-middleware-pipeline.ts +0 -123
  256. package/src/adapters/shared/fs-server-response-factory.ts +0 -118
  257. package/src/adapters/shared/fs-server-response-matcher.ts +0 -198
  258. package/src/adapters/shared/render-context.ts +0 -105
  259. package/src/adapters/shared/server-adapter.ts +0 -442
  260. package/src/adapters/shared/server-route-handler.ts +0 -166
  261. package/src/adapters/shared/server-static-builder.ts +0 -82
  262. package/src/build/build-adapter.ts +0 -132
  263. package/src/build/build-types.ts +0 -83
  264. package/src/build/esbuild-build-adapter.ts +0 -510
  265. package/src/config/config-builder.ts +0 -474
  266. package/src/constants.ts +0 -39
  267. package/src/create-app.ts +0 -87
  268. package/src/define-api-handler.js +0 -15
  269. package/src/define-api-handler.ts +0 -66
  270. package/src/dev/sc-server.ts +0 -143
  271. package/src/eco/component-render-context.ts +0 -202
  272. package/src/eco/eco.ts +0 -221
  273. package/src/eco/eco.types.ts +0 -202
  274. package/src/eco/eco.utils.ts +0 -89
  275. package/src/eco/global-injector-map.ts +0 -112
  276. package/src/eco/lazy-injector-map.ts +0 -120
  277. package/src/eco/module-dependencies.ts +0 -75
  278. package/src/errors/http-error.ts +0 -72
  279. package/src/errors/index.ts +0 -2
  280. package/src/errors/locals-access-error.ts +0 -7
  281. package/src/global/app-logger.ts +0 -4
  282. package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-HMR-Server-Integration-should-have-HMR-script-injected-in-page-1.png +0 -0
  283. package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-HMR-Server-Integration-should-load-fixture-app-page-1.png +0 -0
  284. package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-WebSocket-Connection-should-connect-to-correct-HMR-endpoint-1.png +0 -0
  285. package/src/hmr/client/hmr-runtime.ts +0 -121
  286. package/src/hmr/hmr-strategy.ts +0 -172
  287. package/src/hmr/hmr.test.e2e.ts +0 -75
  288. package/src/hmr/strategies/default-hmr-strategy.ts +0 -60
  289. package/src/hmr/strategies/js-hmr-strategy.ts +0 -308
  290. package/src/index.browser.ts +0 -3
  291. package/src/index.ts +0 -5
  292. package/src/integrations/ghtml/ghtml-renderer.ts +0 -93
  293. package/src/integrations/ghtml/ghtml.plugin.ts +0 -32
  294. package/src/internal-types.ts +0 -212
  295. package/src/plugins/alias-resolver-plugin.ts +0 -45
  296. package/src/plugins/eco-component-meta-plugin.ts +0 -474
  297. package/src/plugins/integration-plugin.ts +0 -184
  298. package/src/plugins/processor.ts +0 -220
  299. package/src/public-types.ts +0 -1255
  300. package/src/route-renderer/component-graph-executor.ts +0 -84
  301. package/src/route-renderer/component-graph.ts +0 -159
  302. package/src/route-renderer/component-marker.ts +0 -117
  303. package/src/route-renderer/dependency-resolver.ts +0 -596
  304. package/src/route-renderer/html-post-processing.service.d.ts +0 -40
  305. package/src/route-renderer/html-post-processing.service.js +0 -86
  306. package/src/route-renderer/html-post-processing.service.ts +0 -103
  307. package/src/route-renderer/integration-renderer.ts +0 -696
  308. package/src/route-renderer/marker-graph-resolver.ts +0 -153
  309. package/src/route-renderer/page-module-loader.d.ts +0 -61
  310. package/src/route-renderer/page-module-loader.ts +0 -153
  311. package/src/route-renderer/render-execution.service.js +0 -91
  312. package/src/route-renderer/render-execution.service.ts +0 -158
  313. package/src/route-renderer/render-preparation.service.ts +0 -358
  314. package/src/route-renderer/route-renderer.ts +0 -80
  315. package/src/router/fs-router-scanner.ts +0 -217
  316. package/src/router/fs-router.ts +0 -122
  317. package/src/services/asset-processing-service/asset-processing.service.d.ts +0 -41
  318. package/src/services/asset-processing-service/asset-processing.service.ts +0 -306
  319. package/src/services/asset-processing-service/asset.factory.ts +0 -105
  320. package/src/services/asset-processing-service/assets.types.ts +0 -112
  321. package/src/services/asset-processing-service/index.d.ts +0 -3
  322. package/src/services/asset-processing-service/index.js +0 -3
  323. package/src/services/asset-processing-service/index.ts +0 -3
  324. package/src/services/asset-processing-service/processor.interface.ts +0 -27
  325. package/src/services/asset-processing-service/processor.registry.ts +0 -18
  326. package/src/services/asset-processing-service/processors/base/base-processor.ts +0 -76
  327. package/src/services/asset-processing-service/processors/base/base-script-processor.ts +0 -105
  328. package/src/services/asset-processing-service/processors/index.d.ts +0 -5
  329. package/src/services/asset-processing-service/processors/index.js +0 -5
  330. package/src/services/asset-processing-service/processors/index.ts +0 -5
  331. package/src/services/asset-processing-service/processors/script/content-script.processor.ts +0 -66
  332. package/src/services/asset-processing-service/processors/script/file-script.processor.ts +0 -88
  333. package/src/services/asset-processing-service/processors/script/node-module-script.processor.ts +0 -84
  334. package/src/services/asset-processing-service/processors/stylesheet/content-stylesheet.processor.ts +0 -27
  335. package/src/services/asset-processing-service/processors/stylesheet/file-stylesheet.processor.ts +0 -77
  336. package/src/services/cache/cache.types.ts +0 -126
  337. package/src/services/cache/index.ts +0 -18
  338. package/src/services/cache/memory-cache-store.ts +0 -130
  339. package/src/services/cache/page-cache-service.ts +0 -202
  340. package/src/services/html-transformer.service.d.ts +0 -50
  341. package/src/services/html-transformer.service.js +0 -163
  342. package/src/services/html-transformer.service.ts +0 -217
  343. package/src/services/page-module-import.service.d.ts +0 -37
  344. package/src/services/page-module-import.service.js +0 -88
  345. package/src/services/page-module-import.service.ts +0 -129
  346. package/src/services/page-request-cache-coordinator.service.ts +0 -128
  347. package/src/services/schema-validation-service.ts +0 -204
  348. package/src/services/validation/standard-schema.types.ts +0 -68
  349. package/src/static-site-generator/static-site-generator.ts +0 -359
  350. package/src/utils/css.d.ts +0 -1
  351. package/src/utils/css.js +0 -7
  352. package/src/utils/css.ts +0 -5
  353. package/src/utils/deep-merge.ts +0 -47
  354. package/src/utils/hash.ts +0 -5
  355. package/src/utils/html.ts +0 -1
  356. package/src/utils/invariant.ts +0 -15
  357. package/src/utils/locals-utils.ts +0 -37
  358. package/src/utils/parse-cli-args.ts +0 -83
  359. package/src/utils/path-utils.module.ts +0 -14
  360. package/src/utils/runtime.ts +0 -44
  361. package/src/utils/server-utils.module.ts +0 -67
  362. package/src/watchers/project-watcher.test-helpers.ts +0 -40
  363. package/src/watchers/project-watcher.ts +0 -306
  364. /package/src/adapters/{bun → shared}/define-api-handler.js +0 -0
  365. /package/src/{internal-types.js → plugins/runtime-capability.js} +0 -0
  366. /package/src/route-renderer/{component-marker.d.ts → component-graph/component-marker.d.ts} +0 -0
  367. /package/src/route-renderer/{component-marker.js → component-graph/component-marker.js} +0 -0
  368. /package/src/services/{asset-processing-service → assets/asset-processing-service}/assets.types.js +0 -0
  369. /package/src/services/{asset-processing-service → assets/asset-processing-service}/processor.interface.js +0 -0
  370. /package/src/services/{asset-processing-service → assets/asset-processing-service}/processor.registry.js +0 -0
  371. /package/src/{public-types.js → services/module-loading/module-loading-types.js} +0 -0
  372. /package/src/services/{schema-validation-service.js → validation/schema-validation-service.js} +0 -0
@@ -1,24 +1,60 @@
1
1
  import { type Server as NodeHttpServer } from 'node:http';
2
- import type { EcoPagesAppConfig } from '../../internal-types.js';
2
+ import type { EcoPagesAppConfig } from '../../types/internal-types.js';
3
3
  type NodeStaticContentServerOptions = {
4
4
  hostname?: string;
5
5
  port?: number;
6
6
  };
7
+ /**
8
+ * Serves prebuilt static Ecopages output through Node's HTTP server.
9
+ *
10
+ * @remarks
11
+ * This server is used by the Node preview/build path once the app has already
12
+ * emitted its static output. It intentionally stays small: path sanitization,
13
+ * content-type selection, optional gzip serving, and 404 handling.
14
+ */
7
15
  export declare class NodeStaticContentServer {
8
16
  private readonly appConfig;
9
17
  private readonly options;
10
18
  private server;
19
+ /**
20
+ * Creates the Node static-content server for one built app output directory.
21
+ */
11
22
  constructor({ appConfig, options }: {
12
23
  appConfig: EcoPagesAppConfig;
13
24
  options?: NodeStaticContentServerOptions;
14
25
  });
26
+ /**
27
+ * Returns whether the given content type should be served from a pre-gzipped
28
+ * companion file when available.
29
+ */
15
30
  private shouldServeGzip;
31
+ /**
32
+ * Normalizes a request pathname and rejects directory traversal attempts.
33
+ */
16
34
  private sanitizePath;
35
+ /**
36
+ * Writes one HTTP response with the provided headers and optional body.
37
+ */
17
38
  private sendResponse;
39
+ /**
40
+ * Serves the generated 404 page when present, or a plain-text fallback.
41
+ */
18
42
  private sendNotFoundPage;
43
+ /**
44
+ * Serves one concrete file path, honoring gzip and HEAD semantics.
45
+ */
19
46
  private serveFile;
47
+ /**
48
+ * Handles one incoming Node HTTP request against the built static output tree.
49
+ */
20
50
  private handleRequest;
51
+ /**
52
+ * Starts the static preview server.
53
+ */
21
54
  start(): Promise<NodeHttpServer>;
55
+ /**
56
+ * Stops the static preview server and optionally closes active connections.
57
+ */
22
58
  stop(force?: boolean): Promise<void>;
23
59
  }
24
60
  export {};
@@ -1,12 +1,15 @@
1
1
  import { createServer } from "node:http";
2
2
  import { extname, join, normalize, sep } from "node:path";
3
- import { DEFAULT_ECOPAGES_HOSTNAME, DEFAULT_ECOPAGES_PORT, STATUS_MESSAGE } from "../../constants.js";
3
+ import { DEFAULT_ECOPAGES_HOSTNAME, DEFAULT_ECOPAGES_PORT, STATUS_MESSAGE } from "../../config/constants.js";
4
4
  import { fileSystem } from "@ecopages/file-system";
5
5
  import { ServerUtils } from "../../utils/server-utils.module.js";
6
6
  class NodeStaticContentServer {
7
7
  appConfig;
8
8
  options;
9
9
  server = null;
10
+ /**
11
+ * Creates the Node static-content server for one built app output directory.
12
+ */
10
13
  constructor({ appConfig, options }) {
11
14
  this.appConfig = appConfig;
12
15
  this.options = {
@@ -14,9 +17,16 @@ class NodeStaticContentServer {
14
17
  port: options?.port ?? DEFAULT_ECOPAGES_PORT
15
18
  };
16
19
  }
20
+ /**
21
+ * Returns whether the given content type should be served from a pre-gzipped
22
+ * companion file when available.
23
+ */
17
24
  shouldServeGzip(contentType) {
18
25
  return ["text/javascript", "text/css"].includes(contentType);
19
26
  }
27
+ /**
28
+ * Normalizes a request pathname and rejects directory traversal attempts.
29
+ */
20
30
  sanitizePath(pathname) {
21
31
  const withoutLeadingSlash = pathname.replace(/^\/+/, "");
22
32
  const normalizedPath = normalize(withoutLeadingSlash);
@@ -25,6 +35,9 @@ class NodeStaticContentServer {
25
35
  }
26
36
  return normalizedPath;
27
37
  }
38
+ /**
39
+ * Writes one HTTP response with the provided headers and optional body.
40
+ */
28
41
  sendResponse(res, status, headers, body) {
29
42
  res.statusCode = status;
30
43
  for (const [key, value] of Object.entries(headers)) {
@@ -36,6 +49,9 @@ class NodeStaticContentServer {
36
49
  }
37
50
  res.end(body);
38
51
  }
52
+ /**
53
+ * Serves the generated 404 page when present, or a plain-text fallback.
54
+ */
39
55
  sendNotFoundPage(req, res) {
40
56
  const error404TemplatePath = join(this.appConfig.absolutePaths.distDir, "404.html");
41
57
  const isHead = (req.method ?? "GET").toUpperCase() === "HEAD";
@@ -51,6 +67,9 @@ class NodeStaticContentServer {
51
67
  const file = fileSystem.readFileAsBuffer(error404TemplatePath);
52
68
  this.sendResponse(res, 404, { "Content-Type": "text/html" }, isHead ? void 0 : file);
53
69
  }
70
+ /**
71
+ * Serves one concrete file path, honoring gzip and HEAD semantics.
72
+ */
54
73
  serveFile(req, res, filePath, status = 200) {
55
74
  const contentType = ServerUtils.getContentType(extname(filePath));
56
75
  const acceptsGzip = req.headers["accept-encoding"]?.includes("gzip");
@@ -79,6 +98,9 @@ class NodeStaticContentServer {
79
98
  const file = fileSystem.readFileAsBuffer(filePath);
80
99
  this.sendResponse(res, status, { "Content-Type": contentType }, isHead ? void 0 : file);
81
100
  }
101
+ /**
102
+ * Handles one incoming Node HTTP request against the built static output tree.
103
+ */
82
104
  handleRequest(req, res) {
83
105
  const method = (req.method ?? "GET").toUpperCase();
84
106
  const isHead = method === "HEAD";
@@ -129,6 +151,9 @@ class NodeStaticContentServer {
129
151
  }
130
152
  this.sendNotFoundPage(req, res);
131
153
  }
154
+ /**
155
+ * Starts the static preview server.
156
+ */
132
157
  async start() {
133
158
  if (this.server) {
134
159
  return this.server;
@@ -141,6 +166,9 @@ class NodeStaticContentServer {
141
166
  });
142
167
  return this.server;
143
168
  }
169
+ /**
170
+ * Stops the static preview server and optionally closes active connections.
171
+ */
144
172
  async stop(force = true) {
145
173
  if (!this.server) {
146
174
  return;
@@ -1,4 +1,4 @@
1
- import type { ApiHandler, ApiHandlerContext, Middleware, RouteGroupBuilder, RouteOptions } from '../../public-types.js';
1
+ import type { ApiHandler, ApiHandlerContext, Middleware, RouteGroupBuilder, RouteOptions } from '../../types/public-types.js';
2
2
  import { AbstractApplicationAdapter, type ApplicationAdapterOptions, type RouteGroupDefinition, type RouteHandler } from '../abstract/application-adapter.js';
3
3
  export declare abstract class SharedApplicationAdapter<TOptions extends ApplicationAdapterOptions = ApplicationAdapterOptions, TServer = any, TRequest extends Request = Request> extends AbstractApplicationAdapter<TOptions, TServer, TRequest> {
4
4
  protected register<P extends string, TContext extends ApiHandlerContext<TRequest, TServer> = ApiHandlerContext<TRequest, TServer>>(path: P, method: ApiHandler['method'], handler: RouteHandler<TRequest, TServer, TContext>, options?: RouteOptions<TRequest, TServer, TContext>): this;
@@ -1,4 +1,4 @@
1
- import type { ApiHandler, ApiHandlerContext, Middleware, RouteSchema, TypedGroupHandlerContext } from './public-types.js';
1
+ import type { ApiHandler, ApiHandlerContext, Middleware, RouteSchema, TypedGroupHandlerContext } from '../../types/public-types.js';
2
2
  type UniversalContext = ApiHandlerContext<Request, unknown>;
3
3
  type SchemaHandlerContext<TSchema extends RouteSchema | undefined, TContext extends UniversalContext> = TSchema extends RouteSchema ? TypedGroupHandlerContext<TSchema, TContext> : TContext;
4
4
  export declare function defineApiHandler<TPath extends string, TSchema extends RouteSchema | undefined = undefined, TContext extends UniversalContext = UniversalContext>(handler: Omit<ApiHandler<TPath, Request, unknown>, 'handler' | 'middleware' | 'schema'> & {
@@ -1,5 +1,5 @@
1
- import type { EcoPagesAppConfig } from '../../internal-types.js';
2
- import type { StaticRoute } from '../../public-types.js';
1
+ import type { EcoPagesAppConfig } from '../../types/internal-types.js';
2
+ import type { StaticRoute } from '../../types/public-types.js';
3
3
  import type { RouteRendererFactory } from '../../route-renderer/route-renderer.js';
4
4
  export declare const EXPLICIT_STATIC_ROUTE_MATCHER_ERRORS: {
5
5
  readonly missingIntegration: (routePath: string) => string;
@@ -3,6 +3,9 @@ const EXPLICIT_STATIC_ROUTE_MATCHER_ERRORS = {
3
3
  missingIntegration: (routePath) => `View at ${routePath} is missing __eco.integration. Ensure it's defined with eco.page() and exported as default.`,
4
4
  noRendererForIntegration: (integrationName) => `No renderer found for integration: ${integrationName}`
5
5
  };
6
+ function getViewIntegrationName(view) {
7
+ return view.config?.integration ?? view.config?.__eco?.integration;
8
+ }
6
9
  class ExplicitStaticRouteMatcher {
7
10
  appConfig;
8
11
  routeRendererFactory;
@@ -71,7 +74,7 @@ class ExplicitStaticRouteMatcher {
71
74
  try {
72
75
  const mod = await route.loader();
73
76
  const view = mod.default;
74
- const integrationName = view.config?.__eco?.integration;
77
+ const integrationName = getViewIntegrationName(view);
75
78
  if (!integrationName) {
76
79
  throw new Error(EXPLICIT_STATIC_ROUTE_MATCHER_ERRORS.missingIntegration(route.path));
77
80
  }
@@ -1,4 +1,4 @@
1
- import type { Middleware, ApiHandlerContext, RequestLocals } from '../../public-types.js';
1
+ import type { Middleware, ApiHandlerContext, RequestLocals } from '../../types/public-types.js';
2
2
  import type { PageCacheService } from '../../services/cache/page-cache-service.js';
3
3
  export declare const FILE_ROUTE_MIDDLEWARE_PIPELINE_ERRORS: {
4
4
  readonly CTX_RENDER_UNAVAILABLE: "[ecopages] ctx.render is not available in file-route middleware";
@@ -7,6 +7,7 @@ const FILE_ROUTE_MIDDLEWARE_PIPELINE_ERRORS = {
7
7
  middlewareRequiresDynamic: (filePath) => `[ecopages] Page middleware requires cache: 'dynamic'. Page: ${filePath}`
8
8
  };
9
9
  class FileRouteMiddlewarePipeline {
10
+ cacheService;
10
11
  constructor(cacheService) {
11
12
  this.cacheService = cacheService;
12
13
  }
@@ -1,5 +1,5 @@
1
- import type { EcoPagesAppConfig, FileSystemServerOptions } from '../../internal-types.js';
2
- import type { RouteRendererBody } from '../../public-types.js';
1
+ import type { EcoPagesAppConfig, FileSystemServerOptions } from '../../types/internal-types.js';
2
+ import type { RouteRendererBody } from '../../types/public-types.js';
3
3
  import type { RouteRendererFactory } from '../../route-renderer/route-renderer.js';
4
4
  export declare class FileSystemServerResponseFactory {
5
5
  private appConfig;
@@ -1,4 +1,4 @@
1
- import { STATUS_MESSAGE } from "../../constants.js";
1
+ import { STATUS_MESSAGE } from "../../config/constants.js";
2
2
  import { appLogger } from "../../global/app-logger.js";
3
3
  import { fileSystem } from "@ecopages/file-system";
4
4
  class FileSystemServerResponseFactory {
@@ -1,6 +1,6 @@
1
- import type { MatchResult } from '../../internal-types.js';
1
+ import type { EcoPagesAppConfig, MatchResult } from '../../types/internal-types.js';
2
2
  import type { RouteRendererFactory } from '../../route-renderer/route-renderer.js';
3
- import type { FSRouter } from '../../router/fs-router.js';
3
+ import type { FSRouter } from '../../router/server/fs-router.js';
4
4
  import type { PageCacheService } from '../../services/cache/page-cache-service.js';
5
5
  import type { CacheStrategy } from '../../services/cache/cache.types.js';
6
6
  import type { FileSystemServerResponseFactory } from './fs-server-response-factory.js';
@@ -9,6 +9,7 @@ export declare const FILE_SYSTEM_RESPONSE_MATCHER_ERRORS: {
9
9
  readonly noTranspiledOutputForPageModule: (filePath: string) => string;
10
10
  };
11
11
  export interface FileSystemResponseMatcherOptions {
12
+ appConfig: EcoPagesAppConfig;
12
13
  router: FSRouter;
13
14
  routeRendererFactory: RouteRendererFactory;
14
15
  fileSystemResponseFactory: FileSystemServerResponseFactory;
@@ -26,13 +27,14 @@ export interface FileSystemResponseMatcherOptions {
26
27
  * error translation.
27
28
  */
28
29
  export declare class FileSystemResponseMatcher {
30
+ private appConfig;
29
31
  private router;
30
32
  private routeRendererFactory;
31
33
  private fileSystemResponseFactory;
32
- private pageModuleImportService;
34
+ private serverModuleTranspiler;
33
35
  private pageRequestCacheCoordinator;
34
36
  private fileRouteMiddlewarePipeline;
35
- constructor({ router, routeRendererFactory, fileSystemResponseFactory, cacheService, defaultCacheStrategy, }: FileSystemResponseMatcherOptions);
37
+ constructor({ appConfig, router, routeRendererFactory, fileSystemResponseFactory, cacheService, defaultCacheStrategy, }: FileSystemResponseMatcherOptions);
36
38
  /**
37
39
  * Resolves unmatched paths either as static asset requests or as the custom
38
40
  * not-found page.
@@ -58,7 +60,9 @@ export declare class FileSystemResponseMatcher {
58
60
  *
59
61
  * The matcher needs access to page-level metadata such as `cache` and
60
62
  * `middleware` before full rendering starts, so it uses the shared module
61
- * import service directly rather than going through route rendering.
63
+ * import service directly rather than going through route rendering. The
64
+ * app config is injected explicitly so build ownership stays at the adapter
65
+ * boundary instead of leaking through nested router collaborators.
62
66
  *
63
67
  * @param filePath Absolute page module path.
64
68
  * @returns Imported page module.
@@ -1,7 +1,8 @@
1
1
  import path from "node:path";
2
2
  import { appLogger } from "../../global/app-logger.js";
3
- import { PageModuleImportService } from "../../services/page-module-import.service.js";
4
- import { PageRequestCacheCoordinator } from "../../services/page-request-cache-coordinator.service.js";
3
+ import { PageRequestCacheCoordinator } from "../../services/cache/page-request-cache-coordinator.service.js";
4
+ import { getAppServerModuleTranspiler } from "../../services/module-loading/app-server-module-transpiler.service.js";
5
+ import { resolveInternalExecutionDir } from "../../utils/resolve-work-dir.js";
5
6
  import { ServerUtils } from "../../utils/server-utils.module.js";
6
7
  import { FileRouteMiddlewarePipeline } from "./file-route-middleware-pipeline.js";
7
8
  import { LocalsAccessError } from "../../errors/locals-access-error.js";
@@ -11,23 +12,26 @@ const FILE_SYSTEM_RESPONSE_MATCHER_ERRORS = {
11
12
  noTranspiledOutputForPageModule: (filePath) => `No transpiled output generated for page module: ${filePath}`
12
13
  };
13
14
  class FileSystemResponseMatcher {
15
+ appConfig;
14
16
  router;
15
17
  routeRendererFactory;
16
18
  fileSystemResponseFactory;
17
- pageModuleImportService;
19
+ serverModuleTranspiler;
18
20
  pageRequestCacheCoordinator;
19
21
  fileRouteMiddlewarePipeline;
20
22
  constructor({
23
+ appConfig,
21
24
  router,
22
25
  routeRendererFactory,
23
26
  fileSystemResponseFactory,
24
27
  cacheService = null,
25
28
  defaultCacheStrategy = "static"
26
29
  }) {
30
+ this.appConfig = appConfig;
27
31
  this.router = router;
28
32
  this.routeRendererFactory = routeRendererFactory;
29
33
  this.fileSystemResponseFactory = fileSystemResponseFactory;
30
- this.pageModuleImportService = new PageModuleImportService();
34
+ this.serverModuleTranspiler = getAppServerModuleTranspiler(appConfig);
31
35
  this.pageRequestCacheCoordinator = new PageRequestCacheCoordinator(cacheService, defaultCacheStrategy);
32
36
  this.fileRouteMiddlewarePipeline = new FileRouteMiddlewarePipeline(cacheService);
33
37
  }
@@ -128,16 +132,17 @@ class FileSystemResponseMatcher {
128
132
  *
129
133
  * The matcher needs access to page-level metadata such as `cache` and
130
134
  * `middleware` before full rendering starts, so it uses the shared module
131
- * import service directly rather than going through route rendering.
135
+ * import service directly rather than going through route rendering. The
136
+ * app config is injected explicitly so build ownership stays at the adapter
137
+ * boundary instead of leaking through nested router collaborators.
132
138
  *
133
139
  * @param filePath Absolute page module path.
134
140
  * @returns Imported page module.
135
141
  */
136
142
  async importPageModule(filePath) {
137
- return this.pageModuleImportService.importModule({
143
+ return this.serverModuleTranspiler.importModule({
138
144
  filePath,
139
- rootDir: path.dirname(this.router.assetPrefix),
140
- outdir: path.join(this.router.assetPrefix, ".server-modules-meta"),
145
+ outdir: path.join(resolveInternalExecutionDir(this.appConfig), ".server-modules-meta"),
141
146
  transpileErrorMessage: FILE_SYSTEM_RESPONSE_MATCHER_ERRORS.transpilePageModuleFailed,
142
147
  noOutputMessage: FILE_SYSTEM_RESPONSE_MATCHER_ERRORS.noTranspiledOutputForPageModule
143
148
  });
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Shared runtime state used while registering HMR-owned entrypoints.
3
+ */
4
+ export interface HmrEntrypointRegistrarOptions {
5
+ /** Absolute source directory used to derive the emitted HMR path. */
6
+ srcDir: string;
7
+ /** Absolute distribution directory where HMR outputs are written. */
8
+ distDir: string;
9
+ /** In-flight registrations keyed by normalized absolute entrypoint path. */
10
+ entrypointRegistrations: Map<string, Promise<string>>;
11
+ /** Stable entrypoint-to-output mapping retained once an entrypoint is registered. */
12
+ watchedFiles: Map<string, string>;
13
+ /** Runtime-specific cleanup invoked when an entrypoint registration fails. */
14
+ clearFailedRegistration?: (entrypointPath: string) => void;
15
+ /** Development-only guardrail for integrations that never finish producing output. */
16
+ registrationTimeoutMs: number;
17
+ }
18
+ /**
19
+ * Runtime-specific hooks required to materialize a single HMR entrypoint.
20
+ */
21
+ export interface HmrEntrypointRegistrationOptions {
22
+ /**
23
+ * Emits the browser-consumable HMR artifact for an entrypoint.
24
+ */
25
+ emit(entrypointPath: string, outputPath: string): Promise<void>;
26
+ /**
27
+ * Creates the runtime-specific error raised when the emit hook completes without producing output.
28
+ */
29
+ getMissingOutputError(entrypointPath: string, outputPath: string): Error;
30
+ }
31
+ /**
32
+ * Coordinates the shared HMR entrypoint registration lifecycle for both Node and Bun managers.
33
+ *
34
+ * The registrar owns the cross-runtime policy: normalize entrypoint identities, dedupe concurrent
35
+ * registrations, derive the emitted `_hmr` output path, clear stale output before rebuilding, and
36
+ * apply the development timeout that prevents unresolved registrations from hanging navigation.
37
+ * Runtime-specific managers remain responsible for the actual emit step and any cleanup outside
38
+ * this shared registration flow.
39
+ */
40
+ export declare class HmrEntrypointRegistrar {
41
+ private readonly options;
42
+ constructor(options: HmrEntrypointRegistrarOptions);
43
+ /**
44
+ * Registers a single source entrypoint and returns the browser URL for its emitted HMR module.
45
+ *
46
+ * Concurrent requests for the same normalized entrypoint share the same in-flight promise so the
47
+ * integration only builds once per registration cycle.
48
+ */
49
+ registerEntrypoint(entrypointPath: string, registrationOptions: HmrEntrypointRegistrationOptions): Promise<string>;
50
+ private registerEntrypointInternal;
51
+ private awaitEntrypointRegistration;
52
+ private getEntrypointOutput;
53
+ private removeStaleEntrypointOutput;
54
+ private encodeDynamicSegments;
55
+ }
@@ -0,0 +1,87 @@
1
+ import path from "node:path";
2
+ import { fileSystem } from "@ecopages/file-system";
3
+ import { appLogger } from "../../global/app-logger.js";
4
+ import { RESOLVED_ASSETS_DIR } from "../../config/constants.js";
5
+ class HmrEntrypointRegistrar {
6
+ options;
7
+ constructor(options) {
8
+ this.options = options;
9
+ }
10
+ /**
11
+ * Registers a single source entrypoint and returns the browser URL for its emitted HMR module.
12
+ *
13
+ * Concurrent requests for the same normalized entrypoint share the same in-flight promise so the
14
+ * integration only builds once per registration cycle.
15
+ */
16
+ async registerEntrypoint(entrypointPath, registrationOptions) {
17
+ const normalizedEntrypoint = path.resolve(entrypointPath);
18
+ const existingRegistration = this.options.entrypointRegistrations.get(normalizedEntrypoint);
19
+ if (existingRegistration) {
20
+ return await this.awaitEntrypointRegistration(existingRegistration, normalizedEntrypoint);
21
+ }
22
+ const registration = this.registerEntrypointInternal(normalizedEntrypoint, registrationOptions);
23
+ this.options.entrypointRegistrations.set(normalizedEntrypoint, registration);
24
+ try {
25
+ return await this.awaitEntrypointRegistration(registration, normalizedEntrypoint);
26
+ } catch (error) {
27
+ this.options.clearFailedRegistration?.(normalizedEntrypoint);
28
+ throw error;
29
+ } finally {
30
+ this.options.entrypointRegistrations.delete(normalizedEntrypoint);
31
+ }
32
+ }
33
+ async registerEntrypointInternal(entrypointPath, registrationOptions) {
34
+ if (this.options.watchedFiles.has(entrypointPath)) {
35
+ return this.options.watchedFiles.get(entrypointPath);
36
+ }
37
+ const { outputPath, outputUrl } = this.getEntrypointOutput(entrypointPath);
38
+ this.options.watchedFiles.set(entrypointPath, outputUrl);
39
+ this.removeStaleEntrypointOutput(outputPath);
40
+ await registrationOptions.emit(entrypointPath, outputPath);
41
+ if (!fileSystem.exists(outputPath)) {
42
+ throw registrationOptions.getMissingOutputError(entrypointPath, outputPath);
43
+ }
44
+ return outputUrl;
45
+ }
46
+ async awaitEntrypointRegistration(registration, entrypointPath) {
47
+ if (process.env.NODE_ENV !== "development") {
48
+ return await registration;
49
+ }
50
+ return await Promise.race([
51
+ registration,
52
+ new Promise((_, reject) => {
53
+ setTimeout(() => {
54
+ reject(new Error(`[HMR] Timed out registering entrypoint: ${entrypointPath}`));
55
+ }, this.options.registrationTimeoutMs);
56
+ })
57
+ ]);
58
+ }
59
+ getEntrypointOutput(entrypointPath) {
60
+ const relativePath = path.relative(this.options.srcDir, entrypointPath);
61
+ const relativePathJs = relativePath.replace(/\.(tsx?|jsx?|mdx?)$/, ".js");
62
+ const encodedPathJs = this.encodeDynamicSegments(relativePathJs);
63
+ const urlPath = encodedPathJs.split(path.sep).join("/");
64
+ return {
65
+ outputUrl: `/${path.join(RESOLVED_ASSETS_DIR, "_hmr", urlPath)}`,
66
+ outputPath: path.join(this.options.distDir, urlPath)
67
+ };
68
+ }
69
+ removeStaleEntrypointOutput(outputPath) {
70
+ if (!fileSystem.exists(outputPath)) {
71
+ return;
72
+ }
73
+ try {
74
+ fileSystem.remove(outputPath);
75
+ } catch (error) {
76
+ appLogger.warn(
77
+ `[HMR] Failed to remove stale entrypoint output ${outputPath}: ${error instanceof Error ? error.message : String(error)}`
78
+ );
79
+ }
80
+ }
81
+ encodeDynamicSegments(filepath) {
82
+ return filepath.replace(/\[([^\]]+)\]/g, "_$1_");
83
+ }
84
+ }
85
+ export {
86
+ HmrEntrypointRegistrar
87
+ };
@@ -0,0 +1,22 @@
1
+ import type { IHmrManager } from '../../types/public-types.js';
2
+ /**
3
+ * Returns whether a response is HTML and therefore eligible for development HMR
4
+ * runtime injection.
5
+ */
6
+ export declare function isHtmlResponse(response: Response): boolean;
7
+ /**
8
+ * Returns whether HTML responses should receive the HMR runtime bootstrap.
9
+ *
10
+ * This is shared because filesystem page responses and adapter-level HTML
11
+ * responses flow through different layers, but both need identical injection
12
+ * behavior in watch mode.
13
+ */
14
+ export declare function shouldInjectHmrHtmlResponse(watch: boolean, hmrManager?: Pick<IHmrManager, 'isEnabled'>): boolean;
15
+ /**
16
+ * Injects the development HMR runtime script into an HTML response if it is not
17
+ * already present.
18
+ *
19
+ * The check is intentionally idempotent because an HTML response can pass
20
+ * through more than one development-layer wrapper before reaching the client.
21
+ */
22
+ export declare function injectHmrRuntimeIntoHtmlResponse(response: Response): Promise<Response>;
@@ -0,0 +1,32 @@
1
+ const HMR_RUNTIME_IMPORT = "import '/_hmr_runtime.js'";
2
+ const HMR_RUNTIME_SCRIPT = `<script type="module">${HMR_RUNTIME_IMPORT};<\/script>`;
3
+ function isHtmlResponse(response) {
4
+ const contentType = response.headers.get("Content-Type");
5
+ return contentType !== null && contentType.startsWith("text/html");
6
+ }
7
+ function shouldInjectHmrHtmlResponse(watch, hmrManager) {
8
+ return watch && hmrManager?.isEnabled() === true;
9
+ }
10
+ async function injectHmrRuntimeIntoHtmlResponse(response) {
11
+ const html = await response.text();
12
+ if (html.includes(HMR_RUNTIME_IMPORT)) {
13
+ return new Response(html, {
14
+ status: response.status,
15
+ statusText: response.statusText,
16
+ headers: response.headers
17
+ });
18
+ }
19
+ const updatedHtml = html.replace(/<\/html>/i, `${HMR_RUNTIME_SCRIPT}</html>`);
20
+ const headers = new Headers(response.headers);
21
+ headers.delete("Content-Length");
22
+ return new Response(updatedHtml, {
23
+ status: response.status,
24
+ statusText: response.statusText,
25
+ headers
26
+ });
27
+ }
28
+ export {
29
+ injectHmrRuntimeIntoHtmlResponse,
30
+ isHtmlResponse,
31
+ shouldInjectHmrHtmlResponse
32
+ };
@@ -1,7 +1,8 @@
1
- import type { RenderContext } from '../../public-types.js';
1
+ import type { RenderContext } from '../../types/public-types.js';
2
2
  import type { IntegrationPlugin } from '../../plugins/integration-plugin.js';
3
3
  export interface CreateRenderContextOptions {
4
4
  integrations: IntegrationPlugin[];
5
+ rendererModules?: unknown;
5
6
  }
6
7
  /**
7
8
  * Creates a render context for route handlers.
@@ -15,12 +15,14 @@ function createRenderContext(options) {
15
15
  );
16
16
  const integration = integrations.find((i) => i.name === integrationName);
17
17
  invariant(!!integration, `No integration found for: ${integrationName}`);
18
- return integration.initializeRenderer();
18
+ return integration.initializeRenderer({
19
+ rendererModules: options.rendererModules
20
+ });
19
21
  };
20
- return {
22
+ const renderContext = {
21
23
  async render(view, props, renderOptions) {
22
24
  const locals = this?.locals;
23
- const mergedProps = mergePropsWithLocals(props, locals);
25
+ const mergedProps = mergePropsWithLocals(props ?? {}, locals);
24
26
  const renderer = getRendererForView(view);
25
27
  const ctx = {
26
28
  partial: false,
@@ -63,6 +65,7 @@ function createRenderContext(options) {
63
65
  });
64
66
  }
65
67
  };
68
+ return renderContext;
66
69
  }
67
70
  export {
68
71
  createRenderContext
@@ -0,0 +1,38 @@
1
+ import { type BuildExecutor } from '../../build/build-adapter.js';
2
+ import type { EcoBuildPlugin } from '../../build/build-types.js';
3
+ import type { EcoPagesAppConfig, IClientBridge, IHmrManager } from '../../types/internal-types.js';
4
+ /**
5
+ * Installs and returns the app-owned runtime build executor used by adapter
6
+ * startup and follow-up runtime work.
7
+ */
8
+ export declare function installSharedRuntimeBuildExecutor(appConfig: EcoPagesAppConfig, options: {
9
+ development: boolean;
10
+ }): BuildExecutor;
11
+ /**
12
+ * Copies app public assets into dist and ensures the resolved assets directory
13
+ * exists before request handling begins.
14
+ */
15
+ export declare function prepareSharedRuntimePublicDir(appConfig: EcoPagesAppConfig): void;
16
+ /**
17
+ * Runs runtime plugin setup against app-owned config/runtime state and optional
18
+ * host plugin registration hooks.
19
+ */
20
+ export declare function initializeSharedRuntimePlugins(options: {
21
+ appConfig: EcoPagesAppConfig;
22
+ runtimeOrigin: string;
23
+ hmrManager?: IHmrManager;
24
+ onRuntimePlugin?: (plugin: unknown) => void;
25
+ }): Promise<void>;
26
+ /**
27
+ * Starts shared project watching for runtime adapters.
28
+ */
29
+ export declare function startSharedProjectWatching(options: {
30
+ appConfig: EcoPagesAppConfig;
31
+ refreshRouterRoutesCallback: () => Promise<void>;
32
+ hmrManager: IHmrManager;
33
+ bridge: IClientBridge;
34
+ }): Promise<void>;
35
+ /**
36
+ * Binds a runtime HMR manager to app-owned plugin and integration state.
37
+ */
38
+ export declare function bindSharedRuntimeHmrManager(appConfig: EcoPagesAppConfig, hmrManager: IHmrManager): EcoBuildPlugin[];
@@ -0,0 +1,43 @@
1
+ import path from "node:path";
2
+ import { fileSystem } from "@ecopages/file-system";
3
+ import { getAppBrowserBuildPlugins, setupAppRuntimePlugins } from "../../build/build-adapter.js";
4
+ import { installAppRuntimeBuildExecutor } from "../../build/runtime-build-executor.js";
5
+ import { RESOLVED_ASSETS_DIR } from "../../config/constants.js";
6
+ import { ProjectWatcher } from "../../watchers/project-watcher.js";
7
+ function installSharedRuntimeBuildExecutor(appConfig, options) {
8
+ return installAppRuntimeBuildExecutor(appConfig, options);
9
+ }
10
+ function prepareSharedRuntimePublicDir(appConfig) {
11
+ const srcPublicDir = path.join(appConfig.rootDir, appConfig.srcDir, appConfig.publicDir);
12
+ if (fileSystem.exists(srcPublicDir)) {
13
+ fileSystem.copyDir(srcPublicDir, path.join(appConfig.rootDir, appConfig.distDir));
14
+ }
15
+ fileSystem.ensureDir(path.join(appConfig.absolutePaths.distDir, RESOLVED_ASSETS_DIR));
16
+ }
17
+ async function initializeSharedRuntimePlugins(options) {
18
+ await setupAppRuntimePlugins(options);
19
+ }
20
+ async function startSharedProjectWatching(options) {
21
+ const watcher = new ProjectWatcher({
22
+ config: options.appConfig,
23
+ refreshRouterRoutesCallback: options.refreshRouterRoutesCallback,
24
+ hmrManager: options.hmrManager,
25
+ bridge: options.bridge
26
+ });
27
+ await watcher.createWatcherSubscription();
28
+ }
29
+ function bindSharedRuntimeHmrManager(appConfig, hmrManager) {
30
+ const browserBuildPlugins = getAppBrowserBuildPlugins(appConfig);
31
+ hmrManager.setPlugins(browserBuildPlugins);
32
+ for (const integration of appConfig.integrations) {
33
+ integration.setHmrManager(hmrManager);
34
+ }
35
+ return browserBuildPlugins;
36
+ }
37
+ export {
38
+ bindSharedRuntimeHmrManager,
39
+ initializeSharedRuntimePlugins,
40
+ installSharedRuntimeBuildExecutor,
41
+ prepareSharedRuntimePublicDir,
42
+ startSharedProjectWatching
43
+ };