@ecopages/core 0.2.0-alpha.22 → 0.2.0-alpha.24

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 (515) hide show
  1. package/package.json +93 -226
  2. package/src/adapters/abstract/application-adapter.test.ts +172 -0
  3. package/src/adapters/abstract/application-adapter.ts +379 -0
  4. package/src/adapters/abstract/router-adapter.ts +30 -0
  5. package/src/adapters/abstract/server-adapter.ts +79 -0
  6. package/src/adapters/bun/client-bridge.ts +62 -0
  7. package/src/adapters/bun/create-app.ts +180 -0
  8. package/src/adapters/bun/hmr-manager.test.ts +267 -0
  9. package/src/adapters/bun/hmr-manager.ts +406 -0
  10. package/src/adapters/bun/index.ts +2 -0
  11. package/src/adapters/bun/server-adapter.ts +500 -0
  12. package/src/adapters/bun/server-lifecycle.ts +124 -0
  13. package/src/adapters/create-app.test.ts +10 -0
  14. package/src/adapters/create-app.ts +91 -0
  15. package/src/adapters/index.ts +2 -0
  16. package/src/adapters/node/create-app.test.ts +53 -0
  17. package/src/adapters/node/create-app.ts +183 -0
  18. package/src/adapters/node/node-client-bridge.test.ts +198 -0
  19. package/src/adapters/node/node-client-bridge.ts +79 -0
  20. package/src/adapters/node/node-hmr-manager.test.ts +322 -0
  21. package/src/adapters/node/node-hmr-manager.ts +378 -0
  22. package/src/adapters/node/server-adapter.ts +502 -0
  23. package/src/adapters/node/static-content-server.test.ts +60 -0
  24. package/src/adapters/node/static-content-server.ts +239 -0
  25. package/src/adapters/shared/api-response.test.ts +97 -0
  26. package/src/adapters/shared/api-response.ts +104 -0
  27. package/src/adapters/shared/application-adapter.ts +199 -0
  28. package/src/adapters/shared/define-api-handler.ts +66 -0
  29. package/src/adapters/shared/explicit-static-route-matcher.test.ts +381 -0
  30. package/src/adapters/shared/explicit-static-route-matcher.ts +140 -0
  31. package/src/adapters/shared/file-route-middleware-pipeline.test.ts +90 -0
  32. package/src/adapters/shared/file-route-middleware-pipeline.ts +127 -0
  33. package/src/adapters/shared/fs-server-response-factory.test.ts +187 -0
  34. package/src/adapters/shared/fs-server-response-factory.ts +118 -0
  35. package/src/adapters/shared/fs-server-response-matcher.test.ts +285 -0
  36. package/src/adapters/shared/fs-server-response-matcher.ts +189 -0
  37. package/src/adapters/shared/hmr-entrypoint-registrar.ts +149 -0
  38. package/src/adapters/shared/hmr-html-response.ts +52 -0
  39. package/src/adapters/shared/hmr-manager.contract.test.ts +232 -0
  40. package/src/adapters/shared/hmr-manager.dispatch.test.ts +220 -0
  41. package/src/adapters/shared/render-context.test.ts +150 -0
  42. package/src/adapters/shared/render-context.ts +123 -0
  43. package/src/adapters/shared/runtime-bootstrap.ts +79 -0
  44. package/src/adapters/shared/server-adapter.test.ts +77 -0
  45. package/src/adapters/shared/server-adapter.ts +493 -0
  46. package/src/adapters/shared/server-route-handler.test.ts +110 -0
  47. package/src/adapters/shared/server-route-handler.ts +153 -0
  48. package/src/adapters/shared/server-static-builder.test.ts +338 -0
  49. package/src/adapters/shared/server-static-builder.ts +170 -0
  50. package/src/build/build-adapter-serialization.test.ts +281 -0
  51. package/src/build/build-adapter.test.ts +1240 -0
  52. package/src/build/build-adapter.ts +1012 -0
  53. package/src/build/build-manifest.ts +54 -0
  54. package/src/build/build-types.ts +83 -0
  55. package/src/build/dev-build-coordinator.ts +220 -0
  56. package/src/build/esbuild-build-adapter.ts +660 -0
  57. package/src/build/runtime-build-executor.test.ts +81 -0
  58. package/src/build/runtime-build-executor.ts +40 -0
  59. package/src/build/runtime-specifier-alias-plugin.test.ts +67 -0
  60. package/src/build/runtime-specifier-alias-plugin.ts +62 -0
  61. package/src/build/runtime-specifier-aliases.ts +135 -0
  62. package/src/config/config-builder.test.ts +443 -0
  63. package/src/config/config-builder.ts +742 -0
  64. package/src/config/config-builder.typecheck.test.ts +96 -0
  65. package/src/config/{constants.d.ts → constants.ts} +22 -13
  66. package/src/dev/sc-server.ts +143 -0
  67. package/src/eco/eco.browser.test.ts +43 -0
  68. package/src/eco/eco.browser.ts +118 -0
  69. package/src/eco/eco.test.ts +654 -0
  70. package/src/eco/eco.ts +205 -0
  71. package/src/eco/eco.types.ts +221 -0
  72. package/src/eco/eco.utils.test.ts +219 -0
  73. package/src/eco/eco.utils.ts +5 -0
  74. package/src/eco/global-injector-map.test.ts +42 -0
  75. package/src/eco/global-injector-map.ts +112 -0
  76. package/src/eco/lazy-injector-map.test.ts +66 -0
  77. package/src/eco/lazy-injector-map.ts +120 -0
  78. package/src/eco/module-dependencies.test.ts +30 -0
  79. package/src/eco/module-dependencies.ts +75 -0
  80. package/src/errors/http-error.test.ts +134 -0
  81. package/src/errors/http-error.ts +72 -0
  82. package/src/errors/{index.d.ts → index.ts} +2 -2
  83. package/src/errors/locals-access-error.ts +7 -0
  84. package/src/global/app-logger.ts +4 -0
  85. package/src/global/utils.test.ts +12 -0
  86. 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
  87. package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-HMR-Server-Integration-should-load-fixture-app-page-1.png +0 -0
  88. package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-WebSocket-Connection-should-connect-to-correct-HMR-endpoint-1.png +0 -0
  89. package/src/hmr/client/hmr-runtime.ts +160 -0
  90. package/src/hmr/hmr-strategy.test.ts +124 -0
  91. package/src/hmr/hmr-strategy.ts +177 -0
  92. package/src/hmr/hmr.postcss.test.e2e.ts +41 -0
  93. package/src/hmr/hmr.test.e2e.ts +66 -0
  94. package/src/hmr/strategies/default-hmr-strategy.ts +60 -0
  95. package/src/hmr/strategies/js-hmr-strategy.test.ts +335 -0
  96. package/src/hmr/strategies/js-hmr-strategy.ts +320 -0
  97. package/src/index.browser.ts +3 -0
  98. package/src/index.ts +15 -0
  99. package/src/integrations/ghtml/ghtml-renderer.test.ts +253 -0
  100. package/src/integrations/ghtml/ghtml-renderer.ts +97 -0
  101. package/src/integrations/ghtml/ghtml.constants.ts +1 -0
  102. package/src/integrations/ghtml/ghtml.plugin.ts +28 -0
  103. package/src/plugins/alias-resolver-plugin.test.ts +41 -0
  104. package/src/plugins/alias-resolver-plugin.ts +63 -0
  105. package/src/plugins/eco-component-meta-plugin.test.ts +406 -0
  106. package/src/plugins/eco-component-meta-plugin.ts +495 -0
  107. package/src/plugins/foreign-jsx-override-plugin.test.ts +65 -0
  108. package/src/plugins/foreign-jsx-override-plugin.ts +67 -0
  109. package/src/plugins/integration-plugin.test.ts +156 -0
  110. package/src/plugins/integration-plugin.ts +311 -0
  111. package/src/plugins/processor.test.ts +148 -0
  112. package/src/plugins/processor.ts +240 -0
  113. package/src/plugins/{runtime-capability.d.ts → runtime-capability.ts} +8 -3
  114. package/src/plugins/source-transform.test.ts +82 -0
  115. package/src/plugins/source-transform.ts +123 -0
  116. package/src/route-renderer/orchestration/boundary-planning.service.ts +146 -0
  117. package/src/route-renderer/orchestration/component-render-context.ts +318 -0
  118. package/src/route-renderer/orchestration/integration-renderer.test.ts +2088 -0
  119. package/src/route-renderer/orchestration/integration-renderer.ts +1285 -0
  120. package/src/route-renderer/orchestration/page-packaging.service.test.ts +76 -0
  121. package/src/route-renderer/orchestration/page-packaging.service.ts +85 -0
  122. package/src/route-renderer/orchestration/processed-asset-dedupe.ts +25 -0
  123. package/src/route-renderer/orchestration/queued-boundary-runtime.service.test.ts +319 -0
  124. package/src/route-renderer/orchestration/queued-boundary-runtime.service.ts +289 -0
  125. package/src/route-renderer/orchestration/render-execution.service.test.ts +196 -0
  126. package/src/route-renderer/orchestration/render-execution.service.ts +182 -0
  127. package/src/route-renderer/orchestration/render-output.utils.ts +302 -0
  128. package/src/route-renderer/orchestration/render-preparation.service.test.ts +569 -0
  129. package/src/route-renderer/orchestration/render-preparation.service.ts +508 -0
  130. package/src/route-renderer/orchestration/route-shell-composer.service.ts +162 -0
  131. package/src/route-renderer/orchestration/template-serialization.test.ts +110 -0
  132. package/src/route-renderer/orchestration/template-serialization.ts +117 -0
  133. package/src/route-renderer/page-loading/component-dependency-collection.ts +196 -0
  134. package/src/route-renderer/page-loading/declared-asset-collection.ts +156 -0
  135. package/src/route-renderer/page-loading/dependency-resolver.test.ts +665 -0
  136. package/src/route-renderer/page-loading/dependency-resolver.ts +150 -0
  137. package/src/route-renderer/page-loading/ecopages-virtual-imports.ts +75 -0
  138. package/src/route-renderer/page-loading/lazy-entry-collection.ts +167 -0
  139. package/src/route-renderer/page-loading/lazy-trigger-planning.ts +74 -0
  140. package/src/route-renderer/page-loading/module-declaration-aggregation.ts +60 -0
  141. package/src/route-renderer/page-loading/module-declaration-scripts.ts +16 -0
  142. package/src/route-renderer/page-loading/page-dependency-bundling.ts +205 -0
  143. package/src/route-renderer/page-loading/page-module-loader.test.ts +183 -0
  144. package/src/route-renderer/page-loading/page-module-loader.ts +184 -0
  145. package/src/route-renderer/route-renderer.ts +136 -0
  146. package/src/router/client/link-intent.test.browser.ts +51 -0
  147. package/src/router/client/link-intent.ts +92 -0
  148. package/src/router/client/navigation-coordinator.test.ts +237 -0
  149. package/src/router/client/navigation-coordinator.ts +453 -0
  150. package/src/router/server/fs-router-scanner.test.ts +83 -0
  151. package/src/router/server/fs-router-scanner.ts +224 -0
  152. package/src/router/server/fs-router.test.ts +214 -0
  153. package/src/router/server/fs-router.ts +122 -0
  154. package/src/services/assets/asset-processing-service/asset-dependency-keys.ts +66 -0
  155. package/src/services/assets/asset-processing-service/asset-processing.service.test.ts +476 -0
  156. package/src/services/assets/asset-processing-service/asset-processing.service.ts +345 -0
  157. package/src/services/assets/asset-processing-service/asset.factory.test.ts +63 -0
  158. package/src/services/assets/asset-processing-service/asset.factory.ts +105 -0
  159. package/src/services/assets/asset-processing-service/assets.types.ts +125 -0
  160. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.test.ts +74 -0
  161. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.ts +96 -0
  162. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.test.ts +67 -0
  163. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.ts +78 -0
  164. package/src/services/assets/asset-processing-service/grouped-content-bundles.ts +104 -0
  165. package/src/services/assets/asset-processing-service/index.ts +5 -0
  166. package/src/services/assets/asset-processing-service/{processor.interface.d.ts → processor.interface.ts} +10 -5
  167. package/src/services/assets/asset-processing-service/processor.registry.ts +18 -0
  168. package/src/services/assets/asset-processing-service/processors/base/base-processor.test.ts +59 -0
  169. package/src/services/assets/asset-processing-service/processors/base/base-processor.ts +83 -0
  170. package/src/services/assets/asset-processing-service/processors/base/base-script-processor.ts +174 -0
  171. package/src/services/assets/asset-processing-service/processors/index.ts +5 -0
  172. package/src/services/assets/asset-processing-service/processors/script/content-script.processor.test.ts +192 -0
  173. package/src/services/assets/asset-processing-service/processors/script/content-script.processor.ts +134 -0
  174. package/src/services/assets/asset-processing-service/processors/script/file-script.processor.test.ts +326 -0
  175. package/src/services/assets/asset-processing-service/processors/script/file-script.processor.ts +110 -0
  176. package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.test.ts +227 -0
  177. package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.ts +87 -0
  178. package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.test.ts +261 -0
  179. package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.ts +71 -0
  180. package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.ts +81 -0
  181. package/src/services/assets/asset-processing-service/ungrouped-dependency-processing.ts +65 -0
  182. package/src/services/assets/browser-bundle.service.test.ts +66 -0
  183. package/src/services/assets/browser-bundle.service.ts +109 -0
  184. package/src/services/cache/cache.types.ts +126 -0
  185. package/src/services/cache/index.ts +18 -0
  186. package/src/services/cache/memory-cache-store.test.ts +225 -0
  187. package/src/services/cache/memory-cache-store.ts +130 -0
  188. package/src/services/cache/page-cache-service.test.ts +175 -0
  189. package/src/services/cache/page-cache-service.ts +202 -0
  190. package/src/services/cache/page-request-cache-coordinator.service.test.ts +79 -0
  191. package/src/services/cache/page-request-cache-coordinator.service.ts +131 -0
  192. package/src/services/html/html-rewriter-provider.service.test.ts +183 -0
  193. package/src/services/html/html-rewriter-provider.service.ts +104 -0
  194. package/src/services/html/html-transformer.service.test.ts +479 -0
  195. package/src/services/html/html-transformer.service.ts +275 -0
  196. package/src/services/invalidation/development-invalidation.service.test.ts +87 -0
  197. package/src/services/invalidation/development-invalidation.service.ts +262 -0
  198. package/src/services/module-loading/app-module-loader.service.ts +9 -0
  199. package/src/services/module-loading/app-server-module-transpiler.service.test.ts +130 -0
  200. package/src/services/module-loading/app-server-module-transpiler.service.ts +143 -0
  201. package/src/services/module-loading/host-module-loader-registry.ts +15 -0
  202. package/src/services/module-loading/{module-loading-types.d.ts → module-loading-types.ts} +1 -0
  203. package/src/services/module-loading/node-bootstrap-plugin.test.ts +335 -0
  204. package/src/services/module-loading/node-bootstrap-plugin.ts +297 -0
  205. package/src/services/module-loading/page-module-import.service.test.ts +504 -0
  206. package/src/services/module-loading/page-module-import.service.ts +252 -0
  207. package/src/services/module-loading/server-module-transpiler.service.test.ts +243 -0
  208. package/src/services/module-loading/server-module-transpiler.service.ts +104 -0
  209. package/src/services/module-loading/source-module-support.ts +19 -0
  210. package/src/services/runtime-state/dev-graph.service.ts +217 -0
  211. package/src/services/runtime-state/entrypoint-dependency-graph.service.ts +136 -0
  212. package/src/services/runtime-state/runtime-specifier-registry.service.ts +96 -0
  213. package/src/services/runtime-state/server-invalidation-state.service.ts +68 -0
  214. package/src/services/validation/schema-validation-service.test.ts +223 -0
  215. package/src/services/validation/schema-validation-service.ts +204 -0
  216. package/src/services/validation/{standard-schema.types.d.ts → standard-schema.types.ts} +20 -17
  217. package/src/static-site-generator/static-site-generator.test.ts +316 -0
  218. package/src/static-site-generator/static-site-generator.ts +462 -0
  219. package/src/types/internal-types.ts +242 -0
  220. package/src/types/public-types.ts +1443 -0
  221. package/src/utils/deep-merge.test.ts +114 -0
  222. package/src/utils/deep-merge.ts +47 -0
  223. package/src/utils/hash.ts +5 -0
  224. package/src/utils/html-escaping.ts +9 -0
  225. package/src/utils/invariant.test.ts +22 -0
  226. package/src/utils/invariant.ts +15 -0
  227. package/src/utils/locals-utils.ts +37 -0
  228. package/src/utils/parse-cli-args.test.ts +69 -0
  229. package/src/utils/parse-cli-args.ts +105 -0
  230. package/src/utils/path-utils.module.ts +14 -0
  231. package/src/utils/path-utils.test.ts +15 -0
  232. package/src/utils/resolve-work-dir.ts +45 -0
  233. package/src/utils/runtime.ts +44 -0
  234. package/src/utils/server-utils.module.ts +67 -0
  235. package/src/utils/server-utils.test.ts +38 -0
  236. package/src/watchers/project-watcher.integration.test.ts +337 -0
  237. package/src/watchers/project-watcher.test-helpers.ts +41 -0
  238. package/src/watchers/project-watcher.test.ts +768 -0
  239. package/src/watchers/project-watcher.ts +357 -0
  240. package/CHANGELOG.md +0 -51
  241. package/src/adapters/abstract/application-adapter.d.ts +0 -194
  242. package/src/adapters/abstract/application-adapter.js +0 -121
  243. package/src/adapters/abstract/router-adapter.d.ts +0 -26
  244. package/src/adapters/abstract/router-adapter.js +0 -5
  245. package/src/adapters/abstract/server-adapter.d.ts +0 -69
  246. package/src/adapters/abstract/server-adapter.js +0 -15
  247. package/src/adapters/bun/client-bridge.d.ts +0 -34
  248. package/src/adapters/bun/client-bridge.js +0 -48
  249. package/src/adapters/bun/create-app.d.ts +0 -52
  250. package/src/adapters/bun/create-app.js +0 -116
  251. package/src/adapters/bun/hmr-manager.d.ts +0 -143
  252. package/src/adapters/bun/hmr-manager.js +0 -333
  253. package/src/adapters/bun/index.d.ts +0 -2
  254. package/src/adapters/bun/index.js +0 -8
  255. package/src/adapters/bun/server-adapter.d.ts +0 -155
  256. package/src/adapters/bun/server-adapter.js +0 -374
  257. package/src/adapters/bun/server-lifecycle.d.ts +0 -63
  258. package/src/adapters/bun/server-lifecycle.js +0 -92
  259. package/src/adapters/create-app.d.ts +0 -20
  260. package/src/adapters/create-app.js +0 -66
  261. package/src/adapters/index.d.ts +0 -2
  262. package/src/adapters/index.js +0 -8
  263. package/src/adapters/node/create-app.d.ts +0 -18
  264. package/src/adapters/node/create-app.js +0 -149
  265. package/src/adapters/node/node-client-bridge.d.ts +0 -26
  266. package/src/adapters/node/node-client-bridge.js +0 -66
  267. package/src/adapters/node/node-hmr-manager.d.ts +0 -133
  268. package/src/adapters/node/node-hmr-manager.js +0 -311
  269. package/src/adapters/node/server-adapter.d.ts +0 -161
  270. package/src/adapters/node/server-adapter.js +0 -359
  271. package/src/adapters/node/static-content-server.d.ts +0 -60
  272. package/src/adapters/node/static-content-server.js +0 -194
  273. package/src/adapters/shared/api-response.d.ts +0 -52
  274. package/src/adapters/shared/api-response.js +0 -96
  275. package/src/adapters/shared/application-adapter.d.ts +0 -18
  276. package/src/adapters/shared/application-adapter.js +0 -90
  277. package/src/adapters/shared/define-api-handler.d.ts +0 -25
  278. package/src/adapters/shared/define-api-handler.js +0 -15
  279. package/src/adapters/shared/explicit-static-route-matcher.d.ts +0 -38
  280. package/src/adapters/shared/explicit-static-route-matcher.js +0 -103
  281. package/src/adapters/shared/file-route-middleware-pipeline.d.ts +0 -65
  282. package/src/adapters/shared/file-route-middleware-pipeline.js +0 -99
  283. package/src/adapters/shared/fs-server-response-factory.d.ts +0 -19
  284. package/src/adapters/shared/fs-server-response-factory.js +0 -97
  285. package/src/adapters/shared/fs-server-response-matcher.d.ts +0 -67
  286. package/src/adapters/shared/fs-server-response-matcher.js +0 -147
  287. package/src/adapters/shared/hmr-entrypoint-registrar.d.ts +0 -55
  288. package/src/adapters/shared/hmr-entrypoint-registrar.js +0 -87
  289. package/src/adapters/shared/hmr-html-response.d.ts +0 -22
  290. package/src/adapters/shared/hmr-html-response.js +0 -32
  291. package/src/adapters/shared/render-context.d.ts +0 -15
  292. package/src/adapters/shared/render-context.js +0 -72
  293. package/src/adapters/shared/runtime-bootstrap.d.ts +0 -38
  294. package/src/adapters/shared/runtime-bootstrap.js +0 -43
  295. package/src/adapters/shared/server-adapter.d.ts +0 -97
  296. package/src/adapters/shared/server-adapter.js +0 -390
  297. package/src/adapters/shared/server-route-handler.d.ts +0 -89
  298. package/src/adapters/shared/server-route-handler.js +0 -111
  299. package/src/adapters/shared/server-static-builder.d.ts +0 -70
  300. package/src/adapters/shared/server-static-builder.js +0 -100
  301. package/src/build/build-adapter.d.ts +0 -239
  302. package/src/build/build-adapter.js +0 -642
  303. package/src/build/build-manifest.d.ts +0 -27
  304. package/src/build/build-manifest.js +0 -30
  305. package/src/build/build-types.d.ts +0 -57
  306. package/src/build/build-types.js +0 -0
  307. package/src/build/dev-build-coordinator.d.ts +0 -72
  308. package/src/build/dev-build-coordinator.js +0 -154
  309. package/src/build/esbuild-build-adapter.d.ts +0 -78
  310. package/src/build/esbuild-build-adapter.js +0 -505
  311. package/src/build/runtime-build-executor.d.ts +0 -14
  312. package/src/build/runtime-build-executor.js +0 -22
  313. package/src/build/runtime-specifier-alias-plugin.d.ts +0 -15
  314. package/src/build/runtime-specifier-alias-plugin.js +0 -35
  315. package/src/build/runtime-specifier-aliases.d.ts +0 -5
  316. package/src/build/runtime-specifier-aliases.js +0 -95
  317. package/src/config/config-builder.d.ts +0 -252
  318. package/src/config/config-builder.js +0 -603
  319. package/src/config/constants.js +0 -25
  320. package/src/dev/sc-server.d.ts +0 -30
  321. package/src/dev/sc-server.js +0 -111
  322. package/src/eco/eco.browser.d.ts +0 -2
  323. package/src/eco/eco.browser.js +0 -83
  324. package/src/eco/eco.d.ts +0 -9
  325. package/src/eco/eco.js +0 -85
  326. package/src/eco/eco.types.d.ts +0 -178
  327. package/src/eco/eco.types.js +0 -0
  328. package/src/eco/eco.utils.d.ts +0 -1
  329. package/src/eco/eco.utils.js +0 -10
  330. package/src/eco/global-injector-map.d.ts +0 -16
  331. package/src/eco/global-injector-map.js +0 -80
  332. package/src/eco/lazy-injector-map.d.ts +0 -8
  333. package/src/eco/lazy-injector-map.js +0 -70
  334. package/src/eco/module-dependencies.d.ts +0 -18
  335. package/src/eco/module-dependencies.js +0 -49
  336. package/src/errors/http-error.d.ts +0 -31
  337. package/src/errors/http-error.js +0 -50
  338. package/src/errors/index.js +0 -4
  339. package/src/errors/locals-access-error.d.ts +0 -4
  340. package/src/errors/locals-access-error.js +0 -9
  341. package/src/global/app-logger.d.ts +0 -2
  342. package/src/global/app-logger.js +0 -6
  343. package/src/hmr/client/hmr-runtime.d.ts +0 -5
  344. package/src/hmr/client/hmr-runtime.js +0 -109
  345. package/src/hmr/hmr-strategy.d.ts +0 -162
  346. package/src/hmr/hmr-strategy.js +0 -44
  347. package/src/hmr/hmr.postcss.test.e2e.d.ts +0 -1
  348. package/src/hmr/hmr.postcss.test.e2e.js +0 -31
  349. package/src/hmr/hmr.test.e2e.d.ts +0 -1
  350. package/src/hmr/hmr.test.e2e.js +0 -43
  351. package/src/hmr/strategies/default-hmr-strategy.d.ts +0 -43
  352. package/src/hmr/strategies/default-hmr-strategy.js +0 -34
  353. package/src/hmr/strategies/js-hmr-strategy.d.ts +0 -139
  354. package/src/hmr/strategies/js-hmr-strategy.js +0 -178
  355. package/src/index.browser.d.ts +0 -3
  356. package/src/index.browser.js +0 -4
  357. package/src/index.d.ts +0 -6
  358. package/src/index.js +0 -21
  359. package/src/integrations/ghtml/ghtml-renderer.d.ts +0 -20
  360. package/src/integrations/ghtml/ghtml-renderer.js +0 -63
  361. package/src/integrations/ghtml/ghtml.constants.d.ts +0 -1
  362. package/src/integrations/ghtml/ghtml.constants.js +0 -4
  363. package/src/integrations/ghtml/ghtml.plugin.d.ts +0 -16
  364. package/src/integrations/ghtml/ghtml.plugin.js +0 -20
  365. package/src/plugins/alias-resolver-plugin.d.ts +0 -2
  366. package/src/plugins/alias-resolver-plugin.js +0 -53
  367. package/src/plugins/eco-component-meta-plugin.d.ts +0 -108
  368. package/src/plugins/eco-component-meta-plugin.js +0 -163
  369. package/src/plugins/foreign-jsx-override-plugin.d.ts +0 -31
  370. package/src/plugins/foreign-jsx-override-plugin.js +0 -35
  371. package/src/plugins/integration-plugin.d.ts +0 -219
  372. package/src/plugins/integration-plugin.js +0 -196
  373. package/src/plugins/processor.d.ts +0 -95
  374. package/src/plugins/processor.js +0 -136
  375. package/src/plugins/runtime-capability.js +0 -0
  376. package/src/plugins/source-transform.d.ts +0 -46
  377. package/src/plugins/source-transform.js +0 -71
  378. package/src/route-renderer/orchestration/boundary-planning.service.d.ts +0 -25
  379. package/src/route-renderer/orchestration/boundary-planning.service.js +0 -97
  380. package/src/route-renderer/orchestration/component-render-context.d.ts +0 -83
  381. package/src/route-renderer/orchestration/component-render-context.js +0 -147
  382. package/src/route-renderer/orchestration/integration-renderer.d.ts +0 -554
  383. package/src/route-renderer/orchestration/integration-renderer.js +0 -957
  384. package/src/route-renderer/orchestration/queued-boundary-runtime.service.d.ts +0 -89
  385. package/src/route-renderer/orchestration/queued-boundary-runtime.service.js +0 -155
  386. package/src/route-renderer/orchestration/render-execution.service.d.ts +0 -43
  387. package/src/route-renderer/orchestration/render-execution.service.js +0 -106
  388. package/src/route-renderer/orchestration/render-output.utils.d.ts +0 -46
  389. package/src/route-renderer/orchestration/render-output.utils.js +0 -65
  390. package/src/route-renderer/orchestration/render-preparation.service.d.ts +0 -120
  391. package/src/route-renderer/orchestration/render-preparation.service.js +0 -341
  392. package/src/route-renderer/orchestration/route-shell-composer.service.d.ts +0 -50
  393. package/src/route-renderer/orchestration/route-shell-composer.service.js +0 -81
  394. package/src/route-renderer/orchestration/template-serialization.d.ts +0 -38
  395. package/src/route-renderer/orchestration/template-serialization.js +0 -45
  396. package/src/route-renderer/page-loading/dependency-resolver.d.ts +0 -35
  397. package/src/route-renderer/page-loading/dependency-resolver.js +0 -444
  398. package/src/route-renderer/page-loading/page-module-loader.d.ts +0 -90
  399. package/src/route-renderer/page-loading/page-module-loader.js +0 -127
  400. package/src/route-renderer/route-renderer.d.ts +0 -67
  401. package/src/route-renderer/route-renderer.js +0 -103
  402. package/src/router/client/link-intent.js +0 -34
  403. package/src/router/client/link-intent.test.browser.d.ts +0 -1
  404. package/src/router/client/link-intent.test.browser.js +0 -43
  405. package/src/router/client/navigation-coordinator.d.ts +0 -149
  406. package/src/router/client/navigation-coordinator.js +0 -215
  407. package/src/router/server/fs-router-scanner.d.ts +0 -41
  408. package/src/router/server/fs-router-scanner.js +0 -161
  409. package/src/router/server/fs-router.d.ts +0 -26
  410. package/src/router/server/fs-router.js +0 -100
  411. package/src/services/assets/asset-processing-service/asset-processing.service.d.ts +0 -120
  412. package/src/services/assets/asset-processing-service/asset-processing.service.js +0 -331
  413. package/src/services/assets/asset-processing-service/asset.factory.d.ts +0 -17
  414. package/src/services/assets/asset-processing-service/asset.factory.js +0 -82
  415. package/src/services/assets/asset-processing-service/assets.types.d.ts +0 -89
  416. package/src/services/assets/asset-processing-service/assets.types.js +0 -0
  417. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.d.ts +0 -55
  418. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.js +0 -48
  419. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.d.ts +0 -20
  420. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.js +0 -41
  421. package/src/services/assets/asset-processing-service/index.d.ts +0 -5
  422. package/src/services/assets/asset-processing-service/index.js +0 -5
  423. package/src/services/assets/asset-processing-service/processor.interface.js +0 -6
  424. package/src/services/assets/asset-processing-service/processor.registry.d.ts +0 -8
  425. package/src/services/assets/asset-processing-service/processor.registry.js +0 -15
  426. package/src/services/assets/asset-processing-service/processors/base/base-processor.d.ts +0 -24
  427. package/src/services/assets/asset-processing-service/processors/base/base-processor.js +0 -64
  428. package/src/services/assets/asset-processing-service/processors/base/base-script-processor.d.ts +0 -17
  429. package/src/services/assets/asset-processing-service/processors/base/base-script-processor.js +0 -72
  430. package/src/services/assets/asset-processing-service/processors/index.d.ts +0 -5
  431. package/src/services/assets/asset-processing-service/processors/index.js +0 -5
  432. package/src/services/assets/asset-processing-service/processors/script/content-script.processor.d.ts +0 -5
  433. package/src/services/assets/asset-processing-service/processors/script/content-script.processor.js +0 -57
  434. package/src/services/assets/asset-processing-service/processors/script/file-script.processor.d.ts +0 -9
  435. package/src/services/assets/asset-processing-service/processors/script/file-script.processor.js +0 -88
  436. package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.d.ts +0 -7
  437. package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.js +0 -75
  438. package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.d.ts +0 -5
  439. package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.js +0 -25
  440. package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.d.ts +0 -9
  441. package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.js +0 -66
  442. package/src/services/assets/browser-bundle.service.d.ts +0 -32
  443. package/src/services/assets/browser-bundle.service.js +0 -33
  444. package/src/services/cache/cache.types.d.ts +0 -107
  445. package/src/services/cache/cache.types.js +0 -0
  446. package/src/services/cache/index.d.ts +0 -7
  447. package/src/services/cache/index.js +0 -7
  448. package/src/services/cache/memory-cache-store.d.ts +0 -42
  449. package/src/services/cache/memory-cache-store.js +0 -98
  450. package/src/services/cache/page-cache-service.d.ts +0 -70
  451. package/src/services/cache/page-cache-service.js +0 -152
  452. package/src/services/cache/page-request-cache-coordinator.service.d.ts +0 -75
  453. package/src/services/cache/page-request-cache-coordinator.service.js +0 -109
  454. package/src/services/html/html-rewriter-provider.service.d.ts +0 -37
  455. package/src/services/html/html-rewriter-provider.service.js +0 -68
  456. package/src/services/html/html-transformer.service.d.ts +0 -77
  457. package/src/services/html/html-transformer.service.js +0 -215
  458. package/src/services/invalidation/development-invalidation.service.d.ts +0 -74
  459. package/src/services/invalidation/development-invalidation.service.js +0 -190
  460. package/src/services/module-loading/app-module-loader.service.d.ts +0 -28
  461. package/src/services/module-loading/app-module-loader.service.js +0 -35
  462. package/src/services/module-loading/app-server-module-transpiler.service.d.ts +0 -24
  463. package/src/services/module-loading/app-server-module-transpiler.service.js +0 -109
  464. package/src/services/module-loading/host-module-loader-registry.d.ts +0 -4
  465. package/src/services/module-loading/host-module-loader-registry.js +0 -15
  466. package/src/services/module-loading/module-loading-types.js +0 -0
  467. package/src/services/module-loading/node-bootstrap-plugin.d.ts +0 -42
  468. package/src/services/module-loading/node-bootstrap-plugin.js +0 -204
  469. package/src/services/module-loading/page-module-import.service.d.ts +0 -76
  470. package/src/services/module-loading/page-module-import.service.js +0 -173
  471. package/src/services/module-loading/server-module-transpiler.service.d.ts +0 -72
  472. package/src/services/module-loading/server-module-transpiler.service.js +0 -64
  473. package/src/services/runtime-state/dev-graph.service.d.ts +0 -118
  474. package/src/services/runtime-state/dev-graph.service.js +0 -162
  475. package/src/services/runtime-state/entrypoint-dependency-graph.service.d.ts +0 -41
  476. package/src/services/runtime-state/entrypoint-dependency-graph.service.js +0 -85
  477. package/src/services/runtime-state/runtime-specifier-registry.service.d.ts +0 -69
  478. package/src/services/runtime-state/runtime-specifier-registry.service.js +0 -37
  479. package/src/services/runtime-state/server-invalidation-state.service.d.ts +0 -26
  480. package/src/services/runtime-state/server-invalidation-state.service.js +0 -35
  481. package/src/services/validation/schema-validation-service.d.ts +0 -122
  482. package/src/services/validation/schema-validation-service.js +0 -101
  483. package/src/services/validation/standard-schema.types.js +0 -0
  484. package/src/static-site-generator/static-site-generator.d.ts +0 -104
  485. package/src/static-site-generator/static-site-generator.js +0 -338
  486. package/src/types/internal-types.d.ts +0 -231
  487. package/src/types/internal-types.js +0 -0
  488. package/src/types/public-types.d.ts +0 -1219
  489. package/src/types/public-types.js +0 -0
  490. package/src/utils/deep-merge.d.ts +0 -14
  491. package/src/utils/deep-merge.js +0 -32
  492. package/src/utils/hash.d.ts +0 -1
  493. package/src/utils/hash.js +0 -7
  494. package/src/utils/html-escaping.d.ts +0 -7
  495. package/src/utils/html-escaping.js +0 -6
  496. package/src/utils/html.js +0 -4
  497. package/src/utils/invariant.d.ts +0 -5
  498. package/src/utils/invariant.js +0 -11
  499. package/src/utils/locals-utils.d.ts +0 -15
  500. package/src/utils/locals-utils.js +0 -24
  501. package/src/utils/parse-cli-args.d.ts +0 -27
  502. package/src/utils/parse-cli-args.js +0 -62
  503. package/src/utils/path-utils.module.d.ts +0 -5
  504. package/src/utils/path-utils.module.js +0 -14
  505. package/src/utils/resolve-work-dir.d.ts +0 -11
  506. package/src/utils/resolve-work-dir.js +0 -31
  507. package/src/utils/runtime.d.ts +0 -11
  508. package/src/utils/runtime.js +0 -40
  509. package/src/utils/server-utils.module.d.ts +0 -19
  510. package/src/utils/server-utils.module.js +0 -56
  511. package/src/watchers/project-watcher.d.ts +0 -136
  512. package/src/watchers/project-watcher.js +0 -275
  513. package/src/watchers/project-watcher.test-helpers.d.ts +0 -4
  514. package/src/watchers/project-watcher.test-helpers.js +0 -52
  515. /package/src/utils/{html.d.ts → html.ts} +0 -0
