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

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 (323) hide show
  1. package/CHANGELOG.md +13 -70
  2. package/README.md +213 -12
  3. package/package.json +50 -18
  4. package/src/adapters/README.md +39 -0
  5. package/src/adapters/bun/hmr-manager.d.ts +77 -18
  6. package/src/adapters/bun/hmr-manager.js +159 -52
  7. package/src/adapters/bun/index.d.ts +1 -2
  8. package/src/adapters/bun/index.js +1 -1
  9. package/src/adapters/bun/server-adapter.js +35 -30
  10. package/src/adapters/bun/server-lifecycle.d.ts +24 -13
  11. package/src/adapters/bun/server-lifecycle.js +32 -60
  12. package/src/adapters/index.d.ts +1 -1
  13. package/src/adapters/index.js +1 -1
  14. package/src/adapters/node/bootstrap-dependency-resolver.d.ts +44 -0
  15. package/src/adapters/node/bootstrap-dependency-resolver.js +172 -0
  16. package/src/adapters/node/index.d.ts +2 -0
  17. package/src/adapters/node/index.js +3 -0
  18. package/src/adapters/node/node-hmr-manager.d.ts +87 -16
  19. package/src/adapters/node/node-hmr-manager.js +179 -88
  20. package/src/adapters/node/runtime-adapter.d.ts +46 -0
  21. package/src/adapters/node/runtime-adapter.js +306 -0
  22. package/src/adapters/node/server-adapter.d.ts +2 -31
  23. package/src/adapters/node/server-adapter.js +31 -93
  24. package/src/adapters/node/static-content-server.d.ts +36 -0
  25. package/src/adapters/node/static-content-server.js +28 -0
  26. package/src/adapters/node/write-runtime-manifest.d.ts +26 -0
  27. package/src/adapters/node/write-runtime-manifest.js +12 -0
  28. package/src/{define-api-handler.d.ts → adapters/shared/define-api-handler.d.ts} +1 -1
  29. package/src/adapters/shared/explicit-static-route-matcher.js +4 -1
  30. package/src/adapters/shared/file-route-middleware-pipeline.js +1 -0
  31. package/src/adapters/shared/fs-server-response-matcher.d.ts +9 -5
  32. package/src/adapters/shared/fs-server-response-matcher.js +13 -8
  33. package/src/adapters/shared/hmr-entrypoint-registrar.d.ts +55 -0
  34. package/src/adapters/shared/hmr-entrypoint-registrar.js +87 -0
  35. package/src/adapters/shared/hmr-html-response.d.ts +22 -0
  36. package/src/adapters/shared/hmr-html-response.js +32 -0
  37. package/src/adapters/shared/render-context.js +3 -2
  38. package/src/adapters/shared/runtime-bootstrap.d.ts +38 -0
  39. package/src/adapters/shared/runtime-bootstrap.js +43 -0
  40. package/src/adapters/shared/server-adapter.d.ts +12 -2
  41. package/src/adapters/shared/server-adapter.js +37 -4
  42. package/src/adapters/shared/server-route-handler.d.ts +1 -1
  43. package/src/adapters/shared/server-route-handler.js +4 -13
  44. package/src/adapters/shared/server-static-builder.d.ts +35 -3
  45. package/src/adapters/shared/server-static-builder.js +59 -6
  46. package/src/build/README.md +101 -0
  47. package/src/build/build-adapter.d.ts +114 -2
  48. package/src/build/build-adapter.js +119 -5
  49. package/src/build/build-manifest.d.ts +27 -0
  50. package/src/build/build-manifest.js +30 -0
  51. package/src/build/dev-build-coordinator.d.ts +74 -0
  52. package/src/build/dev-build-coordinator.js +161 -0
  53. package/src/build/esbuild-build-adapter.d.ts +9 -6
  54. package/src/build/esbuild-build-adapter.js +103 -71
  55. package/src/build/runtime-build-executor.d.ts +13 -0
  56. package/src/build/runtime-build-executor.js +20 -0
  57. package/src/build/runtime-specifier-alias-plugin.d.ts +15 -0
  58. package/src/build/runtime-specifier-alias-plugin.js +31 -0
  59. package/src/config/README.md +33 -0
  60. package/src/config/config-builder.d.ts +28 -17
  61. package/src/config/config-builder.js +221 -48
  62. package/src/constants.d.ts +13 -0
  63. package/src/constants.js +4 -0
  64. package/src/declarations.d.ts +18 -13
  65. package/src/eco/README.md +70 -16
  66. package/src/eco/component-render-context.d.ts +1 -1
  67. package/src/eco/component-render-context.js +26 -16
  68. package/src/eco/eco.js +16 -12
  69. package/src/eco/eco.types.d.ts +12 -4
  70. package/src/hmr/README.md +26 -0
  71. package/src/hmr/client/hmr-runtime.d.ts +1 -6
  72. package/src/hmr/client/hmr-runtime.js +30 -7
  73. package/src/hmr/hmr.postcss.test.e2e.d.ts +1 -0
  74. package/src/hmr/hmr.postcss.test.e2e.js +31 -0
  75. package/src/hmr/hmr.test.e2e.js +26 -33
  76. package/src/hmr/strategies/js-hmr-strategy.d.ts +45 -42
  77. package/src/hmr/strategies/js-hmr-strategy.js +70 -71
  78. package/src/index.d.ts +1 -1
  79. package/src/index.js +1 -1
  80. package/src/integrations/ghtml/ghtml-renderer.d.ts +1 -1
  81. package/src/integrations/ghtml/ghtml-renderer.js +3 -1
  82. package/src/internal-types.d.ts +39 -18
  83. package/src/plugins/README.md +34 -0
  84. package/src/plugins/alias-resolver-plugin.js +17 -3
  85. package/src/plugins/eco-component-meta-plugin.d.ts +2 -0
  86. package/src/plugins/eco-component-meta-plugin.js +1 -1
  87. package/src/plugins/integration-plugin.d.ts +38 -4
  88. package/src/plugins/integration-plugin.js +34 -1
  89. package/src/plugins/processor.d.ts +14 -1
  90. package/src/plugins/processor.js +15 -1
  91. package/src/plugins/runtime-capability.d.ts +9 -0
  92. package/src/public-types.d.ts +65 -10
  93. package/src/route-renderer/GRAPH.md +16 -20
  94. package/src/route-renderer/README.md +8 -21
  95. package/src/route-renderer/component-graph/component-reference.d.ts +10 -0
  96. package/src/route-renderer/component-graph/component-reference.js +19 -0
  97. package/src/route-renderer/{marker-graph-resolver.d.ts → component-graph/marker-graph-resolver.d.ts} +6 -5
  98. package/src/route-renderer/{marker-graph-resolver.js → component-graph/marker-graph-resolver.js} +10 -8
  99. package/src/route-renderer/{integration-renderer.d.ts → orchestration/integration-renderer.d.ts} +45 -12
  100. package/src/route-renderer/{integration-renderer.js → orchestration/integration-renderer.js} +79 -16
  101. package/src/route-renderer/{render-execution.service.d.ts → orchestration/render-execution.service.d.ts} +39 -5
  102. package/src/route-renderer/{render-execution.service.js → orchestration/render-execution.service.js} +58 -28
  103. package/src/route-renderer/{render-preparation.service.d.ts → orchestration/render-preparation.service.d.ts} +13 -4
  104. package/src/route-renderer/{render-preparation.service.js → orchestration/render-preparation.service.js} +92 -3
  105. package/src/route-renderer/{dependency-resolver.d.ts → page-loading/dependency-resolver.d.ts} +15 -4
  106. package/src/route-renderer/{dependency-resolver.js → page-loading/dependency-resolver.js} +18 -4
  107. package/src/route-renderer/page-loading/page-module-loader.d.ts +87 -0
  108. package/src/route-renderer/{page-module-loader.js → page-loading/page-module-loader.js} +36 -14
  109. package/src/route-renderer/route-renderer.d.ts +36 -1
  110. package/src/route-renderer/route-renderer.js +19 -0
  111. package/src/router/README.md +26 -0
  112. package/src/router/client/link-intent.d.ts +53 -0
  113. package/src/router/client/link-intent.js +34 -0
  114. package/src/router/client/link-intent.test.browser.d.ts +1 -0
  115. package/src/router/client/link-intent.test.browser.js +43 -0
  116. package/src/router/client/navigation-coordinator.d.ts +149 -0
  117. package/src/router/client/navigation-coordinator.js +215 -0
  118. package/src/router/{fs-router-scanner.d.ts → server/fs-router-scanner.d.ts} +3 -3
  119. package/src/router/{fs-router-scanner.js → server/fs-router-scanner.js} +8 -7
  120. package/src/router/{fs-router.d.ts → server/fs-router.d.ts} +1 -1
  121. package/src/router/{fs-router.js → server/fs-router.js} +1 -1
  122. package/src/services/README.md +29 -0
  123. package/src/services/assets/asset-processing-service/asset-processing.service.d.ts +120 -0
  124. package/src/services/{asset-processing-service → assets/asset-processing-service}/asset-processing.service.js +88 -7
  125. package/src/services/{asset-processing-service → assets/asset-processing-service}/asset.factory.js +2 -2
  126. package/src/services/{asset-processing-service → assets/asset-processing-service}/assets.types.d.ts +2 -1
  127. package/src/services/assets/asset-processing-service/assets.types.js +0 -0
  128. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.d.ts +55 -0
  129. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.js +48 -0
  130. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.d.ts +20 -0
  131. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.js +41 -0
  132. package/src/services/{asset-processing-service → assets/asset-processing-service}/index.d.ts +2 -0
  133. package/src/services/{asset-processing-service → assets/asset-processing-service}/index.js +2 -0
  134. package/src/services/{asset-processing-service → assets/asset-processing-service}/processor.interface.d.ts +1 -1
  135. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/base/base-processor.d.ts +1 -1
  136. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/base/base-processor.js +9 -4
  137. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/base/base-script-processor.d.ts +3 -2
  138. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/base/base-script-processor.js +14 -22
  139. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/file-script.processor.d.ts +1 -1
  140. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/file-script.processor.js +2 -2
  141. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/node-module-script.processor.js +5 -4
  142. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/stylesheet/file-stylesheet.processor.js +4 -1
  143. package/src/services/assets/browser-bundle.service.d.ts +32 -0
  144. package/src/services/assets/browser-bundle.service.js +33 -0
  145. package/src/services/{page-request-cache-coordinator.service.d.ts → cache/page-request-cache-coordinator.service.d.ts} +2 -2
  146. package/src/services/{page-request-cache-coordinator.service.js → cache/page-request-cache-coordinator.service.js} +3 -1
  147. package/src/services/html/html-rewriter-provider.service.d.ts +37 -0
  148. package/src/services/html/html-rewriter-provider.service.js +65 -0
  149. package/src/services/html/html-transformer.service.d.ts +77 -0
  150. package/src/services/html/html-transformer.service.js +221 -0
  151. package/src/services/invalidation/development-invalidation.service.d.ts +74 -0
  152. package/src/services/invalidation/development-invalidation.service.js +189 -0
  153. package/src/services/module-loading/app-server-module-transpiler.service.d.ts +16 -0
  154. package/src/services/module-loading/app-server-module-transpiler.service.js +34 -0
  155. package/src/services/module-loading/page-module-import.service.d.ts +71 -0
  156. package/src/services/module-loading/page-module-import.service.js +132 -0
  157. package/src/services/module-loading/server-loader.service.d.ts +96 -0
  158. package/src/services/module-loading/server-loader.service.js +32 -0
  159. package/src/services/module-loading/server-module-transpiler.service.d.ts +69 -0
  160. package/src/services/module-loading/server-module-transpiler.service.js +61 -0
  161. package/src/services/runtime-manifest/node-runtime-manifest.service.d.ts +35 -0
  162. package/src/services/runtime-manifest/node-runtime-manifest.service.js +60 -0
  163. package/src/services/runtime-state/dev-graph.service.d.ts +118 -0
  164. package/src/services/runtime-state/dev-graph.service.js +162 -0
  165. package/src/services/runtime-state/entrypoint-dependency-graph.service.d.ts +41 -0
  166. package/src/services/runtime-state/entrypoint-dependency-graph.service.js +85 -0
  167. package/src/services/runtime-state/runtime-specifier-registry.service.d.ts +69 -0
  168. package/src/services/runtime-state/runtime-specifier-registry.service.js +37 -0
  169. package/src/services/runtime-state/server-invalidation-state.service.d.ts +26 -0
  170. package/src/services/runtime-state/server-invalidation-state.service.js +35 -0
  171. package/src/services/{schema-validation-service.d.ts → validation/schema-validation-service.d.ts} +1 -1
  172. package/src/static-site-generator/README.md +26 -0
  173. package/src/static-site-generator/static-site-generator.d.ts +53 -1
  174. package/src/static-site-generator/static-site-generator.js +86 -5
  175. package/src/utils/resolve-work-dir.d.ts +11 -0
  176. package/src/utils/resolve-work-dir.js +31 -0
  177. package/src/watchers/project-watcher.d.ts +37 -21
  178. package/src/watchers/project-watcher.js +109 -66
  179. package/src/watchers/project-watcher.test-helpers.js +1 -0
  180. package/src/adapters/abstract/application-adapter.ts +0 -337
  181. package/src/adapters/abstract/router-adapter.ts +0 -30
  182. package/src/adapters/abstract/server-adapter.ts +0 -79
  183. package/src/adapters/bun/client-bridge.ts +0 -62
  184. package/src/adapters/bun/create-app.ts +0 -189
  185. package/src/adapters/bun/define-api-handler.d.ts +0 -61
  186. package/src/adapters/bun/define-api-handler.ts +0 -114
  187. package/src/adapters/bun/hmr-manager.ts +0 -281
  188. package/src/adapters/bun/index.ts +0 -3
  189. package/src/adapters/bun/server-adapter.ts +0 -492
  190. package/src/adapters/bun/server-lifecycle.ts +0 -154
  191. package/src/adapters/index.ts +0 -6
  192. package/src/adapters/node/create-app.ts +0 -179
  193. package/src/adapters/node/index.ts +0 -9
  194. package/src/adapters/node/node-client-bridge.ts +0 -79
  195. package/src/adapters/node/node-hmr-manager.ts +0 -271
  196. package/src/adapters/node/server-adapter.ts +0 -561
  197. package/src/adapters/node/static-content-server.ts +0 -203
  198. package/src/adapters/shared/api-response.ts +0 -104
  199. package/src/adapters/shared/application-adapter.ts +0 -199
  200. package/src/adapters/shared/explicit-static-route-matcher.ts +0 -134
  201. package/src/adapters/shared/file-route-middleware-pipeline.ts +0 -123
  202. package/src/adapters/shared/fs-server-response-factory.ts +0 -118
  203. package/src/adapters/shared/fs-server-response-matcher.ts +0 -198
  204. package/src/adapters/shared/render-context.ts +0 -105
  205. package/src/adapters/shared/server-adapter.ts +0 -442
  206. package/src/adapters/shared/server-route-handler.ts +0 -166
  207. package/src/adapters/shared/server-static-builder.ts +0 -82
  208. package/src/build/build-adapter.ts +0 -132
  209. package/src/build/build-types.ts +0 -83
  210. package/src/build/esbuild-build-adapter.ts +0 -510
  211. package/src/config/config-builder.ts +0 -474
  212. package/src/constants.ts +0 -39
  213. package/src/create-app.ts +0 -87
  214. package/src/define-api-handler.js +0 -15
  215. package/src/define-api-handler.ts +0 -66
  216. package/src/dev/sc-server.ts +0 -143
  217. package/src/eco/component-render-context.ts +0 -202
  218. package/src/eco/eco.ts +0 -221
  219. package/src/eco/eco.types.ts +0 -202
  220. package/src/eco/eco.utils.ts +0 -89
  221. package/src/eco/global-injector-map.ts +0 -112
  222. package/src/eco/lazy-injector-map.ts +0 -120
  223. package/src/eco/module-dependencies.ts +0 -75
  224. package/src/errors/http-error.ts +0 -72
  225. package/src/errors/index.ts +0 -2
  226. package/src/errors/locals-access-error.ts +0 -7
  227. package/src/global/app-logger.ts +0 -4
  228. 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
  229. package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-HMR-Server-Integration-should-load-fixture-app-page-1.png +0 -0
  230. package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-WebSocket-Connection-should-connect-to-correct-HMR-endpoint-1.png +0 -0
  231. package/src/hmr/client/hmr-runtime.ts +0 -121
  232. package/src/hmr/hmr-strategy.ts +0 -172
  233. package/src/hmr/hmr.test.e2e.ts +0 -75
  234. package/src/hmr/strategies/default-hmr-strategy.ts +0 -60
  235. package/src/hmr/strategies/js-hmr-strategy.ts +0 -308
  236. package/src/index.browser.ts +0 -3
  237. package/src/index.ts +0 -5
  238. package/src/integrations/ghtml/ghtml-renderer.ts +0 -93
  239. package/src/integrations/ghtml/ghtml.plugin.ts +0 -32
  240. package/src/internal-types.ts +0 -212
  241. package/src/plugins/alias-resolver-plugin.ts +0 -45
  242. package/src/plugins/eco-component-meta-plugin.ts +0 -474
  243. package/src/plugins/integration-plugin.ts +0 -184
  244. package/src/plugins/processor.ts +0 -220
  245. package/src/public-types.ts +0 -1255
  246. package/src/route-renderer/component-graph-executor.ts +0 -84
  247. package/src/route-renderer/component-graph.ts +0 -159
  248. package/src/route-renderer/component-marker.ts +0 -117
  249. package/src/route-renderer/dependency-resolver.ts +0 -596
  250. package/src/route-renderer/html-post-processing.service.d.ts +0 -40
  251. package/src/route-renderer/html-post-processing.service.js +0 -86
  252. package/src/route-renderer/html-post-processing.service.ts +0 -103
  253. package/src/route-renderer/integration-renderer.ts +0 -696
  254. package/src/route-renderer/marker-graph-resolver.ts +0 -153
  255. package/src/route-renderer/page-module-loader.d.ts +0 -61
  256. package/src/route-renderer/page-module-loader.ts +0 -153
  257. package/src/route-renderer/render-execution.service.ts +0 -158
  258. package/src/route-renderer/render-preparation.service.ts +0 -358
  259. package/src/route-renderer/route-renderer.ts +0 -80
  260. package/src/router/fs-router-scanner.ts +0 -217
  261. package/src/router/fs-router.ts +0 -122
  262. package/src/services/asset-processing-service/asset-processing.service.d.ts +0 -41
  263. package/src/services/asset-processing-service/asset-processing.service.ts +0 -306
  264. package/src/services/asset-processing-service/asset.factory.ts +0 -105
  265. package/src/services/asset-processing-service/assets.types.ts +0 -112
  266. package/src/services/asset-processing-service/index.ts +0 -3
  267. package/src/services/asset-processing-service/processor.interface.ts +0 -27
  268. package/src/services/asset-processing-service/processor.registry.ts +0 -18
  269. package/src/services/asset-processing-service/processors/base/base-processor.ts +0 -76
  270. package/src/services/asset-processing-service/processors/base/base-script-processor.ts +0 -105
  271. package/src/services/asset-processing-service/processors/index.ts +0 -5
  272. package/src/services/asset-processing-service/processors/script/content-script.processor.ts +0 -66
  273. package/src/services/asset-processing-service/processors/script/file-script.processor.ts +0 -88
  274. package/src/services/asset-processing-service/processors/script/node-module-script.processor.ts +0 -84
  275. package/src/services/asset-processing-service/processors/stylesheet/content-stylesheet.processor.ts +0 -27
  276. package/src/services/asset-processing-service/processors/stylesheet/file-stylesheet.processor.ts +0 -77
  277. package/src/services/cache/cache.types.ts +0 -126
  278. package/src/services/cache/index.ts +0 -18
  279. package/src/services/cache/memory-cache-store.ts +0 -130
  280. package/src/services/cache/page-cache-service.ts +0 -202
  281. package/src/services/html-transformer.service.d.ts +0 -50
  282. package/src/services/html-transformer.service.js +0 -163
  283. package/src/services/html-transformer.service.ts +0 -217
  284. package/src/services/page-module-import.service.d.ts +0 -37
  285. package/src/services/page-module-import.service.js +0 -88
  286. package/src/services/page-module-import.service.ts +0 -129
  287. package/src/services/page-request-cache-coordinator.service.ts +0 -128
  288. package/src/services/schema-validation-service.ts +0 -204
  289. package/src/services/validation/standard-schema.types.ts +0 -68
  290. package/src/static-site-generator/static-site-generator.ts +0 -359
  291. package/src/utils/css.ts +0 -5
  292. package/src/utils/deep-merge.ts +0 -47
  293. package/src/utils/hash.ts +0 -5
  294. package/src/utils/html.ts +0 -1
  295. package/src/utils/invariant.ts +0 -15
  296. package/src/utils/locals-utils.ts +0 -37
  297. package/src/utils/parse-cli-args.ts +0 -83
  298. package/src/utils/path-utils.module.ts +0 -14
  299. package/src/utils/runtime.ts +0 -44
  300. package/src/utils/server-utils.module.ts +0 -67
  301. package/src/watchers/project-watcher.test-helpers.ts +0 -40
  302. package/src/watchers/project-watcher.ts +0 -306
  303. /package/src/adapters/{bun → shared}/define-api-handler.js +0 -0
  304. /package/src/{services/asset-processing-service/assets.types.js → plugins/runtime-capability.js} +0 -0
  305. /package/src/route-renderer/{component-graph-executor.d.ts → component-graph/component-graph-executor.d.ts} +0 -0
  306. /package/src/route-renderer/{component-graph-executor.js → component-graph/component-graph-executor.js} +0 -0
  307. /package/src/route-renderer/{component-graph.d.ts → component-graph/component-graph.d.ts} +0 -0
  308. /package/src/route-renderer/{component-graph.js → component-graph/component-graph.js} +0 -0
  309. /package/src/route-renderer/{component-marker.d.ts → component-graph/component-marker.d.ts} +0 -0
  310. /package/src/route-renderer/{component-marker.js → component-graph/component-marker.js} +0 -0
  311. /package/src/services/{asset-processing-service → assets/asset-processing-service}/asset.factory.d.ts +0 -0
  312. /package/src/services/{asset-processing-service → assets/asset-processing-service}/processor.interface.js +0 -0
  313. /package/src/services/{asset-processing-service → assets/asset-processing-service}/processor.registry.d.ts +0 -0
  314. /package/src/services/{asset-processing-service → assets/asset-processing-service}/processor.registry.js +0 -0
  315. /package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/index.d.ts +0 -0
  316. /package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/index.js +0 -0
  317. /package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/content-script.processor.d.ts +0 -0
  318. /package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/content-script.processor.js +0 -0
  319. /package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/node-module-script.processor.d.ts +0 -0
  320. /package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/stylesheet/content-stylesheet.processor.d.ts +0 -0
  321. /package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/stylesheet/content-stylesheet.processor.js +0 -0
  322. /package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/stylesheet/file-stylesheet.processor.d.ts +0 -0
  323. /package/src/services/{schema-validation-service.js → validation/schema-validation-service.js} +0 -0
