@snowcone-app/canvas 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/LICENSE.txt +70 -0
- package/README.md +357 -0
- package/dist/CanvasStateV1-D5GzvmnY.cjs +65 -0
- package/dist/CanvasStateV1-D5GzvmnY.cjs.map +1 -0
- package/dist/CanvasStateV1-ejb4d_LM.js +3692 -0
- package/dist/CanvasStateV1-ejb4d_LM.js.map +1 -0
- package/dist/ElementFactory-B7UOaJSD.cjs +23865 -0
- package/dist/ElementFactory-B7UOaJSD.cjs.map +1 -0
- package/dist/ElementFactory-uJTXU-nP.js +29615 -0
- package/dist/ElementFactory-uJTXU-nP.js.map +1 -0
- package/dist/HybridHistoryManager-BV6XV0nD.js +8048 -0
- package/dist/HybridHistoryManager-BV6XV0nD.js.map +1 -0
- package/dist/HybridHistoryManager-BXD93pp8.cjs +8 -0
- package/dist/HybridHistoryManager-BXD93pp8.cjs.map +1 -0
- package/dist/ImportManager-BYwuK6n4.cjs +2 -0
- package/dist/ImportManager-BYwuK6n4.cjs.map +1 -0
- package/dist/ImportManager-CxiaRg1N.js +222 -0
- package/dist/ImportManager-CxiaRg1N.js.map +1 -0
- package/dist/ThemeContext-4mJ_y0Me.cjs +2 -0
- package/dist/ThemeContext-4mJ_y0Me.cjs.map +1 -0
- package/dist/ThemeContext-H0Z-MqqR.js +1077 -0
- package/dist/ThemeContext-H0Z-MqqR.js.map +1 -0
- package/dist/advanced.d.ts +2 -0
- package/dist/advanced.js +48 -0
- package/dist/advanced.js.map +1 -0
- package/dist/advanced.mjs +15679 -0
- package/dist/advanced.mjs.map +1 -0
- package/dist/api/advanced.d.ts +110 -0
- package/dist/api/internals.d.ts +39 -0
- package/dist/api/stable.d.ts +44 -0
- package/dist/api/testing.d.ts +25 -0
- package/dist/browser-module-D0gHY9rY.cjs +9 -0
- package/dist/browser-module-D0gHY9rY.cjs.map +1 -0
- package/dist/browser-module-DFvKXBUE.js +15474 -0
- package/dist/browser-module-DFvKXBUE.js.map +1 -0
- package/dist/components/ArtboardDistressPanel.d.ts +7 -0
- package/dist/components/ArtboardImageMaskPanel.d.ts +7 -0
- package/dist/components/ArtboardPropertiesToolbar.d.ts +19 -0
- package/dist/components/ArtboardToolbar.d.ts +10 -0
- package/dist/components/BackButton.d.ts +7 -0
- package/dist/components/BackgroundPickerDropdown.d.ts +11 -0
- package/dist/components/BackgroundSwitcher.d.ts +7 -0
- package/dist/components/CanvasA11yFallback.d.ts +62 -0
- package/dist/components/CanvasEditor/CanvasRendererComponent.d.ts +51 -0
- package/dist/components/CanvasEditor/handlers/cropModeHandlers.d.ts +114 -0
- package/dist/components/CanvasEditor/handlers/groupChildHandlers.d.ts +65 -0
- package/dist/components/CanvasEditor/handlers/index.d.ts +10 -0
- package/dist/components/CanvasEditor/handlers/multiSelectionHandlers.d.ts +86 -0
- package/dist/components/CanvasEditor/hooks/buildSpreadClipShape.d.ts +20 -0
- package/dist/components/CanvasEditor/hooks/index.d.ts +24 -0
- package/dist/components/CanvasEditor/hooks/useActiveChild.d.ts +23 -0
- package/dist/components/CanvasEditor/hooks/useAnimatedFocusRect.d.ts +17 -0
- package/dist/components/CanvasEditor/hooks/useCanvasInteraction.d.ts +284 -0
- package/dist/components/CanvasEditor/hooks/useCanvasLayout.d.ts +50 -0
- package/dist/components/CanvasEditor/hooks/useCanvasRenderLoop.d.ts +140 -0
- package/dist/components/CanvasEditor/hooks/useCropMode.d.ts +4 -0
- package/dist/components/CanvasEditor/hooks/useHoverState.d.ts +9 -0
- package/dist/components/CanvasEditor/hooks/useInteractionState.d.ts +23 -0
- package/dist/components/CanvasEditor/hooks/useKeyboardHandlers.d.ts +16 -0
- package/dist/components/CanvasEditor/hooks/useMarqueeSelection.d.ts +22 -0
- package/dist/components/CanvasEditor/hooks/useMultiSelection.d.ts +5 -0
- package/dist/components/CanvasEditor/hooks/usePenTool.d.ts +10 -0
- package/dist/components/CanvasEditor/hooks/useRenderState.d.ts +31 -0
- package/dist/components/CanvasEditor/hooks/useSnapAndSpacing.d.ts +42 -0
- package/dist/components/CanvasEditor/hooks/useTextEditing.d.ts +56 -0
- package/dist/components/CanvasEditor/hooks/useTextEditingHandlers.d.ts +75 -0
- package/dist/components/CanvasEditor/renderers/hoverRenderer.d.ts +12 -0
- package/dist/components/CanvasEditor/renderers/index.d.ts +10 -0
- package/dist/components/CanvasEditor/renderers/marqueeRenderer.d.ts +21 -0
- package/dist/components/CanvasEditor/renderers/multiSelectionRenderer.d.ts +52 -0
- package/dist/components/CanvasEditor/renderers/renderingConstants.d.ts +59 -0
- package/dist/components/CanvasEditor/types/index.d.ts +11 -0
- package/dist/components/CanvasEditor.d.ts +102 -0
- package/dist/components/ColorPickerDropdown.d.ts +29 -0
- package/dist/components/CompositingPanel.d.ts +8 -0
- package/dist/components/ContextualToolbars.d.ts +150 -0
- package/dist/components/CropPanel.d.ts +20 -0
- package/dist/components/DistressPanel.d.ts +7 -0
- package/dist/components/DocsPage.d.ts +6 -0
- package/dist/components/Drawer.d.ts +39 -0
- package/dist/components/EffectsPanel.d.ts +14 -0
- package/dist/components/ExportTestPanel.d.ts +16 -0
- package/dist/components/FontBrowserDrawer.d.ts +20 -0
- package/dist/components/FontSizeDropdown.d.ts +12 -0
- package/dist/components/GlyphBrowserDrawer.d.ts +13 -0
- package/dist/components/GlyphPicker.d.ts +14 -0
- package/dist/components/IconMatchTest.d.ts +3 -0
- package/dist/components/IconSizeTest.d.ts +3 -0
- package/dist/components/ImageBrowserDrawer.d.ts +27 -0
- package/dist/components/ImageToolbar.d.ts +47 -0
- package/dist/components/LayerEffects.d.ts +11 -0
- package/dist/components/LayerLeadingChip.d.ts +9 -0
- package/dist/components/LayersPanel.d.ts +30 -0
- package/dist/components/MaskItem.d.ts +12 -0
- package/dist/components/MasksPanel.d.ts +7 -0
- package/dist/components/MonotypeDemoPage.d.ts +2 -0
- package/dist/components/MoreMenu.d.ts +15 -0
- package/dist/components/OpenTypeFeaturesPanel.d.ts +12 -0
- package/dist/components/PathToolbar.d.ts +10 -0
- package/dist/components/PenToolDemo.d.ts +3 -0
- package/dist/components/ProgressiveBlur.d.ts +25 -0
- package/dist/components/RotationHandle.d.ts +47 -0
- package/dist/components/SaveLoadMenu.d.ts +15 -0
- package/dist/components/ShapeToolbar.d.ts +71 -0
- package/dist/components/ShapeTypeDrawer.d.ts +10 -0
- package/dist/components/StrokePanel.d.ts +7 -0
- package/dist/components/TailwindDemo.d.ts +3 -0
- package/dist/components/TextEffectsDropdown.d.ts +14 -0
- package/dist/components/TextToolbar.d.ts +47 -0
- package/dist/components/TextTypeDrawer.d.ts +8 -0
- package/dist/components/ThemeToggle.d.ts +2 -0
- package/dist/components/TransformControlPanel.d.ts +12 -0
- package/dist/components/VisualGuideOverlay.d.ts +156 -0
- package/dist/components/embed/ArtboardTabs.d.ts +74 -0
- package/dist/components/embed/Canvas.d.ts +72 -0
- package/dist/components/embed/EffectsPanel.d.ts +76 -0
- package/dist/components/embed/ErrorBoundary.d.ts +34 -0
- package/dist/components/embed/ExportPanel.d.ts +51 -0
- package/dist/components/embed/GlyphPanel.d.ts +70 -0
- package/dist/components/embed/ImagePanel.d.ts +58 -0
- package/dist/components/embed/LayersPanel.d.ts +13 -0
- package/dist/components/embed/LoadingStates.d.ts +32 -0
- package/dist/components/embed/MenuButton.d.ts +47 -0
- package/dist/components/embed/SnowconeCanvas.d.ts +844 -0
- package/dist/components/embed/ZoomControls.d.ts +16 -0
- package/dist/components/embed/index.d.ts +129 -0
- package/dist/components/embed/primitives/index.d.ts +42 -0
- package/dist/components/embed/ui/index.d.ts +52 -0
- package/dist/components/embed/utils/index.d.ts +31 -0
- package/dist/components/embedded/ArtboardEmbed.d.ts +70 -0
- package/dist/components/embedded/MerchifyThemeWrapper.d.ts +30 -0
- package/dist/components/embedded/ProductPreviewCard.d.ts +8 -0
- package/dist/components/embedded/index.d.ts +7 -0
- package/dist/components/primitives/ButtonGroup.d.ts +27 -0
- package/dist/components/primitives/ControlGroup.d.ts +15 -0
- package/dist/components/primitives/Dropdown.d.ts +27 -0
- package/dist/components/primitives/DropdownMenu.d.ts +9 -0
- package/dist/components/primitives/MenuItem.d.ts +13 -0
- package/dist/components/primitives/Panel.d.ts +25 -0
- package/dist/components/primitives/SecondaryToolbar.d.ts +9 -0
- package/dist/components/primitives/Switch.d.ts +10 -0
- package/dist/components/primitives/Toggle.d.ts +17 -0
- package/dist/components/primitives/index.d.ts +22 -0
- package/dist/components/stories/utils/MockEditorProvider.d.ts +32 -0
- package/dist/components/stories/utils/QACanvasCard.d.ts +41 -0
- package/dist/components/stories/utils/VisualQACard.d.ts +24 -0
- package/dist/components/stories/utils/element-factories.d.ts +188 -0
- package/dist/components/stories/utils/spec-to-elements.d.ts +74 -0
- package/dist/components/stories/utils/themeDecorator.d.ts +45 -0
- package/dist/components/stories/utils/unified-test-cases.d.ts +27 -0
- package/dist/components/text-toolbar/BoldButton.d.ts +5 -0
- package/dist/components/text-toolbar/FontColorButton.d.ts +6 -0
- package/dist/components/text-toolbar/FontSizeGroup.d.ts +5 -0
- package/dist/components/text-toolbar/ItalicButton.d.ts +5 -0
- package/dist/components/text-toolbar/TextAlignButton.d.ts +5 -0
- package/dist/components/text-toolbar/TextMoreMenu.d.ts +7 -0
- package/dist/components/text-toolbar/UnderlineButton.d.ts +5 -0
- package/dist/components/text-toolbar/UppercaseButton.d.ts +5 -0
- package/dist/components/text-toolbar/index.d.ts +25 -0
- package/dist/components/toolbars/EmbeddedToolbarLayout.d.ts +49 -0
- package/dist/components/toolbars/ExpandedPanelIcon.d.ts +13 -0
- package/dist/components/toolbars/FloatingPanels.d.ts +23 -0
- package/dist/components/toolbars/GroupElementToolbar.d.ts +35 -0
- package/dist/components/toolbars/SecondaryPanels.d.ts +125 -0
- package/dist/components/toolbars/index.d.ts +18 -0
- package/dist/components/toolbars/shared/ColorPanelWrapper.d.ts +9 -0
- package/dist/components/toolbars/shared/SecondaryPanelWrapper.d.ts +9 -0
- package/dist/components/ui/PresetCarousel.d.ts +21 -0
- package/dist/components/ui/SecondaryPanel.d.ts +28 -0
- package/dist/components/ui/SliderRow.d.ts +30 -0
- package/dist/components/ui/collapsed-toolbar-header.d.ts +14 -0
- package/dist/components/ui/custom-icons.d.ts +25 -0
- package/dist/components/ui/icons.d.ts +100 -0
- package/dist/components/ui/index.d.ts +48 -0
- package/dist/components/ui/normalized-icon.d.ts +63 -0
- package/dist/components/ui/toolbar-button.d.ts +24 -0
- package/dist/compose-Bo108juW.cjs +33 -0
- package/dist/compose-Bo108juW.cjs.map +1 -0
- package/dist/compose-DQ1FZS3O.js +7690 -0
- package/dist/compose-DQ1FZS3O.js.map +1 -0
- package/dist/constants.d.ts +121 -0
- package/dist/contexts/CommandContext.d.ts +87 -0
- package/dist/contexts/EditorContext.d.ts +190 -0
- package/dist/contexts/ElementsContext.d.ts +104 -0
- package/dist/contexts/HistoryContext.d.ts +60 -0
- package/dist/contexts/KitContext.d.ts +50 -0
- package/dist/contexts/SelectionContext.d.ts +51 -0
- package/dist/contexts/ThemeContext.d.ts +55 -0
- package/dist/contexts/ToolStateContext.d.ts +60 -0
- package/dist/contexts/ViewportContext.d.ts +87 -0
- package/dist/core/AlignmentSnapSystem.d.ts +270 -0
- package/dist/core/ArtboardElement.d.ts +106 -0
- package/dist/core/ArtboardManager.d.ts +130 -0
- package/dist/core/ArtboardRenderer.d.ts +97 -0
- package/dist/core/BaseElement.d.ts +94 -0
- package/dist/core/CanvasRenderer.d.ts +237 -0
- package/dist/core/CommandHistory.d.ts +173 -0
- package/dist/core/CoordinateTransform.d.ts +69 -0
- package/dist/core/CropModeController.d.ts +90 -0
- package/dist/core/EditModeRenderer.d.ts +51 -0
- package/dist/core/ElementFactory.d.ts +73 -0
- package/dist/core/ElementStore.d.ts +69 -0
- package/dist/core/EventBus.d.ts +163 -0
- package/dist/core/GeometryUtils.d.ts +247 -0
- package/dist/core/GroupElement.d.ts +134 -0
- package/dist/core/HoverRenderer.d.ts +103 -0
- package/dist/core/HybridHistoryManager.d.ts +137 -0
- package/dist/core/ImageCache.d.ts +63 -0
- package/dist/core/ImageElement.d.ts +226 -0
- package/dist/core/ImageLoadEvents.d.ts +23 -0
- package/dist/core/InteractionFeedbackRenderer.d.ts +15 -0
- package/dist/core/InteractionStateMachine.d.ts +199 -0
- package/dist/core/PathElement.d.ts +84 -0
- package/dist/core/PenToolManager.d.ts +112 -0
- package/dist/core/PinchHandler.d.ts +32 -0
- package/dist/core/ResizeHandler.d.ts +51 -0
- package/dist/core/ResizePipeline.d.ts +83 -0
- package/dist/core/ResizeUtils.d.ts +17 -0
- package/dist/core/RotationAnchorResolver.d.ts +60 -0
- package/dist/core/RotationUtils.d.ts +28 -0
- package/dist/core/SelectionRenderer.d.ts +24 -0
- package/dist/core/ShapeElement.d.ts +121 -0
- package/dist/core/SpacingSystem.d.ts +73 -0
- package/dist/core/SpatialGrid.d.ts +53 -0
- package/dist/core/TextElement.d.ts +80 -0
- package/dist/core/TextMetrics.d.ts +117 -0
- package/dist/core/Transform.d.ts +158 -0
- package/dist/core/TransformConverter.d.ts +16 -0
- package/dist/core/TransformHandles.d.ts +55 -0
- package/dist/core/artboardReducer.d.ts +46 -0
- package/dist/effects/DistressGenerator.d.ts +26 -0
- package/dist/effects/DistressTextureCache.d.ts +49 -0
- package/dist/effects/distress-presets.d.ts +86 -0
- package/dist/effects/distress-textures.d.ts +34 -0
- package/dist/effects/distress-utils.d.ts +39 -0
- package/dist/effects/mask-presets.d.ts +36 -0
- package/dist/fonts/google-fonts.d.ts +48 -0
- package/dist/google-fonts.json +1 -0
- package/dist/hooks/index.d.ts +42 -0
- package/dist/hooks/useArtboards.d.ts +71 -0
- package/dist/hooks/useAutoExport.d.ts +66 -0
- package/dist/hooks/useBreakpoint.d.ts +53 -0
- package/dist/hooks/useCanvasEvents.d.ts +8 -0
- package/dist/hooks/useCanvasReady.d.ts +22 -0
- package/dist/hooks/useClickOutside.d.ts +3 -0
- package/dist/hooks/useCommandHistory.d.ts +39 -0
- package/dist/hooks/useCommands.d.ts +47 -0
- package/dist/hooks/useContentReady.d.ts +18 -0
- package/dist/hooks/useElementById.d.ts +20 -0
- package/dist/hooks/useElementByName.d.ts +10 -0
- package/dist/hooks/useElementProperties.d.ts +29 -0
- package/dist/hooks/useExport.d.ts +89 -0
- package/dist/hooks/useImageBinding.d.ts +34 -0
- package/dist/hooks/useKeyboardShortcuts.d.ts +13 -0
- package/dist/hooks/useLayerDndKit.d.ts +24 -0
- package/dist/hooks/useLayerDragDrop.d.ts +58 -0
- package/dist/hooks/useLayerPreview.d.ts +31 -0
- package/dist/hooks/useLayerSelection.d.ts +76 -0
- package/dist/hooks/useLayers.d.ts +91 -0
- package/dist/hooks/usePerformance.d.ts +48 -0
- package/dist/hooks/useProjectLoader.d.ts +64 -0
- package/dist/hooks/useSelectedElement.d.ts +17 -0
- package/dist/hooks/useTextBinding.d.ts +26 -0
- package/dist/hooks/useTextToolbar.d.ts +61 -0
- package/dist/hooks/useViewport.d.ts +46 -0
- package/dist/icons/icon-data.d.ts +2 -0
- package/dist/icons/registry.d.ts +28 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1138 -0
- package/dist/index.mjs.map +1 -0
- package/dist/internals.d.ts +2 -0
- package/dist/internals.js +2 -0
- package/dist/internals.js.map +1 -0
- package/dist/internals.mjs +219 -0
- package/dist/internals.mjs.map +1 -0
- package/dist/kits/compose.d.ts +69 -0
- package/dist/kits/index.d.ts +21 -0
- package/dist/kits/presets.d.ts +40 -0
- package/dist/kits/registry.d.ts +33 -0
- package/dist/kits/sections.d.ts +119 -0
- package/dist/kits/serialization.d.ts +78 -0
- package/dist/kits/types.d.ts +129 -0
- package/dist/kits/validation.d.ts +36 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/plugins/ElementTypePlugin.d.ts +90 -0
- package/dist/presets/artboard-color-presets.d.ts +22 -0
- package/dist/presets/tshirt-presets.d.ts +60 -0
- package/dist/rendering/CompositingRenderer.d.ts +33 -0
- package/dist/rendering/DistressTextureRenderer.d.ts +39 -0
- package/dist/rendering/ElementRenderUtils.d.ts +17 -0
- package/dist/rendering/MaskRenderer.d.ts +41 -0
- package/dist/rendering/PieceGuideRenderer.d.ts +177 -0
- package/dist/rendering/StrokeRenderer.d.ts +24 -0
- package/dist/rendering/canvas-renderer.d.ts +18 -0
- package/dist/rendering/element-serializer.d.ts +143 -0
- package/dist/rendering/image-renderer.d.ts +6 -0
- package/dist/rendering/knockout-utils.d.ts +48 -0
- package/dist/rendering/mask-utils.d.ts +65 -0
- package/dist/rendering/renderer-types.d.ts +79 -0
- package/dist/rendering/rich-text-renderer.d.ts +43 -0
- package/dist/rendering/serialize-for-server.d.ts +45 -0
- package/dist/rendering/shape-renderer.d.ts +6 -0
- package/dist/rendering/stroke-utils.d.ts +18 -0
- package/dist/rendering/text-renderer.d.ts +71 -0
- package/dist/rendering/transform-renderer.d.ts +33 -0
- package/dist/services/AutoExportManager.d.ts +107 -0
- package/dist/services/falApi.d.ts +63 -0
- package/dist/services/nounProjectApi.d.ts +90 -0
- package/dist/services/recraftApi.d.ts +65 -0
- package/dist/services/runwareApi.d.ts +69 -0
- package/dist/state/CanvasStateV1.d.ts +373 -0
- package/dist/state/index.d.ts +10 -0
- package/dist/style.css +1 -0
- package/dist/taco-reference-cropped.jpg +0 -0
- package/dist/testing/MockEditorProvider.d.ts +49 -0
- package/dist/testing/index.d.ts +25 -0
- package/dist/testing/utils.d.ts +128 -0
- package/dist/testing.d.ts +2 -0
- package/dist/testing.js +2 -0
- package/dist/testing.js.map +1 -0
- package/dist/testing.mjs +140 -0
- package/dist/testing.mjs.map +1 -0
- package/dist/textures/glass-frame.svg +32 -0
- package/dist/theme.d.ts +99 -0
- package/dist/themes/index.d.ts +23 -0
- package/dist/transforms/ArchTransform.d.ts +14 -0
- package/dist/transforms/AscendTransform.d.ts +14 -0
- package/dist/transforms/CircleTransform.d.ts +51 -0
- package/dist/transforms/CustomTransform.d.ts +81 -0
- package/dist/transforms/FlagTransform.d.ts +14 -0
- package/dist/transforms/LeanTransform.d.ts +14 -0
- package/dist/transforms/WaveTransform.d.ts +16 -0
- package/dist/transforms/defaults.d.ts +33 -0
- package/dist/transforms/index.d.ts +10 -0
- package/dist/transforms/registry.d.ts +51 -0
- package/dist/types/capabilities.d.ts +50 -0
- package/dist/types/guards.d.ts +31 -0
- package/dist/types/index.d.ts +765 -0
- package/dist/types/public.d.ts +31 -0
- package/dist/types/react.d.ts +132 -0
- package/dist/utils/ArtworkPlacement.d.ts +97 -0
- package/dist/utils/ElementPreviewRenderer.d.ts +19 -0
- package/dist/utils/ExportManager.d.ts +208 -0
- package/dist/utils/FontAnalyzer.d.ts +137 -0
- package/dist/utils/GlyphRenderer.d.ts +55 -0
- package/dist/utils/GoogleFontsService.d.ts +37 -0
- package/dist/utils/ImageLoader.d.ts +124 -0
- package/dist/utils/ImportManager.d.ts +72 -0
- package/dist/utils/MonotypeCategoryMapping.d.ts +36 -0
- package/dist/utils/MonotypeService.d.ts +148 -0
- package/dist/utils/PerformanceMonitor.d.ts +54 -0
- package/dist/utils/TextureManager.d.ts +60 -0
- package/dist/utils/UnifiedFontService.d.ts +117 -0
- package/dist/utils/WorkerExportManager.d.ts +185 -0
- package/dist/utils/clickProtection.d.ts +39 -0
- package/dist/utils/cn.d.ts +4 -0
- package/dist/utils/colorConversion.d.ts +101 -0
- package/dist/utils/documentColors.d.ts +108 -0
- package/dist/utils/featureApplied.d.ts +14 -0
- package/dist/utils/google-fonts-loader.d.ts +67 -0
- package/dist/utils/logger.d.ts +66 -0
- package/dist/utils/selectionPreservation.d.ts +42 -0
- package/dist/utils/textCursorUtils.d.ts +39 -0
- package/dist/utils/textUtils.d.ts +11 -0
- package/dist/workers/export-protocol.d.ts +119 -0
- package/dist/workers/export-worker.bundle.string.d.ts +2 -0
- package/dist/workers/export-worker.d.ts +5 -0
- package/package.json +201 -0
|
@@ -0,0 +1,844 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { CanvasError, ClipShape, AnyElementConfig } from '../../types/index.js';
|
|
3
|
+
import { KitPresetId, KitDefinition } from '../../kits/types.js';
|
|
4
|
+
import { PieceGuide, PieceGuideRendererPiece, PieceGuideRendererStyle, PieceGuideVisibility } from '../../rendering/PieceGuideRenderer.js';
|
|
5
|
+
export type { ClipShape } from '../../types/index.js';
|
|
6
|
+
/** 9-point alignment grid values */
|
|
7
|
+
export type AlignmentPoint = 'tl' | 't' | 'tr' | 'l' | 'c' | 'r' | 'bl' | 'b' | 'br' | 'center' | 'top' | 'bottom' | 'left' | 'right';
|
|
8
|
+
/** Events emitted during the export lifecycle */
|
|
9
|
+
export type ExportStatusEvent = {
|
|
10
|
+
status: 'scheduled';
|
|
11
|
+
artboardId: string;
|
|
12
|
+
} | {
|
|
13
|
+
status: 'rendering';
|
|
14
|
+
artboardId: string;
|
|
15
|
+
} | {
|
|
16
|
+
status: 'complete';
|
|
17
|
+
artboardId: string;
|
|
18
|
+
result: Record<string, string | Blob>;
|
|
19
|
+
} | {
|
|
20
|
+
status: 'error';
|
|
21
|
+
artboardId: string;
|
|
22
|
+
error: Error;
|
|
23
|
+
};
|
|
24
|
+
export interface ArtboardConfig {
|
|
25
|
+
/** Display name for the artboard (used as key in export results) */
|
|
26
|
+
name: string;
|
|
27
|
+
/** Width in pixels */
|
|
28
|
+
width: number;
|
|
29
|
+
/** Height in pixels */
|
|
30
|
+
height: number;
|
|
31
|
+
/** Optional clip shape for content masking */
|
|
32
|
+
clipShape?: ClipShape;
|
|
33
|
+
/** Optional background color */
|
|
34
|
+
backgroundColor?: string;
|
|
35
|
+
/** Scale mode for initial image: "cover" fills area (may crop), "contain" fits inside (may have space). Default: "cover" */
|
|
36
|
+
scaleMode?: 'cover' | 'contain';
|
|
37
|
+
/** Top margin in pixels for contain mode (reduces available area) */
|
|
38
|
+
fitMarginTop?: number;
|
|
39
|
+
/** Right margin in pixels for contain mode (reduces available area) */
|
|
40
|
+
fitMarginRight?: number;
|
|
41
|
+
/** Bottom margin in pixels for contain mode (reduces available area) */
|
|
42
|
+
fitMarginBottom?: number;
|
|
43
|
+
/** Left margin in pixels for contain mode (reduces available area) */
|
|
44
|
+
fitMarginLeft?: number;
|
|
45
|
+
/** Alignment override for contain mode (9-point grid: 'tl','t','tr','l','c','r','bl','b','br') */
|
|
46
|
+
fitAlign?: AlignmentPoint;
|
|
47
|
+
}
|
|
48
|
+
export interface CanvasState {
|
|
49
|
+
/** Serialized element configurations for persistence */
|
|
50
|
+
elements: AnyElementConfig[];
|
|
51
|
+
/** Artboard configurations */
|
|
52
|
+
artboards: ArtboardConfig[];
|
|
53
|
+
/** Currently active artboard name */
|
|
54
|
+
activeArtboard: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Imperative handle for programmatic control of SnowconeCanvas
|
|
58
|
+
*/
|
|
59
|
+
export interface SnowconeCanvasHandle {
|
|
60
|
+
/**
|
|
61
|
+
* Trigger an export of artboards programmatically.
|
|
62
|
+
* Returns a promise that resolves with the exported artboards.
|
|
63
|
+
*
|
|
64
|
+
* @param options Export options
|
|
65
|
+
* @returns Promise resolving to exported artboards keyed by name
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* const canvasRef = useRef<SnowconeCanvasHandle>(null);
|
|
69
|
+
* const handleExport = async () => {
|
|
70
|
+
* const exports = await canvasRef.current?.exportArtboards();
|
|
71
|
+
* console.log('Exported:', exports);
|
|
72
|
+
* };
|
|
73
|
+
*/
|
|
74
|
+
exportArtboards: (options?: {
|
|
75
|
+
/** Export format */
|
|
76
|
+
format?: 'dataUrl' | 'blob';
|
|
77
|
+
/** Resolution multiplier */
|
|
78
|
+
scale?: number;
|
|
79
|
+
/** Export all artboards or just active */
|
|
80
|
+
all?: boolean;
|
|
81
|
+
}) => Promise<Record<string, string | Blob>>;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Configuration for export behavior (scale, format, auto-export).
|
|
85
|
+
*
|
|
86
|
+
* Group these props together instead of passing them individually:
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```tsx
|
|
90
|
+
* <SnowconeCanvas
|
|
91
|
+
* exportConfig={{
|
|
92
|
+
* autoExportConfig: { enabled: true, debounceMs: 100, maxWaitMs: 1000 },
|
|
93
|
+
* format: 'blob',
|
|
94
|
+
* exportAll: true,
|
|
95
|
+
* scale: 2,
|
|
96
|
+
* maxSize: 4000,
|
|
97
|
+
* imageFormat: 'webp',
|
|
98
|
+
* imageQuality: 0.85,
|
|
99
|
+
* }}
|
|
100
|
+
* onExportStatus={(event) => { ... }}
|
|
101
|
+
* />
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
export interface ExportConfig {
|
|
105
|
+
/**
|
|
106
|
+
* Smart auto-export configuration with debouncing and change detection.
|
|
107
|
+
* Replaces the timer-based `autoExportInterval` with an event-driven approach.
|
|
108
|
+
*/
|
|
109
|
+
autoExportConfig?: {
|
|
110
|
+
/** Enable/disable auto-export */
|
|
111
|
+
enabled?: boolean;
|
|
112
|
+
/** Debounce delay - wait this long after last change before exporting (ms) */
|
|
113
|
+
debounceMs?: number;
|
|
114
|
+
/** Maximum wait time - force export after this duration even if changes keep coming (ms) */
|
|
115
|
+
maxWaitMs?: number;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Export format: 'dataUrl' (base64 string) or 'blob' (binary).
|
|
119
|
+
* Blob is more efficient for API uploads.
|
|
120
|
+
*/
|
|
121
|
+
format?: 'dataUrl' | 'blob';
|
|
122
|
+
/**
|
|
123
|
+
* If true, exports all artboards on each interval.
|
|
124
|
+
* If false, only exports the active artboard.
|
|
125
|
+
*/
|
|
126
|
+
exportAll?: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Resolution multiplier for exports.
|
|
129
|
+
* Default: 2 (recommended for print quality).
|
|
130
|
+
*
|
|
131
|
+
* Note: This scale is applied intelligently - if the resulting image would
|
|
132
|
+
* exceed `maxSize`, the scale is reduced to cap the largest dimension.
|
|
133
|
+
*/
|
|
134
|
+
scale?: number;
|
|
135
|
+
/**
|
|
136
|
+
* Maximum export dimension (largest side) in pixels.
|
|
137
|
+
* Default: 4000 (4K).
|
|
138
|
+
*
|
|
139
|
+
* When the artboard dimensions multiplied by scale would exceed this,
|
|
140
|
+
* the effective scale is reduced to cap the output at this size.
|
|
141
|
+
* Set to 0 or Infinity to disable this capping behavior.
|
|
142
|
+
*/
|
|
143
|
+
maxSize?: number;
|
|
144
|
+
/**
|
|
145
|
+
* Image format for auto-exports.
|
|
146
|
+
* Default: 'png'.
|
|
147
|
+
* Use 'webp' for smaller file sizes with transparency support (good for realtime preview).
|
|
148
|
+
*/
|
|
149
|
+
imageFormat?: 'png' | 'jpg' | 'jpeg' | 'webp';
|
|
150
|
+
/**
|
|
151
|
+
* Image quality for auto-exports (0-1).
|
|
152
|
+
* Only applies to JPEG and WebP formats. PNG ignores this.
|
|
153
|
+
* Default: 0.92.
|
|
154
|
+
*/
|
|
155
|
+
imageQuality?: number;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Configuration for the initial image loaded into the canvas.
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* ```tsx
|
|
162
|
+
* <SnowconeCanvas
|
|
163
|
+
* imageConfig={{
|
|
164
|
+
* src: 'https://example.com/artwork.png',
|
|
165
|
+
* alignment: 'center',
|
|
166
|
+
* scale: 1.2,
|
|
167
|
+
* scaleMode: 'contain',
|
|
168
|
+
* }}
|
|
169
|
+
* />
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
export interface ImageConfig {
|
|
173
|
+
/**
|
|
174
|
+
* URL of initial image to load into the canvas.
|
|
175
|
+
* Shows loading state while fetching, error state on failure.
|
|
176
|
+
*/
|
|
177
|
+
src?: string;
|
|
178
|
+
/**
|
|
179
|
+
* Alignment for the initial image on the artboard.
|
|
180
|
+
* Uses a 9-point grid: 'tl', 't', 'tr', 'l', 'c', 'r', 'bl', 'b', 'br'
|
|
181
|
+
* Or semantic values: 'center', 'top', 'bottom', 'left', 'right'
|
|
182
|
+
* Default: 'center'
|
|
183
|
+
*/
|
|
184
|
+
alignment?: AlignmentPoint;
|
|
185
|
+
/**
|
|
186
|
+
* Scale multiplier for the initial image.
|
|
187
|
+
* Default: 1 (image covers artboard exactly)
|
|
188
|
+
* Values > 1 make the image larger, < 1 make it smaller.
|
|
189
|
+
*/
|
|
190
|
+
scale?: number;
|
|
191
|
+
/**
|
|
192
|
+
* Scale mode for initial image placement.
|
|
193
|
+
* - "cover" (default): image fills artboard completely, may crop edges
|
|
194
|
+
* - "contain": image fits entirely inside artboard, may have empty space
|
|
195
|
+
*/
|
|
196
|
+
scaleMode?: 'cover' | 'contain';
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Configuration for layout and visual appearance of the canvas.
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* ```tsx
|
|
203
|
+
* <SnowconeCanvas
|
|
204
|
+
* layoutConfig={{
|
|
205
|
+
* width: 1200,
|
|
206
|
+
* height: 1200,
|
|
207
|
+
* viewPadding: 0.85,
|
|
208
|
+
* artboardBorderRadius: 12,
|
|
209
|
+
* showToolbar: false,
|
|
210
|
+
* showLayers: false,
|
|
211
|
+
* }}
|
|
212
|
+
* />
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
export interface LayoutConfig {
|
|
216
|
+
/**
|
|
217
|
+
* Artboard width (shorthand for single artboard).
|
|
218
|
+
* If `artboards` prop is provided, this is ignored.
|
|
219
|
+
*/
|
|
220
|
+
width?: number;
|
|
221
|
+
/**
|
|
222
|
+
* Artboard height (shorthand for single artboard).
|
|
223
|
+
* If `artboards` prop is provided, this is ignored.
|
|
224
|
+
*/
|
|
225
|
+
height?: number;
|
|
226
|
+
/**
|
|
227
|
+
* Controls how much of the container the artboard fills.
|
|
228
|
+
* Value between 0 and 1, where 1 means the artboard fills 100% of the container.
|
|
229
|
+
* Default is 0.9 (90%).
|
|
230
|
+
*/
|
|
231
|
+
viewPadding?: number;
|
|
232
|
+
/**
|
|
233
|
+
* Border radius for artboard corners in pixels.
|
|
234
|
+
* This is a visual-only effect - exports will still have the full artboard.
|
|
235
|
+
* @default 0
|
|
236
|
+
*/
|
|
237
|
+
artboardBorderRadius?: number;
|
|
238
|
+
/**
|
|
239
|
+
* Fixed screen-space margin in pixels.
|
|
240
|
+
* When set, the artboard will have this exact left/top margin regardless of zoom level.
|
|
241
|
+
* Overrides viewPadding for positioning.
|
|
242
|
+
*/
|
|
243
|
+
fixedMargin?: number;
|
|
244
|
+
/**
|
|
245
|
+
* Maximum HTML height in pixels.
|
|
246
|
+
* When the artboard (with vertical fixedMargin padding) would exceed this height,
|
|
247
|
+
* horizontal padding is increased to shrink the artboard until it fits.
|
|
248
|
+
*/
|
|
249
|
+
maxHeight?: number;
|
|
250
|
+
/**
|
|
251
|
+
* Show toolbar UI.
|
|
252
|
+
* Default: false (canvas-only mode).
|
|
253
|
+
*/
|
|
254
|
+
showToolbar?: boolean;
|
|
255
|
+
/**
|
|
256
|
+
* Show layers panel.
|
|
257
|
+
* Default: false (canvas-only mode).
|
|
258
|
+
*/
|
|
259
|
+
showLayers?: boolean;
|
|
260
|
+
/**
|
|
261
|
+
* Whether to show the rotation handle on the canvas.
|
|
262
|
+
* Set to false for embedded mode where rotation is handled via toolbar panel.
|
|
263
|
+
* @default true
|
|
264
|
+
*/
|
|
265
|
+
showRotationHandle?: boolean;
|
|
266
|
+
/**
|
|
267
|
+
* When true, hides the internal Canvas component.
|
|
268
|
+
* Use this when rendering a separate Canvas (e.g., in fullscreen mode)
|
|
269
|
+
* that shares the same EditorProvider context.
|
|
270
|
+
*/
|
|
271
|
+
hideCanvas?: boolean;
|
|
272
|
+
/**
|
|
273
|
+
* CSS class name for the canvas wrapper element.
|
|
274
|
+
*/
|
|
275
|
+
canvasWrapperClassName?: string;
|
|
276
|
+
/**
|
|
277
|
+
* Inline styles for the canvas wrapper element.
|
|
278
|
+
*/
|
|
279
|
+
canvasWrapperStyle?: React.CSSProperties;
|
|
280
|
+
/**
|
|
281
|
+
* ADR-0054 Phase 4: cutout shapes (in artboard-space px) that get
|
|
282
|
+
* punched through the `<canvas>` element as truly transparent holes,
|
|
283
|
+
* revealing whatever sits behind SnowconeCanvas in the DOM. Internally
|
|
284
|
+
* translated to a CSS `clip-path: path(evenodd, ...)` that accounts
|
|
285
|
+
* for the canvas's padding margin and zoom. Each shape is a rect,
|
|
286
|
+
* rounded rect, or SVG path — the same `SvgPath` shape used by the
|
|
287
|
+
* `VisualGuideOverlay`.
|
|
288
|
+
*/
|
|
289
|
+
canvasCutouts?: CanvasCutoutShape[];
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* ADR-0054: piece-guide config passed to `SnowconeCanvas`. The render
|
|
293
|
+
* loop calls `renderPieceGuides` with these values after drawing the
|
|
294
|
+
* artboard and its elements, so boundary/zone/label coordinates are in
|
|
295
|
+
* the artboard's local pixel frame and compose cleanly with the canvas
|
|
296
|
+
* viewport transform.
|
|
297
|
+
*/
|
|
298
|
+
export interface PieceGuidesConfig {
|
|
299
|
+
/** Pieces (artboard-space rects) the guides attach to. */
|
|
300
|
+
pieces: PieceGuideRendererPiece[];
|
|
301
|
+
/** Authored guides keyed by piece id. Pieces without a guide fall back to the piece rect. */
|
|
302
|
+
guides?: Record<string, PieceGuide>;
|
|
303
|
+
/** Per-layer visibility toggles. All default to true. */
|
|
304
|
+
show?: PieceGuideVisibility;
|
|
305
|
+
/** Optional style overrides. */
|
|
306
|
+
style?: PieceGuideRendererStyle;
|
|
307
|
+
}
|
|
308
|
+
/** ADR-0054 Phase 4: shape union used for `canvasCutouts`. Mirrors the
|
|
309
|
+
* `SvgPath` shape in `VisualGuideOverlay`. Coordinates are in artboard
|
|
310
|
+
* pixel units (the canvas's intrinsic/native size). */
|
|
311
|
+
export type CanvasCutoutShape = {
|
|
312
|
+
kind: "rect";
|
|
313
|
+
x: number;
|
|
314
|
+
y: number;
|
|
315
|
+
width: number;
|
|
316
|
+
height: number;
|
|
317
|
+
} | {
|
|
318
|
+
kind: "roundedRect";
|
|
319
|
+
x: number;
|
|
320
|
+
y: number;
|
|
321
|
+
width: number;
|
|
322
|
+
height: number;
|
|
323
|
+
rx?: number;
|
|
324
|
+
ry?: number;
|
|
325
|
+
} | {
|
|
326
|
+
kind: "path";
|
|
327
|
+
d: string;
|
|
328
|
+
};
|
|
329
|
+
/**
|
|
330
|
+
* Props for the SnowconeCanvas component.
|
|
331
|
+
*
|
|
332
|
+
* Props can be passed individually (flat) or grouped using config objects.
|
|
333
|
+
* When both are provided, individual props take precedence over config values.
|
|
334
|
+
*
|
|
335
|
+
* @example Grouped config pattern (recommended for new code)
|
|
336
|
+
* ```tsx
|
|
337
|
+
* <SnowconeCanvas
|
|
338
|
+
* artboards={[{ name: 'Front', width: 1200, height: 1200 }]}
|
|
339
|
+
* imageConfig={{
|
|
340
|
+
* src: 'https://example.com/artwork.png',
|
|
341
|
+
* alignment: 'center',
|
|
342
|
+
* scaleMode: 'contain',
|
|
343
|
+
* }}
|
|
344
|
+
* exportConfig={{
|
|
345
|
+
* autoExportConfig: { enabled: true, debounceMs: 100 },
|
|
346
|
+
* format: 'blob',
|
|
347
|
+
* scale: 2,
|
|
348
|
+
* imageFormat: 'webp',
|
|
349
|
+
* }}
|
|
350
|
+
* layoutConfig={{
|
|
351
|
+
* viewPadding: 0.85,
|
|
352
|
+
* artboardBorderRadius: 12,
|
|
353
|
+
* showRotationHandle: false,
|
|
354
|
+
* }}
|
|
355
|
+
* onExportStatus={(event) => { ... }}
|
|
356
|
+
* />
|
|
357
|
+
* ```
|
|
358
|
+
*
|
|
359
|
+
* @example Flat props (backwards compatible, still fully supported)
|
|
360
|
+
* ```tsx
|
|
361
|
+
* <SnowconeCanvas
|
|
362
|
+
* artboards={[{ name: 'Front', width: 1200, height: 1200 }]}
|
|
363
|
+
* initialImage="https://example.com/artwork.png"
|
|
364
|
+
* autoExportConfig={{ enabled: true, debounceMs: 100 }}
|
|
365
|
+
* autoExportFormat="blob"
|
|
366
|
+
* exportScale={2}
|
|
367
|
+
* viewPadding={0.85}
|
|
368
|
+
* onExportStatus={(event) => { ... }}
|
|
369
|
+
* />
|
|
370
|
+
* ```
|
|
371
|
+
*/
|
|
372
|
+
export interface SnowconeCanvasProps {
|
|
373
|
+
/**
|
|
374
|
+
* Grouped export configuration. See {@link ExportConfig}.
|
|
375
|
+
* Individual export props (autoExportConfig, autoExportFormat, etc.) take precedence if also provided.
|
|
376
|
+
*/
|
|
377
|
+
exportConfig?: ExportConfig;
|
|
378
|
+
/**
|
|
379
|
+
* Grouped initial image configuration. See {@link ImageConfig}.
|
|
380
|
+
* Individual image props (initialImage, initialImageAlignment, etc.) take precedence if also provided.
|
|
381
|
+
*/
|
|
382
|
+
imageConfig?: ImageConfig;
|
|
383
|
+
/**
|
|
384
|
+
* Grouped layout/appearance configuration. See {@link LayoutConfig}.
|
|
385
|
+
* Individual layout props (width, height, viewPadding, etc.) take precedence if also provided.
|
|
386
|
+
*/
|
|
387
|
+
layoutConfig?: LayoutConfig;
|
|
388
|
+
/**
|
|
389
|
+
* Editor kit configuration. Use a preset name ('compact-customizer', 'pro-studio', 'embed-only')
|
|
390
|
+
* or a custom KitDefinition for full control over layout, capabilities, and behavior.
|
|
391
|
+
* @default 'pro-studio'
|
|
392
|
+
*/
|
|
393
|
+
kit?: KitPresetId | KitDefinition;
|
|
394
|
+
/**
|
|
395
|
+
* Array of artboard configurations.
|
|
396
|
+
* Each artboard represents a placement area (e.g., 'Front', 'Back').
|
|
397
|
+
*/
|
|
398
|
+
artboards?: ArtboardConfig[];
|
|
399
|
+
/**
|
|
400
|
+
* Currently active artboard by name.
|
|
401
|
+
* Used for controlled artboard selection.
|
|
402
|
+
*/
|
|
403
|
+
activeArtboard?: string;
|
|
404
|
+
/**
|
|
405
|
+
* Callback when user switches artboards.
|
|
406
|
+
* Receives the name of the newly active artboard.
|
|
407
|
+
*/
|
|
408
|
+
onArtboardChange?: (name: string) => void;
|
|
409
|
+
/**
|
|
410
|
+
* Artboard width (shorthand for single artboard).
|
|
411
|
+
* If `artboards` prop is provided, this is ignored.
|
|
412
|
+
* @deprecated Use `layoutConfig.width` instead.
|
|
413
|
+
*/
|
|
414
|
+
width?: number;
|
|
415
|
+
/**
|
|
416
|
+
* Artboard height (shorthand for single artboard).
|
|
417
|
+
* If `artboards` prop is provided, this is ignored.
|
|
418
|
+
* @deprecated Use `layoutConfig.height` instead.
|
|
419
|
+
*/
|
|
420
|
+
height?: number;
|
|
421
|
+
/**
|
|
422
|
+
* URL of initial image to load into the canvas.
|
|
423
|
+
* Shows loading state while fetching, error state on failure.
|
|
424
|
+
*
|
|
425
|
+
* The image will be sized to "cover" the artboard (like CSS object-fit: cover)
|
|
426
|
+
* and positioned according to `initialImageAlignment`.
|
|
427
|
+
* @deprecated Use `imageConfig.src` instead.
|
|
428
|
+
*/
|
|
429
|
+
initialImage?: string;
|
|
430
|
+
/**
|
|
431
|
+
* Alignment for the initial image on the artboard.
|
|
432
|
+
* Uses a 9-point grid: 'tl', 't', 'tr', 'l', 'c', 'r', 'bl', 'b', 'br'
|
|
433
|
+
* Or semantic values: 'center', 'top', 'bottom', 'left', 'right'
|
|
434
|
+
*
|
|
435
|
+
* Default: 'center' (places image centered on artboard)
|
|
436
|
+
* @deprecated Use `imageConfig.alignment` instead.
|
|
437
|
+
*/
|
|
438
|
+
initialImageAlignment?: AlignmentPoint;
|
|
439
|
+
/**
|
|
440
|
+
* Scale multiplier for the initial image.
|
|
441
|
+
* Default: 1 (image covers artboard exactly)
|
|
442
|
+
* Values > 1 make the image larger, < 1 make it smaller.
|
|
443
|
+
* @deprecated Use `imageConfig.scale` instead.
|
|
444
|
+
*/
|
|
445
|
+
initialImageScale?: number;
|
|
446
|
+
/**
|
|
447
|
+
* Scale mode for initial image placement.
|
|
448
|
+
* - "cover" (default): image fills artboard completely, may crop edges
|
|
449
|
+
* - "contain": image fits entirely inside artboard, may have empty space
|
|
450
|
+
* @deprecated Use `imageConfig.scaleMode` instead.
|
|
451
|
+
*/
|
|
452
|
+
initialImageScaleMode?: 'cover' | 'contain';
|
|
453
|
+
/**
|
|
454
|
+
* Serialized element configurations for restoring saved state.
|
|
455
|
+
* Use this to restore a previously saved design.
|
|
456
|
+
*/
|
|
457
|
+
initialElements?: AnyElementConfig[];
|
|
458
|
+
/**
|
|
459
|
+
* Called when canvas content changes (elements added, modified, or removed).
|
|
460
|
+
* Use this to persist the design state.
|
|
461
|
+
*/
|
|
462
|
+
onChange?: (state: CanvasState) => void;
|
|
463
|
+
/**
|
|
464
|
+
* Called when selection changes.
|
|
465
|
+
* Receives null when nothing is selected.
|
|
466
|
+
*/
|
|
467
|
+
onSelectionChange?: (elementId: string | null) => void;
|
|
468
|
+
/**
|
|
469
|
+
* Interval in milliseconds for automatic exports.
|
|
470
|
+
* Set to 0 or undefined to disable auto-export.
|
|
471
|
+
* Recommended: 500ms for responsive preview updates.
|
|
472
|
+
*
|
|
473
|
+
* @deprecated Use `autoExportConfig` or `exportConfig.autoExportConfig` instead, which provides smart debouncing and change detection rather than fixed-interval polling.
|
|
474
|
+
*/
|
|
475
|
+
autoExportInterval?: number;
|
|
476
|
+
/**
|
|
477
|
+
* Smart auto-export configuration with debouncing and change detection.
|
|
478
|
+
* Replaces the timer-based `autoExportInterval` with an event-driven approach.
|
|
479
|
+
* @deprecated Use `exportConfig.autoExportConfig` instead.
|
|
480
|
+
*
|
|
481
|
+
* @example
|
|
482
|
+
* ```tsx
|
|
483
|
+
* <SnowconeCanvas
|
|
484
|
+
* autoExportConfig={{
|
|
485
|
+
* enabled: true,
|
|
486
|
+
* debounceMs: 100, // Wait 100ms after last change
|
|
487
|
+
* maxWaitMs: 1000, // Force export after 1s of continuous changes
|
|
488
|
+
* }}
|
|
489
|
+
* onExport={(exports) => console.log('Exported:', exports)}
|
|
490
|
+
* />
|
|
491
|
+
* ```
|
|
492
|
+
*/
|
|
493
|
+
autoExportConfig?: {
|
|
494
|
+
/** Enable/disable auto-export */
|
|
495
|
+
enabled?: boolean;
|
|
496
|
+
/** Debounce delay - wait this long after last change before exporting (ms) */
|
|
497
|
+
debounceMs?: number;
|
|
498
|
+
/** Maximum wait time - force export after this duration even if changes keep coming (ms) */
|
|
499
|
+
maxWaitMs?: number;
|
|
500
|
+
};
|
|
501
|
+
/**
|
|
502
|
+
* Export format: 'dataUrl' (base64 string) or 'blob' (binary).
|
|
503
|
+
* Blob is more efficient for API uploads.
|
|
504
|
+
* @deprecated Use `exportConfig.format` instead.
|
|
505
|
+
*/
|
|
506
|
+
autoExportFormat?: 'dataUrl' | 'blob';
|
|
507
|
+
/**
|
|
508
|
+
* If true, exports all artboards on each interval.
|
|
509
|
+
* If false, only exports the active artboard.
|
|
510
|
+
* @deprecated Use `exportConfig.exportAll` instead.
|
|
511
|
+
*/
|
|
512
|
+
autoExportAll?: boolean;
|
|
513
|
+
/**
|
|
514
|
+
* Resolution multiplier for exports.
|
|
515
|
+
* Default: 2 (recommended for print quality).
|
|
516
|
+
*
|
|
517
|
+
* Note: This scale is applied intelligently - if the resulting image would
|
|
518
|
+
* exceed `maxExportSize`, the scale is reduced to cap the largest dimension.
|
|
519
|
+
* @deprecated Use `exportConfig.scale` instead.
|
|
520
|
+
*/
|
|
521
|
+
exportScale?: number;
|
|
522
|
+
/**
|
|
523
|
+
* Maximum export dimension (largest side) in pixels.
|
|
524
|
+
* Default: 4000 (4K).
|
|
525
|
+
*
|
|
526
|
+
* When the artboard dimensions multiplied by exportScale would exceed this,
|
|
527
|
+
* the effective scale is reduced to cap the output at this size.
|
|
528
|
+
*
|
|
529
|
+
* For example:
|
|
530
|
+
* - Artboard 3951x4800 with exportScale=2 would normally be 7902x9600
|
|
531
|
+
* - With maxExportSize=4000, it stays at 3951x4800 (scale effectively 1)
|
|
532
|
+
* - Artboard 1200x1200 with exportScale=2 becomes 2400x2400 (under limit)
|
|
533
|
+
*
|
|
534
|
+
* Set to 0 or Infinity to disable this capping behavior.
|
|
535
|
+
* @deprecated Use `exportConfig.maxSize` instead.
|
|
536
|
+
*/
|
|
537
|
+
maxExportSize?: number;
|
|
538
|
+
/**
|
|
539
|
+
* Image format for auto-exports.
|
|
540
|
+
* Default: 'png'.
|
|
541
|
+
* Use 'webp' for smaller file sizes with transparency support (good for realtime preview).
|
|
542
|
+
* @deprecated Use `exportConfig.imageFormat` instead.
|
|
543
|
+
*/
|
|
544
|
+
exportImageFormat?: 'png' | 'jpg' | 'jpeg' | 'webp';
|
|
545
|
+
/**
|
|
546
|
+
* Image quality for auto-exports (0-1).
|
|
547
|
+
* Only applies to JPEG and WebP formats. PNG ignores this.
|
|
548
|
+
* Default: 0.92.
|
|
549
|
+
* @deprecated Use `exportConfig.imageQuality` instead.
|
|
550
|
+
*/
|
|
551
|
+
exportImageQuality?: number;
|
|
552
|
+
/**
|
|
553
|
+
* Called with export results.
|
|
554
|
+
* Results are keyed by artboard name.
|
|
555
|
+
*
|
|
556
|
+
* @deprecated Use `onExportStatus` for a unified export lifecycle callback, or `onExportReady` for on-demand export control.
|
|
557
|
+
*/
|
|
558
|
+
onExport?: (exports: Record<string, string | Blob>) => void;
|
|
559
|
+
/**
|
|
560
|
+
* Called immediately when an export is scheduled (before debounce).
|
|
561
|
+
* Use this to show loading indicators right away instead of waiting for export to complete.
|
|
562
|
+
* This fires as soon as a change is detected, giving consumers early warning.
|
|
563
|
+
*
|
|
564
|
+
* @deprecated Use `onExportStatus` instead, which provides `{ status: 'scheduled' }` events along with the full export lifecycle.
|
|
565
|
+
*
|
|
566
|
+
* @example
|
|
567
|
+
* ```tsx
|
|
568
|
+
* <SnowconeCanvas
|
|
569
|
+
* onExportScheduled={() => {
|
|
570
|
+
* // Show shimmer/loading immediately
|
|
571
|
+
* setIsExporting(true);
|
|
572
|
+
* }}
|
|
573
|
+
* onExport={(exports) => {
|
|
574
|
+
* // Hide shimmer after export completes
|
|
575
|
+
* setIsExporting(false);
|
|
576
|
+
* }}
|
|
577
|
+
* />
|
|
578
|
+
* ```
|
|
579
|
+
*/
|
|
580
|
+
onExportScheduled?: () => void;
|
|
581
|
+
/**
|
|
582
|
+
* Unified export status callback. Prefer this over individual `onExport`/`onExportScheduled` callbacks.
|
|
583
|
+
*
|
|
584
|
+
* Receives events for each phase of the export lifecycle:
|
|
585
|
+
* - `scheduled` - Export was requested (before debounce completes)
|
|
586
|
+
* - `rendering` - Export rendering has started
|
|
587
|
+
* - `complete` - Export finished successfully with results
|
|
588
|
+
* - `error` - Export failed with an error
|
|
589
|
+
*
|
|
590
|
+
* @example
|
|
591
|
+
* ```tsx
|
|
592
|
+
* <SnowconeCanvas
|
|
593
|
+
* onExportStatus={(event) => {
|
|
594
|
+
* switch (event.status) {
|
|
595
|
+
* case 'scheduled':
|
|
596
|
+
* setIsExporting(true);
|
|
597
|
+
* break;
|
|
598
|
+
* case 'complete':
|
|
599
|
+
* setIsExporting(false);
|
|
600
|
+
* uploadResults(event.result);
|
|
601
|
+
* break;
|
|
602
|
+
* case 'error':
|
|
603
|
+
* setIsExporting(false);
|
|
604
|
+
* showError(event.error);
|
|
605
|
+
* break;
|
|
606
|
+
* }
|
|
607
|
+
* }}
|
|
608
|
+
* />
|
|
609
|
+
* ```
|
|
610
|
+
*/
|
|
611
|
+
onExportStatus?: (event: ExportStatusEvent) => void;
|
|
612
|
+
/**
|
|
613
|
+
* Callback that provides an export function.
|
|
614
|
+
* Called once when the canvas is ready.
|
|
615
|
+
* Use this for manual/on-demand exports triggered by UI buttons.
|
|
616
|
+
*
|
|
617
|
+
* @example
|
|
618
|
+
* ```tsx
|
|
619
|
+
* const [exportFn, setExportFn] = useState<(() => Promise<Record<string, string | Blob>>) | null>(null);
|
|
620
|
+
*
|
|
621
|
+
* <SnowconeCanvas
|
|
622
|
+
* onExportReady={(fn) => setExportFn(() => fn)}
|
|
623
|
+
* ...
|
|
624
|
+
* />
|
|
625
|
+
*
|
|
626
|
+
* <button onClick={() => exportFn?.()}>Export</button>
|
|
627
|
+
* ```
|
|
628
|
+
*/
|
|
629
|
+
onExportReady?: (exportFn: () => Promise<Record<string, string | Blob>>) => void;
|
|
630
|
+
/**
|
|
631
|
+
* Called when initialImage loads successfully.
|
|
632
|
+
*/
|
|
633
|
+
onImageLoad?: (src: string) => void;
|
|
634
|
+
/**
|
|
635
|
+
* Called when initialImage fails to load.
|
|
636
|
+
*/
|
|
637
|
+
onImageError?: (src: string, error: Error) => void;
|
|
638
|
+
/**
|
|
639
|
+
* General error callback for recoverable and non-recoverable canvas errors.
|
|
640
|
+
* Receives a structured CanvasError with category, message, and context.
|
|
641
|
+
*
|
|
642
|
+
* This fires for:
|
|
643
|
+
* - Image loading failures (category: 'image')
|
|
644
|
+
* - Export errors (category: 'export')
|
|
645
|
+
* - Element import/deserialization errors (category: 'import')
|
|
646
|
+
* - Unexpected React crashes caught by ErrorBoundary (category: 'unknown')
|
|
647
|
+
*
|
|
648
|
+
* Existing `onExportStatus` and `onImageError` callbacks continue to work.
|
|
649
|
+
* `onError` provides a unified stream of all errors for logging/analytics.
|
|
650
|
+
*
|
|
651
|
+
* @example
|
|
652
|
+
* ```tsx
|
|
653
|
+
* <SnowconeCanvas
|
|
654
|
+
* onError={(error) => {
|
|
655
|
+
* console.error(`[${error.category}] ${error.message}`);
|
|
656
|
+
* if (!error.recoverable) {
|
|
657
|
+
* analytics.track('canvas_crash', { category: error.category });
|
|
658
|
+
* }
|
|
659
|
+
* }}
|
|
660
|
+
* />
|
|
661
|
+
* ```
|
|
662
|
+
*/
|
|
663
|
+
onError?: (error: CanvasError) => void;
|
|
664
|
+
/**
|
|
665
|
+
* Theme name (reserved for future use).
|
|
666
|
+
*/
|
|
667
|
+
theme?: string;
|
|
668
|
+
/**
|
|
669
|
+
* When true, skips the internal ThemeProvider and inherits theme from parent.
|
|
670
|
+
* Use this when embedding SnowconeCanvas in an app that already manages themes.
|
|
671
|
+
* This prevents the canvas from overriding the parent app's theme on document.documentElement.
|
|
672
|
+
*
|
|
673
|
+
* @default false
|
|
674
|
+
*/
|
|
675
|
+
inheritTheme?: boolean;
|
|
676
|
+
/**
|
|
677
|
+
* When true, assumes EditorProvider already exists in a parent component.
|
|
678
|
+
* Skips creating the internal EditorProvider so multiple SnowconeCanvas instances
|
|
679
|
+
* can share the same editor state (e.g., when conditionally rendering mobile/desktop layouts).
|
|
680
|
+
*
|
|
681
|
+
* @default false
|
|
682
|
+
*/
|
|
683
|
+
externalProvider?: boolean;
|
|
684
|
+
/**
|
|
685
|
+
* CSS class name for the container.
|
|
686
|
+
*/
|
|
687
|
+
className?: string;
|
|
688
|
+
/**
|
|
689
|
+
* Inline styles for the container.
|
|
690
|
+
*/
|
|
691
|
+
style?: React.CSSProperties;
|
|
692
|
+
/**
|
|
693
|
+
* CSS class name for the canvas wrapper element.
|
|
694
|
+
* Use this to apply CSS masks, clips, or other effects to just the canvas
|
|
695
|
+
* without affecting the overlay elements.
|
|
696
|
+
* @deprecated Use `layoutConfig.canvasWrapperClassName` instead.
|
|
697
|
+
*/
|
|
698
|
+
canvasWrapperClassName?: string;
|
|
699
|
+
/**
|
|
700
|
+
* Inline styles for the canvas wrapper element.
|
|
701
|
+
* Use this to apply CSS masks, clips, or other effects to just the canvas
|
|
702
|
+
* without affecting the overlay elements.
|
|
703
|
+
* @deprecated Use `layoutConfig.canvasWrapperStyle` instead.
|
|
704
|
+
*/
|
|
705
|
+
canvasWrapperStyle?: React.CSSProperties;
|
|
706
|
+
/**
|
|
707
|
+
* ADR-0054 Phase 4: shapes punched through the `<canvas>` as truly
|
|
708
|
+
* transparent holes. See matching field on LayoutConfig for details.
|
|
709
|
+
* Takes precedence over `layoutConfig.canvasCutouts`.
|
|
710
|
+
*/
|
|
711
|
+
canvasCutouts?: CanvasCutoutShape[];
|
|
712
|
+
/**
|
|
713
|
+
* ADR-0054: piece boundary / safe-area / zone / label overlays drawn
|
|
714
|
+
* directly into the canvas render loop (no DOM SVG overlay). Pieces
|
|
715
|
+
* are in artboard-space coordinates (same frame as placements and
|
|
716
|
+
* `canvasCutouts`). `guides` is keyed by piece id. Supply `undefined`
|
|
717
|
+
* or omit to skip piece-guide rendering entirely.
|
|
718
|
+
*
|
|
719
|
+
* Replaces the old `VisualGuideOverlay` sibling-overlay pattern —
|
|
720
|
+
* drawing directly in the ctx means no fixedMargin-unit / aspect-
|
|
721
|
+
* ratio-letterbox / canvas-wrapper-negative-margin shenanigans.
|
|
722
|
+
*/
|
|
723
|
+
pieceGuides?: PieceGuidesConfig;
|
|
724
|
+
/**
|
|
725
|
+
* ADR-0060: viewport focus mode for multi-piece spread layouts.
|
|
726
|
+
*
|
|
727
|
+
* - Omit / `'spread'` — show the entire artboard with all pieces
|
|
728
|
+
* visible (historical behaviour). The toggle is a no-op for
|
|
729
|
+
* single-piece layouts.
|
|
730
|
+
* - `{ pieceId: 'front' }` — fit the viewport to that piece's
|
|
731
|
+
* rect plus a peek margin so neighbour pieces remain visible
|
|
732
|
+
* at the edges (dimmed) for overflow feedback. The piece id
|
|
733
|
+
* must match an entry in `pieceGuides.pieces[]`; unrecognised
|
|
734
|
+
* ids fall back to spread mode.
|
|
735
|
+
*
|
|
736
|
+
* Element data is unaffected — elements always live in spread
|
|
737
|
+
* (artboard) coordinates regardless of focus. Switching focus is
|
|
738
|
+
* purely an editor viewport / chrome decision.
|
|
739
|
+
*/
|
|
740
|
+
pieceFocus?: 'spread' | {
|
|
741
|
+
pieceId: string;
|
|
742
|
+
};
|
|
743
|
+
/**
|
|
744
|
+
* Show toolbar UI (reserved for future use).
|
|
745
|
+
* Default: false (canvas-only mode).
|
|
746
|
+
* @deprecated Use `layoutConfig.showToolbar` instead.
|
|
747
|
+
*/
|
|
748
|
+
showToolbar?: boolean;
|
|
749
|
+
/**
|
|
750
|
+
* Show layers panel (reserved for future use).
|
|
751
|
+
* Default: false (canvas-only mode).
|
|
752
|
+
* @deprecated Use `layoutConfig.showLayers` instead.
|
|
753
|
+
*/
|
|
754
|
+
showLayers?: boolean;
|
|
755
|
+
/**
|
|
756
|
+
* Enable keyboard shortcuts.
|
|
757
|
+
* Default: true.
|
|
758
|
+
*/
|
|
759
|
+
enableShortcuts?: boolean;
|
|
760
|
+
/**
|
|
761
|
+
* Render custom controls on top of the canvas.
|
|
762
|
+
* Useful for adding menu buttons, toolbars, etc.
|
|
763
|
+
* The overlay is rendered inside the EditorProvider context.
|
|
764
|
+
*/
|
|
765
|
+
overlay?: React.ReactNode;
|
|
766
|
+
/**
|
|
767
|
+
* When true, hides the internal Canvas component.
|
|
768
|
+
* Use this when rendering a separate Canvas (e.g., in fullscreen mode)
|
|
769
|
+
* that shares the same EditorProvider context.
|
|
770
|
+
* This prevents two Canvas components from fighting over the same refs.
|
|
771
|
+
* @deprecated Use `layoutConfig.hideCanvas` instead.
|
|
772
|
+
*/
|
|
773
|
+
hideCanvas?: boolean;
|
|
774
|
+
/**
|
|
775
|
+
* Controls how much of the container the artboard fills.
|
|
776
|
+
* Value between 0 and 1, where 1 means the artboard fills 100% of the container.
|
|
777
|
+
* Default is 0.9 (90%), leaving 5% padding on each side.
|
|
778
|
+
* Use smaller values (e.g., 0.8) to show more canvas area around the artboard,
|
|
779
|
+
* which is useful for seeing selection handles that extend beyond the artboard.
|
|
780
|
+
* @deprecated Use `layoutConfig.viewPadding` instead.
|
|
781
|
+
*/
|
|
782
|
+
viewPadding?: number;
|
|
783
|
+
/**
|
|
784
|
+
* Border radius for artboard corners in pixels.
|
|
785
|
+
* Use this to give the artboard rounded corners in the editor.
|
|
786
|
+
* This is a visual-only effect - exports will still have the full artboard.
|
|
787
|
+
* @default 0
|
|
788
|
+
* @deprecated Use `layoutConfig.artboardBorderRadius` instead.
|
|
789
|
+
*/
|
|
790
|
+
artboardBorderRadius?: number;
|
|
791
|
+
/**
|
|
792
|
+
* Fixed screen-space margin in pixels.
|
|
793
|
+
* When set, the artboard will have this exact left/top margin regardless of zoom level.
|
|
794
|
+
* This is useful for aligning the artboard with fixed-position UI elements like headers.
|
|
795
|
+
* Overrides viewPadding for positioning (viewPadding still affects zoom calculation).
|
|
796
|
+
* @deprecated Use `layoutConfig.fixedMargin` instead.
|
|
797
|
+
*/
|
|
798
|
+
fixedMargin?: number;
|
|
799
|
+
/**
|
|
800
|
+
* Maximum HTML height in pixels.
|
|
801
|
+
* When the artboard (with vertical fixedMargin padding) would exceed this height,
|
|
802
|
+
* horizontal padding is increased to shrink the artboard until it fits within
|
|
803
|
+
* this constraint while still respecting vertical fixedMargin.
|
|
804
|
+
* @deprecated Use `layoutConfig.maxHeight` instead.
|
|
805
|
+
*/
|
|
806
|
+
maxHeight?: number;
|
|
807
|
+
/**
|
|
808
|
+
* Whether to show the rotation handle on the canvas.
|
|
809
|
+
* Set to false for embedded mode where rotation is handled via toolbar panel.
|
|
810
|
+
* @default true
|
|
811
|
+
* @deprecated Use `layoutConfig.showRotationHandle` instead.
|
|
812
|
+
*/
|
|
813
|
+
showRotationHandle?: boolean;
|
|
814
|
+
/**
|
|
815
|
+
* Called once when the canvas is fully ready for interaction and export.
|
|
816
|
+
* Fires after: artboards initialized, initial elements loaded, fonts ready,
|
|
817
|
+
* and at least one render frame completed.
|
|
818
|
+
*/
|
|
819
|
+
onReady?: () => void;
|
|
820
|
+
}
|
|
821
|
+
/**
|
|
822
|
+
* SnowconeCanvas - Self-contained embeddable canvas editor
|
|
823
|
+
* Wraps with ThemeProvider and EditorProvider for full functionality
|
|
824
|
+
*
|
|
825
|
+
* @example With imperative export
|
|
826
|
+
* ```tsx
|
|
827
|
+
* const canvasRef = useRef<SnowconeCanvasHandle>(null);
|
|
828
|
+
*
|
|
829
|
+
* const handleExport = async () => {
|
|
830
|
+
* const exports = await canvasRef.current?.exportArtboards();
|
|
831
|
+
* console.log('Exported:', exports);
|
|
832
|
+
* };
|
|
833
|
+
*
|
|
834
|
+
* return <SnowconeCanvas ref={canvasRef} ... />;
|
|
835
|
+
* ```
|
|
836
|
+
*
|
|
837
|
+
* @example Embedded in app with existing theme
|
|
838
|
+
* ```tsx
|
|
839
|
+
* // When your app already manages themes, use inheritTheme to prevent conflicts
|
|
840
|
+
* <SnowconeCanvas inheritTheme ... />
|
|
841
|
+
* ```
|
|
842
|
+
*/
|
|
843
|
+
export declare const SnowconeCanvas: React.ForwardRefExoticComponent<SnowconeCanvasProps & React.RefAttributes<SnowconeCanvasHandle>>;
|
|
844
|
+
export default SnowconeCanvas;
|