@ecopages/core 0.2.0-alpha.7 → 0.2.0-alpha.9

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 (354) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/package.json +212 -92
  3. package/src/adapters/abstract/application-adapter.d.ts +168 -0
  4. package/src/adapters/abstract/application-adapter.js +109 -0
  5. package/src/adapters/abstract/router-adapter.d.ts +26 -0
  6. package/src/adapters/abstract/router-adapter.js +5 -0
  7. package/src/adapters/abstract/server-adapter.d.ts +69 -0
  8. package/src/adapters/abstract/server-adapter.js +15 -0
  9. package/src/adapters/bun/client-bridge.d.ts +34 -0
  10. package/src/adapters/bun/client-bridge.js +48 -0
  11. package/src/adapters/bun/create-app.d.ts +60 -0
  12. package/src/adapters/bun/create-app.js +117 -0
  13. package/src/adapters/bun/hmr-manager.d.ts +143 -0
  14. package/src/adapters/bun/hmr-manager.js +334 -0
  15. package/src/adapters/bun/index.d.ts +2 -0
  16. package/src/adapters/bun/index.js +8 -0
  17. package/src/adapters/bun/server-adapter.d.ts +155 -0
  18. package/src/adapters/bun/server-adapter.js +373 -0
  19. package/src/adapters/bun/server-lifecycle.d.ts +63 -0
  20. package/src/adapters/bun/server-lifecycle.js +92 -0
  21. package/src/adapters/index.d.ts +6 -0
  22. package/src/adapters/index.js +14 -0
  23. package/src/adapters/node/bootstrap-dependency-resolver.d.ts +44 -0
  24. package/src/adapters/node/bootstrap-dependency-resolver.js +172 -0
  25. package/src/adapters/node/create-app.d.ts +21 -0
  26. package/src/adapters/node/create-app.js +143 -0
  27. package/src/adapters/node/index.d.ts +6 -0
  28. package/src/adapters/node/index.js +11 -0
  29. package/src/adapters/node/node-client-bridge.d.ts +26 -0
  30. package/src/adapters/node/node-client-bridge.js +66 -0
  31. package/src/adapters/node/node-hmr-manager.d.ts +133 -0
  32. package/src/adapters/node/node-hmr-manager.js +312 -0
  33. package/src/adapters/node/runtime-adapter.d.ts +46 -0
  34. package/src/adapters/node/runtime-adapter.js +306 -0
  35. package/src/adapters/node/server-adapter.d.ts +161 -0
  36. package/src/adapters/node/server-adapter.js +358 -0
  37. package/src/adapters/node/static-content-server.d.ts +60 -0
  38. package/src/adapters/node/static-content-server.js +194 -0
  39. package/src/adapters/node/write-runtime-manifest.d.ts +26 -0
  40. package/src/adapters/node/write-runtime-manifest.js +12 -0
  41. package/src/adapters/shared/api-response.d.ts +52 -0
  42. package/src/adapters/shared/api-response.js +96 -0
  43. package/src/adapters/shared/application-adapter.d.ts +18 -0
  44. package/src/adapters/shared/application-adapter.js +90 -0
  45. package/src/adapters/shared/define-api-handler.d.ts +25 -0
  46. package/src/adapters/shared/define-api-handler.js +15 -0
  47. package/src/adapters/shared/explicit-static-route-matcher.d.ts +38 -0
  48. package/src/adapters/shared/explicit-static-route-matcher.js +103 -0
  49. package/src/adapters/shared/file-route-middleware-pipeline.d.ts +65 -0
  50. package/src/adapters/shared/file-route-middleware-pipeline.js +99 -0
  51. package/src/adapters/shared/fs-server-response-factory.d.ts +19 -0
  52. package/src/adapters/shared/fs-server-response-factory.js +97 -0
  53. package/src/adapters/shared/fs-server-response-matcher.d.ts +75 -0
  54. package/src/adapters/shared/fs-server-response-matcher.js +160 -0
  55. package/src/adapters/shared/hmr-entrypoint-registrar.d.ts +55 -0
  56. package/src/adapters/shared/hmr-entrypoint-registrar.js +87 -0
  57. package/src/adapters/shared/hmr-html-response.d.ts +22 -0
  58. package/src/adapters/shared/hmr-html-response.js +32 -0
  59. package/src/adapters/shared/render-context.d.ts +14 -0
  60. package/src/adapters/shared/render-context.js +70 -0
  61. package/src/adapters/shared/runtime-bootstrap.d.ts +38 -0
  62. package/src/adapters/shared/runtime-bootstrap.js +43 -0
  63. package/src/adapters/shared/server-adapter.d.ts +97 -0
  64. package/src/adapters/shared/server-adapter.js +386 -0
  65. package/src/adapters/shared/server-route-handler.d.ts +89 -0
  66. package/src/adapters/shared/server-route-handler.js +111 -0
  67. package/src/adapters/shared/server-static-builder.d.ts +70 -0
  68. package/src/adapters/shared/server-static-builder.js +99 -0
  69. package/src/build/build-adapter.d.ts +186 -0
  70. package/src/build/build-adapter.js +168 -0
  71. package/src/build/build-manifest.d.ts +27 -0
  72. package/src/build/build-manifest.js +30 -0
  73. package/src/build/build-types.d.ts +57 -0
  74. package/src/build/build-types.js +0 -0
  75. package/src/build/dev-build-coordinator.d.ts +74 -0
  76. package/src/build/dev-build-coordinator.js +161 -0
  77. package/src/build/esbuild-build-adapter.d.ts +72 -0
  78. package/src/build/esbuild-build-adapter.js +422 -0
  79. package/src/build/runtime-build-executor.d.ts +13 -0
  80. package/src/build/runtime-build-executor.js +20 -0
  81. package/src/build/runtime-specifier-alias-plugin.d.ts +15 -0
  82. package/src/build/runtime-specifier-alias-plugin.js +31 -0
  83. package/src/config/config-builder.d.ts +238 -0
  84. package/src/config/config-builder.js +565 -0
  85. package/src/constants.d.ts +45 -0
  86. package/src/constants.js +25 -0
  87. package/src/create-app.d.ts +17 -0
  88. package/src/create-app.js +66 -0
  89. package/src/dev/sc-server.d.ts +30 -0
  90. package/src/dev/sc-server.js +111 -0
  91. package/src/eco/component-render-context.d.ts +105 -0
  92. package/src/eco/component-render-context.js +87 -0
  93. package/src/eco/eco.d.ts +9 -0
  94. package/src/eco/eco.js +114 -0
  95. package/src/eco/eco.types.d.ts +178 -0
  96. package/src/eco/eco.types.js +0 -0
  97. package/src/eco/eco.utils.d.ts +40 -0
  98. package/src/eco/eco.utils.js +40 -0
  99. package/src/eco/global-injector-map.d.ts +16 -0
  100. package/src/eco/global-injector-map.js +80 -0
  101. package/src/eco/lazy-injector-map.d.ts +8 -0
  102. package/src/eco/lazy-injector-map.js +70 -0
  103. package/src/eco/module-dependencies.d.ts +18 -0
  104. package/src/eco/module-dependencies.js +49 -0
  105. package/src/errors/http-error.d.ts +31 -0
  106. package/src/errors/http-error.js +50 -0
  107. package/src/errors/index.d.ts +2 -0
  108. package/src/errors/index.js +4 -0
  109. package/src/errors/locals-access-error.d.ts +4 -0
  110. package/src/errors/locals-access-error.js +9 -0
  111. package/src/global/app-logger.d.ts +2 -0
  112. package/src/global/app-logger.js +6 -0
  113. package/src/hmr/client/hmr-runtime.d.ts +5 -0
  114. package/src/hmr/client/hmr-runtime.js +109 -0
  115. package/src/hmr/hmr-strategy.d.ts +159 -0
  116. package/src/hmr/hmr-strategy.js +29 -0
  117. package/src/hmr/hmr.postcss.test.e2e.d.ts +1 -0
  118. package/src/hmr/hmr.postcss.test.e2e.js +31 -0
  119. package/src/hmr/hmr.test.e2e.d.ts +1 -0
  120. package/src/hmr/hmr.test.e2e.js +43 -0
  121. package/src/hmr/strategies/default-hmr-strategy.d.ts +43 -0
  122. package/src/hmr/strategies/default-hmr-strategy.js +34 -0
  123. package/src/hmr/strategies/js-hmr-strategy.d.ts +139 -0
  124. package/src/hmr/strategies/js-hmr-strategy.js +178 -0
  125. package/src/index.browser.d.ts +3 -0
  126. package/src/index.browser.js +4 -0
  127. package/src/index.d.ts +5 -0
  128. package/src/index.js +10 -0
  129. package/src/integrations/ghtml/ghtml-renderer.d.ts +15 -0
  130. package/src/integrations/ghtml/ghtml-renderer.js +62 -0
  131. package/src/integrations/ghtml/ghtml.plugin.d.ts +20 -0
  132. package/src/integrations/ghtml/ghtml.plugin.js +21 -0
  133. package/src/internal-types.d.ts +221 -0
  134. package/src/internal-types.js +0 -0
  135. package/src/plugins/alias-resolver-plugin.d.ts +2 -0
  136. package/src/plugins/alias-resolver-plugin.js +53 -0
  137. package/src/plugins/eco-component-meta-plugin.d.ts +97 -0
  138. package/src/plugins/eco-component-meta-plugin.js +157 -0
  139. package/src/plugins/integration-plugin.d.ts +136 -0
  140. package/src/plugins/integration-plugin.js +133 -0
  141. package/src/plugins/processor.d.ts +95 -0
  142. package/src/plugins/processor.js +136 -0
  143. package/src/plugins/runtime-capability.d.ts +9 -0
  144. package/src/plugins/runtime-capability.js +0 -0
  145. package/src/public-types.d.ts +1149 -0
  146. package/src/public-types.js +0 -0
  147. package/src/route-renderer/component-graph/component-graph-executor.d.ts +32 -0
  148. package/src/route-renderer/component-graph/component-graph-executor.js +31 -0
  149. package/src/route-renderer/component-graph/component-graph.d.ts +42 -0
  150. package/src/route-renderer/component-graph/component-graph.js +72 -0
  151. package/src/route-renderer/component-graph/component-marker.d.ts +52 -0
  152. package/src/route-renderer/component-graph/component-marker.js +46 -0
  153. package/src/route-renderer/component-graph/component-reference.d.ts +10 -0
  154. package/src/route-renderer/component-graph/component-reference.js +19 -0
  155. package/src/route-renderer/component-graph/marker-graph-resolver.d.ts +77 -0
  156. package/src/route-renderer/component-graph/marker-graph-resolver.js +95 -0
  157. package/src/route-renderer/orchestration/integration-renderer.d.ts +372 -0
  158. package/src/route-renderer/orchestration/integration-renderer.js +589 -0
  159. package/src/route-renderer/orchestration/render-execution.service.d.ts +103 -0
  160. package/src/route-renderer/orchestration/render-execution.service.js +121 -0
  161. package/src/route-renderer/orchestration/render-preparation.service.d.ts +121 -0
  162. package/src/route-renderer/orchestration/render-preparation.service.js +332 -0
  163. package/src/route-renderer/page-loading/dependency-resolver.d.ts +35 -0
  164. package/src/route-renderer/page-loading/dependency-resolver.js +442 -0
  165. package/src/route-renderer/page-loading/page-module-loader.d.ts +87 -0
  166. package/src/route-renderer/page-loading/page-module-loader.js +124 -0
  167. package/src/route-renderer/route-renderer.d.ts +61 -0
  168. package/src/route-renderer/route-renderer.js +87 -0
  169. package/src/router/client/link-intent.js +34 -0
  170. package/src/router/client/link-intent.test.browser.d.ts +1 -0
  171. package/src/router/client/link-intent.test.browser.js +43 -0
  172. package/src/router/client/navigation-coordinator.d.ts +149 -0
  173. package/src/router/client/navigation-coordinator.js +215 -0
  174. package/src/router/server/fs-router-scanner.d.ts +41 -0
  175. package/src/router/server/fs-router-scanner.js +156 -0
  176. package/src/router/server/fs-router.d.ts +26 -0
  177. package/src/router/server/fs-router.js +100 -0
  178. package/src/services/assets/asset-processing-service/asset-processing.service.d.ts +120 -0
  179. package/src/services/assets/asset-processing-service/asset-processing.service.js +331 -0
  180. package/src/services/assets/asset-processing-service/asset.factory.d.ts +17 -0
  181. package/src/services/assets/asset-processing-service/asset.factory.js +82 -0
  182. package/src/services/assets/asset-processing-service/assets.types.d.ts +89 -0
  183. package/src/services/assets/asset-processing-service/assets.types.js +0 -0
  184. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.d.ts +55 -0
  185. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.js +48 -0
  186. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.d.ts +20 -0
  187. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.js +41 -0
  188. package/src/services/assets/asset-processing-service/index.d.ts +5 -0
  189. package/src/services/assets/asset-processing-service/index.js +5 -0
  190. package/src/services/assets/asset-processing-service/processor.interface.d.ts +22 -0
  191. package/src/services/assets/asset-processing-service/processor.interface.js +6 -0
  192. package/src/services/assets/asset-processing-service/processor.registry.d.ts +8 -0
  193. package/src/services/assets/asset-processing-service/processor.registry.js +15 -0
  194. package/src/services/assets/asset-processing-service/processors/base/base-processor.d.ts +24 -0
  195. package/src/services/assets/asset-processing-service/processors/base/base-processor.js +64 -0
  196. package/src/services/assets/asset-processing-service/processors/base/base-script-processor.d.ts +17 -0
  197. package/src/services/assets/asset-processing-service/processors/base/base-script-processor.js +72 -0
  198. package/src/services/assets/asset-processing-service/processors/index.d.ts +5 -0
  199. package/src/services/assets/asset-processing-service/processors/index.js +5 -0
  200. package/src/services/assets/asset-processing-service/processors/script/content-script.processor.d.ts +5 -0
  201. package/src/services/assets/asset-processing-service/processors/script/content-script.processor.js +57 -0
  202. package/src/services/assets/asset-processing-service/processors/script/file-script.processor.d.ts +8 -0
  203. package/src/services/assets/asset-processing-service/processors/script/file-script.processor.js +76 -0
  204. package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.d.ts +7 -0
  205. package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.js +75 -0
  206. package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.d.ts +5 -0
  207. package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.js +25 -0
  208. package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.d.ts +9 -0
  209. package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.js +66 -0
  210. package/src/services/assets/browser-bundle.service.d.ts +32 -0
  211. package/src/services/assets/browser-bundle.service.js +33 -0
  212. package/src/services/cache/cache.types.d.ts +107 -0
  213. package/src/services/cache/cache.types.js +0 -0
  214. package/src/services/cache/index.d.ts +7 -0
  215. package/src/services/cache/index.js +7 -0
  216. package/src/services/cache/memory-cache-store.d.ts +42 -0
  217. package/src/services/cache/memory-cache-store.js +98 -0
  218. package/src/services/cache/page-cache-service.d.ts +70 -0
  219. package/src/services/cache/page-cache-service.js +152 -0
  220. package/src/services/cache/page-request-cache-coordinator.service.d.ts +75 -0
  221. package/src/services/cache/page-request-cache-coordinator.service.js +109 -0
  222. package/src/services/html/html-rewriter-provider.service.d.ts +37 -0
  223. package/src/services/html/html-rewriter-provider.service.js +65 -0
  224. package/src/services/html/html-transformer.service.d.ts +77 -0
  225. package/src/services/html/html-transformer.service.js +221 -0
  226. package/src/services/invalidation/development-invalidation.service.d.ts +74 -0
  227. package/src/services/invalidation/development-invalidation.service.js +189 -0
  228. package/src/services/module-loading/app-server-module-transpiler.service.d.ts +16 -0
  229. package/src/services/module-loading/app-server-module-transpiler.service.js +34 -0
  230. package/src/services/module-loading/page-module-import.service.d.ts +71 -0
  231. package/src/services/module-loading/page-module-import.service.js +132 -0
  232. package/src/services/module-loading/server-loader.service.d.ts +96 -0
  233. package/src/services/module-loading/server-loader.service.js +32 -0
  234. package/src/services/module-loading/server-module-transpiler.service.d.ts +69 -0
  235. package/src/services/module-loading/server-module-transpiler.service.js +61 -0
  236. package/src/services/runtime-manifest/node-runtime-manifest.service.d.ts +35 -0
  237. package/src/services/runtime-manifest/node-runtime-manifest.service.js +60 -0
  238. package/src/services/runtime-state/dev-graph.service.d.ts +118 -0
  239. package/src/services/runtime-state/dev-graph.service.js +162 -0
  240. package/src/services/runtime-state/entrypoint-dependency-graph.service.d.ts +41 -0
  241. package/src/services/runtime-state/entrypoint-dependency-graph.service.js +85 -0
  242. package/src/services/runtime-state/runtime-specifier-registry.service.d.ts +69 -0
  243. package/src/services/runtime-state/runtime-specifier-registry.service.js +37 -0
  244. package/src/services/runtime-state/server-invalidation-state.service.d.ts +26 -0
  245. package/src/services/runtime-state/server-invalidation-state.service.js +35 -0
  246. package/src/services/validation/schema-validation-service.d.ts +122 -0
  247. package/src/services/validation/schema-validation-service.js +101 -0
  248. package/src/services/validation/standard-schema.types.d.ts +65 -0
  249. package/src/services/validation/standard-schema.types.js +0 -0
  250. package/src/static-site-generator/static-site-generator.d.ts +109 -0
  251. package/src/static-site-generator/static-site-generator.js +353 -0
  252. package/src/utils/css.d.ts +1 -0
  253. package/src/utils/css.js +7 -0
  254. package/src/utils/deep-merge.d.ts +14 -0
  255. package/src/utils/deep-merge.js +32 -0
  256. package/src/utils/hash.d.ts +1 -0
  257. package/src/utils/hash.js +7 -0
  258. package/src/utils/html.d.ts +1 -0
  259. package/src/utils/html.js +4 -0
  260. package/src/utils/invariant.d.ts +5 -0
  261. package/src/utils/invariant.js +11 -0
  262. package/src/utils/locals-utils.d.ts +15 -0
  263. package/src/utils/locals-utils.js +24 -0
  264. package/src/utils/parse-cli-args.d.ts +24 -0
  265. package/src/utils/parse-cli-args.js +47 -0
  266. package/src/utils/path-utils.module.d.ts +5 -0
  267. package/src/utils/path-utils.module.js +14 -0
  268. package/src/utils/resolve-work-dir.d.ts +11 -0
  269. package/src/utils/resolve-work-dir.js +31 -0
  270. package/src/utils/runtime.d.ts +11 -0
  271. package/src/utils/runtime.js +40 -0
  272. package/src/utils/server-utils.module.d.ts +19 -0
  273. package/src/utils/server-utils.module.js +56 -0
  274. package/src/watchers/project-watcher.d.ts +136 -0
  275. package/src/watchers/project-watcher.js +281 -0
  276. package/src/watchers/project-watcher.test-helpers.d.ts +4 -0
  277. package/src/watchers/project-watcher.test-helpers.js +52 -0
  278. package/src/adapters/bun/hmr-manager.test.ts +0 -267
  279. package/src/adapters/node/bootstrap-dependency-resolver.test.ts +0 -282
  280. package/src/adapters/node/node-client-bridge.test.ts +0 -198
  281. package/src/adapters/node/node-hmr-manager.test.ts +0 -322
  282. package/src/adapters/node/runtime-adapter.test.ts +0 -868
  283. package/src/adapters/node/static-content-server.test.ts +0 -60
  284. package/src/adapters/shared/api-response.test.ts +0 -97
  285. package/src/adapters/shared/explicit-static-route-matcher.test.ts +0 -381
  286. package/src/adapters/shared/file-route-middleware-pipeline.test.ts +0 -90
  287. package/src/adapters/shared/fs-server-response-factory.test.ts +0 -187
  288. package/src/adapters/shared/fs-server-response-matcher.test.ts +0 -286
  289. package/src/adapters/shared/hmr-manager.contract.test.ts +0 -196
  290. package/src/adapters/shared/hmr-manager.dispatch.test.ts +0 -220
  291. package/src/adapters/shared/render-context.test.ts +0 -146
  292. package/src/adapters/shared/server-adapter.test.ts +0 -77
  293. package/src/adapters/shared/server-route-handler.test.ts +0 -110
  294. package/src/adapters/shared/server-static-builder.test.ts +0 -316
  295. package/src/build/build-adapter-serialization.test.ts +0 -268
  296. package/src/build/build-adapter.test.ts +0 -815
  297. package/src/build/runtime-specifier-alias-plugin.test.ts +0 -43
  298. package/src/config/config-builder.test.ts +0 -410
  299. package/src/eco/eco.test.ts +0 -678
  300. package/src/eco/eco.utils.test.ts +0 -124
  301. package/src/eco/global-injector-map.test.ts +0 -42
  302. package/src/eco/lazy-injector-map.test.ts +0 -66
  303. package/src/eco/module-dependencies.test.ts +0 -30
  304. package/src/errors/http-error.test.ts +0 -134
  305. package/src/global/utils.test.ts +0 -12
  306. 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
  307. package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-HMR-Server-Integration-should-load-fixture-app-page-1.png +0 -0
  308. package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-WebSocket-Connection-should-connect-to-correct-HMR-endpoint-1.png +0 -0
  309. package/src/hmr/hmr-strategy.test.ts +0 -124
  310. package/src/hmr/strategies/js-hmr-strategy.test.ts +0 -335
  311. package/src/integrations/ghtml/ghtml-renderer.test.ts +0 -63
  312. package/src/plugins/alias-resolver-plugin.test.ts +0 -41
  313. package/src/plugins/eco-component-meta-plugin.test.ts +0 -380
  314. package/src/plugins/integration-plugin.test.ts +0 -111
  315. package/src/plugins/processor.test.ts +0 -148
  316. package/src/route-renderer/component-graph/component-graph-executor.test.ts +0 -41
  317. package/src/route-renderer/component-graph/component-graph.test.ts +0 -63
  318. package/src/route-renderer/component-graph/component-marker.test.ts +0 -73
  319. package/src/route-renderer/component-graph/marker-graph-resolver.test.ts +0 -135
  320. package/src/route-renderer/orchestration/integration-renderer.test.ts +0 -936
  321. package/src/route-renderer/orchestration/render-execution.service.test.ts +0 -97
  322. package/src/route-renderer/orchestration/render-preparation.service.test.ts +0 -235
  323. package/src/route-renderer/page-loading/dependency-resolver.test.ts +0 -345
  324. package/src/route-renderer/page-loading/page-module-loader.test.ts +0 -96
  325. package/src/router/client/navigation-coordinator.test.ts +0 -237
  326. package/src/router/server/fs-router-scanner.test.ts +0 -83
  327. package/src/router/server/fs-router.test.ts +0 -214
  328. package/src/services/assets/asset-processing-service/asset-processing.service.test.ts +0 -385
  329. package/src/services/assets/asset-processing-service/asset.factory.test.ts +0 -63
  330. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.test.ts +0 -72
  331. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.test.ts +0 -67
  332. package/src/services/assets/asset-processing-service/processors/base/base-processor.test.ts +0 -59
  333. package/src/services/assets/asset-processing-service/processors/script/file-script.processor.test.ts +0 -286
  334. package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.test.ts +0 -227
  335. package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.test.ts +0 -199
  336. package/src/services/assets/browser-bundle.service.test.ts +0 -36
  337. package/src/services/cache/memory-cache-store.test.ts +0 -225
  338. package/src/services/cache/page-cache-service.test.ts +0 -175
  339. package/src/services/cache/page-request-cache-coordinator.service.test.ts +0 -79
  340. package/src/services/html/html-rewriter-provider.service.test.ts +0 -183
  341. package/src/services/html/html-transformer.service.test.ts +0 -378
  342. package/src/services/invalidation/development-invalidation.service.test.ts +0 -77
  343. package/src/services/module-loading/page-module-import.service.test.ts +0 -253
  344. package/src/services/module-loading/server-loader.service.test.ts +0 -161
  345. package/src/services/module-loading/server-module-transpiler.service.test.ts +0 -115
  346. package/src/services/runtime-manifest/node-runtime-manifest.service.test.ts +0 -95
  347. package/src/services/validation/schema-validation-service.test.ts +0 -223
  348. package/src/static-site-generator/static-site-generator.test.ts +0 -307
  349. package/src/utils/deep-merge.test.ts +0 -114
  350. package/src/utils/invariant.test.ts +0 -22
  351. package/src/utils/path-utils.test.ts +0 -15
  352. package/src/utils/server-utils.test.ts +0 -38
  353. package/src/watchers/project-watcher.integration.test.ts +0 -337
  354. package/src/watchers/project-watcher.test.ts +0 -678