@@ -0,0 +1,26 @@
1
+ import { type NodeRuntimeManifest } from '../../services/runtime-manifest/node-runtime-manifest.service.js';
2
+ /**
3
+ * Writes the app-owned Node runtime manifest from a bundled manifest-writer
4
+ * entrypoint.
5
+ *
6
+ * @remarks
7
+ * The Node thin-host launch plan executes a bundled JavaScript prep artifact
8
+ * instead of evaluating TypeScript config directly in the launcher. This helper
9
+ * is the narrow bridge between that bundle and the core-owned manifest writer.
10
+ */
11
+ export declare function writeBundledNodeRuntimeManifest(appConfig: {
12
+ rootDir: string;
13
+ absolutePaths: {
14
+ config: string;
15
+ srcDir: string;
16
+ distDir: string;
17
+ workDir?: string;
18
+ };
19
+ loaders: Map<string, unknown>;
20
+ runtime?: {
21
+ nodeRuntimeManifest?: NodeRuntimeManifest;
22
+ };
23
+ }, options: {
24
+ entryModulePath: string;
25
+ manifestFilePath: string;
26
+ }): void;
@@ -0,0 +1,12 @@
1
+ import {
2
+ writeAppNodeRuntimeManifest
3
+ } from "../../services/runtime-manifest/node-runtime-manifest.service.js";
4
+ function writeBundledNodeRuntimeManifest(appConfig, options) {
5
+ writeAppNodeRuntimeManifest(appConfig, {
6
+ entryModulePath: options.entryModulePath,
7
+ manifestFilePath: options.manifestFilePath
8
+ });
9
+ }
10
+ export {
11
+ writeBundledNodeRuntimeManifest
12
+ };
@@ -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 '../../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'> & {
@@ -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
  }
