@ecopages/core 0.2.0-alpha.7 → 0.2.0-alpha.8

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 (354) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/package.json +212 -92
  3. package/src/adapters/abstract/application-adapter.d.ts +168 -0
  4. package/src/adapters/abstract/application-adapter.js +109 -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 +60 -0
  12. package/src/adapters/bun/create-app.js +117 -0
  13. package/src/adapters/bun/hmr-manager.d.ts +143 -0
  14. package/src/adapters/bun/hmr-manager.js +334 -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 +373 -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/index.d.ts +6 -0
  22. package/src/adapters/index.js +14 -0
  23. package/src/adapters/node/bootstrap-dependency-resolver.d.ts +44 -0
  24. package/src/adapters/node/bootstrap-dependency-resolver.js +172 -0
  25. package/src/adapters/node/create-app.d.ts +21 -0
  26. package/src/adapters/node/create-app.js +143 -0
  27. package/src/adapters/node/index.d.ts +6 -0
  28. package/src/adapters/node/index.js +11 -0
  29. package/src/adapters/node/node-client-bridge.d.ts +26 -0
  30. package/src/adapters/node/node-client-bridge.js +66 -0
  31. package/src/adapters/node/node-hmr-manager.d.ts +133 -0
  32. package/src/adapters/node/node-hmr-manager.js +312 -0
  33. package/src/adapters/node/runtime-adapter.d.ts +46 -0
  34. package/src/adapters/node/runtime-adapter.js +306 -0
  35. package/src/adapters/node/server-adapter.d.ts +161 -0
  36. package/src/adapters/node/server-adapter.js +358 -0
  37. package/src/adapters/node/static-content-server.d.ts +60 -0
  38. package/src/adapters/node/static-content-server.js +194 -0
  39. package/src/adapters/node/write-runtime-manifest.d.ts +26 -0
  40. package/src/adapters/node/write-runtime-manifest.js +12 -0
  41. package/src/adapters/shared/api-response.d.ts +52 -0
  42. package/src/adapters/shared/api-response.js +96 -0
  43. package/src/adapters/shared/application-adapter.d.ts +18 -0
  44. package/src/adapters/shared/application-adapter.js +90 -0
  45. package/src/adapters/shared/define-api-handler.d.ts +25 -0
  46. package/src/adapters/shared/define-api-handler.js +15 -0
  47. package/src/adapters/shared/explicit-static-route-matcher.d.ts +38 -0
  48. package/src/adapters/shared/explicit-static-route-matcher.js +103 -0
  49. package/src/adapters/shared/file-route-middleware-pipeline.d.ts +65 -0
  50. package/src/adapters/shared/file-route-middleware-pipeline.js +99 -0
  51. package/src/adapters/shared/fs-server-response-factory.d.ts +19 -0
  52. package/src/adapters/shared/fs-server-response-factory.js +97 -0
  53. package/src/adapters/shared/fs-server-response-matcher.d.ts +75 -0
  54. package/src/adapters/shared/fs-server-response-matcher.js +160 -0
  55. package/src/adapters/shared/hmr-entrypoint-registrar.d.ts +55 -0
  56. package/src/adapters/shared/hmr-entrypoint-registrar.js +87 -0
  57. package/src/adapters/shared/hmr-html-response.d.ts +22 -0
  58. package/src/adapters/shared/hmr-html-response.js +32 -0
  59. package/src/adapters/shared/render-context.d.ts +14 -0
  60. package/src/adapters/shared/render-context.js +70 -0
  61. package/src/adapters/shared/runtime-bootstrap.d.ts +38 -0
  62. package/src/adapters/shared/runtime-bootstrap.js +43 -0
  63. package/src/adapters/shared/server-adapter.d.ts +97 -0
  64. package/src/adapters/shared/server-adapter.js +386 -0
  65. package/src/adapters/shared/server-route-handler.d.ts +89 -0
  66. package/src/adapters/shared/server-route-handler.js +111 -0
  67. package/src/adapters/shared/server-static-builder.d.ts +70 -0
  68. package/src/adapters/shared/server-static-builder.js +99 -0
  69. package/src/build/build-adapter.d.ts +186 -0
  70. package/src/build/build-adapter.js +168 -0
  71. package/src/build/build-manifest.d.ts +27 -0
  72. package/src/build/build-manifest.js +30 -0
  73. package/src/build/build-types.d.ts +57 -0
  74. package/src/build/build-types.js +0 -0
  75. package/src/build/dev-build-coordinator.d.ts +74 -0
  76. package/src/build/dev-build-coordinator.js +161 -0
  77. package/src/build/esbuild-build-adapter.d.ts +72 -0
  78. package/src/build/esbuild-build-adapter.js +422 -0
  79. package/src/build/runtime-build-executor.d.ts +13 -0
  80. package/src/build/runtime-build-executor.js +20 -0
  81. package/src/build/runtime-specifier-alias-plugin.d.ts +15 -0
  82. package/src/build/runtime-specifier-alias-plugin.js +31 -0
  83. package/src/config/config-builder.d.ts +238 -0
  84. package/src/config/config-builder.js +565 -0
  85. package/src/constants.d.ts +45 -0
  86. package/src/constants.js +25 -0
  87. package/src/create-app.d.ts +17 -0
  88. package/src/create-app.js +66 -0
  89. package/src/dev/sc-server.d.ts +30 -0
  90. package/src/dev/sc-server.js +111 -0
  91. package/src/eco/component-render-context.d.ts +105 -0
  92. package/src/eco/component-render-context.js +87 -0
  93. package/src/eco/eco.d.ts +9 -0
  94. package/src/eco/eco.js +114 -0
  95. package/src/eco/eco.types.d.ts +178 -0
  96. package/src/eco/eco.types.js +0 -0
  97. package/src/eco/eco.utils.d.ts +40 -0
  98. package/src/eco/eco.utils.js +40 -0
  99. package/src/eco/global-injector-map.d.ts +16 -0
  100. package/src/eco/global-injector-map.js +80 -0
  101. package/src/eco/lazy-injector-map.d.ts +8 -0
  102. package/src/eco/lazy-injector-map.js +70 -0
  103. package/src/eco/module-dependencies.d.ts +18 -0
  104. package/src/eco/module-dependencies.js +49 -0
  105. package/src/errors/http-error.d.ts +31 -0
  106. package/src/errors/http-error.js +50 -0
  107. package/src/errors/index.d.ts +2 -0
  108. package/src/errors/index.js +4 -0
  109. package/src/errors/locals-access-error.d.ts +4 -0
  110. package/src/errors/locals-access-error.js +9 -0
  111. package/src/global/app-logger.d.ts +2 -0
  112. package/src/global/app-logger.js +6 -0
  113. package/src/hmr/client/hmr-runtime.d.ts +5 -0
  114. package/src/hmr/client/hmr-runtime.js +109 -0
  115. package/src/hmr/hmr-strategy.d.ts +159 -0
  116. package/src/hmr/hmr-strategy.js +29 -0
  117. package/src/hmr/hmr.postcss.test.e2e.d.ts +1 -0
  118. package/src/hmr/hmr.postcss.test.e2e.js +31 -0
  119. package/src/hmr/hmr.test.e2e.d.ts +1 -0
  120. package/src/hmr/hmr.test.e2e.js +43 -0
  121. package/src/hmr/strategies/default-hmr-strategy.d.ts +43 -0
  122. package/src/hmr/strategies/default-hmr-strategy.js +34 -0
  123. package/src/hmr/strategies/js-hmr-strategy.d.ts +139 -0
  124. package/src/hmr/strategies/js-hmr-strategy.js +178 -0
  125. package/src/index.browser.d.ts +3 -0
  126. package/src/index.browser.js +4 -0
  127. package/src/index.d.ts +5 -0
  128. package/src/index.js +10 -0
  129. package/src/integrations/ghtml/ghtml-renderer.d.ts +15 -0
  130. package/src/integrations/ghtml/ghtml-renderer.js +62 -0
  131. package/src/integrations/ghtml/ghtml.plugin.d.ts +20 -0
  132. package/src/integrations/ghtml/ghtml.plugin.js +21 -0
  133. package/src/internal-types.d.ts +221 -0
  134. package/src/internal-types.js +0 -0
  135. package/src/plugins/alias-resolver-plugin.d.ts +2 -0
  136. package/src/plugins/alias-resolver-plugin.js +53 -0
  137. package/src/plugins/eco-component-meta-plugin.d.ts +97 -0
  138. package/src/plugins/eco-component-meta-plugin.js +157 -0
  139. package/src/plugins/integration-plugin.d.ts +136 -0
  140. package/src/plugins/integration-plugin.js +133 -0
  141. package/src/plugins/processor.d.ts +95 -0
  142. package/src/plugins/processor.js +136 -0
  143. package/src/plugins/runtime-capability.d.ts +9 -0
  144. package/src/plugins/runtime-capability.js +0 -0
  145. package/src/public-types.d.ts +1149 -0
  146. package/src/public-types.js +0 -0
  147. package/src/route-renderer/component-graph/component-graph-executor.d.ts +32 -0
  148. package/src/route-renderer/component-graph/component-graph-executor.js +31 -0
  149. package/src/route-renderer/component-graph/component-graph.d.ts +42 -0
  150. package/src/route-renderer/component-graph/component-graph.js +72 -0
  151. package/src/route-renderer/component-graph/component-marker.d.ts +52 -0
  152. package/src/route-renderer/component-graph/component-marker.js +46 -0
  153. package/src/route-renderer/component-graph/component-reference.d.ts +10 -0
  154. package/src/route-renderer/component-graph/component-reference.js +19 -0
  155. package/src/route-renderer/component-graph/marker-graph-resolver.d.ts +77 -0
  156. package/src/route-renderer/component-graph/marker-graph-resolver.js +95 -0
  157. package/src/route-renderer/orchestration/integration-renderer.d.ts +372 -0
  158. package/src/route-renderer/orchestration/integration-renderer.js +589 -0
  159. package/src/route-renderer/orchestration/render-execution.service.d.ts +103 -0
  160. package/src/route-renderer/orchestration/render-execution.service.js +121 -0
  161. package/src/route-renderer/orchestration/render-preparation.service.d.ts +121 -0
  162. package/src/route-renderer/orchestration/render-preparation.service.js +332 -0
  163. package/src/route-renderer/page-loading/dependency-resolver.d.ts +35 -0
  164. package/src/route-renderer/page-loading/dependency-resolver.js +442 -0
  165. package/src/route-renderer/page-loading/page-module-loader.d.ts +87 -0
  166. package/src/route-renderer/page-loading/page-module-loader.js +124 -0
  167. package/src/route-renderer/route-renderer.d.ts +61 -0
  168. package/src/route-renderer/route-renderer.js +87 -0
  169. package/src/router/client/link-intent.js +34 -0
  170. package/src/router/client/link-intent.test.browser.d.ts +1 -0
  171. package/src/router/client/link-intent.test.browser.js +43 -0
  172. package/src/router/client/navigation-coordinator.d.ts +149 -0
  173. package/src/router/client/navigation-coordinator.js +215 -0
  174. package/src/router/server/fs-router-scanner.d.ts +41 -0
  175. package/src/router/server/fs-router-scanner.js +156 -0
  176. package/src/router/server/fs-router.d.ts +26 -0
  177. package/src/router/server/fs-router.js +100 -0
  178. package/src/services/assets/asset-processing-service/asset-processing.service.d.ts +120 -0
  179. package/src/services/assets/asset-processing-service/asset-processing.service.js +331 -0
  180. package/src/services/assets/asset-processing-service/asset.factory.d.ts +17 -0
  181. package/src/services/assets/asset-processing-service/asset.factory.js +82 -0
  182. package/src/services/assets/asset-processing-service/assets.types.d.ts +89 -0
  183. package/src/services/assets/asset-processing-service/assets.types.js +0 -0
  184. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.d.ts +55 -0
  185. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.js +48 -0
  186. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.d.ts +20 -0
  187. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.js +41 -0
  188. package/src/services/assets/asset-processing-service/index.d.ts +5 -0
  189. package/src/services/assets/asset-processing-service/index.js +5 -0
  190. package/src/services/assets/asset-processing-service/processor.interface.d.ts +22 -0
  191. package/src/services/assets/asset-processing-service/processor.interface.js +6 -0
  192. package/src/services/assets/asset-processing-service/processor.registry.d.ts +8 -0
  193. package/src/services/assets/asset-processing-service/processor.registry.js +15 -0
  194. package/src/services/assets/asset-processing-service/processors/base/base-processor.d.ts +24 -0
  195. package/src/services/assets/asset-processing-service/processors/base/base-processor.js +64 -0
  196. package/src/services/assets/asset-processing-service/processors/base/base-script-processor.d.ts +17 -0
  197. package/src/services/assets/asset-processing-service/processors/base/base-script-processor.js +72 -0
  198. package/src/services/assets/asset-processing-service/processors/index.d.ts +5 -0
  199. package/src/services/assets/asset-processing-service/processors/index.js +5 -0
  200. package/src/services/assets/asset-processing-service/processors/script/content-script.processor.d.ts +5 -0
  201. package/src/services/assets/asset-processing-service/processors/script/content-script.processor.js +57 -0
  202. package/src/services/assets/asset-processing-service/processors/script/file-script.processor.d.ts +8 -0
  203. package/src/services/assets/asset-processing-service/processors/script/file-script.processor.js +76 -0
  204. package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.d.ts +7 -0
  205. package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.js +75 -0
  206. package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.d.ts +5 -0
  207. package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.js +25 -0
  208. package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.d.ts +9 -0
  209. package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.js +66 -0
  210. package/src/services/assets/browser-bundle.service.d.ts +32 -0
  211. package/src/services/assets/browser-bundle.service.js +33 -0
  212. package/src/services/cache/cache.types.d.ts +107 -0
  213. package/src/services/cache/cache.types.js +0 -0
  214. package/src/services/cache/index.d.ts +7 -0
  215. package/src/services/cache/index.js +7 -0
  216. package/src/services/cache/memory-cache-store.d.ts +42 -0
  217. package/src/services/cache/memory-cache-store.js +98 -0
  218. package/src/services/cache/page-cache-service.d.ts +70 -0
  219. package/src/services/cache/page-cache-service.js +152 -0
  220. package/src/services/cache/page-request-cache-coordinator.service.d.ts +75 -0
  221. package/src/services/cache/page-request-cache-coordinator.service.js +109 -0
  222. package/src/services/html/html-rewriter-provider.service.d.ts +37 -0
  223. package/src/services/html/html-rewriter-provider.service.js +65 -0
  224. package/src/services/html/html-transformer.service.d.ts +77 -0
  225. package/src/services/html/html-transformer.service.js +221 -0
  226. package/src/services/invalidation/development-invalidation.service.d.ts +74 -0
  227. package/src/services/invalidation/development-invalidation.service.js +189 -0
  228. package/src/services/module-loading/app-server-module-transpiler.service.d.ts +16 -0
  229. package/src/services/module-loading/app-server-module-transpiler.service.js +34 -0
  230. package/src/services/module-loading/page-module-import.service.d.ts +71 -0
  231. package/src/services/module-loading/page-module-import.service.js +132 -0
  232. package/src/services/module-loading/server-loader.service.d.ts +96 -0
  233. package/src/services/module-loading/server-loader.service.js +32 -0
  234. package/src/services/module-loading/server-module-transpiler.service.d.ts +69 -0
  235. package/src/services/module-loading/server-module-transpiler.service.js +61 -0
  236. package/src/services/runtime-manifest/node-runtime-manifest.service.d.ts +35 -0
  237. package/src/services/runtime-manifest/node-runtime-manifest.service.js +60 -0
  238. package/src/services/runtime-state/dev-graph.service.d.ts +118 -0
  239. package/src/services/runtime-state/dev-graph.service.js +162 -0
  240. package/src/services/runtime-state/entrypoint-dependency-graph.service.d.ts +41 -0
  241. package/src/services/runtime-state/entrypoint-dependency-graph.service.js +85 -0
  242. package/src/services/runtime-state/runtime-specifier-registry.service.d.ts +69 -0
  243. package/src/services/runtime-state/runtime-specifier-registry.service.js +37 -0
  244. package/src/services/runtime-state/server-invalidation-state.service.d.ts +26 -0
  245. package/src/services/runtime-state/server-invalidation-state.service.js +35 -0
  246. package/src/services/validation/schema-validation-service.d.ts +122 -0
  247. package/src/services/validation/schema-validation-service.js +101 -0
  248. package/src/services/validation/standard-schema.types.d.ts +65 -0
  249. package/src/services/validation/standard-schema.types.js +0 -0
  250. package/src/static-site-generator/static-site-generator.d.ts +109 -0
  251. package/src/static-site-generator/static-site-generator.js +353 -0
  252. package/src/utils/css.d.ts +1 -0
  253. package/src/utils/css.js +7 -0
  254. package/src/utils/deep-merge.d.ts +14 -0
  255. package/src/utils/deep-merge.js +32 -0
  256. package/src/utils/hash.d.ts +1 -0
  257. package/src/utils/hash.js +7 -0
  258. package/src/utils/html.d.ts +1 -0
  259. package/src/utils/html.js +4 -0
  260. package/src/utils/invariant.d.ts +5 -0
  261. package/src/utils/invariant.js +11 -0
  262. package/src/utils/locals-utils.d.ts +15 -0
  263. package/src/utils/locals-utils.js +24 -0
  264. package/src/utils/parse-cli-args.d.ts +24 -0
  265. package/src/utils/parse-cli-args.js +47 -0
  266. package/src/utils/path-utils.module.d.ts +5 -0
  267. package/src/utils/path-utils.module.js +14 -0
  268. package/src/utils/resolve-work-dir.d.ts +11 -0
  269. package/src/utils/resolve-work-dir.js +31 -0
  270. package/src/utils/runtime.d.ts +11 -0
  271. package/src/utils/runtime.js +40 -0
  272. package/src/utils/server-utils.module.d.ts +19 -0
  273. package/src/utils/server-utils.module.js +56 -0
  274. package/src/watchers/project-watcher.d.ts +136 -0
  275. package/src/watchers/project-watcher.js +281 -0
  276. package/src/watchers/project-watcher.test-helpers.d.ts +4 -0
  277. package/src/watchers/project-watcher.test-helpers.js +52 -0
  278. package/src/adapters/bun/hmr-manager.test.ts +0 -267
  279. package/src/adapters/node/bootstrap-dependency-resolver.test.ts +0 -282
  280. package/src/adapters/node/node-client-bridge.test.ts +0 -198
  281. package/src/adapters/node/node-hmr-manager.test.ts +0 -322
  282. package/src/adapters/node/runtime-adapter.test.ts +0 -868
  283. package/src/adapters/node/static-content-server.test.ts +0 -60
  284. package/src/adapters/shared/api-response.test.ts +0 -97
  285. package/src/adapters/shared/explicit-static-route-matcher.test.ts +0 -381
  286. package/src/adapters/shared/file-route-middleware-pipeline.test.ts +0 -90
  287. package/src/adapters/shared/fs-server-response-factory.test.ts +0 -187
  288. package/src/adapters/shared/fs-server-response-matcher.test.ts +0 -286
  289. package/src/adapters/shared/hmr-manager.contract.test.ts +0 -196
  290. package/src/adapters/shared/hmr-manager.dispatch.test.ts +0 -220
  291. package/src/adapters/shared/render-context.test.ts +0 -146
  292. package/src/adapters/shared/server-adapter.test.ts +0 -77
  293. package/src/adapters/shared/server-route-handler.test.ts +0 -110
  294. package/src/adapters/shared/server-static-builder.test.ts +0 -316
  295. package/src/build/build-adapter-serialization.test.ts +0 -268
  296. package/src/build/build-adapter.test.ts +0 -815
  297. package/src/build/runtime-specifier-alias-plugin.test.ts +0 -43
  298. package/src/config/config-builder.test.ts +0 -410
  299. package/src/eco/eco.test.ts +0 -678
  300. package/src/eco/eco.utils.test.ts +0 -124
  301. package/src/eco/global-injector-map.test.ts +0 -42
  302. package/src/eco/lazy-injector-map.test.ts +0 -66
  303. package/src/eco/module-dependencies.test.ts +0 -30
  304. package/src/errors/http-error.test.ts +0 -134
  305. package/src/global/utils.test.ts +0 -12
  306. 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
  307. package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-HMR-Server-Integration-should-load-fixture-app-page-1.png +0 -0
  308. package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-WebSocket-Connection-should-connect-to-correct-HMR-endpoint-1.png +0 -0
  309. package/src/hmr/hmr-strategy.test.ts +0 -124
  310. package/src/hmr/strategies/js-hmr-strategy.test.ts +0 -335
  311. package/src/integrations/ghtml/ghtml-renderer.test.ts +0 -63
  312. package/src/plugins/alias-resolver-plugin.test.ts +0 -41
  313. package/src/plugins/eco-component-meta-plugin.test.ts +0 -380
  314. package/src/plugins/integration-plugin.test.ts +0 -111
  315. package/src/plugins/processor.test.ts +0 -148
  316. package/src/route-renderer/component-graph/component-graph-executor.test.ts +0 -41
  317. package/src/route-renderer/component-graph/component-graph.test.ts +0 -63
  318. package/src/route-renderer/component-graph/component-marker.test.ts +0 -73
  319. package/src/route-renderer/component-graph/marker-graph-resolver.test.ts +0 -135
  320. package/src/route-renderer/orchestration/integration-renderer.test.ts +0 -936
  321. package/src/route-renderer/orchestration/render-execution.service.test.ts +0 -97
  322. package/src/route-renderer/orchestration/render-preparation.service.test.ts +0 -235
  323. package/src/route-renderer/page-loading/dependency-resolver.test.ts +0 -345
  324. package/src/route-renderer/page-loading/page-module-loader.test.ts +0 -96
  325. package/src/router/client/navigation-coordinator.test.ts +0 -237
  326. package/src/router/server/fs-router-scanner.test.ts +0 -83
  327. package/src/router/server/fs-router.test.ts +0 -214
  328. package/src/services/assets/asset-processing-service/asset-processing.service.test.ts +0 -385
  329. package/src/services/assets/asset-processing-service/asset.factory.test.ts +0 -63
  330. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.test.ts +0 -72
  331. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.test.ts +0 -67
  332. package/src/services/assets/asset-processing-service/processors/base/base-processor.test.ts +0 -59
  333. package/src/services/assets/asset-processing-service/processors/script/file-script.processor.test.ts +0 -286
  334. package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.test.ts +0 -227
  335. package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.test.ts +0 -199
  336. package/src/services/assets/browser-bundle.service.test.ts +0 -36
  337. package/src/services/cache/memory-cache-store.test.ts +0 -225
  338. package/src/services/cache/page-cache-service.test.ts +0 -175
  339. package/src/services/cache/page-request-cache-coordinator.service.test.ts +0 -79
  340. package/src/services/html/html-rewriter-provider.service.test.ts +0 -183
  341. package/src/services/html/html-transformer.service.test.ts +0 -378
  342. package/src/services/invalidation/development-invalidation.service.test.ts +0 -77
  343. package/src/services/module-loading/page-module-import.service.test.ts +0 -253
  344. package/src/services/module-loading/server-loader.service.test.ts +0 -161
  345. package/src/services/module-loading/server-module-transpiler.service.test.ts +0 -115
  346. package/src/services/runtime-manifest/node-runtime-manifest.service.test.ts +0 -95
  347. package/src/services/validation/schema-validation-service.test.ts +0 -223
  348. package/src/static-site-generator/static-site-generator.test.ts +0 -307
  349. package/src/utils/deep-merge.test.ts +0 -114
  350. package/src/utils/invariant.test.ts +0 -22
  351. package/src/utils/path-utils.test.ts +0 -15
  352. package/src/utils/server-utils.test.ts +0 -38
  353. package/src/watchers/project-watcher.integration.test.ts +0 -337
  354. package/src/watchers/project-watcher.test.ts +0 -678
