@ecopages/core 0.2.0-alpha.1 → 0.2.0-alpha.10

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 (323) hide show
  1. package/CHANGELOG.md +13 -70
  2. package/README.md +213 -12
  3. package/package.json +50 -18
  4. package/src/adapters/README.md +39 -0
  5. package/src/adapters/bun/hmr-manager.d.ts +77 -18
  6. package/src/adapters/bun/hmr-manager.js +159 -52
  7. package/src/adapters/bun/index.d.ts +1 -2
  8. package/src/adapters/bun/index.js +1 -1
  9. package/src/adapters/bun/server-adapter.js +35 -30
  10. package/src/adapters/bun/server-lifecycle.d.ts +24 -13
  11. package/src/adapters/bun/server-lifecycle.js +32 -60
  12. package/src/adapters/index.d.ts +1 -1
  13. package/src/adapters/index.js +1 -1
  14. package/src/adapters/node/bootstrap-dependency-resolver.d.ts +44 -0
  15. package/src/adapters/node/bootstrap-dependency-resolver.js +172 -0
  16. package/src/adapters/node/index.d.ts +2 -0
  17. package/src/adapters/node/index.js +3 -0
  18. package/src/adapters/node/node-hmr-manager.d.ts +87 -16
  19. package/src/adapters/node/node-hmr-manager.js +179 -88
  20. package/src/adapters/node/runtime-adapter.d.ts +46 -0
  21. package/src/adapters/node/runtime-adapter.js +306 -0
  22. package/src/adapters/node/server-adapter.d.ts +2 -31
  23. package/src/adapters/node/server-adapter.js +31 -93
  24. package/src/adapters/node/static-content-server.d.ts +36 -0
  25. package/src/adapters/node/static-content-server.js +28 -0
  26. package/src/adapters/node/write-runtime-manifest.d.ts +26 -0
  27. package/src/adapters/node/write-runtime-manifest.js +12 -0
  28. package/src/{define-api-handler.d.ts → adapters/shared/define-api-handler.d.ts} +1 -1
  29. package/src/adapters/shared/explicit-static-route-matcher.js +4 -1
  30. package/src/adapters/shared/file-route-middleware-pipeline.js +1 -0
  31. package/src/adapters/shared/fs-server-response-matcher.d.ts +9 -5
  32. package/src/adapters/shared/fs-server-response-matcher.js +13 -8
  33. package/src/adapters/shared/hmr-entrypoint-registrar.d.ts +55 -0
  34. package/src/adapters/shared/hmr-entrypoint-registrar.js +87 -0
  35. package/src/adapters/shared/hmr-html-response.d.ts +22 -0
  36. package/src/adapters/shared/hmr-html-response.js +32 -0
  37. package/src/adapters/shared/render-context.js +3 -2
  38. package/src/adapters/shared/runtime-bootstrap.d.ts +38 -0
  39. package/src/adapters/shared/runtime-bootstrap.js +43 -0
  40. package/src/adapters/shared/server-adapter.d.ts +12 -2
  41. package/src/adapters/shared/server-adapter.js +37 -4
  42. package/src/adapters/shared/server-route-handler.d.ts +1 -1
  43. package/src/adapters/shared/server-route-handler.js +4 -13
  44. package/src/adapters/shared/server-static-builder.d.ts +35 -3
  45. package/src/adapters/shared/server-static-builder.js +59 -6
  46. package/src/build/README.md +101 -0
  47. package/src/build/build-adapter.d.ts +114 -2
  48. package/src/build/build-adapter.js +119 -5
  49. package/src/build/build-manifest.d.ts +27 -0
  50. package/src/build/build-manifest.js +30 -0
  51. package/src/build/dev-build-coordinator.d.ts +74 -0
  52. package/src/build/dev-build-coordinator.js +161 -0
  53. package/src/build/esbuild-build-adapter.d.ts +9 -6
  54. package/src/build/esbuild-build-adapter.js +103 -71
  55. package/src/build/runtime-build-executor.d.ts +13 -0
  56. package/src/build/runtime-build-executor.js +20 -0
  57. package/src/build/runtime-specifier-alias-plugin.d.ts +15 -0
  58. package/src/build/runtime-specifier-alias-plugin.js +31 -0
  59. package/src/config/README.md +33 -0
  60. package/src/config/config-builder.d.ts +28 -17
  61. package/src/config/config-builder.js +221 -48
  62. package/src/constants.d.ts +13 -0
  63. package/src/constants.js +4 -0
  64. package/src/declarations.d.ts +18 -13
  65. package/src/eco/README.md +70 -16
  66. package/src/eco/component-render-context.d.ts +1 -1
  67. package/src/eco/component-render-context.js +26 -16
  68. package/src/eco/eco.js +16 -12
  69. package/src/eco/eco.types.d.ts +12 -4
  70. package/src/hmr/README.md +26 -0
  71. package/src/hmr/client/hmr-runtime.d.ts +1 -6
  72. package/src/hmr/client/hmr-runtime.js +30 -7
  73. package/src/hmr/hmr.postcss.test.e2e.d.ts +1 -0
  74. package/src/hmr/hmr.postcss.test.e2e.js +31 -0
  75. package/src/hmr/hmr.test.e2e.js +26 -33
  76. package/src/hmr/strategies/js-hmr-strategy.d.ts +45 -42
  77. package/src/hmr/strategies/js-hmr-strategy.js +70 -71
  78. package/src/index.d.ts +1 -1
  79. package/src/index.js +1 -1
  80. package/src/integrations/ghtml/ghtml-renderer.d.ts +1 -1
  81. package/src/integrations/ghtml/ghtml-renderer.js +3 -1
  82. package/src/internal-types.d.ts +39 -18
  83. package/src/plugins/README.md +34 -0
  84. package/src/plugins/alias-resolver-plugin.js +17 -3
  85. package/src/plugins/eco-component-meta-plugin.d.ts +2 -0
  86. package/src/plugins/eco-component-meta-plugin.js +1 -1
  87. package/src/plugins/integration-plugin.d.ts +38 -4
  88. package/src/plugins/integration-plugin.js +34 -1
  89. package/src/plugins/processor.d.ts +14 -1
  90. package/src/plugins/processor.js +15 -1
  91. package/src/plugins/runtime-capability.d.ts +9 -0
  92. package/src/public-types.d.ts +65 -10
  93. package/src/route-renderer/GRAPH.md +16 -20
  94. package/src/route-renderer/README.md +8 -21
  95. package/src/route-renderer/component-graph/component-reference.d.ts +10 -0
  96. package/src/route-renderer/component-graph/component-reference.js +19 -0
  97. package/src/route-renderer/{marker-graph-resolver.d.ts → component-graph/marker-graph-resolver.d.ts} +6 -5
  98. package/src/route-renderer/{marker-graph-resolver.js → component-graph/marker-graph-resolver.js} +10 -8
  99. package/src/route-renderer/{integration-renderer.d.ts → orchestration/integration-renderer.d.ts} +45 -12
  100. package/src/route-renderer/{integration-renderer.js → orchestration/integration-renderer.js} +79 -16
  101. package/src/route-renderer/{render-execution.service.d.ts → orchestration/render-execution.service.d.ts} +39 -5
  102. package/src/route-renderer/{render-execution.service.js → orchestration/render-execution.service.js} +58 -28
  103. package/src/route-renderer/{render-preparation.service.d.ts → orchestration/render-preparation.service.d.ts} +13 -4
  104. package/src/route-renderer/{render-preparation.service.js → orchestration/render-preparation.service.js} +92 -3
  105. package/src/route-renderer/{dependency-resolver.d.ts → page-loading/dependency-resolver.d.ts} +15 -4
  106. package/src/route-renderer/{dependency-resolver.js → page-loading/dependency-resolver.js} +18 -4
  107. package/src/route-renderer/page-loading/page-module-loader.d.ts +87 -0
  108. package/src/route-renderer/{page-module-loader.js → page-loading/page-module-loader.js} +36 -14
  109. package/src/route-renderer/route-renderer.d.ts +36 -1
  110. package/src/route-renderer/route-renderer.js +19 -0
  111. package/src/router/README.md +26 -0
  112. package/src/router/client/link-intent.d.ts +53 -0
  113. package/src/router/client/link-intent.js +34 -0
  114. package/src/router/client/link-intent.test.browser.d.ts +1 -0
  115. package/src/router/client/link-intent.test.browser.js +43 -0
  116. package/src/router/client/navigation-coordinator.d.ts +149 -0
  117. package/src/router/client/navigation-coordinator.js +215 -0
  118. package/src/router/{fs-router-scanner.d.ts → server/fs-router-scanner.d.ts} +3 -3
  119. package/src/router/{fs-router-scanner.js → server/fs-router-scanner.js} +8 -7
  120. package/src/router/{fs-router.d.ts → server/fs-router.d.ts} +1 -1
  121. package/src/router/{fs-router.js → server/fs-router.js} +1 -1
  122. package/src/services/README.md +29 -0
  123. package/src/services/assets/asset-processing-service/asset-processing.service.d.ts +120 -0
  124. package/src/services/{asset-processing-service → assets/asset-processing-service}/asset-processing.service.js +88 -7
  125. package/src/services/{asset-processing-service → assets/asset-processing-service}/asset.factory.js +2 -2
  126. package/src/services/{asset-processing-service → assets/asset-processing-service}/assets.types.d.ts +2 -1
  127. package/src/services/assets/asset-processing-service/assets.types.js +0 -0
  128. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.d.ts +55 -0
  129. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.js +48 -0
  130. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.d.ts +20 -0
  131. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.js +41 -0
  132. package/src/services/{asset-processing-service → assets/asset-processing-service}/index.d.ts +2 -0
  133. package/src/services/{asset-processing-service → assets/asset-processing-service}/index.js +2 -0
  134. package/src/services/{asset-processing-service → assets/asset-processing-service}/processor.interface.d.ts +1 -1
  135. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/base/base-processor.d.ts +1 -1
  136. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/base/base-processor.js +9 -4
  137. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/base/base-script-processor.d.ts +3 -2
  138. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/base/base-script-processor.js +14 -22
  139. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/file-script.processor.d.ts +1 -1
  140. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/file-script.processor.js +2 -2
  141. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/node-module-script.processor.js +5 -4
  142. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/stylesheet/file-stylesheet.processor.js +4 -1
  143. package/src/services/assets/browser-bundle.service.d.ts +32 -0
  144. package/src/services/assets/browser-bundle.service.js +33 -0
  145. package/src/services/{page-request-cache-coordinator.service.d.ts → cache/page-request-cache-coordinator.service.d.ts} +2 -2
  146. package/src/services/{page-request-cache-coordinator.service.js → cache/page-request-cache-coordinator.service.js} +3 -1
  147. package/src/services/html/html-rewriter-provider.service.d.ts +37 -0
  148. package/src/services/html/html-rewriter-provider.service.js +65 -0
  149. package/src/services/html/html-transformer.service.d.ts +77 -0
  150. package/src/services/html/html-transformer.service.js +221 -0
  151. package/src/services/invalidation/development-invalidation.service.d.ts +74 -0
  152. package/src/services/invalidation/development-invalidation.service.js +189 -0
  153. package/src/services/module-loading/app-server-module-transpiler.service.d.ts +16 -0
  154. package/src/services/module-loading/app-server-module-transpiler.service.js +34 -0
  155. package/src/services/module-loading/page-module-import.service.d.ts +71 -0
  156. package/src/services/module-loading/page-module-import.service.js +132 -0
  157. package/src/services/module-loading/server-loader.service.d.ts +96 -0
  158. package/src/services/module-loading/server-loader.service.js +32 -0
  159. package/src/services/module-loading/server-module-transpiler.service.d.ts +69 -0
  160. package/src/services/module-loading/server-module-transpiler.service.js +61 -0
  161. package/src/services/runtime-manifest/node-runtime-manifest.service.d.ts +35 -0
  162. package/src/services/runtime-manifest/node-runtime-manifest.service.js +60 -0
  163. package/src/services/runtime-state/dev-graph.service.d.ts +118 -0
  164. package/src/services/runtime-state/dev-graph.service.js +162 -0
  165. package/src/services/runtime-state/entrypoint-dependency-graph.service.d.ts +41 -0
  166. package/src/services/runtime-state/entrypoint-dependency-graph.service.js +85 -0
  167. package/src/services/runtime-state/runtime-specifier-registry.service.d.ts +69 -0
  168. package/src/services/runtime-state/runtime-specifier-registry.service.js +37 -0
  169. package/src/services/runtime-state/server-invalidation-state.service.d.ts +26 -0
  170. package/src/services/runtime-state/server-invalidation-state.service.js +35 -0
  171. package/src/services/{schema-validation-service.d.ts → validation/schema-validation-service.d.ts} +1 -1
  172. package/src/static-site-generator/README.md +26 -0
  173. package/src/static-site-generator/static-site-generator.d.ts +53 -1
  174. package/src/static-site-generator/static-site-generator.js +86 -5
  175. package/src/utils/resolve-work-dir.d.ts +11 -0
  176. package/src/utils/resolve-work-dir.js +31 -0
  177. package/src/watchers/project-watcher.d.ts +37 -21
  178. package/src/watchers/project-watcher.js +109 -66
  179. package/src/watchers/project-watcher.test-helpers.js +1 -0
  180. package/src/adapters/abstract/application-adapter.ts +0 -337
  181. package/src/adapters/abstract/router-adapter.ts +0 -30
  182. package/src/adapters/abstract/server-adapter.ts +0 -79
  183. package/src/adapters/bun/client-bridge.ts +0 -62
  184. package/src/adapters/bun/create-app.ts +0 -189
  185. package/src/adapters/bun/define-api-handler.d.ts +0 -61
  186. package/src/adapters/bun/define-api-handler.ts +0 -114
  187. package/src/adapters/bun/hmr-manager.ts +0 -281
  188. package/src/adapters/bun/index.ts +0 -3
  189. package/src/adapters/bun/server-adapter.ts +0 -492
  190. package/src/adapters/bun/server-lifecycle.ts +0 -154
  191. package/src/adapters/index.ts +0 -6
  192. package/src/adapters/node/create-app.ts +0 -179
  193. package/src/adapters/node/index.ts +0 -9
  194. package/src/adapters/node/node-client-bridge.ts +0 -79
  195. package/src/adapters/node/node-hmr-manager.ts +0 -271
  196. package/src/adapters/node/server-adapter.ts +0 -561
  197. package/src/adapters/node/static-content-server.ts +0 -203
  198. package/src/adapters/shared/api-response.ts +0 -104
  199. package/src/adapters/shared/application-adapter.ts +0 -199
  200. package/src/adapters/shared/explicit-static-route-matcher.ts +0 -134
  201. package/src/adapters/shared/file-route-middleware-pipeline.ts +0 -123
  202. package/src/adapters/shared/fs-server-response-factory.ts +0 -118
  203. package/src/adapters/shared/fs-server-response-matcher.ts +0 -198
  204. package/src/adapters/shared/render-context.ts +0 -105
  205. package/src/adapters/shared/server-adapter.ts +0 -442
  206. package/src/adapters/shared/server-route-handler.ts +0 -166
  207. package/src/adapters/shared/server-static-builder.ts +0 -82
  208. package/src/build/build-adapter.ts +0 -132
  209. package/src/build/build-types.ts +0 -83
  210. package/src/build/esbuild-build-adapter.ts +0 -510
  211. package/src/config/config-builder.ts +0 -474
  212. package/src/constants.ts +0 -39
  213. package/src/create-app.ts +0 -87
  214. package/src/define-api-handler.js +0 -15
  215. package/src/define-api-handler.ts +0 -66
  216. package/src/dev/sc-server.ts +0 -143
  217. package/src/eco/component-render-context.ts +0 -202
  218. package/src/eco/eco.ts +0 -221
  219. package/src/eco/eco.types.ts +0 -202
  220. package/src/eco/eco.utils.ts +0 -89
  221. package/src/eco/global-injector-map.ts +0 -112
  222. package/src/eco/lazy-injector-map.ts +0 -120
  223. package/src/eco/module-dependencies.ts +0 -75
  224. package/src/errors/http-error.ts +0 -72
  225. package/src/errors/index.ts +0 -2
  226. package/src/errors/locals-access-error.ts +0 -7
  227. package/src/global/app-logger.ts +0 -4
  228. 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
  229. package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-HMR-Server-Integration-should-load-fixture-app-page-1.png +0 -0
  230. package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-WebSocket-Connection-should-connect-to-correct-HMR-endpoint-1.png +0 -0
  231. package/src/hmr/client/hmr-runtime.ts +0 -121
  232. package/src/hmr/hmr-strategy.ts +0 -172
  233. package/src/hmr/hmr.test.e2e.ts +0 -75
  234. package/src/hmr/strategies/default-hmr-strategy.ts +0 -60
  235. package/src/hmr/strategies/js-hmr-strategy.ts +0 -308
  236. package/src/index.browser.ts +0 -3
  237. package/src/index.ts +0 -5
  238. package/src/integrations/ghtml/ghtml-renderer.ts +0 -93
  239. package/src/integrations/ghtml/ghtml.plugin.ts +0 -32
  240. package/src/internal-types.ts +0 -212
  241. package/src/plugins/alias-resolver-plugin.ts +0 -45
  242. package/src/plugins/eco-component-meta-plugin.ts +0 -474
  243. package/src/plugins/integration-plugin.ts +0 -184
  244. package/src/plugins/processor.ts +0 -220
  245. package/src/public-types.ts +0 -1255
  246. package/src/route-renderer/component-graph-executor.ts +0 -84
  247. package/src/route-renderer/component-graph.ts +0 -159
  248. package/src/route-renderer/component-marker.ts +0 -117
  249. package/src/route-renderer/dependency-resolver.ts +0 -596
  250. package/src/route-renderer/html-post-processing.service.d.ts +0 -40
  251. package/src/route-renderer/html-post-processing.service.js +0 -86
  252. package/src/route-renderer/html-post-processing.service.ts +0 -103
  253. package/src/route-renderer/integration-renderer.ts +0 -696
  254. package/src/route-renderer/marker-graph-resolver.ts +0 -153
  255. package/src/route-renderer/page-module-loader.d.ts +0 -61
  256. package/src/route-renderer/page-module-loader.ts +0 -153
  257. package/src/route-renderer/render-execution.service.ts +0 -158
  258. package/src/route-renderer/render-preparation.service.ts +0 -358
  259. package/src/route-renderer/route-renderer.ts +0 -80
  260. package/src/router/fs-router-scanner.ts +0 -217
  261. package/src/router/fs-router.ts +0 -122
  262. package/src/services/asset-processing-service/asset-processing.service.d.ts +0 -41
  263. package/src/services/asset-processing-service/asset-processing.service.ts +0 -306
  264. package/src/services/asset-processing-service/asset.factory.ts +0 -105
  265. package/src/services/asset-processing-service/assets.types.ts +0 -112
  266. package/src/services/asset-processing-service/index.ts +0 -3
  267. package/src/services/asset-processing-service/processor.interface.ts +0 -27
  268. package/src/services/asset-processing-service/processor.registry.ts +0 -18
  269. package/src/services/asset-processing-service/processors/base/base-processor.ts +0 -76
  270. package/src/services/asset-processing-service/processors/base/base-script-processor.ts +0 -105
  271. package/src/services/asset-processing-service/processors/index.ts +0 -5
  272. package/src/services/asset-processing-service/processors/script/content-script.processor.ts +0 -66
  273. package/src/services/asset-processing-service/processors/script/file-script.processor.ts +0 -88
  274. package/src/services/asset-processing-service/processors/script/node-module-script.processor.ts +0 -84
  275. package/src/services/asset-processing-service/processors/stylesheet/content-stylesheet.processor.ts +0 -27
  276. package/src/services/asset-processing-service/processors/stylesheet/file-stylesheet.processor.ts +0 -77
  277. package/src/services/cache/cache.types.ts +0 -126
  278. package/src/services/cache/index.ts +0 -18
  279. package/src/services/cache/memory-cache-store.ts +0 -130
  280. package/src/services/cache/page-cache-service.ts +0 -202
  281. package/src/services/html-transformer.service.d.ts +0 -50
  282. package/src/services/html-transformer.service.js +0 -163
  283. package/src/services/html-transformer.service.ts +0 -217
  284. package/src/services/page-module-import.service.d.ts +0 -37
  285. package/src/services/page-module-import.service.js +0 -88
  286. package/src/services/page-module-import.service.ts +0 -129
  287. package/src/services/page-request-cache-coordinator.service.ts +0 -128
  288. package/src/services/schema-validation-service.ts +0 -204
  289. package/src/services/validation/standard-schema.types.ts +0 -68
  290. package/src/static-site-generator/static-site-generator.ts +0 -359
  291. package/src/utils/css.ts +0 -5
  292. package/src/utils/deep-merge.ts +0 -47
  293. package/src/utils/hash.ts +0 -5
  294. package/src/utils/html.ts +0 -1
  295. package/src/utils/invariant.ts +0 -15
  296. package/src/utils/locals-utils.ts +0 -37
  297. package/src/utils/parse-cli-args.ts +0 -83
  298. package/src/utils/path-utils.module.ts +0 -14
  299. package/src/utils/runtime.ts +0 -44
  300. package/src/utils/server-utils.module.ts +0 -67
  301. package/src/watchers/project-watcher.test-helpers.ts +0 -40
  302. package/src/watchers/project-watcher.ts +0 -306
  303. /package/src/adapters/{bun → shared}/define-api-handler.js +0 -0
  304. /package/src/{services/asset-processing-service/assets.types.js → plugins/runtime-capability.js} +0 -0
  305. /package/src/route-renderer/{component-graph-executor.d.ts → component-graph/component-graph-executor.d.ts} +0 -0
  306. /package/src/route-renderer/{component-graph-executor.js → component-graph/component-graph-executor.js} +0 -0
  307. /package/src/route-renderer/{component-graph.d.ts → component-graph/component-graph.d.ts} +0 -0
  308. /package/src/route-renderer/{component-graph.js → component-graph/component-graph.js} +0 -0
  309. /package/src/route-renderer/{component-marker.d.ts → component-graph/component-marker.d.ts} +0 -0
  310. /package/src/route-renderer/{component-marker.js → component-graph/component-marker.js} +0 -0
  311. /package/src/services/{asset-processing-service → assets/asset-processing-service}/asset.factory.d.ts +0 -0
  312. /package/src/services/{asset-processing-service → assets/asset-processing-service}/processor.interface.js +0 -0
  313. /package/src/services/{asset-processing-service → assets/asset-processing-service}/processor.registry.d.ts +0 -0
  314. /package/src/services/{asset-processing-service → assets/asset-processing-service}/processor.registry.js +0 -0
  315. /package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/index.d.ts +0 -0
  316. /package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/index.js +0 -0
  317. /package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/content-script.processor.d.ts +0 -0
  318. /package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/content-script.processor.js +0 -0
  319. /package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/node-module-script.processor.d.ts +0 -0
  320. /package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/stylesheet/content-stylesheet.processor.d.ts +0 -0
  321. /package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/stylesheet/content-stylesheet.processor.js +0 -0
  322. /package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/stylesheet/file-stylesheet.processor.d.ts +0 -0
  323. /package/src/services/{schema-validation-service.js → validation/schema-validation-service.js} +0 -0
