@ecopages/core 0.2.0-alpha.4 → 0.2.0-alpha.6

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 (418) hide show
  1. package/README.md +213 -12
  2. package/package.json +100 -188
  3. package/src/adapters/README.md +39 -0
  4. package/src/adapters/bun/hmr-manager.test.ts +267 -0
  5. package/src/adapters/bun/hmr-manager.ts +181 -68
  6. package/src/adapters/bun/index.ts +1 -2
  7. package/src/adapters/bun/server-adapter.ts +41 -34
  8. package/src/adapters/bun/server-lifecycle.ts +40 -70
  9. package/src/adapters/index.ts +1 -1
  10. package/src/adapters/node/bootstrap-dependency-resolver.test.ts +282 -0
  11. package/src/adapters/node/bootstrap-dependency-resolver.ts +301 -0
  12. package/src/adapters/node/index.ts +7 -0
  13. package/src/adapters/node/node-client-bridge.test.ts +198 -0
  14. package/src/adapters/node/node-hmr-manager.test.ts +322 -0
  15. package/src/adapters/node/node-hmr-manager.ts +208 -116
  16. package/src/adapters/node/runtime-adapter.test.ts +868 -0
  17. package/src/adapters/node/runtime-adapter.ts +439 -0
  18. package/src/adapters/node/server-adapter.ts +31 -104
  19. package/src/adapters/node/static-content-server.test.ts +60 -0
  20. package/src/adapters/node/static-content-server.ts +36 -0
  21. package/src/adapters/node/write-runtime-manifest.ts +38 -0
  22. package/src/adapters/shared/api-response.test.ts +97 -0
  23. package/src/{define-api-handler.ts → adapters/shared/define-api-handler.ts} +1 -1
  24. package/src/adapters/shared/explicit-static-route-matcher.test.ts +381 -0
  25. package/src/adapters/shared/explicit-static-route-matcher.ts +7 -1
  26. package/src/adapters/shared/file-route-middleware-pipeline.test.ts +90 -0
  27. package/src/adapters/shared/file-route-middleware-pipeline.ts +6 -2
  28. package/src/adapters/shared/fs-server-response-factory.test.ts +187 -0
  29. package/src/adapters/shared/fs-server-response-matcher.test.ts +286 -0
  30. package/src/adapters/shared/fs-server-response-matcher.ts +17 -10
  31. package/src/adapters/shared/hmr-entrypoint-registrar.ts +149 -0
  32. package/src/adapters/shared/hmr-html-response.ts +52 -0
  33. package/src/adapters/shared/hmr-manager.contract.test.ts +196 -0
  34. package/src/adapters/shared/hmr-manager.dispatch.test.ts +220 -0
  35. package/src/adapters/shared/render-context.test.ts +146 -0
  36. package/src/adapters/shared/render-context.ts +21 -6
  37. package/src/adapters/shared/runtime-bootstrap.ts +79 -0
  38. package/src/adapters/shared/server-adapter.test.ts +77 -0
  39. package/src/adapters/shared/server-adapter.ts +51 -4
  40. package/src/adapters/shared/server-route-handler.test.ts +110 -0
  41. package/src/adapters/shared/server-route-handler.ts +5 -18
  42. package/src/adapters/shared/server-static-builder.test.ts +316 -0
  43. package/src/adapters/shared/server-static-builder.ts +92 -8
  44. package/src/build/README.md +101 -0
  45. package/src/build/build-adapter-serialization.test.ts +268 -0
  46. package/src/build/build-adapter.test.ts +815 -0
  47. package/src/build/build-adapter.ts +235 -6
  48. package/src/build/build-manifest.ts +54 -0
  49. package/src/build/dev-build-coordinator.ts +221 -0
  50. package/src/build/esbuild-build-adapter.ts +132 -83
  51. package/src/build/runtime-build-executor.ts +34 -0
  52. package/src/build/runtime-specifier-alias-plugin.test.ts +43 -0
  53. package/src/build/runtime-specifier-alias-plugin.ts +58 -0
  54. package/src/config/README.md +33 -0
  55. package/src/config/config-builder.test.ts +410 -0
  56. package/src/config/config-builder.ts +281 -49
  57. package/src/constants.ts +15 -0
  58. package/src/declarations.d.ts +18 -13
  59. package/src/eco/README.md +70 -16
  60. package/src/eco/component-render-context.ts +39 -17
  61. package/src/eco/eco.test.ts +678 -0
  62. package/src/eco/eco.ts +29 -8
  63. package/src/eco/eco.types.ts +20 -1
  64. package/src/eco/eco.utils.test.ts +124 -0
  65. package/src/eco/global-injector-map.test.ts +42 -0
  66. package/src/eco/lazy-injector-map.test.ts +66 -0
  67. package/src/eco/module-dependencies.test.ts +30 -0
  68. package/src/errors/http-error.test.ts +134 -0
  69. package/src/global/utils.test.ts +12 -0
  70. package/src/hmr/README.md +26 -0
  71. 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
  72. package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-HMR-Server-Integration-should-load-fixture-app-page-1.png +0 -0
  73. package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-WebSocket-Connection-should-connect-to-correct-HMR-endpoint-1.png +0 -0
  74. package/src/hmr/client/hmr-runtime.ts +38 -7
  75. package/src/hmr/hmr-strategy.test.ts +124 -0
  76. package/src/hmr/hmr.postcss.test.e2e.ts +41 -0
  77. package/src/hmr/hmr.test.e2e.ts +29 -38
  78. package/src/hmr/strategies/js-hmr-strategy.test.ts +335 -0
  79. package/src/hmr/strategies/js-hmr-strategy.ts +115 -115
  80. package/src/index.ts +1 -1
  81. package/src/integrations/ghtml/ghtml-renderer.test.ts +63 -0
  82. package/src/integrations/ghtml/ghtml-renderer.ts +4 -1
  83. package/src/internal-types.ts +39 -19
  84. package/src/plugins/README.md +34 -0
  85. package/src/plugins/alias-resolver-plugin.test.ts +41 -0
  86. package/src/plugins/alias-resolver-plugin.ts +21 -3
  87. package/src/plugins/eco-component-meta-plugin.test.ts +380 -0
  88. package/src/plugins/eco-component-meta-plugin.ts +10 -3
  89. package/src/plugins/integration-plugin.test.ts +111 -0
  90. package/src/plugins/integration-plugin.ts +45 -3
  91. package/src/plugins/processor.test.ts +148 -0
  92. package/src/plugins/processor.ts +22 -2
  93. package/src/plugins/runtime-capability.ts +14 -0
  94. package/src/public-types.ts +73 -16
  95. package/src/route-renderer/GRAPH.md +16 -20
  96. package/src/route-renderer/README.md +8 -21
  97. package/src/route-renderer/component-graph/component-graph-executor.test.ts +41 -0
  98. package/src/route-renderer/component-graph/component-graph.test.ts +63 -0
  99. package/src/route-renderer/component-graph/component-marker.test.ts +73 -0
  100. package/src/route-renderer/component-graph/component-reference.ts +29 -0
  101. package/src/route-renderer/component-graph/marker-graph-resolver.test.ts +135 -0
  102. package/src/route-renderer/{marker-graph-resolver.ts → component-graph/marker-graph-resolver.ts} +11 -9
  103. package/src/route-renderer/orchestration/integration-renderer.test.ts +936 -0
  104. package/src/route-renderer/{integration-renderer.ts → orchestration/integration-renderer.ts} +113 -19
  105. package/src/route-renderer/orchestration/render-execution.service.test.ts +97 -0
  106. package/src/route-renderer/{render-execution.service.ts → orchestration/render-execution.service.ts} +109 -37
  107. package/src/route-renderer/orchestration/render-preparation.service.test.ts +235 -0
  108. package/src/route-renderer/{render-preparation.service.ts → orchestration/render-preparation.service.ts} +127 -9
  109. package/src/route-renderer/page-loading/dependency-resolver.test.ts +345 -0
  110. package/src/route-renderer/{dependency-resolver.ts → page-loading/dependency-resolver.ts} +28 -12
  111. package/src/route-renderer/page-loading/page-module-loader.test.ts +96 -0
  112. package/src/route-renderer/{page-module-loader.ts → page-loading/page-module-loader.ts} +49 -21
  113. package/src/route-renderer/route-renderer.ts +36 -1
  114. package/src/router/README.md +26 -0
  115. package/src/router/client/link-intent.d.ts +53 -0
  116. package/src/router/client/link-intent.test.browser.ts +51 -0
  117. package/src/router/client/link-intent.ts +92 -0
  118. package/src/router/client/navigation-coordinator.test.ts +237 -0
  119. package/src/router/client/navigation-coordinator.ts +433 -0
  120. package/src/router/server/fs-router-scanner.test.ts +83 -0
  121. package/src/router/{fs-router-scanner.ts → server/fs-router-scanner.ts} +12 -10
  122. package/src/router/server/fs-router.test.ts +214 -0
  123. package/src/router/{fs-router.ts → server/fs-router.ts} +2 -2
  124. package/src/services/README.md +29 -0
  125. package/src/services/assets/asset-processing-service/asset-processing.service.test.ts +385 -0
  126. package/src/services/{asset-processing-service → assets/asset-processing-service}/asset-processing.service.ts +101 -6
  127. package/src/services/assets/asset-processing-service/asset.factory.test.ts +63 -0
  128. package/src/services/{asset-processing-service → assets/asset-processing-service}/asset.factory.ts +2 -2
  129. package/src/services/{asset-processing-service → assets/asset-processing-service}/assets.types.ts +2 -1
  130. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.test.ts +72 -0
  131. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.ts +95 -0
  132. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.test.ts +67 -0
  133. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.ts +78 -0
  134. package/src/services/{asset-processing-service → assets/asset-processing-service}/index.ts +2 -0
  135. package/src/services/{asset-processing-service → assets/asset-processing-service}/processor.interface.ts +1 -1
  136. package/src/services/assets/asset-processing-service/processors/base/base-processor.test.ts +59 -0
  137. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/base/base-processor.ts +11 -5
  138. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/base/base-script-processor.ts +17 -27
  139. package/src/services/assets/asset-processing-service/processors/script/file-script.processor.test.ts +286 -0
  140. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/file-script.processor.ts +3 -3
  141. package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.test.ts +227 -0
  142. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/node-module-script.processor.ts +5 -4
  143. package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.test.ts +199 -0
  144. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/stylesheet/file-stylesheet.processor.ts +4 -1
  145. package/src/services/assets/browser-bundle.service.test.ts +36 -0
  146. package/src/services/assets/browser-bundle.service.ts +53 -0
  147. package/src/services/cache/index.ts +3 -3
  148. package/src/services/cache/memory-cache-store.test.ts +225 -0
  149. package/src/services/cache/memory-cache-store.ts +1 -1
  150. package/src/services/cache/page-cache-service.test.ts +175 -0
  151. package/src/services/cache/page-cache-service.ts +3 -3
  152. package/src/services/cache/page-request-cache-coordinator.service.test.ts +79 -0
  153. package/src/services/{page-request-cache-coordinator.service.ts → cache/page-request-cache-coordinator.service.ts} +9 -6
  154. package/src/services/html/html-rewriter-provider.service.test.ts +183 -0
  155. package/src/services/html/html-rewriter-provider.service.ts +103 -0
  156. package/src/services/html/html-transformer.service.test.ts +378 -0
  157. package/src/services/html/html-transformer.service.ts +279 -0
  158. package/src/services/invalidation/development-invalidation.service.test.ts +77 -0
  159. package/src/services/invalidation/development-invalidation.service.ts +261 -0
  160. package/src/services/module-loading/app-server-module-transpiler.service.ts +52 -0
  161. package/src/services/module-loading/page-module-import.service.test.ts +253 -0
  162. package/src/services/module-loading/page-module-import.service.ts +200 -0
  163. package/src/services/module-loading/server-loader.service.test.ts +161 -0
  164. package/src/services/module-loading/server-loader.service.ts +130 -0
  165. package/src/services/module-loading/server-module-transpiler.service.test.ts +115 -0
  166. package/src/services/module-loading/server-module-transpiler.service.ts +105 -0
  167. package/src/services/runtime-manifest/node-runtime-manifest.service.test.ts +95 -0
  168. package/src/services/runtime-manifest/node-runtime-manifest.service.ts +101 -0
  169. package/src/services/runtime-state/dev-graph.service.ts +217 -0
  170. package/src/services/runtime-state/entrypoint-dependency-graph.service.ts +136 -0
  171. package/src/services/runtime-state/runtime-specifier-registry.service.ts +96 -0
  172. package/src/services/runtime-state/server-invalidation-state.service.ts +68 -0
  173. package/src/services/validation/schema-validation-service.test.ts +223 -0
  174. package/src/services/{schema-validation-service.ts → validation/schema-validation-service.ts} +1 -1
  175. package/src/static-site-generator/README.md +26 -0
  176. package/src/static-site-generator/static-site-generator.test.ts +307 -0
  177. package/src/static-site-generator/static-site-generator.ts +109 -6
  178. package/src/utils/deep-merge.test.ts +114 -0
  179. package/src/utils/invariant.test.ts +22 -0
  180. package/src/utils/path-utils.test.ts +15 -0
  181. package/src/utils/resolve-work-dir.ts +45 -0
  182. package/src/utils/server-utils.test.ts +38 -0
  183. package/src/watchers/project-watcher.integration.test.ts +337 -0
  184. package/src/watchers/project-watcher.test-helpers.ts +1 -1
  185. package/src/watchers/project-watcher.test.ts +678 -0
  186. package/src/watchers/project-watcher.ts +130 -111
  187. package/CHANGELOG.md +0 -91
  188. package/src/adapters/abstract/application-adapter.d.ts +0 -168
  189. package/src/adapters/abstract/application-adapter.js +0 -109
  190. package/src/adapters/abstract/router-adapter.d.ts +0 -26
  191. package/src/adapters/abstract/router-adapter.js +0 -5
  192. package/src/adapters/abstract/server-adapter.d.ts +0 -69
  193. package/src/adapters/abstract/server-adapter.js +0 -15
  194. package/src/adapters/bun/client-bridge.d.ts +0 -34
  195. package/src/adapters/bun/client-bridge.js +0 -48
  196. package/src/adapters/bun/create-app.d.ts +0 -60
  197. package/src/adapters/bun/create-app.js +0 -117
  198. package/src/adapters/bun/define-api-handler.d.ts +0 -61
  199. package/src/adapters/bun/define-api-handler.js +0 -15
  200. package/src/adapters/bun/define-api-handler.ts +0 -114
  201. package/src/adapters/bun/hmr-manager.d.ts +0 -85
  202. package/src/adapters/bun/hmr-manager.js +0 -240
  203. package/src/adapters/bun/index.d.ts +0 -3
  204. package/src/adapters/bun/index.js +0 -8
  205. package/src/adapters/bun/server-adapter.d.ts +0 -155
  206. package/src/adapters/bun/server-adapter.js +0 -368
  207. package/src/adapters/bun/server-lifecycle.d.ts +0 -52
  208. package/src/adapters/bun/server-lifecycle.js +0 -120
  209. package/src/adapters/index.d.ts +0 -6
  210. package/src/adapters/index.js +0 -14
  211. package/src/adapters/node/create-app.d.ts +0 -21
  212. package/src/adapters/node/create-app.js +0 -143
  213. package/src/adapters/node/index.d.ts +0 -4
  214. package/src/adapters/node/index.js +0 -8
  215. package/src/adapters/node/node-client-bridge.d.ts +0 -26
  216. package/src/adapters/node/node-client-bridge.js +0 -66
  217. package/src/adapters/node/node-hmr-manager.d.ts +0 -63
  218. package/src/adapters/node/node-hmr-manager.js +0 -237
  219. package/src/adapters/node/server-adapter.d.ts +0 -190
  220. package/src/adapters/node/server-adapter.js +0 -420
  221. package/src/adapters/node/static-content-server.d.ts +0 -24
  222. package/src/adapters/node/static-content-server.js +0 -166
  223. package/src/adapters/shared/api-response.d.ts +0 -52
  224. package/src/adapters/shared/api-response.js +0 -96
  225. package/src/adapters/shared/application-adapter.d.ts +0 -18
  226. package/src/adapters/shared/application-adapter.js +0 -90
  227. package/src/adapters/shared/explicit-static-route-matcher.d.ts +0 -38
  228. package/src/adapters/shared/explicit-static-route-matcher.js +0 -100
  229. package/src/adapters/shared/file-route-middleware-pipeline.d.ts +0 -65
  230. package/src/adapters/shared/file-route-middleware-pipeline.js +0 -98
  231. package/src/adapters/shared/fs-server-response-factory.d.ts +0 -19
  232. package/src/adapters/shared/fs-server-response-factory.js +0 -97
  233. package/src/adapters/shared/fs-server-response-matcher.d.ts +0 -71
  234. package/src/adapters/shared/fs-server-response-matcher.js +0 -155
  235. package/src/adapters/shared/render-context.d.ts +0 -14
  236. package/src/adapters/shared/render-context.js +0 -69
  237. package/src/adapters/shared/server-adapter.d.ts +0 -87
  238. package/src/adapters/shared/server-adapter.js +0 -353
  239. package/src/adapters/shared/server-route-handler.d.ts +0 -89
  240. package/src/adapters/shared/server-route-handler.js +0 -120
  241. package/src/adapters/shared/server-static-builder.d.ts +0 -38
  242. package/src/adapters/shared/server-static-builder.js +0 -46
  243. package/src/build/build-adapter.d.ts +0 -74
  244. package/src/build/build-adapter.js +0 -54
  245. package/src/build/build-types.d.ts +0 -57
  246. package/src/build/build-types.js +0 -0
  247. package/src/build/esbuild-build-adapter.d.ts +0 -69
  248. package/src/build/esbuild-build-adapter.js +0 -390
  249. package/src/config/config-builder.d.ts +0 -227
  250. package/src/config/config-builder.js +0 -392
  251. package/src/constants.d.ts +0 -32
  252. package/src/constants.js +0 -21
  253. package/src/create-app.d.ts +0 -17
  254. package/src/create-app.js +0 -66
  255. package/src/define-api-handler.d.ts +0 -25
  256. package/src/define-api-handler.js +0 -15
  257. package/src/dev/sc-server.d.ts +0 -30
  258. package/src/dev/sc-server.js +0 -111
  259. package/src/eco/component-render-context.d.ts +0 -105
  260. package/src/eco/component-render-context.js +0 -77
  261. package/src/eco/eco.d.ts +0 -9
  262. package/src/eco/eco.js +0 -110
  263. package/src/eco/eco.types.d.ts +0 -170
  264. package/src/eco/eco.types.js +0 -0
  265. package/src/eco/eco.utils.d.ts +0 -40
  266. package/src/eco/eco.utils.js +0 -40
  267. package/src/eco/global-injector-map.d.ts +0 -16
  268. package/src/eco/global-injector-map.js +0 -80
  269. package/src/eco/lazy-injector-map.d.ts +0 -8
  270. package/src/eco/lazy-injector-map.js +0 -70
  271. package/src/eco/module-dependencies.d.ts +0 -18
  272. package/src/eco/module-dependencies.js +0 -49
  273. package/src/errors/http-error.d.ts +0 -31
  274. package/src/errors/http-error.js +0 -50
  275. package/src/errors/index.d.ts +0 -2
  276. package/src/errors/index.js +0 -4
  277. package/src/errors/locals-access-error.d.ts +0 -4
  278. package/src/errors/locals-access-error.js +0 -9
  279. package/src/global/app-logger.d.ts +0 -2
  280. package/src/global/app-logger.js +0 -6
  281. package/src/hmr/client/hmr-runtime.d.ts +0 -10
  282. package/src/hmr/client/hmr-runtime.js +0 -86
  283. package/src/hmr/hmr-strategy.d.ts +0 -159
  284. package/src/hmr/hmr-strategy.js +0 -29
  285. package/src/hmr/hmr.test.e2e.d.ts +0 -1
  286. package/src/hmr/hmr.test.e2e.js +0 -50
  287. package/src/hmr/strategies/default-hmr-strategy.d.ts +0 -43
  288. package/src/hmr/strategies/default-hmr-strategy.js +0 -34
  289. package/src/hmr/strategies/js-hmr-strategy.d.ts +0 -136
  290. package/src/hmr/strategies/js-hmr-strategy.js +0 -188
  291. package/src/index.browser.d.ts +0 -3
  292. package/src/index.browser.js +0 -4
  293. package/src/index.d.ts +0 -5
  294. package/src/index.js +0 -10
  295. package/src/integrations/ghtml/ghtml-renderer.d.ts +0 -15
  296. package/src/integrations/ghtml/ghtml-renderer.js +0 -60
  297. package/src/integrations/ghtml/ghtml.plugin.d.ts +0 -20
  298. package/src/integrations/ghtml/ghtml.plugin.js +0 -21
  299. package/src/internal-types.d.ts +0 -200
  300. package/src/internal-types.js +0 -0
  301. package/src/plugins/alias-resolver-plugin.d.ts +0 -2
  302. package/src/plugins/alias-resolver-plugin.js +0 -39
  303. package/src/plugins/eco-component-meta-plugin.d.ts +0 -95
  304. package/src/plugins/eco-component-meta-plugin.js +0 -157
  305. package/src/plugins/integration-plugin.d.ts +0 -102
  306. package/src/plugins/integration-plugin.js +0 -100
  307. package/src/plugins/processor.d.ts +0 -82
  308. package/src/plugins/processor.js +0 -122
  309. package/src/public-types.d.ts +0 -1098
  310. package/src/public-types.js +0 -0
  311. package/src/route-renderer/component-graph-executor.d.ts +0 -32
  312. package/src/route-renderer/component-graph-executor.js +0 -31
  313. package/src/route-renderer/component-graph.d.ts +0 -42
  314. package/src/route-renderer/component-graph.js +0 -72
  315. package/src/route-renderer/component-marker.d.ts +0 -52
  316. package/src/route-renderer/component-marker.js +0 -46
  317. package/src/route-renderer/dependency-resolver.d.ts +0 -24
  318. package/src/route-renderer/dependency-resolver.js +0 -428
  319. package/src/route-renderer/html-post-processing.service.d.ts +0 -40
  320. package/src/route-renderer/html-post-processing.service.js +0 -86
  321. package/src/route-renderer/html-post-processing.service.ts +0 -103
  322. package/src/route-renderer/integration-renderer.d.ts +0 -339
  323. package/src/route-renderer/integration-renderer.js +0 -526
  324. package/src/route-renderer/marker-graph-resolver.d.ts +0 -76
  325. package/src/route-renderer/marker-graph-resolver.js +0 -93
  326. package/src/route-renderer/page-module-loader.d.ts +0 -61
  327. package/src/route-renderer/page-module-loader.js +0 -102
  328. package/src/route-renderer/render-execution.service.d.ts +0 -69
  329. package/src/route-renderer/render-execution.service.js +0 -91
  330. package/src/route-renderer/render-preparation.service.d.ts +0 -112
  331. package/src/route-renderer/render-preparation.service.js +0 -243
  332. package/src/route-renderer/route-renderer.d.ts +0 -26
  333. package/src/route-renderer/route-renderer.js +0 -68
  334. package/src/router/fs-router-scanner.d.ts +0 -41
  335. package/src/router/fs-router-scanner.js +0 -155
  336. package/src/router/fs-router.d.ts +0 -26
  337. package/src/router/fs-router.js +0 -100
  338. package/src/services/asset-processing-service/asset-processing.service.d.ts +0 -41
  339. package/src/services/asset-processing-service/asset-processing.service.js +0 -250
  340. package/src/services/asset-processing-service/asset.factory.d.ts +0 -17
  341. package/src/services/asset-processing-service/asset.factory.js +0 -82
  342. package/src/services/asset-processing-service/assets.types.d.ts +0 -88
  343. package/src/services/asset-processing-service/assets.types.js +0 -0
  344. package/src/services/asset-processing-service/index.d.ts +0 -3
  345. package/src/services/asset-processing-service/index.js +0 -3
  346. package/src/services/asset-processing-service/processor.interface.d.ts +0 -22
  347. package/src/services/asset-processing-service/processor.interface.js +0 -6
  348. package/src/services/asset-processing-service/processor.registry.d.ts +0 -8
  349. package/src/services/asset-processing-service/processor.registry.js +0 -15
  350. package/src/services/asset-processing-service/processors/base/base-processor.d.ts +0 -24
  351. package/src/services/asset-processing-service/processors/base/base-processor.js +0 -59
  352. package/src/services/asset-processing-service/processors/base/base-script-processor.d.ts +0 -16
  353. package/src/services/asset-processing-service/processors/base/base-script-processor.js +0 -80
  354. package/src/services/asset-processing-service/processors/index.d.ts +0 -5
  355. package/src/services/asset-processing-service/processors/index.js +0 -5
  356. package/src/services/asset-processing-service/processors/script/content-script.processor.d.ts +0 -5
  357. package/src/services/asset-processing-service/processors/script/content-script.processor.js +0 -57
  358. package/src/services/asset-processing-service/processors/script/file-script.processor.d.ts +0 -8
  359. package/src/services/asset-processing-service/processors/script/file-script.processor.js +0 -76
  360. package/src/services/asset-processing-service/processors/script/node-module-script.processor.d.ts +0 -7
  361. package/src/services/asset-processing-service/processors/script/node-module-script.processor.js +0 -74
  362. package/src/services/asset-processing-service/processors/stylesheet/content-stylesheet.processor.d.ts +0 -5
  363. package/src/services/asset-processing-service/processors/stylesheet/content-stylesheet.processor.js +0 -25
  364. package/src/services/asset-processing-service/processors/stylesheet/file-stylesheet.processor.d.ts +0 -9
  365. package/src/services/asset-processing-service/processors/stylesheet/file-stylesheet.processor.js +0 -63
  366. package/src/services/cache/cache.types.d.ts +0 -107
  367. package/src/services/cache/cache.types.js +0 -0
  368. package/src/services/cache/index.d.ts +0 -7
  369. package/src/services/cache/index.js +0 -7
  370. package/src/services/cache/memory-cache-store.d.ts +0 -42
  371. package/src/services/cache/memory-cache-store.js +0 -98
  372. package/src/services/cache/page-cache-service.d.ts +0 -70
  373. package/src/services/cache/page-cache-service.js +0 -152
  374. package/src/services/html-transformer.service.d.ts +0 -50
  375. package/src/services/html-transformer.service.js +0 -163
  376. package/src/services/html-transformer.service.ts +0 -217
  377. package/src/services/page-module-import.service.d.ts +0 -37
  378. package/src/services/page-module-import.service.js +0 -88
  379. package/src/services/page-module-import.service.ts +0 -129
  380. package/src/services/page-request-cache-coordinator.service.d.ts +0 -75
  381. package/src/services/page-request-cache-coordinator.service.js +0 -107
  382. package/src/services/schema-validation-service.d.ts +0 -122
  383. package/src/services/schema-validation-service.js +0 -101
  384. package/src/services/validation/standard-schema.types.d.ts +0 -65
  385. package/src/services/validation/standard-schema.types.js +0 -0
  386. package/src/static-site-generator/static-site-generator.d.ts +0 -57
  387. package/src/static-site-generator/static-site-generator.js +0 -272
  388. package/src/utils/css.d.ts +0 -1
  389. package/src/utils/css.js +0 -7
  390. package/src/utils/deep-merge.d.ts +0 -14
  391. package/src/utils/deep-merge.js +0 -32
  392. package/src/utils/hash.d.ts +0 -1
  393. package/src/utils/hash.js +0 -7
  394. package/src/utils/html.d.ts +0 -1
  395. package/src/utils/html.js +0 -4
  396. package/src/utils/invariant.d.ts +0 -5
  397. package/src/utils/invariant.js +0 -11
  398. package/src/utils/locals-utils.d.ts +0 -15
  399. package/src/utils/locals-utils.js +0 -24
  400. package/src/utils/parse-cli-args.d.ts +0 -24
  401. package/src/utils/parse-cli-args.js +0 -47
  402. package/src/utils/path-utils.module.d.ts +0 -5
  403. package/src/utils/path-utils.module.js +0 -14
  404. package/src/utils/runtime.d.ts +0 -11
  405. package/src/utils/runtime.js +0 -40
  406. package/src/utils/server-utils.module.d.ts +0 -19
  407. package/src/utils/server-utils.module.js +0 -56
  408. package/src/watchers/project-watcher.d.ts +0 -125
  409. package/src/watchers/project-watcher.js +0 -265
  410. package/src/watchers/project-watcher.test-helpers.d.ts +0 -4
  411. package/src/watchers/project-watcher.test-helpers.js +0 -52
  412. /package/src/route-renderer/{component-graph-executor.ts → component-graph/component-graph-executor.ts} +0 -0
  413. /package/src/route-renderer/{component-graph.ts → component-graph/component-graph.ts} +0 -0
  414. /package/src/route-renderer/{component-marker.ts → component-graph/component-marker.ts} +0 -0
  415. /package/src/services/{asset-processing-service → assets/asset-processing-service}/processor.registry.ts +0 -0
  416. /package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/index.ts +0 -0
  417. /package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/content-script.processor.ts +0 -0
  418. /package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/stylesheet/content-stylesheet.processor.ts +0 -0