@@ -0,0 +1,178 @@
1
+ import path from "node:path";
2
+ import { fileSystem } from "@ecopages/file-system";
3
+ import { HmrStrategy, HmrStrategyType } from "../hmr-strategy";
4
+ import { appLogger } from "../../global/app-logger";
5
+ class JsHmrStrategy extends HmrStrategy {
6
+ type = HmrStrategyType.SCRIPT;
7
+ context;
8
+ constructor(context) {
9
+ super();
10
+ this.context = context;
11
+ }
12
+ /**
13
+ * Determines if the file is a JS/TS file that could affect registered entrypoints.
14
+ *
15
+ * Matches if:
16
+ * 1. There are registered entrypoints to rebuild
17
+ * 2. The changed file is a JS/TS file in the src directory
18
+ *
19
+ * @param filePath - Absolute path to the changed file
20
+ * @returns True if this file should trigger entrypoint rebuilds
21
+ */
22
+ matches(filePath) {
23
+ const watchedFiles = this.context.getWatchedFiles();
24
+ const isJsTs = /\.(ts|tsx|js|jsx)$/.test(filePath);
25
+ const isInSrc = filePath.startsWith(this.context.getSrcDir());
26
+ const isRouteTemplate = filePath.startsWith(this.context.getPagesDir()) || filePath.startsWith(this.context.getLayoutsDir());
27
+ const isIntegrationTemplate = isRouteTemplate && this.context.getTemplateExtensions().some((extension) => filePath.endsWith(extension));
28
+ if (watchedFiles.size === 0) {
29
+ return false;
30
+ }
31
+ if (!isJsTs || !isInSrc) {
32
+ return false;
33
+ }
34
+ if (isIntegrationTemplate) {
35
+ return false;
36
+ }
37
+ if (watchedFiles.has(filePath)) {
38
+ return true;
39
+ }
40
+ const entrypointDependencyGraph = this.context.getEntrypointDependencyGraph();
41
+ if (entrypointDependencyGraph.supportsSelectiveInvalidation()) {
42
+ return entrypointDependencyGraph.getDependencyEntrypoints(filePath).size > 0;
43
+ }
44
+ return true;
45
+ }
46
+ /**
47
+ * Processes a file change by rebuilding affected entrypoints.
48
+ *
49
+ * @param filePath - Absolute path to the changed file
50
+ *
51
+ * @remarks
52
+ * If runtime-specific dependency graph hooks are unavailable, this strategy
53
+ * falls back to rebuilding all watched entrypoints.
54
+ * When multiple entrypoints are impacted they are bundled in a single esbuild
55
+ * invocation to share AST parsing and chunk deduplication.
56
+ * @returns Action to broadcast update events
57
+ */
58
+ async process(filePath) {
59
+ appLogger.debug(`[JsHmrStrategy] Processing ${filePath}`);
60
+ const watchedFiles = this.context.getWatchedFiles();
61
+ if (watchedFiles.size === 0) {
62
+ appLogger.debug(`[JsHmrStrategy] No watched files to rebuild`);
63
+ return { type: "none" };
64
+ }
65
+ const dependencyHits = this.context.getEntrypointDependencyGraph().getDependencyEntrypoints(filePath);
66
+ const hasDependencyHit = dependencyHits.size > 0;
67
+ const impactedEntrypoints = hasDependencyHit ? Array.from(dependencyHits).filter((entrypoint) => watchedFiles.has(entrypoint)) : Array.from(watchedFiles.keys());
68
+ const buildableEntrypoints = impactedEntrypoints.filter(
69
+ (entrypoint) => this.context.shouldProcessEntrypoint?.(entrypoint) ?? true
70
+ );
71
+ if (!hasDependencyHit) {
72
+ appLogger.debug("[JsHmrStrategy] Dependency graph miss, rebuilding all watched entrypoints");
73
+ }
74
+ if (buildableEntrypoints.length === 0) {
75
+ return { type: "none" };
76
+ }
77
+ const buildResult = await this.bundleEntrypoints(buildableEntrypoints);
78
+ if (!buildResult.success) {
79
+ return { type: "none" };
80
+ }
81
+ const updates = [];
82
+ let reloadRequired = false;
83
+ for (const entrypoint of buildableEntrypoints) {
84
+ const outputUrl = watchedFiles.get(entrypoint);
85
+ if (!outputUrl) continue;
86
+ if (buildResult.dependencies) {
87
+ const entrypointDeps = buildResult.dependencies.get(path.resolve(entrypoint)) ?? [];
88
+ this.context.getEntrypointDependencyGraph().setEntrypointDependencies(entrypoint, entrypointDeps);
89
+ }
90
+ const srcDir = this.context.getSrcDir();
91
+ const relativePath = path.relative(srcDir, entrypoint);
92
+ const relativePathJs = relativePath.replace(/\.(tsx?|jsx?|mdx?)$/, ".js");
93
+ const outputPath = path.join(this.context.getDistDir(), relativePathJs);
94
+ const result = await this.processOutput(outputPath, outputUrl);
95
+ if (result.success) {
96
+ updates.push(outputUrl);
97
+ if (result.requiresReload) {
98
+ reloadRequired = true;
99
+ }
100
+ }
101
+ }
102
+ if (updates.length > 0) {
103
+ if (reloadRequired) {
104
+ appLogger.debug(`[JsHmrStrategy] Full reload required (no HMR accept found)`);
105
+ return {
106
+ type: "broadcast",
107
+ events: [{ type: "reload" }]
108
+ };
109
+ }
110
+ return {
111
+ type: "broadcast",
112
+ events: updates.map((p) => ({
113
+ type: "update",
114
+ path: p,
115
+ timestamp: Date.now()
116
+ }))
117
+ };
118
+ }
119
+ return { type: "none" };
120
+ }
121
+ /**
122
+ * Bundles one or more entrypoints in a single esbuild invocation.
123
+ * Uses the source directory as the output base so that the directory structure
124
+ * is preserved under the HMR dist folder.
125
+ */
126
+ async bundleEntrypoints(entrypoints) {
127
+ try {
128
+ const result = await this.context.getBrowserBundleService().bundle({
129
+ profile: "hmr-entrypoint",
130
+ entrypoints,
131
+ outdir: this.context.getDistDir(),
132
+ outbase: this.context.getSrcDir(),
133
+ naming: "[dir]/[name]",
134
+ plugins: this.context.getPlugins(),
135
+ minify: false
136
+ });
137
+ if (!result.success) {
138
+ appLogger.error("[JsHmrStrategy] Batched build failed:", result.logs);
139
+ return { success: false };
140
+ }
141
+ const dependencies = /* @__PURE__ */ new Map();
142
+ if (result.dependencyGraph?.entrypoints) {
143
+ for (const [entrypoint, deps] of Object.entries(result.dependencyGraph.entrypoints)) {
144
+ dependencies.set(path.resolve(entrypoint), deps);
145
+ }
146
+ }
147
+ return { success: true, dependencies };
148
+ } catch (error) {
149
+ appLogger.error("[JsHmrStrategy] Error in batched build:", error);
150
+ return { success: false };
151
+ }
152
+ }
153
+ /**
154
+ * Processes bundled output and determines whether the browser can hot-accept
155
+ * the update or must fall back to a full reload.
156
+ *
157
+ * @param filepath - Path to the bundled output file
158
+ * @param url - URL path for the bundled file
159
+ * @returns True if processing was successful and update should be broadcast
160
+ */
161
+ async processOutput(filepath, url) {
162
+ try {
163
+ const code = await fileSystem.readFile(filepath);
164
+ if (code.includes("/* [ecopages] hmr */")) {
165
+ return { success: true, requiresReload: !code.includes("import.meta.hot.accept") };
166
+ }
167
+ appLogger.debug(`[JsHmrStrategy] Processed ${url}`);
168
+ const hasHmrAccept = code.includes("import.meta.hot.accept");
169
+ return { success: true, requiresReload: !hasHmrAccept };
170
+ } catch (error) {
171
+ appLogger.error(`[JsHmrStrategy] Error processing output for ${url}:`, error);
172
+ return { success: false, requiresReload: false };
173
+ }
174
+ }
175
+ }
176
+ export {
177
+ JsHmrStrategy
178
+ };
@@ -0,0 +1,3 @@
1
+ export type * from './public-types.js';
2
+ export type * from './eco/eco.types.js';
3
+ export { eco } from './eco/eco.js';
@@ -0,0 +1,4 @@
1
+ import { eco } from "./eco/eco.js";
2
+ export {
3
+ eco
4
+ };
package/src/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export type * from './public-types.js';
2
+ export type * from './eco/eco.types.js';
3
+ export { eco } from './eco/eco.js';
4
+ export { EcopagesApp, createApp, type EcopagesAppOptions } from './create-app.js';
5
+ export { defineApiHandler, defineGroupHandler, type GroupHandler } from './adapters/shared/define-api-handler.js';
package/src/index.js ADDED
@@ -0,0 +1,10 @@
1
+ import { eco } from "./eco/eco.js";
2
+ import { EcopagesApp, createApp } from "./create-app.js";
3
+ import { defineApiHandler, defineGroupHandler } from "./adapters/shared/define-api-handler.js";
4
+ export {
5
+ EcopagesApp,
6
+ createApp,
7
+ defineApiHandler,
8
+ defineGroupHandler,
9
+ eco
10
+ };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * This module contains the ghtml renderer
3
+ * @module
4
+ */
5
+ import type { EcoComponent, EcoPagesElement, IntegrationRendererRenderOptions, RouteRendererBody } from '../../public-types.js';
6
+ import { IntegrationRenderer, type RenderToResponseContext } from '../../route-renderer/orchestration/integration-renderer.js';
7
+ /**
8
+ * A renderer for the ghtml integration.
9
+ * It renders a page using the HtmlTemplate and Page components.
10
+ */
11
+ export declare class GhtmlRenderer extends IntegrationRenderer<EcoPagesElement> {
12
+ name: string;
13
+ render({ params, query, props, locals, pageLocals, metadata, Page, Layout, HtmlTemplate, }: IntegrationRendererRenderOptions): Promise<RouteRendererBody>;
14
+ renderToResponse<P = Record<string, unknown>>(view: EcoComponent<P>, props: P, ctx: RenderToResponseContext): Promise<Response>;
15
+ }
@@ -0,0 +1,62 @@
1
+ import {
2
+ IntegrationRenderer
3
+ } from "../../route-renderer/orchestration/integration-renderer.js";
4
+ import { GHTML_PLUGIN_NAME } from "./ghtml.plugin.js";
5
+ class GhtmlRenderer extends IntegrationRenderer {
6
+ name = GHTML_PLUGIN_NAME;
7
+ async render({
8
+ params,
9
+ query,
10
+ props,
11
+ locals,
12
+ pageLocals,
13
+ metadata,
14
+ Page,
15
+ Layout,
16
+ HtmlTemplate
17
+ }) {
18
+ try {
19
+ const pageContent = await Page({ params, query, ...props, locals: pageLocals });
20
+ const children = Layout && typeof Layout === "function" ? await Layout({ children: pageContent, locals }) : pageContent;
21
+ const body = await HtmlTemplate({
22
+ metadata,
23
+ children,
24
+ pageProps: props || {}
25
+ });
26
+ return this.DOC_TYPE + body;
27
+ } catch (error) {
28
+ throw this.createRenderError("Error rendering page", error);
29
+ }
30
+ }
31
+ async renderToResponse(view, props, ctx) {
32
+ try {
33
+ const Layout = view.config?.layout;
34
+ const viewFn = view;
35
+ const pageContent = await viewFn(props);
36
+ let body;
37
+ if (ctx.partial) {
38
+ body = pageContent;
39
+ } else {
40
+ const children = Layout ? await Layout({ children: pageContent }) : pageContent;
41
+ const HtmlTemplate = await this.getHtmlTemplate();
42
+ const metadata = view.metadata ? await view.metadata({
43
+ params: {},
44
+ query: {},
45
+ props,
46
+ appConfig: this.appConfig
47
+ }) : this.appConfig.defaultMetadata;
48
+ body = this.DOC_TYPE + await HtmlTemplate({
49
+ metadata,
50
+ children,
51
+ pageProps: props
52
+ });
53
+ }
54
+ return this.createHtmlResponse(body, ctx);
55
+ } catch (error) {
56
+ throw this.createRenderError("Error rendering view", error);
57
+ }
58
+ }
59
+ }
60
+ export {
61
+ GhtmlRenderer
62
+ };
@@ -0,0 +1,20 @@
1
+ import { IntegrationPlugin, type IntegrationPluginConfig } from '../../plugins/integration-plugin';
2
+ import { GhtmlRenderer } from './ghtml-renderer';
3
+ /**
4
+ * The name of the ghtml plugin
5
+ */
6
+ export declare const GHTML_PLUGIN_NAME = "ghtml";
7
+ /**
8
+ * The Ghtml plugin class
9
+ * This plugin provides support for ghtml components in Ecopages
10
+ */
11
+ export declare class GhtmlPlugin extends IntegrationPlugin {
12
+ renderer: typeof GhtmlRenderer;
13
+ constructor(options?: Omit<IntegrationPluginConfig, 'name'>);
14
+ }
15
+ /**
16
+ * Factory function to create a Ghtml plugin instance
17
+ * @param options Configuration options for the Ghtml plugin
18
+ * @returns A new GhtmlPlugin instance
19
+ */
20
+ export declare function ghtmlPlugin(options?: Omit<IntegrationPluginConfig, 'name'>): GhtmlPlugin;
@@ -0,0 +1,21 @@
1
+ import { IntegrationPlugin } from "../../plugins/integration-plugin";
2
+ import { GhtmlRenderer } from "./ghtml-renderer";
3
+ const GHTML_PLUGIN_NAME = "ghtml";
4
+ class GhtmlPlugin extends IntegrationPlugin {
5
+ renderer = GhtmlRenderer;
6
+ constructor(options) {
7
+ super({
8
+ name: GHTML_PLUGIN_NAME,
9
+ extensions: [".ghtml.ts", ".ghtml.tsx", ".ghtml"],
10
+ ...options
11
+ });
12
+ }
13
+ }
14
+ function ghtmlPlugin(options) {
15
+ return new GhtmlPlugin(options);
16
+ }
17
+ export {
18
+ GHTML_PLUGIN_NAME,
19
+ GhtmlPlugin,
20
+ ghtmlPlugin
21
+ };
@@ -0,0 +1,221 @@
1
+ import type { EcoBuildPlugin } from './build/build-types.js';
2
+ import type { AppBuildManifest } from './build/build-manifest.js';
3
+ import type { BuildAdapter, BuildExecutor } from './build/build-adapter.js';
4
+ import type { IntegrationPlugin } from './plugins/integration-plugin.js';
5
+ import type { Processor } from './plugins/processor.js';
6
+ import type { PageMetadataProps } from './public-types.js';
7
+ import type { FSRouter } from './router/server/fs-router.js';
8
+ import type { CacheConfig } from './services/cache/cache.types.js';
9
+ import type { DevGraphService } from './services/runtime-state/dev-graph.service.js';
10
+ import type { EntrypointDependencyGraph } from './services/runtime-state/entrypoint-dependency-graph.service.js';
11
+ import type { NodeRuntimeManifest } from './services/runtime-manifest/node-runtime-manifest.service.js';
12
+ import type { RuntimeSpecifierRegistry } from './services/runtime-state/runtime-specifier-registry.service.js';
13
+ import type { ServerInvalidationState } from './services/runtime-state/server-invalidation-state.service.js';
14
+ import type { ServerModuleTranspiler } from './services/module-loading/server-module-transpiler.service.js';
15
+ export interface RobotsPreference {
16
+ /**
17
+ * The user agent
18
+ * If an empty array is provided, it will enable all paths for the user agent
19
+ * If a path is provided, it will disallow the path for the user agent
20
+ */
21
+ [key: string]: string[];
22
+ }
23
+ /**
24
+ * Represents the complete configuration object for EcoPages.
25
+ */
26
+ export type EcoPagesAppConfig = {
27
+ /**
28
+ * The base URL of the website, localhost or the domain
29
+ */
30
+ baseUrl: string;
31
+ /**
32
+ * The root directory of the project
33
+ * @default "."
34
+ */
35
+ rootDir: string;
36
+ /**
37
+ * The root directory of the project
38
+ * @default "src"
39
+ */
40
+ srcDir: string;
41
+ /**
42
+ * The directory where the public files are located
43
+ * @default "public"
44
+ */
45
+ publicDir: string;
46
+ /**
47
+ * The directory where the pages are located
48
+ * @default "pages"
49
+ */
50
+ pagesDir: string;
51
+ /**
52
+ * The directory where the includes templates are located
53
+ * @default "includes"
54
+ */
55
+ includesDir: string;
56
+ /**
57
+ * The directory where the layouts are located
58
+ * @default "layouts"
59
+ */
60
+ layoutsDir: string;
61
+ /**
62
+ * The directory where the output will be located
63
+ * @default "dist"
64
+ */
65
+ distDir: string;
66
+ /**
67
+ * The directory where internal runtime and build artifacts are stored.
68
+ *
69
+ * @remarks
70
+ * This directory is not intended for deployment. It owns transpiled server
71
+ * modules, runtime manifests, and processor caches so `distDir` can remain a
72
+ * clean export tree.
73
+ *
74
+ * @default ".eco"
75
+ */
76
+ workDir: string;
77
+ /**
78
+ * The templates extensions based on the integrations
79
+ */
80
+ templatesExt: string[];
81
+ /**
82
+ * The directory where the components are located
83
+ * @default "components"
84
+ */
85
+ componentsDir: string;
86
+ /**
87
+ * The robots.txt configuration
88
+ */
89
+ robotsTxt: {
90
+ /**
91
+ * The robots preferences. The key is the user agent and the value is the disallowed paths.
92
+ * @default { "*": [] }
93
+ */
94
+ preferences: RobotsPreference;
95
+ };
96
+ /** Additional paths to watch. Use this to monitor extra files. It is relative to the rootDir */
97
+ additionalWatchPaths: string[];
98
+ /**
99
+ * @default { title: 'Ecopages', description: 'Ecopages' }
100
+ */
101
+ defaultMetadata: PageMetadataProps;
102
+ /** Integrations plugins */
103
+ integrations: IntegrationPlugin[];
104
+ /** Integrations dependencies */
105
+ integrationsDependencies: IntegrationDependencyConfig[];
106
+ /** Derived Paths */
107
+ absolutePaths: {
108
+ config: string;
109
+ componentsDir: string;
110
+ distDir: string;
111
+ workDir: string;
112
+ includesDir: string;
113
+ layoutsDir: string;
114
+ pagesDir: string;
115
+ projectDir: string;
116
+ publicDir: string;
117
+ srcDir: string;
118
+ htmlTemplatePath: string;
119
+ error404TemplatePath: string;
120
+ };
121
+ /**
122
+ * The processors to be used in the app
123
+ */
124
+ processors: Map<string, Processor>;
125
+ /**
126
+ * Loaders to be used in the app, these are used to process the files when importing them
127
+ */
128
+ loaders: Map<string, EcoBuildPlugin>;
129
+ /**
130
+ * Cache configuration for ISR and page caching.
131
+ * @default { store: 'memory', defaultStrategy: 'static', enabled: true }
132
+ */
133
+ cache?: CacheConfig;
134
+ /**
135
+ * Runtime-owned services attached after config construction.
136
+ *
137
+ * These values are internal implementation details used to thread per-app
138
+ * executors and similar runtime state through the system without relying on
139
+ * process-global registries.
140
+ */
141
+ runtime?: {
142
+ buildAdapter?: BuildAdapter;
143
+ buildManifest?: AppBuildManifest;
144
+ buildExecutor?: BuildExecutor;
145
+ devGraphService?: DevGraphService;
146
+ entrypointDependencyGraph?: EntrypointDependencyGraph;
147
+ nodeRuntimeManifest?: NodeRuntimeManifest;
148
+ runtimeSpecifierRegistry?: RuntimeSpecifierRegistry;
149
+ serverInvalidationState?: ServerInvalidationState;
150
+ serverModuleTranspiler?: ServerModuleTranspiler;
151
+ };
152
+ /**
153
+ * Experimental features.
154
+ */
155
+ experimental?: {
156
+ /** Escape hatch for short-lived private toggles. No validation or IntelliSense. */
157
+ unsafe?: Record<string, unknown>;
158
+ };
159
+ };
160
+ export type IntegrationDependencyConfig = {
161
+ integration: string;
162
+ kind: 'script' | 'stylesheet';
163
+ position?: 'head' | 'body';
164
+ srcUrl: string;
165
+ filePath: string;
166
+ /** @todo inline dependencies not implemented yet */
167
+ inline?: boolean;
168
+ };
169
+ /**
170
+ * The possible kinds of a route.
171
+ */
172
+ export type RouteKind = 'exact' | 'catch-all' | 'dynamic';
173
+ /**
174
+ * Represents the result of a route match.
175
+ */
176
+ export type MatchResult = {
177
+ filePath: string;
178
+ kind: RouteKind;
179
+ pathname: string;
180
+ query?: Record<string, string>;
181
+ params?: Record<string, string | string[]>;
182
+ };
183
+ /**
184
+ * Represents a route in EcoPages.
185
+ */
186
+ export type Route = {
187
+ kind: RouteKind;
188
+ filePath: string;
189
+ pathname: string;
190
+ };
191
+ /**
192
+ * Represents the routes in EcoPages.
193
+ */
194
+ export type Routes = Record<string, Route>;
195
+ /**
196
+ * Represents the options for the file system server.
197
+ */
198
+ export type FileSystemServerOptions = {
199
+ watchMode: boolean;
200
+ port?: number | string;
201
+ };
202
+ /**
203
+ * Represents the file system server adapter.
204
+ */
205
+ export interface EcoPagesFileSystemServerAdapter<ServerInstanceOptions = unknown> {
206
+ startServer(serverOptions: ServerInstanceOptions): {
207
+ router: FSRouter;
208
+ server: unknown;
209
+ } | Promise<{
210
+ router: FSRouter;
211
+ server: unknown;
212
+ }>;
213
+ }
214
+ export interface ProcessorPlugin {
215
+ name: string;
216
+ description?: string;
217
+ setup(): Promise<void>;
218
+ process<T = unknown>(input: T): Promise<T>;
219
+ teardown?(): Promise<void>;
220
+ }
221
+ export type { ClientBridgeEvent, DefaultHmrContext, IHmrManager, IClientBridge } from './public-types.js';
File without changes
@@ -0,0 +1,2 @@
1
+ import type { EcoBuildPlugin } from '../build/build-types.js';
2
+ export declare function createAliasResolverPlugin(srcDir: string): EcoBuildPlugin;
@@ -0,0 +1,53 @@
1
+ import { existsSync, readFileSync } from "node:fs";
2
+ import path from "node:path";
3
+ const RESOLVABLE_EXTENSIONS = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".mdx", ".css", ".scss", ".sass", ".less"];
4
+ function findResolvablePath(candidate) {
5
+ if (path.extname(candidate)) {
6
+ if (existsSync(candidate)) {
7
+ return candidate;
8
+ }
9
+ }
10
+ for (const extension of RESOLVABLE_EXTENSIONS) {
11
+ const fileCandidate = `${candidate}${extension}`;
12
+ if (existsSync(fileCandidate)) {
13
+ return fileCandidate;
14
+ }
15
+ }
16
+ for (const extension of RESOLVABLE_EXTENSIONS) {
17
+ const indexCandidate = path.join(candidate, `index${extension}`);
18
+ if (existsSync(indexCandidate)) {
19
+ return indexCandidate;
20
+ }
21
+ }
22
+ return void 0;
23
+ }
24
+ function resolveAliasedBarrelTarget(resolvedPath) {
25
+ if (!path.basename(resolvedPath).startsWith("index.")) {
26
+ return resolvedPath;
27
+ }
28
+ const source = readFileSync(resolvedPath, "utf8").trim();
29
+ const match = source.match(/^export\s+\*\s+from\s+['"]([^'"]+)['"]\s*;?$/);
30
+ if (!match?.[1]?.startsWith(".")) {
31
+ return resolvedPath;
32
+ }
33
+ const target = findResolvablePath(path.resolve(path.dirname(resolvedPath), match[1]));
34
+ return target ?? resolvedPath;
35
+ }
36
+ function createAliasResolverPlugin(srcDir) {
37
+ return {
38
+ name: "ecopages-alias-resolver",
39
+ setup(build) {
40
+ build.onResolve({ filter: /^@\// }, (args) => {
41
+ const candidate = path.join(srcDir, args.path.slice(2));
42
+ const resolved = findResolvablePath(candidate);
43
+ if (resolved) {
44
+ return { path: resolveAliasedBarrelTarget(resolved) };
45
+ }
46
+ return {};
47
+ });
48
+ }
49
+ };
50
+ }
51
+ export {
52
+ createAliasResolverPlugin
53
+ };