@@ -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,6 +1,6 @@
1
- import type { MatchResult } from '../../internal-types.js';
1
+ import type { EcoPagesAppConfig, MatchResult } from '../../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 "../../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 '../../public-types';
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
+ };
@@ -17,10 +17,10 @@ function createRenderContext(options) {
17
17
  invariant(!!integration, `No integration found for: ${integrationName}`);
18
18
  return integration.initializeRenderer();
19
19
  };
20
- return {
20
+ const renderContext = {
21
21
  async render(view, props, renderOptions) {
22
22
  const locals = this?.locals;
23
- const mergedProps = mergePropsWithLocals(props, locals);
23
+ const mergedProps = mergePropsWithLocals(props ?? {}, locals);
24
24
  const renderer = getRendererForView(view);
25
25
  const ctx = {
26
26
  partial: false,
@@ -63,6 +63,7 @@ function createRenderContext(options) {
63
63
  });
64
64
  }
65
65
  };
66
+ return renderContext;
66
67
  }
67
68
  export {
68
69
  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 '../../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 "../../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
+ };
@@ -1,8 +1,8 @@
1
1
  import { AbstractServerAdapter } from '../abstract/server-adapter.js';
2
2
  import type { ServerAdapterOptions, ServerAdapterResult } from '../abstract/server-adapter.js';