@@ -0,0 +1,439 @@
1
+ import path from 'node:path';
2
+ import { fileURLToPath } from 'node:url';
3
+ import type { EcoBuildPlugin } from '../../build/build-types.ts';
4
+ import type { EcoPagesAppConfig } from '../../internal-types.ts';
5
+ import {
6
+ createBuildAdapter,
7
+ getAppBuildExecutor,
8
+ type BuildAdapter,
9
+ type BuildExecutor,
10
+ } from '../../build/build-adapter.ts';
11
+ import { createAppBuildExecutor } from '../../build/dev-build-coordinator.ts';
12
+ import { createNodeBootstrapPlugin, getNodeRuntimeNodeModulesDir } from './bootstrap-dependency-resolver.ts';
13
+ import {
14
+ setAppNodeRuntimeManifest,
15
+ type NodeRuntimeManifest,
16
+ } from '../../services/runtime-manifest/node-runtime-manifest.service.ts';
17
+ import { DevelopmentInvalidationService } from '../../services/invalidation/development-invalidation.service.ts';
18
+ import { getAppEntrypointDependencyGraph } from '../../services/runtime-state/entrypoint-dependency-graph.service.ts';
19
+ import { createAliasResolverPlugin } from '../../plugins/alias-resolver-plugin.ts';
20
+ import {
21
+ TranspilerServerLoader,
22
+ type ServerLoaderAppContext,
23
+ } from '../../services/module-loading/server-loader.service.ts';
24
+ import { resolveInternalExecutionDir } from '../../utils/resolve-work-dir.ts';
25
+ import { installAppRuntimeBuildExecutor } from '../../build/runtime-build-executor.ts';
26
+
27
+ /**
28
+ * Host-to-adapter handoff contract for the Node thin-host runtime.
29
+ *
30
+ * @remarks
31
+ * The thin host is responsible only for validating the persisted manifest,
32
+ * capturing process-level launch context, and passing those values into the
33
+ * adapter. All framework bootstrap work begins after this handoff.
34
+ */
35
+ export interface NodeRuntimeStartOptions {
36
+ manifest: NodeRuntimeManifest;
37
+ workingDirectory: string;
38
+ cliArgs: string[];
39
+ }
40
+
41
+ /**
42
+ * Runtime session state produced after the adapter has loaded the app through
43
+ * the framework-owned loader path.
44
+ */
45
+ export interface LoadedAppRuntime {
46
+ manifest: NodeRuntimeManifest;
47
+ workingDirectory: string;
48
+ entryModulePath: string;
49
+ appConfig: EcoPagesAppConfig;
50
+ entryModule: unknown;
51
+ }
52
+
53
+ /**
54
+ * Live Node thin-host runtime session.
55
+ */
56
+ export interface NodeRuntimeSession {
57
+ loadApp(): Promise<LoadedAppRuntime>;
58
+ invalidate(changedFiles: string[]): Promise<void>;
59
+ dispose(): Promise<void>;
60
+ }
61
+
62
+ /**
63
+ * Adapter boundary created by the thin host after manifest validation.
64
+ */
65
+ export interface NodeRuntimeAdapter {
66
+ start(options: NodeRuntimeStartOptions): Promise<NodeRuntimeSession>;
67
+ }
68
+
69
+ const NODE_RUNTIME_CONFIG_OUTDIR = '.node-runtime-config';
70
+ const NODE_RUNTIME_ENTRY_OUTDIR = '.node-runtime-entry';
71
+ const NODE_RUNTIME_BOOTSTRAP_SPLITTING = false;
72
+ const NODE_RUNTIME_CONFIG_NAMESPACE = 'ecopages-runtime-config';
73
+ const NODE_RUNTIME_CONFIG_GLOBAL_KEY = '__ecopagesNodeRuntimeConfig';
74
+ const NODE_HMR_MANAGER_SOURCE_PATH = fileURLToPath(new URL('./node-hmr-manager.ts', import.meta.url));
75
+
76
+ /**
77
+ * Resolves a relative import path to an absolute path given its importer.
78
+ * Returns undefined for bare specifiers or when resolution is not possible.
79
+ */
80
+ function resolveConfigImportPath(importPath: string, importer?: string): string | undefined {
81
+ if (!importPath) {
82
+ return undefined;
83
+ }
84
+
85
+ if (path.isAbsolute(importPath)) {
86
+ return importPath;
87
+ }
88
+
89
+ if (!importPath.startsWith('.')) {
90
+ return undefined;
91
+ }
92
+
93
+ if (!importer) {
94
+ return undefined;
95
+ }
96
+
97
+ return path.resolve(path.dirname(importer), importPath);
98
+ }
99
+
100
+ /**
101
+ * Returns true if the given esbuild resolve args refer to the app's eco.config
102
+ * module, by matching against the absolute config path (with or without
103
+ * extension) or the well-known relative form `./eco.config`.
104
+ */
105
+ function doesImportReferenceConfig(args: { path: string; importer?: string }, configModulePath: string): boolean {
106
+ if (args.path === configModulePath) {
107
+ return true;
108
+ }
109
+
110
+ if (args.path === './eco.config' || args.path === './eco.config.ts') {
111
+ return true;
112
+ }
113
+
114
+ const resolvedImportPath = resolveConfigImportPath(args.path, args.importer);
115
+ if (!resolvedImportPath) {
116
+ return false;
117
+ }
118
+
119
+ if (resolvedImportPath === configModulePath) {
120
+ return true;
121
+ }
122
+
123
+ const configPathWithoutExtension = configModulePath.replace(/\.[cm]?[jt]sx?$/i, '');
124
+ const resolvedPathWithoutExtension = resolvedImportPath.replace(/\.[cm]?[jt]sx?$/i, '');
125
+ return resolvedPathWithoutExtension === configPathWithoutExtension;
126
+ }
127
+
128
+ /**
129
+ * Creates an esbuild plugin that intercepts any import of the app's eco.config
130
+ * module during app-entry transpilation and redirects it to a synthetic module
131
+ * that reads the pre-loaded config from `globalThis`. This prevents eco.config
132
+ * from being re-executed as a side effect of bundling the app-entry module.
133
+ */
134
+ function createRuntimeConfigBridgePlugin(configModulePath: string): EcoBuildPlugin {
135
+ return {
136
+ name: 'node-runtime-config-bridge',
137
+ setup(build) {
138
+ build.onResolve({ filter: /.*/ }, (args) => {
139
+ if (!doesImportReferenceConfig(args, configModulePath)) {
140
+ return undefined;
141
+ }
142
+
143
+ return {
144
+ path: NODE_RUNTIME_CONFIG_GLOBAL_KEY,
145
+ namespace: NODE_RUNTIME_CONFIG_NAMESPACE,
146
+ };
147
+ });
148
+
149
+ build.onLoad({ filter: /.*/, namespace: NODE_RUNTIME_CONFIG_NAMESPACE }, () => {
150
+ return {
151
+ loader: 'js',
152
+ contents: [
153
+ `const key = ${JSON.stringify(NODE_RUNTIME_CONFIG_GLOBAL_KEY)};`,
154
+ 'const appConfig = globalThis[key];',
155
+ 'if (!appConfig) {',
156
+ "throw new Error('Node runtime config bridge expected a loaded app config before app-entry evaluation.');",
157
+ '}',
158
+ 'export default appConfig;',
159
+ ].join('\n'),
160
+ };
161
+ });
162
+ },
163
+ };
164
+ }
165
+
166
+ /**
167
+ * Validates and narrows the persisted Node runtime manifest used by the thin
168
+ * host handoff.
169
+ */
170
+ export function assertNodeRuntimeManifest(manifest: unknown): NodeRuntimeManifest {
171
+ if (!manifest || typeof manifest !== 'object') {
172
+ throw new Error('Invalid Node runtime manifest: expected an object.');
173
+ }
174
+
175
+ const candidate = manifest as Record<string, unknown>;
176
+ const modulePaths = candidate.modulePaths as Record<string, unknown> | undefined;
177
+
178
+ if (candidate.runtime !== 'node') {
179
+ throw new Error('Invalid Node runtime manifest: runtime must be "node".');
180
+ }
181
+
182
+ if (
183
+ typeof candidate.appRootDir !== 'string' ||
184
+ typeof candidate.sourceRootDir !== 'string' ||
185
+ typeof candidate.distDir !== 'string'
186
+ ) {
187
+ throw new Error('Invalid Node runtime manifest: root, source, and dist paths must be strings.');
188
+ }
189
+
190
+ if (!modulePaths || typeof modulePaths.config !== 'string') {
191
+ throw new Error('Invalid Node runtime manifest: modulePaths.config must be present.');
192
+ }
193
+
194
+ return candidate as unknown as NodeRuntimeManifest;
195
+ }
196
+
197
+ /**
198
+ * Resolves the runtime-specific output directory used for bootstrap module
199
+ * transpilation.
200
+ */
201
+ function getRuntimeOutdir(
202
+ manifest: NodeRuntimeManifest,
203
+ kind: typeof NODE_RUNTIME_CONFIG_OUTDIR | typeof NODE_RUNTIME_ENTRY_OUTDIR,
204
+ ): string {
205
+ return path.join(
206
+ resolveInternalExecutionDir({
207
+ rootDir: manifest.appRootDir,
208
+ workDir: manifest.workDir,
209
+ absolutePaths: {
210
+ workDir: manifest.workDir,
211
+ distDir: manifest.distDir,
212
+ },
213
+ }),
214
+ kind,
215
+ );
216
+ }
217
+
218
+ class NodeRuntimeAdapterSession implements NodeRuntimeSession {
219
+ private readonly options: NodeRuntimeStartOptions;
220
+ private readonly serverLoader: TranspilerServerLoader;
221
+ private readonly bootstrapBundlePlugin: EcoBuildPlugin;
222
+ private readonly bootstrapBuildAdapter: BuildAdapter;
223
+ private readonly bootstrapBuildExecutor: BuildExecutor;
224
+ private invalidationService: DevelopmentInvalidationService | null = null;
225
+ private appConfig: EcoPagesAppConfig | null = null;
226
+ private loadedAppRuntime: LoadedAppRuntime | null = null;
227
+
228
+ constructor(options: NodeRuntimeStartOptions) {
229
+ this.options = options;
230
+ this.bootstrapBundlePlugin = createNodeBootstrapPlugin({
231
+ projectDir: options.manifest.appRootDir,
232
+ runtimeNodeModulesDir: getNodeRuntimeNodeModulesDir(options.manifest),
233
+ preserveImportMetaPaths: [
234
+ options.manifest.modulePaths.config,
235
+ ...(options.manifest.modulePaths.entry ? [options.manifest.modulePaths.entry] : []),
236
+ NODE_HMR_MANAGER_SOURCE_PATH,
237
+ ],
238
+ });
239
+ this.bootstrapBuildAdapter = createBuildAdapter();
240
+ this.bootstrapBuildExecutor = createAppBuildExecutor({
241
+ development: false,
242
+ adapter: this.bootstrapBuildAdapter,
243
+ });
244
+ this.serverLoader = new TranspilerServerLoader({
245
+ rootDir: options.manifest.appRootDir,
246
+ getBuildExecutor: () => this.bootstrapBuildExecutor,
247
+ });
248
+ }
249
+
250
+ private isDevelopmentMode(): boolean {
251
+ return this.options.cliArgs.includes('--dev') || process.env.NODE_ENV === 'development';
252
+ }
253
+
254
+ private get manifest(): NodeRuntimeManifest {
255
+ return this.options.manifest;
256
+ }
257
+
258
+ private getEntryModulePath(): string {
259
+ const entryModulePath = this.manifest.modulePaths.entry;
260
+
261
+ if (!entryModulePath) {
262
+ throw new Error(
263
+ 'Invalid Node runtime manifest: modulePaths.entry must be present before the Node thin-host adapter can load the app.',
264
+ );
265
+ }
266
+
267
+ return entryModulePath;
268
+ }
269
+
270
+ private createAppLoaderContext(
271
+ appConfig: EcoPagesAppConfig,
272
+ buildExecutor: BuildExecutor,
273
+ invalidationService: DevelopmentInvalidationService,
274
+ ): ServerLoaderAppContext {
275
+ return {
276
+ rootDir: appConfig.rootDir,
277
+ getBuildExecutor: () => buildExecutor,
278
+ getInvalidationVersion: () => invalidationService.getServerModuleInvalidationVersion(),
279
+ invalidateModules: (changedFiles?: string[]) => invalidationService.invalidateServerModules(changedFiles),
280
+ };
281
+ }
282
+
283
+ /**
284
+ * Installs and returns the app-owned runtime build executor.
285
+ */
286
+ private installAppBuildExecutor(appConfig: EcoPagesAppConfig): BuildExecutor {
287
+ const appBuildExecutor = installAppRuntimeBuildExecutor(appConfig, {
288
+ development: this.isDevelopmentMode(),
289
+ });
290
+ return appBuildExecutor;
291
+ }
292
+
293
+ /**
294
+ * Rebinds app-phase server loading to the installed app-owned executor.
295
+ */
296
+ private bindAppServerLoader(appConfig: EcoPagesAppConfig, buildExecutor: BuildExecutor): void {
297
+ if (!this.invalidationService) {
298
+ throw new Error('Node runtime invalidation service is not initialized.');
299
+ }
300
+
301
+ this.serverLoader.rebindAppContext(
302
+ this.createAppLoaderContext(appConfig, buildExecutor, this.invalidationService),
303
+ );
304
+ }
305
+
306
+ private initializeAppRuntime(appConfig: EcoPagesAppConfig): EcoPagesAppConfig {
307
+ setAppNodeRuntimeManifest(appConfig, this.manifest);
308
+ this.invalidationService = new DevelopmentInvalidationService(appConfig);
309
+ const appBuildExecutor = this.installAppBuildExecutor(appConfig);
310
+ this.bindAppServerLoader(appConfig, appBuildExecutor);
311
+ this.appConfig = appConfig;
312
+ return appConfig;
313
+ }
314
+
315
+ /**
316
+ * Loads and validates the built app config through the framework-owned server
317
+ * loader.
318
+ */
319
+ private async loadAppConfig(): Promise<EcoPagesAppConfig> {
320
+ if (this.appConfig) {
321
+ return this.appConfig;
322
+ }
323
+
324
+ let importedConfigModule;
325
+
326
+ try {
327
+ importedConfigModule = await this.serverLoader.loadConfig<
328
+ | {
329
+ default: EcoPagesAppConfig;
330
+ }
331
+ | EcoPagesAppConfig
332
+ >({
333
+ filePath: this.manifest.modulePaths.config,
334
+ outdir: getRuntimeOutdir(this.manifest, NODE_RUNTIME_CONFIG_OUTDIR),
335
+ splitting: NODE_RUNTIME_BOOTSTRAP_SPLITTING,
336
+ externalPackages: false,
337
+ plugins: [createAliasResolverPlugin(this.manifest.sourceRootDir), this.bootstrapBundlePlugin],
338
+ transpileErrorMessage: (details) => `Failed to transpile Ecopages config module: ${details}`,
339
+ noOutputMessage: (filePath) => `No transpiled output generated for Ecopages config module: ${filePath}`,
340
+ });
341
+ } catch (error) {
342
+ throw new Error(
343
+ `Node thin-host runtime config bootstrap failed: ${error instanceof Error ? error.message : String(error)}`,
344
+ );
345
+ }
346
+
347
+ const exportedConfig = 'default' in importedConfigModule ? importedConfigModule.default : importedConfigModule;
348
+ return this.initializeAppRuntime(exportedConfig);
349
+ }
350
+
351
+ /**
352
+ * Loads the application entry through the framework-owned server loader after
353
+ * config bootstrap has established app-owned runtime/build services.
354
+ */
355
+ async loadApp(): Promise<LoadedAppRuntime> {
356
+ if (this.loadedAppRuntime) {
357
+ return this.loadedAppRuntime;
358
+ }
359
+
360
+ const appConfig = await this.loadAppConfig();
361
+ const entryModulePath = this.getEntryModulePath();
362
+ let loadedEntryModule;
363
+ const runtimeGlobal = globalThis as typeof globalThis & {
364
+ [NODE_RUNTIME_CONFIG_GLOBAL_KEY]?: EcoPagesAppConfig;
365
+ };
366
+
367
+ runtimeGlobal[NODE_RUNTIME_CONFIG_GLOBAL_KEY] = appConfig;
368
+
369
+ try {
370
+ loadedEntryModule = await this.serverLoader.loadApp({
371
+ filePath: entryModulePath,
372
+ outdir: getRuntimeOutdir(this.manifest, NODE_RUNTIME_ENTRY_OUTDIR),
373
+ splitting: NODE_RUNTIME_BOOTSTRAP_SPLITTING,
374
+ externalPackages: false,
375
+ plugins: [
376
+ createRuntimeConfigBridgePlugin(this.manifest.modulePaths.config),
377
+ createAliasResolverPlugin(appConfig.absolutePaths.srcDir),
378
+ this.bootstrapBundlePlugin,
379
+ ],
380
+ transpileErrorMessage: (details) => `Failed to transpile Ecopages app entry module: ${details}`,
381
+ noOutputMessage: (filePath) =>
382
+ `No transpiled output generated for Ecopages app entry module: ${filePath}`,
383
+ });
384
+ } catch (error) {
385
+ throw new Error(
386
+ `Node thin-host runtime app-entry bootstrap failed: ${error instanceof Error ? error.message : String(error)}`,
387
+ );
388
+ } finally {
389
+ delete runtimeGlobal[NODE_RUNTIME_CONFIG_GLOBAL_KEY];
390
+ }
391
+
392
+ this.loadedAppRuntime = {
393
+ manifest: this.manifest,
394
+ workingDirectory: this.options.workingDirectory,
395
+ appConfig,
396
+ entryModulePath,
397
+ entryModule: loadedEntryModule,
398
+ };
399
+
400
+ return this.loadedAppRuntime;
401
+ }
402
+
403
+ /**
404
+ * Invalidates server-loader and app dev-graph state before the next bootstrap
405
+ * cycle.
406
+ */
407
+ async invalidate(_changedFiles: string[]): Promise<void> {
408
+ this.serverLoader.invalidate(_changedFiles);
409
+ if (this.invalidationService) {
410
+ this.invalidationService.resetRuntimeState(_changedFiles);
411
+ }
412
+ this.loadedAppRuntime = null;
413
+ if (this.appConfig) {
414
+ this.bindAppServerLoader(this.appConfig, getAppBuildExecutor(this.appConfig));
415
+ return;
416
+ }
417
+ }
418
+
419
+ /**
420
+ * Disposes loader-owned resources for the current runtime session.
421
+ */
422
+ async dispose(): Promise<void> {
423
+ await this.serverLoader.dispose();
424
+ if (this.appConfig) {
425
+ getAppEntrypointDependencyGraph(this.appConfig).reset();
426
+ }
427
+ this.invalidationService = null;
428
+ }
429
+ }
430
+
431
+ class DefaultNodeRuntimeAdapter implements NodeRuntimeAdapter {
432
+ async start(options: NodeRuntimeStartOptions): Promise<NodeRuntimeSession> {
433
+ return new NodeRuntimeAdapterSession(options);
434
+ }
435
+ }
436
+
437
+ export function createNodeRuntimeAdapter(): NodeRuntimeAdapter {
438
+ return new DefaultNodeRuntimeAdapter();
439
+ }
@@ -1,12 +1,6 @@
1
1
  import { createServer, type IncomingMessage, type Server as NodeHttpServer, type ServerResponse } from 'node:http';
