@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,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public types barrel for @snowcone-app/canvas
|
|
3
|
+
*
|
|
4
|
+
* Re-exports all types that external consumers (e.g., snowcone-shopify) may need.
|
|
5
|
+
* Organized by domain for discoverability.
|
|
6
|
+
*/
|
|
7
|
+
export { TextElement } from '../core/TextElement.js';
|
|
8
|
+
export { ImageElement } from '../core/ImageElement.js';
|
|
9
|
+
export { GroupElement } from '../core/GroupElement.js';
|
|
10
|
+
export { ShapeElement } from '../core/ShapeElement.js';
|
|
11
|
+
export { PathElement } from '../core/PathElement.js';
|
|
12
|
+
export { ArtboardElement } from '../core/ArtboardElement.js';
|
|
13
|
+
export { BaseElement } from '../core/BaseElement.js';
|
|
14
|
+
export type { EditorElement } from '../contexts/EditorContext.js';
|
|
15
|
+
export type { TransformType, AnyTransformData, CustomTransformData, DistortTransformData, CircleTransformData, LeanTransformData, ArchTransformData, AscendTransformData, WaveTransformData, FlagTransformData, ImageTransformData, GroupTransformData, ArtboardTransformData, ShapeTransformData, PathTransformData, } from './index.js';
|
|
16
|
+
export type { AnyElementConfig, BaseElementConfig, BaseTextElementConfig, TextOnlyElementConfig, CustomElementConfig, DistortElementConfig, CircleElementConfig, LeanElementConfig, ArchElementConfig, AscendElementConfig, WaveElementConfig, FlagElementConfig, ImageElementConfig, GroupElementConfig, ShapeElementConfig, PathElementConfig, } from './index.js';
|
|
17
|
+
export type { ArtboardConfig as ArtboardElementConfig, ArtboardBackgroundType, ClipShape, } from './index.js';
|
|
18
|
+
export type { BoundingBox, Point, ResizeAnchor, } from './index.js';
|
|
19
|
+
export type { BlendMode, KnockoutScope, KnockoutConfig, StrokeConfig, MaskType, MaskDefinition, DistressStyle, DistressEffect, } from './index.js';
|
|
20
|
+
export type { TextAlign, CharacterStyle, TextSpan, GlyphOverride, GlyphAlternate, OpenTypeFeatures, } from './index.js';
|
|
21
|
+
export { RichText } from './index.js';
|
|
22
|
+
export type { ShapeType, } from './index.js';
|
|
23
|
+
export type { PathPointType, PathPoint, } from './index.js';
|
|
24
|
+
export type { InteractionMode, SelectionState, TransformStartData, } from './index.js';
|
|
25
|
+
export type { RenderingContext, } from './index.js';
|
|
26
|
+
export type { CanvasError, CanvasErrorCategory, } from './index.js';
|
|
27
|
+
export type { Theme } from '../contexts/ThemeContext.js';
|
|
28
|
+
export { isTextElementConfig, isImageElementConfig, isCustomElementConfig, isCircleElementConfig, isLeanElementConfig, isArchElementConfig, isAscendElementConfig, isWaveElementConfig, isFlagElementConfig, isGroupElementConfig, isShapeElementConfig, isPathElementConfig, } from './index.js';
|
|
29
|
+
export { isCustomTransform, isDistortTransform, isCircleTransform, isLeanTransform, isArchTransform, isAscendTransform, isWaveTransform, isFlagTransform, isImageTransform, isGroupTransform, isArtboardTransform, isShapeTransform, isPathTransform, } from './index.js';
|
|
30
|
+
export { hasStroke, hasMasks, isKnockout, hasDistressEffect, } from './index.js';
|
|
31
|
+
export { isTextElement, isImageElement, isGroupElement, isShapeElement, isPathElement, } from './guards.js';
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { AnyElementConfig, TransformType, TextAlign, Command, HandleInfo } from './index';
|
|
2
|
+
import { BaseElement } from '../core/BaseElement';
|
|
3
|
+
export type AnyElement = BaseElement;
|
|
4
|
+
export interface CanvasEditorProps {
|
|
5
|
+
elements: AnyElement[];
|
|
6
|
+
selectedId: string | null;
|
|
7
|
+
onElementUpdate: (oldElement: AnyElement, newElement: AnyElement) => void;
|
|
8
|
+
onSelectionChange: (newSelectedId: string | null) => void;
|
|
9
|
+
}
|
|
10
|
+
export interface AppProps {
|
|
11
|
+
}
|
|
12
|
+
export interface TransformControlPanelProps {
|
|
13
|
+
element: AnyElement;
|
|
14
|
+
onUpdate: (updates: Partial<AnyElementConfig>) => void;
|
|
15
|
+
}
|
|
16
|
+
export interface ImageToolbarProps {
|
|
17
|
+
element: AnyElement;
|
|
18
|
+
onUpdate: (updates: Partial<AnyElementConfig>) => void;
|
|
19
|
+
onEnterCropMode?: () => void;
|
|
20
|
+
onExitCropMode?: () => void;
|
|
21
|
+
}
|
|
22
|
+
export interface BackButtonProps {
|
|
23
|
+
onClick: () => void;
|
|
24
|
+
label?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface TooltipProps {
|
|
27
|
+
text: string;
|
|
28
|
+
children: React.ReactNode;
|
|
29
|
+
position?: 'top' | 'bottom' | 'left' | 'right';
|
|
30
|
+
delay?: number;
|
|
31
|
+
}
|
|
32
|
+
export interface MoreMenuProps {
|
|
33
|
+
items: ToolbarItem[];
|
|
34
|
+
onItemClick: (item: ToolbarItem) => void;
|
|
35
|
+
selectedElement?: AnyElement;
|
|
36
|
+
}
|
|
37
|
+
export interface ColorPickerDropdownProps {
|
|
38
|
+
currentColor: string;
|
|
39
|
+
onChange: (color: string) => void;
|
|
40
|
+
documentColors?: string[];
|
|
41
|
+
isOpen?: boolean;
|
|
42
|
+
onToggle?: () => void;
|
|
43
|
+
}
|
|
44
|
+
export interface FontBrowserDrawerProps {
|
|
45
|
+
currentFont: string;
|
|
46
|
+
onChange: (fontFamily: string) => void;
|
|
47
|
+
isOpen?: boolean;
|
|
48
|
+
onToggle?: () => void;
|
|
49
|
+
}
|
|
50
|
+
export interface FontSizeDropdownProps {
|
|
51
|
+
currentSize: number;
|
|
52
|
+
onChange: (fontSize: number) => void;
|
|
53
|
+
isOpen?: boolean;
|
|
54
|
+
onToggle?: () => void;
|
|
55
|
+
}
|
|
56
|
+
export interface ToolbarItem {
|
|
57
|
+
id: string;
|
|
58
|
+
label: string;
|
|
59
|
+
icon?: React.ReactNode;
|
|
60
|
+
action: () => void;
|
|
61
|
+
active?: boolean;
|
|
62
|
+
priority?: number;
|
|
63
|
+
type?: 'button' | 'toggle' | 'dropdown' | 'separator';
|
|
64
|
+
}
|
|
65
|
+
export interface ToolbarPriorities {
|
|
66
|
+
[key: string]: number;
|
|
67
|
+
}
|
|
68
|
+
export interface CommandHistoryHook {
|
|
69
|
+
canUndo: boolean;
|
|
70
|
+
canRedo: boolean;
|
|
71
|
+
undo: () => void;
|
|
72
|
+
redo: () => void;
|
|
73
|
+
execute: (command: Command) => void;
|
|
74
|
+
clear: () => void;
|
|
75
|
+
}
|
|
76
|
+
export interface ElementPropertiesHook {
|
|
77
|
+
fontSize: number;
|
|
78
|
+
fontFamily: string;
|
|
79
|
+
color: string;
|
|
80
|
+
textAlign: TextAlign;
|
|
81
|
+
bold: boolean;
|
|
82
|
+
italic: boolean;
|
|
83
|
+
underline: boolean;
|
|
84
|
+
strikethrough: boolean;
|
|
85
|
+
updateProperty: (property: string, value: string | number | boolean) => void;
|
|
86
|
+
updateProperties: (properties: Record<string, string | number | boolean>) => void;
|
|
87
|
+
}
|
|
88
|
+
export type ElementUpdateHandler = (oldElement: AnyElement, newElement: AnyElement) => void;
|
|
89
|
+
export type SelectionChangeHandler = (elementId: string | null) => void;
|
|
90
|
+
export type PropertyUpdateHandler = (property: string, value: string | number | boolean) => void;
|
|
91
|
+
export type TransformChangeHandler = (transformType: TransformType) => void;
|
|
92
|
+
export type AddElementHandler = (element: AnyElement) => void;
|
|
93
|
+
export type DeleteElementHandler = (elementId: string) => void;
|
|
94
|
+
export type MenuState = 'root' | 'transforms' | 'font' | 'align' | 'color';
|
|
95
|
+
export interface MenuStateManager {
|
|
96
|
+
activeMenu: MenuState;
|
|
97
|
+
setActiveMenu: (menu: MenuState) => void;
|
|
98
|
+
goBack: () => void;
|
|
99
|
+
}
|
|
100
|
+
export type DropdownType = 'fontSize' | 'fontFamily' | 'color' | null;
|
|
101
|
+
export interface DropdownStateManager {
|
|
102
|
+
openDropdown: DropdownType;
|
|
103
|
+
setOpenDropdown: (dropdown: DropdownType) => void;
|
|
104
|
+
closeDropdown: () => void;
|
|
105
|
+
}
|
|
106
|
+
export interface CanvasSize {
|
|
107
|
+
width: number;
|
|
108
|
+
height: number;
|
|
109
|
+
}
|
|
110
|
+
export interface EditState {
|
|
111
|
+
isEditing: boolean;
|
|
112
|
+
editText: string;
|
|
113
|
+
editPosition: {
|
|
114
|
+
x: number;
|
|
115
|
+
y: number;
|
|
116
|
+
width: number;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
export interface RotationState {
|
|
120
|
+
isRotating: boolean;
|
|
121
|
+
rotationStartAngle: number;
|
|
122
|
+
currentRotation: number;
|
|
123
|
+
}
|
|
124
|
+
export interface HoverState {
|
|
125
|
+
type: 'element' | 'resize-handle' | 'rotation-handle' | null;
|
|
126
|
+
data: BaseElement | HandleInfo | null;
|
|
127
|
+
}
|
|
128
|
+
export type CanvasRef = React.RefObject<HTMLCanvasElement>;
|
|
129
|
+
export type InputRef = React.RefObject<HTMLInputElement>;
|
|
130
|
+
export type CanvasEditorComponent = React.FC<CanvasEditorProps>;
|
|
131
|
+
export type AppComponent = React.FC<AppProps>;
|
|
132
|
+
export type ToolbarComponent = React.FC<Record<string, unknown>>;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ArtworkPlacement - Utility for calculating artwork position and scale
|
|
3
|
+
*
|
|
4
|
+
* Uses "cover" logic (like CSS object-fit: cover) to ensure artwork fills
|
|
5
|
+
* the entire artboard while maintaining aspect ratio.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* 9-point alignment options for positioning artwork
|
|
9
|
+
*/
|
|
10
|
+
export type Alignment = 'tl' | 't' | 'tr' | 'l' | 'c' | 'r' | 'bl' | 'b' | 'br';
|
|
11
|
+
/**
|
|
12
|
+
* Scale mode for artwork placement
|
|
13
|
+
* - "cover" (default): fills entire area, may crop (like CSS object-fit: cover)
|
|
14
|
+
* - "contain": fits entirely inside area, may have empty space (like CSS object-fit: contain)
|
|
15
|
+
*/
|
|
16
|
+
export type ScaleMode = 'cover' | 'contain';
|
|
17
|
+
/**
|
|
18
|
+
* Placement configuration for artwork positioning
|
|
19
|
+
*/
|
|
20
|
+
export interface PlacementConfig {
|
|
21
|
+
/** Artboard width in pixels */
|
|
22
|
+
width: number;
|
|
23
|
+
/** Artboard height in pixels */
|
|
24
|
+
height: number;
|
|
25
|
+
/** User scale multiplier (default: 1) */
|
|
26
|
+
scale?: number;
|
|
27
|
+
/** 9-point alignment (default: "c" for center) */
|
|
28
|
+
align?: Alignment;
|
|
29
|
+
/** X offset in range -1 to 1 (default: 0) */
|
|
30
|
+
offsetX?: number;
|
|
31
|
+
/** Y offset in range -1 to 1 (default: 0) */
|
|
32
|
+
offsetY?: number;
|
|
33
|
+
/** Scale mode: "cover" fills area (may crop), "contain" fits inside (may have space). Default: "cover" */
|
|
34
|
+
scaleMode?: ScaleMode;
|
|
35
|
+
/** Top margin in pixels (reduces available area in contain mode) */
|
|
36
|
+
marginTop?: number;
|
|
37
|
+
/** Right margin in pixels (reduces available area in contain mode) */
|
|
38
|
+
marginRight?: number;
|
|
39
|
+
/** Bottom margin in pixels (reduces available area in contain mode) */
|
|
40
|
+
marginBottom?: number;
|
|
41
|
+
/** Left margin in pixels (reduces available area in contain mode) */
|
|
42
|
+
marginLeft?: number;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Result of artwork placement calculation
|
|
46
|
+
*/
|
|
47
|
+
export interface ArtworkPlacementResult {
|
|
48
|
+
/** Final scale to apply to artwork */
|
|
49
|
+
scale: number;
|
|
50
|
+
/** Final artwork dimensions after scaling */
|
|
51
|
+
width: number;
|
|
52
|
+
height: number;
|
|
53
|
+
/** Position to draw artwork (relative to artboard origin) */
|
|
54
|
+
x: number;
|
|
55
|
+
y: number;
|
|
56
|
+
/** Debug information */
|
|
57
|
+
debug: {
|
|
58
|
+
coverScale: number;
|
|
59
|
+
userScale: number;
|
|
60
|
+
overflow: {
|
|
61
|
+
x: number;
|
|
62
|
+
y: number;
|
|
63
|
+
};
|
|
64
|
+
alignment: string;
|
|
65
|
+
appliedOffset: {
|
|
66
|
+
x: number;
|
|
67
|
+
y: number;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Map string alignment values to 9-point grid
|
|
73
|
+
*/
|
|
74
|
+
export declare const alignmentMap: Record<string, Alignment>;
|
|
75
|
+
/**
|
|
76
|
+
* Get Alignment from string (supports various naming conventions)
|
|
77
|
+
*/
|
|
78
|
+
export declare function getAlignment(value: string | Alignment | undefined): Alignment;
|
|
79
|
+
/**
|
|
80
|
+
* Calculates how to size and position artwork on an artboard
|
|
81
|
+
* Uses "cover" logic (like CSS object-fit: cover) to ensure artwork fills the entire area
|
|
82
|
+
*
|
|
83
|
+
* @param artwork - The artwork dimensions
|
|
84
|
+
* @param placement - The placement configuration
|
|
85
|
+
* @returns Positioning and scaling information
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* const result = calculateArtworkPlacement(
|
|
89
|
+
* { width: 1000, height: 1000 }, // Square artwork
|
|
90
|
+
* { width: 500, height: 800 } // Tall artboard
|
|
91
|
+
* );
|
|
92
|
+
* // Result: artwork scaled to 800x800, positioned at x: -150, y: 0
|
|
93
|
+
*/
|
|
94
|
+
export declare function calculateArtworkPlacement(artwork: {
|
|
95
|
+
width: number;
|
|
96
|
+
height: number;
|
|
97
|
+
}, placement: PlacementConfig): ArtworkPlacementResult;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { TextElement } from '../core/TextElement.js';
|
|
2
|
+
import { ImageElement } from '../core/ImageElement.js';
|
|
3
|
+
import { GroupElement } from '../core/GroupElement.js';
|
|
4
|
+
import { ShapeElement } from '../core/ShapeElement.js';
|
|
5
|
+
import { PathElement } from '../core/PathElement.js';
|
|
6
|
+
type LayerElement = TextElement | ImageElement | GroupElement | ShapeElement | PathElement;
|
|
7
|
+
export interface PreviewOptions {
|
|
8
|
+
width?: number;
|
|
9
|
+
height?: number;
|
|
10
|
+
padding?: number;
|
|
11
|
+
backgroundColor?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Generate a thumbnail preview for an element
|
|
15
|
+
* Returns a data URL that can be used as an image src
|
|
16
|
+
* Uses the element's actual renderContent method for accurate representation
|
|
17
|
+
*/
|
|
18
|
+
export declare function generateElementPreview(element: LayerElement, options?: PreviewOptions): string;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { ArtboardElement } from '../core/ArtboardElement.js';
|
|
2
|
+
import { TextElement } from '../core/TextElement.js';
|
|
3
|
+
import { ImageElement } from '../core/ImageElement.js';
|
|
4
|
+
import { GroupElement } from '../core/GroupElement.js';
|
|
5
|
+
import { ShapeElement } from '../core/ShapeElement.js';
|
|
6
|
+
import { PathElement } from '../core/PathElement.js';
|
|
7
|
+
import { ArtboardManager } from '../core/ArtboardManager.js';
|
|
8
|
+
import { AnyElementConfig } from '../types/index.js';
|
|
9
|
+
/** Union of all element types supported by export */
|
|
10
|
+
type ExportElement = TextElement | ImageElement | GroupElement | ShapeElement | PathElement;
|
|
11
|
+
/** Serialized workspace document for JSON import/export. */
|
|
12
|
+
export interface CanvasDocument {
|
|
13
|
+
metadata: {
|
|
14
|
+
version: string;
|
|
15
|
+
timestamp: string;
|
|
16
|
+
appVersion?: string;
|
|
17
|
+
};
|
|
18
|
+
artboards: Array<{
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
x: number;
|
|
22
|
+
y: number;
|
|
23
|
+
width: number;
|
|
24
|
+
height: number;
|
|
25
|
+
backgroundColor: string;
|
|
26
|
+
elements: AnyElementConfig[];
|
|
27
|
+
}>;
|
|
28
|
+
activeArtboardId: string | null;
|
|
29
|
+
}
|
|
30
|
+
/** Options for image export operations. */
|
|
31
|
+
export interface ExportImageOptions {
|
|
32
|
+
/** Image format. Default: `'png'`. */
|
|
33
|
+
format?: 'png' | 'jpg' | 'jpeg' | 'webp';
|
|
34
|
+
/** Compression quality for JPEG/WebP (0-1). Ignored for PNG. Default: 0.92. */
|
|
35
|
+
quality?: number;
|
|
36
|
+
/** Resolution multiplier (1x, 2x, 3x). Default: 3. */
|
|
37
|
+
scale?: number;
|
|
38
|
+
/** Export with transparent background. Should be `true` for print-on-demand designs. Default: true. */
|
|
39
|
+
transparentBackground?: boolean;
|
|
40
|
+
/** Background color when `transparentBackground` is false. */
|
|
41
|
+
backgroundColor?: string;
|
|
42
|
+
/** Suggested filename for downloads. */
|
|
43
|
+
filename?: string;
|
|
44
|
+
/** Force main-thread rendering (skip Web Worker). Useful for debugging. */
|
|
45
|
+
forceMainThread?: boolean;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Static utility class for exporting workspace data and artboard images.
|
|
49
|
+
*
|
|
50
|
+
* All methods are static -- there is no need to instantiate this class.
|
|
51
|
+
* Internally delegates to {@link WorkerExportManager} for non-blocking
|
|
52
|
+
* image exports when the browser supports `OffscreenCanvas`.
|
|
53
|
+
*/
|
|
54
|
+
export declare class ExportManager {
|
|
55
|
+
private static readonly CURRENT_VERSION;
|
|
56
|
+
private static workerManager;
|
|
57
|
+
private static workerInitPromise;
|
|
58
|
+
/**
|
|
59
|
+
* Check if worker export is supported in this browser
|
|
60
|
+
*/
|
|
61
|
+
static supportsWorkerExport(): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Get or initialize the worker manager
|
|
64
|
+
*/
|
|
65
|
+
private static getWorkerManager;
|
|
66
|
+
/**
|
|
67
|
+
* Terminate the worker (for cleanup)
|
|
68
|
+
*/
|
|
69
|
+
static terminateWorker(): void;
|
|
70
|
+
/**
|
|
71
|
+
* Export entire workspace to JSON
|
|
72
|
+
*/
|
|
73
|
+
static exportToJSON(artboards: ArtboardElement[], elements: ExportElement[], artboardManager: ArtboardManager, filename?: string): void;
|
|
74
|
+
/**
|
|
75
|
+
* Export artboard to image
|
|
76
|
+
* Uses worker if supported, falls back to main thread
|
|
77
|
+
*/
|
|
78
|
+
static exportArtboardToImage(artboard: ArtboardElement, elements: ExportElement[], canvasElement: HTMLCanvasElement, options?: ExportImageOptions): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Export artboard to data URL (for preview/testing)
|
|
81
|
+
* Uses worker if supported, falls back to main thread
|
|
82
|
+
*/
|
|
83
|
+
static exportArtboardToDataURL(artboard: ArtboardElement, elements: ExportElement[], canvasElement: HTMLCanvasElement, options?: ExportImageOptions): Promise<string>;
|
|
84
|
+
/**
|
|
85
|
+
* Export artboard as Blob (more efficient for API uploads)
|
|
86
|
+
* Returns a Blob instead of data URL - smaller payload, faster for network operations
|
|
87
|
+
* Uses worker if supported, falls back to main thread
|
|
88
|
+
*/
|
|
89
|
+
static exportArtboardToBlob(artboard: ArtboardElement, elements: ExportElement[], canvasElement: HTMLCanvasElement, options?: ExportImageOptions): Promise<Blob>;
|
|
90
|
+
/**
|
|
91
|
+
* Main thread export to Blob (fallback/legacy method).
|
|
92
|
+
*
|
|
93
|
+
* On iOS WebKit this is also the *primary* path (`isIOSWebKit()` skips the
|
|
94
|
+
* worker), so font readiness matters here even when no fallback occurred.
|
|
95
|
+
*/
|
|
96
|
+
private static mainThreadExportToBlob;
|
|
97
|
+
/**
|
|
98
|
+
* Main thread export to data URL (fallback/legacy method).
|
|
99
|
+
*
|
|
100
|
+
* On iOS WebKit this is also the *primary* path (`isIOSWebKit()` skips the
|
|
101
|
+
* worker), so font readiness matters here even when no fallback occurred.
|
|
102
|
+
*/
|
|
103
|
+
private static mainThreadExportToDataURL;
|
|
104
|
+
/**
|
|
105
|
+
* Apply clip path for export background (uses 0,0 as origin since background is drawn before translate)
|
|
106
|
+
*/
|
|
107
|
+
private static applyExportBackgroundClipPath;
|
|
108
|
+
/**
|
|
109
|
+
* Apply clip path for export based on artboard's clipShape
|
|
110
|
+
* This creates the clip region for the given artboard during export
|
|
111
|
+
*/
|
|
112
|
+
private static applyExportClipPath;
|
|
113
|
+
/**
|
|
114
|
+
* Export all artboards as separate images (HIGH PERFORMANCE - parallel rendering)
|
|
115
|
+
*/
|
|
116
|
+
static exportAllArtboardsToImages(artboards: ArtboardElement[], elements: ExportElement[], canvasElement: HTMLCanvasElement, options?: ExportImageOptions): Promise<void>;
|
|
117
|
+
/**
|
|
118
|
+
* Download a blob as a file
|
|
119
|
+
*/
|
|
120
|
+
private static downloadBlob;
|
|
121
|
+
/**
|
|
122
|
+
* Convert data URL to blob
|
|
123
|
+
*/
|
|
124
|
+
private static dataUrlToBlob;
|
|
125
|
+
/**
|
|
126
|
+
* Get export summary (for UI display)
|
|
127
|
+
*/
|
|
128
|
+
static getExportSummary(artboards: ArtboardElement[], elements: ExportElement[]): {
|
|
129
|
+
artboardCount: number;
|
|
130
|
+
totalElementCount: number;
|
|
131
|
+
estimatedFileSize: string;
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Performance benchmark: Compare worker vs main thread export
|
|
135
|
+
* Returns timing data for both methods
|
|
136
|
+
*/
|
|
137
|
+
static benchmarkExport(artboard: ArtboardElement, elements: ExportElement[], canvasElement: HTMLCanvasElement, options?: ExportImageOptions): Promise<{
|
|
138
|
+
workerSupported: boolean;
|
|
139
|
+
mainThread: {
|
|
140
|
+
time: number;
|
|
141
|
+
dataUrl: string;
|
|
142
|
+
};
|
|
143
|
+
worker?: {
|
|
144
|
+
time: number;
|
|
145
|
+
dataUrl: string;
|
|
146
|
+
mainThreadBlockTime: number;
|
|
147
|
+
};
|
|
148
|
+
speedup?: number;
|
|
149
|
+
recommendation: string;
|
|
150
|
+
}>;
|
|
151
|
+
/**
|
|
152
|
+
* Performance benchmark: Test continuous exports to measure UI impact
|
|
153
|
+
* Returns statistics about export performance over time
|
|
154
|
+
*/
|
|
155
|
+
static benchmarkContinuousExport(artboard: ArtboardElement, elements: ExportElement[], canvasElement: HTMLCanvasElement, options?: {
|
|
156
|
+
duration?: number;
|
|
157
|
+
interval?: number;
|
|
158
|
+
useWorker?: boolean;
|
|
159
|
+
}): Promise<{
|
|
160
|
+
totalExports: number;
|
|
161
|
+
duration: number;
|
|
162
|
+
averageTime: number;
|
|
163
|
+
minTime: number;
|
|
164
|
+
maxTime: number;
|
|
165
|
+
totalMainThreadBlockTime: number;
|
|
166
|
+
exportsPerSecond: number;
|
|
167
|
+
recommendation: string;
|
|
168
|
+
}>;
|
|
169
|
+
/**
|
|
170
|
+
* Get performance statistics for the worker (if initialized)
|
|
171
|
+
*/
|
|
172
|
+
static getWorkerStats(): {
|
|
173
|
+
workerSupported: boolean;
|
|
174
|
+
workerInitialized: boolean;
|
|
175
|
+
workerStatus?: {
|
|
176
|
+
isReady: boolean;
|
|
177
|
+
pendingRequests: number;
|
|
178
|
+
queuedRequests: number;
|
|
179
|
+
crashCount: number;
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* Get recommended export options for t-shirt designs
|
|
184
|
+
* T-shirt designs should ALWAYS use transparent backgrounds with knockout effects
|
|
185
|
+
*/
|
|
186
|
+
static getTShirtExportOptions(options?: Partial<ExportImageOptions>): ExportImageOptions;
|
|
187
|
+
/**
|
|
188
|
+
* Get recommended export options for pillow/pattern designs
|
|
189
|
+
* These may use group-scoped knockout with pattern backgrounds
|
|
190
|
+
*/
|
|
191
|
+
static getPatternExportOptions(options?: Partial<ExportImageOptions>): ExportImageOptions;
|
|
192
|
+
/**
|
|
193
|
+
* Validate export options for common issues
|
|
194
|
+
* Returns warnings if options might cause problems
|
|
195
|
+
*/
|
|
196
|
+
static validateExportOptions(options: ExportImageOptions, hasKnockout: boolean): string[];
|
|
197
|
+
/**
|
|
198
|
+
* Check if any elements in the list have knockout effects
|
|
199
|
+
*/
|
|
200
|
+
static hasKnockoutEffects(elements: ExportElement[]): boolean;
|
|
201
|
+
/**
|
|
202
|
+
* CRITICAL: Ensure artboard is export-safe
|
|
203
|
+
* Strips preview background color to prevent accidental export
|
|
204
|
+
* Returns a copy of the artboard safe for export
|
|
205
|
+
*/
|
|
206
|
+
static makeArtboardExportSafe(artboard: ArtboardElement): ArtboardElement;
|
|
207
|
+
}
|
|
208
|
+
export default ExportManager;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { GlyphAlternate } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Minimal type for fontkit Font objects.
|
|
4
|
+
* The fontkit library doesn't export clean TS types for browser usage,
|
|
5
|
+
* so we define the subset we use here.
|
|
6
|
+
*/
|
|
7
|
+
export interface FontkitGlyph {
|
|
8
|
+
id: number;
|
|
9
|
+
name: string;
|
|
10
|
+
advanceWidth: number;
|
|
11
|
+
codePoints?: number[];
|
|
12
|
+
bbox?: {
|
|
13
|
+
minX: number;
|
|
14
|
+
minY: number;
|
|
15
|
+
maxX: number;
|
|
16
|
+
maxY: number;
|
|
17
|
+
};
|
|
18
|
+
path: {
|
|
19
|
+
toSVG: () => string | null;
|
|
20
|
+
toPath?: () => string | null;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export interface FontkitGlyphRun {
|
|
24
|
+
glyphs: FontkitGlyph[];
|
|
25
|
+
positions: Array<{
|
|
26
|
+
xOffset: number;
|
|
27
|
+
yOffset: number;
|
|
28
|
+
}>;
|
|
29
|
+
}
|
|
30
|
+
export interface FontkitFont {
|
|
31
|
+
unitsPerEm: number;
|
|
32
|
+
numGlyphs: number;
|
|
33
|
+
GSUB?: {
|
|
34
|
+
featureList?: Array<{
|
|
35
|
+
tag: string;
|
|
36
|
+
feature?: {
|
|
37
|
+
lookupListIndexes?: number[];
|
|
38
|
+
};
|
|
39
|
+
}>;
|
|
40
|
+
lookupList?: {
|
|
41
|
+
lookups?: Array<{
|
|
42
|
+
lookupType: number;
|
|
43
|
+
subtables?: Record<string, unknown>[];
|
|
44
|
+
}>;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
GPOS?: {
|
|
48
|
+
featureList?: Array<{
|
|
49
|
+
tag: string;
|
|
50
|
+
}>;
|
|
51
|
+
};
|
|
52
|
+
layout(text: string, features: Record<string, boolean>, script?: string): FontkitGlyphRun;
|
|
53
|
+
getGlyph(glyphId: number): FontkitGlyph | null;
|
|
54
|
+
glyphForCodePoint(codePoint: number): FontkitGlyph | null;
|
|
55
|
+
}
|
|
56
|
+
declare class FontAnalyzerService {
|
|
57
|
+
private fontCache;
|
|
58
|
+
private failedFonts;
|
|
59
|
+
private readonly CACHE_DURATION;
|
|
60
|
+
private readonly MAX_CACHE_SIZE;
|
|
61
|
+
/**
|
|
62
|
+
* Evict the oldest font from cache if over the limit
|
|
63
|
+
* Uses LRU (Least Recently Used) strategy based on timestamp
|
|
64
|
+
*/
|
|
65
|
+
private evictOldestFont;
|
|
66
|
+
/**
|
|
67
|
+
* Check if a font is a system font
|
|
68
|
+
*/
|
|
69
|
+
private isSystemFont;
|
|
70
|
+
/**
|
|
71
|
+
* Get Google Fonts API URL for a specific font family
|
|
72
|
+
*/
|
|
73
|
+
private getGoogleFontUrl;
|
|
74
|
+
/**
|
|
75
|
+
* Extract actual font file URL from Google Fonts CSS
|
|
76
|
+
*/
|
|
77
|
+
private extractFontFileUrl;
|
|
78
|
+
/**
|
|
79
|
+
* Load and parse a font file
|
|
80
|
+
*/
|
|
81
|
+
loadFont(fontFamily: string, weight?: number): Promise<FontkitFont | null>;
|
|
82
|
+
/**
|
|
83
|
+
* Get font from cache synchronously (for rendering)
|
|
84
|
+
* Returns null if font is not cached - font should be pre-loaded before rendering
|
|
85
|
+
*/
|
|
86
|
+
getFontSync(fontFamily: string, weight?: number): FontkitFont | null;
|
|
87
|
+
/**
|
|
88
|
+
* Clear font cache (useful for debugging or forcing reload)
|
|
89
|
+
* Also clears failed fonts to allow retry
|
|
90
|
+
*/
|
|
91
|
+
clearCache(fontFamily?: string, weight?: number): void;
|
|
92
|
+
/**
|
|
93
|
+
* Get all glyphs in a font (for browsing)
|
|
94
|
+
*/
|
|
95
|
+
getAllGlyphs(fontFamily: string, weight?: number, limit?: number): Promise<GlyphAlternate[]>;
|
|
96
|
+
/**
|
|
97
|
+
* Get glyph alternates for a specific character
|
|
98
|
+
*/
|
|
99
|
+
getGlyphAlternates(fontFamily: string, character: string, weight?: number): Promise<GlyphAlternate[]>;
|
|
100
|
+
/**
|
|
101
|
+
* Get available OpenType features for a font
|
|
102
|
+
*/
|
|
103
|
+
getAvailableFeatures(fontFamily: string, weight?: number): Promise<string[]>;
|
|
104
|
+
/**
|
|
105
|
+
* Generate a preview image for a glyph
|
|
106
|
+
*/
|
|
107
|
+
private generateGlyphPreview;
|
|
108
|
+
/**
|
|
109
|
+
* Check if a feature tag is relevant for glyph alternates
|
|
110
|
+
*/
|
|
111
|
+
private isRelevantFeature;
|
|
112
|
+
/**
|
|
113
|
+
* Categorize a feature tag
|
|
114
|
+
*/
|
|
115
|
+
private categorizeFeature;
|
|
116
|
+
/**
|
|
117
|
+
* Get coverage index for a glyph
|
|
118
|
+
*/
|
|
119
|
+
private getCoverageIndex;
|
|
120
|
+
/**
|
|
121
|
+
* Get substitute glyph from a single substitution subtable
|
|
122
|
+
*/
|
|
123
|
+
private getSubstituteGlyph;
|
|
124
|
+
/**
|
|
125
|
+
* Get the count of alternate glyphs in a font (fast - no preview generation)
|
|
126
|
+
*/
|
|
127
|
+
getAlternateGlyphCount(fontFamily: string, weight?: number): Promise<number>;
|
|
128
|
+
/**
|
|
129
|
+
* Get cache statistics
|
|
130
|
+
*/
|
|
131
|
+
getCacheStats(): {
|
|
132
|
+
size: number;
|
|
133
|
+
entries: string[];
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
export declare const FontAnalyzer: FontAnalyzerService;
|
|
137
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { GlyphOverride, OpenTypeFeatures } from '../types';
|
|
2
|
+
import { FontkitFont } from './FontAnalyzer';
|
|
3
|
+
/**
|
|
4
|
+
* Build CSS font-feature-settings string from OpenTypeFeatures
|
|
5
|
+
*/
|
|
6
|
+
export declare function buildFontFeatureSettings(features?: OpenTypeFeatures): string;
|
|
7
|
+
/**
|
|
8
|
+
* Apply OpenType features to canvas context via font string
|
|
9
|
+
* Note: Browser support for font-feature-settings in canvas is limited
|
|
10
|
+
* This works in Chrome 99+, Firefox 105+, Safari 16.4+
|
|
11
|
+
*/
|
|
12
|
+
export declare function applyOpenTypeFeaturestoContext(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, features?: OpenTypeFeatures): void;
|
|
13
|
+
/**
|
|
14
|
+
* Render text with OpenType features using fontkit (synchronous version)
|
|
15
|
+
* This method renders glyphs as paths with features applied
|
|
16
|
+
* Requires font to be pre-loaded and passed as parameter
|
|
17
|
+
*/
|
|
18
|
+
export declare function renderTextWithOpenTypeFeaturesSync(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, font: FontkitFont, text: string, x: number, y: number, fontSize: number, features: OpenTypeFeatures, options?: {
|
|
19
|
+
color?: string;
|
|
20
|
+
align?: 'left' | 'center' | 'right';
|
|
21
|
+
}): void;
|
|
22
|
+
/**
|
|
23
|
+
* Render text with OpenType features using fontkit (async version)
|
|
24
|
+
* This method renders glyphs as paths with features applied
|
|
25
|
+
*/
|
|
26
|
+
export declare function renderTextWithOpenTypeFeatures(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, text: string, x: number, y: number, fontSize: number, fontFamily: string, features: OpenTypeFeatures, options?: {
|
|
27
|
+
color?: string;
|
|
28
|
+
bold?: boolean;
|
|
29
|
+
italic?: boolean;
|
|
30
|
+
align?: 'left' | 'center' | 'right';
|
|
31
|
+
}): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Render text with glyph overrides using fontkit (synchronous version)
|
|
34
|
+
* Requires font to be pre-loaded and passed as parameter
|
|
35
|
+
*/
|
|
36
|
+
export declare function renderTextWithGlyphOverridesSync(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, font: FontkitFont, text: string, x: number, y: number, fontSize: number, glyphOverrides?: GlyphOverride[], options?: {
|
|
37
|
+
color?: string;
|
|
38
|
+
align?: 'left' | 'center' | 'right';
|
|
39
|
+
}): void;
|
|
40
|
+
/**
|
|
41
|
+
* Render text with glyph overrides using fontkit (async version)
|
|
42
|
+
* Loads the font and calls the synchronous version
|
|
43
|
+
*/
|
|
44
|
+
export declare function renderTextWithGlyphOverrides(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, text: string, x: number, y: number, fontSize: number, fontFamily: string, glyphOverrides?: GlyphOverride[], options?: {
|
|
45
|
+
color?: string;
|
|
46
|
+
bold?: boolean;
|
|
47
|
+
italic?: boolean;
|
|
48
|
+
align?: 'left' | 'center' | 'right';
|
|
49
|
+
}): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Measure text width with glyph overrides
|
|
52
|
+
*/
|
|
53
|
+
export declare function measureTextWithGlyphOverrides(text: string, fontSize: number, fontFamily: string, glyphOverrides?: GlyphOverride[], options?: {
|
|
54
|
+
bold?: boolean;
|
|
55
|
+
}): Promise<number>;
|