@@ -1,7 +1,7 @@
1
1
  import type { EcoPagesAppConfig } from '../../internal-types';
2
- import type { StaticRoute } from '../../public-types';
2
+ import type { ApiHandler, StaticRoute } from '../../public-types';
3
3
  import type { RouteRendererFactory } from '../../route-renderer/route-renderer';
4
- import type { FSRouter } from '../../router/fs-router';
4
+ import type { FSRouter } from '../../router/server/fs-router';
5
5
  import type { StaticSiteGenerator } from '../../static-site-generator/static-site-generator';
6
6
  export interface StaticBuildOptions {
7
7
  preview?: boolean;
@@ -14,6 +14,32 @@ export interface ServerStaticBuilderParams {
14
14
  appConfig: EcoPagesAppConfig;
15
15
  staticSiteGenerator: StaticSiteGenerator;
16
16
  serveOptions: ServeOptions;
17
+ apiHandlers?: ApiHandler[];
18
+ logger?: ServerStaticBuilderLogger;
19
+ previewServerFactory?: ServerStaticPreviewServerFactory;
20
+ }
21
+ /**
22
+ * Minimal logger dependency used by the static builder.
23
+ */
24
+ export interface ServerStaticBuilderLogger {
25
+ warn(message: string, detail?: string): unknown;
26
+ info(message: string): unknown;
27
+ error(message: string): unknown;
28
+ }
29
+ /**
30
+ * Preview server factory dependency used when static preview mode is enabled.
31
+ */
32
+ export interface ServerStaticPreviewServerFactory {
33
+ createServer(args: {
34
+ appConfig: EcoPagesAppConfig;
35
+ options: {
36
+ port: number;
37
+ };
38
+ }): {
39
+ server?: {
40
+ port?: number;
41
+ } | null;
42
+ };
17
43
  }
18
44
  /**
19
45
  * Handles static site generation and previews.
@@ -22,7 +48,13 @@ export declare class ServerStaticBuilder {
22
48
  private readonly appConfig;
23
49
  private readonly staticSiteGenerator;
24
50
  private readonly serveOptions;
25
- constructor({ appConfig, staticSiteGenerator, serveOptions }: ServerStaticBuilderParams);
51
+ private readonly apiHandlers;
52
+ private readonly logger;
53
+ private readonly previewServerFactory;
54
+ constructor({ appConfig, staticSiteGenerator, serveOptions, apiHandlers, logger, previewServerFactory, }: ServerStaticBuilderParams);
55
+ private warnApiHandlersUnavailableInStaticMode;
56
+ private prepareExportDirectory;
57
+ private refreshRuntimeAssets;
26
58
  /**
27
59
  * Generates a static build of the site for deployment.
28
60
  * @param options.preview - If true, starts a preview server after build
@@ -1,13 +1,63 @@
1
+ import path from "node:path";
2
+ import { fileSystem } from "@ecopages/file-system";
1
3
  import { StaticContentServer } from "../../dev/sc-server";
2
4
  import { appLogger } from "../../global/app-logger";
3
5
  class ServerStaticBuilder {
4
6
  appConfig;
5
7
  staticSiteGenerator;
6
8
  serveOptions;
7
- constructor({ appConfig, staticSiteGenerator, serveOptions }) {
9
+ apiHandlers;
10
+ logger;
11
+ previewServerFactory;
12
+ constructor({
13
+ appConfig,
14
+ staticSiteGenerator,
15
+ serveOptions,
16
+ apiHandlers,
17
+ logger,
18
+ previewServerFactory
19
+ }) {
8
20
  this.appConfig = appConfig;
9
21
  this.staticSiteGenerator = staticSiteGenerator;
10
22
  this.serveOptions = serveOptions;
23
+ this.apiHandlers = apiHandlers ?? [];
24
+ this.logger = logger ?? appLogger;
25
+ this.previewServerFactory = previewServerFactory ?? StaticContentServer;
26
+ }
27
+ warnApiHandlersUnavailableInStaticMode() {
28
+ if (this.apiHandlers.length === 0) {
29
+ return;
30
+ }
31
+ const uniqueHandlers = Array.from(
32
+ new Set(this.apiHandlers.map((handler) => `${handler.method} ${handler.path}`))
33
+ );
34
+ const visibleHandlers = uniqueHandlers.slice(0, 5).join(", ");
35
+ const remainingCount = uniqueHandlers.length - Math.min(uniqueHandlers.length, 5);
36
+ const summary = remainingCount > 0 ? `${visibleHandlers}, +${remainingCount} more` : visibleHandlers;
37
+ this.logger.warn(
38
+ "Registered API endpoints are not available in static build or preview modes because no server runtime is started. They are excluded from the generated output.\n",
39
+ `\u27A4 ${summary}`
40
+ );
41
+ }
42
+ prepareExportDirectory() {
43
+ const exportDir = this.appConfig.absolutePaths?.distDir ?? path.join(this.appConfig.rootDir, this.appConfig.distDir);
44
+ fileSystem.ensureDir(exportDir, true);
45
+ const srcPublicDir = path.join(
46
+ this.appConfig.rootDir,
47
+ this.appConfig.srcDir ?? "src",
48
+ this.appConfig.publicDir ?? "public"
49
+ );
50
+ if (fileSystem.exists(srcPublicDir)) {
51
+ fileSystem.copyDir(srcPublicDir, exportDir);
52
+ }
53
+ }
54
+ async refreshRuntimeAssets() {
55
+ for (const processor of this.appConfig.processors.values()) {
56
+ await processor.setup();
57
+ }
58
+ for (const integration of this.appConfig.integrations) {
59
+ await integration.setup();
60
+ }
11
61
  }
12
62
  /**
13
63
  * Generates a static build of the site for deployment.
@@ -19,6 +69,9 @@ class ServerStaticBuilder {
19
69
  async build(options, dependencies) {
20
70
  const { preview = false } = options ?? {};
21
71
  const baseUrl = `http://${this.serveOptions.hostname || "localhost"}:${this.serveOptions.port || 3e3}`;
72
+ this.warnApiHandlersUnavailableInStaticMode();
73
+ this.prepareExportDirectory();
74
+ await this.refreshRuntimeAssets();
22
75
  await this.staticSiteGenerator.run({
23
76
  router: dependencies.router,
24
77
  baseUrl,
@@ -26,18 +79,18 @@ class ServerStaticBuilder {
26
79
  staticRoutes: dependencies.staticRoutes
27
80
  });
28
81
  if (!preview) {
29
- appLogger.info("Build completed");
82
+ this.logger.info("Build completed");
30
83
  return;
31
84
  }
32
85
  const previewPort = this.serveOptions.port || 3e3;
33
- const { server } = StaticContentServer.createServer({
86
+ const { server } = this.previewServerFactory.createServer({
34
87
  appConfig: this.appConfig,
35
88
  options: { port: Number(previewPort) }
36
89
  });
37
- if (server) {
38
- appLogger.info(`Preview running at http://localhost:${server.port}`);
90
+ if (server?.port) {
91
+ this.logger.info(`Preview running at http://localhost:${server.port}`);
39
92
  } else {
40
- appLogger.error("Failed to start preview server");
93
+ this.logger.error("Failed to start preview server");
41
94
  }
42
95
  }
43
96
  }
@@ -0,0 +1,101 @@
1
+ # Build Layer
2
+
3
+ This directory contains the runtime-neutral build contract used across Ecopages and the esbuild-backed implementation that currently powers the default fallback adapter.
4
+
5
+ ## Files
6
+
7
+ - `build-adapter.ts`: shared build interfaces, result types, app-owned adapter/executor helpers, the exported `defaultBuildAdapter` fallback, and the top-level `build()` / `getTranspileOptions()` pipeline functions.
8
+ - `build-types.ts`: plugin bridge types used by integrations and processors.
9
+ - `esbuild-build-adapter.ts`: the concrete esbuild backend.
10
+ - `dev-build-coordinator.ts`: development-only orchestration around the shared esbuild backend.
11
+ - `*.test.ts`: focused regression coverage for plain builds and development serialization and recovery.
12
+
13
+ ## Responsibilities
14
+
15
+ The build layer is intentionally split into two parts.
16
+
17
+ `BuildExecutor` is the runtime-facing contract.
18
+
19
+ - It is the narrow facade stored on `appConfig.runtime.buildExecutor`.
20
+ - It answers only how a given app instance should execute builds right now.
21
+ - `EsbuildBuildAdapter` satisfies this contract directly in plain flows.
22
+ - `DevBuildCoordinator` also satisfies this contract by wrapping the shared esbuild adapter with development-only serialization and recovery policy.
23
+
24
+ `EsbuildBuildAdapter` is the backend. It knows how to:
25
+
26
+ - load the esbuild module
27
+ - translate Ecopages `BuildOptions` into esbuild options
28
+ - bridge Ecopages build plugins into esbuild hooks
29
+ - normalize build output, logs, and dependency graph metadata
30
+ - detect the subset of runtime faults that mean the esbuild worker protocol is corrupted
31
+
32
+ `DevBuildCoordinator` is the development policy layer. It exists because one app/runtime can have many build callers during dev mode, including:
33
+
34
+ - page module imports
35
+ - HMR entrypoint builds
36
+ - script and asset processors
37
+ - React integration build paths
38
+
39
+ Those callers must not race each other against one long-lived esbuild worker. The coordinator therefore owns:
40
+
41
+ - serialized access to the shared adapter in development
42
+ - recycling warm Node-target esbuild sessions between builds
43
+ - recovery from known esbuild worker protocol faults
44
+
45
+ ## Default Flow
46
+
47
+ Each `EcoPagesAppConfig` owns a build adapter, build manifest, and `buildExecutor` in `appConfig.runtime`. `ConfigBuilder.build()` now creates that app-owned build state up front so later runtime startup can reuse it rather than mutating a shared adapter.
48
+
49
+ When a Node or Bun server adapter starts in watch mode, it replaces that executor with a per-app `DevBuildCoordinator`. Build consumers then either call the executor directly or pass it explicitly to the top-level `build()` helper.
50
+
51
+ Plugins are part of app-owned manifest or per-build input now. The source build contract no longer exposes adapter-level plugin registration, which keeps build composition scoped to an app/runtime instance instead of leaking across instances.
52
+
53
+ HMR callers follow the same ownership model. Integration-specific runtime aliasing stays with the integration that owns those specifiers, rather than in generic core HMR bundling.
54
+
55
+ ## Orchestration Diagram
56
+
57
+ ```mermaid
58
+ flowchart TD
59
+ Config["ConfigBuilder.build()"] --> DefaultExec["appConfig.runtime.buildExecutor = createAppBuildExecutor(app adapter, manifest)"]
60
+ Adapter["Server adapter initialize() in watch mode"] --> DevExec["appConfig.runtime.buildExecutor = DevBuildCoordinator"]
61
+ Caller["Any build caller with app/runtime context"] --> Build["executor.build(options) or build(options, executor)"]
62
+ Build --> Executor["BuildExecutor"]
63
+ Executor --> Coordinator["DevBuildCoordinator.build()"]
64
+ Coordinator --> Backend["EsbuildBuildAdapter.buildOrThrow()"]
65
+ Executor -->|plain flow| Direct["EsbuildBuildAdapter.build()"]
66
+ Backend --> Result["BuildResult"]
67
+ Direct --> Result["BuildResult"]
68
+ Result --> Browser["Browser consumes emitted bundle directly"]
69
+ ```
70
+
71
+ ## Recovery Model
72
+
73
+ The recovery path is narrow on purpose. The coordinator only treats an error as recoverable when `EsbuildBuildAdapter.isEsbuildProtocolError()` matches one of the known worker-protocol failure signatures.
74
+
75
+ When that happens, recovery does three things in order:
76
+
77
+ 1. Reset the serialized queue so future builds are not stuck behind a wedged promise.
78
+ 2. Stop the current esbuild service instance.
79
+ 3. Increment the esbuild module generation so the next import gets a fresh worker instance.
80
+
81
+ After that reset, the coordinator retries the failed build once.
82
+
83
+ ## Why Explicit App Ownership
84
+
85
+ There are many build callsites across core and integrations. The coordinator still needs to stay centralized, but process-global installation hid the real dependency and tied behavior to startup order.
86
+
87
+ The explicit app-owned executor model keeps the design honest:
88
+
89
+ - each app/runtime owns its own build executor
90
+ - development policy stays in one place (`DevBuildCoordinator`)
91
+ - callers with app context use that executor explicitly instead of consulting global state
92
+ - tests can still instantiate `EsbuildBuildAdapter` or `DevBuildCoordinator` directly when they want the raw backend only
93
+
94
+ ## Testing Strategy
95
+
96
+ The build tests are split by concern.
97
+
98
+ - `build-adapter.test.ts` verifies plain backend behavior and plugin bridging.
99
+ - `build-adapter-serialization.test.ts` verifies development orchestration behavior such as serialization, warm-session recycling, and protocol-fault recovery.
100
+
101
+ If you change the build orchestration rules, update the coordinator tests first. If you change esbuild option mapping or plugin behavior, update the backend tests first.
@@ -1,4 +1,7 @@
1
1
  import type { EcoBuildPlugin } from './build-types.js';
2
+ import { type AppBuildManifest } from './build-manifest.js';
3
+ import type { EcoPagesAppConfig } from '../internal-types.js';
4
+ import type { IHmrManager } from '../public-types.js';
2
5
  export { EsbuildBuildAdapter } from './esbuild-build-adapter.js';
3
6
  export interface BuildLog {
4
7
  message: string;
@@ -36,7 +39,10 @@ export interface BuildResult {
36
39
  export interface BuildOptions {
37
40
  entrypoints: string[];
38
41
  outdir?: string;
42
+ outbase?: string;
39
43
  naming?: string;
44
+ conditions?: string[];
45
+ define?: Record<string, string>;
40
46
  minify?: boolean;
41
47
  treeshaking?: boolean;
42
48
  target?: string;
@@ -57,18 +63,124 @@ export interface BuildTranspileOptions {
57
63
  sourcemap: string;
58
64
  }
59
65
  export interface BuildAdapter {
66
+ /**
67
+ * Executes one concrete backend build.
68
+ *
69
+ * @remarks
70
+ * `BuildAdapter` is the low-level backend contract. The default adapter is
71
+ * `EsbuildBuildAdapter`, but alternate adapters may satisfy the same shape.
72
+ */
60
73
  build(options: BuildOptions): Promise<BuildResult>;
61
74
  resolve(importPath: string, rootDir: string): string;
62
- registerPlugin(plugin: EcoBuildPlugin): void;
63
75
  getTranspileOptions(profile: BuildTranspileProfile): BuildTranspileOptions;
64
76
  }