2
- import path from 'node:path';
3
- import { fileSystem } from '@ecopages/file-system';
4
- import { RESOLVED_ASSETS_DIR } from '../../constants.ts';
5
- import { defaultBuildAdapter } from '../../build/build-adapter.ts';
6
- import type { EcoBuildPlugin } from '../../build/build-types.ts';
7
2
  import { appLogger } from '../../global/app-logger.ts';
8
3
  import type { EcoPagesAppConfig } from '../../internal-types.ts';
9
- import { ProjectWatcher } from '../../watchers/project-watcher.ts';
10
4
  import { NodeClientBridge } from './node-client-bridge.ts';
11
5
  import { NodeHmrManager } from './node-hmr-manager.ts';
12
6
  import type { ApiHandler, ErrorHandler, StaticRoute } from '../../public-types.ts';
@@ -15,6 +9,13 @@ import { StaticSiteGenerator } from '../../static-site-generator/static-site-gen
15
9
  import { SharedServerAdapter } from '../shared/server-adapter.ts';
16
10
  import type { ServerAdapterResult } from '../abstract/server-adapter.ts';
17
11
  import { ServerStaticBuilder } from '../shared/server-static-builder.ts';
12
+ import {
13
+ bindSharedRuntimeHmrManager,
14
+ initializeSharedRuntimePlugins,
15
+ installSharedRuntimeBuildExecutor,
16
+ prepareSharedRuntimePublicDir,
17
+ startSharedProjectWatching,
18
+ } from '../shared/runtime-bootstrap.ts';
18
19
 
