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

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
@@ -0,0 +1,1012 @@
1
+ import type { EcoBuildPlugin } from './build-types.ts';
2
+ import {
3
+ createAppBuildManifest,
4
+ getBrowserBuildPlugins,
5
+ getServerBuildPlugins,
6
+ type AppBuildManifest,
7
+ } from './build-manifest.ts';
8
+ import { EsbuildBuildAdapter } from './esbuild-build-adapter.ts';
9
+ import { collectRuntimeSpecifierAliasMap, rewriteRuntimeSpecifierAliases } from './runtime-specifier-aliases.ts';
10
+ import type { EcoPagesAppConfig } from '../types/internal-types.ts';
11
+ import type { IHmrManager } from '../types/public-types.ts';
12
+ import { getBunRuntime } from '../utils/runtime.ts';
13
+ import fs from 'node:fs';
14
+ import path from 'node:path';
15
+
16
+ export { EsbuildBuildAdapter } from './esbuild-build-adapter.ts';
17
+
18
+ export type BuildOwnership = 'bun-native' | 'vite-host';
19
+
20
+ export interface BuildLog {
21
+ message: string;
22
+ }
23
+
24
+ export interface BuildOutput {
25
+ path: string;
26
+ }
27
+
28
+ /**
29
+ * Dependency graph metadata produced by a build backend.
30
+ *
31
+ * @remarks
32
+ * This structure is runtime-neutral at the type level, but current population
33
+ * is Node/esbuild-only. Bun-backed builds may omit this metadata.
34
+ */
35
+ export interface BuildDependencyGraph {
36
+ /**
37
+ * Normalized absolute entrypoint path mapped to all normalized absolute
38
+ * source inputs that contributed to that entrypoint output.
39
+ */
40
+ entrypoints: Record<string, string[]>;
41
+ }
42
+
43
+ export interface BuildResult {
44
+ success: boolean;
45
+ logs: BuildLog[];
46
+ outputs: BuildOutput[];
47
+ /**
48
+ * Optional build dependency metadata for selective invalidation.
49
+ *
50
+ * @remarks
51
+ * This is currently filled by the Node/esbuild adapter. Other runtimes should
52
+ * treat missing graph data as a valid state and fall back deterministically.
53
+ */
54
+ dependencyGraph?: BuildDependencyGraph;
55
+ }
56
+
57
+ export interface BuildOptions {
58
+ entrypoints: string[];
59
+ outdir?: string;
60
+ outbase?: string;
61
+ naming?: string;
62
+ conditions?: string[];
63
+ define?: Record<string, string>;
64
+ minify?: boolean;
65
+ treeshaking?: boolean;
66
+ target?: string;
67
+ format?: string;
68
+ sourcemap?: string;
69
+ splitting?: boolean;
70
+ root?: string;
71
+ bundle?: boolean;
72
+ externalPackages?: boolean;
73
+ external?: string[];
74
+ plugins?: EcoBuildPlugin[];
75
+ [key: string]: unknown;
76
+ }
77
+
78
+ export type BuildTranspileProfile = 'browser-script' | 'hmr-runtime' | 'hmr-entrypoint';
79
+
80
+ export interface BuildTranspileOptions {
81
+ target: string;
82
+ format: string;
83
+ sourcemap: string;
84
+ }
85
+
86
+ export interface BuildAdapter {
87
+ readonly ownership?: BuildOwnership;
88
+ /**
89
+ * Executes one concrete backend build.
90
+ *
91
+ * @remarks
92
+ * `BuildAdapter` is the low-level backend contract. Bun-native execution owns
93
+ * one adapter directly; Vite-hosted execution is represented as an explicit
94
+ * host-owned compatibility path rather than an implicit esbuild default.
95
+ */
96
+ build(options: BuildOptions): Promise<BuildResult>;
97
+ resolve(importPath: string, rootDir: string): string;
98
+ getTranspileOptions(profile: BuildTranspileProfile): BuildTranspileOptions;
99
+ }
100
+
101
+ /**
102
+ * Runtime-owned facade for issuing builds.
103
+ *
104
+ * @remarks
105
+ * This is intentionally narrower than `BuildAdapter`. A build executor answers
106
+ * only the question "how should this app execute a build right now?".
107
+ *
108
+ * In Bun-native production and non-watch flows the executor is usually the
109
+ * adapter itself. In development watch flows the executor may be a
110
+ * compatibility coordinator around the Bun-native adapter while the Vite host
111
+ * path continues migrating toward host-owned execution.
112
+ */
113
+ export interface BuildExecutor {
114
+ build(options: BuildOptions): Promise<BuildResult>;
115
+ }
116
+
117
+ type RuntimeBun = NonNullable<ReturnType<typeof getBunRuntime>>;
118
+
119
+ type NormalizedBunOutput = {
120
+ concretePath: string;
121
+ };
122
+
123
+ type BunPluginBuilder = {
124
+ config?: {
125
+ external?: string[];
126
+ };
127
+ onResolve(
128
+ options: { filter: RegExp; namespace?: string },
129
+ callback: (args: {
130
+ path: string;
131
+ importer: string;
132
+ namespace?: string;
133
+ }) =>
134
+ | { path?: string; namespace?: string; external?: boolean }
135
+ | undefined
136
+ | Promise<{ path?: string; namespace?: string; external?: boolean } | undefined>,
137
+ ): void;
138
+ onLoad(
139
+ options: { filter: RegExp; namespace?: string },
140
+ callback: (args: {
141
+ path: string;
142
+ namespace?: string;
143
+ }) =>
144
+ | { contents?: string | Uint8Array; loader?: string; resolveDir?: string }
145
+ | undefined
146
+ | Promise<{ contents?: string | Uint8Array; loader?: string; resolveDir?: string } | undefined>,
147
+ ): void;
148
+ };
149
+
150
+ function transpileProfileToOptions(profile: BuildTranspileProfile): BuildTranspileOptions {
151
+ switch (profile) {
152
+ case 'browser-script':
153
+ return {
154
+ target: 'browser',
155
+ format: 'esm',
156
+ sourcemap: 'none',
157
+ };
158
+ case 'hmr-runtime':
159
+ return {
160
+ target: 'browser',
161
+ format: 'esm',
162
+ sourcemap: 'none',
163
+ };
164
+ case 'hmr-entrypoint':
165
+ return {
166
+ target: 'browser',
167
+ format: 'esm',
168
+ sourcemap: 'none',
169
+ };
170
+ }
171
+ }
172
+
173
+ export class BunBuildAdapter implements BuildAdapter {
174
+ readonly ownership = 'bun-native' as const;
175
+ private readonly fallbackAdapter = new EsbuildBuildAdapter();
176
+
177
+ private getPluginsForBuild(additionalPlugins?: EcoBuildPlugin[]): EcoBuildPlugin[] {
178
+ const byName = new Map<string, EcoBuildPlugin>();
179
+
180
+ for (const plugin of additionalPlugins ?? []) {
181
+ if (!byName.has(plugin.name)) {
182
+ byName.set(plugin.name, plugin);
183
+ }
184
+ }
185
+
186
+ return Array.from(byName.values());
187
+ }
188
+
189
+ private escapeRegExp(value: string): string {
190
+ return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
191
+ }
192
+
193
+ private resolvePluginPath(value: string, importer: string, contextRoot: string): string {
194
+ if (path.isAbsolute(value)) {
195
+ return value;
196
+ }
197
+
198
+ if (value.startsWith('.') || value.startsWith('..')) {
199
+ const baseDir = importer ? path.dirname(importer) : contextRoot;
200
+ return path.resolve(baseDir, value);
201
+ }
202
+
203
+ return value;
204
+ }
205
+
206
+ private inferLoaderFromPath(filePath: string): string {
207
+ const extension = path.extname(filePath).toLowerCase();
208
+
209
+ switch (extension) {
210
+ case '.ts':
211
+ return 'ts';
212
+ case '.tsx':
213
+ return 'tsx';
214
+ case '.jsx':
215
+ return 'jsx';
216
+ case '.json':
217
+ return 'json';
218
+ case '.css':
219
+ return 'css';
220
+ default:
221
+ return 'js';
222
+ }
223
+ }
224
+
225
+ private normalizeBunLoader(loader: unknown): string | undefined {
226
+ switch (loader) {
227
+ case 'js':
228
+ case 'jsx':
229
+ case 'ts':
230
+ case 'tsx':
231
+ case 'json':
232
+ case 'toml':
233
+ case 'text':
234
+ case 'file':
235
+ case 'css':
236
+ return loader;
237
+ case 'global-css':
238
+ case 'local-css':
239
+ return 'css';
240
+ default:
241
+ return undefined;
242
+ }
243
+ }
244
+
245
+ private convertLoadResultToModuleSource(result: unknown): string | undefined {
246
+ if (!result || typeof result !== 'object') {
247
+ return undefined;
248
+ }
249
+
250
+ const candidate = result as {
251
+ contents?: string;
252
+ loader?: unknown;
253
+ exports?: Record<string, unknown>;
254
+ };
255
+
256
+ if (typeof candidate.contents === 'string') {
257
+ return candidate.contents;
258
+ }
259
+
260
+ if (candidate.loader === 'object' && candidate.exports && typeof candidate.exports === 'object') {
261
+ return Object.entries(candidate.exports)
262
+ .map(([key, value]) =>
263
+ key === 'default'
264
+ ? `export default ${JSON.stringify(value)};`
265
+ : `export const ${key} = ${JSON.stringify(value)};`,
266
+ )
267
+ .join('\n');
268
+ }
269
+
270
+ return undefined;
271
+ }
272
+
273
+ private convertPluginOnLoadResult(
274
+ args: { path: string },
275
+ result: unknown,
276
+ ): { contents?: string | Uint8Array; loader?: string; resolveDir?: string } | undefined {
277
+ if (!result || typeof result !== 'object') {
278
+ return undefined;
279
+ }
280
+
281
+ const candidate = result as {
282
+ contents?: string | Uint8Array;
283
+ loader?: unknown;
284
+ exports?: Record<string, unknown>;
285
+ resolveDir?: unknown;
286
+ };
287
+
288
+ const sourceFromExports =
289
+ candidate.loader === 'object' && candidate.exports && typeof candidate.exports === 'object'
290
+ ? this.convertLoadResultToModuleSource(candidate)
291
+ : undefined;
292
+
293
+ if (sourceFromExports) {
294
+ return {
295
+ contents: sourceFromExports,
296
+ loader: 'js',
297
+ ...(typeof candidate.resolveDir === 'string' ? { resolveDir: candidate.resolveDir } : {}),
298
+ };
299
+ }
300
+
301
+ if (typeof candidate.contents === 'string' || candidate.contents instanceof Uint8Array) {
302
+ return {
303
+ contents: candidate.contents,
304
+ loader: this.normalizeBunLoader(candidate.loader) ?? this.inferLoaderFromPath(args.path),
305
+ ...(typeof candidate.resolveDir === 'string' ? { resolveDir: candidate.resolveDir } : {}),
306
+ };
307
+ }
308
+
309
+ return undefined;
310
+ }
311
+
312
+ private createEcoPluginBridge(
313
+ plugins: EcoBuildPlugin[],
314
+ contextRoot: string,
315
+ ): RuntimeBun['plugin'] extends (...args: infer A) => unknown ? A[0] : never {
316
+ return {
317
+ name: 'ecopages-plugin-bridge',
318
+ setup: async (build: BunPluginBuilder) => {
319
+ let moduleCounter = 0;
320
+
321
+ const bridge = {
322
+ onResolve: (options, callback) => {
323
+ build.onResolve(options, async (args) => {
324
+ const result = await callback({
325
+ path: args.path,
326
+ importer: args.importer,
327
+ namespace: args.namespace,
328
+ });
329
+
330
+ if (!result || typeof result !== 'object') {
331
+ return undefined;
332
+ }
333
+
334
+ return {
335
+ ...(typeof result.path === 'string'
336
+ ? { path: this.resolvePluginPath(result.path, args.importer, contextRoot) }
337
+ : {}),
338
+ ...(typeof result.namespace === 'string' ? { namespace: result.namespace } : {}),
339
+ ...(typeof result.external === 'boolean' ? { external: result.external } : {}),
340
+ };
341
+ });
342
+ },
343
+ onLoad: (options, callback) => {
344
+ build.onLoad(options, async (args) =>
345
+ this.convertPluginOnLoadResult(
346
+ { path: args.path },
347
+ await callback({
348
+ path: args.path,
349
+ namespace: args.namespace,
350
+ }),
351
+ ),
352
+ );
353
+ },
354
+ module: (specifier, callback) => {
355
+ const namespace = `ecopages-module-${moduleCounter}`;
356
+ moduleCounter += 1;
357
+ const filter = new RegExp(`^${this.escapeRegExp(specifier)}$`);
358
+
359
+ build.onResolve({ filter }, async () => ({
360
+ path: specifier,
361
+ namespace,
362
+ }));
363
+
364
+ build.onLoad({ filter, namespace }, async () =>
365
+ this.convertPluginOnLoadResult({ path: specifier }, await callback()),
366
+ );
367
+ },
368
+ } satisfies import('./build-types.ts').EcoBuildPluginBuilder;
369
+
370
+ for (const plugin of plugins) {
371
+ await plugin.setup(bridge);
372
+ }
373
+ },
374
+ } as RuntimeBun['plugin'] extends (...args: infer A) => unknown ? A[0] : never;
375
+ }
376
+
377
+ private toBuildLogs(error: unknown): BuildLog[] {
378
+ if (error instanceof Error) {
379
+ return [{ message: error.message }];
380
+ }
381
+
382
+ return [{ message: 'Unknown Bun build error' }];
383
+ }
384
+
385
+ private mapBunTarget(value: string | undefined): 'browser' | 'bun' {
386
+ return value === 'browser' ? 'browser' : 'bun';
387
+ }
388
+
389
+ private mapBunFormat(value: string | undefined): 'esm' | 'cjs' | undefined {
390
+ switch (value) {
391
+ case 'cjs':
392
+ return 'cjs';
393
+ case 'esm':
394
+ default:
395
+ return 'esm';
396
+ }
397
+ }
398
+
399
+ private getOutputExtension(options: BuildOptions, entrypointPath: string): string {
400
+ const entryExtension = path.extname(entrypointPath).toLowerCase();
401
+
402
+ if (entryExtension === '.css') {
403
+ return '.css';
404
+ }
405
+
406
+ if (entryExtension === '.json') {
407
+ return '.json';
408
+ }
409
+
410
+ if (entryExtension === '.toml') {
411
+ return '.toml';
412
+ }
413
+
414
+ return options.format === 'cjs' || options.format === 'esm' ? '.js' : '.js';
415
+ }
416
+
417
+ private resolveConcreteOutputPath(outputPath: string): string | undefined {
418
+ if (fs.existsSync(outputPath)) {
419
+ return outputPath;
420
+ }
421
+
422
+ if (!outputPath.includes('[hash]')) {
423
+ return outputPath;
424
+ }
425
+
426
+ const directory = path.dirname(outputPath);
427
+ if (!fs.existsSync(directory)) {
428
+ return undefined;
429
+ }
430
+
431
+ const basenamePattern = path.basename(outputPath);
432
+ const matcher = new RegExp(`^${this.escapeRegExp(basenamePattern).replace(/\\\[hash\\\]/g, '(.+)')}$`);
433
+ const matches = fs
434
+ .readdirSync(directory)
435
+ .filter((candidate) => matcher.test(candidate))
436
+ .sort();
437
+
438
+ if (matches.length === 0) {
439
+ return undefined;
440
+ }
441
+
442
+ return path.join(directory, matches[0]!);
443
+ }
444
+
445
+ private normalizePathForMatch(filePath: string): string {
446
+ return path.normalize(filePath).split(path.sep).join('/');
447
+ }
448
+
449
+ private normalizeOutputPathForMatch(outputPath: string, templatePath: string): string {
450
+ const normalizedOutputPath = path.normalize(outputPath);
451
+ const templateExtension = path.extname(templatePath);
452
+
453
+ if (!templateExtension) {
454
+ return normalizedOutputPath;
455
+ }
456
+
457
+ if (templateExtension === '.js') {
458
+ if (this.hasJavaScriptExtension(normalizedOutputPath)) {
459
+ return path.normalize(normalizedOutputPath.replace(/\.(?:[cm]?js)$/u, '.js'));
460
+ }
461
+
462
+ return path.normalize(`${normalizedOutputPath}.js`);
463
+ }
464
+
465
+ if (normalizedOutputPath.endsWith(templateExtension)) {
466
+ return normalizedOutputPath;
467
+ }
468
+
469
+ return path.normalize(`${normalizedOutputPath}${templateExtension}`);
470
+ }
471
+
472
+ private extractTemplateHashTokens(templatePath: string, candidatePath: string): string[] | undefined {
473
+ const normalizedTemplatePath = this.normalizePathForMatch(templatePath);
474
+ const normalizedCandidatePath = this.normalizePathForMatch(
475
+ this.normalizeOutputPathForMatch(candidatePath, templatePath),
476
+ );
477
+ const matcher = new RegExp(
478
+ `^${this.escapeRegExp(normalizedTemplatePath).replace(/\\\[hash\\\]/g, '([^/]+)')}$`,
479
+ );
480
+ const match = normalizedCandidatePath.match(matcher);
481
+
482
+ if (!match) {
483
+ return undefined;
484
+ }
485
+
486
+ return match.slice(1);
487
+ }
488
+
489
+ private applyTemplateHashTokens(templatePath: string, hashTokens: string[]): string | undefined {
490
+ const hashTokenCount = templatePath.match(/\[hash\]/g)?.length ?? 0;
491
+
492
+ if (hashTokenCount !== hashTokens.length) {
493
+ return undefined;
494
+ }
495
+
496
+ if (hashTokenCount === 0) {
497
+ return templatePath;
498
+ }
499
+
500
+ let hashTokenIndex = 0;
501
+ return templatePath.replace(/\[hash\]/g, () => hashTokens[hashTokenIndex++] ?? '');
502
+ }
503
+
504
+ private resolveTemplatedOutputPath(options: BuildOptions, entrypointPath: string): string | undefined {
505
+ if (!options.outdir) {
506
+ return undefined;
507
+ }
508
+
509
+ const template = typeof options.naming === 'string' ? options.naming : '[dir]/[name]';
510
+ const outdir = path.resolve(options.outdir);
511
+ const outputExtension = this.getOutputExtension(options, entrypointPath);
512
+ const relativeBase = path.resolve(options.outbase ?? options.root ?? process.cwd());
513
+ const relativeEntrypoint = path.relative(relativeBase, entrypointPath);
514
+ const relativeDir = path.dirname(relativeEntrypoint);
515
+ const dirToken = relativeDir === '.' ? '' : relativeDir.split(path.sep).join('/');
516
+ const nameToken = path.basename(relativeEntrypoint, path.extname(relativeEntrypoint));
517
+ const extToken = outputExtension.replace(/^\./, '');
518
+
519
+ let resolvedPath = template
520
+ .replaceAll('[dir]', dirToken)
521
+ .replaceAll('[name]', nameToken)
522
+ .replaceAll('[ext]', extToken);
523
+
524
+ if (outputExtension && !resolvedPath.endsWith(outputExtension)) {
525
+ resolvedPath += outputExtension;
526
+ }
527
+
528
+ resolvedPath = resolvedPath.replace(/^\.\//, '');
529
+
530
+ return path.join(outdir, resolvedPath);
531
+ }
532
+
533
+ private relocateOutputFile(currentPath: string, targetPath: string): string {
534
+ if (currentPath === targetPath || !fs.existsSync(currentPath)) {
535
+ return fs.existsSync(targetPath) ? targetPath : currentPath;
536
+ }
537
+
538
+ fs.mkdirSync(path.dirname(targetPath), { recursive: true });
539
+ fs.rmSync(targetPath, { force: true });
540
+ fs.renameSync(currentPath, targetPath);
541
+ return targetPath;
542
+ }
543
+
544
+ private hasJavaScriptExtension(outputPath: string): boolean {
545
+ return /\.(?:[cm]?js)$/u.test(outputPath);
546
+ }
547
+
548
+ private findOutputMatchForEntrypoint(
549
+ options: BuildOptions,
550
+ entrypointPath: string,
551
+ outputs: NormalizedBunOutput[],
552
+ usedOutputIndexes: Set<number>,
553
+ ): { outputIndex: number; targetPath: string } | undefined {
554
+ const expectedOutputPath = this.resolveTemplatedOutputPath(options, entrypointPath);
555
+
556
+ if (!expectedOutputPath) {
557
+ return undefined;
558
+ }
559
+
560
+ const expectedMatchPaths = [expectedOutputPath];
561
+
562
+ if (options.outbase) {
563
+ const bunRootRelativeOutputPath = this.resolveTemplatedOutputPath(
564
+ { ...options, outbase: undefined },
565
+ entrypointPath,
566
+ );
567
+
568
+ if (bunRootRelativeOutputPath && bunRootRelativeOutputPath !== expectedOutputPath) {
569
+ expectedMatchPaths.push(bunRootRelativeOutputPath);
570
+ }
571
+ }
572
+
573
+ for (const [outputIndex, output] of outputs.entries()) {
574
+ if (usedOutputIndexes.has(outputIndex)) {
575
+ continue;
576
+ }
577
+
578
+ for (const matchPath of expectedMatchPaths) {
579
+ const hashTokens = this.extractTemplateHashTokens(matchPath, output.concretePath);
580
+ if (!hashTokens) {
581
+ continue;
582
+ }
583
+
584
+ const targetPath = this.applyTemplateHashTokens(expectedOutputPath, hashTokens);
585
+ if (!targetPath) {
586
+ continue;
587
+ }
588
+
589
+ usedOutputIndexes.add(outputIndex);
590
+ return { outputIndex, targetPath };
591
+ }
592
+ }
593
+
594
+ return undefined;
595
+ }
596
+
597
+ private normalizeBunOutputs(result: BuildResult, options: BuildOptions): BuildResult {
598
+ if (!result.success || result.outputs.length === 0) {
599
+ return result;
600
+ }
601
+
602
+ const normalizedOutputs = result.outputs.map((output) => ({
603
+ concretePath: this.resolveConcreteOutputPath(output.path) ?? output.path,
604
+ }));
605
+ const matchedTargetsByIndex = new Map<number, string>();
606
+ const usedOutputIndexes = new Set<number>();
607
+
608
+ for (const entrypointPath of options.entrypoints) {
609
+ const matchedOutput = this.findOutputMatchForEntrypoint(
610
+ options,
611
+ entrypointPath,
612
+ normalizedOutputs,
613
+ usedOutputIndexes,
614
+ );
615
+
616
+ if (matchedOutput) {
617
+ matchedTargetsByIndex.set(matchedOutput.outputIndex, matchedOutput.targetPath);
618
+ }
619
+ }
620
+
621
+ return {
622
+ ...result,
623
+ outputs: normalizedOutputs.map((output, index) => {
624
+ const expectedOutputPath = matchedTargetsByIndex.get(index);
625
+ const concreteOutputPath = output.concretePath;
626
+
627
+ if (expectedOutputPath) {
628
+ return {
629
+ path: this.relocateOutputFile(concreteOutputPath, expectedOutputPath),
630
+ };
631
+ }
632
+
633
+ if (this.hasJavaScriptExtension(concreteOutputPath)) {
634
+ return {
635
+ path: concreteOutputPath,
636
+ };
637
+ }
638
+
639
+ const normalizedPath = `${concreteOutputPath}.js`;
640
+ return {
641
+ path: this.relocateOutputFile(concreteOutputPath, normalizedPath),
642
+ };
643
+ }),
644
+ };
645
+ }
646
+
647
+ private rewriteAliasedRuntimeSpecifiers(result: BuildResult, plugins: EcoBuildPlugin[]): BuildResult {
648
+ if (!result.success || result.outputs.length === 0) {
649
+ return result;
650
+ }
651
+
652
+ const aliasMap = collectRuntimeSpecifierAliasMap(plugins);
653
+ if (aliasMap.size === 0) {
654
+ return result;
655
+ }
656
+
657
+ for (const output of result.outputs) {
658
+ if (!/\.(?:[cm]?js)$/u.test(output.path) || !fs.existsSync(output.path)) {
659
+ continue;
660
+ }
661
+
662
+ const code = fs.readFileSync(output.path, 'utf-8');
663
+ const rewritten = rewriteRuntimeSpecifierAliases(code, aliasMap);
664
+
665
+ if (rewritten !== code) {
666
+ fs.writeFileSync(output.path, rewritten);
667
+ }
668
+ }
669
+
670
+ return result;
671
+ }
672
+
673
+ async build(options: BuildOptions): Promise<BuildResult> {
674
+ const bun = getBunRuntime();
675
+
676
+ if (!bun) {
677
+ return this.fallbackAdapter.build(options);
678
+ }
679
+
680
+ try {
681
+ const contextRoot = options.root ? path.resolve(options.root) : process.cwd();
682
+ const outdir = path.resolve(options.outdir ?? 'dist/assets');
683
+ const plugins = this.getPluginsForBuild(options.plugins);
684
+ const result = await bun.build({
685
+ entrypoints: options.entrypoints,
686
+ outdir,
687
+ root: contextRoot,
688
+ naming: typeof options.naming === 'string' ? options.naming : undefined,
689
+ define: options.define,
690
+ external: options.external,
691
+ format: this.mapBunFormat(options.format),
692
+ target: this.mapBunTarget(options.target),
693
+ sourcemap: options.sourcemap as 'none' | 'external' | 'linked' | 'inline' | undefined,
694
+ splitting: !!options.splitting,
695
+ minify: !!options.minify,
696
+ packages: options.target !== 'browser' && options.externalPackages !== false ? 'external' : undefined,
697
+ plugins: plugins.length > 0 ? [this.createEcoPluginBridge(plugins, contextRoot)] : undefined,
698
+ });
699
+
700
+ return this.rewriteAliasedRuntimeSpecifiers(
701
+ this.normalizeBunOutputs(
702
+ {
703
+ success: result.success,
704
+ logs: result.logs.map((log) => ({ message: log.message })),
705
+ outputs: result.outputs.map((output) => ({ path: output.path })),
706
+ },
707
+ options,
708
+ ),
709
+ plugins,
710
+ );
711
+ } catch (error) {
712
+ return {
713
+ success: false,
714
+ logs: this.toBuildLogs(error),
715
+ outputs: [],
716
+ };
717
+ }
718
+ }
719
+
720
+ resolve(importPath: string, rootDir: string): string {
721
+ const bun = getBunRuntime();
722
+
723
+ if (!bun) {
724
+ return this.fallbackAdapter.resolve(importPath, rootDir);
725
+ }
726
+
727
+ return bun.resolveSync(importPath, rootDir);
728
+ }
729
+
730
+ getTranspileOptions(profile: BuildTranspileProfile): BuildTranspileOptions {
731
+ return transpileProfileToOptions(profile);
732
+ }
733
+ }
734
+
735
+ function createHostOwnedBuildError(methodName: string): Error {
736
+ return new Error(
737
+ `Vite-hosted builds are owned by the host runtime. Core cannot ${methodName} through the host-owned compatibility adapter.`,
738
+ );
739
+ }
740
+
741
+ export class ViteHostBuildAdapter implements BuildAdapter {
742
+ readonly ownership = 'vite-host' as const;
743
+
744
+ async build(_options: BuildOptions): Promise<BuildResult> {
745
+ throw createHostOwnedBuildError('build');
746
+ }
747
+
748
+ resolve(_importPath: string, _rootDir: string): string {
749
+ throw createHostOwnedBuildError('resolve imports');
750
+ }
751
+
752
+ getTranspileOptions(_profile: BuildTranspileProfile): BuildTranspileOptions {
753
+ throw createHostOwnedBuildError('derive transpile options');
754
+ }
755
+ }
756
+
757
+ export function createBunBuildAdapter(): BuildAdapter {
758
+ return new BunBuildAdapter();
759
+ }
760
+
761
+ export function createViteHostBuildAdapter(): BuildAdapter {
762
+ return new ViteHostBuildAdapter();
763
+ }
764
+
765
+ export function createBuildAdapter(options?: { ownership?: BuildOwnership }): BuildAdapter {
766
+ switch (options?.ownership ?? 'bun-native') {
767
+ case 'vite-host':
768
+ return createViteHostBuildAdapter();
769
+ case 'bun-native':
770
+ default:
771
+ return createBunBuildAdapter();
772
+ }
773
+ }
774
+
775
+ export const defaultBunBuildAdapter: BuildAdapter = createBuildAdapter({ ownership: 'bun-native' });
776
+ export const defaultViteHostBuildAdapter: BuildAdapter = createBuildAdapter({ ownership: 'vite-host' });
777
+ /**
778
+ * Bun-native fallback export for callsites that still resolve build state
779
+ * globally.
780
+ *
781
+ * New app-aware code should prefer `getAppBuildAdapter()`.
782
+ */
783
+ export const defaultBuildAdapter: BuildAdapter = defaultBunBuildAdapter;
784
+
785
+ export function getDefaultBuildAdapter(ownership: BuildOwnership = 'bun-native'): BuildAdapter {
786
+ return ownership === 'vite-host' ? defaultViteHostBuildAdapter : defaultBunBuildAdapter;
787
+ }
788
+
789
+ export function getBuildAdapterOwnership(buildAdapter: BuildAdapter | undefined): BuildOwnership {
790
+ return buildAdapter?.ownership ?? 'bun-native';
791
+ }
792
+
793
+ export function getAppBuildOwnership(appConfig: EcoPagesAppConfig): BuildOwnership {
794
+ return appConfig.runtime?.buildOwnership ?? getBuildAdapterOwnership(appConfig.runtime?.buildAdapter);
795
+ }
796
+
797
+ export function setAppBuildOwnership(appConfig: EcoPagesAppConfig, buildOwnership: BuildOwnership): void {
798
+ appConfig.runtime = {
799
+ ...(appConfig.runtime ?? {}),
800
+ buildOwnership,
801
+ };
802
+ }
803
+
804
+ /**
805
+ * Returns the adapter owned by an app/runtime instance.
806
+ *
807
+ * @remarks
808
+ * The config builder installs an explicit adapter per app. The Bun-native
809
+ * fallback remains only as compatibility scaffolding for helpers that do not
810
+ * yet thread app runtime state explicitly.
811
+ */
812
+ export function getAppBuildAdapter(appConfig: EcoPagesAppConfig): BuildAdapter {
813
+ return appConfig.runtime?.buildAdapter ?? getDefaultBuildAdapter(getAppBuildOwnership(appConfig));
814
+ }
815
+
816
+ /**
817
+ * Installs the adapter that should serve future builds for one app instance.
818
+ */
819
+ export function setAppBuildAdapter(appConfig: EcoPagesAppConfig, buildAdapter: BuildAdapter): void {
820
+ appConfig.runtime = {
821
+ ...(appConfig.runtime ?? {}),
822
+ buildOwnership: getBuildAdapterOwnership(buildAdapter),
823
+ buildAdapter,
824
+ };
825
+ }
826
+
827
+ /**
828
+ * Returns the build manifest owned by an app/runtime instance.
829
+ */
830
+ export function getAppBuildManifest(appConfig: EcoPagesAppConfig): AppBuildManifest {
831
+ return (
832
+ appConfig.runtime?.buildManifest ??
833
+ createAppBuildManifest({
834
+ loaderPlugins: Array.from(appConfig.loaders.values()),
835
+ })
836
+ );
837
+ }
838
+
839
+ /**
840
+ * Installs the build manifest that should be visible to one app instance.
841
+ */
842
+ export function setAppBuildManifest(appConfig: EcoPagesAppConfig, buildManifest: AppBuildManifest): void {
843
+ appConfig.runtime = {
844
+ ...(appConfig.runtime ?? {}),
845
+ buildManifest,
846
+ };
847
+ }
848
+
849
+ /**
850
+ * Rebuilds an app-owned manifest from config-owned loaders plus explicit
851
+ * runtime/browser contribution input.
852
+ *
853
+ * @remarks
854
+ * This keeps loader ownership with config finalization while still letting a
855
+ * caller supply the non-loader plugin buckets that were discovered elsewhere.
856
+ */
857
+ export function createConfiguredAppBuildManifest(
858
+ appConfig: EcoPagesAppConfig,
859
+ input?: Partial<AppBuildManifest>,
860
+ ): AppBuildManifest {
861
+ return createAppBuildManifest({
862
+ loaderPlugins: input?.loaderPlugins ?? Array.from(appConfig.loaders.values()),
863
+ runtimePlugins: input?.runtimePlugins,
864
+ browserBundlePlugins: input?.browserBundlePlugins,
865
+ });
866
+ }
867
+
868
+ /**
869
+ * Replaces the app-owned manifest using config-owned loaders and explicit
870
+ * contribution input.
871
+ */
872
+ export function updateAppBuildManifest(appConfig: EcoPagesAppConfig, input?: Partial<AppBuildManifest>): void {
873
+ setAppBuildManifest(appConfig, createConfiguredAppBuildManifest(appConfig, input));
874
+ }
875
+
876
+ /**
877
+ * Collects the build-facing processor and integration contributions that should
878
+ * be sealed into the app manifest during config finalization.
879
+ *
880
+ * @remarks
881
+ * This runs `prepareBuildContributions()` only. Runtime-only side effects such
882
+ * as HMR registration, cache prewarming, and runtime-origin wiring belong to
883
+ * the startup path and must not be triggered here.
884
+ */
885
+ export async function collectConfiguredAppBuildManifestContributions(
886
+ appConfig: EcoPagesAppConfig,
887
+ ): Promise<Pick<AppBuildManifest, 'runtimePlugins' | 'browserBundlePlugins'>> {
888
+ const runtimePlugins: EcoBuildPlugin[] = [];
889
+ const browserBundlePlugins: EcoBuildPlugin[] = [];
890
+
891
+ for (const processor of appConfig.processors.values()) {
892
+ await processor.prepareBuildContributions();
893
+
894
+ if (processor.plugins) {
895
+ runtimePlugins.push(...processor.plugins);
896
+ }
897
+
898
+ if (processor.buildPlugins) {
899
+ browserBundlePlugins.push(...processor.buildPlugins);
900
+ }
901
+ }
902
+
903
+ for (const integration of appConfig.integrations) {
904
+ integration.setConfig(appConfig);
905
+ await integration.prepareBuildContributions();
906
+ runtimePlugins.push(...(integration.plugins ?? []));
907
+ browserBundlePlugins.push(...(integration.browserBuildPlugins ?? []));
908
+ }
909
+
910
+ return {
911
+ runtimePlugins,
912
+ browserBundlePlugins,
913
+ };
914
+ }
915
+
916
+ /**
917
+ * Runs runtime-only processor and integration setup against an already sealed
918
+ * app manifest.
919
+ *
920
+ * @remarks
921
+ * Startup paths call this after config build has finalized manifest
922
+ * contributions. The manifest is reused as-is; this helper only performs the
923
+ * runtime side effects that still need live startup context.
924
+ */
925
+ export async function setupAppRuntimePlugins(options: {
926
+ appConfig: EcoPagesAppConfig;
927
+ runtimeOrigin: string;
928
+ hmrManager?: IHmrManager;
929
+ onRuntimePlugin?: (plugin: EcoBuildPlugin) => void;
930
+ }): Promise<void> {
931
+ for (const processor of options.appConfig.processors.values()) {
932
+ await processor.setup();
933
+
934
+ if (processor.plugins) {
935
+ for (const plugin of processor.plugins) {
936
+ options.onRuntimePlugin?.(plugin);
937
+ }
938
+ }
939
+ }
940
+
941
+ for (const integration of options.appConfig.integrations) {
942
+ integration.setConfig(options.appConfig);
943
+ integration.setRuntimeOrigin(options.runtimeOrigin);
944
+ if (options.hmrManager) {
945
+ integration.setHmrManager(options.hmrManager);
946
+ }
947
+
948
+ await integration.setup();
949
+
950
+ for (const plugin of integration.plugins) {
951
+ options.onRuntimePlugin?.(plugin);
952
+ }
953
+ }
954
+ }
955
+
956
+ export function getAppServerBuildPlugins(appConfig: EcoPagesAppConfig): EcoBuildPlugin[] {
957
+ return getServerBuildPlugins(getAppBuildManifest(appConfig));
958
+ }
959
+
960
+ export function getAppBrowserBuildPlugins(appConfig: EcoPagesAppConfig): EcoBuildPlugin[] {
961
+ return getBrowserBuildPlugins(getAppBuildManifest(appConfig));
962
+ }
963
+
964
+ /**
965
+ * Returns the executor owned by an app/runtime instance.
966
+ *
967
+ * @remarks
968
+ * The config builder seeds this with the app-owned adapter. Runtime adapters
969
+ * may replace it with a compatibility coordinator while keeping ownership tied
970
+ * to the same Bun-native backend.
971
+ */
972
+ export function getAppBuildExecutor(appConfig: EcoPagesAppConfig): BuildExecutor {
973
+ return appConfig.runtime?.buildExecutor ?? getAppBuildAdapter(appConfig);
974
+ }
975
+
976
+ /**
977
+ * Installs the executor that should serve future builds for one app instance.
978
+ */
979
+ export function setAppBuildExecutor(appConfig: EcoPagesAppConfig, buildExecutor: BuildExecutor): void {
980
+ appConfig.runtime = {
981
+ ...(appConfig.runtime ?? {}),
982
+ buildExecutor,
983
+ };
984
+ }
985
+
986
+ /**
987
+ * Runs a build through the active pipeline.
988
+ *
989
+ * @remarks
990
+ * Callers can pass an explicit executor when builds should be routed through an
991
+ * app-owned development coordinator. Without one, the Bun-native default
992
+ * adapter is used directly.
993
+ */
994
+ export function build(options: BuildOptions, executor: BuildExecutor = defaultBunBuildAdapter): Promise<BuildResult> {
995
+ return executor.build(options);
996
+ }
997
+
998
+ /**
999
+ * Bun-native fallback helper for callsites without app runtime context.
1000
+ *
1001
+ * New app-aware code should prefer `getAppTranspileOptions()`.
1002
+ */
1003
+ export function getTranspileOptions(profile: BuildTranspileProfile): BuildTranspileOptions {
1004
+ return defaultBunBuildAdapter.getTranspileOptions(profile);
1005
+ }
1006
+
1007
+ export function getAppTranspileOptions(
1008
+ appConfig: EcoPagesAppConfig,
1009
+ profile: BuildTranspileProfile,
1010
+ ): BuildTranspileOptions {
1011
+ return getAppBuildAdapter(appConfig).getTranspileOptions(profile);
1012
+ }