77
+ /**
78
+ * Runtime-owned facade for issuing builds.
79
+ *
80
+ * @remarks
81
+ * This is intentionally narrower than `BuildAdapter`. A build executor answers
82
+ * only the question "how should this app execute a build right now?".
83
+ *
84
+ * In production and non-watch flows the executor is usually the adapter itself,
85
+ * which today means `EsbuildBuildAdapter`. In development watch flows the
86
+ * executor is typically `DevBuildCoordinator`, which wraps the shared esbuild
87
+ * adapter to serialize callers and recover from known worker faults.
88
+ */
89
+ export interface BuildExecutor {
90
+ build(options: BuildOptions): Promise<BuildResult>;
91
+ }
92
+ export declare function createBuildAdapter(): BuildAdapter;
65
93
  /**
66
94
  * @deprecated Use EsbuildBuildAdapter instead. Bun native build is missing some dependency graph features.
67
95
  */
68
96
  export declare class BunBuildAdapter implements BuildAdapter {
69
97
  build(options: BuildOptions): Promise<BuildResult>;
70
98
  resolve(importPath: string, rootDir: string): string;
71
- registerPlugin(plugin: EcoBuildPlugin): void;
72
99
  getTranspileOptions(profile: BuildTranspileProfile): BuildTranspileOptions;
73
100
  }
