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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (323) hide show
  1. package/CHANGELOG.md +13 -70
  2. package/README.md +213 -12
  3. package/package.json +50 -18
  4. package/src/adapters/README.md +39 -0
  5. package/src/adapters/bun/hmr-manager.d.ts +77 -18
  6. package/src/adapters/bun/hmr-manager.js +159 -52
  7. package/src/adapters/bun/index.d.ts +1 -2
  8. package/src/adapters/bun/index.js +1 -1
  9. package/src/adapters/bun/server-adapter.js +35 -30
  10. package/src/adapters/bun/server-lifecycle.d.ts +24 -13
  11. package/src/adapters/bun/server-lifecycle.js +32 -60
  12. package/src/adapters/index.d.ts +1 -1
  13. package/src/adapters/index.js +1 -1
  14. package/src/adapters/node/bootstrap-dependency-resolver.d.ts +44 -0
  15. package/src/adapters/node/bootstrap-dependency-resolver.js +172 -0
  16. package/src/adapters/node/index.d.ts +2 -0
  17. package/src/adapters/node/index.js +3 -0
  18. package/src/adapters/node/node-hmr-manager.d.ts +87 -16
  19. package/src/adapters/node/node-hmr-manager.js +179 -88
  20. package/src/adapters/node/runtime-adapter.d.ts +46 -0
  21. package/src/adapters/node/runtime-adapter.js +306 -0
  22. package/src/adapters/node/server-adapter.d.ts +2 -31
  23. package/src/adapters/node/server-adapter.js +31 -93
  24. package/src/adapters/node/static-content-server.d.ts +36 -0
  25. package/src/adapters/node/static-content-server.js +28 -0
  26. package/src/adapters/node/write-runtime-manifest.d.ts +26 -0
  27. package/src/adapters/node/write-runtime-manifest.js +12 -0
  28. package/src/{define-api-handler.d.ts → adapters/shared/define-api-handler.d.ts} +1 -1
  29. package/src/adapters/shared/explicit-static-route-matcher.js +4 -1
  30. package/src/adapters/shared/file-route-middleware-pipeline.js +1 -0
  31. package/src/adapters/shared/fs-server-response-matcher.d.ts +9 -5
  32. package/src/adapters/shared/fs-server-response-matcher.js +13 -8
  33. package/src/adapters/shared/hmr-entrypoint-registrar.d.ts +55 -0
  34. package/src/adapters/shared/hmr-entrypoint-registrar.js +87 -0
  35. package/src/adapters/shared/hmr-html-response.d.ts +22 -0
  36. package/src/adapters/shared/hmr-html-response.js +32 -0
  37. package/src/adapters/shared/render-context.js +3 -2
  38. package/src/adapters/shared/runtime-bootstrap.d.ts +38 -0
  39. package/src/adapters/shared/runtime-bootstrap.js +43 -0
  40. package/src/adapters/shared/server-adapter.d.ts +12 -2
  41. package/src/adapters/shared/server-adapter.js +37 -4
  42. package/src/adapters/shared/server-route-handler.d.ts +1 -1
  43. package/src/adapters/shared/server-route-handler.js +4 -13
  44. package/src/adapters/shared/server-static-builder.d.ts +35 -3
  45. package/src/adapters/shared/server-static-builder.js +59 -6
  46. package/src/build/README.md +101 -0
  47. package/src/build/build-adapter.d.ts +114 -2
  48. package/src/build/build-adapter.js +119 -5
  49. package/src/build/build-manifest.d.ts +27 -0
  50. package/src/build/build-manifest.js +30 -0
  51. package/src/build/dev-build-coordinator.d.ts +74 -0
  52. package/src/build/dev-build-coordinator.js +161 -0
  53. package/src/build/esbuild-build-adapter.d.ts +9 -6
  54. package/src/build/esbuild-build-adapter.js +103 -71
  55. package/src/build/runtime-build-executor.d.ts +13 -0
  56. package/src/build/runtime-build-executor.js +20 -0
  57. package/src/build/runtime-specifier-alias-plugin.d.ts +15 -0
  58. package/src/build/runtime-specifier-alias-plugin.js +31 -0
  59. package/src/config/README.md +33 -0
  60. package/src/config/config-builder.d.ts +28 -17
  61. package/src/config/config-builder.js +221 -48
  62. package/src/constants.d.ts +13 -0
  63. package/src/constants.js +4 -0
  64. package/src/declarations.d.ts +18 -13
  65. package/src/eco/README.md +70 -16
  66. package/src/eco/component-render-context.d.ts +1 -1
  67. package/src/eco/component-render-context.js +26 -16
  68. package/src/eco/eco.js +16 -12
  69. package/src/eco/eco.types.d.ts +12 -4
  70. package/src/hmr/README.md +26 -0
  71. package/src/hmr/client/hmr-runtime.d.ts +1 -6
  72. package/src/hmr/client/hmr-runtime.js +30 -7
  73. package/src/hmr/hmr.postcss.test.e2e.d.ts +1 -0
  74. package/src/hmr/hmr.postcss.test.e2e.js +31 -0
  75. package/src/hmr/hmr.test.e2e.js +26 -33
  76. package/src/hmr/strategies/js-hmr-strategy.d.ts +45 -42
  77. package/src/hmr/strategies/js-hmr-strategy.js +70 -71
  78. package/src/index.d.ts +1 -1
  79. package/src/index.js +1 -1
  80. package/src/integrations/ghtml/ghtml-renderer.d.ts +1 -1
  81. package/src/integrations/ghtml/ghtml-renderer.js +3 -1
  82. package/src/internal-types.d.ts +39 -18
  83. package/src/plugins/README.md +34 -0
  84. package/src/plugins/alias-resolver-plugin.js +17 -3
  85. package/src/plugins/eco-component-meta-plugin.d.ts +2 -0
  86. package/src/plugins/eco-component-meta-plugin.js +1 -1
  87. package/src/plugins/integration-plugin.d.ts +38 -4
  88. package/src/plugins/integration-plugin.js +34 -1
  89. package/src/plugins/processor.d.ts +14 -1
  90. package/src/plugins/processor.js +15 -1
  91. package/src/plugins/runtime-capability.d.ts +9 -0
  92. package/src/public-types.d.ts +65 -10
  93. package/src/route-renderer/GRAPH.md +16 -20
  94. package/src/route-renderer/README.md +8 -21
  95. package/src/route-renderer/component-graph/component-reference.d.ts +10 -0
  96. package/src/route-renderer/component-graph/component-reference.js +19 -0
  97. package/src/route-renderer/{marker-graph-resolver.d.ts → component-graph/marker-graph-resolver.d.ts} +6 -5
  98. package/src/route-renderer/{marker-graph-resolver.js → component-graph/marker-graph-resolver.js} +10 -8
  99. package/src/route-renderer/{integration-renderer.d.ts → orchestration/integration-renderer.d.ts} +45 -12
  100. package/src/route-renderer/{integration-renderer.js → orchestration/integration-renderer.js} +79 -16
  101. package/src/route-renderer/{render-execution.service.d.ts → orchestration/render-execution.service.d.ts} +39 -5
  102. package/src/route-renderer/{render-execution.service.js → orchestration/render-execution.service.js} +58 -28
  103. package/src/route-renderer/{render-preparation.service.d.ts → orchestration/render-preparation.service.d.ts} +13 -4
  104. package/src/route-renderer/{render-preparation.service.js → orchestration/render-preparation.service.js} +92 -3
  105. package/src/route-renderer/{dependency-resolver.d.ts → page-loading/dependency-resolver.d.ts} +15 -4
  106. package/src/route-renderer/{dependency-resolver.js → page-loading/dependency-resolver.js} +18 -4
  107. package/src/route-renderer/page-loading/page-module-loader.d.ts +87 -0
  108. package/src/route-renderer/{page-module-loader.js → page-loading/page-module-loader.js} +36 -14
  109. package/src/route-renderer/route-renderer.d.ts +36 -1
  110. package/src/route-renderer/route-renderer.js +19 -0
  111. package/src/router/README.md +26 -0
  112. package/src/router/client/link-intent.d.ts +53 -0
  113. package/src/router/client/link-intent.js +34 -0
  114. package/src/router/client/link-intent.test.browser.d.ts +1 -0
  115. package/src/router/client/link-intent.test.browser.js +43 -0
  116. package/src/router/client/navigation-coordinator.d.ts +149 -0
  117. package/src/router/client/navigation-coordinator.js +215 -0
  118. package/src/router/{fs-router-scanner.d.ts → server/fs-router-scanner.d.ts} +3 -3
  119. package/src/router/{fs-router-scanner.js → server/fs-router-scanner.js} +8 -7
  120. package/src/router/{fs-router.d.ts → server/fs-router.d.ts} +1 -1
  121. package/src/router/{fs-router.js → server/fs-router.js} +1 -1
  122. package/src/services/README.md +29 -0
  123. package/src/services/assets/asset-processing-service/asset-processing.service.d.ts +120 -0
  124. package/src/services/{asset-processing-service → assets/asset-processing-service}/asset-processing.service.js +88 -7
  125. package/src/services/{asset-processing-service → assets/asset-processing-service}/asset.factory.js +2 -2
  126. package/src/services/{asset-processing-service → assets/asset-processing-service}/assets.types.d.ts +2 -1
  127. package/src/services/assets/asset-processing-service/assets.types.js +0 -0
  128. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.d.ts +55 -0
  129. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.js +48 -0
  130. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.d.ts +20 -0
  131. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.js +41 -0
  132. package/src/services/{asset-processing-service → assets/asset-processing-service}/index.d.ts +2 -0
  133. package/src/services/{asset-processing-service → assets/asset-processing-service}/index.js +2 -0
  134. package/src/services/{asset-processing-service → assets/asset-processing-service}/processor.interface.d.ts +1 -1
  135. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/base/base-processor.d.ts +1 -1
  136. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/base/base-processor.js +9 -4
  137. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/base/base-script-processor.d.ts +3 -2
  138. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/base/base-script-processor.js +14 -22
  139. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/file-script.processor.d.ts +1 -1
  140. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/file-script.processor.js +2 -2
  141. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/node-module-script.processor.js +5 -4
  142. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/stylesheet/file-stylesheet.processor.js +4 -1
  143. package/src/services/assets/browser-bundle.service.d.ts +32 -0
  144. package/src/services/assets/browser-bundle.service.js +33 -0
  145. package/src/services/{page-request-cache-coordinator.service.d.ts → cache/page-request-cache-coordinator.service.d.ts} +2 -2
  146. package/src/services/{page-request-cache-coordinator.service.js → cache/page-request-cache-coordinator.service.js} +3 -1
  147. package/src/services/html/html-rewriter-provider.service.d.ts +37 -0
  148. package/src/services/html/html-rewriter-provider.service.js +65 -0
  149. package/src/services/html/html-transformer.service.d.ts +77 -0
  150. package/src/services/html/html-transformer.service.js +221 -0
  151. package/src/services/invalidation/development-invalidation.service.d.ts +74 -0
  152. package/src/services/invalidation/development-invalidation.service.js +189 -0
  153. package/src/services/module-loading/app-server-module-transpiler.service.d.ts +16 -0
  154. package/src/services/module-loading/app-server-module-transpiler.service.js +34 -0
  155. package/src/services/module-loading/page-module-import.service.d.ts +71 -0
  156. package/src/services/module-loading/page-module-import.service.js +132 -0
  157. package/src/services/module-loading/server-loader.service.d.ts +96 -0
  158. package/src/services/module-loading/server-loader.service.js +32 -0
  159. package/src/services/module-loading/server-module-transpiler.service.d.ts +69 -0
  160. package/src/services/module-loading/server-module-transpiler.service.js +61 -0
  161. package/src/services/runtime-manifest/node-runtime-manifest.service.d.ts +35 -0
  162. package/src/services/runtime-manifest/node-runtime-manifest.service.js +60 -0
  163. package/src/services/runtime-state/dev-graph.service.d.ts +118 -0
  164. package/src/services/runtime-state/dev-graph.service.js +162 -0
  165. package/src/services/runtime-state/entrypoint-dependency-graph.service.d.ts +41 -0
  166. package/src/services/runtime-state/entrypoint-dependency-graph.service.js +85 -0
  167. package/src/services/runtime-state/runtime-specifier-registry.service.d.ts +69 -0
  168. package/src/services/runtime-state/runtime-specifier-registry.service.js +37 -0
  169. package/src/services/runtime-state/server-invalidation-state.service.d.ts +26 -0
  170. package/src/services/runtime-state/server-invalidation-state.service.js +35 -0
  171. package/src/services/{schema-validation-service.d.ts → validation/schema-validation-service.d.ts} +1 -1
  172. package/src/static-site-generator/README.md +26 -0
  173. package/src/static-site-generator/static-site-generator.d.ts +53 -1
  174. package/src/static-site-generator/static-site-generator.js +86 -5
  175. package/src/utils/resolve-work-dir.d.ts +11 -0
  176. package/src/utils/resolve-work-dir.js +31 -0
  177. package/src/watchers/project-watcher.d.ts +37 -21
  178. package/src/watchers/project-watcher.js +109 -66
  179. package/src/watchers/project-watcher.test-helpers.js +1 -0
  180. package/src/adapters/abstract/application-adapter.ts +0 -337
  181. package/src/adapters/abstract/router-adapter.ts +0 -30
  182. package/src/adapters/abstract/server-adapter.ts +0 -79
  183. package/src/adapters/bun/client-bridge.ts +0 -62
  184. package/src/adapters/bun/create-app.ts +0 -189
  185. package/src/adapters/bun/define-api-handler.d.ts +0 -61
  186. package/src/adapters/bun/define-api-handler.ts +0 -114
  187. package/src/adapters/bun/hmr-manager.ts +0 -281
  188. package/src/adapters/bun/index.ts +0 -3
  189. package/src/adapters/bun/server-adapter.ts +0 -492
  190. package/src/adapters/bun/server-lifecycle.ts +0 -154
  191. package/src/adapters/index.ts +0 -6
  192. package/src/adapters/node/create-app.ts +0 -179
  193. package/src/adapters/node/index.ts +0 -9
  194. package/src/adapters/node/node-client-bridge.ts +0 -79
  195. package/src/adapters/node/node-hmr-manager.ts +0 -271
  196. package/src/adapters/node/server-adapter.ts +0 -561
  197. package/src/adapters/node/static-content-server.ts +0 -203
  198. package/src/adapters/shared/api-response.ts +0 -104
  199. package/src/adapters/shared/application-adapter.ts +0 -199
  200. package/src/adapters/shared/explicit-static-route-matcher.ts +0 -134
  201. package/src/adapters/shared/file-route-middleware-pipeline.ts +0 -123
  202. package/src/adapters/shared/fs-server-response-factory.ts +0 -118
  203. package/src/adapters/shared/fs-server-response-matcher.ts +0 -198
  204. package/src/adapters/shared/render-context.ts +0 -105
  205. package/src/adapters/shared/server-adapter.ts +0 -442
  206. package/src/adapters/shared/server-route-handler.ts +0 -166
  207. package/src/adapters/shared/server-static-builder.ts +0 -82
  208. package/src/build/build-adapter.ts +0 -132
  209. package/src/build/build-types.ts +0 -83
  210. package/src/build/esbuild-build-adapter.ts +0 -510
  211. package/src/config/config-builder.ts +0 -474
  212. package/src/constants.ts +0 -39
  213. package/src/create-app.ts +0 -87
  214. package/src/define-api-handler.js +0 -15
  215. package/src/define-api-handler.ts +0 -66
  216. package/src/dev/sc-server.ts +0 -143
  217. package/src/eco/component-render-context.ts +0 -202
  218. package/src/eco/eco.ts +0 -221
  219. package/src/eco/eco.types.ts +0 -202
  220. package/src/eco/eco.utils.ts +0 -89
  221. package/src/eco/global-injector-map.ts +0 -112
  222. package/src/eco/lazy-injector-map.ts +0 -120
  223. package/src/eco/module-dependencies.ts +0 -75
  224. package/src/errors/http-error.ts +0 -72
  225. package/src/errors/index.ts +0 -2
  226. package/src/errors/locals-access-error.ts +0 -7
  227. package/src/global/app-logger.ts +0 -4
  228. package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-HMR-Server-Integration-should-have-HMR-script-injected-in-page-1.png +0 -0
  229. package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-HMR-Server-Integration-should-load-fixture-app-page-1.png +0 -0
  230. package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-WebSocket-Connection-should-connect-to-correct-HMR-endpoint-1.png +0 -0
  231. package/src/hmr/client/hmr-runtime.ts +0 -121
  232. package/src/hmr/hmr-strategy.ts +0 -172
  233. package/src/hmr/hmr.test.e2e.ts +0 -75
  234. package/src/hmr/strategies/default-hmr-strategy.ts +0 -60
  235. package/src/hmr/strategies/js-hmr-strategy.ts +0 -308
  236. package/src/index.browser.ts +0 -3
  237. package/src/index.ts +0 -5
  238. package/src/integrations/ghtml/ghtml-renderer.ts +0 -93
  239. package/src/integrations/ghtml/ghtml.plugin.ts +0 -32
  240. package/src/internal-types.ts +0 -212
  241. package/src/plugins/alias-resolver-plugin.ts +0 -45
  242. package/src/plugins/eco-component-meta-plugin.ts +0 -474
  243. package/src/plugins/integration-plugin.ts +0 -184
  244. package/src/plugins/processor.ts +0 -220
  245. package/src/public-types.ts +0 -1255
  246. package/src/route-renderer/component-graph-executor.ts +0 -84
  247. package/src/route-renderer/component-graph.ts +0 -159
  248. package/src/route-renderer/component-marker.ts +0 -117
  249. package/src/route-renderer/dependency-resolver.ts +0 -596
  250. package/src/route-renderer/html-post-processing.service.d.ts +0 -40
  251. package/src/route-renderer/html-post-processing.service.js +0 -86
  252. package/src/route-renderer/html-post-processing.service.ts +0 -103
  253. package/src/route-renderer/integration-renderer.ts +0 -696
  254. package/src/route-renderer/marker-graph-resolver.ts +0 -153
  255. package/src/route-renderer/page-module-loader.d.ts +0 -61
  256. package/src/route-renderer/page-module-loader.ts +0 -153
  257. package/src/route-renderer/render-execution.service.ts +0 -158
  258. package/src/route-renderer/render-preparation.service.ts +0 -358
  259. package/src/route-renderer/route-renderer.ts +0 -80
  260. package/src/router/fs-router-scanner.ts +0 -217
  261. package/src/router/fs-router.ts +0 -122
  262. package/src/services/asset-processing-service/asset-processing.service.d.ts +0 -41
  263. package/src/services/asset-processing-service/asset-processing.service.ts +0 -306
  264. package/src/services/asset-processing-service/asset.factory.ts +0 -105
  265. package/src/services/asset-processing-service/assets.types.ts +0 -112
  266. package/src/services/asset-processing-service/index.ts +0 -3
  267. package/src/services/asset-processing-service/processor.interface.ts +0 -27
  268. package/src/services/asset-processing-service/processor.registry.ts +0 -18
  269. package/src/services/asset-processing-service/processors/base/base-processor.ts +0 -76
  270. package/src/services/asset-processing-service/processors/base/base-script-processor.ts +0 -105
  271. package/src/services/asset-processing-service/processors/index.ts +0 -5
  272. package/src/services/asset-processing-service/processors/script/content-script.processor.ts +0 -66
  273. package/src/services/asset-processing-service/processors/script/file-script.processor.ts +0 -88
  274. package/src/services/asset-processing-service/processors/script/node-module-script.processor.ts +0 -84
  275. package/src/services/asset-processing-service/processors/stylesheet/content-stylesheet.processor.ts +0 -27
  276. package/src/services/asset-processing-service/processors/stylesheet/file-stylesheet.processor.ts +0 -77
  277. package/src/services/cache/cache.types.ts +0 -126
  278. package/src/services/cache/index.ts +0 -18
  279. package/src/services/cache/memory-cache-store.ts +0 -130
  280. package/src/services/cache/page-cache-service.ts +0 -202
  281. package/src/services/html-transformer.service.d.ts +0 -50
  282. package/src/services/html-transformer.service.js +0 -163
  283. package/src/services/html-transformer.service.ts +0 -217
  284. package/src/services/page-module-import.service.d.ts +0 -37
  285. package/src/services/page-module-import.service.js +0 -88
  286. package/src/services/page-module-import.service.ts +0 -129
  287. package/src/services/page-request-cache-coordinator.service.ts +0 -128
  288. package/src/services/schema-validation-service.ts +0 -204
  289. package/src/services/validation/standard-schema.types.ts +0 -68
  290. package/src/static-site-generator/static-site-generator.ts +0 -359
  291. package/src/utils/css.ts +0 -5
  292. package/src/utils/deep-merge.ts +0 -47
  293. package/src/utils/hash.ts +0 -5
  294. package/src/utils/html.ts +0 -1
  295. package/src/utils/invariant.ts +0 -15
  296. package/src/utils/locals-utils.ts +0 -37
  297. package/src/utils/parse-cli-args.ts +0 -83
  298. package/src/utils/path-utils.module.ts +0 -14
  299. package/src/utils/runtime.ts +0 -44
  300. package/src/utils/server-utils.module.ts +0 -67
  301. package/src/watchers/project-watcher.test-helpers.ts +0 -40
  302. package/src/watchers/project-watcher.ts +0 -306
  303. /package/src/adapters/{bun → shared}/define-api-handler.js +0 -0
  304. /package/src/{services/asset-processing-service/assets.types.js → plugins/runtime-capability.js} +0 -0
  305. /package/src/route-renderer/{component-graph-executor.d.ts → component-graph/component-graph-executor.d.ts} +0 -0
  306. /package/src/route-renderer/{component-graph-executor.js → component-graph/component-graph-executor.js} +0 -0
  307. /package/src/route-renderer/{component-graph.d.ts → component-graph/component-graph.d.ts} +0 -0
  308. /package/src/route-renderer/{component-graph.js → component-graph/component-graph.js} +0 -0
  309. /package/src/route-renderer/{component-marker.d.ts → component-graph/component-marker.d.ts} +0 -0
  310. /package/src/route-renderer/{component-marker.js → component-graph/component-marker.js} +0 -0
  311. /package/src/services/{asset-processing-service → assets/asset-processing-service}/asset.factory.d.ts +0 -0
  312. /package/src/services/{asset-processing-service → assets/asset-processing-service}/processor.interface.js +0 -0
  313. /package/src/services/{asset-processing-service → assets/asset-processing-service}/processor.registry.d.ts +0 -0
  314. /package/src/services/{asset-processing-service → assets/asset-processing-service}/processor.registry.js +0 -0
  315. /package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/index.d.ts +0 -0
  316. /package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/index.js +0 -0
  317. /package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/content-script.processor.d.ts +0 -0
  318. /package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/content-script.processor.js +0 -0
  319. /package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/node-module-script.processor.d.ts +0 -0
  320. /package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/stylesheet/content-stylesheet.processor.d.ts +0 -0
  321. /package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/stylesheet/content-stylesheet.processor.js +0 -0
  322. /package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/stylesheet/file-stylesheet.processor.d.ts +0 -0
  323. /package/src/services/{schema-validation-service.js → validation/schema-validation-service.js} +0 -0
