@ecopages/core 0.2.0-alpha.23 → 0.2.0-alpha.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (515) hide show
  1. package/package.json +93 -226
  2. package/src/adapters/abstract/application-adapter.test.ts +172 -0
  3. package/src/adapters/abstract/application-adapter.ts +379 -0
  4. package/src/adapters/abstract/router-adapter.ts +30 -0
  5. package/src/adapters/abstract/server-adapter.ts +79 -0
  6. package/src/adapters/bun/client-bridge.ts +62 -0
  7. package/src/adapters/bun/create-app.ts +180 -0
  8. package/src/adapters/bun/hmr-manager.test.ts +267 -0
  9. package/src/adapters/bun/hmr-manager.ts +406 -0
  10. package/src/adapters/bun/index.ts +2 -0
  11. package/src/adapters/bun/server-adapter.ts +500 -0
  12. package/src/adapters/bun/server-lifecycle.ts +124 -0
  13. package/src/adapters/create-app.test.ts +10 -0
  14. package/src/adapters/create-app.ts +91 -0
  15. package/src/adapters/index.ts +2 -0
  16. package/src/adapters/node/create-app.test.ts +53 -0
  17. package/src/adapters/node/create-app.ts +183 -0
  18. package/src/adapters/node/node-client-bridge.test.ts +198 -0
  19. package/src/adapters/node/node-client-bridge.ts +79 -0
  20. package/src/adapters/node/node-hmr-manager.test.ts +322 -0
  21. package/src/adapters/node/node-hmr-manager.ts +378 -0
  22. package/src/adapters/node/server-adapter.ts +502 -0
  23. package/src/adapters/node/static-content-server.test.ts +60 -0
  24. package/src/adapters/node/static-content-server.ts +239 -0
  25. package/src/adapters/shared/api-response.test.ts +97 -0
  26. package/src/adapters/shared/api-response.ts +104 -0
  27. package/src/adapters/shared/application-adapter.ts +199 -0
  28. package/src/adapters/shared/define-api-handler.ts +66 -0
  29. package/src/adapters/shared/explicit-static-route-matcher.test.ts +381 -0
  30. package/src/adapters/shared/explicit-static-route-matcher.ts +140 -0
  31. package/src/adapters/shared/file-route-middleware-pipeline.test.ts +90 -0
  32. package/src/adapters/shared/file-route-middleware-pipeline.ts +127 -0
  33. package/src/adapters/shared/fs-server-response-factory.test.ts +187 -0
  34. package/src/adapters/shared/fs-server-response-factory.ts +118 -0
  35. package/src/adapters/shared/fs-server-response-matcher.test.ts +285 -0
  36. package/src/adapters/shared/fs-server-response-matcher.ts +189 -0
  37. package/src/adapters/shared/hmr-entrypoint-registrar.ts +149 -0
  38. package/src/adapters/shared/hmr-html-response.ts +52 -0
  39. package/src/adapters/shared/hmr-manager.contract.test.ts +232 -0
  40. package/src/adapters/shared/hmr-manager.dispatch.test.ts +220 -0
  41. package/src/adapters/shared/render-context.test.ts +150 -0
  42. package/src/adapters/shared/render-context.ts +123 -0
  43. package/src/adapters/shared/runtime-bootstrap.ts +79 -0
  44. package/src/adapters/shared/server-adapter.test.ts +77 -0
  45. package/src/adapters/shared/server-adapter.ts +493 -0
  46. package/src/adapters/shared/server-route-handler.test.ts +110 -0
  47. package/src/adapters/shared/server-route-handler.ts +153 -0
  48. package/src/adapters/shared/server-static-builder.test.ts +338 -0
  49. package/src/adapters/shared/server-static-builder.ts +170 -0
  50. package/src/build/build-adapter-serialization.test.ts +281 -0
  51. package/src/build/build-adapter.test.ts +1240 -0
  52. package/src/build/build-adapter.ts +1012 -0
  53. package/src/build/build-manifest.ts +54 -0
  54. package/src/build/build-types.ts +83 -0
  55. package/src/build/dev-build-coordinator.ts +220 -0
  56. package/src/build/esbuild-build-adapter.ts +660 -0
  57. package/src/build/runtime-build-executor.test.ts +81 -0
  58. package/src/build/runtime-build-executor.ts +40 -0
  59. package/src/build/runtime-specifier-alias-plugin.test.ts +67 -0
  60. package/src/build/runtime-specifier-alias-plugin.ts +62 -0
  61. package/src/build/runtime-specifier-aliases.ts +135 -0
  62. package/src/config/config-builder.test.ts +443 -0
  63. package/src/config/config-builder.ts +742 -0
  64. package/src/config/config-builder.typecheck.test.ts +96 -0
  65. package/src/config/{constants.d.ts → constants.ts} +22 -13
  66. package/src/dev/sc-server.ts +143 -0
  67. package/src/eco/eco.browser.test.ts +43 -0
  68. package/src/eco/eco.browser.ts +118 -0
  69. package/src/eco/eco.test.ts +654 -0
  70. package/src/eco/eco.ts +205 -0
  71. package/src/eco/eco.types.ts +221 -0
  72. package/src/eco/eco.utils.test.ts +219 -0
  73. package/src/eco/eco.utils.ts +5 -0
  74. package/src/eco/global-injector-map.test.ts +42 -0
  75. package/src/eco/global-injector-map.ts +112 -0
  76. package/src/eco/lazy-injector-map.test.ts +66 -0
  77. package/src/eco/lazy-injector-map.ts +120 -0
  78. package/src/eco/module-dependencies.test.ts +30 -0
  79. package/src/eco/module-dependencies.ts +75 -0
  80. package/src/errors/http-error.test.ts +134 -0
  81. package/src/errors/http-error.ts +72 -0
  82. package/src/errors/{index.d.ts → index.ts} +2 -2
  83. package/src/errors/locals-access-error.ts +7 -0
  84. package/src/global/app-logger.ts +4 -0
  85. package/src/global/utils.test.ts +12 -0
  86. package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-HMR-Server-Integration-should-have-HMR-script-injected-in-page-1.png +0 -0
  87. package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-HMR-Server-Integration-should-load-fixture-app-page-1.png +0 -0
  88. package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-WebSocket-Connection-should-connect-to-correct-HMR-endpoint-1.png +0 -0
  89. package/src/hmr/client/hmr-runtime.ts +160 -0
  90. package/src/hmr/hmr-strategy.test.ts +124 -0
  91. package/src/hmr/hmr-strategy.ts +177 -0
  92. package/src/hmr/hmr.postcss.test.e2e.ts +41 -0
  93. package/src/hmr/hmr.test.e2e.ts +66 -0
  94. package/src/hmr/strategies/default-hmr-strategy.ts +60 -0
  95. package/src/hmr/strategies/js-hmr-strategy.test.ts +335 -0
  96. package/src/hmr/strategies/js-hmr-strategy.ts +320 -0
  97. package/src/index.browser.ts +3 -0
  98. package/src/index.ts +15 -0
  99. package/src/integrations/ghtml/ghtml-renderer.test.ts +253 -0
  100. package/src/integrations/ghtml/ghtml-renderer.ts +97 -0
  101. package/src/integrations/ghtml/ghtml.constants.ts +1 -0
  102. package/src/integrations/ghtml/ghtml.plugin.ts +28 -0
  103. package/src/plugins/alias-resolver-plugin.test.ts +41 -0
  104. package/src/plugins/alias-resolver-plugin.ts +63 -0
  105. package/src/plugins/eco-component-meta-plugin.test.ts +406 -0
  106. package/src/plugins/eco-component-meta-plugin.ts +495 -0
  107. package/src/plugins/foreign-jsx-override-plugin.test.ts +65 -0
  108. package/src/plugins/foreign-jsx-override-plugin.ts +67 -0
  109. package/src/plugins/integration-plugin.test.ts +156 -0
  110. package/src/plugins/integration-plugin.ts +311 -0
  111. package/src/plugins/processor.test.ts +148 -0
  112. package/src/plugins/processor.ts +240 -0
  113. package/src/plugins/{runtime-capability.d.ts → runtime-capability.ts} +8 -3
  114. package/src/plugins/source-transform.test.ts +82 -0
  115. package/src/plugins/source-transform.ts +123 -0
  116. package/src/route-renderer/orchestration/boundary-planning.service.ts +146 -0
  117. package/src/route-renderer/orchestration/component-render-context.ts +318 -0
  118. package/src/route-renderer/orchestration/integration-renderer.test.ts +2088 -0
  119. package/src/route-renderer/orchestration/integration-renderer.ts +1285 -0
  120. package/src/route-renderer/orchestration/page-packaging.service.test.ts +76 -0
  121. package/src/route-renderer/orchestration/page-packaging.service.ts +85 -0
  122. package/src/route-renderer/orchestration/processed-asset-dedupe.ts +25 -0
  123. package/src/route-renderer/orchestration/queued-boundary-runtime.service.test.ts +319 -0
  124. package/src/route-renderer/orchestration/queued-boundary-runtime.service.ts +289 -0
  125. package/src/route-renderer/orchestration/render-execution.service.test.ts +196 -0
  126. package/src/route-renderer/orchestration/render-execution.service.ts +182 -0
  127. package/src/route-renderer/orchestration/render-output.utils.ts +302 -0
  128. package/src/route-renderer/orchestration/render-preparation.service.test.ts +569 -0
  129. package/src/route-renderer/orchestration/render-preparation.service.ts +508 -0
  130. package/src/route-renderer/orchestration/route-shell-composer.service.ts +162 -0
  131. package/src/route-renderer/orchestration/template-serialization.test.ts +110 -0
  132. package/src/route-renderer/orchestration/template-serialization.ts +117 -0
  133. package/src/route-renderer/page-loading/component-dependency-collection.ts +196 -0
  134. package/src/route-renderer/page-loading/declared-asset-collection.ts +156 -0
  135. package/src/route-renderer/page-loading/dependency-resolver.test.ts +665 -0
  136. package/src/route-renderer/page-loading/dependency-resolver.ts +150 -0
  137. package/src/route-renderer/page-loading/ecopages-virtual-imports.ts +75 -0
  138. package/src/route-renderer/page-loading/lazy-entry-collection.ts +167 -0
  139. package/src/route-renderer/page-loading/lazy-trigger-planning.ts +74 -0
  140. package/src/route-renderer/page-loading/module-declaration-aggregation.ts +60 -0
  141. package/src/route-renderer/page-loading/module-declaration-scripts.ts +16 -0
  142. package/src/route-renderer/page-loading/page-dependency-bundling.ts +205 -0
  143. package/src/route-renderer/page-loading/page-module-loader.test.ts +183 -0
  144. package/src/route-renderer/page-loading/page-module-loader.ts +184 -0
  145. package/src/route-renderer/route-renderer.ts +136 -0
  146. package/src/router/client/link-intent.test.browser.ts +51 -0
  147. package/src/router/client/link-intent.ts +92 -0
  148. package/src/router/client/navigation-coordinator.test.ts +237 -0
  149. package/src/router/client/navigation-coordinator.ts +453 -0
  150. package/src/router/server/fs-router-scanner.test.ts +83 -0
  151. package/src/router/server/fs-router-scanner.ts +224 -0
  152. package/src/router/server/fs-router.test.ts +214 -0
  153. package/src/router/server/fs-router.ts +122 -0
  154. package/src/services/assets/asset-processing-service/asset-dependency-keys.ts +66 -0
  155. package/src/services/assets/asset-processing-service/asset-processing.service.test.ts +476 -0
  156. package/src/services/assets/asset-processing-service/asset-processing.service.ts +345 -0
  157. package/src/services/assets/asset-processing-service/asset.factory.test.ts +63 -0
  158. package/src/services/assets/asset-processing-service/asset.factory.ts +105 -0
  159. package/src/services/assets/asset-processing-service/assets.types.ts +125 -0
  160. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.test.ts +74 -0
  161. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.ts +96 -0
  162. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.test.ts +67 -0
  163. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.ts +78 -0
  164. package/src/services/assets/asset-processing-service/grouped-content-bundles.ts +104 -0
  165. package/src/services/assets/asset-processing-service/index.ts +5 -0
  166. package/src/services/assets/asset-processing-service/{processor.interface.d.ts → processor.interface.ts} +10 -5
  167. package/src/services/assets/asset-processing-service/processor.registry.ts +18 -0
  168. package/src/services/assets/asset-processing-service/processors/base/base-processor.test.ts +59 -0
  169. package/src/services/assets/asset-processing-service/processors/base/base-processor.ts +83 -0
  170. package/src/services/assets/asset-processing-service/processors/base/base-script-processor.ts +174 -0
  171. package/src/services/assets/asset-processing-service/processors/index.ts +5 -0
  172. package/src/services/assets/asset-processing-service/processors/script/content-script.processor.test.ts +192 -0
  173. package/src/services/assets/asset-processing-service/processors/script/content-script.processor.ts +134 -0
  174. package/src/services/assets/asset-processing-service/processors/script/file-script.processor.test.ts +326 -0
  175. package/src/services/assets/asset-processing-service/processors/script/file-script.processor.ts +110 -0
  176. package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.test.ts +227 -0
  177. package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.ts +87 -0
  178. package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.test.ts +261 -0
  179. package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.ts +71 -0
  180. package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.ts +81 -0
  181. package/src/services/assets/asset-processing-service/ungrouped-dependency-processing.ts +65 -0
  182. package/src/services/assets/browser-bundle.service.test.ts +66 -0
  183. package/src/services/assets/browser-bundle.service.ts +109 -0
  184. package/src/services/cache/cache.types.ts +126 -0
  185. package/src/services/cache/index.ts +18 -0
  186. package/src/services/cache/memory-cache-store.test.ts +225 -0
  187. package/src/services/cache/memory-cache-store.ts +130 -0
  188. package/src/services/cache/page-cache-service.test.ts +175 -0
  189. package/src/services/cache/page-cache-service.ts +202 -0
  190. package/src/services/cache/page-request-cache-coordinator.service.test.ts +79 -0
  191. package/src/services/cache/page-request-cache-coordinator.service.ts +131 -0
  192. package/src/services/html/html-rewriter-provider.service.test.ts +183 -0
  193. package/src/services/html/html-rewriter-provider.service.ts +104 -0
  194. package/src/services/html/html-transformer.service.test.ts +479 -0
  195. package/src/services/html/html-transformer.service.ts +275 -0
  196. package/src/services/invalidation/development-invalidation.service.test.ts +87 -0
  197. package/src/services/invalidation/development-invalidation.service.ts +262 -0
  198. package/src/services/module-loading/app-module-loader.service.ts +9 -0
  199. package/src/services/module-loading/app-server-module-transpiler.service.test.ts +130 -0
  200. package/src/services/module-loading/app-server-module-transpiler.service.ts +143 -0
  201. package/src/services/module-loading/host-module-loader-registry.ts +15 -0
  202. package/src/services/module-loading/{module-loading-types.d.ts → module-loading-types.ts} +1 -0
  203. package/src/services/module-loading/node-bootstrap-plugin.test.ts +335 -0
  204. package/src/services/module-loading/node-bootstrap-plugin.ts +297 -0
  205. package/src/services/module-loading/page-module-import.service.test.ts +504 -0
  206. package/src/services/module-loading/page-module-import.service.ts +252 -0
  207. package/src/services/module-loading/server-module-transpiler.service.test.ts +243 -0
  208. package/src/services/module-loading/server-module-transpiler.service.ts +104 -0
  209. package/src/services/module-loading/source-module-support.ts +19 -0
  210. package/src/services/runtime-state/dev-graph.service.ts +217 -0
  211. package/src/services/runtime-state/entrypoint-dependency-graph.service.ts +136 -0
  212. package/src/services/runtime-state/runtime-specifier-registry.service.ts +96 -0
  213. package/src/services/runtime-state/server-invalidation-state.service.ts +68 -0
  214. package/src/services/validation/schema-validation-service.test.ts +223 -0
  215. package/src/services/validation/schema-validation-service.ts +204 -0
  216. package/src/services/validation/{standard-schema.types.d.ts → standard-schema.types.ts} +20 -17
  217. package/src/static-site-generator/static-site-generator.test.ts +316 -0
  218. package/src/static-site-generator/static-site-generator.ts +462 -0
  219. package/src/types/internal-types.ts +242 -0
  220. package/src/types/public-types.ts +1443 -0
  221. package/src/utils/deep-merge.test.ts +114 -0
  222. package/src/utils/deep-merge.ts +47 -0
  223. package/src/utils/hash.ts +5 -0
  224. package/src/utils/html-escaping.ts +9 -0
  225. package/src/utils/invariant.test.ts +22 -0
  226. package/src/utils/invariant.ts +15 -0
  227. package/src/utils/locals-utils.ts +37 -0
  228. package/src/utils/parse-cli-args.test.ts +69 -0
  229. package/src/utils/parse-cli-args.ts +105 -0
  230. package/src/utils/path-utils.module.ts +14 -0
  231. package/src/utils/path-utils.test.ts +15 -0
  232. package/src/utils/resolve-work-dir.ts +45 -0
  233. package/src/utils/runtime.ts +44 -0
  234. package/src/utils/server-utils.module.ts +67 -0
  235. package/src/utils/server-utils.test.ts +38 -0
  236. package/src/watchers/project-watcher.integration.test.ts +337 -0
  237. package/src/watchers/project-watcher.test-helpers.ts +41 -0
  238. package/src/watchers/project-watcher.test.ts +768 -0
  239. package/src/watchers/project-watcher.ts +357 -0
  240. package/CHANGELOG.md +0 -51
  241. package/src/adapters/abstract/application-adapter.d.ts +0 -194
  242. package/src/adapters/abstract/application-adapter.js +0 -121
  243. package/src/adapters/abstract/router-adapter.d.ts +0 -26
  244. package/src/adapters/abstract/router-adapter.js +0 -5
  245. package/src/adapters/abstract/server-adapter.d.ts +0 -69
  246. package/src/adapters/abstract/server-adapter.js +0 -15
  247. package/src/adapters/bun/client-bridge.d.ts +0 -34
  248. package/src/adapters/bun/client-bridge.js +0 -48
  249. package/src/adapters/bun/create-app.d.ts +0 -52
  250. package/src/adapters/bun/create-app.js +0 -116
  251. package/src/adapters/bun/hmr-manager.d.ts +0 -143
  252. package/src/adapters/bun/hmr-manager.js +0 -333
  253. package/src/adapters/bun/index.d.ts +0 -2
  254. package/src/adapters/bun/index.js +0 -8
  255. package/src/adapters/bun/server-adapter.d.ts +0 -155
  256. package/src/adapters/bun/server-adapter.js +0 -374
  257. package/src/adapters/bun/server-lifecycle.d.ts +0 -63
  258. package/src/adapters/bun/server-lifecycle.js +0 -92
  259. package/src/adapters/create-app.d.ts +0 -20
  260. package/src/adapters/create-app.js +0 -66
  261. package/src/adapters/index.d.ts +0 -2
  262. package/src/adapters/index.js +0 -8
  263. package/src/adapters/node/create-app.d.ts +0 -18
  264. package/src/adapters/node/create-app.js +0 -149
  265. package/src/adapters/node/node-client-bridge.d.ts +0 -26
  266. package/src/adapters/node/node-client-bridge.js +0 -66
  267. package/src/adapters/node/node-hmr-manager.d.ts +0 -133
  268. package/src/adapters/node/node-hmr-manager.js +0 -311
  269. package/src/adapters/node/server-adapter.d.ts +0 -161
  270. package/src/adapters/node/server-adapter.js +0 -359
  271. package/src/adapters/node/static-content-server.d.ts +0 -60
  272. package/src/adapters/node/static-content-server.js +0 -194
  273. package/src/adapters/shared/api-response.d.ts +0 -52
  274. package/src/adapters/shared/api-response.js +0 -96
  275. package/src/adapters/shared/application-adapter.d.ts +0 -18
  276. package/src/adapters/shared/application-adapter.js +0 -90
  277. package/src/adapters/shared/define-api-handler.d.ts +0 -25
  278. package/src/adapters/shared/define-api-handler.js +0 -15
  279. package/src/adapters/shared/explicit-static-route-matcher.d.ts +0 -38
  280. package/src/adapters/shared/explicit-static-route-matcher.js +0 -103
  281. package/src/adapters/shared/file-route-middleware-pipeline.d.ts +0 -65
  282. package/src/adapters/shared/file-route-middleware-pipeline.js +0 -99
  283. package/src/adapters/shared/fs-server-response-factory.d.ts +0 -19
  284. package/src/adapters/shared/fs-server-response-factory.js +0 -97
  285. package/src/adapters/shared/fs-server-response-matcher.d.ts +0 -67
  286. package/src/adapters/shared/fs-server-response-matcher.js +0 -147
  287. package/src/adapters/shared/hmr-entrypoint-registrar.d.ts +0 -55
  288. package/src/adapters/shared/hmr-entrypoint-registrar.js +0 -87
  289. package/src/adapters/shared/hmr-html-response.d.ts +0 -22
  290. package/src/adapters/shared/hmr-html-response.js +0 -32
  291. package/src/adapters/shared/render-context.d.ts +0 -15
  292. package/src/adapters/shared/render-context.js +0 -72
  293. package/src/adapters/shared/runtime-bootstrap.d.ts +0 -38
  294. package/src/adapters/shared/runtime-bootstrap.js +0 -43
  295. package/src/adapters/shared/server-adapter.d.ts +0 -97
  296. package/src/adapters/shared/server-adapter.js +0 -390
  297. package/src/adapters/shared/server-route-handler.d.ts +0 -89
  298. package/src/adapters/shared/server-route-handler.js +0 -111
  299. package/src/adapters/shared/server-static-builder.d.ts +0 -70
  300. package/src/adapters/shared/server-static-builder.js +0 -100
  301. package/src/build/build-adapter.d.ts +0 -239
  302. package/src/build/build-adapter.js +0 -642
  303. package/src/build/build-manifest.d.ts +0 -27
  304. package/src/build/build-manifest.js +0 -30
  305. package/src/build/build-types.d.ts +0 -57
  306. package/src/build/build-types.js +0 -0
  307. package/src/build/dev-build-coordinator.d.ts +0 -72
  308. package/src/build/dev-build-coordinator.js +0 -154
  309. package/src/build/esbuild-build-adapter.d.ts +0 -78
  310. package/src/build/esbuild-build-adapter.js +0 -505
  311. package/src/build/runtime-build-executor.d.ts +0 -14
  312. package/src/build/runtime-build-executor.js +0 -22
  313. package/src/build/runtime-specifier-alias-plugin.d.ts +0 -15
  314. package/src/build/runtime-specifier-alias-plugin.js +0 -35
  315. package/src/build/runtime-specifier-aliases.d.ts +0 -5
  316. package/src/build/runtime-specifier-aliases.js +0 -95
  317. package/src/config/config-builder.d.ts +0 -252
  318. package/src/config/config-builder.js +0 -603
  319. package/src/config/constants.js +0 -25
  320. package/src/dev/sc-server.d.ts +0 -30
  321. package/src/dev/sc-server.js +0 -111
  322. package/src/eco/eco.browser.d.ts +0 -2
  323. package/src/eco/eco.browser.js +0 -83
  324. package/src/eco/eco.d.ts +0 -9
  325. package/src/eco/eco.js +0 -85
  326. package/src/eco/eco.types.d.ts +0 -178
  327. package/src/eco/eco.types.js +0 -0
  328. package/src/eco/eco.utils.d.ts +0 -1
  329. package/src/eco/eco.utils.js +0 -10
  330. package/src/eco/global-injector-map.d.ts +0 -16
  331. package/src/eco/global-injector-map.js +0 -80
  332. package/src/eco/lazy-injector-map.d.ts +0 -8
  333. package/src/eco/lazy-injector-map.js +0 -70
  334. package/src/eco/module-dependencies.d.ts +0 -18
  335. package/src/eco/module-dependencies.js +0 -49
  336. package/src/errors/http-error.d.ts +0 -31
  337. package/src/errors/http-error.js +0 -50
  338. package/src/errors/index.js +0 -4
  339. package/src/errors/locals-access-error.d.ts +0 -4
  340. package/src/errors/locals-access-error.js +0 -9
  341. package/src/global/app-logger.d.ts +0 -2
  342. package/src/global/app-logger.js +0 -6
  343. package/src/hmr/client/hmr-runtime.d.ts +0 -5
  344. package/src/hmr/client/hmr-runtime.js +0 -109
  345. package/src/hmr/hmr-strategy.d.ts +0 -162
  346. package/src/hmr/hmr-strategy.js +0 -44
  347. package/src/hmr/hmr.postcss.test.e2e.d.ts +0 -1
  348. package/src/hmr/hmr.postcss.test.e2e.js +0 -31
  349. package/src/hmr/hmr.test.e2e.d.ts +0 -1
  350. package/src/hmr/hmr.test.e2e.js +0 -43
  351. package/src/hmr/strategies/default-hmr-strategy.d.ts +0 -43
  352. package/src/hmr/strategies/default-hmr-strategy.js +0 -34
  353. package/src/hmr/strategies/js-hmr-strategy.d.ts +0 -139
  354. package/src/hmr/strategies/js-hmr-strategy.js +0 -178
  355. package/src/index.browser.d.ts +0 -3
  356. package/src/index.browser.js +0 -4
  357. package/src/index.d.ts +0 -6
  358. package/src/index.js +0 -21
  359. package/src/integrations/ghtml/ghtml-renderer.d.ts +0 -20
  360. package/src/integrations/ghtml/ghtml-renderer.js +0 -63
  361. package/src/integrations/ghtml/ghtml.constants.d.ts +0 -1
  362. package/src/integrations/ghtml/ghtml.constants.js +0 -4
  363. package/src/integrations/ghtml/ghtml.plugin.d.ts +0 -16
  364. package/src/integrations/ghtml/ghtml.plugin.js +0 -20
  365. package/src/plugins/alias-resolver-plugin.d.ts +0 -2
  366. package/src/plugins/alias-resolver-plugin.js +0 -53
  367. package/src/plugins/eco-component-meta-plugin.d.ts +0 -108
  368. package/src/plugins/eco-component-meta-plugin.js +0 -163
  369. package/src/plugins/foreign-jsx-override-plugin.d.ts +0 -31
  370. package/src/plugins/foreign-jsx-override-plugin.js +0 -35
  371. package/src/plugins/integration-plugin.d.ts +0 -219
  372. package/src/plugins/integration-plugin.js +0 -196
  373. package/src/plugins/processor.d.ts +0 -95
  374. package/src/plugins/processor.js +0 -136
  375. package/src/plugins/runtime-capability.js +0 -0
  376. package/src/plugins/source-transform.d.ts +0 -46
  377. package/src/plugins/source-transform.js +0 -71
  378. package/src/route-renderer/orchestration/boundary-planning.service.d.ts +0 -25
  379. package/src/route-renderer/orchestration/boundary-planning.service.js +0 -97
  380. package/src/route-renderer/orchestration/component-render-context.d.ts +0 -83
  381. package/src/route-renderer/orchestration/component-render-context.js +0 -147
  382. package/src/route-renderer/orchestration/integration-renderer.d.ts +0 -554
  383. package/src/route-renderer/orchestration/integration-renderer.js +0 -957
  384. package/src/route-renderer/orchestration/queued-boundary-runtime.service.d.ts +0 -89
  385. package/src/route-renderer/orchestration/queued-boundary-runtime.service.js +0 -155
  386. package/src/route-renderer/orchestration/render-execution.service.d.ts +0 -43
  387. package/src/route-renderer/orchestration/render-execution.service.js +0 -106
  388. package/src/route-renderer/orchestration/render-output.utils.d.ts +0 -46
  389. package/src/route-renderer/orchestration/render-output.utils.js +0 -65
  390. package/src/route-renderer/orchestration/render-preparation.service.d.ts +0 -120
  391. package/src/route-renderer/orchestration/render-preparation.service.js +0 -341
  392. package/src/route-renderer/orchestration/route-shell-composer.service.d.ts +0 -50
  393. package/src/route-renderer/orchestration/route-shell-composer.service.js +0 -81
  394. package/src/route-renderer/orchestration/template-serialization.d.ts +0 -38
  395. package/src/route-renderer/orchestration/template-serialization.js +0 -45
  396. package/src/route-renderer/page-loading/dependency-resolver.d.ts +0 -35
  397. package/src/route-renderer/page-loading/dependency-resolver.js +0 -444
  398. package/src/route-renderer/page-loading/page-module-loader.d.ts +0 -90
  399. package/src/route-renderer/page-loading/page-module-loader.js +0 -127
  400. package/src/route-renderer/route-renderer.d.ts +0 -67
  401. package/src/route-renderer/route-renderer.js +0 -103
  402. package/src/router/client/link-intent.js +0 -34
  403. package/src/router/client/link-intent.test.browser.d.ts +0 -1
  404. package/src/router/client/link-intent.test.browser.js +0 -43
  405. package/src/router/client/navigation-coordinator.d.ts +0 -149
  406. package/src/router/client/navigation-coordinator.js +0 -215
  407. package/src/router/server/fs-router-scanner.d.ts +0 -41
  408. package/src/router/server/fs-router-scanner.js +0 -161
  409. package/src/router/server/fs-router.d.ts +0 -26
  410. package/src/router/server/fs-router.js +0 -100
  411. package/src/services/assets/asset-processing-service/asset-processing.service.d.ts +0 -120
  412. package/src/services/assets/asset-processing-service/asset-processing.service.js +0 -331
  413. package/src/services/assets/asset-processing-service/asset.factory.d.ts +0 -17
  414. package/src/services/assets/asset-processing-service/asset.factory.js +0 -82
  415. package/src/services/assets/asset-processing-service/assets.types.d.ts +0 -89
  416. package/src/services/assets/asset-processing-service/assets.types.js +0 -0
  417. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.d.ts +0 -55
  418. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.js +0 -48
  419. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.d.ts +0 -20
  420. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.js +0 -41
  421. package/src/services/assets/asset-processing-service/index.d.ts +0 -5
  422. package/src/services/assets/asset-processing-service/index.js +0 -5
  423. package/src/services/assets/asset-processing-service/processor.interface.js +0 -6
  424. package/src/services/assets/asset-processing-service/processor.registry.d.ts +0 -8
  425. package/src/services/assets/asset-processing-service/processor.registry.js +0 -15
  426. package/src/services/assets/asset-processing-service/processors/base/base-processor.d.ts +0 -24
  427. package/src/services/assets/asset-processing-service/processors/base/base-processor.js +0 -64
  428. package/src/services/assets/asset-processing-service/processors/base/base-script-processor.d.ts +0 -17
  429. package/src/services/assets/asset-processing-service/processors/base/base-script-processor.js +0 -72
  430. package/src/services/assets/asset-processing-service/processors/index.d.ts +0 -5
  431. package/src/services/assets/asset-processing-service/processors/index.js +0 -5
  432. package/src/services/assets/asset-processing-service/processors/script/content-script.processor.d.ts +0 -5
  433. package/src/services/assets/asset-processing-service/processors/script/content-script.processor.js +0 -57
  434. package/src/services/assets/asset-processing-service/processors/script/file-script.processor.d.ts +0 -9
  435. package/src/services/assets/asset-processing-service/processors/script/file-script.processor.js +0 -88
  436. package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.d.ts +0 -7
  437. package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.js +0 -75
  438. package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.d.ts +0 -5
  439. package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.js +0 -25
  440. package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.d.ts +0 -9
  441. package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.js +0 -66
  442. package/src/services/assets/browser-bundle.service.d.ts +0 -32
  443. package/src/services/assets/browser-bundle.service.js +0 -33
  444. package/src/services/cache/cache.types.d.ts +0 -107
  445. package/src/services/cache/cache.types.js +0 -0
  446. package/src/services/cache/index.d.ts +0 -7
  447. package/src/services/cache/index.js +0 -7
  448. package/src/services/cache/memory-cache-store.d.ts +0 -42
  449. package/src/services/cache/memory-cache-store.js +0 -98
  450. package/src/services/cache/page-cache-service.d.ts +0 -70
  451. package/src/services/cache/page-cache-service.js +0 -152
  452. package/src/services/cache/page-request-cache-coordinator.service.d.ts +0 -75
  453. package/src/services/cache/page-request-cache-coordinator.service.js +0 -109
  454. package/src/services/html/html-rewriter-provider.service.d.ts +0 -37
  455. package/src/services/html/html-rewriter-provider.service.js +0 -68
  456. package/src/services/html/html-transformer.service.d.ts +0 -77
  457. package/src/services/html/html-transformer.service.js +0 -215
  458. package/src/services/invalidation/development-invalidation.service.d.ts +0 -74
  459. package/src/services/invalidation/development-invalidation.service.js +0 -190
  460. package/src/services/module-loading/app-module-loader.service.d.ts +0 -28
  461. package/src/services/module-loading/app-module-loader.service.js +0 -35
  462. package/src/services/module-loading/app-server-module-transpiler.service.d.ts +0 -24
  463. package/src/services/module-loading/app-server-module-transpiler.service.js +0 -109
  464. package/src/services/module-loading/host-module-loader-registry.d.ts +0 -4
  465. package/src/services/module-loading/host-module-loader-registry.js +0 -15
  466. package/src/services/module-loading/module-loading-types.js +0 -0
  467. package/src/services/module-loading/node-bootstrap-plugin.d.ts +0 -42
  468. package/src/services/module-loading/node-bootstrap-plugin.js +0 -204
  469. package/src/services/module-loading/page-module-import.service.d.ts +0 -76
  470. package/src/services/module-loading/page-module-import.service.js +0 -173
  471. package/src/services/module-loading/server-module-transpiler.service.d.ts +0 -72
  472. package/src/services/module-loading/server-module-transpiler.service.js +0 -64
  473. package/src/services/runtime-state/dev-graph.service.d.ts +0 -118
  474. package/src/services/runtime-state/dev-graph.service.js +0 -162
  475. package/src/services/runtime-state/entrypoint-dependency-graph.service.d.ts +0 -41
  476. package/src/services/runtime-state/entrypoint-dependency-graph.service.js +0 -85
  477. package/src/services/runtime-state/runtime-specifier-registry.service.d.ts +0 -69
  478. package/src/services/runtime-state/runtime-specifier-registry.service.js +0 -37
  479. package/src/services/runtime-state/server-invalidation-state.service.d.ts +0 -26
  480. package/src/services/runtime-state/server-invalidation-state.service.js +0 -35
  481. package/src/services/validation/schema-validation-service.d.ts +0 -122
  482. package/src/services/validation/schema-validation-service.js +0 -101
  483. package/src/services/validation/standard-schema.types.js +0 -0
  484. package/src/static-site-generator/static-site-generator.d.ts +0 -104
  485. package/src/static-site-generator/static-site-generator.js +0 -338
  486. package/src/types/internal-types.d.ts +0 -231
  487. package/src/types/internal-types.js +0 -0
  488. package/src/types/public-types.d.ts +0 -1219
  489. package/src/types/public-types.js +0 -0
  490. package/src/utils/deep-merge.d.ts +0 -14
  491. package/src/utils/deep-merge.js +0 -32
  492. package/src/utils/hash.d.ts +0 -1
  493. package/src/utils/hash.js +0 -7
  494. package/src/utils/html-escaping.d.ts +0 -7
  495. package/src/utils/html-escaping.js +0 -6
  496. package/src/utils/html.js +0 -4
  497. package/src/utils/invariant.d.ts +0 -5
  498. package/src/utils/invariant.js +0 -11
  499. package/src/utils/locals-utils.d.ts +0 -15
  500. package/src/utils/locals-utils.js +0 -24
  501. package/src/utils/parse-cli-args.d.ts +0 -27
  502. package/src/utils/parse-cli-args.js +0 -62
  503. package/src/utils/path-utils.module.d.ts +0 -5
  504. package/src/utils/path-utils.module.js +0 -14
  505. package/src/utils/resolve-work-dir.d.ts +0 -11
  506. package/src/utils/resolve-work-dir.js +0 -31
  507. package/src/utils/runtime.d.ts +0 -11
  508. package/src/utils/runtime.js +0 -40
  509. package/src/utils/server-utils.module.d.ts +0 -19
  510. package/src/utils/server-utils.module.js +0 -56
  511. package/src/watchers/project-watcher.d.ts +0 -136
  512. package/src/watchers/project-watcher.js +0 -275
  513. package/src/watchers/project-watcher.test-helpers.d.ts +0 -4
  514. package/src/watchers/project-watcher.test-helpers.js +0 -52
  515. /package/src/utils/{html.d.ts → html.ts} +0 -0
