@ecopages/core 0.2.0-alpha.9 → 0.2.1

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 (357) hide show
  1. package/CHANGELOG.md +18 -11
  2. package/README.md +23 -26
  3. package/package.json +76 -58
  4. package/src/adapters/README.md +2 -2
  5. package/src/adapters/abstract/application-adapter.d.ts +28 -2
  6. package/src/adapters/abstract/application-adapter.js +14 -2
  7. package/src/adapters/abstract/router-adapter.d.ts +1 -1
  8. package/src/adapters/abstract/server-adapter.d.ts +2 -2
  9. package/src/adapters/bun/client-bridge.d.ts +1 -1
  10. package/src/adapters/bun/create-app.d.ts +4 -12
  11. package/src/adapters/bun/create-app.js +4 -5
  12. package/src/adapters/bun/hmr-manager.d.ts +4 -4
  13. package/src/adapters/bun/hmr-manager.js +8 -8
  14. package/src/adapters/bun/index.d.ts +1 -1
  15. package/src/adapters/bun/index.js +2 -2
  16. package/src/adapters/bun/server-adapter.d.ts +5 -5
  17. package/src/adapters/bun/server-adapter.js +6 -5
  18. package/src/adapters/bun/server-lifecycle.d.ts +4 -4
  19. package/src/adapters/bun/server-lifecycle.js +2 -2
  20. package/src/{create-app.d.ts → adapters/create-app.d.ts} +9 -6
  21. package/src/{create-app.js → adapters/create-app.js} +4 -4
  22. package/src/adapters/index.d.ts +1 -5
  23. package/src/adapters/index.js +1 -7
  24. package/src/adapters/node/create-app.d.ts +6 -9
  25. package/src/adapters/node/create-app.js +12 -6
  26. package/src/adapters/node/node-client-bridge.d.ts +1 -1
  27. package/src/adapters/node/node-hmr-manager.d.ts +2 -2
  28. package/src/adapters/node/node-hmr-manager.js +3 -3
  29. package/src/adapters/node/server-adapter.d.ts +4 -4
  30. package/src/adapters/node/server-adapter.js +13 -12
  31. package/src/adapters/node/static-content-server.d.ts +1 -1
  32. package/src/adapters/node/static-content-server.js +1 -1
  33. package/src/adapters/shared/application-adapter.d.ts +1 -1
  34. package/src/adapters/shared/define-api-handler.d.ts +1 -1
  35. package/src/adapters/shared/explicit-static-route-matcher.d.ts +2 -2
  36. package/src/adapters/shared/file-route-middleware-pipeline.d.ts +1 -1
  37. package/src/adapters/shared/fs-server-response-factory.d.ts +2 -2
  38. package/src/adapters/shared/fs-server-response-factory.js +1 -1
  39. package/src/adapters/shared/fs-server-response-matcher.d.ts +1 -1
  40. package/src/adapters/shared/hmr-entrypoint-registrar.js +1 -1
  41. package/src/adapters/shared/hmr-html-response.d.ts +1 -1
  42. package/src/adapters/shared/render-context.d.ts +2 -1
  43. package/src/adapters/shared/render-context.js +3 -1
  44. package/src/adapters/shared/runtime-bootstrap.d.ts +1 -1
  45. package/src/adapters/shared/runtime-bootstrap.js +1 -1
  46. package/src/adapters/shared/server-adapter.d.ts +1 -1
  47. package/src/adapters/shared/server-adapter.js +5 -1
  48. package/src/adapters/shared/server-route-handler.d.ts +4 -4
  49. package/src/adapters/shared/server-route-handler.js +3 -3
  50. package/src/adapters/shared/server-static-builder.d.ts +5 -5
  51. package/src/adapters/shared/server-static-builder.js +5 -4
  52. package/src/build/README.md +19 -13
  53. package/src/build/build-adapter.d.ts +67 -20
  54. package/src/build/build-adapter.js +420 -19
  55. package/src/build/dev-build-coordinator.d.ts +10 -12
  56. package/src/build/dev-build-coordinator.js +8 -15
  57. package/src/build/esbuild-build-adapter.d.ts +6 -0
  58. package/src/build/esbuild-build-adapter.js +94 -11
  59. package/src/build/runtime-build-executor.d.ts +5 -4
  60. package/src/build/runtime-build-executor.js +5 -3
  61. package/src/build/runtime-specifier-alias-plugin.js +19 -15
  62. package/src/build/runtime-specifier-aliases.d.ts +5 -0
  63. package/src/build/runtime-specifier-aliases.js +95 -0
  64. package/src/config/README.md +5 -2
  65. package/src/config/config-builder.d.ts +25 -2
  66. package/src/config/config-builder.js +44 -7
  67. package/src/declarations.d.ts +1 -1
  68. package/src/dev/sc-server.d.ts +1 -1
  69. package/src/dev/sc-server.js +1 -1
  70. package/src/eco/eco.browser.d.ts +2 -0
  71. package/src/eco/eco.browser.js +83 -0
  72. package/src/eco/eco.js +19 -48
  73. package/src/eco/eco.types.d.ts +1 -1
  74. package/src/eco/eco.utils.d.ts +1 -40
  75. package/src/eco/eco.utils.js +5 -35
  76. package/src/eco/global-injector-map.d.ts +1 -1
  77. package/src/eco/lazy-injector-map.d.ts +1 -1
  78. package/src/hmr/hmr-strategy.d.ts +16 -13
  79. package/src/hmr/hmr-strategy.js +22 -7
  80. package/src/hmr/strategies/default-hmr-strategy.d.ts +2 -2
  81. package/src/hmr/strategies/default-hmr-strategy.js +1 -1
  82. package/src/hmr/strategies/js-hmr-strategy.d.ts +2 -2
  83. package/src/hmr/strategies/js-hmr-strategy.js +2 -2
  84. package/src/index.browser.d.ts +2 -2
  85. package/src/index.browser.js +1 -1
  86. package/src/index.d.ts +3 -2
  87. package/src/index.js +15 -4
  88. package/src/integrations/ghtml/ghtml-renderer.d.ts +6 -1
  89. package/src/integrations/ghtml/ghtml-renderer.js +29 -28
  90. package/src/integrations/ghtml/ghtml.plugin.d.ts +2 -2
  91. package/src/integrations/ghtml/ghtml.plugin.js +2 -2
  92. package/src/plugins/README.md +1 -0
  93. package/src/plugins/eco-component-meta-plugin.d.ts +12 -1
  94. package/src/plugins/eco-component-meta-plugin.js +26 -20
  95. package/src/plugins/foreign-jsx-override-plugin.d.ts +31 -0
  96. package/src/plugins/foreign-jsx-override-plugin.js +35 -0
  97. package/src/plugins/integration-plugin.d.ts +99 -33
  98. package/src/plugins/integration-plugin.js +68 -21
  99. package/src/plugins/processor.d.ts +2 -2
  100. package/src/plugins/processor.js +2 -2
  101. package/src/plugins/source-transform.d.ts +46 -0
  102. package/src/plugins/source-transform.js +71 -0
  103. package/src/route-renderer/GRAPH.md +54 -84
  104. package/src/route-renderer/README.md +14 -20
  105. package/src/route-renderer/orchestration/component-render-context.d.ts +83 -0
  106. package/src/route-renderer/orchestration/component-render-context.js +147 -0
  107. package/src/route-renderer/orchestration/integration-renderer.d.ts +233 -76
  108. package/src/route-renderer/orchestration/integration-renderer.js +500 -143
  109. package/src/route-renderer/orchestration/queued-boundary-runtime.service.d.ts +93 -0
  110. package/src/route-renderer/orchestration/queued-boundary-runtime.service.js +155 -0
  111. package/src/route-renderer/orchestration/render-execution.service.d.ts +11 -71
  112. package/src/route-renderer/orchestration/render-execution.service.js +65 -80
  113. package/src/{eco/eco.utils.ts → route-renderer/orchestration/render-output.utils.d.ts} +10 -53
  114. package/src/route-renderer/orchestration/render-output.utils.js +65 -0
  115. package/src/route-renderer/orchestration/render-preparation.service.d.ts +2 -8
  116. package/src/route-renderer/orchestration/render-preparation.service.js +10 -17
  117. package/src/route-renderer/orchestration/template-serialization.d.ts +38 -0
  118. package/src/route-renderer/orchestration/template-serialization.js +45 -0
  119. package/src/route-renderer/page-loading/dependency-resolver.d.ts +2 -2
  120. package/src/route-renderer/page-loading/dependency-resolver.js +10 -8
  121. package/src/route-renderer/page-loading/page-module-loader.d.ts +6 -4
  122. package/src/route-renderer/page-loading/page-module-loader.js +7 -5
  123. package/src/route-renderer/route-renderer.d.ts +5 -3
  124. package/src/route-renderer/route-renderer.js +13 -3
  125. package/src/router/README.md +79 -8
  126. package/src/router/client/navigation-coordinator.js +2 -2
  127. package/src/router/server/fs-router-scanner.d.ts +1 -1
  128. package/src/router/server/fs-router-scanner.js +6 -1
  129. package/src/router/server/fs-router.d.ts +1 -1
  130. package/src/services/assets/asset-processing-service/asset-processing.service.d.ts +3 -3
  131. package/src/services/assets/asset-processing-service/asset-processing.service.js +6 -6
  132. package/src/services/assets/asset-processing-service/asset.factory.d.ts +1 -1
  133. package/src/services/assets/asset-processing-service/asset.factory.js +2 -2
  134. package/src/services/assets/asset-processing-service/index.d.ts +5 -5
  135. package/src/services/assets/asset-processing-service/index.js +5 -5
  136. package/src/services/assets/asset-processing-service/processor.interface.d.ts +2 -2
  137. package/src/services/assets/asset-processing-service/processor.registry.d.ts +2 -2
  138. package/src/services/assets/asset-processing-service/processors/base/base-processor.d.ts +1 -1
  139. package/src/services/assets/asset-processing-service/processors/base/base-processor.js +1 -1
  140. package/src/services/assets/asset-processing-service/processors/base/base-script-processor.d.ts +3 -3
  141. package/src/services/assets/asset-processing-service/processors/base/base-script-processor.js +2 -2
  142. package/src/services/assets/asset-processing-service/processors/index.d.ts +5 -5
  143. package/src/services/assets/asset-processing-service/processors/index.js +5 -5
  144. package/src/services/assets/asset-processing-service/processors/script/content-script.processor.d.ts +2 -2
  145. package/src/services/assets/asset-processing-service/processors/script/content-script.processor.js +1 -1
  146. package/src/services/assets/asset-processing-service/processors/script/file-script.processor.d.ts +4 -3
  147. package/src/services/assets/asset-processing-service/processors/script/file-script.processor.js +15 -3
  148. package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.d.ts +3 -3
  149. package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.js +1 -1
  150. package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.d.ts +2 -2
  151. package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.js +1 -1
  152. package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.d.ts +2 -2
  153. package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.js +1 -1
  154. package/src/services/assets/browser-bundle.service.d.ts +1 -1
  155. package/src/services/assets/browser-bundle.service.js +2 -2
  156. package/src/services/html/html-rewriter-provider.service.js +4 -1
  157. package/src/services/html/html-transformer.service.d.ts +2 -2
  158. package/src/services/html/html-transformer.service.js +4 -10
  159. package/src/services/invalidation/development-invalidation.service.d.ts +1 -1
  160. package/src/services/invalidation/development-invalidation.service.js +1 -0
  161. package/src/services/module-loading/app-module-loader.service.d.ts +25 -0
  162. package/src/services/module-loading/app-module-loader.service.js +31 -0
  163. package/src/services/module-loading/app-server-module-transpiler.service.d.ts +9 -1
  164. package/src/services/module-loading/app-server-module-transpiler.service.js +77 -2
  165. package/src/services/module-loading/host-module-loader-registry.d.ts +4 -0
  166. package/src/services/module-loading/host-module-loader-registry.js +15 -0
  167. package/src/services/module-loading/module-loading-types.d.ts +2 -0
  168. package/src/{adapters/node/bootstrap-dependency-resolver.d.ts → services/module-loading/node-bootstrap-plugin.d.ts} +2 -24
  169. package/src/{adapters/node/bootstrap-dependency-resolver.js → services/module-loading/node-bootstrap-plugin.js} +42 -22
  170. package/src/services/module-loading/page-module-import.service.d.ts +4 -0
  171. package/src/services/module-loading/page-module-import.service.js +38 -9
  172. package/src/services/module-loading/server-module-transpiler.service.d.ts +3 -0
  173. package/src/services/module-loading/server-module-transpiler.service.js +4 -1
  174. package/src/services/runtime-state/dev-graph.service.d.ts +6 -6
  175. package/src/services/runtime-state/dev-graph.service.js +10 -10
  176. package/src/services/runtime-state/entrypoint-dependency-graph.service.d.ts +1 -1
  177. package/src/services/runtime-state/runtime-specifier-registry.service.d.ts +1 -1
  178. package/src/services/runtime-state/server-invalidation-state.service.d.ts +1 -1
  179. package/src/static-site-generator/static-site-generator.d.ts +2 -2
  180. package/src/static-site-generator/static-site-generator.js +1 -1
  181. package/src/{internal-types.d.ts → types/internal-types.d.ts} +24 -14
  182. package/src/{public-types.d.ts → types/public-types.d.ts} +30 -14
  183. package/src/types/public-types.js +0 -0
  184. package/src/utils/html-escaping.d.ts +7 -0
  185. package/src/utils/html-escaping.js +6 -0
  186. package/src/utils/locals-utils.d.ts +1 -1
  187. package/src/utils/parse-cli-args.d.ts +4 -1
  188. package/src/utils/parse-cli-args.js +16 -1
  189. package/src/utils/resolve-work-dir.js +1 -1
  190. package/src/watchers/project-watcher.d.ts +4 -4
  191. package/src/watchers/project-watcher.js +4 -10
  192. package/src/watchers/project-watcher.test-helpers.d.ts +2 -2
  193. package/src/adapters/abstract/application-adapter.ts +0 -337
  194. package/src/adapters/abstract/router-adapter.ts +0 -30
  195. package/src/adapters/abstract/server-adapter.ts +0 -79
  196. package/src/adapters/bun/client-bridge.ts +0 -62
  197. package/src/adapters/bun/create-app.ts +0 -189
  198. package/src/adapters/bun/hmr-manager.ts +0 -409
  199. package/src/adapters/bun/index.ts +0 -2
  200. package/src/adapters/bun/server-adapter.ts +0 -499
  201. package/src/adapters/bun/server-lifecycle.ts +0 -124
  202. package/src/adapters/index.ts +0 -6
  203. package/src/adapters/node/bootstrap-dependency-resolver.ts +0 -301
  204. package/src/adapters/node/create-app.ts +0 -179
  205. package/src/adapters/node/index.d.ts +0 -6
  206. package/src/adapters/node/index.js +0 -11
  207. package/src/adapters/node/index.ts +0 -16
  208. package/src/adapters/node/node-client-bridge.ts +0 -79
  209. package/src/adapters/node/node-hmr-manager.ts +0 -381
  210. package/src/adapters/node/runtime-adapter.d.ts +0 -46
  211. package/src/adapters/node/runtime-adapter.js +0 -306
  212. package/src/adapters/node/runtime-adapter.ts +0 -439
  213. package/src/adapters/node/server-adapter.ts +0 -488
  214. package/src/adapters/node/static-content-server.ts +0 -239
  215. package/src/adapters/node/write-runtime-manifest.d.ts +0 -26
  216. package/src/adapters/node/write-runtime-manifest.js +0 -12
  217. package/src/adapters/node/write-runtime-manifest.ts +0 -38
  218. package/src/adapters/shared/api-response.ts +0 -104
  219. package/src/adapters/shared/application-adapter.ts +0 -199
  220. package/src/adapters/shared/define-api-handler.ts +0 -66
  221. package/src/adapters/shared/explicit-static-route-matcher.ts +0 -140
  222. package/src/adapters/shared/file-route-middleware-pipeline.ts +0 -127
  223. package/src/adapters/shared/fs-server-response-factory.ts +0 -118
  224. package/src/adapters/shared/fs-server-response-matcher.ts +0 -205
  225. package/src/adapters/shared/hmr-entrypoint-registrar.ts +0 -149
  226. package/src/adapters/shared/hmr-html-response.ts +0 -52
  227. package/src/adapters/shared/render-context.ts +0 -120
  228. package/src/adapters/shared/runtime-bootstrap.ts +0 -79
  229. package/src/adapters/shared/server-adapter.ts +0 -489
  230. package/src/adapters/shared/server-route-handler.ts +0 -153
  231. package/src/adapters/shared/server-static-builder.ts +0 -166
  232. package/src/build/build-adapter.ts +0 -361
  233. package/src/build/build-manifest.ts +0 -54
  234. package/src/build/build-types.ts +0 -83
  235. package/src/build/dev-build-coordinator.ts +0 -221
  236. package/src/build/esbuild-build-adapter.ts +0 -559
  237. package/src/build/runtime-build-executor.ts +0 -34
  238. package/src/build/runtime-specifier-alias-plugin.ts +0 -58
  239. package/src/config/config-builder.ts +0 -706
  240. package/src/constants.ts +0 -54
  241. package/src/create-app.ts +0 -87
  242. package/src/dev/sc-server.ts +0 -143
  243. package/src/eco/component-render-context.d.ts +0 -105
  244. package/src/eco/component-render-context.js +0 -87
  245. package/src/eco/component-render-context.ts +0 -224
  246. package/src/eco/eco.ts +0 -242
  247. package/src/eco/eco.types.ts +0 -221
  248. package/src/eco/global-injector-map.ts +0 -112
  249. package/src/eco/lazy-injector-map.ts +0 -120
  250. package/src/eco/module-dependencies.ts +0 -75
  251. package/src/errors/http-error.ts +0 -72
  252. package/src/errors/index.ts +0 -2
  253. package/src/errors/locals-access-error.ts +0 -7
  254. package/src/global/app-logger.ts +0 -4
  255. package/src/hmr/client/hmr-runtime.ts +0 -152
  256. package/src/hmr/hmr-strategy.ts +0 -172
  257. package/src/hmr/hmr.postcss.test.e2e.ts +0 -41
  258. package/src/hmr/hmr.test.e2e.ts +0 -66
  259. package/src/hmr/strategies/default-hmr-strategy.ts +0 -60
  260. package/src/hmr/strategies/js-hmr-strategy.ts +0 -320
  261. package/src/index.browser.ts +0 -3
  262. package/src/index.ts +0 -5
  263. package/src/integrations/ghtml/ghtml-renderer.ts +0 -96
  264. package/src/integrations/ghtml/ghtml.plugin.ts +0 -32
  265. package/src/internal-types.ts +0 -232
  266. package/src/plugins/alias-resolver-plugin.ts +0 -63
  267. package/src/plugins/eco-component-meta-plugin.ts +0 -481
  268. package/src/plugins/integration-plugin.ts +0 -226
  269. package/src/plugins/processor.ts +0 -240
  270. package/src/plugins/runtime-capability.ts +0 -14
  271. package/src/public-types.ts +0 -1317
  272. package/src/route-renderer/component-graph/component-graph-executor.d.ts +0 -32
  273. package/src/route-renderer/component-graph/component-graph-executor.js +0 -31
  274. package/src/route-renderer/component-graph/component-graph-executor.ts +0 -84
  275. package/src/route-renderer/component-graph/component-graph.d.ts +0 -42
  276. package/src/route-renderer/component-graph/component-graph.js +0 -72
  277. package/src/route-renderer/component-graph/component-graph.ts +0 -159
  278. package/src/route-renderer/component-graph/component-marker.d.ts +0 -52
  279. package/src/route-renderer/component-graph/component-marker.js +0 -46
  280. package/src/route-renderer/component-graph/component-marker.ts +0 -117
  281. package/src/route-renderer/component-graph/component-reference.d.ts +0 -10
  282. package/src/route-renderer/component-graph/component-reference.js +0 -19
  283. package/src/route-renderer/component-graph/component-reference.ts +0 -29
  284. package/src/route-renderer/component-graph/marker-graph-resolver.d.ts +0 -77
  285. package/src/route-renderer/component-graph/marker-graph-resolver.js +0 -95
  286. package/src/route-renderer/component-graph/marker-graph-resolver.ts +0 -155
  287. package/src/route-renderer/orchestration/integration-renderer.ts +0 -790
  288. package/src/route-renderer/orchestration/render-execution.service.ts +0 -230
  289. package/src/route-renderer/orchestration/render-preparation.service.ts +0 -476
  290. package/src/route-renderer/page-loading/dependency-resolver.ts +0 -612
  291. package/src/route-renderer/page-loading/page-module-loader.ts +0 -181
  292. package/src/route-renderer/route-renderer.ts +0 -115
  293. package/src/router/client/link-intent.test.browser.ts +0 -51
  294. package/src/router/client/link-intent.ts +0 -92
  295. package/src/router/client/navigation-coordinator.ts +0 -433
  296. package/src/router/server/fs-router-scanner.ts +0 -219
  297. package/src/router/server/fs-router.ts +0 -122
  298. package/src/services/assets/asset-processing-service/asset-processing.service.ts +0 -401
  299. package/src/services/assets/asset-processing-service/asset.factory.ts +0 -105
  300. package/src/services/assets/asset-processing-service/assets.types.ts +0 -113
  301. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.ts +0 -95
  302. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.ts +0 -78
  303. package/src/services/assets/asset-processing-service/index.ts +0 -5
  304. package/src/services/assets/asset-processing-service/processor.interface.ts +0 -27
  305. package/src/services/assets/asset-processing-service/processor.registry.ts +0 -18
  306. package/src/services/assets/asset-processing-service/processors/base/base-processor.ts +0 -82
  307. package/src/services/assets/asset-processing-service/processors/base/base-script-processor.ts +0 -95
  308. package/src/services/assets/asset-processing-service/processors/index.ts +0 -5
  309. package/src/services/assets/asset-processing-service/processors/script/content-script.processor.ts +0 -66
  310. package/src/services/assets/asset-processing-service/processors/script/file-script.processor.ts +0 -88
  311. package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.ts +0 -85
  312. package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.ts +0 -27
  313. package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.ts +0 -80
  314. package/src/services/assets/browser-bundle.service.ts +0 -53
  315. package/src/services/cache/cache.types.ts +0 -126
  316. package/src/services/cache/index.ts +0 -18
  317. package/src/services/cache/memory-cache-store.ts +0 -130
  318. package/src/services/cache/page-cache-service.ts +0 -202
  319. package/src/services/cache/page-request-cache-coordinator.service.ts +0 -131
  320. package/src/services/html/html-rewriter-provider.service.ts +0 -103
  321. package/src/services/html/html-transformer.service.ts +0 -279
  322. package/src/services/invalidation/development-invalidation.service.ts +0 -261
  323. package/src/services/module-loading/app-server-module-transpiler.service.ts +0 -52
  324. package/src/services/module-loading/page-module-import.service.ts +0 -200
  325. package/src/services/module-loading/server-loader.service.d.ts +0 -96
  326. package/src/services/module-loading/server-loader.service.js +0 -32
  327. package/src/services/module-loading/server-loader.service.ts +0 -130
  328. package/src/services/module-loading/server-module-transpiler.service.ts +0 -105
  329. package/src/services/runtime-manifest/node-runtime-manifest.service.d.ts +0 -35
  330. package/src/services/runtime-manifest/node-runtime-manifest.service.js +0 -60
  331. package/src/services/runtime-manifest/node-runtime-manifest.service.ts +0 -101
  332. package/src/services/runtime-state/dev-graph.service.ts +0 -217
  333. package/src/services/runtime-state/entrypoint-dependency-graph.service.ts +0 -136
  334. package/src/services/runtime-state/runtime-specifier-registry.service.ts +0 -96
  335. package/src/services/runtime-state/server-invalidation-state.service.ts +0 -68
  336. package/src/services/validation/schema-validation-service.ts +0 -204
  337. package/src/services/validation/standard-schema.types.ts +0 -68
  338. package/src/static-site-generator/static-site-generator.ts +0 -462
  339. package/src/utils/css.d.ts +0 -1
  340. package/src/utils/css.js +0 -7
  341. package/src/utils/css.ts +0 -5
  342. package/src/utils/deep-merge.ts +0 -47
  343. package/src/utils/hash.ts +0 -5
  344. package/src/utils/html.ts +0 -1
  345. package/src/utils/invariant.ts +0 -15
  346. package/src/utils/locals-utils.ts +0 -37
  347. package/src/utils/parse-cli-args.ts +0 -83
  348. package/src/utils/path-utils.module.ts +0 -14
  349. package/src/utils/resolve-work-dir.ts +0 -45
  350. package/src/utils/runtime.ts +0 -44
  351. package/src/utils/server-utils.module.ts +0 -67
  352. package/src/watchers/project-watcher.test-helpers.ts +0 -41
  353. package/src/watchers/project-watcher.ts +0 -363
  354. /package/src/{constants.d.ts → config/constants.d.ts} +0 -0
  355. /package/src/{constants.js → config/constants.js} +0 -0
  356. /package/src/{internal-types.js → services/module-loading/module-loading-types.js} +0 -0
  357. /package/src/{public-types.js → types/internal-types.js} +0 -0