@@ -0,0 +1,462 @@
1
+ import path from 'node:path';
2
+ import { appLogger } from '../global/app-logger.ts';
3
+ import type { EcoPagesAppConfig } from '../types/internal-types.ts';
4
+ import type { EcoPageComponent, StaticRoute } from '../types/public-types.ts';
5
+ import type { RouteRendererFactory } from '../route-renderer/route-renderer.ts';
6
+ import type { FSRouter } from '../router/server/fs-router.ts';
7
+ import { fileSystem } from '@ecopages/file-system';
8
+ import { PathUtils } from '../utils/path-utils.module.ts';
9
+
10
+ export const STATIC_SITE_GENERATOR_ERRORS = {
11
+ ROUTE_RENDERER_FACTORY_REQUIRED: 'RouteRendererFactory is required for render strategy',
12
+ unsupportedBodyType: (bodyType: string) => `Unsupported body type for static generation: ${bodyType}`,
13
+ missingIntegration: (routePath: string) =>
14
+ `View at ${routePath} is missing __eco.integration. Ensure it's defined with eco.page().`,
15
+ noRendererForIntegration: (integrationName: string) => `No renderer found for integration: ${integrationName}`,
16
+ dynamicRouteRequiresStaticPaths: (routePath: string) =>
17
+ `Dynamic route ${routePath} requires staticPaths to be defined on the view.`,
18
+ } as const;
19
+
20
+ /**
21
+ * Generates static output files from the finalized app config and route graph.
22
+ *
23
+ * @remarks
24
+ * This class intentionally reuses the same routing, renderer, and server-module
25
+ * loading seams used by runtime rendering. Static generation should be a build
26
+ * loop over the normal app model, not a parallel rendering stack with different
27
+ * semantics.
28
+ */
29
+ export class StaticSiteGenerator {
30
+ appConfig: EcoPagesAppConfig;
31
+
32
+ /**
33
+ * Creates the static-site generator for one app config.
34
+ */
35
+ constructor({ appConfig }: { appConfig: EcoPagesAppConfig }) {
36
+ this.appConfig = appConfig;
37
+ }
38
+
39
+ private getExportDir(): string {
40
+ return this.appConfig.absolutePaths?.distDir ?? path.join(this.appConfig.rootDir, this.appConfig.distDir);
41
+ }
42
+
43
+ /**
44
+ * Logs the standardized warning emitted when a dynamic-cache page is skipped.
45
+ */
46
+ private warnDynamicPageSkipped(filePath: string): void {
47
+ appLogger.warn(
48
+ "Pages with cache: 'dynamic' are not supported in static generation or preview, so they will be skipped\n",
49
+ `➤ ${filePath}`,
50
+ );
51
+ }
52
+
53
+ /**
54
+ * Determines whether one filesystem-discovered page should be excluded from
55
+ * static generation.
56
+ */
57
+ private async shouldSkipStaticPageFile(
58
+ filePath: string,
59
+ routeRendererFactory: RouteRendererFactory,
60
+ ): Promise<boolean> {
61
+ const module = (await routeRendererFactory.createRenderer(filePath).loadPageModule(filePath, {
62
+ cacheScope: 'static-page-probe',
63
+ })) as {
64
+ default?: EcoPageComponent<any>;
65
+ };
66
+
67
+ if (module.default?.cache !== 'dynamic') {
68
+ return false;
69
+ }
70
+
71
+ this.warnDynamicPageSkipped(filePath);
72
+ return true;
73
+ }
74
+
75
+ /**
76
+ * Determines whether one explicit static route view should be excluded from
77
+ * static generation.
78
+ */
79
+ private shouldSkipStaticView(routePath: string, view: EcoPageComponent<any>): boolean {
80
+ if (view.cache !== 'dynamic') {
81
+ return false;
82
+ }
83
+
84
+ this.warnDynamicPageSkipped(routePath);
85
+ return true;
86
+ }
87
+
88
+ /**
89
+ * Writes the robots.txt file declared by the app config.
90
+ */
91
+ generateRobotsTxt(): void {
92
+ let data = '';
93
+ const preferences = this.appConfig.robotsTxt.preferences;
94
+
95
+ for (const userAgent in preferences) {
96
+ data += `user-agent: ${userAgent}\n`;
97
+ for (const path of preferences[userAgent]) {
98
+ data += `disallow: ${path}\n`;
99
+ }
100
+ data += '\n';
101
+ }
102
+
103
+ fileSystem.ensureDir(this.getExportDir());
104
+ fileSystem.write(path.join(this.getExportDir(), 'robots.txt'), data);
105
+ }
106
+
107
+ /**
108
+ * Returns whether the input path points at the root directory.
109
+ */
110
+ isRootDir(path: string) {
111
+ const slashes = path.match(/\//g);
112
+ return slashes && slashes.length === 1;
113
+ }
114
+
115
+ /**
116
+ * Collects parent directories that must exist for the generated route set.
117
+ */
118
+ getDirectories(routes: string[]) {
119
+ const directories = new Set<string>();
120
+
121
+ for (const route of routes) {
122
+ const path = route.startsWith('http') ? new URL(route).pathname : route;
123
+
124
+ const segments = path.split('/');
125
+
126
+ if (segments.length > 2) {
127
+ directories.add(segments.slice(0, segments.length - 1).join('/'));
128
+ }
129
+ }
130
+
131
+ return Array.from(directories);
132
+ }
133
+
134
+ /**
135
+ * Extracts dynamic parameters from the actual path based on the template path.
136
+ *
137
+ * @param templatePath - The template path (e.g., "/blog/[slug]")
138
+ * @param actualPath - The actual path (e.g., "/blog/my-post")
139
+ * @returns A record of extracted parameters (e.g., { slug: "my-post" })
140
+ */
141
+ private extractParams(templatePath: string, actualPath: string): Record<string, string> {
142
+ const templateSegments = templateSegmentsFromPath(templatePath);
143
+ const actualSegments = templateSegmentsFromPath(actualPath);
144
+ const params: Record<string, string> = {};
145
+
146
+ for (let i = 0; i < templateSegments.length; i++) {
147
+ const segment = templateSegments[i];
148
+ if (segment.startsWith('[') && segment.endsWith(']')) {
149
+ const paramName = segment.slice(1, -1).replace('...', '');
150
+ params[paramName] = actualSegments[i];
151
+ }
152
+ }
153
+
154
+ return params;
155
+ }
156
+
157
+ /**
158
+ * Generates static output for all filesystem-discovered routes.
159
+ *
160
+ * @remarks
161
+ * Routes whose integrations opt into fetch-based static builds are rendered by
162
+ * issuing a request against the running server origin. Render-strategy routes
163
+ * go through the normal route renderer directly.
164
+ */
165
+ async generateStaticPages(router: FSRouter, baseUrl: string, routeRendererFactory?: RouteRendererFactory) {
166
+ const routes = Object.keys(router.routes).filter((route) => !route.includes('['));
167
+
168
+ appLogger.debug('Static Pages', routes);
169
+
170
+ const directories = this.getDirectories(routes);
171
+
172
+ for (const directory of directories) {
173
+ fileSystem.ensureDir(path.join(this.getExportDir(), directory));
174
+ }
175
+
176
+ for (const route of routes) {
177
+ try {
178
+ const { filePath, pathname: routePathname } = router.routes[route];
179
+
180
+ const ext = PathUtils.getEcoTemplateExtension(filePath);
181
+ const integration = this.appConfig.integrations.find((plugin) => plugin.extensions.includes(ext));
182
+ const strategy = integration?.staticBuildStep || 'render';
183
+
184
+ let contents: string | Buffer;
185
+
186
+ if (strategy === 'fetch') {
187
+ const fetchUrl = this.resolveStaticFetchUrl(route, baseUrl);
188
+ const response = await fetch(fetchUrl);
189
+
190
+ if (!response.ok) {
191
+ appLogger.error(`Failed to fetch ${fetchUrl}. Status: ${response.status}`);
192
+ continue;
193
+ }
194
+ contents = await response.text();
195
+ } else {
196
+ if (!routeRendererFactory) {
197
+ throw new Error(STATIC_SITE_GENERATOR_ERRORS.ROUTE_RENDERER_FACTORY_REQUIRED);
198
+ }
199
+
200
+ if (await this.shouldSkipStaticPageFile(filePath, routeRendererFactory)) {
201
+ continue;
202
+ }
203
+
204
+ let pathname = routePathname;
205
+ const pathnameSegments = pathname.split('/').filter(Boolean);
206
+
207
+ if (pathname === '/') {
208
+ pathname = '/index.html';
209
+ } else if (pathnameSegments.join('/').includes('[')) {
210
+ pathname = `${route.replace(router.origin, '')}.html`;
211
+ } else if (pathnameSegments.length >= 1 && directories.includes(`/${pathnameSegments.join('/')}`)) {
212
+ pathname = `${pathname.endsWith('/') ? pathname : `${pathname}/`}index.html`;
213
+ } else {
214
+ pathname += '.html';
215
+ }
216
+
217
+ const renderer = routeRendererFactory.createRenderer(filePath);
218
+ const params = this.extractParams(routePathname, pathname.replace('.html', ''));
219
+
220
+ const result = await renderer.createRoute({
221
+ file: filePath,
222
+ params,
223
+ });
224
+
225
+ const body = result.body;
226
+
227
+ if (typeof body === 'string' || Buffer.isBuffer(body)) {
228
+ contents = body;
229
+ } else if (body instanceof ReadableStream) {
230
+ contents = await new Response(body).text();
231
+ } else {
232
+ throw new Error(STATIC_SITE_GENERATOR_ERRORS.unsupportedBodyType(typeof body));
233
+ }
234
+ }
235
+
236
+ let pathname = routePathname;
237
+ const pathnameSegments = pathname.split('/').filter(Boolean);
238
+
239
+ if (pathname === '/') {
240
+ pathname = '/index.html';
241
+ } else if (pathnameSegments.join('/').includes('[')) {
242
+ pathname = `${route.replace(router.origin, '')}.html`;
243
+ } else if (pathnameSegments.length >= 1 && directories.includes(`/${pathnameSegments.join('/')}`)) {
244
+ pathname = `${pathname.endsWith('/') ? pathname : `${pathname}/`}index.html`;
245
+ } else {
246
+ pathname += '.html';
247
+ }
248
+
249
+ const outputPath = path.join(this.getExportDir(), pathname);
250
+ fileSystem.write(outputPath, contents);
251
+ } catch (error) {
252
+ appLogger.error(
253
+ `Error generating static page for ${route}:`,
254
+ error instanceof Error ? error : String(error),
255
+ );
256
+ }
257
+ }
258
+ }
259
+
260
+ private resolveStaticFetchUrl(route: string, baseUrl: string): string {
261
+ if (!route.startsWith('http://') && !route.startsWith('https://')) {
262
+ return `${baseUrl}${route}`;
263
+ }
264
+
265
+ const targetUrl = new URL(route);
266
+ const buildUrl = new URL(baseUrl);
267
+ buildUrl.pathname = targetUrl.pathname;
268
+ buildUrl.search = targetUrl.search;
269
+ buildUrl.hash = targetUrl.hash;
270
+
271
+ return buildUrl.href;
272
+ }
273
+
274
+ /**
275
+ * Executes the full static-generation workflow for one app run.
276
+ */
277
+ async run({
278
+ router,
279
+ baseUrl,
280
+ routeRendererFactory,
281
+ staticRoutes,
282
+ }: {
283
+ router: FSRouter;
284
+ baseUrl: string;
285
+ routeRendererFactory?: RouteRendererFactory;
286
+ staticRoutes?: StaticRoute[];
287
+ }) {
288
+ this.generateRobotsTxt();
289
+ await this.generateStaticPages(router, baseUrl, routeRendererFactory);
290
+
291
+ if (staticRoutes && staticRoutes.length > 0 && routeRendererFactory) {
292
+ await this.generateExplicitStaticPages(staticRoutes, routeRendererFactory);
293
+ }
294
+ }
295
+
296
+ /**
297
+ * Generates static pages from explicit static routes registered via app.static().
298
+ * These routes use eco.page views via loader functions for HMR support.
299
+ */
300
+ private async generateExplicitStaticPages(
301
+ staticRoutes: StaticRoute[],
302
+ routeRendererFactory: RouteRendererFactory,
303
+ ): Promise<void> {
304
+ appLogger.debug(
305
+ 'Generating explicit static routes',
306
+ staticRoutes.map((r) => r.path),
307
+ );
308
+
309
+ for (const route of staticRoutes) {
310
+ try {
311
+ const mod = await route.loader();
312
+ const view = mod.default;
313
+ if (this.shouldSkipStaticView(route.path, view)) {
314
+ continue;
315
+ }
316
+
317
+ const isDynamic = route.path.includes(':') || route.path.includes('[');
318
+
319
+ if (isDynamic) {
320
+ await this.generateDynamicStaticRoute(route.path, view, routeRendererFactory);
321
+ } else {
322
+ await this.generateSingleStaticRoute(route.path, view, routeRendererFactory);
323
+ }
324
+ } catch (error) {
325
+ appLogger.error(
326
+ `Error generating explicit static page for ${route.path}:`,
327
+ error instanceof Error ? error : String(error),
328
+ );
329
+ }
330
+ }
331
+ }
332
+
333
+ /**
334
+ * Generate a single static page for a non-dynamic route.
335
+ */
336
+ private async generateSingleStaticRoute(
337
+ routePath: string,
338
+ view: EcoPageComponent<any>,
339
+ routeRendererFactory: RouteRendererFactory,
340
+ ): Promise<void> {
341
+ const integrationName = view.config?.__eco?.integration;
342
+ if (!integrationName) {
343
+ throw new Error(STATIC_SITE_GENERATOR_ERRORS.missingIntegration(routePath));
344
+ }
345
+
346
+ const renderer = routeRendererFactory.getRendererByIntegration(integrationName);
347
+ if (!renderer) {
348
+ throw new Error(STATIC_SITE_GENERATOR_ERRORS.noRendererForIntegration(integrationName));
349
+ }
350
+
351
+ const props = view.staticProps
352
+ ? (
353
+ await view.staticProps({
354
+ pathname: { params: {} },
355
+ appConfig: this.appConfig,
356
+ runtimeOrigin: this.appConfig.baseUrl,
357
+ })
358
+ ).props
359
+ : {};
360
+
361
+ const response = await renderer.renderToResponse(view, props, {});
362
+ const contents = await response.text();
363
+
364
+ const outputPath = this.getOutputPath(routePath);
365
+ fileSystem.ensureDir(path.dirname(outputPath));
366
+ fileSystem.write(outputPath, contents);
367
+
368
+ appLogger.debug(`Generated static page: ${routePath} -> ${outputPath}`);
369
+ }
370
+
371
+ /**
372
+ * Generate static pages for a dynamic route using staticPaths.
373
+ */
374
+ private async generateDynamicStaticRoute(
375
+ routePath: string,
376
+ view: EcoPageComponent<any>,
377
+ routeRendererFactory: RouteRendererFactory,
378
+ ): Promise<void> {
379
+ if (!view.staticPaths) {
380
+ throw new Error(STATIC_SITE_GENERATOR_ERRORS.dynamicRouteRequiresStaticPaths(routePath));
381
+ }
382
+
383
+ const integrationName = view.config?.__eco?.integration;
384
+ if (!integrationName) {
385
+ throw new Error(STATIC_SITE_GENERATOR_ERRORS.missingIntegration(routePath));
386
+ }
387
+
388
+ const renderer = routeRendererFactory.getRendererByIntegration(integrationName);
389
+ if (!renderer) {
390
+ throw new Error(STATIC_SITE_GENERATOR_ERRORS.noRendererForIntegration(integrationName));
391
+ }
392
+
393
+ const { paths } = await view.staticPaths({
394
+ appConfig: this.appConfig,
395
+ runtimeOrigin: this.appConfig.baseUrl,
396
+ });
397
+
398
+ for (const { params } of paths) {
399
+ const resolvedPath = this.resolveRoutePath(routePath, params);
400
+
401
+ const props = view.staticProps
402
+ ? (
403
+ await view.staticProps({
404
+ pathname: { params },
405
+ appConfig: this.appConfig,
406
+ runtimeOrigin: this.appConfig.baseUrl,
407
+ })
408
+ ).props
409
+ : {};
410
+
411
+ const response = await renderer.renderToResponse(view, props, {});
412
+ const contents = await response.text();
413
+
414
+ const outputPath = this.getOutputPath(resolvedPath);
415
+ fileSystem.ensureDir(path.dirname(outputPath));
416
+ fileSystem.write(outputPath, contents);
417
+
418
+ appLogger.debug(`Generated static page: ${resolvedPath} -> ${outputPath}`);
419
+ }
420
+ }
421
+
422
+ /**
423
+ * Resolve a route path template with actual params.
424
+ * Supports both :param and [param] syntax.
425
+ */
426
+ private resolveRoutePath(routePath: string, params: Record<string, string | string[]>): string {
427
+ let resolved = routePath;
428
+
429
+ for (const [key, value] of Object.entries(params)) {
430
+ const paramValue = Array.isArray(value) ? value.join('/') : value;
431
+ resolved = resolved.replace(`:${key}`, paramValue);
432
+ resolved = resolved.replace(`[${key}]`, paramValue);
433
+ resolved = resolved.replace(`[...${key}]`, paramValue);
434
+ }
435
+
436
+ return resolved;
437
+ }
438
+
439
+ /**
440
+ * Get the output file path for a given route.
441
+ */
442
+ private getOutputPath(routePath: string): string {
443
+ let outputName: string;
444
+
445
+ if (routePath === '/') {
446
+ outputName = 'index.html';
447
+ } else if (routePath.endsWith('/')) {
448
+ outputName = `${routePath}index.html`;
449
+ } else {
450
+ outputName = `${routePath}.html`;
451
+ }
452
+
453
+ return path.join(this.getExportDir(), outputName);
454
+ }
455
+ }
456
+
457
+ /**
458
+ * Splits a path into segments, filtering out empty strings.
459
+ */
460
+ function templateSegmentsFromPath(path: string) {
461
+ return path.split('/').filter(Boolean);
462
+ }
@@ -0,0 +1,242 @@
1
+ import type { EcoBuildPlugin } from '../build/build-types.ts';
2
+ import type { AppBuildManifest } from '../build/build-manifest.ts';
3
+ import type { BuildAdapter, BuildExecutor, BuildOwnership } from '../build/build-adapter.ts';
4
+ import type { IntegrationPlugin } from '../plugins/integration-plugin.ts';
5
+ import type { Processor } from '../plugins/processor.ts';
6
+ import type { EcoSourceTransform } from '../plugins/source-transform.ts';
7
+ import type { PageMetadataProps } from './public-types.ts';
8
+ import type { FSRouter } from '../router/server/fs-router.ts';
9
+ import type { CacheConfig } from '../services/cache/cache.types.ts';
10
+ import type { DevGraphService } from '../services/runtime-state/dev-graph.service.ts';
11
+ import type { AppModuleLoader } from '../services/module-loading/app-module-loader.service.ts';
12
+ import type { SourceModuleLoader } from '../services/module-loading/module-loading-types.ts';
13
+ import type { EntrypointDependencyGraph } from '../services/runtime-state/entrypoint-dependency-graph.service.ts';
14
+ import type { RuntimeSpecifierRegistry } from '../services/runtime-state/runtime-specifier-registry.service.ts';
15
+ import type { ServerInvalidationState } from '../services/runtime-state/server-invalidation-state.service.ts';
16
+ import type { ServerModuleTranspiler } from '../services/module-loading/server-module-transpiler.service.ts';
17
+
18
+ export interface RobotsPreference {
19
+ /**
20
+ * The user agent
21
+ * If an empty array is provided, it will enable all paths for the user agent
22
+ * If a path is provided, it will disallow the path for the user agent
23
+ */
24
+ [key: string]: string[];
25
+ }
26
+
27
+ /**
28
+ * Represents the complete configuration object for EcoPages.
29
+ */
30
+ export type EcoPagesAppConfig = {
31
+ /**
32
+ * The base URL of the website, localhost or the domain
33
+ */
34
+ baseUrl: string;
35
+ /**
36
+ * The root directory of the project
37
+ * @default "."
38
+ */
39
+ rootDir: string;
40
+ /**
41
+ * The root directory of the project
42
+ * @default "src"
43
+ */
44
+ srcDir: string;
45
+ /**
46
+ * The directory where the public files are located
47
+ * @default "public"
48
+ */
49
+ publicDir: string;
50
+ /**
51
+ * The directory where the pages are located
52
+ * @default "pages"
53
+ */
54
+ pagesDir: string;
55
+ /**
56
+ * The directory where the includes templates are located
57
+ * @default "includes"
58
+ */
59
+ includesDir: string;
60
+ /**
61
+ * The directory where the layouts are located
62
+ * @default "layouts"
63
+ */
64
+ layoutsDir: string;
65
+ /**
66
+ * The directory where the output will be located
67
+ * @default "dist"
68
+ */
69
+ distDir: string;
70
+ /**
71
+ * The directory where internal runtime and build artifacts are stored.
72
+ *
73
+ * @remarks
74
+ * This directory is not intended for deployment. It owns transpiled server
75
+ * modules, runtime manifests, and processor caches so `distDir` can remain a
76
+ * clean export tree.
77
+ *
78
+ * @default ".eco"
79
+ */
80
+ workDir: string;
81
+ /**
82
+ * The templates extensions based on the integrations
83
+ */
84
+ templatesExt: string[];
85
+ /**
86
+ * The directory where the components are located
87
+ * @default "components"
88
+ */
89
+ componentsDir: string;
90
+ /**
91
+ * The robots.txt configuration
92
+ */
93
+ robotsTxt: {
94
+ /**
95
+ * The robots preferences. The key is the user agent and the value is the disallowed paths.
96
+ * @default { "*": [] }
97
+ */
98
+ preferences: RobotsPreference;
99
+ };
100
+ /** Additional paths to watch. Use this to monitor extra files. It is relative to the rootDir */
101
+ additionalWatchPaths: string[];
102
+ /**
103
+ * @default { title: 'Ecopages', description: 'Ecopages' }
104
+ */
105
+ defaultMetadata: PageMetadataProps;
106
+ /** Integrations plugins */
107
+ integrations: IntegrationPlugin[];
108
+ /** Integrations dependencies */
109
+ integrationsDependencies: IntegrationDependencyConfig[];
110
+ /** Derived Paths */
111
+ absolutePaths: {
112
+ config: string;
113
+ componentsDir: string;
114
+ distDir: string;
115
+ workDir: string;
116
+ includesDir: string;
117
+ layoutsDir: string;
118
+ pagesDir: string;
119
+ projectDir: string;
120
+ publicDir: string;
121
+ srcDir: string;
122
+ htmlTemplatePath: string;
123
+ error404TemplatePath: string;
124
+ };
125
+ /**
126
+ * The processors to be used in the app
127
+ */
128
+ processors: Map<string, Processor>;
129
+ /**
130
+ * Loaders to be used in the app, these are used to process the files when importing them
131
+ */
132
+ loaders: Map<string, EcoBuildPlugin>;
133
+ /**
134
+ * App-owned source transforms that can be adapted into Vite or other
135
+ * transform-first bundlers without going through the legacy loader bridge.
136
+ */
137
+ sourceTransforms: Map<string, EcoSourceTransform>;
138
+ /**
139
+ * Cache configuration for ISR and page caching.
140
+ * @default { store: 'memory', defaultStrategy: 'static', enabled: true }
141
+ */
142
+ cache?: CacheConfig;
143
+ /**
144
+ * Runtime-owned services attached after config construction.
145
+ *
146
+ * These values are internal implementation details used to thread per-app
147
+ * executors and similar runtime state through the system without relying on
148
+ * process-global registries.
149
+ */
150
+ runtime?: {
151
+ appModuleLoader?: AppModuleLoader;
152
+ buildOwnership?: BuildOwnership;
153
+ buildAdapter?: BuildAdapter;
154
+ buildManifest?: AppBuildManifest;
155
+ buildExecutor?: BuildExecutor;
156
+ devGraphService?: DevGraphService;
157
+ entrypointDependencyGraph?: EntrypointDependencyGraph;
158
+ hostModuleLoader?: SourceModuleLoader;
159
+ rendererModuleContext?: unknown;
160
+ runtimeSpecifierRegistry?: RuntimeSpecifierRegistry;
161
+ serverInvalidationState?: ServerInvalidationState;
162
+ serverModuleTranspiler?: ServerModuleTranspiler;
163
+ };
164
+ /**
165
+ * Experimental features.
166
+ */
167
+ experimental?: {
168
+ /** Escape hatch for short-lived private toggles. No validation or IntelliSense. */
169
+ unsafe?: Record<string, unknown>;
170
+ };
171
+ };
172
+
173
+ export type IntegrationDependencyConfig = {
174
+ integration: string;
175
+ kind: 'script' | 'stylesheet';
176
+ position?: 'head' | 'body';
177
+ srcUrl: string;
178
+ filePath: string;
179
+ /** @todo inline dependencies not implemented yet */
180
+ inline?: boolean;
181
+ };
182
+
183
+ /**
184
+ * The possible kinds of a route.
185
+ */
186
+ export type RouteKind = 'exact' | 'catch-all' | 'dynamic';
187
+
188
+ /**
189
+ * Represents the result of a route match.
190
+ */
191
+ export type MatchResult = {
192
+ filePath: string;
193
+ kind: RouteKind;
194
+ pathname: string;
195
+ query?: Record<string, string>;
196
+ params?: Record<string, string | string[]>;
197
+ };
198
+
199
+ /**
200
+ * Represents a route in EcoPages.
201
+ */
202
+ export type Route = {
203
+ kind: RouteKind;
204
+ filePath: string;
205
+ pathname: string;
206
+ };
207
+
208
+ /**
209
+ * Represents the routes in EcoPages.
210
+ */
211
+ export type Routes = Record<string, Route>;
212
+
213
+ /**
214
+ * Represents the options for the file system server.
215
+ */
216
+ export type FileSystemServerOptions = {
217
+ watchMode: boolean;
218
+ port?: number | string;
219
+ };
220
+
221
+ /**
222
+ * Represents the file system server adapter.
223
+ */
224
+ export interface EcoPagesFileSystemServerAdapter<ServerInstanceOptions = unknown> {
225
+ startServer(serverOptions: ServerInstanceOptions):
226
+ | {
227
+ router: FSRouter;
228
+ server: unknown;
229
+ }
230
+ | Promise<{ router: FSRouter; server: unknown }>;
231
+ }
232
+
233
+ export interface ProcessorPlugin {
234
+ name: string;
235
+ description?: string;
236
+ setup(): Promise<void>;
237
+ process<T = unknown>(input: T): Promise<T>;
238
+ teardown?(): Promise<void>;
239
+ }
240
+
241
+ // Re-export HMR types from public-types for internal use
242
+ export type { ClientBridgeEvent, DefaultHmrContext, IHmrManager, IClientBridge } from './public-types.ts';