@drawnagency/primitives 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -0
- package/dist/auth/cookies.d.ts +8 -0
- package/dist/auth/cookies.d.ts.map +1 -0
- package/dist/auth/cookies.js +44 -0
- package/dist/auth/errors.d.ts +8 -0
- package/dist/auth/errors.d.ts.map +1 -0
- package/dist/auth/errors.js +10 -0
- package/dist/auth/index.d.ts +5 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +3 -0
- package/dist/auth/security.d.ts +13 -0
- package/dist/auth/security.d.ts.map +1 -0
- package/dist/auth/security.js +48 -0
- package/dist/auth/types.d.ts +64 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +1 -0
- package/dist/components/brandguide/ColorSwatchSettings.d.ts +8 -0
- package/dist/components/brandguide/ColorSwatchSettings.d.ts.map +1 -0
- package/dist/components/brandguide/ColorSwatchSettings.js +10 -0
- package/dist/components/brandguide/Colors.d.ts +15 -0
- package/dist/components/brandguide/Colors.d.ts.map +1 -0
- package/dist/components/brandguide/Colors.js +79 -0
- package/dist/components/brandguide/DoDontList.d.ts +16 -0
- package/dist/components/brandguide/DoDontList.d.ts.map +1 -0
- package/dist/components/brandguide/DoDontList.js +22 -0
- package/dist/components/brandguide/DoDontMediaGrid.d.ts +16 -0
- package/dist/components/brandguide/DoDontMediaGrid.d.ts.map +1 -0
- package/dist/components/brandguide/DoDontMediaGrid.js +5 -0
- package/dist/components/editor/AudiencePicker.d.ts +9 -0
- package/dist/components/editor/AudiencePicker.d.ts.map +1 -0
- package/dist/components/editor/AudiencePicker.js +24 -0
- package/dist/components/editor/DeleteButton.d.ts +6 -0
- package/dist/components/editor/DeleteButton.d.ts.map +1 -0
- package/dist/components/editor/DeleteButton.js +6 -0
- package/dist/components/editor/DragHandle.d.ts +2 -0
- package/dist/components/editor/DragHandle.d.ts.map +1 -0
- package/dist/components/editor/DragHandle.js +8 -0
- package/dist/components/editor/InsertButton.d.ts +7 -0
- package/dist/components/editor/InsertButton.d.ts.map +1 -0
- package/dist/components/editor/InsertButton.js +7 -0
- package/dist/components/editor/SectionWrapper.d.ts +3 -0
- package/dist/components/editor/SectionWrapper.d.ts.map +1 -0
- package/dist/components/editor/SectionWrapper.js +135 -0
- package/dist/components/editor/SettingsButton.d.ts +6 -0
- package/dist/components/editor/SettingsButton.d.ts.map +1 -0
- package/dist/components/editor/SettingsButton.js +6 -0
- package/dist/components/editor/SettingsForm.d.ts +13 -0
- package/dist/components/editor/SettingsForm.d.ts.map +1 -0
- package/dist/components/editor/SettingsForm.js +64 -0
- package/dist/components/editor/StatusBadge.d.ts +7 -0
- package/dist/components/editor/StatusBadge.d.ts.map +1 -0
- package/dist/components/editor/StatusBadge.js +10 -0
- package/dist/components/editor/StatusPicker.d.ts +9 -0
- package/dist/components/editor/StatusPicker.d.ts.map +1 -0
- package/dist/components/editor/StatusPicker.js +30 -0
- package/dist/components/editor/index.d.ts +8 -0
- package/dist/components/editor/index.d.ts.map +1 -0
- package/dist/components/editor/index.js +7 -0
- package/dist/components/primitives/CustomParagraph.d.ts +2 -0
- package/dist/components/primitives/CustomParagraph.d.ts.map +1 -0
- package/dist/components/primitives/CustomParagraph.js +24 -0
- package/dist/components/primitives/EditableGrid.d.ts +19 -0
- package/dist/components/primitives/EditableGrid.d.ts.map +1 -0
- package/dist/components/primitives/EditableGrid.js +90 -0
- package/dist/components/primitives/EditableList.d.ts +15 -0
- package/dist/components/primitives/EditableList.d.ts.map +1 -0
- package/dist/components/primitives/EditableList.js +54 -0
- package/dist/components/primitives/EditablePlainText.d.ts +12 -0
- package/dist/components/primitives/EditablePlainText.d.ts.map +1 -0
- package/dist/components/primitives/EditablePlainText.js +52 -0
- package/dist/components/primitives/EditableRichText.d.ts +11 -0
- package/dist/components/primitives/EditableRichText.d.ts.map +1 -0
- package/dist/components/primitives/EditableRichText.js +86 -0
- package/dist/components/primitives/HeadingSection.d.ts +10 -0
- package/dist/components/primitives/HeadingSection.d.ts.map +1 -0
- package/dist/components/primitives/HeadingSection.js +7 -0
- package/dist/components/primitives/IconPicker.d.ts +9 -0
- package/dist/components/primitives/IconPicker.d.ts.map +1 -0
- package/dist/components/primitives/IconPicker.js +21 -0
- package/dist/components/primitives/LinkPopover.d.ts +8 -0
- package/dist/components/primitives/LinkPopover.d.ts.map +1 -0
- package/dist/components/primitives/LinkPopover.js +48 -0
- package/dist/components/primitives/MediaSettingsForms.d.ts +19 -0
- package/dist/components/primitives/MediaSettingsForms.d.ts.map +1 -0
- package/dist/components/primitives/MediaSettingsForms.js +42 -0
- package/dist/components/primitives/ResolvedMedia.d.ts +8 -0
- package/dist/components/primitives/ResolvedMedia.d.ts.map +1 -0
- package/dist/components/primitives/ResolvedMedia.js +9 -0
- package/dist/components/primitives/RichTextToolbar.d.ts +9 -0
- package/dist/components/primitives/RichTextToolbar.d.ts.map +1 -0
- package/dist/components/primitives/RichTextToolbar.js +26 -0
- package/dist/components/primitives/tiptap-presets.d.ts +4 -0
- package/dist/components/primitives/tiptap-presets.d.ts.map +1 -0
- package/dist/components/primitives/tiptap-presets.js +44 -0
- package/dist/components/primitives/useEditableCollection.d.ts +19 -0
- package/dist/components/primitives/useEditableCollection.d.ts.map +1 -0
- package/dist/components/primitives/useEditableCollection.js +61 -0
- package/dist/components/primitives/useEditablePlainText.d.ts +14 -0
- package/dist/components/primitives/useEditablePlainText.d.ts.map +1 -0
- package/dist/components/primitives/useEditablePlainText.js +27 -0
- package/dist/components/primitives/useEditableRichText.d.ts +16 -0
- package/dist/components/primitives/useEditableRichText.d.ts.map +1 -0
- package/dist/components/primitives/useEditableRichText.js +52 -0
- package/dist/components/sections/Button/CTAButton.d.ts +11 -0
- package/dist/components/sections/Button/CTAButton.d.ts.map +1 -0
- package/dist/components/sections/Button/CTAButton.js +18 -0
- package/dist/components/sections/Button/index.d.ts +11 -0
- package/dist/components/sections/Button/index.d.ts.map +1 -0
- package/dist/components/sections/Button/index.js +28 -0
- package/dist/components/sections/Colors/index.d.ts +22 -0
- package/dist/components/sections/Colors/index.d.ts.map +1 -0
- package/dist/components/sections/Colors/index.js +34 -0
- package/dist/components/sections/DoDontList/index.d.ts +21 -0
- package/dist/components/sections/DoDontList/index.d.ts.map +1 -0
- package/dist/components/sections/DoDontList/index.js +33 -0
- package/dist/components/sections/DoDontMediaGrid/index.d.ts +55 -0
- package/dist/components/sections/DoDontMediaGrid/index.d.ts.map +1 -0
- package/dist/components/sections/DoDontMediaGrid/index.js +41 -0
- package/dist/components/sections/IconList/IconList.d.ts +20 -0
- package/dist/components/sections/IconList/IconList.d.ts.map +1 -0
- package/dist/components/sections/IconList/IconList.js +131 -0
- package/dist/components/sections/IconList/IconListSettings.d.ts +11 -0
- package/dist/components/sections/IconList/IconListSettings.d.ts.map +1 -0
- package/dist/components/sections/IconList/IconListSettings.js +22 -0
- package/dist/components/sections/IconList/index.d.ts +17 -0
- package/dist/components/sections/IconList/index.d.ts.map +1 -0
- package/dist/components/sections/IconList/index.js +27 -0
- package/dist/components/sections/LinkHeading/index.d.ts +8 -0
- package/dist/components/sections/LinkHeading/index.d.ts.map +1 -0
- package/dist/components/sections/LinkHeading/index.js +15 -0
- package/dist/components/sections/MediaGrid/MediaGrid.d.ts +17 -0
- package/dist/components/sections/MediaGrid/MediaGrid.d.ts.map +1 -0
- package/dist/components/sections/MediaGrid/MediaGrid.js +62 -0
- package/dist/components/sections/MediaGrid/index.d.ts +55 -0
- package/dist/components/sections/MediaGrid/index.d.ts.map +1 -0
- package/dist/components/sections/MediaGrid/index.js +35 -0
- package/dist/components/sections/Prose/Prose.d.ts +8 -0
- package/dist/components/sections/Prose/Prose.d.ts.map +1 -0
- package/dist/components/sections/Prose/Prose.js +11 -0
- package/dist/components/sections/Prose/index.d.ts +8 -0
- package/dist/components/sections/Prose/index.d.ts.map +1 -0
- package/dist/components/sections/Prose/index.js +15 -0
- package/dist/components/sections/SectionLayout.d.ts +11 -0
- package/dist/components/sections/SectionLayout.d.ts.map +1 -0
- package/dist/components/sections/SectionLayout.js +15 -0
- package/dist/components/sections/SplitContent/SplitContent.d.ts +11 -0
- package/dist/components/sections/SplitContent/SplitContent.d.ts.map +1 -0
- package/dist/components/sections/SplitContent/SplitContent.js +31 -0
- package/dist/components/sections/SplitContent/SplitContentSettings.d.ts +9 -0
- package/dist/components/sections/SplitContent/SplitContentSettings.d.ts.map +1 -0
- package/dist/components/sections/SplitContent/SplitContentSettings.js +17 -0
- package/dist/components/sections/SplitContent/index.d.ts +13 -0
- package/dist/components/sections/SplitContent/index.d.ts.map +1 -0
- package/dist/components/sections/SplitContent/index.js +27 -0
- package/dist/components/sections/SubHeading/index.d.ts +9 -0
- package/dist/components/sections/SubHeading/index.d.ts.map +1 -0
- package/dist/components/sections/SubHeading/index.js +18 -0
- package/dist/components/sections/SubSubHeading/index.d.ts +9 -0
- package/dist/components/sections/SubSubHeading/index.d.ts.map +1 -0
- package/dist/components/sections/SubSubHeading/index.js +18 -0
- package/dist/components/sections/ViewRenderer.d.ts +8 -0
- package/dist/components/sections/ViewRenderer.d.ts.map +1 -0
- package/dist/components/sections/ViewRenderer.js +13 -0
- package/dist/components/sections/register-schemas.d.ts +2 -0
- package/dist/components/sections/register-schemas.d.ts.map +1 -0
- package/dist/components/sections/register-schemas.js +15 -0
- package/dist/components/sections/register.d.ts +2 -0
- package/dist/components/sections/register.d.ts.map +1 -0
- package/dist/components/sections/register.js +15 -0
- package/dist/components/shared/Button.d.ts +15 -0
- package/dist/components/shared/Button.d.ts.map +1 -0
- package/dist/components/shared/Button.js +27 -0
- package/dist/components/shared/Checkbox.d.ts +14 -0
- package/dist/components/shared/Checkbox.d.ts.map +1 -0
- package/dist/components/shared/Checkbox.js +10 -0
- package/dist/components/shared/ColorPicker.d.ts +9 -0
- package/dist/components/shared/ColorPicker.d.ts.map +1 -0
- package/dist/components/shared/ColorPicker.js +5 -0
- package/dist/components/shared/ErrorBoundary.d.ts +24 -0
- package/dist/components/shared/ErrorBoundary.d.ts.map +1 -0
- package/dist/components/shared/ErrorBoundary.js +30 -0
- package/dist/components/shared/FontPicker.d.ts +8 -0
- package/dist/components/shared/FontPicker.d.ts.map +1 -0
- package/dist/components/shared/FontPicker.js +190 -0
- package/dist/components/shared/FormLabel.d.ts +8 -0
- package/dist/components/shared/FormLabel.d.ts.map +1 -0
- package/dist/components/shared/FormLabel.js +5 -0
- package/dist/components/shared/IconButton.d.ts +12 -0
- package/dist/components/shared/IconButton.d.ts.map +1 -0
- package/dist/components/shared/IconButton.js +16 -0
- package/dist/components/shared/Input.d.ts +8 -0
- package/dist/components/shared/Input.d.ts.map +1 -0
- package/dist/components/shared/Input.js +8 -0
- package/dist/components/shared/Navigation.d.ts +9 -0
- package/dist/components/shared/Navigation.d.ts.map +1 -0
- package/dist/components/shared/Navigation.js +71 -0
- package/dist/components/shared/PasswordInput.d.ts +13 -0
- package/dist/components/shared/PasswordInput.d.ts.map +1 -0
- package/dist/components/shared/PasswordInput.js +11 -0
- package/dist/components/shared/Popover.d.ts +12 -0
- package/dist/components/shared/Popover.d.ts.map +1 -0
- package/dist/components/shared/Popover.js +33 -0
- package/dist/components/shared/PopoverItem.d.ts +7 -0
- package/dist/components/shared/PopoverItem.d.ts.map +1 -0
- package/dist/components/shared/PopoverItem.js +6 -0
- package/dist/components/shared/Select.d.ts +16 -0
- package/dist/components/shared/Select.d.ts.map +1 -0
- package/dist/components/shared/Select.js +9 -0
- package/dist/components/shared/Textarea.d.ts +8 -0
- package/dist/components/shared/Textarea.d.ts.map +1 -0
- package/dist/components/shared/Textarea.js +8 -0
- package/dist/components/shared/Toggle.d.ts +10 -0
- package/dist/components/shared/Toggle.d.ts.map +1 -0
- package/dist/components/shared/Toggle.js +5 -0
- package/dist/components/shared/Tooltip.d.ts +12 -0
- package/dist/components/shared/Tooltip.d.ts.map +1 -0
- package/dist/components/shared/Tooltip.js +8 -0
- package/dist/components/shared/icons.d.ts +17 -0
- package/dist/components/shared/icons.d.ts.map +1 -0
- package/dist/components/shared/icons.js +23 -0
- package/dist/components/shell/AudienceAddForm.d.ts +11 -0
- package/dist/components/shell/AudienceAddForm.d.ts.map +1 -0
- package/dist/components/shell/AudienceAddForm.js +43 -0
- package/dist/components/shell/AudienceRow.d.ts +15 -0
- package/dist/components/shell/AudienceRow.d.ts.map +1 -0
- package/dist/components/shell/AudienceRow.js +74 -0
- package/dist/components/shell/EditorContext.d.ts +14 -0
- package/dist/components/shell/EditorContext.d.ts.map +1 -0
- package/dist/components/shell/EditorContext.js +24 -0
- package/dist/components/shell/EditorLoginForm.d.ts +13 -0
- package/dist/components/shell/EditorLoginForm.d.ts.map +1 -0
- package/dist/components/shell/EditorLoginForm.js +46 -0
- package/dist/components/shell/EditorModal.d.ts +13 -0
- package/dist/components/shell/EditorModal.d.ts.map +1 -0
- package/dist/components/shell/EditorModal.js +43 -0
- package/dist/components/shell/EditorModalContext.d.ts +16 -0
- package/dist/components/shell/EditorModalContext.d.ts.map +1 -0
- package/dist/components/shell/EditorModalContext.js +20 -0
- package/dist/components/shell/EditorShell.d.ts +22 -0
- package/dist/components/shell/EditorShell.d.ts.map +1 -0
- package/dist/components/shell/EditorShell.js +483 -0
- package/dist/components/shell/MediaLibraryContext.d.ts +14 -0
- package/dist/components/shell/MediaLibraryContext.d.ts.map +1 -0
- package/dist/components/shell/MediaLibraryContext.js +5 -0
- package/dist/components/shell/MediaLibraryModal.d.ts +14 -0
- package/dist/components/shell/MediaLibraryModal.d.ts.map +1 -0
- package/dist/components/shell/MediaLibraryModal.js +145 -0
- package/dist/components/shell/ProcessingIndicator.d.ts +7 -0
- package/dist/components/shell/ProcessingIndicator.d.ts.map +1 -0
- package/dist/components/shell/ProcessingIndicator.js +15 -0
- package/dist/components/shell/SectionSkeleton.d.ts +9 -0
- package/dist/components/shell/SectionSkeleton.d.ts.map +1 -0
- package/dist/components/shell/SectionSkeleton.js +22 -0
- package/dist/components/shell/SectionTypePicker.d.ts +14 -0
- package/dist/components/shell/SectionTypePicker.d.ts.map +1 -0
- package/dist/components/shell/SectionTypePicker.js +15 -0
- package/dist/components/shell/SiteSettingsDisplay.d.ts +8 -0
- package/dist/components/shell/SiteSettingsDisplay.d.ts.map +1 -0
- package/dist/components/shell/SiteSettingsDisplay.js +28 -0
- package/dist/components/shell/SiteSettingsModal.d.ts +24 -0
- package/dist/components/shell/SiteSettingsModal.d.ts.map +1 -0
- package/dist/components/shell/SiteSettingsModal.js +40 -0
- package/dist/components/shell/SiteSettingsUsers.d.ts +9 -0
- package/dist/components/shell/SiteSettingsUsers.d.ts.map +1 -0
- package/dist/components/shell/SiteSettingsUsers.js +87 -0
- package/dist/components/shell/SiteSettingsViewerAccess.d.ts +9 -0
- package/dist/components/shell/SiteSettingsViewerAccess.d.ts.map +1 -0
- package/dist/components/shell/SiteSettingsViewerAccess.js +94 -0
- package/dist/components/shell/ViewerLoginForm.d.ts +10 -0
- package/dist/components/shell/ViewerLoginForm.d.ts.map +1 -0
- package/dist/components/shell/ViewerLoginForm.js +40 -0
- package/dist/data/google-fonts.json +7718 -0
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +6 -0
- package/dist/hooks/useActiveHeadings.d.ts +7 -0
- package/dist/hooks/useActiveHeadings.d.ts.map +1 -0
- package/dist/hooks/useActiveHeadings.js +99 -0
- package/dist/hooks/useEditorPersistence.d.ts +13 -0
- package/dist/hooks/useEditorPersistence.d.ts.map +1 -0
- package/dist/hooks/useEditorPersistence.js +73 -0
- package/dist/hooks/useEditorPublish.d.ts +24 -0
- package/dist/hooks/useEditorPublish.d.ts.map +1 -0
- package/dist/hooks/useEditorPublish.js +145 -0
- package/dist/hooks/useFocusTrap.d.ts +3 -0
- package/dist/hooks/useFocusTrap.d.ts.map +1 -0
- package/dist/hooks/useFocusTrap.js +51 -0
- package/dist/hooks/useMediaPipeline.d.ts +65 -0
- package/dist/hooks/useMediaPipeline.d.ts.map +1 -0
- package/dist/hooks/useMediaPipeline.js +253 -0
- package/dist/hooks/useResolvedMedia.d.ts +9 -0
- package/dist/hooks/useResolvedMedia.d.ts.map +1 -0
- package/dist/hooks/useResolvedMedia.js +39 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/lib/cn.d.ts +3 -0
- package/dist/lib/cn.d.ts.map +1 -0
- package/dist/lib/cn.js +5 -0
- package/dist/lib/contrast.d.ts +2 -0
- package/dist/lib/contrast.d.ts.map +1 -0
- package/dist/lib/contrast.js +11 -0
- package/dist/lib/dexie.d.ts +41 -0
- package/dist/lib/dexie.d.ts.map +1 -0
- package/dist/lib/dexie.js +236 -0
- package/dist/lib/events.d.ts +12 -0
- package/dist/lib/events.d.ts.map +1 -0
- package/dist/lib/events.js +15 -0
- package/dist/lib/google-fonts.d.ts +2 -0
- package/dist/lib/google-fonts.d.ts.map +1 -0
- package/dist/lib/google-fonts.js +11 -0
- package/dist/lib/grid.d.ts +2 -0
- package/dist/lib/grid.d.ts.map +1 -0
- package/dist/lib/grid.js +7 -0
- package/dist/lib/icons.d.ts +9 -0
- package/dist/lib/icons.d.ts.map +1 -0
- package/dist/lib/icons.js +27 -0
- package/dist/lib/index.d.ts +13 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +12 -0
- package/dist/lib/loader.d.ts +28 -0
- package/dist/lib/loader.d.ts.map +1 -0
- package/dist/lib/loader.js +57 -0
- package/dist/lib/nav.d.ts +15 -0
- package/dist/lib/nav.d.ts.map +1 -0
- package/dist/lib/nav.js +58 -0
- package/dist/lib/registry.d.ts +110 -0
- package/dist/lib/registry.d.ts.map +1 -0
- package/dist/lib/registry.js +64 -0
- package/dist/lib/safeRedirect.d.ts +7 -0
- package/dist/lib/safeRedirect.d.ts.map +1 -0
- package/dist/lib/safeRedirect.js +11 -0
- package/dist/lib/sanitize.d.ts +2 -0
- package/dist/lib/sanitize.d.ts.map +1 -0
- package/dist/lib/sanitize.js +6 -0
- package/dist/lib/timestamp.d.ts +2 -0
- package/dist/lib/timestamp.d.ts.map +1 -0
- package/dist/lib/timestamp.js +28 -0
- package/dist/media/github.d.ts +3 -0
- package/dist/media/github.d.ts.map +1 -0
- package/dist/media/github.js +60 -0
- package/dist/media/index.d.ts +8 -0
- package/dist/media/index.d.ts.map +1 -0
- package/dist/media/index.js +9 -0
- package/dist/media/queue.d.ts +74 -0
- package/dist/media/queue.d.ts.map +1 -0
- package/dist/media/queue.js +116 -0
- package/dist/media/resolve.d.ts +14 -0
- package/dist/media/resolve.d.ts.map +1 -0
- package/dist/media/resolve.js +50 -0
- package/dist/media/types.d.ts +42 -0
- package/dist/media/types.d.ts.map +1 -0
- package/dist/media/types.js +1 -0
- package/dist/media/utils.d.ts +7 -0
- package/dist/media/utils.d.ts.map +1 -0
- package/dist/media/utils.js +41 -0
- package/dist/media/videoPoster.d.ts +6 -0
- package/dist/media/videoPoster.d.ts.map +1 -0
- package/dist/media/videoPoster.js +44 -0
- package/dist/media/worker.d.ts +36 -0
- package/dist/media/worker.d.ts.map +1 -0
- package/dist/media/worker.js +73 -0
- package/dist/schemas/audience.d.ts +12 -0
- package/dist/schemas/audience.d.ts.map +1 -0
- package/dist/schemas/audience.js +19 -0
- package/dist/schemas/auth.d.ts +36 -0
- package/dist/schemas/auth.d.ts.map +1 -0
- package/dist/schemas/auth.js +22 -0
- package/dist/schemas/index.d.ts +8 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +7 -0
- package/dist/schemas/media-grid-options.d.ts +8 -0
- package/dist/schemas/media-grid-options.d.ts.map +1 -0
- package/dist/schemas/media-grid-options.js +7 -0
- package/dist/schemas/media.d.ts +63 -0
- package/dist/schemas/media.d.ts.map +1 -0
- package/dist/schemas/media.js +28 -0
- package/dist/schemas/sections.d.ts +12 -0
- package/dist/schemas/sections.d.ts.map +1 -0
- package/dist/schemas/sections.js +12 -0
- package/dist/schemas/shared.d.ts +98 -0
- package/dist/schemas/shared.d.ts.map +1 -0
- package/dist/schemas/shared.js +71 -0
- package/dist/schemas/site-config.d.ts +48 -0
- package/dist/schemas/site-config.d.ts.map +1 -0
- package/dist/schemas/site-config.js +26 -0
- package/package.json +57 -0
- package/src/auth/cookies.ts +51 -0
- package/src/auth/errors.ts +10 -0
- package/src/auth/index.ts +15 -0
- package/src/auth/security.ts +44 -0
- package/src/auth/types.ts +61 -0
- package/src/components/brandguide/ColorSwatchSettings.tsx +34 -0
- package/src/components/brandguide/Colors.tsx +277 -0
- package/src/components/brandguide/DoDontList.tsx +67 -0
- package/src/components/brandguide/DoDontMediaGrid.tsx +19 -0
- package/src/components/editor/AudiencePicker.tsx +103 -0
- package/src/components/editor/DeleteButton.tsx +18 -0
- package/src/components/editor/DragHandle.tsx +18 -0
- package/src/components/editor/InsertButton.tsx +22 -0
- package/src/components/editor/SectionWrapper.tsx +279 -0
- package/src/components/editor/SettingsButton.tsx +17 -0
- package/src/components/editor/SettingsForm.tsx +159 -0
- package/src/components/editor/StatusBadge.tsx +30 -0
- package/src/components/editor/StatusPicker.tsx +86 -0
- package/src/components/editor/index.ts +7 -0
- package/src/components/primitives/CustomParagraph.ts +25 -0
- package/src/components/primitives/EditableGrid.tsx +260 -0
- package/src/components/primitives/EditableList.tsx +160 -0
- package/src/components/primitives/EditablePlainText.tsx +99 -0
- package/src/components/primitives/EditableRichText.tsx +132 -0
- package/src/components/primitives/HeadingSection.tsx +25 -0
- package/src/components/primitives/IconPicker.tsx +60 -0
- package/src/components/primitives/LinkPopover.tsx +109 -0
- package/src/components/primitives/MediaSettingsForms.tsx +109 -0
- package/src/components/primitives/ResolvedMedia.tsx +36 -0
- package/src/components/primitives/RichTextToolbar.tsx +149 -0
- package/src/components/primitives/tiptap-presets.ts +50 -0
- package/src/components/primitives/useEditableCollection.ts +104 -0
- package/src/components/primitives/useEditablePlainText.ts +49 -0
- package/src/components/primitives/useEditableRichText.ts +74 -0
- package/src/components/sections/Button/CTAButton.tsx +50 -0
- package/src/components/sections/Button/index.tsx +37 -0
- package/src/components/sections/Colors/index.tsx +45 -0
- package/src/components/sections/DoDontList/index.tsx +43 -0
- package/src/components/sections/DoDontMediaGrid/index.tsx +53 -0
- package/src/components/sections/IconList/IconList.tsx +462 -0
- package/src/components/sections/IconList/IconListSettings.tsx +81 -0
- package/src/components/sections/IconList/index.tsx +36 -0
- package/src/components/sections/LinkHeading/index.tsx +24 -0
- package/src/components/sections/MediaGrid/MediaGrid.tsx +219 -0
- package/src/components/sections/MediaGrid/index.tsx +47 -0
- package/src/components/sections/Prose/Prose.tsx +34 -0
- package/src/components/sections/Prose/index.tsx +18 -0
- package/src/components/sections/SectionLayout.tsx +31 -0
- package/src/components/sections/SplitContent/SplitContent.tsx +77 -0
- package/src/components/sections/SplitContent/SplitContentSettings.tsx +42 -0
- package/src/components/sections/SplitContent/index.tsx +36 -0
- package/src/components/sections/SubHeading/index.tsx +27 -0
- package/src/components/sections/SubSubHeading/index.tsx +27 -0
- package/src/components/sections/ViewRenderer.tsx +29 -0
- package/src/components/sections/register-schemas.ts +16 -0
- package/src/components/sections/register.ts +16 -0
- package/src/components/shared/Button.tsx +77 -0
- package/src/components/shared/Checkbox.tsx +73 -0
- package/src/components/shared/ColorPicker.tsx +28 -0
- package/src/components/shared/ErrorBoundary.tsx +92 -0
- package/src/components/shared/FontPicker.tsx +300 -0
- package/src/components/shared/FormLabel.tsx +18 -0
- package/src/components/shared/IconButton.tsx +45 -0
- package/src/components/shared/Input.tsx +34 -0
- package/src/components/shared/Navigation.tsx +196 -0
- package/src/components/shared/PasswordInput.tsx +64 -0
- package/src/components/shared/Popover.tsx +61 -0
- package/src/components/shared/PopoverItem.tsx +24 -0
- package/src/components/shared/Select.tsx +60 -0
- package/src/components/shared/Textarea.tsx +34 -0
- package/src/components/shared/Toggle.tsx +35 -0
- package/src/components/shared/Tooltip.tsx +28 -0
- package/src/components/shared/icons.tsx +28 -0
- package/src/components/shell/AudienceAddForm.tsx +94 -0
- package/src/components/shell/AudienceRow.tsx +171 -0
- package/src/components/shell/EditorContext.tsx +44 -0
- package/src/components/shell/EditorLoginForm.tsx +130 -0
- package/src/components/shell/EditorModal.tsx +93 -0
- package/src/components/shell/EditorModalContext.tsx +40 -0
- package/src/components/shell/EditorShell.tsx +910 -0
- package/src/components/shell/MediaLibraryContext.tsx +19 -0
- package/src/components/shell/MediaLibraryModal.tsx +371 -0
- package/src/components/shell/ProcessingIndicator.tsx +84 -0
- package/src/components/shell/SectionSkeleton.tsx +54 -0
- package/src/components/shell/SectionTypePicker.tsx +47 -0
- package/src/components/shell/SiteSettingsDisplay.tsx +78 -0
- package/src/components/shell/SiteSettingsModal.tsx +129 -0
- package/src/components/shell/SiteSettingsUsers.tsx +190 -0
- package/src/components/shell/SiteSettingsViewerAccess.tsx +171 -0
- package/src/components/shell/ViewerLoginForm.tsx +95 -0
- package/src/data/google-fonts.json +7718 -0
- package/src/env.d.ts +3 -0
- package/src/hooks/index.ts +6 -0
- package/src/hooks/useActiveHeadings.ts +120 -0
- package/src/hooks/useEditorPersistence.ts +103 -0
- package/src/hooks/useEditorPublish.ts +187 -0
- package/src/hooks/useFocusTrap.ts +57 -0
- package/src/hooks/useMediaPipeline.ts +309 -0
- package/src/hooks/useResolvedMedia.ts +54 -0
- package/src/index.ts +4 -0
- package/src/lib/cn.ts +6 -0
- package/src/lib/contrast.ts +11 -0
- package/src/lib/dexie.ts +347 -0
- package/src/lib/events.ts +23 -0
- package/src/lib/google-fonts.ts +10 -0
- package/src/lib/grid.ts +7 -0
- package/src/lib/icons.ts +58 -0
- package/src/lib/index.ts +35 -0
- package/src/lib/loader.ts +81 -0
- package/src/lib/nav.ts +64 -0
- package/src/lib/registry.ts +202 -0
- package/src/lib/safeRedirect.ts +11 -0
- package/src/lib/sanitize.ts +6 -0
- package/src/lib/timestamp.ts +31 -0
- package/src/media/github.ts +72 -0
- package/src/media/index.ts +12 -0
- package/src/media/queue.ts +166 -0
- package/src/media/resolve.ts +63 -0
- package/src/media/types.ts +58 -0
- package/src/media/utils.ts +48 -0
- package/src/media/videoPoster.ts +53 -0
- package/src/media/worker.ts +122 -0
- package/src/schemas/audience.ts +28 -0
- package/src/schemas/auth.ts +31 -0
- package/src/schemas/index.ts +7 -0
- package/src/schemas/media-grid-options.ts +8 -0
- package/src/schemas/media.ts +40 -0
- package/src/schemas/sections.ts +24 -0
- package/src/schemas/shared.ts +96 -0
- package/src/schemas/site-config.ts +38 -0
package/src/lib/dexie.ts
ADDED
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
import Dexie from "dexie";
|
|
2
|
+
import type { SectionContent } from "../schemas/sections";
|
|
3
|
+
import type { SiteIndex, SectionMeta } from "../schemas/site-config";
|
|
4
|
+
import type { LoadedSection } from "./loader";
|
|
5
|
+
import type { MediaManifest, MediaItem } from "../media/types";
|
|
6
|
+
|
|
7
|
+
interface SectionRow {
|
|
8
|
+
sectionId: string;
|
|
9
|
+
content: SectionContent;
|
|
10
|
+
dirty: boolean;
|
|
11
|
+
updatedAt: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface SiteIndexRow {
|
|
15
|
+
key: string;
|
|
16
|
+
order: string[];
|
|
17
|
+
sections: Record<string, SectionMeta>;
|
|
18
|
+
updatedAt: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface MetaRow {
|
|
22
|
+
key: string;
|
|
23
|
+
lastSavedSha: string | null;
|
|
24
|
+
lastSavedAt: string | null;
|
|
25
|
+
siteId: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface SiteConfigRow {
|
|
29
|
+
key: string;
|
|
30
|
+
config: Record<string, unknown>;
|
|
31
|
+
updatedAt: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface ContentCacheRow {
|
|
35
|
+
key: string;
|
|
36
|
+
sha: string;
|
|
37
|
+
sections: LoadedSection[];
|
|
38
|
+
index: SiteIndex;
|
|
39
|
+
siteConfig: Record<string, unknown>;
|
|
40
|
+
updatedAt: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
interface MediaManifestRow {
|
|
44
|
+
key: string;
|
|
45
|
+
manifest: MediaManifest;
|
|
46
|
+
updatedAt: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
interface PendingMediaRow {
|
|
50
|
+
id: string;
|
|
51
|
+
item: MediaItem;
|
|
52
|
+
localUrls: Record<string, string>;
|
|
53
|
+
updatedAt: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
interface PendingMediaDeletionRow {
|
|
57
|
+
id: string;
|
|
58
|
+
deletedAt: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
class EditorDatabase extends Dexie {
|
|
62
|
+
sections!: Dexie.Table<SectionRow, string>;
|
|
63
|
+
siteIndex!: Dexie.Table<SiteIndexRow, string>;
|
|
64
|
+
meta!: Dexie.Table<MetaRow, string>;
|
|
65
|
+
siteConfig!: Dexie.Table<SiteConfigRow, string>;
|
|
66
|
+
contentCache!: Dexie.Table<ContentCacheRow, string>;
|
|
67
|
+
mediaManifest!: Dexie.Table<MediaManifestRow, string>;
|
|
68
|
+
pendingMedia!: Dexie.Table<PendingMediaRow, string>;
|
|
69
|
+
pendingMediaDeletions!: Dexie.Table<PendingMediaDeletionRow, string>;
|
|
70
|
+
|
|
71
|
+
constructor(siteId: string) {
|
|
72
|
+
super(`brand-portal-${siteId}`);
|
|
73
|
+
this.version(1).stores({
|
|
74
|
+
sections: "sectionId",
|
|
75
|
+
siteIndex: "key",
|
|
76
|
+
meta: "key",
|
|
77
|
+
});
|
|
78
|
+
this.version(2).stores({
|
|
79
|
+
sections: "sectionId",
|
|
80
|
+
siteIndex: "key",
|
|
81
|
+
meta: "key",
|
|
82
|
+
siteConfig: "key",
|
|
83
|
+
});
|
|
84
|
+
this.version(3).stores({
|
|
85
|
+
sections: "sectionId",
|
|
86
|
+
siteIndex: "key",
|
|
87
|
+
meta: "key",
|
|
88
|
+
siteConfig: "key",
|
|
89
|
+
contentCache: "key",
|
|
90
|
+
});
|
|
91
|
+
this.version(4).stores({
|
|
92
|
+
sections: "sectionId",
|
|
93
|
+
siteIndex: "key",
|
|
94
|
+
meta: "key",
|
|
95
|
+
siteConfig: "key",
|
|
96
|
+
contentCache: "key",
|
|
97
|
+
mediaManifest: "key",
|
|
98
|
+
pendingMedia: "id",
|
|
99
|
+
pendingMediaDeletions: "id",
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
let db: EditorDatabase | null = null;
|
|
105
|
+
|
|
106
|
+
function getDb(): EditorDatabase {
|
|
107
|
+
if (!db) throw new Error("Editor store not initialized. Call initEditorStore first.");
|
|
108
|
+
return db;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export function initEditorStore(siteId: string): void {
|
|
112
|
+
db = new EditorDatabase(siteId);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export async function checkForLocalChanges(): Promise<{ latestTimestamp: string } | null> {
|
|
116
|
+
const database = getDb();
|
|
117
|
+
const dirtyRows = await database.sections.filter((row) => row.dirty).toArray();
|
|
118
|
+
const indexRow = await database.siteIndex.get("current");
|
|
119
|
+
const configRow = await database.siteConfig.get("current");
|
|
120
|
+
if (dirtyRows.length === 0 && !indexRow && !configRow) return null;
|
|
121
|
+
|
|
122
|
+
const timestamps: string[] = [];
|
|
123
|
+
for (const row of dirtyRows) timestamps.push(row.updatedAt);
|
|
124
|
+
if (indexRow) timestamps.push(indexRow.updatedAt);
|
|
125
|
+
if (configRow) timestamps.push(configRow.updatedAt);
|
|
126
|
+
|
|
127
|
+
timestamps.sort();
|
|
128
|
+
return { latestTimestamp: timestamps[timestamps.length - 1] };
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export async function restoreLocalChanges(): Promise<{
|
|
132
|
+
sections: Record<string, SectionContent>;
|
|
133
|
+
siteIndex?: SiteIndex;
|
|
134
|
+
siteConfig?: Record<string, unknown>;
|
|
135
|
+
}> {
|
|
136
|
+
const sectionRows = await getDb().sections.toArray();
|
|
137
|
+
const sections: Record<string, SectionContent> = {};
|
|
138
|
+
for (const row of sectionRows) {
|
|
139
|
+
sections[row.sectionId] = row.content;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const indexRow = await getDb().siteIndex.get("current");
|
|
143
|
+
const configRow = await getDb().siteConfig.get("current");
|
|
144
|
+
|
|
145
|
+
if (indexRow) {
|
|
146
|
+
const metaRow = await getDb().meta.get("current");
|
|
147
|
+
const siteId = metaRow?.siteId ?? "";
|
|
148
|
+
return {
|
|
149
|
+
sections,
|
|
150
|
+
siteIndex: { siteId, order: indexRow.order, sections: indexRow.sections },
|
|
151
|
+
siteConfig: configRow?.config,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return { sections, siteIndex: undefined, siteConfig: configRow?.config };
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export async function discardLocalChanges(): Promise<void> {
|
|
159
|
+
const database = getDb();
|
|
160
|
+
await database.transaction("rw", [database.sections, database.siteIndex, database.meta, database.siteConfig, database.pendingMedia, database.pendingMediaDeletions, database.mediaManifest], async () => {
|
|
161
|
+
await database.sections.clear();
|
|
162
|
+
await database.siteIndex.clear();
|
|
163
|
+
await database.meta.clear();
|
|
164
|
+
await database.siteConfig.clear();
|
|
165
|
+
await database.pendingMedia.clear();
|
|
166
|
+
await database.pendingMediaDeletions.clear();
|
|
167
|
+
await database.mediaManifest.clear();
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export async function persistSiteIndex(index: SiteIndex): Promise<void> {
|
|
172
|
+
const now = new Date().toISOString();
|
|
173
|
+
const database = getDb();
|
|
174
|
+
await database.transaction("rw", [database.siteIndex, database.meta], async () => {
|
|
175
|
+
await database.siteIndex.put({
|
|
176
|
+
key: "current",
|
|
177
|
+
order: index.order,
|
|
178
|
+
sections: index.sections,
|
|
179
|
+
updatedAt: now,
|
|
180
|
+
});
|
|
181
|
+
await database.meta.put({
|
|
182
|
+
key: "current",
|
|
183
|
+
lastSavedSha: null,
|
|
184
|
+
lastSavedAt: null,
|
|
185
|
+
siteId: index.siteId,
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export async function persistSiteConfig(config: Record<string, unknown>): Promise<void> {
|
|
191
|
+
const now = new Date().toISOString();
|
|
192
|
+
const database = getDb();
|
|
193
|
+
await database.siteConfig.put({
|
|
194
|
+
key: "current",
|
|
195
|
+
config,
|
|
196
|
+
updatedAt: now,
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export async function hasLocalChanges(): Promise<boolean> {
|
|
201
|
+
const database = getDb();
|
|
202
|
+
const dirtyCount = await database.sections.filter((row) => row.dirty).count();
|
|
203
|
+
if (dirtyCount > 0) return true;
|
|
204
|
+
const indexRow = await database.siteIndex.get("current");
|
|
205
|
+
if (indexRow != null) return true;
|
|
206
|
+
const configRow = await database.siteConfig.get("current");
|
|
207
|
+
return configRow != null;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export async function getDirtySections(): Promise<
|
|
211
|
+
{ sectionId: string; content: SectionContent }[]
|
|
212
|
+
> {
|
|
213
|
+
const rows = await getDb().sections.filter((row) => row.dirty).toArray();
|
|
214
|
+
return rows.map((row) => ({ sectionId: row.sectionId, content: row.content }));
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export async function persistAll(
|
|
218
|
+
sections: { sectionId: string; content: SectionContent }[],
|
|
219
|
+
siteIndex?: SiteIndex,
|
|
220
|
+
deletedSectionIds?: string[],
|
|
221
|
+
siteConfig?: Record<string, unknown>,
|
|
222
|
+
): Promise<void> {
|
|
223
|
+
const now = new Date().toISOString();
|
|
224
|
+
const database = getDb();
|
|
225
|
+
await database.transaction(
|
|
226
|
+
"rw",
|
|
227
|
+
[database.sections, database.siteIndex, database.meta, database.siteConfig],
|
|
228
|
+
async () => {
|
|
229
|
+
if (sections.length > 0) {
|
|
230
|
+
await database.sections.bulkPut(
|
|
231
|
+
sections.map((e) => ({
|
|
232
|
+
sectionId: e.sectionId,
|
|
233
|
+
content: e.content,
|
|
234
|
+
dirty: true,
|
|
235
|
+
updatedAt: now,
|
|
236
|
+
})),
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
if (deletedSectionIds && deletedSectionIds.length > 0) {
|
|
241
|
+
await database.sections.bulkDelete(deletedSectionIds);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (siteIndex) {
|
|
245
|
+
await database.siteIndex.put({
|
|
246
|
+
key: "current",
|
|
247
|
+
order: siteIndex.order,
|
|
248
|
+
sections: siteIndex.sections,
|
|
249
|
+
updatedAt: now,
|
|
250
|
+
});
|
|
251
|
+
await database.meta.put({
|
|
252
|
+
key: "current",
|
|
253
|
+
lastSavedSha: null,
|
|
254
|
+
lastSavedAt: null,
|
|
255
|
+
siteId: siteIndex.siteId,
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (siteConfig) {
|
|
260
|
+
await database.siteConfig.put({
|
|
261
|
+
key: "current",
|
|
262
|
+
config: siteConfig,
|
|
263
|
+
updatedAt: now,
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export async function cacheContent(
|
|
271
|
+
sha: string,
|
|
272
|
+
sections: LoadedSection[],
|
|
273
|
+
index: SiteIndex,
|
|
274
|
+
siteConfig: Record<string, unknown>,
|
|
275
|
+
): Promise<void> {
|
|
276
|
+
const now = new Date().toISOString();
|
|
277
|
+
await getDb().contentCache.put({
|
|
278
|
+
key: "current",
|
|
279
|
+
sha,
|
|
280
|
+
sections,
|
|
281
|
+
index,
|
|
282
|
+
siteConfig,
|
|
283
|
+
updatedAt: now,
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export async function getCachedContent(): Promise<{
|
|
288
|
+
sha: string;
|
|
289
|
+
sections: LoadedSection[];
|
|
290
|
+
index: SiteIndex;
|
|
291
|
+
siteConfig: Record<string, unknown>;
|
|
292
|
+
} | null> {
|
|
293
|
+
const row = await getDb().contentCache.get("current");
|
|
294
|
+
if (!row) return null;
|
|
295
|
+
return {
|
|
296
|
+
sha: row.sha,
|
|
297
|
+
sections: row.sections,
|
|
298
|
+
index: row.index,
|
|
299
|
+
siteConfig: row.siteConfig,
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
export async function persistMediaManifest(manifest: MediaManifest): Promise<void> {
|
|
304
|
+
const now = new Date().toISOString();
|
|
305
|
+
await getDb().mediaManifest.put({ key: "current", manifest, updatedAt: now });
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
export async function getMediaManifest(): Promise<MediaManifest | null> {
|
|
309
|
+
const row = await getDb().mediaManifest.get("current");
|
|
310
|
+
return row?.manifest ?? null;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
export async function addPendingMediaItem(
|
|
314
|
+
item: MediaItem,
|
|
315
|
+
localUrls: Record<string, string> = {},
|
|
316
|
+
): Promise<void> {
|
|
317
|
+
const now = new Date().toISOString();
|
|
318
|
+
await getDb().pendingMedia.put({ id: item.id, item, localUrls, updatedAt: now });
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
export async function getPendingMediaItems(): Promise<MediaItem[]> {
|
|
322
|
+
const rows = await getDb().pendingMedia.toArray();
|
|
323
|
+
return rows.map((r) => r.item);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
export async function getPendingMediaLocalUrls(id: string): Promise<Record<string, string> | null> {
|
|
327
|
+
const row = await getDb().pendingMedia.get(id);
|
|
328
|
+
return row?.localUrls ?? null;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
export async function markPendingMediaDeleted(id: string): Promise<void> {
|
|
332
|
+
const now = new Date().toISOString();
|
|
333
|
+
await getDb().pendingMediaDeletions.put({ id, deletedAt: now });
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export async function getPendingMediaDeletions(): Promise<string[]> {
|
|
337
|
+
const rows = await getDb().pendingMediaDeletions.toArray();
|
|
338
|
+
return rows.map((r) => r.id);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
export async function clearPendingMedia(): Promise<void> {
|
|
342
|
+
const database = getDb();
|
|
343
|
+
await database.transaction("rw", [database.pendingMedia, database.pendingMediaDeletions], async () => {
|
|
344
|
+
await database.pendingMedia.clear();
|
|
345
|
+
await database.pendingMediaDeletions.clear();
|
|
346
|
+
});
|
|
347
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { NavItem } from "./nav";
|
|
2
|
+
|
|
3
|
+
export interface TypedEvent<T> {
|
|
4
|
+
dispatch(detail: T): void;
|
|
5
|
+
listen(callback: (detail: T) => void): () => void;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function createEvent<T>(name: string): TypedEvent<T> {
|
|
9
|
+
return {
|
|
10
|
+
dispatch(detail: T) {
|
|
11
|
+
window.dispatchEvent(new CustomEvent(name, { detail }));
|
|
12
|
+
},
|
|
13
|
+
listen(callback: (detail: T) => void): () => void {
|
|
14
|
+
const handler = (e: Event) => callback((e as CustomEvent<T>).detail);
|
|
15
|
+
window.addEventListener(name, handler);
|
|
16
|
+
return () => window.removeEventListener(name, handler);
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const editModeEvent = createEvent<{ isEditMode: boolean }>("editmodechange");
|
|
22
|
+
export const navChangeEvent = createEvent<NavItem[]>("sitenavchange");
|
|
23
|
+
export const darkModeEvent = createEvent<string>("sitedarkmode");
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function buildGoogleFontsUrl(headingFont: string, bodyFont: string): string | null {
|
|
2
|
+
const fonts = new Set<string>();
|
|
3
|
+
if (headingFont !== "system-ui") fonts.add(headingFont);
|
|
4
|
+
if (bodyFont !== "system-ui") fonts.add(bodyFont);
|
|
5
|
+
|
|
6
|
+
if (fonts.size === 0) return null;
|
|
7
|
+
|
|
8
|
+
const params = [...fonts].map((f) => `family=${f.replace(/ /g, "+")}:wght@400;700`).join("&");
|
|
9
|
+
return `https://fonts.googleapis.com/css2?${params}&display=swap`;
|
|
10
|
+
}
|
package/src/lib/grid.ts
ADDED
package/src/lib/icons.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Check,
|
|
3
|
+
X,
|
|
4
|
+
ArrowRight,
|
|
5
|
+
Star,
|
|
6
|
+
Info,
|
|
7
|
+
AlertTriangle,
|
|
8
|
+
Heart,
|
|
9
|
+
Lightbulb,
|
|
10
|
+
Flag,
|
|
11
|
+
Shield,
|
|
12
|
+
Zap,
|
|
13
|
+
Eye,
|
|
14
|
+
Lock,
|
|
15
|
+
Globe,
|
|
16
|
+
Users,
|
|
17
|
+
Target,
|
|
18
|
+
Bookmark,
|
|
19
|
+
Clock,
|
|
20
|
+
ThumbsUp,
|
|
21
|
+
ThumbsDown,
|
|
22
|
+
type LucideIcon,
|
|
23
|
+
} from "lucide-react";
|
|
24
|
+
|
|
25
|
+
export interface IconEntry {
|
|
26
|
+
id: string;
|
|
27
|
+
label: string;
|
|
28
|
+
icon: LucideIcon;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const curatedIcons: IconEntry[] = [
|
|
32
|
+
{ id: "check", label: "Check", icon: Check },
|
|
33
|
+
{ id: "x", label: "X", icon: X },
|
|
34
|
+
{ id: "arrow-right", label: "Arrow Right", icon: ArrowRight },
|
|
35
|
+
{ id: "star", label: "Star", icon: Star },
|
|
36
|
+
{ id: "info", label: "Info", icon: Info },
|
|
37
|
+
{ id: "alert-triangle", label: "Warning", icon: AlertTriangle },
|
|
38
|
+
{ id: "heart", label: "Heart", icon: Heart },
|
|
39
|
+
{ id: "lightbulb", label: "Lightbulb", icon: Lightbulb },
|
|
40
|
+
{ id: "flag", label: "Flag", icon: Flag },
|
|
41
|
+
{ id: "shield", label: "Shield", icon: Shield },
|
|
42
|
+
{ id: "zap", label: "Zap", icon: Zap },
|
|
43
|
+
{ id: "eye", label: "Eye", icon: Eye },
|
|
44
|
+
{ id: "lock", label: "Lock", icon: Lock },
|
|
45
|
+
{ id: "globe", label: "Globe", icon: Globe },
|
|
46
|
+
{ id: "users", label: "Users", icon: Users },
|
|
47
|
+
{ id: "target", label: "Target", icon: Target },
|
|
48
|
+
{ id: "bookmark", label: "Bookmark", icon: Bookmark },
|
|
49
|
+
{ id: "clock", label: "Clock", icon: Clock },
|
|
50
|
+
{ id: "thumbs-up", label: "Thumbs Up", icon: ThumbsUp },
|
|
51
|
+
{ id: "thumbs-down", label: "Thumbs Down", icon: ThumbsDown },
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
const iconMap = new Map(curatedIcons.map((e) => [e.id, e]));
|
|
55
|
+
|
|
56
|
+
export function getIcon(id: string): IconEntry | undefined {
|
|
57
|
+
return iconMap.get(id);
|
|
58
|
+
}
|
package/src/lib/index.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export { cn } from "./cn";
|
|
2
|
+
export { generateNavLinks, toSectionId, type NavItem } from "./nav";
|
|
3
|
+
export { deriveContrast } from "./contrast";
|
|
4
|
+
export { sanitizeHtml } from "./sanitize";
|
|
5
|
+
export { gridColsClass } from "./grid";
|
|
6
|
+
export { getIcon, curatedIcons, type IconEntry } from "./icons";
|
|
7
|
+
export { buildGoogleFontsUrl } from "./google-fonts";
|
|
8
|
+
export { formatTimestamp } from "./timestamp";
|
|
9
|
+
export { safeRedirect } from "./safeRedirect";
|
|
10
|
+
export { createEvent, editModeEvent, navChangeEvent, darkModeEvent, type TypedEvent } from "./events";
|
|
11
|
+
export {
|
|
12
|
+
createRegistry,
|
|
13
|
+
defineSection,
|
|
14
|
+
registerSection,
|
|
15
|
+
registerSchema,
|
|
16
|
+
getSection,
|
|
17
|
+
getSchema,
|
|
18
|
+
getAllSections,
|
|
19
|
+
getAllSchemas,
|
|
20
|
+
clearRegistry,
|
|
21
|
+
type SectionRegistry,
|
|
22
|
+
type SectionDefinition,
|
|
23
|
+
type SectionProps,
|
|
24
|
+
type WrapperProps,
|
|
25
|
+
type SettingsFieldDef,
|
|
26
|
+
type SettingsSchema,
|
|
27
|
+
type CustomSettingsFormProps,
|
|
28
|
+
} from "./registry";
|
|
29
|
+
export {
|
|
30
|
+
mergeSiteContent,
|
|
31
|
+
loadStaticSiteContent,
|
|
32
|
+
loadSiteContent,
|
|
33
|
+
type LoadedSection,
|
|
34
|
+
type SiteContent,
|
|
35
|
+
} from "./loader";
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { getSectionSchema, type Section } from "../schemas/sections";
|
|
2
|
+
import { IndexSchema, type SiteIndex, type SectionMeta } from "../schemas/site-config";
|
|
3
|
+
|
|
4
|
+
export interface LoadedSection {
|
|
5
|
+
section: Section;
|
|
6
|
+
meta: SectionMeta;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface SiteContent {
|
|
10
|
+
sections: LoadedSection[];
|
|
11
|
+
index: SiteIndex;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Merge a validated index with raw section file contents.
|
|
16
|
+
* Validates each section file against its Zod schema.
|
|
17
|
+
* Returns sections in the order specified by index.order.
|
|
18
|
+
*/
|
|
19
|
+
export function mergeSiteContent(
|
|
20
|
+
index: SiteIndex,
|
|
21
|
+
sectionFiles: Record<string, unknown>
|
|
22
|
+
): SiteContent {
|
|
23
|
+
const sections: LoadedSection[] = [];
|
|
24
|
+
|
|
25
|
+
for (const id of index.order) {
|
|
26
|
+
const raw = sectionFiles[id];
|
|
27
|
+
if (!raw) {
|
|
28
|
+
console.warn(`Section file missing for id: ${id}, skipping`);
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
const result = getSectionSchema().safeParse(raw);
|
|
32
|
+
if (!result.success) {
|
|
33
|
+
const type = (raw as Record<string, unknown>).type ?? "unknown";
|
|
34
|
+
console.warn(`Skipping section "${id}" (type: ${type}): invalid schema`);
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
const meta = index.sections[id];
|
|
38
|
+
sections.push({ section: result.data, meta });
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return { sections, index };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Build a SiteContent from a Vite `import.meta.glob` result.
|
|
46
|
+
* Callers glob the section JSON files at build time, pass the parsed index, and
|
|
47
|
+
* receive sections merged in index.order.
|
|
48
|
+
*/
|
|
49
|
+
export function loadStaticSiteContent(
|
|
50
|
+
index: SiteIndex,
|
|
51
|
+
sectionGlob: Record<string, unknown>,
|
|
52
|
+
): SiteContent {
|
|
53
|
+
const sectionFiles: Record<string, unknown> = {};
|
|
54
|
+
for (const [path, data] of Object.entries(sectionGlob)) {
|
|
55
|
+
const filename = path.split("/").pop()!;
|
|
56
|
+
const id = filename.replace(".json", "");
|
|
57
|
+
sectionFiles[id] = data;
|
|
58
|
+
}
|
|
59
|
+
return mergeSiteContent(index, sectionFiles);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Load site content from the filesystem.
|
|
64
|
+
* For use in scripts and tests — Astro pages should use import.meta.glob instead.
|
|
65
|
+
*/
|
|
66
|
+
export async function loadSiteContent(contentDir: string): Promise<SiteContent> {
|
|
67
|
+
const fs = await import("node:fs/promises");
|
|
68
|
+
const path = await import("node:path");
|
|
69
|
+
|
|
70
|
+
const indexPath = path.join(contentDir, "index.json");
|
|
71
|
+
const indexRaw = JSON.parse(await fs.readFile(indexPath, "utf-8"));
|
|
72
|
+
const index = IndexSchema.parse(indexRaw);
|
|
73
|
+
|
|
74
|
+
const sectionFiles: Record<string, unknown> = {};
|
|
75
|
+
for (const id of index.order) {
|
|
76
|
+
const sectionPath = path.join(contentDir, "sections", `${id}.json`);
|
|
77
|
+
sectionFiles[id] = JSON.parse(await fs.readFile(sectionPath, "utf-8"));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return mergeSiteContent(index, sectionFiles);
|
|
81
|
+
}
|
package/src/lib/nav.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { LoadedSection } from "./loader";
|
|
2
|
+
|
|
3
|
+
export interface NavItem {
|
|
4
|
+
href: string;
|
|
5
|
+
label: string;
|
|
6
|
+
status?: string;
|
|
7
|
+
children: NavItem[];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function toSectionId(text: string): string {
|
|
11
|
+
return text
|
|
12
|
+
.toLowerCase()
|
|
13
|
+
.replace(/[^\w\s-]/g, "")
|
|
14
|
+
.trim()
|
|
15
|
+
.replace(/\s+/g, "-");
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Generate a three-tier navigation structure from sections.
|
|
20
|
+
* link_heading → top-level, sub_heading → second-level, sub_sub_heading → third-level.
|
|
21
|
+
* Non-heading sections are skipped.
|
|
22
|
+
*/
|
|
23
|
+
export function generateNavLinks(sections: LoadedSection[]): NavItem[] {
|
|
24
|
+
const nav: NavItem[] = [];
|
|
25
|
+
let currentParent: NavItem | null = null;
|
|
26
|
+
let currentChild: NavItem | null = null;
|
|
27
|
+
|
|
28
|
+
for (const { section, meta } of sections) {
|
|
29
|
+
const content = section.content as { heading?: string; excludeFromNav?: boolean };
|
|
30
|
+
if (!content.heading) continue;
|
|
31
|
+
|
|
32
|
+
if (section.type === "link_heading") {
|
|
33
|
+
currentParent = {
|
|
34
|
+
href: `#${toSectionId(content.heading)}`,
|
|
35
|
+
label: content.heading,
|
|
36
|
+
status: meta.status,
|
|
37
|
+
children: [],
|
|
38
|
+
};
|
|
39
|
+
currentChild = null;
|
|
40
|
+
nav.push(currentParent);
|
|
41
|
+
} else if (section.type === "sub_heading") {
|
|
42
|
+
if (content.excludeFromNav) continue;
|
|
43
|
+
if (!currentParent) continue;
|
|
44
|
+
currentChild = {
|
|
45
|
+
href: `#${toSectionId(content.heading)}`,
|
|
46
|
+
label: content.heading,
|
|
47
|
+
status: meta.status,
|
|
48
|
+
children: [],
|
|
49
|
+
};
|
|
50
|
+
currentParent.children.push(currentChild);
|
|
51
|
+
} else if (section.type === "sub_sub_heading") {
|
|
52
|
+
if (content.excludeFromNav) continue;
|
|
53
|
+
if (!currentChild) continue;
|
|
54
|
+
currentChild.children.push({
|
|
55
|
+
href: `#${toSectionId(content.heading)}`,
|
|
56
|
+
label: content.heading,
|
|
57
|
+
status: meta.status,
|
|
58
|
+
children: [],
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return nav;
|
|
64
|
+
}
|