74
101
  export declare const defaultBuildAdapter: BuildAdapter;
102
+ /**
103
+ * Returns the adapter owned by an app/runtime instance.
104
+ *
105
+ * @remarks
106
+ * The config builder installs a dedicated adapter per app. The shared default
107
+ * adapter remains only as a compatibility fallback for older tests and helpers
108
+ * that do not yet thread app runtime state explicitly.
109
+ */
110
+ export declare function getAppBuildAdapter(appConfig: EcoPagesAppConfig): BuildAdapter;
111
+ /**
112
+ * Installs the adapter that should serve future builds for one app instance.
113
+ */
114
+ export declare function setAppBuildAdapter(appConfig: EcoPagesAppConfig, buildAdapter: BuildAdapter): void;
115
+ /**
116
+ * Returns the build manifest owned by an app/runtime instance.
117
+ */
118
+ export declare function getAppBuildManifest(appConfig: EcoPagesAppConfig): AppBuildManifest;
119
+ /**
120
+ * Installs the build manifest that should be visible to one app instance.
121
+ */
122
+ export declare function setAppBuildManifest(appConfig: EcoPagesAppConfig, buildManifest: AppBuildManifest): void;
123
+ /**
124
+ * Rebuilds an app-owned manifest from config-owned loaders plus explicit
125
+ * runtime/browser contribution input.
126
+ *
127
+ * @remarks
128
+ * This keeps loader ownership with config finalization while still letting a
129
+ * caller supply the non-loader plugin buckets that were discovered elsewhere.
130
+ */
131
+ export declare function createConfiguredAppBuildManifest(appConfig: EcoPagesAppConfig, input?: Partial<AppBuildManifest>): AppBuildManifest;
132
+ /**
133
+ * Replaces the app-owned manifest using config-owned loaders and explicit
134
+ * contribution input.
135
+ */
136
+ export declare function updateAppBuildManifest(appConfig: EcoPagesAppConfig, input?: Partial<AppBuildManifest>): void;
137
+ /**
138
+ * Collects the build-facing processor and integration contributions that should
139
+ * be sealed into the app manifest during config finalization.
140
+ *
141
+ * @remarks
142
+ * This runs `prepareBuildContributions()` only. Runtime-only side effects such
143
+ * as HMR registration, cache prewarming, and runtime-origin wiring belong to
144
+ * the startup path and must not be triggered here.
145
+ */
146
+ export declare function collectConfiguredAppBuildManifestContributions(appConfig: EcoPagesAppConfig): Promise<Pick<AppBuildManifest, 'runtimePlugins' | 'browserBundlePlugins'>>;
147
+ /**
148
+ * Runs runtime-only processor and integration setup against an already sealed
149
+ * app manifest.
150
+ *
151
+ * @remarks
152
+ * Startup paths call this after config build has finalized manifest
153
+ * contributions. The manifest is reused as-is; this helper only performs the
154
+ * runtime side effects that still need live startup context.
155
+ */
156
+ export declare function setupAppRuntimePlugins(options: {
157
+ appConfig: EcoPagesAppConfig;
158
+ runtimeOrigin: string;
159
+ hmrManager?: IHmrManager;
160
+ onRuntimePlugin?: (plugin: EcoBuildPlugin) => void;
161
+ }): Promise<void>;
162
+ export declare function getAppServerBuildPlugins(appConfig: EcoPagesAppConfig): EcoBuildPlugin[];
163
+ export declare function getAppBrowserBuildPlugins(appConfig: EcoPagesAppConfig): EcoBuildPlugin[];
164
+ /**
165
+ * Returns the executor owned by an app/runtime instance.
166
+ *
167
+ * @remarks
168
+ * The config builder seeds this with the shared default adapter. Runtime
169
+ * adapters may replace it with a coordinator that still delegates to the same
170
+ * backend while adding development policy.
171
+ */
172
+ export declare function getAppBuildExecutor(appConfig: EcoPagesAppConfig): BuildExecutor;
173
+ /**
174
+ * Installs the executor that should serve future builds for one app instance.
175
+ */
176
+ export declare function setAppBuildExecutor(appConfig: EcoPagesAppConfig, buildExecutor: BuildExecutor): void;
177
+ /**
178
+ * Runs a build through the active pipeline.
179
+ *
180
+ * @remarks
181
+ * Callers can pass an explicit executor when builds should be routed through an
182
+ * app-owned development coordinator. Without one, the shared default adapter is
183
+ * used directly.
184
+ */
185
+ export declare function build(options: BuildOptions, executor?: BuildExecutor): Promise<BuildResult>;
186
+ export declare function getTranspileOptions(profile: BuildTranspileProfile): BuildTranspileOptions;
@@ -1,6 +1,14 @@
1
+ import {
2
+ createAppBuildManifest,
3
+ getBrowserBuildPlugins,
4
+ getServerBuildPlugins
5
+ } from "./build-manifest.js";
1
6
  import { EsbuildBuildAdapter } from "./esbuild-build-adapter.js";