@@ -0,0 +1,31 @@
1
+ import type { EcoBuildPlugin } from '../build/build-types.js';
2
+ /**
3
+ * Options for the shared foreign-JSX override build plugin.
4
+ */
5
+ export interface ForeignJsxOverrideOptions {
6
+ /** JSX runtime that should own the transformed foreign files. */
7
+ hostJsxImportSource: string;
8
+ /** Extensions claimed by other JSX integrations that may appear in the host graph. */
9
+ foreignExtensions: string[];
10
+ /** Optional plugin name override for debug output. */
11
+ name?: string;
12
+ }
13
+ /**
14
+ * Build plugin that prepends a `@jsxImportSource` pragma to foreign integration
15
+ * files bundled into a host integration's client graph.
16
+ *
17
+ * When a host integration (e.g. React) bundles a component file that belongs to
18
+ * another JSX integration (e.g. `.kita.tsx`), that file inherits the project
19
+ * `tsconfig` JSX runtime which produces the wrong output (HTML strings instead
20
+ * of framework elements). This plugin rewrites the source to explicitly target
21
+ * the host's JSX factory so esbuild compiles every JSX expression into the
22
+ * correct element creation calls.
23
+ *
24
+ * The plugin is intentionally framework-agnostic: any integration that does
25
+ * client-side bundling can use it by passing its own `jsxImportSource` and the
26
+ * set of foreign extensions collected from the app config.
27
+ *
28
+ * When no JSX-bearing foreign extensions are present, the returned plugin is a
29
+ * no-op so integrations can register it unconditionally.
30
+ */
31
+ export declare function createForeignJsxOverridePlugin(options: ForeignJsxOverrideOptions): EcoBuildPlugin;
@@ -0,0 +1,35 @@
1
+ import { readFileSync } from "node:fs";
2
+ import path from "node:path";
3
+ function createForeignJsxOverridePlugin(options) {
4
+ const extensions = options.foreignExtensions.filter((ext) => ext.endsWith(".tsx") || ext.endsWith(".jsx"));
5
+ if (extensions.length === 0) {
6
+ return {
7
+ name: options.name ?? "foreign-jsx-override",
8
+ setup() {
9
+ }
10
+ };
11
+ }
12
+ const pragma = `/** @jsxImportSource ${options.hostJsxImportSource} */
13
+ `;
14
+ const filter = new RegExp(`(${extensions.map((e) => e.replace(".", "\\.")).join("|")})$`);
15
+ return {
16
+ name: options.name ?? "foreign-jsx-override",
17
+ setup(build) {
18
+ build.onLoad({ filter }, (args) => {
19
+ const source = readFileSync(args.path, "utf-8");
20
+ const loader = args.path.endsWith(".jsx") ? "jsx" : "tsx";
21
+ if (source.includes("@jsxImportSource")) {
22
+ return void 0;
23
+ }
24
+ return {
25
+ contents: pragma + source,
26
+ loader,
27
+ resolveDir: path.dirname(args.path)
28
+ };
29
+ });
30
+ }
31
+ };
32
+ }
33
+ export {
34
+ createForeignJsxOverridePlugin
35
+ };
@@ -1,16 +1,24 @@
1
- import type { EcoBuildPlugin } from '../build/build-types';
2
- import type { EcoPagesAppConfig, IHmrManager } from '../internal-types';
3
- import type { HmrStrategy } from '../hmr/hmr-strategy';
4
- import type { EcoComponent, EcoPagesElement } from '../public-types';
5
- import type { IntegrationRenderer } from '../route-renderer/orchestration/integration-renderer';
6
- import { AssetProcessingService } from '../services/assets/asset-processing-service/asset-processing.service';
7
- import type { AssetDefinition, ProcessedAsset } from '../services/assets/asset-processing-service/assets.types';
1
+ import type { EcoBuildPlugin } from '../build/build-types.js';
2
+ import type { EcoPagesAppConfig, IHmrManager } from '../types/internal-types.js';
3
+ import type { HmrStrategy } from '../hmr/hmr-strategy.js';
4
+ import type { EcoPagesElement } from '../types/public-types.js';
5
+ import type { IntegrationRenderer } from '../route-renderer/orchestration/integration-renderer.js';
6
+ import { AssetProcessingService } from '../services/assets/asset-processing-service/asset-processing.service.js';
7
+ import type { AssetDefinition, ProcessedAsset } from '../services/assets/asset-processing-service/assets.types.js';
8
8
  import type { RuntimeCapabilityDeclaration } from './runtime-capability.js';
