@conloca/astro-cms 0.1.15 → 0.2.0

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 (367) hide show
  1. package/README.md +259 -247
  2. package/dist/internal/acorn-default.mjs +11 -3
  3. package/dist/internal/page-handler.astro +137 -358
  4. package/dist/ts/node/content.d.ts +4 -0
  5. package/dist/ts/node/content.d.ts.map +1 -0
  6. package/dist/ts/node/content.js +3 -0
  7. package/dist/ts/node/content.js.map +1 -0
  8. package/dist/ts/node/index.d.ts +9 -0
  9. package/dist/ts/node/index.d.ts.map +1 -0
  10. package/dist/ts/node/index.js +14 -0
  11. package/dist/ts/node/index.js.map +1 -0
  12. package/dist/ts/src/asset-ref-base.d.ts +3 -0
  13. package/dist/ts/src/asset-ref-base.d.ts.map +1 -0
  14. package/dist/ts/src/asset-ref-base.js +48 -0
  15. package/dist/ts/src/asset-ref-base.js.map +1 -0
  16. package/dist/ts/src/checks.d.ts +7 -0
  17. package/dist/ts/src/checks.d.ts.map +1 -0
  18. package/dist/ts/src/checks.js +7 -0
  19. package/dist/ts/src/checks.js.map +1 -0
  20. package/dist/ts/src/cms-handler.d.ts +18 -0
  21. package/dist/ts/src/cms-handler.d.ts.map +1 -0
  22. package/dist/ts/src/cms-handler.js +245 -0
  23. package/dist/ts/src/cms-handler.js.map +1 -0
  24. package/dist/ts/src/collections.d.ts +160 -0
  25. package/dist/ts/src/collections.d.ts.map +1 -0
  26. package/dist/ts/src/collections.js +170 -0
  27. package/dist/ts/src/collections.js.map +1 -0
  28. package/dist/ts/src/components/HydrationWrapper.d.ts +18 -0
  29. package/dist/ts/src/components/HydrationWrapper.d.ts.map +1 -0
  30. package/dist/ts/src/components/HydrationWrapper.js +22 -0
  31. package/dist/ts/src/components/HydrationWrapper.js.map +1 -0
  32. package/dist/ts/src/components/RenderWithFragments.d.ts +27 -0
  33. package/dist/ts/src/components/RenderWithFragments.d.ts.map +1 -0
  34. package/dist/ts/src/components/RenderWithFragments.js +133 -0
  35. package/dist/ts/src/components/RenderWithFragments.js.map +1 -0
  36. package/dist/ts/src/components/RenderWithHydration.d.ts +21 -0
  37. package/dist/ts/src/components/RenderWithHydration.d.ts.map +1 -0
  38. package/dist/ts/src/components/RenderWithHydration.js +39 -0
  39. package/dist/ts/src/components/RenderWithHydration.js.map +1 -0
  40. package/dist/ts/src/components.d.ts +4 -0
  41. package/dist/ts/src/components.d.ts.map +1 -0
  42. package/dist/ts/src/components.js +4 -0
  43. package/dist/ts/src/components.js.map +1 -0
  44. package/dist/ts/src/discovery/astro-frontmatter.d.ts +18 -0
  45. package/dist/ts/src/discovery/astro-frontmatter.d.ts.map +1 -0
  46. package/dist/ts/src/discovery/astro-frontmatter.js +25 -0
  47. package/dist/ts/src/discovery/astro-frontmatter.js.map +1 -0
  48. package/dist/ts/src/discovery/discover.d.ts +43 -0
  49. package/dist/ts/src/discovery/discover.d.ts.map +1 -0
  50. package/dist/ts/src/discovery/discover.js +87 -0
  51. package/dist/ts/src/discovery/discover.js.map +1 -0
  52. package/dist/ts/src/discovery/extract-props-ts.d.ts +41 -0
  53. package/dist/ts/src/discovery/extract-props-ts.d.ts.map +1 -0
  54. package/dist/ts/src/discovery/extract-props-ts.js +232 -0
  55. package/dist/ts/src/discovery/extract-props-ts.js.map +1 -0
  56. package/dist/ts/src/discovery/merge-registry.d.ts +58 -0
  57. package/dist/ts/src/discovery/merge-registry.d.ts.map +1 -0
  58. package/dist/ts/src/discovery/merge-registry.js +333 -0
  59. package/dist/ts/src/discovery/merge-registry.js.map +1 -0
  60. package/dist/ts/src/discovery/registry-endpoint.d.ts +27 -0
  61. package/dist/ts/src/discovery/registry-endpoint.d.ts.map +1 -0
  62. package/dist/ts/src/discovery/registry-endpoint.js +76 -0
  63. package/dist/ts/src/discovery/registry-endpoint.js.map +1 -0
  64. package/dist/ts/src/discovery/scan-components.d.ts +94 -0
  65. package/dist/ts/src/discovery/scan-components.d.ts.map +1 -0
  66. package/dist/ts/src/discovery/scan-components.js +397 -0
  67. package/dist/ts/src/discovery/scan-components.js.map +1 -0
  68. package/dist/ts/src/discovery/scan-mdx.d.ts +63 -0
  69. package/dist/ts/src/discovery/scan-mdx.d.ts.map +1 -0
  70. package/dist/ts/src/discovery/scan-mdx.js +113 -0
  71. package/dist/ts/src/discovery/scan-mdx.js.map +1 -0
  72. package/dist/ts/src/discovery/scan-overrides.d.ts +71 -0
  73. package/dist/ts/src/discovery/scan-overrides.d.ts.map +1 -0
  74. package/dist/ts/src/discovery/scan-overrides.js +34 -0
  75. package/dist/ts/src/discovery/scan-overrides.js.map +1 -0
  76. package/dist/ts/src/editor-descriptors.d.ts +31 -0
  77. package/dist/ts/src/editor-descriptors.d.ts.map +1 -0
  78. package/dist/ts/src/editor-descriptors.js +84 -0
  79. package/dist/ts/src/editor-descriptors.js.map +1 -0
  80. package/dist/ts/src/handlers/collection-content-api.d.ts +32 -0
  81. package/dist/ts/src/handlers/collection-content-api.d.ts.map +1 -0
  82. package/dist/ts/src/handlers/collection-content-api.js +166 -0
  83. package/dist/ts/src/handlers/collection-content-api.js.map +1 -0
  84. package/dist/ts/src/handlers/page-render-core.d.ts +137 -0
  85. package/dist/ts/src/handlers/page-render-core.d.ts.map +1 -0
  86. package/dist/ts/src/handlers/page-render-core.js +315 -0
  87. package/dist/ts/src/handlers/page-render-core.js.map +1 -0
  88. package/dist/ts/src/hydration.d.ts +4 -0
  89. package/dist/ts/src/hydration.d.ts.map +1 -0
  90. package/dist/ts/src/hydration.js +5 -0
  91. package/dist/ts/src/hydration.js.map +1 -0
  92. package/dist/ts/src/index.d.ts +21 -0
  93. package/dist/ts/src/index.d.ts.map +1 -0
  94. package/dist/ts/src/index.js +45 -0
  95. package/dist/ts/src/index.js.map +1 -0
  96. package/dist/ts/src/internal/declared-collections.d.ts +30 -0
  97. package/dist/ts/src/internal/declared-collections.d.ts.map +1 -0
  98. package/dist/ts/src/internal/declared-collections.js +84 -0
  99. package/dist/ts/src/internal/declared-collections.js.map +1 -0
  100. package/dist/ts/src/internal/page-collection-schema.d.ts +44 -0
  101. package/dist/ts/src/internal/page-collection-schema.d.ts.map +1 -0
  102. package/dist/ts/src/internal/page-collection-schema.js +152 -0
  103. package/dist/ts/src/internal/page-collection-schema.js.map +1 -0
  104. package/dist/ts/src/lib/content-config-guard.d.ts +11 -0
  105. package/dist/ts/src/lib/content-config-guard.d.ts.map +1 -0
  106. package/dist/ts/src/lib/content-config-guard.js +41 -0
  107. package/dist/ts/src/lib/content-config-guard.js.map +1 -0
  108. package/dist/ts/src/lib/hydration-scanner.d.ts +47 -0
  109. package/dist/ts/src/lib/hydration-scanner.d.ts.map +1 -0
  110. package/dist/ts/src/lib/hydration-scanner.js +136 -0
  111. package/dist/ts/src/lib/hydration-scanner.js.map +1 -0
  112. package/dist/{lib/hydration-script.d.mts → ts/src/lib/hydration-script.d.ts} +7 -10
  113. package/dist/ts/src/lib/hydration-script.d.ts.map +1 -0
  114. package/dist/ts/src/lib/hydration-script.js +89 -0
  115. package/dist/ts/src/lib/hydration-script.js.map +1 -0
  116. package/dist/ts/src/lib/hydration-utils.d.ts +51 -0
  117. package/dist/ts/src/lib/hydration-utils.d.ts.map +1 -0
  118. package/dist/ts/src/lib/hydration-utils.js +84 -0
  119. package/dist/ts/src/lib/hydration-utils.js.map +1 -0
  120. package/dist/ts/src/lib/resolve-locale.d.ts +15 -0
  121. package/dist/ts/src/lib/resolve-locale.d.ts.map +1 -0
  122. package/dist/ts/src/lib/resolve-locale.js +16 -0
  123. package/dist/ts/src/lib/resolve-locale.js.map +1 -0
  124. package/dist/ts/src/lib/resolve-site-name.d.ts +8 -0
  125. package/dist/ts/src/lib/resolve-site-name.d.ts.map +1 -0
  126. package/dist/ts/src/lib/resolve-site-name.js +12 -0
  127. package/dist/ts/src/lib/resolve-site-name.js.map +1 -0
  128. package/dist/ts/src/lib/route-utils.d.ts +61 -0
  129. package/dist/ts/src/lib/route-utils.d.ts.map +1 -0
  130. package/dist/ts/src/lib/route-utils.js +96 -0
  131. package/dist/ts/src/lib/route-utils.js.map +1 -0
  132. package/dist/ts/src/lib/routing-config.d.ts +38 -0
  133. package/dist/ts/src/lib/routing-config.d.ts.map +1 -0
  134. package/dist/ts/src/lib/routing-config.js +106 -0
  135. package/dist/ts/src/lib/routing-config.js.map +1 -0
  136. package/dist/ts/src/lib/serialize-props.d.ts +6 -0
  137. package/dist/ts/src/lib/serialize-props.d.ts.map +1 -0
  138. package/dist/ts/src/lib/serialize-props.js +8 -0
  139. package/dist/ts/src/lib/serialize-props.js.map +1 -0
  140. package/dist/ts/src/lib/unknown-components.d.ts +21 -0
  141. package/dist/ts/src/lib/unknown-components.d.ts.map +1 -0
  142. package/dist/ts/src/lib/unknown-components.js +49 -0
  143. package/dist/ts/src/lib/unknown-components.js.map +1 -0
  144. package/dist/ts/src/lib/virtual-module-generators.d.ts +33 -0
  145. package/dist/ts/src/lib/virtual-module-generators.d.ts.map +1 -0
  146. package/dist/ts/src/lib/virtual-module-generators.js +51 -0
  147. package/dist/ts/src/lib/virtual-module-generators.js.map +1 -0
  148. package/dist/{withHydration-HIvO9ysY.d.mts → ts/src/lib/withHydration.d.ts} +7 -11
  149. package/dist/ts/src/lib/withHydration.d.ts.map +1 -0
  150. package/dist/ts/src/lib/withHydration.js +50 -0
  151. package/dist/ts/src/lib/withHydration.js.map +1 -0
  152. package/dist/ts/src/loader.d.ts +27 -0
  153. package/dist/ts/src/loader.d.ts.map +1 -0
  154. package/dist/ts/src/loader.js +118 -0
  155. package/dist/ts/src/loader.js.map +1 -0
  156. package/dist/ts/src/locales-helpers.d.ts +61 -0
  157. package/dist/ts/src/locales-helpers.d.ts.map +1 -0
  158. package/dist/ts/src/locales-helpers.js +50 -0
  159. package/dist/ts/src/locales-helpers.js.map +1 -0
  160. package/dist/ts/src/mime-types.d.ts +3 -0
  161. package/dist/ts/src/mime-types.d.ts.map +1 -0
  162. package/dist/ts/src/mime-types.js +20 -0
  163. package/dist/ts/src/mime-types.js.map +1 -0
  164. package/dist/ts/src/page-feed.d.ts +13 -0
  165. package/dist/ts/src/page-feed.d.ts.map +1 -0
  166. package/dist/ts/src/page-feed.js +20 -0
  167. package/dist/ts/src/page-feed.js.map +1 -0
  168. package/dist/ts/src/page-schemas.d.ts +6 -0
  169. package/dist/ts/src/page-schemas.d.ts.map +1 -0
  170. package/dist/ts/src/page-schemas.js +6 -0
  171. package/dist/ts/src/page-schemas.js.map +1 -0
  172. package/dist/ts/src/path-validation.d.ts +8 -0
  173. package/dist/ts/src/path-validation.d.ts.map +1 -0
  174. package/dist/ts/src/path-validation.js +13 -0
  175. package/dist/ts/src/path-validation.js.map +1 -0
  176. package/dist/ts/src/plugin-spa.d.ts +182 -0
  177. package/dist/ts/src/plugin-spa.d.ts.map +1 -0
  178. package/dist/ts/src/plugin-spa.js +1165 -0
  179. package/dist/ts/src/plugin-spa.js.map +1 -0
  180. package/dist/ts/src/puck-manifest/components-endpoint.d.ts +30 -0
  181. package/dist/ts/src/puck-manifest/components-endpoint.d.ts.map +1 -0
  182. package/dist/ts/src/puck-manifest/components-endpoint.js +54 -0
  183. package/dist/ts/src/puck-manifest/components-endpoint.js.map +1 -0
  184. package/dist/ts/src/puck-manifest/field-projection.d.ts +91 -0
  185. package/dist/ts/src/puck-manifest/field-projection.d.ts.map +1 -0
  186. package/dist/ts/src/puck-manifest/field-projection.js +422 -0
  187. package/dist/ts/src/puck-manifest/field-projection.js.map +1 -0
  188. package/dist/ts/src/puck-manifest/index.d.ts +4 -0
  189. package/dist/ts/src/puck-manifest/index.d.ts.map +1 -0
  190. package/dist/ts/src/puck-manifest/index.js +3 -0
  191. package/dist/ts/src/puck-manifest/index.js.map +1 -0
  192. package/dist/ts/src/puck-manifest/literal.d.ts +163 -0
  193. package/dist/ts/src/puck-manifest/literal.d.ts.map +1 -0
  194. package/dist/ts/src/puck-manifest/literal.js +354 -0
  195. package/dist/ts/src/puck-manifest/literal.js.map +1 -0
  196. package/dist/ts/src/puck-manifest/read-config.d.ts +42 -0
  197. package/dist/ts/src/puck-manifest/read-config.d.ts.map +1 -0
  198. package/dist/ts/src/puck-manifest/read-config.js +517 -0
  199. package/dist/ts/src/puck-manifest/read-config.js.map +1 -0
  200. package/dist/ts/src/puck-manifest/read-field.d.ts +7 -0
  201. package/dist/ts/src/puck-manifest/read-field.d.ts.map +1 -0
  202. package/dist/ts/src/puck-manifest/read-field.js +11 -0
  203. package/dist/ts/src/puck-manifest/read-field.js.map +1 -0
  204. package/dist/ts/src/puck-manifest/read-wrapper.d.ts +147 -0
  205. package/dist/ts/src/puck-manifest/read-wrapper.d.ts.map +1 -0
  206. package/dist/ts/src/puck-manifest/read-wrapper.js +889 -0
  207. package/dist/ts/src/puck-manifest/read-wrapper.js.map +1 -0
  208. package/dist/ts/src/puck-manifest/reading-budget.d.ts +50 -0
  209. package/dist/ts/src/puck-manifest/reading-budget.d.ts.map +1 -0
  210. package/dist/ts/src/puck-manifest/reading-budget.js +113 -0
  211. package/dist/ts/src/puck-manifest/reading-budget.js.map +1 -0
  212. package/dist/ts/src/puck-manifest/resolve-reference.d.ts +4 -0
  213. package/dist/ts/src/puck-manifest/resolve-reference.d.ts.map +1 -0
  214. package/dist/ts/src/puck-manifest/resolve-reference.js +4 -0
  215. package/dist/ts/src/puck-manifest/resolve-reference.js.map +1 -0
  216. package/dist/ts/src/puck-manifest/source-reference.d.ts +96 -0
  217. package/dist/ts/src/puck-manifest/source-reference.d.ts.map +1 -0
  218. package/dist/ts/src/puck-manifest/source-reference.js +424 -0
  219. package/dist/ts/src/puck-manifest/source-reference.js.map +1 -0
  220. package/dist/ts/src/puck-manifest/syntax.d.ts +29 -0
  221. package/dist/ts/src/puck-manifest/syntax.d.ts.map +1 -0
  222. package/dist/ts/src/puck-manifest/syntax.js +79 -0
  223. package/dist/ts/src/puck-manifest/syntax.js.map +1 -0
  224. package/dist/ts/src/puck-manifest/types.d.ts +145 -0
  225. package/dist/ts/src/puck-manifest/types.d.ts.map +1 -0
  226. package/dist/ts/src/puck-manifest/types.js +2 -0
  227. package/dist/ts/src/puck-manifest/types.js.map +1 -0
  228. package/dist/ts/src/safe-json-stringify.d.ts +13 -0
  229. package/dist/ts/src/safe-json-stringify.d.ts.map +1 -0
  230. package/dist/ts/src/safe-json-stringify.js +7 -0
  231. package/dist/ts/src/safe-json-stringify.js.map +1 -0
  232. package/dist/ts/src/sandbox-frame-handler.d.ts +19 -0
  233. package/dist/ts/src/sandbox-frame-handler.d.ts.map +1 -0
  234. package/dist/ts/src/sandbox-frame-handler.js +27 -0
  235. package/dist/ts/src/sandbox-frame-handler.js.map +1 -0
  236. package/dist/ts/src/site-styles/content-wrapper-endpoint.d.ts +73 -0
  237. package/dist/ts/src/site-styles/content-wrapper-endpoint.d.ts.map +1 -0
  238. package/dist/ts/src/site-styles/content-wrapper-endpoint.js +224 -0
  239. package/dist/ts/src/site-styles/content-wrapper-endpoint.js.map +1 -0
  240. package/dist/ts/src/site-styles/render-endpoint.d.ts +50 -0
  241. package/dist/ts/src/site-styles/render-endpoint.d.ts.map +1 -0
  242. package/dist/ts/src/site-styles/render-endpoint.js +264 -0
  243. package/dist/ts/src/site-styles/render-endpoint.js.map +1 -0
  244. package/dist/ts/src/site-styles/styles-endpoint.d.ts +59 -0
  245. package/dist/ts/src/site-styles/styles-endpoint.d.ts.map +1 -0
  246. package/dist/ts/src/site-styles/styles-endpoint.js +156 -0
  247. package/dist/ts/src/site-styles/styles-endpoint.js.map +1 -0
  248. package/dist/ts/src/sitemap-options.d.ts +21 -0
  249. package/dist/ts/src/sitemap-options.d.ts.map +1 -0
  250. package/dist/ts/src/sitemap-options.js +92 -0
  251. package/dist/ts/src/sitemap-options.js.map +1 -0
  252. package/dist/ts/src/tiptap-html-static.d.ts +15 -0
  253. package/dist/ts/src/tiptap-html-static.d.ts.map +1 -0
  254. package/dist/ts/src/tiptap-html-static.js +67 -0
  255. package/dist/ts/src/tiptap-html-static.js.map +1 -0
  256. package/dist/ts/src/types.d.ts +543 -0
  257. package/dist/ts/src/types.d.ts.map +1 -0
  258. package/dist/ts/src/types.js +2 -0
  259. package/dist/ts/src/types.js.map +1 -0
  260. package/dist/virtual-modules.d.ts +74 -0
  261. package/node/content.ts +14 -0
  262. package/node/index.ts +22 -0
  263. package/package.json +198 -56
  264. package/src/asset-ref-base.ts +48 -0
  265. package/src/checks.ts +10 -0
  266. package/src/cms-handler.ts +280 -0
  267. package/src/collections.ts +262 -0
  268. package/src/components/HydrationWrapper.tsx +41 -0
  269. package/src/components/RenderWithFragments.tsx +204 -0
  270. package/src/components/RenderWithHydration.tsx +55 -0
  271. package/src/components.ts +3 -0
  272. package/src/discovery/astro-frontmatter.ts +24 -0
  273. package/src/discovery/discover.ts +108 -0
  274. package/src/discovery/extract-props-ts.ts +255 -0
  275. package/src/discovery/merge-registry.ts +411 -0
  276. package/src/discovery/registry-endpoint.ts +80 -0
  277. package/src/discovery/scan-components.ts +458 -0
  278. package/src/discovery/scan-mdx.ts +190 -0
  279. package/src/discovery/scan-overrides.ts +92 -0
  280. package/src/editor-descriptors.ts +96 -0
  281. package/src/env.d.ts +31 -0
  282. package/src/handlers/collection-content-api.ts +196 -0
  283. package/src/handlers/page-handler.astro +320 -0
  284. package/src/handlers/page-render-core.ts +456 -0
  285. package/src/hydration.ts +7 -0
  286. package/src/index.ts +111 -0
  287. package/src/internal/acorn-default.mjs +37 -0
  288. package/src/internal/declared-collections.ts +98 -0
  289. package/src/internal/page-collection-schema.ts +210 -0
  290. package/src/lib/content-config-guard.ts +48 -0
  291. package/src/lib/hydration-scanner.ts +176 -0
  292. package/src/lib/hydration-script.ts +126 -0
  293. package/src/lib/hydration-utils.ts +120 -0
  294. package/src/lib/resolve-locale.ts +22 -0
  295. package/src/lib/resolve-site-name.ts +10 -0
  296. package/src/lib/route-utils.ts +106 -0
  297. package/src/lib/routing-config.ts +126 -0
  298. package/src/lib/serialize-props.ts +7 -0
  299. package/src/lib/unknown-components.ts +64 -0
  300. package/src/lib/virtual-module-generators.ts +58 -0
  301. package/src/lib/withHydration.ts +71 -0
  302. package/src/loader.ts +145 -0
  303. package/src/locales-helpers.ts +68 -0
  304. package/src/mime-types.ts +19 -0
  305. package/src/page-feed.ts +26 -0
  306. package/src/page-schemas.ts +19 -0
  307. package/src/path-validation.ts +13 -0
  308. package/src/plugin-spa.ts +1480 -0
  309. package/src/puck-manifest/components-endpoint.ts +55 -0
  310. package/src/puck-manifest/field-projection.ts +510 -0
  311. package/src/puck-manifest/index.ts +3 -0
  312. package/src/puck-manifest/literal.ts +459 -0
  313. package/src/puck-manifest/read-config.ts +577 -0
  314. package/src/puck-manifest/read-field.ts +19 -0
  315. package/src/puck-manifest/read-wrapper.ts +1056 -0
  316. package/src/puck-manifest/reading-budget.ts +127 -0
  317. package/src/puck-manifest/resolve-reference.ts +9 -0
  318. package/src/puck-manifest/source-reference.ts +484 -0
  319. package/src/puck-manifest/syntax.ts +104 -0
  320. package/src/puck-manifest/types.ts +139 -0
  321. package/src/safe-json-stringify.ts +17 -0
  322. package/src/sandbox-frame-handler.ts +31 -0
  323. package/src/site-styles/content-wrapper-endpoint.ts +327 -0
  324. package/src/site-styles/render-endpoint.ts +331 -0
  325. package/src/site-styles/styles-endpoint.ts +184 -0
  326. package/src/sitemap-options.ts +115 -0
  327. package/src/tiptap-html-static.ts +84 -0
  328. package/{dist/types-CVQNmPxF.d.mts → src/types.ts} +232 -79
  329. package/src/virtual-modules.d.ts +74 -0
  330. package/dist/collections.d.mts +0 -36
  331. package/dist/collections.d.mts.map +0 -1
  332. package/dist/collections.mjs +0 -65
  333. package/dist/collections.mjs.map +0 -1
  334. package/dist/components.d.mts +0 -46
  335. package/dist/components.d.mts.map +0 -1
  336. package/dist/components.mjs +0 -226
  337. package/dist/components.mjs.map +0 -1
  338. package/dist/hydration-scanner-B0NjYkZ_.mjs +0 -109
  339. package/dist/hydration-scanner-B0NjYkZ_.mjs.map +0 -1
  340. package/dist/hydration.d.mts +0 -4
  341. package/dist/hydration.mjs +0 -3
  342. package/dist/index.d.mts +0 -139
  343. package/dist/index.d.mts.map +0 -1
  344. package/dist/index.mjs +0 -66
  345. package/dist/index.mjs.map +0 -1
  346. package/dist/internal/cms-handler.d.mts +0 -26
  347. package/dist/internal/cms-handler.d.mts.map +0 -1
  348. package/dist/internal/cms-handler.mjs +0 -267
  349. package/dist/internal/cms-handler.mjs.map +0 -1
  350. package/dist/lib/hydration-script.d.mts.map +0 -1
  351. package/dist/lib/hydration-script.mjs +0 -85
  352. package/dist/lib/hydration-script.mjs.map +0 -1
  353. package/dist/loader-By-AQWHc.mjs +0 -68
  354. package/dist/loader-By-AQWHc.mjs.map +0 -1
  355. package/dist/node/content.d.mts +0 -19
  356. package/dist/node/content.d.mts.map +0 -1
  357. package/dist/node/content.mjs +0 -4
  358. package/dist/node/index.d.mts +0 -52
  359. package/dist/node/index.d.mts.map +0 -1
  360. package/dist/node/index.mjs +0 -753
  361. package/dist/node/index.mjs.map +0 -1
  362. package/dist/serialize-props-Dhv_MnkY.mjs +0 -73
  363. package/dist/serialize-props-Dhv_MnkY.mjs.map +0 -1
  364. package/dist/types-CVQNmPxF.d.mts.map +0 -1
  365. package/dist/withHydration-EzyzBQ-Y.mjs +0 -49
  366. package/dist/withHydration-EzyzBQ-Y.mjs.map +0 -1
  367. package/dist/withHydration-HIvO9ysY.d.mts.map +0 -1
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Host-provided override for an auto-discovered component descriptor.
3
+ *
4
+ * Lives in a sidecar JSON file inside the configured overrides folder
5
+ * (default `src/cms-overrides/`). One file per component, keyed by
6
+ * basename: `Card.cms.json` overrides the auto-discovered `Card`.
7
+ *
8
+ * Why JSON, not TS:
9
+ * - Zero tooling. The host doesn't need to import any types, set up
10
+ * build steps, or worry about which export shape we expect.
11
+ * - Static — we don't have to spin up Vite's SSR loader to read it.
12
+ * - Survives copy/paste between projects.
13
+ *
14
+ * The shape is intentionally a flat subset of `MdxJsxComponentDescriptor` —
15
+ * not the full union — because hosts only need to override the
16
+ * fields that come up in practice (insert menu hints, prop schema
17
+ * tweaks, defaults). New fields can be added later without breaking
18
+ * existing JSON files.
19
+ */
20
+ export interface CmsOverride {
21
+ /** Override the slash-menu / toolbar entry (label, category, icon, etc.). */
22
+ insert?: {
23
+ label?: string;
24
+ description?: string;
25
+ category?: string;
26
+ icon?: string;
27
+ keywords?: string[];
28
+ };
29
+ /** Override the insert-time starter attribute values. Merges over
30
+ * the auto-derived `defaults.attributes` so hosts can pin specific
31
+ * placeholder text or set a default for a prop the inference missed. */
32
+ defaults?: {
33
+ attributes?: Record<string, string | number | boolean>;
34
+ /** Raw MDX snippet parsed to mdast children at insert time. */
35
+ children?: string;
36
+ };
37
+ /** Per-prop overrides keyed by prop name. Fields here merge over
38
+ * the inferred prop schema (matched by `name`). Useful when:
39
+ * - The interface scan missed `required` (rare type pattern).
40
+ * - You want explicit help text or a friendly label.
41
+ * - You want a curated `options` list instead of usage-observed values. */
42
+ props?: Record<string, {
43
+ required?: boolean;
44
+ label?: string;
45
+ help?: string;
46
+ options?: Array<{
47
+ value: string;
48
+ label: string;
49
+ }>;
50
+ }>;
51
+ /** Override whether the component accepts children. Inferred to
52
+ * `true` by default; set to `false` for self-closing components. */
53
+ hasChildren?: boolean;
54
+ /** Override the flow/text kind. The flow-wins promotion in
55
+ * `merge-registry.ts` usually gets this right, but a host can
56
+ * pin the kind explicitly here if their fixtures don't exercise
57
+ * the block-context usage. */
58
+ kind?: 'flow' | 'text';
59
+ }
60
+ /**
61
+ * Read every `*.cms.json` file under `folder` (recursive) and return
62
+ * the parsed overrides keyed by basename (`Card.cms.json` → `Card`).
63
+ *
64
+ * Failures are skipped with a warning — a broken JSON file shouldn't
65
+ * take down the rest of the registry build. The folder being empty
66
+ * (or not existing) returns an empty map silently; that's the
67
+ * common zero-config case where the host hasn't added any
68
+ * overrides yet.
69
+ */
70
+ export declare function loadCmsOverrides(folder: string, projectRoot: string): Promise<Map<string, CmsOverride>>;
71
+ //# sourceMappingURL=scan-overrides.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scan-overrides.d.ts","sourceRoot":"","sources":["../../../../src/discovery/scan-overrides.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,WAAW;IAC1B,6EAA6E;IAC7E,MAAM,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;KACrB,CAAC;IACF;;4EAEwE;IACxE,QAAQ,CAAC,EAAE;QACT,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;QACvD,+DAA+D;QAC/D,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;IACF;;;;iFAI6E;IAC7E,KAAK,CAAC,EAAE,MAAM,CACZ,MAAM,EACN;QACE,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,KAAK,CAAC;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KACnD,CACF,CAAC;IACF;wEACoE;IACpE,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;kCAG8B;IAC9B,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB;AAED;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAiB7G"}
@@ -0,0 +1,34 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import { basename } from 'node:path';
3
+ import fg from 'fast-glob';
4
+ /**
5
+ * Read every `*.cms.json` file under `folder` (recursive) and return
6
+ * the parsed overrides keyed by basename (`Card.cms.json` → `Card`).
7
+ *
8
+ * Failures are skipped with a warning — a broken JSON file shouldn't
9
+ * take down the rest of the registry build. The folder being empty
10
+ * (or not existing) returns an empty map silently; that's the
11
+ * common zero-config case where the host hasn't added any
12
+ * overrides yet.
13
+ */
14
+ export async function loadCmsOverrides(folder, projectRoot) {
15
+ const out = new Map();
16
+ if (!folder)
17
+ return out;
18
+ const pattern = `${folder.replace(/\/+$/, '')}/**/*.cms.json`;
19
+ const files = await fg(pattern, { cwd: projectRoot, absolute: true, dot: false });
20
+ for (const file of files) {
21
+ try {
22
+ const content = await readFile(file, 'utf8');
23
+ const parsed = JSON.parse(content);
24
+ const base = basename(file);
25
+ const name = base.slice(0, -'.cms.json'.length);
26
+ out.set(name, parsed);
27
+ }
28
+ catch (err) {
29
+ console.warn(`[conloca:discovery] failed to load override ${file}:`, err instanceof Error ? err.message : err);
30
+ }
31
+ }
32
+ return out;
33
+ }
34
+ //# sourceMappingURL=scan-overrides.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scan-overrides.js","sourceRoot":"","sources":["../../../../src/discovery/scan-overrides.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,MAAM,WAAW,CAAC;AA8D3B;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,MAAc,EAAE,WAAmB;IACxE,MAAM,GAAG,GAAG,IAAI,GAAG,EAAuB,CAAC;IAC3C,IAAI,CAAC,MAAM;QAAE,OAAO,GAAG,CAAC;IACxB,MAAM,OAAO,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,gBAAgB,CAAC;IAC9D,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,GAAG,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC;IAClF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAC7C,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAgB,CAAC;YAClD,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;YAC5B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;YAChD,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACxB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,IAAI,CAAC,+CAA+C,IAAI,GAAG,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACjH,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,31 @@
1
+ import type { MdxRegistryScanOptions } from './discovery/discover.js';
2
+ import type { EditorDataBindings, TemplateConfig } from './types.js';
3
+ /**
4
+ * Env var through which `conlocaCMS` publishes the editor descriptors it
5
+ * resolved during an Astro build, alongside `CONLOCA_CONTENT_ROOT`.
6
+ *
7
+ * The CMS resolves them once — the site's schemas module, the MDX registry
8
+ * scan inputs, the page templates and the routing data bindings — so another
9
+ * integration in the same build reads the SAME descriptors dev serves from
10
+ * `schemasPath`, `/api/registry` and its UI config instead of taking those
11
+ * options a second time.
12
+ */
13
+ export declare const EDITOR_DESCRIPTORS_ENV_VAR = "CONLOCA_EDITOR_DESCRIPTORS";
14
+ export interface EditorDescriptorChannel {
15
+ /** Absolute path of the host's schemas module (the `schemasPath` option), when configured. */
16
+ schemasPath?: string;
17
+ /** Resolved inputs for the MDX component registry scan (`mdxComponentFolders` + the MDX content root). */
18
+ registry: MdxRegistryScanOptions;
19
+ /** Page-creation templates (the `templates` option), when configured. */
20
+ templates?: Record<string, TemplateConfig>;
21
+ /** The routing data bindings each page's data context is built from, when the site has content routes. */
22
+ dataBindings?: EditorDataBindings;
23
+ }
24
+ /**
25
+ * Reads the channel conlocaCMS published, or undefined when it is absent or
26
+ * unusable — a CMS-less build, or an older `@conloca/astro-cms`. Never throws:
27
+ * descriptors are an enhancement to the editor, and a site's build must
28
+ * not die over them.
29
+ */
30
+ export declare function readEditorDescriptors(env?: Record<string, string | undefined>): EditorDescriptorChannel | undefined;
31
+ //# sourceMappingURL=editor-descriptors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editor-descriptors.d.ts","sourceRoot":"","sources":["../../../src/editor-descriptors.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAErE;;;;;;;;;GASG;AACH,eAAO,MAAM,0BAA0B,+BAA+B,CAAC;AAEvE,MAAM,WAAW,uBAAuB;IACtC,8FAA8F;IAC9F,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0GAA0G;IAC1G,QAAQ,EAAE,sBAAsB,CAAC;IACjC,yEAAyE;IACzE,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC3C,0GAA0G;IAC1G,YAAY,CAAC,EAAE,kBAAkB,CAAC;CACnC;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GACpD,uBAAuB,GAAG,SAAS,CAuCrC"}
@@ -0,0 +1,84 @@
1
+ import { readEditorDataBindings } from '@conloca/content-api';
2
+ /**
3
+ * Env var through which `conlocaCMS` publishes the editor descriptors it
4
+ * resolved during an Astro build, alongside `CONLOCA_CONTENT_ROOT`.
5
+ *
6
+ * The CMS resolves them once — the site's schemas module, the MDX registry
7
+ * scan inputs, the page templates and the routing data bindings — so another
8
+ * integration in the same build reads the SAME descriptors dev serves from
9
+ * `schemasPath`, `/api/registry` and its UI config instead of taking those
10
+ * options a second time.
11
+ */
12
+ export const EDITOR_DESCRIPTORS_ENV_VAR = 'CONLOCA_EDITOR_DESCRIPTORS';
13
+ /**
14
+ * Reads the channel conlocaCMS published, or undefined when it is absent or
15
+ * unusable — a CMS-less build, or an older `@conloca/astro-cms`. Never throws:
16
+ * descriptors are an enhancement to the editor, and a site's build must
17
+ * not die over them.
18
+ */
19
+ export function readEditorDescriptors(env = process.env) {
20
+ const raw = env[EDITOR_DESCRIPTORS_ENV_VAR];
21
+ if (raw === undefined || raw === '')
22
+ return undefined;
23
+ let parsed;
24
+ try {
25
+ parsed = JSON.parse(raw);
26
+ }
27
+ catch {
28
+ return undefined;
29
+ }
30
+ if (typeof parsed !== 'object' || parsed === null)
31
+ return undefined;
32
+ const schemasPath = 'schemasPath' in parsed ? parsed.schemasPath : undefined;
33
+ const registry = 'registry' in parsed ? parsed.registry : undefined;
34
+ const templateValue = 'templates' in parsed ? parsed.templates : undefined;
35
+ const dataBindingValue = 'dataBindings' in parsed ? parsed.dataBindings : undefined;
36
+ if (typeof registry !== 'object' || registry === null)
37
+ return undefined;
38
+ const contentRoot = 'contentRoot' in registry ? registry.contentRoot : undefined;
39
+ const componentFolders = 'componentFolders' in registry ? registry.componentFolders : undefined;
40
+ const projectRoot = 'projectRoot' in registry ? registry.projectRoot : undefined;
41
+ const overridesFolder = 'overridesFolder' in registry ? registry.overridesFolder : undefined;
42
+ if (typeof contentRoot !== 'string' ||
43
+ !Array.isArray(componentFolders) ||
44
+ !componentFolders.every((folder) => typeof folder === 'string')) {
45
+ return undefined;
46
+ }
47
+ const templates = readTemplates(templateValue);
48
+ const dataBindings = readEditorDataBindings(dataBindingValue);
49
+ return {
50
+ ...(typeof schemasPath === 'string' ? { schemasPath } : {}),
51
+ registry: {
52
+ contentRoot,
53
+ componentFolders,
54
+ ...(typeof projectRoot === 'string' ? { projectRoot } : {}),
55
+ ...(typeof overridesFolder === 'string' ? { overridesFolder } : {}),
56
+ },
57
+ ...(templates === undefined ? {} : { templates }),
58
+ ...(dataBindings === undefined ? {} : { dataBindings }),
59
+ };
60
+ }
61
+ /**
62
+ * Per-entry validation: a malformed entry is dropped, the rest survive — one
63
+ * bad template must not cost the create-page dialog all of them.
64
+ */
65
+ function readTemplates(raw) {
66
+ if (typeof raw !== 'object' || raw === null)
67
+ return undefined;
68
+ const templates = {};
69
+ for (const [key, value] of Object.entries(raw)) {
70
+ if (typeof value !== 'object' || value === null)
71
+ continue;
72
+ const { label, component, pathPrefix, description } = value;
73
+ if (typeof label !== 'string' || typeof component !== 'string')
74
+ continue;
75
+ templates[key] = {
76
+ label,
77
+ component,
78
+ ...(typeof pathPrefix === 'string' ? { pathPrefix } : {}),
79
+ ...(typeof description === 'string' ? { description } : {}),
80
+ };
81
+ }
82
+ return Object.keys(templates).length > 0 ? templates : undefined;
83
+ }
84
+ //# sourceMappingURL=editor-descriptors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editor-descriptors.js","sourceRoot":"","sources":["../../../src/editor-descriptors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAI9D;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,4BAA4B,CAAC;AAavE;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CACnC,GAAG,GAAuC,OAAO,CAAC,GAAG;IAErD,MAAM,GAAG,GAAG,GAAG,CAAC,0BAA0B,CAAC,CAAC;IAC5C,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,EAAE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,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;YAAE,SAAS;QAC1D,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,KAAgC,CAAC;QACvF,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,SAAS,KAAK,QAAQ;YAAE,SAAS;QACzE,SAAS,CAAC,GAAG,CAAC,GAAG;YACf,KAAK;YACL,SAAS;YACT,GAAG,CAAC,OAAO,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACzD,GAAG,CAAC,OAAO,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC5D,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;AACnE,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Read-only {@link ContentAPI} over the Astro content collections baked into
3
+ * the build, for a caller that needs the ContentAPI read surface where there is
4
+ * no content folder on disk.
5
+ *
6
+ * This factory projects `getCollection` entries back into the `ContentAPI`
7
+ * read surface: `listAllContent`, `getLocalized`, `getContent`, `sitesConfig`.
8
+ * It is astro-free — `getCollection` and the resolved routing config are
9
+ * injected — so it can be imported outside an Astro page.
10
+ *
11
+ * Reconstruction is the inverse of `loader.ts`: collection entries are the
12
+ * flattened per-locale records; we regroup them by id into manifests and rebuild
13
+ * per-locale content from the record's `puckData`/`mdx`/`data`. The index is
14
+ * built eagerly (the factory is async) because the `ContentAPI.listAllContent`
15
+ * generator is synchronous. It is a content-fidelity surface, not a byte-perfect
16
+ * index: manifest etags are synthesised from the record's `modified` stamp, and
17
+ * every write is rejected.
18
+ */
19
+ import type { ContentAPI } from '@conloca/content-api';
20
+ import type { ResolvedRoutingConfig } from '../types.js';
21
+ interface CollectionEntry {
22
+ data: Record<string, unknown>;
23
+ }
24
+ export interface CollectionBackedContentAPIOptions {
25
+ /** Astro's `getCollection`, narrowed to the entry shape this factory reads. */
26
+ getCollection: (collection: string) => Promise<CollectionEntry[]>;
27
+ /** Resolved routing config — enumerates the page + data collections to index. */
28
+ routing: ResolvedRoutingConfig;
29
+ }
30
+ export declare function createCollectionBackedContentAPI(opts: CollectionBackedContentAPIOptions): Promise<ContentAPI>;
31
+ export {};
32
+ //# sourceMappingURL=collection-content-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collection-content-api.d.ts","sourceRoot":"","sources":["../../../../src/handlers/collection-content-api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAEV,UAAU,EAcX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAGzD,UAAU,eAAe;IACvB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AA+CD,MAAM,WAAW,iCAAiC;IAChD,+EAA+E;IAC/E,aAAa,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IAClE,iFAAiF;IACjF,OAAO,EAAE,qBAAqB,CAAC;CAChC;AAED,wBAAsB,gCAAgC,CAAC,IAAI,EAAE,iCAAiC,GAAG,OAAO,CAAC,UAAU,CAAC,CAoGnH"}
@@ -0,0 +1,166 @@
1
+ /**
2
+ * Read-only {@link ContentAPI} over the Astro content collections baked into
3
+ * the build, for a caller that needs the ContentAPI read surface where there is
4
+ * no content folder on disk.
5
+ *
6
+ * This factory projects `getCollection` entries back into the `ContentAPI`
7
+ * read surface: `listAllContent`, `getLocalized`, `getContent`, `sitesConfig`.
8
+ * It is astro-free — `getCollection` and the resolved routing config are
9
+ * injected — so it can be imported outside an Astro page.
10
+ *
11
+ * Reconstruction is the inverse of `loader.ts`: collection entries are the
12
+ * flattened per-locale records; we regroup them by id into manifests and rebuild
13
+ * per-locale content from the record's `puckData`/`mdx`/`data`. The index is
14
+ * built eagerly (the factory is async) because the `ContentAPI.listAllContent`
15
+ * generator is synchronous. It is a content-fidelity surface, not a byte-perfect
16
+ * index: manifest etags are synthesised from the record's `modified` stamp, and
17
+ * every write is rejected.
18
+ */
19
+ import { ALL_FRAGMENTS_COLLECTION } from './page-render-core.js';
20
+ const WRITE_REJECTED = 'collection-backed ContentAPI is read-only';
21
+ function str(value) {
22
+ return typeof value === 'string' ? value : undefined;
23
+ }
24
+ /** Split a record into its LocaleVersion metadata and its content payload. */
25
+ function splitRecord(record) {
26
+ // The rest element is the meta split: everything named here is LocaleVersion
27
+ // structure or content payload, and whatever remains is page metadata (host
28
+ // schema fields plus title/description).
29
+ const { id, locale, pathname, name, puckData, mdx, data, created, modified, publishAt, unpublishAt, ...meta } = record;
30
+ const path = str(pathname);
31
+ const entryName = str(name);
32
+ const modifiedAt = str(modified);
33
+ const publishesAt = str(publishAt);
34
+ const unpublishesAt = str(unpublishAt);
35
+ const version = {
36
+ locale: str(locale) ?? '',
37
+ ...(path !== undefined && { pathname: path }),
38
+ ...(entryName !== undefined && { name: entryName }),
39
+ etag: `collection:${modifiedAt ?? '0'}`,
40
+ created: str(created) ?? '',
41
+ modified: modifiedAt ?? '',
42
+ ...(publishesAt !== undefined && { publishAt: publishesAt }),
43
+ ...(unpublishesAt !== undefined && { unpublishAt: unpublishesAt }),
44
+ meta: meta,
45
+ };
46
+ const content = {};
47
+ if (puckData !== undefined)
48
+ content.puckData = puckData;
49
+ if (typeof mdx === 'string')
50
+ content.mdx = mdx;
51
+ if (data !== undefined)
52
+ content.data = data;
53
+ return { version, content };
54
+ }
55
+ /** Infer the content kind + type from a record's shape (pathname → page, mdx → fragment, else data). */
56
+ function classify(collection, record) {
57
+ if (collection === ALL_FRAGMENTS_COLLECTION || record.mdx !== undefined)
58
+ return { kind: 'fragment', type: 'mdx' };
59
+ if (record.pathname !== undefined || record.puckData !== undefined)
60
+ return { kind: 'page', type: 'puck' };
61
+ return { kind: 'data', type: 'json' };
62
+ }
63
+ export async function createCollectionBackedContentAPI(opts) {
64
+ // Every collection a reader can ask for: page collections and their
65
+ // bound data collections (from routing) plus the synthetic fragments collection.
66
+ const collectionNames = new Set([ALL_FRAGMENTS_COLLECTION]);
67
+ for (const route of Object.values(opts.routing.routes)) {
68
+ collectionNames.add(route.collection);
69
+ for (const dataCollection of route.dataBindings?.collections ?? [])
70
+ collectionNames.add(dataCollection);
71
+ }
72
+ // Build the index eagerly — `listAllContent` is a synchronous generator, so
73
+ // the data must be present before anyone iterates it.
74
+ const manifests = [];
75
+ const entries = new Map();
76
+ for (const collection of collectionNames) {
77
+ const records = (await opts.getCollection(collection).catch(() => [])).map((entry) => entry.data);
78
+ // Group a collection's per-locale records back into per-id manifests.
79
+ const byId = new Map();
80
+ for (const record of records) {
81
+ const id = str(record.id);
82
+ if (id === undefined)
83
+ continue;
84
+ const group = byId.get(id);
85
+ if (group)
86
+ group.push(record);
87
+ else
88
+ byId.set(id, [record]);
89
+ }
90
+ for (const [id, group] of byId) {
91
+ const { kind, type } = classify(collection, group[0]);
92
+ const identity = { id, type, kind, collection };
93
+ const locales = {};
94
+ for (const record of group) {
95
+ const locale = str(record.locale);
96
+ if (locale === undefined)
97
+ continue;
98
+ const { version, content } = splitRecord(record);
99
+ locales[locale] = version;
100
+ entries.set(`${id} ${locale}`, { ...identity, localized: { ...version, content } });
101
+ }
102
+ manifests.push({ ...identity, locales });
103
+ }
104
+ }
105
+ return {
106
+ get sitesConfig() {
107
+ return { sites: {}, globalLocales: [opts.routing.locale ?? 'en'] };
108
+ },
109
+ // Content is read through getLocalized, never through these
110
+ // shared-collection accessors; they return rather than throw so that code
111
+ // reading every property of a ContentAPI keeps working.
112
+ fragments: undefined,
113
+ data: undefined,
114
+ async getContent(id) {
115
+ const manifest = manifests.find((candidate) => candidate.id === id);
116
+ if (!manifest)
117
+ return null;
118
+ const locales = {};
119
+ for (const locale of Object.keys(manifest.locales)) {
120
+ const entry = entries.get(`${id} ${locale}`);
121
+ if (entry)
122
+ locales[locale] = entry.localized;
123
+ }
124
+ return { ...manifest, locales };
125
+ },
126
+ async getLocalized(id, locale) {
127
+ return entries.get(`${id} ${locale}`) ?? null;
128
+ },
129
+ getSite(_siteName) {
130
+ return null;
131
+ },
132
+ *listAllContent(filters) {
133
+ for (const manifest of manifests) {
134
+ if (filters?.collection !== undefined && manifest.collection !== filters.collection)
135
+ continue;
136
+ if (filters?.kind !== undefined && manifest.kind !== filters.kind)
137
+ continue;
138
+ if (filters?.site !== undefined && manifest.site !== filters.site)
139
+ continue;
140
+ yield manifest;
141
+ }
142
+ },
143
+ *findUntranslatedContent() {
144
+ // Not part of the preview render path.
145
+ },
146
+ async createContent() {
147
+ return { success: false, reason: 'write_error', error: new Error(WRITE_REJECTED) };
148
+ },
149
+ async updateLocalized() {
150
+ return { success: false, reason: 'write_error', error: new Error(WRITE_REJECTED) };
151
+ },
152
+ async deleteContent() {
153
+ return { success: false, reason: 'delete_error', error: new Error(WRITE_REJECTED) };
154
+ },
155
+ async deleteLocalized() {
156
+ return { success: false, reason: 'delete_error', error: new Error(WRITE_REJECTED) };
157
+ },
158
+ async batchUpdate() {
159
+ return { operations: [], success: false, failed: 0, updated: 0 };
160
+ },
161
+ async getContentAsBuffer() {
162
+ return null;
163
+ },
164
+ };
165
+ }
166
+ //# sourceMappingURL=collection-content-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collection-content-api.js","sourceRoot":"","sources":["../../../../src/handlers/collection-content-api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAoBH,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAQjE,MAAM,cAAc,GAAG,2CAA2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C,cAAc,CAAC,EAAE,CAAC;QACtF,CAAC;QACD,KAAK,CAAC,eAAe;YACnB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,IAAI,KAAK,CAAC,cAAc,CAAC,EAAE,CAAC;QACtF,CAAC;QACD,KAAK,CAAC,WAAW;YACf,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;QACnE,CAAC;QACD,KAAK,CAAC,kBAAkB;YACtB,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,137 @@
1
+ /**
2
+ * Astro-free render core for the page handler.
3
+ *
4
+ * The pure frontmatter logic of `page-handler.astro` (entry shaping/filtering,
5
+ * data context assembly, puck-data resolution, MDX fragment loading) lives here,
6
+ * parameterized over a narrow {@link PageContentSource} so the same logic runs
7
+ * against two backends: Astro content collections, and a ContentAPI reader a
8
+ * caller installs on `Astro.locals.contentApi`. No `astro:content` import and
9
+ * no `import.meta.env` — the `.astro` file injects `getCollection` (via
10
+ * {@link createCollectionContentSource}) and the dev flag, so this module is
11
+ * importable outside an Astro page.
12
+ */
13
+ import { type ContentAPI, type MDXHeading } from '@conloca/content-api';
14
+ import type { Config } from '@puckeditor/core';
15
+ import { type Data } from '@puckeditor/core';
16
+ import type { ComponentType } from 'react';
17
+ import type { DataCollectionEntry, DataContext, PageReference, ResolvedRoutingConfig } from '../types.js';
18
+ export { findUnknownComponentTypes } from '../lib/unknown-components.js';
19
+ /**
20
+ * Synthetic collection every discovered fragment lands in (the loader flattens
21
+ * all fragment collections into one). Owned here — rather than imported from
22
+ * `collections.ts` — so this core stays free of the `astro:content` that module
23
+ * pulls in; `collections.ts` re-exports it to keep the public name stable.
24
+ */
25
+ export declare const ALL_FRAGMENTS_COLLECTION = "__conloca_fragments";
26
+ /**
27
+ * The single content-access seam the render core depends on: give me the raw
28
+ * frontmatter data records for a collection. The collection-backed impl wraps
29
+ * Astro's `getCollection`; the reader-backed impl (preview) projects
30
+ * ContentAPI content into the same record shape.
31
+ */
32
+ export interface PageContentSource {
33
+ listEntries(collection: string): Promise<Record<string, unknown>[]>;
34
+ }
35
+ interface BaseEntryData {
36
+ id: string;
37
+ locale: string;
38
+ title?: string;
39
+ description?: string;
40
+ created?: string | Date;
41
+ modified?: string | Date;
42
+ publishAt?: string | Date | null;
43
+ unpublishAt?: string | Date | null;
44
+ }
45
+ export interface PageEntryData extends BaseEntryData {
46
+ pathname?: string;
47
+ puckData?: Data;
48
+ }
49
+ /**
50
+ * A page entry as the content loader delivers it: the structural fields above
51
+ * plus the host page schema's meta fields flattened alongside them.
52
+ */
53
+ export type PageEntryRecord = PageEntryData & Record<string, unknown>;
54
+ /** An evaluated MDX fragment ready to render, matching RenderWithFragments' shape. */
55
+ export interface MdxFragmentComponent {
56
+ id: string;
57
+ title: string;
58
+ Component: ComponentType;
59
+ outline: readonly MDXHeading[];
60
+ }
61
+ type EvaluateMDXToComponentFn = typeof import('@conloca/mdx/node')['evaluateMDXToComponent'];
62
+ /**
63
+ * Collection-backed {@link PageContentSource}. The production render path
64
+ * injects Astro's `getCollection`; the dev flag preserves the handler's
65
+ * cache-bypass-in-DEV behaviour and the per-render dedup cache. Kept identical
66
+ * to the handler's former inline `loadCollectionEntries`/`getCollectionEntries`
67
+ * so the built page HTML is byte-for-byte unchanged.
68
+ */
69
+ export declare function createCollectionContentSource(deps: {
70
+ getCollection: (collection: string) => Promise<{
71
+ data: unknown;
72
+ }[]>;
73
+ isDev: boolean;
74
+ }): PageContentSource;
75
+ /**
76
+ * Canonical pathname form: no trailing slash, except the root itself. Site
77
+ * nav links carry trailing slashes ('/faq/') while entry pathnames are
78
+ * canonical ('/faq'); every exact-equality match must go through this.
79
+ */
80
+ export declare function normalizePathname(pathname: string): string;
81
+ /**
82
+ * Response for a matched route whose content lookup found nothing. The
83
+ * 'passthrough' body is deliberately null: Astro only reroutes a 404 to the
84
+ * site's own /404 route when the body is empty, and that reroute serves even a
85
+ * prerendered /404 page with a real 404 status — so the site keeps its designed
86
+ * not-found page without a soft-404 redirect.
87
+ */
88
+ export declare function pageNotFoundResponse(fallback: '404' | 'passthrough'): Response;
89
+ /**
90
+ * Published page entries for a collection/locale, shaped for downstream use.
91
+ * The narrowing `isPageEntryRecord` performs is kept in the return type, so
92
+ * callers read `pathname` as the string the filter already guaranteed.
93
+ */
94
+ export declare function getPageEntries(source: PageContentSource, collectionName: string, locale: string): Promise<(PageEntryRecord & {
95
+ pathname: string;
96
+ })[]>;
97
+ export declare function getPagesByPrefix(source: PageContentSource, prefix: string, locale: string, config: ResolvedRoutingConfig, options?: {
98
+ sort?: 'date-desc' | 'date-asc' | 'title';
99
+ limit?: number;
100
+ }): Promise<PageReference[]>;
101
+ export declare function getDataCollectionEntries(source: PageContentSource, collectionName: string, locale: string): Promise<DataCollectionEntry[]>;
102
+ /**
103
+ * Evaluate every published MDX fragment for a locale into a renderable React
104
+ * component. `evaluateMDXToComponent` and `isDev` are injected so the core
105
+ * stays astro/vite-free.
106
+ */
107
+ export declare function loadMdxComponents(source: PageContentSource, locale: string, evaluateMDXToComponent: EvaluateMDXToComponentFn, isDev: boolean): Promise<MdxFragmentComponent[]>;
108
+ /**
109
+ * Assemble the data context every block of `entry` is rendered with: the page
110
+ * itself, plus the collections and pages-by-prefix its route's data bindings
111
+ * declare.
112
+ */
113
+ export declare function buildDataContext(source: PageContentSource, routeConfig: ResolvedRoutingConfig['routes'][string], config: ResolvedRoutingConfig, entry: PageEntryRecord & {
114
+ pathname: string;
115
+ }): Promise<DataContext>;
116
+ /**
117
+ * Resolve a page's Puck data for render: apply component defaultProps, then run
118
+ * Puck's async data-resolution with the data context as each resolver's
119
+ * `metadata`. Falls back to the merged (unresolved) data on a resolver error,
120
+ * matching the handler's former behaviour.
121
+ */
122
+ export declare function resolvePuckData(puckData: Data, puckConfig: Config, dataContext: DataContext): Promise<Data>;
123
+ /**
124
+ * Reader-backed {@link PageContentSource} over a {@link ContentAPI}, the one a
125
+ * caller installs on `Astro.locals.contentApi`. It projects the reader's
126
+ * manifest listing + per-locale content into the SAME record shape the
127
+ * collection-backed source (and the Astro loader) produce, so the render core
128
+ * is oblivious to which backend served it: the page shows whatever that
129
+ * reader returns.
130
+ *
131
+ * The synthetic `__conloca_fragments` collection is not a real ContentAPI
132
+ * collection (the loader flattens every fragment collection into it), so it maps
133
+ * to a `kind: 'fragment'` query; `type: 'mdx'` PAGES are skipped exactly as the
134
+ * loader skips them (they belong to an external renderer).
135
+ */
136
+ export declare function createReaderContentSource(api: ContentAPI, renderLocale?: string): PageContentSource;
137
+ //# sourceMappingURL=page-render-core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page-render-core.d.ts","sourceRoot":"","sources":["../../../../src/handlers/page-render-core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EACL,KAAK,UAAU,EAIf,KAAK,UAAU,EAGhB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,KAAK,IAAI,EAAkB,MAAM,kBAAkB,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,KAAK,EAAE,mBAAmB,EAAE,WAAW,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAI1G,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAEzE;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,wBAAwB,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;CACrE;AAED,UAAU,aAAa;IACr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