@@ -1,957 +0,0 @@
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 { RenderExecutionService } from "./render-execution.service.js";
10
- import { RenderPreparationService } from "./render-preparation.service.js";
11
- import { RouteShellComposer } from "./route-shell-composer.service.js";
12
- import { normalizeBoundaryArtifactHtml } from "./render-output.utils.js";
13
- import { getComponentRenderContext, runWithComponentRenderContext } from "./component-render-context.js";
14
- import {
15
- QueuedBoundaryRuntimeService
16
- } from "./queued-boundary-runtime.service.js";
17
- function createLocalsProxy(filePath) {
18
- 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.`;
19
- return new Proxy(
20
- {},
21
- {
22
- get: () => {
23
- throw new LocalsAccessError(errorMessage);
24
- },
25
- set: () => {
26
- throw new LocalsAccessError(errorMessage);
27
- },
28
- has: () => {
29
- throw new LocalsAccessError(errorMessage);
30
- },
31
- ownKeys: () => {
32
- throw new LocalsAccessError(errorMessage);
33
- },
34
- deleteProperty: () => {
35
- throw new LocalsAccessError(errorMessage);
36
- },
37
- defineProperty: () => {
38
- throw new LocalsAccessError(errorMessage);
39
- },
40
- getOwnPropertyDescriptor: () => {
41
- throw new LocalsAccessError(errorMessage);
42
- }
43
- }
44
- );
45
- }
46
- class IntegrationRenderer {
47
- appConfig;
48
- assetProcessingService;
49
- htmlTransformer;
50
- hmrManager;
51
- resolvedIntegrationDependencies = [];
52
- rendererModules;
53
- runtimeOrigin;
54
- dependencyResolverService;
55
- pageModuleLoaderService;
56
- renderPreparationService;
57
- renderExecutionService;
58
- routeShellComposer = new RouteShellComposer();
59
- queuedBoundaryRuntimeService = new QueuedBoundaryRuntimeService();
60
- DOC_TYPE = "<!DOCTYPE html>";
61
- /**
62
- * Loads one route module through the owning renderer's import path.
63
- *
64
- * Request-time infrastructure may need page metadata such as cache strategy or
65
- * middleware before full rendering starts. Exposing this narrow entrypoint lets
66
- * those callers reuse integration-specific import setup instead of bypassing it
67
- * with raw transpiler access.
68
- */
69
- async loadPageModule(file, options) {
70
- return this.importPageFile(file, options);
71
- }
72
- /**
73
- * Reads the execution-scoped foreign renderer cache from one boundary input.
74
- *
75
- * Shared page/layout/document shell helpers pass one cache through
76
- * `integrationContext` so repeated delegation to the same foreign integration
77
- * can reuse a single initialized renderer instance during one render flow.
78
- * The cache is deliberately scoped to the current render execution rather than
79
- * stored on the renderer, which avoids leaking mutable integration state across
80
- * requests while still preventing redundant renderer initialization.
81
- *
82
- * @param integrationContext - Optional boundary context carried with one render input.
83
- * @returns The current execution cache when present.
84
- */
85
- getBoundaryRendererCache(integrationContext) {
86
- if (integrationContext?.rendererCache instanceof Map) {
87
- return integrationContext.rendererCache;
88
- }
89
- return void 0;
90
- }
91
- getRegisteredBoundaryOwner(component) {
92
- const integrationName = component.config?.integration ?? component.config?.__eco?.integration;
93
- if (!integrationName || integrationName === this.name) {
94
- return void 0;
95
- }
96
- return this.appConfig.integrations.some((integration) => integration.name === integrationName) ? integrationName : void 0;
97
- }
98
- /**
99
- * Attaches an execution-scoped foreign renderer cache to one boundary input.
100
- *
101
- * Foreign-owned page, layout, or document shells may delegate several times in
102
- * the same render flow. Threading the cache through `integrationContext`
103
- * preserves renderer reuse without changing the public boundary input contract.
104
- * Existing integration-specific context is preserved and augmented.
105
- *
106
- * @param input - Original boundary render input.
107
- * @param rendererCache - Execution-scoped renderer cache to propagate.
108
- * @returns Boundary input augmented with the shared renderer cache.
109
- */
110
- withBoundaryRendererCache(input, rendererCache) {
111
- const integrationContext = input.integrationContext;
112
- const sharedRendererCache = rendererCache;
113
- return {
114
- ...input,
115
- integrationContext: integrationContext ? { ...integrationContext, rendererCache: sharedRendererCache } : { rendererCache: sharedRendererCache }
116
- };
117
- }
118
- getRendererModuleValue(key) {
119
- if (!this.rendererModules || typeof this.rendererModules !== "object") {
120
- return void 0;
121
- }
122
- return this.rendererModules[key];
123
- }
124
- getRendererModuleString(key) {
125
- const value = this.getRendererModuleValue(key);
126
- return typeof value === "string" && value.length > 0 ? value : void 0;
127
- }
128
- getRendererBootstrapDependencies(partial = false) {
129
- if (partial) {
130
- return [];
131
- }
132
- const islandClientModuleId = this.getRendererModuleString("islandClientModuleId");
133
- if (!islandClientModuleId) {
134
- return [];
135
- }
136
- return [
137
- {
138
- attributes: {
139
- crossorigin: "anonymous",
140
- "data-ecopages-runtime": "islands",
141
- type: "module"
142
- },
143
- content: `import ${JSON.stringify(islandClientModuleId)};`,
144
- inline: true,
145
- kind: "script",
146
- position: "body"
147
- }
148
- ];
149
- }
150
- setHmrManager(hmrManager) {
151
- this.hmrManager = hmrManager;
152
- if (this.assetProcessingService) {
153
- this.assetProcessingService.setHmrManager(hmrManager);
154
- }
155
- }
156
- /**
157
- * Build response headers with optional custom headers.
158
- * @param contentType - The Content-Type header value
159
- * @param customHeaders - Optional custom headers to merge
160
- * @returns Headers object
161
- */
162
- buildHeaders(contentType, customHeaders) {
163
- const headers = new Headers({ "Content-Type": contentType });
164
- if (customHeaders) {
165
- const incoming = new Headers(customHeaders);
166
- incoming.forEach((value, key) => headers.set(key, value));
167
- }
168
- return headers;
169
- }
170
- /**
171
- * Create an HTML Response.
172
- * @param body - Response body (string or ReadableStream)
173
- * @param ctx - Render context with status and headers
174
- * @returns Response object
175
- */
176
- createHtmlResponse(body, ctx) {
177
- return new Response(body, {
178
- status: ctx.status ?? 200,
179
- headers: this.buildHeaders("text/html; charset=utf-8", ctx.headers)
180
- });
181
- }
182
- /**
183
- * Create an HttpError for render failures.
184
- * @param message - Error message
185
- * @param cause - Original error if available
186
- * @returns HttpError with 500 status
187
- */
188
- createRenderError(message, cause) {
189
- const errorMessage = cause instanceof Error ? `${message}: ${cause.message}` : message;
190
- return HttpError.InternalServerError(errorMessage);
191
- }
192
- /**
193
- * Prepares dependencies for renderToResponse by resolving component dependencies
194
- * and configuring the HTML transformer.
195
- * @param view - The view component being rendered
196
- * @param layout - Optional layout component
197
- * @returns Resolved processed assets
198
- */
199
- async prepareViewDependencies(view, layout) {
200
- const HtmlTemplate = await this.getHtmlTemplate();
201
- const componentsToResolve = layout ? [HtmlTemplate, layout, view] : [HtmlTemplate, view];
202
- const resolvedDependencies = this.htmlTransformer.dedupeProcessedAssets(
203
- await this.resolveDependencies(componentsToResolve)
204
- );
205
- this.htmlTransformer.setProcessedDependencies(resolvedDependencies);
206
- return resolvedDependencies;
207
- }
208
- /**
209
- * Merges component-scoped assets into the active HTML transformer state.
210
- *
211
- * Explicit page, layout, and document shell composition can produce assets at
212
- * each boundary. This helper deduplicates those groups and folds them back into
213
- * the transformer so downstream HTML finalization sees one canonical asset set.
214
- *
215
- * @param assetGroups - Optional groups of processed assets to merge.
216
- * @returns The deduplicated asset subset contributed by this merge operation.
217
- */
218
- appendProcessedDependencies(...assetGroups) {
219
- const nextDependencies = this.htmlTransformer.dedupeProcessedAssets(
220
- assetGroups.flatMap((assets) => assets ?? [])
221
- );
222
- if (nextDependencies.length === 0) {
223
- return nextDependencies;
224
- }
225
- this.htmlTransformer.setProcessedDependencies(
226
- this.htmlTransformer.dedupeProcessedAssets([
227
- ...this.htmlTransformer.getProcessedDependencies(),
228
- ...nextDependencies
229
- ])
230
- );
231
- return nextDependencies;
232
- }
233
- /**
234
- * Resolves metadata for explicit view rendering.
235
- *
236
- * When a view declares a `metadata()` function, that contract owns the final
237
- * metadata for the explicit render. Otherwise the app-level default metadata is
238
- * reused so explicit routes and page-module routes share the same fallback.
239
- *
240
- * @param view - View component being rendered.
241
- * @param props - Props passed to the view.
242
- * @returns Resolved metadata for the final document shell.
243
- */
244
- async resolveViewMetadata(view, props) {
245
- return view.metadata ? await view.metadata({
246
- params: {},
247
- query: {},
248
- props,
249
- appConfig: this.appConfig
250
- }) : this.appConfig.defaultMetadata;
251
- }
252
- /**
253
- * Renders one explicit view response in partial mode.
254
- *
255
- * Same-integration views can optionally stream or render inline via the caller's
256
- * `renderInline()` hook. Once a view may cross integration boundaries, this
257
- * helper routes the render through `renderComponentBoundary()` instead so mixed
258
- * shells can reuse the execution-scoped renderer cache and resolve nested
259
- * foreign ownership before the partial response is returned.
260
- *
261
- * @param input - View render options for the partial response.
262
- * @returns HTML response for the partial render.
263
- */
264
- async renderPartialViewResponse(input) {
265
- return this.routeShellComposer.renderPartialViewResponse(input, {
266
- hasForeignBoundaryDescendants: (component) => this.hasForeignBoundaryDescendants(component),
267
- createHtmlResponse: (body, ctx) => this.createHtmlResponse(body, ctx),
268
- renderComponentBoundary: (boundaryInput) => this.renderComponentBoundary(boundaryInput),
269
- prepareViewDependencies: (view, layout) => this.prepareViewDependencies(view, layout),
270
- getHtmlTemplate: () => this.getHtmlTemplate(),
271
- resolveViewMetadata: (view, props) => this.resolveViewMetadata(view, props),
272
- appendProcessedDependencies: (...assetGroups) => this.appendProcessedDependencies(...assetGroups),
273
- finalizeResolvedHtml: (options) => this.finalizeResolvedHtml(options),
274
- docType: this.DOC_TYPE
275
- });
276
- }
277
- /**
278
- * Renders an explicit view through optional layout and document shells.
279
- *
280
- * This helper is the shared explicit-route path for string-oriented and mixed
281
- * integrations. It prepares view dependencies, resolves metadata, and composes
282
- * view, layout, and html template boundaries with one execution-scoped renderer
283
- * cache so repeated foreign shell delegation can reuse initialized renderers
284
- * during the same render flow.
285
- *
286
- * @param input - View, props, and optional layout metadata for the render.
287
- * @returns HTML response for the explicit view render.
288
- */
289
- async renderViewWithDocumentShell(input) {
290
- return this.routeShellComposer.renderViewWithDocumentShell(input, {
291
- hasForeignBoundaryDescendants: (component) => this.hasForeignBoundaryDescendants(component),
292
- createHtmlResponse: (body, ctx) => this.createHtmlResponse(body, ctx),
293
- renderComponentBoundary: (boundaryInput) => this.renderComponentBoundary(boundaryInput),
294
- prepareViewDependencies: (view, layout) => this.prepareViewDependencies(view, layout),
295
- getHtmlTemplate: () => this.getHtmlTemplate(),
296
- resolveViewMetadata: (view, props) => this.resolveViewMetadata(view, props),
297
- appendProcessedDependencies: (...assetGroups) => this.appendProcessedDependencies(...assetGroups),
298
- finalizeResolvedHtml: (options) => this.finalizeResolvedHtml(options),
299
- docType: this.DOC_TYPE
300
- });
301
- }
302
- /**
303
- * Renders a route page through optional layout and document shells.
304
- *
305
- * Route rendering and explicit view rendering now share the same boundary-owned
306
- * shell composition model. This helper composes page, layout, and html template
307
- * boundaries while threading one execution-scoped renderer cache through every
308
- * delegated boundary so foreign shell ownership remains stable and renderer
309
- * initialization is reused inside the current request.
310
- *
311
- * @param input - Page, layout, document, and metadata inputs for the route render.
312
- * @returns Final serialized document HTML including the doctype prefix.
313
- */
314
- async renderPageWithDocumentShell(input) {
315
- return this.routeShellComposer.renderPageWithDocumentShell(input, {
316
- hasForeignBoundaryDescendants: (component) => this.hasForeignBoundaryDescendants(component),
317
- createHtmlResponse: (body, ctx) => this.createHtmlResponse(body, ctx),
318
- renderComponentBoundary: (boundaryInput) => this.renderComponentBoundary(boundaryInput),
319
- prepareViewDependencies: (view, layout) => this.prepareViewDependencies(view, layout),
320
- getHtmlTemplate: () => this.getHtmlTemplate(),
321
- resolveViewMetadata: (view, props) => this.resolveViewMetadata(view, props),
322
- appendProcessedDependencies: (...assetGroups) => this.appendProcessedDependencies(...assetGroups),
323
- finalizeResolvedHtml: (options) => this.finalizeResolvedHtml(options),
324
- docType: this.DOC_TYPE
325
- });
326
- }
327
- /**
328
- * Renders one string-first component boundary and collects its assets.
329
- *
330
- * String-oriented integrations frequently share the same boundary contract:
331
- * pass serialized children through props, coerce the render result to HTML, and
332
- * attach any component-scoped dependencies. This helper centralizes that flow
333
- * so integrations can opt into shared orchestration without repeating the same
334
- * boundary boilerplate.
335
- *
336
- * @param input - Boundary render input.
337
- * @param component - String-oriented component implementation to execute.
338
- * @returns Structured component render result for orchestration paths.
339
- */
340
- async renderStringComponentBoundary(input, component) {
341
- const props = input.children === void 0 ? input.props : { ...input.props, children: input.children };
342
- const content = await component(props);
343
- const html = String(content);
344
- const assets = input.component.config?.dependencies && typeof this.assetProcessingService?.processDependencies === "function" ? await this.processComponentDependencies([input.component]) : void 0;
345
- return {
346
- html,
347
- canAttachAttributes: true,
348
- rootTag: this.getRootTagName(html),
349
- integrationName: this.name,
350
- assets
351
- };
352
- }
353
- getBoundaryTokenPrefix() {
354
- return `__${this.name}_boundary__`;
355
- }
356
- getBoundaryRuntimeContextKey() {
357
- return `__${this.name}_boundary_runtime__`;
358
- }
359
- getQueuedBoundaryRuntime(input, runtimeContextKey = this.getBoundaryRuntimeContextKey()) {
360
- return this.queuedBoundaryRuntimeService.getRuntimeContext(input, runtimeContextKey);
361
- }
362
- async resolveQueuedBoundaryTokens(html, queuedResolutionsByToken, resolveToken) {
363
- let resolvedHtml = html;
364
- for (const token of queuedResolutionsByToken.keys()) {
365
- if (!resolvedHtml.includes(token)) {
366
- continue;
367
- }
368
- resolvedHtml = resolvedHtml.split(token).join(await resolveToken(token));
369
- }
370
- return resolvedHtml;
371
- }
372
- createQueuedBoundaryRuntime(options) {
373
- return this.queuedBoundaryRuntimeService.createRuntime({
374
- boundaryInput: options.boundaryInput,
375
- rendererCache: options.rendererCache,
376
- runtimeContextKey: options.runtimeContextKey ?? this.getBoundaryRuntimeContextKey(),
377
- tokenPrefix: options.tokenPrefix ?? this.getBoundaryTokenPrefix(),
378
- shouldQueueBoundary: (input) => this.shouldResolveBoundaryInOwningRenderer(input),
379
- createRuntimeContext: options.createRuntimeContext
380
- });
381
- }
382
- async resolveRendererOwnedQueuedBoundaryHtml(options) {
383
- return this.queuedBoundaryRuntimeService.resolveQueuedHtml({
384
- html: options.html,
385
- runtimeContext: options.runtimeContext,
386
- queueLabel: options.queueLabel,
387
- renderQueuedChildren: options.renderQueuedChildren,
388
- resolveBoundary: (input, rendererCache) => this.resolveBoundaryPayloadInOwningRenderer(
389
- input,
390
- rendererCache
391
- ),
392
- applyAttributesToFirstElement: (html, attributes) => this.htmlTransformer.applyAttributesToFirstElement(html, attributes),
393
- dedupeProcessedAssets: (assets) => this.htmlTransformer.dedupeProcessedAssets(assets)
394
- });
395
- }
396
- /**
397
- * Renders a string-first component, then resolves any queued foreign
398
- * boundaries before returning final component HTML.
399
- */
400
- async renderStringComponentBoundaryWithQueuedForeignBoundaries(input, component) {
401
- const componentRender = await this.renderStringComponentBoundary(input, component);
402
- const queuedBoundaryResolution = await this.resolveRendererOwnedQueuedBoundaryHtml({
403
- html: componentRender.html,
404
- runtimeContext: this.getQueuedBoundaryRuntime(input),
405
- queueLabel: "String",
406
- renderQueuedChildren: async (children, _runtimeContext, queuedResolutionsByToken, resolveToken) => {
407
- if (children === void 0) {
408
- return { assets: [], html: void 0 };
409
- }
410
- const html = await this.resolveQueuedBoundaryTokens(
411
- typeof children === "string" ? children : String(children ?? ""),
412
- queuedResolutionsByToken,
413
- resolveToken
414
- );
415
- return { assets: [], html };
416
- }
417
- });
418
- const mergedAssets = this.htmlTransformer.dedupeProcessedAssets([
419
- ...componentRender.assets ?? [],
420
- ...queuedBoundaryResolution.assets
421
- ]);
422
- return {
423
- ...componentRender,
424
- html: queuedBoundaryResolution.html,
425
- rootTag: this.getRootTagName(queuedBoundaryResolution.html),
426
- assets: mergedAssets.length > 0 ? mergedAssets : void 0
427
- };
428
- }
429
- constructor({
430
- appConfig,
431
- assetProcessingService,
432
- resolvedIntegrationDependencies,
433
- rendererModules,
434
- runtimeOrigin
435
- }) {
436
- this.appConfig = appConfig;
437
- this.assetProcessingService = assetProcessingService;
438
- this.htmlTransformer = new HtmlTransformerService();
439
- this.resolvedIntegrationDependencies = resolvedIntegrationDependencies || [];
440
- this.rendererModules = rendererModules ?? appConfig.runtime?.rendererModuleContext;
441
- this.runtimeOrigin = runtimeOrigin;
442
- this.dependencyResolverService = new DependencyResolverService(appConfig, assetProcessingService);
443
- this.pageModuleLoaderService = new PageModuleLoaderService(appConfig, runtimeOrigin);
444
- this.renderPreparationService = new RenderPreparationService(appConfig, assetProcessingService);
445
- this.renderExecutionService = new RenderExecutionService();
446
- }
447
- /**
448
- * Returns the HTML path from the provided file path.
449
- * It extracts the path relative to the pages directory and removes the 'index' part if present.
450
- *
451
- * @param file - The file path to extract the HTML path from.
452
- * @returns The extracted HTML path.
453
- */
454
- getHtmlPath({ file }) {
455
- const pagesDir = this.appConfig.absolutePaths.pagesDir;
456
- const pagesIndex = file.indexOf(pagesDir);
457
- if (pagesIndex === -1) return file;
458
- const startIndex = file.indexOf(pagesDir) + pagesDir.length;
459
- const endIndex = file.lastIndexOf("/");
460
- const path = file.substring(startIndex, endIndex);
461
- if (path === "/index") return "";
462
- return path;
463
- }
464
- /**
465
- * Returns the HTML template component.
466
- * It imports the HTML template from the specified path in the app configuration.
467
- *
468
- * @returns The HTML template component.
469
- */
470
- async getHtmlTemplate() {
471
- const htmlTemplatePath = this.getRendererModuleString("htmlTemplateModulePath") ?? this.appConfig.absolutePaths.htmlTemplatePath;
472
- try {
473
- const { default: HtmlTemplate } = await this.importPageFile(htmlTemplatePath);
474
- return HtmlTemplate;
475
- } catch (error) {
476
- invariant(false, `Error importing HtmlTemplate: ${error}`);
477
- }
478
- }
479
- /**
480
- * Returns the static props for the page.
481
- * It calls the provided getStaticProps function with the given options.
482
- *
483
- * @param getStaticProps - The function to get static props.
484
- * @param options - The options to pass to the getStaticProps function.
485
- * @returns The static props and metadata.
486
- */
487
- async getStaticProps(getStaticProps, options) {
488
- return this.pageModuleLoaderService.getStaticPropsForPage({
489
- getStaticProps,
490
- params: options?.params
491
- });
492
- }
493
- /**
494
- * Returns the metadata properties for the page.
495
- * It calls the provided getMetadata function with the given context.
496
- *
497
- * @param getMetadata - The function to get metadata.
498
- * @param context - The context to pass to the getMetadata function.
499
- * @returns The metadata properties.
500
- */
501
- async getMetadataProps(getMetadata, { props, params, query }) {
502
- return this.pageModuleLoaderService.getMetadataPropsForPage({
503
- getMetadata,
504
- context: { props, params, query }
505
- });
506
- }
507
- usesIntegrationPageImporter(_file) {
508
- return false;
509
- }
510
- async importIntegrationPageFile(_file, _options) {
511
- invariant(false, "Integration page importer must be implemented when enabled");
512
- }
513
- normalizeImportedPageFile(_file, pageModule) {
514
- return pageModule;
515
- }
516
- /**
517
- * Imports the page file from the specified path.
518
- * It uses dynamic import to load the file and returns the imported module.
519
- *
520
- * @param file - The file path to import.
521
- * @returns The imported module.
522
- */
523
- async importPageFile(file, options) {
524
- const bypassCache = options?.bypassCache ?? (typeof Bun !== "undefined" && process.env.NODE_ENV === "development");
525
- const pageModule = this.usesIntegrationPageImporter(file) ? await this.importIntegrationPageFile(file, {
526
- bypassCache,
527
- cacheScope: options?.cacheScope
528
- }) : await this.pageModuleLoaderService.importPageFile(file, {
529
- bypassCache,
530
- cacheScope: options?.cacheScope
531
- });
532
- return this.normalizeImportedPageFile(file, pageModule);
533
- }
534
- /**
535
- * Resolves the dependency path based on the component directory.
536
- * It combines the component directory with the provided path URL.
537
- *
538
- * @param componentDir - The component directory path.
539
- * @param pathUrl - The path URL to resolve.
540
- * @returns The resolved dependency path.
541
- */
542
- resolveDependencyPath(componentDir, pathUrl) {
543
- return this.dependencyResolverService.resolveDependencyPath(componentDir, pathUrl);
544
- }
545
- /**
546
- * Extracts the dependencies from the provided component configuration.
547
- * It resolves the paths for scripts and stylesheets based on the component directory.
548
- *
549
- * @param componentDir - The component directory path.
550
- * @param scripts - The scripts to extract.
551
- * @param stylesheets - The stylesheets to extract.
552
- * @returns The extracted dependencies.
553
- */
554
- extractDependencies({
555
- componentDir,
556
- scripts,
557
- stylesheets
558
- }) {
559
- const scriptsPaths = [
560
- ...new Set(
561
- (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))
562
- )
563
- ];
564
- const stylesheetsPaths = [
565
- ...new Set(
566
- (stylesheets ?? []).map((style) => typeof style === "string" ? style : style.src).filter((style) => Boolean(style)).map((style) => this.resolveDependencyPath(componentDir, style))
567
- )
568
- ];
569
- return {
570
- scripts: scriptsPaths,
571
- stylesheets: stylesheetsPaths
572
- };
573
- }
574
- /**
575
- * Resolves lazy script paths to public asset URLs.
576
- * Converts source paths to their final bundled output paths.
577
- *
578
- * @param componentDir - The component directory path.
579
- * @param scripts - The lazy script paths to resolve.
580
- * @returns Comma-separated string of resolved public script paths.
581
- */
582
- resolveLazyScripts(componentDir, scripts) {
583
- return this.dependencyResolverService.resolveLazyScripts(componentDir, scripts);
584
- }
585
- /**
586
- * Collects the dependencies for the provided components.
587
- * Combines component-specific dependencies with global integration dependencies.
588
- *
589
- * @param components - The components to collect dependencies from.
590
- */
591
- async resolveDependencies(components) {
592
- const componentDeps = await this.processComponentDependencies(components);
593
- return this.resolvedIntegrationDependencies.concat(componentDeps);
594
- }
595
- /**
596
- * Processes component-specific dependencies WITHOUT prepending global integration dependencies.
597
- * Use this method when you need only the component's own assets.
598
- *
599
- * @param components - The components to collect dependencies from.
600
- */
601
- async processComponentDependencies(components) {
602
- return this.dependencyResolverService.processComponentDependencies(components, this.name);
603
- }
604
- /**
605
- * Prepares the render options for the integration renderer.
606
- * It imports the page file, collects dependencies, and prepares the render options.
607
- *
608
- * @param options - The route renderer options.
609
- * @returns The prepared render options.
610
- */
611
- async prepareRenderOptions(options) {
612
- return this.renderPreparationService.prepare(options, this.name, {
613
- resolvePageModule: (file) => this.resolvePageModule(file),
614
- getHtmlTemplate: () => this.getHtmlTemplate(),
615
- resolvePageData: (pageModule, routeOptions) => this.resolvePageData(pageModule, routeOptions),
616
- resolveDependencies: (components) => this.resolveDependencies(components),
617
- buildRouteRenderAssets: (file) => this.buildRouteRenderAssets(file),
618
- shouldRenderPageComponent: (input) => this.shouldRenderPageComponent(input),
619
- renderPageComponent: ({ component, props }) => this.renderComponentBoundary({
620
- component,
621
- props,
622
- integrationContext: {
623
- componentInstanceId: "eco-page-root"
624
- }
625
- }),
626
- setProcessedDependencies: (dependencies) => this.htmlTransformer.setProcessedDependencies(dependencies),
627
- dedupeProcessedAssets: (assets) => this.htmlTransformer.dedupeProcessedAssets(assets),
628
- createPageLocalsProxy: (filePath) => createLocalsProxy(filePath)
629
- });
630
- }
631
- /**
632
- * Controls whether the page root should be rendered through `renderComponent()`
633
- * during route option preparation in component-capable modes.
634
- *
635
- * Integrations that already own page-level hydration (for example router-driven
636
- * React rendering) can override this and return `false` to avoid duplicate root
637
- * mount assets and competing hydration entrypoints.
638
- */
639
- shouldRenderPageComponent(_input) {
640
- return true;
641
- }
642
- /**
643
- * Resolves the page module and normalizes exports.
644
- */
645
- async resolvePageModule(file) {
646
- return this.pageModuleLoaderService.resolvePageModule({
647
- file,
648
- importPageFileFn: (targetFile) => this.importPageFile(targetFile)
649
- });
650
- }
651
- /**
652
- * Resolves static props and metadata for the page.
653
- */
654
- async resolvePageData(pageModule, options) {
655
- return this.pageModuleLoaderService.resolvePageData({
656
- pageModule,
657
- routeOptions: options
658
- });
659
- }
660
- /**
661
- * Executes the integration renderer with the provided options.
662
- *
663
- * Execution flow:
664
- * 1. Build normalized render options (`prepareRenderOptions`).
665
- * 2. Render the route body once.
666
- * 3. Reject unresolved route-level boundary artifacts.
667
- * 4. Optionally apply root attributes for page/component root boundaries.
668
- * 5. Run HTML transformer with final dependency set.
669
- *
670
- * Stream-safety note: the first render result is normalized to a string once,
671
- * then the pipeline continues with that immutable HTML value to avoid disturbed
672
- * response-body errors.
673
- *
674
- * @param options Route renderer options.
675
- * @returns Rendered route body plus effective cache strategy.
676
- */
677
- async execute(options) {
678
- return this.renderExecutionService.execute(options, {
679
- prepareRenderOptions: (routeOptions) => this.prepareRenderOptions(routeOptions),
680
- render: (renderOptions) => this.render(renderOptions),
681
- getDocumentAttributes: (renderOptions) => this.getDocumentAttributes(renderOptions),
682
- applyAttributesToHtmlElement: (html, attributes) => this.htmlTransformer.applyAttributesToHtmlElement(html, attributes),
683
- applyAttributesToFirstBodyElement: (html, attributes) => this.htmlTransformer.applyAttributesToFirstBodyElement(html, attributes),
684
- transformResponse: async (response) => {
685
- const transformedResponse = await this.htmlTransformer.transform(response);
686
- return transformedResponse.body ?? await transformedResponse.text();
687
- }
688
- });
689
- }
690
- /**
691
- * Finalizes already-resolved HTML for explicit renderer-owned paths.
692
- *
693
- * This keeps document and root-attribute stamping plus HTML transformation
694
- * available after a renderer has completed nested boundary resolution without
695
- * routing back through shared route execution.
696
- */
697
- async finalizeResolvedHtml(options) {
698
- const rendererBootstrapDependencies = this.getRendererBootstrapDependencies(options.partial);
699
- this.appendProcessedDependencies(rendererBootstrapDependencies);
700
- let html = options.html;
701
- if (options.componentRootAttributes && Object.keys(options.componentRootAttributes).length > 0) {
702
- html = this.htmlTransformer.applyAttributesToFirstBodyElement(html, options.componentRootAttributes);
703
- }
704
- if (options.documentAttributes && Object.keys(options.documentAttributes).length > 0) {
705
- html = this.htmlTransformer.applyAttributesToHtmlElement(html, options.documentAttributes);
706
- }
707
- const shouldTransform = options.transformHtml ?? !options.partial;
708
- if (!shouldTransform) {
709
- return html;
710
- }
711
- const transformedResponse = await this.htmlTransformer.transform(
712
- new Response(html, {
713
- headers: { "Content-Type": "text/html" }
714
- })
715
- );
716
- return await transformedResponse.text();
717
- }
718
- /**
719
- * Returns document-level attributes to stamp onto the rendered `<html>` tag.
720
- *
721
- * Integrations can override this to expose explicit document ownership or
722
- * other runtime coordination markers without relying on script sniffing.
723
- */
724
- getDocumentAttributes(_renderOptions) {
725
- return void 0;
726
- }
727
- /**
728
- * Returns a renderer instance for a given integration name.
729
- *
730
- * Uses a per-execution cache to avoid repeated renderer initialization.
731
- *
732
- * @param integrationName Target integration name.
733
- * @param cache Render-pass renderer cache.
734
- * @returns Renderer for the requested integration.
735
- * @throws Error when no integration plugin matches `integrationName`.
736
- */
737
- getIntegrationRendererForName(integrationName, cache) {
738
- if (cache.has(integrationName)) {
739
- return cache.get(integrationName);
740
- }
741
- if (integrationName === this.name) {
742
- cache.set(integrationName, this);
743
- return this;
744
- }
745
- const integrationPlugin = this.appConfig.integrations.find(
746
- (integration) => integration.name === integrationName
747
- );
748
- invariant(!!integrationPlugin, `[ecopages] Integration not found for boundary owner: ${integrationName}`);
749
- const renderer = integrationPlugin.initializeRenderer({
750
- rendererModules: this.appConfig.runtime?.rendererModuleContext
751
- });
752
- cache.set(integrationName, renderer);
753
- return renderer;
754
- }
755
- async resolveBoundaryInOwningRenderer(input, rendererCache) {
756
- const boundaryOwner = this.getRegisteredBoundaryOwner(input.component);
757
- if (!boundaryOwner) {
758
- return void 0;
759
- }
760
- const owningRenderer = this.getIntegrationRendererForName(boundaryOwner, rendererCache);
761
- if (owningRenderer === this || owningRenderer.name === this.name) {
762
- return void 0;
763
- }
764
- return await owningRenderer.renderComponentBoundary(this.withBoundaryRendererCache(input, rendererCache));
765
- }
766
- async resolveBoundaryPayloadInOwningRenderer(input, rendererCache) {
767
- const boundaryOwner = this.getRegisteredBoundaryOwner(input.component);
768
- if (!boundaryOwner) {
769
- return void 0;
770
- }
771
- const owningRenderer = this.getIntegrationRendererForName(boundaryOwner, rendererCache);
772
- if (owningRenderer === this || owningRenderer.name === this.name) {
773
- return void 0;
774
- }
775
- return await owningRenderer.renderBoundary(this.withBoundaryRendererCache(input, rendererCache));
776
- }
777
- /**
778
- * Renders one component under this integration's boundary runtime and resolves
779
- * any nested foreign boundaries captured during that render.
780
- *
781
- * Without this wrapper, a component tree with foreign-owned descendants would
782
- * render them with no active boundary runtime, which bypasses the owning
783
- * renderer's nested-boundary handoff.
784
- */
785
- async renderComponentBoundary(input) {
786
- const rendererCache = this.getBoundaryRendererCache(input.integrationContext) ?? /* @__PURE__ */ new Map();
787
- const delegatedBoundaryRender = await this.resolveBoundaryInOwningRenderer(input, rendererCache);
788
- if (delegatedBoundaryRender) {
789
- return delegatedBoundaryRender;
790
- }
791
- const hasForeignBoundaries = this.hasForeignBoundaryDescendants(input.component);
792
- const activeRenderContext = getComponentRenderContext();
793
- if (!hasForeignBoundaries) {
794
- if (!activeRenderContext || activeRenderContext.currentIntegration === this.name) {
795
- return this.normalizeComponentBoundaryRender(await this.renderComponent(input));
796
- }
797
- const sameIntegrationExecution = await runWithComponentRenderContext(
798
- {
799
- currentIntegration: this.name
800
- },
801
- async () => this.renderComponent(input)
802
- );
803
- return this.normalizeComponentBoundaryRender(sameIntegrationExecution.value);
804
- }
805
- const execution = await runWithComponentRenderContext(
806
- {
807
- currentIntegration: this.name,
808
- boundaryRuntime: this.createComponentBoundaryRuntime({
809
- boundaryInput: input,
810
- rendererCache
811
- })
812
- },
813
- async () => this.renderComponent(input)
814
- );
815
- return this.normalizeComponentBoundaryRender(execution.value);
816
- }
817
- /**
818
- * Compatibility boundary contract that exposes a narrower payload shape for
819
- * future route-composition work while preserving the current
820
- * `renderComponentBoundary()` runtime semantics.
821
- */
822
- async renderBoundary(input) {
823
- const result = await this.renderComponentBoundary(input);
824
- return {
825
- html: result.html,
826
- assets: result.assets ?? [],
827
- rootTag: result.rootTag,
828
- rootAttributes: result.rootAttributes,
829
- attachmentPolicy: result.canAttachAttributes ? { kind: "first-element" } : { kind: "none" },
830
- integrationName: result.integrationName
831
- };
832
- }
833
- normalizeComponentBoundaryRender(result) {
834
- const normalizedHtml = this.normalizeBoundaryArtifactHtml(result.html);
835
- return normalizedHtml === result.html ? result : {
836
- ...result,
837
- html: normalizedHtml
838
- };
839
- }
840
- normalizeBoundaryArtifactHtml(html) {
841
- return normalizeBoundaryArtifactHtml(html);
842
- }
843
- /**
844
- * Returns whether the component dependency tree crosses into another
845
- * integration.
846
- *
847
- * This keeps boundary-runtime setup narrow: same-integration trees can render
848
- * directly without paying the queue orchestration cost.
849
- */
850
- hasForeignBoundaryDescendants(component) {
851
- const stack = [component];
852
- const seen = /* @__PURE__ */ new Set();
853
- while (stack.length > 0) {
854
- const current = stack.pop();
855
- if (!current || seen.has(current)) {
856
- continue;
857
- }
858
- seen.add(current);
859
- const integrationName = current.config?.integration ?? current.config?.__eco?.integration;
860
- if (integrationName && integrationName !== this.name) {
861
- return true;
862
- }
863
- stack.push(...current.config?.dependencies?.components ?? []);
864
- }
865
- return false;
866
- }
867
- /**
868
- * Render a single component and return structured output for orchestration paths.
869
- *
870
- * Default behavior delegates to `renderToResponse` in partial mode and wraps
871
- * the resulting HTML into the `ComponentRenderResult` contract.
872
- *
873
- * In boundary resolution, this method is the integration-owned step that turns an
874
- * already-resolved deferred boundary into concrete HTML, assets, and optional
875
- * root attributes.
876
- *
877
- * Integrations can override this for richer behavior (asset emission,
878
- * root attributes, integration-specific hydration metadata).
879
- *
880
- * @param input Component render request.
881
- * @returns Structured render result used by component/page orchestration.
882
- */
883
- async renderComponent(input) {
884
- const response = await this.renderToResponse(
885
- input.component,
886
- input.props,
887
- { partial: true }
888
- );
889
- const html = await response.text();
890
- return {
891
- html,
892
- canAttachAttributes: true,
893
- rootTag: this.getRootTagName(html),
894
- integrationName: this.name
895
- };
896
- }
897
- /**
898
- * Extracts the first root element tag name from HTML output.
899
- *
900
- * @param html HTML fragment.
901
- * @returns Root tag name when present; otherwise `undefined`.
902
- */
903
- getRootTagName(html) {
904
- const rootTag = html.match(/^(?:\s|<!--[\s\S]*?-->)*<([a-zA-Z][a-zA-Z0-9:-]*)\b/);
905
- return rootTag?.[1];
906
- }
907
- /**
908
- * Method to build route render assets.
909
- * This method can be optionally overridden by the specific integration renderer.
910
- *
911
- * @param file - The file path to build assets for.
912
- * @returns The processed assets or undefined.
913
- */
914
- buildRouteRenderAssets(_file) {
915
- return void 0;
916
- }
917
- /**
918
- * Creates the per-render boundary runtime adopted by the shared component
919
- * render context.
920
- *
921
- * Real mixed-integration renderers should override this and keep foreign
922
- * boundary resolution inside their own renderer-owned queue. The base runtime
923
- * fails fast when a renderer crosses into a foreign owner without providing its
924
- * own handoff mechanism.
925
- */
926
- createComponentBoundaryRuntime(_options) {
927
- const decideBoundaryInterception = (input) => {
928
- if (!this.shouldResolveBoundaryInOwningRenderer(input)) {
929
- return { kind: "inline" };
930
- }
931
- throw new Error(
932
- `[ecopages] ${this.name} renderer crossed into ${input.targetIntegration} without a renderer-owned boundary runtime. Override createComponentBoundaryRuntime() to resolve foreign boundaries inside the owning renderer.`
933
- );
934
- };
935
- const runtime = {
936
- interceptBoundary: decideBoundaryInterception,
937
- interceptBoundarySync: decideBoundaryInterception
938
- };
939
- return runtime;
940
- }
941
- /**
942
- * Resolves whether a boundary should leave the current render pass and be
943
- * resolved by its owning renderer.
944
- *
945
- * Boundaries owned by the current integration always render inline. Foreign-
946
- * owned boundaries must be handed off by a renderer-owned runtime.
947
- *
948
- * @param input Boundary metadata for the active render pass.
949
- * @returns `true` when the boundary should leave the current pass; otherwise `false`.
950
- */
951
- shouldResolveBoundaryInOwningRenderer(input) {
952
- return !!input.targetIntegration && input.targetIntegration !== input.currentIntegration;
953
- }
954
- }
955
- export {
956
- IntegrationRenderer
957
- };