@conloca/astro-cms 0.1.16 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (422) hide show
  1. package/README.md +254 -301
  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/{src → ts/src}/cms-handler.d.ts +0 -1
  21. package/dist/ts/src/cms-handler.d.ts.map +1 -0
  22. package/dist/{src → ts/src}/cms-handler.js +11 -131
  23. package/dist/ts/src/cms-handler.js.map +1 -0
  24. package/dist/ts/src/collections.d.ts +161 -0
  25. package/dist/ts/src/collections.d.ts.map +1 -0
  26. package/dist/ts/src/collections.js +178 -0
  27. package/dist/ts/src/collections.js.map +1 -0
  28. package/dist/{src → ts/src}/components/HydrationWrapper.d.ts +1 -1
  29. package/dist/ts/src/components/HydrationWrapper.d.ts.map +1 -0
  30. package/dist/{src → ts/src}/components/HydrationWrapper.js +1 -0
  31. package/dist/ts/src/components/HydrationWrapper.js.map +1 -0
  32. package/dist/{src/components/RenderWithBlocks.d.ts → ts/src/components/RenderWithFragments.d.ts} +8 -4
  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/{src → ts/src}/components/RenderWithHydration.d.ts +6 -2
  37. package/dist/ts/src/components/RenderWithHydration.d.ts.map +1 -0
  38. package/dist/{src → ts/src}/components/RenderWithHydration.js +6 -3
  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.map +1 -0
  45. package/dist/{src → ts/src}/discovery/astro-frontmatter.js +1 -0
  46. package/dist/ts/src/discovery/astro-frontmatter.js.map +1 -0
  47. package/dist/ts/src/discovery/discover.d.ts +43 -0
  48. package/dist/ts/src/discovery/discover.d.ts.map +1 -0
  49. package/dist/ts/src/discovery/discover.js +87 -0
  50. package/dist/ts/src/discovery/discover.js.map +1 -0
  51. package/dist/ts/src/discovery/extract-props-ts.d.ts.map +1 -0
  52. package/dist/{src → ts/src}/discovery/extract-props-ts.js +1 -0
  53. package/dist/ts/src/discovery/extract-props-ts.js.map +1 -0
  54. package/dist/{src → ts/src}/discovery/merge-registry.d.ts +3 -3
  55. package/dist/ts/src/discovery/merge-registry.d.ts.map +1 -0
  56. package/dist/{src → ts/src}/discovery/merge-registry.js +1 -0
  57. package/dist/ts/src/discovery/merge-registry.js.map +1 -0
  58. package/dist/ts/src/discovery/registry-endpoint.d.ts +27 -0
  59. package/dist/ts/src/discovery/registry-endpoint.d.ts.map +1 -0
  60. package/dist/ts/src/discovery/registry-endpoint.js +76 -0
  61. package/dist/ts/src/discovery/registry-endpoint.js.map +1 -0
  62. package/dist/{src → ts/src}/discovery/scan-components.d.ts +3 -7
  63. package/dist/ts/src/discovery/scan-components.d.ts.map +1 -0
  64. package/dist/{src → ts/src}/discovery/scan-components.js +4 -6
  65. package/dist/ts/src/discovery/scan-components.js.map +1 -0
  66. package/dist/ts/src/discovery/scan-mdx.d.ts.map +1 -0
  67. package/dist/{src → ts/src}/discovery/scan-mdx.js +1 -0
  68. package/dist/ts/src/discovery/scan-mdx.js.map +1 -0
  69. package/dist/ts/src/discovery/scan-overrides.d.ts.map +1 -0
  70. package/dist/{src → ts/src}/discovery/scan-overrides.js +1 -0
  71. package/dist/ts/src/discovery/scan-overrides.js.map +1 -0
  72. package/dist/ts/src/editor-descriptors.d.ts +31 -0
  73. package/dist/ts/src/editor-descriptors.d.ts.map +1 -0
  74. package/dist/ts/src/editor-descriptors.js +84 -0
  75. package/dist/ts/src/editor-descriptors.js.map +1 -0
  76. package/dist/ts/src/handlers/collection-content-api.d.ts +32 -0
  77. package/dist/ts/src/handlers/collection-content-api.d.ts.map +1 -0
  78. package/dist/ts/src/handlers/collection-content-api.js +166 -0
  79. package/dist/ts/src/handlers/collection-content-api.js.map +1 -0
  80. package/dist/ts/src/handlers/page-render-core.d.ts +137 -0
  81. package/dist/ts/src/handlers/page-render-core.d.ts.map +1 -0
  82. package/dist/ts/src/handlers/page-render-core.js +315 -0
  83. package/dist/ts/src/handlers/page-render-core.js.map +1 -0
  84. package/dist/ts/src/hydration.d.ts.map +1 -0
  85. package/dist/{src → ts/src}/hydration.js +1 -0
  86. package/dist/ts/src/hydration.js.map +1 -0
  87. package/dist/ts/src/index.d.ts +21 -0
  88. package/dist/ts/src/index.d.ts.map +1 -0
  89. package/dist/ts/src/index.js +45 -0
  90. package/dist/ts/src/index.js.map +1 -0
  91. package/dist/ts/src/internal/declared-collections.d.ts +30 -0
  92. package/dist/ts/src/internal/declared-collections.d.ts.map +1 -0
  93. package/dist/ts/src/internal/declared-collections.js +84 -0
  94. package/dist/ts/src/internal/declared-collections.js.map +1 -0
  95. package/dist/ts/src/internal/page-collection-schema.d.ts +44 -0
  96. package/dist/ts/src/internal/page-collection-schema.d.ts.map +1 -0
  97. package/dist/ts/src/internal/page-collection-schema.js +152 -0
  98. package/dist/ts/src/internal/page-collection-schema.js.map +1 -0
  99. package/dist/ts/src/lib/content-config-guard.d.ts +13 -0
  100. package/dist/ts/src/lib/content-config-guard.d.ts.map +1 -0
  101. package/dist/ts/src/lib/content-config-guard.js +45 -0
  102. package/dist/ts/src/lib/content-config-guard.js.map +1 -0
  103. package/dist/ts/src/lib/hydration-scanner.d.ts.map +1 -0
  104. package/dist/{src → ts/src}/lib/hydration-scanner.js +1 -0
  105. package/dist/ts/src/lib/hydration-scanner.js.map +1 -0
  106. package/dist/ts/src/lib/hydration-script.d.ts.map +1 -0
  107. package/dist/{src → ts/src}/lib/hydration-script.js +1 -0
  108. package/dist/ts/src/lib/hydration-script.js.map +1 -0
  109. package/dist/ts/src/lib/hydration-utils.d.ts.map +1 -0
  110. package/dist/{src → ts/src}/lib/hydration-utils.js +1 -0
  111. package/dist/ts/src/lib/hydration-utils.js.map +1 -0
  112. package/dist/ts/src/lib/resolve-locale.d.ts +15 -0
  113. package/dist/ts/src/lib/resolve-locale.d.ts.map +1 -0
  114. package/dist/ts/src/lib/resolve-locale.js +16 -0
  115. package/dist/ts/src/lib/resolve-locale.js.map +1 -0
  116. package/dist/ts/src/lib/resolve-site-name.d.ts +8 -0
  117. package/dist/ts/src/lib/resolve-site-name.d.ts.map +1 -0
  118. package/dist/ts/src/lib/resolve-site-name.js +12 -0
  119. package/dist/ts/src/lib/resolve-site-name.js.map +1 -0
  120. package/dist/{src → ts/src}/lib/route-utils.d.ts +26 -6
  121. package/dist/ts/src/lib/route-utils.d.ts.map +1 -0
  122. package/dist/{src → ts/src}/lib/route-utils.js +33 -15
  123. package/dist/ts/src/lib/route-utils.js.map +1 -0
  124. package/dist/{src → ts/src}/lib/routing-config.d.ts +7 -1
  125. package/dist/ts/src/lib/routing-config.d.ts.map +1 -0
  126. package/dist/{src → ts/src}/lib/routing-config.js +13 -0
  127. package/dist/ts/src/lib/routing-config.js.map +1 -0
  128. package/dist/ts/src/lib/serialize-props.d.ts.map +1 -0
  129. package/dist/{src → ts/src}/lib/serialize-props.js +1 -0
  130. package/dist/ts/src/lib/serialize-props.js.map +1 -0
  131. package/dist/ts/src/lib/unknown-components.d.ts +21 -0
  132. package/dist/ts/src/lib/unknown-components.d.ts.map +1 -0
  133. package/dist/ts/src/lib/unknown-components.js +49 -0
  134. package/dist/ts/src/lib/unknown-components.js.map +1 -0
  135. package/dist/{src → ts/src}/lib/virtual-module-generators.d.ts +0 -24
  136. package/dist/ts/src/lib/virtual-module-generators.d.ts.map +1 -0
  137. package/dist/ts/src/lib/virtual-module-generators.js +51 -0
  138. package/dist/ts/src/lib/virtual-module-generators.js.map +1 -0
  139. package/dist/ts/src/lib/withHydration.d.ts.map +1 -0
  140. package/dist/{src → ts/src}/lib/withHydration.js +1 -0
  141. package/dist/ts/src/lib/withHydration.js.map +1 -0
  142. package/dist/ts/src/loader.d.ts +27 -0
  143. package/dist/ts/src/loader.d.ts.map +1 -0
  144. package/dist/{src → ts/src}/loader.js +33 -4
  145. package/dist/ts/src/loader.js.map +1 -0
  146. package/dist/ts/src/locales-helpers.d.ts.map +1 -0
  147. package/dist/{src → ts/src}/locales-helpers.js +1 -0
  148. package/dist/ts/src/locales-helpers.js.map +1 -0
  149. package/dist/ts/src/mime-types.d.ts.map +1 -0
  150. package/dist/{src → ts/src}/mime-types.js +1 -0
  151. package/dist/ts/src/mime-types.js.map +1 -0
  152. package/dist/ts/src/page-feed.d.ts +13 -0
  153. package/dist/ts/src/page-feed.d.ts.map +1 -0
  154. package/dist/ts/src/page-feed.js +20 -0
  155. package/dist/ts/src/page-feed.js.map +1 -0
  156. package/dist/ts/src/page-schemas.d.ts +6 -0
  157. package/dist/ts/src/page-schemas.d.ts.map +1 -0
  158. package/dist/ts/src/page-schemas.js +6 -0
  159. package/dist/ts/src/page-schemas.js.map +1 -0
  160. package/dist/ts/src/path-validation.d.ts.map +1 -0
  161. package/dist/{src → ts/src}/path-validation.js +1 -0
  162. package/dist/ts/src/path-validation.js.map +1 -0
  163. package/dist/{src → ts/src}/plugin-spa.d.ts +28 -10
  164. package/dist/ts/src/plugin-spa.d.ts.map +1 -0
  165. package/dist/{src → ts/src}/plugin-spa.js +301 -88
  166. package/dist/ts/src/plugin-spa.js.map +1 -0
  167. package/dist/ts/src/puck-manifest/components-endpoint.d.ts +30 -0
  168. package/dist/ts/src/puck-manifest/components-endpoint.d.ts.map +1 -0
  169. package/dist/ts/src/puck-manifest/components-endpoint.js +54 -0
  170. package/dist/ts/src/puck-manifest/components-endpoint.js.map +1 -0
  171. package/dist/ts/src/puck-manifest/field-projection.d.ts +91 -0
  172. package/dist/ts/src/puck-manifest/field-projection.d.ts.map +1 -0
  173. package/dist/ts/src/puck-manifest/field-projection.js +422 -0
  174. package/dist/ts/src/puck-manifest/field-projection.js.map +1 -0
  175. package/dist/ts/src/puck-manifest/index.d.ts +4 -0
  176. package/dist/ts/src/puck-manifest/index.d.ts.map +1 -0
  177. package/dist/ts/src/puck-manifest/index.js +3 -0
  178. package/dist/ts/src/puck-manifest/index.js.map +1 -0
  179. package/dist/ts/src/puck-manifest/literal.d.ts +163 -0
  180. package/dist/ts/src/puck-manifest/literal.d.ts.map +1 -0
  181. package/dist/ts/src/puck-manifest/literal.js +354 -0
  182. package/dist/ts/src/puck-manifest/literal.js.map +1 -0
  183. package/dist/ts/src/puck-manifest/read-config.d.ts +42 -0
  184. package/dist/ts/src/puck-manifest/read-config.d.ts.map +1 -0
  185. package/dist/ts/src/puck-manifest/read-config.js +517 -0
  186. package/dist/ts/src/puck-manifest/read-config.js.map +1 -0
  187. package/dist/ts/src/puck-manifest/read-field.d.ts +7 -0
  188. package/dist/ts/src/puck-manifest/read-field.d.ts.map +1 -0
  189. package/dist/ts/src/puck-manifest/read-field.js +11 -0
  190. package/dist/ts/src/puck-manifest/read-field.js.map +1 -0
  191. package/dist/ts/src/puck-manifest/read-wrapper.d.ts +147 -0
  192. package/dist/ts/src/puck-manifest/read-wrapper.d.ts.map +1 -0
  193. package/dist/ts/src/puck-manifest/read-wrapper.js +889 -0
  194. package/dist/ts/src/puck-manifest/read-wrapper.js.map +1 -0
  195. package/dist/ts/src/puck-manifest/reading-budget.d.ts +50 -0
  196. package/dist/ts/src/puck-manifest/reading-budget.d.ts.map +1 -0
  197. package/dist/ts/src/puck-manifest/reading-budget.js +113 -0
  198. package/dist/ts/src/puck-manifest/reading-budget.js.map +1 -0
  199. package/dist/ts/src/puck-manifest/resolve-reference.d.ts +4 -0
  200. package/dist/ts/src/puck-manifest/resolve-reference.d.ts.map +1 -0
  201. package/dist/ts/src/puck-manifest/resolve-reference.js +4 -0
  202. package/dist/ts/src/puck-manifest/resolve-reference.js.map +1 -0
  203. package/dist/ts/src/puck-manifest/source-reference.d.ts +96 -0
  204. package/dist/ts/src/puck-manifest/source-reference.d.ts.map +1 -0
  205. package/dist/ts/src/puck-manifest/source-reference.js +424 -0
  206. package/dist/ts/src/puck-manifest/source-reference.js.map +1 -0
  207. package/dist/ts/src/puck-manifest/syntax.d.ts +29 -0
  208. package/dist/ts/src/puck-manifest/syntax.d.ts.map +1 -0
  209. package/dist/ts/src/puck-manifest/syntax.js +79 -0
  210. package/dist/ts/src/puck-manifest/syntax.js.map +1 -0
  211. package/dist/ts/src/puck-manifest/types.d.ts +145 -0
  212. package/dist/ts/src/puck-manifest/types.d.ts.map +1 -0
  213. package/dist/ts/src/puck-manifest/types.js +2 -0
  214. package/dist/ts/src/puck-manifest/types.js.map +1 -0
  215. package/dist/ts/src/safe-json-stringify.d.ts.map +1 -0
  216. package/dist/{src → ts/src}/safe-json-stringify.js +1 -0
  217. package/dist/ts/src/safe-json-stringify.js.map +1 -0
  218. package/dist/ts/src/sandbox-frame-handler.d.ts +19 -0
  219. package/dist/ts/src/sandbox-frame-handler.d.ts.map +1 -0
  220. package/dist/ts/src/sandbox-frame-handler.js +27 -0
  221. package/dist/ts/src/sandbox-frame-handler.js.map +1 -0
  222. package/dist/{src → ts/src}/site-styles/content-wrapper-endpoint.d.ts +2 -5
  223. package/dist/ts/src/site-styles/content-wrapper-endpoint.d.ts.map +1 -0
  224. package/dist/{src → ts/src}/site-styles/content-wrapper-endpoint.js +5 -8
  225. package/dist/ts/src/site-styles/content-wrapper-endpoint.js.map +1 -0
  226. package/dist/{src → ts/src}/site-styles/render-endpoint.d.ts +4 -9
  227. package/dist/ts/src/site-styles/render-endpoint.d.ts.map +1 -0
  228. package/dist/{src → ts/src}/site-styles/render-endpoint.js +1 -0
  229. package/dist/ts/src/site-styles/render-endpoint.js.map +1 -0
  230. package/dist/{src → ts/src}/site-styles/styles-endpoint.d.ts +2 -4
  231. package/dist/ts/src/site-styles/styles-endpoint.d.ts.map +1 -0
  232. package/dist/{src → ts/src}/site-styles/styles-endpoint.js +3 -5
  233. package/dist/ts/src/site-styles/styles-endpoint.js.map +1 -0
  234. package/dist/ts/src/sitemap-options.d.ts +21 -0
  235. package/dist/ts/src/sitemap-options.d.ts.map +1 -0
  236. package/dist/ts/src/sitemap-options.js +92 -0
  237. package/dist/ts/src/sitemap-options.js.map +1 -0
  238. package/dist/ts/src/tiptap-html-static.d.ts +16 -0
  239. package/dist/ts/src/tiptap-html-static.d.ts.map +1 -0
  240. package/dist/ts/src/tiptap-html-static.js +117 -0
  241. package/dist/ts/src/tiptap-html-static.js.map +1 -0
  242. package/dist/{src → ts/src}/types.d.ts +26 -110
  243. package/dist/ts/src/types.d.ts.map +1 -0
  244. package/dist/ts/src/types.js +2 -0
  245. package/dist/ts/src/types.js.map +1 -0
  246. package/dist/virtual-modules.d.ts +12 -93
  247. package/node/content.ts +14 -0
  248. package/node/index.ts +22 -0
  249. package/package.json +161 -73
  250. package/src/asset-ref-base.ts +48 -0
  251. package/src/checks.ts +11 -0
  252. package/src/cms-handler.ts +281 -0
  253. package/src/collections.ts +271 -0
  254. package/src/components/HydrationWrapper.tsx +41 -0
  255. package/src/components/RenderWithFragments.tsx +204 -0
  256. package/src/components/RenderWithHydration.tsx +55 -0
  257. package/src/components.ts +3 -0
  258. package/src/discovery/astro-frontmatter.ts +24 -0
  259. package/src/discovery/discover.ts +108 -0
  260. package/src/discovery/extract-props-ts.ts +255 -0
  261. package/src/discovery/merge-registry.ts +411 -0
  262. package/src/discovery/registry-endpoint.ts +80 -0
  263. package/src/discovery/scan-components.ts +458 -0
  264. package/src/discovery/scan-mdx.ts +190 -0
  265. package/src/discovery/scan-overrides.ts +92 -0
  266. package/src/editor-descriptors.ts +96 -0
  267. package/src/env.d.ts +31 -0
  268. package/src/handlers/collection-content-api.ts +196 -0
  269. package/src/handlers/page-handler.astro +320 -0
  270. package/src/handlers/page-render-core.ts +456 -0
  271. package/src/hydration.ts +7 -0
  272. package/src/index.ts +111 -0
  273. package/src/internal/acorn-default.mjs +37 -0
  274. package/src/internal/declared-collections.ts +98 -0
  275. package/src/internal/page-collection-schema.ts +210 -0
  276. package/src/lib/content-config-guard.ts +53 -0
  277. package/src/lib/hydration-scanner.ts +176 -0
  278. package/src/lib/hydration-script.ts +126 -0
  279. package/src/lib/hydration-utils.ts +120 -0
  280. package/src/lib/resolve-locale.ts +22 -0
  281. package/src/lib/resolve-site-name.ts +10 -0
  282. package/src/lib/route-utils.ts +106 -0
  283. package/src/lib/routing-config.ts +126 -0
  284. package/src/lib/serialize-props.ts +7 -0
  285. package/src/lib/unknown-components.ts +64 -0
  286. package/src/lib/virtual-module-generators.ts +58 -0
  287. package/{dist/withHydration-DkKpkmzJ.d.mts → src/lib/withHydration.ts} +25 -8
  288. package/src/loader.ts +145 -0
  289. package/{dist/locales-helpers-BvYYqnJ5.d.mts → src/locales-helpers.ts} +21 -17
  290. package/src/mime-types.ts +19 -0
  291. package/src/page-feed.ts +26 -0
  292. package/src/page-schemas.ts +19 -0
  293. package/src/path-validation.ts +13 -0
  294. package/src/plugin-spa.ts +1496 -0
  295. package/src/puck-manifest/components-endpoint.ts +55 -0
  296. package/src/puck-manifest/field-projection.ts +510 -0
  297. package/src/puck-manifest/index.ts +3 -0
  298. package/src/puck-manifest/literal.ts +459 -0
  299. package/src/puck-manifest/read-config.ts +577 -0
  300. package/src/puck-manifest/read-field.ts +19 -0
  301. package/src/puck-manifest/read-wrapper.ts +1056 -0
  302. package/src/puck-manifest/reading-budget.ts +127 -0
  303. package/src/puck-manifest/resolve-reference.ts +9 -0
  304. package/src/puck-manifest/source-reference.ts +484 -0
  305. package/src/puck-manifest/syntax.ts +104 -0
  306. package/src/puck-manifest/types.ts +139 -0
  307. package/src/safe-json-stringify.ts +17 -0
  308. package/src/sandbox-frame-handler.ts +31 -0
  309. package/src/site-styles/content-wrapper-endpoint.ts +327 -0
  310. package/src/site-styles/render-endpoint.ts +331 -0
  311. package/src/site-styles/styles-endpoint.ts +184 -0
  312. package/src/sitemap-options.ts +115 -0
  313. package/src/tiptap-html-static.ts +134 -0
  314. package/{dist/types-CS9neadI.d.mts → src/types.ts} +87 -124
  315. package/src/virtual-modules.d.ts +74 -0
  316. package/dist/collections-Bd7EME4b.mjs +0 -129
  317. package/dist/collections-Bd7EME4b.mjs.map +0 -1
  318. package/dist/collections.d.mts +0 -35
  319. package/dist/collections.d.mts.map +0 -1
  320. package/dist/collections.mjs +0 -2
  321. package/dist/components.d.mts +0 -41
  322. package/dist/components.d.mts.map +0 -1
  323. package/dist/components.mjs +0 -223
  324. package/dist/components.mjs.map +0 -1
  325. package/dist/hydration.d.mts +0 -4
  326. package/dist/hydration.mjs +0 -2
  327. package/dist/index.d.mts +0 -108
  328. package/dist/index.d.mts.map +0 -1
  329. package/dist/index.mjs +0 -67
  330. package/dist/index.mjs.map +0 -1
  331. package/dist/internal/cms-handler.d.mts +0 -25
  332. package/dist/internal/cms-handler.d.mts.map +0 -1
  333. package/dist/internal/cms-handler.mjs +0 -314
  334. package/dist/internal/cms-handler.mjs.map +0 -1
  335. package/dist/lib/hydration-script.d.mts +0 -30
  336. package/dist/lib/hydration-script.d.mts.map +0 -1
  337. package/dist/lib/hydration-script.mjs +0 -84
  338. package/dist/lib/hydration-script.mjs.map +0 -1
  339. package/dist/locales-helpers-BvYYqnJ5.d.mts.map +0 -1
  340. package/dist/locales-helpers-qiwh7nxS.mjs +0 -54
  341. package/dist/locales-helpers-qiwh7nxS.mjs.map +0 -1
  342. package/dist/node/content.d.mts +0 -18
  343. package/dist/node/content.d.mts.map +0 -1
  344. package/dist/node/content.d.ts +0 -3
  345. package/dist/node/content.d.ts.map +0 -1
  346. package/dist/node/content.js +0 -2
  347. package/dist/node/content.mjs +0 -2
  348. package/dist/node/index.d.mts +0 -200
  349. package/dist/node/index.d.mts.map +0 -1
  350. package/dist/node/index.d.ts +0 -4
  351. package/dist/node/index.d.ts.map +0 -1
  352. package/dist/node/index.js +0 -3
  353. package/dist/node/index.mjs +0 -2513
  354. package/dist/node/index.mjs.map +0 -1
  355. package/dist/serialize-props-BHoNpzH6.mjs +0 -72
  356. package/dist/serialize-props-BHoNpzH6.mjs.map +0 -1
  357. package/dist/src/cms-handler.d.ts.map +0 -1
  358. package/dist/src/collections.d.ts +0 -32
  359. package/dist/src/collections.d.ts.map +0 -1
  360. package/dist/src/collections.js +0 -50
  361. package/dist/src/components/HydrationWrapper.d.ts.map +0 -1
  362. package/dist/src/components/RenderWithBlocks.d.ts.map +0 -1
  363. package/dist/src/components/RenderWithBlocks.js +0 -129
  364. package/dist/src/components/RenderWithHydration.d.ts.map +0 -1
  365. package/dist/src/components.d.ts +0 -4
  366. package/dist/src/components.d.ts.map +0 -1
  367. package/dist/src/components.js +0 -3
  368. package/dist/src/discovery/astro-frontmatter.d.ts.map +0 -1
  369. package/dist/src/discovery/extract-props-ts.d.ts.map +0 -1
  370. package/dist/src/discovery/merge-registry.d.ts.map +0 -1
  371. package/dist/src/discovery/registry-endpoint.d.ts +0 -42
  372. package/dist/src/discovery/registry-endpoint.d.ts.map +0 -1
  373. package/dist/src/discovery/registry-endpoint.js +0 -81
  374. package/dist/src/discovery/scan-components.d.ts.map +0 -1
  375. package/dist/src/discovery/scan-mdx.d.ts.map +0 -1
  376. package/dist/src/discovery/scan-overrides.d.ts.map +0 -1
  377. package/dist/src/hydration.d.ts.map +0 -1
  378. package/dist/src/index.d.ts +0 -11
  379. package/dist/src/index.d.ts.map +0 -1
  380. package/dist/src/index.js +0 -25
  381. package/dist/src/lib/hydration-scanner.d.ts.map +0 -1
  382. package/dist/src/lib/hydration-script.d.ts.map +0 -1
  383. package/dist/src/lib/hydration-utils.d.ts.map +0 -1
  384. package/dist/src/lib/page-api.d.ts +0 -77
  385. package/dist/src/lib/page-api.d.ts.map +0 -1
  386. package/dist/src/lib/page-api.js +0 -121
  387. package/dist/src/lib/route-utils.d.ts.map +0 -1
  388. package/dist/src/lib/routing-config.d.ts.map +0 -1
  389. package/dist/src/lib/serialize-props.d.ts.map +0 -1
  390. package/dist/src/lib/virtual-module-generators.d.ts.map +0 -1
  391. package/dist/src/lib/virtual-module-generators.js +0 -263
  392. package/dist/src/lib/withHydration.d.ts.map +0 -1
  393. package/dist/src/loader.d.ts +0 -14
  394. package/dist/src/loader.d.ts.map +0 -1
  395. package/dist/src/locales-helpers.d.ts.map +0 -1
  396. package/dist/src/mime-types.d.ts.map +0 -1
  397. package/dist/src/path-validation.d.ts.map +0 -1
  398. package/dist/src/plugin-spa.d.ts.map +0 -1
  399. package/dist/src/safe-json-stringify.d.ts.map +0 -1
  400. package/dist/src/site-styles/content-wrapper-endpoint.d.ts.map +0 -1
  401. package/dist/src/site-styles/render-endpoint.d.ts.map +0 -1
  402. package/dist/src/site-styles/styles-endpoint.d.ts.map +0 -1
  403. package/dist/src/types.d.ts.map +0 -1
  404. package/dist/src/types.js +0 -1
  405. package/dist/types-CS9neadI.d.mts.map +0 -1
  406. package/dist/withHydration-C256ox_6.mjs +0 -49
  407. package/dist/withHydration-C256ox_6.mjs.map +0 -1
  408. package/dist/withHydration-DkKpkmzJ.d.mts.map +0 -1
  409. /package/dist/{src → ts/src}/discovery/astro-frontmatter.d.ts +0 -0
  410. /package/dist/{src → ts/src}/discovery/extract-props-ts.d.ts +0 -0
  411. /package/dist/{src → ts/src}/discovery/scan-mdx.d.ts +0 -0
  412. /package/dist/{src → ts/src}/discovery/scan-overrides.d.ts +0 -0
  413. /package/dist/{src → ts/src}/hydration.d.ts +0 -0
  414. /package/dist/{src → ts/src}/lib/hydration-scanner.d.ts +0 -0
  415. /package/dist/{src → ts/src}/lib/hydration-script.d.ts +0 -0
  416. /package/dist/{src → ts/src}/lib/hydration-utils.d.ts +0 -0
  417. /package/dist/{src → ts/src}/lib/serialize-props.d.ts +0 -0
  418. /package/dist/{src → ts/src}/lib/withHydration.d.ts +0 -0
  419. /package/dist/{src → ts/src}/locales-helpers.d.ts +0 -0
  420. /package/dist/{src → ts/src}/mime-types.d.ts +0 -0
  421. /package/dist/{src → ts/src}/path-validation.d.ts +0 -0
  422. /package/dist/{src → ts/src}/safe-json-stringify.d.ts +0 -0
