@ecopages/core 0.2.0-alpha.52 → 0.2.0-alpha.54

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 (590) hide show
  1. package/README.md +2 -3
  2. package/package.json +97 -182
  3. package/src/adapters/abstract/application-adapter.test.ts +218 -0
  4. package/src/adapters/abstract/application-adapter.ts +379 -0
  5. package/src/adapters/abstract/router-adapter.ts +30 -0
  6. package/src/adapters/abstract/server-adapter.ts +79 -0
  7. package/src/adapters/bun/client-bridge.ts +62 -0
  8. package/src/adapters/bun/create-app.ts +214 -0
  9. package/src/adapters/bun/hmr-manager.test.ts +265 -0
  10. package/src/adapters/bun/hmr-manager.ts +88 -0
  11. package/src/adapters/bun/index.ts +2 -0
  12. package/src/adapters/bun/runtime-host.ts +76 -0
  13. package/src/adapters/bun/server-adapter.ts +605 -0
  14. package/src/adapters/bun/static-preview-host.ts +70 -0
  15. package/src/adapters/create-app.test.ts +10 -0
  16. package/src/adapters/create-app.ts +91 -0
  17. package/src/adapters/index.ts +2 -0
  18. package/src/adapters/node/create-app.test.ts +76 -0
  19. package/src/adapters/node/create-app.ts +116 -0
  20. package/src/adapters/node/http-request-bridge.test.ts +146 -0
  21. package/src/adapters/node/http-request-bridge.ts +176 -0
  22. package/src/adapters/node/node-client-bridge.test.ts +198 -0
  23. package/src/adapters/node/node-client-bridge.ts +79 -0
  24. package/src/adapters/node/node-hmr-manager.test.ts +374 -0
  25. package/src/adapters/node/node-hmr-manager.ts +72 -0
  26. package/src/adapters/node/runtime-host.test.ts +49 -0
  27. package/src/adapters/node/runtime-host.ts +113 -0
  28. package/src/adapters/node/server-adapter-dependencies.ts +28 -0
  29. package/src/adapters/node/server-adapter.test.ts +84 -0
  30. package/src/adapters/node/server-adapter.ts +423 -0
  31. package/src/adapters/node/static-content-server.test.ts +60 -0
  32. package/src/adapters/node/static-content-server.ts +239 -0
  33. package/src/adapters/node/static-preview-host.test.ts +89 -0
  34. package/src/adapters/node/static-preview-host.ts +101 -0
  35. package/src/adapters/shared/api-response.test.ts +97 -0
  36. package/src/adapters/shared/api-response.ts +104 -0
  37. package/src/adapters/shared/application-adapter.ts +199 -0
  38. package/src/adapters/shared/define-api-handler.ts +66 -0
  39. package/src/adapters/shared/explicit-static-render-preparation.ts +58 -0
  40. package/src/adapters/shared/explicit-static-route-matcher.test.ts +381 -0
  41. package/src/adapters/shared/explicit-static-route-matcher.ts +131 -0
  42. package/src/adapters/shared/file-route-middleware-pipeline.test.ts +85 -0
  43. package/src/adapters/shared/file-route-middleware-pipeline.ts +118 -0
  44. package/src/adapters/shared/fs-server-response-factory.test.ts +176 -0
  45. package/src/adapters/shared/fs-server-response-factory.ts +96 -0
  46. package/src/adapters/shared/fs-server-response-matcher.test.ts +311 -0
  47. package/src/adapters/shared/fs-server-response-matcher.ts +240 -0
  48. package/src/adapters/shared/hmr-entrypoint-registrar.ts +149 -0
  49. package/src/adapters/shared/hmr-html-response.ts +54 -0
  50. package/src/adapters/shared/hmr-manager.contract.test.ts +228 -0
  51. package/src/adapters/shared/hmr-manager.dispatch.test.ts +229 -0
  52. package/src/adapters/shared/render-context.test.ts +244 -0
  53. package/src/adapters/shared/render-context.ts +161 -0
  54. package/src/adapters/shared/runtime-app-bootstrap.test.ts +96 -0
  55. package/src/adapters/shared/runtime-app-bootstrap.ts +72 -0
  56. package/src/adapters/shared/runtime-host.ts +11 -0
  57. package/src/adapters/shared/server-adapter.test.ts +130 -0
  58. package/src/adapters/shared/server-adapter.ts +571 -0
  59. package/src/adapters/shared/server-route-handler.test.ts +112 -0
  60. package/src/adapters/shared/server-route-handler.ts +153 -0
  61. package/src/adapters/shared/server-static-builder.test.ts +338 -0
  62. package/src/adapters/shared/server-static-builder.ts +170 -0
  63. package/src/adapters/shared/shared-hmr-manager.ts +298 -0
  64. package/src/adapters/shared/static-preview-host.ts +12 -0
  65. package/src/build/README.md +57 -73
  66. package/src/build/browser-runtime-manifest.test.ts +121 -0
  67. package/src/build/browser-runtime-manifest.ts +105 -0
  68. package/src/build/browser-runtime-plugin-helpers.test.ts +49 -0
  69. package/src/build/browser-runtime-plugin-helpers.ts +37 -0
  70. package/src/build/browser-runtime-plugin.test.ts +256 -0
  71. package/src/build/browser-runtime-plugin.ts +306 -0
  72. package/src/build/build-adapter.test.ts +463 -0
  73. package/src/build/build-adapter.ts +788 -0
  74. package/src/build/build-manifest.ts +79 -0
  75. package/src/build/build-types.ts +83 -0
  76. package/src/build/rolldown-build-adapter.test.ts +352 -0
  77. package/src/build/rolldown-build-adapter.ts +363 -0
  78. package/src/build/rolldown-plugin-bridge.test.ts +256 -0
  79. package/src/build/rolldown-plugin-bridge.ts +309 -0
  80. package/src/build/runtime-build-executor.test.ts +130 -0
  81. package/src/build/runtime-build-executor.ts +37 -0
  82. package/src/build/runtime-build-output-normalizer.ts +137 -0
  83. package/src/build/serialized-build-executor.test.ts +96 -0
  84. package/src/build/serialized-build-executor.ts +90 -0
  85. package/src/build/server-side-css-shim-plugin.ts +77 -0
  86. package/src/cache/index.ts +6 -0
  87. package/src/cache/module-parse-cache.test.ts +73 -0
  88. package/src/cache/module-parse-cache.ts +137 -0
  89. package/src/config/README.md +1 -1
  90. package/src/config/config-builder.test.ts +456 -0
  91. package/src/config/config-builder.ts +728 -0
  92. package/src/config/config-builder.typecheck.test.ts +96 -0
  93. package/src/config/{constants.d.ts → constants.ts} +22 -13
  94. package/src/dev/host-runtime.ts +34 -0
  95. package/src/dev/sc-server.ts +143 -0
  96. package/src/eco/eco.browser.test.ts +43 -0
  97. package/src/eco/eco.browser.ts +137 -0
  98. package/src/eco/eco.test.ts +781 -0
  99. package/src/eco/eco.ts +262 -0
  100. package/src/eco/eco.types.ts +293 -0
  101. package/src/eco/eco.utils.test.ts +219 -0
  102. package/src/eco/eco.utils.ts +5 -0
  103. package/src/eco/global-injector-map.test.ts +42 -0
  104. package/src/eco/global-injector-map.ts +112 -0
  105. package/src/eco/lazy-injector-map.test.ts +66 -0
  106. package/src/eco/lazy-injector-map.ts +120 -0
  107. package/src/eco/module-dependencies.test.ts +30 -0
  108. package/src/eco/module-dependencies.ts +75 -0
  109. package/src/errors/http-error.test.ts +134 -0
  110. package/src/errors/http-error.ts +72 -0
  111. package/src/errors/index.ts +3 -0
  112. package/src/errors/locals-access-error.ts +7 -0
  113. package/src/global/app-logger.ts +4 -0
  114. package/src/global/utils.test.ts +12 -0
  115. 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
  116. package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-HMR-Server-Integration-should-load-fixture-app-page-1.png +0 -0
  117. package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-WebSocket-Connection-should-connect-to-correct-HMR-endpoint-1.png +0 -0
  118. package/src/hmr/client/hmr-runtime.ts +162 -0
  119. package/src/hmr/hmr-strategy.test.ts +124 -0
  120. package/src/hmr/hmr-strategy.ts +177 -0
  121. package/src/hmr/hmr.postcss.test.e2e.ts +41 -0
  122. package/src/hmr/hmr.test.e2e.ts +66 -0
  123. package/src/hmr/strategies/default-hmr-strategy.ts +60 -0
  124. package/src/hmr/strategies/js-hmr-strategy.test.ts +344 -0
  125. package/src/hmr/strategies/js-hmr-strategy.ts +307 -0
  126. package/src/index.browser.ts +3 -0
  127. package/src/index.ts +15 -0
  128. package/src/integrations/ghtml/ghtml-renderer.test.ts +253 -0
  129. package/src/integrations/ghtml/ghtml-renderer.ts +87 -0
  130. package/src/integrations/ghtml/ghtml.constants.ts +1 -0
  131. package/src/integrations/ghtml/ghtml.plugin.ts +28 -0
  132. package/src/plugins/alias-resolver-cache.test.ts +110 -0
  133. package/src/plugins/alias-resolver-cache.ts +145 -0
  134. package/src/plugins/alias-resolver-plugin.test.ts +41 -0
  135. package/src/plugins/alias-resolver-plugin.ts +75 -0
  136. package/src/plugins/eco-component-meta-plugin.test.ts +421 -0
  137. package/src/plugins/eco-component-meta-plugin.ts +518 -0
  138. package/src/plugins/foreign-jsx-override-plugin.test.ts +65 -0
  139. package/src/plugins/foreign-jsx-override-plugin.ts +76 -0
  140. package/src/plugins/integration-plugin.test.ts +151 -0
  141. package/src/plugins/integration-plugin.ts +344 -0
  142. package/src/plugins/processor.test.ts +148 -0
  143. package/src/plugins/processor.ts +257 -0
  144. package/src/plugins/{runtime-capability.d.ts → runtime-capability.ts} +8 -3
  145. package/src/plugins/source-transform.test.ts +82 -0
  146. package/src/plugins/source-transform.ts +123 -0
  147. package/src/route-renderer/orchestration/component-render-context.ts +338 -0
  148. package/src/route-renderer/orchestration/declared-ownership-graph.ts +62 -0
  149. package/src/route-renderer/orchestration/foreign-subtree-execution.service.ts +431 -0
  150. package/src/route-renderer/orchestration/integration-renderer.test.ts +2251 -0
  151. package/src/route-renderer/orchestration/integration-renderer.ts +1384 -0
  152. package/src/route-renderer/orchestration/ownership-planning.service.ts +97 -0
  153. package/src/route-renderer/orchestration/ownership-validation.service.ts +76 -0
  154. package/src/route-renderer/orchestration/processed-asset-dedupe.ts +29 -0
  155. package/src/route-renderer/orchestration/queued-foreign-subtree-resolution.service.test.ts +435 -0
  156. package/src/route-renderer/orchestration/queued-foreign-subtree-resolution.service.ts +310 -0
  157. package/src/route-renderer/orchestration/render-output.utils.ts +310 -0
  158. package/src/route-renderer/orchestration/route-render-orchestrator.prepare-render-options.test.ts +1365 -0
  159. package/src/route-renderer/orchestration/route-render-orchestrator.test.ts +267 -0
  160. package/src/route-renderer/orchestration/route-render-orchestrator.ts +879 -0
  161. package/src/route-renderer/orchestration/template-serialization.test.ts +110 -0
  162. package/src/route-renderer/orchestration/template-serialization.ts +117 -0
  163. package/src/route-renderer/page-loading/component-dependency-collection.ts +202 -0
  164. package/src/route-renderer/page-loading/declared-asset-collection.ts +153 -0
  165. package/src/route-renderer/page-loading/dependency-resolver.test.ts +761 -0
  166. package/src/route-renderer/page-loading/dependency-resolver.ts +144 -0
  167. package/src/route-renderer/page-loading/ecopages-virtual-imports.ts +75 -0
  168. package/src/route-renderer/page-loading/lazy-entry-collection.ts +167 -0
  169. package/src/route-renderer/page-loading/lazy-trigger-planning.ts +74 -0
  170. package/src/route-renderer/page-loading/module-declaration-aggregation.ts +60 -0
  171. package/src/route-renderer/page-loading/module-declaration-scripts.ts +16 -0
  172. package/src/route-renderer/page-loading/page-dependency-bundling.ts +244 -0
  173. package/src/route-renderer/page-loading/page-module-loader.test.ts +183 -0
  174. package/src/route-renderer/page-loading/page-module-loader.ts +184 -0
  175. package/src/route-renderer/route-renderer.ts +133 -0
  176. package/src/router/client/link-intent.test.browser.ts +51 -0
  177. package/src/router/client/link-intent.ts +92 -0
  178. package/src/router/client/navigation-coordinator.test.ts +237 -0
  179. package/src/router/client/navigation-coordinator.ts +453 -0
  180. package/src/router/server/route-registry.test.ts +176 -0
  181. package/src/router/server/route-registry.ts +382 -0
  182. package/src/services/assets/asset-processing-service/asset-dependency-keys.ts +66 -0
  183. package/src/services/assets/asset-processing-service/asset-processing.service.test.ts +473 -0
  184. package/src/services/assets/asset-processing-service/asset-processing.service.ts +344 -0
  185. package/src/services/assets/asset-processing-service/asset.factory.test.ts +63 -0
  186. package/src/services/assets/asset-processing-service/asset.factory.ts +105 -0
  187. package/src/services/assets/asset-processing-service/assets.types.ts +128 -0
  188. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.test.ts +74 -0
  189. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.ts +98 -0
  190. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.test.ts +67 -0
  191. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.ts +78 -0
  192. package/src/services/assets/asset-processing-service/grouped-content-bundles.ts +104 -0
  193. package/src/services/assets/asset-processing-service/index.ts +6 -0
  194. package/src/services/assets/asset-processing-service/page-package.test.ts +135 -0
  195. package/src/services/assets/asset-processing-service/page-package.ts +103 -0
  196. package/src/services/assets/asset-processing-service/{processor.interface.d.ts → processor.interface.ts} +10 -5
  197. package/src/services/assets/asset-processing-service/processor.registry.ts +18 -0
  198. package/src/services/assets/asset-processing-service/processors/base/base-processor.test.ts +59 -0
  199. package/src/services/assets/asset-processing-service/processors/base/base-processor.ts +83 -0
  200. package/src/services/assets/asset-processing-service/processors/base/base-script-processor.ts +173 -0
  201. package/src/services/assets/asset-processing-service/processors/index.ts +5 -0
  202. package/src/services/assets/asset-processing-service/processors/script/content-script.processor.test.ts +188 -0
  203. package/src/services/assets/asset-processing-service/processors/script/content-script.processor.ts +138 -0
  204. package/src/services/assets/asset-processing-service/processors/script/file-script.processor.test.ts +326 -0
  205. package/src/services/assets/asset-processing-service/processors/script/file-script.processor.ts +116 -0
  206. package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.test.ts +270 -0
  207. package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.ts +145 -0
  208. package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.test.ts +261 -0
  209. package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.ts +72 -0
  210. package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.ts +83 -0
  211. package/src/services/assets/asset-processing-service/ungrouped-dependency-processing.ts +65 -0
  212. package/src/services/assets/browser-bundle.service.test.ts +66 -0
  213. package/src/services/assets/browser-bundle.service.ts +109 -0
  214. package/src/services/cache/cache.types.ts +126 -0
  215. package/src/services/cache/index.ts +18 -0
  216. package/src/services/cache/memory-cache-store.test.ts +225 -0
  217. package/src/services/cache/memory-cache-store.ts +130 -0
  218. package/src/services/cache/page-cache-service.test.ts +175 -0
  219. package/src/services/cache/page-cache-service.ts +202 -0
  220. package/src/services/cache/page-request-cache-coordinator.service.test.ts +79 -0
  221. package/src/services/cache/page-request-cache-coordinator.service.ts +131 -0
  222. package/src/services/html/html-rewriter-provider.service.test.ts +183 -0
  223. package/src/services/html/html-rewriter-provider.service.ts +105 -0
  224. package/src/services/html/html-transformer.service.test.ts +544 -0
  225. package/src/services/html/html-transformer.service.ts +369 -0
  226. package/src/services/invalidation/development-invalidation.service.test.ts +87 -0
  227. package/src/services/invalidation/development-invalidation.service.ts +262 -0
  228. package/src/services/module-loading/app-module-loader.service.ts +9 -0
  229. package/src/services/module-loading/app-server-module-transpiler.service.test.ts +297 -0
  230. package/src/services/module-loading/app-server-module-transpiler.service.ts +168 -0
  231. package/src/services/module-loading/host-module-loader-registry.ts +15 -0
  232. package/src/services/module-loading/{module-loading-types.d.ts → module-loading-types.ts} +1 -0
  233. package/src/services/module-loading/page-module-import.service.test.ts +652 -0
  234. package/src/services/module-loading/page-module-import.service.ts +302 -0
  235. package/src/services/module-loading/server-module-transpiler.service.test.ts +242 -0
  236. package/src/services/module-loading/server-module-transpiler.service.ts +104 -0
  237. package/src/services/module-loading/source-module-support.ts +19 -0
  238. package/src/services/runtime-state/dev-graph.service.ts +217 -0
  239. package/src/services/runtime-state/entrypoint-dependency-graph.service.ts +136 -0
  240. package/src/services/runtime-state/server-invalidation-state.service.ts +68 -0
  241. package/src/services/validation/schema-validation-service.test.ts +223 -0
  242. package/src/services/validation/schema-validation-service.ts +204 -0
  243. package/src/services/validation/{standard-schema.types.d.ts → standard-schema.types.ts} +20 -17
  244. package/src/static-site-generator/static-site-generator.test.ts +408 -0
  245. package/src/static-site-generator/static-site-generator.ts +445 -0
  246. package/src/types/internal-types.ts +243 -0
  247. package/src/types/public-types.ts +1508 -0
  248. package/src/utils/deep-merge.test.ts +114 -0
  249. package/src/utils/deep-merge.ts +47 -0
  250. package/src/utils/hash.ts +5 -0
  251. package/src/utils/html-escaping.ts +9 -0
  252. package/src/utils/invariant.test.ts +22 -0
  253. package/src/utils/invariant.ts +15 -0
  254. package/src/utils/locals-utils.ts +37 -0
  255. package/src/utils/parse-cli-args.test.ts +69 -0
  256. package/src/utils/parse-cli-args.ts +105 -0
  257. package/src/utils/path-utils.module.ts +14 -0
  258. package/src/utils/path-utils.test.ts +15 -0
  259. package/src/utils/resolve-work-dir.ts +45 -0
  260. package/src/utils/runtime.ts +44 -0
  261. package/src/utils/server-utils.module.ts +67 -0
  262. package/src/utils/server-utils.test.ts +38 -0
  263. package/src/watchers/project-watcher.integration.test.ts +337 -0
  264. package/src/watchers/project-watcher.test-helpers.ts +42 -0
  265. package/src/watchers/project-watcher.test.ts +768 -0
  266. package/src/watchers/project-watcher.ts +357 -0
  267. package/src/adapters/abstract/application-adapter.d.ts +0 -194
  268. package/src/adapters/abstract/application-adapter.js +0 -121
  269. package/src/adapters/abstract/router-adapter.d.ts +0 -26
  270. package/src/adapters/abstract/router-adapter.js +0 -5
  271. package/src/adapters/abstract/server-adapter.d.ts +0 -69
  272. package/src/adapters/abstract/server-adapter.js +0 -15
  273. package/src/adapters/bun/client-bridge.d.ts +0 -34
  274. package/src/adapters/bun/client-bridge.js +0 -48
  275. package/src/adapters/bun/create-app.d.ts +0 -60
  276. package/src/adapters/bun/create-app.js +0 -140
  277. package/src/adapters/bun/hmr-manager.d.ts +0 -47
  278. package/src/adapters/bun/hmr-manager.js +0 -58
  279. package/src/adapters/bun/index.d.ts +0 -2
  280. package/src/adapters/bun/index.js +0 -8
  281. package/src/adapters/bun/runtime-host.d.ts +0 -52
  282. package/src/adapters/bun/runtime-host.js +0 -56
  283. package/src/adapters/bun/server-adapter.d.ts +0 -216
  284. package/src/adapters/bun/server-adapter.js +0 -445
  285. package/src/adapters/bun/static-preview-host.d.ts +0 -28
  286. package/src/adapters/bun/static-preview-host.js +0 -45
  287. package/src/adapters/create-app.d.ts +0 -20
  288. package/src/adapters/create-app.js +0 -66
  289. package/src/adapters/index.d.ts +0 -2
  290. package/src/adapters/index.js +0 -8
  291. package/src/adapters/node/create-app.d.ts +0 -24
  292. package/src/adapters/node/create-app.js +0 -92
  293. package/src/adapters/node/http-request-bridge.d.ts +0 -57
  294. package/src/adapters/node/http-request-bridge.js +0 -118
  295. package/src/adapters/node/node-client-bridge.d.ts +0 -26
  296. package/src/adapters/node/node-client-bridge.js +0 -66
  297. package/src/adapters/node/node-hmr-manager.d.ts +0 -52
  298. package/src/adapters/node/node-hmr-manager.js +0 -49
  299. package/src/adapters/node/runtime-host.d.ts +0 -57
  300. package/src/adapters/node/runtime-host.js +0 -92
  301. package/src/adapters/node/server-adapter-dependencies.d.ts +0 -19
  302. package/src/adapters/node/server-adapter-dependencies.js +0 -18
  303. package/src/adapters/node/server-adapter.d.ts +0 -138
  304. package/src/adapters/node/server-adapter.js +0 -315
  305. package/src/adapters/node/static-content-server.d.ts +0 -60
  306. package/src/adapters/node/static-content-server.js +0 -194
  307. package/src/adapters/node/static-preview-host.d.ts +0 -55
  308. package/src/adapters/node/static-preview-host.js +0 -68
  309. package/src/adapters/shared/api-response.d.ts +0 -52
  310. package/src/adapters/shared/api-response.js +0 -96
  311. package/src/adapters/shared/application-adapter.d.ts +0 -18
  312. package/src/adapters/shared/application-adapter.js +0 -90
  313. package/src/adapters/shared/define-api-handler.d.ts +0 -25
  314. package/src/adapters/shared/define-api-handler.js +0 -15
  315. package/src/adapters/shared/explicit-static-render-preparation.d.ts +0 -25
  316. package/src/adapters/shared/explicit-static-render-preparation.js +0 -26
  317. package/src/adapters/shared/explicit-static-route-matcher.d.ts +0 -41
  318. package/src/adapters/shared/explicit-static-route-matcher.js +0 -101
  319. package/src/adapters/shared/file-route-middleware-pipeline.d.ts +0 -62
  320. package/src/adapters/shared/file-route-middleware-pipeline.js +0 -90
  321. package/src/adapters/shared/fs-server-response-factory.d.ts +0 -23
  322. package/src/adapters/shared/fs-server-response-factory.js +0 -81
  323. package/src/adapters/shared/fs-server-response-matcher.d.ts +0 -75
  324. package/src/adapters/shared/fs-server-response-matcher.js +0 -186
  325. package/src/adapters/shared/hmr-entrypoint-registrar.d.ts +0 -55
  326. package/src/adapters/shared/hmr-entrypoint-registrar.js +0 -87
  327. package/src/adapters/shared/hmr-html-response.d.ts +0 -22
  328. package/src/adapters/shared/hmr-html-response.js +0 -33
  329. package/src/adapters/shared/render-context.d.ts +0 -16
  330. package/src/adapters/shared/render-context.js +0 -93
  331. package/src/adapters/shared/runtime-app-bootstrap.d.ts +0 -26
  332. package/src/adapters/shared/runtime-app-bootstrap.js +0 -46
  333. package/src/adapters/shared/runtime-host.d.ts +0 -12
  334. package/src/adapters/shared/runtime-host.js +0 -0
  335. package/src/adapters/shared/server-adapter.d.ts +0 -108
  336. package/src/adapters/shared/server-adapter.js +0 -436
  337. package/src/adapters/shared/server-route-handler.d.ts +0 -89
  338. package/src/adapters/shared/server-route-handler.js +0 -111
  339. package/src/adapters/shared/server-static-builder.d.ts +0 -71
  340. package/src/adapters/shared/server-static-builder.js +0 -100
  341. package/src/adapters/shared/shared-hmr-manager.d.ts +0 -59
  342. package/src/adapters/shared/shared-hmr-manager.js +0 -241
  343. package/src/adapters/shared/static-preview-host.d.ts +0 -10
  344. package/src/adapters/shared/static-preview-host.js +0 -0
  345. package/src/build/browser-runtime-import-rewrite-plugin.d.ts +0 -26
  346. package/src/build/browser-runtime-import-rewrite-plugin.js +0 -165
  347. package/src/build/browser-runtime-manifest.d.ts +0 -31
  348. package/src/build/browser-runtime-manifest.js +0 -61
  349. package/src/build/build-adapter.d.ts +0 -247
  350. package/src/build/build-adapter.js +0 -671
  351. package/src/build/build-manifest.d.ts +0 -33
  352. package/src/build/build-manifest.js +0 -52
  353. package/src/build/build-types.d.ts +0 -57
  354. package/src/build/build-types.js +0 -0
  355. package/src/build/dev-build-coordinator.d.ts +0 -72
  356. package/src/build/dev-build-coordinator.js +0 -154
  357. package/src/build/esbuild-build-adapter.d.ts +0 -79
  358. package/src/build/esbuild-build-adapter.js +0 -521
  359. package/src/build/runtime-build-executor.d.ts +0 -14
  360. package/src/build/runtime-build-executor.js +0 -22
  361. package/src/build/runtime-specifier-alias-plugin.d.ts +0 -15
  362. package/src/build/runtime-specifier-alias-plugin.js +0 -31
  363. package/src/config/config-builder.d.ts +0 -252
  364. package/src/config/config-builder.js +0 -598
  365. package/src/config/constants.js +0 -25
  366. package/src/dev/host-runtime.d.ts +0 -10
  367. package/src/dev/host-runtime.js +0 -24
  368. package/src/dev/sc-server.d.ts +0 -30
  369. package/src/dev/sc-server.js +0 -111
  370. package/src/eco/eco.browser.d.ts +0 -2
  371. package/src/eco/eco.browser.js +0 -88
  372. package/src/eco/eco.d.ts +0 -9
  373. package/src/eco/eco.js +0 -119
  374. package/src/eco/eco.types.d.ts +0 -233
  375. package/src/eco/eco.types.js +0 -0
  376. package/src/eco/eco.utils.d.ts +0 -1
  377. package/src/eco/eco.utils.js +0 -10
  378. package/src/eco/global-injector-map.d.ts +0 -16
  379. package/src/eco/global-injector-map.js +0 -80
  380. package/src/eco/lazy-injector-map.d.ts +0 -8
  381. package/src/eco/lazy-injector-map.js +0 -70
  382. package/src/eco/module-dependencies.d.ts +0 -18
  383. package/src/eco/module-dependencies.js +0 -49
  384. package/src/errors/http-error.d.ts +0 -31
  385. package/src/errors/http-error.js +0 -50
  386. package/src/errors/index.d.ts +0 -3
  387. package/src/errors/index.js +0 -6
  388. package/src/errors/locals-access-error.d.ts +0 -4
  389. package/src/errors/locals-access-error.js +0 -9
  390. package/src/global/app-logger.d.ts +0 -2
  391. package/src/global/app-logger.js +0 -6
  392. package/src/hmr/client/hmr-runtime.d.ts +0 -5
  393. package/src/hmr/client/hmr-runtime.js +0 -117
  394. package/src/hmr/hmr-strategy.d.ts +0 -162
  395. package/src/hmr/hmr-strategy.js +0 -44
  396. package/src/hmr/hmr.postcss.test.e2e.d.ts +0 -1
  397. package/src/hmr/hmr.postcss.test.e2e.js +0 -31
  398. package/src/hmr/hmr.test.e2e.d.ts +0 -1
  399. package/src/hmr/hmr.test.e2e.js +0 -43
  400. package/src/hmr/strategies/default-hmr-strategy.d.ts +0 -43
  401. package/src/hmr/strategies/default-hmr-strategy.js +0 -34
  402. package/src/hmr/strategies/js-hmr-strategy.d.ts +0 -134
  403. package/src/hmr/strategies/js-hmr-strategy.js +0 -173
  404. package/src/index.browser.d.ts +0 -3
  405. package/src/index.browser.js +0 -4
  406. package/src/index.d.ts +0 -6
  407. package/src/index.js +0 -21
  408. package/src/integrations/ghtml/ghtml-renderer.d.ts +0 -16
  409. package/src/integrations/ghtml/ghtml-renderer.js +0 -57
  410. package/src/integrations/ghtml/ghtml.constants.d.ts +0 -1
  411. package/src/integrations/ghtml/ghtml.constants.js +0 -4
  412. package/src/integrations/ghtml/ghtml.plugin.d.ts +0 -16
  413. package/src/integrations/ghtml/ghtml.plugin.js +0 -20
  414. package/src/plugins/alias-resolver-plugin.d.ts +0 -3
  415. package/src/plugins/alias-resolver-plugin.js +0 -61
  416. package/src/plugins/eco-component-meta-plugin.d.ts +0 -108
  417. package/src/plugins/eco-component-meta-plugin.js +0 -175
  418. package/src/plugins/foreign-jsx-override-plugin.d.ts +0 -33
  419. package/src/plugins/foreign-jsx-override-plugin.js +0 -41
  420. package/src/plugins/integration-plugin.d.ts +0 -230
  421. package/src/plugins/integration-plugin.js +0 -201
  422. package/src/plugins/processor.d.ts +0 -97
  423. package/src/plugins/processor.js +0 -141
  424. package/src/plugins/runtime-capability.js +0 -0
  425. package/src/plugins/source-transform.d.ts +0 -46
  426. package/src/plugins/source-transform.js +0 -71
  427. package/src/route-renderer/orchestration/component-render-context.d.ts +0 -97
  428. package/src/route-renderer/orchestration/component-render-context.js +0 -147
  429. package/src/route-renderer/orchestration/declared-ownership-graph.d.ts +0 -18
  430. package/src/route-renderer/orchestration/declared-ownership-graph.js +0 -34
  431. package/src/route-renderer/orchestration/foreign-subtree-execution.service.d.ts +0 -110
  432. package/src/route-renderer/orchestration/foreign-subtree-execution.service.js +0 -233
  433. package/src/route-renderer/orchestration/integration-renderer.d.ts +0 -534
  434. package/src/route-renderer/orchestration/integration-renderer.js +0 -991
  435. package/src/route-renderer/orchestration/ownership-planning.service.d.ts +0 -24
  436. package/src/route-renderer/orchestration/ownership-planning.service.js +0 -63
  437. package/src/route-renderer/orchestration/ownership-validation.service.d.ts +0 -29
  438. package/src/route-renderer/orchestration/ownership-validation.service.js +0 -53
  439. package/src/route-renderer/orchestration/processed-asset-dedupe.d.ts +0 -3
  440. package/src/route-renderer/orchestration/processed-asset-dedupe.js +0 -27
  441. package/src/route-renderer/orchestration/queued-foreign-subtree-resolution.service.d.ts +0 -91
  442. package/src/route-renderer/orchestration/queued-foreign-subtree-resolution.service.js +0 -170
  443. package/src/route-renderer/orchestration/render-output.utils.d.ts +0 -66
  444. package/src/route-renderer/orchestration/render-output.utils.js +0 -171
  445. package/src/route-renderer/orchestration/route-render-orchestrator.d.ts +0 -156
  446. package/src/route-renderer/orchestration/route-render-orchestrator.js +0 -577
  447. package/src/route-renderer/orchestration/template-serialization.d.ts +0 -38
  448. package/src/route-renderer/orchestration/template-serialization.js +0 -45
  449. package/src/route-renderer/page-loading/component-dependency-collection.d.ts +0 -37
  450. package/src/route-renderer/page-loading/component-dependency-collection.js +0 -132
  451. package/src/route-renderer/page-loading/declared-asset-collection.d.ts +0 -24
  452. package/src/route-renderer/page-loading/declared-asset-collection.js +0 -106
  453. package/src/route-renderer/page-loading/dependency-resolver.d.ts +0 -35
  454. package/src/route-renderer/page-loading/dependency-resolver.js +0 -115
  455. package/src/route-renderer/page-loading/ecopages-virtual-imports.d.ts +0 -11
  456. package/src/route-renderer/page-loading/ecopages-virtual-imports.js +0 -57
  457. package/src/route-renderer/page-loading/lazy-entry-collection.d.ts +0 -45
  458. package/src/route-renderer/page-loading/lazy-entry-collection.js +0 -105
  459. package/src/route-renderer/page-loading/lazy-trigger-planning.d.ts +0 -19
  460. package/src/route-renderer/page-loading/lazy-trigger-planning.js +0 -40
  461. package/src/route-renderer/page-loading/module-declaration-aggregation.d.ts +0 -5
  462. package/src/route-renderer/page-loading/module-declaration-aggregation.js +0 -33
  463. package/src/route-renderer/page-loading/module-declaration-scripts.d.ts +0 -3
  464. package/src/route-renderer/page-loading/module-declaration-scripts.js +0 -18
  465. package/src/route-renderer/page-loading/page-dependency-bundling.d.ts +0 -13
  466. package/src/route-renderer/page-loading/page-dependency-bundling.js +0 -137
  467. package/src/route-renderer/page-loading/page-module-loader.d.ts +0 -90
  468. package/src/route-renderer/page-loading/page-module-loader.js +0 -127
  469. package/src/route-renderer/route-renderer.d.ts +0 -69
  470. package/src/route-renderer/route-renderer.js +0 -80
  471. package/src/router/client/link-intent.js +0 -34
  472. package/src/router/client/link-intent.test.browser.d.ts +0 -1
  473. package/src/router/client/link-intent.test.browser.js +0 -43
  474. package/src/router/client/navigation-coordinator.d.ts +0 -169
  475. package/src/router/client/navigation-coordinator.js +0 -215
  476. package/src/router/server/route-registry.d.ts +0 -78
  477. package/src/router/server/route-registry.js +0 -262
  478. package/src/services/assets/asset-processing-service/asset-dependency-keys.d.ts +0 -3
  479. package/src/services/assets/asset-processing-service/asset-dependency-keys.js +0 -56
  480. package/src/services/assets/asset-processing-service/asset-processing.service.d.ts +0 -103
  481. package/src/services/assets/asset-processing-service/asset-processing.service.js +0 -285
  482. package/src/services/assets/asset-processing-service/asset.factory.d.ts +0 -17
  483. package/src/services/assets/asset-processing-service/asset.factory.js +0 -82
  484. package/src/services/assets/asset-processing-service/assets.types.d.ts +0 -103
  485. package/src/services/assets/asset-processing-service/assets.types.js +0 -0
  486. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.d.ts +0 -57
  487. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.js +0 -49
  488. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.d.ts +0 -20
  489. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.js +0 -41
  490. package/src/services/assets/asset-processing-service/grouped-content-bundles.d.ts +0 -30
  491. package/src/services/assets/asset-processing-service/grouped-content-bundles.js +0 -65
  492. package/src/services/assets/asset-processing-service/index.d.ts +0 -6
  493. package/src/services/assets/asset-processing-service/index.js +0 -6
  494. package/src/services/assets/asset-processing-service/page-package.d.ts +0 -6
  495. package/src/services/assets/asset-processing-service/page-package.js +0 -80
  496. package/src/services/assets/asset-processing-service/processor.interface.js +0 -6
  497. package/src/services/assets/asset-processing-service/processor.registry.d.ts +0 -8
  498. package/src/services/assets/asset-processing-service/processor.registry.js +0 -15
  499. package/src/services/assets/asset-processing-service/processors/base/base-processor.d.ts +0 -24
  500. package/src/services/assets/asset-processing-service/processors/base/base-processor.js +0 -65
  501. package/src/services/assets/asset-processing-service/processors/base/base-script-processor.d.ts +0 -22
  502. package/src/services/assets/asset-processing-service/processors/base/base-script-processor.js +0 -136
  503. package/src/services/assets/asset-processing-service/processors/index.d.ts +0 -5
  504. package/src/services/assets/asset-processing-service/processors/index.js +0 -5
  505. package/src/services/assets/asset-processing-service/processors/script/content-script.processor.d.ts +0 -6
  506. package/src/services/assets/asset-processing-service/processors/script/content-script.processor.js +0 -120
  507. package/src/services/assets/asset-processing-service/processors/script/file-script.processor.d.ts +0 -9
  508. package/src/services/assets/asset-processing-service/processors/script/file-script.processor.js +0 -97
  509. package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.d.ts +0 -42
  510. package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.js +0 -126
  511. package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.d.ts +0 -8
  512. package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.js +0 -59
  513. package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.d.ts +0 -9
  514. package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.js +0 -69
  515. package/src/services/assets/asset-processing-service/ungrouped-dependency-processing.d.ts +0 -18
  516. package/src/services/assets/asset-processing-service/ungrouped-dependency-processing.js +0 -45
  517. package/src/services/assets/browser-bundle.service.d.ts +0 -73
  518. package/src/services/assets/browser-bundle.service.js +0 -41
  519. package/src/services/cache/cache.types.d.ts +0 -107
  520. package/src/services/cache/cache.types.js +0 -0
  521. package/src/services/cache/index.d.ts +0 -7
  522. package/src/services/cache/index.js +0 -7
  523. package/src/services/cache/memory-cache-store.d.ts +0 -42
  524. package/src/services/cache/memory-cache-store.js +0 -98
  525. package/src/services/cache/page-cache-service.d.ts +0 -70
  526. package/src/services/cache/page-cache-service.js +0 -152
  527. package/src/services/cache/page-request-cache-coordinator.service.d.ts +0 -75
  528. package/src/services/cache/page-request-cache-coordinator.service.js +0 -109
  529. package/src/services/html/html-rewriter-provider.service.d.ts +0 -40
  530. package/src/services/html/html-rewriter-provider.service.js +0 -68
  531. package/src/services/html/html-transformer.service.d.ts +0 -96
  532. package/src/services/html/html-transformer.service.js +0 -287
  533. package/src/services/invalidation/development-invalidation.service.d.ts +0 -74
  534. package/src/services/invalidation/development-invalidation.service.js +0 -190
  535. package/src/services/module-loading/app-module-loader.service.d.ts +0 -7
  536. package/src/services/module-loading/app-module-loader.service.js +0 -0
  537. package/src/services/module-loading/app-server-module-transpiler.service.d.ts +0 -24
  538. package/src/services/module-loading/app-server-module-transpiler.service.js +0 -151
  539. package/src/services/module-loading/host-module-loader-registry.d.ts +0 -4
  540. package/src/services/module-loading/host-module-loader-registry.js +0 -15
  541. package/src/services/module-loading/module-loading-types.js +0 -0
  542. package/src/services/module-loading/node-bootstrap-plugin.d.ts +0 -38
  543. package/src/services/module-loading/node-bootstrap-plugin.js +0 -215
  544. package/src/services/module-loading/page-module-import.service.d.ts +0 -95
  545. package/src/services/module-loading/page-module-import.service.js +0 -191
  546. package/src/services/module-loading/server-module-transpiler.service.d.ts +0 -63
  547. package/src/services/module-loading/server-module-transpiler.service.js +0 -64
  548. package/src/services/module-loading/source-module-support.d.ts +0 -5
  549. package/src/services/module-loading/source-module-support.js +0 -8
  550. package/src/services/runtime-state/dev-graph.service.d.ts +0 -118
  551. package/src/services/runtime-state/dev-graph.service.js +0 -162
  552. package/src/services/runtime-state/entrypoint-dependency-graph.service.d.ts +0 -41
  553. package/src/services/runtime-state/entrypoint-dependency-graph.service.js +0 -85
  554. package/src/services/runtime-state/server-invalidation-state.service.d.ts +0 -26
  555. package/src/services/runtime-state/server-invalidation-state.service.js +0 -35
  556. package/src/services/validation/schema-validation-service.d.ts +0 -122
  557. package/src/services/validation/schema-validation-service.js +0 -101
  558. package/src/services/validation/standard-schema.types.js +0 -0
  559. package/src/static-site-generator/static-site-generator.d.ts +0 -104
  560. package/src/static-site-generator/static-site-generator.js +0 -316
  561. package/src/types/internal-types.d.ts +0 -232
  562. package/src/types/internal-types.js +0 -0
  563. package/src/types/public-types.d.ts +0 -1307
  564. package/src/types/public-types.js +0 -0
  565. package/src/utils/deep-merge.d.ts +0 -14
  566. package/src/utils/deep-merge.js +0 -32
  567. package/src/utils/hash.d.ts +0 -1
  568. package/src/utils/hash.js +0 -7
  569. package/src/utils/html-escaping.d.ts +0 -7
  570. package/src/utils/html-escaping.js +0 -6
  571. package/src/utils/html.js +0 -4
  572. package/src/utils/invariant.d.ts +0 -5
  573. package/src/utils/invariant.js +0 -11
  574. package/src/utils/locals-utils.d.ts +0 -15
  575. package/src/utils/locals-utils.js +0 -24
  576. package/src/utils/parse-cli-args.d.ts +0 -27
  577. package/src/utils/parse-cli-args.js +0 -62
  578. package/src/utils/path-utils.module.d.ts +0 -5
  579. package/src/utils/path-utils.module.js +0 -14
  580. package/src/utils/resolve-work-dir.d.ts +0 -11
  581. package/src/utils/resolve-work-dir.js +0 -31
  582. package/src/utils/runtime.d.ts +0 -11
  583. package/src/utils/runtime.js +0 -40
  584. package/src/utils/server-utils.module.d.ts +0 -19
  585. package/src/utils/server-utils.module.js +0 -56
  586. package/src/watchers/project-watcher.d.ts +0 -136
  587. package/src/watchers/project-watcher.js +0 -275
  588. package/src/watchers/project-watcher.test-helpers.d.ts +0 -4
  589. package/src/watchers/project-watcher.test-helpers.js +0 -52
  590. /package/src/utils/{html.d.ts → html.ts} +0 -0
