@conloca/astro-cms 0.1.15 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (367) hide show
  1. package/README.md +259 -247
  2. package/dist/internal/acorn-default.mjs +11 -3
  3. package/dist/internal/page-handler.astro +137 -358
  4. package/dist/ts/node/content.d.ts +4 -0
  5. package/dist/ts/node/content.d.ts.map +1 -0
  6. package/dist/ts/node/content.js +3 -0
  7. package/dist/ts/node/content.js.map +1 -0
  8. package/dist/ts/node/index.d.ts +9 -0
  9. package/dist/ts/node/index.d.ts.map +1 -0
  10. package/dist/ts/node/index.js +14 -0
  11. package/dist/ts/node/index.js.map +1 -0
  12. package/dist/ts/src/asset-ref-base.d.ts +3 -0
  13. package/dist/ts/src/asset-ref-base.d.ts.map +1 -0
  14. package/dist/ts/src/asset-ref-base.js +48 -0
  15. package/dist/ts/src/asset-ref-base.js.map +1 -0
  16. package/dist/ts/src/checks.d.ts +7 -0
  17. package/dist/ts/src/checks.d.ts.map +1 -0
  18. package/dist/ts/src/checks.js +7 -0
  19. package/dist/ts/src/checks.js.map +1 -0
  20. package/dist/ts/src/cms-handler.d.ts +18 -0
  21. package/dist/ts/src/cms-handler.d.ts.map +1 -0
  22. package/dist/ts/src/cms-handler.js +245 -0
  23. package/dist/ts/src/cms-handler.js.map +1 -0
  24. package/dist/ts/src/collections.d.ts +160 -0
  25. package/dist/ts/src/collections.d.ts.map +1 -0
  26. package/dist/ts/src/collections.js +170 -0
  27. package/dist/ts/src/collections.js.map +1 -0
  28. package/dist/ts/src/components/HydrationWrapper.d.ts +18 -0
  29. package/dist/ts/src/components/HydrationWrapper.d.ts.map +1 -0
  30. package/dist/ts/src/components/HydrationWrapper.js +22 -0
  31. package/dist/ts/src/components/HydrationWrapper.js.map +1 -0
  32. package/dist/ts/src/components/RenderWithFragments.d.ts +27 -0
  33. package/dist/ts/src/components/RenderWithFragments.d.ts.map +1 -0
  34. package/dist/ts/src/components/RenderWithFragments.js +133 -0
  35. package/dist/ts/src/components/RenderWithFragments.js.map +1 -0
  36. package/dist/ts/src/components/RenderWithHydration.d.ts +21 -0
  37. package/dist/ts/src/components/RenderWithHydration.d.ts.map +1 -0
  38. package/dist/ts/src/components/RenderWithHydration.js +39 -0
  39. package/dist/ts/src/components/RenderWithHydration.js.map +1 -0
  40. package/dist/ts/src/components.d.ts +4 -0
  41. package/dist/ts/src/components.d.ts.map +1 -0
  42. package/dist/ts/src/components.js +4 -0
  43. package/dist/ts/src/components.js.map +1 -0
  44. package/dist/ts/src/discovery/astro-frontmatter.d.ts +18 -0
  45. package/dist/ts/src/discovery/astro-frontmatter.d.ts.map +1 -0
  46. package/dist/ts/src/discovery/astro-frontmatter.js +25 -0
  47. package/dist/ts/src/discovery/astro-frontmatter.js.map +1 -0
  48. package/dist/ts/src/discovery/discover.d.ts +43 -0
  49. package/dist/ts/src/discovery/discover.d.ts.map +1 -0
  50. package/dist/ts/src/discovery/discover.js +87 -0
  51. package/dist/ts/src/discovery/discover.js.map +1 -0
  52. package/dist/ts/src/discovery/extract-props-ts.d.ts +41 -0
  53. package/dist/ts/src/discovery/extract-props-ts.d.ts.map +1 -0
  54. package/dist/ts/src/discovery/extract-props-ts.js +232 -0
  55. package/dist/ts/src/discovery/extract-props-ts.js.map +1 -0
  56. package/dist/ts/src/discovery/merge-registry.d.ts +58 -0
  57. package/dist/ts/src/discovery/merge-registry.d.ts.map +1 -0
  58. package/dist/ts/src/discovery/merge-registry.js +333 -0
  59. package/dist/ts/src/discovery/merge-registry.js.map +1 -0
  60. package/dist/ts/src/discovery/registry-endpoint.d.ts +27 -0
  61. package/dist/ts/src/discovery/registry-endpoint.d.ts.map +1 -0
  62. package/dist/ts/src/discovery/registry-endpoint.js +76 -0
  63. package/dist/ts/src/discovery/registry-endpoint.js.map +1 -0
  64. package/dist/ts/src/discovery/scan-components.d.ts +94 -0
  65. package/dist/ts/src/discovery/scan-components.d.ts.map +1 -0
  66. package/dist/ts/src/discovery/scan-components.js +397 -0
  67. package/dist/ts/src/discovery/scan-components.js.map +1 -0
  68. package/dist/ts/src/discovery/scan-mdx.d.ts +63 -0
  69. package/dist/ts/src/discovery/scan-mdx.d.ts.map +1 -0
  70. package/dist/ts/src/discovery/scan-mdx.js +113 -0
  71. package/dist/ts/src/discovery/scan-mdx.js.map +1 -0
  72. package/dist/ts/src/discovery/scan-overrides.d.ts +71 -0
  73. package/dist/ts/src/discovery/scan-overrides.d.ts.map +1 -0
  74. package/dist/ts/src/discovery/scan-overrides.js +34 -0
  75. package/dist/ts/src/discovery/scan-overrides.js.map +1 -0
  76. package/dist/ts/src/editor-descriptors.d.ts +31 -0
  77. package/dist/ts/src/editor-descriptors.d.ts.map +1 -0
  78. package/dist/ts/src/editor-descriptors.js +84 -0
  79. package/dist/ts/src/editor-descriptors.js.map +1 -0
  80. package/dist/ts/src/handlers/collection-content-api.d.ts +32 -0
  81. package/dist/ts/src/handlers/collection-content-api.d.ts.map +1 -0
  82. package/dist/ts/src/handlers/collection-content-api.js +166 -0
  83. package/dist/ts/src/handlers/collection-content-api.js.map +1 -0
  84. package/dist/ts/src/handlers/page-render-core.d.ts +137 -0
  85. package/dist/ts/src/handlers/page-render-core.d.ts.map +1 -0
  86. package/dist/ts/src/handlers/page-render-core.js +315 -0
  87. package/dist/ts/src/handlers/page-render-core.js.map +1 -0
  88. package/dist/ts/src/hydration.d.ts +4 -0
  89. package/dist/ts/src/hydration.d.ts.map +1 -0
  90. package/dist/ts/src/hydration.js +5 -0
  91. package/dist/ts/src/hydration.js.map +1 -0
  92. package/dist/ts/src/index.d.ts +21 -0
  93. package/dist/ts/src/index.d.ts.map +1 -0
  94. package/dist/ts/src/index.js +45 -0
  95. package/dist/ts/src/index.js.map +1 -0
  96. package/dist/ts/src/internal/declared-collections.d.ts +30 -0
  97. package/dist/ts/src/internal/declared-collections.d.ts.map +1 -0
  98. package/dist/ts/src/internal/declared-collections.js +84 -0
  99. package/dist/ts/src/internal/declared-collections.js.map +1 -0
  100. package/dist/ts/src/internal/page-collection-schema.d.ts +44 -0
  101. package/dist/ts/src/internal/page-collection-schema.d.ts.map +1 -0
  102. package/dist/ts/src/internal/page-collection-schema.js +152 -0
  103. package/dist/ts/src/internal/page-collection-schema.js.map +1 -0
  104. package/dist/ts/src/lib/content-config-guard.d.ts +11 -0
  105. package/dist/ts/src/lib/content-config-guard.d.ts.map +1 -0
  106. package/dist/ts/src/lib/content-config-guard.js +41 -0
  107. package/dist/ts/src/lib/content-config-guard.js.map +1 -0
  108. package/dist/ts/src/lib/hydration-scanner.d.ts +47 -0
  109. package/dist/ts/src/lib/hydration-scanner.d.ts.map +1 -0
  110. package/dist/ts/src/lib/hydration-scanner.js +136 -0
  111. package/dist/ts/src/lib/hydration-scanner.js.map +1 -0
  112. package/dist/{lib/hydration-script.d.mts → ts/src/lib/hydration-script.d.ts} +7 -10
  113. package/dist/ts/src/lib/hydration-script.d.ts.map +1 -0
  114. package/dist/ts/src/lib/hydration-script.js +89 -0
  115. package/dist/ts/src/lib/hydration-script.js.map +1 -0
  116. package/dist/ts/src/lib/hydration-utils.d.ts +51 -0
  117. package/dist/ts/src/lib/hydration-utils.d.ts.map +1 -0
  118. package/dist/ts/src/lib/hydration-utils.js +84 -0
  119. package/dist/ts/src/lib/hydration-utils.js.map +1 -0
  120. package/dist/ts/src/lib/resolve-locale.d.ts +15 -0
  121. package/dist/ts/src/lib/resolve-locale.d.ts.map +1 -0
  122. package/dist/ts/src/lib/resolve-locale.js +16 -0
  123. package/dist/ts/src/lib/resolve-locale.js.map +1 -0
  124. package/dist/ts/src/lib/resolve-site-name.d.ts +8 -0
  125. package/dist/ts/src/lib/resolve-site-name.d.ts.map +1 -0
  126. package/dist/ts/src/lib/resolve-site-name.js +12 -0
  127. package/dist/ts/src/lib/resolve-site-name.js.map +1 -0
  128. package/dist/ts/src/lib/route-utils.d.ts +61 -0
  129. package/dist/ts/src/lib/route-utils.d.ts.map +1 -0
  130. package/dist/ts/src/lib/route-utils.js +96 -0
  131. package/dist/ts/src/lib/route-utils.js.map +1 -0
  132. package/dist/ts/src/lib/routing-config.d.ts +38 -0
  133. package/dist/ts/src/lib/routing-config.d.ts.map +1 -0
  134. package/dist/ts/src/lib/routing-config.js +106 -0
  135. package/dist/ts/src/lib/routing-config.js.map +1 -0
  136. package/dist/ts/src/lib/serialize-props.d.ts +6 -0
  137. package/dist/ts/src/lib/serialize-props.d.ts.map +1 -0
  138. package/dist/ts/src/lib/serialize-props.js +8 -0
  139. package/dist/ts/src/lib/serialize-props.js.map +1 -0
  140. package/dist/ts/src/lib/unknown-components.d.ts +21 -0
  141. package/dist/ts/src/lib/unknown-components.d.ts.map +1 -0
  142. package/dist/ts/src/lib/unknown-components.js +49 -0
  143. package/dist/ts/src/lib/unknown-components.js.map +1 -0
  144. package/dist/ts/src/lib/virtual-module-generators.d.ts +33 -0
  145. package/dist/ts/src/lib/virtual-module-generators.d.ts.map +1 -0
  146. package/dist/ts/src/lib/virtual-module-generators.js +51 -0
  147. package/dist/ts/src/lib/virtual-module-generators.js.map +1 -0
  148. package/dist/{withHydration-HIvO9ysY.d.mts → ts/src/lib/withHydration.d.ts} +7 -11
  149. package/dist/ts/src/lib/withHydration.d.ts.map +1 -0
  150. package/dist/ts/src/lib/withHydration.js +50 -0
  151. package/dist/ts/src/lib/withHydration.js.map +1 -0
  152. package/dist/ts/src/loader.d.ts +27 -0
  153. package/dist/ts/src/loader.d.ts.map +1 -0
  154. package/dist/ts/src/loader.js +118 -0
  155. package/dist/ts/src/loader.js.map +1 -0
  156. package/dist/ts/src/locales-helpers.d.ts +61 -0
  157. package/dist/ts/src/locales-helpers.d.ts.map +1 -0
  158. package/dist/ts/src/locales-helpers.js +50 -0
  159. package/dist/ts/src/locales-helpers.js.map +1 -0
  160. package/dist/ts/src/mime-types.d.ts +3 -0
  161. package/dist/ts/src/mime-types.d.ts.map +1 -0
  162. package/dist/ts/src/mime-types.js +20 -0
  163. package/dist/ts/src/mime-types.js.map +1 -0
  164. package/dist/ts/src/page-feed.d.ts +13 -0
  165. package/dist/ts/src/page-feed.d.ts.map +1 -0
  166. package/dist/ts/src/page-feed.js +20 -0
  167. package/dist/ts/src/page-feed.js.map +1 -0
  168. package/dist/ts/src/page-schemas.d.ts +6 -0
  169. package/dist/ts/src/page-schemas.d.ts.map +1 -0
  170. package/dist/ts/src/page-schemas.js +6 -0
  171. package/dist/ts/src/page-schemas.js.map +1 -0
  172. package/dist/ts/src/path-validation.d.ts +8 -0
  173. package/dist/ts/src/path-validation.d.ts.map +1 -0
  174. package/dist/ts/src/path-validation.js +13 -0
  175. package/dist/ts/src/path-validation.js.map +1 -0
  176. package/dist/ts/src/plugin-spa.d.ts +182 -0
  177. package/dist/ts/src/plugin-spa.d.ts.map +1 -0
  178. package/dist/ts/src/plugin-spa.js +1165 -0
  179. package/dist/ts/src/plugin-spa.js.map +1 -0
  180. package/dist/ts/src/puck-manifest/components-endpoint.d.ts +30 -0
  181. package/dist/ts/src/puck-manifest/components-endpoint.d.ts.map +1 -0
  182. package/dist/ts/src/puck-manifest/components-endpoint.js +54 -0
  183. package/dist/ts/src/puck-manifest/components-endpoint.js.map +1 -0
  184. package/dist/ts/src/puck-manifest/field-projection.d.ts +91 -0
  185. package/dist/ts/src/puck-manifest/field-projection.d.ts.map +1 -0
  186. package/dist/ts/src/puck-manifest/field-projection.js +422 -0
  187. package/dist/ts/src/puck-manifest/field-projection.js.map +1 -0
  188. package/dist/ts/src/puck-manifest/index.d.ts +4 -0
  189. package/dist/ts/src/puck-manifest/index.d.ts.map +1 -0
  190. package/dist/ts/src/puck-manifest/index.js +3 -0
  191. package/dist/ts/src/puck-manifest/index.js.map +1 -0
  192. package/dist/ts/src/puck-manifest/literal.d.ts +163 -0
  193. package/dist/ts/src/puck-manifest/literal.d.ts.map +1 -0
  194. package/dist/ts/src/puck-manifest/literal.js +354 -0
  195. package/dist/ts/src/puck-manifest/literal.js.map +1 -0
  196. package/dist/ts/src/puck-manifest/read-config.d.ts +42 -0
  197. package/dist/ts/src/puck-manifest/read-config.d.ts.map +1 -0
  198. package/dist/ts/src/puck-manifest/read-config.js +517 -0
  199. package/dist/ts/src/puck-manifest/read-config.js.map +1 -0
  200. package/dist/ts/src/puck-manifest/read-field.d.ts +7 -0
  201. package/dist/ts/src/puck-manifest/read-field.d.ts.map +1 -0
  202. package/dist/ts/src/puck-manifest/read-field.js +11 -0
  203. package/dist/ts/src/puck-manifest/read-field.js.map +1 -0
  204. package/dist/ts/src/puck-manifest/read-wrapper.d.ts +147 -0
  205. package/dist/ts/src/puck-manifest/read-wrapper.d.ts.map +1 -0
  206. package/dist/ts/src/puck-manifest/read-wrapper.js +889 -0
  207. package/dist/ts/src/puck-manifest/read-wrapper.js.map +1 -0
  208. package/dist/ts/src/puck-manifest/reading-budget.d.ts +50 -0
  209. package/dist/ts/src/puck-manifest/reading-budget.d.ts.map +1 -0
  210. package/dist/ts/src/puck-manifest/reading-budget.js +113 -0
  211. package/dist/ts/src/puck-manifest/reading-budget.js.map +1 -0
  212. package/dist/ts/src/puck-manifest/resolve-reference.d.ts +4 -0
  213. package/dist/ts/src/puck-manifest/resolve-reference.d.ts.map +1 -0
  214. package/dist/ts/src/puck-manifest/resolve-reference.js +4 -0
  215. package/dist/ts/src/puck-manifest/resolve-reference.js.map +1 -0
  216. package/dist/ts/src/puck-manifest/source-reference.d.ts +96 -0
  217. package/dist/ts/src/puck-manifest/source-reference.d.ts.map +1 -0
  218. package/dist/ts/src/puck-manifest/source-reference.js +424 -0
  219. package/dist/ts/src/puck-manifest/source-reference.js.map +1 -0
  220. package/dist/ts/src/puck-manifest/syntax.d.ts +29 -0
  221. package/dist/ts/src/puck-manifest/syntax.d.ts.map +1 -0
  222. package/dist/ts/src/puck-manifest/syntax.js +79 -0
  223. package/dist/ts/src/puck-manifest/syntax.js.map +1 -0
  224. package/dist/ts/src/puck-manifest/types.d.ts +145 -0
  225. package/dist/ts/src/puck-manifest/types.d.ts.map +1 -0
  226. package/dist/ts/src/puck-manifest/types.js +2 -0
  227. package/dist/ts/src/puck-manifest/types.js.map +1 -0
  228. package/dist/ts/src/safe-json-stringify.d.ts +13 -0
  229. package/dist/ts/src/safe-json-stringify.d.ts.map +1 -0
  230. package/dist/ts/src/safe-json-stringify.js +7 -0
  231. package/dist/ts/src/safe-json-stringify.js.map +1 -0
  232. package/dist/ts/src/sandbox-frame-handler.d.ts +19 -0
  233. package/dist/ts/src/sandbox-frame-handler.d.ts.map +1 -0
  234. package/dist/ts/src/sandbox-frame-handler.js +27 -0
  235. package/dist/ts/src/sandbox-frame-handler.js.map +1 -0
  236. package/dist/ts/src/site-styles/content-wrapper-endpoint.d.ts +73 -0
  237. package/dist/ts/src/site-styles/content-wrapper-endpoint.d.ts.map +1 -0
  238. package/dist/ts/src/site-styles/content-wrapper-endpoint.js +224 -0
  239. package/dist/ts/src/site-styles/content-wrapper-endpoint.js.map +1 -0
  240. package/dist/ts/src/site-styles/render-endpoint.d.ts +50 -0
  241. package/dist/ts/src/site-styles/render-endpoint.d.ts.map +1 -0
  242. package/dist/ts/src/site-styles/render-endpoint.js +264 -0
  243. package/dist/ts/src/site-styles/render-endpoint.js.map +1 -0
  244. package/dist/ts/src/site-styles/styles-endpoint.d.ts +59 -0
  245. package/dist/ts/src/site-styles/styles-endpoint.d.ts.map +1 -0
  246. package/dist/ts/src/site-styles/styles-endpoint.js +156 -0
  247. package/dist/ts/src/site-styles/styles-endpoint.js.map +1 -0
  248. package/dist/ts/src/sitemap-options.d.ts +21 -0
  249. package/dist/ts/src/sitemap-options.d.ts.map +1 -0
  250. package/dist/ts/src/sitemap-options.js +92 -0
  251. package/dist/ts/src/sitemap-options.js.map +1 -0
  252. package/dist/ts/src/tiptap-html-static.d.ts +15 -0
  253. package/dist/ts/src/tiptap-html-static.d.ts.map +1 -0
  254. package/dist/ts/src/tiptap-html-static.js +67 -0
  255. package/dist/ts/src/tiptap-html-static.js.map +1 -0
  256. package/dist/ts/src/types.d.ts +543 -0
  257. package/dist/ts/src/types.d.ts.map +1 -0
  258. package/dist/ts/src/types.js +2 -0
  259. package/dist/ts/src/types.js.map +1 -0
  260. package/dist/virtual-modules.d.ts +74 -0
  261. package/node/content.ts +14 -0
  262. package/node/index.ts +22 -0
  263. package/package.json +198 -56
  264. package/src/asset-ref-base.ts +48 -0
  265. package/src/checks.ts +10 -0
  266. package/src/cms-handler.ts +280 -0
  267. package/src/collections.ts +262 -0
  268. package/src/components/HydrationWrapper.tsx +41 -0
  269. package/src/components/RenderWithFragments.tsx +204 -0
  270. package/src/components/RenderWithHydration.tsx +55 -0
  271. package/src/components.ts +3 -0
  272. package/src/discovery/astro-frontmatter.ts +24 -0
  273. package/src/discovery/discover.ts +108 -0
  274. package/src/discovery/extract-props-ts.ts +255 -0
  275. package/src/discovery/merge-registry.ts +411 -0
  276. package/src/discovery/registry-endpoint.ts +80 -0
  277. package/src/discovery/scan-components.ts +458 -0
  278. package/src/discovery/scan-mdx.ts +190 -0
  279. package/src/discovery/scan-overrides.ts +92 -0
  280. package/src/editor-descriptors.ts +96 -0
  281. package/src/env.d.ts +31 -0
  282. package/src/handlers/collection-content-api.ts +196 -0
  283. package/src/handlers/page-handler.astro +320 -0
  284. package/src/handlers/page-render-core.ts +456 -0
  285. package/src/hydration.ts +7 -0
  286. package/src/index.ts +111 -0
  287. package/src/internal/acorn-default.mjs +37 -0
  288. package/src/internal/declared-collections.ts +98 -0
  289. package/src/internal/page-collection-schema.ts +210 -0
  290. package/src/lib/content-config-guard.ts +48 -0
  291. package/src/lib/hydration-scanner.ts +176 -0
  292. package/src/lib/hydration-script.ts +126 -0
  293. package/src/lib/hydration-utils.ts +120 -0
  294. package/src/lib/resolve-locale.ts +22 -0
  295. package/src/lib/resolve-site-name.ts +10 -0
  296. package/src/lib/route-utils.ts +106 -0
  297. package/src/lib/routing-config.ts +126 -0
  298. package/src/lib/serialize-props.ts +7 -0
  299. package/src/lib/unknown-components.ts +64 -0
  300. package/src/lib/virtual-module-generators.ts +58 -0
  301. package/src/lib/withHydration.ts +71 -0
  302. package/src/loader.ts +145 -0
  303. package/src/locales-helpers.ts +68 -0
  304. package/src/mime-types.ts +19 -0
  305. package/src/page-feed.ts +26 -0
  306. package/src/page-schemas.ts +19 -0
  307. package/src/path-validation.ts +13 -0
  308. package/src/plugin-spa.ts +1480 -0
  309. package/src/puck-manifest/components-endpoint.ts +55 -0
  310. package/src/puck-manifest/field-projection.ts +510 -0
  311. package/src/puck-manifest/index.ts +3 -0
  312. package/src/puck-manifest/literal.ts +459 -0
  313. package/src/puck-manifest/read-config.ts +577 -0
  314. package/src/puck-manifest/read-field.ts +19 -0
  315. package/src/puck-manifest/read-wrapper.ts +1056 -0
  316. package/src/puck-manifest/reading-budget.ts +127 -0
  317. package/src/puck-manifest/resolve-reference.ts +9 -0
  318. package/src/puck-manifest/source-reference.ts +484 -0
  319. package/src/puck-manifest/syntax.ts +104 -0
  320. package/src/puck-manifest/types.ts +139 -0
  321. package/src/safe-json-stringify.ts +17 -0
  322. package/src/sandbox-frame-handler.ts +31 -0
  323. package/src/site-styles/content-wrapper-endpoint.ts +327 -0
  324. package/src/site-styles/render-endpoint.ts +331 -0
  325. package/src/site-styles/styles-endpoint.ts +184 -0
  326. package/src/sitemap-options.ts +115 -0
  327. package/src/tiptap-html-static.ts +84 -0
  328. package/{dist/types-CVQNmPxF.d.mts → src/types.ts} +232 -79
  329. package/src/virtual-modules.d.ts +74 -0
  330. package/dist/collections.d.mts +0 -36
  331. package/dist/collections.d.mts.map +0 -1
  332. package/dist/collections.mjs +0 -65
  333. package/dist/collections.mjs.map +0 -1
  334. package/dist/components.d.mts +0 -46
  335. package/dist/components.d.mts.map +0 -1
  336. package/dist/components.mjs +0 -226
  337. package/dist/components.mjs.map +0 -1
  338. package/dist/hydration-scanner-B0NjYkZ_.mjs +0 -109
  339. package/dist/hydration-scanner-B0NjYkZ_.mjs.map +0 -1
  340. package/dist/hydration.d.mts +0 -4
  341. package/dist/hydration.mjs +0 -3
  342. package/dist/index.d.mts +0 -139
  343. package/dist/index.d.mts.map +0 -1
  344. package/dist/index.mjs +0 -66
  345. package/dist/index.mjs.map +0 -1
  346. package/dist/internal/cms-handler.d.mts +0 -26
  347. package/dist/internal/cms-handler.d.mts.map +0 -1
  348. package/dist/internal/cms-handler.mjs +0 -267
  349. package/dist/internal/cms-handler.mjs.map +0 -1
  350. package/dist/lib/hydration-script.d.mts.map +0 -1
  351. package/dist/lib/hydration-script.mjs +0 -85
  352. package/dist/lib/hydration-script.mjs.map +0 -1
  353. package/dist/loader-By-AQWHc.mjs +0 -68
  354. package/dist/loader-By-AQWHc.mjs.map +0 -1
  355. package/dist/node/content.d.mts +0 -19
  356. package/dist/node/content.d.mts.map +0 -1
  357. package/dist/node/content.mjs +0 -4
  358. package/dist/node/index.d.mts +0 -52
  359. package/dist/node/index.d.mts.map +0 -1
  360. package/dist/node/index.mjs +0 -753
  361. package/dist/node/index.mjs.map +0 -1
  362. package/dist/serialize-props-Dhv_MnkY.mjs +0 -73
  363. package/dist/serialize-props-Dhv_MnkY.mjs.map +0 -1
  364. package/dist/types-CVQNmPxF.d.mts.map +0 -1
  365. package/dist/withHydration-EzyzBQ-Y.mjs +0 -49
  366. package/dist/withHydration-EzyzBQ-Y.mjs.map +0 -1
  367. package/dist/withHydration-HIvO9ysY.d.mts.map +0 -1