9
9
  export type { RuntimeCapabilityDeclaration, RuntimeCapabilityTag } from './runtime-capability.js';
10
10
  export declare const INTEGRATION_PLUGIN_ERRORS: {
11
11
  readonly NOT_INITIALIZED_WITH_APP_CONFIG: "Plugin not initialized with app config";
12
12
  readonly NOT_INITIALIZED_WITH_ASSET_SERVICE: "Plugin not initialized with asset dependency service";
13
13
  };
14
+ /**
15
+ * Base configuration shared by all integration plugins.
16
+ *
17
+ * @remarks
18
+ * Integrations declare their file ownership, optional runtime requirements, and
19
+ * any global assets or build-time contributions here. Runtime-only side effects
20
+ * belong in `setup()` rather than the constructor.
21
+ */
14
22
  export interface IntegrationPluginConfig {
15
23
  /**
16
24
  * The name of the integration plugin.
@@ -38,30 +46,43 @@ export interface IntegrationPluginConfig {
38
46
  * app can start with this integration enabled.
39
47
  */
40
48
  runtimeCapability?: RuntimeCapabilityDeclaration;
49
+ /**
50
+ * JSX import source owned by this integration.
51
+ *
52
+ * @remarks
53
+ * This is primarily used by mixed-JSX flows where host-owned browser bundles
54
+ * need to preserve the correct JSX runtime for files claimed by the
55
+ * integration.
56
+ */
57
+ jsxImportSource?: string;
41
58
  }
