@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
@@ -4,9 +4,15 @@ import { fileURLToPath } from 'node:url';
4
4
  import { readSitesConfig } from '@conloca/content-api/node';
5
5
  import viteReact from '@vitejs/plugin-react';
6
6
  import { searchForWorkspaceRoot } from 'vite';
7
+ import { deriveAssetRefBase } from './asset-ref-base.js';
7
8
  import { createRegistryEndpoint } from './discovery/registry-endpoint.js';
9
+ import { EDITOR_DESCRIPTORS_ENV_VAR } from './editor-descriptors.js';
10
+ import { CONTENT_CONFIG_SNIPPET, findContentConfigProblem } from './lib/content-config-guard.js';
8
11
  import { deriveComponentPaths, scanForHydratableComponents } from './lib/hydration-scanner.js';
9
- import { normalizeRoutingConfig, resolveRouteConfig } from './lib/routing-config.js';
12
+ import { resolveLocale } from './lib/resolve-locale.js';
13
+ import { resolveSiteName } from './lib/resolve-site-name.js';
14
+ import { normalizeRoutingConfig, resolveRouteConfig, toEditorDataBindings } from './lib/routing-config.js';
15
+ import { createComponentsEndpoint, endpointReaderOptions } from './puck-manifest/components-endpoint.js';
10
16
  import { createContentWrapperEndpoint } from './site-styles/content-wrapper-endpoint.js';
11
17
  import { createRenderEndpoint } from './site-styles/render-endpoint.js';
12
18
  import { createStylesEndpoint } from './site-styles/styles-endpoint.js';
@@ -20,31 +26,46 @@ if (typeof viteReact.preambleCode !== 'string') {
20
26
  'Check @vitejs/plugin-react release notes and update the preamble injection logic.');
21
27
  }
22
28
  const reactRefreshPreamble = viteReact.preambleCode.replace('__BASE__', '/');
23
- // Get the directory of this module to resolve page-handler.astro
24
- // Works from both src/ (dev) and dist/ (published) since build copies the file
29
+ // The preamble is served as a module of its own rather than pasted into each
30
+ // dev virtual module below. A module's static imports all evaluate before its
31
+ // own body runs, so inlined preamble statements always lose to the cms-spa
32
+ // import underneath them — and cms-spa's built entries are plain `.js`, which
33
+ // Vite's React plugin rewrites with Fast Refresh, throwing on evaluation while
34
+ // `window.$RefreshReg$` is still unset. Imported first, the preamble wins.
35
+ const VIRTUAL_REFRESH_PREAMBLE = 'virtual:conloca-react-refresh-preamble';
36
+ const RESOLVED_REFRESH_PREAMBLE = `\0${VIRTUAL_REFRESH_PREAMBLE}`;
37
+ // Get the directory of this module to resolve the copied handler assets.
38
+ // Compiled, this file sits in dist/ts/src/, the copied Astro handler in
39
+ // dist/internal/, and the emitted handler modules right next to this file.
25
40
  const __dirname = dirname(fileURLToPath(import.meta.url));
26
- const PAGE_HANDLER_PATH = join(__dirname, '..', 'internal', 'page-handler.astro');
27
- const CMS_HANDLER_PATH = join(__dirname, '..', 'internal', 'cms-handler.mjs');
28
- const ACORN_DEFAULT_SHIM_PATH = join(__dirname, '..', 'internal', 'acorn-default.mjs');
29
- import { generateLayoutModule, generatePageApiModule, generatePuckConfigModule, generateRoutingConfigModule, } from './lib/virtual-module-generators.js';
41
+ const PAGE_HANDLER_PATH = join(__dirname, '..', '..', 'internal', 'page-handler.astro');
42
+ const CMS_HANDLER_PATH = join(__dirname, 'cms-handler.js');
43
+ const SANDBOX_FRAME_HANDLER_PATH = join(__dirname, 'sandbox-frame-handler.js');
44
+ const ACORN_DEFAULT_SHIM_PATH = join(__dirname, '..', '..', 'internal', 'acorn-default.mjs');
45
+ const TIPTAP_HTML_SHIM_PATH = join(__dirname, 'tiptap-html-static.js');
46
+ import { generateLayoutModule, generatePuckConfigModule, generateRoutingConfigModule, } from './lib/virtual-module-generators.js';
30
47
  // Virtual module for passing config from plugin to route handler
31
48
  const VIRTUAL_CONFIG_MODULE = 'virtual:conloca-config';
32
49
  const RESOLVED_VIRTUAL_CONFIG = `\0${VIRTUAL_CONFIG_MODULE}`;
33
50
  // Virtual module IDs for routing system
34
51
  const VIRTUAL_ROUTING_CONFIG = 'virtual:conloca-routing-config';
35
52
  const VIRTUAL_LAYOUT = 'virtual:conloca-layout';
36
- const VIRTUAL_PAGE_API = 'virtual:conloca-page-api';
37
53
  const VIRTUAL_PUCK_CONFIG = 'virtual:conloca-puck-config';
38
54
  // Resolved IDs (with \0 prefix to prevent file resolution)