@@ -0,0 +1,145 @@
1
+ import type { JsonValue } from '@conloca/content-api';
2
+ export type { JsonValue };
3
+ /**
4
+ * Machine-readable description of a site's Puck config, read from source
5
+ * without executing it. Consumed by agents that edit a site's content and have
6
+ * no checkout — they need to know what components exist and what each accepts
7
+ * before they can compose a page.
8
+ */
9
+ export interface PuckManifest {
10
+ components: Record<string, ManifestComponent>;
11
+ /**
12
+ * Page-level fields from the config's `root`. `fieldsUnreadable` means what
13
+ * it means on a component: some of the set could not be read, the entries
14
+ * listed are the ones it provably declares, and any other prop may exist.
15
+ */
16
+ root?: {
17
+ fields: Record<string, ManifestField>;
18
+ fieldsUnreadable?: true;
19
+ };
20
+ /** Sidebar grouping, as declared in `categories`. */
21
+ categories?: Record<string, {
22
+ title?: string;
23
+ components: string[];
24
+ }>;
25
+ /**
26
+ * Some of `categories` could not be read: the value as a whole, a category
27
+ * whose name or entry is written in a shape this reader cannot follow, or a
28
+ * title or component list it could not take. The categories listed are ones
29
+ * the config provably declares, with their components; others may exist,
30
+ * and a listed one may carry a title that is missing here.
31
+ */
32
+ categoriesUnreadable?: true;
33
+ /** Components named in `components` whose definition could not be resolved. */
34
+ unresolved: string[];
35
+ /**
36
+ * Why a name in `unresolved` could not be followed, where a reason is known —
37
+ * e.g. "the function is async, so the call returns a promise rather than a
38
+ * component". Diagnostic prose for humans
39
+ * and doctors, not a contract: keys are a subset of `unresolved`.
40
+ */
41
+ unresolvedReasons?: Record<string, string>;
42
+ /**
43
+ * The config may declare components this manifest cannot name. With no
44
+ * components listed, the names are unknown altogether: the file cannot be
45
+ * opened, it exports no object, its component map is written in a shape
46
+ * this reader cannot follow, or reading it — or sending what it reads — would
47
+ * cost more than the reader allows. The empty manifest is an admission, not
48
+ * a site that declares no components. With components listed, those are provably
49
+ * declared, and a spread, a computed name or a prototype this reader cannot
50
+ * follow may add others.
51
+ */
52
+ unreadable?: true;
53
+ /**
54
+ * Why `unreadable` is set, beside every one. With no components listed: its
55
+ * file could not be opened, it or a file it loads does not parse, it has no
56
+ * default export, its
57
+ * default export or its components map is not an object this reader can
58
+ * read, or reading it — or the manifest it makes — would cost more than the
59
+ * reader allows. With components listed: the write in the components map
60
+ * that may add others. Written for the site's developer; prose, not a
61
+ * contract.
62
+ */
63
+ unreadableReason?: string;
64
+ }
65
+ export interface ManifestComponent {
66
+ label?: string;
67
+ fields: Record<string, ManifestField>;
68
+ defaultProps?: Record<string, JsonValue>;
69
+ /** Puck's own agent annotations, copied verbatim. */
70
+ ai?: JsonValue;
71
+ /**
72
+ * Some of the `fields` value could not be followed — a getter, a call, a
73
+ * name leading nowhere, or a spread or computed key inside the set that may
74
+ * add or replace any entry. A name that DOES lead somewhere is followed, so
75
+ * this marks what stayed unknown rather than merely what was named. The
76
+ * entries listed above are the ones the set provably declares — none, when
77
+ * the value as a whole was unreadable — and any other prop may exist too.
78
+ */
79
+ fieldsUnreadable?: true;
80
+ /**
81
+ * Keys the source writes that could not be read, in whole or in part —
82
+ * `label: makeLabel()`, a `defaultProps` entry computed at runtime, a
83
+ * computed key that may have replaced any of them. Such a key is absent from
84
+ * this entry, or carries only the part that did read; what is missing is
85
+ * unknown rather than absent. `fields` has `fieldsUnreadable` instead.
86
+ *
87
+ * A behaviour key listed here — `resolveFields`, `resolveData`,
88
+ * `resolvePermissions` — is one a computed key this reader cannot name may
89
+ * have written or erased, so whether its marker below applies cannot be
90
+ * read, and the marker is left off.
91
+ */
92
+ unreadableKeys?: ('label' | 'defaultProps' | 'ai' | 'resolveFields' | 'resolveData' | 'resolvePermissions')[];
93
+ /** Field list is computed at render (`resolveFields`); the read list is a superset. */
94
+ dynamicFields?: true;
95
+ /** Props may be overwritten at render (`resolveData`). */
96
+ derivedProps?: true;
97
+ /** Placement or cardinality limited by `resolvePermissions` — the rule itself is code and unreadable. */
98
+ hasPlacementRules?: true;
99
+ }
100
+ export interface ManifestField {
101
+ type: string;
102
+ label?: string;
103
+ /** `radio` / `select` choices. */
104
+ options?: Array<{
105
+ label: JsonValue;
106
+ value: JsonValue;
107
+ }>;
108
+ /** `array` item fields. */
109
+ arrayFields?: Record<string, ManifestField>;
110
+ /** `object` sub-fields. */
111
+ objectFields?: Record<string, ManifestField>;
112
+ /** Value bounds on a `number` field; item-count bounds on an `array` field. */
113
+ min?: number;
114
+ max?: number;
115
+ /** `slot` nesting rules — what may and may not be dropped inside. */
116
+ allow?: string[];
117
+ disallow?: string[];
118
+ ai?: JsonValue;
119
+ /** A `custom` or `external` field with no `ai.schema`: nothing can infer its shape. */
120
+ opaque?: true;
121
+ /**
122
+ * Some part of this field is written in a shape this reader cannot follow: a
123
+ * function (`defaultItemProps: () => …`), a spread leading nowhere, a key it
124
+ * cannot name (`[key]: …`), a prototype set with `__proto__`, a name whose
125
+ * declaration could not be reached (`options: buildOptions()`), or an
126
+ * options list that is not `{ label, value }` pairs. A plain name IS
127
+ * followed — `options: sizeOptions` and the shorthand `{ options }` read the
128
+ * list, and a spread of a written-down source merges — so this marks what
129
+ * stayed unknown, not merely what was named. Whatever is missing from the
130
+ * properties above is unknown, not absent, and a write this reader could not
131
+ * name takes every value read before it.
132
+ *
133
+ * On a `slot` it stands for rules written somewhere this reader does not
134
+ * look: Puck takes `allow`/`disallow` from the field or from the slot the
135
+ * component's `render` draws, so a slot writing neither here has nesting
136
+ * rules that are unknown rather than none.
137
+ *
138
+ * Beside `type: 'unknown'` it says something stronger: the entry is not a
139
+ * field declaration this reader could recognise at all — nothing it or its
140
+ * spreads write mentions a type — so the prop is named and nothing about its
141
+ * shape is claimed.
142
+ */
143
+ unreadable?: true;
144
+ }
145
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/puck-manifest/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,YAAY,EAAE,SAAS,EAAE,CAAC;AAE1B;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAC9C;;;;OAIG;IACH,IAAI,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;QAAC,gBAAgB,CAAC,EAAE,IAAI,CAAA;KAAE,CAAC;IAC1E,qDAAqD;IACrD,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAC;IACtE;;;;;;OAMG;IACH,oBAAoB,CAAC,EAAE,IAAI,CAAC;I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C;IAC7C,+EAA+E;IAC/E,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,qEAAqE;IACrE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,EAAE,CAAC,EAAE,SAAS,CAAC;IACf,uFAAuF;IACvF,MAAM,CAAC,EAAE,IAAI,CAAC;IACd;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,UAAU,CAAC,EAAE,IAAI,CAAC;CACnB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/puck-manifest/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * JSON.stringify replacement that escapes characters dangerous in HTML script contexts.
3
+ *
4
+ * When embedding JSON in `<script>` tags, characters like `<`, `>`, `&`, and `'` can break
5
+ * out of the script context (e.g., `</script>` closes the tag prematurely). This function
6
+ * replaces those characters with their Unicode escape equivalents, which are valid in both
7
+ * JSON and JavaScript string contexts.
8
+ *
9
+ * @see https://cheatsheetseries.owasp.org/cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.html
10
+ */
11
+ export declare function safeJsonStringify(data: Record<string, unknown> | unknown[] | string | number | boolean | null): string;
12
+ export declare function safeJsonStringify(data: unknown): string | undefined;
13
+ //# sourceMappingURL=safe-json-stringify.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safe-json-stringify.d.ts","sourceRoot":"","sources":["../../../src/safe-json-stringify.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,EAAE,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,MAAM,CAAC;AACxH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC"}
@@ -0,0 +1,7 @@
1
+ export function safeJsonStringify(data) {
2
+ const json = JSON.stringify(data);
3
+ if (json === undefined)
4
+ return undefined;
5
+ return json.replace(/[<>&']/g, (ch) => `\\u${ch.charCodeAt(0).toString(16).padStart(4, '0')}`);
6
+ }
7
+ //# sourceMappingURL=safe-json-stringify.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safe-json-stringify.js","sourceRoot":"","sources":["../../../src/safe-json-stringify.ts"],"names":[],"mappings":"AAYA,MAAM,UAAU,iBAAiB,CAAC,IAAa;IAC7C,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAClC,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACzC,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;AACjG,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type { APIRoute } from 'astro';
2
+ /**
3
+ * GET /api/v1/mdx/sandbox-frame — the opaque-origin iframe document that
4
+ * ContentSandbox loads for MDX fragment previews (canvas chips, fragment
5
+ * editor live preview).
6
+ *
7
+ * The path is root-absolute by contract: `SANDBOX_FRAME_PATH` in
8
+ * `@conloca/mdx` is what the editor requests wherever it runs, so anything
9
+ * that serves the editor must serve this path too. astro-cms routes otherwise
10
+ * live under the cmsRoute prefix, so without this route the frame 404s and
11
+ * chips render the site's 404 page. Response headers are the frame's contract
12
+ * (`SANDBOX_FRAME_CSP`); any other server of the frame must match them.
13
+ *
14
+ * No auth gate: the document is static boilerplate — content only ever enters
15
+ * the frame via postMessage from the editor.
16
+ */
17
+ export declare const prerender = false;
18
+ export declare const GET: APIRoute;
19
+ //# sourceMappingURL=sandbox-frame-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sandbox-frame-handler.d.ts","sourceRoot":"","sources":["../../../src/sandbox-frame-handler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtC;;;;;;;;;;;;;;GAcG;AAEH,eAAO,MAAM,SAAS,QAAQ,CAAC;AAE/B,eAAO,MAAM,GAAG,EAAE,QASd,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { buildSandboxSrcdoc, SANDBOX_FRAME_CSP } from '@conloca/mdx/sandbox-frame';
2
+ /**
3
+ * GET /api/v1/mdx/sandbox-frame — the opaque-origin iframe document that
4
+ * ContentSandbox loads for MDX fragment previews (canvas chips, fragment
5
+ * editor live preview).
6
+ *
7
+ * The path is root-absolute by contract: `SANDBOX_FRAME_PATH` in
8
+ * `@conloca/mdx` is what the editor requests wherever it runs, so anything
9
+ * that serves the editor must serve this path too. astro-cms routes otherwise
10
+ * live under the cmsRoute prefix, so without this route the frame 404s and
11
+ * chips render the site's 404 page. Response headers are the frame's contract
12
+ * (`SANDBOX_FRAME_CSP`); any other server of the frame must match them.
13
+ *
14
+ * No auth gate: the document is static boilerplate — content only ever enters
15
+ * the frame via postMessage from the editor.
16
+ */
17
+ export const prerender = false;
18
+ export const GET = () => new Response(buildSandboxSrcdoc(), {
19
+ status: 200,
20
+ headers: {
21
+ 'content-type': 'text/html; charset=utf-8',
22
+ 'content-security-policy': `${SANDBOX_FRAME_CSP}; frame-ancestors 'self'`,
23
+ 'x-content-type-options': 'nosniff',
24
+ 'cache-control': 'no-store',
25
+ },
26
+ });
27
+ //# sourceMappingURL=sandbox-frame-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sandbox-frame-handler.js","sourceRoot":"","sources":["../../../src/sandbox-frame-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAGnF;;;;;;;;;;;;;;GAcG;AAEH,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,CAAC;AAE/B,MAAM,CAAC,MAAM,GAAG,GAAa,GAAG,EAAE,CAChC,IAAI,QAAQ,CAAC,kBAAkB,EAAE,EAAE;IACjC,MAAM,EAAE,GAAG;IACX,OAAO,EAAE;QACP,cAAc,EAAE,0BAA0B;QAC1C,yBAAyB,EAAE,GAAG,iBAAiB,0BAA0B;QACzE,wBAAwB,EAAE,SAAS;QACnC,eAAe,EAAE,UAAU;KAC5B;CACF,CAAC,CAAC"}
@@ -0,0 +1,73 @@
1
+ import type { Connect } from 'vite';
2
+ /**
3
+ * Per-route content-wrapper discovery endpoint.
4
+ *
5
+ * The editor mirrors the host's content surface by rendering its
6
+ * contenteditable inside a clone of whatever element the host wraps
7
+ * its page content in. This endpoint fetches the live HTML the dev
8
+ * server serves at `?url=<route>`, locates the relevant wrappers
9
+ * (prose content + code-block chrome), and returns them as JSON.
10
+ *
11
+ * Returned shape:
12
+ *
13
+ * {
14
+ * content: { tagName, className } | null,
15
+ * codeBlock: { tagName, className }[] | null,
16
+ * }
17
+ *
18
+ * - `content` is the wrapper for prose (h1-h6, p, lists, etc.). The
19
+ * editor wraps its contenteditable in a clone so the host's prose
20
+ * CSS reaches via the cascade.
21
+ * - `codeBlock` is the ORDERED chain of classed wrappers around the
22
+ * host's `<pre>`, outermost first. For Starlight's expressive-code:
23
+ * `[{ div, 'expressive-code' }, { figure, 'frame has-title …' }]`.
24
+ * The editor's CodeMirror frame renders each link as a nested
25
+ * element (outer→inner) so the host's code-block CSS reaches via
26
+ * the cascade including descendant selectors (`.expressive-code
27
+ * .frame .header`, etc.) — not just single-class targets.
28
+ *
29
+ * Discovery priorities (content):
30
+ *
31
+ * 1. `[data-conloca-content-root]` — explicit opt-in.
32
+ * 2. The smallest classed wrapper inside `<main>` containing the
33
+ * majority of prose tags.
34
+ * 3. `<main>` itself.
35
+ * 4. `null`.
36
+ *
37
+ * Discovery (codeBlock): walk up from a `<pre>` inside `<main>` and
38
+ * collect classed ancestors between the content wrapper and `<pre>`,
39
+ * preserving their nesting order. Returns null when no `<pre>` exists,
40
+ * or when there are no classed wrappers between the prose wrapper and
41
+ * the `<pre>`.
42
+ */
43
+ export interface ContentWrapperInfo {
44
+ /** Lower-case HTML tag name as it appeared in source, eg `'article'`. */
45
+ tagName: string;
46
+ /** Space-separated class list from the source element. Preserved
47
+ * verbatim so Astro-scoped hashes (`astro-e3flfouy`) survive — host
48
+ * scoped CSS only matches when those hashes are present on the
49
+ * element. */
50
+ className: string;
51
+ }
52
+ export interface DiscoveredWrappers {
53
+ /** The element wrapping the page's prose content (h1-h6, p, etc.).
54
+ * For Starlight: `.sl-markdown-content`. For Tailwind Typography:
55
+ * `.prose`. Null when no prose wrapper exists on the page. */
56
+ content: ContentWrapperInfo | null;
57
+ /** Ordered chain of classed wrappers between the content wrapper
58
+ * and the `<pre>`, outermost first. For Starlight:
59
+ * `[{ div, 'expressive-code' }, { figure, 'frame has-title …' }]`.
60
+ * Null when the page has no code blocks or no classed wrappers
61
+ * between the prose wrapper and the `<pre>`. */
62
+ codeBlock: ContentWrapperInfo[] | null;
63
+ }
64
+ export declare function createContentWrapperEndpoint(): Connect.NextHandleFunction;
65
+ /**
66
+ * Locate the host's content + code-block wrappers in raw HTML. Single-
67
+ * pass regex walk with a stack so we can recover ancestor chains for
68
+ * both prose tags and `<pre>` tags without a full DOM parser dep.
69
+ *
70
+ * Exported for unit testing.
71
+ */
72
+ export declare function findContentWrapper(html: string): DiscoveredWrappers;
73
+ //# sourceMappingURL=content-wrapper-endpoint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-wrapper-endpoint.d.ts","sourceRoot":"","sources":["../../../../src/site-styles/content-wrapper-endpoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAM,WAAW,kBAAkB;IACjC,yEAAyE;IACzE,OAAO,EAAE,MAAM,CAAC;IAChB;;;kBAGc;IACd,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,kBAAkB;IACjC;;kEAE8D;IAC9D,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACnC;;;;oDAIgD;IAChD,SAAS,EAAE,kBAAkB,EAAE,GAAG,IAAI,CAAC;CACxC;AAED,wBAAgB,4BAA4B,IAAI,OAAO,CAAC,kBAAkB,CA+BzE;AAuCD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,CAsEnE"}
@@ -0,0 +1,224 @@
1
+ export function createContentWrapperEndpoint() {
2
+ return async (req, res, _next) => {
3
+ try {
4
+ const parsed = new URL(req.url ?? '', 'http://localhost');
5
+ const routeUrl = parsed.searchParams.get('url');
6
+ if (!routeUrl) {
7
+ res.statusCode = 400;
8
+ res.setHeader('content-type', 'text/plain');
9
+ res.end('Missing required query parameter: url');
10
+ return;
11
+ }
12
+ const host = req.headers.host ?? 'localhost:4321';
13
+ const protocol = req.headers['x-forwarded-proto'] ?? 'http';
14
+ const liveUrl = `${protocol}://${host}${routeUrl}`;
15
+ const html = await fetch(liveUrl, {
16
+ headers: req.headers.cookie ? { cookie: req.headers.cookie } : undefined,
17
+ }).then((r) => r.text());
18
+ const wrappers = findContentWrapper(html);
19
+ res.statusCode = 200;
20
+ res.setHeader('content-type', 'application/json; charset=utf-8');
21
+ res.setHeader('cache-control', 'no-store');
22
+ res.end(JSON.stringify(wrappers));
23
+ }
24
+ catch (err) {
25
+ res.statusCode = 500;
26
+ res.setHeader('content-type', 'text/plain');
27
+ res.end(`Content-wrapper discovery failed: ${err instanceof Error ? err.message : String(err)}`);
28
+ }
29
+ };
30
+ }
31
+ /** Tags whose presence signals "this element holds prose content."
32
+ * We walk up from the first such element we find inside `<main>` to
33
+ * locate the wrapper. Headings + paragraphs cover every prose-styling
34
+ * convention we've seen — every CSS framework scopes typography
35
+ * through descendant selectors on `h1`–`h6` and `p`. */
36
+ const PROSE_TAGS = new Set(['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p']);
37
+ /** Tag that anchors code-block wrapper discovery. The host's code-
38
+ * block library (Starlight's expressive-code, Tailwind's `pre`
39
+ * styling, etc.) always renders a `<pre>` containing the code,
40
+ * often wrapped in additional classed elements. */
41
+ const CODE_BLOCK_ANCHOR = 'pre';
42
+ /** HTML5 void elements — never push onto the open-tag stack since they
43
+ * have no closing tag. */
44
+ const VOID_TAGS = new Set([
45
+ 'area',
46
+ 'base',
47
+ 'br',
48
+ 'col',
49
+ 'embed',
50
+ 'hr',
51
+ 'img',
52
+ 'input',
53
+ 'link',
54
+ 'meta',
55
+ 'source',
56
+ 'track',
57
+ 'wbr',
58
+ ]);
59
+ /**
60
+ * Locate the host's content + code-block wrappers in raw HTML. Single-
61
+ * pass regex walk with a stack so we can recover ancestor chains for
62
+ * both prose tags and `<pre>` tags without a full DOM parser dep.
63
+ *
64
+ * Exported for unit testing.
65
+ */
66
+ export function findContentWrapper(html) {
67
+ // Strip comments and scripts so opening-tag-shaped strings inside
68
+ // them don't pollute the walk.
69
+ const cleaned = html
70
+ .replace(/<!--[\s\S]*?-->/g, '')
71
+ .replace(/<script[\s\S]*?<\/script>/gi, '')
72
+ .replace(/<style[\s\S]*?<\/style>/gi, '');
73
+ const tagRe = /<(\/?)([a-zA-Z][a-zA-Z0-9-]*)((?:\s+[^>]*)?)\s*(\/?)>/g;
74
+ const stack = [];
75
+ let explicit = null;
76
+ let mainEl = null;
77
+ const proseAncestorChains = [];
78
+ const preAncestorChains = [];
79
+ for (const match of cleaned.matchAll(tagRe)) {
80
+ const isClose = match[1] === '/';
81
+ const tagName = match[2].toLowerCase();
82
+ const attrBlob = match[3] ?? '';
83
+ const explicitlySelfClosing = match[4] === '/';
84
+ if (isClose) {
85
+ for (let i = stack.length - 1; i >= 0; i--) {
86
+ if (stack[i].tag === tagName) {
87
+ stack.length = i;
88
+ break;
89
+ }
90
+ }
91
+ continue;
92
+ }
93
+ const attrs = parseAttributes(attrBlob);
94
+ const className = attrs.class ?? '';
95
+ const el = { tag: tagName, className, attrs };
96
+ // Priority 1 (content only): explicit opt-in. Capture and keep
97
+ // walking — we still need to discover the code-block wrapper.
98
+ if (!explicit && 'data-conloca-content-root' in attrs) {
99
+ explicit = { tagName, className };
100
+ }
101
+ if (!mainEl && tagName === 'main') {
102
+ mainEl = el;
103
+ }
104
+ if (mainEl && PROSE_TAGS.has(tagName)) {
105
+ const mainIdx = stack.indexOf(mainEl);
106
+ if (mainIdx >= 0) {
107
+ proseAncestorChains.push(stack.slice(mainIdx + 1));
108
+ }
109
+ }
110
+ if (mainEl && tagName === CODE_BLOCK_ANCHOR) {
111
+ const mainIdx = stack.indexOf(mainEl);
112
+ if (mainIdx >= 0) {
113
+ preAncestorChains.push(stack.slice(mainIdx + 1));
114
+ }
115
+ }
116
+ const isVoid = VOID_TAGS.has(tagName);
117
+ if (!isVoid && !explicitlySelfClosing) {
118
+ stack.push(el);
119
+ }
120
+ }
121
+ const content = resolveContentWrapper(explicit, mainEl, proseAncestorChains);
122
+ const codeBlock = resolveCodeBlockWrapper(content, preAncestorChains);
123
+ return { content, codeBlock };
124
+ }
125
+ /**
126
+ * Pick the content wrapper from the walk's collected data.
127
+ *
128
+ * Priority: explicit opt-in > majority-prose-wrapper-inside-main >
129
+ * `<main>` fallback > null.
130
+ */
131
+ function resolveContentWrapper(explicit, mainEl, proseAncestorChains) {
132
+ if (explicit)
133
+ return explicit;
134
+ if (!mainEl)
135
+ return null;
136
+ if (proseAncestorChains.length === 0) {
137
+ return { tagName: 'main', className: mainEl.className };
138
+ }
139
+ // Tally classed-ancestor occurrences across all prose chains.
140
+ const scores = new Map();
141
+ for (const chain of proseAncestorChains) {
142
+ for (const ancestor of chain) {
143
+ if (!ancestor.className)
144
+ continue;
145
+ scores.set(ancestor, (scores.get(ancestor) ?? 0) + 1);
146
+ }
147
+ }
148
+ // Majority threshold rules out partial-coverage classed ancestors
149
+ // (single Cards holding one of many prose blocks).
150
+ const threshold = proseAncestorChains.length / 2;
151
+ const candidates = [...scores.entries()].filter(([, count]) => count > threshold);
152
+ if (candidates.length === 0) {
153
+ return { tagName: 'main', className: mainEl.className };
154
+ }
155
+ // Tie-break by depth: the candidate that appears deepest in any
156
+ // chain is the most specific (closest to the prose tags).
157
+ const maxChainIndex = (el) => Math.max(...proseAncestorChains.map((c) => c.indexOf(el)));
158
+ candidates.sort((a, b) => {
159
+ if (b[1] !== a[1])
160
+ return b[1] - a[1];
161
+ return maxChainIndex(b[0]) - maxChainIndex(a[0]);
162
+ });
163
+ const winner = candidates[0][0];
164
+ return { tagName: winner.tag, className: winner.className };
165
+ }
166
+ /**
167
+ * Derive the code-block wrapper chain from a representative `<pre>`'s
168
+ * ancestor chain. We strip everything at or above the content wrapper
169
+ * (its styles are already handled by the content-wrapper mirror) and
170
+ * return the remaining classed elements in nesting order, outermost
171
+ * first.
172
+ *
173
+ * Returning a chain (instead of one collapsed element) preserves the
174
+ * shape host CSS expects:
175
+ *
176
+ * - Single-class selectors (`.frame { ... }`) hit on whichever link
177
+ * carries that class.
178
+ * - Descendant selectors (`.expressive-code .frame { ... }`,
179
+ * `.frame .header > .title`) hit because the editor's renderer
180
+ * materialises the chain as nested elements with the host's
181
+ * expected tag names.
182
+ *
183
+ * The editor's code-block frame component (`code-block-frame.tsx` in
184
+ * `@conloca/mdx`) treats the LAST link as the "frame" element (where
185
+ * figcaption/pre/copy children render) and wraps it with the earlier
186
+ * links from inside out. This matches the host's authoring shape for
187
+ * libraries like ExpressiveCode (`.expressive-code > figure.frame >
188
+ * figcaption + pre + .copy`).
189
+ */
190
+ function resolveCodeBlockWrapper(content, preAncestorChains) {
191
+ if (preAncestorChains.length === 0)
192
+ return null;
193
+ // Pick the first <pre>'s chain as representative. Code blocks on a
194
+ // single page are uniformly wrapped, so chains are interchangeable.
195
+ const chain = preAncestorChains[0];
196
+ // Strip everything at-or-above the content wrapper; the rest is
197
+ // code-block-specific chrome that this endpoint is responsible for.
198
+ const contentIdx = content
199
+ ? chain.findIndex((el) => el.tag === content.tagName && el.className === content.className)
200
+ : -1;
201
+ const codeBlockChain = chain.slice(contentIdx + 1);
202
+ const classedAncestors = codeBlockChain.filter((el) => el.className);
203
+ if (classedAncestors.length === 0)
204
+ return null;
205
+ return classedAncestors.map((el) => ({ tagName: el.tag, className: el.className }));
206
+ }
207
+ /**
208
+ * Parse the attribute blob inside an opening tag. Handles `name="v"`,
209
+ * `name='v'`, `name=v`, and boolean (no-value) attributes. Doesn't
210
+ * handle entity decoding (`&amp;` → `&`) since the values we read
211
+ * (tag name, class list, the marker attribute) don't carry entities
212
+ * in practice.
213
+ */
214
+ function parseAttributes(s) {
215
+ const out = {};
216
+ const re = /([a-zA-Z_:][-a-zA-Z0-9_:.]*)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|(\S+)))?/g;
217
+ for (const match of s.matchAll(re)) {
218
+ const name = match[1];
219
+ const value = match[2] ?? match[3] ?? match[4] ?? '';
220
+ out[name] = value;
221
+ }
222
+ return out;
223
+ }
224
+ //# sourceMappingURL=content-wrapper-endpoint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-wrapper-endpoint.js","sourceRoot":"","sources":["../../../../src/site-styles/content-wrapper-endpoint.ts"],"names":[],"mappings":"AAkEA,MAAM,UAAU,4BAA4B;IAC1C,OAAO,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE;QAC/B,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,EAAE,kBAAkB,CAAC,CAAC;YAC1D,MAAM,QAAQ,GAAG,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACh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C,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;QACnC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACtB,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QACrD,GAAG,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;IACpB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,50 @@
1
+ import type { Connect } from 'vite';
2
+ interface ViteModuleLoader {
3
+ ssrLoadModule(url: string): Promise<unknown>;
4
+ }
5
+ /**
6
+ * Vite middleware that renders an MDX JSX subtree to HTML on demand.
7
+ *
8
+ * Container components (CardGrid, Tabs, …) have JSX children that on
9
+ * the published page render as direct DOM children of the parent —
10
+ * positional CSS (`:nth-child` colour cycling on Card grids, CSS-grid
11
+ * placement) depends on that DOM shape. Per-block isolated rendering
12
+ * breaks both: each child gets its own wrapper, and the parent's only
13
+ * direct child is a slot marker.
14
+ *
15
+ * This endpoint renders a recursive tree: each node provides its
16
+ * component name + source + props, optionally with its own `children`
17
+ * tree. The server renders leaves first and assembles parents by
18
+ * passing rendered children HTML as the parent's default slot, so the
19
+ * final markup matches what Astro would emit for the same MDX
20
+ * source — same DOM, same CSS context.
21
+ *
22
+ * Request shape (JSON body):
23
+ * {
24
+ * tree: {
25
+ * component: string,
26
+ * source: string,
27
+ * defaultExport?: boolean,
28
+ * props?: Record<string, unknown>,
29
+ * slotId: string,
30
+ * children?: RenderTreeNode[]
31
+ * },
32
+ * documentIndex?: number // wraps top-level output to fix
33
+ * // sibling-position CSS for root-level
34
+ * // blocks (see phantom-sibling fix).
35
+ * }
36
+ *
37
+ * Legacy shape (kept for backward compatibility):
38
+ * { component, source, defaultExport?, props?, documentIndex? }
39
+ *
40
+ * For each node, the rendered slot content is either:
41
+ * - The concatenated HTML of recursively-rendered children, if any.
42
+ * - `<conloca-slot data-slot-id="<id>"></conloca-slot>` placeholder
43
+ * otherwise (the SPA portals a Lexical editor into it).
44
+ *
45
+ * Returns 200 with `Content-Type: text/html` on success; 4xx with a
46
+ * plain-text error otherwise.
47
+ */
48
+ export declare function createRenderEndpoint(server: ViteModuleLoader, getAllowedSources: () => Promise<Set<string>>): Connect.NextHandleFunction;
49
+ export {};
50
+ //# sourceMappingURL=render-endpoint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-endpoint.d.ts","sourceRoot":"","sources":["../../../../src/site-styles/render-endpoint.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAEpC,UAAU,gBAAgB;IACxB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC9C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,gBAAgB,EACxB,iBAAiB,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAC5C,OAAO,CAAC,kBAAkB,CA4F5B"}