@ecopages/core 0.2.0-alpha.2 → 0.2.0-alpha.21

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 (391) hide show
  1. package/CHANGELOG.md +26 -64
  2. package/README.md +212 -14
  3. package/package.json +116 -66
  4. package/src/adapters/README.md +39 -0
  5. package/src/adapters/abstract/application-adapter.d.ts +28 -2
  6. package/src/adapters/abstract/application-adapter.js +14 -2
  7. package/src/adapters/abstract/router-adapter.d.ts +1 -1
  8. package/src/adapters/abstract/server-adapter.d.ts +2 -2
  9. package/src/adapters/bun/client-bridge.d.ts +1 -1
  10. package/src/adapters/bun/create-app.d.ts +4 -12
  11. package/src/adapters/bun/create-app.js +4 -5
  12. package/src/adapters/bun/hmr-manager.d.ts +80 -21
  13. package/src/adapters/bun/hmr-manager.js +168 -62
  14. package/src/adapters/bun/index.d.ts +2 -3
  15. package/src/adapters/bun/index.js +3 -3
  16. package/src/adapters/bun/server-adapter.d.ts +5 -5
  17. package/src/adapters/bun/server-adapter.js +40 -34
  18. package/src/adapters/bun/server-lifecycle.d.ts +28 -17
  19. package/src/adapters/bun/server-lifecycle.js +34 -62
  20. package/src/{create-app.d.ts → adapters/create-app.d.ts} +9 -6
  21. package/src/{create-app.js → adapters/create-app.js} +4 -4
  22. package/src/adapters/index.d.ts +2 -6
  23. package/src/adapters/index.js +2 -8
  24. package/src/adapters/node/create-app.d.ts +6 -9
  25. package/src/adapters/node/create-app.js +12 -6
  26. package/src/adapters/node/node-client-bridge.d.ts +1 -1
  27. package/src/adapters/node/node-hmr-manager.d.ts +89 -18
  28. package/src/adapters/node/node-hmr-manager.js +185 -95
  29. package/src/adapters/node/server-adapter.d.ts +6 -35
  30. package/src/adapters/node/server-adapter.js +44 -105
  31. package/src/adapters/node/static-content-server.d.ts +37 -1
  32. package/src/adapters/node/static-content-server.js +29 -1
  33. package/src/adapters/shared/application-adapter.d.ts +1 -1
  34. package/src/{define-api-handler.d.ts → adapters/shared/define-api-handler.d.ts} +1 -1
  35. package/src/adapters/shared/explicit-static-route-matcher.d.ts +2 -2
  36. package/src/adapters/shared/explicit-static-route-matcher.js +4 -1
  37. package/src/adapters/shared/file-route-middleware-pipeline.d.ts +1 -1
  38. package/src/adapters/shared/file-route-middleware-pipeline.js +1 -0
  39. package/src/adapters/shared/fs-server-response-factory.d.ts +2 -2
  40. package/src/adapters/shared/fs-server-response-factory.js +1 -1
  41. package/src/adapters/shared/fs-server-response-matcher.d.ts +8 -12
  42. package/src/adapters/shared/fs-server-response-matcher.js +10 -18
  43. package/src/adapters/shared/hmr-entrypoint-registrar.d.ts +55 -0
  44. package/src/adapters/shared/hmr-entrypoint-registrar.js +87 -0
  45. package/src/adapters/shared/hmr-html-response.d.ts +22 -0
  46. package/src/adapters/shared/hmr-html-response.js +32 -0
  47. package/src/adapters/shared/render-context.d.ts +2 -1
  48. package/src/adapters/shared/render-context.js +6 -3
  49. package/src/adapters/shared/runtime-bootstrap.d.ts +38 -0
  50. package/src/adapters/shared/runtime-bootstrap.js +43 -0
  51. package/src/adapters/shared/server-adapter.d.ts +13 -3
  52. package/src/adapters/shared/server-adapter.js +42 -5
  53. package/src/adapters/shared/server-route-handler.d.ts +4 -4
  54. package/src/adapters/shared/server-route-handler.js +6 -15
  55. package/src/adapters/shared/server-static-builder.d.ts +38 -6
  56. package/src/adapters/shared/server-static-builder.js +64 -10
  57. package/src/build/README.md +107 -0
  58. package/src/build/build-adapter.d.ts +168 -3
  59. package/src/build/build-adapter.js +604 -16
  60. package/src/build/build-manifest.d.ts +27 -0
  61. package/src/build/build-manifest.js +30 -0
  62. package/src/build/dev-build-coordinator.d.ts +72 -0
  63. package/src/build/dev-build-coordinator.js +154 -0
  64. package/src/build/esbuild-build-adapter.d.ts +15 -6
  65. package/src/build/esbuild-build-adapter.js +189 -74
  66. package/src/build/runtime-build-executor.d.ts +14 -0
  67. package/src/build/runtime-build-executor.js +22 -0
  68. package/src/build/runtime-specifier-alias-plugin.d.ts +15 -0
  69. package/src/build/runtime-specifier-alias-plugin.js +35 -0
  70. package/src/build/runtime-specifier-aliases.d.ts +5 -0
  71. package/src/build/runtime-specifier-aliases.js +95 -0
  72. package/src/config/README.md +36 -0
  73. package/src/config/config-builder.d.ts +52 -27
  74. package/src/config/config-builder.js +260 -49
  75. package/src/{constants.d.ts → config/constants.d.ts} +13 -0
  76. package/src/{constants.js → config/constants.js} +4 -0
  77. package/src/declarations.d.ts +19 -14
  78. package/src/dev/sc-server.d.ts +1 -1
  79. package/src/dev/sc-server.js +1 -1
  80. package/src/eco/README.md +70 -16
  81. package/src/eco/eco.browser.d.ts +2 -0
  82. package/src/eco/eco.browser.js +83 -0
  83. package/src/eco/eco.js +32 -57
  84. package/src/eco/eco.types.d.ts +12 -4
  85. package/src/eco/eco.utils.d.ts +1 -40
  86. package/src/eco/eco.utils.js +5 -35
  87. package/src/eco/global-injector-map.d.ts +1 -1
  88. package/src/eco/lazy-injector-map.d.ts +1 -1
  89. package/src/hmr/README.md +26 -0
  90. package/src/hmr/client/hmr-runtime.d.ts +1 -6
  91. package/src/hmr/client/hmr-runtime.js +30 -7
  92. package/src/hmr/hmr-strategy.d.ts +16 -13
  93. package/src/hmr/hmr-strategy.js +22 -7
  94. package/src/hmr/hmr.postcss.test.e2e.d.ts +1 -0
  95. package/src/hmr/hmr.postcss.test.e2e.js +31 -0
  96. package/src/hmr/hmr.test.e2e.js +26 -33
  97. package/src/hmr/strategies/default-hmr-strategy.d.ts +2 -2
  98. package/src/hmr/strategies/default-hmr-strategy.js +1 -1
  99. package/src/hmr/strategies/js-hmr-strategy.d.ts +46 -43
  100. package/src/hmr/strategies/js-hmr-strategy.js +72 -73
  101. package/src/index.browser.d.ts +2 -2
  102. package/src/index.browser.js +1 -1
  103. package/src/index.d.ts +4 -3
  104. package/src/index.js +16 -5
  105. package/src/integrations/ghtml/ghtml-renderer.d.ts +7 -2
  106. package/src/integrations/ghtml/ghtml-renderer.js +33 -30
  107. package/src/integrations/ghtml/ghtml.constants.d.ts +1 -0
  108. package/src/integrations/ghtml/ghtml.constants.js +4 -0
  109. package/src/integrations/ghtml/ghtml.plugin.d.ts +2 -6
  110. package/src/integrations/ghtml/ghtml.plugin.js +3 -4
  111. package/src/plugins/README.md +35 -0
  112. package/src/plugins/alias-resolver-plugin.js +17 -3
  113. package/src/plugins/eco-component-meta-plugin.d.ts +14 -1
  114. package/src/plugins/eco-component-meta-plugin.js +27 -21
  115. package/src/plugins/foreign-jsx-override-plugin.d.ts +31 -0
  116. package/src/plugins/foreign-jsx-override-plugin.js +35 -0
  117. package/src/plugins/integration-plugin.d.ts +145 -28
  118. package/src/plugins/integration-plugin.js +109 -13
  119. package/src/plugins/processor.d.ts +15 -2
  120. package/src/plugins/processor.js +16 -2
  121. package/src/plugins/runtime-capability.d.ts +9 -0
  122. package/src/plugins/source-transform.d.ts +46 -0
  123. package/src/plugins/source-transform.js +71 -0
  124. package/src/route-renderer/GRAPH.md +64 -98
  125. package/src/route-renderer/README.md +67 -46
  126. package/src/route-renderer/orchestration/boundary-planning.service.d.ts +25 -0
  127. package/src/route-renderer/orchestration/boundary-planning.service.js +97 -0
  128. package/src/route-renderer/orchestration/component-render-context.d.ts +83 -0
  129. package/src/route-renderer/orchestration/component-render-context.js +147 -0
  130. package/src/route-renderer/orchestration/integration-renderer.d.ts +554 -0
  131. package/src/route-renderer/orchestration/integration-renderer.js +957 -0
  132. package/src/route-renderer/orchestration/queued-boundary-runtime.service.d.ts +89 -0
  133. package/src/route-renderer/orchestration/queued-boundary-runtime.service.js +155 -0
  134. package/src/route-renderer/orchestration/render-execution.service.d.ts +43 -0
  135. package/src/route-renderer/orchestration/render-execution.service.js +106 -0
  136. package/src/{eco/eco.utils.ts → route-renderer/orchestration/render-output.utils.d.ts} +10 -53
  137. package/src/route-renderer/orchestration/render-output.utils.js +65 -0
  138. package/src/route-renderer/{render-preparation.service.d.ts → orchestration/render-preparation.service.d.ts} +18 -10
  139. package/src/route-renderer/{render-preparation.service.js → orchestration/render-preparation.service.js} +115 -17
  140. package/src/route-renderer/orchestration/route-shell-composer.service.d.ts +50 -0
  141. package/src/route-renderer/orchestration/route-shell-composer.service.js +81 -0
  142. package/src/route-renderer/orchestration/template-serialization.d.ts +38 -0
  143. package/src/route-renderer/orchestration/template-serialization.js +45 -0
  144. package/src/route-renderer/{dependency-resolver.d.ts → page-loading/dependency-resolver.d.ts} +15 -4
  145. package/src/route-renderer/{dependency-resolver.js → page-loading/dependency-resolver.js} +28 -12
  146. package/src/route-renderer/page-loading/page-module-loader.d.ts +90 -0
  147. package/src/route-renderer/{page-module-loader.js → page-loading/page-module-loader.js} +39 -14
  148. package/src/route-renderer/route-renderer.d.ts +45 -4
  149. package/src/route-renderer/route-renderer.js +38 -3
  150. package/src/router/README.md +97 -0
  151. package/src/router/client/link-intent.d.ts +53 -0
  152. package/src/router/client/link-intent.js +34 -0
  153. package/src/router/client/link-intent.test.browser.d.ts +1 -0
  154. package/src/router/client/link-intent.test.browser.js +43 -0
  155. package/src/router/client/navigation-coordinator.d.ts +149 -0
  156. package/src/router/client/navigation-coordinator.js +215 -0
  157. package/src/router/{fs-router-scanner.d.ts → server/fs-router-scanner.d.ts} +3 -3
  158. package/src/router/{fs-router-scanner.js → server/fs-router-scanner.js} +14 -8
  159. package/src/router/{fs-router.d.ts → server/fs-router.d.ts} +1 -1
  160. package/src/router/{fs-router.js → server/fs-router.js} +1 -1
  161. package/src/services/README.md +29 -0
  162. package/src/services/assets/asset-processing-service/asset-processing.service.d.ts +120 -0
  163. package/src/services/{asset-processing-service → assets/asset-processing-service}/asset-processing.service.js +91 -10
  164. package/src/services/{asset-processing-service → assets/asset-processing-service}/asset.factory.d.ts +1 -1
  165. package/src/services/{asset-processing-service → assets/asset-processing-service}/asset.factory.js +2 -2
  166. package/src/services/{asset-processing-service → assets/asset-processing-service}/assets.types.d.ts +2 -1
  167. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.d.ts +55 -0
  168. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.js +48 -0
  169. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.d.ts +20 -0
  170. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.js +41 -0
  171. package/src/services/assets/asset-processing-service/index.d.ts +5 -0
  172. package/src/services/assets/asset-processing-service/index.js +5 -0
  173. package/src/services/{asset-processing-service → assets/asset-processing-service}/processor.interface.d.ts +2 -2
  174. package/src/services/{asset-processing-service → assets/asset-processing-service}/processor.registry.d.ts +2 -2
  175. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/base/base-processor.d.ts +1 -1
  176. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/base/base-processor.js +9 -4
  177. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/base/base-script-processor.d.ts +5 -4
  178. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/base/base-script-processor.js +15 -23
  179. package/src/services/assets/asset-processing-service/processors/index.d.ts +5 -0
  180. package/src/services/assets/asset-processing-service/processors/index.js +5 -0
  181. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/content-script.processor.d.ts +2 -2
  182. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/content-script.processor.js +1 -1
  183. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/file-script.processor.d.ts +4 -3
  184. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/file-script.processor.js +16 -4
  185. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/node-module-script.processor.d.ts +3 -3
  186. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/script/node-module-script.processor.js +6 -5
  187. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/stylesheet/content-stylesheet.processor.d.ts +2 -2
  188. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/stylesheet/content-stylesheet.processor.js +1 -1
  189. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/stylesheet/file-stylesheet.processor.d.ts +2 -2
  190. package/src/services/{asset-processing-service → assets/asset-processing-service}/processors/stylesheet/file-stylesheet.processor.js +5 -2
  191. package/src/services/assets/browser-bundle.service.d.ts +32 -0
  192. package/src/services/assets/browser-bundle.service.js +33 -0
  193. package/src/services/{page-request-cache-coordinator.service.d.ts → cache/page-request-cache-coordinator.service.d.ts} +2 -2
  194. package/src/services/{page-request-cache-coordinator.service.js → cache/page-request-cache-coordinator.service.js} +3 -1
  195. package/src/services/html/html-rewriter-provider.service.d.ts +37 -0
  196. package/src/services/html/html-rewriter-provider.service.js +68 -0
  197. package/src/services/html/html-transformer.service.d.ts +77 -0
  198. package/src/services/html/html-transformer.service.js +215 -0
  199. package/src/services/invalidation/development-invalidation.service.d.ts +74 -0
  200. package/src/services/invalidation/development-invalidation.service.js +190 -0
  201. package/src/services/module-loading/app-module-loader.service.d.ts +28 -0
  202. package/src/services/module-loading/app-module-loader.service.js +35 -0
  203. package/src/services/module-loading/app-server-module-transpiler.service.d.ts +24 -0
  204. package/src/services/module-loading/app-server-module-transpiler.service.js +109 -0
  205. package/src/services/module-loading/host-module-loader-registry.d.ts +4 -0
  206. package/src/services/module-loading/host-module-loader-registry.js +15 -0
  207. package/src/services/module-loading/module-loading-types.d.ts +2 -0
  208. package/src/services/module-loading/node-bootstrap-plugin.d.ts +42 -0
  209. package/src/services/module-loading/node-bootstrap-plugin.js +204 -0
  210. package/src/services/module-loading/page-module-import.service.d.ts +76 -0
  211. package/src/services/module-loading/page-module-import.service.js +173 -0
  212. package/src/services/module-loading/server-module-transpiler.service.d.ts +72 -0
  213. package/src/services/module-loading/server-module-transpiler.service.js +64 -0
  214. package/src/services/runtime-state/dev-graph.service.d.ts +118 -0
  215. package/src/services/runtime-state/dev-graph.service.js +162 -0
  216. package/src/services/runtime-state/entrypoint-dependency-graph.service.d.ts +41 -0
  217. package/src/services/runtime-state/entrypoint-dependency-graph.service.js +85 -0
  218. package/src/services/runtime-state/runtime-specifier-registry.service.d.ts +69 -0
  219. package/src/services/runtime-state/runtime-specifier-registry.service.js +37 -0
  220. package/src/services/runtime-state/server-invalidation-state.service.d.ts +26 -0
  221. package/src/services/runtime-state/server-invalidation-state.service.js +35 -0
  222. package/src/services/{schema-validation-service.d.ts → validation/schema-validation-service.d.ts} +1 -1
  223. package/src/static-site-generator/README.md +26 -0
  224. package/src/static-site-generator/static-site-generator.d.ts +50 -3
  225. package/src/static-site-generator/static-site-generator.js +71 -5
  226. package/src/{internal-types.d.ts → types/internal-types.d.ts} +53 -22
  227. package/src/types/internal-types.js +0 -0
  228. package/src/{public-types.d.ts → types/public-types.d.ts} +146 -21
  229. package/src/types/public-types.js +0 -0
  230. package/src/utils/html-escaping.d.ts +7 -0
  231. package/src/utils/html-escaping.js +6 -0
  232. package/src/utils/locals-utils.d.ts +1 -1
  233. package/src/utils/parse-cli-args.d.ts +4 -1
  234. package/src/utils/parse-cli-args.js +16 -1
  235. package/src/utils/resolve-work-dir.d.ts +11 -0
  236. package/src/utils/resolve-work-dir.js +31 -0
  237. package/src/watchers/project-watcher.d.ts +40 -24
  238. package/src/watchers/project-watcher.js +129 -92
  239. package/src/watchers/project-watcher.test-helpers.d.ts +2 -2
  240. package/src/watchers/project-watcher.test-helpers.js +1 -0
  241. package/src/adapters/abstract/application-adapter.ts +0 -337
  242. package/src/adapters/abstract/router-adapter.ts +0 -30
  243. package/src/adapters/abstract/server-adapter.ts +0 -79
  244. package/src/adapters/bun/client-bridge.ts +0 -62
  245. package/src/adapters/bun/create-app.ts +0 -189
  246. package/src/adapters/bun/define-api-handler.d.ts +0 -61
  247. package/src/adapters/bun/define-api-handler.ts +0 -114
  248. package/src/adapters/bun/hmr-manager.ts +0 -281
  249. package/src/adapters/bun/index.ts +0 -3
  250. package/src/adapters/bun/server-adapter.ts +0 -492
  251. package/src/adapters/bun/server-lifecycle.ts +0 -154
  252. package/src/adapters/index.ts +0 -6
  253. package/src/adapters/node/create-app.ts +0 -179
  254. package/src/adapters/node/index.d.ts +0 -4
  255. package/src/adapters/node/index.js +0 -8
  256. package/src/adapters/node/index.ts +0 -9
  257. package/src/adapters/node/node-client-bridge.ts +0 -79
  258. package/src/adapters/node/node-hmr-manager.ts +0 -271
  259. package/src/adapters/node/server-adapter.ts +0 -561
  260. package/src/adapters/node/static-content-server.ts +0 -203
  261. package/src/adapters/shared/api-response.ts +0 -104
  262. package/src/adapters/shared/application-adapter.ts +0 -199
  263. package/src/adapters/shared/explicit-static-route-matcher.ts +0 -134
  264. package/src/adapters/shared/file-route-middleware-pipeline.ts +0 -123
  265. package/src/adapters/shared/fs-server-response-factory.ts +0 -118
  266. package/src/adapters/shared/fs-server-response-matcher.ts +0 -198
  267. package/src/adapters/shared/render-context.ts +0 -105
  268. package/src/adapters/shared/server-adapter.ts +0 -442
  269. package/src/adapters/shared/server-route-handler.ts +0 -166
  270. package/src/adapters/shared/server-static-builder.ts +0 -82
  271. package/src/build/build-adapter.ts +0 -132
  272. package/src/build/build-types.ts +0 -83
  273. package/src/build/esbuild-build-adapter.ts +0 -510
  274. package/src/config/config-builder.ts +0 -474
  275. package/src/constants.ts +0 -39
  276. package/src/create-app.ts +0 -87
  277. package/src/define-api-handler.js +0 -15
  278. package/src/define-api-handler.ts +0 -66
  279. package/src/dev/sc-server.ts +0 -143
  280. package/src/eco/component-render-context.d.ts +0 -105
  281. package/src/eco/component-render-context.js +0 -77
  282. package/src/eco/component-render-context.ts +0 -202
  283. package/src/eco/eco.ts +0 -221
  284. package/src/eco/eco.types.ts +0 -202
  285. package/src/eco/global-injector-map.ts +0 -112
  286. package/src/eco/lazy-injector-map.ts +0 -120
  287. package/src/eco/module-dependencies.ts +0 -75
  288. package/src/errors/http-error.ts +0 -72
  289. package/src/errors/index.ts +0 -2
  290. package/src/errors/locals-access-error.ts +0 -7
  291. package/src/global/app-logger.ts +0 -4
  292. 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
  293. package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-HMR-Server-Integration-should-load-fixture-app-page-1.png +0 -0
  294. package/src/hmr/client/__screenshots__/hmr-runtime.test.browser.ts/HMR-Runtime-WebSocket-Connection-should-connect-to-correct-HMR-endpoint-1.png +0 -0
  295. package/src/hmr/client/hmr-runtime.ts +0 -121
  296. package/src/hmr/hmr-strategy.ts +0 -172
  297. package/src/hmr/hmr.test.e2e.ts +0 -75
  298. package/src/hmr/strategies/default-hmr-strategy.ts +0 -60
  299. package/src/hmr/strategies/js-hmr-strategy.ts +0 -308
  300. package/src/index.browser.ts +0 -3
  301. package/src/index.ts +0 -5
  302. package/src/integrations/ghtml/ghtml-renderer.ts +0 -93
  303. package/src/integrations/ghtml/ghtml.plugin.ts +0 -32
  304. package/src/internal-types.ts +0 -212
  305. package/src/plugins/alias-resolver-plugin.ts +0 -45
  306. package/src/plugins/eco-component-meta-plugin.ts +0 -474
  307. package/src/plugins/integration-plugin.ts +0 -184
  308. package/src/plugins/processor.ts +0 -220
  309. package/src/public-types.ts +0 -1255
  310. package/src/route-renderer/component-graph-executor.d.ts +0 -32
  311. package/src/route-renderer/component-graph-executor.js +0 -31
  312. package/src/route-renderer/component-graph-executor.ts +0 -84
  313. package/src/route-renderer/component-graph.d.ts +0 -42
  314. package/src/route-renderer/component-graph.js +0 -72
  315. package/src/route-renderer/component-graph.ts +0 -159
  316. package/src/route-renderer/component-marker.d.ts +0 -52
  317. package/src/route-renderer/component-marker.js +0 -46
  318. package/src/route-renderer/component-marker.ts +0 -117
  319. package/src/route-renderer/dependency-resolver.ts +0 -596
  320. package/src/route-renderer/html-post-processing.service.d.ts +0 -40
  321. package/src/route-renderer/html-post-processing.service.js +0 -86
  322. package/src/route-renderer/html-post-processing.service.ts +0 -103
  323. package/src/route-renderer/integration-renderer.d.ts +0 -339
  324. package/src/route-renderer/integration-renderer.js +0 -526
  325. package/src/route-renderer/integration-renderer.ts +0 -696
  326. package/src/route-renderer/marker-graph-resolver.d.ts +0 -76
  327. package/src/route-renderer/marker-graph-resolver.js +0 -93
  328. package/src/route-renderer/marker-graph-resolver.ts +0 -153
  329. package/src/route-renderer/page-module-loader.d.ts +0 -61
  330. package/src/route-renderer/page-module-loader.ts +0 -153
  331. package/src/route-renderer/render-execution.service.d.ts +0 -69
  332. package/src/route-renderer/render-execution.service.js +0 -91
  333. package/src/route-renderer/render-execution.service.ts +0 -158
  334. package/src/route-renderer/render-preparation.service.ts +0 -358
  335. package/src/route-renderer/route-renderer.ts +0 -80
  336. package/src/router/fs-router-scanner.ts +0 -217
  337. package/src/router/fs-router.ts +0 -122
  338. package/src/services/asset-processing-service/asset-processing.service.d.ts +0 -41
  339. package/src/services/asset-processing-service/asset-processing.service.ts +0 -306
  340. package/src/services/asset-processing-service/asset.factory.ts +0 -105
  341. package/src/services/asset-processing-service/assets.types.ts +0 -112
  342. package/src/services/asset-processing-service/index.d.ts +0 -3
  343. package/src/services/asset-processing-service/index.js +0 -3
  344. package/src/services/asset-processing-service/index.ts +0 -3
  345. package/src/services/asset-processing-service/processor.interface.ts +0 -27
  346. package/src/services/asset-processing-service/processor.registry.ts +0 -18
  347. package/src/services/asset-processing-service/processors/base/base-processor.ts +0 -76
  348. package/src/services/asset-processing-service/processors/base/base-script-processor.ts +0 -105
  349. package/src/services/asset-processing-service/processors/index.d.ts +0 -5
  350. package/src/services/asset-processing-service/processors/index.js +0 -5
  351. package/src/services/asset-processing-service/processors/index.ts +0 -5
  352. package/src/services/asset-processing-service/processors/script/content-script.processor.ts +0 -66
  353. package/src/services/asset-processing-service/processors/script/file-script.processor.ts +0 -88
  354. package/src/services/asset-processing-service/processors/script/node-module-script.processor.ts +0 -84
  355. package/src/services/asset-processing-service/processors/stylesheet/content-stylesheet.processor.ts +0 -27
  356. package/src/services/asset-processing-service/processors/stylesheet/file-stylesheet.processor.ts +0 -77
  357. package/src/services/cache/cache.types.ts +0 -126
  358. package/src/services/cache/index.ts +0 -18
  359. package/src/services/cache/memory-cache-store.ts +0 -130
  360. package/src/services/cache/page-cache-service.ts +0 -202
  361. package/src/services/html-transformer.service.d.ts +0 -50
  362. package/src/services/html-transformer.service.js +0 -163
  363. package/src/services/html-transformer.service.ts +0 -217
  364. package/src/services/page-module-import.service.d.ts +0 -37
  365. package/src/services/page-module-import.service.js +0 -88
  366. package/src/services/page-module-import.service.ts +0 -129
  367. package/src/services/page-request-cache-coordinator.service.ts +0 -128
  368. package/src/services/schema-validation-service.ts +0 -204
  369. package/src/services/validation/standard-schema.types.ts +0 -68
  370. package/src/static-site-generator/static-site-generator.ts +0 -359
  371. package/src/utils/css.d.ts +0 -1
  372. package/src/utils/css.js +0 -7
  373. package/src/utils/css.ts +0 -5
  374. package/src/utils/deep-merge.ts +0 -47
  375. package/src/utils/hash.ts +0 -5
  376. package/src/utils/html.ts +0 -1
  377. package/src/utils/invariant.ts +0 -15
  378. package/src/utils/locals-utils.ts +0 -37
  379. package/src/utils/parse-cli-args.ts +0 -83
  380. package/src/utils/path-utils.module.ts +0 -14
  381. package/src/utils/runtime.ts +0 -44
  382. package/src/utils/server-utils.module.ts +0 -67
  383. package/src/watchers/project-watcher.test-helpers.ts +0 -40
  384. package/src/watchers/project-watcher.ts +0 -306
  385. /package/src/adapters/{bun → shared}/define-api-handler.js +0 -0
  386. /package/src/{internal-types.js → plugins/runtime-capability.js} +0 -0
  387. /package/src/services/{asset-processing-service → assets/asset-processing-service}/assets.types.js +0 -0
  388. /package/src/services/{asset-processing-service → assets/asset-processing-service}/processor.interface.js +0 -0
  389. /package/src/services/{asset-processing-service → assets/asset-processing-service}/processor.registry.js +0 -0
  390. /package/src/{public-types.js → services/module-loading/module-loading-types.js} +0 -0
  391. /package/src/services/{schema-validation-service.js → validation/schema-validation-service.js} +0 -0