39
55
  const RESOLVED_ROUTING_CONFIG = `\0${VIRTUAL_ROUTING_CONFIG}`;
40
56
  const RESOLVED_LAYOUT = `\0${VIRTUAL_LAYOUT}`;
41
- const RESOLVED_PAGE_API = `\0${VIRTUAL_PAGE_API}`;
42
57
  const RESOLVED_PUCK_CONFIG = `\0${VIRTUAL_PUCK_CONFIG}`;
43
58
  // Virtual modules for hydration system
44
59
  const VIRTUAL_HYDRATION_REGISTRY = 'virtual:conloca-hydration-registry';
45
60
  const VIRTUAL_HYDRATION_ENTRY = 'virtual:conloca-hydration-entry';
46
61
  const RESOLVED_HYDRATION_REGISTRY = `\0${VIRTUAL_HYDRATION_REGISTRY}`;
47
62
  const RESOLVED_HYDRATION_ENTRY = `\0${VIRTUAL_HYDRATION_ENTRY}`;
63
+ /** Vite payloads whose browser-side effects would overwrite the editor's own save update. */
64
+ function dropsEditorSaveUpdate(payload) {
65
+ if (payload.type === 'full-reload')
66
+ return true;
67
+ return payload.type === 'custom' && payload.event === 'conloca:content-update';
68
+ }
48
69
  // Virtual module for CMS SPA source loading (dev only)
49
70
  const VIRTUAL_CMS_SPA_ENTRY = 'virtual:conloca-cms-spa-entry';
50
71
  const RESOLVED_CMS_SPA_ENTRY = `\0${VIRTUAL_CMS_SPA_ENTRY}`;
@@ -73,10 +94,10 @@ export default {};
73
94
  const puckConfigLoader = (absolutePuckPath, cmsSpaDistDir) => {
74
95
  // We need to ensure the preamble executes before ANY module evaluation
75
96
  // So we'll use a dynamic import after the preamble is set up
76
- const puckConfigImport = cmsSpaDistDir ? `${cmsSpaDistDir}/puck-config.mjs` : '@conloca/cms-spa/puck-config';
97
+ const puckConfigImport = cmsSpaDistDir ? `${cmsSpaDistDir}/ts/puck-config.js` : '@conloca/cms-spa/puck-config';
77
98
  return `
78
- // Import and execute React refresh preamble first (from @vitejs/plugin-react)
79
- ${reactRefreshPreamble}
99
+ // React refresh preamble first — it must be the first import, see its module
100
+ import '${VIRTUAL_REFRESH_PREAMBLE}';
80
101
 
81
102
  // Import the setPuckConfig function from cms-spa
82
103
  import { setPuckConfig } from '${puckConfigImport}';
@@ -110,19 +131,23 @@ export default puckConfigPromise.then(m => m.default);
110
131
  };
111
132
  // Template for the schemas loader virtual module
112
133
  const schemasLoader = (absoluteSchemasPath, cmsSpaDistDir) => {
113
- const pageSchemasImport = cmsSpaDistDir ? `${cmsSpaDistDir}/page-schemas.mjs` : '@conloca/cms-spa/page-schemas';
114
- const mdxComponentsImport = cmsSpaDistDir ? `${cmsSpaDistDir}/mdx-components.mjs` : '@conloca/cms-spa/mdx-components';
134
+ const pageSchemasImport = cmsSpaDistDir ? `${cmsSpaDistDir}/ts/page-schemas.js` : '@conloca/cms-spa/page-schemas';
135
+ const mdxComponentsImport = cmsSpaDistDir
136
+ ? `${cmsSpaDistDir}/ts/mdx-components.js`
137
+ : '@conloca/cms-spa/mdx-components';
138
+ const dataSchemasImport = cmsSpaDistDir ? `${cmsSpaDistDir}/ts/data-schemas.js` : '@conloca/cms-spa/data-schemas';
115
139
  // The host's schemas file may transitively import React components (the
116
140
  // `Editor` field on an MdxComponentDescriptor can be a JSX/TSX
117
- // component). Vite's React plugin requires the Fast Refresh preamble to
118
- // run before any TSX module is evaluated, so we emit it here and then
119
- // dynamically import the schemas file — matching the pattern used by
120
- // the Puck config loader above.
141
+ // component), and so does cms-spa's own mdx-components entry. Vite's React
142
+ // plugin requires the Fast Refresh preamble to run before any such module
143
+ // is evaluated, so we import it first and then dynamically import the
144
+ // schemas file — matching the pattern used by the Puck config loader above.
121
145
  return `
122
- ${reactRefreshPreamble}
146
+ import '${VIRTUAL_REFRESH_PREAMBLE}';
123
147
 
124
148
  import { setPageSchemas } from '${pageSchemasImport}';
125
- import { setMdxComponents } from '${mdxComponentsImport}';
149
+ import { installHostAuthoredMdxComponents } from '${mdxComponentsImport}';
150
+ import { setDataSchemas } from '${dataSchemasImport}';
126
151
 
127
152
  const schemasPromise = import('${absoluteSchemasPath}');
128
153
 
@@ -131,7 +156,13 @@ schemasPromise.then((schemas) => {
131
156
  setPageSchemas(schemas.pageSchemas);
132
157
  }
133
158
  if (schemas.mdxComponents) {
134
- setMdxComponents(schemas.mdxComponents);
159
+ // Slotted installer, not setMdxComponents: this module and the SPA's
160
+ // /api/registry fetch settle in either order, and a bare set from the
161
+ // late one would overwrite the other's components.
162
+ installHostAuthoredMdxComponents(schemas.mdxComponents);
163
+ }
164
+ if (schemas.dataSchemas) {
165
+ setDataSchemas(schemas.dataSchemas);
135
166
  }
136
167
  });