42
- /**
43
- * Metadata used by integration-owned boundary policy.
44
- *
45
- * This payload describes the currently active integration pass together with the
46
- * target component boundary being entered.
47
- */
48
- export type ComponentBoundaryPolicyInput = {
49
- currentIntegration: string;
50
- targetIntegration?: string;
51
- component: EcoComponent;
52
- };
53
59
  type RendererClass<C> = new (options: {
54
60
  appConfig: EcoPagesAppConfig;
55
61
  assetProcessingService: AssetProcessingService;
56
62
  resolvedIntegrationDependencies: ProcessedAsset[];
63
+ rendererModules?: unknown;
57
64
  runtimeOrigin: string;
58
65
  }) => IntegrationRenderer<C>;
66
+ /**
67
+ * Base class for framework integrations.
68
+ *
69
+ * @remarks
70
+ * An integration owns three main concerns:
71
+ * - which file extensions it claims
72
+ * - which renderer class turns those files into HTML
73
+ * - which build-time or runtime contributions must be registered for that framework
74
+ *
75
+ * Core owns lifecycle ordering. Integrations declare contributions through the
76
+ * hooks on this class, while `ConfigBuilder.build()` and app startup decide when
77
+ * those hooks run.
78
+ */
59
79
  export declare abstract class IntegrationPlugin<C = EcoPagesElement> {
60
80
  readonly name: string;
61
81
  readonly extensions: string[];
62
82
  abstract renderer: RendererClass<C>;
63
83
  readonly staticBuildStep: 'render' | 'fetch';
64
84
  readonly runtimeCapability?: RuntimeCapabilityDeclaration;
85
+ readonly jsxImportSource?: string;
65
86
  protected integrationDependencies: AssetDefinition[];
66
87
  protected resolvedIntegrationDependencies: ProcessedAsset[];
67
88
  protected options?: Record<string, unknown>;
@@ -70,8 +91,33 @@ export declare abstract class IntegrationPlugin<C = EcoPagesElement> {
70
91
  protected hmrManager?: IHmrManager;
71
92
  runtimeOrigin: string;
72
93
  get plugins(): EcoBuildPlugin[];
94
+ /**
95
+ * Returns build plugins that should only apply to browser-oriented bundles.
96
+ *
97
+ * @remarks
98
+ * Browser-only transforms such as runtime import aliasing belong here so they
99
+ * do not affect server bundles or static-page module generation.
100
+ */
101
+ get browserBuildPlugins(): EcoBuildPlugin[];
102
+ /**
103
+ * Creates the integration with static declaration-only configuration.
104
+ *
105
+ * @remarks
106
+ * Constructors are expected to stay side-effect free. Build-manifest
107
+ * contributions belong in `prepareBuildContributions()` and runtime-only setup
108
+ * belongs in `setup()`.
109
+ */
73
110
  constructor(config: IntegrationPluginConfig);
111
+ /**
112
+ * Attaches the finalized app config to the integration.
113
+ *
114
+ * Core calls this during config finalization before runtime setup so the
115
+ * integration can resolve asset paths and other app-owned services later.
116
+ */
74
117
  setConfig(appConfig: EcoPagesAppConfig): void;
118
+ /**
119
+ * Records the runtime origin used for page-module loading and renderer setup.
120
+ */
75
121
  setRuntimeOrigin(runtimeOrigin: string): void;
76
122
  /**
77
123
  * Returns an HMR strategy for this integration, if applicable.
@@ -93,8 +139,8 @@ export declare abstract class IntegrationPlugin<C = EcoPagesElement> {
93
139
  * runtime specifier registry.
94
140
  *
95
141
  * @remarks
96
- * Override this when the integration owns browser runtime bundles that must
97
- * be addressable from client-side imports through stable bare specifiers.
142
+ * Integrations that own browser runtime bundles can override this to expose
143
+ * stable bare specifiers for client-side imports.
98
144
  *
99
145
  * Today these mappings are consumed by the development runtime and browser
100
146
  * bundle aliasing path. They are intentionally generic enough to grow into a
@@ -102,29 +148,41 @@ export declare abstract class IntegrationPlugin<C = EcoPagesElement> {
102
148
  * map contents into core.
103
149
  */
104
150
  getRuntimeSpecifierMap(): Record<string, string>;
151
+ /**
152
+ * Attaches the shared HMR manager and registers integration-owned development hooks.
153
+ *
154
+ * @remarks
155
+ * The default implementation registers both runtime bare-specifier mappings and
156
+ * the optional integration HMR strategy. Integrations should override this only
157
+ * when they need to extend that shared behavior rather than replace it.
158
+ */
105
159
  setHmrManager(hmrManager: IHmrManager): void;
160
+ /**
161
+ * Creates the asset-processing service used for global integration dependencies.
162
+ */
106
163
  initializeAssetDefinitionService(): void;
164
+ /**
165
+ * Returns processed global assets resolved during `setup()`.
166
+ */
107
167
  getResolvedIntegrationDependencies(): ProcessedAsset[];
108
- initializeRenderer(): IntegrationRenderer<C>;
109
168
  /**
110
- * Declares whether a component boundary targeting this integration should be
111
- * deferred through the marker pipeline.
112
- *
113
- * The default implementation never defers. Integrations that require deferred
114
- * subtree rendering should override this method and return `true` when their
115
- * boundary must be resolved during the marker graph stage.
169
+ * Instantiates the integration renderer with app-owned services.
116
170
  *
117
- * @param input Boundary metadata for the current render pass.
118
- * @returns `true` when the boundary should be deferred; otherwise `false`.
171
+ * @remarks
172
+ * Renderers are cheap runtime objects. They receive the finalized app config,
173
+ * a fresh asset-processing service, integration-global processed assets, and
174
+ * any renderer module context supplied by the active runtime.
119
175
  */
120
- shouldDeferComponentBoundary(_input: ComponentBoundaryPolicyInput): boolean;
176
+ initializeRenderer(options?: {
177
+ rendererModules?: unknown;
178
+ }): IntegrationRenderer<C>;
121
179
  /**
122
180
  * Prepares build-facing contributions before the app build manifest is sealed.
123
181
  *
124
182
  * @remarks
125
- * Override this when an integration needs to materialize runtime/build plugin
126
- * declarations ahead of runtime startup. Keep runtime-only side effects out of
127
- * this hook; they belong in `setup()`.
183
+ * Integrations can override this when runtime or build plugin declarations must
184
+ * be materialized ahead of runtime startup. Runtime-only side effects stay in
185
+ * `setup()`.
128
186
  */
129
187
  prepareBuildContributions(): Promise<void>;
130
188
  /**
@@ -132,5 +190,13 @@ export declare abstract class IntegrationPlugin<C = EcoPagesElement> {
132
190
  * sealed manifest contributions.
133
191
  */
134
192
  setup(): Promise<void>;
193
+ /**
194
+ * Releases runtime resources owned by the integration.
195
+ *
196
+ * @remarks
197
+ * Most integrations do not need custom teardown. Override this only for
198
+ * explicit cleanup such as watchers, compiler handles, or runtime registries
199
+ * that outlive individual requests.
200
+ */
135
201
  teardown(): Promise<void>;
136
202
  }
@@ -1,4 +1,4 @@
1
- import { AssetProcessingService } from "../services/assets/asset-processing-service/asset-processing.service";
1
+ import { AssetProcessingService } from "../services/assets/asset-processing-service/asset-processing.service.js";
2
2
  const INTEGRATION_PLUGIN_ERRORS = {
3
3
  NOT_INITIALIZED_WITH_APP_CONFIG: "Plugin not initialized with app config",
4
4
  NOT_INITIALIZED_WITH_ASSET_SERVICE: "Plugin not initialized with asset dependency service"
@@ -8,6 +8,7 @@ class IntegrationPlugin {
8
8
  extensions;
9
9
  staticBuildStep;
10
10
  runtimeCapability;
11
+ jsxImportSource;
11
12
  integrationDependencies;
12
13
  resolvedIntegrationDependencies = [];
13
14
  options;
@@ -17,17 +18,45 @@ class IntegrationPlugin {
17
18
  get plugins() {
18
19
  return [];
19
20
  }
21
+ /**
22
+ * Returns build plugins that should only apply to browser-oriented bundles.
23
+ *
24
+ * @remarks
25
+ * Browser-only transforms such as runtime import aliasing belong here so they
26
+ * do not affect server bundles or static-page module generation.
27
+ */
28
+ get browserBuildPlugins() {
29
+ return [];
30
+ }
31
+ /**
32
+ * Creates the integration with static declaration-only configuration.
33
+ *
34
+ * @remarks
35
+ * Constructors are expected to stay side-effect free. Build-manifest
36
+ * contributions belong in `prepareBuildContributions()` and runtime-only setup
37
+ * belongs in `setup()`.
38
+ */
20
39
  constructor(config) {
21
40
  this.name = config.name;
22
41
  this.extensions = config.extensions;
23
42
  this.integrationDependencies = config.integrationDependencies || [];
24
43
  this.staticBuildStep = config.staticBuildStep || "render";
25
44
  this.runtimeCapability = config.runtimeCapability;
45
+ this.jsxImportSource = config.jsxImportSource;
26
46
  }
47
+ /**
48
+ * Attaches the finalized app config to the integration.
49
+ *
50
+ * Core calls this during config finalization before runtime setup so the
51
+ * integration can resolve asset paths and other app-owned services later.
52
+ */
27
53
  setConfig(appConfig) {
28
54
  this.appConfig = appConfig;
29
55
  this.initializeAssetDefinitionService();
30
56
  }
57
+ /**
58
+ * Records the runtime origin used for page-module loading and renderer setup.
59
+ */
31
60
  setRuntimeOrigin(runtimeOrigin) {
32
61
  this.runtimeOrigin = runtimeOrigin;
33
62
  }
@@ -36,8 +65,8 @@ class IntegrationPlugin {
36
65
  * runtime specifier registry.
37
66
  *
38
67
  * @remarks
39
- * Override this when the integration owns browser runtime bundles that must
40
- * be addressable from client-side imports through stable bare specifiers.
68
+ * Integrations that own browser runtime bundles can override this to expose
69
+ * stable bare specifiers for client-side imports.
41
70
  *
42
71
  * Today these mappings are consumed by the development runtime and browser
43
72
  * bundle aliasing path. They are intentionally generic enough to grow into a
@@ -47,6 +76,14 @@ class IntegrationPlugin {
47
76
  getRuntimeSpecifierMap() {
48
77
  return {};
49
78
  }
79
+ /**
80
+ * Attaches the shared HMR manager and registers integration-owned development hooks.
81
+ *
82
+ * @remarks
83
+ * The default implementation registers both runtime bare-specifier mappings and
84
+ * the optional integration HMR strategy. Integrations should override this only
85
+ * when they need to extend that shared behavior rather than replace it.
86
+ */
50
87
  setHmrManager(hmrManager) {
51
88
  this.hmrManager = hmrManager;
52
89
  hmrManager.registerSpecifierMap(this.getRuntimeSpecifierMap());
@@ -58,6 +95,9 @@ class IntegrationPlugin {
58
95
  this.assetProcessingService.setHmrManager(hmrManager);
59
96
  }
60
97
  }
98
+ /**
99
+ * Creates the asset-processing service used for global integration dependencies.
100
+ */
61
101
  initializeAssetDefinitionService() {
62
102
  if (!this.appConfig) throw new Error(INTEGRATION_PLUGIN_ERRORS.NOT_INITIALIZED_WITH_APP_CONFIG);
63
103
  this.assetProcessingService = AssetProcessingService.createWithDefaultProcessors(this.appConfig);
@@ -65,10 +105,21 @@ class IntegrationPlugin {
65
105
  this.assetProcessingService.setHmrManager(this.hmrManager);
66
106
  }
67
107
  }
108
+ /**
109
+ * Returns processed global assets resolved during `setup()`.
110
+ */
68
111
  getResolvedIntegrationDependencies() {
69
112
  return this.resolvedIntegrationDependencies;
70
113
  }
71
- initializeRenderer() {
114
+ /**
115
+ * Instantiates the integration renderer with app-owned services.
116
+ *
117
+ * @remarks
118
+ * Renderers are cheap runtime objects. They receive the finalized app config,
119
+ * a fresh asset-processing service, integration-global processed assets, and
120
+ * any renderer module context supplied by the active runtime.
121
+ */
122
+ initializeRenderer(options) {
72
123
  if (!this.appConfig) {
73
124
  throw new Error(INTEGRATION_PLUGIN_ERRORS.NOT_INITIALIZED_WITH_APP_CONFIG);
74
125
  }
@@ -80,34 +131,22 @@ class IntegrationPlugin {
80
131
  appConfig: this.appConfig,
81
132
  assetProcessingService,
82
133
  resolvedIntegrationDependencies: this.resolvedIntegrationDependencies,
134
+ rendererModules: options?.rendererModules,
83
135
  runtimeOrigin: this.runtimeOrigin
84
136
  });
137
+ renderer.name ||= this.name;
85
138
  if (this.hmrManager) {
86
139
  renderer.setHmrManager(this.hmrManager);
87
140
  }
88
141
  return renderer;
89
142
  }
90
- /**
91
- * Declares whether a component boundary targeting this integration should be
92
- * deferred through the marker pipeline.
93
- *
94
- * The default implementation never defers. Integrations that require deferred
95
- * subtree rendering should override this method and return `true` when their
96
- * boundary must be resolved during the marker graph stage.
97
- *
98
- * @param input Boundary metadata for the current render pass.
99
- * @returns `true` when the boundary should be deferred; otherwise `false`.
100
- */
101
- shouldDeferComponentBoundary(_input) {
102
- return false;
103
- }
104
143
  /**
105
144
  * Prepares build-facing contributions before the app build manifest is sealed.
106
145
  *
107
146
  * @remarks
108
- * Override this when an integration needs to materialize runtime/build plugin
109
- * declarations ahead of runtime startup. Keep runtime-only side effects out of
110
- * this hook; they belong in `setup()`.
147
+ * Integrations can override this when runtime or build plugin declarations must
148
+ * be materialized ahead of runtime startup. Runtime-only side effects stay in
149
+ * `setup()`.
111
150
  */
112
151
  async prepareBuildContributions() {
113
152
  }
@@ -124,6 +163,14 @@ class IntegrationPlugin {
124
163
  );
125
164
  this.initializeRenderer();
126
165
  }
166
+ /**
167
+ * Releases runtime resources owned by the integration.
168
+ *
169
+ * @remarks
170
+ * Most integrations do not need custom teardown. Override this only for
171
+ * explicit cleanup such as watchers, compiler handles, or runtime registries
172
+ * that outlive individual requests.
173
+ */
127
174
  async teardown() {
128
175
  }
129
176
  }
@@ -1,6 +1,6 @@
1
1
  import type { EcoBuildPlugin } from '../build/build-types.js';
2
- import type { EcoPagesAppConfig, IClientBridge } from '../internal-types';
3
- import type { AssetDefinition } from '../services/assets/asset-processing-service';
2
+ import type { EcoPagesAppConfig, IClientBridge } from '../types/internal-types.js';
3
+ import type { AssetDefinition } from '../services/assets/asset-processing-service/assets.types.js';
4
4
  import type { RuntimeCapabilityDeclaration } from './runtime-capability.js';
5
5
  export type { RuntimeCapabilityDeclaration, RuntimeCapabilityTag } from './runtime-capability.js';
6
6
  export declare const PROCESSOR_ERRORS: {
@@ -1,7 +1,7 @@
1
1
  import path from "node:path";
2
2
  import { fileSystem } from "@ecopages/file-system";
3
- import { DEFAULT_ECOPAGES_WORK_DIR } from "../constants.js";
4
- import { GENERATED_BASE_PATHS } from "../constants";
3
+ import { DEFAULT_ECOPAGES_WORK_DIR } from "../config/constants.js";
4
+ import { GENERATED_BASE_PATHS } from "../config/constants.js";
5
5
  const PROCESSOR_ERRORS = {
6
6
  CACHE_DIRECTORY_NOT_SET: "Cache directory not set in context"
7
7
  };
@@ -0,0 +1,46 @@
1
+ import type { EcoBuildPlugin } from '../build/build-types.js';
2
+ import type { EcoPagesAppConfig } from '../types/internal-types.js';
3
+ export interface EcoSourceTransformResult {
4
+ code: string;
5
+ map?: unknown;
6
+ }
7
+ export interface EcoSourceTransform {
8
+ name: string;
9
+ filter: RegExp;
10
+ enforce?: 'pre' | 'post';
11
+ transform(code: string, id: string): EcoSourceTransformResult | string | undefined;
12
+ }
13
+ export interface EcoViteCompatiblePlugin {
14
+ name: string;
15
+ enforce?: 'pre' | 'post';
16
+ transform(code: string, id: string): EcoSourceTransformResult | string | undefined;
17
+ }
18
+ /**
19
+ * Normalizes bundler module ids so one transform can serve Ecopages loaders,
20
+ * Vite, and future bundler adapters.
21
+ */
22
+ export declare function normalizeTransformId(id: string): string;
23
+ /**
24
+ * Applies one source transform if the normalized id matches its filter.
25
+ */
26
+ export declare function applySourceTransform(transform: EcoSourceTransform, code: string, id: string): EcoSourceTransformResult | string | undefined;
27
+ /**
28
+ * Adapts a source transform into the existing Ecopages build-plugin contract.
29
+ */
30
+ export declare function createEcoBuildPluginFromSourceTransform(transform: EcoSourceTransform): EcoBuildPlugin;
31
+ /**
32
+ * Adapts a source transform into a Vite-compatible plugin object.
33
+ *
34
+ * @remarks
35
+ * This intentionally returns a plain object shape so core does not need a hard
36
+ * dependency on `vite` just to author transform primitives.
37
+ */
38
+ export declare function createVitePluginFromSourceTransform(transform: EcoSourceTransform): EcoViteCompatiblePlugin;
39
+ /**
40
+ * Returns the app-owned source transforms in stable registration order.
41
+ */
42
+ export declare function getAppSourceTransforms(appConfig: EcoPagesAppConfig): EcoSourceTransform[];
43
+ /**
44
+ * Adapts the app-owned source transforms into Vite-compatible plugin objects.
45
+ */
46
+ export declare function createVitePluginsFromAppSourceTransforms(appConfig: EcoPagesAppConfig): EcoViteCompatiblePlugin[];
@@ -0,0 +1,71 @@
1
+ import path from "node:path";
2
+ import { fileSystem } from "@ecopages/file-system";
3
+ function normalizeTransformId(id) {
4
+ const queryIndex = id.indexOf("?");
5
+ const hashIndex = id.indexOf("#");
6
+ const endIndex = [queryIndex, hashIndex].filter((index) => index >= 0).sort((left, right) => left - right)[0];
7
+ return endIndex === void 0 ? id : id.slice(0, endIndex);
8
+ }
9
+ function applySourceTransform(transform, code, id) {
10
+ const normalizedId = normalizeTransformId(id);
11
+ if (!transform.filter.test(normalizedId)) {
12
+ return void 0;
13
+ }
14
+ return transform.transform(code, normalizedId);
15
+ }
16
+ function inferLoaderFromPath(filePath) {
17
+ const extension = path.extname(filePath).toLowerCase();
18
+ switch (extension) {
19
+ case ".ts":
20
+ return "ts";
21
+ case ".tsx":
22
+ return "tsx";
23
+ case ".jsx":
24
+ return "jsx";
25
+ default:
26
+ return "js";
27
+ }
28
+ }
29
+ function createEcoBuildPluginFromSourceTransform(transform) {
30
+ return {
31
+ name: transform.name,
32
+ setup(build) {
33
+ build.onLoad({ filter: transform.filter }, (args) => {
34
+ const filePath = normalizeTransformId(args.path);
35
+ const code = fileSystem.readFileSync(filePath);
36
+ const result = applySourceTransform(transform, code, filePath);
37
+ if (!result) {
38
+ return void 0;
39
+ }
40
+ return {
41
+ contents: typeof result === "string" ? result : result.code,
42
+ loader: inferLoaderFromPath(filePath),
43
+ resolveDir: path.dirname(filePath)
44
+ };
45
+ });
46
+ }
47
+ };
48
+ }
49
+ function createVitePluginFromSourceTransform(transform) {
50
+ return {
51
+ name: transform.name,
52
+ enforce: transform.enforce,
53
+ transform(code, id) {
54
+ return applySourceTransform(transform, code, id);
55
+ }
56
+ };
57
+ }
58
+ function getAppSourceTransforms(appConfig) {
59
+ return Array.from(appConfig.sourceTransforms.values());
60
+ }
61
+ function createVitePluginsFromAppSourceTransforms(appConfig) {
62
+ return getAppSourceTransforms(appConfig).map((transform) => createVitePluginFromSourceTransform(transform));
63
+ }
64
+ export {
65
+ applySourceTransform,
66
+ createEcoBuildPluginFromSourceTransform,
67
+ createVitePluginFromSourceTransform,
68
+ createVitePluginsFromAppSourceTransforms,
69
+ getAppSourceTransforms,
70
+ normalizeTransformId
71
+ };