3
3
  import { RouteRendererFactory } from '../../route-renderer/route-renderer.js';
4
- import { FSRouter } from '../../router/fs-router.js';
5
- import { SchemaValidationService } from '../../services/schema-validation-service.js';
4
+ import { FSRouter } from '../../router/server/fs-router.js';
5
+ import { SchemaValidationService } from '../../services/validation/schema-validation-service.js';
6
6
  import { StaticSiteGenerator } from '../../static-site-generator/static-site-generator.js';
7
7
  import { ServerStaticBuilder } from './server-static-builder.js';
8
8
  import { FileSystemResponseMatcher } from './fs-server-response-matcher.js';
@@ -16,6 +16,16 @@ export declare abstract class SharedServerAdapter<TOptions extends ServerAdapter
16
16
  protected staticSiteGenerator: StaticSiteGenerator;
17
17
  protected staticBuilder: ServerStaticBuilder;
18
18
  protected readonly schemaValidator: SchemaValidationService;
19
+ protected initializeSharedRouteHandling(options: {
20
+ staticRoutes: StaticRoute[];
21
+ hmrManager?: any;
22
+ }): Promise<void>;
23
+ protected createSharedWatchRefreshCallback(options: {
24
+ staticRoutes: StaticRoute[];
25
+ hmrManager?: any;
26
+ onRoutesReady?: () => Promise<void> | void;
27
+ onError?: (error: Error) => Promise<void> | void;
28
+ }): () => Promise<void>;
19
29
  /**
20
30
  * Scans the filesystem and dynamically constructs the universal router map.
21
31
  *
@@ -1,11 +1,11 @@
1
1
  import path from "node:path";
2
2
  import { AbstractServerAdapter } from "../abstract/server-adapter.js";
3
3
  import { RouteRendererFactory } from "../../route-renderer/route-renderer.js";
4
- import { FSRouter } from "../../router/fs-router.js";
5
- import { FSRouterScanner } from "../../router/fs-router-scanner.js";
4
+ import { FSRouter } from "../../router/server/fs-router.js";
5
+ import { FSRouterScanner } from "../../router/server/fs-router-scanner.js";
6
6
  import { MemoryCacheStore } from "../../services/cache/memory-cache-store.js";
7
7
  import { PageCacheService } from "../../services/cache/page-cache-service.js";
8
- import { SchemaValidationService } from "../../services/schema-validation-service.js";
8
+ import { SchemaValidationService } from "../../services/validation/schema-validation-service.js";
9
9
  import { StaticSiteGenerator } from "../../static-site-generator/static-site-generator.js";
10
10
  import { ServerStaticBuilder } from "./server-static-builder.js";
11
11
  import { ExplicitStaticRouteMatcher } from "./explicit-static-route-matcher.js";
@@ -17,6 +17,7 @@ import { createRequire } from "../../utils/locals-utils.js";
17
17
  import { HttpError } from "../../errors/http-error.js";
18
18
  import { ApiResponseBuilder } from "./api-response.js";
19
19
  import { appLogger } from "../../global/app-logger.js";
20
+ import { fileSystem } from "@ecopages/file-system";
20
21
  class SharedServerAdapter extends AbstractServerAdapter {
21
22
  router;
22
23
  fileSystemResponseMatcher;
@@ -25,6 +26,29 @@ class SharedServerAdapter extends AbstractServerAdapter {
25
26
  staticSiteGenerator;
26
27
  staticBuilder;
27
28
  schemaValidator = new SchemaValidationService();
29
+ async initializeSharedRouteHandling(options) {
30
+ await this.initSharedRouter();
31
+ this.configureSharedResponseHandlers(options.staticRoutes, options.hmrManager);
32
+ }
33
+ createSharedWatchRefreshCallback(options) {
34
+ return async () => {
35
+ try {
36
+ await this.initializeSharedRouteHandling({
37
+ staticRoutes: options.staticRoutes,
38
+ hmrManager: options.hmrManager
39
+ });
40
+ if (options.onRoutesReady) {
41
+ await options.onRoutesReady();
42
+ }
43
+ } catch (error) {
44
+ if (options.onError) {
45
+ await options.onError(error instanceof Error ? error : new Error(String(error)));
46
+ return;
47
+ }
48
+ throw error;
49
+ }
50
+ };
51
+ }
28
52
  /**
29
53
  * Scans the filesystem and dynamically constructs the universal router map.
30
54
  *
@@ -84,6 +108,7 @@ class SharedServerAdapter extends AbstractServerAdapter {
84
108
  cacheService = new PageCacheService({ store, enabled: true });
85
109
  }
86
110
  this.fileSystemResponseMatcher = new FileSystemResponseMatcher({
111
+ appConfig: this.appConfig,
87
112
  router: this.router,
88
113
  routeRendererFactory: this.routeRendererFactory,
89
114
  fileSystemResponseFactory,
@@ -328,13 +353,21 @@ class SharedServerAdapter extends AbstractServerAdapter {
328
353
  const url = new URL(request.url);
329
354
  if (url.pathname === "/_hmr_runtime.js" && context.hmrManager) {
330
355
  const runtimePath = context.hmrManager.getRuntimePath();
331
- const fileSystem = (await import("@ecopages/file-system")).fileSystem;
332
356
  if (fileSystem.exists(runtimePath)) {
333
357
  return new Response(fileSystem.readFileAsBuffer(runtimePath), {
334
358
  headers: { "Content-Type": "application/javascript" }
335
359
  });
336
360
  }
337
361
  }
362
+ if (url.pathname.startsWith("/assets/_hmr/") && context.hmrManager) {
363
+ const relativePath = url.pathname.slice("/assets/_hmr/".length);
364
+ const assetPath = path.join(context.hmrManager.getDistDir(), relativePath);
365
+ if (fileSystem.exists(assetPath)) {
366
+ return new Response(fileSystem.readFileAsBuffer(assetPath), {
367
+ headers: { "Content-Type": "application/javascript" }
368
+ });
369
+ }
370
+ }
338
371
  const apiMatch = this.matchApiHandler(request, context.apiHandlers);
339
372
  if (apiMatch) {
340
373
  return this.executeApiHandler(
@@ -1,5 +1,5 @@
1
1
  import type { IHmrManager } from '../../public-types';
2
- import type { FSRouter } from '../../router/fs-router';
2
+ import type { FSRouter } from '../../router/server/fs-router';
3
3
  import type { ExplicitStaticRouteMatcher } from './explicit-static-route-matcher';
4
4
  import type { FileSystemResponseMatcher } from './fs-server-response-matcher';
5
5
  /**
@@ -1,5 +1,6 @@
1
1
  import { appLogger } from "../../global/app-logger";
2
2
  import { HttpError } from "../../errors/http-error";
3
+ import { injectHmrRuntimeIntoHtmlResponse, isHtmlResponse, shouldInjectHmrHtmlResponse } from "./hmr-html-response";
3
4
  class ServerRouteHandler {
4
5
  router;
5
6
  fileSystemResponseMatcher;
@@ -30,7 +31,7 @@ class ServerRouteHandler {
30
31
  * @returns true if in watch mode and HMR manager is enabled
31
32
  */
