@ecopages/core 0.2.0-alpha.25 → 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,1443 +0,0 @@
1
- import type { Readable } from 'node:stream';
2
- import type { ApiResponseBuilder } from '../adapters/shared/api-response.ts';
3
- import type { BuildExecutor } from '../build/build-adapter.ts';
4
- import type { EcoBuildPlugin } from '../build/build-types.ts';
5
- import type { ComponentBoundaryRuntime } from '../route-renderer/orchestration/component-render-context.ts';
6
- import type { EcoPageComponent } from '../eco/eco.types.ts';
7
- import type { EcoPagesAppConfig } from './internal-types.ts';
8
- import type { HmrStrategy } from '../hmr/hmr-strategy.ts';
9
- import type { BrowserBundleExecutor } from '../services/assets/browser-bundle.service.ts';
10
- import type { ProcessedAsset } from '../services/assets/asset-processing-service/assets.types.ts';
11
- import type { CacheStats, CacheStrategy } from '../services/cache/cache.types.ts';
12
- import type { InteractionEventsString as ScriptsInjectorInteractionEventsString } from '@ecopages/scripts-injector/types';
13
-
14
- export type { EcoPagesAppConfig } from './internal-types.ts';
15
- export type { EcoPageComponent } from '../eco/eco.types.ts';
16
- export type { ProcessedAsset } from '../services/assets/asset-processing-service/assets.types.ts';
17
-
18
- import type {
19
- StandardSchema,
20
- StandardSchemaResult,
21
- StandardSchemaSuccessResult,
22
- StandardSchemaFailureResult,
23
- StandardSchemaIssue,
24
- InferOutput,
25
- } from '../services/validation/standard-schema.types.ts';
26
-
27
- export type {
28
- StandardSchema,
29
- StandardSchemaResult,
30
- StandardSchemaSuccessResult,
31
- StandardSchemaFailureResult,
32
- StandardSchemaIssue,
33
- InferOutput,
34
- ComponentBoundaryRuntime,
35
- };
36
-
37
- export type InteractionEventsString = ScriptsInjectorInteractionEventsString;
38
-
39
- export type DependencyLazyTrigger =
40
- | { 'on:idle': true }
41
- | { 'on:interaction': InteractionEventsString }
42
- | { 'on:visible': true | string };
43
-
44
- export type DependencyAttributes = Record<string, string>;
45
-
46
- export type EcoComponentStylesheetEntry = {
47
- src?: string;
48
- content?: string;
49
- attributes?: DependencyAttributes;
50
- };
51
-
52
- export type EcoComponentScriptEntry = {
53
- src?: string;
54
- content?: string;
55
- attributes?: DependencyAttributes;
56
- lazy?: DependencyLazyTrigger;
57
- ssr?: boolean;
58
- };
59
-
60
- export type ResolvedLazyScriptGroup = {
61
- lazy: DependencyLazyTrigger;
62
- scripts: string;
63
- };
64
-
65
- export type LazyTriggerRule =
66
- | { 'on:idle': { scripts: string[] } }
67
- | { 'on:interaction': { value: string; scripts: string[] } }
68
- | { 'on:visible': { value?: string; scripts: string[] } };
69
-
70
- export type ResolvedLazyTrigger = {
71
- triggerId: string;
72
- rules: LazyTriggerRule[];
73
- };
74
-
75
- /**
76
- * Narrow interface for cache invalidation in API handlers.
77
- * Exposes only the methods needed for programmatic cache control.
78
- */
79
- export interface CacheInvalidator {
80
- /**
81
- * Invalidate all cached entries matching any of the provided tags.
82
- * @param tags - Array of tags to invalidate
83
- * @returns Number of entries invalidated
84
- */
85
- invalidateByTags(tags: string[]): Promise<number>;
86
-
87
- /**
88
- * Invalidate cached entries by exact path.
89
- * @param paths - Array of URL paths to invalidate
90
- * @returns Number of entries invalidated
91
- */
92
- invalidateByPaths(paths: string[]): Promise<number>;
93
-
94
- /**
95
- * Clear all cached entries.
96
- */
97
- clear(): Promise<void>;
98
-
99
- /**
100
- * Get cache statistics for debugging.
101
- */
102
- stats(): Promise<CacheStats>;
103
- }
104
-
105
- /**
106
- * Context interface for HMR strategies.
107
- * Provides access to watched files, registered bare-specifier mappings, and build configuration.
108
- */
109
- export interface DefaultHmrContext {
110
- /**
111
- * Map of registered entrypoints to their output URLs.
112
- */
113
- getWatchedFiles(): Map<string, string>;
114
-
115
- /**
116
- * Map of bare specifiers to runtime URLs for browser import resolution.
117
- */
118
- getSpecifierMap(): Map<string, string>;
119
-
120
- /**
121
- * Directory where HMR bundles are written.
122
- */
123
- getDistDir(): string;
124
-
125
- /**
126
- * Build plugins to use during bundling.
127
- */
128
- getPlugins(): EcoBuildPlugin[];
129
-
130
- /**
131
- * Absolute path to the source directory.
132
- */
133
- getSrcDir(): string;
134
-
135
- /**
136
- * Absolute path to the layouts directory.
137
- * Used to detect layout file changes that require full page reloads.
138
- */
139
- getLayoutsDir(): string;
140
-
141
- /**
142
- * Absolute path to the pages directory.
143
- * Used by plugins to identify page files for transformation.
144
- */
145
- getPagesDir(): string;
146
-
147
- /**
148
- * Build executor owned by the active app/runtime.
149
- */
150
- getBuildExecutor(): BuildExecutor;
151
-
152
- /**
153
- * Browser bundler owned by the active app/runtime.
154
- */
155
- getBrowserBundleService(): BrowserBundleExecutor;
156
- /**
157
- * Server-side module loader owned by the active app/runtime.
158
- */
159
- importServerModule<T = unknown>(filePath: string): Promise<T>;
160
- }
161
-
162
- /**
163
- * Represents an event broadcast to connected clients via the ClientBridge.
164
- */
165
- export type ClientBridgeEvent = {
166
- /**
167
- * Event type: 'reload' triggers full refresh, 'update' for JS modules, 'css-update' for stylesheets, 'layout-update' for layout changes
168
- */
169
- type: 'reload' | 'error' | 'update' | 'css-update' | 'layout-update';
170
- /**
171
- * Path to the changed file
172
- */
173
- path?: string;
174
- /**
175
- * Optional message for error or debug info
176
- */
177
- message?: string;
178
- /**
179
- * Timestamp for cache busting
180
- */
181
- timestamp?: number;
182
- };
183
-
184
- /**
185
- * Adapter-agnostic interface for broadcasting development events to connected clients.
186
- * Implemented by both the Bun and Node client bridges.
187
- */
188
- export interface IClientBridge {
189
- broadcast(event: ClientBridgeEvent): void;
190
- reload(): void;
191
- cssUpdate(path: string): void;
192
- update(path: string): void;
193
- error(message: string): void;
194
- subscriberCount: number;
195
- }
196
-
197
- /**
198
- * Interface for the HMR Manager.
199
- * Used by integration plugins to register entrypoints and strategies.
200
- */
201
- export interface IHmrManager {
202
- /**
203
- * Registers an integration-owned client entrypoint to be built and watched.
204
- *
205
- * @remarks
206
- * This path is strict: the owning integration must emit the expected `_hmr`
207
- * bundle. Missing output is treated as a development pipeline failure.
208
- */
209
- registerEntrypoint(entrypointPath: string): Promise<string>;
210
-
211
- /**
212
- * Registers a generic script asset entrypoint to be built and watched.
213
- *
214
- * @remarks
215
- * This path exists for non-page script assets that are not owned by a
216
- * framework integration. Unlike `registerEntrypoint()`, it may use the generic
217
- * script bundling path.
218
- */
219
- registerScriptEntrypoint(entrypointPath: string): Promise<string>;
220
-
221
- /**
222
- * Registers mappings from bare specifiers to runtime URLs.
223
- *
224
- * @remarks
225
- * This is the shared registration seam for integration-owned runtime alias
226
- * maps. The registry may later back a broader import-map-style facility, but
227
- * the mappings themselves remain integration-owned.
228
- */
229
- registerSpecifierMap(map: Record<string, string>): void;
230
-
231
- /**
232
- * Registers a custom HMR strategy.
233
- */
234
- registerStrategy(strategy: HmrStrategy): void;
235
-
236
- /**
237
- * Sets the build plugins to use during bundling.
238
- */
239
- setPlugins(plugins: EcoBuildPlugin[]): void;
240
-
241
- /**
242
- * Enables or disables HMR.
243
- */
244
- setEnabled(enabled: boolean): void;
245
-
246
- /**
247
- * Returns whether HMR is enabled.
248
- */
249
- isEnabled(): boolean;
250
-
251
- /**
252
- * Broadcasts an HMR event to connected clients.
253
- */
254
- broadcast(event: ClientBridgeEvent): void;
255
-
256
- /**
257
- * Gets the output URL for a registered entrypoint.
258
- */
259
- getOutputUrl(entrypointPath: string): string | undefined;
260
-
261
- /**
262
- * Gets the map of watched files.
263
- */
264
- getWatchedFiles(): Map<string, string>;
265
-
266
- /**
267
- * Gets the registered bare-specifier map.
268
- */
269
- getSpecifierMap(): Map<string, string>;
270
-
271
- /**
272
- * Gets the HMR dist directory.
273
- */
274
- getDistDir(): string;
275
-
276
- /**
277
- * Gets the build plugins.
278
- */
279
- getPlugins(): EcoBuildPlugin[];
280
-
281
- /**
282
- * Gets the default HMR context.
283
- */
284
- getDefaultContext(): DefaultHmrContext;
285
-
286
- /**
287
- * Handles a file change event.
288
- */
289
- handleFileChange(path: string): Promise<void>;
290
- }
291
-
292
- /**
293
- * Represents the dependencies for an EcoComponent.
294
- */
295
- export type EcoComponentDependencies = {
296
- stylesheets?: Array<string | EcoComponentStylesheetEntry>;
297
- scripts?: Array<string | EcoComponentScriptEntry>;
298
- /**
299
- * Browser module declarations resolved from node_modules.
300
- *
301
- * Supports grammar entries such as `react-aria-components{Table,Select}`
302
- * to express explicit module imports for client bundles.
303
- */
304
- modules?: string[];
305
- components?: EcoComponent[];
306
- };
307
-
308
- export type EcoPagesElement = string | Promise<string>;
309
-
310
- /**
311
- * Serializable child payloads accepted by cross-integration deferred rendering.
312
- *
313
- * This models the broad value shapes that EcoPages already flattens when a
314
- * foreign component boundary serializes its children for another integration.
315
- * It is intentionally transport-oriented rather than framework-native, so it
316
- * can be shared across Kita, Lit, React, and Ecopages JSX authoring surfaces
317
- * without coupling core types to any one renderer.
318
- */
319
- export type EcoChildren =
320
- | string
321
- | Promise<string>
322
- | number
323
- | bigint
324
- | boolean
325
- | null
326
- | undefined
327
- | readonly EcoChildren[]
328
- | {
329
- strings: readonly string[];
330
- values?: readonly EcoChildren[];
331
- }
332
- | {
333
- [key: string]: EcoChildren;
334
- };
335
-
336
- /**
337
- * Represents the input configuration for EcoPages.
338
- */
339
- export type EcoPagesConfig = Omit<
340
- Partial<EcoPagesAppConfig>,
341
- 'baseUrl' | 'derivedPaths' | 'templatesExt' | 'integrationsDependencies'
342
- > &
343
- Pick<EcoPagesAppConfig, 'baseUrl' | 'rootDir'>;
344
-
345
- /**
346
- * Internal metadata injected by eco-component-meta-plugin.
347
- * Contains component file path and integration info for dependency resolution.
348
- * @internal
349
- */
350
- export interface EcoInjectedMeta {
351
- /** Hashed identifier for client-side use (doesn't expose file paths) */
352
- id: string;
353
- /** Full file path of the component (use path.dirname() to get directory) */
354
- file: string;
355
- /** The integration identifier (e.g., 'react', 'kitajs', 'lit', 'ghtml', 'mdx') */
356
- integration: string;
357
- }
358
-
359
- export type EcoComponentConfig = {
360
- /** @internal Injected by eco-component-meta-plugin */
361
- __eco?: EcoInjectedMeta;
362
- /**
363
- * Explicit integration override for this component.
364
- * When provided, this takes precedence over auto-detected integration metadata.
365
- */
366
- integration?: string;
367
- /**
368
- * The layout component to wrap this page during rendering.
369
- *
370
- * The layout receives the page content as `children` and is responsible for
371
- * providing the page structure (header, footer, navigation, etc.).
372
- *
373
- * For React pages with client-side routing, the layout also handles the router context.
374
- * Use `EcoRouter` and `PageContent` from `@ecopages/react-router` in layouts that
375
- * need SPA navigation support.
376
- *
377
- * @example
378
- * ```tsx
379
- * // Simple layout (no routing)
380
- * const Layout = ({ children }) => <main>{children}</main>;
381
- *
382
- * // Layout with SPA routing
383
- * const Layout = ({ children }) => (
384
- * <EcoRouter page={...} pageProps={...}>
385
- * <Header />
386
- * <PageContent />
387
- * </EcoRouter>
388
- * );
389
- *
390
- * // Page using the layout
391
- * const MyPage = () => <h1>Hello</h1>;
392
- * MyPage.config = { layout: Layout };
393
- * ```
394
- */
395
- layout?: EcoPageLayoutComponent<any>;
396
- dependencies?: EcoComponentDependencies;
397
- /**
398
- * Internal: Resolved lazy scripts grouped by trigger.
399
- * Set by the renderer, used by eco.component() for multi-trigger auto-wrapping.
400
- * @internal
401
- */
402
- _resolvedLazyScripts?: ResolvedLazyScriptGroup[];
403
- /**
404
- * Internal: Resolved lazy triggers for the global injector map.
405
- * Set by the renderer in the default full orchestration flow.
406
- * @internal
407
- */
408
- _resolvedLazyTriggers?: ResolvedLazyTrigger[];
409
- };
410
-
411
- /**
412
- * The base structure for any EcoPages component.
413
- */
414
- export type EcoComponentBase = {
415
- /**
416
- * The configuration options for the EcoComponent.
417
- */
418
- config?: EcoComponentConfig;
419
-
420
- /**
421
- * Static paths for dynamic routes (consolidated eco.page API).
422
- * @internal Used by the renderer to retrieve static paths from the page component.
423
- */
424
- staticPaths?: GetStaticPaths;
425
-
426
- /**
427
- * Static props fetcher (consolidated eco.page API).
428
- * @internal Used by the renderer to retrieve static props from the page component.
429
- */
430
- staticProps?: GetStaticProps<any>;
431
-
432
- /**
433
- * Metadata generator (consolidated eco.page API).
434
- * @internal Used by the renderer to retrieve metadata from the page component.
435
- */
436
- metadata?: GetMetadata<any>;
437
- };
438
-
439
- /**
440
- * Checks if a type is `any`.
441
- */
442
- export type IsAny<T> = 0 extends 1 & T ? true : false;
443
-
444
- /**
445
- * A function component type that is framework-agnostic.
446
- * Uses a broader signature to support both direct calls and HOC wrappers.
447
- */
448
- export type EcoFunctionComponent<P, R> = {
449
- (props: P, ...args: any[]): R;
450
- } & EcoComponentBase;
451
-
452
- /**
453
- * Represents an EcoComponent.
454
- *
455
- * It can be defined by passing the props type as the first generic,
456
- * or by passing the component type itself to infer the signature.
457
- *
458
- * @template T - The type of the props object or the component function itself.
459
- * @template C - The type of the rendered element.
460
- *
461
- * @example
462
- * //1. Simplest usage
463
- * export const MyComponent: EcoComponent<{prop1: string}> = ({prop1}) => {
464
- * return <div>...</div>;
465
- * };
466
- *
467
- * @example
468
- * // 2. Using with HOCs like MobX observer (passing the props type)
469
- * export const MyObservedComponent: EcoComponent<object> = observer(function MyObservedComponent() {
470
- * return <div>...</div>;
471
- * });
472
- *
473
- * @example
474
- * // 3. Passing the full function signature (Perfect for Generic Components)
475
- * export const Select: EcoComponent<<T extends object>(props: SelectProps<T>) => JSX.Element> = <T extends object>({
476
- * label,
477
- * items,
478
- * }: SelectProps<T>) => {
479
- * return <select>...</select>;
480
- * };
481
- */
482
- /**
483
- * A function component type that is framework-agnostic.
484
- * Uses a broader signature to support both direct calls and HOC wrappers.
485
- */
486
- export type EcoComponent<P = any, R = any> =
487
- IsAny<P> extends true
488
- ? EcoFunctionComponent<any, any> | EcoComponentBase
489
- : P extends (props: infer Props, ...args: any[]) => infer Return
490
- ? EcoFunctionComponent<Props, Return>
491
- : EcoFunctionComponent<P, R>;
492
-
493
- /**
494
- * Represents a page in EcoPages.
495
- */
496
- export type PageProps<T = unknown> = T & StaticPageContext & { locals?: RequestLocals };
497
-
498
- /**
499
- * Represents the metadata for a page.
500
- */
501
- export interface PageMetadataProps {
502
- title: string;
503
- description: string;
504
- image?: string;
505
- url?: string;
506
- keywords?: string[];
507
- }
508
-
509
- /**
510
- * Represents the props for the head of a page.
511
- */
512
- export interface PageHeadProps<T = EcoPagesElement> {
513
- metadata: PageMetadataProps;
514
- dependencies?: EcoComponentDependencies;
515
- children?: T;
516
- }
517
-
518
- /**
519
- * Represents the props for a route layout.
520
- */
521
- export interface LayoutProps<T = EcoPagesElement> extends Partial<RequestPageContext> {
522
- children: T;
523
- }
524
-
525
- /**
526
- * Represents the props for the HTML template of a page.
527
- */
528
- export interface HtmlTemplateProps extends PageHeadProps {
529
- children: EcoPagesElement;
530
- language?: string;
531
- headContent?: EcoPagesElement;
532
- pageProps: Record<string, unknown>;
533
- }
534
-
535
- /**
536
- * Layout components accepted by pages.
537
- *
538
- * This preserves compatibility with existing `eco.component()` layouts while
539
- * also supporting semantic `eco.layout()` declarations.
540
- */
541
- export type EcoPageLayoutComponent<T = EcoPagesElement> = EcoLayoutComponent<T> | EcoComponent<any, T>;
542
-
543
- /**
544
- * Represents a layout component created with eco.layout().
545
- */
546
- export type EcoLayoutComponent<T = EcoPagesElement> = EcoComponent<LayoutProps<T>, T>;
547
-
548
- /**
549
- * Represents an HTML shell component created with eco.html().
550
- */
551
- export type EcoHtmlComponent<T = EcoPagesElement> = EcoComponent<HtmlTemplateProps, T>;
552
-
553
- /**
554
- * Represents the props for the error 404 template.
555
- */
556
- export interface Error404TemplateProps extends Omit<HtmlTemplateProps, 'children'> {
557
- message: string;
558
- stack?: string;
559
- }
560
-
561
- /**
562
- * Represents the parameters for a page.
563
- * The keys are strings, and the values can be either a string or an array of strings.
564
- */
565
- export type PageParams = Record<string, string | string[]>;
566
-
567
- /**
568
- * Represents a query object for a page.
569
- * The keys are strings and the values can be either a string or an array of strings.
570
- */
571
- export type PageQuery = Record<string, string | string[]>;
572
-
573
- /**
574
- * Request-scoped data that is only available during request-time rendering.
575
- *
576
- * Apps should augment this interface via module augmentation:
577
- *
578
- * declare module '@ecopages/core' {
579
- * interface RequestLocals { session?: Session | null }
580
- * }
581
- */
582
- export interface RequestLocals {}
583
-
584
- /**
585
- * Represents the context object for a static page.
586
- */
587
- export type StaticPageContext = {
588
- params?: PageParams;
589
- query?: PageQuery;
590
- };
591
-
592
- /**
593
- * Request-time page context.
594
- *
595
- * This is only populated during SSR. Static generation must not access locals.
596
- */
597
- export type RequestPageContext = {
598
- locals: RequestLocals;
599
- };
600
-
601
- /**
602
- * Adds optional `locals` to a props type.
603
- * Primarily used for layouts that may receive request-scoped data from middleware.
604
- *
605
- * @template P - The base props type
606
- *
607
- * @example
608
- * ```ts
609
- * type MyLayoutProps = WithLocals<{ children: ReactNode }>;
610
- * // { children: ReactNode; locals?: RequestLocals }
611
- * ```
612
- */
613
- export type WithLocals<P> = P & { locals?: RequestLocals };
614
-
615
- /**
616
- * Represents the params for a static path.
617
- */
618
- export type StaticPath = { params: PageParams };
619
-
620
- /**
621
- * The function that returns the static paths for a page.
622
- */
623
- export type GetStaticPaths = (context: { appConfig: EcoPagesAppConfig; runtimeOrigin: string }) => Promise<{
624
- paths: StaticPath[];
625
- }>;
626
-
627
- /**
628
- * The context object for the getMetadata function.
629
- */
630
- export type GetMetadataContext<T = Record<string, unknown>> = Required<StaticPageContext> & {
631
- props: T;
632
- appConfig: EcoPagesAppConfig;
633
- };
634
-
635
- /**
636
- * The function that returns the metadata for a page.
637
- */
638
- export type GetMetadata<T = Record<string, unknown>> = (
639
- context: GetMetadataContext<T>,
640
- ) => PageMetadataProps | Promise<PageMetadataProps>;
641
-
642
- /**
643
- * The function that returns the static props for a page.
644
- */
645
- export type GetStaticProps<T> = (context: {
646
- pathname: StaticPath;
647
- appConfig: EcoPagesAppConfig;
648
- runtimeOrigin: string;
649
- }) => Promise<{
650
- props: T;
651
- }>;
652
-
653
- /**
654
- * Represents a page file in EcoPages.
655
- * @template T - The type of the page props.
656
- */
657
- export type EcoPageFile<T = unknown> = T & {
658
- default: EcoComponent<any, any>;
659
- getStaticPaths?: GetStaticPaths;
660
- getStaticProps?: GetStaticProps<Record<string, unknown>>;
661
- getMetadata?: GetMetadata;
662
- cache?: CacheStrategy;
663
- };
664
-
665
- /**
666
- * Represents a CSS processor.
667
- */
668
- export interface CssProcessor {
669
- /**
670
- * Processes a CSS file at the specified path.
671
- * @param path - The path to the CSS file.
672
- * @returns A promise that resolves to the processed CSS as a string.
673
- */
674
- processPath: (path: string, options?: any) => Promise<string>;
675
-
676
- /**
677
- * Processes a CSS string or buffer.
678
- * @param contents - The CSS contents as a string or buffer.
679
- * @returns A promise that resolves to the processed CSS as a string.
680
- */
681
- processStringOrBuffer: (contents: string | Buffer, options?: any) => Promise<string>;
682
- }
683
-
684
- /**
685
- * The options for the route renderer.
686
- */
687
- export type RouteRendererOptions = {
688
- file: string;
689
- params?: PageParams;
690
- query?: PageQuery;
691
- locals?: RequestLocals;
692
- };
693
-
694
- /**
695
- * The body of the route renderer.
696
- */
697
- export type RouteRendererBody = BodyInit | Readable;
698
-
699
- /**
700
- * Result of rendering a route, including body and optional cache configuration.
701
- */
702
- export type RouteRenderResult = {
703
- body: RouteRendererBody;
704
- /** Cache strategy from page component's eco.page({ cache }) option */
705
- cacheStrategy?: CacheStrategy;
706
- };
707
-
708
- /**
709
- * Represents the dependencies required for an integration plugin.
710
- * It combines the base integration plugin dependencies with specific integration plugin dependencies.
711
- */
712
- export type IntegrationPluginDependencies = BaseIntegrationPluginDependencies & SpecificIntegrationPluginDependencies;
713
-
714
- type BaseIntegrationPluginDependencies = {
715
- inline?: boolean;
716
- };
717
-
718
- /**
719
- * Represents the dependencies required for a specific integration plugin.
720
- * It can be one of the following types:
721
- * {@link ScriptImportIntegrationPluginDependencies}
722
- * {@link ScriptContentIntegrationPluginDependencies}
723
- * {@link StylesheetImportIntegrationPluginDependencies}
724
- * {@link StylesheetContentIntegrationPluginDependencies}
725
- */
726
- type SpecificIntegrationPluginDependencies =
727
- | ScriptImportIntegrationPluginDependencies
728
- | ScriptContentIntegrationPluginDependencies
729
- | StylesheetImportIntegrationPluginDependencies
730
- | StylesheetContentIntegrationPluginDependencies;
731
-
732
- /**
733
- * Script dependencies for an integration plugin with an import path.
734
- */
735
- type ScriptImportIntegrationPluginDependencies = {
736
- kind: 'script';
737
- importPath: string;
738
- position?: 'head' | 'body';
739
- /** @default true */
740
- minify?: boolean;
741
- };
742
-
743
- /**
744
- * Script dependencies for an integration plugin with content.
745
- */
746
- type ScriptContentIntegrationPluginDependencies = {
747
- kind: 'script';
748
- content: string;
749
- position?: 'head' | 'body';
750
- /** @default true */
751
- minify?: boolean;
752
- };
753
-
754
- /**
755
- * Stylesheet dependencies for an integration plugin with an import path.
756
- */
757
- type StylesheetImportIntegrationPluginDependencies = {
758
- kind: 'stylesheet';
759
- importPath: string;
760
- };
761
-
762
- /**
763
- * Stylesheet dependencies for an integration plugin with content.
764
- */
765
- type StylesheetContentIntegrationPluginDependencies = {
766
- kind: 'stylesheet';
767
- content: string;
768
- };
769
-
770
- /**
771
- * The options for the integration renderer.
772
- */
773
- export type IntegrationRendererRenderOptions<C = EcoPagesElement> = RouteRendererOptions & {
774
- props?: Record<string, unknown>;
775
- metadata: PageMetadataProps;
776
- HtmlTemplate: EcoHtmlComponent<C>;
777
- Page: EcoComponent<PageProps, C>;
778
- Layout?: EcoPageLayoutComponent<any>;
779
- dependencies?: EcoComponentDependencies;
780
- resolvedDependencies: ProcessedAsset[];
781
- pagePackage?: PagePackageResult;
782
- componentRender?: ComponentRenderResult;
783
- pageProps?: Record<string, unknown>;
784
- cacheStrategy?: CacheStrategy;
785
- pageLocals?: RequestLocals;
786
- boundaryPlan?: BoundaryPlan;
787
- };
788
-
789
- /**
790
- * Structured page asset package produced after dependency resolution.
791
- *
792
- * `assets` retains the full processed asset list, while the remaining fields
793
- * split that list into the subsets used during final HTML injection and
794
- * renderer-owned follow-up work.
795
- */
796
- export interface PagePackageResult {
797
- /**
798
- * Full processed asset list before any page-level partitioning.
799
- */
800
- assets: ProcessedAsset[];
801
- /**
802
- * Assets that should still be injected into the final HTML document.
803
- */
804
- htmlAssets: ProcessedAsset[];
805
- /**
806
- * Primary page-owned browser entry when one was identified during packaging.
807
- */
808
- pageScript?: ProcessedAsset;
809
- /**
810
- * Primary page-owned stylesheet when one was identified during packaging.
811
- */
812
- pageStylesheet?: ProcessedAsset;
813
- /**
814
- * Inline assets that remain embedded directly in the document.
815
- */
816
- inlineAssets: ProcessedAsset[];
817
- /**
818
- * Assets kept outside the main page package so callers can manage them explicitly.
819
- */
820
- separateAssets: ProcessedAsset[];
821
- /**
822
- * Browser chunks needed after initial page bootstrap, including eager lazy-entry bundles.
823
- */
824
- dynamicChunks: ProcessedAsset[];
825
- }
826
-
827
- export type BoundaryValidationErrorCode = 'UNKNOWN_INTEGRATION_OWNER' | 'MISSING_COMPONENT_METADATA';
828
-
829
- export interface BoundaryValidationError {
830
- code: BoundaryValidationErrorCode;
831
- message: string;
832
- componentId?: string;
833
- componentFile?: string;
834
- integrationName?: string;
835
- }
836
-
837
- export type BoundaryPlanNodeSource = 'route' | 'page' | 'layout' | 'html-template' | 'dependency';
838
-
839
- export interface BoundaryOwnership {
840
- integrationName: string;
841
- componentId: string;
842
- componentFile?: string;
843
- isPageEntry: boolean;
844
- isForeignToParent: boolean;
845
- }
846
-
847
- export interface BoundaryPlanNode {
848
- id: string;
849
- source: BoundaryPlanNodeSource;
850
- ownership: BoundaryOwnership;
851
- children: BoundaryPlanNode[];
852
- declaredDependenciesValid: boolean;
853
- }
854
-
855
- export interface BoundaryPlan {
856
- root: BoundaryPlanNode;
857
- rendererNames: string[];
858
- foreignEdgeCount: number;
859
- hasValidationErrors: boolean;
860
- validationErrors: BoundaryValidationError[];
861
- }
862
-
863
- export type BoundaryAttachmentPolicy = { kind: 'none' } | { kind: 'first-element' };
864
-
865
- export interface BoundaryRenderPayload {
866
- html: string;
867
- assets: ProcessedAsset[];
868
- rootTag?: string;
869
- rootAttributes?: Record<string, string>;
870
- attachmentPolicy: BoundaryAttachmentPolicy;
871
- integrationName: string;
872
- }
873
-
874
- /**
875
- * Shared execution-scoped context threaded through component boundary renders.
876
- *
877
- * Integrations can extend this with renderer-local runtime keys, but the cache
878
- * and optional component instance identity are shared across all renderers.
879
- */
880
- export interface BaseIntegrationContext {
881
- rendererCache?: Map<string, unknown>;
882
- componentInstanceId?: string;
883
- }
884
-
885
- export interface ComponentRenderInput<TIntegrationContext extends BaseIntegrationContext = BaseIntegrationContext> {
886
- component: EcoComponent;
887
- props: Record<string, unknown>;
888
- children?: unknown;
889
- integrationContext?: TIntegrationContext;
890
- }
891
-
892
- export interface ComponentRenderResult {
893
- html: string;
894
- canAttachAttributes: boolean;
895
- rootTag?: string;
896
- integrationName: string;
897
- rootAttributes?: Record<string, string>;
898
- assets?: ProcessedAsset[];
899
- }
900
-
901
- /**
902
- * Represents a deep required type for a given object
903
- */
904
- export type DeepRequired<T> = Required<{
905
- [K in keyof T]: T[K] extends Required<T[K]> ? T[K] : DeepRequired<T[K]>;
906
- }>;
907
-
908
- /**
909
- * The Prettify helper is a utility type that takes an object type and makes the hover overlay more readable.
910
- */
911
- export type Prettify<T> = {
912
- [K in keyof T]: T[K];
913
- } & {};
914
-
915
- /**
916
- * Services available to API handlers.
917
- */
918
- export interface ApiHandlerServices {
919
- /**
920
- * Cache invalidation service.
921
- * Null when caching is disabled.
922
- */
923
- cache: CacheInvalidator | null;
924
- }
925
-
926
- /**
927
- * Options for rendering a view.
928
- */
929
- export interface RenderOptions {
930
- status?: number;
931
- headers?: HeadersInit;
932
- }
933
-
934
- /**
935
- * Options for JSON/HTML response helpers.
936
- */
937
- export interface ResponseOptions {
938
- status?: number;
939
- headers?: HeadersInit;
940
- }
941
-
942
- /**
943
- * Context for rendering views in route handlers.
944
- * Provides methods to render eco.page views and return formatted responses.
945
- */
946
- export interface RenderContext {
947
- /**
948
- * Render an eco.page view with full layout and includes.
949
- * @param view - The eco.page component to render
950
- * @param props - Props to pass to the view
951
- * @param options - Optional status code and headers
952
- */
953
- render<P = Record<string, unknown>>(view: EcoComponent<P>, props?: P, options?: RenderOptions): Promise<Response>;
954
-
955
- /**
956
- * Render an eco.page view without layout (for partials/fragments).
957
- * @param view - The eco.page component to render
958
- * @param props - Props to pass to the view
959
- * @param options - Optional status code and headers
960
- */
961
- renderPartial<P = Record<string, unknown>>(
962
- view: EcoComponent<P>,
963
- props: P,
964
- options?: RenderOptions,
965
- ): Promise<Response>;
966
-
967
- /**
968
- * Return a JSON response.
969
- * @param data - Data to serialize as JSON
970
- * @param options - Optional status code and headers
971
- */
972
- json(data: unknown, options?: ResponseOptions): Response;
973
-
974
- /**
975
- * Return an HTML response.
976
- * @param content - HTML string content
977
- * @param options - Optional status code and headers
978
- */
979
- html(content: string, options?: ResponseOptions): Response;
980
- }
981
-
982
- /**
983
- * Context provided to the API handler.
984
- */
985
- export interface ApiHandlerContext<TRequest extends Request = Request, TServer = any> extends RenderContext {
986
- request: TRequest;
987
- params: Record<string, string>;
988
- response: ApiResponseBuilder;
989
- server: TServer;
990
- /**
991
- * Request-scoped data store.
992
- * Only valid during request-time handling (SSR/API). Must not be used for static generation.
993
- */
994
- locals: RequestLocals;
995
- /**
996
- * Require one or more locals keys. If missing, executes `onMissing` to produce a terminating Response.
997
- */
998
- require: {
999
- <K extends keyof RequestLocals>(key: K, onMissing: () => Response): Exclude<RequestLocals[K], null | undefined>;
1000
- <K extends keyof RequestLocals>(
1001
- keys: readonly K[],
1002
- onMissing: () => Response,
1003
- ): { [P in K]-?: Exclude<RequestLocals[P], null | undefined> };
1004
- };
1005
- /**
1006
- * Services available to the API handler.
1007
- */
1008
- services: ApiHandlerServices;
1009
- /**
1010
- * Parsed and optionally validated request body.
1011
- *
1012
- * - Without schema: Contains the parsed JSON body as `unknown`
1013
- * - With schema: Contains the validated and type-safe body data
1014
- *
1015
- * For raw access to the request body stream, use `ctx.request.body`.
1016
- *
1017
- * @example Without validation
1018
- * ```typescript
1019
- * app.post('/posts', async (ctx) => {
1020
- * const data = ctx.body; // [unknown] - parsed JSON
1021
- * return ctx.json({ received: data });
1022
- * });
1023
- * ```
1024
- *
1025
- * @example With validation
1026
- * ```typescript
1027
- * import { z } from 'zod';
1028
- *
1029
- * app.post('/posts', async (ctx) => {
1030
- * const { title, author } = ctx.body; // [type-safe]
1031
- * return ctx.json({ title, author });
1032
- * }, {
1033
- * schema: {
1034
- * body: z.object({ title: z.string(), author: z.string() })
1035
- * }
1036
- * });
1037
- * ```
1038
- *
1039
- * Validation runs before the handler executes. Invalid requests receive a 400 response.
1040
- */
1041
- body?: unknown;
1042
- /**
1043
- * Parsed and optionally validated query parameters.
1044
- *
1045
- * - Without schema: Contains the parsed query params as a string record
1046
- * - With schema: Contains the validated and type-safe query data
1047
- *
1048
- * For raw access to query parameters, use `ctx.request.url` and parse manually.
1049
- *
1050
- * @example Pagination with type coercion
1051
- * ```typescript
1052
- * import { z } from 'zod';
1053
- *
1054
- * app.get('/posts', async (ctx) => {
1055
- * const { page, limit, sortBy } = ctx.query;
1056
- * // page: number, limit: number, sortBy: 'date' | 'title' | 'views'
1057
- * return ctx.json({ page, limit, sortBy });
1058
- * }, {
1059
- * schema: {
1060
- * query: z.object({
1061
- * page: z.coerce.number().min(1).default(1),
1062
- * limit: z.coerce.number().min(1).max(100).default(20),
1063
- * sortBy: z.enum(['date', 'title', 'views']).default('date')
1064
- * })
1065
- * }
1066
- * });
1067
- * ```
1068
- *
1069
- * @example Search with filters
1070
- * ```typescript
1071
- * app.get('/search', async (ctx) => {
1072
- * const { q, category } = ctx.query;
1073
- * return ctx.json({ results: await search(q, category) });
1074
- * }, {
1075
- * schema: {
1076
- * query: z.object({
1077
- * q: z.string().min(2).max(100),
1078
- * category: z.enum(['posts', 'users', 'comments']).optional()
1079
- * })
1080
- * }
1081
- * });
1082
- * ```
1083
- */
1084
- query?: unknown;
1085
- /**
1086
- * Parsed and optionally validated request headers.
1087
- *
1088
- * - Without schema: Contains the parsed headers as a string record
1089
- * - With schema: Contains the validated and type-safe header data
1090
- *
1091
- * For raw access to headers, use `ctx.request.headers`.
1092
- *
1093
- * @example API key authentication
1094
- * ```typescript
1095
- * import { z } from 'zod';
1096
- *
1097
- * app.post('/api/webhooks', async (ctx) => {
1098
- * const apiKey = ctx.headers['x-api-key'];
1099
- * // apiKey is guaranteed to be a valid UUID
1100
- * return ctx.json({ received: true });
1101
- * }, {
1102
- * schema: {
1103
- * headers: z.object({
1104
- * 'x-api-key': z.string().uuid()
1105
- * })
1106
- * }
1107
- * });
1108
- * ```
1109
- *
1110
- * @example Webhook signature validation
1111
- * ```typescript
1112
- * app.post('/webhooks/stripe', async (ctx) => {
1113
- * const signature = ctx.headers['stripe-signature'];
1114
- * // signature is guaranteed to exist
1115
- * const isValid = verifyStripeSignature(ctx.body, signature);
1116
- * return ctx.json({ verified: isValid });
1117
- * }, {
1118
- * schema: {
1119
- * headers: z.object({
1120
- * 'stripe-signature': z.string().min(1)
1121
- * })
1122
- * }
1123
- * });
1124
- * ```
1125
- *
1126
- * @example Content negotiation
1127
- * ```typescript
1128
- * app.post('/api/data', async (ctx) => {
1129
- * const { accept } = ctx.headers;
1130
- * if (accept === 'application/xml') {
1131
- * return ctx.html(toXml(data), { headers: { 'Content-Type': 'application/xml' } });
1132
- * }
1133
- * return ctx.json(data);
1134
- * }, {
1135
- * schema: {
1136
- * headers: z.object({
1137
- * 'content-type': z.literal('application/json'),
1138
- * accept: z.enum(['application/json', 'application/xml']).optional()
1139
- * })
1140
- * }
1141
- * });
1142
- * ```
1143
- */
1144
- headers?: unknown;
1145
- }
1146
-
1147
- /**
1148
- * Next function for middleware chain.
1149
- * Call to continue to the next middleware or final handler.
1150
- */
1151
- export type MiddlewareNext = () => Promise<Response>;
1152
-
1153
- /**
1154
- * Middleware function signature.
1155
- * Receives the request context and a next function to continue the chain.
1156
- * Can short-circuit by returning a Response directly without calling next().
1157
- *
1158
- * @typeParam TRequest - Request type
1159
- * @typeParam TServer - Server type
1160
- * @typeParam TContext - Extended context type, defaults to base ApiHandlerContext
1161
- *
1162
- * @example Basic middleware (no context extension)
1163
- * ```typescript
1164
- * const loggingMiddleware: Middleware = async (ctx, next) => {
1165
- * console.log(`${ctx.request.method} ${ctx.request.url}`);
1166
- * return next();
1167
- * };
1168
- * ```
1169
- *
1170
- * @example Middleware with extended context (use EcoMiddleware helper)
1171
- * ```typescript
1172
- * type AuthContext = ApiHandlerContext<BunRequest<string>, Server> & { user: User };
1173
- *
1174
- * const authMiddleware: EcoMiddleware<AuthContext> = async (ctx, next) => {
1175
- * const user = await authenticate(ctx.request);
1176
- * if (!user) return ctx.response.status(401).json({ error: 'Unauthorized' });
1177
- * ctx.user = user;
1178
- * return next();
1179
- * };
1180
- * ```
1181
- */
1182
- export type Middleware<
1183
- TRequest extends Request = Request,
1184
- TServer = any,
1185
- TContext extends ApiHandlerContext<TRequest, TServer> = ApiHandlerContext<TRequest, TServer>,
1186
- > = (context: TContext, next: MiddlewareNext) => Promise<Response> | Response;
1187
-
1188
- /**
1189
- * Helper type for defining middleware with extended context.
1190
- * Automatically infers TRequest and TServer from the provided context type.
1191
- *
1192
- * @typeParam TContext - The extended context type that includes TRequest and TServer
1193
- *
1194
- * @example
1195
- * ```typescript
1196
- * type AuthContext = ApiHandlerContext<BunRequest<string>, Server> & {
1197
- * session: { user: User };
1198
- * };
1199
- *
1200
- * const authMiddleware: EcoMiddleware<AuthContext> = async (ctx, next) => {
1201
- * const session = await authenticate(ctx.request);
1202
- * if (!session) return Response.redirect('/login');
1203
- * ctx.session = session;
1204
- * return next();
1205
- * };
1206
- * ```
1207
- */
1208
- export type EcoMiddleware<TContext extends ApiHandlerContext<any, any>> =
1209
- TContext extends ApiHandlerContext<infer TRequest, infer TServer> ? Middleware<TRequest, TServer, TContext> : never;
1210
-
1211
- /**
1212
- * Represents an API handler in EcoPages.
1213
- * Defines the path, method, handler function, optional middleware, and validation schemas.
1214
- *
1215
- * @example Basic handler
1216
- * ```typescript
1217
- * app.get('/users/:id', async (ctx) => {
1218
- * return ctx.json({ id: ctx.params.id });
1219
- * });
1220
- * ```
1221
- *
1222
- * @example With validation
1223
- * ```typescript
1224
- * import { z } from 'zod';
1225
- *
1226
- * app.post('/posts', async (ctx) => {
1227
- * const { title, content } = ctx.body;
1228
- * return ctx.json({ success: true, title, content });
1229
- * }, {
1230
- * schema: {
1231
- * body: z.object({
1232
- * title: z.string().min(3),
1233
- * content: z.string()
1234
- * })
1235
- * }
1236
- * });
1237
- * ```
1238
- *
1239
- * @example With middleware
1240
- * ```typescript
1241
- * const authMiddleware = async (ctx, next) => {
1242
- * if (!ctx.request.headers.get('authorization')) {
1243
- * return ctx.response.status(401).json({ error: 'Unauthorized' });
1244
- * }
1245
- * return next();
1246
- * };
1247
- *
1248
- * app.get('/protected', async (ctx) => {
1249
- * return ctx.json({ message: 'Secret data' });
1250
- * }, {
1251
- * middleware: [authMiddleware]
1252
- * });
1253
- * ```
1254
- *
1255
- * @example Multiple validations
1256
- * ```typescript
1257
- * import { z } from 'zod';
1258
- *
1259
- * app.post('/api/search', async (ctx) => {
1260
- * const { q, page } = ctx.query;
1261
- * const filters = ctx.body;
1262
- * return ctx.json({ query: q, page, filters });
1263
- * }, {
1264
- * schema: {
1265
- * query: z.object({ q: z.string(), page: z.string() }),
1266
- * body: z.object({ category: z.string().optional() })
1267
- * }
1268
- * });
1269
- * ```
1270
- */
1271
- export interface ApiHandler<TPath extends string = string, TRequest extends Request = Request, TServer = any> {
1272
- path: TPath;
1273
- method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS' | 'HEAD';
1274
- handler: (context: ApiHandlerContext<TRequest, TServer>) => Promise<Response> | Response;
1275
- /** Optional middleware chain executed before the handler */
1276
- middleware?: Middleware<TRequest, TServer, any>[];
1277
- /** Optional validation schemas for request body, query parameters, and headers */
1278
- schema?: {
1279
- body?: StandardSchema;
1280
- query?: StandardSchema;
1281
- headers?: StandardSchema;
1282
- params?: StandardSchema;
1283
- };
1284
- }
1285
-
1286
- /**
1287
- * Global error handler for centralized error handling across all routes.
1288
- * Receives the error and full request context, returns a Response.
1289
- * Falls back to default handling if the handler itself throws.
1290
- */
1291
- export type ErrorHandler<TRequest extends Request = Request, TServer = any> = (
1292
- error: unknown,
1293
- context: ApiHandlerContext<TRequest, TServer>,
1294
- ) => Promise<Response> | Response;
1295
-
1296
- /**
1297
- * Options for route handlers.
1298
- */
1299
- export interface RouteOptions<
1300
- TRequest extends Request = Request,
1301
- TServer = any,
1302
- TContext extends ApiHandlerContext<TRequest, TServer> = ApiHandlerContext<TRequest, TServer>,
1303
- > {
1304
- middleware?: Middleware<TRequest, TServer, TContext>[];
1305
- schema?: RouteSchema;
1306
- }
1307
-
1308
- export interface RouteSchema {
1309
- body?: StandardSchema;
1310
- query?: StandardSchema;
1311
- headers?: StandardSchema;
1312
- params?: StandardSchema;
1313
- }
1314
-
1315
- /**
1316
- * Helper type to extract inferred types from a schema, with fallback to unknown.
1317
- */
1318
- export type InferSchemaOutput<T> = T extends StandardSchema ? InferOutput<T> : unknown;
1319
-
1320
- /**
1321
- * Context with typed body/query/headers based on the provided schema.
1322
- */
1323
- export type TypedApiHandlerContext<
1324
- TSchema extends RouteSchema,
1325
- TRequest extends Request = Request,
1326
- TServer = any,
1327
- > = Omit<ApiHandlerContext<TRequest, TServer>, 'body' | 'query' | 'headers'> & {
1328
- body: InferSchemaOutput<TSchema['body']>;
1329
- query: InferSchemaOutput<TSchema['query']>;
1330
- headers: InferSchemaOutput<TSchema['headers']>;
1331
- params: InferSchemaOutput<TSchema['params']>;
1332
- };
1333
-
1334
- /**
1335
- * Options for the group method.
1336
- *
1337
- * @typeParam TContext - Extended context type that middleware provides to handlers
1338
- *
1339
- * @example Group with auth middleware extending context
1340
- * ```typescript
1341
- * type AuthContext = ApiHandlerContext<BunRequest<string>, Server> & { user: User };
1342
- *
1343
- * app.group<AuthContext>('/api', (r) => {
1344
- * r.get('/profile', (ctx) => {
1345
- * // ctx.user is properly typed!
1346
- * return ctx.json({ name: ctx.user.name });
1347
- * });
1348
- * }, { middleware: [authMiddleware] });
1349
- * ```
1350
- */
1351
- export interface GroupOptions<
1352
- TRequest extends Request = Request,
1353
- TServer = any,
1354
- TContext extends ApiHandlerContext<TRequest, TServer> = ApiHandlerContext<TRequest, TServer>,
1355
- > {
1356
- middleware?: Middleware<TRequest, TServer, TContext>[];
1357
- }
1358
-
1359
- /**
1360
- * Context type that combines schema-typed fields with an extended base context.
1361
- * Used by RouteGroupBuilder to merge schema validation types with middleware-extended context.
1362
- * Note: Path parameter typing (e.g., :id -> params.id) comes from the TContext.request type.
1363
- */
1364
- export type TypedGroupHandlerContext<TSchema extends RouteSchema, TContext extends ApiHandlerContext<any, any>> = Omit<
1365
- TContext,
1366
- 'body' | 'query' | 'headers' | 'params'
1367
- > & {
1368
- body: InferSchemaOutput<TSchema['body']>;
1369
- query: InferSchemaOutput<TSchema['query']>;
1370
- headers: InferSchemaOutput<TSchema['headers']>;
1371
- params: InferSchemaOutput<TSchema['params']>;
1372
- };
1373
-
1374
- /**
1375
- * Builder interface for defining routes within a group.
1376
- * Provides chainable methods for registering routes with shared prefix and middleware.
1377
- *
1378
- * @typeParam TRequest - The request type
1379
- * @typeParam TServer - The server type
1380
- * @typeParam TContext - Extended context type from group middleware
1381
- */
1382
- export interface RouteGroupBuilder<
1383
- TRequest extends Request = Request,
1384
- TServer = any,
1385
- TContext extends ApiHandlerContext<TRequest, TServer> = ApiHandlerContext<TRequest, TServer>,
1386
- > {
1387
- get<P extends string, TSchema extends RouteSchema = RouteSchema>(
1388
- path: P,
1389
- handler: (context: TypedGroupHandlerContext<TSchema, TContext>) => Promise<Response> | Response,
1390
- options?: RouteOptions<TRequest, TServer, TContext> & { schema?: TSchema },
1391
- ): RouteGroupBuilder<TRequest, TServer, TContext>;
1392
-
1393
- post<P extends string, TSchema extends RouteSchema = RouteSchema>(
1394
- path: P,
1395
- handler: (context: TypedGroupHandlerContext<TSchema, TContext>) => Promise<Response> | Response,
1396
- options?: RouteOptions<TRequest, TServer, TContext> & { schema?: TSchema },
1397
- ): RouteGroupBuilder<TRequest, TServer, TContext>;
1398
-
1399
- put<P extends string, TSchema extends RouteSchema = RouteSchema>(
1400
- path: P,
1401
- handler: (context: TypedGroupHandlerContext<TSchema, TContext>) => Promise<Response> | Response,
1402
- options?: RouteOptions<TRequest, TServer, TContext> & { schema?: TSchema },
1403
- ): RouteGroupBuilder<TRequest, TServer, TContext>;
1404
-
1405
- delete<P extends string, TSchema extends RouteSchema = RouteSchema>(
1406
- path: P,
1407
- handler: (context: TypedGroupHandlerContext<TSchema, TContext>) => Promise<Response> | Response,
1408
- options?: RouteOptions<TRequest, TServer, TContext> & { schema?: TSchema },
1409
- ): RouteGroupBuilder<TRequest, TServer, TContext>;
1410
-
1411
- patch<P extends string, TSchema extends RouteSchema = RouteSchema>(
1412
- path: P,
1413
- handler: (context: TypedGroupHandlerContext<TSchema, TContext>) => Promise<Response> | Response,
1414
- options?: RouteOptions<TRequest, TServer, TContext> & { schema?: TSchema },
1415
- ): RouteGroupBuilder<TRequest, TServer, TContext>;
1416
-
1417
- options<P extends string, TSchema extends RouteSchema = RouteSchema>(
1418
- path: P,
1419
- handler: (context: TypedGroupHandlerContext<TSchema, TContext>) => Promise<Response> | Response,
1420
- options?: RouteOptions<TRequest, TServer, TContext> & { schema?: TSchema },
1421
- ): RouteGroupBuilder<TRequest, TServer, TContext>;
1422
-
1423
- head<P extends string, TSchema extends RouteSchema = RouteSchema>(
1424
- path: P,
1425
- handler: (context: TypedGroupHandlerContext<TSchema, TContext>) => Promise<Response> | Response,
1426
- options?: RouteOptions<TRequest, TServer, TContext> & { schema?: TSchema },
1427
- ): RouteGroupBuilder<TRequest, TServer, TContext>;
1428
- }
1429
-
1430
- /**
1431
- * A function that dynamically imports a view module.
1432
- * Used by app.static() to enable HMR in development.
1433
- */
1434
- export type ViewLoader<P = any> = () => Promise<{ default: EcoPageComponent<P> }>;
1435
-
1436
- /**
1437
- * Represents a static route registered via app.static().
1438
- * Uses a loader function to enable HMR in development mode.
1439
- */
1440
- export interface StaticRoute<P = any> {
1441
- path: string;
1442
- loader: ViewLoader<P>;
1443
- }