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

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,97 @@
1
+ /**
2
+ * Bun plugin that auto-injects `__eco` metadata into EcoComponent config objects.
3
+ *
4
+ * This plugin uses AST parsing (via oxc-parser) to reliably inject the `__eco` property
5
+ * into EcoComponent config objects at import time. The injected metadata contains:
6
+ * - `dir`: The directory path of the component file (used for dependency resolution)
7
+ * - `integration`: The integration type (e.g., 'react', 'kitajs', 'ghtml', 'lit')
8
+ *
9
+ * The plugin intercepts file loading for all configured integration extensions and
10
+ * transforms component configs before they are executed.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * // Before transformation:
15
+ * export default eco.page({
16
+ * render: () => '<div>Hello</div>',
17
+ * });
18
+ *
19
+ * // After transformation:
20
+ * export default eco.page({
21
+ * __eco: { id: "<hash>", file: "/path/to/pages/index.tsx", integration: "react" },
22
+ * render: () => '<div>Hello</div>',
23
+ * });
24
+ * ```
25
+ *
26
+ * @module eco-component-meta-plugin
27
+ */
28
+ import type { EcoBuildPlugin } from '../build/build-types.js';
29
+ import type { EcoPagesAppConfig } from '../internal-types.js';
30
+ /**
31
+ * Options for creating the eco-component-meta-plugin.
32
+ */
33
+ export interface EcoComponentDirPluginOptions {
34
+ /** The EcoPages application configuration containing integration settings */
35
+ config: EcoPagesAppConfig;
36
+ }
37
+ /**
38
+ * Creates a build plugin that auto-injects `__eco` metadata into EcoComponent config objects.
39
+ *
40
+ * This plugin intercepts file loading for all integration-compatible files and:
41
+ * 1. Strips any query string from the file path (for dev mode cache-busting)
42
+ * 2. Reads the file contents
43
+ * 3. Parses the AST using oxc-parser to find injection points
44
+ * 4. Injects `__eco: { id: "...", file: "...", integration: "..." }` into config objects
45
+ * 5. Returns the transformed content with the appropriate loader
46
+ *
47
+ * Supported patterns:
48
+ * - `eco.page({ ... })` - Page component declarations
49
+ * - `eco.component({ ... })` - Reusable component declarations
50
+ * - `eco.html({ ... })` - HTML shell declarations
51
+ * - `eco.layout({ ... })` - Layout declarations
52
+ * - `Component.config = { ... }` - Config assignment pattern
53
+ * - `config: { ... }` - Config property in object literals
54
+ * - `export const config = { ... }` - Exported config declarations
55
+ *
56
+ * @param options - Plugin options containing the EcoPages config
57
+ * @returns A build plugin instance ready for registration
58
+ *
59
+ * @example
60
+ * ```typescript
61
+ * import { createEcoComponentMetaPlugin } from '@ecopages/core';
62
+ *
63
+ * const plugin = createEcoComponentMetaPlugin({ config: appConfig });
64
+ * appConfig.loaders.set(plugin.name, plugin);
65
+ * ```
66
+ */
67
+ export declare function createEcoComponentMetaPlugin(options: EcoComponentDirPluginOptions): EcoBuildPlugin;
68
+ /**
69
+ * Injects `__eco` metadata into EcoComponent config objects in file content.
70
+ *
71
+ * Uses oxc-parser for robust AST-based code analysis, which handles edge cases
72
+ * that regex-based approaches would miss (e.g., complex generics, nested objects,
73
+ * comments, string literals containing similar patterns).
74
+ *
75
+ * The injection is performed by:
76
+ * 1. Parsing the source code into an AST
77
+ * 2. Walking the AST to find all config object patterns
78
+ * 3. Collecting insertion points (sorted in reverse order to preserve positions)
79
+ * 4. Inserting the `__eco` property at each point
80
+ *
81
+ * @param contents - The source code content to transform
82
+ * @param filePath - Absolute path to the file (used to derive the directory)
83
+ * @param integration - The integration identifier for this file type
84
+ * @returns Transformed source code with `__eco` injected, or original if no patterns found
85
+ *
86
+ * @example
87
+ * ```typescript
88
+ * const result = injectEcoMeta(
89
+ * 'export default eco.page({ render: () => "<div>Hi</div>" });',
90
+ * '/app/src/pages/index.tsx',
91
+ * 'react'
92
+ * );
93
+ * // Result: 'export default eco.page({ __eco: { id: "<hash>", file: "/app/src/pages/index.tsx", integration: "react" }, render: () => "<div>Hi</div>" });'
94
+ * ```
95
+ */
96
+ export declare function injectEcoMeta(contents: string, filePath: string, integration: string): string;
97
+ export default createEcoComponentMetaPlugin;
@@ -0,0 +1,157 @@
1
+ import path from "node:path";
2
+ import { parseSync } from "oxc-parser";
3
+ import { fileSystem } from "@ecopages/file-system";
4
+ import { rapidhash } from "../utils/hash.js";
5
+ const REGEX_SPECIAL_CHARS = /[.*+?^${}()|[\]\\]/g;
6
+ const VALID_LOADER_EXTENSIONS = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx"]);
7
+ function hasValidLoaderExtension(ext) {
8
+ for (const validExt of VALID_LOADER_EXTENSIONS) {
9
+ if (ext.endsWith(validExt)) {
10
+ return true;
11
+ }
12
+ }
13
+ return false;
14
+ }
15
+ function buildExtensionToIntegrationMap(integrations) {
16
+ const mapping = [];
17
+ for (const integration of integrations) {
18
+ for (const ext of integration.extensions) {
19
+ mapping.push([ext, integration.name]);
20
+ }
21
+ }
22
+ mapping.sort((a, b) => b[0].length - a[0].length);
23
+ return mapping;
24
+ }
25
+ function detectIntegration(filePath, extensionToIntegration) {
26
+ for (const [ext, integration] of extensionToIntegration) {
27
+ if (filePath.endsWith(ext)) {
28
+ return integration;
29
+ }
30
+ }
31
+ return "ghtml";
32
+ }
33
+ function createExtensionPattern(extensions) {
34
+ if (extensions.length === 0) {
35
+ throw new Error("[eco-component-meta-plugin] No extensions configured. At least one integration is required.");
36
+ }
37
+ const uniqueExtensions = [...new Set(extensions)];
38
+ const escaped = uniqueExtensions.map((ext) => ext.replace(REGEX_SPECIAL_CHARS, "\\$&"));
39
+ return new RegExp(`(${escaped.join("|")})(\\?.*)?$`);
40
+ }
41
+ function createEcoComponentMetaPlugin(options) {
42
+ return {
43
+ name: "eco-component-meta-plugin",
44
+ setup(build) {
45
+ const allExtensions = options.config.integrations.flatMap((integration) => integration.extensions).filter(hasValidLoaderExtension);
46
+ if (allExtensions.length === 0) {
47
+ return;
48
+ }
49
+ const extensionPattern = createExtensionPattern(allExtensions);
50
+ const extensionToIntegration = buildExtensionToIntegrationMap(options.config.integrations);
51
+ build.onLoad({ filter: extensionPattern }, (args) => {
52
+ const filePath = args.path.split("?")[0];
53
+ const contents = fileSystem.readFileSync(filePath);
54
+ const integration = detectIntegration(filePath, extensionToIntegration);
55
+ const transformedContents = injectEcoMeta(contents, filePath, integration);
56
+ const ext = path.extname(filePath).slice(1);
57
+ return {
58
+ contents: transformedContents,
59
+ loader: ext || "ts"
60
+ };
61
+ });
62
+ }
63
+ };
64
+ }
65
+ function findInjectionPoints(node, insertions, injection, isInsideEcoComponent = false) {
66
+ if (!node || typeof node !== "object") return;
67
+ const n = node;
68
+ if (n.type === "CallExpression") {
69
+ const callee = n.callee;
70
+ if (callee?.type === "MemberExpression" || callee?.type === "StaticMemberExpression") {
71
+ const obj = callee.object;
72
+ const prop = callee.property;
73
+ if (obj?.type === "Identifier" && obj?.name === "eco" && (prop?.name === "page" || prop?.name === "component" || prop?.name === "html" || prop?.name === "layout")) {
74
+ const args = n.arguments;
75
+ const firstArg = args?.[0];
76
+ if (firstArg?.type === "ObjectExpression") {
77
+ const start = firstArg.start;
78
+ if (typeof start === "number") {
79
+ insertions.push({ position: start + 1, text: injection });
80
+ }
81
+ }
82
+ }
83
+ }
84
+ }
85
+ if (n.type === "AssignmentExpression") {
86
+ const left = n.left;
87
+ const right = n.right;
88
+ if (left?.type === "MemberExpression" || left?.type === "StaticMemberExpression") {
89
+ const prop = left.property;
90
+ if (prop?.name === "config" && right?.type === "ObjectExpression") {
91
+ const start = right.start;
92
+ if (typeof start === "number") {
93
+ insertions.push({ position: start + 1, text: injection });
94
+ }
95
+ }
96
+ }
97
+ }
98
+ if (n.type === "ObjectProperty" || n.type === "Property") {
99
+ const key = n.key;
100
+ const value = n.value;
101
+ if ((key?.type === "Identifier" || key?.type === "IdentifierName") && key?.name === "config" && value?.type === "ObjectExpression" && isInsideEcoComponent) {
102
+ const start = value.start;
103
+ if (typeof start === "number") {
104
+ insertions.push({ position: start + 1, text: injection });
105
+ }
106
+ }
107
+ }
108
+ let childIsInsideEcoComponent = isInsideEcoComponent;
109
+ if (n.type === "VariableDeclarator") {
110
+ const id = n.id;
111
+ const typeAnnotation = id?.typeAnnotation;
112
+ if (typeAnnotation) {
113
+ const typeStr = JSON.stringify(typeAnnotation);
114
+ if (typeStr.includes("EcoComponent")) {
115
+ childIsInsideEcoComponent = true;
116
+ }
117
+ }
118
+ }
119
+ for (const key in n) {
120
+ if (key === "start" || key === "end" || key === "type") continue;
121
+ const value = n[key];
122
+ if (Array.isArray(value)) {
123
+ for (const child of value) {
124
+ findInjectionPoints(child, insertions, injection, childIsInsideEcoComponent);
125
+ }
126
+ } else if (typeof value === "object" && value !== null) {
127
+ findInjectionPoints(value, insertions, injection, childIsInsideEcoComponent);
128
+ }
129
+ }
130
+ }
131
+ function injectEcoMeta(contents, filePath, integration) {
132
+ const result = parseSync(filePath, contents);
133
+ if (result.errors.length > 0) {
134
+ console.warn(`[eco-component-meta-plugin] Parse errors in ${filePath}:`, result.errors);
135
+ return contents;
136
+ }
137
+ const ast = result.program;
138
+ const id = rapidhash(filePath).toString(36);
139
+ const injection = ` __eco: { id: "${id}", file: "${filePath}", integration: "${integration}" },`;
140
+ const insertions = [];
141
+ findInjectionPoints(ast, insertions, injection);
142
+ if (insertions.length === 0) {
143
+ return contents;
144
+ }
145
+ insertions.sort((a, b) => b.position - a.position);
146
+ let transformed = contents;
147
+ for (const { position, text } of insertions) {
148
+ transformed = transformed.slice(0, position) + text + transformed.slice(position);
149
+ }
150
+ return transformed;
151
+ }
152
+ var eco_component_meta_plugin_default = createEcoComponentMetaPlugin;
153
+ export {
154
+ createEcoComponentMetaPlugin,
155
+ eco_component_meta_plugin_default as default,
156
+ injectEcoMeta
157
+ };
@@ -0,0 +1,136 @@
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';
8
+ import type { RuntimeCapabilityDeclaration } from './runtime-capability.js';
9
+ export type { RuntimeCapabilityDeclaration, RuntimeCapabilityTag } from './runtime-capability.js';
10
+ export declare const INTEGRATION_PLUGIN_ERRORS: {
11
+ readonly NOT_INITIALIZED_WITH_APP_CONFIG: "Plugin not initialized with app config";
12
+ readonly NOT_INITIALIZED_WITH_ASSET_SERVICE: "Plugin not initialized with asset dependency service";
13
+ };
14
+ export interface IntegrationPluginConfig {
15
+ /**
16
+ * The name of the integration plugin.
17
+ */
18
+ name: string;
19
+ /**
20
+ * The extensions that this plugin supports (e.g., ['.kita.js', '.kita.tsx']).
21
+ */
22
+ extensions: string[];
23
+ /**
24
+ * The dependencies that this plugin requires on a global level.
25
+ * These dependencies will be resolved during the setup process and injected into the global scope of the application.
26
+ * They are not specific to any particular page or component.
27
+ */
28
+ integrationDependencies?: AssetDefinition[];
29
+ /**
30
+ * The strategy to use for static building.
31
+ * - 'render': Execute component function directly (faster, efficient).
32
+ * - 'fetch': Start server and fetch URL (slower, needed for some SSR like Lit).
33
+ * @default 'render'
34
+ */
35
+ staticBuildStep?: 'render' | 'fetch';
36
+ /**
37
+ * Declares runtime-specific requirements that must be satisfied before the
38
+ * app can start with this integration enabled.
39
+ */
40
+ runtimeCapability?: RuntimeCapabilityDeclaration;
41
+ }
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
+ type RendererClass<C> = new (options: {
54
+ appConfig: EcoPagesAppConfig;
55
+ assetProcessingService: AssetProcessingService;
56
+ resolvedIntegrationDependencies: ProcessedAsset[];
57
+ runtimeOrigin: string;
58
+ }) => IntegrationRenderer<C>;
59
+ export declare abstract class IntegrationPlugin<C = EcoPagesElement> {
60
+ readonly name: string;
61
+ readonly extensions: string[];
62
+ abstract renderer: RendererClass<C>;
63
+ readonly staticBuildStep: 'render' | 'fetch';
64
+ readonly runtimeCapability?: RuntimeCapabilityDeclaration;
65
+ protected integrationDependencies: AssetDefinition[];
66
+ protected resolvedIntegrationDependencies: ProcessedAsset[];
67
+ protected options?: Record<string, unknown>;
68
+ protected appConfig?: EcoPagesAppConfig;
69
+ protected assetProcessingService?: AssetProcessingService;
70
+ protected hmrManager?: IHmrManager;
71
+ runtimeOrigin: string;
72
+ get plugins(): EcoBuildPlugin[];
73
+ constructor(config: IntegrationPluginConfig);
74
+ setConfig(appConfig: EcoPagesAppConfig): void;
75
+ setRuntimeOrigin(runtimeOrigin: string): void;
76
+ /**
77
+ * Returns an HMR strategy for this integration, if applicable.
78
+ * The strategy will be registered with the HmrManager during initialization.
79
+ *
80
+ * @returns HmrStrategy instance or undefined if no custom HMR handling needed
81
+ *
82
+ * @example
83
+ * ```typescript
84
+ * getHmrStrategy(): HmrStrategy {
85
+ * const context = this.hmrManager!.getDefaultContext();
86
+ * return new ReactHmrStrategy(context);
87
+ * }
88
+ * ```
89
+ */
90
+ getHmrStrategy?(): HmrStrategy | undefined;
91
+ /**
92
+ * Returns bare-specifier mappings that should be registered in the active
93
+ * runtime specifier registry.
94
+ *
95
+ * @remarks
96
+ * Override this when the integration owns browser runtime bundles that must
97
+ * be addressable from client-side imports through stable bare specifiers.
98
+ *
99
+ * Today these mappings are consumed by the development runtime and browser
100
+ * bundle aliasing path. They are intentionally generic enough to grow into a
101
+ * broader import-map-style facility later without moving framework-specific
102
+ * map contents into core.
103
+ */
104
+ getRuntimeSpecifierMap(): Record<string, string>;
105
+ setHmrManager(hmrManager: IHmrManager): void;
106
+ initializeAssetDefinitionService(): void;
107
+ getResolvedIntegrationDependencies(): ProcessedAsset[];
108
+ initializeRenderer(): IntegrationRenderer<C>;
109
+ /**
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.
116
+ *
117
+ * @param input Boundary metadata for the current render pass.
118
+ * @returns `true` when the boundary should be deferred; otherwise `false`.
119
+ */
120
+ shouldDeferComponentBoundary(_input: ComponentBoundaryPolicyInput): boolean;
121
+ /**
122
+ * Prepares build-facing contributions before the app build manifest is sealed.
123
+ *
124
+ * @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()`.
128
+ */
129
+ prepareBuildContributions(): Promise<void>;
130
+ /**
131
+ * Performs runtime-only integration setup after config build has already
132
+ * sealed manifest contributions.
133
+ */
134
+ setup(): Promise<void>;
135
+ teardown(): Promise<void>;
136
+ }
@@ -0,0 +1,133 @@
1
+ import { AssetProcessingService } from "../services/assets/asset-processing-service/asset-processing.service";
2
+ const INTEGRATION_PLUGIN_ERRORS = {
3
+ NOT_INITIALIZED_WITH_APP_CONFIG: "Plugin not initialized with app config",
4
+ NOT_INITIALIZED_WITH_ASSET_SERVICE: "Plugin not initialized with asset dependency service"
5
+ };
6
+ class IntegrationPlugin {
7
+ name;
8
+ extensions;
9
+ staticBuildStep;
10
+ runtimeCapability;
11
+ integrationDependencies;
12
+ resolvedIntegrationDependencies = [];
13
+ options;
14
+ appConfig;
15
+ assetProcessingService;
16
+ hmrManager;
17
+ get plugins() {
18
+ return [];
19
+ }
20
+ constructor(config) {
21
+ this.name = config.name;
22
+ this.extensions = config.extensions;
23
+ this.integrationDependencies = config.integrationDependencies || [];
24
+ this.staticBuildStep = config.staticBuildStep || "render";
25
+ this.runtimeCapability = config.runtimeCapability;
26
+ }
27
+ setConfig(appConfig) {
28
+ this.appConfig = appConfig;
29
+ this.initializeAssetDefinitionService();
30
+ }
31
+ setRuntimeOrigin(runtimeOrigin) {
32
+ this.runtimeOrigin = runtimeOrigin;
33
+ }
34
+ /**
35
+ * Returns bare-specifier mappings that should be registered in the active
36
+ * runtime specifier registry.
37
+ *
38
+ * @remarks
39
+ * Override this when the integration owns browser runtime bundles that must
40
+ * be addressable from client-side imports through stable bare specifiers.
41
+ *
42
+ * Today these mappings are consumed by the development runtime and browser
43
+ * bundle aliasing path. They are intentionally generic enough to grow into a
44
+ * broader import-map-style facility later without moving framework-specific
45
+ * map contents into core.
46
+ */
47
+ getRuntimeSpecifierMap() {
48
+ return {};
49
+ }
50
+ setHmrManager(hmrManager) {
51
+ this.hmrManager = hmrManager;
52
+ hmrManager.registerSpecifierMap(this.getRuntimeSpecifierMap());
53
+ const strategy = this.getHmrStrategy?.();
54
+ if (strategy) {
55
+ hmrManager.registerStrategy(strategy);
56
+ }
57
+ if (this.assetProcessingService) {
58
+ this.assetProcessingService.setHmrManager(hmrManager);
59
+ }
60
+ }
61
+ initializeAssetDefinitionService() {
62
+ if (!this.appConfig) throw new Error(INTEGRATION_PLUGIN_ERRORS.NOT_INITIALIZED_WITH_APP_CONFIG);
63
+ this.assetProcessingService = AssetProcessingService.createWithDefaultProcessors(this.appConfig);
64
+ if (this.hmrManager) {
65
+ this.assetProcessingService.setHmrManager(this.hmrManager);
66
+ }
67
+ }
68
+ getResolvedIntegrationDependencies() {
69
+ return this.resolvedIntegrationDependencies;
70
+ }
71
+ initializeRenderer() {
72
+ if (!this.appConfig) {
73
+ throw new Error(INTEGRATION_PLUGIN_ERRORS.NOT_INITIALIZED_WITH_APP_CONFIG);
74
+ }
75
+ const assetProcessingService = AssetProcessingService.createWithDefaultProcessors(this.appConfig);
76
+ if (this.hmrManager) {
77
+ assetProcessingService.setHmrManager(this.hmrManager);
78
+ }
79
+ const renderer = new this.renderer({
80
+ appConfig: this.appConfig,
81
+ assetProcessingService,
82
+ resolvedIntegrationDependencies: this.resolvedIntegrationDependencies,
83
+ runtimeOrigin: this.runtimeOrigin
84
+ });
85
+ if (this.hmrManager) {
86
+ renderer.setHmrManager(this.hmrManager);
87
+ }
88
+ return renderer;
89
+ }
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
+ /**
105
+ * Prepares build-facing contributions before the app build manifest is sealed.
106
+ *
107
+ * @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()`.
111
+ */
112
+ async prepareBuildContributions() {
113
+ }
114
+ /**
115
+ * Performs runtime-only integration setup after config build has already
116
+ * sealed manifest contributions.
117
+ */
118
+ async setup() {
119
+ if (this.integrationDependencies.length === 0) return;
120
+ if (!this.assetProcessingService) throw new Error(INTEGRATION_PLUGIN_ERRORS.NOT_INITIALIZED_WITH_ASSET_SERVICE);
121
+ this.resolvedIntegrationDependencies = await this.assetProcessingService.processDependencies(
122
+ this.integrationDependencies,
123
+ this.name
124
+ );
125
+ this.initializeRenderer();
126
+ }
127
+ async teardown() {
128
+ }
129
+ }
130
+ export {
131
+ INTEGRATION_PLUGIN_ERRORS,
132
+ IntegrationPlugin
133
+ };
@@ -0,0 +1,95 @@
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';
4
+ import type { RuntimeCapabilityDeclaration } from './runtime-capability.js';
5
+ export type { RuntimeCapabilityDeclaration, RuntimeCapabilityTag } from './runtime-capability.js';
6
+ export declare const PROCESSOR_ERRORS: {
7
+ readonly CACHE_DIRECTORY_NOT_SET: "Cache directory not set in context";
8
+ };
9
+ export interface ProcessorWatchContext {
10
+ path: string;
11
+ bridge: IClientBridge;
12
+ }
13
+ export interface ProcessorWatchConfig {
14
+ paths: string[];
15
+ extensions?: string[];
16
+ onCreate?: (ctx: ProcessorWatchContext) => Promise<void>;
17
+ onChange?: (ctx: ProcessorWatchContext) => Promise<void>;
18
+ onDelete?: (ctx: ProcessorWatchContext) => Promise<void>;
19
+ onError?: (error: Error) => void;
20
+ }
21
+ export type ProcessorAssetKind = 'script' | 'stylesheet' | 'image';
22
+ export type ProcessorExtensionPattern = string;
23
+ export interface ProcessorAssetCapability {
24
+ kind: ProcessorAssetKind;
25
+ /**
26
+ * Supported patterns:
27
+ * - `*` (all extensions)
28
+ * - `.css` or `css`
29
+ * - `*.css`
30
+ * - `*.{css,scss,sass}`
31
+ *
32
+ * Pattern matching is case-insensitive and trims surrounding spaces,
33
+ * including grouped values (e.g. `*.{ CSS, ScSs }`).
34
+ */
35
+ extensions?: ProcessorExtensionPattern[];
36
+ }
37
+ export interface ProcessorConfig<TOptions = Record<string, unknown>> {
38
+ name: string;
39
+ description?: string;
40
+ options?: TOptions;
41
+ watch?: ProcessorWatchConfig;
42
+ capabilities?: ProcessorAssetCapability[];
43
+ runtimeCapability?: RuntimeCapabilityDeclaration;
44
+ }
45
+ export interface ProcessorContext {
46
+ config: EcoPagesAppConfig;
47
+ rootDir: string;
48
+ srcDir: string;
49
+ distDir: string;
50
+ cache?: string;
51
+ }
52
+ /**
53
+ * Interface for processor build plugins
54
+ * This is used to pass plugins to the build process directly from the processor
55
+ * For instance it can become very handy when dealing with virtual modules that needs to be recognized by the bundler
56
+ * i.e. @ecopages/image-processor
57
+ */
58
+ export declare abstract class Processor<TOptions = Record<string, unknown>> {
59
+ readonly name: string;
60
+ protected dependencies: AssetDefinition[];
61
+ protected context?: ProcessorContext;
62
+ protected options?: TOptions;
63
+ protected watchConfig?: ProcessorWatchConfig;
64
+ protected capabilities: ProcessorAssetCapability[];
65
+ readonly runtimeCapability?: RuntimeCapabilityDeclaration;
66
+ /** Plugins that are only used during the build process */
67
+ abstract buildPlugins?: EcoBuildPlugin[];
68
+ /** Plugins that are used during runtime for file processing */
69
+ abstract plugins?: EcoBuildPlugin[];
70
+ constructor(config: ProcessorConfig<TOptions>);
71
+ setContext(appConfig: EcoPagesAppConfig): void;
72
+ /**
73
+ * Prepares build-facing processor contributions before config finalization.
74
+ *
75
+ * @remarks
76
+ * Override this when a processor must compute runtime/build plugins or other
77
+ * manifest-owned state before startup. Runtime-only work such as cache
78
+ * warming or watcher registration should stay in `setup()`.
79
+ */
80
+ prepareBuildContributions(): Promise<void>;
81
+ abstract setup(): Promise<void>;
82
+ abstract teardown(): Promise<void>;
83
+ abstract process(input: unknown, filePath?: string): Promise<unknown>;
84
+ protected getCachePath(key: string): string;
85
+ protected readCache<T>(key: string): Promise<T | null>;
86
+ protected writeCache<T>(key: string, data: T): Promise<void>;
87
+ getWatchConfig(): ProcessorWatchConfig | undefined;
88
+ getDependencies(): AssetDefinition[];
89
+ getName(): string;
90
+ getAssetCapabilities(): ProcessorAssetCapability[];
91
+ matchesFileFilter(_filepath: string): boolean;
92
+ canProcessAsset(kind: ProcessorAssetKind, filepath?: string): boolean;
93
+ private matchesCapabilityExtensions;
94
+ private normalizeExtensionPattern;
95
+ }