32
33
  shouldInjectHmrScript() {
33
- return this.watch && this.hmrManager?.isEnabled() === true;
34
+ return shouldInjectHmrHtmlResponse(this.watch, this.hmrManager);
34
35
  }
35
36
  /**
36
37
  * Checks if a response contains HTML content.
@@ -39,8 +40,7 @@ class ServerRouteHandler {
39
40
  * @returns true if Content-Type header starts with 'text/html'
40
41
  */
41
42
  isHtmlResponse(response) {
42
- const contentType = response.headers.get("Content-Type");
43
- return contentType !== null && contentType.startsWith("text/html");
43
+ return isHtmlResponse(response);
44
44
  }
45
45
  /**
46
46
  * Handles HTTP requests from the router adapter.
@@ -75,16 +75,7 @@ class ServerRouteHandler {
75
75
  */
76
76
  async maybeInjectHmrScript(response) {
77
77
  if (this.shouldInjectHmrScript() && this.isHtmlResponse(response)) {
78
- const html = await response.text();
79
- const hmrScript = `<script type="module">import '/_hmr_runtime.js';<\/script>`;
80
- const updatedHtml = html.replace(/<\/html>/i, `${hmrScript}</html>`);
81
- const headers = new Headers(response.headers);
82
- headers.delete("Content-Length");
83
- return new Response(updatedHtml, {
84
- status: response.status,
85
- statusText: response.statusText,
86
- headers
87
- });
78
+ return injectHmrRuntimeIntoHtmlResponse(response);
88
79
  }
89
80
  return response;
90
81
  }