@@ -0,0 +1,120 @@
1
+ import type { Config, Data } from '@puckeditor/core';
2
+ import type { HydrationStrategy } from '../types.js';
3
+ import type { HydrationMeta } from './withHydration.js';
4
+
5
+ /**
6
+ * Extended ComponentConfig with hydration support.
7
+ * @deprecated Use withHydration() wrapper instead of hydration property.
8
+ */
9
+ export interface HydratableComponentConfig {
10
+ /** @deprecated Use withHydration() wrapper on render function instead */
11
+ hydration?: HydrationStrategy;
12
+ render?: (props: unknown) => unknown;
13
+ }
14
+
15
+ /**
16
+ * Component instance requiring hydration.
17
+ * Contains the component name, props, and hydration strategy.
18
+ */
19
+ export interface HydratableComponent {
20
+ /** Component type name from Puck config */
21
+ type: string;
22
+ /** Props to pass to the component */
23
+ props: Record<string, unknown>;
24
+ /** Hydration strategy from ComponentConfig */
25
+ strategy: Exclude<HydrationStrategy, 'none'>;
26
+ /** Unique ID from Puck data (for keying) */
27
+ id: string;
28
+ }
29
+
30
+ /**
31
+ * Check if a component type has hydration enabled.
32
+ *
33
+ * First checks for __hydration metadata on the render function (new withHydration API),
34
+ * then falls back to hydration property on ComponentConfig (deprecated).
35
+ *
36
+ * @param componentType - The component type name from Puck data
37
+ * @param config - The Puck config with component definitions
38
+ * @returns The hydration strategy ('none', 'load', 'visible', 'idle')
39
+ */
40
+ export function isHydratable(componentType: string, config: Config): HydrationStrategy {
41
+ const componentConfig = config.components[componentType] as HydratableComponentConfig | undefined;
42
+ if (!componentConfig?.render) return 'none';
43
+
44
+ // New API: Check for __hydration metadata attached by withHydration()
45
+ const render = componentConfig.render as { __hydration?: HydrationMeta };
46
+ if (render.__hydration?.__isHydratable) {
47
+ return render.__hydration.strategy;
48
+ }
49
+
50
+ // Deprecated: Check hydration property on ComponentConfig
51
+ return componentConfig?.hydration ?? 'none';
52
+ }
53
+
54
+ /**
55
+ * Find all components in a Puck data tree that require hydration.
56
+ * Walks the content array and zones recursively.
57
+ *
58
+ * @param data - Puck data object containing content tree
59
+ * @param config - Puck config with component definitions
60
+ * @returns Array of components that need hydration
61
+ */
62
+ export function findHydratableComponents(data: Data, config: Config): HydratableComponent[] {
63
+ const hydratable: HydratableComponent[] = [];
64
+
65
+ // Walk content array
66
+ if (data.content) {
67
+ for (const item of data.content) {
68
+ const strategy = isHydratable(item.type, config);
69
+ if (strategy !== 'none') {
70
+ hydratable.push({
71
+ type: item.type,
72
+ props: item.props ?? {},
73
+ strategy,
74
+ id: item.props?.id ?? item.type,
75
+ });
76
+ }
77
+ }
78
+ }
79
+
80
+ // Walk zones (named drop zones with nested content)
81
+ if (data.zones) {
82
+ for (const [zoneName, zoneContent] of Object.entries(data.zones)) {
83
+ for (const item of zoneContent) {
84
+ const strategy = isHydratable(item.type, config);
85
+ if (strategy !== 'none') {
86
+ hydratable.push({
87
+ type: item.type,
88
+ props: item.props ?? {},
89
+ strategy,
90
+ id: item.props?.id ?? `${zoneName}-${item.type}`,
91
+ });
92
+ }
93
+ }
94
+ }
95
+ }
96
+
97
+ return hydratable;
98
+ }
99
+
100
+ /**
101
+ * Check if Puck data contains any hydratable components.
102
+ * Quick check before more expensive operations.
103
+ */
104
+ export function hasHydratableComponents(data: Data, config: Config): boolean {
105
+ // Check content
106
+ if (data.content?.some((item) => isHydratable(item.type, config) !== 'none')) {
107
+ return true;
108
+ }
109
+
110
+ // Check zones
111
+ if (data.zones) {
112
+ for (const zoneContent of Object.values(data.zones)) {
113
+ if (zoneContent.some((item) => isHydratable(item.type, config) !== 'none')) {
114
+ return true;
115
+ }
116
+ }
117
+ }
118
+
119
+ return false;
120
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Pick the locale to read content in. A hardcoded 'en' silently yields zero
3
+ * pages for any project whose content is not English — `getStaticPaths` drops
4
+ * every entry whose locale does not match — so prefer the explicit routing
5
+ * option, then the framework-level `locales` declaration, then the resolved
6
+ * site's own default, then the first global locale. Mirrors the chain
7
+ * FileSystemContentAPI already uses for its default locale.
8
+ */
9
+ export function resolveLocale(
10
+ configured: string | undefined,
11
+ frameworkDefault: string | undefined,
12
+ siteName: string,
13
+ sitesConfig: { sites: Record<string, { defaultLocale?: string } | undefined>; globalLocales?: string[] },
14
+ ): string {
15
+ return (
16
+ configured ??
17
+ frameworkDefault ??
18
+ sitesConfig.sites[siteName]?.defaultLocale ??
19
+ sitesConfig.globalLocales?.[0] ??
20
+ 'en'
21
+ );
22
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Pick the site to operate on. A hardcoded 'default' silently yields zero
3
+ * pages for any project whose site is named anything else, so prefer the
4
+ * explicit option, then the first site declared in sites.json. Mirrors the
5
+ * fallback chain in FileSystemContentAPI.
6
+ */
7
+ export function resolveSiteName(configured: string | undefined, sites: Record<string, unknown>): string {
8
+ if (configured) return configured;
9
+ return Object.keys(sites)[0] ?? 'default';
10
+ }
@@ -0,0 +1,106 @@
1
+ import { isContentPublished } from '@conloca/content-api';
2
+
3
+ /** The existing public date helper, retaining Date identity for callers that already hold one. */
4
+ export function toDate(value: string | Date | null | undefined): Date | undefined {
5
+ if (!value) return undefined;
6
+ if (value instanceof Date) return value;
7
+ const parsed = new Date(value);
8
+ return Number.isNaN(parsed.getTime()) ? undefined : parsed;
9
+ }
10
+
11
+ /** Preserve the one-argument public predicate, including direct use as an array filter. */
12
+ export function isPublished(schedule: Parameters<typeof isContentPublished>[0]): boolean {
13
+ return isContentPublished(schedule);
14
+ }
15
+
16
+ /**
17
+ * Extract slug from pathname given a route pattern.
18
+ *
19
+ * The slug is the portion of the pathname that comes after the
20
+ * static prefix of the pattern.
21
+ *
22
+ * @param pathname - URL pathname (e.g., '/about', '/blog/post-1')
23
+ * @param pattern - Route pattern (e.g., '/[...slug]', '/blog/[...slug]')
24
+ * @returns The extracted slug, or undefined for root paths
25
+ *
26
+ * @example
27
+ * extractSlugFromPathname('/about', '/[...slug]') // 'about'
28
+ * extractSlugFromPathname('/blog/post-1', '/blog/[...slug]') // 'post-1'
29
+ * extractSlugFromPathname('/', '/[...slug]') // undefined
30
+ * extractSlugFromPathname('/blog', '/blog/[...slug]') // undefined
31
+ */
32
+ export function extractSlugFromPathname(pathname: string, pattern: string): string | undefined {
33
+ // Pattern: /[...slug] -> prefix: ''
34
+ // Pattern: /blog/[...slug] -> prefix: '/blog'
35
+ // Pattern: /docs/[...path] -> prefix: '/docs'
36
+
37
+ const prefixMatch = pattern.match(/^(.*?)\[/);
38
+ const prefix = prefixMatch ? prefixMatch[1].replace(/\/$/, '') : '';
39
+
40
+ // Remove prefix from pathname
41
+ const slugPart = pathname.slice(prefix.length);
42
+
43
+ // Remove leading slash
44
+ const slug = slugPart.replace(/^\//, '');
45
+
46
+ // Empty string means root page (e.g., /blog for /blog/[...slug])
47
+ // Return undefined for root to match [...slug] behavior
48
+ return slug || undefined;
49
+ }
50
+
51
+ /**
52
+ * Convert a slug back to a pathname given a route pattern.
53
+ *
54
+ * The inverse of extractSlugFromPathname.
55
+ *
56
+ * @param slug - The page slug (e.g., 'about', 'post-1'), or undefined for root
57
+ * @param pattern - Route pattern (e.g., '/[...slug]', '/blog/[...slug]')
58
+ * @returns Full URL pathname
59
+ *
60
+ * @example
61
+ * pathnameFromSlug('about', '/[...slug]') // '/about'
62
+ * pathnameFromSlug('post-1', '/blog/[...slug]') // '/blog/post-1'
63
+ * pathnameFromSlug(undefined, '/[...slug]') // '/'
64
+ * pathnameFromSlug(undefined, '/blog/[...slug]') // '/blog'
65
+ */
66
+ export function pathnameFromSlug(slug: string | undefined, pattern: string): string {
67
+ // Extract the static prefix before the dynamic segment
68
+ const prefixMatch = pattern.match(/^(.*?)\[/);
69
+ const prefix = prefixMatch ? prefixMatch[1].replace(/\/$/, '') : '';
70
+
71
+ if (!slug) {
72
+ // No slug means root of this pattern
73
+ return prefix || '/';
74
+ }
75
+
76
+ // Combine prefix and slug
77
+ return `${prefix}/${slug}`;
78
+ }
79
+
80
+ /**
81
+ * The `params` a prerendered path must carry for a route pattern. Astro keys
82
+ * them by the name inside the pattern's brackets, so a `/[...page]` route
83
+ * needs `{ page }`, not `{ slug }`; static patterns carry none.
84
+ */
85
+ export function staticPathParams(pathname: string, pattern: string): Record<string, string | undefined> {
86
+ const name = pattern.match(/\[(?:\.\.\.)?([^\]]+)\]/)?.[1];
87
+
88
+ return name ? { [name]: extractSlugFromPathname(pathname, pattern) } : {};
89
+ }
90
+
91
+ /**
92
+ * Entry-id factory for Astro content loaders over Conloca-managed markdown.
93
+ *
94
+ * Conloca's read-repair writes a tracking `id: vx-*` into managed frontmatter,
95
+ * and Astro's glob-style loaders prefer a frontmatter `id` over the file path
96
+ * — which silently breaks filename-based slug lookups (a Starlight sidebar
97
+ * entry like `slug: 'getting-started'` stops resolving). Pass this as the
98
+ * loader's `generateId` to pin entry ids to the file path; the Conloca `id`
99
+ * stays available as frontmatter data.
100
+ *
101
+ * @example
102
+ * docsLoader({ generateId: entryIdFromPath })
103
+ */
104
+ export function entryIdFromPath({ entry }: { entry: string }): string {
105
+ return entry.replace(/\.(md|mdx|markdown|mdown|mkdn|mkd|mdwn|mdoc)$/, '');
106
+ }
@@ -0,0 +1,126 @@
1
+ import type {
2
+ DataBindingConfig,
3
+ EditorDataBindings,
4
+ ResolvedRoutingConfig,
5
+ RouteConfig,
6
+ RoutingConfig,
7
+ RoutingConfigInput,
8
+ } from '../types.js';
9
+
10
+ /**
11
+ * Normalize routing config input to full RoutingConfig.
12
+ *
13
+ * Handles the `routing: true` shorthand, boolean values, and top-level layout option.
14
+ *
15
+ * @param input - The routing config input (boolean, object, or undefined)
16
+ * @param topLevelLayout - Optional top-level layout path (enables routing when provided)
17
+ * @returns Normalized RoutingConfig or undefined if not enabled
18
+ */
19
+ export function normalizeRoutingConfig(
20
+ input: RoutingConfigInput | undefined,
21
+ topLevelLayout?: string,
22
+ ): RoutingConfig | undefined {
23
+ // If no routing config but layout provided, enable with defaults
24
+ if (input === undefined && topLevelLayout) {
25
+ return {
26
+ enabled: true,
27
+ routes: {
28
+ pages: {
29
+ pattern: '/[...slug]',
30
+ collection: 'pages',
31
+ layout: topLevelLayout,
32
+ prerender: true,
33
+ },
34
+ },
35
+ fallback: '404',
36
+ onConflict: 'warn',
37
+ };
38
+ }
39
+
40
+ if (input === undefined) {
41
+ return undefined;
42
+ }
43
+
44
+ if (input === true) {
45
+ return {
46
+ enabled: true,
47
+ routes: {
48
+ pages: {
49
+ pattern: '/[...slug]',
50
+ collection: 'pages',
51
+ prerender: true,
52
+ },
53
+ },
54
+ fallback: '404',
55
+ onConflict: 'warn',
56
+ };
57
+ }
58
+
59
+ if (input === false) {
60
+ return { enabled: false };
61
+ }
62
+
63
+ return input;
64
+ }
65
+
66
+ /**
67
+ * Apply defaults to a RouteConfig.
68
+ *
69
+ * Fills in missing optional fields with their default values.
70
+ *
71
+ * @param config - Partial route configuration
72
+ * @returns Complete route configuration with all fields
73
+ */
74
+ export function resolveRouteConfig(config: RouteConfig): Required<RouteConfig> {
75
+ return {
76
+ pattern: config.pattern,
77
+ collection: config.collection ?? 'pages',
78
+ layout: config.layout ?? '',
79
+ prerender: config.prerender ?? true,
80
+ meta: config.meta ?? {},
81
+ dataBindings: config.dataBindings ?? { collections: [] },
82
+ };
83
+ }
84
+
85
+ /**
86
+ * The bindings the editor builds a page's data context from: every page
87
+ * collection a route serves, with that route's bindings. A page's collection is
88
+ * all the editor knows of its route, so the first route wins when two share one.
89
+ */
90
+ export function toEditorDataBindings(resolved: ResolvedRoutingConfig): EditorDataBindings {
91
+ const routes: Record<string, DataBindingConfig> = {};
92
+ for (const route of Object.values(resolved.routes)) {
93
+ routes[route.collection] ??= route.dataBindings;
94
+ }
95
+ return { siteName: resolved.siteName, locale: resolved.locale, routes };
96
+ }
97
+
98
+ /**
99
+ * Validate a route pattern.
100
+ *
101
+ * Ensures the pattern is a valid Astro route pattern.
102
+ * Throws descriptive error if invalid.
103
+ *
104
+ * @param pattern - The route pattern to validate
105
+ * @param routeName - Name of the route (for error messages)
106
+ * @throws Error if pattern is invalid
107
+ */
108
+ export function validateRoutePattern(pattern: string, routeName: string): void {
109
+ if (!pattern.startsWith('/')) {
110
+ throw new Error(`Route '${routeName}': pattern must start with '/', got '${pattern}'`);
111
+ }
112
+
113
+ // Check for valid Astro route syntax
114
+ // Allow: a-zA-Z0-9, hyphen, underscore, slash, brackets, dots
115
+ const invalidChars = pattern.match(/[^a-zA-Z0-9\-_/[\].]/g);
116
+ if (invalidChars) {
117
+ throw new Error(`Route '${routeName}': pattern contains invalid characters: ${invalidChars.join(', ')}`);
118
+ }
119
+
120
+ // Check for balanced brackets
121
+ const openBrackets = (pattern.match(/\[/g) || []).length;
122
+ const closeBrackets = (pattern.match(/\]/g) || []).length;
123
+ if (openBrackets !== closeBrackets) {
124
+ throw new Error(`Route '${routeName}': pattern has unbalanced brackets: '${pattern}'`);
125
+ }
126
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Safely serialize props for embedding in HTML data attributes.
3
+ * Escapes < to prevent XSS when JSON is parsed in browser.
4
+ */
5
+ export function serializeProps(props: Record<string, unknown>): string {
6
+ return JSON.stringify(props).replace(/</g, '\\u003c');
7
+ }
@@ -0,0 +1,64 @@
1
+ /** One entry in a Puck content array: a component type plus its props. */
2
+ interface PuckItem {
3
+ type?: string;
4
+ props?: Record<string, unknown>;
5
+ }
6
+
7
+ /**
8
+ * A prop whose value is Puck slot content — an array of components nested
9
+ * inside another component (`items: Slot` and friends). Puck stores slots
10
+ * among the ordinary props, so the shape is what identifies them: asking the
11
+ * config which fields are slots would miss a component the config no longer
12
+ * declares, and that is precisely the case this check exists for.
13
+ */
14
+ function isSlotContent(value: unknown): value is PuckItem[] {
15
+ return (
16
+ Array.isArray(value) &&
17
+ value.length > 0 &&
18
+ value.every(
19
+ (entry) =>
20
+ typeof entry === 'object' &&
21
+ entry !== null &&
22
+ typeof (entry as PuckItem).type === 'string' &&
23
+ typeof (entry as PuckItem).props === 'object',
24
+ )
25
+ );
26
+ }
27
+
28
+ /**
29
+ * Component types present in stored content but absent from the Puck config,
30
+ * at any nesting depth.
31
+ *
32
+ * Puck renders unknown types as null with no warning, so a page referencing
33
+ * them serves HTTP 200 with an empty body and a clean console. Fragment_*
34
+ * entries are excluded: RenderWithFragments injects those after this check.
35
+ */
36
+ export function findUnknownComponentTypes(
37
+ // `root` is unused here but present on every real Puck payload; declaring it
38
+ // keeps callers from having to strip it to satisfy the type.
39
+ data: { content?: PuckItem[]; root?: unknown } | undefined,
40
+ config: { components?: Record<string, unknown> } | undefined,
41
+ ): string[] {
42
+ // A Set of the registered names, rather than a lookup on the config object:
43
+ // a stored type named after an Object.prototype key ('constructor',
44
+ // 'toString') would otherwise look registered and stay silent — the exact
45
+ // failure this check exists to surface.
46
+ const registered = new Set(Object.keys(config?.components ?? {}));
47
+ const seen = new Set<string>();
48
+
49
+ const visit = (items: PuckItem[]): void => {
50
+ for (const item of items) {
51
+ const type = item?.type;
52
+ if (type && !type.startsWith('Fragment_') && !registered.has(type)) {
53
+ seen.add(type);
54
+ }
55
+ for (const value of Object.values(item?.props ?? {})) {
56
+ if (isSlotContent(value)) visit(value);
57
+ }
58
+ }
59
+ };
60
+
61
+ visit(data?.content ?? []);
62
+
63
+ return [...seen];
64
+ }
@@ -0,0 +1,58 @@
1
+ import type { ResolvedRoutingConfig, RoutingConfig } from '../types.js';
2
+
3
+ /**
4
+ * Generate the virtual:conloca-routing-config module.
5
+ *
6
+ * Returns a module that exports the resolved routing configuration as default.
7
+ *
8
+ * @param config - Resolved routing configuration with all defaults applied
9
+ * @returns JavaScript module code as a string
10
+ */
11
+ export function generateRoutingConfigModule(config: ResolvedRoutingConfig): string {
12
+ return `export default ${JSON.stringify(config, null, 2)};`;
13
+ }
14
+
15
+ /**
16
+ * Generate the virtual:conloca-layout module.
17
+ *
18
+ * Returns a module that re-exports the layout component or exports undefined
19
+ * if no layout is configured.
20
+ *
21
+ * Currently uses the first route's layout. Multi-layout support is future work.
22
+ *
23
+ * @param routing - Routing configuration (may be undefined if routing disabled)
24
+ * @returns JavaScript module code as a string
25
+ */
26
+ export function generateLayoutModule(routing: RoutingConfig | undefined): string {
27
+ // Get layout from first route (for now - multi-layout is future work)
28
+ const routes = routing?.routes || {};
29
+ const firstRoute = Object.values(routes)[0];
30
+ const layoutPath = firstRoute?.layout;
31
+
32
+ if (layoutPath) {
33
+ // Convert relative path to absolute for Vite resolution
34
+ // ./src/... -> /src/...
35
+ const absolutePath = layoutPath.startsWith('.') ? `/${layoutPath.slice(2)}` : layoutPath;
36
+
37
+ return `export { default } from '${absolutePath}';`;
38
+ }
39
+
40
+ return 'export default undefined;';
41
+ }
42
+
43
+ /**
44
+ * Generate the virtual:conloca-puck-config module.
45
+ *
46
+ * Returns a module that re-exports the Puck configuration.
47
+ * This is separate from the HMR-enabled puck-entry.js used by the CMS SPA.
48
+ *
49
+ * @param puckConfigPath - Path to the puck config module
50
+ * @returns JavaScript module code as a string
51
+ */
52
+ export function generatePuckConfigModule(puckConfigPath: string): string {
53
+ // Convert relative path to absolute for Vite resolution
54
+ // ./src/... -> /src/...
55
+ const absolutePath = puckConfigPath.startsWith('.') ? `/${puckConfigPath.slice(2)}` : puckConfigPath;
56
+
57
+ return `export { default } from '${absolutePath}';`;
58
+ }
@@ -1,18 +1,20 @@
1
- import React from "react";
2
- //#region src/lib/withHydration.d.ts
1
+ import type React from 'react';
2
+
3
3
  /**
4
4
  * Metadata attached to components marked for hydration.
5
5
  * Used by the build-time scanner and runtime hydration system.
6
6
  */
7
- interface HydrationMeta {
7
+ export interface HydrationMeta {
8
8
  strategy: 'load' | 'visible' | 'idle';
9
9
  __isHydratable: true;
10
10
  }
11
+
11
12
  /**
12
13
  * Hydration strategy for the withHydration wrapper.
13
14
  * Does not include 'none' since wrapping implies hydration is desired.
14
15
  */
15
- type WithHydrationStrategy = 'load' | 'visible' | 'idle';
16
+ export type WithHydrationStrategy = 'load' | 'visible' | 'idle';
17
+
16
18
  /**
17
19
  * Marks a component's render function for client-side hydration.
18
20
  *
@@ -48,7 +50,22 @@ type WithHydrationStrategy = 'load' | 'visible' | 'idle';
48
50
  * }
49
51
  * ```
50
52
  */
51
- declare function withHydration<T extends (props: any) => React.ReactNode>(Component: T, strategy: WithHydrationStrategy): T;
52
- //#endregion
53
- export { WithHydrationStrategy as n, withHydration as r, HydrationMeta as t };
54
- //# sourceMappingURL=withHydration-DkKpkmzJ.d.mts.map
53
+ export function withHydration<T extends (props: any) => React.ReactNode>(
54
+ Component: T,
55
+ strategy: WithHydrationStrategy,
56
+ ): T {
57
+ // Environment variable escape hatch for debugging
58
+ if (typeof process !== 'undefined' && process.env?.CONLOCA_DISABLE_HYDRATION === 'true') {
59
+ return Component;
60
+ }
61
+
62
+ // Attach metadata directly to the function object
63
+ // This avoids creating a wrapper component and keeps bundle size minimal
64
+ const HydratableComponent = Component as T & { __hydration: HydrationMeta };
65
+ HydratableComponent.__hydration = {
66
+ strategy,
67
+ __isHydratable: true,
68
+ };
69
+
70
+ return HydratableComponent;
71
+ }