@@ -0,0 +1,788 @@
1
+ /**
2
+ * Build pipeline contracts and app-owned adapter wiring.
3
+ *
4
+ * @remarks
5
+ * The build layer exposes three concentric shapes:
6
+ *
7
+ * - `BuildAdapter` — the low-level backend contract. Two implementations
8
+ * exist: a bundler-backed adapter (the real backend) and
9
+ * {@link ViteHostBuildAdapter} (a host-owned boundary marker that throws
10
+ * on direct use, for host runtimes that own their own build pipeline).
11
+ * - `BuildExecutor` — the runtime-facing facade stored on
12
+ * `appConfig.runtime.buildExecutor`. It is intentionally narrower than
13
+ * `BuildAdapter` so callers that only need to issue builds do not depend
14
+ * on `resolve` / `getTranspileOptions`.
15
+ * - App-owned helpers (`getAppBuildAdapter`, `getAppBuildExecutor`, and
16
+ * the `set*` counterparts) — the supported way for runtime code to read
17
+ * and mutate the active adapter per `EcoPagesAppConfig`.
18
+ */
19
+
20
+ import type { EcoBuildPlugin } from './build-types.ts';
21
+ import { mergeBrowserRuntimeManifests } from './browser-runtime-manifest.ts';
22
+ import { normalizeNodeRuntimeBuildOutputs } from './runtime-build-output-normalizer.ts';
23
+ import { createForeignJsxOverridePlugin } from '../plugins/foreign-jsx-override-plugin.ts';
24
+ import {
25
+ createAppBuildManifest,
26
+ getBrowserBuildPlugins,
27
+ getServerBuildPlugins,
28
+ type AppBuildManifest,
29
+ } from './build-manifest.ts';
30
+ import { createRolldownBuildAdapter } from './rolldown-build-adapter.ts';
31
+ import type { EcoPagesAppConfig } from '../types/internal-types.ts';
32
+ import type { IHmrManager } from '../types/public-types.ts';
33
+
34
+ /**
35
+ * Which backend owns the app's build pipeline.
36
+ *
37
+ * - `'rolldown'`: the default. Ecopages runs the build directly through
38
+ * its bundler-backed adapter.
39
+ * - `'vite-host'`: a host runtime owns the build. {@link ViteHostBuildAdapter}
40
+ * is exposed as a boundary marker; any direct call into it throws.
41
+ */
42
+ export type BuildOwnership = 'vite-host' | 'rolldown';
43
+
44
+ /**
45
+ * A single message emitted by the build backend.
46
+ *
47
+ * @remarks
48
+ * Today this only carries `message`. Severity and structured fields
49
+ * belong in a future schema bump; the current shape mirrors the
50
+ * bundler's log output 1:1.
51
+ */
52
+ export interface BuildLog {
53
+ message: string;
54
+ }
55
+
56
+ /**
57
+ * A single artifact emitted by the build backend.
58
+ *
59
+ * @remarks
60
+ * `path` is the absolute on-disk path of the emitted file. For
61
+ * filename templates that include a content-hash token, the bundler
62
+ * returns the concrete resolved path (not the template), so callers
63
+ * can read the file directly.
64
+ */
65
+ export interface BuildOutput {
66
+ path: string;
67
+ }
68
+
69
+ /**
70
+ * Per-entrypoint dependency metadata surfaced alongside a build.
71
+ *
72
+ * @remarks
73
+ * Populated from the bundler's per-chunk module list and exposed as a
74
+ * normalized absolute-path map. Consumers (HMR invalidation, the build
75
+ * manifest) read this without needing to know which adapter produced
76
+ * it. The shape is preserved across adapters so historical callers
77
+ * continue to compile.
78
+ */
79
+ export interface BuildDependencyGraph {
80
+ /**
81
+ * Normalized absolute entrypoint path mapped to every normalized
82
+ * absolute source input that contributed to that entrypoint's
83
+ * output, including the entrypoint itself.
84
+ */
85
+ entrypoints: Record<string, string[]>;
86
+ }
87
+
88
+ /**
89
+ * The full result of one `BuildAdapter.build` call.
90
+ *
91
+ * @remarks
92
+ * `success === false` means the build failed and `outputs` will be
93
+ * empty. Inspect `logs` for the error message; the original `Error` is
94
+ * already normalized into `BuildLog` shape.
95
+ */
96
+ export interface BuildResult {
97
+ success: boolean;
98
+ logs: BuildLog[];
99
+ outputs: BuildOutput[];
100
+ /**
101
+ * Per-entrypoint dependency metadata, when the backend produced it.
102
+ * Some backends (notably the Vite-host boundary marker) leave this
103
+ * undefined; callers must treat that as a valid state and fall
104
+ * back deterministically.
105
+ */
106
+ dependencyGraph?: BuildDependencyGraph;
107
+ }
108
+
109
+ /**
110
+ * Options accepted by every `BuildAdapter.build` call.
111
+ *
112
+ * @remarks
113
+ * Fields that the adapter can forward are honored; fields that cannot
114
+ * (currently `splitting`, `bundle`, and `outbase`) are accepted so
115
+ * call-sites compile, but the adapter ignores them. See each field's
116
+ * docstring for the current behavior.
117
+ */
118
+ export interface BuildOptions {
119
+ /**
120
+ * Absolute or context-root-relative source files that begin the build graph.
121
+ *
122
+ * Use a record (key → source path) when the caller needs to control chunk
123
+ * names. Keys become the `[name]` token in `naming`, which lets the caller
124
+ * embed path information that the bundler would otherwise strip.
125
+ */
126
+ entrypoints: string[] | Record<string, string>;
127
+ /** Output directory. Defaults to `dist/assets` when omitted. */
128
+ outdir?: string;
129
+ /**
130
+ * Base directory for `[dir]` placeholders in `naming`. Currently
131
+ * the bundled adapter derives the base from `root` directly and
132
+ * ignores this field.
133
+ */
134
+ outbase?: string;
135
+ /**
136
+ * Filename pattern for entrypoints. The bundled adapter honors
137
+ * `[name]`, `[hash]`, and `[ext]`. The `[dir]` token is stripped
138
+ * before forwarding to the bundler (rolldown does not implement it);
139
+ * callers that need directory structure preserved should use the
140
+ * record form of `entrypoints` so each key becomes its own chunk.
141
+ * When omitted, the bundler's default applies.
142
+ */
143
+ naming?: string;
144
+ /**
145
+ * Package export conditions to honor during resolution
146
+ * (e.g. `['import', 'browser', 'default']`).
147
+ */
148
+ conditions?: string[];
149
+ /**
150
+ * Global identifier replacements. Honored by the bundled adapter.
151
+ */
152
+ define?: Record<string, string>;
153
+ /** Run the bundler's minifier. Off by default. */
154
+ minify?: boolean;
155
+ /** Enable the bundler's tree-shaker. Defaults to `true`. */
156
+ treeshaking?: boolean;
157
+ /**
158
+ * Output target family. Accepted values: `'browser'`, `'node'`,
159
+ * anything else falls through to a platform-neutral setup.
160
+ */
161
+ target?: string;
162
+ /** Output module format. Accepted: `'esm'`, `'cjs'`, `'iife'`. */
163
+ format?: string;
164
+ /**
165
+ * Source map mode. Accepted: `'none'`, `'inline'`, `'external'`,
166
+ * `'linked'`. Anything else maps to the bundler's default (linked).
167
+ */
168
+ sourcemap?: string;
169
+ /**
170
+ * Historical code-splitting flag. Currently a no-op on the bundled
171
+ * adapter: the bundler splits by default and this flag is not
172
+ * forwarded. See the per-chunk naming convention in the adapter for
173
+ * the available control.
174
+ */
175
+ splitting?: boolean;
176
+ /** Project root used to resolve relative paths and the tsconfig lookup. */
177
+ root?: string;
178
+ /**
179
+ * Historical bundle flag. Currently a no-op on the bundled adapter:
180
+ * the bundler always bundles. Accepted so call-sites compile.
181
+ */
182
+ bundle?: boolean;
183
+ /**
184
+ * Treat `node_modules` packages as external. Honored by the bundled
185
+ * adapter.
186
+ */
187
+ externalPackages?: boolean;
188
+ /** Explicit list of module specifiers to leave as external imports. */
189
+ external?: string[];
190
+ /**
191
+ * JSX runtime configuration. Mirrors the bundler's `jsx` option shape.
192
+ */
193
+ jsx?: {
194
+ development?: boolean;
195
+ factory?: string;
196
+ fragment?: string;
197
+ importSource?: string;
198
+ runtime?: 'classic' | 'automatic';
199
+ sideEffects?: boolean;
200
+ };
201
+ /**
202
+ * Runtime-agnostic `EcoBuildPlugin[]` to attach to this build. The
203
+ * bundled adapter translates the array via the rolldown plugin
204
+ * bridge.
205
+ */
206
+ plugins?: EcoBuildPlugin[];
207
+ /**
208
+ * Escape hatch for backends that need to forward unknown options
209
+ * to their underlying driver. Consumers should prefer the typed
210
+ * fields above.
211
+ */
212
+ [key: string]: unknown;
213
+ }
214
+
215
+ /** Stable profile identifiers for `BuildAdapter.getTranspileOptions`. */
216
+ export type BuildTranspileProfile = 'browser-script' | 'hmr-runtime' | 'hmr-entrypoint';
217
+
218
+ /**
219
+ * Resolved transpile settings for a given profile.
220
+ *
221
+ * @remarks
222
+ * The three fields map 1:1 to the trio the HMR and browser-script
223
+ * code paths look at: target platform, output format, and source-map
224
+ * mode. Today the bundled adapter returns identical defaults for all
225
+ * three profiles; the type is kept open so per-profile tuning can
226
+ * land without breaking callers.
227
+ */
228
+ export interface BuildTranspileOptions {
229
+ target: string;
230
+ format: string;
231
+ sourcemap: string;
232
+ }
233
+
234
+ /**
235
+ * Low-level build backend contract.
236
+ *
237
+ * @remarks
238
+ * One instance is owned by each `EcoPagesAppConfig` (see
239
+ * {@link getAppBuildAdapter}). Two implementations exist: the bundled
240
+ * adapter does the work; {@link ViteHostBuildAdapter} is a host-owned
241
+ * boundary marker that throws on direct use.
242
+ */
243
+ export interface BuildAdapter {
244
+ /** Which backend owns this adapter. Used for routing decisions in app helpers. */
245
+ readonly ownership?: BuildOwnership;
246
+ /**
247
+ * Run one build.
248
+ *
249
+ * @remarks
250
+ * Implementations are expected to be safe to call from any caller.
251
+ * Concurrent calls are not guaranteed to be serialized by the
252
+ * adapter itself; the dev-watch pipeline wraps the adapter in
253
+ * {@link SerializedBuildExecutor} when it needs FIFO ordering.
254
+ *
255
+ * Returns a `BuildResult` with `success: false` on failure; the
256
+ * thrown-error variant (`buildOrThrow`) is reserved for callers
257
+ * that need the original `Error` object.
258
+ */
259
+ build(options: BuildOptions): Promise<BuildResult>;
260
+ /**
261
+ * Resolve a module specifier against the project's `rootDir`.
262
+ *
263
+ * @remarks
264
+ * Used by the source-loading services when they need to know the
265
+ * absolute path of a specifier without performing a full build.
266
+ */
267
+ resolve(importPath: string, rootDir: string): string;
268
+ /**
269
+ * Resolve transpile settings for a known profile.
270
+ *
271
+ * @remarks
272
+ * Today the bundled adapter returns identical defaults for all
273
+ * profiles. The profile argument is kept so per-profile tuning
274
+ * can land without breaking callers.
275
+ */
276
+ getTranspileOptions(profile: BuildTranspileProfile): BuildTranspileOptions;
277
+ }
278
+
279
+ /**
280
+ * Runtime-facing facade for issuing builds.
281
+ *
282
+ * @remarks
283
+ * Strictly narrower than {@link BuildAdapter}: it only exposes `build`.
284
+ * This is the shape stored on `appConfig.runtime.buildExecutor` and
285
+ * passed across the dev-watch and server-module-loading seams, so
286
+ * callers cannot accidentally depend on `resolve` or
287
+ * `getTranspileOptions`.
288
+ *
289
+ * In production and non-watch flows the executor is the adapter
290
+ * itself. In development watch flows the executor is a
291
+ * {@link SerializedBuildExecutor} wrapping the adapter so dev-watch
292
+ * pipelines are FIFO-serialized.
293
+ */
294
+ export interface BuildExecutor {
295
+ build(options: BuildOptions): Promise<BuildResult>;
296
+ }
297
+
298
+ /**
299
+ * Merges `appPlugins` into an existing `plugins` array, deduping by
300
+ * `plugin.name` so the app-owned manifest always wins on collision.
301
+ *
302
+ * @remarks
303
+ * The last write wins because the function intentionally lets the
304
+ * caller-supplied list override a manifest entry. Tests that exercise
305
+ * this behavior live in `build-adapter.test.ts`.
306
+ */
307
+ function mergeBuildExecutorPlugins(
308
+ existing: EcoBuildPlugin[] | undefined,
309
+ appPlugins: EcoBuildPlugin[],
310
+ ): EcoBuildPlugin[] {
311
+ if (!existing || existing.length === 0) {
312
+ return appPlugins;
313
+ }
314
+ const byName = new Map<string, EcoBuildPlugin>();
315
+ for (const plugin of existing) {
316
+ byName.set(plugin.name, plugin);
317
+ }
318
+ for (const plugin of appPlugins) {
319
+ byName.set(plugin.name, plugin);
320
+ }
321
+ return Array.from(byName.values());
322
+ }
323
+
324
+ /**
325
+ * Wraps a {@link BuildExecutor} so each call to `build` receives the
326
+ * union of the caller's `options.plugins` and the plugins sourced
327
+ * from `getPlugins()`.
328
+ *
329
+ * @remarks
330
+ * The single point of plugin injection in the runtime path: the
331
+ * `ConfigBuilder` stores a raw adapter on
332
+ * `appConfig.runtime.buildAdapter` and the
333
+ * `installAppRuntimeBuildExecutor` step wraps that adapter with this
334
+ * helper. Callers that issue builds against
335
+ * `appConfig.runtime.buildExecutor` get the merged plugin set without
336
+ * further ceremony.
337
+ */
338
+ export function withBuildExecutorPlugins(executor: BuildExecutor, getPlugins: () => EcoBuildPlugin[]): BuildExecutor {
339
+ return {
340
+ async build(options: BuildOptions): Promise<BuildResult> {
341
+ const appPlugins = getPlugins();
342
+ if (appPlugins.length === 0) {
343
+ return executor.build(options);
344
+ }
345
+ return executor.build({
346
+ ...options,
347
+ plugins: mergeBuildExecutorPlugins(options.plugins, appPlugins),
348
+ });
349
+ },
350
+ };
351
+ }
352
+
353
+ function createHostOwnedBuildError(methodName: string): Error {
354
+ return new Error(
355
+ `Vite-hosted builds are owned by the host runtime. Core cannot ${methodName} through the host-owned compatibility adapter.`,
356
+ );
357
+ }
358
+
359
+ /**
360
+ * Boundary-marker adapter for Vite-host ownership.
361
+ *
362
+ * @remarks
363
+ * This is not a real backend. It exists so `appConfig.runtime.buildAdapter`
364
+ * can carry the `'vite-host'` ownership without falling back to a
365
+ * framework-owned bundler path. Every method throws a
366
+ * {@link createHostOwnedBuildError} so misrouted calls fail loudly
367
+ * with a clear message instead of silently executing under a
368
+ * different backend.
369
+ *
370
+ * The class stays in the public surface for host runtimes that own
371
+ * their build pipeline (e.g. Nitro) and for app code that wants to
372
+ * opt into host-owned ownership before its host wires up the build.
373
+ */
374
+ export class ViteHostBuildAdapter implements BuildAdapter {
375
+ readonly ownership = 'vite-host' as const;
376
+
377
+ async build(_options: BuildOptions): Promise<BuildResult> {
378
+ throw createHostOwnedBuildError('build');
379
+ }
380
+
381
+ resolve(_importPath: string, _rootDir: string): string {
382
+ throw createHostOwnedBuildError('resolve imports');
383
+ }
384
+
385
+ getTranspileOptions(_profile: BuildTranspileProfile): BuildTranspileOptions {
386
+ throw createHostOwnedBuildError('derive transpile options');
387
+ }
388
+ }
389
+
390
+ /**
391
+ * Constructs a {@link ViteHostBuildAdapter}. Use only in code paths
392
+ * that explicitly opt into the host-owned boundary.
393
+ */
394
+ export function createViteHostBuildAdapter(): BuildAdapter {
395
+ return new ViteHostBuildAdapter();
396
+ }
397
+
398
+ /**
399
+ * Constructs a build adapter for the given ownership.
400
+ *
401
+ * @param options - When `options.ownership` is omitted, the default is
402
+ * `'rolldown'`. The Vite-host path is opt-in.
403
+ */
404
+ export function createBuildAdapter(options?: { ownership?: BuildOwnership }): BuildAdapter {
405
+ switch (options?.ownership ?? 'rolldown') {
406
+ case 'vite-host':
407
+ return createViteHostBuildAdapter();
408
+ case 'rolldown':
409
+ default:
410
+ return createRolldownBuildAdapter();
411
+ }
412
+ }
413
+
414
+ /** The shared default-bundler backend instance. Use {@link getAppBuildAdapter} in app-aware code. */
415
+ export const defaultRolldownBuildAdapter: BuildAdapter = createBuildAdapter({ ownership: 'rolldown' });
416
+
417
+ /** The shared Vite-host boundary instance. Use {@link getAppBuildAdapter} in app-aware code. */
418
+ export const defaultViteHostBuildAdapter: BuildAdapter = createBuildAdapter({ ownership: 'vite-host' });
419
+
420
+ /**
421
+ * Global default build adapter.
422
+ *
423
+ * @remarks
424
+ * Resolves to the bundled default-bundler adapter. New app-aware
425
+ * code should prefer {@link getAppBuildAdapter}.
426
+ */
427
+ export const defaultBuildAdapter: BuildAdapter = defaultRolldownBuildAdapter;
428
+
429
+ /**
430
+ * Resolves the default build adapter for an ownership value.
431
+ *
432
+ * @param ownership - Defaults to `'rolldown'`. Returns the
433
+ * {@link ViteHostBuildAdapter} only when the caller explicitly asks
434
+ * for `'vite-host'`.
435
+ */
436
+ export function getDefaultBuildAdapter(ownership: BuildOwnership = 'rolldown'): BuildAdapter {
437
+ return ownership === 'vite-host' ? defaultViteHostBuildAdapter : defaultRolldownBuildAdapter;
438
+ }
439
+
440
+ /**
441
+ * Reads the {@link BuildOwnership} declared on a {@link BuildAdapter}.
442
+ *
443
+ * @param buildAdapter - When `undefined`, defaults to `'rolldown'`.
444
+ */
445
+ export function getBuildAdapterOwnership(buildAdapter: BuildAdapter | undefined): BuildOwnership {
446
+ return buildAdapter?.ownership ?? 'rolldown';
447
+ }
448
+
449
+ /**
450
+ * Resolves the build ownership of an app config.
451
+ *
452
+ * @remarks
453
+ * Resolution order: `appConfig.runtime.buildOwnership` (explicit), then
454
+ * the ownership declared on `appConfig.runtime.buildAdapter`, then the
455
+ * default `'rolldown'`.
456
+ */
457
+ export function getAppBuildOwnership(appConfig: EcoPagesAppConfig): BuildOwnership {
458
+ return appConfig.runtime?.buildOwnership ?? getBuildAdapterOwnership(appConfig.runtime?.buildAdapter);
459
+ }
460
+
461
+ /**
462
+ * Sets the explicit build ownership on an app config.
463
+ *
464
+ * @remarks
465
+ * The `ConfigBuilder` uses this when the caller calls
466
+ * `setBuildOwnership`. App code that needs a different ownership
467
+ * should call this directly with a new value; passing the same
468
+ * value is a no-op.
469
+ */
470
+ export function setAppBuildOwnership(appConfig: EcoPagesAppConfig, buildOwnership: BuildOwnership): void {
471
+ appConfig.runtime = {
472
+ ...(appConfig.runtime ?? {}),
473
+ buildOwnership,
474
+ };
475
+ }
476
+
477
+ /**
478
+ * Returns the adapter owned by an app/runtime instance.
479
+ *
480
+ * @remarks
481
+ * Falls back through `appConfig.runtime.buildAdapter` →
482
+ * {@link getDefaultBuildAdapter} on the resolved ownership. Throws
483
+ * never; a missing adapter resolves to the global default.
484
+ */
485
+ export function getAppBuildAdapter(appConfig: EcoPagesAppConfig): BuildAdapter {
486
+ return appConfig.runtime?.buildAdapter ?? getDefaultBuildAdapter(getAppBuildOwnership(appConfig));
487
+ }
488
+
489
+ /**
490
+ * Installs the adapter that should serve future builds for one app
491
+ * instance, and aligns the ownership field to the new adapter's
492
+ * declared ownership.
493
+ */
494
+ export function setAppBuildAdapter(appConfig: EcoPagesAppConfig, buildAdapter: BuildAdapter): void {
495
+ appConfig.runtime = {
496
+ ...(appConfig.runtime ?? {}),
497
+ buildOwnership: getBuildAdapterOwnership(buildAdapter),
498
+ buildAdapter,
499
+ };
500
+ }
501
+
502
+ /**
503
+ * Returns the build manifest owned by an app/runtime instance.
504
+ *
505
+ * @remarks
506
+ * Falls back to a fresh manifest seeded from the config's loaders when
507
+ * the app config has no manifest yet. This is the supported way to
508
+ * read the manifest across the source-loading and asset-processing
509
+ * services.
510
+ */
511
+ export function getAppBuildManifest(appConfig: EcoPagesAppConfig): AppBuildManifest {
512
+ return (
513
+ appConfig.runtime?.buildManifest ??
514
+ createAppBuildManifest({
515
+ loaderPlugins: Array.from(appConfig.loaders.values()),
516
+ })
517
+ );
518
+ }
519
+
520
+ /** Installs the build manifest that should be visible to one app instance. */
521
+ export function setAppBuildManifest(appConfig: EcoPagesAppConfig, buildManifest: AppBuildManifest): void {
522
+ appConfig.runtime = {
523
+ ...(appConfig.runtime ?? {}),
524
+ buildManifest,
525
+ };
526
+ }
527
+
528
+ /**
529
+ * Builds a fresh app manifest from the config's loaders plus optional
530
+ * caller-supplied runtime/browser contributions.
531
+ *
532
+ * @remarks
533
+ * Loader plugins are always taken from the config; runtime and
534
+ * browser-bundle plugins are passed through from the caller when
535
+ * supplied, otherwise left empty for later population by
536
+ * {@link collectConfiguredAppBuildManifestContributions}.
537
+ */
538
+ export function createConfiguredAppBuildManifest(
539
+ appConfig: EcoPagesAppConfig,
540
+ input?: Partial<AppBuildManifest>,
541
+ ): AppBuildManifest {
542
+ return createAppBuildManifest({
543
+ loaderPlugins: input?.loaderPlugins ?? Array.from(appConfig.loaders.values()),
544
+ runtimePlugins: input?.runtimePlugins,
545
+ browserBundlePlugins: input?.browserBundlePlugins,
546
+ browserRuntimeManifest: input?.browserRuntimeManifest,
547
+ });
548
+ }
549
+
550
+ /**
551
+ * Replaces the app-owned manifest using config-owned loaders and the
552
+ * caller-supplied contribution input.
553
+ */
554
+ export function updateAppBuildManifest(appConfig: EcoPagesAppConfig, input?: Partial<AppBuildManifest>): void {
555
+ setAppBuildManifest(appConfig, createConfiguredAppBuildManifest(appConfig, input));
556
+ }
557
+
558
+ /**
559
+ * Collects the build-facing processor and integration contributions
560
+ * that should be sealed into the app manifest during config
561
+ * finalization.
562
+ *
563
+ * @remarks
564
+ * Runs `prepareBuildContributions()` on every processor and
565
+ * integration. Runtime-only side effects (HMR registration, cache
566
+ * prewarming, runtime-origin wiring) belong to the startup path and
567
+ * must not be triggered here; use {@link setupAppRuntimePlugins} for
568
+ * those.
569
+ *
570
+ * @returns The new manifest's runtime / browser / browser-runtime-manifest
571
+ * contribution buckets. Caller seals them into a manifest via
572
+ * {@link updateAppBuildManifest}.
573
+ */
574
+ export async function collectConfiguredAppBuildManifestContributions(
575
+ appConfig: EcoPagesAppConfig,
576
+ ): Promise<Pick<AppBuildManifest, 'runtimePlugins' | 'browserBundlePlugins' | 'browserRuntimeManifest'>> {
577
+ const runtimePlugins: EcoBuildPlugin[] = [];
578
+ const browserBundlePlugins: EcoBuildPlugin[] = [];
579
+ const browserRuntimeManifests = [];
580
+
581
+ for (const processor of appConfig.processors.values()) {
582
+ await processor.prepareBuildContributions();
583
+
584
+ if (processor.plugins) {
585
+ runtimePlugins.push(...processor.plugins);
586
+ }
587
+
588
+ if (processor.buildPlugins) {
589
+ browserBundlePlugins.push(...processor.buildPlugins);
590
+ }
591
+ }
592
+
593
+ for (const integration of appConfig.integrations) {
594
+ integration.setConfig(appConfig);
595
+ await integration.prepareBuildContributions();
596
+ runtimePlugins.push(...(integration.plugins ?? []));
597
+ browserBundlePlugins.push(...(integration.browserBuildPlugins ?? []));
598
+ browserRuntimeManifests.push(integration.browserRuntimeManifest);
599
+ }
600
+
601
+ return {
602
+ runtimePlugins,
603
+ browserBundlePlugins,
604
+ browserRuntimeManifest: mergeBrowserRuntimeManifests(...browserRuntimeManifests),
605
+ };
606
+ }
607
+
608
+ /**
609
+ * Runs runtime-only processor and integration setup against an already
610
+ * sealed app manifest.
611
+ *
612
+ * @remarks
613
+ * Startup paths call this after `ConfigBuilder.build` has finalized
614
+ * the manifest. The manifest is reused as-is; this helper only performs
615
+ * the runtime side effects that need live startup context (cache
616
+ * prewarming, runtime-origin wiring, HMR manager attachment).
617
+ *
618
+ * Loaders, processors, and integrations are visited in that order;
619
+ * each one's plugins are forwarded to the optional `onRuntimePlugin`
620
+ * callback so callers can attach to every plugin discovered.
621
+ */
622
+ export async function setupAppRuntimePlugins(options: {
623
+ appConfig: EcoPagesAppConfig;
624
+ runtimeOrigin: string;
625
+ hmrManager?: IHmrManager;
626
+ onRuntimePlugin?: (plugin: EcoBuildPlugin) => void;
627
+ }): Promise<void> {
628
+ for (const loader of options.appConfig.loaders.values()) {
629
+ options.onRuntimePlugin?.(loader);
630
+ }
631
+
632
+ for (const processor of options.appConfig.processors.values()) {
633
+ await processor.setup();
634
+
635
+ if (processor.plugins) {
636
+ for (const plugin of processor.plugins) {
637
+ options.onRuntimePlugin?.(plugin);
638
+ }
639
+ }
640
+ }
641
+
642
+ for (const integration of options.appConfig.integrations) {
643
+ integration.setConfig(options.appConfig);
644
+ integration.setRuntimeOrigin(options.runtimeOrigin);
645
+ if (options.hmrManager) {
646
+ integration.setHmrManager(options.hmrManager);
647
+ }
648
+
649
+ await integration.setup();
650
+
651
+ for (const plugin of integration.plugins) {
652
+ options.onRuntimePlugin?.(plugin);
653
+ }
654
+ }
655
+ }
656
+
657
+ /**
658
+ * Returns the server-bundle plugin list for one app/runtime instance.
659
+ *
660
+ * @remarks
661
+ * Reads from the app's sealed build manifest; the manifest itself is
662
+ * the source of truth for which plugins participate in the server
663
+ * bundle.
664
+ */
665
+ export function getAppServerBuildPlugins(appConfig: EcoPagesAppConfig): EcoBuildPlugin[] {
666
+ return getServerBuildPlugins(getAppBuildManifest(appConfig));
667
+ }
668
+
669
+ /**
670
+ * Returns the browser-bundle plugin list for one app/runtime instance.
671
+ *
672
+ * @remarks
673
+ * Reads from the app's sealed build manifest. The browser-bundle
674
+ * manifest is the source of truth for which plugins participate in the
675
+ * browser bundle.
676
+ */
677
+ export function getAppBrowserBuildPlugins(appConfig: EcoPagesAppConfig): EcoBuildPlugin[] {
678
+ const manifest = getAppBuildManifest(appConfig);
679
+ const jsxOwnershipPlugins = collectJsxOwnershipPlugins(appConfig);
680
+ return [...getBrowserBuildPlugins(manifest), ...jsxOwnershipPlugins];
681
+ }
682
+
683
+ /**
684
+ * Builds one {@link createForeignJsxOverridePlugin} instance per JSX
685
+ * extension per integration declared in the app config.
686
+ *
687
+ * The plugin rewrites every file matching a JSX extension with a
688
+ * `@jsxImportSource` pragma that names the owning integration. The
689
+ * pragma wins over both the bundler default and any tsconfig setting,
690
+ * so JSX files in multi-integration graphs always compile against the
691
+ * right runtime.
692
+ *
693
+ * @param appConfig - The app config whose integrations should be
694
+ * enumerated. Integrations without a `jsxImportSource` are skipped.
695
+ * @returns A flat list of plugins, one per (integration, extension)
696
+ * pair, sorted by extension length so more specific suffixes take
697
+ * priority.
698
+ */
699
+ function collectJsxOwnershipPlugins(appConfig: EcoPagesAppConfig): EcoBuildPlugin[] {
700
+ const jsxExtensions = (appConfig.integrations ?? [])
701
+ .filter((integration) => integration.jsxImportSource)
702
+ .flatMap((integration) =>
703
+ integration.extensions
704
+ .filter((extension) => extension.endsWith('.tsx') || extension.endsWith('.jsx'))
705
+ .map((extension) => ({ integration, extension })),
706
+ )
707
+ .sort((left, right) => right.extension.length - left.extension.length);
708
+
709
+ return jsxExtensions.map(({ integration, extension }) =>
710
+ createForeignJsxOverridePlugin({
711
+ hostJsxImportSource: integration.jsxImportSource!,
712
+ foreignExtensions: [extension],
713
+ excludeExtensions: jsxExtensions
714
+ .filter((candidate) => candidate.extension.length > extension.length)
715
+ .filter((candidate) => candidate.extension.endsWith(extension))
716
+ .map((candidate) => candidate.extension),
717
+ name: `ecopages-jsx-ownership-${integration.name}-${extension.replace(/[^a-zA-Z0-9]+/g, '-')}`,
718
+ }),
719
+ );
720
+ }
721
+
722
+ /**
723
+ * Returns the executor owned by an app/runtime instance.
724
+ *
725
+ * @remarks
726
+ * Falls back to {@link getAppBuildAdapter} when no executor is set
727
+ * on the runtime yet. The dev-watch pipeline replaces this value with
728
+ * a {@link SerializedBuildExecutor} via
729
+ * {@link installAppRuntimeBuildExecutor}.
730
+ */
731
+ export function getAppBuildExecutor(appConfig: EcoPagesAppConfig): BuildExecutor {
732
+ return appConfig.runtime?.buildExecutor ?? getAppBuildAdapter(appConfig);
733
+ }
734
+
735
+ /** Installs the executor that should serve future builds for one app instance. */
736
+ export function setAppBuildExecutor(appConfig: EcoPagesAppConfig, buildExecutor: BuildExecutor): void {
737
+ appConfig.runtime = {
738
+ ...(appConfig.runtime ?? {}),
739
+ buildExecutor,
740
+ };
741
+ }
742
+
743
+ /**
744
+ * Runs a build through the active pipeline.
745
+ *
746
+ * @remarks
747
+ * `executor` defaults to the default-bundler adapter for non-app-aware
748
+ * callsites. App-aware code should pass
749
+ * `getAppBuildExecutor(appConfig)` (or read it directly) to honor the
750
+ * per-app pipeline.
751
+ */
752
+ export function build(
753
+ options: BuildOptions,
754
+ executor: BuildExecutor = defaultRolldownBuildAdapter,
755
+ ): Promise<BuildResult> {
756
+ return executor.build(options).then((result) => {
757
+ if (result.success) {
758
+ normalizeNodeRuntimeBuildOutputs(
759
+ result.outputs.map((output) => output.path),
760
+ options.root ?? process.cwd(),
761
+ );
762
+ }
763
+
764
+ return result;
765
+ });
766
+ }
767
+
768
+ /**
769
+ * Default transpile-options helper for callsites without app runtime
770
+ * context.
771
+ *
772
+ * @remarks
773
+ * New app-aware code should prefer {@link getAppTranspileOptions}.
774
+ */
775
+ export function getTranspileOptions(profile: BuildTranspileProfile): BuildTranspileOptions {
776
+ return defaultRolldownBuildAdapter.getTranspileOptions(profile);
777
+ }
778
+
779
+ /**
780
+ * Resolves transpile options for one app/runtime instance by asking
781
+ * the app's adapter.
782
+ */
783
+ export function getAppTranspileOptions(
784
+ appConfig: EcoPagesAppConfig,
785
+ profile: BuildTranspileProfile,
786
+ ): BuildTranspileOptions {
787
+ return getAppBuildAdapter(appConfig).getTranspileOptions(profile);
788
+ }