@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
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,1138 @@
|
|
|
1
|
+
import { A as ft, D as mt, r as ht, v as gt, u as pt, a as bt, S as vt, K as xt, C as Xe, e as wt } from "./compose-DQ1FZS3O.js";
|
|
2
|
+
import { b as pr, c as br, E as vr, M as xr, P as wr, d as Er, f as yr, g as Ar } from "./compose-DQ1FZS3O.js";
|
|
3
|
+
import { c as _, s as Et, I as Ke, p as yt, T as At } from "./HybridHistoryManager-BV6XV0nD.js";
|
|
4
|
+
import { jsxs as de, jsx as C } from "react/jsx-runtime";
|
|
5
|
+
import { Component as St, useRef as T, useState as q, useEffect as R, useCallback as B, forwardRef as je, useMemo as ye, useImperativeHandle as Rt } from "react";
|
|
6
|
+
import { u as ue, T as Oe, E as It, a as Ae, b as Ge, c as kt } from "./ThemeContext-H0Z-MqqR.js";
|
|
7
|
+
import { C as we, E as Ct } from "./ElementFactory-uJTXU-nP.js";
|
|
8
|
+
import { d as Rr, m as Ir, s as kr, v as Cr } from "./CanvasStateV1-ejb4d_LM.js";
|
|
9
|
+
const Mt = _("ErrorBoundary");
|
|
10
|
+
class Tt extends St {
|
|
11
|
+
constructor(e) {
|
|
12
|
+
super(e), this.resetError = () => {
|
|
13
|
+
this.setState({
|
|
14
|
+
hasError: !1,
|
|
15
|
+
error: null
|
|
16
|
+
});
|
|
17
|
+
}, this.state = {
|
|
18
|
+
hasError: !1,
|
|
19
|
+
error: null
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
static getDerivedStateFromError(e) {
|
|
23
|
+
return {
|
|
24
|
+
hasError: !0,
|
|
25
|
+
error: e
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
componentDidCatch(e, r) {
|
|
29
|
+
if (Mt.error("Caught error:", e, r), this.props.onError && this.props.onError(e, r), this.props.onCanvasError) {
|
|
30
|
+
const a = {
|
|
31
|
+
category: "unknown",
|
|
32
|
+
message: e.message,
|
|
33
|
+
originalError: e,
|
|
34
|
+
recoverable: !1
|
|
35
|
+
};
|
|
36
|
+
this.props.onCanvasError(a);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
render() {
|
|
40
|
+
return this.state.hasError && this.state.error ? this.props.renderError ? this.props.renderError(this.state.error, this.resetError) : this.props.fallback ? typeof this.props.fallback == "function" ? this.props.fallback(this.state.error, this.resetError) : this.props.fallback : /* @__PURE__ */ de(
|
|
41
|
+
"div",
|
|
42
|
+
{
|
|
43
|
+
style: {
|
|
44
|
+
padding: "24px",
|
|
45
|
+
border: "2px solid var(--danger)",
|
|
46
|
+
borderRadius: "8px",
|
|
47
|
+
backgroundColor: "color-mix(in oklch, var(--danger) 10%, var(--background))",
|
|
48
|
+
color: "var(--danger)",
|
|
49
|
+
fontFamily: "system-ui, sans-serif"
|
|
50
|
+
},
|
|
51
|
+
children: [
|
|
52
|
+
/* @__PURE__ */ C("h2", { style: { margin: "0 0 16px 0", fontSize: "18px", fontWeight: 600 }, children: "Something went wrong" }),
|
|
53
|
+
/* @__PURE__ */ C(
|
|
54
|
+
"pre",
|
|
55
|
+
{
|
|
56
|
+
style: {
|
|
57
|
+
margin: "0 0 16px 0",
|
|
58
|
+
padding: "12px",
|
|
59
|
+
backgroundColor: "color-mix(in oklch, var(--danger) 15%, var(--background))",
|
|
60
|
+
borderRadius: "4px",
|
|
61
|
+
fontSize: "14px",
|
|
62
|
+
overflow: "auto",
|
|
63
|
+
maxHeight: "200px"
|
|
64
|
+
},
|
|
65
|
+
children: this.state.error.message
|
|
66
|
+
}
|
|
67
|
+
),
|
|
68
|
+
/* @__PURE__ */ C(
|
|
69
|
+
"button",
|
|
70
|
+
{
|
|
71
|
+
onClick: this.resetError,
|
|
72
|
+
style: {
|
|
73
|
+
padding: "8px 16px",
|
|
74
|
+
backgroundColor: "var(--danger)",
|
|
75
|
+
color: "var(--danger-foreground)",
|
|
76
|
+
border: "none",
|
|
77
|
+
borderRadius: "4px",
|
|
78
|
+
fontSize: "14px",
|
|
79
|
+
fontWeight: 500,
|
|
80
|
+
cursor: "pointer"
|
|
81
|
+
},
|
|
82
|
+
children: "Try again"
|
|
83
|
+
}
|
|
84
|
+
)
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
) : this.props.children;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const Dt = _("useAutoExport");
|
|
91
|
+
function Ft(t) {
|
|
92
|
+
const { config: e, historyManager: r, artboards: a, elements: n, onExport: c, onExportScheduled: o, isCanvasReady: i = !1 } = t, l = T(null), p = T(!1), A = T({
|
|
93
|
+
totalExports: 0,
|
|
94
|
+
skippedExports: 0,
|
|
95
|
+
lastExportTime: null,
|
|
96
|
+
avgExportInterval: 0
|
|
97
|
+
}), [P, I] = q(A.current), E = T(c);
|
|
98
|
+
E.current = c, R(() => {
|
|
99
|
+
const m = new ft({
|
|
100
|
+
...mt,
|
|
101
|
+
...e
|
|
102
|
+
});
|
|
103
|
+
return m.onExport(async () => {
|
|
104
|
+
try {
|
|
105
|
+
await E.current(), A.current = m.getStats();
|
|
106
|
+
} catch (S) {
|
|
107
|
+
Dt.error("[useAutoExport] Export failed:", S);
|
|
108
|
+
}
|
|
109
|
+
}), l.current = m, () => {
|
|
110
|
+
m.destroy();
|
|
111
|
+
};
|
|
112
|
+
}, []), R(() => {
|
|
113
|
+
i && p.current && l.current && (p.current = !1, l.current.forceExport());
|
|
114
|
+
}, [i]), R(() => {
|
|
115
|
+
l.current && e && l.current.updateConfig(e);
|
|
116
|
+
}, [e == null ? void 0 : e.enabled, e == null ? void 0 : e.debounceMs, e == null ? void 0 : e.maxWaitMs]), R(() => {
|
|
117
|
+
l.current && o && l.current.onExportScheduled(o);
|
|
118
|
+
}, [o]), R(() => {
|
|
119
|
+
if (!r || !l.current)
|
|
120
|
+
return;
|
|
121
|
+
const m = r.onCommandExecuted(() => {
|
|
122
|
+
if (l.current) {
|
|
123
|
+
if (!i) {
|
|
124
|
+
p.current = !0;
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
l.current.scheduleExport();
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
return () => {
|
|
131
|
+
m();
|
|
132
|
+
};
|
|
133
|
+
}, [r, i]), R(() => {
|
|
134
|
+
if (l.current) {
|
|
135
|
+
if (!i) {
|
|
136
|
+
p.current = !0;
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
l.current.scheduleExport();
|
|
140
|
+
}
|
|
141
|
+
}, [n, a, i]), R(() => Et((S) => {
|
|
142
|
+
if (!l.current || !i) return;
|
|
143
|
+
n.some((W) => W.id === S) && l.current.scheduleExport();
|
|
144
|
+
}), [n, i]);
|
|
145
|
+
const M = B((m) => {
|
|
146
|
+
l.current && l.current.updateConfig(m);
|
|
147
|
+
}, []), w = B(async () => {
|
|
148
|
+
l.current && (await l.current.forceExport(), A.current = l.current.getStats(), I(A.current));
|
|
149
|
+
}, []), H = B(() => {
|
|
150
|
+
l.current && (l.current.resetStats(), A.current = l.current.getStats(), I(A.current));
|
|
151
|
+
}, []), y = B(() => {
|
|
152
|
+
l.current && l.current.resetChangeDetection();
|
|
153
|
+
}, []);
|
|
154
|
+
return {
|
|
155
|
+
stats: P,
|
|
156
|
+
updateConfig: M,
|
|
157
|
+
forceExport: w,
|
|
158
|
+
resetStats: H,
|
|
159
|
+
resetChangeDetection: y
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
const Qe = _("useContentReady");
|
|
163
|
+
function Pt(t) {
|
|
164
|
+
var r;
|
|
165
|
+
const e = /* @__PURE__ */ new Set();
|
|
166
|
+
for (const a of t)
|
|
167
|
+
if ("fontFamily" in a && typeof a.fontFamily == "string" && a.fontFamily && e.add(a.fontFamily), "getRichText" in a && typeof a.getRichText == "function")
|
|
168
|
+
try {
|
|
169
|
+
const n = a.getRichText();
|
|
170
|
+
if (n != null && n.spans)
|
|
171
|
+
for (const c of n.spans)
|
|
172
|
+
(r = c.style) != null && r.fontFamily && e.add(c.style.fontFamily);
|
|
173
|
+
} catch {
|
|
174
|
+
}
|
|
175
|
+
return Array.from(e);
|
|
176
|
+
}
|
|
177
|
+
async function Ht(t) {
|
|
178
|
+
if (t.length === 0 || typeof document > "u" || !document.fonts) return;
|
|
179
|
+
const e = [];
|
|
180
|
+
for (const r of t) {
|
|
181
|
+
const a = `16px "${r}"`;
|
|
182
|
+
e.push(document.fonts.load(a));
|
|
183
|
+
}
|
|
184
|
+
await Promise.all(e), document.fonts.ready && await Promise.race([
|
|
185
|
+
document.fonts.ready,
|
|
186
|
+
new Promise((r) => setTimeout(r, 250))
|
|
187
|
+
]), Qe.debug(`Awaited ${e.length} font(s)`);
|
|
188
|
+
}
|
|
189
|
+
function Lt() {
|
|
190
|
+
return new Promise((t) => requestAnimationFrame(() => t()));
|
|
191
|
+
}
|
|
192
|
+
function Wt(t) {
|
|
193
|
+
const { isCanvasReady: e, elements: r, hasInitialElements: a, initialElementsLoaded: n } = t, [c, o] = q(!1), i = T(!1);
|
|
194
|
+
return R(() => {
|
|
195
|
+
if (c || !e || a && !n || a && r.length === 0 || i.current) return;
|
|
196
|
+
i.current = !0;
|
|
197
|
+
let l = !1;
|
|
198
|
+
return (async () => {
|
|
199
|
+
try {
|
|
200
|
+
const p = Pt(r);
|
|
201
|
+
if (p.length > 0 && (await Ht(p), l) || (await Lt(), l)) return;
|
|
202
|
+
o(!0);
|
|
203
|
+
} catch (p) {
|
|
204
|
+
Qe.error("Error during content readiness check:", p), l || o(!0);
|
|
205
|
+
} finally {
|
|
206
|
+
i.current = !1;
|
|
207
|
+
}
|
|
208
|
+
})(), () => {
|
|
209
|
+
l = !0, i.current = !1;
|
|
210
|
+
};
|
|
211
|
+
}, [e, r, a, n, c]), c;
|
|
212
|
+
}
|
|
213
|
+
const Bt = {
|
|
214
|
+
// Vertical alignments (map to top/center/bottom center)
|
|
215
|
+
"far-top": "t",
|
|
216
|
+
top: "t",
|
|
217
|
+
center: "c",
|
|
218
|
+
bottom: "b",
|
|
219
|
+
"far-bottom": "b",
|
|
220
|
+
// Horizontal alignments (map to left/center/right middle)
|
|
221
|
+
"far-left": "l",
|
|
222
|
+
left: "l",
|
|
223
|
+
right: "r",
|
|
224
|
+
"far-right": "r",
|
|
225
|
+
// Direct 9-point values
|
|
226
|
+
tl: "tl",
|
|
227
|
+
t: "t",
|
|
228
|
+
tr: "tr",
|
|
229
|
+
l: "l",
|
|
230
|
+
c: "c",
|
|
231
|
+
r: "r",
|
|
232
|
+
bl: "bl",
|
|
233
|
+
b: "b",
|
|
234
|
+
br: "br"
|
|
235
|
+
};
|
|
236
|
+
function Nt(t) {
|
|
237
|
+
return t && Bt[t] || "c";
|
|
238
|
+
}
|
|
239
|
+
function Ut(t, e) {
|
|
240
|
+
const r = e.scaleMode || "cover", a = (r === "contain" ? e.marginTop : 0) || 0, n = (r === "contain" ? e.marginRight : 0) || 0, c = (r === "contain" ? e.marginBottom : 0) || 0, o = (r === "contain" ? e.marginLeft : 0) || 0, i = e.width - o - n, l = e.height - a - c, p = i / t.width, A = l / t.height, P = r === "contain" ? Math.min(p, A) : Math.max(p, A), I = e.scale || 1, E = P * I, M = t.width * E, w = t.height * E, H = e.align || "c";
|
|
241
|
+
let y = 0, m = 0;
|
|
242
|
+
const S = M - i, v = w - l;
|
|
243
|
+
switch (H) {
|
|
244
|
+
// Top row
|
|
245
|
+
case "tl":
|
|
246
|
+
y = 0, m = 0;
|
|
247
|
+
break;
|
|
248
|
+
case "t":
|
|
249
|
+
y = -S / 2, m = 0;
|
|
250
|
+
break;
|
|
251
|
+
case "tr":
|
|
252
|
+
y = -S, m = 0;
|
|
253
|
+
break;
|
|
254
|
+
// Middle row
|
|
255
|
+
case "l":
|
|
256
|
+
y = 0, m = -v / 2;
|
|
257
|
+
break;
|
|
258
|
+
case "c":
|
|
259
|
+
// Center (default)
|
|
260
|
+
default:
|
|
261
|
+
y = -S / 2, m = -v / 2;
|
|
262
|
+
break;
|
|
263
|
+
case "r":
|
|
264
|
+
y = -S, m = -v / 2;
|
|
265
|
+
break;
|
|
266
|
+
// Bottom row
|
|
267
|
+
case "bl":
|
|
268
|
+
y = 0, m = -v;
|
|
269
|
+
break;
|
|
270
|
+
case "b":
|
|
271
|
+
y = -S / 2, m = -v;
|
|
272
|
+
break;
|
|
273
|
+
case "br":
|
|
274
|
+
y = -S, m = -v;
|
|
275
|
+
break;
|
|
276
|
+
}
|
|
277
|
+
y += o, m += a;
|
|
278
|
+
const W = e.offsetX || 0, D = e.offsetY || 0, $ = S, ee = v;
|
|
279
|
+
return y += W * $, m += D * ee, y = Math.round(y), m = Math.round(m), {
|
|
280
|
+
// Final scale to apply to artwork
|
|
281
|
+
scale: E,
|
|
282
|
+
// Final artwork dimensions after scaling
|
|
283
|
+
width: Math.round(M),
|
|
284
|
+
height: Math.round(w),
|
|
285
|
+
// Position to draw artwork (relative to artboard origin)
|
|
286
|
+
x: y,
|
|
287
|
+
y: m,
|
|
288
|
+
// Debug info
|
|
289
|
+
debug: {
|
|
290
|
+
coverScale: P,
|
|
291
|
+
userScale: I,
|
|
292
|
+
overflow: { x: S, y: v },
|
|
293
|
+
alignment: H,
|
|
294
|
+
appliedOffset: { x: W * $, y: D * ee }
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
const zt = {
|
|
299
|
+
timeout: 3e4,
|
|
300
|
+
retries: 1,
|
|
301
|
+
retryDelay: 1e3,
|
|
302
|
+
validateUrl: !0
|
|
303
|
+
};
|
|
304
|
+
function Yt(t) {
|
|
305
|
+
try {
|
|
306
|
+
const e = new URL(t);
|
|
307
|
+
return ["http:", "https:", "data:", "blob:"].includes(e.protocol);
|
|
308
|
+
} catch {
|
|
309
|
+
return !1;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
async function $t(t, e = {}) {
|
|
313
|
+
const r = { ...zt, ...e };
|
|
314
|
+
if (r.validateUrl && !Yt(t))
|
|
315
|
+
return {
|
|
316
|
+
success: !1,
|
|
317
|
+
error: new Error(`Invalid image URL: ${t}`)
|
|
318
|
+
};
|
|
319
|
+
let a;
|
|
320
|
+
for (let n = 0; n <= r.retries; n++)
|
|
321
|
+
try {
|
|
322
|
+
return await Xt(t, r.timeout);
|
|
323
|
+
} catch (c) {
|
|
324
|
+
a = c instanceof Error ? c : new Error(String(c)), n < r.retries && await Vt(r.retryDelay);
|
|
325
|
+
}
|
|
326
|
+
return {
|
|
327
|
+
success: !1,
|
|
328
|
+
error: a || new Error("Failed to load image after retries")
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
function Xt(t, e) {
|
|
332
|
+
return new Promise((r) => {
|
|
333
|
+
const a = new Image();
|
|
334
|
+
a.crossOrigin = "anonymous";
|
|
335
|
+
let n = null, c = !1;
|
|
336
|
+
const o = () => {
|
|
337
|
+
n && (clearTimeout(n), n = null);
|
|
338
|
+
}, i = () => {
|
|
339
|
+
if (c) return;
|
|
340
|
+
c = !0, o();
|
|
341
|
+
const p = a.naturalWidth || a.width, A = a.naturalHeight || a.height;
|
|
342
|
+
r({
|
|
343
|
+
success: !0,
|
|
344
|
+
element: a,
|
|
345
|
+
width: p,
|
|
346
|
+
height: A,
|
|
347
|
+
aspectRatio: A > 0 ? p / A : 1
|
|
348
|
+
});
|
|
349
|
+
}, l = (p) => {
|
|
350
|
+
c || (c = !0, o(), r({
|
|
351
|
+
success: !1,
|
|
352
|
+
error: new Error(p)
|
|
353
|
+
}));
|
|
354
|
+
};
|
|
355
|
+
a.onload = i, a.onerror = () => {
|
|
356
|
+
l(`Failed to load image: ${t}`);
|
|
357
|
+
}, n = setTimeout(() => {
|
|
358
|
+
l(`Image load timed out after ${e}ms: ${t}`);
|
|
359
|
+
}, e), a.src = t;
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
async function Ot(t, e, r = {}, a = {}) {
|
|
363
|
+
var I, E, M, w, H, y, m;
|
|
364
|
+
const n = await $t(t, a);
|
|
365
|
+
if (!n.success || !n.width || !n.height)
|
|
366
|
+
return {
|
|
367
|
+
success: !1,
|
|
368
|
+
error: n.error || new Error("Failed to get image dimensions")
|
|
369
|
+
};
|
|
370
|
+
const c = {
|
|
371
|
+
width: e.artboard.width,
|
|
372
|
+
height: e.artboard.height,
|
|
373
|
+
scale: e.scale,
|
|
374
|
+
align: Nt(e.alignment),
|
|
375
|
+
offsetX: e.offsetX,
|
|
376
|
+
offsetY: e.offsetY,
|
|
377
|
+
scaleMode: e.scaleMode,
|
|
378
|
+
marginTop: e.marginTop,
|
|
379
|
+
marginRight: e.marginRight,
|
|
380
|
+
marginBottom: e.marginBottom,
|
|
381
|
+
marginLeft: e.marginLeft
|
|
382
|
+
}, o = Ut(
|
|
383
|
+
{ width: n.width, height: n.height },
|
|
384
|
+
c
|
|
385
|
+
), i = e.artboard.x + o.x, l = e.artboard.y + o.y, p = i + o.width / 2, A = l + o.height / 2;
|
|
386
|
+
return {
|
|
387
|
+
success: !0,
|
|
388
|
+
element: new Ke({
|
|
389
|
+
...r,
|
|
390
|
+
x: p,
|
|
391
|
+
y: A,
|
|
392
|
+
imageUrl: t,
|
|
393
|
+
imageAspectRatio: n.aspectRatio,
|
|
394
|
+
preserveDimensions: !0,
|
|
395
|
+
// Don't recalculate dimensions on image load
|
|
396
|
+
transformData: {
|
|
397
|
+
type: "image",
|
|
398
|
+
width: o.width,
|
|
399
|
+
height: o.height,
|
|
400
|
+
cropX: ((I = r.transformData) == null ? void 0 : I.cropX) ?? 0,
|
|
401
|
+
cropY: ((E = r.transformData) == null ? void 0 : E.cropY) ?? 0,
|
|
402
|
+
cropWidth: ((M = r.transformData) == null ? void 0 : M.cropWidth) ?? 1,
|
|
403
|
+
cropHeight: ((w = r.transformData) == null ? void 0 : w.cropHeight) ?? 1,
|
|
404
|
+
flipHorizontal: ((H = r.transformData) == null ? void 0 : H.flipHorizontal) ?? !1,
|
|
405
|
+
flipVertical: ((y = r.transformData) == null ? void 0 : y.flipVertical) ?? !1,
|
|
406
|
+
borderRadius: ((m = r.transformData) == null ? void 0 : m.borderRadius) ?? 0
|
|
407
|
+
}
|
|
408
|
+
}),
|
|
409
|
+
placement: {
|
|
410
|
+
artworkSize: { width: n.width, height: n.height },
|
|
411
|
+
finalSize: { width: o.width, height: o.height },
|
|
412
|
+
position: { x: p, y: A },
|
|
413
|
+
scale: o.scale
|
|
414
|
+
}
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
function Vt(t) {
|
|
418
|
+
return new Promise((e) => setTimeout(e, t));
|
|
419
|
+
}
|
|
420
|
+
const K = _("SnowconeCanvas");
|
|
421
|
+
function Ee(t, e, r, a) {
|
|
422
|
+
if (a <= 0 || !isFinite(a))
|
|
423
|
+
return r;
|
|
424
|
+
const n = t * r, c = e * r;
|
|
425
|
+
if (Math.max(n, c) <= a)
|
|
426
|
+
return r;
|
|
427
|
+
const i = Math.max(t, e), l = a / i;
|
|
428
|
+
return Math.min(l, r);
|
|
429
|
+
}
|
|
430
|
+
const Je = je((t, e) => {
|
|
431
|
+
const {
|
|
432
|
+
exportConfig: r,
|
|
433
|
+
imageConfig: a,
|
|
434
|
+
layoutConfig: n,
|
|
435
|
+
kit: c,
|
|
436
|
+
artboards: o,
|
|
437
|
+
activeArtboard: i,
|
|
438
|
+
onArtboardChange: l,
|
|
439
|
+
initialElements: p,
|
|
440
|
+
onChange: A,
|
|
441
|
+
onSelectionChange: P,
|
|
442
|
+
autoExportInterval: I,
|
|
443
|
+
onExport: E,
|
|
444
|
+
onExportScheduled: M,
|
|
445
|
+
onExportStatus: w,
|
|
446
|
+
onExportReady: H,
|
|
447
|
+
onImageLoad: y,
|
|
448
|
+
onImageError: m,
|
|
449
|
+
onError: S,
|
|
450
|
+
onReady: v,
|
|
451
|
+
className: W,
|
|
452
|
+
style: D,
|
|
453
|
+
enableShortcuts: $,
|
|
454
|
+
overlay: ee
|
|
455
|
+
} = t, Se = I, J = t.autoExportConfig ?? (r == null ? void 0 : r.autoExportConfig), j = t.autoExportFormat ?? (r == null ? void 0 : r.format) ?? "dataUrl", fe = t.autoExportAll ?? (r == null ? void 0 : r.exportAll) ?? !1, O = t.exportScale ?? (r == null ? void 0 : r.scale) ?? 2, U = t.maxExportSize ?? (r == null ? void 0 : r.maxSize) ?? 4e3, te = t.exportImageFormat ?? (r == null ? void 0 : r.imageFormat) ?? "png", re = t.exportImageQuality ?? (r == null ? void 0 : r.imageQuality) ?? 0.92, z = t.initialImage ?? (a == null ? void 0 : a.src), Re = t.initialImageAlignment ?? (a == null ? void 0 : a.alignment) ?? "center", Ie = t.initialImageScale ?? (a == null ? void 0 : a.scale) ?? 1, ke = t.initialImageScaleMode ?? (a == null ? void 0 : a.scaleMode) ?? "cover", Ze = t.width ?? (n == null ? void 0 : n.width) ?? 1200, qe = t.height ?? (n == null ? void 0 : n.height) ?? 1200, Ce = t.viewPadding ?? (n == null ? void 0 : n.viewPadding) ?? 0.9, Me = t.artboardBorderRadius ?? (n == null ? void 0 : n.artboardBorderRadius) ?? 0, Te = t.fixedMargin ?? (n == null ? void 0 : n.fixedMargin), De = t.maxHeight ?? (n == null ? void 0 : n.maxHeight), Fe = t.showRotationHandle ?? (n == null ? void 0 : n.showRotationHandle) ?? !0, _e = t.hideCanvas ?? (n == null ? void 0 : n.hideCanvas) ?? !1, Pe = t.canvasWrapperClassName ?? (n == null ? void 0 : n.canvasWrapperClassName), He = t.canvasWrapperStyle ?? (n == null ? void 0 : n.canvasWrapperStyle), Le = t.canvasCutouts ?? (n == null ? void 0 : n.canvasCutouts), me = t.pieceGuides, We = t.pieceFocus, Be = $ ?? !0, ne = ye(() => ht(c ?? "pro-studio"), [c]);
|
|
456
|
+
R(() => {
|
|
457
|
+
if (yt.env.NODE_ENV === "development" && ne) {
|
|
458
|
+
const s = gt(ne);
|
|
459
|
+
s.valid || K.warn("Kit validation warnings:", s.errors), s.warnings.length > 0 && K.warn("Kit validation warnings:", s.warnings);
|
|
460
|
+
}
|
|
461
|
+
}, [ne]);
|
|
462
|
+
const ae = T(S);
|
|
463
|
+
ae.current = S;
|
|
464
|
+
const N = B((s) => {
|
|
465
|
+
var d;
|
|
466
|
+
K.error(`[${s.category}] ${s.message}`, s.originalError), (d = ae.current) == null || d.call(ae, s);
|
|
467
|
+
}, []);
|
|
468
|
+
R(() => (we.onRenderError = N, () => {
|
|
469
|
+
we.onRenderError === N && (we.onRenderError = null);
|
|
470
|
+
}), [N]);
|
|
471
|
+
const {
|
|
472
|
+
elements: V,
|
|
473
|
+
setElements: oe,
|
|
474
|
+
selectedId: Ne,
|
|
475
|
+
artboardManager: k,
|
|
476
|
+
refreshArtboards: et,
|
|
477
|
+
historyManager: tt,
|
|
478
|
+
isCanvasReady: he,
|
|
479
|
+
setCanvasReady: se
|
|
480
|
+
} = ue(), { createArtboard: rt, selectArtboard: nt, artboards: L } = pt(), { exportArtboard: G, exportAllArtboards: ie, exportArtboardAsBlob: Q, exportAllArtboardsAsBlobs: ce } = bt();
|
|
481
|
+
Rt(e, () => ({
|
|
482
|
+
exportArtboards: async (s = {}) => {
|
|
483
|
+
const d = s.format || j, h = s.scale || O, g = s.all ?? !1;
|
|
484
|
+
let f = h;
|
|
485
|
+
if (U > 0 && isFinite(U))
|
|
486
|
+
for (const x of L) {
|
|
487
|
+
const b = Ee(x.width, x.height, h, U);
|
|
488
|
+
f = Math.min(f, b);
|
|
489
|
+
}
|
|
490
|
+
const u = { scale: f, format: te, quality: re };
|
|
491
|
+
if (g) {
|
|
492
|
+
const x = d === "blob" ? await ce(u) : await ie(u), b = {};
|
|
493
|
+
for (const [F, Y] of Object.entries(x)) {
|
|
494
|
+
const X = L.find((Z) => Z.id === F);
|
|
495
|
+
X && (b[X.name] = Y);
|
|
496
|
+
}
|
|
497
|
+
return b;
|
|
498
|
+
} else {
|
|
499
|
+
const x = k.getActiveArtboard();
|
|
500
|
+
if (!x)
|
|
501
|
+
throw new Error("[SnowconeCanvas] No active artboard found");
|
|
502
|
+
if (d === "blob") {
|
|
503
|
+
const b = await Q(x.id, u);
|
|
504
|
+
return { [x.name]: b };
|
|
505
|
+
} else {
|
|
506
|
+
const b = await G(x.id, u);
|
|
507
|
+
return { [x.name]: b };
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
}), [G, ie, Q, ce, j, O, U, te, re, k, L]), R(() => {
|
|
512
|
+
H && H(async () => {
|
|
513
|
+
const d = k.getActiveArtboard();
|
|
514
|
+
if (!d)
|
|
515
|
+
throw new Error("[SnowconeCanvas] No active artboard found");
|
|
516
|
+
const h = Ee(
|
|
517
|
+
d.width,
|
|
518
|
+
d.height,
|
|
519
|
+
O,
|
|
520
|
+
U
|
|
521
|
+
), g = j === "blob" ? await Q(d.id, { scale: h }) : await G(d.id, { scale: h });
|
|
522
|
+
return { [d.name]: g };
|
|
523
|
+
});
|
|
524
|
+
}, [H, G, Q, k, j, O, U]);
|
|
525
|
+
const [Ue, le] = q("idle"), [ze, ge] = q(null), pe = T(void 0), be = T(!1), Ye = T(!1), [at, ot] = q(!1), st = T(0), it = T(0), ve = T(!1);
|
|
526
|
+
R(() => {
|
|
527
|
+
if (be.current) return;
|
|
528
|
+
be.current = !0;
|
|
529
|
+
const s = o || [{ name: "Design", width: Ze, height: qe }], d = k.getAllArtboards();
|
|
530
|
+
if (d.length > 0) {
|
|
531
|
+
const h = s[0], g = d[0], f = me ? "transparent" : void 0;
|
|
532
|
+
g.name = h.name, g.width = h.width, g.height = h.height, g.clipShape = h.clipShape, h.backgroundColor ? g.backgroundColor = h.backgroundColor : f && (g.backgroundColor = f);
|
|
533
|
+
for (let u = 1; u < s.length; u++)
|
|
534
|
+
rt(s[u].width, s[u].height, {
|
|
535
|
+
name: s[u].name,
|
|
536
|
+
backgroundColor: s[u].backgroundColor ?? f,
|
|
537
|
+
clipShape: s[u].clipShape
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
et();
|
|
541
|
+
}, []), R(() => {
|
|
542
|
+
if (!(!p || p.length === 0) && !Ye.current && be.current) {
|
|
543
|
+
Ye.current = !0, ot(!0);
|
|
544
|
+
try {
|
|
545
|
+
const s = Ct.createManyFromJSON(p), d = k.getAllArtboards();
|
|
546
|
+
if (d.length > 0) {
|
|
547
|
+
const g = d[0];
|
|
548
|
+
for (const f of s)
|
|
549
|
+
k.addElementToArtboard(f.id, g.id);
|
|
550
|
+
}
|
|
551
|
+
oe(s);
|
|
552
|
+
const h = /* @__PURE__ */ new Set();
|
|
553
|
+
for (const g of s) {
|
|
554
|
+
const f = g.fontFamily;
|
|
555
|
+
typeof f == "string" && f.trim().length > 0 && h.add(f);
|
|
556
|
+
}
|
|
557
|
+
if (h.size > 0 && typeof document < "u") {
|
|
558
|
+
const g = document.fonts ?? null, f = Array.from(h).map((u) => {
|
|
559
|
+
const x = `font-${u.replace(/\s+/g, "-").toLowerCase()}`;
|
|
560
|
+
let b = document.getElementById(x);
|
|
561
|
+
return b || (b = document.createElement("link"), b.id = x, b.rel = "stylesheet", b.href = `https://fonts.googleapis.com/css2?family=${u.replace(
|
|
562
|
+
/\s+/g,
|
|
563
|
+
"+"
|
|
564
|
+
)}:wght@400;700&display=swap`, document.head.appendChild(b)), new Promise((F) => {
|
|
565
|
+
if (b.sheet) {
|
|
566
|
+
F(u);
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
const Y = () => F(u);
|
|
570
|
+
b.addEventListener("load", Y, { once: !0 }), b.addEventListener("error", Y, { once: !0 }), setTimeout(Y, 4e3);
|
|
571
|
+
});
|
|
572
|
+
});
|
|
573
|
+
Promise.all(f).then((u) => {
|
|
574
|
+
if (g)
|
|
575
|
+
return Promise.all(
|
|
576
|
+
u.flatMap((x) => [
|
|
577
|
+
g.load(`400 16px "${x}"`).catch(() => {
|
|
578
|
+
}),
|
|
579
|
+
g.load(`700 16px "${x}"`).catch(() => {
|
|
580
|
+
})
|
|
581
|
+
])
|
|
582
|
+
);
|
|
583
|
+
}).then(() => {
|
|
584
|
+
oe((u) => u.slice());
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
} catch (s) {
|
|
588
|
+
K.error("Failed to load initial elements:", s);
|
|
589
|
+
const d = s instanceof Error ? s : new Error(String(s));
|
|
590
|
+
N({
|
|
591
|
+
category: "import",
|
|
592
|
+
message: `Failed to load initial elements: ${d.message}`,
|
|
593
|
+
originalError: d,
|
|
594
|
+
recoverable: !0
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
}, [p, k, oe, N]), R(() => {
|
|
599
|
+
if (!i) {
|
|
600
|
+
ve.current = !0;
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
603
|
+
const s = L.find((d) => d.name === i);
|
|
604
|
+
if (s) {
|
|
605
|
+
const d = k.getActiveArtboard();
|
|
606
|
+
(d == null ? void 0 : d.name) !== i && nt(s.id), ve.current = !0;
|
|
607
|
+
}
|
|
608
|
+
}, [i, L]), R(() => {
|
|
609
|
+
if (!z || pe.current === z) return;
|
|
610
|
+
if (V.length > 0) {
|
|
611
|
+
pe.current = z;
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
614
|
+
pe.current = z, (async () => {
|
|
615
|
+
le("loading"), ge(null);
|
|
616
|
+
try {
|
|
617
|
+
const d = k.getAllArtboards();
|
|
618
|
+
if (d.length === 0)
|
|
619
|
+
throw new Error("No artboards available");
|
|
620
|
+
const h = [];
|
|
621
|
+
for (const g of d) {
|
|
622
|
+
const f = o == null ? void 0 : o.find((b) => b.name === g.name), u = (f == null ? void 0 : f.scaleMode) || ke, x = await Ot(
|
|
623
|
+
z,
|
|
624
|
+
{
|
|
625
|
+
artboard: {
|
|
626
|
+
width: g.width,
|
|
627
|
+
height: g.height,
|
|
628
|
+
x: g.x,
|
|
629
|
+
y: g.y
|
|
630
|
+
},
|
|
631
|
+
alignment: (f == null ? void 0 : f.fitAlign) || Re,
|
|
632
|
+
scale: Ie,
|
|
633
|
+
scaleMode: u,
|
|
634
|
+
marginTop: f == null ? void 0 : f.fitMarginTop,
|
|
635
|
+
marginRight: f == null ? void 0 : f.fitMarginRight,
|
|
636
|
+
marginBottom: f == null ? void 0 : f.fitMarginBottom,
|
|
637
|
+
marginLeft: f == null ? void 0 : f.fitMarginLeft
|
|
638
|
+
}
|
|
639
|
+
);
|
|
640
|
+
x.success && x.element ? (k.addElementToArtboard(x.element.id, g.id), h.push(x.element)) : K.error("Failed to load image for artboard:", g.name, x.error);
|
|
641
|
+
}
|
|
642
|
+
if (h.length > 0)
|
|
643
|
+
oe((g) => [...g, ...h]), le("success"), y == null || y(z);
|
|
644
|
+
else {
|
|
645
|
+
const g = new Error("Failed to load image into any artboard");
|
|
646
|
+
le("error"), ge(g), m == null || m(z, g), N({
|
|
647
|
+
category: "image",
|
|
648
|
+
message: g.message,
|
|
649
|
+
originalError: g,
|
|
650
|
+
recoverable: !0
|
|
651
|
+
});
|
|
652
|
+
}
|
|
653
|
+
} catch (d) {
|
|
654
|
+
const h = d instanceof Error ? d : new Error(String(d));
|
|
655
|
+
le("error"), ge(h), m == null || m(z, h), N({
|
|
656
|
+
category: "image",
|
|
657
|
+
message: h.message,
|
|
658
|
+
originalError: h,
|
|
659
|
+
recoverable: !0
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
})();
|
|
663
|
+
}, [z, Re, Ie, ke]), R(() => {
|
|
664
|
+
P == null || P(Ne);
|
|
665
|
+
}, [Ne, P]), R(() => {
|
|
666
|
+
if (!A) return;
|
|
667
|
+
const s = k.getActiveArtboard(), d = {
|
|
668
|
+
elements: V.map((h) => h.toJSON()),
|
|
669
|
+
artboards: L.map((h) => ({
|
|
670
|
+
name: h.name,
|
|
671
|
+
width: h.width,
|
|
672
|
+
height: h.height,
|
|
673
|
+
clipShape: h.clipShape,
|
|
674
|
+
backgroundColor: h.backgroundColor
|
|
675
|
+
})),
|
|
676
|
+
activeArtboard: (s == null ? void 0 : s.name) || "Design"
|
|
677
|
+
};
|
|
678
|
+
A(d);
|
|
679
|
+
}, [V, L, A]), R(() => {
|
|
680
|
+
if (!l || !ve.current) return;
|
|
681
|
+
const s = k.getActiveArtboard();
|
|
682
|
+
s && l(s.name);
|
|
683
|
+
}, [k.getActiveArtboardId()]);
|
|
684
|
+
const ct = B(async () => {
|
|
685
|
+
if (!E && !w) return;
|
|
686
|
+
const s = ++it.current, d = Date.now();
|
|
687
|
+
let h = O;
|
|
688
|
+
if (U > 0 && isFinite(U))
|
|
689
|
+
for (const u of L) {
|
|
690
|
+
const x = Ee(u.width, u.height, O, U);
|
|
691
|
+
h = Math.min(h, x);
|
|
692
|
+
}
|
|
693
|
+
const g = k.getActiveArtboard(), f = (g == null ? void 0 : g.id) ?? "unknown";
|
|
694
|
+
w == null || w({ status: "rendering", artboardId: f }), st.current = d;
|
|
695
|
+
try {
|
|
696
|
+
let u;
|
|
697
|
+
const x = {
|
|
698
|
+
format: te,
|
|
699
|
+
scale: h,
|
|
700
|
+
quality: re
|
|
701
|
+
};
|
|
702
|
+
if (j === "blob")
|
|
703
|
+
if (fe) {
|
|
704
|
+
const b = await ce(x);
|
|
705
|
+
u = {};
|
|
706
|
+
for (const [F, Y] of Object.entries(b)) {
|
|
707
|
+
const X = L.find((Z) => Z.id === F);
|
|
708
|
+
X && (u[X.name] = Y);
|
|
709
|
+
}
|
|
710
|
+
} else {
|
|
711
|
+
const b = k.getActiveArtboard();
|
|
712
|
+
if (!b) return;
|
|
713
|
+
const F = await Q(b.id, x);
|
|
714
|
+
u = { [b.name]: F };
|
|
715
|
+
}
|
|
716
|
+
else if (fe) {
|
|
717
|
+
const b = await ie(x);
|
|
718
|
+
u = {};
|
|
719
|
+
for (const [F, Y] of Object.entries(b)) {
|
|
720
|
+
const X = L.find((Z) => Z.id === F);
|
|
721
|
+
X && (u[X.name] = Y);
|
|
722
|
+
}
|
|
723
|
+
} else {
|
|
724
|
+
const b = k.getActiveArtboard();
|
|
725
|
+
if (!b) return;
|
|
726
|
+
const F = await G(b.id, x);
|
|
727
|
+
u = { [b.name]: F };
|
|
728
|
+
}
|
|
729
|
+
E == null || E(u), w == null || w({ status: "complete", artboardId: f, result: u });
|
|
730
|
+
} catch (u) {
|
|
731
|
+
const x = u instanceof Error ? u.message : String(u);
|
|
732
|
+
if (x.includes("Canvas ref not available"))
|
|
733
|
+
return;
|
|
734
|
+
const b = Date.now() - d;
|
|
735
|
+
K.error("Export failed (export #" + s + "):", {
|
|
736
|
+
duration: `${b}ms`,
|
|
737
|
+
error: x
|
|
738
|
+
});
|
|
739
|
+
const F = u instanceof Error ? u : new Error(x);
|
|
740
|
+
w == null || w({ status: "error", artboardId: f, error: F }), N({
|
|
741
|
+
category: "export",
|
|
742
|
+
message: F.message,
|
|
743
|
+
originalError: F,
|
|
744
|
+
artboardId: f,
|
|
745
|
+
recoverable: !0
|
|
746
|
+
});
|
|
747
|
+
}
|
|
748
|
+
}, [E, w, fe, j, O, U, te, re, G, ie, Q, ce, L, k, V, J, N]);
|
|
749
|
+
R(() => {
|
|
750
|
+
Se !== void 0 && Se > 0 && K.warn(
|
|
751
|
+
"autoExportInterval is deprecated and ignored. Use autoExportConfig={{ enabled: true, debounceMs: 100, maxWaitMs: 1000 }} instead."
|
|
752
|
+
);
|
|
753
|
+
}, []), R(() => {
|
|
754
|
+
}, [V]);
|
|
755
|
+
const lt = B(() => {
|
|
756
|
+
if (M == null || M(), w) {
|
|
757
|
+
const s = k.getActiveArtboard();
|
|
758
|
+
w({ status: "scheduled", artboardId: (s == null ? void 0 : s.id) ?? "unknown" });
|
|
759
|
+
}
|
|
760
|
+
}, [M, w, k]), dt = !!p && p.length > 0, xe = Wt({
|
|
761
|
+
isCanvasReady: he,
|
|
762
|
+
elements: V,
|
|
763
|
+
hasInitialElements: dt,
|
|
764
|
+
initialElementsLoaded: at
|
|
765
|
+
}), $e = T(!1);
|
|
766
|
+
R(() => {
|
|
767
|
+
xe && !$e.current && ($e.current = !0, v == null || v());
|
|
768
|
+
}, [xe, v]), Ft({
|
|
769
|
+
config: J ? {
|
|
770
|
+
enabled: J.enabled ?? !0,
|
|
771
|
+
debounceMs: J.debounceMs ?? 100,
|
|
772
|
+
maxWaitMs: J.maxWaitMs ?? 1e3
|
|
773
|
+
} : {
|
|
774
|
+
enabled: !1
|
|
775
|
+
// Only use smart export if autoExportConfig is provided
|
|
776
|
+
},
|
|
777
|
+
historyManager: tt,
|
|
778
|
+
artboards: L,
|
|
779
|
+
elements: V,
|
|
780
|
+
onExport: ct,
|
|
781
|
+
onExportScheduled: lt,
|
|
782
|
+
isCanvasReady: xe
|
|
783
|
+
// Gate exports until content is fully ready (fonts loaded, elements deserialized)
|
|
784
|
+
}), R(() => {
|
|
785
|
+
if (L.length > 0 && !he) {
|
|
786
|
+
const s = requestAnimationFrame(() => {
|
|
787
|
+
se(!0);
|
|
788
|
+
});
|
|
789
|
+
return () => cancelAnimationFrame(s);
|
|
790
|
+
}
|
|
791
|
+
}, [L.length, he, se]), R(() => () => {
|
|
792
|
+
se(!1);
|
|
793
|
+
}, [se]);
|
|
794
|
+
const ut = B((s) => {
|
|
795
|
+
N({
|
|
796
|
+
category: "unknown",
|
|
797
|
+
message: s.message,
|
|
798
|
+
originalError: s,
|
|
799
|
+
recoverable: !1
|
|
800
|
+
});
|
|
801
|
+
}, [N]);
|
|
802
|
+
return Ue === "loading" ? /* @__PURE__ */ C(
|
|
803
|
+
"div",
|
|
804
|
+
{
|
|
805
|
+
className: W,
|
|
806
|
+
style: {
|
|
807
|
+
...D,
|
|
808
|
+
display: "flex",
|
|
809
|
+
alignItems: "center",
|
|
810
|
+
justifyContent: "center",
|
|
811
|
+
backgroundColor: "var(--surface, #f5f5f5)"
|
|
812
|
+
},
|
|
813
|
+
children: /* @__PURE__ */ C(vt, { size: 48 })
|
|
814
|
+
}
|
|
815
|
+
) : Ue === "error" && ze ? /* @__PURE__ */ C(
|
|
816
|
+
"div",
|
|
817
|
+
{
|
|
818
|
+
className: W,
|
|
819
|
+
style: {
|
|
820
|
+
...D,
|
|
821
|
+
display: "flex",
|
|
822
|
+
alignItems: "center",
|
|
823
|
+
justifyContent: "center",
|
|
824
|
+
backgroundColor: "var(--surface, #f5f5f5)",
|
|
825
|
+
color: "var(--danger, #dc2626)",
|
|
826
|
+
padding: "1rem"
|
|
827
|
+
},
|
|
828
|
+
children: /* @__PURE__ */ de("div", { className: "text-center", children: [
|
|
829
|
+
/* @__PURE__ */ C("div", { className: "font-medium", children: "Failed to load image" }),
|
|
830
|
+
/* @__PURE__ */ C("div", { className: "text-sm mt-1 opacity-70", children: ze.message })
|
|
831
|
+
] })
|
|
832
|
+
}
|
|
833
|
+
) : /* @__PURE__ */ C(xt, { kit: ne, children: /* @__PURE__ */ C("div", { className: `app-modern ${W || ""}`, style: { ...D, position: "relative" }, children: /* @__PURE__ */ de(
|
|
834
|
+
Tt,
|
|
835
|
+
{
|
|
836
|
+
onError: ut,
|
|
837
|
+
fallback: (s, d) => /* @__PURE__ */ de(
|
|
838
|
+
"div",
|
|
839
|
+
{
|
|
840
|
+
style: {
|
|
841
|
+
display: "flex",
|
|
842
|
+
flexDirection: "column",
|
|
843
|
+
alignItems: "center",
|
|
844
|
+
justifyContent: "center",
|
|
845
|
+
padding: "24px",
|
|
846
|
+
minHeight: "200px",
|
|
847
|
+
backgroundColor: "var(--surface, #f5f5f5)",
|
|
848
|
+
color: "var(--foreground, #333)",
|
|
849
|
+
fontFamily: "system-ui, sans-serif",
|
|
850
|
+
textAlign: "center"
|
|
851
|
+
},
|
|
852
|
+
children: [
|
|
853
|
+
/* @__PURE__ */ C("div", { style: { fontSize: "18px", fontWeight: 600, marginBottom: "8px" }, children: "Something went wrong" }),
|
|
854
|
+
/* @__PURE__ */ C("div", { style: { fontSize: "14px", opacity: 0.7, marginBottom: "16px", maxWidth: "400px" }, children: s.message }),
|
|
855
|
+
/* @__PURE__ */ C(
|
|
856
|
+
"button",
|
|
857
|
+
{
|
|
858
|
+
onClick: d,
|
|
859
|
+
style: {
|
|
860
|
+
padding: "8px 20px",
|
|
861
|
+
backgroundColor: "var(--primary, #333)",
|
|
862
|
+
color: "var(--primary-foreground, #fff)",
|
|
863
|
+
border: "none",
|
|
864
|
+
borderRadius: "6px",
|
|
865
|
+
fontSize: "14px",
|
|
866
|
+
fontWeight: 500,
|
|
867
|
+
cursor: "pointer"
|
|
868
|
+
},
|
|
869
|
+
children: "Try again"
|
|
870
|
+
}
|
|
871
|
+
)
|
|
872
|
+
]
|
|
873
|
+
}
|
|
874
|
+
),
|
|
875
|
+
children: [
|
|
876
|
+
!_e && (Pe || He ? /* @__PURE__ */ C("div", { className: Pe, style: He, children: /* @__PURE__ */ C(
|
|
877
|
+
Xe,
|
|
878
|
+
{
|
|
879
|
+
style: { width: "100%" },
|
|
880
|
+
fitPadding: Ce,
|
|
881
|
+
artboardBorderRadius: Me,
|
|
882
|
+
fixedMargin: Te,
|
|
883
|
+
maxHeight: De,
|
|
884
|
+
showRotationHandle: Fe,
|
|
885
|
+
enableShortcuts: Be,
|
|
886
|
+
canvasCutouts: Le,
|
|
887
|
+
pieceGuides: me,
|
|
888
|
+
pieceFocus: We
|
|
889
|
+
}
|
|
890
|
+
) }) : /* @__PURE__ */ C(
|
|
891
|
+
Xe,
|
|
892
|
+
{
|
|
893
|
+
style: { width: "100%" },
|
|
894
|
+
fitPadding: Ce,
|
|
895
|
+
artboardBorderRadius: Me,
|
|
896
|
+
fixedMargin: Te,
|
|
897
|
+
maxHeight: De,
|
|
898
|
+
showRotationHandle: Fe,
|
|
899
|
+
enableShortcuts: Be,
|
|
900
|
+
canvasCutouts: Le,
|
|
901
|
+
pieceGuides: me,
|
|
902
|
+
pieceFocus: We
|
|
903
|
+
}
|
|
904
|
+
)),
|
|
905
|
+
ee
|
|
906
|
+
]
|
|
907
|
+
}
|
|
908
|
+
) }) });
|
|
909
|
+
});
|
|
910
|
+
Je.displayName = "SnowconeCanvasInner";
|
|
911
|
+
const Kt = je((t, e) => {
|
|
912
|
+
var o;
|
|
913
|
+
const { inheritTheme: r, externalProvider: a } = t, n = t.viewPadding ?? ((o = t.layoutConfig) == null ? void 0 : o.viewPadding), c = /* @__PURE__ */ C(Je, { ref: e, ...t });
|
|
914
|
+
return a ? /* @__PURE__ */ C(Oe, { defaultTheme: "light", passive: r, children: c }) : /* @__PURE__ */ C(Oe, { defaultTheme: "light", passive: r, children: /* @__PURE__ */ C(It, { viewPadding: n, children: c }) });
|
|
915
|
+
});
|
|
916
|
+
Kt.displayName = "SnowconeCanvas";
|
|
917
|
+
const Ve = _("useCommands");
|
|
918
|
+
function sr() {
|
|
919
|
+
const t = ue(), {
|
|
920
|
+
undo: e,
|
|
921
|
+
redo: r,
|
|
922
|
+
canUndo: a,
|
|
923
|
+
canRedo: n,
|
|
924
|
+
executeElementUpdate: c,
|
|
925
|
+
executeAddElement: o,
|
|
926
|
+
executeRemoveElement: i,
|
|
927
|
+
executeReorderElement: l,
|
|
928
|
+
executeCommandBatch: p,
|
|
929
|
+
executeCreateArtboard: A,
|
|
930
|
+
executeDeleteArtboard: P,
|
|
931
|
+
executeUpdateArtboard: I
|
|
932
|
+
} = t, E = B(() => {
|
|
933
|
+
Ve.warn("[useCommands] clearHistory is not yet implemented in EditorContext");
|
|
934
|
+
}, []), M = B((w) => {
|
|
935
|
+
Ve.warn("[useCommands] clearArtboardHistory is not yet implemented in EditorContext");
|
|
936
|
+
}, []);
|
|
937
|
+
return {
|
|
938
|
+
// Undo/Redo
|
|
939
|
+
undo: e,
|
|
940
|
+
redo: r,
|
|
941
|
+
canUndo: a,
|
|
942
|
+
canRedo: n,
|
|
943
|
+
// History management
|
|
944
|
+
clearHistory: E,
|
|
945
|
+
clearArtboardHistory: M,
|
|
946
|
+
// Command execution
|
|
947
|
+
executeElementUpdate: c,
|
|
948
|
+
executeAddElement: o,
|
|
949
|
+
executeRemoveElement: i,
|
|
950
|
+
executeReorderElement: l,
|
|
951
|
+
executeCreateArtboard: A,
|
|
952
|
+
executeDeleteArtboard: P,
|
|
953
|
+
executeUpdateArtboard: I,
|
|
954
|
+
// Batch execution
|
|
955
|
+
executeCommandBatch: p
|
|
956
|
+
};
|
|
957
|
+
}
|
|
958
|
+
function ir() {
|
|
959
|
+
const { selectedElement: t } = ue();
|
|
960
|
+
return t ?? null;
|
|
961
|
+
}
|
|
962
|
+
function cr() {
|
|
963
|
+
const { isCanvasReady: t } = ue();
|
|
964
|
+
return t;
|
|
965
|
+
}
|
|
966
|
+
const jt = () => {
|
|
967
|
+
}, Gt = [];
|
|
968
|
+
function lr(t) {
|
|
969
|
+
const { elementStore: e } = Ae(), { executeElementUpdate: r } = Ge(), a = ye(() => e.getAllByName(t).filter((o) => o instanceof At), [e, t]), n = B(
|
|
970
|
+
(c) => {
|
|
971
|
+
for (const o of a) {
|
|
972
|
+
const i = o.clone();
|
|
973
|
+
i.setText(c), r(o, i);
|
|
974
|
+
}
|
|
975
|
+
},
|
|
976
|
+
[a, r]
|
|
977
|
+
);
|
|
978
|
+
return a.length === 0 ? { text: "", setText: jt, element: null, elements: Gt, isConnected: !1 } : {
|
|
979
|
+
text: a[0].getText(),
|
|
980
|
+
setText: n,
|
|
981
|
+
element: a[0],
|
|
982
|
+
elements: a,
|
|
983
|
+
isConnected: !0
|
|
984
|
+
};
|
|
985
|
+
}
|
|
986
|
+
const Qt = () => {
|
|
987
|
+
}, Jt = [];
|
|
988
|
+
function Zt(t, e, r) {
|
|
989
|
+
const a = t / e;
|
|
990
|
+
if (r >= a) {
|
|
991
|
+
const n = e, c = n * r, o = t / c;
|
|
992
|
+
return {
|
|
993
|
+
width: c,
|
|
994
|
+
height: n,
|
|
995
|
+
cropX: (1 - o) / 2,
|
|
996
|
+
cropY: 0,
|
|
997
|
+
cropWidth: o,
|
|
998
|
+
cropHeight: 1
|
|
999
|
+
};
|
|
1000
|
+
} else {
|
|
1001
|
+
const n = t, c = n / r, o = e / c;
|
|
1002
|
+
return {
|
|
1003
|
+
width: n,
|
|
1004
|
+
height: c,
|
|
1005
|
+
cropX: 0,
|
|
1006
|
+
cropY: (1 - o) / 2,
|
|
1007
|
+
cropWidth: 1,
|
|
1008
|
+
cropHeight: o
|
|
1009
|
+
};
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
function dr(t, e) {
|
|
1013
|
+
const r = (e == null ? void 0 : e.fit) ?? "cover", { elementStore: a, setElements: n } = Ae(), { executeElementUpdate: c } = Ge(), o = ye(() => a.getAllByName(t).filter((E) => E instanceof Ke), [a, t]), i = T(/* @__PURE__ */ new Map());
|
|
1014
|
+
for (const I of o)
|
|
1015
|
+
if (!i.current.has(I.id)) {
|
|
1016
|
+
const E = I.transformData;
|
|
1017
|
+
i.current.set(I.id, {
|
|
1018
|
+
width: E.width * E.cropWidth,
|
|
1019
|
+
height: E.height * E.cropHeight
|
|
1020
|
+
});
|
|
1021
|
+
}
|
|
1022
|
+
const l = T(o);
|
|
1023
|
+
l.current = o;
|
|
1024
|
+
const p = T(c);
|
|
1025
|
+
p.current = c;
|
|
1026
|
+
const A = T(n);
|
|
1027
|
+
A.current = n;
|
|
1028
|
+
const P = B(
|
|
1029
|
+
(I) => {
|
|
1030
|
+
const E = l.current, M = p.current;
|
|
1031
|
+
A.current;
|
|
1032
|
+
for (const w of E) {
|
|
1033
|
+
const H = i.current.get(w.id);
|
|
1034
|
+
if (!H) continue;
|
|
1035
|
+
const { width: y, height: m } = H, S = w.clone();
|
|
1036
|
+
S.imageLoaded = !1, S.imageElement = null, S.isCropping = !1, S.imageUrl = I, r === "cover" ? (S.preserveDimensions = !0, S.onLoadCallback = (v) => {
|
|
1037
|
+
const W = v.imageAspectRatio || 1, D = Zt(y, m, W);
|
|
1038
|
+
v.transformData.width = D.width, v.transformData.height = D.height, v.transformData.cropX = D.cropX, v.transformData.cropY = D.cropY, v.transformData.cropWidth = D.cropWidth, v.transformData.cropHeight = D.cropHeight, M(w, v);
|
|
1039
|
+
}) : (S.preserveDimensions = !1, S.onLoadCallback = (v) => {
|
|
1040
|
+
const W = v.transformData.width, D = v.transformData.height, $ = Math.min(y / W, m / D, 1);
|
|
1041
|
+
$ < 1 && (v.transformData.width = W * $, v.transformData.height = D * $), v.transformData.cropX = 0, v.transformData.cropY = 0, v.transformData.cropWidth = 1, v.transformData.cropHeight = 1, M(w, v);
|
|
1042
|
+
}), S.loadImage(I);
|
|
1043
|
+
}
|
|
1044
|
+
},
|
|
1045
|
+
[r]
|
|
1046
|
+
// Stable deps only — imageElements/executeElementUpdate/setElements accessed via refs
|
|
1047
|
+
);
|
|
1048
|
+
return o.length === 0 ? { imageUrl: "", setImageUrl: Qt, element: null, elements: Jt, isConnected: !1 } : {
|
|
1049
|
+
imageUrl: o[0].imageUrl,
|
|
1050
|
+
setImageUrl: P,
|
|
1051
|
+
element: o[0],
|
|
1052
|
+
elements: o,
|
|
1053
|
+
isConnected: !0
|
|
1054
|
+
};
|
|
1055
|
+
}
|
|
1056
|
+
function ur(t) {
|
|
1057
|
+
const { elementStore: e } = Ae();
|
|
1058
|
+
return t ? e.getByName(t) ?? null : null;
|
|
1059
|
+
}
|
|
1060
|
+
function fr() {
|
|
1061
|
+
const { zoom: t, panOffset: e, zoomIn: r, zoomOut: a, zoomToFit: n, resetView: c, setZoom: o, setPanOffset: i } = kt();
|
|
1062
|
+
return { zoom: t, panOffset: e, zoomIn: r, zoomOut: a, zoomToFit: n, resetView: c, setZoom: o, setPanOffset: i };
|
|
1063
|
+
}
|
|
1064
|
+
function mr(t) {
|
|
1065
|
+
var a;
|
|
1066
|
+
const e = ((a = t.artboards) == null ? void 0 : a[0]) || { name: "Front", width: 800, height: 800 }, r = (t.elements || []).map(qt);
|
|
1067
|
+
return {
|
|
1068
|
+
artboards: [{
|
|
1069
|
+
id: "artboard-1",
|
|
1070
|
+
name: e.name || "Front",
|
|
1071
|
+
x: 0,
|
|
1072
|
+
y: 0,
|
|
1073
|
+
width: e.width || 800,
|
|
1074
|
+
height: e.height || 800,
|
|
1075
|
+
backgroundColor: e.backgroundColor || "transparent",
|
|
1076
|
+
exportBackground: !1,
|
|
1077
|
+
elements: r,
|
|
1078
|
+
distressTexture: e.distressTexture,
|
|
1079
|
+
imageMask: e.imageMask
|
|
1080
|
+
}]
|
|
1081
|
+
};
|
|
1082
|
+
}
|
|
1083
|
+
function qt(t) {
|
|
1084
|
+
const e = t.type || t.transformType;
|
|
1085
|
+
return e === "image" ? _t(t) : {
|
|
1086
|
+
...t,
|
|
1087
|
+
type: e
|
|
1088
|
+
};
|
|
1089
|
+
}
|
|
1090
|
+
function _t(t) {
|
|
1091
|
+
var p;
|
|
1092
|
+
const e = t.transformData || {}, r = t.masks && t.masks.length > 0, a = e.width || 0, n = e.height || 0, c = r ? a : a * (e.cropWidth ?? 1), o = r ? n : n * (e.cropHeight ?? 1), i = {
|
|
1093
|
+
id: t.id,
|
|
1094
|
+
type: "image",
|
|
1095
|
+
x: t.x || 0,
|
|
1096
|
+
y: t.y || 0,
|
|
1097
|
+
width: c,
|
|
1098
|
+
height: o,
|
|
1099
|
+
rotation: t.rotation || 0,
|
|
1100
|
+
imageUrl: t.imageUrl,
|
|
1101
|
+
imageAspectRatio: t.imageAspectRatio
|
|
1102
|
+
};
|
|
1103
|
+
return !r && (e.cropX !== 0 || e.cropY !== 0 || e.cropWidth !== 1 || e.cropHeight !== 1) && (i.cropX = e.cropX, i.cropY = e.cropY, i.cropWidth = e.cropWidth, i.cropHeight = e.cropHeight, i.needsCropPixelConversion = !0), e.flipHorizontal && (i.flipHorizontal = e.flipHorizontal), e.flipVertical && (i.flipVertical = e.flipVertical), e.borderRadius && (i.borderRadius = e.borderRadius), t.opacity !== void 0 && (i.opacity = t.opacity), t.distressEffect && (i.distressEffect = t.distressEffect), ((p = t.masks) == null ? void 0 : p.length) > 0 && (i.masks = t.masks), t.blendMode && (i.blendMode = t.blendMode), t.knockoutParts && (i.knockoutParts = t.knockoutParts), t.stroke && (i.stroke = t.stroke), i;
|
|
1104
|
+
}
|
|
1105
|
+
wt();
|
|
1106
|
+
export {
|
|
1107
|
+
pr as ALL_CAPABILITIES,
|
|
1108
|
+
br as COMPACT_CUSTOMIZER,
|
|
1109
|
+
vr as EMBED_ONLY,
|
|
1110
|
+
Tt as ErrorBoundary,
|
|
1111
|
+
xr as MINIMAL_CAPABILITIES,
|
|
1112
|
+
wr as PRO_STUDIO,
|
|
1113
|
+
Kt as SnowconeCanvas,
|
|
1114
|
+
Er as createKit,
|
|
1115
|
+
Kt as default,
|
|
1116
|
+
Rr as deserializeState,
|
|
1117
|
+
yr as extendKit,
|
|
1118
|
+
Ir as migrateState,
|
|
1119
|
+
ht as resolveKit,
|
|
1120
|
+
kr as serializeState,
|
|
1121
|
+
mr as serializeStateForServer,
|
|
1122
|
+
pt as useArtboards,
|
|
1123
|
+
Ft as useAutoExport,
|
|
1124
|
+
cr as useCanvasReady,
|
|
1125
|
+
sr as useCommands,
|
|
1126
|
+
Wt as useContentReady,
|
|
1127
|
+
ue as useEditor,
|
|
1128
|
+
ur as useElementByName,
|
|
1129
|
+
bt as useExport,
|
|
1130
|
+
dr as useImageBinding,
|
|
1131
|
+
Ar as useLayers,
|
|
1132
|
+
ir as useSelectedElement,
|
|
1133
|
+
lr as useTextBinding,
|
|
1134
|
+
fr as useViewport,
|
|
1135
|
+
gt as validateKit,
|
|
1136
|
+
Cr as validateState
|
|
1137
|
+
};
|
|
1138
|
+
//# sourceMappingURL=index.mjs.map
|