2
7
  import { getRequiredBunRuntime } from "../utils/runtime.js";
3
8
  import { EsbuildBuildAdapter as EsbuildBuildAdapter2 } from "./esbuild-build-adapter.js";
9
+ function createBuildAdapter() {
10
+ return new EsbuildBuildAdapter();
11
+ }
4
12
  function transpileProfileToOptions(profile) {
5
13
  switch (profile) {
6
14
  case "browser-script":
@@ -39,16 +47,122 @@ class BunBuildAdapter {
39
47
  resolve(importPath, rootDir) {
40
48
  return getRequiredBunRuntime().resolveSync(importPath, rootDir);
41
49
  }
42
- registerPlugin(plugin) {
43
- getRequiredBunRuntime().plugin(plugin);
44
- }
45
50
  getTranspileOptions(profile) {
46
51
  return transpileProfileToOptions(profile);
47
52
  }
48
53
  }
49
- const defaultBuildAdapter = new EsbuildBuildAdapter();
54
+ const defaultBuildAdapter = createBuildAdapter();
55
+ function getAppBuildAdapter(appConfig) {
56
+ return appConfig.runtime?.buildAdapter ?? defaultBuildAdapter;
57
+ }
58
+ function setAppBuildAdapter(appConfig, buildAdapter) {
59
+ appConfig.runtime = {
60
+ ...appConfig.runtime ?? {},
61
+ buildAdapter
62
+ };
63
+ }
64
+ function getAppBuildManifest(appConfig) {
65
+ return appConfig.runtime?.buildManifest ?? createAppBuildManifest({
66
+ loaderPlugins: Array.from(appConfig.loaders.values())
67
+ });
68
+ }
69
+ function setAppBuildManifest(appConfig, buildManifest) {
70
+ appConfig.runtime = {
71
+ ...appConfig.runtime ?? {},
72
+ buildManifest
73
+ };
74
+ }
75
+ function createConfiguredAppBuildManifest(appConfig, input) {
76
+ return createAppBuildManifest({
77
+ loaderPlugins: input?.loaderPlugins ?? Array.from(appConfig.loaders.values()),
78
+ runtimePlugins: input?.runtimePlugins,
79
+ browserBundlePlugins: input?.browserBundlePlugins
80
+ });
81
+ }
82
+ function updateAppBuildManifest(appConfig, input) {
83
+ setAppBuildManifest(appConfig, createConfiguredAppBuildManifest(appConfig, input));
84
+ }
85
+ async function collectConfiguredAppBuildManifestContributions(appConfig) {
86
+ const runtimePlugins = [];
87
+ const browserBundlePlugins = [];
88
+ for (const processor of appConfig.processors.values()) {
89
+ await processor.prepareBuildContributions();
90
+ if (processor.plugins) {
91
+ runtimePlugins.push(...processor.plugins);
92
+ }
93
+ if (processor.buildPlugins) {
94
+ browserBundlePlugins.push(...processor.buildPlugins);
95
+ }
96
+ }
97
+ for (const integration of appConfig.integrations) {
98
+ integration.setConfig(appConfig);
99
+ await integration.prepareBuildContributions();
100
+ runtimePlugins.push(...integration.plugins);
101
+ }
102
+ return {
103
+ runtimePlugins,
104
+ browserBundlePlugins
105
+ };
106
+ }
107
+ async function setupAppRuntimePlugins(options) {
108
+ for (const processor of options.appConfig.processors.values()) {
109
+ await processor.setup();
110
+ if (processor.plugins) {
111
+ for (const plugin of processor.plugins) {
112
+ options.onRuntimePlugin?.(plugin);
113
+ }
114
+ }
115
+ }
116
+ for (const integration of options.appConfig.integrations) {
117
+ integration.setConfig(options.appConfig);
118
+ integration.setRuntimeOrigin(options.runtimeOrigin);
119
+ if (options.hmrManager) {
120
+ integration.setHmrManager(options.hmrManager);
121
+ }
122
+ await integration.setup();
123
+ for (const plugin of integration.plugins) {
124
+ options.onRuntimePlugin?.(plugin);
125
+ }
126
+ }
127
+ }
128
+ function getAppServerBuildPlugins(appConfig) {
129
+ return getServerBuildPlugins(getAppBuildManifest(appConfig));
130
+ }
131
+ function getAppBrowserBuildPlugins(appConfig) {
132
+ return getBrowserBuildPlugins(getAppBuildManifest(appConfig));
133
+ }
134
+ function getAppBuildExecutor(appConfig) {
135
+ return appConfig.runtime?.buildExecutor ?? getAppBuildAdapter(appConfig);
136
+ }
137
+ function setAppBuildExecutor(appConfig, buildExecutor) {
138
+ appConfig.runtime = {
139
+ ...appConfig.runtime ?? {},
140
+ buildExecutor
141
+ };
142
+ }
143
+ function build(options, executor = defaultBuildAdapter) {
144
+ return executor.build(options);
145
+ }
146
+ function getTranspileOptions(profile) {
147
+ return defaultBuildAdapter.getTranspileOptions(profile);
148
+ }
50
149
  export {
51
150
  BunBuildAdapter,
52
151
  EsbuildBuildAdapter2 as EsbuildBuildAdapter,
53
- defaultBuildAdapter
152
+ build,
153
+ collectConfiguredAppBuildManifestContributions,
154
+ createBuildAdapter,
155
+ createConfiguredAppBuildManifest,
156
+ defaultBuildAdapter,
157
+ getAppBrowserBuildPlugins,
158
+ getAppBuildAdapter,
159
+ getAppBuildExecutor,
160
+ getAppBuildManifest,
161
+ getAppServerBuildPlugins,
162
+ getTranspileOptions,
163
+ setAppBuildAdapter,
164
+ setAppBuildExecutor,
165
+ setAppBuildManifest,
166
+ setupAppRuntimePlugins,
167
+ updateAppBuildManifest
54
168
  };
@@ -0,0 +1,27 @@
1
+ import type { EcoBuildPlugin } from './build-types.js';
2
+ export interface AppBuildManifest {
3
+ loaderPlugins: EcoBuildPlugin[];
4
+ runtimePlugins: EcoBuildPlugin[];
5
+ browserBundlePlugins: EcoBuildPlugin[];
6
+ }
7
+ /**
8
+ * Merges plugin lists while preserving first-registration precedence by name.
9
+ *
10
+ * @remarks
11
+ * Build manifests treat plugin names as stable identities. The first plugin
12
+ * with a given name wins so config-time assembly stays deterministic across
13
+ * loader, runtime, and browser buckets.
14
+ */
15
+ export declare function mergeEcoBuildPlugins(...pluginLists: Array<EcoBuildPlugin[] | undefined>): EcoBuildPlugin[];
16
+ /**
17
+ * Creates one app-owned build manifest from the supplied plugin buckets.
18
+ */
19
+ export declare function createAppBuildManifest(input?: Partial<AppBuildManifest>): AppBuildManifest;
20
+ /**
21
+ * Returns the plugin list used for server-oriented builds.
22
+ */
23
+ export declare function getServerBuildPlugins(manifest: AppBuildManifest): EcoBuildPlugin[];
24
+ /**
25
+ * Returns the plugin list used for browser-oriented builds.
26
+ */
27
+ export declare function getBrowserBuildPlugins(manifest: AppBuildManifest): EcoBuildPlugin[];
@@ -0,0 +1,30 @@
1
+ function mergeEcoBuildPlugins(...pluginLists) {
2
+ const byName = /* @__PURE__ */ new Map();
3
+ for (const plugins of pluginLists) {
4
+ for (const plugin of plugins ?? []) {
5
+ if (!byName.has(plugin.name)) {
6
+ byName.set(plugin.name, plugin);
7
+ }
8
+ }
9
+ }
10
+ return Array.from(byName.values());
11
+ }
12
+ function createAppBuildManifest(input) {
13
+ return {
14
+ loaderPlugins: mergeEcoBuildPlugins(input?.loaderPlugins),
15
+ runtimePlugins: mergeEcoBuildPlugins(input?.runtimePlugins),
16
+ browserBundlePlugins: mergeEcoBuildPlugins(input?.browserBundlePlugins)
17
+ };
18
+ }
19
+ function getServerBuildPlugins(manifest) {
20
+ return mergeEcoBuildPlugins(manifest.loaderPlugins, manifest.runtimePlugins);
21
+ }
22
+ function getBrowserBuildPlugins(manifest) {
23
+ return mergeEcoBuildPlugins(manifest.loaderPlugins, manifest.runtimePlugins, manifest.browserBundlePlugins);
24
+ }
25
+ export {
26
+ createAppBuildManifest,
27
+ getBrowserBuildPlugins,
28
+ getServerBuildPlugins,
29
+ mergeEcoBuildPlugins
30
+ };
@@ -0,0 +1,74 @@
1
+ import { type BuildAdapter, type BuildExecutor, type BuildOptions, type BuildResult, EsbuildBuildAdapter } from './build-adapter.js';
2
+ import type { EcoBuildPlugin } from './build-types.js';
3
+ export declare function withBuildExecutorPlugins(executor: BuildExecutor, getPlugins: () => EcoBuildPlugin[]): BuildExecutor;
4
+ /**
5
+ * Serialized development build coordinator for the shared esbuild adapter.
6
+ *
7
+ * The underlying adapter remains responsible for plain build execution. This
8
+ * coordinator owns the policy that must be shared across callers in dev mode:
9
+ *
10
+ * - serialized access to the shared esbuild service
11
+ * - warm-service recycling for Node-target builds
12
+ * - recovery from known esbuild worker protocol faults
13
+ *
14
+ * Unlike the previous design, the coordinator does not monkey-patch the adapter
15
+ * or install process-level fault handlers. The owning app/runtime passes this
16
+ * executor explicitly to build consumers that need coordinated development
17
+ * builds.
18
+ */
19
+ export declare class DevBuildCoordinator implements BuildExecutor {
20
+ private buildQueue;
21
+ private esbuildSessionWarm;
22
+ private esbuildModuleGeneration;
23
+ private readonly adapter;
24
+ constructor(adapter: EsbuildBuildAdapter);
25
+ /**
26
+ * Executes a build through the serialized development queue.
27
+ *
28
+ * Node-target builds recycle the warmed esbuild service between requests to
29
+ * avoid stale worker state accumulating across long-lived dev sessions.
30
+ *
31
+ * If an esbuild protocol fault is detected, the coordinator resets the queue,
32
+ * stops the corrupted service, increments the module generation, and retries
33
+ * the build once.
34
+ */
35
+ build(options: BuildOptions): Promise<BuildResult>;
36
+ /**
37
+ * Attempts recovery from a known esbuild worker protocol fault.
38
+ *
39
+ * Returns `true` only when the error matches the protocol-fault signature and
40
+ * the coordinator successfully reset its shared state.
41
+ */
42
+ recoverFromProtocolFault(error: unknown): Promise<boolean>;
43
+ /**
44
+ * Clears internal coordinator state for isolated tests.
45
+ */
46
+ resetForTests(): void;
47
+ /**
48
+ * Overrides the internal queue promise for fault-recovery tests.
49
+ */
50
+ setBuildQueueForTests(queue: Promise<void>): void;
51
+ /**
52
+ * Returns the current internal queue promise for fault-recovery tests.
53
+ */
54
+ getBuildQueueForTests(): Promise<void>;
55
+ private shouldRecycleEsbuildService;
56
+ private runSerialized;
57
+ }
58
+ /**
59
+ * Creates the appropriate build executor for one app/runtime instance.
60
+ *
61
+ * Development runtimes get a dedicated coordinator around the shared esbuild
62
+ * adapter. Non-development runtimes use the adapter directly.
63
+ */
64
+ export declare function createAppBuildExecutor(options: {
65
+ development: boolean;
66
+ adapter?: BuildAdapter;
67
+ getPlugins?: () => EcoBuildPlugin[];
68
+ }): BuildExecutor;
69
+ export declare function createOrReuseAppBuildExecutor(options: {
70
+ development: boolean;
71
+ adapter?: BuildAdapter;
72
+ currentExecutor?: BuildExecutor;
73
+ getPlugins?: () => EcoBuildPlugin[];
74
+ }): BuildExecutor;