@@ -1,308 +0,0 @@
1
- /**
2
- * JavaScript HMR Strategy
3
- *
4
- * Handles hot module replacement for JavaScript and TypeScript entrypoints.
5
- * Bundles files, replaces bare specifiers, and injects HMR boilerplate.
6
- *
7
- * @module
8
- */
9
-
10
- import path from 'node:path';
11
- import { fileSystem } from '@ecopages/file-system';
12
- import { HmrStrategy, HmrStrategyType, type HmrAction } from '../hmr-strategy';
13
- import { appLogger } from '../../global/app-logger';
14
- import { defaultBuildAdapter } from '../../build/build-adapter.ts';
15
- import type { EcoBuildPlugin } from '../../build/build-types.ts';
16
-
17
- /**
18
- * Context interface providing access to HmrManager state.
19
- * Required for JsHmrStrategy to access registered entrypoints and configuration.
20
- */
21
- export interface JsHmrContext {
22
- /**
23
- * Map of registered entrypoints to their output URLs.
24
- */
25
- getWatchedFiles(): Map<string, string>;
26
-
27
- /**
28
- * Map of bare specifiers to vendor URLs for import resolution.
29
- */
30
- getSpecifierMap(): Map<string, string>;
31
-
32
- /**
33
- * Returns entrypoints impacted by a changed dependency path.
34
- *
35
- * @remarks
36
- * This hook is currently provided by the Node HMR manager where dependency
37
- * graph metadata is extracted from the Node/esbuild build adapter.
38
- */
39
- getDependencyEntrypoints?(filePath: string): Set<string>;
40
-
41
- /**
42
- * Stores latest dependency set for an entrypoint.
43
- *
44
- * @remarks
45
- * This hook is currently used only by the Node HMR manager to maintain a
46
- * reverse invalidation index. Runtimes that do not provide it keep rebuild-all
47
- * fallback semantics.
48
- */
49
- setEntrypointDependencies?(entrypointPath: string, dependencies: string[]): void;
50
-
51
- /**
52
- * Directory where HMR bundles are written.
53
- */
54
- getDistDir(): string;
55
-
56
- /**
57
- * Build plugins to use during bundling.
58
- */
59
- getPlugins(): EcoBuildPlugin[];
60
-
61
- /**
62
- * Absolute path to the source directory.
63
- */
64
- getSrcDir(): string;
65
- }
66
-
67
- /**
68
- * Strategy for handling JavaScript/TypeScript file changes with hot reloading.
69
- *
70
- * This strategy rebuilds all registered entrypoints when any file changes,
71
- * as we don't currently track dependencies. This is safe but inefficient.
72
- *
73
- * The processing steps are:
74
- * 1. Check if any entrypoints are registered
75
- * 2. Rebuild all entrypoints (the changed file could be a dependency)
76
- * 3. Replace bare specifiers with vendor URLs
77
- * 4. Inject generic HMR boilerplate
78
- * 5. Broadcast update events for each rebuilt entrypoint
79
- *
80
- * @remarks
81
- * Future enhancement: Track dependencies using Bun's transpiler API to only
82
- * rebuild affected entrypoints instead of all of them.
83
- *
84
- * @see https://bun.sh/docs/runtime/transpiler
85
- *
86
- * @example
87
- * ```typescript
88
- * const context = {
89
- * getWatchedFiles: () => watchedFilesMap,
90
- * getSpecifierMap: () => specifierMap,
91
- * getDistDir: () => '/path/to/dist/_hmr',
92
- * getPlugins: () => [],
93
- * getSrcDir: () => '/path/to/src'
94
- * };
95
- * const strategy = new JsHmrStrategy(context);
96
- * ```
97
- */
98
- export class JsHmrStrategy extends HmrStrategy {
99
- readonly type = HmrStrategyType.SCRIPT;
100
-
101
- constructor(private context: JsHmrContext) {
102
- super();
103
- }
104
-
105
- /**
106
- * Determines if the file is a JS/TS file that could affect registered entrypoints.
107
- *
108
- * Matches if:
109
- * 1. There are registered entrypoints to rebuild
110
- * 2. The changed file is a JS/TS file in the src directory
111
- *
112
- * @param filePath - Absolute path to the changed file
113
- * @returns True if this file should trigger entrypoint rebuilds
114
- */
115
- matches(filePath: string): boolean {
116
- const watchedFiles = this.context.getWatchedFiles();
117
- const isJsTs = /\.(ts|tsx|js|jsx)$/.test(filePath);
118
- const isInSrc = filePath.startsWith(this.context.getSrcDir());
119
-
120
- if (watchedFiles.size === 0) {
121
- return false;
122
- }
123
-
124
- return isJsTs && isInSrc;
125
- }
126
-
127
- /**
128
- * Processes a file change by rebuilding affected entrypoints.
129
- *
130
- * @param filePath - Absolute path to the changed file
131
- *
132
- * @remarks
133
- * If runtime-specific dependency graph hooks are unavailable, this strategy
134
- * falls back to rebuilding all watched entrypoints.
135
- * @returns Action to broadcast update events
136
- */
137
- async process(filePath: string): Promise<HmrAction> {
138
- appLogger.debug(`[JsHmrStrategy] Processing ${filePath}`);
139
- const watchedFiles = this.context.getWatchedFiles();
140
-
141
- if (watchedFiles.size === 0) {
142
- appLogger.debug(`[JsHmrStrategy] No watched files to rebuild`);
143
- return { type: 'none' };
144
- }
145
-
146
- const updates: string[] = [];
147
- let reloadRequired = false;
148
- const dependencyHits = this.context.getDependencyEntrypoints?.(filePath) ?? new Set<string>();
149
- const hasDependencyHit = dependencyHits.size > 0;
150
- const impactedEntrypoints = hasDependencyHit
151
- ? Array.from(dependencyHits).filter((entrypoint) => watchedFiles.has(entrypoint))
152
- : Array.from(watchedFiles.keys());
153
-
154
- if (!hasDependencyHit) {
155
- appLogger.debug('[JsHmrStrategy] Dependency graph miss, rebuilding all watched entrypoints');
156
- }
157
-
158
- for (const entrypoint of impactedEntrypoints) {
159
- const outputUrl = watchedFiles.get(entrypoint);
160
- if (!outputUrl) {
161
- continue;
162
- }
163
-
164
- const result = await this.bundleEntrypoint(entrypoint, outputUrl);
165
- if (result.success) {
166
- if (result.dependencies && this.context.setEntrypointDependencies) {
167
- this.context.setEntrypointDependencies(entrypoint, result.dependencies);
168
- }
169
-
170
- updates.push(outputUrl);
171
- if (result.requiresReload) {
172
- reloadRequired = true;
173
- }
174
- }
175
- }
176
-
177
- if (updates.length > 0) {
178
- if (reloadRequired) {
179
- appLogger.debug(`[JsHmrStrategy] Full reload required (no HMR accept found)`);
180
- return {
181
- type: 'broadcast',
182
- events: [
183
- {
184
- type: 'reload',
185
- },
186
- ],
187
- };
188
- }
189
-
190
- return {
191
- type: 'broadcast',
192
- events: updates.map((path) => ({
193
- type: 'update',
194
- path,
195
- timestamp: Date.now(),
196
- })),
197
- };
198
- }
199
-
200
- return { type: 'none' };
201
- }
202
-
203
- /**
204
- * Bundles a single entrypoint and processes the output.
205
- *
206
- * @param entrypointPath - Absolute path to the source file
207
- * @param outputUrl - URL path for the bundled file
208
- * @returns True if bundling was successful
209
- */
210
- private async bundleEntrypoint(
211
- entrypointPath: string,
212
- outputUrl: string,
213
- ): Promise<{ success: boolean; requiresReload: boolean; dependencies?: string[] }> {
214
- try {
215
- const srcDir = this.context.getSrcDir();
216
- const relativePath = path.relative(srcDir, entrypointPath);
217
- const relativePathJs = relativePath.replace(/\.(tsx?|jsx?)$/, '.js');
218
- const outputPath = path.join(this.context.getDistDir(), relativePathJs);
219
-
220
- const result = await defaultBuildAdapter.build({
221
- entrypoints: [entrypointPath],
222
- outdir: this.context.getDistDir(),
223
- naming: relativePathJs,
224
- ...defaultBuildAdapter.getTranspileOptions('hmr-entrypoint'),
225
- plugins: this.context.getPlugins(),
226
- minify: false,
227
- external: ['react', 'react-dom'],
228
- });
229
-
230
- if (!result.success) {
231
- appLogger.error(`[JsHmrStrategy] Failed to build ${entrypointPath}:`, result.logs);
232
- return { success: false, requiresReload: false, dependencies: undefined };
233
- }
234
-
235
- const dependencyGraph = result.dependencyGraph?.entrypoints?.[path.resolve(entrypointPath)] ?? [];
236
- const output = await this.processOutput(outputPath, outputUrl);
237
-
238
- return {
239
- ...output,
240
- dependencies: dependencyGraph,
241
- };
242
- } catch (error) {
243
- appLogger.error(`[JsHmrStrategy] Error bundling ${entrypointPath}:`, error as Error);
244
- return { success: false, requiresReload: false, dependencies: undefined };
245
- }
246
- }
247
-
248
- /**
249
- * Processes bundled output by replacing specifiers and injecting HMR code.
250
- *
251
- * @param filepath - Path to the bundled output file
252
- * @param url - URL path for the bundled file
253
- * @returns True if processing was successful and update should be broadcast
254
- */
255
- private async processOutput(filepath: string, url: string): Promise<{ success: boolean; requiresReload: boolean }> {
256
- try {
257
- let code = await fileSystem.readFile(filepath);
258
-
259
- if (code.includes('/* [ecopages] hmr */')) {
260
- /**
261
- * Already processed, assume it supports HMR if it has the header (legacy safety)
262
- * or check specifically for accept
263
- */
264
- return { success: true, requiresReload: !code.includes('import.meta.hot.accept') };
265
- }
266
-
267
- code = this.replaceBareSpecifiers(code);
268
- await fileSystem.writeAsync(filepath, code);
269
-
270
- appLogger.debug(`[JsHmrStrategy] Processed ${url}`);
271
-
272
- /**
273
- * Implicit HMR check: if the code explicitly accepts HMR, we broadcast update.
274
- * Otherwise, we must reload the page to ensure fresh execution (e.g. for Custom Elements or side effects).
275
- */
276
- const hasHmrAccept = code.includes('import.meta.hot.accept');
277
- return { success: true, requiresReload: !hasHmrAccept };
278
- } catch (error) {
279
- appLogger.error(`[JsHmrStrategy] Error processing output for ${url}:`, error as Error);
280
- return { success: false, requiresReload: false };
281
- }
282
- }
283
-
284
- /**
285
- * Replaces bare specifiers with vendor URLs.
286
- *
287
- * Handles both static imports and dynamic imports.
288
- *
289
- * @param code - The bundled code to transform
290
- * @returns The transformed code with vendor URLs
291
- */
292
- private replaceBareSpecifiers(code: string): string {
293
- const specifierMap = this.context.getSpecifierMap();
294
-
295
- if (specifierMap.size === 0) {
296
- return code;
297
- }
298
-
299
- let result = code;
300
- for (const [bareSpec, vendorUrl] of specifierMap.entries()) {
301
- const escaped = bareSpec.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
302
- result = result.replace(new RegExp(`from\\s*["']${escaped}["']`, 'g'), `from "${vendorUrl}"`);
303
- result = result.replace(new RegExp(`import\\(["']${escaped}["']\\)`, 'g'), `import("${vendorUrl}")`);
304
- }
305
-
306
- return result;
307
- }
308
- }
@@ -1,3 +0,0 @@
1
- export type * from './public-types.ts';
2
- export type * from './eco/eco.types.ts';
3
- export { eco } from './eco/eco.ts';
package/src/index.ts DELETED
@@ -1,5 +0,0 @@
1
- export type * from './public-types.ts';
2
- export type * from './eco/eco.types.ts';
3
- export { eco } from './eco/eco.ts';
4
- export { EcopagesApp, createApp, type EcopagesAppOptions } from './create-app.ts';
5
- export { defineApiHandler, defineGroupHandler, type GroupHandler } from './define-api-handler.ts';
@@ -1,93 +0,0 @@
1
- /**
2
- * This module contains the ghtml renderer
3
- * @module
4
- */
5
-
6
- import type {
7
- EcoComponent,
8
- EcoPagesElement,
9
- IntegrationRendererRenderOptions,
10
- PageMetadataProps,
11
- RouteRendererBody,
12
- } from '../../public-types.ts';
13
- import { IntegrationRenderer, type RenderToResponseContext } from '../../route-renderer/integration-renderer.ts';
14
- import { GHTML_PLUGIN_NAME } from './ghtml.plugin.ts';
15
-
16
- /**
17
- * A renderer for the ghtml integration.
18
- * It renders a page using the HtmlTemplate and Page components.
19
- */
20
- export class GhtmlRenderer extends IntegrationRenderer<EcoPagesElement> {
21
- name = GHTML_PLUGIN_NAME;
22
-
23
- async render({
24
- params,
25
- query,
26
- props,
27
- locals,
28
- pageLocals,
29
- metadata,
30
- Page,
31
- Layout,
32
- HtmlTemplate,
33
- }: IntegrationRendererRenderOptions): Promise<RouteRendererBody> {
34
- try {
35
- const pageContent = await Page({ params, query, ...props, locals: pageLocals });
36
- const children =
37
- Layout && typeof Layout === 'function' ? await Layout({ children: pageContent, locals }) : pageContent;
38
- const body = await HtmlTemplate({
39
- metadata,
40
- children,
41
- pageProps: props || {},
42
- });
43
-
44
- return this.DOC_TYPE + body;
45
- } catch (error) {
46
- throw this.createRenderError('Error rendering page', error);
47
- }
48
- }
49
-
50
- async renderToResponse<P = Record<string, unknown>>(
51
- view: EcoComponent<P>,
52
- props: P,
53
- ctx: RenderToResponseContext,
54
- ): Promise<Response> {
55
- try {
56
- const Layout = view.config?.layout as
57
- | ((props: { children: EcoPagesElement } & Record<string, unknown>) => Promise<EcoPagesElement>)
58
- | undefined;
59
-
60
- const viewFn = view as (props: P) => Promise<EcoPagesElement>;
61
- const pageContent = await viewFn(props);
62
-
63
- let body: string;
64
- if (ctx.partial) {
65
- body = pageContent as string;
66
- } else {
67
- const children = Layout ? await Layout({ children: pageContent }) : pageContent;
68
-
69
- const HtmlTemplate = await this.getHtmlTemplate();
70
- const metadata: PageMetadataProps = view.metadata
71
- ? await view.metadata({
72
- params: {},
73
- query: {},
74
- props: props as Record<string, unknown>,
75
- appConfig: this.appConfig,
76
- })
77
- : this.appConfig.defaultMetadata;
78
-
79
- body =
80
- this.DOC_TYPE +
81
- (await HtmlTemplate({
82
- metadata,
83
- children: children as EcoPagesElement,
84
- pageProps: props as Record<string, unknown>,
85
- }));
86
- }
87
-
88
- return this.createHtmlResponse(body, ctx);
89
- } catch (error) {
90
- throw this.createRenderError('Error rendering view', error);
91
- }
92
- }
93
- }
@@ -1,32 +0,0 @@
1
- import { IntegrationPlugin, type IntegrationPluginConfig } from '../../plugins/integration-plugin';
2
- import { GhtmlRenderer } from './ghtml-renderer';
3
-
4
- /**
5
- * The name of the ghtml plugin
6
- */
7
- export const GHTML_PLUGIN_NAME = 'ghtml';
8
-
9
- /**
10
- * The Ghtml plugin class
11
- * This plugin provides support for ghtml components in Ecopages
12
- */
13
- export class GhtmlPlugin extends IntegrationPlugin {
14
- renderer = GhtmlRenderer;
15
-
16
- constructor(options?: Omit<IntegrationPluginConfig, 'name'>) {
17
- super({
18
- name: GHTML_PLUGIN_NAME,
19
- extensions: ['.ghtml.ts', '.ghtml.tsx', '.ghtml'],
20
- ...options,
21
- });
22
- }
23
- }
24
-
25
- /**
26
- * Factory function to create a Ghtml plugin instance
27
- * @param options Configuration options for the Ghtml plugin
28
- * @returns A new GhtmlPlugin instance
29
- */
30
- export function ghtmlPlugin(options?: Omit<IntegrationPluginConfig, 'name'>): GhtmlPlugin {
31
- return new GhtmlPlugin(options);
32
- }
@@ -1,212 +0,0 @@
1
- import type { EcoBuildPlugin } from './build/build-types.ts';
2
- import type { IntegrationPlugin } from './plugins/integration-plugin.ts';
3
- import type { Processor } from './plugins/processor.ts';
4
- import type { PageMetadataProps } from './public-types.ts';
5
- import type { FSRouter } from './router/fs-router.ts';
6
- import type { CacheConfig } from './services/cache/cache.types.ts';
7
-
8
- /**
9
- * The templates used to build the pages and loaded via the includes directory.
10
- */
11
- export type IncludesTemplates = {
12
- head: string;
13
- html: string;
14
- seo: string;
15
- };
16
-
17
- export interface RobotsPreference {
18
- /**
19
- * The user agent
20
- * If an empty array is provided, it will enable all paths for the user agent
21
- * If a path is provided, it will disallow the path for the user agent
22
- */
23
- [key: string]: string[];
24
- }
25
-
26
- /**
27
- * Represents the complete configuration object for EcoPages.
28
- */
29
- export type EcoPagesAppConfig = {
30
- /**
31
- * The base URL of the website, localhost or the domain
32
- */
33
- baseUrl: string;
34
- /**
35
- * The root directory of the project
36
- * @default "."
37
- */
38
- rootDir: string;
39
- /**
40
- * The root directory of the project
41
- * @default "src"
42
- */
43
- srcDir: string;
44
- /**
45
- * The directory where the public files are located
46
- * @default "public"
47
- */
48
- publicDir: string;
49
- /**
50
- * The directory where the pages are located
51
- * @default "pages"
52
- */
53
- pagesDir: string;
54
- /**
55
- * The directory where the includes templates are located
56
- * @default "includes"
57
- */
58
- includesDir: string;
59
- /**
60
- * The directory where the layouts are located
61
- * @default "layouts"
62
- */
63
- layoutsDir: string;
64
- /**
65
- * The templates used for the pages
66
- * @default "{head: 'head.kita.tsx', html: 'html.kita.tsx', seo: 'seo.kita.tsx'}"
67
- */
68
- includesTemplates: IncludesTemplates;
69
- /** Error 404 page
70
- * @default "404.kita.tsx"
71
- */
72
- error404Template: string;
73
- /**
74
- * The directory where the output will be located
75
- * @default "dist"
76
- */
77
- distDir: string;
78
- /**
79
- * The templates extensions based on the integrations
80
- */
81
- templatesExt: string[];
82
- /**
83
- * The directory where the components are located
84
- * @default "components"
85
- */
86
- componentsDir: string;
87
- /**
88
- * The robots.txt configuration
89
- */
90
- robotsTxt: {
91
- /**
92
- * The robots preferences. The key is the user agent and the value is the disallowed paths.
93
- * @default { "*": [] }
94
- */
95
- preferences: RobotsPreference;
96
- };
97
- /** Additional paths to watch. Use this to monitor extra files. It is relative to the rootDir */
98
- additionalWatchPaths: string[];
99
- /**
100
- * @default { title: 'Ecopages', description: 'Ecopages' }
101
- */
102
- defaultMetadata: PageMetadataProps;
103
- /** Integrations plugins */
104
- integrations: IntegrationPlugin[];
105
- /** Integrations dependencies */
106
- integrationsDependencies: IntegrationDependencyConfig[];
107
- /** Derived Paths */
108
- absolutePaths: {
109
- config: string;
110
- componentsDir: string;
111
- distDir: string;
112
- includesDir: string;
113
- layoutsDir: string;
114
- pagesDir: string;
115
- projectDir: string;
116
- publicDir: string;
117
- srcDir: string;
118
- htmlTemplatePath: string;
119
- error404TemplatePath: string;
120
- };
121
- /**
122
- * The processors to be used in the app
123
- */
124
- processors: Map<string, Processor>;
125
- /**
126
- * Loaders to be used in the app, these are used to process the files when importing them
127
- */
128
- loaders: Map<string, EcoBuildPlugin>;
129
- /**
130
- * Cache configuration for ISR and page caching.
131
- * @default { store: 'memory', defaultStrategy: 'static', enabled: true }
132
- */
133
- cache?: CacheConfig;
134
- /**
135
- * Experimental features.
136
- */
137
- experimental?: {
138
- /** Escape hatch for short-lived private toggles. No validation or IntelliSense. */
139
- unsafe?: Record<string, unknown>;
140
- };
141
- };
142
-
143
- export type IntegrationDependencyConfig = {
144
- integration: string;
145
- kind: 'script' | 'stylesheet';
146
- position?: 'head' | 'body';
147
- srcUrl: string;
148
- filePath: string;
149
- /** @todo inline dependencies not implemented yet */
150
- inline?: boolean;
151
- };
152
-
153
- /**
154
- * The possible kinds of a route.
155
- */
156
- export type RouteKind = 'exact' | 'catch-all' | 'dynamic';
157
-
158
- /**
159
- * Represents the result of a route match.
160
- */
161
- export type MatchResult = {
162
- filePath: string;
163
- kind: RouteKind;
164
- pathname: string;
165
- query?: Record<string, string>;
166
- params?: Record<string, string | string[]>;
167
- };
168
-
169
- /**
170
- * Represents a route in EcoPages.
171
- */
172
- export type Route = {
173
- kind: RouteKind;
174
- filePath: string;
175
- pathname: string;
176
- };
177
-
178
- /**
179
- * Represents the routes in EcoPages.
180
- */
181
- export type Routes = Record<string, Route>;
182
-
183
- /**
184
- * Represents the options for the file system server.
185
- */
186
- export type FileSystemServerOptions = {
187
- watchMode: boolean;
188
- port?: number | string;
189
- };
190
-
191
- /**
192
- * Represents the file system server adapter.
193
- */
194
- export interface EcoPagesFileSystemServerAdapter<ServerInstanceOptions = unknown> {
195
- startServer(serverOptions: ServerInstanceOptions):
196
- | {
197
- router: FSRouter;
198
- server: unknown;
199
- }
200
- | Promise<{ router: FSRouter; server: unknown }>;
201
- }
202
-
203
- export interface ProcessorPlugin {
204
- name: string;
205
- description?: string;
206
- setup(): Promise<void>;
207
- process<T = unknown>(input: T): Promise<T>;
208
- teardown?(): Promise<void>;
209
- }
210
-
211
- // Re-export HMR types from public-types for internal use
212
- export type { ClientBridgeEvent, DefaultHmrContext, IHmrManager, IClientBridge } from './public-types.ts';
@@ -1,45 +0,0 @@
1
- import { existsSync } from 'node:fs';
2
- import path from 'node:path';
3
- import type { EcoBuildPlugin } from '../build/build-types.ts';
4
-
5
- const RESOLVABLE_EXTENSIONS = ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs', '.mdx', '.css', '.scss', '.sass', '.less'];
6
-
7
- function findResolvablePath(candidate: string): string | undefined {
8
- if (path.extname(candidate)) {
9
- return existsSync(candidate) ? candidate : undefined;
10
- }
11
-
12
- for (const extension of RESOLVABLE_EXTENSIONS) {
13
- const fileCandidate = `${candidate}${extension}`;
14
- if (existsSync(fileCandidate)) {
15
- return fileCandidate;
16
- }
17
- }
18
-
19
- for (const extension of RESOLVABLE_EXTENSIONS) {
20
- const indexCandidate = path.join(candidate, `index${extension}`);
21
- if (existsSync(indexCandidate)) {
22
- return indexCandidate;
23
- }
24
- }
25
-
26
- return undefined;
27
- }
28
-
29
- export function createAliasResolverPlugin(srcDir: string): EcoBuildPlugin {
30
- return {
31
- name: 'ecopages-alias-resolver',
32
- setup(build) {
33
- build.onResolve({ filter: /^@\// }, (args) => {
34
- const candidate = path.join(srcDir, args.path.slice(2));
35
- const resolved = findResolvablePath(candidate);
36
-
37
- if (resolved) {
38
- return { path: resolved };
39
- }
40
-
41
- return {};
42
- });
43
- },
44
- };
45
- }