19
20
  import { NodeStaticContentServer } from './static-content-server.ts';
20
21
 
@@ -83,7 +84,6 @@ export class NodeServerAdapter extends SharedServerAdapter<NodeServerAdapterPara
83
84
  private previewServer: NodeStaticContentServer | null = null;
84
85
  private bridge: NodeClientBridge | null = null;
85
86
  private hmrManager: NodeHmrManager | null = null;
86
- private processorBuildPlugins: EcoBuildPlugin[] = [];
87
87
 
88
88
  constructor(options: NodeServerAdapterParams) {
89
89
  super(options);
@@ -106,96 +106,30 @@ export class NodeServerAdapter extends SharedServerAdapter<NodeServerAdapterPara
106
106
  * processors during their `setup()` calls.
107
107
  */
108
108
  public async initialize(): Promise<void> {
109
- this.setupLoaders();
110
- this.copyPublicDir();
111
- await this.initializePlugins();
112
- await this.initSharedRouter();
113
- this.configureSharedResponseHandlers(this.staticRoutes, this.hmrManager ?? undefined);
109
+ installSharedRuntimeBuildExecutor(this.appConfig, {
110
+ development: this.options?.watch === true,
111
+ });
112
+
113
+ prepareSharedRuntimePublicDir(this.appConfig);
114
+ await initializeSharedRuntimePlugins({
115
+ appConfig: this.appConfig,
116
+ runtimeOrigin: this.runtimeOrigin,
117
+ hmrManager: this.hmrManager ?? undefined,
118
+ });
119
+ await this.initializeSharedRouteHandling({
120
+ staticRoutes: this.staticRoutes,
121
+ hmrManager: this.hmrManager ?? undefined,
122
+ });
114
123
  this.staticSiteGenerator = new StaticSiteGenerator({ appConfig: this.appConfig });
115
124
  this.staticBuilder = new ServerStaticBuilder({
116
125
  appConfig: this.appConfig,
117
126
  staticSiteGenerator: this.staticSiteGenerator,
118
127
  serveOptions: this.serveOptions,
128
+ apiHandlers: this.apiHandlers,
119
129
  });
120
130
  this.initialized = true;
121
131
  }
122
132
 
123
- /**
124
- * Registers every configured file loader as a build plugin on the shared
125
- * `defaultBuildAdapter`.
126
- *
127
- * Loaders are registered on the *shared* adapter (not on a per-build instance)
128
- * because they must be available globally to both the SSR build and any dynamic
129
- * transpile passes that happen outside of a top-level `build()` call (e.g. HMR
130
- * incremental rebuilds).
131
- */
132
- private setupLoaders(): void {
133
- for (const loader of this.appConfig.loaders.values()) {
134
- defaultBuildAdapter.registerPlugin(loader);
135
- }
136
- }
137
-
138
- private copyPublicDir(): void {
139
- const srcPublicDir = path.join(this.appConfig.rootDir, this.appConfig.srcDir, this.appConfig.publicDir);
140
-
141
- if (fileSystem.exists(srcPublicDir)) {
142
- fileSystem.copyDir(srcPublicDir, path.join(this.appConfig.rootDir, this.appConfig.distDir));
143
- }
144
-
145
- fileSystem.ensureDir(path.join(this.appConfig.absolutePaths.distDir, RESOLVED_ASSETS_DIR));
146
- }
147
-
148
- /**
149
- * Sets up all configured processors and integrations in two distinct phases.
150
- *
151
- * **Phase 1 — Processors:**
152
- * Each processor's `setup()` is called first. A processor may expose two
153
- * plugin lists:
154
- * - `plugins` — transform plugins used during SSR rendering (e.g. PostCSS).
155
- * - `buildPlugins` — esbuild plugins used during the client bundle step.
156
- * Both are registered on `defaultBuildAdapter` so later build calls pick them up.
157
- *
158
- * **Phase 2 — Integrations:**
159
- * Integrations receive the fully-resolved app config, the runtime origin, and
160
- * (if already initialised) the HMR manager before their own `setup()` is called.
161
- * This ordering ensures integrations can query config values that processors
162
- * may have mutated during phase 1.
163
- */
164
- private async initializePlugins(): Promise<void> {
165
- const processorBuildPlugins: EcoBuildPlugin[] = [];
166
-
167
- for (const processor of this.appConfig.processors.values()) {
168
- await processor.setup();
169
-
170
- if (processor.plugins) {
171
- for (const plugin of processor.plugins) {
172
- defaultBuildAdapter.registerPlugin(plugin);
173
- }
174
- }
175
- if (processor.buildPlugins) {
176
- processorBuildPlugins.push(...processor.buildPlugins);
177
- for (const plugin of processor.buildPlugins) {
178
- defaultBuildAdapter.registerPlugin(plugin);
179
- }
180
- }
181
- }
182
-
183
- for (const integration of this.appConfig.integrations) {
184
- integration.setConfig(this.appConfig);
185
- integration.setRuntimeOrigin(this.runtimeOrigin);
186
- if (this.hmrManager) {
187
- integration.setHmrManager(this.hmrManager);
188
- }
189
- await integration.setup();
190
-
191
- for (const plugin of integration.plugins) {
192
- defaultBuildAdapter.registerPlugin(plugin);
193
- }
194
- }
195
-
196
- this.processorBuildPlugins = processorBuildPlugins;
197
- }
198
-
199
133
  public getServerOptions(): NodeServeAdapterServerOptions {
200
134
  return {
201
135
  ...this.serveOptions,
@@ -478,8 +412,8 @@ export class NodeServerAdapter extends SharedServerAdapter<NodeServerAdapterPara
478
412
  * broadcast + heartbeat cleanup.
479
413
  * - `NodeHmrManager` watches the filesystem and triggers incremental esbuild
480
414
  * rebuilds, notifying connected clients via the bridge.
481
- * - `ProjectWatcher` listens for route-level file changes and refreshes the
482
- * router and response handlers when pages are added or removed.
415
+ * - Shared watcher bootstrapping listens for route-level file changes and
416
+ * refreshes the router and response handlers when pages are added or removed.
483
417
  *
484
418
  * WebSocket upgrade requests that do not target `/_hmr` are rejected with an
485
419
  * immediate socket destroy to prevent unhandled upgrade leaks.
@@ -509,26 +443,19 @@ export class NodeServerAdapter extends SharedServerAdapter<NodeServerAdapterPara
509
443
  }
510
444
  });
