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

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 (543) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/package.json +226 -93
  3. package/src/adapters/abstract/application-adapter.d.ts +194 -0
  4. package/src/adapters/abstract/application-adapter.js +121 -0
  5. package/src/adapters/abstract/router-adapter.d.ts +26 -0
  6. package/src/adapters/abstract/router-adapter.js +5 -0
  7. package/src/adapters/abstract/server-adapter.d.ts +69 -0
  8. package/src/adapters/abstract/server-adapter.js +15 -0
  9. package/src/adapters/bun/client-bridge.d.ts +34 -0
  10. package/src/adapters/bun/client-bridge.js +48 -0
  11. package/src/adapters/bun/create-app.d.ts +52 -0
  12. package/src/adapters/bun/create-app.js +116 -0
  13. package/src/adapters/bun/hmr-manager.d.ts +143 -0
  14. package/src/adapters/bun/hmr-manager.js +333 -0
  15. package/src/adapters/bun/index.d.ts +2 -0
  16. package/src/adapters/bun/index.js +8 -0
  17. package/src/adapters/bun/server-adapter.d.ts +155 -0
  18. package/src/adapters/bun/server-adapter.js +374 -0
  19. package/src/adapters/bun/server-lifecycle.d.ts +63 -0
  20. package/src/adapters/bun/server-lifecycle.js +92 -0
  21. package/src/adapters/create-app.d.ts +20 -0
  22. package/src/adapters/create-app.js +66 -0
  23. package/src/adapters/index.d.ts +2 -0
  24. package/src/adapters/index.js +8 -0
  25. package/src/adapters/node/create-app.d.ts +18 -0
  26. package/src/adapters/node/create-app.js +149 -0
  27. package/src/adapters/node/node-client-bridge.d.ts +26 -0
  28. package/src/adapters/node/node-client-bridge.js +66 -0
  29. package/src/adapters/node/node-hmr-manager.d.ts +133 -0
  30. package/src/adapters/node/node-hmr-manager.js +311 -0
  31. package/src/adapters/node/server-adapter.d.ts +162 -0
  32. package/src/adapters/node/server-adapter.js +368 -0
  33. package/src/adapters/node/static-content-server.d.ts +60 -0
  34. package/src/adapters/node/static-content-server.js +194 -0
  35. package/src/adapters/shared/api-response.d.ts +52 -0
  36. package/src/adapters/shared/api-response.js +96 -0
  37. package/src/adapters/shared/application-adapter.d.ts +18 -0
  38. package/src/adapters/shared/application-adapter.js +90 -0
  39. package/src/adapters/shared/define-api-handler.d.ts +25 -0
  40. package/src/adapters/shared/define-api-handler.js +15 -0
  41. package/src/adapters/shared/explicit-static-route-matcher.d.ts +38 -0
  42. package/src/adapters/shared/explicit-static-route-matcher.js +103 -0
  43. package/src/adapters/shared/file-route-middleware-pipeline.d.ts +65 -0
  44. package/src/adapters/shared/file-route-middleware-pipeline.js +99 -0
  45. package/src/adapters/shared/fs-server-response-factory.d.ts +19 -0
  46. package/src/adapters/shared/fs-server-response-factory.js +97 -0
  47. package/src/adapters/shared/fs-server-response-matcher.d.ts +67 -0
  48. package/src/adapters/shared/fs-server-response-matcher.js +147 -0
  49. package/src/adapters/shared/hmr-entrypoint-registrar.d.ts +55 -0
  50. package/src/adapters/shared/hmr-entrypoint-registrar.js +87 -0
  51. package/src/adapters/shared/hmr-html-response.d.ts +22 -0
  52. package/src/adapters/shared/hmr-html-response.js +32 -0
  53. package/src/adapters/shared/render-context.d.ts +15 -0
  54. package/src/adapters/shared/render-context.js +72 -0
  55. package/src/adapters/shared/runtime-bootstrap.d.ts +38 -0
  56. package/src/adapters/shared/runtime-bootstrap.js +43 -0
  57. package/src/adapters/shared/server-adapter.d.ts +97 -0
  58. package/src/adapters/shared/server-adapter.js +390 -0
  59. package/src/adapters/shared/server-route-handler.d.ts +89 -0
  60. package/src/adapters/shared/server-route-handler.js +111 -0
  61. package/src/adapters/shared/server-static-builder.d.ts +71 -0
  62. package/src/adapters/shared/server-static-builder.js +100 -0
  63. package/src/build/build-adapter.d.ts +239 -0
  64. package/src/build/build-adapter.js +642 -0
  65. package/src/build/build-manifest.d.ts +27 -0
  66. package/src/build/build-manifest.js +30 -0
  67. package/src/build/build-types.d.ts +57 -0
  68. package/src/build/build-types.js +0 -0
  69. package/src/build/dev-build-coordinator.d.ts +72 -0
  70. package/src/build/dev-build-coordinator.js +154 -0
  71. package/src/build/esbuild-build-adapter.d.ts +78 -0
  72. package/src/build/esbuild-build-adapter.js +505 -0
  73. package/src/build/runtime-build-executor.d.ts +14 -0
  74. package/src/build/runtime-build-executor.js +22 -0
  75. package/src/build/runtime-specifier-alias-plugin.d.ts +15 -0
  76. package/src/build/runtime-specifier-alias-plugin.js +35 -0
  77. package/src/build/runtime-specifier-aliases.d.ts +5 -0
  78. package/src/build/runtime-specifier-aliases.js +95 -0
  79. package/src/config/config-builder.d.ts +252 -0
  80. package/src/config/config-builder.js +603 -0
  81. package/src/config/{constants.ts → constants.d.ts} +13 -22
  82. package/src/config/constants.js +25 -0
  83. package/src/dev/sc-server.d.ts +30 -0
  84. package/src/dev/sc-server.js +111 -0
  85. package/src/eco/eco.browser.d.ts +2 -0
  86. package/src/eco/eco.browser.js +83 -0
  87. package/src/eco/eco.d.ts +9 -0
  88. package/src/eco/eco.js +85 -0
  89. package/src/eco/eco.types.d.ts +178 -0
  90. package/src/eco/eco.types.js +0 -0
  91. package/src/eco/eco.utils.d.ts +1 -0
  92. package/src/eco/eco.utils.js +10 -0
  93. package/src/eco/global-injector-map.d.ts +16 -0
  94. package/src/eco/global-injector-map.js +80 -0
  95. package/src/eco/lazy-injector-map.d.ts +8 -0
  96. package/src/eco/lazy-injector-map.js +70 -0
  97. package/src/eco/module-dependencies.d.ts +18 -0
  98. package/src/eco/module-dependencies.js +49 -0
  99. package/src/errors/http-error.d.ts +31 -0
  100. package/src/errors/http-error.js +50 -0
  101. package/src/errors/{index.ts → index.d.ts} +2 -2
  102. package/src/errors/index.js +4 -0
  103. package/src/errors/locals-access-error.d.ts +4 -0
  104. package/src/errors/locals-access-error.js +9 -0
  105. package/src/global/app-logger.d.ts +2 -0
  106. package/src/global/app-logger.js +6 -0
  107. package/src/hmr/client/hmr-runtime.d.ts +5 -0
  108. package/src/hmr/client/hmr-runtime.js +117 -0
  109. package/src/hmr/hmr-strategy.d.ts +162 -0
  110. package/src/hmr/hmr-strategy.js +44 -0
  111. package/src/hmr/hmr.postcss.test.e2e.d.ts +1 -0
  112. package/src/hmr/hmr.postcss.test.e2e.js +31 -0
  113. package/src/hmr/hmr.test.e2e.d.ts +1 -0
  114. package/src/hmr/hmr.test.e2e.js +43 -0
  115. package/src/hmr/strategies/default-hmr-strategy.d.ts +43 -0
  116. package/src/hmr/strategies/default-hmr-strategy.js +34 -0
  117. package/src/hmr/strategies/js-hmr-strategy.d.ts +139 -0
  118. package/src/hmr/strategies/js-hmr-strategy.js +178 -0
  119. package/src/index.browser.d.ts +3 -0
  120. package/src/index.browser.js +4 -0
  121. package/src/index.d.ts +6 -0
  122. package/src/index.js +21 -0
  123. package/src/integrations/ghtml/ghtml-renderer.d.ts +20 -0
  124. package/src/integrations/ghtml/ghtml-renderer.js +63 -0
  125. package/src/integrations/ghtml/ghtml.constants.d.ts +1 -0
  126. package/src/integrations/ghtml/ghtml.constants.js +4 -0
  127. package/src/integrations/ghtml/ghtml.plugin.d.ts +16 -0
  128. package/src/integrations/ghtml/ghtml.plugin.js +20 -0
  129. package/src/plugins/alias-resolver-plugin.d.ts +2 -0
  130. package/src/plugins/alias-resolver-plugin.js +53 -0
  131. package/src/plugins/eco-component-meta-plugin.d.ts +108 -0
  132. package/src/plugins/eco-component-meta-plugin.js +163 -0
  133. package/src/plugins/foreign-jsx-override-plugin.d.ts +31 -0
  134. package/src/plugins/foreign-jsx-override-plugin.js +35 -0
  135. package/src/plugins/integration-plugin.d.ts +219 -0
  136. package/src/plugins/integration-plugin.js +196 -0
  137. package/src/plugins/processor.d.ts +95 -0
  138. package/src/plugins/processor.js +136 -0
  139. package/src/plugins/{runtime-capability.ts → runtime-capability.d.ts} +3 -8
  140. package/src/plugins/runtime-capability.js +0 -0
  141. package/src/plugins/source-transform.d.ts +46 -0
  142. package/src/plugins/source-transform.js +71 -0
  143. package/src/route-renderer/orchestration/boundary-planning.service.d.ts +25 -0
  144. package/src/route-renderer/orchestration/boundary-planning.service.js +97 -0
  145. package/src/route-renderer/orchestration/component-render-context.d.ts +83 -0
  146. package/src/route-renderer/orchestration/component-render-context.js +147 -0
  147. package/src/route-renderer/orchestration/integration-renderer.d.ts +556 -0
  148. package/src/route-renderer/orchestration/integration-renderer.js +932 -0
  149. package/src/route-renderer/orchestration/page-packaging.service.d.ts +16 -0
  150. package/src/route-renderer/orchestration/page-packaging.service.js +66 -0
  151. package/src/route-renderer/orchestration/processed-asset-dedupe.d.ts +2 -0
  152. package/src/route-renderer/orchestration/processed-asset-dedupe.js +23 -0
  153. package/src/route-renderer/orchestration/queued-boundary-runtime.service.d.ts +89 -0
  154. package/src/route-renderer/orchestration/queued-boundary-runtime.service.js +155 -0
  155. package/src/route-renderer/orchestration/render-execution.service.d.ts +43 -0
  156. package/src/route-renderer/orchestration/render-execution.service.js +106 -0
  157. package/src/route-renderer/orchestration/render-output.utils.d.ts +66 -0
  158. package/src/route-renderer/orchestration/render-output.utils.js +171 -0
  159. package/src/route-renderer/orchestration/render-preparation.service.d.ts +120 -0
  160. package/src/route-renderer/orchestration/render-preparation.service.js +364 -0
  161. package/src/route-renderer/orchestration/route-shell-composer.service.d.ts +50 -0
  162. package/src/route-renderer/orchestration/route-shell-composer.service.js +81 -0
  163. package/src/route-renderer/orchestration/template-serialization.d.ts +38 -0
  164. package/src/route-renderer/orchestration/template-serialization.js +45 -0
  165. package/src/route-renderer/page-loading/component-dependency-collection.d.ts +37 -0
  166. package/src/route-renderer/page-loading/component-dependency-collection.js +125 -0
  167. package/src/route-renderer/page-loading/declared-asset-collection.d.ts +24 -0
  168. package/src/route-renderer/page-loading/declared-asset-collection.js +106 -0
  169. package/src/route-renderer/page-loading/dependency-resolver.d.ts +35 -0
  170. package/src/route-renderer/page-loading/dependency-resolver.js +117 -0
  171. package/src/route-renderer/page-loading/ecopages-virtual-imports.d.ts +11 -0
  172. package/src/route-renderer/page-loading/ecopages-virtual-imports.js +57 -0
  173. package/src/route-renderer/page-loading/lazy-entry-collection.d.ts +45 -0
  174. package/src/route-renderer/page-loading/lazy-entry-collection.js +105 -0
  175. package/src/route-renderer/page-loading/lazy-trigger-planning.d.ts +19 -0
  176. package/src/route-renderer/page-loading/lazy-trigger-planning.js +40 -0
  177. package/src/route-renderer/page-loading/module-declaration-aggregation.d.ts +5 -0
  178. package/src/route-renderer/page-loading/module-declaration-aggregation.js +33 -0
  179. package/src/route-renderer/page-loading/module-declaration-scripts.d.ts +3 -0
  180. package/src/route-renderer/page-loading/module-declaration-scripts.js +18 -0
  181. package/src/route-renderer/page-loading/page-dependency-bundling.d.ts +13 -0
  182. package/src/route-renderer/page-loading/page-dependency-bundling.js +115 -0
  183. package/src/route-renderer/page-loading/page-module-loader.d.ts +90 -0
  184. package/src/route-renderer/page-loading/page-module-loader.js +127 -0
  185. package/src/route-renderer/route-renderer.d.ts +67 -0
  186. package/src/route-renderer/route-renderer.js +103 -0
  187. package/src/router/client/link-intent.js +34 -0
  188. package/src/router/client/link-intent.test.browser.d.ts +1 -0
  189. package/src/router/client/link-intent.test.browser.js +43 -0
  190. package/src/router/client/navigation-coordinator.d.ts +169 -0
  191. package/src/router/client/navigation-coordinator.js +215 -0
  192. package/src/router/server/fs-router-scanner.d.ts +41 -0
  193. package/src/router/server/fs-router-scanner.js +161 -0
  194. package/src/router/server/fs-router.d.ts +26 -0
  195. package/src/router/server/fs-router.js +100 -0
  196. package/src/services/assets/asset-processing-service/asset-dependency-keys.d.ts +3 -0
  197. package/src/services/assets/asset-processing-service/asset-dependency-keys.js +56 -0
  198. package/src/services/assets/asset-processing-service/asset-processing.service.d.ts +103 -0
  199. package/src/services/assets/asset-processing-service/asset-processing.service.js +285 -0
  200. package/src/services/assets/asset-processing-service/asset.factory.d.ts +17 -0
  201. package/src/services/assets/asset-processing-service/asset.factory.js +82 -0
  202. package/src/services/assets/asset-processing-service/assets.types.d.ts +100 -0
  203. package/src/services/assets/asset-processing-service/assets.types.js +0 -0
  204. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.d.ts +55 -0
  205. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.js +49 -0
  206. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.d.ts +20 -0
  207. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.js +41 -0
  208. package/src/services/assets/asset-processing-service/grouped-content-bundles.d.ts +30 -0
  209. package/src/services/assets/asset-processing-service/grouped-content-bundles.js +65 -0
  210. package/src/services/assets/asset-processing-service/index.d.ts +5 -0
  211. package/src/services/assets/asset-processing-service/index.js +5 -0
  212. package/src/services/assets/asset-processing-service/{processor.interface.ts → processor.interface.d.ts} +5 -10
  213. package/src/services/assets/asset-processing-service/processor.interface.js +6 -0
  214. package/src/services/assets/asset-processing-service/processor.registry.d.ts +8 -0
  215. package/src/services/assets/asset-processing-service/processor.registry.js +15 -0
  216. package/src/services/assets/asset-processing-service/processors/base/base-processor.d.ts +24 -0
  217. package/src/services/assets/asset-processing-service/processors/base/base-processor.js +65 -0
  218. package/src/services/assets/asset-processing-service/processors/base/base-script-processor.d.ts +22 -0
  219. package/src/services/assets/asset-processing-service/processors/base/base-script-processor.js +136 -0
  220. package/src/services/assets/asset-processing-service/processors/index.d.ts +5 -0
  221. package/src/services/assets/asset-processing-service/processors/index.js +5 -0
  222. package/src/services/assets/asset-processing-service/processors/script/content-script.processor.d.ts +6 -0
  223. package/src/services/assets/asset-processing-service/processors/script/content-script.processor.js +116 -0
  224. package/src/services/assets/asset-processing-service/processors/script/file-script.processor.d.ts +9 -0
  225. package/src/services/assets/asset-processing-service/processors/script/file-script.processor.js +91 -0
  226. package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.d.ts +7 -0
  227. package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.js +77 -0
  228. package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.d.ts +8 -0
  229. package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.js +58 -0
  230. package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.d.ts +9 -0
  231. package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.js +67 -0
  232. package/src/services/assets/asset-processing-service/ungrouped-dependency-processing.d.ts +18 -0
  233. package/src/services/assets/asset-processing-service/ungrouped-dependency-processing.js +45 -0
  234. package/src/services/assets/browser-bundle.service.d.ts +73 -0
  235. package/src/services/assets/browser-bundle.service.js +41 -0
  236. package/src/services/cache/cache.types.d.ts +107 -0
  237. package/src/services/cache/cache.types.js +0 -0
  238. package/src/services/cache/index.d.ts +7 -0
  239. package/src/services/cache/index.js +7 -0
  240. package/src/services/cache/memory-cache-store.d.ts +42 -0
  241. package/src/services/cache/memory-cache-store.js +98 -0
  242. package/src/services/cache/page-cache-service.d.ts +70 -0
  243. package/src/services/cache/page-cache-service.js +152 -0
  244. package/src/services/cache/page-request-cache-coordinator.service.d.ts +75 -0
  245. package/src/services/cache/page-request-cache-coordinator.service.js +109 -0
  246. package/src/services/html/html-rewriter-provider.service.d.ts +37 -0
  247. package/src/services/html/html-rewriter-provider.service.js +68 -0
  248. package/src/services/html/html-transformer.service.d.ts +87 -0
  249. package/src/services/html/html-transformer.service.js +216 -0
  250. package/src/services/invalidation/development-invalidation.service.d.ts +74 -0
  251. package/src/services/invalidation/development-invalidation.service.js +190 -0
  252. package/src/services/module-loading/app-module-loader.service.d.ts +7 -0
  253. package/src/services/module-loading/app-module-loader.service.js +0 -0
  254. package/src/services/module-loading/app-server-module-transpiler.service.d.ts +24 -0
  255. package/src/services/module-loading/app-server-module-transpiler.service.js +115 -0
  256. package/src/services/module-loading/host-module-loader-registry.d.ts +4 -0
  257. package/src/services/module-loading/host-module-loader-registry.js +15 -0
  258. package/src/services/module-loading/{module-loading-types.ts → module-loading-types.d.ts} +0 -1
  259. package/src/services/module-loading/module-loading-types.js +0 -0
  260. package/src/services/module-loading/node-bootstrap-plugin.d.ts +42 -0
  261. package/src/services/module-loading/node-bootstrap-plugin.js +204 -0
  262. package/src/services/module-loading/page-module-import.service.d.ts +76 -0
  263. package/src/services/module-loading/page-module-import.service.js +170 -0
  264. package/src/services/module-loading/server-module-transpiler.service.d.ts +63 -0
  265. package/src/services/module-loading/server-module-transpiler.service.js +64 -0
  266. package/src/services/module-loading/source-module-support.d.ts +5 -0
  267. package/src/services/module-loading/source-module-support.js +8 -0
  268. package/src/services/runtime-state/dev-graph.service.d.ts +118 -0
  269. package/src/services/runtime-state/dev-graph.service.js +162 -0
  270. package/src/services/runtime-state/entrypoint-dependency-graph.service.d.ts +41 -0
  271. package/src/services/runtime-state/entrypoint-dependency-graph.service.js +85 -0
  272. package/src/services/runtime-state/runtime-specifier-registry.service.d.ts +69 -0
  273. package/src/services/runtime-state/runtime-specifier-registry.service.js +37 -0
  274. package/src/services/runtime-state/server-invalidation-state.service.d.ts +26 -0
  275. package/src/services/runtime-state/server-invalidation-state.service.js +35 -0
  276. package/src/services/validation/schema-validation-service.d.ts +122 -0
  277. package/src/services/validation/schema-validation-service.js +101 -0
  278. package/src/services/validation/{standard-schema.types.ts → standard-schema.types.d.ts} +17 -20
  279. package/src/services/validation/standard-schema.types.js +0 -0
  280. package/src/static-site-generator/static-site-generator.d.ts +105 -0
  281. package/src/static-site-generator/static-site-generator.js +349 -0
  282. package/src/types/internal-types.d.ts +231 -0
  283. package/src/types/internal-types.js +0 -0
  284. package/src/types/public-types.d.ts +1257 -0
  285. package/src/types/public-types.js +0 -0
  286. package/src/utils/deep-merge.d.ts +14 -0
  287. package/src/utils/deep-merge.js +32 -0
  288. package/src/utils/hash.d.ts +1 -0
  289. package/src/utils/hash.js +7 -0
  290. package/src/utils/html-escaping.d.ts +7 -0
  291. package/src/utils/html-escaping.js +6 -0
  292. package/src/utils/html.js +4 -0
  293. package/src/utils/invariant.d.ts +5 -0
  294. package/src/utils/invariant.js +11 -0
  295. package/src/utils/locals-utils.d.ts +15 -0
  296. package/src/utils/locals-utils.js +24 -0
  297. package/src/utils/parse-cli-args.d.ts +27 -0
  298. package/src/utils/parse-cli-args.js +62 -0
  299. package/src/utils/path-utils.module.d.ts +5 -0
  300. package/src/utils/path-utils.module.js +14 -0
  301. package/src/utils/resolve-work-dir.d.ts +11 -0
  302. package/src/utils/resolve-work-dir.js +31 -0
  303. package/src/utils/runtime.d.ts +11 -0
  304. package/src/utils/runtime.js +40 -0
  305. package/src/utils/server-utils.module.d.ts +19 -0
  306. package/src/utils/server-utils.module.js +56 -0
  307. package/src/watchers/project-watcher.d.ts +136 -0
  308. package/src/watchers/project-watcher.js +275 -0
  309. package/src/watchers/project-watcher.test-helpers.d.ts +4 -0
  310. package/src/watchers/project-watcher.test-helpers.js +52 -0
  311. package/src/adapters/abstract/application-adapter.test.ts +0 -172
  312. package/src/adapters/abstract/application-adapter.ts +0 -379
  313. package/src/adapters/abstract/router-adapter.ts +0 -30
  314. package/src/adapters/abstract/server-adapter.ts +0 -79
  315. package/src/adapters/bun/client-bridge.ts +0 -62
  316. package/src/adapters/bun/create-app.ts +0 -180
  317. package/src/adapters/bun/hmr-manager.test.ts +0 -267
  318. package/src/adapters/bun/hmr-manager.ts +0 -406
  319. package/src/adapters/bun/index.ts +0 -2
  320. package/src/adapters/bun/server-adapter.ts +0 -500
  321. package/src/adapters/bun/server-lifecycle.ts +0 -124
  322. package/src/adapters/create-app.test.ts +0 -10
  323. package/src/adapters/create-app.ts +0 -91
  324. package/src/adapters/index.ts +0 -2
  325. package/src/adapters/node/create-app.test.ts +0 -53
  326. package/src/adapters/node/create-app.ts +0 -183
  327. package/src/adapters/node/node-client-bridge.test.ts +0 -198
  328. package/src/adapters/node/node-client-bridge.ts +0 -79
  329. package/src/adapters/node/node-hmr-manager.test.ts +0 -322
  330. package/src/adapters/node/node-hmr-manager.ts +0 -378
  331. package/src/adapters/node/server-adapter.ts +0 -502
  332. package/src/adapters/node/static-content-server.test.ts +0 -60
  333. package/src/adapters/node/static-content-server.ts +0 -239
  334. package/src/adapters/shared/api-response.test.ts +0 -97
  335. package/src/adapters/shared/api-response.ts +0 -104
  336. package/src/adapters/shared/application-adapter.ts +0 -199
  337. package/src/adapters/shared/define-api-handler.ts +0 -66
  338. package/src/adapters/shared/explicit-static-route-matcher.test.ts +0 -381
  339. package/src/adapters/shared/explicit-static-route-matcher.ts +0 -140
  340. package/src/adapters/shared/file-route-middleware-pipeline.test.ts +0 -90
  341. package/src/adapters/shared/file-route-middleware-pipeline.ts +0 -127
  342. package/src/adapters/shared/fs-server-response-factory.test.ts +0 -187
  343. package/src/adapters/shared/fs-server-response-factory.ts +0 -118
  344. package/src/adapters/shared/fs-server-response-matcher.test.ts +0 -285
  345. package/src/adapters/shared/fs-server-response-matcher.ts +0 -189
  346. package/src/adapters/shared/hmr-entrypoint-registrar.ts +0 -149
  347. package/src/adapters/shared/hmr-html-response.ts +0 -52
  348. package/src/adapters/shared/hmr-manager.contract.test.ts +0 -232
  349. package/src/adapters/shared/hmr-manager.dispatch.test.ts +0 -220
  350. package/src/adapters/shared/render-context.test.ts +0 -150
  351. package/src/adapters/shared/render-context.ts +0 -123
  352. package/src/adapters/shared/runtime-bootstrap.ts +0 -79
  353. package/src/adapters/shared/server-adapter.test.ts +0 -77
  354. package/src/adapters/shared/server-adapter.ts +0 -493
  355. package/src/adapters/shared/server-route-handler.test.ts +0 -110
  356. package/src/adapters/shared/server-route-handler.ts +0 -153
  357. package/src/adapters/shared/server-static-builder.test.ts +0 -338
  358. package/src/adapters/shared/server-static-builder.ts +0 -170
  359. package/src/build/build-adapter-serialization.test.ts +0 -281
  360. package/src/build/build-adapter.test.ts +0 -1240
  361. package/src/build/build-adapter.ts +0 -1012
  362. package/src/build/build-manifest.ts +0 -54
  363. package/src/build/build-types.ts +0 -83
  364. package/src/build/dev-build-coordinator.ts +0 -220
  365. package/src/build/esbuild-build-adapter.ts +0 -660
  366. package/src/build/runtime-build-executor.test.ts +0 -81
  367. package/src/build/runtime-build-executor.ts +0 -40
  368. package/src/build/runtime-specifier-alias-plugin.test.ts +0 -67
  369. package/src/build/runtime-specifier-alias-plugin.ts +0 -62
  370. package/src/build/runtime-specifier-aliases.ts +0 -135
  371. package/src/config/config-builder.test.ts +0 -443
  372. package/src/config/config-builder.ts +0 -742
  373. package/src/config/config-builder.typecheck.test.ts +0 -96
  374. package/src/dev/sc-server.ts +0 -143
  375. package/src/eco/eco.browser.test.ts +0 -43
  376. package/src/eco/eco.browser.ts +0 -118
  377. package/src/eco/eco.test.ts +0 -654
  378. package/src/eco/eco.ts +0 -205
  379. package/src/eco/eco.types.ts +0 -221
  380. package/src/eco/eco.utils.test.ts +0 -219
  381. package/src/eco/eco.utils.ts +0 -5
  382. package/src/eco/global-injector-map.test.ts +0 -42
  383. package/src/eco/global-injector-map.ts +0 -112
  384. package/src/eco/lazy-injector-map.test.ts +0 -66
  385. package/src/eco/lazy-injector-map.ts +0 -120
  386. package/src/eco/module-dependencies.test.ts +0 -30
  387. package/src/eco/module-dependencies.ts +0 -75
  388. package/src/errors/http-error.test.ts +0 -134
  389. package/src/errors/http-error.ts +0 -72
  390. package/src/errors/locals-access-error.ts +0 -7
  391. package/src/global/app-logger.ts +0 -4
  392. package/src/global/utils.test.ts +0 -12
  393. 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
  394. package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-HMR-Server-Integration-should-load-fixture-app-page-1.png +0 -0
  395. package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-WebSocket-Connection-should-connect-to-correct-HMR-endpoint-1.png +0 -0
  396. package/src/hmr/client/hmr-runtime.ts +0 -160
  397. package/src/hmr/hmr-strategy.test.ts +0 -124
  398. package/src/hmr/hmr-strategy.ts +0 -177
  399. package/src/hmr/hmr.postcss.test.e2e.ts +0 -41
  400. package/src/hmr/hmr.test.e2e.ts +0 -66
  401. package/src/hmr/strategies/default-hmr-strategy.ts +0 -60
  402. package/src/hmr/strategies/js-hmr-strategy.test.ts +0 -335
  403. package/src/hmr/strategies/js-hmr-strategy.ts +0 -320
  404. package/src/index.browser.ts +0 -3
  405. package/src/index.ts +0 -15
  406. package/src/integrations/ghtml/ghtml-renderer.test.ts +0 -253
  407. package/src/integrations/ghtml/ghtml-renderer.ts +0 -97
  408. package/src/integrations/ghtml/ghtml.constants.ts +0 -1
  409. package/src/integrations/ghtml/ghtml.plugin.ts +0 -28
  410. package/src/plugins/alias-resolver-plugin.test.ts +0 -41
  411. package/src/plugins/alias-resolver-plugin.ts +0 -63
  412. package/src/plugins/eco-component-meta-plugin.test.ts +0 -406
  413. package/src/plugins/eco-component-meta-plugin.ts +0 -495
  414. package/src/plugins/foreign-jsx-override-plugin.test.ts +0 -65
  415. package/src/plugins/foreign-jsx-override-plugin.ts +0 -67
  416. package/src/plugins/integration-plugin.test.ts +0 -156
  417. package/src/plugins/integration-plugin.ts +0 -311
  418. package/src/plugins/processor.test.ts +0 -148
  419. package/src/plugins/processor.ts +0 -240
  420. package/src/plugins/source-transform.test.ts +0 -82
  421. package/src/plugins/source-transform.ts +0 -123
  422. package/src/route-renderer/orchestration/boundary-planning.service.ts +0 -146
  423. package/src/route-renderer/orchestration/component-render-context.ts +0 -318
  424. package/src/route-renderer/orchestration/integration-renderer.test.ts +0 -2088
  425. package/src/route-renderer/orchestration/integration-renderer.ts +0 -1285
  426. package/src/route-renderer/orchestration/page-packaging.service.test.ts +0 -76
  427. package/src/route-renderer/orchestration/page-packaging.service.ts +0 -85
  428. package/src/route-renderer/orchestration/processed-asset-dedupe.ts +0 -25
  429. package/src/route-renderer/orchestration/queued-boundary-runtime.service.test.ts +0 -319
  430. package/src/route-renderer/orchestration/queued-boundary-runtime.service.ts +0 -289
  431. package/src/route-renderer/orchestration/render-execution.service.test.ts +0 -196
  432. package/src/route-renderer/orchestration/render-execution.service.ts +0 -182
  433. package/src/route-renderer/orchestration/render-output.utils.ts +0 -302
  434. package/src/route-renderer/orchestration/render-preparation.service.test.ts +0 -569
  435. package/src/route-renderer/orchestration/render-preparation.service.ts +0 -508
  436. package/src/route-renderer/orchestration/route-shell-composer.service.ts +0 -162
  437. package/src/route-renderer/orchestration/template-serialization.test.ts +0 -110
  438. package/src/route-renderer/orchestration/template-serialization.ts +0 -117
  439. package/src/route-renderer/page-loading/component-dependency-collection.ts +0 -196
  440. package/src/route-renderer/page-loading/declared-asset-collection.ts +0 -156
  441. package/src/route-renderer/page-loading/dependency-resolver.test.ts +0 -665
  442. package/src/route-renderer/page-loading/dependency-resolver.ts +0 -150
  443. package/src/route-renderer/page-loading/ecopages-virtual-imports.ts +0 -75
  444. package/src/route-renderer/page-loading/lazy-entry-collection.ts +0 -167
  445. package/src/route-renderer/page-loading/lazy-trigger-planning.ts +0 -74
  446. package/src/route-renderer/page-loading/module-declaration-aggregation.ts +0 -60
  447. package/src/route-renderer/page-loading/module-declaration-scripts.ts +0 -16
  448. package/src/route-renderer/page-loading/page-dependency-bundling.ts +0 -205
  449. package/src/route-renderer/page-loading/page-module-loader.test.ts +0 -183
  450. package/src/route-renderer/page-loading/page-module-loader.ts +0 -184
  451. package/src/route-renderer/route-renderer.ts +0 -136
  452. package/src/router/client/link-intent.test.browser.ts +0 -51
  453. package/src/router/client/link-intent.ts +0 -92
  454. package/src/router/client/navigation-coordinator.test.ts +0 -237
  455. package/src/router/client/navigation-coordinator.ts +0 -453
  456. package/src/router/server/fs-router-scanner.test.ts +0 -83
  457. package/src/router/server/fs-router-scanner.ts +0 -224
  458. package/src/router/server/fs-router.test.ts +0 -214
  459. package/src/router/server/fs-router.ts +0 -122
  460. package/src/services/assets/asset-processing-service/asset-dependency-keys.ts +0 -66
  461. package/src/services/assets/asset-processing-service/asset-processing.service.test.ts +0 -476
  462. package/src/services/assets/asset-processing-service/asset-processing.service.ts +0 -345
  463. package/src/services/assets/asset-processing-service/asset.factory.test.ts +0 -63
  464. package/src/services/assets/asset-processing-service/asset.factory.ts +0 -105
  465. package/src/services/assets/asset-processing-service/assets.types.ts +0 -125
  466. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.test.ts +0 -74
  467. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.ts +0 -96
  468. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.test.ts +0 -67
  469. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.ts +0 -78
  470. package/src/services/assets/asset-processing-service/grouped-content-bundles.ts +0 -104
  471. package/src/services/assets/asset-processing-service/index.ts +0 -5
  472. package/src/services/assets/asset-processing-service/processor.registry.ts +0 -18
  473. package/src/services/assets/asset-processing-service/processors/base/base-processor.test.ts +0 -59
  474. package/src/services/assets/asset-processing-service/processors/base/base-processor.ts +0 -83
  475. package/src/services/assets/asset-processing-service/processors/base/base-script-processor.ts +0 -174
  476. package/src/services/assets/asset-processing-service/processors/index.ts +0 -5
  477. package/src/services/assets/asset-processing-service/processors/script/content-script.processor.test.ts +0 -192
  478. package/src/services/assets/asset-processing-service/processors/script/content-script.processor.ts +0 -134
  479. package/src/services/assets/asset-processing-service/processors/script/file-script.processor.test.ts +0 -326
  480. package/src/services/assets/asset-processing-service/processors/script/file-script.processor.ts +0 -110
  481. package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.test.ts +0 -227
  482. package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.ts +0 -87
  483. package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.test.ts +0 -261
  484. package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.ts +0 -71
  485. package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.ts +0 -81
  486. package/src/services/assets/asset-processing-service/ungrouped-dependency-processing.ts +0 -65
  487. package/src/services/assets/browser-bundle.service.test.ts +0 -66
  488. package/src/services/assets/browser-bundle.service.ts +0 -109
  489. package/src/services/cache/cache.types.ts +0 -126
  490. package/src/services/cache/index.ts +0 -18
  491. package/src/services/cache/memory-cache-store.test.ts +0 -225
  492. package/src/services/cache/memory-cache-store.ts +0 -130
  493. package/src/services/cache/page-cache-service.test.ts +0 -175
  494. package/src/services/cache/page-cache-service.ts +0 -202
  495. package/src/services/cache/page-request-cache-coordinator.service.test.ts +0 -79
  496. package/src/services/cache/page-request-cache-coordinator.service.ts +0 -131
  497. package/src/services/html/html-rewriter-provider.service.test.ts +0 -183
  498. package/src/services/html/html-rewriter-provider.service.ts +0 -104
  499. package/src/services/html/html-transformer.service.test.ts +0 -479
  500. package/src/services/html/html-transformer.service.ts +0 -275
  501. package/src/services/invalidation/development-invalidation.service.test.ts +0 -87
  502. package/src/services/invalidation/development-invalidation.service.ts +0 -262
  503. package/src/services/module-loading/app-module-loader.service.ts +0 -9
  504. package/src/services/module-loading/app-server-module-transpiler.service.test.ts +0 -130
  505. package/src/services/module-loading/app-server-module-transpiler.service.ts +0 -143
  506. package/src/services/module-loading/host-module-loader-registry.ts +0 -15
  507. package/src/services/module-loading/node-bootstrap-plugin.test.ts +0 -335
  508. package/src/services/module-loading/node-bootstrap-plugin.ts +0 -297
  509. package/src/services/module-loading/page-module-import.service.test.ts +0 -504
  510. package/src/services/module-loading/page-module-import.service.ts +0 -252
  511. package/src/services/module-loading/server-module-transpiler.service.test.ts +0 -243
  512. package/src/services/module-loading/server-module-transpiler.service.ts +0 -104
  513. package/src/services/module-loading/source-module-support.ts +0 -19
  514. package/src/services/runtime-state/dev-graph.service.ts +0 -217
  515. package/src/services/runtime-state/entrypoint-dependency-graph.service.ts +0 -136
  516. package/src/services/runtime-state/runtime-specifier-registry.service.ts +0 -96
  517. package/src/services/runtime-state/server-invalidation-state.service.ts +0 -68
  518. package/src/services/validation/schema-validation-service.test.ts +0 -223
  519. package/src/services/validation/schema-validation-service.ts +0 -204
  520. package/src/static-site-generator/static-site-generator.test.ts +0 -316
  521. package/src/static-site-generator/static-site-generator.ts +0 -462
  522. package/src/types/internal-types.ts +0 -242
  523. package/src/types/public-types.ts +0 -1443
  524. package/src/utils/deep-merge.test.ts +0 -114
  525. package/src/utils/deep-merge.ts +0 -47
  526. package/src/utils/hash.ts +0 -5
  527. package/src/utils/html-escaping.ts +0 -9
  528. package/src/utils/invariant.test.ts +0 -22
  529. package/src/utils/invariant.ts +0 -15
  530. package/src/utils/locals-utils.ts +0 -37
  531. package/src/utils/parse-cli-args.test.ts +0 -69
  532. package/src/utils/parse-cli-args.ts +0 -105
  533. package/src/utils/path-utils.module.ts +0 -14
  534. package/src/utils/path-utils.test.ts +0 -15
  535. package/src/utils/resolve-work-dir.ts +0 -45
  536. package/src/utils/runtime.ts +0 -44
  537. package/src/utils/server-utils.module.ts +0 -67
  538. package/src/utils/server-utils.test.ts +0 -38
  539. package/src/watchers/project-watcher.integration.test.ts +0 -337
  540. package/src/watchers/project-watcher.test-helpers.ts +0 -41
  541. package/src/watchers/project-watcher.test.ts +0 -768
  542. package/src/watchers/project-watcher.ts +0 -357
  543. /package/src/utils/{html.ts → html.d.ts} +0 -0
@@ -1,462 +0,0 @@
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
- }
@@ -1,242 +0,0 @@
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';