@@ -1,84 +0,0 @@
1
- import path from 'node:path';
2
- import { fileSystem } from '@ecopages/file-system';
3
- import { defaultBuildAdapter } from '../../../../build/build-adapter.ts';
4
- import type { NodeModuleScriptAsset } from '../../assets.types';
5
- import { BaseScriptProcessor } from '../base/base-script-processor';
6
-
7
- export class NodeModuleScriptProcessor extends BaseScriptProcessor<NodeModuleScriptAsset> {
8
- async process(dep: NodeModuleScriptAsset) {
9
- const modulePath = this.resolveModulePath(dep.importPath, this.appConfig.rootDir);
10
- const moduleName = path.basename(modulePath);
11
- const filename = dep.name ?? `nm-${moduleName}`;
12
- const configHash = this.generateHash(
13
- JSON.stringify({ inline: dep.inline, minify: !dep.inline && this.isProduction, opts: dep.bundleOptions }),
14
- );
15
- const cachekey = `${this.buildCacheKey(filename, this.generateHash(modulePath), dep)}:${configHash}`;
16
-
17
- return this.getOrProcess(cachekey, async () => {
18
- if (dep.inline) {
19
- const content = fileSystem.readFileAsBuffer(modulePath).toString();
20
- return {
21
- content,
22
- kind: dep.kind,
23
- position: dep.position,
24
- attributes: dep.attributes,
25
- inline: true,
26
- excludeFromHtml: dep.excludeFromHtml,
27
- };
28
- }
29
-
30
- const outdir = path.join(this.getAssetsDir(), 'vendors');
31
-
32
- const filePath = await this.bundleScript({
33
- entrypoint: modulePath,
34
- outdir: outdir,
35
- minify: this.isProduction,
36
- naming: dep.name ? `${dep.name}-[hash].[ext]` : '[name]-[hash].[ext]',
37
- ...this.getBundlerOptions(dep),
38
- });
39
-
40
- return {
41
- filepath: filePath,
42
- kind: dep.kind,
43
- position: dep.position,
44
- attributes: dep.attributes,
45
- inline: dep.inline,
46
- excludeFromHtml: dep.excludeFromHtml,
47
- };
48
- });
49
- }
50
-
51
- private resolveModulePath(importPath: string, rootDir: string): string {
52
- if (path.isAbsolute(importPath) && fileSystem.exists(importPath)) {
53
- return importPath;
54
- }
55
-
56
- try {
57
- return defaultBuildAdapter.resolve(importPath, rootDir);
58
- } catch {
59
- return this.resolveModulePathFallback(importPath, rootDir);
60
- }
61
- }
62
-
63
- private resolveModulePathFallback(importPath: string, rootDir: string, maxDepth = 5): string {
64
- let currentDir = rootDir;
65
- let remainingDepth = maxDepth;
66
-
67
- while (remainingDepth >= 0) {
68
- const modulePath = path.join(currentDir, 'node_modules', importPath);
69
- if (fileSystem.exists(modulePath)) {
70
- return modulePath;
71
- }
72
-
73
- const parentDir = path.dirname(currentDir);
74
- if (parentDir === currentDir) {
75
- break;
76
- }
77
-
78
- currentDir = parentDir;
79
- remainingDepth -= 1;
80
- }
81
-
82
- throw new Error(`Could not resolve module '${importPath}' from '${rootDir}'`);
83
- }
84
- }
@@ -1,27 +0,0 @@
1
- import path from 'node:path';
2
- import { fileSystem } from '@ecopages/file-system';
3
- import type { ContentStylesheetAsset, ProcessedAsset } from '../../assets.types';
4
- import { BaseProcessor } from '../base/base-processor';
5
-
6
- export class ContentStylesheetProcessor extends BaseProcessor<ContentStylesheetAsset> {
7
- async process(dep: ContentStylesheetAsset): Promise<ProcessedAsset> {
8
- const hash = this.generateHash(dep.content);
9
- const filename = `style-${hash}.css`;
10
- const cachekey = this.buildCacheKey(filename, hash, dep);
11
-
12
- return this.getOrProcess(cachekey, () => {
13
- const filepath = path.join(this.getAssetsDir(), 'styles', filename);
14
-
15
- if (!dep.inline) fileSystem.write(filepath, dep.content);
16
-
17
- return {
18
- filepath: dep.inline ? undefined : filepath,
19
- content: dep.inline ? dep.content : undefined,
20
- kind: 'stylesheet',
21
- position: dep.position,
22
- attributes: dep.attributes,
23
- inline: dep.inline,
24
- };
25
- });
26
- }
27
- }
@@ -1,77 +0,0 @@
1
- import path from 'node:path';
2
- import { fileSystem } from '@ecopages/file-system';
3
- import type { FileStylesheetAsset, ProcessedAsset } from '../../assets.types';
4
- import { BaseProcessor } from '../base/base-processor';
5
-
6
- export class FileStylesheetProcessor extends BaseProcessor<FileStylesheetAsset> {
7
- private static readonly PROCESSABLE_STYLESHEET_EXTENSIONS = new Set(['.css', '.scss', '.sass', '.less']);
8
-
9
- getStyleContent = (srcUrl: string): Buffer => {
10
- return fileSystem.readFileAsBuffer(srcUrl);
11
- };
12
-
13
- private isProcessableStylesheet(filepath: string): boolean {
14
- return FileStylesheetProcessor.PROCESSABLE_STYLESHEET_EXTENSIONS.has(path.extname(filepath));
15
- }
16
-
17
- private async applyStylesheetProcessors(content: string, filepath: string): Promise<string> {
18
- if (!this.isProcessableStylesheet(filepath)) {
19
- return content;
20
- }
21
-
22
- let transformedContent = content;
23
-
24
- for (const processor of this.appConfig.processors.values()) {
25
- const hasCapabilities = processor.getAssetCapabilities().length > 0;
26
- const canProcessStylesheet = processor.canProcessAsset('stylesheet', filepath);
27
-
28
- if (!canProcessStylesheet && (hasCapabilities || !processor.getName().includes('postcss'))) {
29
- continue;
30
- }
31
-
32
- if (!processor.matchesFileFilter(filepath)) {
33
- continue;
34
- }
35
-
36
- const result = await processor.process(transformedContent, filepath);
37
-
38
- if (typeof result === 'string') {
39
- transformedContent = result;
40
- continue;
41
- }
42
-
43
- if (result instanceof Buffer) {
44
- transformedContent = result.toString();
45
- }
46
- }
47
-
48
- return transformedContent;
49
- }
50
-
51
- async process(dep: FileStylesheetAsset): Promise<ProcessedAsset> {
52
- const buffer = this.getStyleContent(dep.filepath);
53
- const rawContent = buffer.toString();
54
- const processedContent = await this.applyStylesheetProcessors(rawContent, dep.filepath);
55
- const hash = this.generateHash(processedContent);
56
- const cachekey = this.buildCacheKey(dep.filepath, hash, dep);
57
-
58
- return this.getOrProcess(cachekey, () => {
59
- const filepath = path.join(this.getAssetsDir(), path.relative(this.appConfig.srcDir, dep.filepath));
60
- const outputBuffer = Buffer.from(processedContent);
61
-
62
- if (!dep.inline) {
63
- fileSystem.ensureDir(path.dirname(filepath));
64
- fileSystem.write(filepath, outputBuffer);
65
- }
66
-
67
- return {
68
- filepath: filepath,
69
- content: dep.inline ? processedContent : undefined,
70
- kind: 'stylesheet',
71
- position: dep.position,
72
- attributes: dep.attributes,
73
- inline: dep.inline,
74
- };
75
- });
76
- }
77
- }
@@ -1,126 +0,0 @@
1
- /**
2
- * Cache types and interfaces for page caching and ISR
3
- * @module
4
- */
5
-
6
- /**
7
- * Result from rendering a page, including HTML and cache strategy.
8
- */
9
- export interface RenderResult {
10
- html: string;
11
- strategy: CacheStrategy;
12
- }
13
-
14
- /**
15
- * Render strategy configuration for pages.
16
- * - `'static'`: Render once, cache indefinitely
17
- * - `'dynamic'`: No caching, render on every request
18
- * - `{ revalidate, tags }`: Cache with time-based revalidation and optional tags
19
- */
20
- export type CacheStrategy =
21
- | 'static'
22
- | 'dynamic'
23
- | {
24
- /** Seconds until cache is considered stale */
25
- revalidate: number;
26
- /** Tags for on-demand invalidation */
27
- tags?: string[];
28
- };
29
-
30
- /**
31
- * Cache entry stored in the cache store.
32
- */
33
- export interface CacheEntry {
34
- /** The rendered HTML content */
35
- html: string;
36
- /** Timestamp when the entry was created */
37
- createdAt: number;
38
- /** Timestamp when the entry should be revalidated (null = never stale) */
39
- revalidateAfter: number | null;
40
- /** Tags associated with this entry for invalidation */
41
- tags: string[];
42
- /** The cache strategy used (for generating headers on HIT) */
43
- strategy: CacheStrategy;
44
- }
45
-
46
- /**
47
- * Cache statistics for debugging and monitoring.
48
- */
49
- export interface CacheStats {
50
- /** Number of entries in the cache */
51
- entries: number;
52
- /** Memory usage in bytes (if available) */
53
- memoryUsage?: number;
54
- /** Cache hit rate (if tracked) */
55
- hitRate?: number;
56
- }
57
-
58
- /**
59
- * Abstract interface for cache storage backends.
60
- * Implementations must handle serialization/deserialization internally.
61
- */
62
- export interface CacheStore {
63
- /** Retrieve an entry by key */
64
- get(key: string): Promise<CacheEntry | null>;
65
-
66
- /** Store an entry */
67
- set(key: string, entry: CacheEntry): Promise<void>;
68
-
69
- /** Delete a specific entry */
70
- delete(key: string): Promise<boolean>;
71
-
72
- /** Delete all entries matching any of the provided tags */
73
- invalidateByTags(tags: string[]): Promise<number>;
74
-
75
- /** Delete entries by exact path */
76
- invalidateByPaths(paths: string[]): Promise<number>;
77
-
78
- /** Clear all entries */
79
- clear(): Promise<void>;
80
-
81
- /** Get cache statistics (optional, for debugging) */
82
- stats?(): Promise<CacheStats>;
83
- }
84
-
85
- /**
86
- * Configuration for the cache system.
87
- */
88
- export interface CacheConfig {
89
- /**
90
- * Cache store implementation.
91
- * @default 'memory'
92
- */
93
- store?: 'memory' | CacheStore;
94
-
95
- /**
96
- * Default cache strategy for pages that don't specify one.
97
- * @default 'static'
98
- */
99
- defaultStrategy?: CacheStrategy;
100
-
101
- /**
102
- * Whether caching is enabled.
103
- * Automatically disabled in dev mode unless explicitly set.
104
- * @default true (production), false (development)
105
- */
106
- enabled?: boolean;
107
-
108
- /**
109
- * Maximum number of entries in the memory cache before LRU eviction.
110
- * Only applies when using the built-in memory store.
111
- * @default 1000
112
- */
113
- maxEntries?: number;
114
- }
115
-
116
- /**
117
- * Result of a cache lookup operation.
118
- */
119
- export interface CacheResult {
120
- /** The cached HTML content */
121
- html: string;
122
- /** Cache status for X-Cache header */
123
- status: 'hit' | 'miss' | 'stale';
124
- /** The cache strategy (for generating Cache-Control headers) */
125
- strategy: CacheStrategy;
126
- }
@@ -1,18 +0,0 @@
1
- /**
2
- * Cache services exports
3
- * @module
4
- */
5
-
6
- export type {
7
- CacheConfig,
8
- CacheEntry,
9
- CacheResult,
10
- CacheStats,
11
- CacheStore,
12
- CacheStrategy,
13
- RenderResult,
14
- } from './cache.types.ts';
15
-
16
- export { MemoryCacheStore, type MemoryCacheStoreOptions } from './memory-cache-store.ts';
17
-
18
- export { getCacheControlHeader, PageCacheService, type PageCacheServiceOptions } from './page-cache-service.ts';
@@ -1,130 +0,0 @@
1
- /**
2
- * In-memory cache store with LRU eviction.
3
- * Suitable for single-instance deployments and development.
4
- * @module
5
- */
6
-
7
- import type { CacheEntry, CacheStats, CacheStore } from './cache.types.ts';
8
-
9
- export interface MemoryCacheStoreOptions {
10
- /** Maximum number of entries before LRU eviction. @default 1000 */
11
- maxEntries?: number;
12
- }
13
-
14
- /**
15
- * Simple in-memory cache store with LRU eviction.
16
- * Uses Map insertion order for LRU tracking.
17
- */
18
- export class MemoryCacheStore implements CacheStore {
19
- private cache = new Map<string, CacheEntry>();
20
- private tagIndex = new Map<string, Set<string>>();
21
- private readonly maxEntries: number;
22
-
23
- constructor(options: MemoryCacheStoreOptions = {}) {
24
- this.maxEntries = options.maxEntries ?? 1000;
25
- }
26
-
27
- /**
28
- * Retrieve an entry by key.
29
- * Uses Map's insertion order for LRU tracking - accessed entries are
30
- * deleted and re-inserted to move them to the "most recently used" position.
31
- */
32
- async get(key: string): Promise<CacheEntry | null> {
33
- const entry = this.cache.get(key);
34
- if (!entry) return null;
35
-
36
- this.cache.delete(key);
37
- this.cache.set(key, entry);
38
-
39
- return entry;
40
- }
41
-
42
- /**
43
- * Store an entry, evicting the oldest if at capacity.
44
- * When maxEntries is reached and a new key is added, the first key in
45
- * the Map (oldest/least-recently-used) is evicted to make room.
46
- * Updating an existing key refreshes its LRU position.
47
- */
48
- async set(key: string, entry: CacheEntry): Promise<void> {
49
- const existingEntry = this.cache.get(key);
50
-
51
- if (existingEntry) {
52
- for (const tag of existingEntry.tags) {
53
- this.tagIndex.get(tag)?.delete(key);
54
- if (this.tagIndex.get(tag)?.size === 0) {
55
- this.tagIndex.delete(tag);
56
- }
57
- }
58
- this.cache.delete(key);
59
- } else if (this.cache.size >= this.maxEntries) {
60
- const oldestKey = this.cache.keys().next().value;
61
- if (oldestKey) await this.delete(oldestKey);
62
- }
63
-
64
- this.cache.set(key, entry);
65
-
66
- for (const tag of entry.tags) {
67
- if (!this.tagIndex.has(tag)) {
68
- this.tagIndex.set(tag, new Set());
69
- }
70
- this.tagIndex.get(tag)!.add(key);
71
- }
72
- }
73
-
74
- /**
75
- * Delete an entry and clean up its tag index references.
76
- * Removes empty tag sets to prevent memory leaks from accumulated tags.
77
- */
78
- async delete(key: string): Promise<boolean> {
79
- const entry = this.cache.get(key);
80
- if (!entry) return false;
81
-
82
- for (const tag of entry.tags) {
83
- this.tagIndex.get(tag)?.delete(key);
84
- if (this.tagIndex.get(tag)?.size === 0) {
85
- this.tagIndex.delete(tag);
86
- }
87
- }
88
-
89
- return this.cache.delete(key);
90
- }
91
-
92
- async invalidateByTags(tags: string[]): Promise<number> {
93
- let count = 0;
94
- const keysToDelete = new Set<string>();
95
-
96
- for (const tag of tags) {
97
- const keys = this.tagIndex.get(tag);
98
- if (keys) {
99
- for (const key of keys) {
100
- keysToDelete.add(key);
101
- }
102
- }
103
- }
104
-
105
- for (const key of keysToDelete) {
106
- if (await this.delete(key)) count++;
107
- }
108
-
109
- return count;
110
- }
111
-
112
- async invalidateByPaths(paths: string[]): Promise<number> {
113
- let count = 0;
114
- for (const path of paths) {
115
- if (await this.delete(path)) count++;
116
- }
117
- return count;
118
- }
119
-
120
- async clear(): Promise<void> {
121
- this.cache.clear();
122
- this.tagIndex.clear();
123
- }
124
-
125
- async stats(): Promise<CacheStats> {
126
- return {
127
- entries: this.cache.size,
128
- };
129
- }
130
- }
@@ -1,202 +0,0 @@
1
- /**
2
- * Page cache service with ISR (Incremental Static Regeneration) support.
3
- * Handles stale-while-revalidate semantics and background regeneration.
4
- * @module
5
- */
6
-
7
- import { appLogger } from '../../global/app-logger.ts';
8
- import type { CacheEntry, CacheResult, CacheStore, CacheStrategy, RenderResult } from './cache.types.ts';
9
- import { MemoryCacheStore } from './memory-cache-store.ts';
10
-
11
- export interface PageCacheServiceOptions {
12
- store?: CacheStore;
13
- enabled?: boolean;
14
- }
15
-
16
- /**
17
- * Core page caching service with ISR support.
18
- */
19
- export class PageCacheService {
20
- private store: CacheStore;
21
- private enabled: boolean;
22
- private regenerationPromises = new Map<string, Promise<string>>();
23
-
24
- constructor(options: PageCacheServiceOptions = {}) {
25
- this.store = options.store ?? new MemoryCacheStore();
26
- this.enabled = options.enabled ?? true;
27
- }
28
-
29
- /**
30
- * Generate a cache key from URL and optional params.
31
- * Uses full URL (path + query) as the key.
32
- */
33
- generateCacheKey(url: string): string {
34
- return url;
35
- }
36
-
37
- /**
38
- * Check if an entry is stale (past its revalidation time).
39
- */
40
- private isStale(entry: CacheEntry): boolean {
41
- if (entry.revalidateAfter === null) return false;
42
- return Date.now() > entry.revalidateAfter;
43
- }
44
-
45
- /**
46
- * Create a cache entry from rendered HTML.
47
- */
48
- private createEntry(html: string, strategy: CacheStrategy): CacheEntry {
49
- const now = Date.now();
50
-
51
- let revalidateAfter: number | null = null;
52
- let tags: string[] = [];
53
-
54
- if (strategy === 'static') {
55
- revalidateAfter = null;
56
- } else if (strategy === 'dynamic') {
57
- revalidateAfter = 0;
58
- } else if (typeof strategy === 'object') {
59
- revalidateAfter = now + strategy.revalidate * 1000;
60
- tags = strategy.tags ?? [];
61
- }
62
-
63
- return {
64
- html,
65
- createdAt: now,
66
- revalidateAfter,
67
- tags,
68
- strategy,
69
- };
70
- }
71
-
72
- /**
73
- * Get cached content or create new content with stale-while-revalidate semantics.
74
- * @param key - Cache key (URL path + query)
75
- * @param defaultStrategy - Default strategy if page doesn't specify one
76
- * @param renderFn - Function that renders the page and returns HTML + strategy
77
- */
78
- async getOrCreate(
79
- key: string,
80
- defaultStrategy: CacheStrategy,
81
- renderFn: () => Promise<RenderResult>,
82
- ): Promise<CacheResult> {
83
- if (!this.enabled) {
84
- const { html, strategy } = await renderFn();
85
- return { html, status: 'miss', strategy };
86
- }
87
-
88
- const entry = await this.store.get(key);
89
-
90
- if (!entry) {
91
- const { html, strategy } = await renderFn();
92
- const effectiveStrategy = strategy ?? defaultStrategy;
93
-
94
- if (effectiveStrategy === 'dynamic') {
95
- return { html, status: 'miss', strategy: effectiveStrategy };
96
- }
97
-
98
- const newEntry = this.createEntry(html, effectiveStrategy);
99
- await this.store.set(key, newEntry);
100
- return { html, status: 'miss', strategy: effectiveStrategy };
101
- }
102
-
103
- if (!this.isStale(entry)) {
104
- return { html: entry.html, status: 'hit', strategy: entry.strategy };
105
- }
106
-
107
- this.regenerateInBackground(key, entry.strategy, renderFn);
108
- return { html: entry.html, status: 'stale', strategy: entry.strategy };
109
- }
110
-
111
- /**
112
- * Regenerate content in the background without blocking the response.
113
- * Uses promise deduplication to prevent multiple concurrent regenerations.
114
- */
115
- private regenerateInBackground(
116
- key: string,
117
- fallbackStrategy: CacheStrategy,
118
- renderFn: () => Promise<{ html: string; strategy: CacheStrategy }>,
119
- ): void {
120
- if (this.regenerationPromises.has(key)) {
121
- return;
122
- }
123
-
124
- const regeneratePromise = (async () => {
125
- try {
126
- const { html, strategy } = await renderFn();
127
- const effectiveStrategy = strategy ?? fallbackStrategy;
128
- const newEntry = this.createEntry(html, effectiveStrategy);
129
- await this.store.set(key, newEntry);
130
- return html;
131
- } finally {
132
- this.regenerationPromises.delete(key);
133
- }
134
- })();
135
-
136
- this.regenerationPromises.set(key, regeneratePromise);
137
-
138
- queueMicrotask(() => {
139
- regeneratePromise.catch((error) => {
140
- appLogger.error(`[PageCacheService] Failed to regenerate: ${key}`, error);
141
- });
142
- });
143
- }
144
-
145
- /**
146
- * Invalidate cache entries by tags.
147
- */
148
- async invalidateByTags(tags: string[]): Promise<number> {
149
- return this.store.invalidateByTags(tags);
150
- }
151
-
152
- /**
153
- * Invalidate cache entries by paths.
154
- */
155
- async invalidateByPaths(paths: string[]): Promise<number> {
156
- return this.store.invalidateByPaths(paths);
157
- }
158
-
159
- /**
160
- * Clear all cached entries.
161
- */
162
- async clear(): Promise<void> {
163
- return this.store.clear();
164
- }
165
-
166
- /**
167
- * Get cache statistics.
168
- */
169
- async stats() {
170
- return this.store.stats?.() ?? { entries: 0 };
171
- }
172
-
173
- /**
174
- * Get the underlying cache store.
175
- */
176
- getStore(): CacheStore {
177
- return this.store;
178
- }
179
- }
180
-
181
- /**
182
- * Generate Cache-Control header value from cache strategy.
183
- */
184
- export function getCacheControlHeader(strategy: CacheStrategy | 'disabled'): string {
185
- if (strategy === 'disabled') {
186
- return 'no-store, must-revalidate';
187
- }
188
- if (strategy === 'static') {
189
- return 'public, max-age=31536000, immutable';
190
- }
191
-
192
- if (strategy === 'dynamic') {
193
- return 'no-store, must-revalidate';
194
- }
195
-
196
- if (typeof strategy === 'object') {
197
- const swr = strategy.revalidate * 2;
198
- return `public, max-age=${strategy.revalidate}, stale-while-revalidate=${swr}`;
199
- }
200
-
201
- return 'no-store';
202
- }