@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
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createGitHubMediaAdapter } from "./github";
|
|
2
|
+
export * from "./types";
|
|
3
|
+
export * from "./utils";
|
|
4
|
+
export * from "./queue";
|
|
5
|
+
export * from "./resolve";
|
|
6
|
+
export { generateVideoPoster } from "./videoPoster";
|
|
7
|
+
export function createMediaAdapter(manifest) {
|
|
8
|
+
return createGitHubMediaAdapter(manifest);
|
|
9
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { MediaKind } from "./types";
|
|
2
|
+
export interface QueueInput {
|
|
3
|
+
buffer: ArrayBuffer;
|
|
4
|
+
originalName: string;
|
|
5
|
+
mimeType: string;
|
|
6
|
+
hash: string;
|
|
7
|
+
kind: MediaKind;
|
|
8
|
+
}
|
|
9
|
+
export interface QueueItem {
|
|
10
|
+
id: string;
|
|
11
|
+
originalName: string;
|
|
12
|
+
mimeType: string;
|
|
13
|
+
hash: string;
|
|
14
|
+
kind: MediaKind;
|
|
15
|
+
percent: number;
|
|
16
|
+
state: "queued" | "active" | "complete" | "error";
|
|
17
|
+
error?: string;
|
|
18
|
+
result?: {
|
|
19
|
+
variants: {
|
|
20
|
+
width: number;
|
|
21
|
+
height: number;
|
|
22
|
+
size: number;
|
|
23
|
+
blob: Blob;
|
|
24
|
+
}[];
|
|
25
|
+
primaryBlob: Blob;
|
|
26
|
+
posterBlob?: Blob;
|
|
27
|
+
width: number;
|
|
28
|
+
height: number;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export type QueueEvent = {
|
|
32
|
+
type: "queued";
|
|
33
|
+
item: QueueItem;
|
|
34
|
+
} | {
|
|
35
|
+
type: "started";
|
|
36
|
+
item: QueueItem;
|
|
37
|
+
} | {
|
|
38
|
+
type: "progress";
|
|
39
|
+
item: QueueItem;
|
|
40
|
+
} | {
|
|
41
|
+
type: "complete";
|
|
42
|
+
item: QueueItem;
|
|
43
|
+
} | {
|
|
44
|
+
type: "error";
|
|
45
|
+
item: QueueItem;
|
|
46
|
+
};
|
|
47
|
+
interface QueueOptions {
|
|
48
|
+
sizes: number[];
|
|
49
|
+
quality: number;
|
|
50
|
+
maxConcurrent: number;
|
|
51
|
+
createWorker: () => Worker;
|
|
52
|
+
onEvent: (event: QueueEvent) => void;
|
|
53
|
+
}
|
|
54
|
+
export declare class ProcessingQueue {
|
|
55
|
+
private items;
|
|
56
|
+
private pending;
|
|
57
|
+
private activeWorkers;
|
|
58
|
+
private options;
|
|
59
|
+
private nextId;
|
|
60
|
+
constructor(options: QueueOptions);
|
|
61
|
+
add(input: QueueInput): string;
|
|
62
|
+
getStatus(): {
|
|
63
|
+
active: number;
|
|
64
|
+
queued: number;
|
|
65
|
+
total: number;
|
|
66
|
+
items: QueueItem[];
|
|
67
|
+
};
|
|
68
|
+
private processNext;
|
|
69
|
+
private startProcessing;
|
|
70
|
+
private cleanupWorker;
|
|
71
|
+
destroy(): void;
|
|
72
|
+
}
|
|
73
|
+
export {};
|
|
74
|
+
//# sourceMappingURL=queue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../src/media/queue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,WAAW,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,SAAS,CAAC;CACjB;AAED,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,QAAQ,GAAG,QAAQ,GAAG,UAAU,GAAG,OAAO,CAAC;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE;QACP,QAAQ,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,IAAI,CAAA;SAAE,EAAE,CAAC;QACxE,WAAW,EAAE,IAAI,CAAC;QAClB,UAAU,CAAC,EAAE,IAAI,CAAC;QAClB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED,MAAM,MAAM,UAAU,GAClB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,SAAS,CAAA;CAAE,GACnC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,SAAS,CAAA;CAAE,GACpC;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,SAAS,CAAA;CAAE,GACrC;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,SAAS,CAAA;CAAE,GACrC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC;AAEvC,UAAU,YAAY;IACpB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,MAAM,CAAC;IAC3B,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;CACtC;AAED,qBAAa,eAAe;IAC1B,OAAO,CAAC,KAAK,CAAgC;IAC7C,OAAO,CAAC,OAAO,CAA2C;IAC1D,OAAO,CAAC,aAAa,CAA6B;IAClD,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,MAAM,CAAK;gBAEP,OAAO,EAAE,YAAY;IAIjC,GAAG,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM;IAkB9B,SAAS,IAAI;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,SAAS,EAAE,CAAA;KAAE;IAelF,OAAO,CAAC,WAAW;IAOnB,OAAO,CAAC,eAAe;IA0DvB,OAAO,CAAC,aAAa;IAKrB,OAAO,IAAI,IAAI;CAQhB"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
export class ProcessingQueue {
|
|
2
|
+
items = new Map();
|
|
3
|
+
pending = [];
|
|
4
|
+
activeWorkers = new Map();
|
|
5
|
+
options;
|
|
6
|
+
nextId = 0;
|
|
7
|
+
constructor(options) {
|
|
8
|
+
this.options = options;
|
|
9
|
+
}
|
|
10
|
+
add(input) {
|
|
11
|
+
const id = `media-${this.nextId++}`;
|
|
12
|
+
const item = {
|
|
13
|
+
id,
|
|
14
|
+
originalName: input.originalName,
|
|
15
|
+
mimeType: input.mimeType,
|
|
16
|
+
hash: input.hash,
|
|
17
|
+
kind: input.kind,
|
|
18
|
+
percent: 0,
|
|
19
|
+
state: "queued",
|
|
20
|
+
};
|
|
21
|
+
this.items.set(id, item);
|
|
22
|
+
this.pending.push({ input, id });
|
|
23
|
+
this.options.onEvent({ type: "queued", item: { ...item } });
|
|
24
|
+
this.processNext();
|
|
25
|
+
return id;
|
|
26
|
+
}
|
|
27
|
+
getStatus() {
|
|
28
|
+
let active = 0;
|
|
29
|
+
let queued = 0;
|
|
30
|
+
for (const item of this.items.values()) {
|
|
31
|
+
if (item.state === "active")
|
|
32
|
+
active++;
|
|
33
|
+
if (item.state === "queued")
|
|
34
|
+
queued++;
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
active,
|
|
38
|
+
queued,
|
|
39
|
+
total: this.items.size,
|
|
40
|
+
items: Array.from(this.items.values()),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
processNext() {
|
|
44
|
+
while (this.activeWorkers.size < this.options.maxConcurrent && this.pending.length > 0) {
|
|
45
|
+
const next = this.pending.shift();
|
|
46
|
+
this.startProcessing(next.id, next.input);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
startProcessing(id, input) {
|
|
50
|
+
const item = this.items.get(id);
|
|
51
|
+
item.state = "active";
|
|
52
|
+
this.options.onEvent({ type: "started", item: { ...item } });
|
|
53
|
+
const worker = this.options.createWorker();
|
|
54
|
+
this.activeWorkers.set(id, worker);
|
|
55
|
+
worker.onmessage = (e) => {
|
|
56
|
+
const msg = e.data;
|
|
57
|
+
if (msg.id !== id)
|
|
58
|
+
return;
|
|
59
|
+
if (msg.type === "progress") {
|
|
60
|
+
item.percent = msg.percent;
|
|
61
|
+
this.options.onEvent({ type: "progress", item: { ...item } });
|
|
62
|
+
}
|
|
63
|
+
else if (msg.type === "complete") {
|
|
64
|
+
item.state = "complete";
|
|
65
|
+
item.percent = 100;
|
|
66
|
+
item.result = {
|
|
67
|
+
variants: msg.variants,
|
|
68
|
+
primaryBlob: msg.primaryBlob,
|
|
69
|
+
posterBlob: msg.posterBlob,
|
|
70
|
+
width: msg.width,
|
|
71
|
+
height: msg.height,
|
|
72
|
+
};
|
|
73
|
+
this.options.onEvent({ type: "complete", item: { ...item } });
|
|
74
|
+
this.cleanupWorker(id, worker);
|
|
75
|
+
this.processNext();
|
|
76
|
+
}
|
|
77
|
+
else if (msg.type === "error") {
|
|
78
|
+
item.state = "error";
|
|
79
|
+
item.error = msg.message;
|
|
80
|
+
this.options.onEvent({ type: "error", item: { ...item } });
|
|
81
|
+
this.cleanupWorker(id, worker);
|
|
82
|
+
this.processNext();
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
worker.onerror = (e) => {
|
|
86
|
+
item.state = "error";
|
|
87
|
+
item.error = e.message || "Worker error";
|
|
88
|
+
this.options.onEvent({ type: "error", item: { ...item } });
|
|
89
|
+
this.cleanupWorker(id, worker);
|
|
90
|
+
this.processNext();
|
|
91
|
+
};
|
|
92
|
+
worker.postMessage({
|
|
93
|
+
type: "process",
|
|
94
|
+
id,
|
|
95
|
+
buffer: input.buffer,
|
|
96
|
+
originalName: input.originalName,
|
|
97
|
+
mimeType: input.mimeType,
|
|
98
|
+
hash: input.hash,
|
|
99
|
+
kind: input.kind,
|
|
100
|
+
sizes: this.options.sizes,
|
|
101
|
+
quality: this.options.quality,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
cleanupWorker(id, worker) {
|
|
105
|
+
worker.terminate();
|
|
106
|
+
this.activeWorkers.delete(id);
|
|
107
|
+
}
|
|
108
|
+
destroy() {
|
|
109
|
+
for (const [id, worker] of this.activeWorkers) {
|
|
110
|
+
worker.terminate();
|
|
111
|
+
this.activeWorkers.delete(id);
|
|
112
|
+
}
|
|
113
|
+
this.pending = [];
|
|
114
|
+
this.items.clear();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { MediaManifest, ResolvedMedia } from "./types";
|
|
2
|
+
export declare function resolveMedia(item: {
|
|
3
|
+
imageId?: string;
|
|
4
|
+
src?: string;
|
|
5
|
+
}, manifest: MediaManifest, sizes: number[]): ResolvedMedia | null;
|
|
6
|
+
/**
|
|
7
|
+
* Deep-walk section content and resolve any { imageId } references to
|
|
8
|
+
* { src, srcset } values using the media manifest.
|
|
9
|
+
*
|
|
10
|
+
* This lets view-mode section components use `item.src` and `item.srcset`
|
|
11
|
+
* without needing to know about the manifest themselves.
|
|
12
|
+
*/
|
|
13
|
+
export declare function resolveManifestReferences(content: unknown, manifest: MediaManifest, sizes: number[]): unknown;
|
|
14
|
+
//# sourceMappingURL=resolve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/media/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAG5D,wBAAgB,YAAY,CAC1B,IAAI,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,EACxC,QAAQ,EAAE,aAAa,EACvB,KAAK,EAAE,MAAM,EAAE,GACd,aAAa,GAAG,IAAI,CAItB;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,aAAa,EACvB,KAAK,EAAE,MAAM,EAAE,GACd,OAAO,CAsCT"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { createMediaAdapter } from "./index";
|
|
2
|
+
export function resolveMedia(item, manifest, sizes) {
|
|
3
|
+
if (!item.imageId)
|
|
4
|
+
return null;
|
|
5
|
+
const adapter = createMediaAdapter(manifest);
|
|
6
|
+
return adapter.resolve(item.imageId, sizes);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Deep-walk section content and resolve any { imageId } references to
|
|
10
|
+
* { src, srcset } values using the media manifest.
|
|
11
|
+
*
|
|
12
|
+
* This lets view-mode section components use `item.src` and `item.srcset`
|
|
13
|
+
* without needing to know about the manifest themselves.
|
|
14
|
+
*/
|
|
15
|
+
export function resolveManifestReferences(content, manifest, sizes) {
|
|
16
|
+
if (Array.isArray(content)) {
|
|
17
|
+
return content.map((item) => resolveManifestReferences(item, manifest, sizes));
|
|
18
|
+
}
|
|
19
|
+
if (content !== null && typeof content === "object") {
|
|
20
|
+
const obj = content;
|
|
21
|
+
// If this object has an imageId, resolve it and merge resolved fields
|
|
22
|
+
if (typeof obj.imageId === "string") {
|
|
23
|
+
const manifestItem = manifest.images[obj.imageId];
|
|
24
|
+
const resolved = resolveMedia({ imageId: obj.imageId }, manifest, sizes);
|
|
25
|
+
const patch = {
|
|
26
|
+
alt: manifestItem?.alt ?? "",
|
|
27
|
+
};
|
|
28
|
+
if (resolved && resolved.tag === "img") {
|
|
29
|
+
patch.src = resolved.src;
|
|
30
|
+
if ("srcSet" in resolved && resolved.srcSet) {
|
|
31
|
+
patch.srcset = resolved.srcSet;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
else if (resolved && resolved.tag === "video") {
|
|
35
|
+
patch.src = resolved.src;
|
|
36
|
+
if (resolved.poster) {
|
|
37
|
+
patch.poster = resolved.poster;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return { ...obj, ...patch };
|
|
41
|
+
}
|
|
42
|
+
// Recurse into all values
|
|
43
|
+
const result = {};
|
|
44
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
45
|
+
result[key] = resolveManifestReferences(value, manifest, sizes);
|
|
46
|
+
}
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
return content;
|
|
50
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export { VariantSchema, MediaItemSchema, ImageManifestSchema, MediaConfigSchema, type Variant, type MediaItem, type MediaManifest, type MediaConfig, } from "../schemas/media";
|
|
2
|
+
import type { MediaItem } from "../schemas/media";
|
|
3
|
+
export type MediaKind = "image" | "animated" | "video";
|
|
4
|
+
export interface MediaFile {
|
|
5
|
+
buffer: ArrayBuffer;
|
|
6
|
+
originalName: string;
|
|
7
|
+
mimeType: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ResolvedImage {
|
|
10
|
+
tag: "img";
|
|
11
|
+
src: string;
|
|
12
|
+
srcSet?: string;
|
|
13
|
+
sizes?: string;
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
}
|
|
17
|
+
export interface ResolvedAnimated {
|
|
18
|
+
tag: "img";
|
|
19
|
+
src: string;
|
|
20
|
+
width: number;
|
|
21
|
+
height: number;
|
|
22
|
+
}
|
|
23
|
+
export interface ResolvedVideo {
|
|
24
|
+
tag: "video";
|
|
25
|
+
src: string;
|
|
26
|
+
poster?: string;
|
|
27
|
+
width: number;
|
|
28
|
+
height: number;
|
|
29
|
+
autoplay: boolean;
|
|
30
|
+
loop: boolean;
|
|
31
|
+
muted: boolean;
|
|
32
|
+
}
|
|
33
|
+
export type ResolvedMedia = ResolvedImage | ResolvedAnimated | ResolvedVideo;
|
|
34
|
+
export interface MediaAdapter {
|
|
35
|
+
hash(file: MediaFile): Promise<string>;
|
|
36
|
+
exists(hash: string): Promise<boolean>;
|
|
37
|
+
process(file: MediaFile, hash: string, sizes: number[]): Promise<MediaItem>;
|
|
38
|
+
delete(id: string): Promise<void>;
|
|
39
|
+
resolve(id: string, sizes: number[]): ResolvedMedia | null;
|
|
40
|
+
list(): Promise<MediaItem[]>;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/media/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,KAAK,OAAO,EACZ,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,WAAW,GACjB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,UAAU,GAAG,OAAO,CAAC;AAEvD,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,WAAW,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,KAAK,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,KAAK,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,OAAO,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,MAAM,aAAa,GAAG,aAAa,GAAG,gBAAgB,GAAG,aAAa,CAAC;AAE7E,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACvC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACvC,OAAO,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IAC5E,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClC,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,aAAa,GAAG,IAAI,CAAC;IAC3D,IAAI,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;CAC9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { VariantSchema, MediaItemSchema, ImageManifestSchema, MediaConfigSchema, } from "../schemas/media";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function hashFileBuffer(buffer: ArrayBuffer): Promise<string>;
|
|
2
|
+
export declare function sanitizeMediaName(name: string): string;
|
|
3
|
+
export declare const MIME_TO_EXT: Record<string, string>;
|
|
4
|
+
export declare const EXT_TO_MIME: Record<string, string>;
|
|
5
|
+
export declare function mimeToExt(mime: string): string;
|
|
6
|
+
export declare function displayFilenameExt(mime: string): string;
|
|
7
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/media/utils.ts"],"names":[],"mappings":"AAAA,wBAAsB,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAqBzE;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAI9C,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAK9C,CAAC;AAEF,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGvD"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export async function hashFileBuffer(buffer) {
|
|
2
|
+
if (typeof crypto !== "undefined" && crypto.subtle) {
|
|
3
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", buffer);
|
|
4
|
+
const hashArray = new Uint8Array(hashBuffer);
|
|
5
|
+
return Array.from(hashArray.slice(0, 8))
|
|
6
|
+
.map((b) => b.toString(16).padStart(2, "0"))
|
|
7
|
+
.join("");
|
|
8
|
+
}
|
|
9
|
+
// FNV-1a fallback: two passes with different seeds, concatenated for 16 hex chars
|
|
10
|
+
const bytes = new Uint8Array(buffer);
|
|
11
|
+
const seeds = [0x811c9dc5, 0x050c5d1f];
|
|
12
|
+
let result = "";
|
|
13
|
+
for (const seed of seeds) {
|
|
14
|
+
let h = seed;
|
|
15
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
16
|
+
h ^= bytes[i];
|
|
17
|
+
h = Math.imul(h, 0x01000193);
|
|
18
|
+
}
|
|
19
|
+
result += (h >>> 0).toString(16).padStart(8, "0");
|
|
20
|
+
}
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
export function sanitizeMediaName(name) {
|
|
24
|
+
return name.replace(/\.[^.]+$/, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
25
|
+
}
|
|
26
|
+
export const MIME_TO_EXT = {
|
|
27
|
+
"image/gif": "gif", "image/apng": "apng", "image/png": "png",
|
|
28
|
+
"image/jpeg": "jpg", "image/webp": "webp", "image/svg+xml": "svg",
|
|
29
|
+
"video/mp4": "mp4", "video/webm": "webm",
|
|
30
|
+
};
|
|
31
|
+
export const EXT_TO_MIME = {
|
|
32
|
+
...Object.fromEntries(Object.entries(MIME_TO_EXT).map(([mime, ext]) => [`.${ext}`, mime])),
|
|
33
|
+
".jpeg": "image/jpeg",
|
|
34
|
+
};
|
|
35
|
+
export function mimeToExt(mime) {
|
|
36
|
+
return MIME_TO_EXT[mime] ?? "bin";
|
|
37
|
+
}
|
|
38
|
+
export function displayFilenameExt(mime) {
|
|
39
|
+
const ext = MIME_TO_EXT[mime];
|
|
40
|
+
return ext ? `.${ext}` : "";
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"videoPoster.d.ts","sourceRoot":"","sources":["../../src/media/videoPoster.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,MAAM,GACd,OAAO,CAAC;IAAE,UAAU,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAiD9D"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export function generateVideoPoster(blob, quality) {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
const video = document.createElement("video");
|
|
4
|
+
const url = URL.createObjectURL(blob);
|
|
5
|
+
video.muted = true;
|
|
6
|
+
video.preload = "auto";
|
|
7
|
+
video.src = url;
|
|
8
|
+
const cleanup = () => {
|
|
9
|
+
URL.revokeObjectURL(url);
|
|
10
|
+
video.removeAttribute("src");
|
|
11
|
+
video.load();
|
|
12
|
+
};
|
|
13
|
+
video.addEventListener("loadeddata", () => {
|
|
14
|
+
video.addEventListener("seeked", () => {
|
|
15
|
+
try {
|
|
16
|
+
const w = video.videoWidth;
|
|
17
|
+
const h = video.videoHeight;
|
|
18
|
+
const canvas = document.createElement("canvas");
|
|
19
|
+
canvas.width = w;
|
|
20
|
+
canvas.height = h;
|
|
21
|
+
const ctx = canvas.getContext("2d");
|
|
22
|
+
ctx.drawImage(video, 0, 0);
|
|
23
|
+
canvas.toBlob((posterBlob) => {
|
|
24
|
+
cleanup();
|
|
25
|
+
if (!posterBlob) {
|
|
26
|
+
reject(new Error("Failed to create poster blob"));
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
resolve({ posterBlob, width: w, height: h });
|
|
30
|
+
}, "image/webp", quality / 100);
|
|
31
|
+
}
|
|
32
|
+
catch (err) {
|
|
33
|
+
cleanup();
|
|
34
|
+
reject(err);
|
|
35
|
+
}
|
|
36
|
+
}, { once: true });
|
|
37
|
+
video.currentTime = isFinite(video.duration) ? Math.min(0.1, video.duration / 2) : 0;
|
|
38
|
+
}, { once: true });
|
|
39
|
+
video.addEventListener("error", () => {
|
|
40
|
+
cleanup();
|
|
41
|
+
reject(new Error("Failed to load video for poster generation"));
|
|
42
|
+
}, { once: true });
|
|
43
|
+
});
|
|
44
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
interface ProcessMessage {
|
|
2
|
+
type: "process";
|
|
3
|
+
id: string;
|
|
4
|
+
buffer: ArrayBuffer;
|
|
5
|
+
originalName: string;
|
|
6
|
+
mimeType: string;
|
|
7
|
+
hash: string;
|
|
8
|
+
kind: "image" | "animated" | "video";
|
|
9
|
+
sizes: number[];
|
|
10
|
+
quality: number;
|
|
11
|
+
}
|
|
12
|
+
interface ProgressMessage {
|
|
13
|
+
type: "progress";
|
|
14
|
+
id: string;
|
|
15
|
+
percent: number;
|
|
16
|
+
}
|
|
17
|
+
interface CompleteMessage {
|
|
18
|
+
type: "complete";
|
|
19
|
+
id: string;
|
|
20
|
+
variants: {
|
|
21
|
+
width: number;
|
|
22
|
+
height: number;
|
|
23
|
+
size: number;
|
|
24
|
+
blob: Blob;
|
|
25
|
+
}[];
|
|
26
|
+
primaryBlob: Blob;
|
|
27
|
+
posterBlob?: Blob;
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
30
|
+
}
|
|
31
|
+
interface ErrorMessage {
|
|
32
|
+
type: "error";
|
|
33
|
+
id: string;
|
|
34
|
+
message: string;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=worker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../src/media/worker.ts"],"names":[],"mappings":"AAAA,UAAU,cAAc;IACtB,IAAI,EAAE,SAAS,CAAC;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,WAAW,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,GAAG,UAAU,GAAG,OAAO,CAAC;IACrC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,eAAe;IACvB,IAAI,EAAE,UAAU,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,eAAe;IACvB,IAAI,EAAE,UAAU,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,IAAI,CAAA;KAAE,EAAE,CAAC;IACxE,WAAW,EAAE,IAAI,CAAC;IAClB,UAAU,CAAC,EAAE,IAAI,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,YAAY;IACpB,IAAI,EAAE,OAAO,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
self.onmessage = async (e) => {
|
|
3
|
+
const msg = e.data;
|
|
4
|
+
if (msg.type !== "process")
|
|
5
|
+
return;
|
|
6
|
+
try {
|
|
7
|
+
const post = (data) => self.postMessage(data);
|
|
8
|
+
post({ type: "progress", id: msg.id, percent: 5 });
|
|
9
|
+
if (msg.kind === "animated" || msg.kind === "video") {
|
|
10
|
+
const primaryBlob = new Blob([msg.buffer], { type: msg.mimeType });
|
|
11
|
+
let posterBlob;
|
|
12
|
+
let width = 0;
|
|
13
|
+
let height = 0;
|
|
14
|
+
if (msg.kind === "animated") {
|
|
15
|
+
const bitmap = await createImageBitmap(primaryBlob);
|
|
16
|
+
width = bitmap.width;
|
|
17
|
+
height = bitmap.height;
|
|
18
|
+
const canvas = new OffscreenCanvas(bitmap.width, bitmap.height);
|
|
19
|
+
const ctx = canvas.getContext("2d");
|
|
20
|
+
ctx.drawImage(bitmap, 0, 0);
|
|
21
|
+
posterBlob = await canvas.convertToBlob({ type: "image/webp", quality: msg.quality / 100 });
|
|
22
|
+
bitmap.close();
|
|
23
|
+
}
|
|
24
|
+
if (msg.kind === "video") {
|
|
25
|
+
width = 0;
|
|
26
|
+
height = 0;
|
|
27
|
+
}
|
|
28
|
+
post({ type: "progress", id: msg.id, percent: 100 });
|
|
29
|
+
post({ type: "complete", id: msg.id, variants: [], primaryBlob, posterBlob, width, height });
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
// Static image processing
|
|
33
|
+
const originalBlob = new Blob([msg.buffer], { type: msg.mimeType });
|
|
34
|
+
const bitmap = await createImageBitmap(originalBlob);
|
|
35
|
+
const origWidth = bitmap.width;
|
|
36
|
+
const origHeight = bitmap.height;
|
|
37
|
+
post({ type: "progress", id: msg.id, percent: 25 });
|
|
38
|
+
const applicableSizes = msg.sizes
|
|
39
|
+
.filter((s) => s <= origWidth)
|
|
40
|
+
.sort((a, b) => b - a);
|
|
41
|
+
if (applicableSizes.length === 0) {
|
|
42
|
+
applicableSizes.push(origWidth);
|
|
43
|
+
}
|
|
44
|
+
const variants = [];
|
|
45
|
+
const totalVariants = applicableSizes.length;
|
|
46
|
+
for (let i = 0; i < applicableSizes.length; i++) {
|
|
47
|
+
const targetWidth = applicableSizes[i];
|
|
48
|
+
const scale = targetWidth / origWidth;
|
|
49
|
+
const targetHeight = Math.round(origHeight * scale);
|
|
50
|
+
const canvas = new OffscreenCanvas(targetWidth, targetHeight);
|
|
51
|
+
const ctx = canvas.getContext("2d");
|
|
52
|
+
ctx.drawImage(bitmap, 0, 0, targetWidth, targetHeight);
|
|
53
|
+
const blob = await canvas.convertToBlob({ type: "image/webp", quality: msg.quality / 100 });
|
|
54
|
+
variants.push({ width: targetWidth, height: targetHeight, size: blob.size, blob });
|
|
55
|
+
const percent = 25 + Math.round(((i + 1) / totalVariants) * 75);
|
|
56
|
+
post({ type: "progress", id: msg.id, percent });
|
|
57
|
+
}
|
|
58
|
+
bitmap.close();
|
|
59
|
+
const primaryBlob = variants[0]?.blob ?? originalBlob;
|
|
60
|
+
post({
|
|
61
|
+
type: "complete",
|
|
62
|
+
id: msg.id,
|
|
63
|
+
variants,
|
|
64
|
+
primaryBlob,
|
|
65
|
+
width: origWidth,
|
|
66
|
+
height: origHeight,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
const message = err instanceof Error ? err.message : "Processing failed";
|
|
71
|
+
self.postMessage({ type: "error", id: msg.id, message });
|
|
72
|
+
}
|
|
73
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const AudienceNameSchema: z.ZodString;
|
|
3
|
+
export declare const AudienceColorSchema: z.ZodNullable<z.ZodString>;
|
|
4
|
+
export type AudienceName = z.infer<typeof AudienceNameSchema>;
|
|
5
|
+
export type AudienceColor = z.infer<typeof AudienceColorSchema>;
|
|
6
|
+
/**
|
|
7
|
+
* Convert a friendly display string into an audience slug.
|
|
8
|
+
* Lowercases, replaces non-alphanumeric runs with single dashes,
|
|
9
|
+
* strips leading/trailing dashes. Result must pass AudienceNameSchema.
|
|
10
|
+
*/
|
|
11
|
+
export declare function slugifyAudienceName(input: string): string;
|
|
12
|
+
//# sourceMappingURL=audience.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audience.d.ts","sourceRoot":"","sources":["../../src/schemas/audience.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,kBAAkB,aAO5B,CAAC;AAEJ,eAAO,MAAM,mBAAmB,4BAA4B,CAAC;AAE7D,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAC9D,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKzD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { HexColorSchema } from "./shared";
|
|
3
|
+
export const AudienceNameSchema = z
|
|
4
|
+
.string()
|
|
5
|
+
.min(1)
|
|
6
|
+
.max(32)
|
|
7
|
+
.regex(/^[a-z0-9]([a-z0-9_-]*[a-z0-9])?$/, "lowercase alphanumeric, dashes and underscores allowed");
|
|
8
|
+
export const AudienceColorSchema = HexColorSchema.nullable();
|
|
9
|
+
/**
|
|
10
|
+
* Convert a friendly display string into an audience slug.
|
|
11
|
+
* Lowercases, replaces non-alphanumeric runs with single dashes,
|
|
12
|
+
* strips leading/trailing dashes. Result must pass AudienceNameSchema.
|
|
13
|
+
*/
|
|
14
|
+
export function slugifyAudienceName(input) {
|
|
15
|
+
return input
|
|
16
|
+
.toLowerCase()
|
|
17
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
18
|
+
.replace(/^-+|-+$/g, "");
|
|
19
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const RoleSchema: z.ZodEnum<{
|
|
3
|
+
owner: "owner";
|
|
4
|
+
editor: "editor";
|
|
5
|
+
}>;
|
|
6
|
+
export declare const SessionSchema: z.ZodObject<{
|
|
7
|
+
userId: z.ZodNullable<z.ZodString>;
|
|
8
|
+
email: z.ZodNullable<z.ZodString>;
|
|
9
|
+
role: z.ZodEnum<{
|
|
10
|
+
owner: "owner";
|
|
11
|
+
editor: "editor";
|
|
12
|
+
}>;
|
|
13
|
+
siteId: z.ZodString;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
export declare const SiteUserSchema: z.ZodObject<{
|
|
16
|
+
id: z.ZodString;
|
|
17
|
+
email: z.ZodString;
|
|
18
|
+
role: z.ZodEnum<{
|
|
19
|
+
owner: "owner";
|
|
20
|
+
editor: "editor";
|
|
21
|
+
}>;
|
|
22
|
+
createdAt: z.ZodString;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
export declare const AudienceSchema: z.ZodObject<{
|
|
25
|
+
name: z.ZodString;
|
|
26
|
+
displayName: z.ZodString;
|
|
27
|
+
color: z.ZodNullable<z.ZodString>;
|
|
28
|
+
readonly: z.ZodBoolean;
|
|
29
|
+
hasPassword: z.ZodBoolean;
|
|
30
|
+
isDefault: z.ZodBoolean;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
export type Session = z.infer<typeof SessionSchema>;
|
|
33
|
+
export type SiteUser = z.infer<typeof SiteUserSchema>;
|
|
34
|
+
export type Audience = z.infer<typeof AudienceSchema>;
|
|
35
|
+
export type Role = z.infer<typeof RoleSchema>;
|
|
36
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/schemas/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,UAAU;;;EAA8B,CAAC;AAEtD,eAAO,MAAM,aAAa;;;;;;;;iBAKxB,CAAC;AAEH,eAAO,MAAM,cAAc;;;;;;;;iBAKzB,CAAC;AAEH,eAAO,MAAM,cAAc;;;;;;;iBAOzB,CAAC;AAEH,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AACpD,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AACtD,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AACtD,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const RoleSchema = z.enum(["owner", "editor"]);
|
|
3
|
+
export const SessionSchema = z.object({
|
|
4
|
+
userId: z.string().nullable(),
|
|
5
|
+
email: z.string().nullable(),
|
|
6
|
+
role: RoleSchema,
|
|
7
|
+
siteId: z.string(),
|
|
8
|
+
});
|
|
9
|
+
export const SiteUserSchema = z.object({
|
|
10
|
+
id: z.string(),
|
|
11
|
+
email: z.string(),
|
|
12
|
+
role: RoleSchema,
|
|
13
|
+
createdAt: z.string(),
|
|
14
|
+
});
|
|
15
|
+
export const AudienceSchema = z.object({
|
|
16
|
+
name: z.string(),
|
|
17
|
+
displayName: z.string(),
|
|
18
|
+
color: z.string().nullable(),
|
|
19
|
+
readonly: z.boolean(),
|
|
20
|
+
hasPassword: z.boolean(),
|
|
21
|
+
isDefault: z.boolean(),
|
|
22
|
+
});
|