@conloca/cms-spa 0.1.14 → 0.1.16

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 (438) hide show
  1. package/dist/App-Bk1LNxbS.mjs +10851 -0
  2. package/dist/App-Bk1LNxbS.mjs.map +1 -0
  3. package/dist/App.d.ts +35 -0
  4. package/dist/App.d.ts.map +1 -0
  5. package/dist/App.js +52 -0
  6. package/dist/CmsSpaApp.d.ts +13 -0
  7. package/dist/CmsSpaApp.d.ts.map +1 -0
  8. package/dist/CmsSpaApp.js +33 -0
  9. package/dist/cn-dlASUkDY.mjs +10 -0
  10. package/dist/cn-dlASUkDY.mjs.map +1 -0
  11. package/dist/components/CMSDashboard.d.ts +2 -0
  12. package/dist/components/CMSDashboard.d.ts.map +1 -0
  13. package/dist/components/CMSDashboard.js +20 -0
  14. package/dist/components/CMSLayout.d.ts +2 -0
  15. package/dist/components/CMSLayout.d.ts.map +1 -0
  16. package/dist/components/CMSLayout.js +15 -0
  17. package/dist/components/ConlocaLogo.d.ts +2 -0
  18. package/dist/components/ConlocaLogo.d.ts.map +1 -0
  19. package/dist/components/ConlocaLogo.js +4 -0
  20. package/dist/components/GitStatusPanel.d.ts +25 -0
  21. package/dist/components/GitStatusPanel.d.ts.map +1 -0
  22. package/dist/components/GitStatusPanel.js +77 -0
  23. package/dist/components/MobileTopBar.d.ts +6 -0
  24. package/dist/components/MobileTopBar.d.ts.map +1 -0
  25. package/dist/components/MobileTopBar.js +6 -0
  26. package/dist/components/Sidebar.d.ts +8 -0
  27. package/dist/components/Sidebar.d.ts.map +1 -0
  28. package/dist/components/Sidebar.js +40 -0
  29. package/dist/components/UserAvatar.d.ts +2 -0
  30. package/dist/components/UserAvatar.d.ts.map +1 -0
  31. package/dist/components/UserAvatar.js +14 -0
  32. package/dist/components/cards/DataEntryCard.d.ts +14 -0
  33. package/dist/components/cards/DataEntryCard.d.ts.map +1 -0
  34. package/dist/components/cards/DataEntryCard.js +32 -0
  35. package/dist/components/cards/SectionCard.d.ts +15 -0
  36. package/dist/components/cards/SectionCard.d.ts.map +1 -0
  37. package/dist/components/cards/SectionCard.js +10 -0
  38. package/dist/components/cards/index.d.ts +2 -0
  39. package/dist/components/cards/index.d.ts.map +1 -0
  40. package/dist/components/cards/index.js +1 -0
  41. package/dist/components/dashboard/RecentActivity.d.ts +2 -0
  42. package/dist/components/dashboard/RecentActivity.d.ts.map +1 -0
  43. package/dist/components/dashboard/RecentActivity.js +58 -0
  44. package/dist/components/dialog.d.ts +53 -0
  45. package/dist/components/dialog.d.ts.map +1 -0
  46. package/dist/components/dialog.js +56 -0
  47. package/dist/components/dialogs/BlockPropertiesDialog.d.ts +12 -0
  48. package/dist/components/dialogs/BlockPropertiesDialog.d.ts.map +1 -0
  49. package/dist/components/dialogs/BlockPropertiesDialog.js +42 -0
  50. package/dist/components/dialogs/ConflictDialog.d.ts +10 -0
  51. package/dist/components/dialogs/ConflictDialog.d.ts.map +1 -0
  52. package/dist/components/dialogs/ConflictDialog.js +29 -0
  53. package/dist/components/dialogs/CreateDataDialog.d.ts +9 -0
  54. package/dist/components/dialogs/CreateDataDialog.d.ts.map +1 -0
  55. package/dist/components/dialogs/CreateDataDialog.js +20 -0
  56. package/dist/components/dialogs/CreateFolderDialog.d.ts +9 -0
  57. package/dist/components/dialogs/CreateFolderDialog.d.ts.map +1 -0
  58. package/dist/components/dialogs/CreateFolderDialog.js +33 -0
  59. package/dist/components/dialogs/CreatePageDialog.d.ts +10 -0
  60. package/dist/components/dialogs/CreatePageDialog.d.ts.map +1 -0
  61. package/dist/components/dialogs/CreatePageDialog.js +155 -0
  62. package/dist/components/dialogs/DataPropertiesDialog.d.ts +10 -0
  63. package/dist/components/dialogs/DataPropertiesDialog.d.ts.map +1 -0
  64. package/dist/components/dialogs/DataPropertiesDialog.js +38 -0
  65. package/dist/components/dialogs/DeleteConfirmDialog.d.ts +12 -0
  66. package/dist/components/dialogs/DeleteConfirmDialog.d.ts.map +1 -0
  67. package/dist/components/dialogs/DeleteConfirmDialog.js +7 -0
  68. package/dist/components/dialogs/ErrorModal.d.ts +14 -0
  69. package/dist/components/dialogs/ErrorModal.d.ts.map +1 -0
  70. package/dist/components/dialogs/ErrorModal.js +38 -0
  71. package/dist/components/dialogs/MoveFolderDialog.d.ts +11 -0
  72. package/dist/components/dialogs/MoveFolderDialog.d.ts.map +1 -0
  73. package/dist/components/dialogs/MoveFolderDialog.js +45 -0
  74. package/dist/components/dialogs/PageMetadataDialog.d.ts +10 -0
  75. package/dist/components/dialogs/PageMetadataDialog.d.ts.map +1 -0
  76. package/dist/components/dialogs/PageMetadataDialog.js +85 -0
  77. package/dist/components/dialogs/UnsavedChangesDialog.d.ts +8 -0
  78. package/dist/components/dialogs/UnsavedChangesDialog.d.ts.map +1 -0
  79. package/dist/components/dialogs/UnsavedChangesDialog.js +6 -0
  80. package/dist/components/dialogs/index.d.ts +9 -0
  81. package/dist/components/dialogs/index.d.ts.map +1 -0
  82. package/dist/components/dialogs/index.js +8 -0
  83. package/dist/components/editor/BlockEditor.d.ts +8 -0
  84. package/dist/components/editor/BlockEditor.d.ts.map +1 -0
  85. package/dist/components/editor/BlockEditor.js +262 -0
  86. package/dist/components/editor/BlockWrappers.d.ts +15 -0
  87. package/dist/components/editor/BlockWrappers.d.ts.map +1 -0
  88. package/dist/components/editor/BlockWrappers.js +29 -0
  89. package/dist/components/editor/CMSMDXEditor.d.ts +13 -0
  90. package/dist/components/editor/CMSMDXEditor.d.ts.map +1 -0
  91. package/dist/components/editor/CMSMDXEditor.js +123 -0
  92. package/dist/components/editor/ContentDiff.d.ts +10 -0
  93. package/dist/components/editor/ContentDiff.d.ts.map +1 -0
  94. package/dist/components/editor/ContentDiff.js +51 -0
  95. package/dist/components/editor/CreateBlockDialog.d.ts +26 -0
  96. package/dist/components/editor/CreateBlockDialog.d.ts.map +1 -0
  97. package/dist/components/editor/CreateBlockDialog.js +131 -0
  98. package/dist/components/editor/DrawerItemOverride.d.ts +8 -0
  99. package/dist/components/editor/DrawerItemOverride.d.ts.map +1 -0
  100. package/dist/components/editor/DrawerItemOverride.js +41 -0
  101. package/dist/components/editor/EditorChromeToggles.d.ts +16 -0
  102. package/dist/components/editor/EditorChromeToggles.d.ts.map +1 -0
  103. package/dist/components/editor/EditorChromeToggles.js +16 -0
  104. package/dist/components/editor/GenericBlock.d.ts +3 -0
  105. package/dist/components/editor/GenericBlock.d.ts.map +1 -0
  106. package/dist/components/editor/GenericBlock.js +1067 -0
  107. package/dist/components/editor/ImagePickerDialog.d.ts +6 -0
  108. package/dist/components/editor/ImagePickerDialog.d.ts.map +1 -0
  109. package/dist/components/editor/ImagePickerDialog.js +24 -0
  110. package/dist/components/editor/JsxPropsPanel.d.ts +16 -0
  111. package/dist/components/editor/JsxPropsPanel.d.ts.map +1 -0
  112. package/dist/components/editor/JsxPropsPanel.js +145 -0
  113. package/dist/components/editor/LocaleSelector.d.ts +9 -0
  114. package/dist/components/editor/LocaleSelector.d.ts.map +1 -0
  115. package/dist/components/editor/LocaleSelector.js +13 -0
  116. package/dist/components/editor/MDXLivePreview.d.ts +14 -0
  117. package/dist/components/editor/MDXLivePreview.d.ts.map +1 -0
  118. package/dist/components/editor/MDXLivePreview.js +103 -0
  119. package/dist/components/editor/MdxPageEditor.d.ts +10 -0
  120. package/dist/components/editor/MdxPageEditor.d.ts.map +1 -0
  121. package/dist/components/editor/MdxPageEditor.js +297 -0
  122. package/dist/components/editor/PageEditor.d.ts +18 -0
  123. package/dist/components/editor/PageEditor.d.ts.map +1 -0
  124. package/dist/components/editor/PageEditor.js +288 -0
  125. package/dist/components/editor/PageEditorHeaderActions.d.ts +16 -0
  126. package/dist/components/editor/PageEditorHeaderActions.d.ts.map +1 -0
  127. package/dist/components/editor/PageEditorHeaderActions.js +19 -0
  128. package/dist/components/editor/PageEditorWrapper.d.ts +7 -0
  129. package/dist/components/editor/PageEditorWrapper.d.ts.map +1 -0
  130. package/dist/components/editor/PageEditorWrapper.js +319 -0
  131. package/dist/components/editor/SearchableSelect.d.ts +34 -0
  132. package/dist/components/editor/SearchableSelect.d.ts.map +1 -0
  133. package/dist/components/editor/SearchableSelect.js +116 -0
  134. package/dist/components/editor/host-wrapper-plugin.d.ts +51 -0
  135. package/dist/components/editor/host-wrapper-plugin.d.ts.map +1 -0
  136. package/dist/components/editor/host-wrapper-plugin.js +37 -0
  137. package/dist/components/editor/index.d.ts +9 -0
  138. package/dist/components/editor/index.d.ts.map +1 -0
  139. package/dist/components/editor/index.js +7 -0
  140. package/dist/components/editor/insert-menu/InsertMdxComponentButton.d.ts +15 -0
  141. package/dist/components/editor/insert-menu/InsertMdxComponentButton.d.ts.map +1 -0
  142. package/dist/components/editor/insert-menu/InsertMdxComponentButton.js +90 -0
  143. package/dist/components/editor/insert-menu/SlashMenuPlugin.d.ts +12 -0
  144. package/dist/components/editor/insert-menu/SlashMenuPlugin.d.ts.map +1 -0
  145. package/dist/components/editor/insert-menu/SlashMenuPlugin.js +106 -0
  146. package/dist/components/editor/insert-menu/insert-payload.d.ts +76 -0
  147. package/dist/components/editor/insert-menu/insert-payload.d.ts.map +1 -0
  148. package/dist/components/editor/insert-menu/insert-payload.js +94 -0
  149. package/dist/components/editor/insert-menu/mdx-components-plugin.d.ts +8 -0
  150. package/dist/components/editor/insert-menu/mdx-components-plugin.d.ts.map +1 -0
  151. package/dist/components/editor/insert-menu/mdx-components-plugin.js +13 -0
  152. package/dist/components/editors/DataEditor.d.ts +19 -0
  153. package/dist/components/editors/DataEditor.d.ts.map +1 -0
  154. package/dist/components/editors/DataEditor.js +139 -0
  155. package/dist/components/fields/ContentBlockSelectorField.d.ts +14 -0
  156. package/dist/components/fields/ContentBlockSelectorField.d.ts.map +1 -0
  157. package/dist/components/fields/ContentBlockSelectorField.js +105 -0
  158. package/dist/components/fields/ImageField.d.ts +16 -0
  159. package/dist/components/fields/ImageField.d.ts.map +1 -0
  160. package/dist/components/fields/ImageField.js +39 -0
  161. package/dist/components/fields/MDXEditField.d.ts +17 -0
  162. package/dist/components/fields/MDXEditField.d.ts.map +1 -0
  163. package/dist/components/fields/MDXEditField.js +28 -0
  164. package/dist/components/forms/ChipArrayField.d.ts +12 -0
  165. package/dist/components/forms/ChipArrayField.d.ts.map +1 -0
  166. package/dist/components/forms/ChipArrayField.js +40 -0
  167. package/dist/components/forms/HintForm.d.ts +22 -0
  168. package/dist/components/forms/HintForm.d.ts.map +1 -0
  169. package/dist/components/forms/HintForm.js +162 -0
  170. package/dist/components/forms/SchemaForm.d.ts +15 -0
  171. package/dist/components/forms/SchemaForm.d.ts.map +1 -0
  172. package/dist/components/forms/SchemaForm.js +106 -0
  173. package/dist/components/index.d.ts +8 -0
  174. package/dist/components/index.d.ts.map +1 -0
  175. package/dist/components/index.js +13 -0
  176. package/dist/components/media/AssetCard.d.ts +14 -0
  177. package/dist/components/media/AssetCard.d.ts.map +1 -0
  178. package/dist/components/media/AssetCard.js +31 -0
  179. package/dist/components/media/AssetDetailSidebar.d.ts +11 -0
  180. package/dist/components/media/AssetDetailSidebar.d.ts.map +1 -0
  181. package/dist/components/media/AssetDetailSidebar.js +101 -0
  182. package/dist/components/media/BulkActionBar.d.ts +9 -0
  183. package/dist/components/media/BulkActionBar.d.ts.map +1 -0
  184. package/dist/components/media/BulkActionBar.js +8 -0
  185. package/dist/components/media/FolderNav.d.ts +7 -0
  186. package/dist/components/media/FolderNav.d.ts.map +1 -0
  187. package/dist/components/media/FolderNav.js +12 -0
  188. package/dist/components/media/FolderTreeSidebar.d.ts +9 -0
  189. package/dist/components/media/FolderTreeSidebar.d.ts.map +1 -0
  190. package/dist/components/media/FolderTreeSidebar.js +41 -0
  191. package/dist/components/media/ImagePicker.d.ts +14 -0
  192. package/dist/components/media/ImagePicker.d.ts.map +1 -0
  193. package/dist/components/media/ImagePicker.js +45 -0
  194. package/dist/components/media/MediaLibrary.d.ts +35 -0
  195. package/dist/components/media/MediaLibrary.d.ts.map +1 -0
  196. package/dist/components/media/MediaLibrary.js +100 -0
  197. package/dist/components/media/MediaToolbar.d.ts +21 -0
  198. package/dist/components/media/MediaToolbar.d.ts.map +1 -0
  199. package/dist/components/media/MediaToolbar.js +6 -0
  200. package/dist/components/media/UploadModal.d.ts +9 -0
  201. package/dist/components/media/UploadModal.d.ts.map +1 -0
  202. package/dist/components/media/UploadModal.js +42 -0
  203. package/dist/components/media/UploadZone.d.ts +8 -0
  204. package/dist/components/media/UploadZone.d.ts.map +1 -0
  205. package/dist/components/media/UploadZone.js +22 -0
  206. package/dist/components/media/index.d.ts +11 -0
  207. package/dist/components/media/index.d.ts.map +1 -0
  208. package/dist/components/media/index.js +10 -0
  209. package/dist/components/pages/BlockList.d.ts +2 -0
  210. package/dist/components/pages/BlockList.d.ts.map +1 -0
  211. package/dist/components/pages/BlockList.js +280 -0
  212. package/dist/components/pages/DataList.d.ts +7 -0
  213. package/dist/components/pages/DataList.d.ts.map +1 -0
  214. package/dist/components/pages/DataList.js +244 -0
  215. package/dist/components/pages/MediaPage.d.ts +8 -0
  216. package/dist/components/pages/MediaPage.d.ts.map +1 -0
  217. package/dist/components/pages/MediaPage.js +107 -0
  218. package/dist/components/pages/PageList.d.ts +7 -0
  219. package/dist/components/pages/PageList.d.ts.map +1 -0
  220. package/dist/components/pages/PageList.js +308 -0
  221. package/dist/components/pages/index.d.ts +3 -0
  222. package/dist/components/pages/index.d.ts.map +1 -0
  223. package/dist/components/pages/index.js +2 -0
  224. package/dist/components/puck/MDXContent.d.ts +10 -0
  225. package/dist/components/puck/MDXContent.d.ts.map +1 -0
  226. package/dist/components/puck/MDXContent.js +80 -0
  227. package/dist/components/puck/index.d.ts +2 -0
  228. package/dist/components/puck/index.d.ts.map +1 -0
  229. package/dist/components/puck/index.js +1 -0
  230. package/dist/components/toast.d.ts +44 -0
  231. package/dist/components/toast.d.ts.map +1 -0
  232. package/dist/components/toast.js +7 -0
  233. package/dist/components/ui/Banner.d.ts +76 -0
  234. package/dist/components/ui/Banner.d.ts.map +1 -0
  235. package/dist/components/ui/Banner.js +49 -0
  236. package/dist/components/ui/Button.d.ts +25 -0
  237. package/dist/components/ui/Button.d.ts.map +1 -0
  238. package/dist/components/ui/Button.js +33 -0
  239. package/dist/components/ui/Card.d.ts +72 -0
  240. package/dist/components/ui/Card.d.ts.map +1 -0
  241. package/dist/components/ui/Card.js +49 -0
  242. package/dist/components/ui/FieldError.d.ts +24 -0
  243. package/dist/components/ui/FieldError.d.ts.map +1 -0
  244. package/dist/components/ui/FieldError.js +17 -0
  245. package/dist/components/ui/IconButton.d.ts +13 -0
  246. package/dist/components/ui/IconButton.d.ts.map +1 -0
  247. package/dist/components/ui/IconButton.js +10 -0
  248. package/dist/components/ui/Input.d.ts +37 -0
  249. package/dist/components/ui/Input.d.ts.map +1 -0
  250. package/dist/components/ui/Input.js +9 -0
  251. package/dist/components/ui/SaveIndicator.d.ts +8 -0
  252. package/dist/components/ui/SaveIndicator.d.ts.map +1 -0
  253. package/dist/components/ui/SaveIndicator.js +32 -0
  254. package/dist/components/ui/Select.d.ts +8 -0
  255. package/dist/components/ui/Select.d.ts.map +1 -0
  256. package/dist/components/ui/Select.js +9 -0
  257. package/dist/components/ui/Separator.d.ts +7 -0
  258. package/dist/components/ui/Separator.d.ts.map +1 -0
  259. package/dist/components/ui/Separator.js +8 -0
  260. package/dist/components/ui/Textarea.d.ts +8 -0
  261. package/dist/components/ui/Textarea.d.ts.map +1 -0
  262. package/dist/components/ui/Textarea.js +5 -0
  263. package/dist/components/ui/Tooltip.d.ts +9 -0
  264. package/dist/components/ui/Tooltip.d.ts.map +1 -0
  265. package/dist/components/ui/Tooltip.js +7 -0
  266. package/dist/components/ui/index.d.ts +14 -0
  267. package/dist/components/ui/index.d.ts.map +1 -0
  268. package/dist/components/ui/index.js +17 -0
  269. package/dist/data-schemas.d.mts +0 -1
  270. package/dist/data-schemas.d.mts.map +1 -1
  271. package/dist/data-schemas.d.ts +22 -0
  272. package/dist/data-schemas.d.ts.map +1 -0
  273. package/dist/data-schemas.js +51 -0
  274. package/dist/data-schemas.mjs +3 -4
  275. package/dist/data-schemas.mjs.map +1 -1
  276. package/dist/dev-entry.d.ts +2 -0
  277. package/dist/dev-entry.d.ts.map +1 -0
  278. package/dist/dev-entry.js +19 -0
  279. package/dist/dialog.d.mts +56 -0
  280. package/dist/dialog.d.mts.map +1 -0
  281. package/dist/dialog.mjs +67 -0
  282. package/dist/dialog.mjs.map +1 -0
  283. package/dist/hooks/index.d.ts +10 -0
  284. package/dist/hooks/index.d.ts.map +1 -0
  285. package/dist/hooks/index.js +7 -0
  286. package/dist/hooks/useCanvasTheme.d.ts +12 -0
  287. package/dist/hooks/useCanvasTheme.d.ts.map +1 -0
  288. package/dist/hooks/useCanvasTheme.js +33 -0
  289. package/dist/hooks/useClickOutside.d.ts +7 -0
  290. package/dist/hooks/useClickOutside.d.ts.map +1 -0
  291. package/dist/hooks/useClickOutside.js +18 -0
  292. package/dist/hooks/useDialogState.d.ts +23 -0
  293. package/dist/hooks/useDialogState.d.ts.map +1 -0
  294. package/dist/hooks/useDialogState.js +31 -0
  295. package/dist/hooks/useEditorPref.d.ts +2 -0
  296. package/dist/hooks/useEditorPref.d.ts.map +1 -0
  297. package/dist/hooks/useEditorPref.js +49 -0
  298. package/dist/hooks/useErrorModal.d.ts +15 -0
  299. package/dist/hooks/useErrorModal.d.ts.map +1 -0
  300. package/dist/hooks/useErrorModal.js +35 -0
  301. package/dist/hooks/useSiteBaseUrl.d.ts +10 -0
  302. package/dist/hooks/useSiteBaseUrl.d.ts.map +1 -0
  303. package/dist/hooks/useSiteBaseUrl.js +14 -0
  304. package/dist/hooks/useTheme.d.ts +13 -0
  305. package/dist/hooks/useTheme.d.ts.map +1 -0
  306. package/dist/hooks/useTheme.js +69 -0
  307. package/dist/hooks/useUnsavedChangesGuard.d.ts +16 -0
  308. package/dist/hooks/useUnsavedChangesGuard.d.ts.map +1 -0
  309. package/dist/hooks/useUnsavedChangesGuard.js +29 -0
  310. package/dist/hooks/useUpload.d.ts +10 -0
  311. package/dist/hooks/useUpload.d.ts.map +1 -0
  312. package/dist/hooks/useUpload.js +42 -0
  313. package/dist/hooks/useUploadFlow.d.ts +42 -0
  314. package/dist/hooks/useUploadFlow.d.ts.map +1 -0
  315. package/dist/hooks/useUploadFlow.js +148 -0
  316. package/dist/host-style-probe.d.ts +22 -0
  317. package/dist/host-style-probe.d.ts.map +1 -0
  318. package/dist/host-style-probe.js +508 -0
  319. package/dist/index.d.mts +165 -48
  320. package/dist/index.d.mts.map +1 -1
  321. package/dist/index.d.ts +10 -0
  322. package/dist/index.d.ts.map +1 -0
  323. package/dist/index.js +12 -0
  324. package/dist/index.mjs +36 -2
  325. package/dist/index.mjs.map +1 -0
  326. package/dist/lib/utils.d.ts +13 -0
  327. package/dist/lib/utils.d.ts.map +1 -0
  328. package/dist/lib/utils.js +47 -0
  329. package/dist/main-spa-781YUplS.mjs +46 -0
  330. package/dist/main-spa-781YUplS.mjs.map +1 -0
  331. package/dist/main-spa.d.ts +8 -0
  332. package/dist/main-spa.d.ts.map +1 -0
  333. package/dist/main-spa.js +61 -0
  334. package/dist/main.d.mts +1 -1
  335. package/dist/main.d.ts +2 -0
  336. package/dist/main.d.ts.map +1 -0
  337. package/dist/main.js +13 -0
  338. package/dist/main.mjs +11 -4998
  339. package/dist/main.mjs.map +1 -1
  340. package/dist/mdx-components.d.mts +207 -0
  341. package/dist/mdx-components.d.mts.map +1 -0
  342. package/dist/mdx-components.d.ts +204 -0
  343. package/dist/mdx-components.d.ts.map +1 -0
  344. package/dist/mdx-components.js +217 -0
  345. package/dist/mdx-components.mjs +208 -0
  346. package/dist/mdx-components.mjs.map +1 -0
  347. package/dist/media/AssetScopePill.d.ts +30 -0
  348. package/dist/media/AssetScopePill.d.ts.map +1 -0
  349. package/dist/media/AssetScopePill.js +30 -0
  350. package/dist/media/MediaIssueBadge.d.ts +33 -0
  351. package/dist/media/MediaIssueBadge.d.ts.map +1 -0
  352. package/dist/media/MediaIssueBadge.js +54 -0
  353. package/dist/media/types.d.ts +101 -0
  354. package/dist/media/types.d.ts.map +1 -0
  355. package/dist/media/types.js +1 -0
  356. package/dist/media/use-asset-scope.d.ts +25 -0
  357. package/dist/media/use-asset-scope.d.ts.map +1 -0
  358. package/dist/media/use-asset-scope.js +54 -0
  359. package/dist/media/use-media-issue.d.ts +24 -0
  360. package/dist/media/use-media-issue.d.ts.map +1 -0
  361. package/dist/media/use-media-issue.js +49 -0
  362. package/dist/mock-puck-config.d.mts +23 -0
  363. package/dist/mock-puck-config.d.mts.map +1 -0
  364. package/dist/mock-puck-config.d.ts +21 -0
  365. package/dist/mock-puck-config.d.ts.map +1 -0
  366. package/dist/mock-puck-config.js +73 -0
  367. package/dist/mock-puck-config.mjs +125 -0
  368. package/dist/mock-puck-config.mjs.map +1 -0
  369. package/dist/page-schemas.d.mts +139 -6
  370. package/dist/page-schemas.d.mts.map +1 -1
  371. package/dist/page-schemas.d.ts +156 -0
  372. package/dist/page-schemas.d.ts.map +1 -0
  373. package/dist/page-schemas.js +118 -0
  374. package/dist/page-schemas.mjs +74 -6
  375. package/dist/page-schemas.mjs.map +1 -1
  376. package/dist/puck-config.d.mts +9 -1
  377. package/dist/puck-config.d.mts.map +1 -1
  378. package/dist/puck-config.d.ts +31 -0
  379. package/dist/puck-config.d.ts.map +1 -0
  380. package/dist/puck-config.js +50 -0
  381. package/dist/puck-config.mjs +3 -4
  382. package/dist/puck-config.mjs.map +1 -1
  383. package/dist/selected-block.d.ts +61 -0
  384. package/dist/selected-block.d.ts.map +1 -0
  385. package/dist/selected-block.js +64 -0
  386. package/dist/site-styles.d.mts +123 -0
  387. package/dist/site-styles.d.mts.map +1 -0
  388. package/dist/site-styles.d.ts +121 -0
  389. package/dist/site-styles.d.ts.map +1 -0
  390. package/dist/site-styles.js +253 -0
  391. package/dist/site-styles.mjs +234 -0
  392. package/dist/site-styles.mjs.map +1 -0
  393. package/dist/spa/main.css +5497 -4371
  394. package/dist/toast.d.mts +7 -0
  395. package/dist/toast.d.mts.map +1 -0
  396. package/dist/toast.mjs +16 -0
  397. package/dist/toast.mjs.map +1 -0
  398. package/dist/types.d.ts +57 -0
  399. package/dist/types.d.ts.map +1 -0
  400. package/dist/types.js +1 -0
  401. package/dist/ui-CIacC6Mv.mjs +318 -0
  402. package/dist/ui-CIacC6Mv.mjs.map +1 -0
  403. package/dist/ui-config.d.ts +70 -0
  404. package/dist/ui-config.d.ts.map +1 -0
  405. package/dist/ui-config.js +44 -0
  406. package/dist/ui.d.mts +290 -0
  407. package/dist/ui.d.mts.map +1 -0
  408. package/dist/ui.mjs +2 -0
  409. package/dist/utils/asset-url.d.ts +3 -0
  410. package/dist/utils/asset-url.d.ts.map +1 -0
  411. package/dist/utils/asset-url.js +7 -0
  412. package/dist/utils/cn.d.ts +3 -0
  413. package/dist/utils/cn.d.ts.map +1 -0
  414. package/dist/utils/cn.js +5 -0
  415. package/dist/utils/format-date.d.ts +15 -0
  416. package/dist/utils/format-date.d.ts.map +1 -0
  417. package/dist/utils/format-date.js +37 -0
  418. package/dist/utils/mdast-to-html.d.ts +55 -0
  419. package/dist/utils/mdast-to-html.d.ts.map +1 -0
  420. package/dist/utils/mdast-to-html.js +206 -0
  421. package/dist/utils/mdast-tree.d.ts +104 -0
  422. package/dist/utils/mdast-tree.d.ts.map +1 -0
  423. package/dist/utils/mdast-tree.js +285 -0
  424. package/dist/utils/pageMetadata.d.ts +67 -0
  425. package/dist/utils/pageMetadata.d.ts.map +1 -0
  426. package/dist/utils/pageMetadata.js +161 -0
  427. package/dist/utils/slugify.d.ts +12 -0
  428. package/dist/utils/slugify.d.ts.map +1 -0
  429. package/dist/utils/slugify.js +17 -0
  430. package/dist/utils/zodIntrospect.d.ts +24 -0
  431. package/dist/utils/zodIntrospect.d.ts.map +1 -0
  432. package/dist/utils/zodIntrospect.js +88 -0
  433. package/package.json +153 -35
  434. package/styles/styles.css.d.ts +2 -0
  435. package/styles/tailwind-theme.css +126 -0
  436. package/styles/tailwind-theme.css.d.ts +2 -0
  437. package/dist/puck-CvjeYQRH.mjs +0 -1533
  438. package/dist/puck-CvjeYQRH.mjs.map +0 -1
