@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.
- 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 +165 -48
- 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 -4998
- 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 +9 -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 +123 -0
- package/dist/site-styles.d.mts.map +1 -0
- 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 +234 -0
- package/dist/site-styles.mjs.map +1 -0
- package/dist/spa/main.css +5497 -4371
- 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 +153 -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-CvjeYQRH.mjs +0 -1533
- package/dist/puck-CvjeYQRH.mjs.map +0 -1
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
//#region src/mdx-components.ts
|
|
3
|
+
/** Type guard: descriptor is the JSX variant (vs. a snippet). */
|
|
4
|
+
function isJsxDescriptor(d) {
|
|
5
|
+
return d.kind === "flow" || d.kind === "text";
|
|
6
|
+
}
|
|
7
|
+
/** Type guard: descriptor is the snippet variant. */
|
|
8
|
+
function isSnippetDescriptor(d) {
|
|
9
|
+
return d.kind === "snippet";
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Identity helper that validates registration-time invariants.
|
|
13
|
+
*
|
|
14
|
+
* Throws on:
|
|
15
|
+
* - duplicate `name` across the array (across kinds — a JSX `<Aside>` and a
|
|
16
|
+
* snippet named 'Aside' would clash in the insert menu);
|
|
17
|
+
* - `kind: 'text'` with `hasChildren: true` (text-kind JSX is treated as an
|
|
18
|
+
* inline atom by the Lexical bridge);
|
|
19
|
+
* - two JSX descriptors with conflicting `import.from` for the same `name`
|
|
20
|
+
* (deterministic merge failure that would otherwise surface as a confusing
|
|
21
|
+
* save-time error);
|
|
22
|
+
* - snippet descriptors with an empty `content` string (would silently
|
|
23
|
+
* insert nothing and look like a broken menu item).
|
|
24
|
+
*/
|
|
25
|
+
function defineMdxComponents(components) {
|
|
26
|
+
const seen = /* @__PURE__ */ new Map();
|
|
27
|
+
for (const descriptor of components) {
|
|
28
|
+
const existing = seen.get(descriptor.name);
|
|
29
|
+
if (existing) {
|
|
30
|
+
const a = isJsxDescriptor(existing) ? existing.import?.from : void 0;
|
|
31
|
+
const b = isJsxDescriptor(descriptor) ? descriptor.import?.from : void 0;
|
|
32
|
+
if (a !== b) throw new Error(`defineMdxComponents: duplicate descriptor for '${descriptor.name}' with conflicting import.from ('${a ?? "<none>"}' vs '${b ?? "<none>"}').`);
|
|
33
|
+
throw new Error(`defineMdxComponents: duplicate descriptor for '${descriptor.name}'.`);
|
|
34
|
+
}
|
|
35
|
+
if (isJsxDescriptor(descriptor) && descriptor.kind === "text" && descriptor.hasChildren) throw new Error(`defineMdxComponents: descriptor '${descriptor.name}' has kind: 'text' with hasChildren: true — text-kind JSX is treated as an inline atom; use kind: 'flow' for components with children.`);
|
|
36
|
+
if (isSnippetDescriptor(descriptor) && descriptor.content.length === 0) throw new Error(`defineMdxComponents: snippet descriptor '${descriptor.name}' has empty content — a snippet with no content would silently insert nothing.`);
|
|
37
|
+
seen.set(descriptor.name, descriptor);
|
|
38
|
+
}
|
|
39
|
+
return components;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Read a string-valued JSX attribute from an mdast flow element. Returns
|
|
43
|
+
* an empty string when the attribute is missing or holds an expression
|
|
44
|
+
* value (e.g. `prop={2}`). Designed for use inside `Editor` components on
|
|
45
|
+
* an `MdxComponentDescriptor` — the typed editor that wants to drive a
|
|
46
|
+
* controlled `<input value={...}>` against a string prop.
|
|
47
|
+
*/
|
|
48
|
+
/**
|
|
49
|
+
* Conservative detection for "this string prop value carries markdown
|
|
50
|
+
* formatting." Used to decide whether inline editing in the SSR'd
|
|
51
|
+
* preview is safe: a plaintext-only contenteditable would strip the
|
|
52
|
+
* formatting on commit, so we'd rather route those props through the
|
|
53
|
+
* side panel (where the author sees the raw text and decides).
|
|
54
|
+
*
|
|
55
|
+
* Detects only unambiguous markers — `**bold**` / `*em*`, inline code
|
|
56
|
+
* `` `x` ``, and the `[text](url)` link form. Skips `_` / `__` (would
|
|
57
|
+
* false-positive on filenames like `__init__.py`) and skips single
|
|
58
|
+
* `*` (false-positive risk on prose). False positives just mean "edit
|
|
59
|
+
* via panel instead of inline" which is the safe fallback; false
|
|
60
|
+
* negatives silently destroy formatting, which is not.
|
|
61
|
+
*/
|
|
62
|
+
const MARKDOWN_MARKER_RE = /\*\*|`|\[[^\]\n]+?\]\([^)\n]+?\)/;
|
|
63
|
+
function containsMarkdownMarkers(value) {
|
|
64
|
+
return MARKDOWN_MARKER_RE.test(value);
|
|
65
|
+
}
|
|
66
|
+
function readStringAttribute(node, name) {
|
|
67
|
+
const attr = node.attributes.find((a) => a.type === "mdxJsxAttribute" && a.name === name);
|
|
68
|
+
if (!attr || typeof attr.value !== "string") return "";
|
|
69
|
+
return attr.value;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Return a new attributes array with the given string attribute set to
|
|
73
|
+
* `value`, or with the attribute removed entirely when `value` is empty.
|
|
74
|
+
* The empty-removes-the-attribute behaviour avoids serializing `prop=""`
|
|
75
|
+
* back to the file.
|
|
76
|
+
*/
|
|
77
|
+
function writeStringAttribute(attributes, name, value) {
|
|
78
|
+
const next = attributes.filter((a) => !(a.type === "mdxJsxAttribute" && a.name === name));
|
|
79
|
+
if (value.length > 0) next.push({
|
|
80
|
+
type: "mdxJsxAttribute",
|
|
81
|
+
name,
|
|
82
|
+
value
|
|
83
|
+
});
|
|
84
|
+
return next;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Type-aware attribute writer. Encodes the value into the right
|
|
88
|
+
* mdast shape so the saved MDX matches what an author would write
|
|
89
|
+
* by hand:
|
|
90
|
+
*
|
|
91
|
+
* - `string` → `prop="value"` (or removed if empty)
|
|
92
|
+
* - `boolean true` → `prop` (JSX shorthand; value: null)
|
|
93
|
+
* - `boolean false` → REMOVED (default is implicit-false)
|
|
94
|
+
* - `number` → `prop={42}` (expression so `2` ≠ `"2"`)
|
|
95
|
+
* - `null`/`undefined` → REMOVED
|
|
96
|
+
*
|
|
97
|
+
* The string-only `writeStringAttribute` stays for callers that only
|
|
98
|
+
* deal with strings (the inline-prop editor, free-text inputs). This
|
|
99
|
+
* is for the side panel where booleans and numbers need correct mdast
|
|
100
|
+
* encoding so a `stagger?: boolean` round-trips as `<CardGrid stagger>`
|
|
101
|
+
* and not the truthy-but-incorrect `<CardGrid stagger="true">`.
|
|
102
|
+
*/
|
|
103
|
+
function writeAttribute(attributes, name, value) {
|
|
104
|
+
const next = attributes.filter((a) => !(a.type === "mdxJsxAttribute" && a.name === name));
|
|
105
|
+
if (value === null || value === void 0) return next;
|
|
106
|
+
if (typeof value === "string") {
|
|
107
|
+
if (value.length === 0) return next;
|
|
108
|
+
next.push({
|
|
109
|
+
type: "mdxJsxAttribute",
|
|
110
|
+
name,
|
|
111
|
+
value
|
|
112
|
+
});
|
|
113
|
+
} else if (typeof value === "boolean") {
|
|
114
|
+
if (!value) return next;
|
|
115
|
+
next.push({
|
|
116
|
+
type: "mdxJsxAttribute",
|
|
117
|
+
name,
|
|
118
|
+
value: null
|
|
119
|
+
});
|
|
120
|
+
} else if (typeof value === "number") next.push({
|
|
121
|
+
type: "mdxJsxAttribute",
|
|
122
|
+
name,
|
|
123
|
+
value: {
|
|
124
|
+
type: "mdxJsxAttributeValueExpression",
|
|
125
|
+
value: String(value)
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
return next;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Translate a JSX-flavored plugin descriptor to the upstream
|
|
132
|
+
* `JsxComponentDescriptor` shape that `@mdxeditor/editor` consumes.
|
|
133
|
+
* Booleans surface as expressions (`{true}`) because the upstream
|
|
134
|
+
* `JsxPropertyDescriptor.type` is `'string' | 'number' | 'expression'`.
|
|
135
|
+
*
|
|
136
|
+
* The fallback editor is injected by the CMS editor entrypoint. Keeping that
|
|
137
|
+
* dependency one-way prevents the registry module from importing GenericBlock,
|
|
138
|
+
* which itself consumes this registry.
|
|
139
|
+
*
|
|
140
|
+
* Snippet descriptors are not JSX — call sites filter them out before
|
|
141
|
+
* dispatching here. Passing one throws to surface the misuse loudly.
|
|
142
|
+
*/
|
|
143
|
+
function toJsxComponentDescriptor(d, fallbackEditor) {
|
|
144
|
+
if (!isJsxDescriptor(d)) throw new Error(`toJsxComponentDescriptor: '${d.name}' is a snippet, not a JSX component.`);
|
|
145
|
+
return {
|
|
146
|
+
name: d.name,
|
|
147
|
+
kind: d.kind,
|
|
148
|
+
props: (d.props ?? []).map((p) => ({
|
|
149
|
+
name: p.name,
|
|
150
|
+
type: p.type === "boolean" ? "expression" : p.type,
|
|
151
|
+
required: p.required
|
|
152
|
+
})),
|
|
153
|
+
hasChildren: d.hasChildren,
|
|
154
|
+
Editor: d.Editor ?? fallbackEditor,
|
|
155
|
+
...d.import ? {
|
|
156
|
+
source: d.import.from,
|
|
157
|
+
defaultExport: d.import.default ?? false
|
|
158
|
+
} : {}
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
const getSharedState = () => {
|
|
162
|
+
if (typeof window !== "undefined") {
|
|
163
|
+
const w = window;
|
|
164
|
+
if (!w.__MDX_COMPONENTS_STATE__) w.__MDX_COMPONENTS_STATE__ = {
|
|
165
|
+
components: [],
|
|
166
|
+
subscribers: /* @__PURE__ */ new Set()
|
|
167
|
+
};
|
|
168
|
+
return w.__MDX_COMPONENTS_STATE__;
|
|
169
|
+
}
|
|
170
|
+
return {
|
|
171
|
+
components: [],
|
|
172
|
+
subscribers: /* @__PURE__ */ new Set()
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
/**
|
|
176
|
+
* Replace the registered MDX components. Called by the virtual module that
|
|
177
|
+
* loads the host's `schemas.ts`. Notifies subscribers so the editor picks
|
|
178
|
+
* up HMR updates without remounting.
|
|
179
|
+
*/
|
|
180
|
+
function setMdxComponents(components) {
|
|
181
|
+
const state = getSharedState();
|
|
182
|
+
state.components = components;
|
|
183
|
+
for (const fn of state.subscribers) fn(components);
|
|
184
|
+
}
|
|
185
|
+
/** Read the current registry synchronously. */
|
|
186
|
+
function getMdxComponents() {
|
|
187
|
+
return getSharedState().components;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* React hook subscribing to registry changes. Returns the current array and
|
|
191
|
+
* updates on HMR.
|
|
192
|
+
*/
|
|
193
|
+
function useMdxComponents() {
|
|
194
|
+
const [components, setComponents] = useState(() => getSharedState().components);
|
|
195
|
+
useEffect(() => {
|
|
196
|
+
const state = getSharedState();
|
|
197
|
+
if (state.components !== components) setComponents(state.components);
|
|
198
|
+
state.subscribers.add(setComponents);
|
|
199
|
+
return () => {
|
|
200
|
+
state.subscribers.delete(setComponents);
|
|
201
|
+
};
|
|
202
|
+
}, [components]);
|
|
203
|
+
return components;
|
|
204
|
+
}
|
|
205
|
+
//#endregion
|
|
206
|
+
export { containsMarkdownMarkers, defineMdxComponents, getMdxComponents, isJsxDescriptor, isSnippetDescriptor, readStringAttribute, setMdxComponents, toJsxComponentDescriptor, useMdxComponents, writeAttribute, writeStringAttribute };
|
|
207
|
+
|
|
208
|
+
//# sourceMappingURL=mdx-components.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mdx-components.mjs","names":[],"sources":["../src/mdx-components.ts"],"sourcesContent":["import type { JsxComponentDescriptor, JsxEditorProps } from '@mdxeditor/editor';\nimport type { MdxJsxAttribute, MdxJsxFlowElement, MdxJsxTextElement } from 'mdast-util-mdx-jsx';\nimport type { ComponentType } from 'react';\nimport { useEffect, useState } from 'react';\n\n/**\n * Plugin API for registering insertable content for the CMS editor.\n *\n * Two flavors live in the same registry:\n *\n * 1. JSX components (`kind: 'flow' | 'text'`) — typed MDX components with\n * prop-editor forms and optional auto-import injection.\n * 2. Markdown snippets (`kind: 'snippet'`) — host-defined boilerplate\n * chunks the toolbar/slash menu insert as raw MDX. Used for \"starting\n * points\" that are pure prose (callouts, comparison tables, lists)\n * rather than reusable JSX surfaces.\n *\n * Mirrors the shape of `page-schemas.ts` — same `define*` identity helper,\n * same `setX/getX/useX` triad backed by a shared window-state cell, same\n * HMR subscriber pattern. Hosts add an `mdxComponents` export to the file\n * pointed at by the Astro integration's `schemasPath` option; the virtual\n * module loader in `@conloca/astro-cms` picks it up alongside `pageSchemas`.\n *\n * Pruning caveat (JSX flavor only): when `import.from` is set, the import\n * is added/removed by `@mdxeditor/editor`'s own export pipeline, which\n * rebuilds the import block on every save from the components actually\n * referenced in the document. Unrelated author imports (types, side\n * effects) are dropped. See the astro-cms README for the full constraint.\n */\n\nexport type MdxComponentProp =\n | {\n name: string;\n type: 'string';\n required?: boolean;\n label?: string;\n help?: string;\n defaultValue?: string;\n options?: ReadonlyArray<{ value: string; label: string }>;\n }\n | {\n name: string;\n type: 'number';\n required?: boolean;\n label?: string;\n help?: string;\n defaultValue?: number;\n }\n | {\n name: string;\n type: 'boolean';\n required?: boolean;\n label?: string;\n help?: string;\n defaultValue?: boolean;\n };\n\nexport interface MdxComponentInsertHint {\n /** Human-readable label shown in the slash menu and the toolbar dropdown. */\n label: string;\n /** Optional one-line description shown under the label in the slash menu. */\n description?: string;\n /** Optional Lucide icon name (rendered by the existing icon registry). */\n icon?: string;\n /** Aliases that match in slash-menu search ('callout' would match Aside). */\n keywords?: ReadonlyArray<string>;\n /**\n * Optional grouping label for the toolbar dropdown. Descriptors with the\n * same `category` render under a shared section header; descriptors that\n * omit it land in the default ungrouped bucket. Slash-menu rendering\n * currently ignores this — typeahead works better as a flat list.\n */\n category?: string;\n}\n\n/**\n * JSX component descriptor — a typed MDX surface the editor can prop-edit\n * and (optionally) keep imports synced for.\n */\nexport interface MdxJsxComponentDescriptor {\n /** Tag name authors write in MDX, e.g. 'Steps'. Unique across the registry. */\n name: string;\n /** Block-level (`flow`) or inline (`text`). */\n kind: 'flow' | 'text';\n /** Insert-time UI hints. Omit to hide from the slash menu and toolbar. */\n insert?: MdxComponentInsertHint;\n /** Props the in-place editor surfaces in its form. */\n props?: ReadonlyArray<MdxComponentProp>;\n /** Whether the component accepts children (nested rich-text editor). */\n hasChildren?: boolean;\n /** Default attributes used at insert time. */\n defaults?: {\n attributes?: Record<string, string | number | boolean>;\n /** Raw MDX snippet parsed to mdast children at insert time. */\n children?: string;\n };\n /** Custom in-place editor. Falls back to GenericJsxEditor when omitted. */\n Editor?: ComponentType<JsxEditorProps>;\n /**\n * Opt-in import injection. When set, the editor's save serializer emits\n * `import { Name } from '<from>'` (or `import Name from '<from>'` when\n * `default: true`) whenever this component appears in the document.\n * Maps directly to upstream `JsxComponentDescriptor.source` +\n * `defaultExport`. See the pruning caveat at the top of this file.\n */\n import?: { from: string; default?: boolean };\n}\n\n/**\n * Markdown snippet descriptor — a host-defined boilerplate chunk inserted\n * as raw MDX. No props, no auto-import, no in-place editor: once inserted\n * the snippet *is* the document content, edited inline like any other\n * markdown.\n */\nexport interface MdxSnippetDescriptor {\n /**\n * Stable id. Not exposed in the output MDX; used only as a registry key\n * (so two snippets named 'Callout' would collide the same way two JSX\n * `<Callout>` components would).\n */\n name: string;\n kind: 'snippet';\n /** Insert-time UI hints. Required — a snippet with no label can't be inserted. */\n insert: MdxComponentInsertHint;\n /**\n * Raw MDX inserted at the cursor when the snippet is chosen. Parsed by\n * `@mdxeditor/editor`'s markdown insertion path, so JSX (e.g. nested\n * `<Card>`) round-trips through the registered JSX descriptors.\n */\n content: string;\n}\n\nexport type MdxComponentDescriptor = MdxJsxComponentDescriptor | MdxSnippetDescriptor;\n\nexport type MdxComponents = ReadonlyArray<MdxComponentDescriptor>;\n\n/** Type guard: descriptor is the JSX variant (vs. a snippet). */\nexport function isJsxDescriptor(d: MdxComponentDescriptor): d is MdxJsxComponentDescriptor {\n return d.kind === 'flow' || d.kind === 'text';\n}\n\n/** Type guard: descriptor is the snippet variant. */\nexport function isSnippetDescriptor(d: MdxComponentDescriptor): d is MdxSnippetDescriptor {\n return d.kind === 'snippet';\n}\n\n/**\n * Identity helper that validates registration-time invariants.\n *\n * Throws on:\n * - duplicate `name` across the array (across kinds — a JSX `<Aside>` and a\n * snippet named 'Aside' would clash in the insert menu);\n * - `kind: 'text'` with `hasChildren: true` (text-kind JSX is treated as an\n * inline atom by the Lexical bridge);\n * - two JSX descriptors with conflicting `import.from` for the same `name`\n * (deterministic merge failure that would otherwise surface as a confusing\n * save-time error);\n * - snippet descriptors with an empty `content` string (would silently\n * insert nothing and look like a broken menu item).\n */\nexport function defineMdxComponents(components: MdxComponents): MdxComponents {\n const seen = new Map<string, MdxComponentDescriptor>();\n for (const descriptor of components) {\n const existing = seen.get(descriptor.name);\n if (existing) {\n // Duplicate-import is reported with its specific message because that\n // class of mistake comes from two registration files merging — the\n // generic 'duplicate descriptor' hint isn't enough to debug it.\n const a = isJsxDescriptor(existing) ? existing.import?.from : undefined;\n const b = isJsxDescriptor(descriptor) ? descriptor.import?.from : undefined;\n if (a !== b) {\n throw new Error(\n `defineMdxComponents: duplicate descriptor for '${descriptor.name}' with conflicting import.from (` +\n `'${a ?? '<none>'}' vs '${b ?? '<none>'}').`,\n );\n }\n throw new Error(`defineMdxComponents: duplicate descriptor for '${descriptor.name}'.`);\n }\n if (isJsxDescriptor(descriptor) && descriptor.kind === 'text' && descriptor.hasChildren) {\n throw new Error(\n `defineMdxComponents: descriptor '${descriptor.name}' has kind: 'text' with hasChildren: true — ` +\n \"text-kind JSX is treated as an inline atom; use kind: 'flow' for components with children.\",\n );\n }\n if (isSnippetDescriptor(descriptor) && descriptor.content.length === 0) {\n throw new Error(\n `defineMdxComponents: snippet descriptor '${descriptor.name}' has empty content — ` +\n 'a snippet with no content would silently insert nothing.',\n );\n }\n seen.set(descriptor.name, descriptor);\n }\n return components;\n}\n\n/**\n * Read a string-valued JSX attribute from an mdast flow element. Returns\n * an empty string when the attribute is missing or holds an expression\n * value (e.g. `prop={2}`). Designed for use inside `Editor` components on\n * an `MdxComponentDescriptor` — the typed editor that wants to drive a\n * controlled `<input value={...}>` against a string prop.\n */\n/**\n * Conservative detection for \"this string prop value carries markdown\n * formatting.\" Used to decide whether inline editing in the SSR'd\n * preview is safe: a plaintext-only contenteditable would strip the\n * formatting on commit, so we'd rather route those props through the\n * side panel (where the author sees the raw text and decides).\n *\n * Detects only unambiguous markers — `**bold**` / `*em*`, inline code\n * `` `x` ``, and the `[text](url)` link form. Skips `_` / `__` (would\n * false-positive on filenames like `__init__.py`) and skips single\n * `*` (false-positive risk on prose). False positives just mean \"edit\n * via panel instead of inline\" which is the safe fallback; false\n * negatives silently destroy formatting, which is not.\n */\nconst MARKDOWN_MARKER_RE = /\\*\\*|`|\\[[^\\]\\n]+?\\]\\([^)\\n]+?\\)/;\nexport function containsMarkdownMarkers(value: string): boolean {\n return MARKDOWN_MARKER_RE.test(value);\n}\n\nexport function readStringAttribute(node: MdxJsxFlowElement | MdxJsxTextElement, name: string): string {\n const attr = node.attributes.find((a): a is MdxJsxAttribute => a.type === 'mdxJsxAttribute' && a.name === name);\n if (!attr || typeof attr.value !== 'string') return '';\n return attr.value;\n}\n\n/**\n * Return a new attributes array with the given string attribute set to\n * `value`, or with the attribute removed entirely when `value` is empty.\n * The empty-removes-the-attribute behaviour avoids serializing `prop=\"\"`\n * back to the file.\n */\nexport function writeStringAttribute<T extends MdxJsxFlowElement | MdxJsxTextElement>(\n attributes: T['attributes'],\n name: string,\n value: string,\n): T['attributes'] {\n const next = attributes.filter((a) => !(a.type === 'mdxJsxAttribute' && a.name === name));\n if (value.length > 0) {\n next.push({ type: 'mdxJsxAttribute', name, value });\n }\n return next as T['attributes'];\n}\n\n/**\n * Type-aware attribute writer. Encodes the value into the right\n * mdast shape so the saved MDX matches what an author would write\n * by hand:\n *\n * - `string` → `prop=\"value\"` (or removed if empty)\n * - `boolean true` → `prop` (JSX shorthand; value: null)\n * - `boolean false` → REMOVED (default is implicit-false)\n * - `number` → `prop={42}` (expression so `2` ≠ `\"2\"`)\n * - `null`/`undefined` → REMOVED\n *\n * The string-only `writeStringAttribute` stays for callers that only\n * deal with strings (the inline-prop editor, free-text inputs). This\n * is for the side panel where booleans and numbers need correct mdast\n * encoding so a `stagger?: boolean` round-trips as `<CardGrid stagger>`\n * and not the truthy-but-incorrect `<CardGrid stagger=\"true\">`.\n */\nexport function writeAttribute<T extends MdxJsxFlowElement | MdxJsxTextElement>(\n attributes: T['attributes'],\n name: string,\n value: string | boolean | number | null | undefined,\n): T['attributes'] {\n const next = attributes.filter((a) => !(a.type === 'mdxJsxAttribute' && a.name === name));\n if (value === null || value === undefined) return next as T['attributes'];\n if (typeof value === 'string') {\n if (value.length === 0) return next as T['attributes'];\n next.push({ type: 'mdxJsxAttribute', name, value });\n } else if (typeof value === 'boolean') {\n if (!value) return next as T['attributes'];\n // JSX shorthand: `<Component prop />` is `value: null` in mdast.\n next.push({ type: 'mdxJsxAttribute', name, value: null });\n } else if (typeof value === 'number') {\n // Numbers must be expressions so the compiler reads `2` as a\n // number, not the string `\"2\"`. mdast-util-mdx-jsx expects an\n // `mdxJsxAttributeValueExpression` whose `value` is the source\n // text the runtime will evaluate.\n next.push({\n type: 'mdxJsxAttribute',\n name,\n value: { type: 'mdxJsxAttributeValueExpression', value: String(value) },\n });\n }\n return next as T['attributes'];\n}\n\n/**\n * Translate a JSX-flavored plugin descriptor to the upstream\n * `JsxComponentDescriptor` shape that `@mdxeditor/editor` consumes.\n * Booleans surface as expressions (`{true}`) because the upstream\n * `JsxPropertyDescriptor.type` is `'string' | 'number' | 'expression'`.\n *\n * The fallback editor is injected by the CMS editor entrypoint. Keeping that\n * dependency one-way prevents the registry module from importing GenericBlock,\n * which itself consumes this registry.\n *\n * Snippet descriptors are not JSX — call sites filter them out before\n * dispatching here. Passing one throws to surface the misuse loudly.\n */\nexport function toJsxComponentDescriptor(\n d: MdxComponentDescriptor,\n fallbackEditor: ComponentType<JsxEditorProps>,\n): JsxComponentDescriptor {\n if (!isJsxDescriptor(d)) {\n throw new Error(`toJsxComponentDescriptor: '${d.name}' is a snippet, not a JSX component.`);\n }\n return {\n name: d.name,\n kind: d.kind,\n props: (d.props ?? []).map((p) => ({\n name: p.name,\n type: p.type === 'boolean' ? 'expression' : p.type,\n required: p.required,\n })),\n hasChildren: d.hasChildren,\n Editor: d.Editor ?? fallbackEditor,\n ...(d.import ? { source: d.import.from, defaultExport: d.import.default ?? false } : {}),\n };\n}\n\ninterface SharedMdxComponentsState {\n components: MdxComponents;\n subscribers: Set<(components: MdxComponents) => void>;\n}\n\nconst getSharedState = (): SharedMdxComponentsState => {\n if (typeof window !== 'undefined') {\n const w = window as unknown as { __MDX_COMPONENTS_STATE__?: SharedMdxComponentsState };\n if (!w.__MDX_COMPONENTS_STATE__) {\n w.__MDX_COMPONENTS_STATE__ = {\n components: [],\n subscribers: new Set(),\n };\n }\n return w.__MDX_COMPONENTS_STATE__;\n }\n return { components: [], subscribers: new Set() };\n};\n\n/**\n * Replace the registered MDX components. Called by the virtual module that\n * loads the host's `schemas.ts`. Notifies subscribers so the editor picks\n * up HMR updates without remounting.\n */\nexport function setMdxComponents(components: MdxComponents): void {\n const state = getSharedState();\n state.components = components;\n for (const fn of state.subscribers) {\n fn(components);\n }\n}\n\n/** Read the current registry synchronously. */\nexport function getMdxComponents(): MdxComponents {\n return getSharedState().components;\n}\n\n/**\n * React hook subscribing to registry changes. Returns the current array and\n * updates on HMR.\n */\nexport function useMdxComponents(): MdxComponents {\n const [components, setComponents] = useState(() => getSharedState().components);\n\n useEffect(() => {\n const state = getSharedState();\n if (state.components !== components) {\n setComponents(state.components);\n }\n state.subscribers.add(setComponents);\n return () => {\n state.subscribers.delete(setComponents);\n };\n }, [components]);\n\n return components;\n}\n"],"mappings":";;;AAyIA,SAAgB,gBAAgB,GAA2D;CACzF,OAAO,EAAE,SAAS,UAAU,EAAE,SAAS;AACzC;;AAGA,SAAgB,oBAAoB,GAAsD;CACxF,OAAO,EAAE,SAAS;AACpB;;;;;;;;;;;;;;;AAgBA,SAAgB,oBAAoB,YAA0C;CAC5E,MAAM,uBAAO,IAAI,IAAoC;CACrD,KAAK,MAAM,cAAc,YAAY;EACnC,MAAM,WAAW,KAAK,IAAI,WAAW,IAAI;EACzC,IAAI,UAAU;GAIZ,MAAM,IAAI,gBAAgB,QAAQ,IAAI,SAAS,QAAQ,OAAO,KAAA;GAC9D,MAAM,IAAI,gBAAgB,UAAU,IAAI,WAAW,QAAQ,OAAO,KAAA;GAClE,IAAI,MAAM,GACR,MAAM,IAAI,MACR,kDAAkD,WAAW,KAAK,mCAC5D,KAAK,SAAS,QAAQ,KAAK,SAAS,IAC5C;GAEF,MAAM,IAAI,MAAM,kDAAkD,WAAW,KAAK,GAAG;EACvF;EACA,IAAI,gBAAgB,UAAU,KAAK,WAAW,SAAS,UAAU,WAAW,aAC1E,MAAM,IAAI,MACR,oCAAoC,WAAW,KAAK,uIAEtD;EAEF,IAAI,oBAAoB,UAAU,KAAK,WAAW,QAAQ,WAAW,GACnE,MAAM,IAAI,MACR,4CAA4C,WAAW,KAAK,+EAE9D;EAEF,KAAK,IAAI,WAAW,MAAM,UAAU;CACtC;CACA,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAM,qBAAqB;AAC3B,SAAgB,wBAAwB,OAAwB;CAC9D,OAAO,mBAAmB,KAAK,KAAK;AACtC;AAEA,SAAgB,oBAAoB,MAA6C,MAAsB;CACrG,MAAM,OAAO,KAAK,WAAW,MAAM,MAA4B,EAAE,SAAS,qBAAqB,EAAE,SAAS,IAAI;CAC9G,IAAI,CAAC,QAAQ,OAAO,KAAK,UAAU,UAAU,OAAO;CACpD,OAAO,KAAK;AACd;;;;;;;AAQA,SAAgB,qBACd,YACA,MACA,OACiB;CACjB,MAAM,OAAO,WAAW,QAAQ,MAAM,EAAE,EAAE,SAAS,qBAAqB,EAAE,SAAS,KAAK;CACxF,IAAI,MAAM,SAAS,GACjB,KAAK,KAAK;EAAE,MAAM;EAAmB;EAAM;CAAM,CAAC;CAEpD,OAAO;AACT;;;;;;;;;;;;;;;;;;AAmBA,SAAgB,eACd,YACA,MACA,OACiB;CACjB,MAAM,OAAO,WAAW,QAAQ,MAAM,EAAE,EAAE,SAAS,qBAAqB,EAAE,SAAS,KAAK;CACxF,IAAI,UAAU,QAAQ,UAAU,KAAA,GAAW,OAAO;CAClD,IAAI,OAAO,UAAU,UAAU;EAC7B,IAAI,MAAM,WAAW,GAAG,OAAO;EAC/B,KAAK,KAAK;GAAE,MAAM;GAAmB;GAAM;EAAM,CAAC;CACpD,OAAO,IAAI,OAAO,UAAU,WAAW;EACrC,IAAI,CAAC,OAAO,OAAO;EAEnB,KAAK,KAAK;GAAE,MAAM;GAAmB;GAAM,OAAO;EAAK,CAAC;CAC1D,OAAO,IAAI,OAAO,UAAU,UAK1B,KAAK,KAAK;EACR,MAAM;EACN;EACA,OAAO;GAAE,MAAM;GAAkC,OAAO,OAAO,KAAK;EAAE;CACxE,CAAC;CAEH,OAAO;AACT;;;;;;;;;;;;;;AAeA,SAAgB,yBACd,GACA,gBACwB;CACxB,IAAI,CAAC,gBAAgB,CAAC,GACpB,MAAM,IAAI,MAAM,8BAA8B,EAAE,KAAK,qCAAqC;CAE5F,OAAO;EACL,MAAM,EAAE;EACR,MAAM,EAAE;EACR,QAAQ,EAAE,SAAS,CAAC,EAAA,CAAG,KAAK,OAAO;GACjC,MAAM,EAAE;GACR,MAAM,EAAE,SAAS,YAAY,eAAe,EAAE;GAC9C,UAAU,EAAE;EACd,EAAE;EACF,aAAa,EAAE;EACf,QAAQ,EAAE,UAAU;EACpB,GAAI,EAAE,SAAS;GAAE,QAAQ,EAAE,OAAO;GAAM,eAAe,EAAE,OAAO,WAAW;EAAM,IAAI,CAAC;CACxF;AACF;AAOA,MAAM,uBAAiD;CACrD,IAAI,OAAO,WAAW,aAAa;EACjC,MAAM,IAAI;EACV,IAAI,CAAC,EAAE,0BACL,EAAE,2BAA2B;GAC3B,YAAY,CAAC;GACb,6BAAa,IAAI,IAAI;EACvB;EAEF,OAAO,EAAE;CACX;CACA,OAAO;EAAE,YAAY,CAAC;EAAG,6BAAa,IAAI,IAAI;CAAE;AAClD;;;;;;AAOA,SAAgB,iBAAiB,YAAiC;CAChE,MAAM,QAAQ,eAAe;CAC7B,MAAM,aAAa;CACnB,KAAK,MAAM,MAAM,MAAM,aACrB,GAAG,UAAU;AAEjB;;AAGA,SAAgB,mBAAkC;CAChD,OAAO,eAAe,CAAC,CAAC;AAC1B;;;;;AAMA,SAAgB,mBAAkC;CAChD,MAAM,CAAC,YAAY,iBAAiB,eAAe,eAAe,CAAC,CAAC,UAAU;CAE9E,gBAAgB;EACd,MAAM,QAAQ,eAAe;EAC7B,IAAI,MAAM,eAAe,YACvB,cAAc,MAAM,UAAU;EAEhC,MAAM,YAAY,IAAI,aAAa;EACnC,aAAa;GACX,MAAM,YAAY,OAAO,aAAa;EACxC;CACF,GAAG,CAAC,UAAU,CAAC;CAEf,OAAO;AACT"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { AssetScope } from './types';
|
|
2
|
+
interface AssetScopePillProps {
|
|
3
|
+
scope: AssetScope | null;
|
|
4
|
+
/**
|
|
5
|
+
* Visual size variant. `sm` is the AssetCard corner badge;
|
|
6
|
+
* `md` is the AssetDetailSidebar inline label. Defaults to `sm`.
|
|
7
|
+
*/
|
|
8
|
+
size?: 'sm' | 'md';
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Pill rendering the hosted-mode `AssetScope` ("Branch only" /
|
|
13
|
+
* "Published"). When `scope` is `null`, renders nothing — callers
|
|
14
|
+
* can safely render this unconditionally and let it disappear when
|
|
15
|
+
* no bridge is installed (the local-Astro case).
|
|
16
|
+
*
|
|
17
|
+
* Colour vocabulary mirrors the broader cms-spa palette:
|
|
18
|
+
*
|
|
19
|
+
* - `published` → green (matches the deploy "live" indicator —
|
|
20
|
+
* "this is what your site is serving").
|
|
21
|
+
* - `branch` → amber (matches the "work in flight" idiom from
|
|
22
|
+
* git-status / divergence banners — "yours alone for now,
|
|
23
|
+
* needs promotion before anyone else sees it").
|
|
24
|
+
*
|
|
25
|
+
* The pill itself is purely presentational; the bridge wiring and
|
|
26
|
+
* promotion gate live in the host shell.
|
|
27
|
+
*/
|
|
28
|
+
export declare function AssetScopePill({ scope, size, className }: AssetScopePillProps): import("react/jsx-runtime").JSX.Element | null;
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=AssetScopePill.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AssetScopePill.d.ts","sourceRoot":"","sources":["../../src/media/AssetScopePill.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,UAAU,mBAAmB;IAC3B,KAAK,EAAE,UAAU,GAAG,IAAI,CAAC;IACzB;;;OAGG;IACH,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,cAAc,CAAC,EAAE,KAAK,EAAE,IAAW,EAAE,SAAS,EAAE,EAAE,mBAAmB,kDAyBpF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from '../utils/cn';
|
|
3
|
+
/**
|
|
4
|
+
* Pill rendering the hosted-mode `AssetScope` ("Branch only" /
|
|
5
|
+
* "Published"). When `scope` is `null`, renders nothing — callers
|
|
6
|
+
* can safely render this unconditionally and let it disappear when
|
|
7
|
+
* no bridge is installed (the local-Astro case).
|
|
8
|
+
*
|
|
9
|
+
* Colour vocabulary mirrors the broader cms-spa palette:
|
|
10
|
+
*
|
|
11
|
+
* - `published` → green (matches the deploy "live" indicator —
|
|
12
|
+
* "this is what your site is serving").
|
|
13
|
+
* - `branch` → amber (matches the "work in flight" idiom from
|
|
14
|
+
* git-status / divergence banners — "yours alone for now,
|
|
15
|
+
* needs promotion before anyone else sees it").
|
|
16
|
+
*
|
|
17
|
+
* The pill itself is purely presentational; the bridge wiring and
|
|
18
|
+
* promotion gate live in the host shell.
|
|
19
|
+
*/
|
|
20
|
+
export function AssetScopePill({ scope, size = 'sm', className }) {
|
|
21
|
+
if (!scope)
|
|
22
|
+
return null;
|
|
23
|
+
const isBranch = scope === 'branch';
|
|
24
|
+
const label = isBranch ? 'Branch only' : 'Published';
|
|
25
|
+
const sizeClasses = size === 'sm' ? 'text-[10px] px-1.5 py-0.5 leading-tight' : 'text-xs px-2 py-0.5';
|
|
26
|
+
const variantClasses = isBranch
|
|
27
|
+
? 'bg-yellow-11 dark:bg-yellow-02 text-yellow-04 dark:text-yellow-09 border-yellow-08 dark:border-yellow-03'
|
|
28
|
+
: 'bg-green-11 dark:bg-green-02 text-green-04 dark:text-green-08 border-green-08 dark:border-green-03';
|
|
29
|
+
return (_jsx("span", { role: "status", "aria-label": `Asset scope: ${label}`, className: cn('inline-flex items-center font-medium rounded border uppercase tracking-wide', sizeClasses, variantClasses, className), children: label }));
|
|
30
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { MediaIssue } from './types';
|
|
2
|
+
interface MediaIssueBadgeProps {
|
|
3
|
+
issue: MediaIssue | null;
|
|
4
|
+
/**
|
|
5
|
+
* Visual size variant. `sm` is the AssetCard corner badge;
|
|
6
|
+
* `md` is the AssetDetailSidebar inline block (with full reason
|
|
7
|
+
* text). Defaults to `sm`.
|
|
8
|
+
*/
|
|
9
|
+
size?: 'sm' | 'md';
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Badge rendering a hosted-mode `MediaIssue` ("Oversized" /
|
|
14
|
+
* "Blocked"). When `issue` is `null`, renders nothing — callers
|
|
15
|
+
* can mount this unconditionally and let it disappear when the
|
|
16
|
+
* host has no bridge or the asset is healthy.
|
|
17
|
+
*
|
|
18
|
+
* Colour vocabulary:
|
|
19
|
+
*
|
|
20
|
+
* - `blocked` → red (matches the destructive / fail palette —
|
|
21
|
+
* "this cannot ship").
|
|
22
|
+
* - `oversized` → amber (matches the "work in flight / take
|
|
23
|
+
* action" idiom shared with `AssetScopePill`'s branch variant —
|
|
24
|
+
* "it ships, just slower than it should").
|
|
25
|
+
*
|
|
26
|
+
* `sm` paints a compact one-word badge for the AssetCard corner
|
|
27
|
+
* (sits below the scope pill so the two stack cleanly). `md` paints
|
|
28
|
+
* a wider block with the full reason / size detail for the
|
|
29
|
+
* AssetDetailSidebar header.
|
|
30
|
+
*/
|
|
31
|
+
export declare function MediaIssueBadge({ issue, size, className }: MediaIssueBadgeProps): import("react/jsx-runtime").JSX.Element | null;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=MediaIssueBadge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MediaIssueBadge.d.ts","sourceRoot":"","sources":["../../src/media/MediaIssueBadge.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,UAAU,oBAAoB;IAC5B,KAAK,EAAE,UAAU,GAAG,IAAI,CAAC;IACzB;;;;OAIG;IACH,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAgBD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,eAAe,CAAC,EAAE,KAAK,EAAE,IAAW,EAAE,SAAS,EAAE,EAAE,oBAAoB,kDAsCtF"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from '../utils/cn';
|
|
3
|
+
/**
|
|
4
|
+
* Format an oversized issue's size delta into customer-facing copy
|
|
5
|
+
* for the `md` variant. `sm` only uses the short label so the corner
|
|
6
|
+
* badge stays scannable; this helper kicks in for the sidebar block.
|
|
7
|
+
*
|
|
8
|
+
* Rounds to one decimal MB for readability — promoting "5.4 MB"
|
|
9
|
+
* over "5,400,000 bytes" matches the rest of cms-spa's file-size
|
|
10
|
+
* vocabulary (`formatFileSize`).
|
|
11
|
+
*/
|
|
12
|
+
function formatOversizedDetail(sizeBytes, limitBytes) {
|
|
13
|
+
const mb = (bytes) => `${(bytes / 1_000_000).toFixed(1).replace(/\.0$/, '')} MB`;
|
|
14
|
+
return `${mb(sizeBytes)} exceeds the ${mb(limitBytes)} inline limit. Move to media storage.`;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Badge rendering a hosted-mode `MediaIssue` ("Oversized" /
|
|
18
|
+
* "Blocked"). When `issue` is `null`, renders nothing — callers
|
|
19
|
+
* can mount this unconditionally and let it disappear when the
|
|
20
|
+
* host has no bridge or the asset is healthy.
|
|
21
|
+
*
|
|
22
|
+
* Colour vocabulary:
|
|
23
|
+
*
|
|
24
|
+
* - `blocked` → red (matches the destructive / fail palette —
|
|
25
|
+
* "this cannot ship").
|
|
26
|
+
* - `oversized` → amber (matches the "work in flight / take
|
|
27
|
+
* action" idiom shared with `AssetScopePill`'s branch variant —
|
|
28
|
+
* "it ships, just slower than it should").
|
|
29
|
+
*
|
|
30
|
+
* `sm` paints a compact one-word badge for the AssetCard corner
|
|
31
|
+
* (sits below the scope pill so the two stack cleanly). `md` paints
|
|
32
|
+
* a wider block with the full reason / size detail for the
|
|
33
|
+
* AssetDetailSidebar header.
|
|
34
|
+
*/
|
|
35
|
+
export function MediaIssueBadge({ issue, size = 'sm', className }) {
|
|
36
|
+
if (!issue)
|
|
37
|
+
return null;
|
|
38
|
+
const isBlocked = issue.kind === 'blocked';
|
|
39
|
+
const shortLabel = isBlocked ? 'Blocked' : 'Oversized';
|
|
40
|
+
const sizeClasses = size === 'sm' ? 'text-[10px] px-1.5 py-0.5 leading-tight' : 'text-xs px-2 py-1';
|
|
41
|
+
const variantClasses = isBlocked
|
|
42
|
+
? 'bg-red-11 dark:bg-red-02 text-red-04 dark:text-red-08 border-red-08 dark:border-red-03'
|
|
43
|
+
: 'bg-amber-11 dark:bg-amber-02 text-amber-04 dark:text-amber-08 border-amber-08 dark:border-amber-03';
|
|
44
|
+
// `md` paints the full reason / size delta so the sidebar
|
|
45
|
+
// surface reads as a self-contained explanation, not just a
|
|
46
|
+
// label. `sm` stays at the short label so the AssetCard corner
|
|
47
|
+
// doesn't get crowded.
|
|
48
|
+
const detail = size === 'md'
|
|
49
|
+
? issue.kind === 'blocked'
|
|
50
|
+
? issue.reason
|
|
51
|
+
: formatOversizedDetail(issue.sizeBytes, issue.limitBytes)
|
|
52
|
+
: null;
|
|
53
|
+
return (_jsxs("span", { role: "status", "aria-label": `Media issue: ${shortLabel}${detail ? ` — ${detail}` : ''}`, className: cn('inline-flex items-center font-medium rounded border', size === 'sm' ? 'uppercase tracking-wide' : 'gap-2', sizeClasses, variantClasses, className), children: [_jsx("span", { className: size === 'md' ? 'uppercase tracking-wide font-semibold' : undefined, children: shortLabel }), detail ? _jsx("span", { className: "font-normal normal-case tracking-normal", children: detail }) : null] }));
|
|
54
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lifecycle scope of a media asset in a hosted-mode (branch-aware)
|
|
3
|
+
* context. cms-spa's renderer-neutral `AssetEntry` (in
|
|
4
|
+
* `content-api/asset-types.ts`) doesn't model this — branch vs
|
|
5
|
+
* published is meaningful only when an asset lives in a working
|
|
6
|
+
* tree separate from the published default branch.
|
|
7
|
+
*
|
|
8
|
+
* The hosted shell surfaces the distinction through
|
|
9
|
+
* `UIConfig.mediaBridge.getAssetScope`. cms-spa's media surfaces
|
|
10
|
+
* (AssetCard, AssetDetailSidebar) paint a "Branch only" /
|
|
11
|
+
* "Published" pill based on the bridge's reply. When no bridge is
|
|
12
|
+
* installed (local Astro dev, astro-cms standalone), the pill is
|
|
13
|
+
* hidden — surfaces render exactly as they did before.
|
|
14
|
+
*
|
|
15
|
+
* - `branch` — exists only on this branch's working tree. Needs
|
|
16
|
+
* promotion before the published site can see it.
|
|
17
|
+
* - `published` — promoted into the org's default branch and
|
|
18
|
+
* visible from every branch.
|
|
19
|
+
*/
|
|
20
|
+
export type AssetScope = 'branch' | 'published';
|
|
21
|
+
/**
|
|
22
|
+
* Standing media issue surfaced by the host shell alongside the
|
|
23
|
+
* `AssetScope` pill. Distinct from a per-call promote outcome:
|
|
24
|
+
* an issue here is a property OF the asset that persists until
|
|
25
|
+
* the customer resolves it.
|
|
26
|
+
*
|
|
27
|
+
* cms-spa's renderer-neutral asset model doesn't carry these
|
|
28
|
+
* fields because the local-Astro case has no notion of upload
|
|
29
|
+
* limits or media scanning — they're hosted-mode state the
|
|
30
|
+
* host exposes through `UIConfig.mediaBridge.getMediaIssue`.
|
|
31
|
+
*
|
|
32
|
+
* - `oversized` — file exceeds the inline-blob limit. The asset
|
|
33
|
+
* is still served, just slower than it should be. Surface
|
|
34
|
+
* paints an amber warning with "move to media storage"
|
|
35
|
+
* guidance.
|
|
36
|
+
* - `blocked` — content is held back by the passthrough scanner
|
|
37
|
+
* (malware, EXIF leak, policy violation). Preview falls back
|
|
38
|
+
* to a placeholder; publishing is hard-blocked until resolved.
|
|
39
|
+
* Surface paints a red error with the scanner's reason.
|
|
40
|
+
*
|
|
41
|
+
* Both variants carry `filename` so flat lists are self-joinable
|
|
42
|
+
* to the user's dirty page set without a second lookup.
|
|
43
|
+
*/
|
|
44
|
+
export type MediaIssue = {
|
|
45
|
+
kind: 'oversized';
|
|
46
|
+
filename: string;
|
|
47
|
+
sizeBytes: number;
|
|
48
|
+
limitBytes: number;
|
|
49
|
+
} | {
|
|
50
|
+
kind: 'blocked';
|
|
51
|
+
filename: string;
|
|
52
|
+
reason: string;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Bridge cms-spa uses to read host-shell-supplied metadata about
|
|
56
|
+
* media assets that cms-spa's renderer-neutral model doesn't carry.
|
|
57
|
+
* Installed by the host shell via `UIConfig.mediaBridge` before
|
|
58
|
+
* rendering `<CmsSpaApp />`; cms-spa never reaches for the
|
|
59
|
+
* HostClient directly.
|
|
60
|
+
*
|
|
61
|
+
* The bridge is optional in `UIConfig` — absence means "no host
|
|
62
|
+
* wiring," in which case cms-spa surfaces degrade cleanly (no
|
|
63
|
+
* scope pill, no host-side hooks fire).
|
|
64
|
+
*/
|
|
65
|
+
export interface MediaBridge {
|
|
66
|
+
/**
|
|
67
|
+
* Resolve the lifecycle scope of a single asset. Called by
|
|
68
|
+
* AssetCard / AssetDetailSidebar whenever they need to render
|
|
69
|
+
* the scope pill. Returns `null` when the host has no opinion
|
|
70
|
+
* (asset unknown to the host, pre-bootstrap state, or a
|
|
71
|
+
* non-hosted mount); the surface treats `null` the same as
|
|
72
|
+
* "no bridge" — pill hidden.
|
|
73
|
+
*
|
|
74
|
+
* The host is responsible for caching: cms-spa calls this
|
|
75
|
+
* synchronously-from-the-surface's-POV via TanStack so
|
|
76
|
+
* repeated renders don't refetch. The bridge implementation
|
|
77
|
+
* (in the host shell) wraps its client's `getAssetScope`
|
|
78
|
+
* call in a `useQuery` so the resolved scope is memoised.
|
|
79
|
+
*/
|
|
80
|
+
getAssetScope(input: {
|
|
81
|
+
filename: string;
|
|
82
|
+
}): Promise<AssetScope | null>;
|
|
83
|
+
/**
|
|
84
|
+
* Resolve the standing media issue for a single asset, or `null`
|
|
85
|
+
* when the asset is healthy. Called by AssetCard /
|
|
86
|
+
* AssetDetailSidebar whenever they paint the per-asset
|
|
87
|
+
* error/warning badge.
|
|
88
|
+
*
|
|
89
|
+
* Returns `null` for the same reasons as `getAssetScope`: host
|
|
90
|
+
* has no opinion (asset unknown, pre-bootstrap state, non-hosted
|
|
91
|
+
* mount). Surfaces treat `null` the same as "no bridge" — badge
|
|
92
|
+
* hidden, `AssetEntry` rendered unchanged.
|
|
93
|
+
*
|
|
94
|
+
* The host caches the lookup so cms-spa's `useMediaIssue` wrapper
|
|
95
|
+
* doesn't have to think about per-asset cache windows.
|
|
96
|
+
*/
|
|
97
|
+
getMediaIssue(input: {
|
|
98
|
+
filename: string;
|
|
99
|
+
}): Promise<MediaIssue | null>;
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/media/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,WAAW,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,MAAM,UAAU,GAClB;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAC9E;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1D;;;;;;;;;;GAUG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;;;;;;;;;;OAaG;IACH,aAAa,CAAC,KAAK,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IACvE;;;;;;;;;;;;;OAaG;IACH,aAAa,CAAC,KAAK,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;CACxE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { AssetScope } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Resolve the hosted-mode lifecycle scope of a single asset.
|
|
4
|
+
*
|
|
5
|
+
* Returns `null` when:
|
|
6
|
+
*
|
|
7
|
+
* - No `mediaBridge` is configured (cms-spa running standalone /
|
|
8
|
+
* astro-cms / local dev) — the surface knows "the host has no
|
|
9
|
+
* opinion" and hides the scope pill.
|
|
10
|
+
* - The bridge resolves to `null` (asset unknown to the host or
|
|
11
|
+
* pre-bootstrap state).
|
|
12
|
+
*
|
|
13
|
+
* The pill is only rendered when this returns `'branch'` or
|
|
14
|
+
* `'published'`. Loading state is also treated as `null` for the
|
|
15
|
+
* caller's purposes — a flashing pill on first paint reads worse
|
|
16
|
+
* than no pill, and the scope is metadata, not primary content.
|
|
17
|
+
*
|
|
18
|
+
* The bridge implementation (in the host shell) wraps its
|
|
19
|
+
* client's `getAssetScope` so the actual fetch is mocked + cached
|
|
20
|
+
* one level deeper. From cms-spa's POV this is just a lookup; the
|
|
21
|
+
* TanStack wrapper here is so repeat AssetCard renders don't re-call
|
|
22
|
+
* the bridge for the same filename.
|
|
23
|
+
*/
|
|
24
|
+
export declare function useAssetScope(filename: string | undefined): AssetScope | null;
|
|
25
|
+
//# sourceMappingURL=use-asset-scope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-asset-scope.d.ts","sourceRoot":"","sources":["../../src/media/use-asset-scope.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAc1C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,IAAI,CAiB7E"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { useQuery } from '@tanstack/react-query';
|
|
2
|
+
import { getUIConfig } from '../ui-config';
|
|
3
|
+
/**
|
|
4
|
+
* Cache-key namespace for per-asset scope lookups. Keyed by
|
|
5
|
+
* filename — the host shell owns the (orgId, branchName) scoping
|
|
6
|
+
* behind the bridge, so cms-spa sees a flat "which filename?"
|
|
7
|
+
* surface and the bridge resolves it against the active workspace.
|
|
8
|
+
*
|
|
9
|
+
* When the user switches branches, the host shell invalidates this
|
|
10
|
+
* whole prefix (`['asset-scope']`) so stale scope answers don't
|
|
11
|
+
* leak across the boundary.
|
|
12
|
+
*/
|
|
13
|
+
const ASSET_SCOPE_QUERY_KEY_PREFIX = ['asset-scope'];
|
|
14
|
+
/**
|
|
15
|
+
* Resolve the hosted-mode lifecycle scope of a single asset.
|
|
16
|
+
*
|
|
17
|
+
* Returns `null` when:
|
|
18
|
+
*
|
|
19
|
+
* - No `mediaBridge` is configured (cms-spa running standalone /
|
|
20
|
+
* astro-cms / local dev) — the surface knows "the host has no
|
|
21
|
+
* opinion" and hides the scope pill.
|
|
22
|
+
* - The bridge resolves to `null` (asset unknown to the host or
|
|
23
|
+
* pre-bootstrap state).
|
|
24
|
+
*
|
|
25
|
+
* The pill is only rendered when this returns `'branch'` or
|
|
26
|
+
* `'published'`. Loading state is also treated as `null` for the
|
|
27
|
+
* caller's purposes — a flashing pill on first paint reads worse
|
|
28
|
+
* than no pill, and the scope is metadata, not primary content.
|
|
29
|
+
*
|
|
30
|
+
* The bridge implementation (in the host shell) wraps its
|
|
31
|
+
* client's `getAssetScope` so the actual fetch is mocked + cached
|
|
32
|
+
* one level deeper. From cms-spa's POV this is just a lookup; the
|
|
33
|
+
* TanStack wrapper here is so repeat AssetCard renders don't re-call
|
|
34
|
+
* the bridge for the same filename.
|
|
35
|
+
*/
|
|
36
|
+
export function useAssetScope(filename) {
|
|
37
|
+
const query = useQuery({
|
|
38
|
+
queryKey: [...ASSET_SCOPE_QUERY_KEY_PREFIX, filename ?? ''],
|
|
39
|
+
queryFn: async () => {
|
|
40
|
+
const bridge = getUIConfig().mediaBridge;
|
|
41
|
+
if (!bridge || !filename)
|
|
42
|
+
return null;
|
|
43
|
+
return bridge.getAssetScope({ filename });
|
|
44
|
+
},
|
|
45
|
+
// Per-filename scope is stable for the lifetime of a branch
|
|
46
|
+
// session — only a promote mutation changes it, and the host
|
|
47
|
+
// shell invalidates the prefix on success. 5 minutes matches
|
|
48
|
+
// the cms-spa default staleTime so the surface doesn't have to
|
|
49
|
+
// think about cache windows.
|
|
50
|
+
staleTime: 1000 * 60 * 5,
|
|
51
|
+
enabled: Boolean(filename),
|
|
52
|
+
});
|
|
53
|
+
return query.data ?? null;
|
|
54
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { MediaIssue } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Resolve the hosted-mode standing media issue for a single asset.
|
|
4
|
+
*
|
|
5
|
+
* Returns `null` when:
|
|
6
|
+
*
|
|
7
|
+
* - No `mediaBridge` is configured (cms-spa standalone, astro-cms,
|
|
8
|
+
* local dev) — the surface knows "the host has no opinion" and
|
|
9
|
+
* hides the issue badge.
|
|
10
|
+
* - The bridge resolves to `null` (asset healthy, unknown to the
|
|
11
|
+
* host, or pre-bootstrap state).
|
|
12
|
+
*
|
|
13
|
+
* The badge is only rendered when this returns a real issue. Loading
|
|
14
|
+
* state is treated as `null` for the caller's purposes — a flashing
|
|
15
|
+
* badge on first paint reads worse than no badge, and issue state is
|
|
16
|
+
* metadata, not primary content.
|
|
17
|
+
*
|
|
18
|
+
* Mirrors the `useAssetScope` discipline: cms-spa stays a thin
|
|
19
|
+
* consumer of `getUIConfig().mediaBridge`; the bridge implementation
|
|
20
|
+
* in the host shell wraps `HostClient.getMediaIssue` with its own
|
|
21
|
+
* TanStack hook so the cache is hit one level deeper.
|
|
22
|
+
*/
|
|
23
|
+
export declare function useMediaIssue(filename: string | undefined): MediaIssue | null;
|
|
24
|
+
//# sourceMappingURL=use-media-issue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-media-issue.d.ts","sourceRoot":"","sources":["../../src/media/use-media-issue.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAU1C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,IAAI,CAiB7E"}
|