@conloca/cms-spa 0.1.15 → 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.
- package/dist/App-Bk1LNxbS.mjs +10851 -0
- package/dist/App-Bk1LNxbS.mjs.map +1 -0
- package/dist/App.d.ts +35 -0
- package/dist/App.d.ts.map +1 -0
- package/dist/App.js +52 -0
- package/dist/CmsSpaApp.d.ts +13 -0
- package/dist/CmsSpaApp.d.ts.map +1 -0
- package/dist/CmsSpaApp.js +33 -0
- package/dist/cn-dlASUkDY.mjs +10 -0
- package/dist/cn-dlASUkDY.mjs.map +1 -0
- package/dist/components/CMSDashboard.d.ts +2 -0
- package/dist/components/CMSDashboard.d.ts.map +1 -0
- package/dist/components/CMSDashboard.js +20 -0
- package/dist/components/CMSLayout.d.ts +2 -0
- package/dist/components/CMSLayout.d.ts.map +1 -0
- package/dist/components/CMSLayout.js +15 -0
- package/dist/components/ConlocaLogo.d.ts +2 -0
- package/dist/components/ConlocaLogo.d.ts.map +1 -0
- package/dist/components/ConlocaLogo.js +4 -0
- package/dist/components/GitStatusPanel.d.ts +25 -0
- package/dist/components/GitStatusPanel.d.ts.map +1 -0
- package/dist/components/GitStatusPanel.js +77 -0
- package/dist/components/MobileTopBar.d.ts +6 -0
- package/dist/components/MobileTopBar.d.ts.map +1 -0
- package/dist/components/MobileTopBar.js +6 -0
- package/dist/components/Sidebar.d.ts +8 -0
- package/dist/components/Sidebar.d.ts.map +1 -0
- package/dist/components/Sidebar.js +40 -0
- package/dist/components/UserAvatar.d.ts +2 -0
- package/dist/components/UserAvatar.d.ts.map +1 -0
- package/dist/components/UserAvatar.js +14 -0
- package/dist/components/cards/DataEntryCard.d.ts +14 -0
- package/dist/components/cards/DataEntryCard.d.ts.map +1 -0
- package/dist/components/cards/DataEntryCard.js +32 -0
- package/dist/components/cards/SectionCard.d.ts +15 -0
- package/dist/components/cards/SectionCard.d.ts.map +1 -0
- package/dist/components/cards/SectionCard.js +10 -0
- package/dist/components/cards/index.d.ts +2 -0
- package/dist/components/cards/index.d.ts.map +1 -0
- package/dist/components/cards/index.js +1 -0
- package/dist/components/dashboard/RecentActivity.d.ts +2 -0
- package/dist/components/dashboard/RecentActivity.d.ts.map +1 -0
- package/dist/components/dashboard/RecentActivity.js +58 -0
- package/dist/components/dialog.d.ts +53 -0
- package/dist/components/dialog.d.ts.map +1 -0
- package/dist/components/dialog.js +56 -0
- package/dist/components/dialogs/BlockPropertiesDialog.d.ts +12 -0
- package/dist/components/dialogs/BlockPropertiesDialog.d.ts.map +1 -0
- package/dist/components/dialogs/BlockPropertiesDialog.js +42 -0
- package/dist/components/dialogs/ConflictDialog.d.ts +10 -0
- package/dist/components/dialogs/ConflictDialog.d.ts.map +1 -0
- package/dist/components/dialogs/ConflictDialog.js +29 -0
- package/dist/components/dialogs/CreateDataDialog.d.ts +9 -0
- package/dist/components/dialogs/CreateDataDialog.d.ts.map +1 -0
- package/dist/components/dialogs/CreateDataDialog.js +20 -0
- package/dist/components/dialogs/CreateFolderDialog.d.ts +9 -0
- package/dist/components/dialogs/CreateFolderDialog.d.ts.map +1 -0
- package/dist/components/dialogs/CreateFolderDialog.js +33 -0
- package/dist/components/dialogs/CreatePageDialog.d.ts +10 -0
- package/dist/components/dialogs/CreatePageDialog.d.ts.map +1 -0
- package/dist/components/dialogs/CreatePageDialog.js +155 -0
- package/dist/components/dialogs/DataPropertiesDialog.d.ts +10 -0
- package/dist/components/dialogs/DataPropertiesDialog.d.ts.map +1 -0
- package/dist/components/dialogs/DataPropertiesDialog.js +38 -0
- package/dist/components/dialogs/DeleteConfirmDialog.d.ts +12 -0
- package/dist/components/dialogs/DeleteConfirmDialog.d.ts.map +1 -0
- package/dist/components/dialogs/DeleteConfirmDialog.js +7 -0
- package/dist/components/dialogs/ErrorModal.d.ts +14 -0
- package/dist/components/dialogs/ErrorModal.d.ts.map +1 -0
- package/dist/components/dialogs/ErrorModal.js +38 -0
- package/dist/components/dialogs/MoveFolderDialog.d.ts +11 -0
- package/dist/components/dialogs/MoveFolderDialog.d.ts.map +1 -0
- package/dist/components/dialogs/MoveFolderDialog.js +45 -0
- package/dist/components/dialogs/PageMetadataDialog.d.ts +10 -0
- package/dist/components/dialogs/PageMetadataDialog.d.ts.map +1 -0
- package/dist/components/dialogs/PageMetadataDialog.js +85 -0
- package/dist/components/dialogs/UnsavedChangesDialog.d.ts +8 -0
- package/dist/components/dialogs/UnsavedChangesDialog.d.ts.map +1 -0
- package/dist/components/dialogs/UnsavedChangesDialog.js +6 -0
- package/dist/components/dialogs/index.d.ts +9 -0
- package/dist/components/dialogs/index.d.ts.map +1 -0
- package/dist/components/dialogs/index.js +8 -0
- package/dist/components/editor/BlockEditor.d.ts +8 -0
- package/dist/components/editor/BlockEditor.d.ts.map +1 -0
- package/dist/components/editor/BlockEditor.js +262 -0
- package/dist/components/editor/BlockWrappers.d.ts +15 -0
- package/dist/components/editor/BlockWrappers.d.ts.map +1 -0
- package/dist/components/editor/BlockWrappers.js +29 -0
- package/dist/components/editor/CMSMDXEditor.d.ts +13 -0
- package/dist/components/editor/CMSMDXEditor.d.ts.map +1 -0
- package/dist/components/editor/CMSMDXEditor.js +123 -0
- package/dist/components/editor/ContentDiff.d.ts +10 -0
- package/dist/components/editor/ContentDiff.d.ts.map +1 -0
- package/dist/components/editor/ContentDiff.js +51 -0
- package/dist/components/editor/CreateBlockDialog.d.ts +26 -0
- package/dist/components/editor/CreateBlockDialog.d.ts.map +1 -0
- package/dist/components/editor/CreateBlockDialog.js +131 -0
- package/dist/components/editor/DrawerItemOverride.d.ts +8 -0
- package/dist/components/editor/DrawerItemOverride.d.ts.map +1 -0
- package/dist/components/editor/DrawerItemOverride.js +41 -0
- package/dist/components/editor/EditorChromeToggles.d.ts +16 -0
- package/dist/components/editor/EditorChromeToggles.d.ts.map +1 -0
- package/dist/components/editor/EditorChromeToggles.js +16 -0
- package/dist/components/editor/GenericBlock.d.ts +3 -0
- package/dist/components/editor/GenericBlock.d.ts.map +1 -0
- package/dist/components/editor/GenericBlock.js +1067 -0
- package/dist/components/editor/ImagePickerDialog.d.ts +6 -0
- package/dist/components/editor/ImagePickerDialog.d.ts.map +1 -0
- package/dist/components/editor/ImagePickerDialog.js +24 -0
- package/dist/components/editor/JsxPropsPanel.d.ts +16 -0
- package/dist/components/editor/JsxPropsPanel.d.ts.map +1 -0
- package/dist/components/editor/JsxPropsPanel.js +145 -0
- package/dist/components/editor/LocaleSelector.d.ts +9 -0
- package/dist/components/editor/LocaleSelector.d.ts.map +1 -0
- package/dist/components/editor/LocaleSelector.js +13 -0
- package/dist/components/editor/MDXLivePreview.d.ts +14 -0
- package/dist/components/editor/MDXLivePreview.d.ts.map +1 -0
- package/dist/components/editor/MDXLivePreview.js +103 -0
- package/dist/components/editor/MdxPageEditor.d.ts +10 -0
- package/dist/components/editor/MdxPageEditor.d.ts.map +1 -0
- package/dist/components/editor/MdxPageEditor.js +297 -0
- package/dist/components/editor/PageEditor.d.ts +18 -0
- package/dist/components/editor/PageEditor.d.ts.map +1 -0
- package/dist/components/editor/PageEditor.js +288 -0
- package/dist/components/editor/PageEditorHeaderActions.d.ts +16 -0
- package/dist/components/editor/PageEditorHeaderActions.d.ts.map +1 -0
- package/dist/components/editor/PageEditorHeaderActions.js +19 -0
- package/dist/components/editor/PageEditorWrapper.d.ts +7 -0
- package/dist/components/editor/PageEditorWrapper.d.ts.map +1 -0
- package/dist/components/editor/PageEditorWrapper.js +319 -0
- package/dist/components/editor/SearchableSelect.d.ts +34 -0
- package/dist/components/editor/SearchableSelect.d.ts.map +1 -0
- package/dist/components/editor/SearchableSelect.js +116 -0
- package/dist/components/editor/host-wrapper-plugin.d.ts +51 -0
- package/dist/components/editor/host-wrapper-plugin.d.ts.map +1 -0
- package/dist/components/editor/host-wrapper-plugin.js +37 -0
- package/dist/components/editor/index.d.ts +9 -0
- package/dist/components/editor/index.d.ts.map +1 -0
- package/dist/components/editor/index.js +7 -0
- package/dist/components/editor/insert-menu/InsertMdxComponentButton.d.ts +15 -0
- package/dist/components/editor/insert-menu/InsertMdxComponentButton.d.ts.map +1 -0
- package/dist/components/editor/insert-menu/InsertMdxComponentButton.js +90 -0
- package/dist/components/editor/insert-menu/SlashMenuPlugin.d.ts +12 -0
- package/dist/components/editor/insert-menu/SlashMenuPlugin.d.ts.map +1 -0
- package/dist/components/editor/insert-menu/SlashMenuPlugin.js +106 -0
- package/dist/components/editor/insert-menu/insert-payload.d.ts +76 -0
- package/dist/components/editor/insert-menu/insert-payload.d.ts.map +1 -0
- package/dist/components/editor/insert-menu/insert-payload.js +94 -0
- package/dist/components/editor/insert-menu/mdx-components-plugin.d.ts +8 -0
- package/dist/components/editor/insert-menu/mdx-components-plugin.d.ts.map +1 -0
- package/dist/components/editor/insert-menu/mdx-components-plugin.js +13 -0
- package/dist/components/editors/DataEditor.d.ts +19 -0
- package/dist/components/editors/DataEditor.d.ts.map +1 -0
- package/dist/components/editors/DataEditor.js +139 -0
- package/dist/components/fields/ContentBlockSelectorField.d.ts +14 -0
- package/dist/components/fields/ContentBlockSelectorField.d.ts.map +1 -0
- package/dist/components/fields/ContentBlockSelectorField.js +105 -0
- package/dist/components/fields/ImageField.d.ts +16 -0
- package/dist/components/fields/ImageField.d.ts.map +1 -0
- package/dist/components/fields/ImageField.js +39 -0
- package/dist/components/fields/MDXEditField.d.ts +17 -0
- package/dist/components/fields/MDXEditField.d.ts.map +1 -0
- package/dist/components/fields/MDXEditField.js +28 -0
- package/dist/components/forms/ChipArrayField.d.ts +12 -0
- package/dist/components/forms/ChipArrayField.d.ts.map +1 -0
- package/dist/components/forms/ChipArrayField.js +40 -0
- package/dist/components/forms/HintForm.d.ts +22 -0
- package/dist/components/forms/HintForm.d.ts.map +1 -0
- package/dist/components/forms/HintForm.js +162 -0
- package/dist/components/forms/SchemaForm.d.ts +15 -0
- package/dist/components/forms/SchemaForm.d.ts.map +1 -0
- package/dist/components/forms/SchemaForm.js +106 -0
- package/dist/components/index.d.ts +8 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +13 -0
- package/dist/components/media/AssetCard.d.ts +14 -0
- package/dist/components/media/AssetCard.d.ts.map +1 -0
- package/dist/components/media/AssetCard.js +31 -0
- package/dist/components/media/AssetDetailSidebar.d.ts +11 -0
- package/dist/components/media/AssetDetailSidebar.d.ts.map +1 -0
- package/dist/components/media/AssetDetailSidebar.js +101 -0
- package/dist/components/media/BulkActionBar.d.ts +9 -0
- package/dist/components/media/BulkActionBar.d.ts.map +1 -0
- package/dist/components/media/BulkActionBar.js +8 -0
- package/dist/components/media/FolderNav.d.ts +7 -0
- package/dist/components/media/FolderNav.d.ts.map +1 -0
- package/dist/components/media/FolderNav.js +12 -0
- package/dist/components/media/FolderTreeSidebar.d.ts +9 -0
- package/dist/components/media/FolderTreeSidebar.d.ts.map +1 -0
- package/dist/components/media/FolderTreeSidebar.js +41 -0
- package/dist/components/media/ImagePicker.d.ts +14 -0
- package/dist/components/media/ImagePicker.d.ts.map +1 -0
- package/dist/components/media/ImagePicker.js +45 -0
- package/dist/components/media/MediaLibrary.d.ts +35 -0
- package/dist/components/media/MediaLibrary.d.ts.map +1 -0
- package/dist/components/media/MediaLibrary.js +100 -0
- package/dist/components/media/MediaToolbar.d.ts +21 -0
- package/dist/components/media/MediaToolbar.d.ts.map +1 -0
- package/dist/components/media/MediaToolbar.js +6 -0
- package/dist/components/media/UploadModal.d.ts +9 -0
- package/dist/components/media/UploadModal.d.ts.map +1 -0
- package/dist/components/media/UploadModal.js +42 -0
- package/dist/components/media/UploadZone.d.ts +8 -0
- package/dist/components/media/UploadZone.d.ts.map +1 -0
- package/dist/components/media/UploadZone.js +22 -0
- package/dist/components/media/index.d.ts +11 -0
- package/dist/components/media/index.d.ts.map +1 -0
- package/dist/components/media/index.js +10 -0
- package/dist/components/pages/BlockList.d.ts +2 -0
- package/dist/components/pages/BlockList.d.ts.map +1 -0
- package/dist/components/pages/BlockList.js +280 -0
- package/dist/components/pages/DataList.d.ts +7 -0
- package/dist/components/pages/DataList.d.ts.map +1 -0
- package/dist/components/pages/DataList.js +244 -0
- package/dist/components/pages/MediaPage.d.ts +8 -0
- package/dist/components/pages/MediaPage.d.ts.map +1 -0
- package/dist/components/pages/MediaPage.js +107 -0
- package/dist/components/pages/PageList.d.ts +7 -0
- package/dist/components/pages/PageList.d.ts.map +1 -0
- package/dist/components/pages/PageList.js +308 -0
- package/dist/components/pages/index.d.ts +3 -0
- package/dist/components/pages/index.d.ts.map +1 -0
- package/dist/components/pages/index.js +2 -0
- package/dist/components/puck/MDXContent.d.ts +10 -0
- package/dist/components/puck/MDXContent.d.ts.map +1 -0
- package/dist/components/puck/MDXContent.js +80 -0
- package/dist/components/puck/index.d.ts +2 -0
- package/dist/components/puck/index.d.ts.map +1 -0
- package/dist/components/puck/index.js +1 -0
- package/dist/components/toast.d.ts +44 -0
- package/dist/components/toast.d.ts.map +1 -0
- package/dist/components/toast.js +7 -0
- package/dist/components/ui/Banner.d.ts +76 -0
- package/dist/components/ui/Banner.d.ts.map +1 -0
- package/dist/components/ui/Banner.js +49 -0
- package/dist/components/ui/Button.d.ts +25 -0
- package/dist/components/ui/Button.d.ts.map +1 -0
- package/dist/components/ui/Button.js +33 -0
- package/dist/components/ui/Card.d.ts +72 -0
- package/dist/components/ui/Card.d.ts.map +1 -0
- package/dist/components/ui/Card.js +49 -0
- package/dist/components/ui/FieldError.d.ts +24 -0
- package/dist/components/ui/FieldError.d.ts.map +1 -0
- package/dist/components/ui/FieldError.js +17 -0
- package/dist/components/ui/IconButton.d.ts +13 -0
- package/dist/components/ui/IconButton.d.ts.map +1 -0
- package/dist/components/ui/IconButton.js +10 -0
- package/dist/components/ui/Input.d.ts +37 -0
- package/dist/components/ui/Input.d.ts.map +1 -0
- package/dist/components/ui/Input.js +9 -0
- package/dist/components/ui/SaveIndicator.d.ts +8 -0
- package/dist/components/ui/SaveIndicator.d.ts.map +1 -0
- package/dist/components/ui/SaveIndicator.js +32 -0
- package/dist/components/ui/Select.d.ts +8 -0
- package/dist/components/ui/Select.d.ts.map +1 -0
- package/dist/components/ui/Select.js +9 -0
- package/dist/components/ui/Separator.d.ts +7 -0
- package/dist/components/ui/Separator.d.ts.map +1 -0
- package/dist/components/ui/Separator.js +8 -0
- package/dist/components/ui/Textarea.d.ts +8 -0
- package/dist/components/ui/Textarea.d.ts.map +1 -0
- package/dist/components/ui/Textarea.js +5 -0
- package/dist/components/ui/Tooltip.d.ts +9 -0
- package/dist/components/ui/Tooltip.d.ts.map +1 -0
- package/dist/components/ui/Tooltip.js +7 -0
- package/dist/components/ui/index.d.ts +14 -0
- package/dist/components/ui/index.d.ts.map +1 -0
- package/dist/components/ui/index.js +17 -0
- package/dist/data-schemas.d.mts +0 -1
- package/dist/data-schemas.d.mts.map +1 -1
- package/dist/data-schemas.d.ts +22 -0
- package/dist/data-schemas.d.ts.map +1 -0
- package/dist/data-schemas.js +51 -0
- package/dist/data-schemas.mjs +3 -4
- package/dist/data-schemas.mjs.map +1 -1
- package/dist/dev-entry.d.ts +2 -0
- package/dist/dev-entry.d.ts.map +1 -0
- package/dist/dev-entry.js +19 -0
- package/dist/dialog.d.mts +56 -0
- package/dist/dialog.d.mts.map +1 -0
- package/dist/dialog.mjs +67 -0
- package/dist/dialog.mjs.map +1 -0
- package/dist/hooks/index.d.ts +10 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +7 -0
- package/dist/hooks/useCanvasTheme.d.ts +12 -0
- package/dist/hooks/useCanvasTheme.d.ts.map +1 -0
- package/dist/hooks/useCanvasTheme.js +33 -0
- package/dist/hooks/useClickOutside.d.ts +7 -0
- package/dist/hooks/useClickOutside.d.ts.map +1 -0
- package/dist/hooks/useClickOutside.js +18 -0
- package/dist/hooks/useDialogState.d.ts +23 -0
- package/dist/hooks/useDialogState.d.ts.map +1 -0
- package/dist/hooks/useDialogState.js +31 -0
- package/dist/hooks/useEditorPref.d.ts +2 -0
- package/dist/hooks/useEditorPref.d.ts.map +1 -0
- package/dist/hooks/useEditorPref.js +49 -0
- package/dist/hooks/useErrorModal.d.ts +15 -0
- package/dist/hooks/useErrorModal.d.ts.map +1 -0
- package/dist/hooks/useErrorModal.js +35 -0
- package/dist/hooks/useSiteBaseUrl.d.ts +10 -0
- package/dist/hooks/useSiteBaseUrl.d.ts.map +1 -0
- package/dist/hooks/useSiteBaseUrl.js +14 -0
- package/dist/hooks/useTheme.d.ts +13 -0
- package/dist/hooks/useTheme.d.ts.map +1 -0
- package/dist/hooks/useTheme.js +69 -0
- package/dist/hooks/useUnsavedChangesGuard.d.ts +16 -0
- package/dist/hooks/useUnsavedChangesGuard.d.ts.map +1 -0
- package/dist/hooks/useUnsavedChangesGuard.js +29 -0
- package/dist/hooks/useUpload.d.ts +10 -0
- package/dist/hooks/useUpload.d.ts.map +1 -0
- package/dist/hooks/useUpload.js +42 -0
- package/dist/hooks/useUploadFlow.d.ts +42 -0
- package/dist/hooks/useUploadFlow.d.ts.map +1 -0
- package/dist/hooks/useUploadFlow.js +148 -0
- package/dist/host-style-probe.d.ts +22 -0
- package/dist/host-style-probe.d.ts.map +1 -0
- package/dist/host-style-probe.js +508 -0
- package/dist/index.d.mts +167 -39
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.mjs +36 -2
- package/dist/index.mjs.map +1 -0
- package/dist/lib/utils.d.ts +13 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +47 -0
- package/dist/main-spa-781YUplS.mjs +46 -0
- package/dist/main-spa-781YUplS.mjs.map +1 -0
- package/dist/main-spa.d.ts +8 -0
- package/dist/main-spa.d.ts.map +1 -0
- package/dist/main-spa.js +61 -0
- package/dist/main.d.mts +1 -1
- package/dist/main.d.ts +2 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +13 -0
- package/dist/main.mjs +11 -5681
- package/dist/main.mjs.map +1 -1
- package/dist/mdx-components.d.mts +207 -0
- package/dist/mdx-components.d.mts.map +1 -0
- package/dist/mdx-components.d.ts +204 -0
- package/dist/mdx-components.d.ts.map +1 -0
- package/dist/mdx-components.js +217 -0
- package/dist/mdx-components.mjs +208 -0
- package/dist/mdx-components.mjs.map +1 -0
- package/dist/media/AssetScopePill.d.ts +30 -0
- package/dist/media/AssetScopePill.d.ts.map +1 -0
- package/dist/media/AssetScopePill.js +30 -0
- package/dist/media/MediaIssueBadge.d.ts +33 -0
- package/dist/media/MediaIssueBadge.d.ts.map +1 -0
- package/dist/media/MediaIssueBadge.js +54 -0
- package/dist/media/types.d.ts +101 -0
- package/dist/media/types.d.ts.map +1 -0
- package/dist/media/types.js +1 -0
- package/dist/media/use-asset-scope.d.ts +25 -0
- package/dist/media/use-asset-scope.d.ts.map +1 -0
- package/dist/media/use-asset-scope.js +54 -0
- package/dist/media/use-media-issue.d.ts +24 -0
- package/dist/media/use-media-issue.d.ts.map +1 -0
- package/dist/media/use-media-issue.js +49 -0
- package/dist/mock-puck-config.d.mts +23 -0
- package/dist/mock-puck-config.d.mts.map +1 -0
- package/dist/mock-puck-config.d.ts +21 -0
- package/dist/mock-puck-config.d.ts.map +1 -0
- package/dist/mock-puck-config.js +73 -0
- package/dist/mock-puck-config.mjs +125 -0
- package/dist/mock-puck-config.mjs.map +1 -0
- package/dist/page-schemas.d.mts +139 -6
- package/dist/page-schemas.d.mts.map +1 -1
- package/dist/page-schemas.d.ts +156 -0
- package/dist/page-schemas.d.ts.map +1 -0
- package/dist/page-schemas.js +118 -0
- package/dist/page-schemas.mjs +74 -6
- package/dist/page-schemas.mjs.map +1 -1
- package/dist/puck-config.d.mts +0 -1
- package/dist/puck-config.d.mts.map +1 -1
- package/dist/puck-config.d.ts +31 -0
- package/dist/puck-config.d.ts.map +1 -0
- package/dist/puck-config.js +50 -0
- package/dist/puck-config.mjs +3 -4
- package/dist/puck-config.mjs.map +1 -1
- package/dist/selected-block.d.ts +61 -0
- package/dist/selected-block.d.ts.map +1 -0
- package/dist/selected-block.js +64 -0
- package/dist/site-styles.d.mts +90 -8
- package/dist/site-styles.d.mts.map +1 -1
- package/dist/site-styles.d.ts +121 -0
- package/dist/site-styles.d.ts.map +1 -0
- package/dist/site-styles.js +253 -0
- package/dist/site-styles.mjs +187 -5
- package/dist/site-styles.mjs.map +1 -1
- package/dist/spa/main.css +690 -127
- package/dist/toast.d.mts +7 -0
- package/dist/toast.d.mts.map +1 -0
- package/dist/toast.mjs +16 -0
- package/dist/toast.mjs.map +1 -0
- package/dist/types.d.ts +57 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/dist/ui-CIacC6Mv.mjs +318 -0
- package/dist/ui-CIacC6Mv.mjs.map +1 -0
- package/dist/ui-config.d.ts +70 -0
- package/dist/ui-config.d.ts.map +1 -0
- package/dist/ui-config.js +44 -0
- package/dist/ui.d.mts +290 -0
- package/dist/ui.d.mts.map +1 -0
- package/dist/ui.mjs +2 -0
- package/dist/utils/asset-url.d.ts +3 -0
- package/dist/utils/asset-url.d.ts.map +1 -0
- package/dist/utils/asset-url.js +7 -0
- package/dist/utils/cn.d.ts +3 -0
- package/dist/utils/cn.d.ts.map +1 -0
- package/dist/utils/cn.js +5 -0
- package/dist/utils/format-date.d.ts +15 -0
- package/dist/utils/format-date.d.ts.map +1 -0
- package/dist/utils/format-date.js +37 -0
- package/dist/utils/mdast-to-html.d.ts +55 -0
- package/dist/utils/mdast-to-html.d.ts.map +1 -0
- package/dist/utils/mdast-to-html.js +206 -0
- package/dist/utils/mdast-tree.d.ts +104 -0
- package/dist/utils/mdast-tree.d.ts.map +1 -0
- package/dist/utils/mdast-tree.js +285 -0
- package/dist/utils/pageMetadata.d.ts +67 -0
- package/dist/utils/pageMetadata.d.ts.map +1 -0
- package/dist/utils/pageMetadata.js +161 -0
- package/dist/utils/slugify.d.ts +12 -0
- package/dist/utils/slugify.d.ts.map +1 -0
- package/dist/utils/slugify.js +17 -0
- package/dist/utils/zodIntrospect.d.ts +24 -0
- package/dist/utils/zodIntrospect.d.ts.map +1 -0
- package/dist/utils/zodIntrospect.js +88 -0
- package/package.json +148 -35
- package/styles/styles.css.d.ts +2 -0
- package/styles/tailwind-theme.css +126 -0
- package/styles/tailwind-theme.css.d.ts +2 -0
- package/dist/puck-C9_F3_cJ.mjs +0 -1589
- package/dist/puck-C9_F3_cJ.mjs.map +0 -1
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Two parallel registries for host-supplied CSS strings: `siteStyles` for the
|
|
3
|
+
* Puck preview iframe (full page styling, Tailwind included), and
|
|
4
|
+
* `editorStyles` for the MDX editor admin shell (narrow component CSS only).
|
|
5
|
+
*
|
|
6
|
+
* Each registry has an astro-cms virtual module (`${cmsRoute}/site-styles.js`
|
|
7
|
+
* and `${cmsRoute}/editor-styles.js`) that imports the configured CSS files
|
|
8
|
+
* with Vite's `?inline` query (so the full CSS pipeline runs) and calls the
|
|
9
|
+
* corresponding setter. Consumers read via the matching hook.
|
|
10
|
+
*
|
|
11
|
+
* The split exists because the two surfaces have opposite cascade
|
|
12
|
+
* requirements:
|
|
13
|
+
* - The iframe shows the host's published page — host CSS should fully win,
|
|
14
|
+
* so `siteStyles` injects everything (Tailwind utilities, `:root` tokens,
|
|
15
|
+
* component CSS) wrapped in `@layer conloca-site` declared after every
|
|
16
|
+
* other top-level layer.
|
|
17
|
+
* - The admin shell shows the editor — admin chrome must keep its own
|
|
18
|
+
* Tailwind utilities (`.bg-white`, `.text-grey-*`, dark variants). Host
|
|
19
|
+
* CSS injected here must NOT include Tailwind utilities or `:root` token
|
|
20
|
+
* overrides; it should be only the host-component selectors
|
|
21
|
+
* (`.conloca-aside`, `.conloca-card`, etc.). `editorStyles` is that
|
|
22
|
+
* narrow path.
|
|
23
|
+
*
|
|
24
|
+
* Uses window to ensure virtual modules and bundled code share the same state.
|
|
25
|
+
*/
|
|
26
|
+
export type SiteStyles = readonly string[];
|
|
27
|
+
interface SharedSiteStylesState {
|
|
28
|
+
styles: SiteStyles;
|
|
29
|
+
subscribers: Set<(styles: SiteStyles) => void>;
|
|
30
|
+
}
|
|
31
|
+
declare global {
|
|
32
|
+
interface Window {
|
|
33
|
+
__SITE_STYLES_STATE__?: SharedSiteStylesState;
|
|
34
|
+
__EDITOR_STYLES_STATE__?: SharedSiteStylesState;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Register the site CSS strings. Called by the virtual module on initial
|
|
39
|
+
* load and on HMR when any of the imported CSS files change. Notifies all
|
|
40
|
+
* subscribers so mounted iframe bridges re-inject fresh style tags.
|
|
41
|
+
*/
|
|
42
|
+
export declare function setSiteStyles(styles: SiteStyles): void;
|
|
43
|
+
/**
|
|
44
|
+
* Get the current site CSS strings synchronously.
|
|
45
|
+
*/
|
|
46
|
+
export declare function getSiteStyles(): SiteStyles;
|
|
47
|
+
/**
|
|
48
|
+
* React hook that returns the current site CSS strings and re-renders the
|
|
49
|
+
* caller when they change (HMR support).
|
|
50
|
+
*/
|
|
51
|
+
export declare function useSiteStyles(): SiteStyles;
|
|
52
|
+
export declare function setEditorStyles(styles: SiteStyles): void;
|
|
53
|
+
export declare function getEditorStyles(): SiteStyles;
|
|
54
|
+
export declare function useEditorStyles(): SiteStyles;
|
|
55
|
+
/**
|
|
56
|
+
* Fetch the host's CSS for a route URL from the integration's
|
|
57
|
+
* `/api/styles` endpoint and return it as a single-element array suitable
|
|
58
|
+
* for `useInjectHostStyles`. Empty until the fetch resolves; empty if no
|
|
59
|
+
* URL is given.
|
|
60
|
+
*/
|
|
61
|
+
export declare function useFetchedSiteStyles(routeUrl: string | undefined, options?: {
|
|
62
|
+
cmsRoute?: string;
|
|
63
|
+
}): SiteStyles;
|
|
64
|
+
/**
|
|
65
|
+
* Shape returned by the `/api/content-wrapper?url=…` endpoint — the
|
|
66
|
+
* tag name and class list of the host page's content-root element.
|
|
67
|
+
* Kept in lock-step with `ContentWrapperInfo` in
|
|
68
|
+
* `packages/astro-cms/src/site-styles/content-wrapper-endpoint.ts`.
|
|
69
|
+
*/
|
|
70
|
+
export interface HostContentWrapper {
|
|
71
|
+
tagName: string;
|
|
72
|
+
className: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Discovered host wrappers for a given route. `content` is the
|
|
76
|
+
* prose-content wrapper (eg `.sl-markdown-content`). `codeBlock` is
|
|
77
|
+
* the ordered chain of classed wrappers between the content wrapper
|
|
78
|
+
* and `<pre>`, outermost first (eg `[.expressive-code, .frame ...]`).
|
|
79
|
+
* Either may be null when not present on the page.
|
|
80
|
+
*/
|
|
81
|
+
export interface HostWrappers {
|
|
82
|
+
content: HostContentWrapper | null;
|
|
83
|
+
codeBlock: HostContentWrapper[] | null;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Fetches the host page's wrappers for the given route URL. The
|
|
87
|
+
* editor mirrors them: the contenteditable is wrapped in a clone of
|
|
88
|
+
* `content` (via the `hostWrapperPlugin`), and the code-block frame
|
|
89
|
+
* picks up the `codeBlock` classes so the host's code-block CSS
|
|
90
|
+
* reaches via the cascade — no shipped mirror needed.
|
|
91
|
+
*
|
|
92
|
+
* Returns `{ content: null, codeBlock: null }` while the fetch is in
|
|
93
|
+
* flight or when the host route has no discoverable wrappers.
|
|
94
|
+
*
|
|
95
|
+
* Re-fetches whenever `routeUrl` changes (eg locale switch / doc
|
|
96
|
+
* switch). Errors are logged and swallowed; the caller falls back to
|
|
97
|
+
* the no-wrapper render path.
|
|
98
|
+
*/
|
|
99
|
+
export declare function useFetchedHostWrappers(routeUrl: string | undefined, options?: {
|
|
100
|
+
cmsRoute?: string;
|
|
101
|
+
}): HostWrappers;
|
|
102
|
+
/**
|
|
103
|
+
* Inject host CSS strings into the current document's `<head>` while the
|
|
104
|
+
* calling component is mounted. Each stylesheet gets wrapped in a named
|
|
105
|
+
* cascade layer so its rules sit at a known position in the cascade.
|
|
106
|
+
*
|
|
107
|
+
* `@import url(...)` statements are hoisted to the top of the injected
|
|
108
|
+
* `<style>` tag because they must come before other rules to be valid.
|
|
109
|
+
* Hosts using Tailwind / Google Fonts depend on this.
|
|
110
|
+
*
|
|
111
|
+
* The chrome / host collision is handled at the class-name level —
|
|
112
|
+
* chrome surfaces that visibly overlap host's Tailwind utilities use
|
|
113
|
+
* the cms-admin semantic palette (`bg-panel`, `text-foreground`,
|
|
114
|
+
* `border-line`, etc.) whose names the host's Tailwind can't generate.
|
|
115
|
+
* Earlier iterations of this hook took a `scopeSelector` and wrapped
|
|
116
|
+
* everything in `@scope (...)`; that approach broke host components
|
|
117
|
+
* relying on ancestor selectors (eg `html.dark .starlight-aside`).
|
|
118
|
+
*/
|
|
119
|
+
export declare function useInjectHostStyles(layerName: string, styles: SiteStyles): void;
|
|
120
|
+
export {};
|
|
121
|
+
//# sourceMappingURL=site-styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"site-styles.d.ts","sourceRoot":"","sources":["../src/site-styles.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,MAAM,MAAM,UAAU,GAAG,SAAS,MAAM,EAAE,CAAC;AAE3C,UAAU,qBAAqB;IAC7B,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,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;QAC9C,uBAAuB,CAAC,EAAE,qBAAqB,CAAC;KACjD;CACF;AAgBD;;;;GAIG;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;AAkBD,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAMxD;AAED,wBAAgB,eAAe,IAAI,UAAU,CAE5C;AAED,wBAAgB,eAAe,IAAI,UAAU,CAa5C;AAWD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,GAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,UAAU,CAkClH;AAED;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACnC,SAAS,EAAE,kBAAkB,EAAE,GAAG,IAAI,CAAC;CACxC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,OAAO,GAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAO,GAClC,YAAY,CAkCd;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CAuD/E"}
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
const getSharedState = () => {
|
|
3
|
+
if (typeof window !== 'undefined') {
|
|
4
|
+
if (!window.__SITE_STYLES_STATE__) {
|
|
5
|
+
window.__SITE_STYLES_STATE__ = {
|
|
6
|
+
styles: [],
|
|
7
|
+
subscribers: new Set(),
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
return window.__SITE_STYLES_STATE__;
|
|
11
|
+
}
|
|
12
|
+
// SSR fallback
|
|
13
|
+
return { styles: [], subscribers: new Set() };
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Register the site CSS strings. Called by the virtual module on initial
|
|
17
|
+
* load and on HMR when any of the imported CSS files change. Notifies all
|
|
18
|
+
* subscribers so mounted iframe bridges re-inject fresh style tags.
|
|
19
|
+
*/
|
|
20
|
+
export function setSiteStyles(styles) {
|
|
21
|
+
const state = getSharedState();
|
|
22
|
+
state.styles = styles;
|
|
23
|
+
for (const fn of state.subscribers) {
|
|
24
|
+
fn(styles);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Get the current site CSS strings synchronously.
|
|
29
|
+
*/
|
|
30
|
+
export function getSiteStyles() {
|
|
31
|
+
return getSharedState().styles;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* React hook that returns the current site CSS strings and re-renders the
|
|
35
|
+
* caller when they change (HMR support).
|
|
36
|
+
*/
|
|
37
|
+
export function useSiteStyles() {
|
|
38
|
+
const [styles, setStyles] = useState(() => getSharedState().styles);
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
const state = getSharedState();
|
|
41
|
+
// Re-sync in case styles changed between render and effect
|
|
42
|
+
if (state.styles !== styles) {
|
|
43
|
+
setStyles(state.styles);
|
|
44
|
+
}
|
|
45
|
+
state.subscribers.add(setStyles);
|
|
46
|
+
return () => {
|
|
47
|
+
state.subscribers.delete(setStyles);
|
|
48
|
+
};
|
|
49
|
+
}, [styles]);
|
|
50
|
+
return styles;
|
|
51
|
+
}
|
|
52
|
+
// ---------------------------------------------------------------------------
|
|
53
|
+
// editorStyles registry — narrow CSS path for the MDX editor admin shell.
|
|
54
|
+
// Mirrors the siteStyles pattern; see the top-of-file comment for why the
|
|
55
|
+
// split exists.
|
|
56
|
+
// ---------------------------------------------------------------------------
|
|
57
|
+
const getEditorStylesState = () => {
|
|
58
|
+
if (typeof window !== 'undefined') {
|
|
59
|
+
if (!window.__EDITOR_STYLES_STATE__) {
|
|
60
|
+
window.__EDITOR_STYLES_STATE__ = { styles: [], subscribers: new Set() };
|
|
61
|
+
}
|
|
62
|
+
return window.__EDITOR_STYLES_STATE__;
|
|
63
|
+
}
|
|
64
|
+
return { styles: [], subscribers: new Set() };
|
|
65
|
+
};
|
|
66
|
+
export function setEditorStyles(styles) {
|
|
67
|
+
const state = getEditorStylesState();
|
|
68
|
+
state.styles = styles;
|
|
69
|
+
for (const fn of state.subscribers) {
|
|
70
|
+
fn(styles);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
export function getEditorStyles() {
|
|
74
|
+
return getEditorStylesState().styles;
|
|
75
|
+
}
|
|
76
|
+
export function useEditorStyles() {
|
|
77
|
+
const [styles, setStyles] = useState(() => getEditorStylesState().styles);
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
const state = getEditorStylesState();
|
|
80
|
+
if (state.styles !== styles)
|
|
81
|
+
setStyles(state.styles);
|
|
82
|
+
state.subscribers.add(setStyles);
|
|
83
|
+
return () => {
|
|
84
|
+
state.subscribers.delete(setStyles);
|
|
85
|
+
};
|
|
86
|
+
}, [styles]);
|
|
87
|
+
return styles;
|
|
88
|
+
}
|
|
89
|
+
// ---------------------------------------------------------------------------
|
|
90
|
+
// Fetched site styles — runtime CSS discovery from the integration endpoint.
|
|
91
|
+
//
|
|
92
|
+
// Replaces the manually-curated `editorStyles` list with the host's real CSS
|
|
93
|
+
// for the page being edited. The integration walks Vite's module graph from
|
|
94
|
+
// the page's URL and returns the concatenated stylesheets (Tailwind, theme
|
|
95
|
+
// CSS, framework-scoped styles) so the editor matches the published page.
|
|
96
|
+
// ---------------------------------------------------------------------------
|
|
97
|
+
/**
|
|
98
|
+
* Fetch the host's CSS for a route URL from the integration's
|
|
99
|
+
* `/api/styles` endpoint and return it as a single-element array suitable
|
|
100
|
+
* for `useInjectHostStyles`. Empty until the fetch resolves; empty if no
|
|
101
|
+
* URL is given.
|
|
102
|
+
*/
|
|
103
|
+
export function useFetchedSiteStyles(routeUrl, options = {}) {
|
|
104
|
+
const [styles, setStyles] = useState([]);
|
|
105
|
+
const cmsRoute = options.cmsRoute ?? '/__cms';
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
if (!routeUrl) {
|
|
108
|
+
setStyles([]);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
let cancelled = false;
|
|
112
|
+
const endpoint = `${cmsRoute}/api/styles?url=${encodeURIComponent(routeUrl)}`;
|
|
113
|
+
fetch(endpoint)
|
|
114
|
+
.then((res) => {
|
|
115
|
+
if (!res.ok)
|
|
116
|
+
throw new Error(`Styles endpoint returned ${res.status}`);
|
|
117
|
+
return res.text();
|
|
118
|
+
})
|
|
119
|
+
.then((css) => {
|
|
120
|
+
if (cancelled)
|
|
121
|
+
return;
|
|
122
|
+
setStyles(css ? [css] : []);
|
|
123
|
+
})
|
|
124
|
+
.catch((err) => {
|
|
125
|
+
if (cancelled)
|
|
126
|
+
return;
|
|
127
|
+
console.warn('[Conloca] Failed to fetch site styles:', err);
|
|
128
|
+
setStyles([]);
|
|
129
|
+
});
|
|
130
|
+
return () => {
|
|
131
|
+
cancelled = true;
|
|
132
|
+
};
|
|
133
|
+
}, [routeUrl, cmsRoute]);
|
|
134
|
+
return styles;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Fetches the host page's wrappers for the given route URL. The
|
|
138
|
+
* editor mirrors them: the contenteditable is wrapped in a clone of
|
|
139
|
+
* `content` (via the `hostWrapperPlugin`), and the code-block frame
|
|
140
|
+
* picks up the `codeBlock` classes so the host's code-block CSS
|
|
141
|
+
* reaches via the cascade — no shipped mirror needed.
|
|
142
|
+
*
|
|
143
|
+
* Returns `{ content: null, codeBlock: null }` while the fetch is in
|
|
144
|
+
* flight or when the host route has no discoverable wrappers.
|
|
145
|
+
*
|
|
146
|
+
* Re-fetches whenever `routeUrl` changes (eg locale switch / doc
|
|
147
|
+
* switch). Errors are logged and swallowed; the caller falls back to
|
|
148
|
+
* the no-wrapper render path.
|
|
149
|
+
*/
|
|
150
|
+
export function useFetchedHostWrappers(routeUrl, options = {}) {
|
|
151
|
+
const [wrappers, setWrappers] = useState({ content: null, codeBlock: null });
|
|
152
|
+
const cmsRoute = options.cmsRoute ?? '/__cms';
|
|
153
|
+
useEffect(() => {
|
|
154
|
+
if (!routeUrl) {
|
|
155
|
+
setWrappers({ content: null, codeBlock: null });
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
let cancelled = false;
|
|
159
|
+
const endpoint = `${cmsRoute}/api/content-wrapper?url=${encodeURIComponent(routeUrl)}`;
|
|
160
|
+
fetch(endpoint)
|
|
161
|
+
.then((res) => {
|
|
162
|
+
if (!res.ok)
|
|
163
|
+
throw new Error(`Content-wrapper endpoint returned ${res.status}`);
|
|
164
|
+
return res.json();
|
|
165
|
+
})
|
|
166
|
+
.then((data) => {
|
|
167
|
+
if (cancelled)
|
|
168
|
+
return;
|
|
169
|
+
setWrappers({ content: data?.content ?? null, codeBlock: data?.codeBlock ?? null });
|
|
170
|
+
})
|
|
171
|
+
.catch((err) => {
|
|
172
|
+
if (cancelled)
|
|
173
|
+
return;
|
|
174
|
+
console.warn('[Conloca] Failed to fetch host wrappers:', err);
|
|
175
|
+
setWrappers({ content: null, codeBlock: null });
|
|
176
|
+
});
|
|
177
|
+
return () => {
|
|
178
|
+
cancelled = true;
|
|
179
|
+
};
|
|
180
|
+
}, [routeUrl, cmsRoute]);
|
|
181
|
+
return wrappers;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Inject host CSS strings into the current document's `<head>` while the
|
|
185
|
+
* calling component is mounted. Each stylesheet gets wrapped in a named
|
|
186
|
+
* cascade layer so its rules sit at a known position in the cascade.
|
|
187
|
+
*
|
|
188
|
+
* `@import url(...)` statements are hoisted to the top of the injected
|
|
189
|
+
* `<style>` tag because they must come before other rules to be valid.
|
|
190
|
+
* Hosts using Tailwind / Google Fonts depend on this.
|
|
191
|
+
*
|
|
192
|
+
* The chrome / host collision is handled at the class-name level —
|
|
193
|
+
* chrome surfaces that visibly overlap host's Tailwind utilities use
|
|
194
|
+
* the cms-admin semantic palette (`bg-panel`, `text-foreground`,
|
|
195
|
+
* `border-line`, etc.) whose names the host's Tailwind can't generate.
|
|
196
|
+
* Earlier iterations of this hook took a `scopeSelector` and wrapped
|
|
197
|
+
* everything in `@scope (...)`; that approach broke host components
|
|
198
|
+
* relying on ancestor selectors (eg `html.dark .starlight-aside`).
|
|
199
|
+
*/
|
|
200
|
+
export function useInjectHostStyles(layerName, styles) {
|
|
201
|
+
useEffect(() => {
|
|
202
|
+
if (typeof document === 'undefined' || styles.length === 0)
|
|
203
|
+
return;
|
|
204
|
+
const tags = [];
|
|
205
|
+
const marker = `data-conloca-host-styles-${layerName}`;
|
|
206
|
+
for (const css of styles) {
|
|
207
|
+
const imports = [];
|
|
208
|
+
const cleaned = css.replace(/@import\s+url\([^)]*\)[^;]*;/g, (m) => {
|
|
209
|
+
imports.push(m.trim());
|
|
210
|
+
return '';
|
|
211
|
+
});
|
|
212
|
+
const wrapped = `${imports.join('\n')}\n@layer ${layerName} {\n${cleaned}\n}`;
|
|
213
|
+
const tag = document.createElement('style');
|
|
214
|
+
tag.setAttribute(marker, '');
|
|
215
|
+
tag.textContent = wrapped;
|
|
216
|
+
document.head.appendChild(tag);
|
|
217
|
+
tags.push(tag);
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Bridge the host page's `body { background }` into a CSS custom
|
|
221
|
+
* property the editor's content-surround region can read. Works
|
|
222
|
+
* together with the `hostWrapperPlugin` (which mirrors the host's
|
|
223
|
+
* `<main>`/marked element around the contenteditable):
|
|
224
|
+
*
|
|
225
|
+
* - Editor's chrome wrapper paints `bg-page` (the CMS grey).
|
|
226
|
+
* - Inside the chrome, the content column paints the host body
|
|
227
|
+
* bg via this bridged var (`--conloca-host-body-bg`).
|
|
228
|
+
* - Inside that surround, the host's content wrapper (eg
|
|
229
|
+
* `<main>`) is rendered around the contenteditable. Hosts who
|
|
230
|
+
* paint a card surface on that wrapper get the paint; hosts
|
|
231
|
+
* like Starlight whose `<main>` is transparent rely on the
|
|
232
|
+
* surround's body bg showing through.
|
|
233
|
+
*
|
|
234
|
+
* Defers a frame so the freshly-appended `<style>` tags actually
|
|
235
|
+
* apply before we read computed style.
|
|
236
|
+
*/
|
|
237
|
+
const rafId = requestAnimationFrame(() => {
|
|
238
|
+
const bg = getComputedStyle(document.body).backgroundColor;
|
|
239
|
+
if (bg && bg !== 'rgba(0, 0, 0, 0)' && bg !== 'transparent') {
|
|
240
|
+
document.documentElement.style.setProperty('--conloca-host-body-bg', bg);
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
return () => {
|
|
244
|
+
cancelAnimationFrame(rafId);
|
|
245
|
+
for (const tag of tags)
|
|
246
|
+
tag.remove();
|
|
247
|
+
// Drop the bridged var so a doc switch to a host without a body
|
|
248
|
+
// bg falls back cleanly to the cms grey fallback rather than
|
|
249
|
+
// sticking with the previous host's color.
|
|
250
|
+
document.documentElement.style.removeProperty('--conloca-host-body-bg');
|
|
251
|
+
};
|
|
252
|
+
}, [styles, layerName]);
|
|
253
|
+
}
|
package/dist/site-styles.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { useEffect, useState } from "react";
|
|
2
|
-
|
|
3
2
|
//#region src/site-styles.ts
|
|
4
3
|
const getSharedState = () => {
|
|
5
4
|
if (typeof window !== "undefined") {
|
|
@@ -22,7 +21,7 @@ const getSharedState = () => {
|
|
|
22
21
|
function setSiteStyles(styles) {
|
|
23
22
|
const state = getSharedState();
|
|
24
23
|
state.styles = styles;
|
|
25
|
-
state.subscribers
|
|
24
|
+
for (const fn of state.subscribers) fn(styles);
|
|
26
25
|
}
|
|
27
26
|
/**
|
|
28
27
|
* Get the current site CSS strings synchronously.
|
|
@@ -43,10 +42,193 @@ function useSiteStyles() {
|
|
|
43
42
|
return () => {
|
|
44
43
|
state.subscribers.delete(setStyles);
|
|
45
44
|
};
|
|
46
|
-
}, []);
|
|
45
|
+
}, [styles]);
|
|
47
46
|
return styles;
|
|
48
47
|
}
|
|
49
|
-
|
|
48
|
+
const getEditorStylesState = () => {
|
|
49
|
+
if (typeof window !== "undefined") {
|
|
50
|
+
if (!window.__EDITOR_STYLES_STATE__) window.__EDITOR_STYLES_STATE__ = {
|
|
51
|
+
styles: [],
|
|
52
|
+
subscribers: /* @__PURE__ */ new Set()
|
|
53
|
+
};
|
|
54
|
+
return window.__EDITOR_STYLES_STATE__;
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
styles: [],
|
|
58
|
+
subscribers: /* @__PURE__ */ new Set()
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
function setEditorStyles(styles) {
|
|
62
|
+
const state = getEditorStylesState();
|
|
63
|
+
state.styles = styles;
|
|
64
|
+
for (const fn of state.subscribers) fn(styles);
|
|
65
|
+
}
|
|
66
|
+
function getEditorStyles() {
|
|
67
|
+
return getEditorStylesState().styles;
|
|
68
|
+
}
|
|
69
|
+
function useEditorStyles() {
|
|
70
|
+
const [styles, setStyles] = useState(() => getEditorStylesState().styles);
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
const state = getEditorStylesState();
|
|
73
|
+
if (state.styles !== styles) setStyles(state.styles);
|
|
74
|
+
state.subscribers.add(setStyles);
|
|
75
|
+
return () => {
|
|
76
|
+
state.subscribers.delete(setStyles);
|
|
77
|
+
};
|
|
78
|
+
}, [styles]);
|
|
79
|
+
return styles;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Fetch the host's CSS for a route URL from the integration's
|
|
83
|
+
* `/api/styles` endpoint and return it as a single-element array suitable
|
|
84
|
+
* for `useInjectHostStyles`. Empty until the fetch resolves; empty if no
|
|
85
|
+
* URL is given.
|
|
86
|
+
*/
|
|
87
|
+
function useFetchedSiteStyles(routeUrl, options = {}) {
|
|
88
|
+
const [styles, setStyles] = useState([]);
|
|
89
|
+
const cmsRoute = options.cmsRoute ?? "/__cms";
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
if (!routeUrl) {
|
|
92
|
+
setStyles([]);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
let cancelled = false;
|
|
96
|
+
const endpoint = `${cmsRoute}/api/styles?url=${encodeURIComponent(routeUrl)}`;
|
|
97
|
+
fetch(endpoint).then((res) => {
|
|
98
|
+
if (!res.ok) throw new Error(`Styles endpoint returned ${res.status}`);
|
|
99
|
+
return res.text();
|
|
100
|
+
}).then((css) => {
|
|
101
|
+
if (cancelled) return;
|
|
102
|
+
setStyles(css ? [css] : []);
|
|
103
|
+
}).catch((err) => {
|
|
104
|
+
if (cancelled) return;
|
|
105
|
+
console.warn("[Conloca] Failed to fetch site styles:", err);
|
|
106
|
+
setStyles([]);
|
|
107
|
+
});
|
|
108
|
+
return () => {
|
|
109
|
+
cancelled = true;
|
|
110
|
+
};
|
|
111
|
+
}, [routeUrl, cmsRoute]);
|
|
112
|
+
return styles;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Fetches the host page's wrappers for the given route URL. The
|
|
116
|
+
* editor mirrors them: the contenteditable is wrapped in a clone of
|
|
117
|
+
* `content` (via the `hostWrapperPlugin`), and the code-block frame
|
|
118
|
+
* picks up the `codeBlock` classes so the host's code-block CSS
|
|
119
|
+
* reaches via the cascade — no shipped mirror needed.
|
|
120
|
+
*
|
|
121
|
+
* Returns `{ content: null, codeBlock: null }` while the fetch is in
|
|
122
|
+
* flight or when the host route has no discoverable wrappers.
|
|
123
|
+
*
|
|
124
|
+
* Re-fetches whenever `routeUrl` changes (eg locale switch / doc
|
|
125
|
+
* switch). Errors are logged and swallowed; the caller falls back to
|
|
126
|
+
* the no-wrapper render path.
|
|
127
|
+
*/
|
|
128
|
+
function useFetchedHostWrappers(routeUrl, options = {}) {
|
|
129
|
+
const [wrappers, setWrappers] = useState({
|
|
130
|
+
content: null,
|
|
131
|
+
codeBlock: null
|
|
132
|
+
});
|
|
133
|
+
const cmsRoute = options.cmsRoute ?? "/__cms";
|
|
134
|
+
useEffect(() => {
|
|
135
|
+
if (!routeUrl) {
|
|
136
|
+
setWrappers({
|
|
137
|
+
content: null,
|
|
138
|
+
codeBlock: null
|
|
139
|
+
});
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
let cancelled = false;
|
|
143
|
+
const endpoint = `${cmsRoute}/api/content-wrapper?url=${encodeURIComponent(routeUrl)}`;
|
|
144
|
+
fetch(endpoint).then((res) => {
|
|
145
|
+
if (!res.ok) throw new Error(`Content-wrapper endpoint returned ${res.status}`);
|
|
146
|
+
return res.json();
|
|
147
|
+
}).then((data) => {
|
|
148
|
+
if (cancelled) return;
|
|
149
|
+
setWrappers({
|
|
150
|
+
content: data?.content ?? null,
|
|
151
|
+
codeBlock: data?.codeBlock ?? null
|
|
152
|
+
});
|
|
153
|
+
}).catch((err) => {
|
|
154
|
+
if (cancelled) return;
|
|
155
|
+
console.warn("[Conloca] Failed to fetch host wrappers:", err);
|
|
156
|
+
setWrappers({
|
|
157
|
+
content: null,
|
|
158
|
+
codeBlock: null
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
return () => {
|
|
162
|
+
cancelled = true;
|
|
163
|
+
};
|
|
164
|
+
}, [routeUrl, cmsRoute]);
|
|
165
|
+
return wrappers;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Inject host CSS strings into the current document's `<head>` while the
|
|
169
|
+
* calling component is mounted. Each stylesheet gets wrapped in a named
|
|
170
|
+
* cascade layer so its rules sit at a known position in the cascade.
|
|
171
|
+
*
|
|
172
|
+
* `@import url(...)` statements are hoisted to the top of the injected
|
|
173
|
+
* `<style>` tag because they must come before other rules to be valid.
|
|
174
|
+
* Hosts using Tailwind / Google Fonts depend on this.
|
|
175
|
+
*
|
|
176
|
+
* The chrome / host collision is handled at the class-name level —
|
|
177
|
+
* chrome surfaces that visibly overlap host's Tailwind utilities use
|
|
178
|
+
* the cms-admin semantic palette (`bg-panel`, `text-foreground`,
|
|
179
|
+
* `border-line`, etc.) whose names the host's Tailwind can't generate.
|
|
180
|
+
* Earlier iterations of this hook took a `scopeSelector` and wrapped
|
|
181
|
+
* everything in `@scope (...)`; that approach broke host components
|
|
182
|
+
* relying on ancestor selectors (eg `html.dark .starlight-aside`).
|
|
183
|
+
*/
|
|
184
|
+
function useInjectHostStyles(layerName, styles) {
|
|
185
|
+
useEffect(() => {
|
|
186
|
+
if (typeof document === "undefined" || styles.length === 0) return;
|
|
187
|
+
const tags = [];
|
|
188
|
+
const marker = `data-conloca-host-styles-${layerName}`;
|
|
189
|
+
for (const css of styles) {
|
|
190
|
+
const imports = [];
|
|
191
|
+
const cleaned = css.replace(/@import\s+url\([^)]*\)[^;]*;/g, (m) => {
|
|
192
|
+
imports.push(m.trim());
|
|
193
|
+
return "";
|
|
194
|
+
});
|
|
195
|
+
const wrapped = `${imports.join("\n")}\n@layer ${layerName} {\n${cleaned}\n}`;
|
|
196
|
+
const tag = document.createElement("style");
|
|
197
|
+
tag.setAttribute(marker, "");
|
|
198
|
+
tag.textContent = wrapped;
|
|
199
|
+
document.head.appendChild(tag);
|
|
200
|
+
tags.push(tag);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Bridge the host page's `body { background }` into a CSS custom
|
|
204
|
+
* property the editor's content-surround region can read. Works
|
|
205
|
+
* together with the `hostWrapperPlugin` (which mirrors the host's
|
|
206
|
+
* `<main>`/marked element around the contenteditable):
|
|
207
|
+
*
|
|
208
|
+
* - Editor's chrome wrapper paints `bg-page` (the CMS grey).
|
|
209
|
+
* - Inside the chrome, the content column paints the host body
|
|
210
|
+
* bg via this bridged var (`--conloca-host-body-bg`).
|
|
211
|
+
* - Inside that surround, the host's content wrapper (eg
|
|
212
|
+
* `<main>`) is rendered around the contenteditable. Hosts who
|
|
213
|
+
* paint a card surface on that wrapper get the paint; hosts
|
|
214
|
+
* like Starlight whose `<main>` is transparent rely on the
|
|
215
|
+
* surround's body bg showing through.
|
|
216
|
+
*
|
|
217
|
+
* Defers a frame so the freshly-appended `<style>` tags actually
|
|
218
|
+
* apply before we read computed style.
|
|
219
|
+
*/
|
|
220
|
+
const rafId = requestAnimationFrame(() => {
|
|
221
|
+
const bg = getComputedStyle(document.body).backgroundColor;
|
|
222
|
+
if (bg && bg !== "rgba(0, 0, 0, 0)" && bg !== "transparent") document.documentElement.style.setProperty("--conloca-host-body-bg", bg);
|
|
223
|
+
});
|
|
224
|
+
return () => {
|
|
225
|
+
cancelAnimationFrame(rafId);
|
|
226
|
+
for (const tag of tags) tag.remove();
|
|
227
|
+
document.documentElement.style.removeProperty("--conloca-host-body-bg");
|
|
228
|
+
};
|
|
229
|
+
}, [styles, layerName]);
|
|
230
|
+
}
|
|
50
231
|
//#endregion
|
|
51
|
-
export { getSiteStyles, setSiteStyles, useSiteStyles };
|
|
232
|
+
export { getEditorStyles, getSiteStyles, setEditorStyles, setSiteStyles, useEditorStyles, useFetchedHostWrappers, useFetchedSiteStyles, useInjectHostStyles, useSiteStyles };
|
|
233
|
+
|
|
52
234
|
//# sourceMappingURL=site-styles.mjs.map
|
package/dist/site-styles.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"site-styles.mjs","names":[],"sources":["../src/site-styles.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\n/**\n * Shared registry for host-site CSS strings across module instances.\n *\n * The astro-cms virtual module (`${cmsRoute}/site-styles.js`) imports each\n * configured CSS file with Vite's `?inline` query (so the full CSS pipeline\n * runs) and calls `setSiteStyles` with the processed strings. The editor's\n * iframe bridge consumes them via `useSiteStyles` and injects them directly\n * into Puck's preview iframe <head>, bypassing the CMS chrome's parent <head>\n * so host-site CSS cannot bleed into the CMS UI.\n *\n * Uses window to ensure virtual modules and bundled code share the same state.\n */\n\nexport type SiteStyles = readonly string[];\n\ninterface SharedSiteStylesState {\n styles: SiteStyles;\n subscribers: Set<(styles: SiteStyles) => void>;\n}\n\ndeclare global {\n interface Window {\n __SITE_STYLES_STATE__?: SharedSiteStylesState;\n }\n}\n\nconst getSharedState = (): SharedSiteStylesState => {\n if (typeof window !== 'undefined') {\n if (!window.__SITE_STYLES_STATE__) {\n window.__SITE_STYLES_STATE__ = {\n styles: [],\n subscribers: new Set(),\n };\n }\n return window.__SITE_STYLES_STATE__;\n }\n // SSR fallback\n return { styles: [], subscribers: new Set() };\n};\n\n/**\n * Register the site CSS strings. Called by the virtual module on initial\n * load and on HMR when any of the imported CSS files change. Notifies all\n * subscribers so mounted iframe bridges re-inject fresh style tags.\n */\nexport function setSiteStyles(styles: SiteStyles): void {\n const state = getSharedState();\n state.styles = styles;\n state.subscribers.forEach((fn) => fn(styles));\n}\n\n/**\n * Get the current site CSS strings synchronously.\n */\nexport function getSiteStyles(): SiteStyles {\n return getSharedState().styles;\n}\n\n/**\n * React hook that returns the current site CSS strings and re-renders the\n * caller when they change (HMR support).\n */\nexport function useSiteStyles(): SiteStyles {\n const [styles, setStyles] = useState(() => getSharedState().styles);\n\n useEffect(() => {\n const state = getSharedState();\n\n // Re-sync in case styles changed between render and effect\n if (state.styles !== styles) {\n setStyles(state.styles);\n }\n\n state.subscribers.add(setStyles);\n return () => {\n state.subscribers.delete(setStyles);\n };\n }, []);\n\n return styles;\n}\n"],"mappings":";;;AA4BA,MAAM,uBAA8C;AAClD,KAAI,OAAO,WAAW,aAAa;AACjC,MAAI,CAAC,OAAO,sBACV,QAAO,wBAAwB;GAC7B,QAAQ,EAAE;GACV,6BAAa,IAAI,KAAK;GACvB;AAEH,SAAO,OAAO;;AAGhB,QAAO;EAAE,QAAQ,EAAE;EAAE,6BAAa,IAAI,KAAK;EAAE;;;;;;;AAQ/C,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":"site-styles.mjs","names":[],"sources":["../src/site-styles.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\n/**\n * Two parallel registries for host-supplied CSS strings: `siteStyles` for the\n * Puck preview iframe (full page styling, Tailwind included), and\n * `editorStyles` for the MDX editor admin shell (narrow component CSS only).\n *\n * Each registry has an astro-cms virtual module (`${cmsRoute}/site-styles.js`\n * and `${cmsRoute}/editor-styles.js`) that imports the configured CSS files\n * with Vite's `?inline` query (so the full CSS pipeline runs) and calls the\n * corresponding setter. Consumers read via the matching hook.\n *\n * The split exists because the two surfaces have opposite cascade\n * requirements:\n * - The iframe shows the host's published page — host CSS should fully win,\n * so `siteStyles` injects everything (Tailwind utilities, `:root` tokens,\n * component CSS) wrapped in `@layer conloca-site` declared after every\n * other top-level layer.\n * - The admin shell shows the editor — admin chrome must keep its own\n * Tailwind utilities (`.bg-white`, `.text-grey-*`, dark variants). Host\n * CSS injected here must NOT include Tailwind utilities or `:root` token\n * overrides; it should be only the host-component selectors\n * (`.conloca-aside`, `.conloca-card`, etc.). `editorStyles` is that\n * narrow path.\n *\n * Uses window to ensure virtual modules and bundled code share the same state.\n */\n\nexport type SiteStyles = readonly string[];\n\ninterface SharedSiteStylesState {\n styles: SiteStyles;\n subscribers: Set<(styles: SiteStyles) => void>;\n}\n\ndeclare global {\n interface Window {\n __SITE_STYLES_STATE__?: SharedSiteStylesState;\n __EDITOR_STYLES_STATE__?: SharedSiteStylesState;\n }\n}\n\nconst getSharedState = (): SharedSiteStylesState => {\n if (typeof window !== 'undefined') {\n if (!window.__SITE_STYLES_STATE__) {\n window.__SITE_STYLES_STATE__ = {\n styles: [],\n subscribers: new Set(),\n };\n }\n return window.__SITE_STYLES_STATE__;\n }\n // SSR fallback\n return { styles: [], subscribers: new Set() };\n};\n\n/**\n * Register the site CSS strings. Called by the virtual module on initial\n * load and on HMR when any of the imported CSS files change. Notifies all\n * subscribers so mounted iframe bridges re-inject fresh style tags.\n */\nexport function setSiteStyles(styles: SiteStyles): void {\n const state = getSharedState();\n state.styles = styles;\n for (const fn of state.subscribers) {\n fn(styles);\n }\n}\n\n/**\n * Get the current site CSS strings synchronously.\n */\nexport function getSiteStyles(): SiteStyles {\n return getSharedState().styles;\n}\n\n/**\n * React hook that returns the current site CSS strings and re-renders the\n * caller when they change (HMR support).\n */\nexport function useSiteStyles(): SiteStyles {\n const [styles, setStyles] = useState(() => getSharedState().styles);\n\n useEffect(() => {\n const state = getSharedState();\n\n // Re-sync in case styles changed between render and effect\n if (state.styles !== styles) {\n setStyles(state.styles);\n }\n\n state.subscribers.add(setStyles);\n return () => {\n state.subscribers.delete(setStyles);\n };\n }, [styles]);\n\n return styles;\n}\n\n// ---------------------------------------------------------------------------\n// editorStyles registry — narrow CSS path for the MDX editor admin shell.\n// Mirrors the siteStyles pattern; see the top-of-file comment for why the\n// split exists.\n// ---------------------------------------------------------------------------\n\nconst getEditorStylesState = (): SharedSiteStylesState => {\n if (typeof window !== 'undefined') {\n if (!window.__EDITOR_STYLES_STATE__) {\n window.__EDITOR_STYLES_STATE__ = { styles: [], subscribers: new Set() };\n }\n return window.__EDITOR_STYLES_STATE__;\n }\n return { styles: [], subscribers: new Set() };\n};\n\nexport function setEditorStyles(styles: SiteStyles): void {\n const state = getEditorStylesState();\n state.styles = styles;\n for (const fn of state.subscribers) {\n fn(styles);\n }\n}\n\nexport function getEditorStyles(): SiteStyles {\n return getEditorStylesState().styles;\n}\n\nexport function useEditorStyles(): SiteStyles {\n const [styles, setStyles] = useState(() => getEditorStylesState().styles);\n\n useEffect(() => {\n const state = getEditorStylesState();\n if (state.styles !== styles) setStyles(state.styles);\n state.subscribers.add(setStyles);\n return () => {\n state.subscribers.delete(setStyles);\n };\n }, [styles]);\n\n return styles;\n}\n\n// ---------------------------------------------------------------------------\n// Fetched site styles — runtime CSS discovery from the integration endpoint.\n//\n// Replaces the manually-curated `editorStyles` list with the host's real CSS\n// for the page being edited. The integration walks Vite's module graph from\n// the page's URL and returns the concatenated stylesheets (Tailwind, theme\n// CSS, framework-scoped styles) so the editor matches the published page.\n// ---------------------------------------------------------------------------\n\n/**\n * Fetch the host's CSS for a route URL from the integration's\n * `/api/styles` endpoint and return it as a single-element array suitable\n * for `useInjectHostStyles`. Empty until the fetch resolves; empty if no\n * URL is given.\n */\nexport function useFetchedSiteStyles(routeUrl: string | undefined, options: { cmsRoute?: string } = {}): SiteStyles {\n const [styles, setStyles] = useState<SiteStyles>([]);\n const cmsRoute = options.cmsRoute ?? '/__cms';\n\n useEffect(() => {\n if (!routeUrl) {\n setStyles([]);\n return;\n }\n\n let cancelled = false;\n const endpoint = `${cmsRoute}/api/styles?url=${encodeURIComponent(routeUrl)}`;\n\n fetch(endpoint)\n .then((res) => {\n if (!res.ok) throw new Error(`Styles endpoint returned ${res.status}`);\n return res.text();\n })\n .then((css) => {\n if (cancelled) return;\n setStyles(css ? [css] : []);\n })\n .catch((err) => {\n if (cancelled) return;\n console.warn('[Conloca] Failed to fetch site styles:', err);\n setStyles([]);\n });\n\n return () => {\n cancelled = true;\n };\n }, [routeUrl, cmsRoute]);\n\n return styles;\n}\n\n/**\n * Shape returned by the `/api/content-wrapper?url=…` endpoint — the\n * tag name and class list of the host page's content-root element.\n * Kept in lock-step with `ContentWrapperInfo` in\n * `packages/astro-cms/src/site-styles/content-wrapper-endpoint.ts`.\n */\nexport interface HostContentWrapper {\n tagName: string;\n className: string;\n}\n\n/**\n * Discovered host wrappers for a given route. `content` is the\n * prose-content wrapper (eg `.sl-markdown-content`). `codeBlock` is\n * the ordered chain of classed wrappers between the content wrapper\n * and `<pre>`, outermost first (eg `[.expressive-code, .frame ...]`).\n * Either may be null when not present on the page.\n */\nexport interface HostWrappers {\n content: HostContentWrapper | null;\n codeBlock: HostContentWrapper[] | null;\n}\n\n/**\n * Fetches the host page's wrappers for the given route URL. The\n * editor mirrors them: the contenteditable is wrapped in a clone of\n * `content` (via the `hostWrapperPlugin`), and the code-block frame\n * picks up the `codeBlock` classes so the host's code-block CSS\n * reaches via the cascade — no shipped mirror needed.\n *\n * Returns `{ content: null, codeBlock: null }` while the fetch is in\n * flight or when the host route has no discoverable wrappers.\n *\n * Re-fetches whenever `routeUrl` changes (eg locale switch / doc\n * switch). Errors are logged and swallowed; the caller falls back to\n * the no-wrapper render path.\n */\nexport function useFetchedHostWrappers(\n routeUrl: string | undefined,\n options: { cmsRoute?: string } = {},\n): HostWrappers {\n const [wrappers, setWrappers] = useState<HostWrappers>({ content: null, codeBlock: null });\n const cmsRoute = options.cmsRoute ?? '/__cms';\n\n useEffect(() => {\n if (!routeUrl) {\n setWrappers({ content: null, codeBlock: null });\n return;\n }\n\n let cancelled = false;\n const endpoint = `${cmsRoute}/api/content-wrapper?url=${encodeURIComponent(routeUrl)}`;\n\n fetch(endpoint)\n .then((res) => {\n if (!res.ok) throw new Error(`Content-wrapper endpoint returned ${res.status}`);\n return res.json() as Promise<HostWrappers>;\n })\n .then((data) => {\n if (cancelled) return;\n setWrappers({ content: data?.content ?? null, codeBlock: data?.codeBlock ?? null });\n })\n .catch((err) => {\n if (cancelled) return;\n console.warn('[Conloca] Failed to fetch host wrappers:', err);\n setWrappers({ content: null, codeBlock: null });\n });\n\n return () => {\n cancelled = true;\n };\n }, [routeUrl, cmsRoute]);\n\n return wrappers;\n}\n\n/**\n * Inject host CSS strings into the current document's `<head>` while the\n * calling component is mounted. Each stylesheet gets wrapped in a named\n * cascade layer so its rules sit at a known position in the cascade.\n *\n * `@import url(...)` statements are hoisted to the top of the injected\n * `<style>` tag because they must come before other rules to be valid.\n * Hosts using Tailwind / Google Fonts depend on this.\n *\n * The chrome / host collision is handled at the class-name level —\n * chrome surfaces that visibly overlap host's Tailwind utilities use\n * the cms-admin semantic palette (`bg-panel`, `text-foreground`,\n * `border-line`, etc.) whose names the host's Tailwind can't generate.\n * Earlier iterations of this hook took a `scopeSelector` and wrapped\n * everything in `@scope (...)`; that approach broke host components\n * relying on ancestor selectors (eg `html.dark .starlight-aside`).\n */\nexport function useInjectHostStyles(layerName: string, styles: SiteStyles): void {\n useEffect(() => {\n if (typeof document === 'undefined' || styles.length === 0) return;\n\n const tags: HTMLStyleElement[] = [];\n const marker = `data-conloca-host-styles-${layerName}`;\n\n for (const css of styles) {\n const imports: string[] = [];\n const cleaned = css.replace(/@import\\s+url\\([^)]*\\)[^;]*;/g, (m) => {\n imports.push(m.trim());\n return '';\n });\n const wrapped = `${imports.join('\\n')}\\n@layer ${layerName} {\\n${cleaned}\\n}`;\n const tag = document.createElement('style');\n tag.setAttribute(marker, '');\n tag.textContent = wrapped;\n document.head.appendChild(tag);\n tags.push(tag);\n }\n\n /**\n * Bridge the host page's `body { background }` into a CSS custom\n * property the editor's content-surround region can read. Works\n * together with the `hostWrapperPlugin` (which mirrors the host's\n * `<main>`/marked element around the contenteditable):\n *\n * - Editor's chrome wrapper paints `bg-page` (the CMS grey).\n * - Inside the chrome, the content column paints the host body\n * bg via this bridged var (`--conloca-host-body-bg`).\n * - Inside that surround, the host's content wrapper (eg\n * `<main>`) is rendered around the contenteditable. Hosts who\n * paint a card surface on that wrapper get the paint; hosts\n * like Starlight whose `<main>` is transparent rely on the\n * surround's body bg showing through.\n *\n * Defers a frame so the freshly-appended `<style>` tags actually\n * apply before we read computed style.\n */\n const rafId = requestAnimationFrame(() => {\n const bg = getComputedStyle(document.body).backgroundColor;\n if (bg && bg !== 'rgba(0, 0, 0, 0)' && bg !== 'transparent') {\n document.documentElement.style.setProperty('--conloca-host-body-bg', bg);\n }\n });\n\n return () => {\n cancelAnimationFrame(rafId);\n for (const tag of tags) tag.remove();\n // Drop the bridged var so a doc switch to a host without a body\n // bg falls back cleanly to the cms grey fallback rather than\n // sticking with the previous host's color.\n document.documentElement.style.removeProperty('--conloca-host-body-bg');\n };\n }, [styles, layerName]);\n}\n"],"mappings":"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"}
|