@@ -0,0 +1,589 @@
1
+ import {
2
+ } from "../../services/assets/asset-processing-service/index.js";
3
+ import { HtmlTransformerService } from "../../services/html/html-transformer.service.js";
4
+ import { invariant } from "../../utils/invariant.js";
5
+ import { HttpError } from "../../errors/http-error.js";
6
+ import { LocalsAccessError } from "../../errors/locals-access-error.js";
7
+ import { DependencyResolverService } from "../page-loading/dependency-resolver.js";
8
+ import { PageModuleLoaderService } from "../page-loading/page-module-loader.js";
9
+ import { MarkerGraphResolver } from "../component-graph/marker-graph-resolver.js";
10
+ import { RenderExecutionService } from "./render-execution.service.js";
11
+ import { RenderPreparationService } from "./render-preparation.service.js";
12
+ function createLocalsProxy(filePath) {
13
+ const errorMessage = `[ecopages] Request locals are only available during request-time rendering with cache: 'dynamic'. Page: ${filePath}. If you meant to use locals here, set cache: 'dynamic' and provide locals from route middleware/handlers.`;
14
+ return new Proxy(
15
+ {},
16
+ {
17
+ get: () => {
18
+ throw new LocalsAccessError(errorMessage);
19
+ },
20
+ set: () => {
21
+ throw new LocalsAccessError(errorMessage);
22
+ },
23
+ has: () => {
24
+ throw new LocalsAccessError(errorMessage);
25
+ },
26
+ ownKeys: () => {
27
+ throw new LocalsAccessError(errorMessage);
28
+ },
29
+ deleteProperty: () => {
30
+ throw new LocalsAccessError(errorMessage);
31
+ },
32
+ defineProperty: () => {
33
+ throw new LocalsAccessError(errorMessage);
34
+ },
35
+ getOwnPropertyDescriptor: () => {
36
+ throw new LocalsAccessError(errorMessage);
37
+ }
38
+ }
39
+ );
40
+ }
41
+ class IntegrationRenderer {
42
+ appConfig;
43
+ assetProcessingService;
44
+ htmlTransformer;
45
+ hmrManager;
46
+ resolvedIntegrationDependencies = [];
47
+ runtimeOrigin;
48
+ dependencyResolverService;
49
+ pageModuleLoaderService;
50
+ markerGraphResolver;
51
+ renderPreparationService;
52
+ renderExecutionService;
53
+ DOC_TYPE = "<!DOCTYPE html>";
54
+ setHmrManager(hmrManager) {
55
+ this.hmrManager = hmrManager;
56
+ if (this.assetProcessingService) {
57
+ this.assetProcessingService.setHmrManager(hmrManager);
58
+ }
59
+ }
60
+ /**
61
+ * Build response headers with optional custom headers.
62
+ * @param contentType - The Content-Type header value
63
+ * @param customHeaders - Optional custom headers to merge
64
+ * @returns Headers object
65
+ */
66
+ buildHeaders(contentType, customHeaders) {
67
+ const headers = new Headers({ "Content-Type": contentType });
68
+ if (customHeaders) {
69
+ const incoming = new Headers(customHeaders);
70
+ incoming.forEach((value, key) => headers.set(key, value));
71
+ }
72
+ return headers;
73
+ }
74
+ /**
75
+ * Create an HTML Response.
76
+ * @param body - Response body (string or ReadableStream)
77
+ * @param ctx - Render context with status and headers
78
+ * @returns Response object
79
+ */
80
+ createHtmlResponse(body, ctx) {
81
+ return new Response(body, {
82
+ status: ctx.status ?? 200,
83
+ headers: this.buildHeaders("text/html; charset=utf-8", ctx.headers)
84
+ });
85
+ }
86
+ /**
87
+ * Create an HttpError for render failures.
88
+ * @param message - Error message
89
+ * @param cause - Original error if available
90
+ * @returns HttpError with 500 status
91
+ */
92
+ createRenderError(message, cause) {
93
+ const errorMessage = cause instanceof Error ? `${message}: ${cause.message}` : message;
94
+ return HttpError.InternalServerError(errorMessage);
95
+ }
96
+ /**
97
+ * Prepares dependencies for renderToResponse by resolving component dependencies
98
+ * and configuring the HTML transformer.
99
+ * @param view - The view component being rendered
100
+ * @param layout - Optional layout component
101
+ * @returns Resolved processed assets
102
+ */
103
+ async prepareViewDependencies(view, layout) {
104
+ const HtmlTemplate = await this.getHtmlTemplate();
105
+ const componentsToResolve = layout ? [HtmlTemplate, layout, view] : [HtmlTemplate, view];
106
+ const resolvedDependencies = this.htmlTransformer.dedupeProcessedAssets(
107
+ await this.resolveDependencies(componentsToResolve)
108
+ );
109
+ this.htmlTransformer.setProcessedDependencies(resolvedDependencies);
110
+ return resolvedDependencies;
111
+ }
112
+ constructor({
113
+ appConfig,
114
+ assetProcessingService,
115
+ resolvedIntegrationDependencies,
116
+ runtimeOrigin
117
+ }) {
118
+ this.appConfig = appConfig;
119
+ this.assetProcessingService = assetProcessingService;
120
+ this.htmlTransformer = new HtmlTransformerService();
121
+ this.resolvedIntegrationDependencies = resolvedIntegrationDependencies || [];
122
+ this.runtimeOrigin = runtimeOrigin;
123
+ this.dependencyResolverService = new DependencyResolverService(appConfig, assetProcessingService);
124
+ this.pageModuleLoaderService = new PageModuleLoaderService(appConfig, runtimeOrigin);
125
+ this.markerGraphResolver = new MarkerGraphResolver();
126
+ this.renderPreparationService = new RenderPreparationService(appConfig, assetProcessingService);
127
+ this.renderExecutionService = new RenderExecutionService();
128
+ }
129
+ /**
130
+ * Returns the HTML path from the provided file path.
131
+ * It extracts the path relative to the pages directory and removes the 'index' part if present.
132
+ *
133
+ * @param file - The file path to extract the HTML path from.
134
+ * @returns The extracted HTML path.
135
+ */
136
+ getHtmlPath({ file }) {
137
+ const pagesDir = this.appConfig.absolutePaths.pagesDir;
138
+ const pagesIndex = file.indexOf(pagesDir);
139
+ if (pagesIndex === -1) return file;
140
+ const startIndex = file.indexOf(pagesDir) + pagesDir.length;
141
+ const endIndex = file.lastIndexOf("/");
142
+ const path = file.substring(startIndex, endIndex);
143
+ if (path === "/index") return "";
144
+ return path;
145
+ }
146
+ /**
147
+ * Returns the HTML template component.
148
+ * It imports the HTML template from the specified path in the app configuration.
149
+ *
150
+ * @returns The HTML template component.
151
+ */
152
+ async getHtmlTemplate() {
153
+ const { absolutePaths } = this.appConfig;
154
+ try {
155
+ const { default: HtmlTemplate } = await this.importPageFile(absolutePaths.htmlTemplatePath);
156
+ return HtmlTemplate;
157
+ } catch (error) {
158
+ invariant(false, `Error importing HtmlTemplate: ${error}`);
159
+ }
160
+ }
161
+ /**
162
+ * Returns the static props for the page.
163
+ * It calls the provided getStaticProps function with the given options.
164
+ *
165
+ * @param getStaticProps - The function to get static props.
166
+ * @param options - The options to pass to the getStaticProps function.
167
+ * @returns The static props and metadata.
168
+ */
169
+ async getStaticProps(getStaticProps, options) {
170
+ return this.pageModuleLoaderService.getStaticPropsForPage({
171
+ getStaticProps,
172
+ params: options?.params
173
+ });
174
+ }
175
+ /**
176
+ * Returns the metadata properties for the page.
177
+ * It calls the provided getMetadata function with the given context.
178
+ *
179
+ * @param getMetadata - The function to get metadata.
180
+ * @param context - The context to pass to the getMetadata function.
181
+ * @returns The metadata properties.
182
+ */
183
+ async getMetadataProps(getMetadata, { props, params, query }) {
184
+ return this.pageModuleLoaderService.getMetadataPropsForPage({
185
+ getMetadata,
186
+ context: { props, params, query }
187
+ });
188
+ }
189
+ /**
190
+ * Imports the page file from the specified path.
191
+ * It uses dynamic import to load the file and returns the imported module.
192
+ *
193
+ * @param file - The file path to import.
194
+ * @returns The imported module.
195
+ */
196
+ async importPageFile(file) {
197
+ return this.pageModuleLoaderService.importPageFile(file);
198
+ }
199
+ /**
200
+ * Resolves the dependency path based on the component directory.
201
+ * It combines the component directory with the provided path URL.
202
+ *
203
+ * @param componentDir - The component directory path.
204
+ * @param pathUrl - The path URL to resolve.
205
+ * @returns The resolved dependency path.
206
+ */
207
+ resolveDependencyPath(componentDir, pathUrl) {
208
+ return this.dependencyResolverService.resolveDependencyPath(componentDir, pathUrl);
209
+ }
210
+ /**
211
+ * Extracts the dependencies from the provided component configuration.
212
+ * It resolves the paths for scripts and stylesheets based on the component directory.
213
+ *
214
+ * @param componentDir - The component directory path.
215
+ * @param scripts - The scripts to extract.
216
+ * @param stylesheets - The stylesheets to extract.
217
+ * @returns The extracted dependencies.
218
+ */
219
+ extractDependencies({
220
+ componentDir,
221
+ scripts,
222
+ stylesheets
223
+ }) {
224
+ const scriptsPaths = [
225
+ ...new Set(
226
+ (scripts ?? []).filter((script) => typeof script === "string" ? true : !script.lazy).map((script) => typeof script === "string" ? script : script.src).filter((script) => Boolean(script)).map((script) => this.resolveDependencyPath(componentDir, script))
227
+ )
228
+ ];
229
+ const stylesheetsPaths = [
230
+ ...new Set(
231
+ (stylesheets ?? []).map((style) => typeof style === "string" ? style : style.src).filter((style) => Boolean(style)).map((style) => this.resolveDependencyPath(componentDir, style))
232
+ )
233
+ ];
234
+ return {
235
+ scripts: scriptsPaths,
236
+ stylesheets: stylesheetsPaths
237
+ };
238
+ }
239
+ /**
240
+ * Resolves lazy script paths to public asset URLs.
241
+ * Converts source paths to their final bundled output paths.
242
+ *
243
+ * @param componentDir - The component directory path.
244
+ * @param scripts - The lazy script paths to resolve.
245
+ * @returns Comma-separated string of resolved public script paths.
246
+ */
247
+ resolveLazyScripts(componentDir, scripts) {
248
+ return this.dependencyResolverService.resolveLazyScripts(componentDir, scripts);
249
+ }
250
+ /**
251
+ * Collects the dependencies for the provided components.
252
+ * Combines component-specific dependencies with global integration dependencies.
253
+ *
254
+ * @param components - The components to collect dependencies from.
255
+ */
256
+ async resolveDependencies(components) {
257
+ const componentDeps = await this.processComponentDependencies(components);
258
+ return this.resolvedIntegrationDependencies.concat(componentDeps);
259
+ }
260
+ /**
261
+ * Processes component-specific dependencies WITHOUT prepending global integration dependencies.
262
+ * Use this method when you need only the component's own assets.
263
+ *
264
+ * @param components - The components to collect dependencies from.
265
+ */
266
+ async processComponentDependencies(components) {
267
+ return this.dependencyResolverService.processComponentDependencies(components, this.name);
268
+ }
269
+ /**
270
+ * Prepares the render options for the integration renderer.
271
+ * It imports the page file, collects dependencies, and prepares the render options.
272
+ *
273
+ * @param options - The route renderer options.
274
+ * @returns The prepared render options.
275
+ */
276
+ async prepareRenderOptions(options) {
277
+ return this.renderPreparationService.prepare(options, this.name, {
278
+ resolvePageModule: (file) => this.resolvePageModule(file),
279
+ getHtmlTemplate: () => this.getHtmlTemplate(),
280
+ resolvePageData: (pageModule, routeOptions) => this.resolvePageData(pageModule, routeOptions),
281
+ resolveDependencies: (components) => this.resolveDependencies(components),
282
+ buildRouteRenderAssets: (file) => this.buildRouteRenderAssets(file),
283
+ shouldRenderPageComponent: (input) => this.shouldRenderPageComponent(input),
284
+ renderPageComponent: ({ component, props }) => this.renderComponent({
285
+ component,
286
+ props,
287
+ integrationContext: {
288
+ componentInstanceId: "eco-page-root"
289
+ }
290
+ }),
291
+ getComponentRenderBoundaryContext: () => this.getComponentRenderBoundaryContext(),
292
+ setProcessedDependencies: (dependencies) => this.htmlTransformer.setProcessedDependencies(dependencies),
293
+ dedupeProcessedAssets: (assets) => this.htmlTransformer.dedupeProcessedAssets(assets),
294
+ createPageLocalsProxy: (filePath) => createLocalsProxy(filePath)
295
+ });
296
+ }
297
+ /**
298
+ * Controls whether the page root should be rendered through `renderComponent()`
299
+ * during route option preparation in component-capable modes.
300
+ *
301
+ * Integrations that already own page-level hydration (for example router-driven
302
+ * React rendering) can override this and return `false` to avoid duplicate root
303
+ * mount assets and competing hydration entrypoints.
304
+ */
305
+ shouldRenderPageComponent(_input) {
306
+ return true;
307
+ }
308
+ /**
309
+ * Resolves the page module and normalizes exports.
310
+ */
311
+ async resolvePageModule(file) {
312
+ return this.pageModuleLoaderService.resolvePageModule({
313
+ file,
314
+ importPageFileFn: (targetFile) => this.importPageFile(targetFile)
315
+ });
316
+ }
317
+ /**
318
+ * Resolves static props and metadata for the page.
319
+ */
320
+ async resolvePageData(pageModule, options) {
321
+ return this.pageModuleLoaderService.resolvePageData({
322
+ pageModule,
323
+ routeOptions: options
324
+ });
325
+ }
326
+ /**
327
+ * Executes the integration renderer with the provided options.
328
+ *
329
+ * Execution flow:
330
+ * 1. Build normalized render options (`prepareRenderOptions`).
331
+ * 2. Render once inside component render context to capture marker graph refs.
332
+ * 3. Merge captured refs with optional explicit page-module graph context.
333
+ * 4. Resolve any `eco-marker` graph bottom-up and merge produced assets.
334
+ * 5. Optionally apply root attributes for page/component root boundaries.
335
+ * 6. Run HTML transformer with final dependency set.
336
+ *
337
+ * Stream-safety note: the first render result is normalized to a string once,
338
+ * then the pipeline continues with that immutable HTML value to avoid disturbed
339
+ * response-body errors.
340
+ *
341
+ * @param options Route renderer options.
342
+ * @returns Rendered route body plus effective cache strategy.
343
+ */
344
+ async execute(options) {
345
+ return this.renderExecutionService.execute(options, this.name, {
346
+ prepareRenderOptions: (routeOptions) => this.prepareRenderOptions(routeOptions),
347
+ render: (renderOptions) => this.render(renderOptions),
348
+ getComponentRenderBoundaryContext: () => this.getComponentRenderBoundaryContext(),
349
+ resolveMarkerGraphHtml: (input) => this.resolveMarkerGraphHtml({
350
+ html: input.html,
351
+ componentsToResolve: input.componentsToResolve,
352
+ graphContext: input.graphContext
353
+ }),
354
+ getDocumentAttributes: (renderOptions) => this.getDocumentAttributes(renderOptions),
355
+ dedupeProcessedAssets: (assets) => this.htmlTransformer.dedupeProcessedAssets(assets),
356
+ getProcessedDependencies: () => this.htmlTransformer.getProcessedDependencies(),
357
+ setProcessedDependencies: (dependencies) => this.htmlTransformer.setProcessedDependencies(dependencies),
358
+ applyAttributesToHtmlElement: (html, attributes) => this.htmlTransformer.applyAttributesToHtmlElement(html, attributes),
359
+ applyAttributesToFirstBodyElement: (html, attributes) => this.htmlTransformer.applyAttributesToFirstBodyElement(html, attributes),
360
+ transformHtml: async (html) => {
361
+ const response = await this.htmlTransformer.transform(
362
+ new Response(html, {
363
+ headers: {
364
+ "Content-Type": "text/html"
365
+ }
366
+ })
367
+ );
368
+ return response.body;
369
+ }
370
+ });
371
+ }
372
+ /**
373
+ * Captures a render pass as immutable HTML along with the graph context needed
374
+ * for deferred marker resolution.
375
+ *
376
+ * This is the shared entry point for direct `renderToResponse()` flows that
377
+ * need the same component graph capture semantics as route execution without
378
+ * going through `prepareRenderOptions()`.
379
+ */
380
+ async captureHtmlRender(render) {
381
+ return this.renderExecutionService.captureHtmlRender(
382
+ this.name,
383
+ this.getComponentRenderBoundaryContext(),
384
+ render
385
+ );
386
+ }
387
+ /**
388
+ * Finalizes previously captured HTML by resolving deferred markers, merging
389
+ * any emitted assets, stamping optional attributes, and optionally running the
390
+ * HTML transformer for full-document flows.
391
+ */
392
+ async finalizeCapturedHtmlRender(options) {
393
+ const finalization = await this.renderExecutionService.finalizeHtmlRender(
394
+ {
395
+ html: options.html,
396
+ graphContext: options.graphContext,
397
+ componentsToResolve: options.componentsToResolve,
398
+ componentRootAttributes: options.componentRootAttributes,
399
+ documentAttributes: options.documentAttributes,
400
+ mergeAssets: options.mergeAssets ?? !options.partial
401
+ },
402
+ {
403
+ resolveMarkerGraphHtml: (input) => this.resolveMarkerGraphHtml({
404
+ html: input.html,
405
+ componentsToResolve: input.componentsToResolve,
406
+ graphContext: input.graphContext
407
+ }),
408
+ dedupeProcessedAssets: (assets) => this.htmlTransformer.dedupeProcessedAssets(assets),
409
+ getProcessedDependencies: () => this.htmlTransformer.getProcessedDependencies(),
410
+ setProcessedDependencies: (dependencies) => this.htmlTransformer.setProcessedDependencies(dependencies),
411
+ applyAttributesToHtmlElement: (html, attributes) => this.htmlTransformer.applyAttributesToHtmlElement(html, attributes),
412
+ applyAttributesToFirstBodyElement: (html, attributes) => this.htmlTransformer.applyAttributesToFirstBodyElement(html, attributes)
413
+ }
414
+ );
415
+ const shouldTransform = options.transformHtml ?? !options.partial;
416
+ if (!shouldTransform) {
417
+ return finalization.html;
418
+ }
419
+ const transformedResponse = await this.htmlTransformer.transform(
420
+ new Response(finalization.html, {
421
+ headers: { "Content-Type": "text/html" }
422
+ })
423
+ );
424
+ return await transformedResponse.text();
425
+ }
426
+ /**
427
+ * Returns document-level attributes to stamp onto the rendered `<html>` tag.
428
+ *
429
+ * Integrations can override this to expose explicit document ownership or
430
+ * other runtime coordination markers without relying on script sniffing.
431
+ */
432
+ getDocumentAttributes(_renderOptions) {
433
+ return void 0;
434
+ }
435
+ /**
436
+ * Resolves all `eco-marker` placeholders in rendered HTML using integration
437
+ * dispatch and bottom-up graph execution.
438
+ *
439
+ * Responsibility split:
440
+ * - core decodes markers into component refs, props, slot children, and target
441
+ * integration dispatch
442
+ * - the selected integration renderer performs the actual component render via
443
+ * `renderComponent()`
444
+ *
445
+ * Resolver callback behavior per marker:
446
+ * - resolve component definition by `componentRef`
447
+ * - resolve serialized props by `propsRef`
448
+ * - stitch resolved child HTML when `slotRef` is present
449
+ * - dispatch to target integration `renderComponent`
450
+ * - collect produced assets and apply root attributes when attachable
451
+ *
452
+ * @param options.html HTML that may still contain marker tokens.
453
+ * @param options.componentsToResolve Component set used to build component ref registry.
454
+ * @param options.graphContext Props/slot linkage captured during render.
455
+ * @returns Resolved HTML plus any component-scoped assets produced while resolving nodes.
456
+ * @throws Error when marker component refs or props refs cannot be resolved.
457
+ */
458
+ async resolveMarkerGraphHtml(options) {
459
+ const integrationRendererCache = /* @__PURE__ */ new Map();
460
+ return this.markerGraphResolver.resolve({
461
+ html: options.html,
462
+ componentsToResolve: options.componentsToResolve,
463
+ graphContext: options.graphContext,
464
+ resolveRenderer: (integrationName) => this.getIntegrationRendererForName(integrationName, integrationRendererCache),
465
+ applyAttributesToFirstElement: (html, attributes) => this.htmlTransformer.applyAttributesToFirstElement(html, attributes)
466
+ });
467
+ }
468
+ /**
469
+ * Returns a renderer instance for a given integration name.
470
+ *
471
+ * Uses a per-execution cache to avoid repeated renderer initialization.
472
+ *
473
+ * @param integrationName Target integration name.
474
+ * @param cache Render-pass renderer cache.
475
+ * @returns Renderer for the requested integration.
476
+ * @throws Error when no integration plugin matches `integrationName`.
477
+ */
478
+ getIntegrationRendererForName(integrationName, cache) {
479
+ if (cache.has(integrationName)) {
480
+ return cache.get(integrationName);
481
+ }
482
+ if (integrationName === this.name) {
483
+ cache.set(integrationName, this);
484
+ return this;
485
+ }
486
+ const integrationPlugin = this.appConfig.integrations.find(
487
+ (integration) => integration.name === integrationName
488
+ );
489
+ invariant(!!integrationPlugin, `[ecopages] Integration not found for marker: ${integrationName}`);
490
+ const renderer = integrationPlugin.initializeRenderer();
491
+ cache.set(integrationName, renderer);
492
+ return renderer;
493
+ }
494
+ /**
495
+ * Render a single component and return structured output for orchestration paths.
496
+ *
497
+ * Default behavior delegates to `renderToResponse` in partial mode and wraps
498
+ * the resulting HTML into the `ComponentRenderResult` contract.
499
+ *
500
+ * In marker resolution, this method is the integration-owned step that turns an
501
+ * already-resolved deferred boundary into concrete HTML, assets, and optional
502
+ * root attributes.
503
+ *
504
+ * Integrations can override this for richer behavior (asset emission,
505
+ * root attributes, integration-specific hydration metadata).
506
+ *
507
+ * @param input Component render request.
508
+ * @returns Structured render result used by marker/page orchestration.
509
+ */
510
+ async renderComponent(input) {
511
+ const response = await this.renderToResponse(
512
+ input.component,
513
+ input.props,
514
+ { partial: true }
515
+ );
516
+ const html = await response.text();
517
+ return {
518
+ html,
519
+ canAttachAttributes: true,
520
+ rootTag: this.getRootTagName(html),
521
+ integrationName: this.name
522
+ };
523
+ }
524
+ /**
525
+ * Extracts the first root element tag name from HTML output.
526
+ *
527
+ * @param html HTML fragment.
528
+ * @returns Root tag name when present; otherwise `undefined`.
529
+ */
530
+ getRootTagName(html) {
531
+ const rootTag = html.match(/^\s*<([a-zA-Z][a-zA-Z0-9:-]*)\b/);
532
+ return rootTag?.[1];
533
+ }
534
+ /**
535
+ * Method to build route render assets.
536
+ * This method can be optionally overridden by the specific integration renderer.
537
+ *
538
+ * @param file - The file path to build assets for.
539
+ * @returns The processed assets or undefined.
540
+ */
541
+ buildRouteRenderAssets(_file) {
542
+ return void 0;
543
+ }
544
+ /**
545
+ * Builds the narrow boundary policy facade injected into component render
546
+ * context for this render pass.
547
+ *
548
+ * `eco.component()` consumes this facade without knowing about integration
549
+ * registries or plugin instances.
550
+ *
551
+ * @returns Boundary policy context for the active integration renderer.
552
+ */
553
+ getComponentRenderBoundaryContext() {
554
+ return {
555
+ decideBoundaryRender: (input) => this.shouldDeferComponentBoundary(input) ? "defer" : "inline"
556
+ };
557
+ }
558
+ /**
559
+ * Resolves whether a component boundary should be deferred by consulting the
560
+ * target integration plugin.
561
+ *
562
+ * Boundaries targeting the current integration always render inline. Cross-
563
+ * integration boundaries delegate the decision to the target integration's
564
+ * `shouldDeferComponentBoundary()` policy.
565
+ *
566
+ * @param input Boundary metadata for the active render pass.
567
+ * @returns `true` when the boundary should emit a marker; otherwise `false`.
568
+ */
569
+ shouldDeferComponentBoundary(input) {
570
+ if (!input.targetIntegration || input.targetIntegration === input.currentIntegration) {
571
+ return false;
572
+ }
573
+ const targetIntegration = this.appConfig.integrations.find(
574
+ (integration) => integration.name === input.targetIntegration
575
+ );
576
+ invariant(
577
+ !!targetIntegration,
578
+ `[ecopages] Integration not found for component boundary: ${input.targetIntegration}`
579
+ );
580
+ return targetIntegration.shouldDeferComponentBoundary({
581
+ currentIntegration: input.currentIntegration,
582
+ targetIntegration: input.targetIntegration,
583
+ component: input.component
584
+ });
585
+ }
586
+ }
587
+ export {
588
+ IntegrationRenderer
589
+ };
@@ -0,0 +1,103 @@
1
+ import { type ComponentRenderBoundaryContext } from '../../eco/component-render-context.js';
2
+ import type { EcoComponent, IntegrationRendererRenderOptions, RouteRendererBody, RouteRendererOptions, RouteRenderResult } from '../../public-types.js';
3
+ import type { ProcessedAsset } from '../../services/assets/asset-processing-service/index.js';
4
+ import type { MarkerGraphContext } from '../component-graph/marker-graph-resolver.js';
5
+ /**
6
+ * Serializable graph context merged from render-time captured references and
7
+ * optional explicit page-module graph metadata.
8
+ */
9
+ export type RenderExecutionGraphContext = {
10
+ propsByRef?: Record<string, Record<string, unknown>>;
11
+ slotChildrenByRef?: MarkerGraphContext['slotChildrenByRef'];
12
+ };
13
+ export interface CapturedHtmlRenderResult {
14
+ html: string;
15
+ graphContext: RenderExecutionGraphContext;
16
+ }
17
+ export interface FinalizeHtmlRenderOptions {
18
+ html: string;
19
+ graphContext: RenderExecutionGraphContext;
20
+ componentsToResolve: EcoComponent[];
21
+ componentRootAttributes?: Record<string, string>;
22
+ documentAttributes?: Record<string, string>;
23
+ mergeAssets?: boolean;
24
+ }
25
+ export interface RenderExecutionCallbacks<C> {
26
+ prepareRenderOptions(options: RouteRendererOptions): Promise<IntegrationRendererRenderOptions<C>>;
27
+ render(renderOptions: IntegrationRendererRenderOptions<C>): Promise<RouteRendererBody>;
28
+ getComponentRenderBoundaryContext(): ComponentRenderBoundaryContext;
29
+ getDocumentAttributes(renderOptions: IntegrationRendererRenderOptions<C>): Record<string, string> | undefined;
30
+ resolveMarkerGraphHtml(input: {
31
+ html: string;
32
+ componentsToResolve: EcoComponent[];
33
+ graphContext: RenderExecutionGraphContext;
34
+ }): Promise<{
35
+ html: string;
36
+ assets: ProcessedAsset[];
37
+ }>;
38
+ dedupeProcessedAssets(assets: ProcessedAsset[]): ProcessedAsset[];
39
+ getProcessedDependencies(): ProcessedAsset[];
40
+ setProcessedDependencies(dependencies: ProcessedAsset[]): void;
41
+ applyAttributesToHtmlElement(html: string, attributes: Record<string, string>): string;
42
+ applyAttributesToFirstBodyElement(html: string, attributes: Record<string, string>): string;
43
+ transformHtml(html: string): Promise<RouteRendererBody>;
44
+ }
45
+ export interface FinalizeHtmlRenderCallbacks {
46
+ resolveMarkerGraphHtml(input: {
47
+ html: string;
48
+ componentsToResolve: EcoComponent[];
49
+ graphContext: RenderExecutionGraphContext;
50
+ }): Promise<{
51
+ html: string;
52
+ assets: ProcessedAsset[];
53
+ }>;
54
+ dedupeProcessedAssets(assets: ProcessedAsset[]): ProcessedAsset[];
55
+ getProcessedDependencies(): ProcessedAsset[];
56
+ setProcessedDependencies(dependencies: ProcessedAsset[]): void;
57
+ applyAttributesToHtmlElement(html: string, attributes: Record<string, string>): string;
58
+ applyAttributesToFirstBodyElement(html: string, attributes: Record<string, string>): string;
59
+ }
60
+ /**
61
+ * Executes the main post-preparation rendering flow for integration renderers.
62
+ *
63
+ * This service owns the orchestration that happens after normalized render
64
+ * options have been prepared: the first render pass, graph-context capture,
65
+ * deferred marker resolution, root-attribute application, and final HTML
66
+ * transformation into a response body stream.
67
+ */
68
+ export declare class RenderExecutionService {
69
+ captureHtmlRender(currentIntegrationName: string, boundaryContext: ComponentRenderBoundaryContext, render: () => Promise<RouteRendererBody>): Promise<CapturedHtmlRenderResult>;
70
+ /**
71
+ * Executes one integration render pass and returns the final route render
72
+ * result.
73
+ *
74
+ * @typeParam C Integration render output element type.
75
+ * @param options Route-level render options.
76
+ * @param currentIntegrationName Active integration name for this render pass.
77
+ * @param callbacks Renderer-specific hooks required during execution.
78
+ * @returns Final route render output with body and cache strategy.
79
+ */
80
+ execute<C = unknown>(options: RouteRendererOptions, currentIntegrationName: string, callbacks: RenderExecutionCallbacks<C>): Promise<RouteRenderResult>;
81
+ /**
82
+ * Merges captured render-time graph references with any explicit graph context
83
+ * provided by the page module.
84
+ *
85
+ * @param capturedGraphContext Graph context captured from the first render pass.
86
+ * @param explicitGraphContext Optional page-module graph metadata.
87
+ * @returns Merged graph context used during marker resolution.
88
+ */
89
+ mergeGraphContext(capturedGraphContext: RenderExecutionGraphContext, explicitGraphContext?: RenderExecutionGraphContext): RenderExecutionGraphContext;
90
+ finalizeHtmlRender(options: FinalizeHtmlRenderOptions, callbacks: FinalizeHtmlRenderCallbacks): Promise<{
91
+ html: string;
92
+ assets: ProcessedAsset[];
93
+ }>;
94
+ /**
95
+ * Returns the component set that participates in marker graph resolution for a
96
+ * render pass.
97
+ *
98
+ * @typeParam C Integration render output element type.
99
+ * @param renderOptions Normalized render options for the pass.
100
+ * @returns Ordered component list for graph registry construction.
101
+ */
102
+ private getComponentsToResolve;
103
+ }