@ecopages/core 0.2.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (342) hide show
  1. package/CHANGELOG.md +89 -0
  2. package/LICENSE +21 -0
  3. package/README.md +32 -0
  4. package/package.json +279 -0
  5. package/src/adapters/abstract/application-adapter.d.ts +168 -0
  6. package/src/adapters/abstract/application-adapter.js +109 -0
  7. package/src/adapters/abstract/application-adapter.ts +337 -0
  8. package/src/adapters/abstract/router-adapter.d.ts +26 -0
  9. package/src/adapters/abstract/router-adapter.js +5 -0
  10. package/src/adapters/abstract/router-adapter.ts +30 -0
  11. package/src/adapters/abstract/server-adapter.d.ts +69 -0
  12. package/src/adapters/abstract/server-adapter.js +15 -0
  13. package/src/adapters/abstract/server-adapter.ts +79 -0
  14. package/src/adapters/bun/client-bridge.d.ts +34 -0
  15. package/src/adapters/bun/client-bridge.js +48 -0
  16. package/src/adapters/bun/client-bridge.ts +62 -0
  17. package/src/adapters/bun/create-app.d.ts +60 -0
  18. package/src/adapters/bun/create-app.js +117 -0
  19. package/src/adapters/bun/create-app.ts +189 -0
  20. package/src/adapters/bun/define-api-handler.d.ts +61 -0
  21. package/src/adapters/bun/define-api-handler.js +15 -0
  22. package/src/adapters/bun/define-api-handler.ts +114 -0
  23. package/src/adapters/bun/hmr-manager.d.ts +84 -0
  24. package/src/adapters/bun/hmr-manager.js +227 -0
  25. package/src/adapters/bun/hmr-manager.ts +281 -0
  26. package/src/adapters/bun/index.d.ts +3 -0
  27. package/src/adapters/bun/index.js +8 -0
  28. package/src/adapters/bun/index.ts +3 -0
  29. package/src/adapters/bun/server-adapter.d.ts +155 -0
  30. package/src/adapters/bun/server-adapter.js +368 -0
  31. package/src/adapters/bun/server-adapter.ts +492 -0
  32. package/src/adapters/bun/server-lifecycle.d.ts +52 -0
  33. package/src/adapters/bun/server-lifecycle.js +120 -0
  34. package/src/adapters/bun/server-lifecycle.ts +154 -0
  35. package/src/adapters/index.d.ts +6 -0
  36. package/src/adapters/index.js +14 -0
  37. package/src/adapters/index.ts +6 -0
  38. package/src/adapters/node/create-app.d.ts +21 -0
  39. package/src/adapters/node/create-app.js +143 -0
  40. package/src/adapters/node/create-app.ts +179 -0
  41. package/src/adapters/node/index.d.ts +4 -0
  42. package/src/adapters/node/index.js +8 -0
  43. package/src/adapters/node/index.ts +9 -0
  44. package/src/adapters/node/node-client-bridge.d.ts +26 -0
  45. package/src/adapters/node/node-client-bridge.js +66 -0
  46. package/src/adapters/node/node-client-bridge.ts +79 -0
  47. package/src/adapters/node/node-hmr-manager.d.ts +62 -0
  48. package/src/adapters/node/node-hmr-manager.js +221 -0
  49. package/src/adapters/node/node-hmr-manager.ts +271 -0
  50. package/src/adapters/node/server-adapter.d.ts +190 -0
  51. package/src/adapters/node/server-adapter.js +420 -0
  52. package/src/adapters/node/server-adapter.ts +561 -0
  53. package/src/adapters/node/static-content-server.d.ts +24 -0
  54. package/src/adapters/node/static-content-server.js +166 -0
  55. package/src/adapters/node/static-content-server.ts +203 -0
  56. package/src/adapters/shared/api-response.d.ts +52 -0
  57. package/src/adapters/shared/api-response.js +96 -0
  58. package/src/adapters/shared/api-response.ts +104 -0
  59. package/src/adapters/shared/application-adapter.d.ts +18 -0
  60. package/src/adapters/shared/application-adapter.js +90 -0
  61. package/src/adapters/shared/application-adapter.ts +199 -0
  62. package/src/adapters/shared/explicit-static-route-matcher.d.ts +38 -0
  63. package/src/adapters/shared/explicit-static-route-matcher.js +100 -0
  64. package/src/adapters/shared/explicit-static-route-matcher.ts +134 -0
  65. package/src/adapters/shared/file-route-middleware-pipeline.d.ts +65 -0
  66. package/src/adapters/shared/file-route-middleware-pipeline.js +98 -0
  67. package/src/adapters/shared/file-route-middleware-pipeline.ts +123 -0
  68. package/src/adapters/shared/fs-server-response-factory.d.ts +19 -0
  69. package/src/adapters/shared/fs-server-response-factory.js +97 -0
  70. package/src/adapters/shared/fs-server-response-factory.ts +118 -0
  71. package/src/adapters/shared/fs-server-response-matcher.d.ts +71 -0
  72. package/src/adapters/shared/fs-server-response-matcher.js +155 -0
  73. package/src/adapters/shared/fs-server-response-matcher.ts +198 -0
  74. package/src/adapters/shared/render-context.d.ts +14 -0
  75. package/src/adapters/shared/render-context.js +69 -0
  76. package/src/adapters/shared/render-context.ts +105 -0
  77. package/src/adapters/shared/server-adapter.d.ts +87 -0
  78. package/src/adapters/shared/server-adapter.js +353 -0
  79. package/src/adapters/shared/server-adapter.ts +442 -0
  80. package/src/adapters/shared/server-route-handler.d.ts +89 -0
  81. package/src/adapters/shared/server-route-handler.js +120 -0
  82. package/src/adapters/shared/server-route-handler.ts +166 -0
  83. package/src/adapters/shared/server-static-builder.d.ts +38 -0
  84. package/src/adapters/shared/server-static-builder.js +46 -0
  85. package/src/adapters/shared/server-static-builder.ts +82 -0
  86. package/src/build/build-adapter.d.ts +74 -0
  87. package/src/build/build-adapter.js +54 -0
  88. package/src/build/build-adapter.ts +132 -0
  89. package/src/build/build-types.d.ts +57 -0
  90. package/src/build/build-types.js +0 -0
  91. package/src/build/build-types.ts +83 -0
  92. package/src/build/esbuild-build-adapter.d.ts +69 -0
  93. package/src/build/esbuild-build-adapter.js +390 -0
  94. package/src/build/esbuild-build-adapter.ts +510 -0
  95. package/src/config/config-builder.d.ts +227 -0
  96. package/src/config/config-builder.js +392 -0
  97. package/src/config/config-builder.ts +474 -0
  98. package/src/constants.d.ts +32 -0
  99. package/src/constants.js +21 -0
  100. package/src/constants.ts +39 -0
  101. package/src/create-app.d.ts +17 -0
  102. package/src/create-app.js +66 -0
  103. package/src/create-app.ts +87 -0
  104. package/src/declarations.d.ts +26 -0
  105. package/src/define-api-handler.d.ts +25 -0
  106. package/src/define-api-handler.js +15 -0
  107. package/src/define-api-handler.ts +66 -0
  108. package/src/dev/sc-server.d.ts +30 -0
  109. package/src/dev/sc-server.js +111 -0
  110. package/src/dev/sc-server.ts +143 -0
  111. package/src/eco/README.md +636 -0
  112. package/src/eco/component-render-context.d.ts +105 -0
  113. package/src/eco/component-render-context.js +77 -0
  114. package/src/eco/component-render-context.ts +202 -0
  115. package/src/eco/eco.d.ts +9 -0
  116. package/src/eco/eco.js +110 -0
  117. package/src/eco/eco.ts +221 -0
  118. package/src/eco/eco.types.d.ts +170 -0
  119. package/src/eco/eco.types.js +0 -0
  120. package/src/eco/eco.types.ts +202 -0
  121. package/src/eco/eco.utils.d.ts +40 -0
  122. package/src/eco/eco.utils.js +40 -0
  123. package/src/eco/eco.utils.ts +89 -0
  124. package/src/eco/global-injector-map.d.ts +16 -0
  125. package/src/eco/global-injector-map.js +80 -0
  126. package/src/eco/global-injector-map.ts +112 -0
  127. package/src/eco/lazy-injector-map.d.ts +8 -0
  128. package/src/eco/lazy-injector-map.js +70 -0
  129. package/src/eco/lazy-injector-map.ts +120 -0
  130. package/src/eco/module-dependencies.d.ts +18 -0
  131. package/src/eco/module-dependencies.js +49 -0
  132. package/src/eco/module-dependencies.ts +75 -0
  133. package/src/env.d.ts +20 -0
  134. package/src/errors/http-error.d.ts +31 -0
  135. package/src/errors/http-error.js +50 -0
  136. package/src/errors/http-error.ts +72 -0
  137. package/src/errors/index.d.ts +2 -0
  138. package/src/errors/index.js +4 -0
  139. package/src/errors/index.ts +2 -0
  140. package/src/errors/locals-access-error.d.ts +4 -0
  141. package/src/errors/locals-access-error.js +9 -0
  142. package/src/errors/locals-access-error.ts +7 -0
  143. package/src/global/app-logger.d.ts +2 -0
  144. package/src/global/app-logger.js +6 -0
  145. package/src/global/app-logger.ts +4 -0
  146. 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
  147. package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-HMR-Server-Integration-should-load-fixture-app-page-1.png +0 -0
  148. package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-WebSocket-Connection-should-connect-to-correct-HMR-endpoint-1.png +0 -0
  149. package/src/hmr/client/hmr-runtime.d.ts +10 -0
  150. package/src/hmr/client/hmr-runtime.js +86 -0
  151. package/src/hmr/client/hmr-runtime.ts +121 -0
  152. package/src/hmr/hmr-strategy.d.ts +159 -0
  153. package/src/hmr/hmr-strategy.js +29 -0
  154. package/src/hmr/hmr-strategy.ts +172 -0
  155. package/src/hmr/hmr.test.e2e.d.ts +1 -0
  156. package/src/hmr/hmr.test.e2e.js +50 -0
  157. package/src/hmr/hmr.test.e2e.ts +75 -0
  158. package/src/hmr/strategies/default-hmr-strategy.d.ts +43 -0
  159. package/src/hmr/strategies/default-hmr-strategy.js +34 -0
  160. package/src/hmr/strategies/default-hmr-strategy.ts +60 -0
  161. package/src/hmr/strategies/js-hmr-strategy.d.ts +136 -0
  162. package/src/hmr/strategies/js-hmr-strategy.js +179 -0
  163. package/src/hmr/strategies/js-hmr-strategy.ts +308 -0
  164. package/src/index.browser.d.ts +3 -0
  165. package/src/index.browser.js +4 -0
  166. package/src/index.browser.ts +3 -0
  167. package/src/index.d.ts +5 -0
  168. package/src/index.js +10 -0
  169. package/src/index.ts +5 -0
  170. package/src/integrations/ghtml/ghtml-renderer.d.ts +15 -0
  171. package/src/integrations/ghtml/ghtml-renderer.js +60 -0
  172. package/src/integrations/ghtml/ghtml-renderer.ts +93 -0
  173. package/src/integrations/ghtml/ghtml.plugin.d.ts +20 -0
  174. package/src/integrations/ghtml/ghtml.plugin.js +21 -0
  175. package/src/integrations/ghtml/ghtml.plugin.ts +32 -0
  176. package/src/internal-types.d.ts +200 -0
  177. package/src/internal-types.js +0 -0
  178. package/src/internal-types.ts +212 -0
  179. package/src/plugins/alias-resolver-plugin.d.ts +2 -0
  180. package/src/plugins/alias-resolver-plugin.js +39 -0
  181. package/src/plugins/alias-resolver-plugin.ts +45 -0
  182. package/src/plugins/eco-component-meta-plugin.d.ts +95 -0
  183. package/src/plugins/eco-component-meta-plugin.js +157 -0
  184. package/src/plugins/eco-component-meta-plugin.ts +474 -0
  185. package/src/plugins/integration-plugin.d.ts +102 -0
  186. package/src/plugins/integration-plugin.js +100 -0
  187. package/src/plugins/integration-plugin.ts +184 -0
  188. package/src/plugins/processor.d.ts +82 -0
  189. package/src/plugins/processor.js +122 -0
  190. package/src/plugins/processor.ts +220 -0
  191. package/src/public-types.d.ts +1094 -0
  192. package/src/public-types.js +0 -0
  193. package/src/public-types.ts +1255 -0
  194. package/src/route-renderer/GRAPH.md +387 -0
  195. package/src/route-renderer/README.md +135 -0
  196. package/src/route-renderer/component-graph-executor.d.ts +32 -0
  197. package/src/route-renderer/component-graph-executor.js +31 -0
  198. package/src/route-renderer/component-graph-executor.ts +84 -0
  199. package/src/route-renderer/component-graph.d.ts +42 -0
  200. package/src/route-renderer/component-graph.js +72 -0
  201. package/src/route-renderer/component-graph.ts +159 -0
  202. package/src/route-renderer/component-marker.d.ts +52 -0
  203. package/src/route-renderer/component-marker.js +46 -0
  204. package/src/route-renderer/component-marker.ts +117 -0
  205. package/src/route-renderer/dependency-resolver.d.ts +24 -0
  206. package/src/route-renderer/dependency-resolver.js +428 -0
  207. package/src/route-renderer/dependency-resolver.ts +596 -0
  208. package/src/route-renderer/html-post-processing.service.d.ts +40 -0
  209. package/src/route-renderer/html-post-processing.service.js +86 -0
  210. package/src/route-renderer/html-post-processing.service.ts +103 -0
  211. package/src/route-renderer/integration-renderer.d.ts +339 -0
  212. package/src/route-renderer/integration-renderer.js +526 -0
  213. package/src/route-renderer/integration-renderer.ts +696 -0
  214. package/src/route-renderer/marker-graph-resolver.d.ts +76 -0
  215. package/src/route-renderer/marker-graph-resolver.js +93 -0
  216. package/src/route-renderer/marker-graph-resolver.ts +153 -0
  217. package/src/route-renderer/page-module-loader.d.ts +61 -0
  218. package/src/route-renderer/page-module-loader.js +102 -0
  219. package/src/route-renderer/page-module-loader.ts +153 -0
  220. package/src/route-renderer/render-execution.service.d.ts +69 -0
  221. package/src/route-renderer/render-execution.service.js +91 -0
  222. package/src/route-renderer/render-execution.service.ts +158 -0
  223. package/src/route-renderer/render-preparation.service.d.ts +112 -0
  224. package/src/route-renderer/render-preparation.service.js +243 -0
  225. package/src/route-renderer/render-preparation.service.ts +358 -0
  226. package/src/route-renderer/route-renderer.d.ts +26 -0
  227. package/src/route-renderer/route-renderer.js +68 -0
  228. package/src/route-renderer/route-renderer.ts +80 -0
  229. package/src/router/fs-router-scanner.d.ts +41 -0
  230. package/src/router/fs-router-scanner.js +155 -0
  231. package/src/router/fs-router-scanner.ts +217 -0
  232. package/src/router/fs-router.d.ts +26 -0
  233. package/src/router/fs-router.js +100 -0
  234. package/src/router/fs-router.ts +122 -0
  235. package/src/services/asset-processing-service/asset-processing.service.d.ts +41 -0
  236. package/src/services/asset-processing-service/asset-processing.service.js +250 -0
  237. package/src/services/asset-processing-service/asset-processing.service.ts +306 -0
  238. package/src/services/asset-processing-service/asset.factory.d.ts +17 -0
  239. package/src/services/asset-processing-service/asset.factory.js +82 -0
  240. package/src/services/asset-processing-service/asset.factory.ts +105 -0
  241. package/src/services/asset-processing-service/assets.types.d.ts +88 -0
  242. package/src/services/asset-processing-service/assets.types.js +0 -0
  243. package/src/services/asset-processing-service/assets.types.ts +112 -0
  244. package/src/services/asset-processing-service/index.d.ts +3 -0
  245. package/src/services/asset-processing-service/index.js +3 -0
  246. package/src/services/asset-processing-service/index.ts +3 -0
  247. package/src/services/asset-processing-service/processor.interface.d.ts +22 -0
  248. package/src/services/asset-processing-service/processor.interface.js +6 -0
  249. package/src/services/asset-processing-service/processor.interface.ts +27 -0
  250. package/src/services/asset-processing-service/processor.registry.d.ts +8 -0
  251. package/src/services/asset-processing-service/processor.registry.js +15 -0
  252. package/src/services/asset-processing-service/processor.registry.ts +18 -0
  253. package/src/services/asset-processing-service/processors/base/base-processor.d.ts +24 -0
  254. package/src/services/asset-processing-service/processors/base/base-processor.js +59 -0
  255. package/src/services/asset-processing-service/processors/base/base-processor.ts +76 -0
  256. package/src/services/asset-processing-service/processors/base/base-script-processor.d.ts +16 -0
  257. package/src/services/asset-processing-service/processors/base/base-script-processor.js +80 -0
  258. package/src/services/asset-processing-service/processors/base/base-script-processor.ts +105 -0
  259. package/src/services/asset-processing-service/processors/index.d.ts +5 -0
  260. package/src/services/asset-processing-service/processors/index.js +5 -0
  261. package/src/services/asset-processing-service/processors/index.ts +5 -0
  262. package/src/services/asset-processing-service/processors/script/content-script.processor.d.ts +5 -0
  263. package/src/services/asset-processing-service/processors/script/content-script.processor.js +57 -0
  264. package/src/services/asset-processing-service/processors/script/content-script.processor.ts +66 -0
  265. package/src/services/asset-processing-service/processors/script/file-script.processor.d.ts +8 -0
  266. package/src/services/asset-processing-service/processors/script/file-script.processor.js +76 -0
  267. package/src/services/asset-processing-service/processors/script/file-script.processor.ts +88 -0
  268. package/src/services/asset-processing-service/processors/script/node-module-script.processor.d.ts +7 -0
  269. package/src/services/asset-processing-service/processors/script/node-module-script.processor.js +74 -0
  270. package/src/services/asset-processing-service/processors/script/node-module-script.processor.ts +84 -0
  271. package/src/services/asset-processing-service/processors/stylesheet/content-stylesheet.processor.d.ts +5 -0
  272. package/src/services/asset-processing-service/processors/stylesheet/content-stylesheet.processor.js +25 -0
  273. package/src/services/asset-processing-service/processors/stylesheet/content-stylesheet.processor.ts +27 -0
  274. package/src/services/asset-processing-service/processors/stylesheet/file-stylesheet.processor.d.ts +9 -0
  275. package/src/services/asset-processing-service/processors/stylesheet/file-stylesheet.processor.js +63 -0
  276. package/src/services/asset-processing-service/processors/stylesheet/file-stylesheet.processor.ts +77 -0
  277. package/src/services/cache/cache.types.d.ts +107 -0
  278. package/src/services/cache/cache.types.js +0 -0
  279. package/src/services/cache/cache.types.ts +126 -0
  280. package/src/services/cache/index.d.ts +7 -0
  281. package/src/services/cache/index.js +7 -0
  282. package/src/services/cache/index.ts +18 -0
  283. package/src/services/cache/memory-cache-store.d.ts +42 -0
  284. package/src/services/cache/memory-cache-store.js +98 -0
  285. package/src/services/cache/memory-cache-store.ts +130 -0
  286. package/src/services/cache/page-cache-service.d.ts +70 -0
  287. package/src/services/cache/page-cache-service.js +152 -0
  288. package/src/services/cache/page-cache-service.ts +202 -0
  289. package/src/services/html-transformer.service.d.ts +50 -0
  290. package/src/services/html-transformer.service.js +163 -0
  291. package/src/services/html-transformer.service.ts +217 -0
  292. package/src/services/page-module-import.service.d.ts +37 -0
  293. package/src/services/page-module-import.service.js +88 -0
  294. package/src/services/page-module-import.service.ts +129 -0
  295. package/src/services/page-request-cache-coordinator.service.d.ts +75 -0
  296. package/src/services/page-request-cache-coordinator.service.js +107 -0
  297. package/src/services/page-request-cache-coordinator.service.ts +128 -0
  298. package/src/services/schema-validation-service.d.ts +122 -0
  299. package/src/services/schema-validation-service.js +101 -0
  300. package/src/services/schema-validation-service.ts +204 -0
  301. package/src/services/validation/standard-schema.types.d.ts +65 -0
  302. package/src/services/validation/standard-schema.types.js +0 -0
  303. package/src/services/validation/standard-schema.types.ts +68 -0
  304. package/src/static-site-generator/static-site-generator.d.ts +57 -0
  305. package/src/static-site-generator/static-site-generator.js +272 -0
  306. package/src/static-site-generator/static-site-generator.ts +359 -0
  307. package/src/utils/css.d.ts +1 -0
  308. package/src/utils/css.js +7 -0
  309. package/src/utils/css.ts +5 -0
  310. package/src/utils/deep-merge.d.ts +14 -0
  311. package/src/utils/deep-merge.js +32 -0
  312. package/src/utils/deep-merge.ts +47 -0
  313. package/src/utils/hash.d.ts +1 -0
  314. package/src/utils/hash.js +7 -0
  315. package/src/utils/hash.ts +5 -0
  316. package/src/utils/html.d.ts +1 -0
  317. package/src/utils/html.js +4 -0
  318. package/src/utils/html.ts +1 -0
  319. package/src/utils/invariant.d.ts +5 -0
  320. package/src/utils/invariant.js +11 -0
  321. package/src/utils/invariant.ts +15 -0
  322. package/src/utils/locals-utils.d.ts +15 -0
  323. package/src/utils/locals-utils.js +24 -0
  324. package/src/utils/locals-utils.ts +37 -0
  325. package/src/utils/parse-cli-args.d.ts +24 -0
  326. package/src/utils/parse-cli-args.js +47 -0
  327. package/src/utils/parse-cli-args.ts +83 -0
  328. package/src/utils/path-utils.module.d.ts +5 -0
  329. package/src/utils/path-utils.module.js +14 -0
  330. package/src/utils/path-utils.module.ts +14 -0
  331. package/src/utils/runtime.d.ts +11 -0
  332. package/src/utils/runtime.js +40 -0
  333. package/src/utils/runtime.ts +44 -0
  334. package/src/utils/server-utils.module.d.ts +19 -0
  335. package/src/utils/server-utils.module.js +56 -0
  336. package/src/utils/server-utils.module.ts +67 -0
  337. package/src/watchers/project-watcher.d.ts +120 -0
  338. package/src/watchers/project-watcher.js +238 -0
  339. package/src/watchers/project-watcher.test-helpers.d.ts +4 -0
  340. package/src/watchers/project-watcher.test-helpers.js +51 -0
  341. package/src/watchers/project-watcher.test-helpers.ts +40 -0
  342. package/src/watchers/project-watcher.ts +306 -0