@@ -0,0 +1,118 @@
1
+ import { useEffect, useState } from 'react';
2
+ /**
3
+ * Identity helper that gives `pageSchemas` entries a typed shape.
4
+ *
5
+ * Mirrors Astro's `defineConfig` — purely for editor inference.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * export const pageSchemas = {
10
+ * 'type:mdx': definePageSchema({
11
+ * label: 'MDX page',
12
+ * schema: mdxPageSchema,
13
+ * ui: { title: { control: 'text', group: 'basics', required: true } },
14
+ * groups: [{ id: 'basics', label: 'Basics' }],
15
+ * coreFields: { mode: 'minimal' },
16
+ * }),
17
+ * };
18
+ * ```
19
+ */
20
+ export function definePageSchema(descriptor) {
21
+ if (descriptor.coreFields?.mode === 'none' && !('title' in descriptor.schema.shape)) {
22
+ throw new Error("definePageSchema: coreFields.mode 'none' requires the schema to declare a `title` field " +
23
+ '(ContentMeta.title is required by the content-api).');
24
+ }
25
+ return descriptor;
26
+ }
27
+ /**
28
+ * Normalize an entry to a descriptor. Bare Zod objects (legacy) get wrapped
29
+ * with default `coreFields.mode: 'full'` so the dialog can render today's
30
+ * three-section layout unchanged.
31
+ */
32
+ export function toPageSchemaDescriptor(entry) {
33
+ if (isPageSchemaDescriptor(entry))
34
+ return entry;
35
+ return { schema: entry, coreFields: { mode: 'full' } };
36
+ }
37
+ function isPageSchemaDescriptor(value) {
38
+ return typeof value === 'object' && value !== null && 'schema' in value && !('shape' in value);
39
+ }
40
+ const getSharedState = () => {
41
+ if (typeof window !== 'undefined') {
42
+ if (!window.__PAGE_SCHEMAS_STATE__) {
43
+ window.__PAGE_SCHEMAS_STATE__ = {
44
+ schemas: {},
45
+ subscribers: new Set(),
46
+ };
47
+ }
48
+ return window.__PAGE_SCHEMAS_STATE__;
49
+ }
50
+ // SSR fallback
51
+ return { schemas: {}, subscribers: new Set() };
52
+ };
53
+ /**
54
+ * Set the page schemas for all match keys.
55
+ * Called by the virtual module that loads user's schema definitions.
56
+ * Notifies all subscribers of the change (enables HMR).
57
+ */
58
+ export function setPageSchemas(schemas) {
59
+ const state = getSharedState();
60
+ state.schemas = schemas;
61
+ for (const fn of state.subscribers) {
62
+ fn(schemas);
63
+ }
64
+ }
65
+ /**
66
+ * Get the current page schemas synchronously.
67
+ */
68
+ export function getPageSchemas() {
69
+ return getSharedState().schemas;
70
+ }
71
+ /**
72
+ * React hook to subscribe to page schema changes.
73
+ * Returns the current schemas and updates when they change (HMR support).
74
+ */
75
+ export function usePageSchemas() {
76
+ const [schemas, setSchemas] = useState(() => getSharedState().schemas);
77
+ useEffect(() => {
78
+ const state = getSharedState();
79
+ // Update immediately in case schemas changed between render and effect
80
+ if (state.schemas !== schemas) {
81
+ setSchemas(state.schemas);
82
+ }
83
+ state.subscribers.add(setSchemas);
84
+ return () => {
85
+ state.subscribers.delete(setSchemas);
86
+ };
87
+ }, [schemas]);
88
+ return schemas;
89
+ }
90
+ /**
91
+ * Resolve the best-matching descriptor for a page.
92
+ *
93
+ * Resolution order: `collection:<name>` > `type:<puck|mdx>` >
94
+ * pathname-prefix (longest match wins). Returns `null` if no key matches.
95
+ */
96
+ export function resolvePageSchemaEntry(schemas, context) {
97
+ if (context.collection) {
98
+ const key = `collection:${context.collection}`;
99
+ if (key in schemas)
100
+ return { key, descriptor: toPageSchemaDescriptor(schemas[key]) };
101
+ }
102
+ if (context.type) {
103
+ const key = `type:${context.type}`;
104
+ if (key in schemas)
105
+ return { key, descriptor: toPageSchemaDescriptor(schemas[key]) };
106
+ }
107
+ let bestPrefix = null;
108
+ for (const key of Object.keys(schemas)) {
109
+ if (!key.startsWith('/'))
110
+ continue;
111
+ if (context.pathname.startsWith(key) && (!bestPrefix || key.length > bestPrefix.length)) {
112
+ bestPrefix = key;
113
+ }
114
+ }
115
+ if (bestPrefix)
116
+ return { key: bestPrefix, descriptor: toPageSchemaDescriptor(schemas[bestPrefix]) };
117
+ return null;
118
+ }
@@ -1,6 +1,42 @@
1
1
  import { useEffect, useState } from "react";