137
168
 
@@ -141,7 +172,10 @@ if (import.meta.hot) {
141
172
  setPageSchemas(newModule.pageSchemas);
142
173
  }
143
174
  if (newModule?.mdxComponents) {
144
- setMdxComponents(newModule.mdxComponents);
175
+ installHostAuthoredMdxComponents(newModule.mdxComponents);
176
+ }
177
+ if (newModule?.dataSchemas) {
178
+ setDataSchemas(newModule.dataSchemas);
145
179
  }
146
180
  });
147
181
  }
@@ -166,8 +200,9 @@ const siteStylesLoader = (cssPaths, cmsSpaDistDir) => {
166
200
  })
167
201
  .join('\n');
168
202
  const vars = cssPaths.map((_, i) => `css${i}`).join(', ');
169
- const siteStylesImport = cmsSpaDistDir ? `${cmsSpaDistDir}/site-styles.mjs` : '@conloca/cms-spa/site-styles';
203
+ const siteStylesImport = cmsSpaDistDir ? `${cmsSpaDistDir}/ts/site-styles.js` : '@conloca/cms-spa/site-styles';
170
204
  return `
205
+ import '${VIRTUAL_REFRESH_PREAMBLE}';
171
206
  ${imports}
172
207
  import { setSiteStyles } from '${siteStylesImport}';
173
208
 
@@ -193,8 +228,9 @@ const editorStylesLoader = (cssPaths, cmsSpaDistDir) => {
193
228
  })
194
229
  .join('\n');
195
230
  const vars = cssPaths.map((_, i) => `css${i}`).join(', ');
196
- const siteStylesImport = cmsSpaDistDir ? `${cmsSpaDistDir}/site-styles.mjs` : '@conloca/cms-spa/site-styles';
231
+ const siteStylesImport = cmsSpaDistDir ? `${cmsSpaDistDir}/ts/site-styles.js` : '@conloca/cms-spa/site-styles';
197
232
  return `
233
+ import '${VIRTUAL_REFRESH_PREAMBLE}';
198
234
  ${imports}
199
235
  import { setEditorStyles } from '${siteStylesImport}';
200
236
 