@@ -0,0 +1,102 @@
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/integration-renderer';
6
+ import { AssetProcessingService } from '../services/asset-processing-service/asset-processing.service';
7
+ import type { AssetDefinition, ProcessedAsset } from '../services/asset-processing-service/assets.types';
8
+ export declare const INTEGRATION_PLUGIN_ERRORS: {
9
+ readonly NOT_INITIALIZED_WITH_APP_CONFIG: "Plugin not initialized with app config";
10
+ readonly NOT_INITIALIZED_WITH_ASSET_SERVICE: "Plugin not initialized with asset dependency service";
11
+ };
12
+ export interface IntegrationPluginConfig {
13
+ /**
14
+ * The name of the integration plugin.
15
+ */
16
+ name: string;
17
+ /**
18
+ * The extensions that this plugin supports (e.g., ['.kita.js', '.kita.tsx']).
19
+ */
20
+ extensions: string[];
21
+ /**
22
+ * The dependencies that this plugin requires on a global level.
23
+ * These dependencies will be resolved during the setup process and injected into the global scope of the application.
24
+ * They are not specific to any particular page or component.
25
+ */
26
+ integrationDependencies?: AssetDefinition[];
27
+ /**
28
+ * The strategy to use for static building.
29
+ * - 'render': Execute component function directly (faster, efficient).
30
+ * - 'fetch': Start server and fetch URL (slower, needed for some SSR like Lit).
31
+ * @default 'render'
32
+ */
33
+ staticBuildStep?: 'render' | 'fetch';
34
+ }
35
+ /**
36
+ * Metadata used by integration-owned boundary policy.
37
+ *
38
+ * This payload describes the currently active integration pass together with the
39
+ * target component boundary being entered.
40
+ */
41
+ export type ComponentBoundaryPolicyInput = {
42
+ currentIntegration: string;
43
+ targetIntegration?: string;
44
+ component: EcoComponent;
45
+ };
46
+ type RendererClass<C> = new (options: {
47
+ appConfig: EcoPagesAppConfig;
48
+ assetProcessingService: AssetProcessingService;
49
+ resolvedIntegrationDependencies: ProcessedAsset[];
50
+ runtimeOrigin: string;
51
+ }) => IntegrationRenderer<C>;
52
+ export declare abstract class IntegrationPlugin<C = EcoPagesElement> {
53
+ readonly name: string;
54
+ readonly extensions: string[];
55
+ abstract renderer: RendererClass<C>;
56
+ readonly staticBuildStep: 'render' | 'fetch';
57
+ protected integrationDependencies: AssetDefinition[];
58
+ protected resolvedIntegrationDependencies: ProcessedAsset[];
59
+ protected options?: Record<string, unknown>;
60
+ protected appConfig?: EcoPagesAppConfig;
61
+ protected assetProcessingService?: AssetProcessingService;
62
+ protected hmrManager?: IHmrManager;
63
+ runtimeOrigin: string;
64
+ get plugins(): EcoBuildPlugin[];
65
+ constructor(config: IntegrationPluginConfig);
66
+ setConfig(appConfig: EcoPagesAppConfig): void;
67
+ setRuntimeOrigin(runtimeOrigin: string): void;
68
+ /**
69
+ * Returns an HMR strategy for this integration, if applicable.
70
+ * The strategy will be registered with the HmrManager during initialization.
71
+ *
72
+ * @returns HmrStrategy instance or undefined if no custom HMR handling needed
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * getHmrStrategy(): HmrStrategy {
77
+ * const context = this.hmrManager!.getDefaultContext();
78
+ * return new ReactHmrStrategy(context);
79
+ * }
80
+ * ```
81
+ */
82
+ getHmrStrategy?(): HmrStrategy | undefined;
83
+ setHmrManager(hmrManager: IHmrManager): void;
84
+ initializeAssetDefinitionService(): void;
85
+ getResolvedIntegrationDependencies(): ProcessedAsset[];
86
+ initializeRenderer(): IntegrationRenderer<C>;
87
+ /**
88
+ * Declares whether a component boundary targeting this integration should be
89
+ * deferred through the marker pipeline.
90
+ *
91
+ * The default implementation never defers. Integrations that require deferred
92
+ * subtree rendering should override this method and return `true` when their
93
+ * boundary must be resolved during the marker graph stage.
94
+ *
95
+ * @param input Boundary metadata for the current render pass.
96
+ * @returns `true` when the boundary should be deferred; otherwise `false`.
97
+ */
98
+ shouldDeferComponentBoundary(_input: ComponentBoundaryPolicyInput): boolean;
99
+ setup(): Promise<void>;
100
+ teardown(): Promise<void>;
101
+ }
102
+ export {};
@@ -0,0 +1,100 @@
1
+ import { AssetProcessingService } from "../services/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
+ integrationDependencies;
11
+ resolvedIntegrationDependencies = [];
12
+ options;
13
+ appConfig;
14
+ assetProcessingService;
15
+ hmrManager;
16
+ get plugins() {
17
+ return [];
18
+ }
19
+ constructor(config) {
20
+ this.name = config.name;
21
+ this.extensions = config.extensions;
22
+ this.integrationDependencies = config.integrationDependencies || [];
23
+ this.staticBuildStep = config.staticBuildStep || "render";
24
+ }
25
+ setConfig(appConfig) {
26
+ this.appConfig = appConfig;
27
+ this.initializeAssetDefinitionService();
28
+ }
29
+ setRuntimeOrigin(runtimeOrigin) {
30
+ this.runtimeOrigin = runtimeOrigin;
31
+ }
32
+ setHmrManager(hmrManager) {
33
+ this.hmrManager = hmrManager;
34
+ const strategy = this.getHmrStrategy?.();
35
+ if (strategy) {
36
+ hmrManager.registerStrategy(strategy);
37
+ }
38
+ if (this.assetProcessingService) {
39
+ this.assetProcessingService.setHmrManager(hmrManager);
40
+ }
41
+ }
42
+ initializeAssetDefinitionService() {
43
+ if (!this.appConfig) throw new Error(INTEGRATION_PLUGIN_ERRORS.NOT_INITIALIZED_WITH_APP_CONFIG);
44
+ this.assetProcessingService = AssetProcessingService.createWithDefaultProcessors(this.appConfig);
45
+ if (this.hmrManager) {
46
+ this.assetProcessingService.setHmrManager(this.hmrManager);
47
+ }
48
+ }
49
+ getResolvedIntegrationDependencies() {
50
+ return this.resolvedIntegrationDependencies;
51
+ }
52
+ initializeRenderer() {
53
+ if (!this.appConfig) {
54
+ throw new Error(INTEGRATION_PLUGIN_ERRORS.NOT_INITIALIZED_WITH_APP_CONFIG);
55
+ }
56
+ const assetProcessingService = AssetProcessingService.createWithDefaultProcessors(this.appConfig);
57
+ if (this.hmrManager) {
58
+ assetProcessingService.setHmrManager(this.hmrManager);
59
+ }
60
+ const renderer = new this.renderer({
61
+ appConfig: this.appConfig,
62
+ assetProcessingService,
63
+ resolvedIntegrationDependencies: this.resolvedIntegrationDependencies,
64
+ runtimeOrigin: this.runtimeOrigin
65
+ });
66
+ if (this.hmrManager) {
67
+ renderer.setHmrManager(this.hmrManager);
68
+ }
69
+ return renderer;
70
+ }
71
+ /**
72
+ * Declares whether a component boundary targeting this integration should be
73
+ * deferred through the marker pipeline.
74
+ *
75
+ * The default implementation never defers. Integrations that require deferred
76
+ * subtree rendering should override this method and return `true` when their
77
+ * boundary must be resolved during the marker graph stage.
78
+ *
79
+ * @param input Boundary metadata for the current render pass.
80
+ * @returns `true` when the boundary should be deferred; otherwise `false`.
81
+ */
82
+ shouldDeferComponentBoundary(_input) {
83
+ return false;
84
+ }
85
+ async setup() {
86
+ if (this.integrationDependencies.length === 0) return;
87
+ if (!this.assetProcessingService) throw new Error(INTEGRATION_PLUGIN_ERRORS.NOT_INITIALIZED_WITH_ASSET_SERVICE);
88
+ this.resolvedIntegrationDependencies = await this.assetProcessingService.processDependencies(
89
+ this.integrationDependencies,
90
+ this.name
91
+ );
92
+ this.initializeRenderer();
93
+ }
94
+ async teardown() {
95
+ }
96
+ }
97
+ export {
98
+ INTEGRATION_PLUGIN_ERRORS,
99
+ IntegrationPlugin
100
+ };
@@ -0,0 +1,184 @@
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/integration-renderer';
6
+ import { AssetProcessingService } from '../services/asset-processing-service/asset-processing.service';
7
+ import type { AssetDefinition, ProcessedAsset } from '../services/asset-processing-service/assets.types';
8
+
9
+ export const INTEGRATION_PLUGIN_ERRORS = {
10
+ NOT_INITIALIZED_WITH_APP_CONFIG: 'Plugin not initialized with app config',
11
+ NOT_INITIALIZED_WITH_ASSET_SERVICE: 'Plugin not initialized with asset dependency service',
12
+ } as const;
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
+
38
+ /**
39
+ * Metadata used by integration-owned boundary policy.
40
+ *
41
+ * This payload describes the currently active integration pass together with the
42
+ * target component boundary being entered.
43
+ */
44
+ export type ComponentBoundaryPolicyInput = {
45
+ currentIntegration: string;
46
+ targetIntegration?: string;
47
+ component: EcoComponent;
48
+ };
49
+
50
+ type RendererClass<C> = new (options: {
51
+ appConfig: EcoPagesAppConfig;
52
+ assetProcessingService: AssetProcessingService;
53
+ resolvedIntegrationDependencies: ProcessedAsset[];
54
+ runtimeOrigin: string;
55
+ }) => IntegrationRenderer<C>;
56
+
57
+ export abstract class IntegrationPlugin<C = EcoPagesElement> {
58
+ readonly name: string;
59
+ readonly extensions: string[];
60
+ abstract renderer: RendererClass<C>;
61
+ readonly staticBuildStep: 'render' | 'fetch';
62
+
63
+ protected integrationDependencies: AssetDefinition[];
64
+ protected resolvedIntegrationDependencies: ProcessedAsset[] = [];
65
+ protected options?: Record<string, unknown>;
66
+ protected appConfig?: EcoPagesAppConfig;
67
+ protected assetProcessingService?: AssetProcessingService;
68
+ protected hmrManager?: IHmrManager;
69
+ declare runtimeOrigin: string;
70
+
71
+ get plugins(): EcoBuildPlugin[] {
72
+ return [];
73
+ }
74
+
75
+ constructor(config: IntegrationPluginConfig) {
76
+ this.name = config.name;
77
+ this.extensions = config.extensions;
78
+ this.integrationDependencies = config.integrationDependencies || [];
79
+ this.staticBuildStep = config.staticBuildStep || 'render';
80
+ }
81
+
82
+ setConfig(appConfig: EcoPagesAppConfig): void {
83
+ this.appConfig = appConfig;
84
+ this.initializeAssetDefinitionService();
85
+ }
86
+
87
+ setRuntimeOrigin(runtimeOrigin: string) {
88
+ this.runtimeOrigin = runtimeOrigin;
89
+ }
90
+
91
+ /**
92
+ * Returns an HMR strategy for this integration, if applicable.
93
+ * The strategy will be registered with the HmrManager during initialization.
94
+ *
95
+ * @returns HmrStrategy instance or undefined if no custom HMR handling needed
96
+ *
97
+ * @example
98
+ * ```typescript
99
+ * getHmrStrategy(): HmrStrategy {
100
+ * const context = this.hmrManager!.getDefaultContext();
101
+ * return new ReactHmrStrategy(context);
102
+ * }
103
+ * ```
104
+ */
105
+ getHmrStrategy?(): HmrStrategy | undefined;
106
+
107
+ setHmrManager(hmrManager: IHmrManager) {
108
+ this.hmrManager = hmrManager;
109
+
110
+ const strategy = this.getHmrStrategy?.();
111
+ if (strategy) {
112
+ hmrManager.registerStrategy(strategy);
113
+ }
114
+
115
+ if (this.assetProcessingService) {
116
+ this.assetProcessingService.setHmrManager(hmrManager);
117
+ }
118
+ }
119
+
120
+ initializeAssetDefinitionService(): void {
121
+ if (!this.appConfig) throw new Error(INTEGRATION_PLUGIN_ERRORS.NOT_INITIALIZED_WITH_APP_CONFIG);
122
+
123
+ this.assetProcessingService = AssetProcessingService.createWithDefaultProcessors(this.appConfig);
124
+ if (this.hmrManager) {
125
+ this.assetProcessingService.setHmrManager(this.hmrManager);
126
+ }
127
+ }
128
+
129
+ getResolvedIntegrationDependencies(): ProcessedAsset[] {
130
+ return this.resolvedIntegrationDependencies;
131
+ }
132
+
133
+ initializeRenderer(): IntegrationRenderer<C> {
134
+ if (!this.appConfig) {
135
+ throw new Error(INTEGRATION_PLUGIN_ERRORS.NOT_INITIALIZED_WITH_APP_CONFIG);
136
+ }
137
+
138
+ const assetProcessingService = AssetProcessingService.createWithDefaultProcessors(this.appConfig);
139
+ if (this.hmrManager) {
140
+ assetProcessingService.setHmrManager(this.hmrManager);
141
+ }
142
+
143
+ const renderer = new this.renderer({
144
+ appConfig: this.appConfig,
145
+ assetProcessingService,
146
+ resolvedIntegrationDependencies: this.resolvedIntegrationDependencies,
147
+ runtimeOrigin: this.runtimeOrigin,
148
+ });
149
+
150
+ if (this.hmrManager) {
151
+ renderer.setHmrManager(this.hmrManager);
152
+ }
153
+
154
+ return renderer;
155
+ }
156
+
157
+ /**
158
+ * Declares whether a component boundary targeting this integration should be
159
+ * deferred through the marker pipeline.
160
+ *
161
+ * The default implementation never defers. Integrations that require deferred
162
+ * subtree rendering should override this method and return `true` when their
163
+ * boundary must be resolved during the marker graph stage.
164
+ *
165
+ * @param input Boundary metadata for the current render pass.
166
+ * @returns `true` when the boundary should be deferred; otherwise `false`.
167
+ */
168
+ shouldDeferComponentBoundary(_input: ComponentBoundaryPolicyInput): boolean {
169
+ return false;
170
+ }
171
+
172
+ async setup(): Promise<void> {
173
+ if (this.integrationDependencies.length === 0) return;
174
+ if (!this.assetProcessingService) throw new Error(INTEGRATION_PLUGIN_ERRORS.NOT_INITIALIZED_WITH_ASSET_SERVICE);
175
+
176
+ this.resolvedIntegrationDependencies = await this.assetProcessingService.processDependencies(
177
+ this.integrationDependencies,
178
+ this.name,
179
+ );
180
+
181
+ this.initializeRenderer();
182
+ }
183
+ async teardown(): Promise<void> {}
184
+ }
@@ -0,0 +1,82 @@
1
+ import type { EcoBuildPlugin } from '../build/build-types.js';
2
+ import type { EcoPagesAppConfig, IClientBridge } from '../internal-types';
3
+ import type { AssetDefinition } from '../services/asset-processing-service';
4
+ export declare const PROCESSOR_ERRORS: {
5
+ readonly CACHE_DIRECTORY_NOT_SET: "Cache directory not set in context";
6
+ };
7
+ export interface ProcessorWatchContext {
8
+ path: string;
9
+ bridge: IClientBridge;
10
+ }
11
+ export interface ProcessorWatchConfig {
12
+ paths: string[];
13
+ extensions?: string[];
14
+ onCreate?: (ctx: ProcessorWatchContext) => Promise<void>;
15
+ onChange?: (ctx: ProcessorWatchContext) => Promise<void>;
16
+ onDelete?: (ctx: ProcessorWatchContext) => Promise<void>;
17
+ onError?: (error: Error) => void;
18
+ }
19
+ export type ProcessorAssetKind = 'script' | 'stylesheet' | 'image';
20
+ export type ProcessorExtensionPattern = string;
21
+ export interface ProcessorAssetCapability {
22
+ kind: ProcessorAssetKind;
23
+ /**
24
+ * Supported patterns:
25
+ * - `*` (all extensions)
26
+ * - `.css` or `css`
27
+ * - `*.css`
28
+ * - `*.{css,scss,sass}`
29
+ *
30
+ * Pattern matching is case-insensitive and trims surrounding spaces,
31
+ * including grouped values (e.g. `*.{ CSS, ScSs }`).
32
+ */
33
+ extensions?: ProcessorExtensionPattern[];
34
+ }
35
+ export interface ProcessorConfig<TOptions = Record<string, unknown>> {
36
+ name: string;
37
+ description?: string;
38
+ options?: TOptions;
39
+ watch?: ProcessorWatchConfig;
40
+ capabilities?: ProcessorAssetCapability[];
41
+ }
42
+ export interface ProcessorContext {
43
+ config: EcoPagesAppConfig;
44
+ rootDir: string;
45
+ srcDir: string;
46
+ distDir: string;
47
+ cache?: string;
48
+ }
49
+ /**
50
+ * Interface for processor build plugins
51
+ * This is used to pass plugins to the build process directly from the processor
52
+ * For instance it can become very handy when dealing with virtual modules that needs to be recognized by the bundler
53
+ * i.e. @ecopages/image-processor
54
+ */
55
+ export declare abstract class Processor<TOptions = Record<string, unknown>> {
56
+ readonly name: string;
57
+ protected dependencies: AssetDefinition[];
58
+ protected context?: ProcessorContext;
59
+ protected options?: TOptions;
60
+ protected watchConfig?: ProcessorWatchConfig;
61
+ protected capabilities: ProcessorAssetCapability[];
62
+ /** Plugins that are only used during the build process */
63
+ abstract buildPlugins?: EcoBuildPlugin[];
64
+ /** Plugins that are used during runtime for file processing */
65
+ abstract plugins?: EcoBuildPlugin[];
66
+ constructor(config: ProcessorConfig<TOptions>);
67
+ setContext(appConfig: EcoPagesAppConfig): void;
68
+ abstract setup(): Promise<void>;
69
+ abstract teardown(): Promise<void>;
70
+ abstract process(input: unknown, filePath?: string): Promise<unknown>;
71
+ protected getCachePath(key: string): string;
72
+ protected readCache<T>(key: string): Promise<T | null>;
73
+ protected writeCache<T>(key: string, data: T): Promise<void>;
74
+ getWatchConfig(): ProcessorWatchConfig | undefined;
75
+ getDependencies(): AssetDefinition[];
76
+ getName(): string;
77
+ getAssetCapabilities(): ProcessorAssetCapability[];
78
+ matchesFileFilter(_filepath: string): boolean;
79
+ canProcessAsset(kind: ProcessorAssetKind, filepath?: string): boolean;
80
+ private matchesCapabilityExtensions;
81
+ private normalizeExtensionPattern;
82
+ }
@@ -0,0 +1,122 @@
1
+ import path from "node:path";
2
+ import { fileSystem } from "@ecopages/file-system";
3
+ import { GENERATED_BASE_PATHS } from "../constants";
4
+ const PROCESSOR_ERRORS = {
5
+ CACHE_DIRECTORY_NOT_SET: "Cache directory not set in context"
6
+ };
7
+ function resolveGeneratedPath(type, options) {
8
+ const { root, module, subPath } = options;
9
+ const parts = [root, GENERATED_BASE_PATHS[type], module, subPath].filter(Boolean);
10
+ return path.join(...parts);
11
+ }
12
+ class Processor {
13
+ name;
14
+ dependencies = [];
15
+ context;
16
+ options;
17
+ watchConfig;
18
+ capabilities = [];
19
+ constructor(config) {
20
+ this.name = config.name;
21
+ this.options = config.options;
22
+ this.watchConfig = config.watch;
23
+ this.capabilities = config.capabilities ?? [];
24
+ }
25
+ setContext(appConfig) {
26
+ const cachePath = resolveGeneratedPath("cache", {
27
+ root: appConfig.absolutePaths.distDir,
28
+ module: this.name
29
+ });
30
+ fileSystem.ensureDir(cachePath);
31
+ this.context = {
32
+ config: appConfig,
33
+ rootDir: appConfig.rootDir,
34
+ srcDir: appConfig.absolutePaths.srcDir,
35
+ distDir: appConfig.absolutePaths.distDir,
36
+ cache: cachePath
37
+ };
38
+ }
39
+ getCachePath(key) {
40
+ return `${this.context?.cache}/${key}`;
41
+ }
42
+ async readCache(key) {
43
+ const cachePath = this.getCachePath(key);
44
+ try {
45
+ const data = await fileSystem.readFile(cachePath);
46
+ return JSON.parse(data);
47
+ } catch {
48
+ return null;
49
+ }
50
+ }
51
+ async writeCache(key, data) {
52
+ if (!this.context?.cache) {
53
+ throw new Error(PROCESSOR_ERRORS.CACHE_DIRECTORY_NOT_SET);
54
+ }
55
+ const cachePath = this.getCachePath(key);
56
+ fileSystem.write(cachePath, JSON.stringify(data, null, 2));
57
+ }
58
+ getWatchConfig() {
59
+ return this.watchConfig;
60
+ }
61
+ getDependencies() {
62
+ return this.dependencies;
63
+ }
64
+ getName() {
65
+ return this.name;
66
+ }
67
+ getAssetCapabilities() {
68
+ return this.capabilities;
69
+ }
70
+ matchesFileFilter(_filepath) {
71
+ return true;
72
+ }
73
+ canProcessAsset(kind, filepath) {
74
+ const capabilities = this.getAssetCapabilities();
75
+ if (capabilities.length === 0) {
76
+ return false;
77
+ }
78
+ const matchingKind = capabilities.filter((capability) => capability.kind === kind);
79
+ if (matchingKind.length === 0) {
80
+ return false;
81
+ }
82
+ if (!filepath) {
83
+ return true;
84
+ }
85
+ return matchingKind.some((capability) => this.matchesCapabilityExtensions(filepath, capability.extensions));
86
+ }
87
+ matchesCapabilityExtensions(filepath, extensions) {
88
+ if (!extensions || extensions.length === 0) {
89
+ return true;
90
+ }
91
+ const normalizedExt = path.extname(filepath).toLowerCase();
92
+ return extensions.some((rawPattern) => {
93
+ const pattern = this.normalizeExtensionPattern(rawPattern);
94
+ if (!pattern) {
95
+ return false;
96
+ }
97
+ if (pattern === "*") {
98
+ return true;
99
+ }
100
+ const groupedMatch = pattern.match(/^\*\.\{(.+)\}$/);
101
+ if (groupedMatch) {
102
+ const groupItems = groupedMatch[1].split(",").map((item) => this.normalizeExtensionPattern(item)).filter(Boolean);
103
+ return groupItems.some((item) => normalizedExt === item || normalizedExt === `.${item}`);
104
+ }
105
+ if (pattern.startsWith("*")) {
106
+ const suffix = pattern.slice(1);
107
+ return normalizedExt.endsWith(suffix);
108
+ }
109
+ if (pattern.startsWith(".")) {
110
+ return normalizedExt === pattern;
111
+ }
112
+ return normalizedExt === `.${pattern}`;
113
+ });
114
+ }
115
+ normalizeExtensionPattern(rawPattern) {
116
+ return rawPattern.trim().toLowerCase();
117
+ }
118
+ }
119
+ export {
120
+ PROCESSOR_ERRORS,
121
+ Processor
122
+ };