511
445
 
512
- const loaderPlugins = Array.from(this.appConfig.loaders.values());
513
- const hmrBuildPlugins = [...loaderPlugins, ...this.processorBuildPlugins];
514
- this.hmrManager.setPlugins(hmrBuildPlugins);
515
-
516
- for (const integration of this.appConfig.integrations) {
517
- integration.setHmrManager(this.hmrManager);
518
- }
446
+ bindSharedRuntimeHmrManager(this.appConfig, this.hmrManager);
519
447
 
520
448
  this.configureSharedResponseHandlers(this.staticRoutes, this.hmrManager);
521
449
 
522
- const watcher = new ProjectWatcher({
523
- config: this.appConfig,
524
- refreshRouterRoutesCallback: async () => {
525
- await this.initSharedRouter();
526
- this.configureSharedResponseHandlers(this.staticRoutes, this.hmrManager);
527
- },
450
+ await startSharedProjectWatching({
451
+ appConfig: this.appConfig,
452
+ refreshRouterRoutesCallback: this.createSharedWatchRefreshCallback({
453
+ staticRoutes: this.staticRoutes,
454
+ hmrManager: this.hmrManager,
455
+ }),
528
456
  hmrManager: this.hmrManager,
529
457
  bridge: this.bridge,
530
458
  });
531
- await watcher.createWatcherSubscription();
532
459
  }
533
460
 
534
461
  appLogger.debug('Node server adapter initialization completed', {
@@ -0,0 +1,60 @@
1
+ import { afterEach, beforeEach, describe, expect, it } from 'vitest';
2
+ import fs from 'node:fs';
3
+ import os from 'node:os';
4
+ import path from 'node:path';
5
+ import type { AddressInfo } from 'node:net';
6
+ import { NodeStaticContentServer } from './static-content-server.ts';
7
+ import type { EcoPagesAppConfig } from '../../internal-types.ts';
8
+
9
+ const TMP_DIR = path.join(os.tmpdir(), 'node-static-content-server-test');
10
+
11
+ const createAppConfig = (): EcoPagesAppConfig =>
12
+ ({
13
+ rootDir: TMP_DIR,
14
+ distDir: 'dist',
15
+ absolutePaths: {
16
+ distDir: path.join(TMP_DIR, 'dist'),
17
+ workDir: path.join(TMP_DIR, '.eco'),
18
+ } as EcoPagesAppConfig['absolutePaths'],
19
+ }) as EcoPagesAppConfig;
20
+
21
+ describe('NodeStaticContentServer', () => {
22
+ beforeEach(() => {
23
+ fs.rmSync(TMP_DIR, { recursive: true, force: true });
24
+ fs.mkdirSync(path.join(TMP_DIR, 'dist', 'assets', 'pages'), { recursive: true });
25
+ });
26
+
27
+ afterEach(() => {
28
+ fs.rmSync(TMP_DIR, { recursive: true, force: true });
29
+ });
30
+
31
+ it('should serve built CSS assets with the correct content type in preview mode', async () => {
32
+ const distDir = path.join(TMP_DIR, 'dist');
33
+ fs.writeFileSync(
34
+ path.join(distDir, 'api-lab.html'),
35
+ '<html><head><link rel="stylesheet" href="/assets/pages/api-lab.css"></head><body>API Lab</body></html>',
36
+ );
37
+ fs.writeFileSync(path.join(distDir, 'assets', 'pages', 'api-lab.css'), '.api-lab { color: tomato; }');
38
+
39
+ const server = new NodeStaticContentServer({
40
+ appConfig: createAppConfig(),
41
+ options: { hostname: '127.0.0.1', port: 0 },
42
+ });
43
+
44
+ const httpServer = await server.start();
45
+ const address = httpServer.address() as AddressInfo;
46
+
47
+ try {
48
+ const htmlResponse = await fetch(`http://127.0.0.1:${address.port}/api-lab`);
49
+ const cssResponse = await fetch(`http://127.0.0.1:${address.port}/assets/pages/api-lab.css`);
50
+
51
+ expect(htmlResponse.status).toBe(200);
52
+ expect(await htmlResponse.text()).toContain('/assets/pages/api-lab.css');
53
+ expect(cssResponse.status).toBe(200);
54
+ expect(cssResponse.headers.get('content-type')).toContain('text/css');
55
+ expect(await cssResponse.text()).toContain('.api-lab { color: tomato; }');
56
+ } finally {
57
+ await server.stop();
58
+ }
59
+ });
60
+ });