2
-
3
2
  //#region src/page-schemas.ts
3
+ /**
4
+ * Identity helper that gives `pageSchemas` entries a typed shape.
5
+ *
6
+ * Mirrors Astro's `defineConfig` — purely for editor inference.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * export const pageSchemas = {
11
+ * 'type:mdx': definePageSchema({
12
+ * label: 'MDX page',
13
+ * schema: mdxPageSchema,
14
+ * ui: { title: { control: 'text', group: 'basics', required: true } },
15
+ * groups: [{ id: 'basics', label: 'Basics' }],
16
+ * coreFields: { mode: 'minimal' },
17
+ * }),
18
+ * };
19
+ * ```
20
+ */
21
+ function definePageSchema(descriptor) {
22
+ if (descriptor.coreFields?.mode === "none" && !("title" in descriptor.schema.shape)) throw new Error("definePageSchema: coreFields.mode 'none' requires the schema to declare a `title` field (ContentMeta.title is required by the content-api).");
23
+ return descriptor;
24
+ }
25
+ /**
26
+ * Normalize an entry to a descriptor. Bare Zod objects (legacy) get wrapped
27
+ * with default `coreFields.mode: 'full'` so the dialog can render today's
28
+ * three-section layout unchanged.
29
+ */
30
+ function toPageSchemaDescriptor(entry) {
31
+ if (isPageSchemaDescriptor(entry)) return entry;
32
+ return {
33
+ schema: entry,
34
+ coreFields: { mode: "full" }
35
+ };
36
+ }
37
+ function isPageSchemaDescriptor(value) {
38
+ return typeof value === "object" && value !== null && "schema" in value && !("shape" in value);
39
+ }
4
40
  const getSharedState = () => {
5
41
  if (typeof window !== "undefined") {
6
42
  if (!window.__PAGE_SCHEMAS_STATE__) window.__PAGE_SCHEMAS_STATE__ = {
@@ -15,14 +51,14 @@ const getSharedState = () => {
15
51
  };
16
52
  };
17
53
  /**
18
- * Set the page schemas for all pathname prefixes.
54
+ * Set the page schemas for all match keys.
19
55
  * Called by the virtual module that loads user's schema definitions.
20
56
  * Notifies all subscribers of the change (enables HMR).
21
57
  */
22
58
  function setPageSchemas(schemas) {
23
59
  const state = getSharedState();
24
60
  state.schemas = schemas;
25
- state.subscribers.forEach((fn) => fn(schemas));
61
+ for (const fn of state.subscribers) fn(schemas);
26
62
  }
27
63
  /**
28
64
  * Get the current page schemas synchronously.
@@ -43,10 +79,42 @@ function usePageSchemas() {
43
79
  return () => {
44
80
  state.subscribers.delete(setSchemas);
45
81
  };
46
- }, []);
82
+ }, [schemas]);
47
83
  return schemas;
48
84
  }
49
-
85
+ /**
86
+ * Resolve the best-matching descriptor for a page.
87
+ *
88
+ * Resolution order: `collection:<name>` > `type:<puck|mdx>` >
89
+ * pathname-prefix (longest match wins). Returns `null` if no key matches.
90
+ */
91
+ function resolvePageSchemaEntry(schemas, context) {
92
+ if (context.collection) {
93
+ const key = `collection:${context.collection}`;
94
+ if (key in schemas) return {
95
+ key,
96
+ descriptor: toPageSchemaDescriptor(schemas[key])
97
+ };
98
+ }
99
+ if (context.type) {
100
+ const key = `type:${context.type}`;
101
+ if (key in schemas) return {
102
+ key,
103
+ descriptor: toPageSchemaDescriptor(schemas[key])
104
+ };
105
+ }
106
+ let bestPrefix = null;
107
+ for (const key of Object.keys(schemas)) {
108
+ if (!key.startsWith("/")) continue;
109
+ if (context.pathname.startsWith(key) && (!bestPrefix || key.length > bestPrefix.length)) bestPrefix = key;
110
+ }
111
+ if (bestPrefix) return {
112
+ key: bestPrefix,
113
+ descriptor: toPageSchemaDescriptor(schemas[bestPrefix])
114
+ };
115
+ return null;
116
+ }
50
117
  //#endregion
51
- export { getPageSchemas, setPageSchemas, usePageSchemas };
118
+ export { definePageSchema, getPageSchemas, resolvePageSchemaEntry, setPageSchemas, toPageSchemaDescriptor, usePageSchemas };
119
+
52
120
  //# sourceMappingURL=page-schemas.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"page-schemas.mjs","names":[],"sources":["../src/page-schemas.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport type { z } from 'zod';\n\n/**\n * Type for a collection of page schemas.\n * Each key is a pathname prefix (e.g. '/blog/'), value is the Zod schema for that page's metadata.\n */\nexport type PageSchemas = Record<string, z.ZodObject<z.ZodRawShape>>;\n\n/**\n * Shared state for page schemas across module instances.\n * Uses window to ensure virtual modules and bundled code share the same state.\n */\n\ninterface SharedPageSchemaState {\n schemas: PageSchemas;\n subscribers: Set<(schemas: PageSchemas) => void>;\n}\n\nconst getSharedState = (): SharedPageSchemaState => {\n if (typeof window !== 'undefined') {\n if (!(window as any).__PAGE_SCHEMAS_STATE__) {\n (window as any).__PAGE_SCHEMAS_STATE__ = {\n schemas: {},\n subscribers: new Set(),\n };\n }\n return (window as any).__PAGE_SCHEMAS_STATE__;\n }\n // SSR fallback\n return { schemas: {}, subscribers: new Set() };\n};\n\n/**\n * Set the page schemas for all pathname prefixes.\n * Called by the virtual module that loads user's schema definitions.\n * Notifies all subscribers of the change (enables HMR).\n */\nexport function setPageSchemas(schemas: PageSchemas): void {\n const state = getSharedState();\n state.schemas = schemas;\n state.subscribers.forEach((fn) => fn(schemas));\n}\n\n/**\n * Get the current page schemas synchronously.\n */\nexport function getPageSchemas(): PageSchemas {\n return getSharedState().schemas;\n}\n\n/**\n * React hook to subscribe to page schema changes.\n * Returns the current schemas and updates when they change (HMR support).\n */\nexport function usePageSchemas(): PageSchemas {\n const [schemas, setSchemas] = useState(() => getSharedState().schemas);\n\n useEffect(() => {\n const state = getSharedState();\n\n // Update immediately in case schemas changed between render and effect\n if (state.schemas !== schemas) {\n setSchemas(state.schemas);\n }\n\n state.subscribers.add(setSchemas);\n return () => {\n state.subscribers.delete(setSchemas);\n };\n }, []);\n\n return schemas;\n}\n"],"mappings":";;;AAmBA,MAAM,uBAA8C;AAClD,KAAI,OAAO,WAAW,aAAa;AACjC,MAAI,CAAE,OAAe,uBACnB,CAAC,OAAe,yBAAyB;GACvC,SAAS,EAAE;GACX,6BAAa,IAAI,KAAK;GACvB;AAEH,SAAQ,OAAe;;AAGzB,QAAO;EAAE,SAAS,EAAE;EAAE,6BAAa,IAAI,KAAK;EAAE;;;;;;;AAQhD,SAAgB,eAAe,SAA4B;CACzD,MAAM,QAAQ,gBAAgB;AAC9B,OAAM,UAAU;AAChB,OAAM,YAAY,SAAS,OAAO,GAAG,QAAQ,CAAC;;;;;AAMhD,SAAgB,iBAA8B;AAC5C,QAAO,gBAAgB,CAAC;;;;;;AAO1B,SAAgB,iBAA8B;CAC5C,MAAM,CAAC,SAAS,cAAc,eAAe,gBAAgB,CAAC,QAAQ;AAEtE,iBAAgB;EACd,MAAM,QAAQ,gBAAgB;AAG9B,MAAI,MAAM,YAAY,QACpB,YAAW,MAAM,QAAQ;AAG3B,QAAM,YAAY,IAAI,WAAW;AACjC,eAAa;AACX,SAAM,YAAY,OAAO,WAAW;;IAErC,EAAE,CAAC;AAEN,QAAO"}
1
+ {"version":3,"file":"page-schemas.mjs","names":[],"sources":["../src/page-schemas.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\nimport type { z } from 'zod';\n\n/**\n * Form-UI hint vocabulary for page metadata fields.\n *\n * Hosts attach a hint to each field they want surfaced in the page-settings\n * dialog. The hint drives form rendering — control type, grouping, helper\n * text, etc. — independently of the Zod schema, which still owns validation.\n *\n * Dotted keys ('sidebar.label') are supported in the hint record; on save\n * they materialize into nested objects in YAML frontmatter, and on load\n * they flatten back to dotted keys for the form.\n */\nexport type FieldHintCommon = {\n label?: string;\n help?: string;\n /** Refs a `groups[].id` to bucket fields into sections in the dialog. */\n group?: string;\n required?: boolean;\n hidden?: boolean | ((doc: Record<string, unknown>) => boolean);\n defaultValue?: unknown;\n};\n\nexport type FieldHintVariant = {\n id: string;\n label: string;\n /** Concrete value written when this variant is selected (for literal variants). */\n value?: unknown;\n} & Partial<FieldHint>;\n\nexport type FieldHint = FieldHintCommon &\n (\n | {\n control: 'text' | 'textarea' | 'url' | 'email' | 'number' | 'switch' | 'date' | 'image' | 'markdown' | 'code';\n }\n | { control: 'select'; options: ReadonlyArray<{ value: string; label: string }> }\n | { control: 'chips' }\n | { control: 'object'; fields: Record<string, FieldHint> }\n | { control: 'array'; of: FieldHint }\n | { control: 'variant'; variants: ReadonlyArray<FieldHintVariant> }\n );\n\nexport type FieldHints = Record<string, FieldHint>;\n\nexport type PageSchemaGroup = {\n id: string;\n label: string;\n description?: string;\n};\n\n/**\n * Which conloca-managed sections to render alongside the host schema.\n *\n * - `'full'` (default): show today's `pageInfoSchema` (title/pathname) +\n * host fields + `seoPublishingSchema` (description/robots/canonical/\n * publishAt/unpublishAt). Backwards-compatible with existing dialogs.\n * - `'minimal'`: show pathname only + host fields + publishAt/unpublishAt.\n * Use when the host owns title/description in its own schema.\n * - `'none'`: host fields only. Host must declare `title` in its schema\n * (validated at registration; ContentMeta.title is required at the\n * content-api level).\n */\nexport type CoreFieldsMode = 'full' | 'minimal' | 'none';\n\nexport interface PageSchemaDescriptor {\n /** Human-readable label shown in the dialog header. */\n label?: string;\n /** Zod schema used for validation and field-shape introspection. */\n schema: z.ZodObject<z.ZodRawShape>;\n /** Form-UI hints keyed by field name (dotted keys allowed for nested fields). */\n ui?: FieldHints;\n /** Section definitions; `FieldHint.group` references `id`. */\n groups?: ReadonlyArray<PageSchemaGroup>;\n /** Which conloca core fields to render alongside the host schema. */\n coreFields?: { mode: CoreFieldsMode };\n}\n\n/**\n * Identity helper that gives `pageSchemas` entries a typed shape.\n *\n * Mirrors Astro's `defineConfig` — purely for editor inference.\n *\n * @example\n * ```ts\n * export const pageSchemas = {\n * 'type:mdx': definePageSchema({\n * label: 'MDX page',\n * schema: mdxPageSchema,\n * ui: { title: { control: 'text', group: 'basics', required: true } },\n * groups: [{ id: 'basics', label: 'Basics' }],\n * coreFields: { mode: 'minimal' },\n * }),\n * };\n * ```\n */\nexport function definePageSchema(descriptor: PageSchemaDescriptor): PageSchemaDescriptor {\n if (descriptor.coreFields?.mode === 'none' && !('title' in descriptor.schema.shape)) {\n throw new Error(\n \"definePageSchema: coreFields.mode 'none' requires the schema to declare a `title` field \" +\n '(ContentMeta.title is required by the content-api).',\n );\n }\n return descriptor;\n}\n\n/**\n * Registry entry value: either a bare Zod object (legacy — wrapped as a\n * descriptor with `coreFields.mode: 'full'`) or an explicit descriptor.\n */\nexport type PageSchemaEntry = z.ZodObject<z.ZodRawShape> | PageSchemaDescriptor;\n\n/**\n * Page-schema registry keyed by match expression.\n *\n * Match key forms (resolved in order):\n * - `collection:<name>` — matches when the loaded entry's collection equals `<name>`.\n * - `type:<puck|mdx>` — matches all pages of the given content type.\n * - pathname prefix (must start with `/`) — longest-prefix-match against the page's pathname.\n */\nexport type PageSchemas = Record<string, PageSchemaEntry>;\n\n/**\n * Normalize an entry to a descriptor. Bare Zod objects (legacy) get wrapped\n * with default `coreFields.mode: 'full'` so the dialog can render today's\n * three-section layout unchanged.\n */\nexport function toPageSchemaDescriptor(entry: PageSchemaEntry): PageSchemaDescriptor {\n if (isPageSchemaDescriptor(entry)) return entry;\n return { schema: entry, coreFields: { mode: 'full' } };\n}\n\nfunction isPageSchemaDescriptor(value: PageSchemaEntry): value is PageSchemaDescriptor {\n return typeof value === 'object' && value !== null && 'schema' in value && !('shape' in value);\n}\n\n/**\n * Shared state for page schemas across module instances.\n * Uses window to ensure virtual modules and bundled code share the same state.\n */\n\ninterface SharedPageSchemaState {\n schemas: PageSchemas;\n subscribers: Set<(schemas: PageSchemas) => void>;\n}\n\nconst getSharedState = (): SharedPageSchemaState => {\n if (typeof window !== 'undefined') {\n if (!(window as any).__PAGE_SCHEMAS_STATE__) {\n (window as any).__PAGE_SCHEMAS_STATE__ = {\n schemas: {},\n subscribers: new Set(),\n };\n }\n return (window as any).__PAGE_SCHEMAS_STATE__;\n }\n // SSR fallback\n return { schemas: {}, subscribers: new Set() };\n};\n\n/**\n * Set the page schemas for all match keys.\n * Called by the virtual module that loads user's schema definitions.\n * Notifies all subscribers of the change (enables HMR).\n */\nexport function setPageSchemas(schemas: PageSchemas): void {\n const state = getSharedState();\n state.schemas = schemas;\n for (const fn of state.subscribers) {\n fn(schemas);\n }\n}\n\n/**\n * Get the current page schemas synchronously.\n */\nexport function getPageSchemas(): PageSchemas {\n return getSharedState().schemas;\n}\n\n/**\n * React hook to subscribe to page schema changes.\n * Returns the current schemas and updates when they change (HMR support).\n */\nexport function usePageSchemas(): PageSchemas {\n const [schemas, setSchemas] = useState(() => getSharedState().schemas);\n\n useEffect(() => {\n const state = getSharedState();\n\n // Update immediately in case schemas changed between render and effect\n if (state.schemas !== schemas) {\n setSchemas(state.schemas);\n }\n\n state.subscribers.add(setSchemas);\n return () => {\n state.subscribers.delete(setSchemas);\n };\n }, [schemas]);\n\n return schemas;\n}\n\n/**\n * Context the resolver needs to pick the right schema.\n *\n * - `collection` and `type` come from the loaded entry's `ContentIdentity`.\n * - `pathname` comes from the page's `LocaleVersion`.\n */\nexport interface ResolveSchemaContext {\n pathname: string;\n collection?: string;\n type?: 'puck' | 'mdx';\n}\n\n/**\n * Resolve the best-matching descriptor for a page.\n *\n * Resolution order: `collection:<name>` > `type:<puck|mdx>` >\n * pathname-prefix (longest match wins). Returns `null` if no key matches.\n */\nexport function resolvePageSchemaEntry(\n schemas: PageSchemas,\n context: ResolveSchemaContext,\n): { key: string; descriptor: PageSchemaDescriptor } | null {\n if (context.collection) {\n const key = `collection:${context.collection}`;\n if (key in schemas) return { key, descriptor: toPageSchemaDescriptor(schemas[key]) };\n }\n\n if (context.type) {\n const key = `type:${context.type}`;\n if (key in schemas) return { key, descriptor: toPageSchemaDescriptor(schemas[key]) };\n }\n\n let bestPrefix: string | null = null;\n for (const key of Object.keys(schemas)) {\n if (!key.startsWith('/')) continue;\n if (context.pathname.startsWith(key) && (!bestPrefix || key.length > bestPrefix.length)) {\n bestPrefix = key;\n }\n }\n if (bestPrefix) return { key: bestPrefix, descriptor: toPageSchemaDescriptor(schemas[bestPrefix]) };\n\n return null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAgGA,SAAgB,iBAAiB,YAAwD;CACvF,IAAI,WAAW,YAAY,SAAS,UAAU,EAAE,WAAW,WAAW,OAAO,QAC3E,MAAM,IAAI,MACR,6IAEF;CAEF,OAAO;AACT;;;;;;AAuBA,SAAgB,uBAAuB,OAA8C;CACnF,IAAI,uBAAuB,KAAK,GAAG,OAAO;CAC1C,OAAO;EAAE,QAAQ;EAAO,YAAY,EAAE,MAAM,OAAO;CAAE;AACvD;AAEA,SAAS,uBAAuB,OAAuD;CACrF,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,YAAY,SAAS,EAAE,WAAW;AAC1F;AAYA,MAAM,uBAA8C;CAClD,IAAI,OAAO,WAAW,aAAa;EACjC,IAAI,CAAE,OAAe,wBACnB,OAAgB,yBAAyB;GACvC,SAAS,CAAC;GACV,6BAAa,IAAI,IAAI;EACvB;EAEF,OAAQ,OAAe;CACzB;CAEA,OAAO;EAAE,SAAS,CAAC;EAAG,6BAAa,IAAI,IAAI;CAAE;AAC/C;;;;;;AAOA,SAAgB,eAAe,SAA4B;CACzD,MAAM,QAAQ,eAAe;CAC7B,MAAM,UAAU;CAChB,KAAK,MAAM,MAAM,MAAM,aACrB,GAAG,OAAO;AAEd;;;;AAKA,SAAgB,iBAA8B;CAC5C,OAAO,eAAe,CAAC,CAAC;AAC1B;;;;;AAMA,SAAgB,iBAA8B;CAC5C,MAAM,CAAC,SAAS,cAAc,eAAe,eAAe,CAAC,CAAC,OAAO;CAErE,gBAAgB;EACd,MAAM,QAAQ,eAAe;EAG7B,IAAI,MAAM,YAAY,SACpB,WAAW,MAAM,OAAO;EAG1B,MAAM,YAAY,IAAI,UAAU;EAChC,aAAa;GACX,MAAM,YAAY,OAAO,UAAU;EACrC;CACF,GAAG,CAAC,OAAO,CAAC;CAEZ,OAAO;AACT;;;;;;;AAoBA,SAAgB,uBACd,SACA,SAC0D;CAC1D,IAAI,QAAQ,YAAY;EACtB,MAAM,MAAM,cAAc,QAAQ;EAClC,IAAI,OAAO,SAAS,OAAO;GAAE;GAAK,YAAY,uBAAuB,QAAQ,IAAI;EAAE;CACrF;CAEA,IAAI,QAAQ,MAAM;EAChB,MAAM,MAAM,QAAQ,QAAQ;EAC5B,IAAI,OAAO,SAAS,OAAO;GAAE;GAAK,YAAY,uBAAuB,QAAQ,IAAI;EAAE;CACrF;CAEA,IAAI,aAA4B;CAChC,KAAK,MAAM,OAAO,OAAO,KAAK,OAAO,GAAG;EACtC,IAAI,CAAC,IAAI,WAAW,GAAG,GAAG;EAC1B,IAAI,QAAQ,SAAS,WAAW,GAAG,MAAM,CAAC,cAAc,IAAI,SAAS,WAAW,SAC9E,aAAa;CAEjB;CACA,IAAI,YAAY,OAAO;EAAE,KAAK;EAAY,YAAY,uBAAuB,QAAQ,WAAW;CAAE;CAElG,OAAO;AACT"}
@@ -1,11 +1,19 @@
1
1
  import { Config } from "@puckeditor/core";
2
-
3
2
  //#region src/puck-config.d.ts
4
3
  /**
5
4
  * Shared state for Puck config across module instances.
6
5
  * Uses window to ensure virtual modules and bundled code share the same state.
7
6
  */
8
7
  type PuckConfig = Config;
8
+ interface SharedPuckState {
9
+ config: PuckConfig;
10
+ subscribers: Set<(config: PuckConfig) => void>;
11
+ }
12
+ declare global {
13
+ interface Window {
14
+ __PUCK_STATE__?: SharedPuckState;
15
+ }
16
+ }
9
17
  /**
10
18
  * Set the Puck config. Called by the virtual module that loads user's config.
11
19
  * Notifies all subscribers of the change (enables HMR).
@@ -1 +1 @@
1
- {"version":3,"file":"puck-config.d.mts","names":[],"sources":["../src/puck-config.ts"],"mappings":";;;;;AAA+C;;KAQ1C,UAAA,GAAa,MAAA;;;AAyBlB;;iBAAgB,aAAA,CAAc,MAAA,EAAQ,UAAA;;;AAStC;iBAAgB,aAAA,CAAA,GAAiB,UAAA;;;;AAQjC;iBAAgB,aAAA,CAAA,GAAiB,UAAA"}
1
+ {"version":3,"file":"puck-config.d.mts","names":[],"sources":["../src/puck-config.ts"],"mappings":";;;;;;KAQK,aAAa;UAER;EACR,QAAQ;EACR,aAAa,KAAK,QAAQ;;QAGpB;YACI;IACR,iBAAiB;;;;;;;iBAsBL,cAAc,QAAQ;;;;iBAWtB,iBAAiB;;;;;iBAQjB,iBAAiB"}
@@ -0,0 +1,31 @@
1
+ import type { Config } from '@puckeditor/core';
2
+ /**
3
+ * Shared state for Puck config across module instances.
4
+ * Uses window to ensure virtual modules and bundled code share the same state.
5
+ */
6
+ type PuckConfig = Config;
7
+ interface SharedPuckState {
8
+ config: PuckConfig;
9
+ subscribers: Set<(config: PuckConfig) => void>;
10
+ }
11
+ declare global {
12
+ interface Window {
13
+ __PUCK_STATE__?: SharedPuckState;
14
+ }
15
+ }
16
+ /**
17
+ * Set the Puck config. Called by the virtual module that loads user's config.
18
+ * Notifies all subscribers of the change (enables HMR).
19
+ */
20
+ export declare function setPuckConfig(config: PuckConfig): void;
21
+ /**
22
+ * Get the current Puck config synchronously.
23
+ */
24
+ export declare function getPuckConfig(): PuckConfig;
25
+ /**
26
+ * React hook to subscribe to Puck config changes.
27
+ * Returns the current config and updates when it changes (HMR support).
28
+ */
29
+ export declare function usePuckConfig(): PuckConfig;
30
+ export {};
31
+ //# sourceMappingURL=puck-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"puck-config.d.ts","sourceRoot":"","sources":["../src/puck-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG/C;;;GAGG;AAEH,KAAK,UAAU,GAAG,MAAM,CAAC;AAEzB,UAAU,eAAe;IACvB,MAAM,EAAE,UAAU,CAAC;IACnB,WAAW,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC,CAAC;CAChD;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,cAAc,CAAC,EAAE,eAAe,CAAC;KAClC;CACF;AAgBD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAMtD;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,UAAU,CAE1C;AAED;;;GAGG;AACH,wBAAgB,aAAa,IAAI,UAAU,CAkB1C"}
@@ -0,0 +1,50 @@
1
+ import { useEffect, useState } from 'react';
2
+ const getSharedState = () => {
3
+ if (typeof window !== 'undefined') {
4
+ if (!window.__PUCK_STATE__) {
5
+ window.__PUCK_STATE__ = {
6
+ config: { components: {} },
7
+ subscribers: new Set(),
8
+ };
9
+ }
10
+ return window.__PUCK_STATE__;
11
+ }
12
+ // SSR fallback
13
+ return { config: { components: {} }, subscribers: new Set() };
14
+ };
15
+ /**
16
+ * Set the Puck config. Called by the virtual module that loads user's config.
17
+ * Notifies all subscribers of the change (enables HMR).
18
+ */
19
+ export function setPuckConfig(config) {
20
+ const state = getSharedState();
21
+ state.config = config;
22
+ for (const fn of state.subscribers) {
23
+ fn(config);
24
+ }
25
+ }
26
+ /**
27
+ * Get the current Puck config synchronously.
28
+ */
29
+ export function getPuckConfig() {
30
+ return getSharedState().config;
31
+ }
32
+ /**
33
+ * React hook to subscribe to Puck config changes.
34
+ * Returns the current config and updates when it changes (HMR support).
35
+ */
36
+ export function usePuckConfig() {
37
+ const [config, setConfig] = useState(() => getSharedState().config);
38
+ useEffect(() => {
39
+ const state = getSharedState();
40
+ // Update immediately in case config changed between render and effect
41
+ if (state.config !== config) {
42
+ setConfig(state.config);
43
+ }
44
+ state.subscribers.add(setConfig);
45
+ return () => {
46
+ state.subscribers.delete(setConfig);
47
+ };
48
+ }, [config]);
49
+ return config;
50
+ }
@@ -1,5 +1,4 @@
1
1
  import { useEffect, useState } from "react";
2
-
3
2
  //#region src/puck-config.ts
4
3
  const getSharedState = () => {
5
4
  if (typeof window !== "undefined") {
@@ -21,7 +20,7 @@ const getSharedState = () => {
21
20
  function setPuckConfig(config) {
22
21
  const state = getSharedState();
23
22
  state.config = config;
24
- state.subscribers.forEach((fn) => fn(config));
23
+ for (const fn of state.subscribers) fn(config);
25
24
  }
26
25
  /**
27
26
  * Get the current Puck config synchronously.
@@ -42,10 +41,10 @@ function usePuckConfig() {
42
41
  return () => {
43
42
  state.subscribers.delete(setConfig);
44
43
  };
45
- }, []);
44
+ }, [config]);
46
45
  return config;
47
46
  }
48
-
49
47
  //#endregion
50
48
  export { getPuckConfig, setPuckConfig, usePuckConfig };
49
+
51
50
  //# sourceMappingURL=puck-config.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"puck-config.mjs","names":[],"sources":["../src/puck-config.ts"],"sourcesContent":["import type { Config } from '@puckeditor/core';\nimport { useEffect, useState } from 'react';\n\n/**\n * Shared state for Puck config across module instances.\n * Uses window to ensure virtual modules and bundled code share the same state.\n */\n\ntype PuckConfig = Config;\n\ninterface SharedPuckState {\n config: PuckConfig;\n subscribers: Set<(config: PuckConfig) => void>;\n}\n\nconst getSharedState = (): SharedPuckState => {\n if (typeof window !== 'undefined') {\n if (!(window as any).__PUCK_STATE__) {\n (window as any).__PUCK_STATE__ = {\n config: { components: {} },\n subscribers: new Set(),\n };\n }\n return (window as any).__PUCK_STATE__;\n }\n // SSR fallback\n return { config: { components: {} }, subscribers: new Set() };\n};\n\n/**\n * Set the Puck config. Called by the virtual module that loads user's config.\n * Notifies all subscribers of the change (enables HMR).\n */\nexport function setPuckConfig(config: PuckConfig): void {\n const state = getSharedState();\n state.config = config;\n state.subscribers.forEach((fn) => fn(config));\n}\n\n/**\n * Get the current Puck config synchronously.\n */\nexport function getPuckConfig(): PuckConfig {\n return getSharedState().config;\n}\n\n/**\n * React hook to subscribe to Puck config changes.\n * Returns the current config and updates when it changes (HMR support).\n */\nexport function usePuckConfig(): PuckConfig {\n const [config, setConfig] = useState(() => getSharedState().config);\n\n useEffect(() => {\n const state = getSharedState();\n\n // Update immediately in case config changed between render and effect\n if (state.config !== config) {\n setConfig(state.config);\n }\n\n state.subscribers.add(setConfig);\n return () => {\n state.subscribers.delete(setConfig);\n };\n }, []);\n\n return config;\n}\n"],"mappings":";;;AAeA,MAAM,uBAAwC;AAC5C,KAAI,OAAO,WAAW,aAAa;AACjC,MAAI,CAAE,OAAe,eACnB,CAAC,OAAe,iBAAiB;GAC/B,QAAQ,EAAE,YAAY,EAAE,EAAE;GAC1B,6BAAa,IAAI,KAAK;GACvB;AAEH,SAAQ,OAAe;;AAGzB,QAAO;EAAE,QAAQ,EAAE,YAAY,EAAE,EAAE;EAAE,6BAAa,IAAI,KAAK;EAAE;;;;;;AAO/D,SAAgB,cAAc,QAA0B;CACtD,MAAM,QAAQ,gBAAgB;AAC9B,OAAM,SAAS;AACf,OAAM,YAAY,SAAS,OAAO,GAAG,OAAO,CAAC;;;;;AAM/C,SAAgB,gBAA4B;AAC1C,QAAO,gBAAgB,CAAC;;;;;;AAO1B,SAAgB,gBAA4B;CAC1C,MAAM,CAAC,QAAQ,aAAa,eAAe,gBAAgB,CAAC,OAAO;AAEnE,iBAAgB;EACd,MAAM,QAAQ,gBAAgB;AAG9B,MAAI,MAAM,WAAW,OACnB,WAAU,MAAM,OAAO;AAGzB,QAAM,YAAY,IAAI,UAAU;AAChC,eAAa;AACX,SAAM,YAAY,OAAO,UAAU;;IAEpC,EAAE,CAAC;AAEN,QAAO"}
1
+ {"version":3,"file":"puck-config.mjs","names":[],"sources":["../src/puck-config.ts"],"sourcesContent":["import type { Config } from '@puckeditor/core';\nimport { useEffect, useState } from 'react';\n\n/**\n * Shared state for Puck config across module instances.\n * Uses window to ensure virtual modules and bundled code share the same state.\n */\n\ntype PuckConfig = Config;\n\ninterface SharedPuckState {\n config: PuckConfig;\n subscribers: Set<(config: PuckConfig) => void>;\n}\n\ndeclare global {\n interface Window {\n __PUCK_STATE__?: SharedPuckState;\n }\n}\n\nconst getSharedState = (): SharedPuckState => {\n if (typeof window !== 'undefined') {\n if (!window.__PUCK_STATE__) {\n window.__PUCK_STATE__ = {\n config: { components: {} },\n subscribers: new Set(),\n };\n }\n return window.__PUCK_STATE__;\n }\n // SSR fallback\n return { config: { components: {} }, subscribers: new Set() };\n};\n\n/**\n * Set the Puck config. Called by the virtual module that loads user's config.\n * Notifies all subscribers of the change (enables HMR).\n */\nexport function setPuckConfig(config: PuckConfig): void {\n const state = getSharedState();\n state.config = config;\n for (const fn of state.subscribers) {\n fn(config);\n }\n}\n\n/**\n * Get the current Puck config synchronously.\n */\nexport function getPuckConfig(): PuckConfig {\n return getSharedState().config;\n}\n\n/**\n * React hook to subscribe to Puck config changes.\n * Returns the current config and updates when it changes (HMR support).\n */\nexport function usePuckConfig(): PuckConfig {\n const [config, setConfig] = useState(() => getSharedState().config);\n\n useEffect(() => {\n const state = getSharedState();\n\n // Update immediately in case config changed between render and effect\n if (state.config !== config) {\n setConfig(state.config);\n }\n\n state.subscribers.add(setConfig);\n return () => {\n state.subscribers.delete(setConfig);\n };\n }, [config]);\n\n return config;\n}\n"],"mappings":";;AAqBA,MAAM,uBAAwC;CAC5C,IAAI,OAAO,WAAW,aAAa;EACjC,IAAI,CAAC,OAAO,gBACV,OAAO,iBAAiB;GACtB,QAAQ,EAAE,YAAY,CAAC,EAAE;GACzB,6BAAa,IAAI,IAAI;EACvB;EAEF,OAAO,OAAO;CAChB;CAEA,OAAO;EAAE,QAAQ,EAAE,YAAY,CAAC,EAAE;EAAG,6BAAa,IAAI,IAAI;CAAE;AAC9D;;;;;AAMA,SAAgB,cAAc,QAA0B;CACtD,MAAM,QAAQ,eAAe;CAC7B,MAAM,SAAS;CACf,KAAK,MAAM,MAAM,MAAM,aACrB,GAAG,MAAM;AAEb;;;;AAKA,SAAgB,gBAA4B;CAC1C,OAAO,eAAe,CAAC,CAAC;AAC1B;;;;;AAMA,SAAgB,gBAA4B;CAC1C,MAAM,CAAC,QAAQ,aAAa,eAAe,eAAe,CAAC,CAAC,MAAM;CAElE,gBAAgB;EACd,MAAM,QAAQ,eAAe;EAG7B,IAAI,MAAM,WAAW,QACnB,UAAU,MAAM,MAAM;EAGxB,MAAM,YAAY,IAAI,SAAS;EAC/B,aAAa;GACX,MAAM,YAAY,OAAO,SAAS;EACpC;CACF,GAAG,CAAC,MAAM,CAAC;CAEX,OAAO;AACT"}
@@ -0,0 +1,61 @@
1
+ import type { MdxJsxComponentDescriptor } from './mdx-components';
2
+ /**
3
+ * Shared registry of the currently-selected MDX JSX block in the editor.
4
+ *
5
+ * The block (`GenericBlock`) is inside the MDXEditor realm and has access
6
+ * to its render-scoped hooks (`useMdastNodeUpdater`, `useLexicalNodeRemove`).
7
+ * The side panel needs to read the block's props AND push changes back
8
+ * through those same hooks, but it lives OUTSIDE the editor's render
9
+ * scope, so it can't call those hooks itself.
10
+ *
11
+ * The bridge: when a block becomes selected, it publishes a small record
12
+ * to this registry — descriptor + current attribute map + bound closures
13
+ * over its own updaters. The panel subscribes, renders the descriptor's
14
+ * `props` as form fields, and calls the closures on change. Updates flow
15
+ * back through the same path inline editing used.
16
+ *
17
+ * Mirrors the `siteStyles` / `mdxComponents` window-state pattern so HMR
18
+ * and SSR work consistently.
19
+ */
20
+ export interface SelectedBlock {
21
+ /** Stable per-block identity — the owning Lexical node's `getKey()`.
22
+ * Used to compare "am I the selected block?" across re-renders without
23
+ * tripping on closure-identity changes (`useLexicalNodeRemove` returns
24
+ * a fresh function every render, so we can't compare by callback). */
25
+ key: string;
26
+ /** Tag name (eg 'Aside'). Used as the panel heading. */
27
+ name: string;
28
+ /** Descriptor providing the prop schema. */
29
+ descriptor: MdxJsxComponentDescriptor;
30
+ /** Current attribute values from the mdast node. */
31
+ attrs: Record<string, unknown>;
32
+ /** Apply a prop change. Wrapped by the owning block over its updater.
33
+ * Accepts strings (text props), booleans (checkbox props), numbers
34
+ * (numeric inputs), or `null`/`undefined` (remove the attribute).
35
+ * The block routes the value through `writeAttribute` which picks
36
+ * the right mdast shape — string literal, JSX shorthand, or
37
+ * expression. */
38
+ onPropChange: (name: string, value: string | boolean | number | null | undefined) => void;
39
+ /** Remove the block from the document. */
40
+ onRemove: () => void;
41
+ }
42
+ interface SharedState {
43
+ selected: SelectedBlock | null;
44
+ subscribers: Set<(next: SelectedBlock | null) => void>;
45
+ }
46
+ declare global {
47
+ interface Window {
48
+ __CONLOCA_SELECTED_BLOCK__?: SharedState;
49
+ }
50
+ }
51
+ /** Replace the currently-selected block. Pass `null` to clear. */
52
+ export declare function setSelectedBlock(next: SelectedBlock | null): void;
53
+ /** Read synchronously. */
54
+ export declare function getSelectedBlock(): SelectedBlock | null;
55
+ /**
56
+ * Subscribe to the current selection in a React component. Returns `null`
57
+ * when nothing is selected.
58
+ */
59
+ export declare function useSelectedBlock(): SelectedBlock | null;
60
+ export {};
61
+ //# sourceMappingURL=selected-block.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selected-block.d.ts","sourceRoot":"","sources":["../src/selected-block.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAElE;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,WAAW,aAAa;IAC5B;;;0EAGsE;IACtE,GAAG,EAAE,MAAM,CAAC;IACZ,wDAAwD;IACxD,IAAI,EAAE,MAAM,CAAC;IACb,4CAA4C;IAC5C,UAAU,EAAE,yBAAyB,CAAC;IACtC,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B;;;;;qBAKiB;IACjB,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,KAAK,IAAI,CAAC;IAC1F,0CAA0C;IAC1C,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,UAAU,WAAW;IACnB,QAAQ,EAAE,aAAa,GAAG,IAAI,CAAC;IAC/B,WAAW,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI,KAAK,IAAI,CAAC,CAAC;CACxD;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,0BAA0B,CAAC,EAAE,WAAW,CAAC;KAC1C;CACF;AAmCD,kEAAkE;AAClE,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI,GAAG,IAAI,CAMjE;AAED,0BAA0B;AAC1B,wBAAgB,gBAAgB,IAAI,aAAa,GAAG,IAAI,CAEvD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,aAAa,GAAG,IAAI,CAavD"}
@@ -0,0 +1,64 @@
1
+ import { useEffect, useState } from 'react';
2
+ /**
3
+ * When the editor mounts in the parent SPA tree, the block lives
4
+ * in the iframe's window but the side panel reading the selection
5
+ * lives in the parent. To keep one registry shared across both, prefer
6
+ * `window.parent` whenever it's a different same-origin window — the
7
+ * editor-side writes hit the parent's set and the parent-side hook
8
+ * picks them up. Standalone (top-window) usage falls through to the
9
+ * current window unchanged.
10
+ */
11
+ function getRegistryHost() {
12
+ if (typeof window === 'undefined')
13
+ return undefined;
14
+ try {
15
+ if (window.parent && window.parent !== window) {
16
+ // Cross-origin access throws — gate access with the try/catch
17
+ // and fall back to the local window if the parent isn't ours.
18
+ void window.parent.document;
19
+ return window.parent;
20
+ }
21
+ }
22
+ catch {
23
+ return window;
24
+ }
25
+ return window;
26
+ }
27
+ function getState() {
28
+ const host = getRegistryHost();
29
+ if (!host)
30
+ return { selected: null, subscribers: new Set() };
31
+ if (!host.__CONLOCA_SELECTED_BLOCK__) {
32
+ host.__CONLOCA_SELECTED_BLOCK__ = { selected: null, subscribers: new Set() };
33
+ }
34
+ return host.__CONLOCA_SELECTED_BLOCK__;
35
+ }
36
+ /** Replace the currently-selected block. Pass `null` to clear. */
37
+ export function setSelectedBlock(next) {
38
+ const state = getState();
39
+ state.selected = next;
40
+ for (const fn of state.subscribers) {
41
+ fn(next);
42
+ }
43
+ }
44
+ /** Read synchronously. */
45
+ export function getSelectedBlock() {
46
+ return getState().selected;
47
+ }
48
+ /**
49
+ * Subscribe to the current selection in a React component. Returns `null`
50
+ * when nothing is selected.
51
+ */
52
+ export function useSelectedBlock() {
53
+ const [selected, setSelected] = useState(() => getState().selected);
54
+ useEffect(() => {
55
+ const state = getState();
56
+ if (state.selected !== selected)
57
+ setSelected(state.selected);
58
+ state.subscribers.add(setSelected);
59
+ return () => {
60
+ state.subscribers.delete(setSelected);
61
+ };
62
+ }, [selected]);
63
+ return selected;
64
+ }