@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
@@ -1,65 +0,0 @@
1
- import { t as conlocaLoader } from "./loader-By-AQWHc.mjs";
2
- import { blockMetaSchema, dataMetaSchema, pageMetaSchema } from "@conloca/content-api/schemas";
3
- import { defineCollection } from "astro:content";
4
- import { createContentAPI } from "@conloca/content-api/reader";
5
-
6
- //#region src/collections.ts
7
- const ALL_BLOCKS_COLLECTION = "__conloca_blocks";
8
- /**
9
- * Creates Astro Content Collections by discovering from indexed content.
10
- * Uses content-api to find collections that have content.
11
- *
12
- * @example
13
- * ```typescript
14
- * // src/content.config.ts
15
- * import { createConlocaCollections } from '@conloca/astro-cms/node/content';
16
- *
17
- * export const { collections } = await createConlocaCollections();
18
- * ```
19
- */
20
- async function createConlocaCollections(options = {}) {
21
- const { contentRoot = "./content", site = "default" } = options;
22
- const api = await createContentAPI({ contentRoot });
23
- const collections = {};
24
- collections[ALL_BLOCKS_COLLECTION] = defineCollection({
25
- loader: conlocaLoader({
26
- contentRoot,
27
- site,
28
- kind: "block"
29
- }),
30
- schema: blockMetaSchema.passthrough()
31
- });
32
- for (const name of api.blocks.collections) collections[name] = defineCollection({
33
- loader: conlocaLoader({
34
- collection: name,
35
- contentRoot,
36
- site,
37
- kind: "block"
38
- }),
39
- schema: blockMetaSchema.passthrough()
40
- });
41
- for (const name of api.data.collections) collections[name] = defineCollection({
42
- loader: conlocaLoader({
43
- collection: name,
44
- contentRoot,
45
- site,
46
- kind: "data"
47
- }),
48
- schema: dataMetaSchema.passthrough()
49
- });
50
- const siteCollections = api.getSite(site)?.collections ?? /* @__PURE__ */ new Set();
51
- for (const name of siteCollections) collections[name] = defineCollection({
52
- loader: conlocaLoader({
53
- collection: name,
54
- contentRoot,
55
- site,
56
- kind: "page"
57
- }),
58
- schema: pageMetaSchema.passthrough()
59
- });
60
- return { collections };
61
- }
62
-
63
- //#endregion
64
- export { ALL_BLOCKS_COLLECTION, createConlocaCollections };
65
- //# sourceMappingURL=collections.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"collections.mjs","names":[],"sources":["../src/collections.ts"],"sourcesContent":["import { defineCollection } from 'astro:content';\nimport { createContentAPI } from '@conloca/content-api/reader';\nimport { blockMetaSchema, dataMetaSchema, pageMetaSchema } from '@conloca/content-api/schemas';\nimport { conlocaLoader } from './loader';\n\nexport const ALL_BLOCKS_COLLECTION = '__conloca_blocks';\n\n/**\n * Options for createConlocaCollections().\n */\nexport interface CreateConlocaCollectionsOptions {\n /** Path to content root directory. @default './content' */\n contentRoot?: string;\n /** Site name for multi-site setups. @default 'default' */\n site?: string;\n}\n\n/**\n * Return type of createConlocaCollections().\n */\nexport interface ConlocaCollectionsResult {\n /** Astro Content Collections definitions - export this as `collections` */\n collections: Record<string, ReturnType<typeof defineCollection>>;\n}\n\n/**\n * Creates Astro Content Collections by discovering from indexed content.\n * Uses content-api to find collections that have content.\n *\n * @example\n * ```typescript\n * // src/content.config.ts\n * import { createConlocaCollections } from '@conloca/astro-cms/node/content';\n *\n * export const { collections } = await createConlocaCollections();\n * ```\n */\nexport async function createConlocaCollections(\n options: CreateConlocaCollectionsOptions = {},\n): Promise<ConlocaCollectionsResult> {\n const { contentRoot = './content', site = 'default' } = options;\n\n const api = await createContentAPI({ contentRoot });\n const collections: Record<string, ReturnType<typeof defineCollection>> = {};\n\n collections[ALL_BLOCKS_COLLECTION] = defineCollection({\n loader: conlocaLoader({ contentRoot, site, kind: 'block' }),\n schema: blockMetaSchema.passthrough() as never,\n });\n\n // Add block collections\n for (const name of api.blocks.collections) {\n collections[name] = defineCollection({\n loader: conlocaLoader({ collection: name, contentRoot, site, kind: 'block' }),\n // Cast needed: Astro uses Zod v3 BaseSchema types, our schemas are Zod v4\n schema: blockMetaSchema.passthrough() as never,\n });\n }\n\n // Add data collections\n for (const name of api.data.collections) {\n collections[name] = defineCollection({\n loader: conlocaLoader({ collection: name, contentRoot, site, kind: 'data' }),\n schema: dataMetaSchema.passthrough() as never,\n });\n }\n\n // Add page collections for this site\n const siteCollections = api.getSite(site)?.collections ?? new Set<string>();\n for (const name of siteCollections) {\n collections[name] = defineCollection({\n loader: conlocaLoader({ collection: name, contentRoot, site, kind: 'page' }),\n schema: pageMetaSchema.passthrough() as never,\n });\n }\n\n return { collections };\n}\n"],"mappings":";;;;;;AAKA,MAAa,wBAAwB;;;;;;;;;;;;;AAgCrC,eAAsB,yBACpB,UAA2C,EAAE,EACV;CACnC,MAAM,EAAE,cAAc,aAAa,OAAO,cAAc;CAExD,MAAM,MAAM,MAAM,iBAAiB,EAAE,aAAa,CAAC;CACnD,MAAM,cAAmE,EAAE;AAE3E,aAAY,yBAAyB,iBAAiB;EACpD,QAAQ,cAAc;GAAE;GAAa;GAAM,MAAM;GAAS,CAAC;EAC3D,QAAQ,gBAAgB,aAAa;EACtC,CAAC;AAGF,MAAK,MAAM,QAAQ,IAAI,OAAO,YAC5B,aAAY,QAAQ,iBAAiB;EACnC,QAAQ,cAAc;GAAE,YAAY;GAAM;GAAa;GAAM,MAAM;GAAS,CAAC;EAE7E,QAAQ,gBAAgB,aAAa;EACtC,CAAC;AAIJ,MAAK,MAAM,QAAQ,IAAI,KAAK,YAC1B,aAAY,QAAQ,iBAAiB;EACnC,QAAQ,cAAc;GAAE,YAAY;GAAM;GAAa;GAAM,MAAM;GAAQ,CAAC;EAC5E,QAAQ,eAAe,aAAa;EACrC,CAAC;CAIJ,MAAM,kBAAkB,IAAI,QAAQ,KAAK,EAAE,+BAAe,IAAI,KAAa;AAC3E,MAAK,MAAM,QAAQ,gBACjB,aAAY,QAAQ,iBAAiB;EACnC,QAAQ,cAAc;GAAE,YAAY;GAAM;GAAa;GAAM,MAAM;GAAQ,CAAC;EAC5E,QAAQ,eAAe,aAAa;EACrC,CAAC;AAGJ,QAAO,EAAE,aAAa"}
@@ -1,46 +0,0 @@
1
- import { MDXBlockEvaluationResult, evaluateMDXBlocks } from "@conloca/mdx/node";
2
- import { Config, Data } from "@puckeditor/core";
3
- import * as react_jsx_runtime0 from "react/jsx-runtime";
4
- import { ComponentType } from "react";
5
-
6
- //#region src/components/RenderWithBlocks.d.ts
7
- interface MDXComponent {
8
- id: string;
9
- title: string;
10
- Component: ComponentType;
11
- }
12
- /**
13
- * Factory function to create a PageRenderer with MDX components baked in via closure.
14
- *
15
- * This approach avoids dangerouslySetInnerHTML by keeping React components as components
16
- * throughout the rendering pipeline. Components are captured in the closure and don't
17
- * need to be passed as props (which Astro can't serialize).
18
- *
19
- * @param config - The Puck configuration with component definitions
20
- * @param data - Puck page data containing component tree
21
- * @param mdxComponents - Array of evaluated MDX block results
22
- * @returns A PageRenderer component with no props needed (components in closure)
23
- */
24
- declare function createPageRendererWithBlocks(config: Config, data: Data, mdxComponents: (MDXBlockEvaluationResult | MDXComponent)[]): ComponentType;
25
- //#endregion
26
- //#region src/components/RenderWithHydration.d.ts
27
- interface RenderWithHydrationProps {
28
- config: Config;
29
- data: Data;
30
- }
31
- /**
32
- * Wrapper around Puck's Render component that adds hydration support.
33
- *
34
- * For each component with a hydration strategy configured, wraps the
35
- * component's render output with HydrationWrapper to add data-hydrate
36
- * attributes for browser-side hydration.
37
- *
38
- * Non-hydratable components render without any wrapper overhead.
39
- */
40
- declare function RenderWithHydration({
41
- config,
42
- data
43
- }: RenderWithHydrationProps): react_jsx_runtime0.JSX.Element;
44
- //#endregion
45
- export { RenderWithHydration, createPageRendererWithBlocks, evaluateMDXBlocks };
46
- //# sourceMappingURL=components.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"components.d.mts","names":[],"sources":["../src/components/RenderWithBlocks.tsx","../src/components/RenderWithHydration.tsx"],"mappings":";;;;;;UAQU,YAAA;EACR,EAAA;EACA,KAAA;EACA,SAAA,EAAW,aAAA;AAAA;;;;;;;;;AAsMb;;;;iBAAgB,4BAAA,CACd,MAAA,EAAQ,MAAA,EACR,IAAA,EAAM,IAAA,EACN,aAAA,GAAgB,wBAAA,GAA2B,YAAA,MAC1C,aAAA;;;UChNO,wBAAA;EACR,MAAA,EAAQ,MAAA;EACR,IAAA,EAAM,IAAA;AAAA;;ADHmC;;;;;;;;iBCe3B,mBAAA,CAAA;EAAsB,MAAA;EAAQ;AAAA,GAAQ,wBAAA,GAAwB,kBAAA,CAAA,GAAA,CAAA,OAAA"}
@@ -1,226 +0,0 @@
1
- import { i as isHydratable, r as hasHydratableComponents, t as serializeProps } from "./serialize-props-Dhv_MnkY.mjs";
2
- import { evaluateMDXBlocks } from "@conloca/mdx/node";
3
- import { Render } from "@puckeditor/core";
4
- import cn from "clsx";
5
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
-
7
- //#region src/components/HydrationWrapper.tsx
8
- /**
9
- * Wraps hydratable components with data attributes for browser hydration.
10
- *
11
- * When strategy is 'none', renders children directly without wrapper overhead.
12
- * Otherwise, wraps in a div with data-hydrate attributes that the browser
13
- * hydration script uses to find and hydrate components.
14
- */
15
- function HydrationWrapper({ componentName, strategy, props, children }) {
16
- if (strategy === "none") return /* @__PURE__ */ jsx(Fragment, { children });
17
- const { puck: _puck, ...hydrateProps } = props;
18
- return /* @__PURE__ */ jsx("div", {
19
- style: { display: "contents" },
20
- "data-hydrate": componentName,
21
- "data-hydrate-strategy": strategy,
22
- "data-props": serializeProps(hydrateProps),
23
- children
24
- });
25
- }
26
-
27
- //#endregion
28
- //#region src/components/RenderWithHydration.tsx
29
- /**
30
- * Wrapper around Puck's Render component that adds hydration support.
31
- *
32
- * For each component with a hydration strategy configured, wraps the
33
- * component's render output with HydrationWrapper to add data-hydrate
34
- * attributes for browser-side hydration.
35
- *
36
- * Non-hydratable components render without any wrapper overhead.
37
- */
38
- function RenderWithHydration({ config, data }) {
39
- return /* @__PURE__ */ jsx(Render, {
40
- config: {
41
- ...config,
42
- components: Object.fromEntries(Object.entries(config.components).map(([name, componentConfig]) => {
43
- const strategy = isHydratable(name, config);
44
- if (strategy === "none") return [name, componentConfig];
45
- const originalRender = componentConfig.render;
46
- return [name, {
47
- ...componentConfig,
48
- render: (props) => /* @__PURE__ */ jsx(HydrationWrapper, {
49
- componentName: name,
50
- strategy,
51
- props,
52
- children: originalRender(props)
53
- })
54
- }];
55
- }))
56
- },
57
- data
58
- });
59
- }
60
-
61
- //#endregion
62
- //#region src/components/RenderWithBlocks.tsx
63
- function isRenderableBlock(block) {
64
- return "Component" in block && !("ok" in block);
65
- }
66
- const contentBlockWidthClasses = {
67
- narrow: "max-w-3xl",
68
- default: "max-w-4xl"
69
- };
70
- const contentBlockToneClasses = {
71
- transparent: "",
72
- subtle: "rounded-3xl border border-surface-200/80 bg-surface-100/70 p-6 sm:p-8 dark:border-surface-800/60 dark:bg-surface-900/50"
73
- };
74
- function createFailedBlockComponent(block) {
75
- return function FailedBlockComponent() {
76
- return /* @__PURE__ */ jsxs("div", {
77
- className: "p-4 bg-red-50 border border-red-200 rounded text-red-600",
78
- children: [
79
- /* @__PURE__ */ jsx("p", {
80
- className: "font-semibold mb-2",
81
- children: "MDX Block Error"
82
- }),
83
- /* @__PURE__ */ jsxs("p", {
84
- className: "text-sm",
85
- children: ["Block: ", block.id]
86
- }),
87
- /* @__PURE__ */ jsx("p", {
88
- className: "text-xs mt-2",
89
- children: block.error.message
90
- })
91
- ]
92
- });
93
- };
94
- }
95
- function resolveRenderableBlocks(blocks) {
96
- return blocks.map((block) => {
97
- if (isRenderableBlock(block)) return block;
98
- if (block.ok) return block;
99
- return {
100
- id: block.id,
101
- title: block.title,
102
- Component: createFailedBlockComponent(block)
103
- };
104
- });
105
- }
106
- /**
107
- * Internal component for rendering Puck pages with MDX blocks.
108
- *
109
- * Enhances the Puck config by:
110
- * 1. Registering each MDX block as a dynamic Puck component (`Block_{id}`)
111
- * 2. Overriding ContentBlockSection's render to resolve blockId → actual MDX content
112
- *
113
- * MDX blocks are passed as React components (not HTML strings), which:
114
- * - Avoids dangerouslySetInnerHTML security risks
115
- * - More efficient (no HTML conversion round-trip)
116
- * - Type-safe with proper React component types
117
- *
118
- * @internal
119
- */
120
- function RenderWithBlocks({ config, data, mdxComponents }) {
121
- const blockComponents = {};
122
- const blockCategoryList = [];
123
- const blockComponentMap = new Map(mdxComponents.map((block) => [block.id, block]));
124
- mdxComponents.forEach((block) => {
125
- const componentKey = `Block_${block.id}`;
126
- const BlockComponent = block.Component;
127
- blockComponents[componentKey] = {
128
- label: block.title,
129
- fields: {},
130
- defaultProps: {},
131
- render: () => {
132
- return /* @__PURE__ */ jsx("div", {
133
- className: "mdx-content conloca-prose max-w-none",
134
- children: /* @__PURE__ */ jsx(BlockComponent, {})
135
- });
136
- }
137
- };
138
- blockCategoryList.push(componentKey);
139
- });
140
- const existingCategories = config.categories || {};
141
- const existingComponents = config.components || {};
142
- const contentBlockSection = existingComponents.ContentBlockSection;
143
- const enhancedContentBlockSection = contentBlockSection ? {
144
- ...contentBlockSection,
145
- render: ({ blockId, label, title, subtitle, tone = "transparent", width = "default" }) => {
146
- const SelectedBlockComponent = blockComponentMap.get(blockId)?.Component;
147
- return /* @__PURE__ */ jsx("section", {
148
- className: "pb-16 sm:pb-20",
149
- children: /* @__PURE__ */ jsxs("div", {
150
- className: cn("mx-auto px-4 sm:px-6 lg:px-8", contentBlockWidthClasses[width]),
151
- children: [
152
- label ? /* @__PURE__ */ jsx("p", {
153
- className: "mb-4 text-sm font-medium uppercase tracking-[0.18em] text-brand-700 dark:text-brand-300",
154
- children: label
155
- }) : null,
156
- title && /* @__PURE__ */ jsx("h2", {
157
- className: "text-2xl sm:text-3xl font-bold text-surface-900 dark:text-white mb-4",
158
- children: title
159
- }),
160
- subtitle && /* @__PURE__ */ jsx("p", {
161
- className: "text-surface-500 dark:text-surface-400 text-sm leading-relaxed mb-6",
162
- children: subtitle
163
- }),
164
- /* @__PURE__ */ jsx("div", {
165
- className: cn(contentBlockToneClasses[tone]),
166
- children: SelectedBlockComponent && /* @__PURE__ */ jsx("div", {
167
- className: "mdx-content conloca-prose max-w-none",
168
- children: /* @__PURE__ */ jsx(SelectedBlockComponent, {})
169
- })
170
- })
171
- ]
172
- })
173
- });
174
- }
175
- } : void 0;
176
- const mergedComponents = {
177
- ...existingComponents,
178
- ...enhancedContentBlockSection && { ContentBlockSection: enhancedContentBlockSection },
179
- ...blockComponents
180
- };
181
- const enhancedConfig = {
182
- ...config,
183
- categories: {
184
- ...existingCategories,
185
- blocks: {
186
- title: "Content Blocks",
187
- components: blockCategoryList
188
- }
189
- },
190
- components: mergedComponents
191
- };
192
- if (hasHydratableComponents(data, enhancedConfig)) return /* @__PURE__ */ jsx(RenderWithHydration, {
193
- config: enhancedConfig,
194
- data
195
- });
196
- return /* @__PURE__ */ jsx(Render, {
197
- config: enhancedConfig,
198
- data
199
- });
200
- }
201
- /**
202
- * Factory function to create a PageRenderer with MDX components baked in via closure.
203
- *
204
- * This approach avoids dangerouslySetInnerHTML by keeping React components as components
205
- * throughout the rendering pipeline. Components are captured in the closure and don't
206
- * need to be passed as props (which Astro can't serialize).
207
- *
208
- * @param config - The Puck configuration with component definitions
209
- * @param data - Puck page data containing component tree
210
- * @param mdxComponents - Array of evaluated MDX block results
211
- * @returns A PageRenderer component with no props needed (components in closure)
212
- */
213
- function createPageRendererWithBlocks(config, data, mdxComponents) {
214
- const renderableBlocks = resolveRenderableBlocks(mdxComponents);
215
- return function PageRendererWithBlocks() {
216
- return /* @__PURE__ */ jsx(RenderWithBlocks, {
217
- config,
218
- data,
219
- mdxComponents: renderableBlocks
220
- });
221
- };
222
- }
223
-
224
- //#endregion
225
- export { RenderWithHydration, createPageRendererWithBlocks, evaluateMDXBlocks };
226
- //# sourceMappingURL=components.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"components.mjs","names":[],"sources":["../src/components/HydrationWrapper.tsx","../src/components/RenderWithHydration.tsx","../src/components/RenderWithBlocks.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { serializeProps } from '../lib/serialize-props.js';\nimport type { HydrationStrategy } from '../types.js';\n\ninterface HydrationWrapperProps {\n componentName: string;\n strategy: HydrationStrategy;\n props: Record<string, unknown>;\n children: ReactNode;\n}\n\n/**\n * Wraps hydratable components with data attributes for browser hydration.\n *\n * When strategy is 'none', renders children directly without wrapper overhead.\n * Otherwise, wraps in a div with data-hydrate attributes that the browser\n * hydration script uses to find and hydrate components.\n */\nexport function HydrationWrapper({ componentName, strategy, props, children }: HydrationWrapperProps) {\n // No hydration needed - render children directly without wrapper\n if (strategy === 'none') {\n return <>{children}</>;\n }\n\n // Strip Puck-internal props that aren't needed for hydration.\n // `puck` contains functions (renderDropZone) that can't survive JSON serialization\n // and would crash on hydration if a component called them.\n const { puck: _puck, ...hydrateProps } = props as Record<string, unknown> & { puck?: unknown };\n\n // Wrap with hydration markers for the browser script to find\n return (\n <div\n style={{ display: 'contents' }}\n data-hydrate={componentName}\n data-hydrate-strategy={strategy}\n data-props={serializeProps(hydrateProps)}\n >\n {children}\n </div>\n );\n}\n","import type { Config, Data } from '@puckeditor/core';\nimport { Render } from '@puckeditor/core';\nimport { isHydratable } from '../lib/hydration-utils.js';\nimport { HydrationWrapper } from './HydrationWrapper.js';\n\ninterface RenderWithHydrationProps {\n config: Config;\n data: Data;\n}\n\n/**\n * Wrapper around Puck's Render component that adds hydration support.\n *\n * For each component with a hydration strategy configured, wraps the\n * component's render output with HydrationWrapper to add data-hydrate\n * attributes for browser-side hydration.\n *\n * Non-hydratable components render without any wrapper overhead.\n */\nexport function RenderWithHydration({ config, data }: RenderWithHydrationProps) {\n // Create wrapped config with hydration-aware render functions\n const wrappedConfig: Config = {\n ...config,\n components: Object.fromEntries(\n Object.entries(config.components).map(([name, componentConfig]) => {\n const strategy = isHydratable(name, config);\n\n if (strategy === 'none') {\n // No wrapping needed - component stays static\n return [name, componentConfig];\n }\n\n // Wrap the render function so its output becomes HydrationWrapper children\n const originalRender = componentConfig.render;\n return [\n name,\n {\n ...componentConfig,\n render: (props) => (\n <HydrationWrapper componentName={name} strategy={strategy} props={props}>\n {originalRender(props)}\n </HydrationWrapper>\n ),\n },\n ];\n }),\n ),\n };\n\n return <Render config={wrappedConfig} data={data} />;\n}\n","import type { MDXBlockEvaluationResult } from '@conloca/mdx/node';\nimport type { ComponentConfig, Config, Data } from '@puckeditor/core';\nimport { Render } from '@puckeditor/core';\nimport cn from 'clsx';\nimport type { ComponentType } from 'react';\nimport { hasHydratableComponents } from '../lib/hydration-utils.js';\nimport { RenderWithHydration } from './RenderWithHydration.js';\n\ninterface MDXComponent {\n id: string;\n title: string;\n Component: ComponentType;\n}\n\nfunction isRenderableBlock(block: MDXBlockEvaluationResult | MDXComponent): block is MDXComponent {\n return 'Component' in block && !('ok' in block);\n}\n\ninterface RenderWithBlocksProps {\n config: Config;\n data: Data;\n mdxComponents: MDXComponent[];\n}\n\ninterface ContentBlockSectionProps {\n title?: string;\n subtitle?: string;\n label?: string;\n blockId: string;\n width?: 'narrow' | 'default';\n tone?: 'transparent' | 'subtle';\n}\n\nconst contentBlockWidthClasses: Record<NonNullable<ContentBlockSectionProps['width']>, string> = {\n narrow: 'max-w-3xl',\n default: 'max-w-4xl',\n};\n\nconst contentBlockToneClasses: Record<NonNullable<ContentBlockSectionProps['tone']>, string> = {\n transparent: '',\n subtle:\n 'rounded-3xl border border-surface-200/80 bg-surface-100/70 p-6 sm:p-8 dark:border-surface-800/60 dark:bg-surface-900/50',\n};\n\nfunction createFailedBlockComponent(block: Extract<MDXBlockEvaluationResult, { ok: false }>): ComponentType {\n return function FailedBlockComponent() {\n return (\n <div className=\"p-4 bg-red-50 border border-red-200 rounded text-red-600\">\n <p className=\"font-semibold mb-2\">MDX Block Error</p>\n <p className=\"text-sm\">Block: {block.id}</p>\n <p className=\"text-xs mt-2\">{block.error.message}</p>\n </div>\n );\n };\n}\n\nfunction resolveRenderableBlocks(blocks: (MDXBlockEvaluationResult | MDXComponent)[]): MDXComponent[] {\n return blocks.map((block) => {\n if (isRenderableBlock(block)) {\n return block;\n }\n\n if (block.ok) {\n return block;\n }\n\n return {\n id: block.id,\n title: block.title,\n Component: createFailedBlockComponent(block),\n };\n });\n}\n\n// ── Main Component ──────────────────────────────────────────────────────────\n\n/**\n * Internal component for rendering Puck pages with MDX blocks.\n *\n * Enhances the Puck config by:\n * 1. Registering each MDX block as a dynamic Puck component (`Block_{id}`)\n * 2. Overriding ContentBlockSection's render to resolve blockId → actual MDX content\n *\n * MDX blocks are passed as React components (not HTML strings), which:\n * - Avoids dangerouslySetInnerHTML security risks\n * - More efficient (no HTML conversion round-trip)\n * - Type-safe with proper React component types\n *\n * @internal\n */\nfunction RenderWithBlocks({ config, data, mdxComponents }: RenderWithBlocksProps) {\n // Build enhanced config with MDX blocks\n const blockComponents: Record<string, ComponentConfig> = {};\n const blockCategoryList: string[] = [];\n const blockComponentMap = new Map(mdxComponents.map((block) => [block.id, block]));\n\n // Create component configs for each block\n mdxComponents.forEach((block) => {\n const componentKey = `Block_${block.id}`;\n\n // Capture component in closure - Puck doesn't persist defaultProps reliably\n const BlockComponent = block.Component;\n\n blockComponents[componentKey] = {\n label: block.title,\n fields: {},\n defaultProps: {},\n render: () => {\n // Use blockId and BlockComponent from closure - no prop dependency\n return (\n <div className=\"mdx-content conloca-prose max-w-none\">\n <BlockComponent />\n </div>\n );\n },\n };\n blockCategoryList.push(componentKey);\n });\n\n // Merge with existing config\n const existingCategories = config.categories || {};\n const existingComponents = config.components || {};\n const contentBlockSection = existingComponents.ContentBlockSection as\n | ComponentConfig<ContentBlockSectionProps>\n | undefined;\n\n const enhancedContentBlockSection = contentBlockSection\n ? {\n ...contentBlockSection,\n render: ({\n blockId,\n label,\n title,\n subtitle,\n tone = 'transparent',\n width = 'default',\n }: ContentBlockSectionProps) => {\n const selectedBlock = blockComponentMap.get(blockId);\n const SelectedBlockComponent = selectedBlock?.Component;\n\n return (\n <section className=\"pb-16 sm:pb-20\">\n <div className={cn('mx-auto px-4 sm:px-6 lg:px-8', contentBlockWidthClasses[width])}>\n {label ? (\n <p className=\"mb-4 text-sm font-medium uppercase tracking-[0.18em] text-brand-700 dark:text-brand-300\">\n {label}\n </p>\n ) : null}\n {title && (\n <h2 className=\"text-2xl sm:text-3xl font-bold text-surface-900 dark:text-white mb-4\">{title}</h2>\n )}\n {subtitle && (\n <p className=\"text-surface-500 dark:text-surface-400 text-sm leading-relaxed mb-6\">{subtitle}</p>\n )}\n <div className={cn(contentBlockToneClasses[tone])}>\n {SelectedBlockComponent && (\n <div className=\"mdx-content conloca-prose max-w-none\">\n <SelectedBlockComponent />\n </div>\n )}\n </div>\n </div>\n </section>\n );\n },\n }\n : undefined;\n\n // Merge block components with existing config components\n const mergedComponents = {\n ...existingComponents,\n ...(enhancedContentBlockSection && { ContentBlockSection: enhancedContentBlockSection }),\n ...blockComponents,\n } as Config['components'];\n\n const enhancedConfig: Config = {\n ...config,\n categories: {\n ...existingCategories,\n blocks: {\n title: 'Content Blocks',\n components: blockCategoryList,\n },\n },\n components: mergedComponents,\n };\n\n // Check if page has hydratable components\n const needsHydration = hasHydratableComponents(data, enhancedConfig);\n\n if (needsHydration) {\n return <RenderWithHydration config={enhancedConfig} data={data} />;\n }\n\n return <Render config={enhancedConfig} data={data} />;\n}\n\n/**\n * Factory function to create a PageRenderer with MDX components baked in via closure.\n *\n * This approach avoids dangerouslySetInnerHTML by keeping React components as components\n * throughout the rendering pipeline. Components are captured in the closure and don't\n * need to be passed as props (which Astro can't serialize).\n *\n * @param config - The Puck configuration with component definitions\n * @param data - Puck page data containing component tree\n * @param mdxComponents - Array of evaluated MDX block results\n * @returns A PageRenderer component with no props needed (components in closure)\n */\nexport function createPageRendererWithBlocks(\n config: Config,\n data: Data,\n mdxComponents: (MDXBlockEvaluationResult | MDXComponent)[],\n): ComponentType {\n const renderableBlocks = resolveRenderableBlocks(mdxComponents);\n\n // Capture components in closure - no need to pass as props\n return function PageRendererWithBlocks() {\n return <RenderWithBlocks config={config} data={data} mdxComponents={renderableBlocks} />;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AAkBA,SAAgB,iBAAiB,EAAE,eAAe,UAAU,OAAO,YAAmC;AAEpG,KAAI,aAAa,OACf,QAAO,gCAAG,WAAY;CAMxB,MAAM,EAAE,MAAM,OAAO,GAAG,iBAAiB;AAGzC,QACE,oBAAC;EACC,OAAO,EAAE,SAAS,YAAY;EAC9B,gBAAc;EACd,yBAAuB;EACvB,cAAY,eAAe,aAAa;EAEvC;GACG;;;;;;;;;;;;;;ACnBV,SAAgB,oBAAoB,EAAE,QAAQ,QAAkC;AA8B9E,QAAO,oBAAC;EAAO,QA5Be;GAC5B,GAAG;GACH,YAAY,OAAO,YACjB,OAAO,QAAQ,OAAO,WAAW,CAAC,KAAK,CAAC,MAAM,qBAAqB;IACjE,MAAM,WAAW,aAAa,MAAM,OAAO;AAE3C,QAAI,aAAa,OAEf,QAAO,CAAC,MAAM,gBAAgB;IAIhC,MAAM,iBAAiB,gBAAgB;AACvC,WAAO,CACL,MACA;KACE,GAAG;KACH,SAAS,UACP,oBAAC;MAAiB,eAAe;MAAgB;MAAiB;gBAC/D,eAAe,MAAM;OACL;KAEtB,CACF;KACD,CACH;GACF;EAE2C;GAAQ;;;;;ACnCtD,SAAS,kBAAkB,OAAuE;AAChG,QAAO,eAAe,SAAS,EAAE,QAAQ;;AAkB3C,MAAM,2BAA2F;CAC/F,QAAQ;CACR,SAAS;CACV;AAED,MAAM,0BAAyF;CAC7F,aAAa;CACb,QACE;CACH;AAED,SAAS,2BAA2B,OAAwE;AAC1G,QAAO,SAAS,uBAAuB;AACrC,SACE,qBAAC;GAAI,WAAU;;IACb,oBAAC;KAAE,WAAU;eAAqB;MAAmB;IACrD,qBAAC;KAAE,WAAU;gBAAU,WAAQ,MAAM;MAAO;IAC5C,oBAAC;KAAE,WAAU;eAAgB,MAAM,MAAM;MAAY;;IACjD;;;AAKZ,SAAS,wBAAwB,QAAqE;AACpG,QAAO,OAAO,KAAK,UAAU;AAC3B,MAAI,kBAAkB,MAAM,CAC1B,QAAO;AAGT,MAAI,MAAM,GACR,QAAO;AAGT,SAAO;GACL,IAAI,MAAM;GACV,OAAO,MAAM;GACb,WAAW,2BAA2B,MAAM;GAC7C;GACD;;;;;;;;;;;;;;;;AAmBJ,SAAS,iBAAiB,EAAE,QAAQ,MAAM,iBAAwC;CAEhF,MAAM,kBAAmD,EAAE;CAC3D,MAAM,oBAA8B,EAAE;CACtC,MAAM,oBAAoB,IAAI,IAAI,cAAc,KAAK,UAAU,CAAC,MAAM,IAAI,MAAM,CAAC,CAAC;AAGlF,eAAc,SAAS,UAAU;EAC/B,MAAM,eAAe,SAAS,MAAM;EAGpC,MAAM,iBAAiB,MAAM;AAE7B,kBAAgB,gBAAgB;GAC9B,OAAO,MAAM;GACb,QAAQ,EAAE;GACV,cAAc,EAAE;GAChB,cAAc;AAEZ,WACE,oBAAC;KAAI,WAAU;eACb,oBAAC,mBAAiB;MACd;;GAGX;AACD,oBAAkB,KAAK,aAAa;GACpC;CAGF,MAAM,qBAAqB,OAAO,cAAc,EAAE;CAClD,MAAM,qBAAqB,OAAO,cAAc,EAAE;CAClD,MAAM,sBAAsB,mBAAmB;CAI/C,MAAM,8BAA8B,sBAChC;EACE,GAAG;EACH,SAAS,EACP,SACA,OACA,OACA,UACA,OAAO,eACP,QAAQ,gBACsB;GAE9B,MAAM,yBADgB,kBAAkB,IAAI,QAAQ,EACN;AAE9C,UACE,oBAAC;IAAQ,WAAU;cACjB,qBAAC;KAAI,WAAW,GAAG,gCAAgC,yBAAyB,OAAO;;MAChF,QACC,oBAAC;OAAE,WAAU;iBACV;QACC,GACF;MACH,SACC,oBAAC;OAAG,WAAU;iBAAwE;QAAW;MAElG,YACC,oBAAC;OAAE,WAAU;iBAAuE;QAAa;MAEnG,oBAAC;OAAI,WAAW,GAAG,wBAAwB,MAAM;iBAC9C,0BACC,oBAAC;QAAI,WAAU;kBACb,oBAAC,2BAAyB;SACtB;QAEJ;;MACF;KACE;;EAGf,GACD;CAGJ,MAAM,mBAAmB;EACvB,GAAG;EACH,GAAI,+BAA+B,EAAE,qBAAqB,6BAA6B;EACvF,GAAG;EACJ;CAED,MAAM,iBAAyB;EAC7B,GAAG;EACH,YAAY;GACV,GAAG;GACH,QAAQ;IACN,OAAO;IACP,YAAY;IACb;GACF;EACD,YAAY;EACb;AAKD,KAFuB,wBAAwB,MAAM,eAAe,CAGlE,QAAO,oBAAC;EAAoB,QAAQ;EAAsB;GAAQ;AAGpE,QAAO,oBAAC;EAAO,QAAQ;EAAsB;GAAQ;;;;;;;;;;;;;;AAevD,SAAgB,6BACd,QACA,MACA,eACe;CACf,MAAM,mBAAmB,wBAAwB,cAAc;AAG/D,QAAO,SAAS,yBAAyB;AACvC,SAAO,oBAAC;GAAyB;GAAc;GAAM,eAAe;IAAoB"}
@@ -1,109 +0,0 @@
1
- import { readFile } from "node:fs/promises";
2
- import { basename, dirname, extname, join, resolve } from "node:path";
3
- import fg from "fast-glob";
4
-
5
- //#region src/lib/hydration-scanner.ts
6
- const HYDRATION_IMPORT_PATTERN = /import\s+\{[^}]*withHydration[^}]*\}\s+from\s+['"]@conloca\/astro-cms(?:\/hydration)?['"]/;
7
- const HYDRATION_PATTERN = /withHydration\s*\(\s*\w+\s*,\s*['"](\w+)['"]\s*\)/g;
8
- const VALID_STRATEGIES = new Set([
9
- "load",
10
- "visible",
11
- "idle"
12
- ]);
13
- /**
14
- * Derives component scan paths from puckConfigPath.
15
- *
16
- * Convention: puckConfigPath directory + '/components/puck'
17
- * Example: './src/puck.config.tsx' -> './src/components/puck'
18
- *
19
- * If explicitPaths provided, they extend (not replace) the auto-discovered path.
20
- *
21
- * @param puckConfigPath - Path to the puck config (e.g., './src/puck.config.tsx')
22
- * @param explicitPaths - Optional additional paths to scan
23
- * @returns Array of paths to scan for hydratable components
24
- */
25
- function deriveComponentPaths(puckConfigPath, explicitPaths) {
26
- const defaultScanPath = join(dirname(puckConfigPath), "components", "puck");
27
- if (explicitPaths && explicitPaths.length > 0) return [defaultScanPath, ...explicitPaths];
28
- return [defaultScanPath];
29
- }
30
- /**
31
- * Derives a PascalCase component name from a file path.
32
- *
33
- * @param filePath - Absolute path to the component file
34
- * @returns Component name in PascalCase
35
- *
36
- * @example
37
- * deriveComponentName('/src/components/puck/TestimonialGrid.tsx')
38
- * // => 'TestimonialGrid'
39
- *
40
- * deriveComponentName('/src/components/puck/blog-post-grid.tsx')
41
- * // => 'BlogPostGrid'
42
- */
43
- function deriveComponentName(filePath) {
44
- const filename = basename(filePath, extname(filePath));
45
- if (filename.includes("-")) return filename.split("-").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
46
- return filename.charAt(0).toUpperCase() + filename.slice(1);
47
- }
48
- /**
49
- * Scans component directories for files using withHydration wrapper.
50
- *
51
- * This function performs static analysis to discover components marked
52
- * for hydration, without executing any component code.
53
- *
54
- * @param componentPaths - Relative paths to scan (e.g., ['src/components/puck'])
55
- * @param projectRoot - Absolute path to the project root
56
- * @returns Array of discovered hydratable components with their strategies
57
- *
58
- * @example
59
- * ```typescript
60
- * const discoveries = await scanForHydratableComponents(
61
- * ['src/components/puck'],
62
- * '/path/to/project'
63
- * )
64
- * // => [{ componentName: 'TestimonialGrid', filePath: '...', strategy: 'visible' }]
65
- * ```
66
- */
67
- async function scanForHydratableComponents(componentPaths, projectRoot) {
68
- const discoveries = [];
69
- const seenNames = /* @__PURE__ */ new Map();
70
- for (const scanPath of componentPaths) {
71
- const files = await fg("**/*.tsx", {
72
- cwd: resolve(projectRoot, scanPath),
73
- absolute: true,
74
- onlyFiles: true
75
- });
76
- for (const filePath of files) try {
77
- const content = await readFile(filePath, "utf-8");
78
- if (!HYDRATION_IMPORT_PATTERN.test(content)) continue;
79
- const matches = [...content.matchAll(HYDRATION_PATTERN)];
80
- if (matches.length === 0) continue;
81
- if (matches.length > 1) console.warn(`[Conloca Hydration] Multiple withHydration calls in ${filePath}. Consider splitting into separate component files. Using first call.`);
82
- const rawStrategy = matches[0][1];
83
- if (!VALID_STRATEGIES.has(rawStrategy)) {
84
- console.warn(`[Conloca Hydration] Invalid strategy '${rawStrategy}' in ${filePath}. Valid options: ${[...VALID_STRATEGIES].join(", ")}. Skipping component.`);
85
- continue;
86
- }
87
- const strategy = rawStrategy;
88
- const componentName = deriveComponentName(filePath);
89
- const existingPath = seenNames.get(componentName);
90
- if (existingPath) {
91
- console.warn(`[Conloca Hydration] Duplicate component name '${componentName}'. Found in: ${existingPath} and ${filePath}. Using first occurrence.`);
92
- continue;
93
- }
94
- seenNames.set(componentName, filePath);
95
- discoveries.push({
96
- componentName,
97
- filePath,
98
- strategy
99
- });
100
- } catch (err) {
101
- console.warn(`[Conloca Hydration] Error reading ${filePath}:`, err);
102
- }
103
- }
104
- return discoveries;
105
- }
106
-
107
- //#endregion
108
- export { scanForHydratableComponents as n, deriveComponentPaths as t };
109
- //# sourceMappingURL=hydration-scanner-B0NjYkZ_.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hydration-scanner-B0NjYkZ_.mjs","names":[],"sources":["../src/lib/hydration-scanner.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { basename, dirname, extname, join, resolve } from 'node:path';\nimport fg from 'fast-glob';\n\n/**\n * Result of scanning a component file for withHydration usage.\n */\nexport interface HydrationDiscovery {\n /** Component name derived from filename (PascalCase) */\n componentName: string;\n /** Absolute path to the component file */\n filePath: string;\n /** Hydration strategy extracted from withHydration call */\n strategy: 'load' | 'visible' | 'idle';\n}\n\n// Regex to check if file imports withHydration from @conloca/astro-cms or @conloca/astro-cms/hydration\n// This is faster than es-module-lexer for JSX files and avoids parse errors\nexport const HYDRATION_IMPORT_PATTERN =\n /import\\s+\\{[^}]*withHydration[^}]*\\}\\s+from\\s+['\"]@conloca\\/astro-cms(?:\\/hydration)?['\"]/;\n\n// Regex to find withHydration calls and extract strategy\n// Matches: withHydration(ComponentName, 'strategy') or withHydration(ComponentName, \"strategy\")\nexport const HYDRATION_PATTERN = /withHydration\\s*\\(\\s*\\w+\\s*,\\s*['\"](\\w+)['\"]\\s*\\)/g;\n\n// Valid hydration strategies\nconst VALID_STRATEGIES = new Set(['load', 'visible', 'idle']);\n\n/**\n * Derives component scan paths from puckConfigPath.\n *\n * Convention: puckConfigPath directory + '/components/puck'\n * Example: './src/puck.config.tsx' -> './src/components/puck'\n *\n * If explicitPaths provided, they extend (not replace) the auto-discovered path.\n *\n * @param puckConfigPath - Path to the puck config (e.g., './src/puck.config.tsx')\n * @param explicitPaths - Optional additional paths to scan\n * @returns Array of paths to scan for hydratable components\n */\nexport function deriveComponentPaths(puckConfigPath: string, explicitPaths?: string[]): string[] {\n const puckDir = dirname(puckConfigPath);\n const defaultScanPath = join(puckDir, 'components', 'puck');\n\n if (explicitPaths && explicitPaths.length > 0) {\n return [defaultScanPath, ...explicitPaths];\n }\n return [defaultScanPath];\n}\n\n/**\n * Derives a PascalCase component name from a file path.\n *\n * @param filePath - Absolute path to the component file\n * @returns Component name in PascalCase\n *\n * @example\n * deriveComponentName('/src/components/puck/TestimonialGrid.tsx')\n * // => 'TestimonialGrid'\n *\n * deriveComponentName('/src/components/puck/blog-post-grid.tsx')\n * // => 'BlogPostGrid'\n */\nfunction deriveComponentName(filePath: string): string {\n const filename = basename(filePath, extname(filePath));\n // Convert kebab-case to PascalCase if needed\n if (filename.includes('-')) {\n return filename\n .split('-')\n .map((part) => part.charAt(0).toUpperCase() + part.slice(1))\n .join('');\n }\n // Ensure first letter is uppercase\n return filename.charAt(0).toUpperCase() + filename.slice(1);\n}\n\n/**\n * Scans component directories for files using withHydration wrapper.\n *\n * This function performs static analysis to discover components marked\n * for hydration, without executing any component code.\n *\n * @param componentPaths - Relative paths to scan (e.g., ['src/components/puck'])\n * @param projectRoot - Absolute path to the project root\n * @returns Array of discovered hydratable components with their strategies\n *\n * @example\n * ```typescript\n * const discoveries = await scanForHydratableComponents(\n * ['src/components/puck'],\n * '/path/to/project'\n * )\n * // => [{ componentName: 'TestimonialGrid', filePath: '...', strategy: 'visible' }]\n * ```\n */\nexport async function scanForHydratableComponents(\n componentPaths: string[],\n projectRoot: string,\n): Promise<HydrationDiscovery[]> {\n const discoveries: HydrationDiscovery[] = [];\n const seenNames = new Map<string, string>(); // componentName -> first filePath\n\n for (const scanPath of componentPaths) {\n const absolutePath = resolve(projectRoot, scanPath);\n\n // Find all .tsx files in the directory and subdirectories\n const files = await fg('**/*.tsx', {\n cwd: absolutePath,\n absolute: true,\n onlyFiles: true,\n });\n\n for (const filePath of files) {\n try {\n const content = await readFile(filePath, 'utf-8');\n\n // Fast path: check if file imports withHydration from @conloca/astro-cms\n // Using simple regex instead of es-module-lexer to avoid JSX parse errors\n if (!HYDRATION_IMPORT_PATTERN.test(content)) {\n continue;\n }\n\n // Find withHydration calls with regex\n const matches = [...content.matchAll(HYDRATION_PATTERN)];\n\n if (matches.length === 0) {\n continue;\n }\n\n if (matches.length > 1) {\n console.warn(\n `[Conloca Hydration] Multiple withHydration calls in ${filePath}. ` +\n 'Consider splitting into separate component files. Using first call.',\n );\n }\n\n const match = matches[0];\n const rawStrategy = match[1];\n\n // Validate strategy\n if (!VALID_STRATEGIES.has(rawStrategy)) {\n console.warn(\n `[Conloca Hydration] Invalid strategy '${rawStrategy}' in ${filePath}. ` +\n `Valid options: ${[...VALID_STRATEGIES].join(', ')}. Skipping component.`,\n );\n continue;\n }\n\n const strategy = rawStrategy as 'load' | 'visible' | 'idle';\n const componentName = deriveComponentName(filePath);\n\n // Check for naming conflicts\n const existingPath = seenNames.get(componentName);\n if (existingPath) {\n console.warn(\n `[Conloca Hydration] Duplicate component name '${componentName}'. ` +\n `Found in: ${existingPath} and ${filePath}. Using first occurrence.`,\n );\n continue;\n }\n\n seenNames.set(componentName, filePath);\n discoveries.push({\n componentName,\n filePath,\n strategy,\n });\n } catch (err) {\n // Log error but continue scanning other files\n console.warn(`[Conloca Hydration] Error reading ${filePath}:`, err);\n }\n }\n }\n\n return discoveries;\n}\n"],"mappings":";;;;;AAkBA,MAAa,2BACX;AAIF,MAAa,oBAAoB;AAGjC,MAAM,mBAAmB,IAAI,IAAI;CAAC;CAAQ;CAAW;CAAO,CAAC;;;;;;;;;;;;;AAc7D,SAAgB,qBAAqB,gBAAwB,eAAoC;CAE/F,MAAM,kBAAkB,KADR,QAAQ,eAAe,EACD,cAAc,OAAO;AAE3D,KAAI,iBAAiB,cAAc,SAAS,EAC1C,QAAO,CAAC,iBAAiB,GAAG,cAAc;AAE5C,QAAO,CAAC,gBAAgB;;;;;;;;;;;;;;;AAgB1B,SAAS,oBAAoB,UAA0B;CACrD,MAAM,WAAW,SAAS,UAAU,QAAQ,SAAS,CAAC;AAEtD,KAAI,SAAS,SAAS,IAAI,CACxB,QAAO,SACJ,MAAM,IAAI,CACV,KAAK,SAAS,KAAK,OAAO,EAAE,CAAC,aAAa,GAAG,KAAK,MAAM,EAAE,CAAC,CAC3D,KAAK,GAAG;AAGb,QAAO,SAAS,OAAO,EAAE,CAAC,aAAa,GAAG,SAAS,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;AAsB7D,eAAsB,4BACpB,gBACA,aAC+B;CAC/B,MAAM,cAAoC,EAAE;CAC5C,MAAM,4BAAY,IAAI,KAAqB;AAE3C,MAAK,MAAM,YAAY,gBAAgB;EAIrC,MAAM,QAAQ,MAAM,GAAG,YAAY;GACjC,KAJmB,QAAQ,aAAa,SAAS;GAKjD,UAAU;GACV,WAAW;GACZ,CAAC;AAEF,OAAK,MAAM,YAAY,MACrB,KAAI;GACF,MAAM,UAAU,MAAM,SAAS,UAAU,QAAQ;AAIjD,OAAI,CAAC,yBAAyB,KAAK,QAAQ,CACzC;GAIF,MAAM,UAAU,CAAC,GAAG,QAAQ,SAAS,kBAAkB,CAAC;AAExD,OAAI,QAAQ,WAAW,EACrB;AAGF,OAAI,QAAQ,SAAS,EACnB,SAAQ,KACN,uDAAuD,SAAS,uEAEjE;GAIH,MAAM,cADQ,QAAQ,GACI;AAG1B,OAAI,CAAC,iBAAiB,IAAI,YAAY,EAAE;AACtC,YAAQ,KACN,yCAAyC,YAAY,OAAO,SAAS,mBACjD,CAAC,GAAG,iBAAiB,CAAC,KAAK,KAAK,CAAC,uBACtD;AACD;;GAGF,MAAM,WAAW;GACjB,MAAM,gBAAgB,oBAAoB,SAAS;GAGnD,MAAM,eAAe,UAAU,IAAI,cAAc;AACjD,OAAI,cAAc;AAChB,YAAQ,KACN,iDAAiD,cAAc,eAChD,aAAa,OAAO,SAAS,2BAC7C;AACD;;AAGF,aAAU,IAAI,eAAe,SAAS;AACtC,eAAY,KAAK;IACf;IACA;IACA;IACD,CAAC;WACK,KAAK;AAEZ,WAAQ,KAAK,qCAAqC,SAAS,IAAI,IAAI;;;AAKzE,QAAO"}
@@ -1,4 +0,0 @@
1
- import { t as HydrationStrategy } from "./types-CVQNmPxF.mjs";
2
- import { n as WithHydrationStrategy, r as withHydration, t as HydrationMeta } from "./withHydration-HIvO9ysY.mjs";
3
- import { ComponentRegistry } from "./lib/hydration-script.mjs";
4
- export { type ComponentRegistry, type HydrationMeta, type HydrationStrategy, type WithHydrationStrategy, withHydration };
@@ -1,3 +0,0 @@
1
- import { t as withHydration } from "./withHydration-EzyzBQ-Y.mjs";
2
-
3
- export { withHydration };
package/dist/index.d.mts DELETED
@@ -1,139 +0,0 @@
1
- import { r as TemplateConfig, t as HydrationStrategy } from "./types-CVQNmPxF.mjs";
2
- import { n as WithHydrationStrategy, r as withHydration, t as HydrationMeta } from "./withHydration-HIvO9ysY.mjs";
3
- import { ComponentRegistry } from "./lib/hydration-script.mjs";
4
- import { BlockMeta, PageMeta, blockMetaSchema, pageMetaSchema } from "@conloca/content-api/schemas";
5
- import { Config, Data } from "@puckeditor/core";
6
-
7
- //#region src/lib/hydration-scanner.d.ts
8
- /**
9
- * Result of scanning a component file for withHydration usage.
10
- */
11
- interface HydrationDiscovery {
12
- /** Component name derived from filename (PascalCase) */
13
- componentName: string;
14
- /** Absolute path to the component file */
15
- filePath: string;
16
- /** Hydration strategy extracted from withHydration call */
17
- strategy: 'load' | 'visible' | 'idle';
18
- }
19
- /**
20
- * Scans component directories for files using withHydration wrapper.
21
- *
22
- * This function performs static analysis to discover components marked
23
- * for hydration, without executing any component code.
24
- *
25
- * @param componentPaths - Relative paths to scan (e.g., ['src/components/puck'])
26
- * @param projectRoot - Absolute path to the project root
27
- * @returns Array of discovered hydratable components with their strategies
28
- *
29
- * @example
30
- * ```typescript
31
- * const discoveries = await scanForHydratableComponents(
32
- * ['src/components/puck'],
33
- * '/path/to/project'
34
- * )
35
- * // => [{ componentName: 'TestimonialGrid', filePath: '...', strategy: 'visible' }]
36
- * ```
37
- */
38
- declare function scanForHydratableComponents(componentPaths: string[], projectRoot: string): Promise<HydrationDiscovery[]>;
39
- //#endregion
40
- //#region src/lib/hydration-utils.d.ts
41
- /**
42
- * Extended ComponentConfig with hydration support.
43
- * @deprecated Use withHydration() wrapper instead of hydration property.
44
- */
45
- interface HydratableComponentConfig {
46
- /** @deprecated Use withHydration() wrapper on render function instead */
47
- hydration?: HydrationStrategy;
48
- render?: (props: unknown) => unknown;
49
- }
50
- /**
51
- * Component instance requiring hydration.
52
- * Contains the component name, props, and hydration strategy.
53
- */
54
- interface HydratableComponent {
55
- /** Component type name from Puck config */
56
- type: string;
57
- /** Props to pass to the component */
58
- props: Record<string, unknown>;
59
- /** Hydration strategy from ComponentConfig */
60
- strategy: Exclude<HydrationStrategy, 'none'>;
61
- /** Unique ID from Puck data (for keying) */
62
- id: string;
63
- }
64
- /**
65
- * Check if a component type has hydration enabled.
66
- *
67
- * First checks for __hydration metadata on the render function (new withHydration API),
68
- * then falls back to hydration property on ComponentConfig (deprecated).
69
- *
70
- * @param componentType - The component type name from Puck data
71
- * @param config - The Puck config with component definitions
72
- * @returns The hydration strategy ('none', 'load', 'visible', 'idle')
73
- */
74
- declare function isHydratable(componentType: string, config: Config): HydrationStrategy;
75
- /**
76
- * Find all components in a Puck data tree that require hydration.
77
- * Walks the content array and zones recursively.
78
- *
79
- * @param data - Puck data object containing content tree
80
- * @param config - Puck config with component definitions
81
- * @returns Array of components that need hydration
82
- */
83
- declare function findHydratableComponents(data: Data, config: Config): HydratableComponent[];
84
- /**
85
- * Check if Puck data contains any hydratable components.
86
- * Quick check before more expensive operations.
87
- */
88
- declare function hasHydratableComponents(data: Data, config: Config): boolean;
89
- //#endregion
90
- //#region src/lib/route-utils.d.ts
91
- declare function toDate(value: string | Date | null | undefined): Date | undefined;
92
- interface PublishSchedule {
93
- publishAt?: string | Date | null;
94
- unpublishAt?: string | Date | null;
95
- }
96
- declare function isPublished(data: PublishSchedule): boolean;
97
- /**
98
- * Extract slug from pathname given a route pattern.
99
- *
100
- * The slug is the portion of the pathname that comes after the
101
- * static prefix of the pattern.
102
- *
103
- * @param pathname - URL pathname (e.g., '/about', '/blog/post-1')
104
- * @param pattern - Route pattern (e.g., '/[...slug]', '/blog/[...slug]')
105
- * @returns The extracted slug, or undefined for root paths
106
- *
107
- * @example
108
- * extractSlugFromPathname('/about', '/[...slug]') // 'about'
109
- * extractSlugFromPathname('/blog/post-1', '/blog/[...slug]') // 'post-1'
110
- * extractSlugFromPathname('/', '/[...slug]') // undefined
111
- * extractSlugFromPathname('/blog', '/blog/[...slug]') // undefined
112
- */
113
- declare function extractSlugFromPathname(pathname: string, pattern: string): string | undefined;
114
- /**
115
- * Convert a slug back to a pathname given a route pattern.
116
- *
117
- * The inverse of extractSlugFromPathname.
118
- *
119
- * @param slug - The page slug (e.g., 'about', 'post-1'), or undefined for root
120
- * @param pattern - Route pattern (e.g., '/[...slug]', '/blog/[...slug]')
121
- * @returns Full URL pathname
122
- *
123
- * @example
124
- * pathnameFromSlug('about', '/[...slug]') // '/about'
125
- * pathnameFromSlug('post-1', '/blog/[...slug]') // '/blog/post-1'
126
- * pathnameFromSlug(undefined, '/[...slug]') // '/'
127
- * pathnameFromSlug(undefined, '/blog/[...slug]') // '/blog'
128
- */
129
- declare function pathnameFromSlug(slug: string | undefined, pattern: string): string;
130
- //#endregion
131
- //#region src/lib/serialize-props.d.ts
132
- /**
133
- * Safely serialize props for embedding in HTML data attributes.
134
- * Escapes < to prevent XSS when JSON is parsed in browser.
135
- */
136
- declare function serializeProps(props: Record<string, unknown>): string;
137
- //#endregion
138
- export { type BlockMeta, type ComponentRegistry, type HydratableComponent, type HydratableComponentConfig, type HydrationDiscovery, type HydrationMeta, type HydrationStrategy, type PageMeta, type TemplateConfig, type WithHydrationStrategy, blockMetaSchema, extractSlugFromPathname, findHydratableComponents, hasHydratableComponents, isHydratable, isPublished, pageMetaSchema, pathnameFromSlug, scanForHydratableComponents, serializeProps, toDate, withHydration };
139
- //# sourceMappingURL=index.d.mts.map