@@ -207,6 +243,18 @@ if (import.meta.hot) {
207
243
  export default {};
208
244
  `;
209
245
  };
246
+ /**
247
+ * Whether a resolved package directory came from the registry rather than from
248
+ * a workspace. @conloca/cms-spa ships its sources so source maps resolve, so
249
+ * the files on disk no longer tell the two apart — the location does. Node
250
+ * resolves symlinks, so a registry install always sits under a node_modules
251
+ * directory (hoisted `<consumer>/node_modules/@conloca/cms-spa`, or isolated
252
+ * `…/node_modules/.bun/…/node_modules/@conloca/cms-spa`), while a workspace
253
+ * package or a cross-repo `bun link` resolves to its own checkout.
254
+ */
255
+ export function isRegistryInstall(packageDir) {
256
+ return packageDir.split(/[\\/]/).includes('node_modules');
257
+ }
210
258
  export function conlocaCMS(options) {
211
259
  const cmsRoute = options.route || '/__cms';
212
260
  // Resolve @conloca/cms-spa package directory for absolute imports in virtual
@@ -238,6 +286,10 @@ export function conlocaCMS(options) {
238
286
  });
239
287
  // Build resolved routing config with all defaults applied
240
288
  let resolvedRoutingConfig;
289
+ // The site's final output mode, read at config:done because integrations
290
+ // that run after this one may still switch it. The duplicate-route-name check
291
+ // below keys on it.
292
+ let outputMode;
241
293
  if (routingConfig?.enabled !== false && routingConfig) {
242
294
  const resolvedRoutes = {};
243
295
  for (const [name, config] of Object.entries(routingConfig.routes || {})) {
@@ -248,6 +300,10 @@ export function conlocaCMS(options) {
248
300
  routes: resolvedRoutes,
249
301
  fallback: routingConfig.fallback ?? '404',
250
302
  onConflict: routingConfig.onConflict ?? 'warn',
303
+ // Both provisional. sites.json cannot be read here — integration
304
+ // construction is synchronous — so `astro:config:setup` below
305
+ // re-resolves them against the declared sites before any consumer
306
+ // loads. See `resolveSiteName` and `resolveLocale`.
251
307
  siteName: routingConfig.siteName ?? 'default',
252
308
  locale: routingConfig.locale ?? 'en',
253
309
  };
@@ -262,6 +318,9 @@ export function conlocaCMS(options) {
262
318
  const spaConfig = {
263
319
  basename: cmsRoute,
264
320
  apiBaseUrl: `${cmsRoute}/api`,
321
+ // The media surfaces' thumbnails, served by the content API under the
322
+ // same route; the editor's own default only covers a CMS at /__cms.
323
+ assetsBasePath: `${cmsRoute}/api/assets/serve`,
265
324
  siteBaseUrl: options.siteBaseUrl,
266
325
  enableDevtools: options.enableDevtools ?? true,
267
326
  queryClientOptions: options.queryClientOptions,
@@ -275,7 +334,8 @@ export function conlocaCMS(options) {
275
334
  // Forward the locale list so the SPA stops hardcoding en/nl/fr in
276
335
  // the create-page dialog. The integration receives this from the
277
336
  // top-level `locales` option, which can in turn be produced by
278
- // `localesFromAstroI18n` / `localesFromStarlight`.
337
+ // `localesFromAstroI18n` / `localesFromStarlight`; without it the
338
+ // `astro:config:setup` hook fills it from sites.json.
279
339
  locales: options.locales ? { list: options.locales.list, defaultLocale: options.locales.defaultLocale } : undefined,
280
340
  };
281
341
  // Resolved mdxPages path, populated from sites.json in the
@@ -283,17 +343,62 @@ export function conlocaCMS(options) {
283
343
  // watcher. `null` means no site declares an `mdxPages` path — .mdx
284
344
  // files (if any) fall back to living alongside Puck pages.
285
345
  let resolvedMdxPages = null;
346
+ // One root for every path this plugin resolves against, so a scan and an
347
+ // endpoint can never disagree about where the project is.
348
+ const projectRoot = process.cwd();
349
+ // Registry scan inputs, resolved ONCE: the dev endpoint below and anything
350
+ // that reads them off the descriptor channel must never disagree about which
351
+ // folders and content root were scanned.
352
+ // `contentRoot` is re-pointed at sites.json's `mdxPages` in config:setup,
353
+ // once that file has been read.
354
+ let registryScan = {
355
+ contentRoot: options.contentRoot,
356
+ componentFolders: options.mdxComponentFolders ?? ['src/components/mdx'],
357
+ projectRoot,
358
+ };
286
359
  let refreshConlocaContent;
287
360
  return {
288
361
  name: '@conloca/astro-cms',
289
362
  hooks: {
290
- 'astro:config:setup': async ({ updateConfig, injectRoute, command, logger }) => {
363
+ 'astro:config:setup': async ({ config, updateConfig, injectRoute, command, logger }) => {
364
+ // Publish the content root for createConlocaCollections(): the
365
+ // content config loads later in this same process, so the contentRoot
366
+ // configured here is the single source of truth. Raw on purpose —
367
+ // FileSystemContentAPI keys its process-wide index cache on the
368
+ // string as-passed, and the dev content watcher uses the raw option;
369
+ // resolving here would split one cache into two and dev refreshes
370
+ // would read stale content.
371
+ process.env.CONLOCA_CONTENT_ROOT = options.contentRoot;
291
372
  // Read sites.json — the canonical home for per-site config
292
373
  // including the optional `mdxPages` field. Reading it here (once,
293
374
  // at integration setup) gives us a single source of truth for
294
375
  // the rest of the hook. `readSitesConfig` returns a safe default
295
376
  // when the file is missing or malformed.
296
377
  const sitesConfig = await readSitesConfig(options.contentRoot);
378
+ // Now that sites.json is known, replace the provisional site name and
379
+ // locale built at construction time. Resolving from the raw options
380
+ // (not the already-defaulted resolved config) is what makes the
381
+ // sites.json fallbacks reachable. Every consumer — the routing
382
+ // virtual module, the editor's data bindings below, and
383
+ // `astro:routes:resolved` — reads them after this, so they all
384
+ // observe the resolved values.
385
+ const siteName = resolveSiteName(routingConfig?.siteName, sitesConfig.sites);
386
+ const locale = resolveLocale(routingConfig?.locale, options.locales?.defaultLocale, siteName, sitesConfig);
387
+ if (resolvedRoutingConfig) {
388
+ resolvedRoutingConfig.siteName = siteName;
389
+ resolvedRoutingConfig.locale = locale;
390
+ }
391
+ // Without the `locales` option the editor offers the site's own
392
+ // languages from sites.json — the list the server checks a new page
393
+ // against — starting from the locale the site renders. Left unset, the
394
+ // editor guessed English: a site in any other language could not
395
+ // create a page, and its new fragments were never rendered.
396
+ if (!options.locales) {
397
+ spaConfig.locales = {
398
+ list: sitesConfig.sites[siteName]?.locales ?? sitesConfig.globalLocales,
399
+ defaultLocale: locale,
400
+ };
401
+ }
297
402
  // Pick the first site that declares an `mdxPages` path. Today's
298
403
  // integration supports a single `mdxPages` per project;
299
404
  // multi-site `mdxPages` is a future expansion (would require
@@ -301,9 +406,61 @@ export function conlocaCMS(options) {
301
406
  const firstSiteWithMdxPages = Object.values(sitesConfig.sites).find((s) => s?.mdxPages);
302
407
  resolvedMdxPages = firstSiteWithMdxPages?.mdxPages ?? null;
303
408
  spaConfig.mdxPagesEnabled = Boolean(resolvedMdxPages);
409
+ // The editor builds each page's data context in the browser from
410
+ // these, the same bindings the published page resolves with.
411
+ spaConfig.dataBindings = resolvedRoutingConfig?.enabled
412
+ ? toEditorDataBindings(resolvedRoutingConfig)
413
+ : undefined;
414
+ registryScan = { ...registryScan, contentRoot: resolvedMdxPages ?? options.contentRoot };
415
+ // Publish the resolved editor descriptors for other integrations in
416
+ // this build (see EDITOR_DESCRIPTORS_ENV_VAR): they read the same
417
+ // descriptors dev loads from `schemasPath`, `/api/registry` and
418
+ // `virtual:conloca-config` instead of taking these options again.
419
+ // schemasPath is absolutized because a reader may use it as an import
420
+ // specifier.
421
+ const editorDescriptors = {
422
+ ...(options.schemasPath ? { schemasPath: resolve(options.schemasPath) } : {}),
423
+ registry: registryScan,
424
+ ...(options.templates ? { templates: options.templates } : {}),
425
+ ...(spaConfig.dataBindings ? { dataBindings: spaConfig.dataBindings } : {}),
426
+ };
427
+ process.env[EDITOR_DESCRIPTORS_ENV_VAR] = JSON.stringify(editorDescriptors);
304
428
  // Auto-inject fs.allow for external contentRoot (dev mode only)
305
429
  const astroRoot = process.cwd();
306
430
  const contentAbsolute = resolve(options.contentRoot);
431
+ // A missing content root used to produce an empty site that 404'd
432
+ // every page with no hint. Fail the build loudly; in dev (and sync)
433
+ // only warn — a brand-new project boots with an empty site and the
434
+ // CMS creates the directory on first save.
435
+ if (!existsSync(contentAbsolute)) {
436
+ const hint = `Content root not found: ${contentAbsolute}. Create the directory ` +
437
+ '(git cannot track empty folders — add a .gitkeep) or fix contentRoot in conlocaCMS().';
438
+ if (command === 'build') {
439
+ throw new Error(`[Conloca] ${hint}`);
440
+ }
441
+ logger.warn(`${hint} Starting with an empty site.`);
442
+ }
443
+ // A content config that never declares Conloca collections yields
444
+ // an empty Astro collection, so the injected route resolves nothing
445
+ // and every page 404s with no other symptom. Astro exposes no hook
446
+ // that reveals resolved collections, so check the file itself.
447
+ const contentConfigProblem = findContentConfigProblem(astroRoot);
448
+ if (contentConfigProblem) {
449
+ const cause = contentConfigProblem === 'missing'
450
+ ? 'No content config found.'
451
+ : 'Your content config does not declare Conloca collections.';
452
+ const hint = `${cause} Conloca pages will 404 until it does. Add this:\n\n${CONTENT_CONFIG_SNIPPET}\n`;
453
+ if (command === 'build') {
454
+ throw new Error(`[Conloca] ${hint}`);
455
+ }
456
+ logger.warn(hint);
457
+ }
458
+ // Every image the editor picks is stored under this base and served
459
+ // as-is by the published site. Derived in build too, so a media
460
+ // folder the site cannot serve fails there as well as in dev.
461
+ if (options.assetsPath) {
462
+ spaConfig.assetRefBase = deriveAssetRefBase(options.assetsPath, config.publicDir, config.base);
463
+ }
307
464
  if (command === 'dev' && !contentAbsolute.startsWith(astroRoot)) {
308
465
  logger.info(`Auto-allowing contentRoot in Vite fs.allow: ${options.contentRoot}`);
309
466
  updateConfig({
@@ -351,7 +508,27 @@ export function conlocaCMS(options) {
351
508
  // package's node_modules and must NOT be forced to resolve from the
352
509
  // consumer root (which would fail).
353
510
  dedupe: ['react', 'react-dom', 'react/jsx-runtime', 'react/jsx-dev-runtime'],
511
+ alias: [
512
+ // Puck's richtext field render imports @tiptap/html. Its browser
513
+ // build throws off-browser ("generateHTML can only be used in a
514
+ // browser environment"), and its /server build fakes a browser
515
+ // with happy-dom — whose Window constructor reaches for
516
+ // node:vm's Script.runInContext, a stub on workerd, so every
517
+ // richtext section died there with "The 'contextifiedObject'
518
+ // argument must be an vm.Context". Both specifiers resolve to a
519
+ // shim that writes the markup as a string, with no DOM and no
520
+ // vm, so the same output comes out on every engine. The alias
521
+ // reaches the editor in the browser too, and the field stores
522
+ // HTML, so the shim also reads it back: with the browser's own
523
+ // parser there, with linkedom on the server.
524
+ { find: /^@tiptap\/html(\/server)?$/, replacement: TIPTAP_HTML_SHIM_PATH },
525
+ ],
354
526
  },
527
+ // react-dom@19 ships ./server as CJS under the workerd exports
528
+ // condition; without pre-bundling, the Cloudflare adapter's type-gen
529
+ // phase evaluates it raw in workerd ("require is not defined").
530
+ // Inert for Node builds.
531
+ optimizeDeps: { include: ['react-dom/server'] },
355
532
  // Virtual modules for routing - needed in both dev and build
356
533
  plugins: [
357
534
  // Public page rendering should use Puck's server entry, not the full editor.
@@ -366,14 +543,15 @@ export function conlocaCMS(options) {
366
543
  return null;
367
544
  },
368
545
  },
369
- // Alias acorn to a CJS shim only during SSR (static page builds).
370
- // Must NOT apply to the browser bundle — the shim uses createRequire
371
- // which is Node.js-only and crashes in the browser.
546
+ // Alias acorn to a default+named shim only during SSR (page
547
+ // builds). Must NOT apply to the browser bundle, and must NOT
548
+ // apply to the shim's own `import ... from 'acorn'` — that
549
+ // static import has to reach the real package, not recurse.
372
550
  {
373
551
  name: 'conloca-acorn-ssr-alias',
374
552
  enforce: 'pre',
375
- resolveId(id, _importer, options) {
376
- if (id === 'acorn' && options?.ssr) {
553
+ resolveId(id, importer, options) {
554
+ if (id === 'acorn' && options?.ssr && !importer?.endsWith('acorn-default.mjs')) {
377
555
  return ACORN_DEFAULT_SHIM_PATH;
378
556
  }
379
557
  return null;
@@ -463,6 +641,23 @@ initHydration(componentRegistry)
463
641
  });
464
642
  }
465
643
  }
644
+ // The sandbox frame document ContentSandbox loads for MDX previews.
645
+ // Root-absolute by contract (SANDBOX_FRAME_PATH in @conloca/mdx) and
646
+ // needed wherever the editor runs — anything that serves the editor
647
+ // serves the same path. Injected outside the dev-only block: a
648
+ // production editor build needs the frame too.
649
+ //
650
+ // On-demand by necessity — the response carries the sandbox CSP, which
651
+ // a prerendered file cannot — so injecting it into a fully static site
652
+ // fails that build with NoAdapterInstalled. Such a site has no runtime
653
+ // editor to serve it to; dev serves it whatever the output mode.
654
+ if (command === 'dev' || config.output !== 'static') {
655
+ injectRoute({
656
+ pattern: '/api/v1/mdx/sandbox-frame',
657
+ entrypoint: SANDBOX_FRAME_HANDLER_PATH,
658
+ prerender: false,
659
+ });
660
+ }
466
661
  // Only inject CMS admin routes and dev-specific config in dev mode
467
662
  if (command !== 'dev')
468
663
  return;
@@ -478,10 +673,10 @@ initHydration(componentRegistry)
478
673
  // longer surfaced as env vars — the content-api reads them
479
674
  // directly from sites.json under `contentRoot` at request
480
675
  // time. See `readSitesConfig()` and `SitesConfig.sites[name].mdxPages`.
481
- // Default route URL the block editor uses for style /
482
- // wrapper discovery. See `blockPreviewRoute` option doc
676
+ // Default route URL the fragment editor uses for style /
677
+ // wrapper discovery. See `fragmentPreviewRoute` option doc
483
678
  // above. `/` is a sane fallback for most layouts.
484
- 'import.meta.env.CONLOCA_BLOCK_PREVIEW_ROUTE': JSON.stringify(options.blockPreviewRoute || '/'),
679
+ 'import.meta.env.CONLOCA_FRAGMENT_PREVIEW_ROUTE': JSON.stringify(options.fragmentPreviewRoute || '/'),
485
680
  // Raw CSS the host wants injected into the editor's
486
681
  // `conloca-host-preview` layer for visual overrides.
487
682
  // See `editorCSS` option doc above for use cases.
@@ -558,6 +753,9 @@ initHydration(componentRegistry)
558
753
  if (id === VIRTUAL_CONFIG_MODULE) {
559
754
  return RESOLVED_VIRTUAL_CONFIG;
560
755
  }
756
+ if (id === VIRTUAL_REFRESH_PREAMBLE) {
757
+ return RESOLVED_REFRESH_PREAMBLE;
758
+ }
561
759
  if (id === `${cmsRoute}/puck-entry.js`) {
562
760
  return id;
563
761
  }
@@ -573,9 +771,6 @@ initHydration(componentRegistry)
573
771
  if (id === `${cmsRoute}/editor-styles.js`) {
574
772
  return id;
575
773
  }
576
- if (id === VIRTUAL_PAGE_API) {
577
- return RESOLVED_PAGE_API;
578
- }
579
774
  if (id === VIRTUAL_CMS_SPA_ENTRY) {
580
775
  return RESOLVED_CMS_SPA_ENTRY;
581
776
  }
@@ -589,6 +784,9 @@ initHydration(componentRegistry)
589
784
  if (id === RESOLVED_VIRTUAL_CONFIG) {
590
785
  return `export default ${JSON.stringify(spaConfig)};`;
591
786
  }
787
+ if (id === RESOLVED_REFRESH_PREAMBLE) {
788
+ return reactRefreshPreamble;
789
+ }
592
790
  if (id === `${cmsRoute}/puck-entry.js`) {
593
791
  const absolutePuckPath = options.puckConfigPath.startsWith('.')
594
792
  ? `/${options.puckConfigPath.slice(2)}`
@@ -621,20 +819,12 @@ initHydration(componentRegistry)
621
819
  }
622
820
  return 'export default {};';
623
821
  }
624
- if (id === RESOLVED_PAGE_API) {
625
- return generatePageApiModule({
626
- contentRoot: options.contentRoot,
627
- canvasDir: options.canvasDir || './canvas',
628
- siteName: resolvedRoutingConfig?.siteName ?? 'default',
629
- locale: resolvedRoutingConfig?.locale ?? 'en',
630
- });
631
- }
632
822
  if (id === RESOLVED_CMS_SPA_ENTRY) {
633
- // Detect whether cms-spa source is available (workspace mode)
634
- // vs only dist/ (npm install). Reuses `cmsSpaDir` resolved
635
- // at plugin setup time.
823
+ // Detect whether cms-spa is a workspace checkout (import its
824
+ // source for HMR) or a registry install (import its built
825
+ // entry). Reuses `cmsSpaDir` resolved at plugin setup time.
636
826
  let cmsSpaImport;
637
- if (cmsSpaDir) {
827
+ if (cmsSpaDir && !isRegistryInstall(cmsSpaDir)) {
638
828
  const realSrcMainPath = join(cmsSpaDir, 'src', 'main.tsx');
639
829
  // Prefer the consumer-side symlink path when @conloca/cms-spa is
640
830
  // linked in from another workspace (e.g. cross-repo `bun link`).
@@ -645,23 +835,17 @@ initHydration(componentRegistry)
645
835
  // point at the same underlying file, so behavior and HMR
646
836
  // are preserved.
647
837
  const linkedSrcMainPath = join(astroRoot, 'node_modules', '@conloca', 'cms-spa', 'src', 'main.tsx');
648
- const srcMainPath = existsSync(linkedSrcMainPath) ? linkedSrcMainPath : realSrcMainPath;
649
- if (existsSync(srcMainPath)) {
650
- // Workspace mode: import source for HMR
651
- cmsSpaImport = `import '${srcMainPath}';`;
652
- }
653
- else {
654
- // npm mode: import pre-built SPA mounting entry
655
- cmsSpaImport = "import '@conloca/cms-spa/main';";
656
- }
838
+ // Workspace mode: import source for HMR
839
+ cmsSpaImport = `import '${existsSync(linkedSrcMainPath) ? linkedSrcMainPath : realSrcMainPath}';`;
657
840
  }
658
841
  else {
659
- // Fallback: use package import
842
+ // npm mode, and the fallback when the package cannot be
843
+ // resolved: import the pre-built SPA mounting entry
660
844
  cmsSpaImport = "import '@conloca/cms-spa/main';";
661
845
  }
662
846
  return `
663
- // Import and execute React refresh preamble first (from @vitejs/plugin-react)
664
- ${reactRefreshPreamble}
847
+ // React refresh preamble first — it must be the first import, see its module
848
+ import '${VIRTUAL_REFRESH_PREAMBLE}';
665
849
 
666
850
  // Import cms-spa through Vite
667
851
  // Vite will resolve React from its pre-bundled deps (same instance as puck.config.tsx)
@@ -723,11 +907,7 @@ if (import.meta.hot) {
723
907
  name: 'conloca-registry-and-render-endpoints',
724
908
  apply: 'serve',
725
909
  configureServer(server) {
726
- const registry = createRegistryEndpoint({
727
- contentRoot: resolvedMdxPages ?? options.contentRoot,
728
- componentFolders: options.mdxComponentFolders ?? ['src/components/mdx'],
729
- projectRoot: process.cwd(),
730
- });
910
+ const registry = createRegistryEndpoint(registryScan);
731
911
  server.middlewares.use(`${cmsRoute}/api/registry`, registry.handler);
732
912
  server.middlewares.use(`${cmsRoute}/api/render`, createRenderEndpoint(server, registry.getAllowedSources));
733
913
  // Invalidate the cached scan whenever an .mdx file or
@@ -745,6 +925,20 @@ if (import.meta.hot) {
745
925
  server.watcher.on('unlink', onFsChange);
746
926
  },
747
927
  },
928
+ {
929
+ // The Puck component vocabulary: every component the config
930
+ // declares, with its fields, read from source and never
931
+ // executed — so an agent editing a page can find out what it
932
+ // may compose with. A build that publishes the vocabulary
933
+ // reads the same config through the same entry
934
+ // (`./puck-manifest`), never describing components a second
935
+ // way.
936
+ name: 'conloca-components-endpoint',
937
+ apply: 'serve',
938
+ configureServer(server) {
939
+ server.middlewares.use(`${cmsRoute}/api/components`, createComponentsEndpoint(endpointReaderOptions({ puckConfigPath: options.puckConfigPath, projectRoot })));
940
+ },
941
+ },
748
942
  {
749
943
  name: 'conloca-content-watcher',
750
944
  async configureServer(server) {
@@ -864,31 +1058,24 @@ if (import.meta.hot) {
864
1058
  // optimistic setQueryData, so this event is redundant for
865
1059
  // CMS-originated writes. External edits (outside the save window)
866
1060
  // still pass through normally.
867
- const shouldDropDuringWindow = (payload) => {
868
- if (!payload || typeof payload !== 'object')
869
- return false;
870
- const p = payload;
871
- if (p.type === 'full-reload')
872
- return true;
873
- if (p.type === 'custom' && p.event === 'conloca:content-update')
874
- return true;
875
- return false;
876
- };
1061
+ const patchedChannels = new WeakSet();
877
1062
  const patchSend = (target) => {
878
- if (!target)
879
- return;
880
- const marked = target;
881
- if (marked.__conlocaPatched)
1063
+ if (!target || patchedChannels.has(target))
882
1064
  return;
883
1065
  const origSend = target.send.bind(target);
884
- target.send = ((payload, ...rest) => {
885
- if (shouldDropDuringWindow(payload) && Date.now() < suppressUntil) {
886
- server.config.logger.info(`[conloca] suppressed ${payload.type} during CMS save window`, { timestamp: true });
1066
+ function send(payloadOrEvent, payload) {
1067
+ if (typeof payloadOrEvent === 'string') {
1068
+ origSend(payloadOrEvent, payload);
1069
+ return;
1070
+ }
1071
+ if (dropsEditorSaveUpdate(payloadOrEvent) && Date.now() < suppressUntil) {
1072
+ server.config.logger.info(`[conloca] suppressed ${payloadOrEvent.type} during CMS save window`, { timestamp: true });
887
1073
  return;
888
1074
  }
889
- return origSend(payload, ...rest);
890
- });
891
- marked.__conlocaPatched = true;
1075
+ origSend(payloadOrEvent);
1076
+ }
1077
+ target.send = send;
1078
+ patchedChannels.add(target);
892
1079
  };
893
1080
  // Astro's content plugin sends `full-reload` via environments.client.hot.
894
1081
  // Conloca's content watcher sends custom events via server.ws (legacy API).
@@ -914,6 +1101,9 @@ if (import.meta.hot) {
914
1101
  prerender: false,
915
1102
  });
916
1103
  },
1104
+ 'astro:config:done': ({ config }) => {
1105
+ outputMode = config.output;
1106
+ },
917
1107
  'astro:server:setup': ({ logger, refreshContent }) => {
918
1108
  logger.info(`Conloca CMS available at ${cmsRoute}`);
919
1109
  let refreshChain = Promise.resolve();
@@ -937,9 +1127,31 @@ if (import.meta.hot) {
937
1127
  if (!resolvedRoutingConfig?.enabled)
938
1128
  return;
939
1129
  const injectedPatterns = new Set(Object.values(resolvedRoutingConfig.routes).map((r) => r.pattern));
1130
+ // Another integration's route with the SAME NAME as a Conloca route is
1131
+ // fatal, whatever `onConflict` says: routing copes (Astro falls through
1132
+ // a prerendered match to the on-demand twin), but Astro's runtime app
1133
+ // resolves a page's stylesheets by route name and takes the first
1134
+ // match, so the twins swap or lose their styles — silently, and only
1135
+ // in the built site. That app renders every page of a server-output
1136
+ // build (prerendering included) and the on-demand pages of a static
1137
+ // one; fully static generation resolves by route and component, where
1138
+ // twins are harmless, so such a site is left alone. Starlight's docs
1139
+ // route is the usual twin: it is named /[...slug] too. The fix is a
1140
+ // different parameter name.
1141
+ const isConlocaHandler = (route) => route.entrypoint?.endsWith('/internal/page-handler.astro') ?? false;
1142
+ const ownRoutes = routes.filter(isConlocaHandler);
1143
+ for (const route of routes) {
1144
+ if (route.origin !== 'external' || !injectedPatterns.has(route.pattern) || isConlocaHandler(route))
1145
+ continue;
1146
+ const own = ownRoutes.find((candidate) => candidate.pattern === route.pattern);
1147
+ const stylesResolvedByName = outputMode === 'server' || !route.isPrerendered || own?.isPrerendered === false;
1148
+ if (!stylesResolvedByName)
1149
+ continue;
1150
+ throw new Error(`[Conloca] Route '${route.pattern}' is registered by Conloca routing and by ${route.entrypoint}. ` +
1151
+ 'Astro resolves stylesheets by route name, so two routes with the same name lose their styles. ' +
1152
+ "Give the Conloca route a parameter name of its own, e.g. '/[...page]'.");
1153
+ }
940
1154
  // Find file-based project routes that conflict with injected routes.
941
- // Integration routes (origin: 'external') sharing the same catch-all pattern
942
- // is expected — Astro's prerender fallthrough handles coexistence automatically.
943
1155
  const conflicts = [];
944
1156
  for (const route of routes) {
945
1157
  if (route.origin !== 'project')
@@ -970,3 +1182,4 @@ if (import.meta.hot) {
970
1182
  },
971
1183
  };
972
1184
  }
1185
+ //# sourceMappingURL=plugin-spa.js.map