@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,129 @@
|
|
|
1
|
+
import { EditorCapabilities } from '../types/capabilities.js';
|
|
2
|
+
/**
|
|
3
|
+
* Runtime theme overrides -- maps to CSS custom properties on the root element.
|
|
4
|
+
* All values are CSS color strings (hex, oklch, hsl, rgb, etc.).
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* const theme: RuntimeTheme = {
|
|
9
|
+
* primary: 'oklch(0.55 0.2 270)',
|
|
10
|
+
* background: '#ffffff',
|
|
11
|
+
* };
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export interface RuntimeTheme {
|
|
15
|
+
/** Primary/accent color used for buttons, links, and interactive elements */
|
|
16
|
+
primary?: string;
|
|
17
|
+
/** Page background color */
|
|
18
|
+
background?: string;
|
|
19
|
+
/** Default text color */
|
|
20
|
+
foreground?: string;
|
|
21
|
+
/** Card/panel background color */
|
|
22
|
+
content1?: string;
|
|
23
|
+
/** Elevated surface background color */
|
|
24
|
+
content2?: string;
|
|
25
|
+
/** Border/divider color */
|
|
26
|
+
divider?: string;
|
|
27
|
+
/** Danger/error color for destructive actions */
|
|
28
|
+
danger?: string;
|
|
29
|
+
/** Success color for positive feedback */
|
|
30
|
+
success?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A complete editor configuration that defines layout, capabilities,
|
|
34
|
+
* behavior, and styling for a specific use case.
|
|
35
|
+
*
|
|
36
|
+
* Three built-in presets are available:
|
|
37
|
+
* - `COMPACT_CUSTOMIZER` -- Canvas + contextual toolbar, text/image only
|
|
38
|
+
* - `PRO_STUDIO` -- Full panels, all features, multi-artboard
|
|
39
|
+
* - `EMBED_ONLY` -- Canvas only, auto-export, no UI chrome
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```tsx
|
|
43
|
+
* import { KitRenderer, COMPACT_CUSTOMIZER } from '@snowcone-app/canvas';
|
|
44
|
+
*
|
|
45
|
+
* <KitRenderer kit={COMPACT_CUSTOMIZER} />
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export interface KitDefinition {
|
|
49
|
+
/**
|
|
50
|
+
* Kit name for identification and debugging.
|
|
51
|
+
* Should be a kebab-case string (e.g., 'compact-customizer').
|
|
52
|
+
*/
|
|
53
|
+
name: string;
|
|
54
|
+
/**
|
|
55
|
+
* Layout slot configuration.
|
|
56
|
+
* Maps named slots to arrays of section IDs that should be rendered
|
|
57
|
+
* in that position. The KitRenderer resolves section IDs to components
|
|
58
|
+
* via the section registry.
|
|
59
|
+
*/
|
|
60
|
+
layout: {
|
|
61
|
+
/** Maps slot names to arrays of registered section IDs */
|
|
62
|
+
slots: {
|
|
63
|
+
/** Sections rendered at the top of the editor (toolbar area) */
|
|
64
|
+
topbar?: string[];
|
|
65
|
+
/** Sections rendered on the left side (panels) */
|
|
66
|
+
left?: string[];
|
|
67
|
+
/** Sections rendered in the center (main canvas area) */
|
|
68
|
+
canvas?: string[];
|
|
69
|
+
/** Sections rendered on the right side (properties panels) */
|
|
70
|
+
right?: string[];
|
|
71
|
+
/** Sections rendered at the bottom (status bar area) */
|
|
72
|
+
bottombar?: string[];
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Editor capabilities (what features are enabled).
|
|
77
|
+
* Controls which elements, transforms, effects, panels, and tools
|
|
78
|
+
* are available to the user.
|
|
79
|
+
*/
|
|
80
|
+
capabilities: EditorCapabilities;
|
|
81
|
+
/**
|
|
82
|
+
* Behavioral configuration that controls how the editor responds
|
|
83
|
+
* to user interactions.
|
|
84
|
+
*/
|
|
85
|
+
behavior: {
|
|
86
|
+
/** How the toolbar is displayed: contextual (near selection), fixed, floating, or hidden */
|
|
87
|
+
toolbar: 'contextual' | 'fixed' | 'floating' | 'none';
|
|
88
|
+
/** Whether the user can select one or multiple elements */
|
|
89
|
+
selection: 'single' | 'multi';
|
|
90
|
+
/** How panels are displayed: sidebar, drawer, overlay, or inline */
|
|
91
|
+
panelMode: 'sidebar' | 'drawer' | 'overlay' | 'inline';
|
|
92
|
+
/** What happens when the user clicks empty canvas space */
|
|
93
|
+
onEmptyClick: 'deselect' | 'add-text' | 'noop';
|
|
94
|
+
/** Whether to automatically export on every change */
|
|
95
|
+
autoExport: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Maximum number of elements allowed on a single artboard.
|
|
98
|
+
* Set to 0 or leave undefined for unlimited.
|
|
99
|
+
*/
|
|
100
|
+
maxElements?: number;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Visual style configuration that controls the editor's appearance.
|
|
104
|
+
*/
|
|
105
|
+
style: {
|
|
106
|
+
/** Theme variant name (e.g., 'dark', 'indigo-light') */
|
|
107
|
+
theme?: string;
|
|
108
|
+
/** UI density -- how tightly elements are packed */
|
|
109
|
+
density?: 'compact' | 'comfortable' | 'spacious';
|
|
110
|
+
/** Toolbar visual variant */
|
|
111
|
+
toolbarVariant?: 'pill' | 'flat' | 'minimal';
|
|
112
|
+
/** Panel visual variant */
|
|
113
|
+
panelVariant?: 'card' | 'flush' | 'floating';
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Default content configuration for new elements.
|
|
117
|
+
*/
|
|
118
|
+
content?: {
|
|
119
|
+
/** Default text for new text elements */
|
|
120
|
+
sampleText?: string;
|
|
121
|
+
/** Default font family for new text elements */
|
|
122
|
+
defaultFontFamily?: string;
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* String identifiers for built-in kit presets.
|
|
127
|
+
* Use with `resolveKit()` to get the full `KitDefinition`.
|
|
128
|
+
*/
|
|
129
|
+
export type KitPresetId = 'compact-customizer' | 'pro-studio' | 'embed-only';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { KitDefinition } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Result of validating a {@link KitDefinition}.
|
|
4
|
+
*/
|
|
5
|
+
export interface KitValidationResult {
|
|
6
|
+
/** Whether the kit is valid (no errors). Warnings do not affect validity. */
|
|
7
|
+
valid: boolean;
|
|
8
|
+
/** Fatal configuration errors that would prevent the editor from functioning. */
|
|
9
|
+
errors: string[];
|
|
10
|
+
/** Non-fatal issues that may produce unexpected behavior. */
|
|
11
|
+
warnings: string[];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Validates a {@link KitDefinition} for consistency and completeness.
|
|
15
|
+
*
|
|
16
|
+
* Use this to catch configuration errors before passing a kit to `KitRenderer`.
|
|
17
|
+
* Errors indicate fatal issues (editor won't work), while warnings indicate
|
|
18
|
+
* potential misconfigurations that may produce unexpected behavior.
|
|
19
|
+
*
|
|
20
|
+
* @param kit - The kit definition to validate.
|
|
21
|
+
* @returns A {@link KitValidationResult} with errors and warnings.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* import { validateKit, COMPACT_CUSTOMIZER } from '@snowcone-app/canvas';
|
|
26
|
+
*
|
|
27
|
+
* const result = validateKit(COMPACT_CUSTOMIZER);
|
|
28
|
+
* if (!result.valid) {
|
|
29
|
+
* console.error('Kit errors:', result.errors);
|
|
30
|
+
* }
|
|
31
|
+
* if (result.warnings.length > 0) {
|
|
32
|
+
* console.warn('Kit warnings:', result.warnings);
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function validateKit(kit: KitDefinition): KitValidationResult;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ElementTypePlugin - Plugin API for registering custom element types
|
|
3
|
+
*
|
|
4
|
+
* Allows external developers to add new element types without modifying
|
|
5
|
+
* core canvas files. Custom types integrate with the transform registry
|
|
6
|
+
* so that GroupElement reconstruction, ElementFactory, and all other
|
|
7
|
+
* registry consumers work seamlessly.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { registerElementType } from '@snowcone-app/canvas/advanced';
|
|
12
|
+
*
|
|
13
|
+
* registerElementType({
|
|
14
|
+
* type: 'custom-shape',
|
|
15
|
+
* Component: CustomShapeElement,
|
|
16
|
+
* label: 'Custom Shape',
|
|
17
|
+
* icon: 'lucide:shapes',
|
|
18
|
+
* category: 'custom',
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @packageDocumentation
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Registration descriptor for a custom element type.
|
|
26
|
+
*/
|
|
27
|
+
export interface ElementTypeRegistration {
|
|
28
|
+
/** Unique type identifier (must not conflict with built-in types) */
|
|
29
|
+
type: string;
|
|
30
|
+
/**
|
|
31
|
+
* Element class constructor.
|
|
32
|
+
* Must accept a config object and produce a valid element instance
|
|
33
|
+
* (i.e., something that extends BaseElement).
|
|
34
|
+
*/
|
|
35
|
+
Component: new (config: any) => any;
|
|
36
|
+
/** Display label for UI (e.g., "Custom Shape") */
|
|
37
|
+
label: string;
|
|
38
|
+
/** Icon identifier in Iconify format (e.g., "lucide:shapes") */
|
|
39
|
+
icon?: string;
|
|
40
|
+
/** Category for grouping in the add-element menu */
|
|
41
|
+
category?: 'text' | 'image' | 'shape' | 'custom';
|
|
42
|
+
/** Default config for new elements of this type */
|
|
43
|
+
defaultConfig?: Record<string, unknown>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Register a custom element type.
|
|
47
|
+
*
|
|
48
|
+
* - Validates the registration (type must be non-empty, Component must be a constructor)
|
|
49
|
+
* - Prevents conflicts with built-in types and duplicate registrations
|
|
50
|
+
* - Adds the type to the transform registry so GroupElement, ElementFactory,
|
|
51
|
+
* and other registry consumers recognize it
|
|
52
|
+
*
|
|
53
|
+
* @param registration - The element type registration descriptor
|
|
54
|
+
* @throws Error if type conflicts with a built-in type
|
|
55
|
+
* @throws Error if type is already registered as a custom type
|
|
56
|
+
* @throws Error if registration is invalid (missing type/Component/label)
|
|
57
|
+
*/
|
|
58
|
+
export declare function registerElementType(registration: ElementTypeRegistration): void;
|
|
59
|
+
/**
|
|
60
|
+
* Unregister a custom element type.
|
|
61
|
+
*
|
|
62
|
+
* Removes the type from both the plugin registry and the transform registry.
|
|
63
|
+
* Built-in types cannot be unregistered.
|
|
64
|
+
*
|
|
65
|
+
* @param type - The type identifier to unregister
|
|
66
|
+
* @throws Error if attempting to unregister a built-in type
|
|
67
|
+
*/
|
|
68
|
+
export declare function unregisterElementType(type: string): void;
|
|
69
|
+
/**
|
|
70
|
+
* Get all registered custom element types.
|
|
71
|
+
*
|
|
72
|
+
* Returns only plugin-registered types, not built-in types.
|
|
73
|
+
* The returned array is a snapshot; mutations do not affect the registry.
|
|
74
|
+
*
|
|
75
|
+
* @returns Array of ElementTypeRegistration descriptors
|
|
76
|
+
*/
|
|
77
|
+
export declare function getCustomElementTypes(): ElementTypeRegistration[];
|
|
78
|
+
/**
|
|
79
|
+
* Check if a type identifier is registered (built-in or custom).
|
|
80
|
+
*
|
|
81
|
+
* @param type - The type identifier to check
|
|
82
|
+
* @returns true if the type exists in the transform registry
|
|
83
|
+
*/
|
|
84
|
+
export declare function isRegisteredElementType(type: string): boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Reset all custom element type registrations (for testing only).
|
|
87
|
+
* Also resets the underlying dynamic transforms in the registry.
|
|
88
|
+
* @internal
|
|
89
|
+
*/
|
|
90
|
+
export declare function _resetCustomElementTypes(): void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Artboard Color Presets
|
|
3
|
+
* A curated set of 10 background colors for artboards
|
|
4
|
+
*/
|
|
5
|
+
export interface ArtboardColor {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
color: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Artboard color presets
|
|
12
|
+
* Includes a variety of colors for different design needs
|
|
13
|
+
*/
|
|
14
|
+
export declare const ARTBOARD_COLORS: ArtboardColor[];
|
|
15
|
+
/**
|
|
16
|
+
* Get a random artboard color
|
|
17
|
+
*/
|
|
18
|
+
export declare function getRandomArtboardColor(): string;
|
|
19
|
+
/**
|
|
20
|
+
* Find artboard color by hex value
|
|
21
|
+
*/
|
|
22
|
+
export declare function findArtboardColor(hexColor: string): ArtboardColor | undefined;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* T-Shirt Color Presets
|
|
3
|
+
* Comprehensive color library for previewing designs on different shirt colors
|
|
4
|
+
* Used for background preview system (PREVIEW ONLY - never exported)
|
|
5
|
+
*/
|
|
6
|
+
export interface TShirtColor {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
color: string;
|
|
10
|
+
category: 'basic' | 'vibrant' | 'pastel' | 'dark' | 'heather' | 'neon';
|
|
11
|
+
isPopular?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Complete t-shirt color library
|
|
15
|
+
* Organized by category for easy browsing
|
|
16
|
+
*/
|
|
17
|
+
export declare const TSHIRT_COLORS: TShirtColor[];
|
|
18
|
+
/**
|
|
19
|
+
* Get popular colors (most commonly used)
|
|
20
|
+
*/
|
|
21
|
+
export declare function getPopularColors(): TShirtColor[];
|
|
22
|
+
/**
|
|
23
|
+
* Get colors by category
|
|
24
|
+
*/
|
|
25
|
+
export declare function getColorsByCategory(category: TShirtColor['category']): TShirtColor[];
|
|
26
|
+
/**
|
|
27
|
+
* Get color by ID
|
|
28
|
+
*/
|
|
29
|
+
export declare function getColorById(id: string): TShirtColor | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Get all categories
|
|
32
|
+
*/
|
|
33
|
+
export declare function getAllCategories(): TShirtColor['category'][];
|
|
34
|
+
/**
|
|
35
|
+
* Get category display name
|
|
36
|
+
*/
|
|
37
|
+
export declare function getCategoryName(category: TShirtColor['category']): string;
|
|
38
|
+
/**
|
|
39
|
+
* Get color contrast for text visibility
|
|
40
|
+
* Returns 'light' or 'dark' based on background color
|
|
41
|
+
*/
|
|
42
|
+
export declare function getColorContrast(hexColor: string): 'light' | 'dark';
|
|
43
|
+
/**
|
|
44
|
+
* Get recommended knockout elements for color
|
|
45
|
+
* Some colors work better with specific knockout configurations
|
|
46
|
+
*/
|
|
47
|
+
export declare function getRecommendedKnockout(colorId: string): {
|
|
48
|
+
useKnockout: boolean;
|
|
49
|
+
strokeKnockout: boolean;
|
|
50
|
+
fillKnockout: boolean;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Default preview color (transparent/none)
|
|
54
|
+
*/
|
|
55
|
+
export declare const NO_PREVIEW_COLOR: TShirtColor;
|
|
56
|
+
/**
|
|
57
|
+
* Get default preview color
|
|
58
|
+
* Returns the first popular color or black
|
|
59
|
+
*/
|
|
60
|
+
export declare function getDefaultPreviewColor(): TShirtColor;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { AnyElementConfig } from '../types/index.js';
|
|
2
|
+
/** Supported composite operations */
|
|
3
|
+
export type CompositeOp = 'destination-out' | 'destination-in';
|
|
4
|
+
/**
|
|
5
|
+
* Render element with compositing (knockout or clip)
|
|
6
|
+
* This is the main entry point for compositing rendering
|
|
7
|
+
*/
|
|
8
|
+
export declare function renderWithCompositing(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, compositingElement: AnyElementConfig, allElements: AnyElementConfig[], renderElementFn: (ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, element: AnyElementConfig) => void, artboardBackgroundColor?: string, artboard?: {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
}, compositeOp?: CompositeOp): void;
|
|
14
|
+
/**
|
|
15
|
+
* Render element with knockout compositing (destination-out)
|
|
16
|
+
* Convenience wrapper — backward-compatible entry point
|
|
17
|
+
*/
|
|
18
|
+
export declare function renderWithKnockout(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, knockoutElement: AnyElementConfig, allElements: AnyElementConfig[], renderElementFn: (ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, element: AnyElementConfig) => void, artboardBackgroundColor?: string, artboard?: {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
width: number;
|
|
22
|
+
height: number;
|
|
23
|
+
}): void;
|
|
24
|
+
/**
|
|
25
|
+
* Render element with clip compositing (destination-in)
|
|
26
|
+
* Keeps only content within the element shape
|
|
27
|
+
*/
|
|
28
|
+
export declare function renderWithClip(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, clipElement: AnyElementConfig, allElements: AnyElementConfig[], renderElementFn: (ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, element: AnyElementConfig) => void, artboardBackgroundColor?: string, artboard?: {
|
|
29
|
+
x: number;
|
|
30
|
+
y: number;
|
|
31
|
+
width: number;
|
|
32
|
+
height: number;
|
|
33
|
+
}): void;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ArtboardDistressTexture, DistressEffect } from '../types/index.js';
|
|
2
|
+
type ContextLike = CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D;
|
|
3
|
+
/**
|
|
4
|
+
* Apply artboard-level distress texture.
|
|
5
|
+
*
|
|
6
|
+
* Only knocks out element pixels — the artboard background stays solid.
|
|
7
|
+
*
|
|
8
|
+
* Algorithm:
|
|
9
|
+
* 1. Copy the current artboard region (background + elements) to an offscreen canvas
|
|
10
|
+
* 2. Draw the alpha mask with `destination-out` to knock holes in everything
|
|
11
|
+
* 3. Clear the artboard region on the main canvas
|
|
12
|
+
* 4. Redraw the artboard background color (fills the holes that were in the bg)
|
|
13
|
+
* 5. Draw the distressed result on top (element holes reveal the fresh background)
|
|
14
|
+
*/
|
|
15
|
+
export declare function applyArtboardDistressTexture(ctx: ContextLike, config: ArtboardDistressTexture, artboard: {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
}, artboardBackgroundColor?: string): void;
|
|
21
|
+
/**
|
|
22
|
+
* Apply per-element distress texture using `destination-out` compositing.
|
|
23
|
+
*
|
|
24
|
+
* Called within the element rendering pipeline when an element has
|
|
25
|
+
* `distressEffect.style === 'custom'` and a `textureUrl`.
|
|
26
|
+
*
|
|
27
|
+
* Works by:
|
|
28
|
+
* 1. Creating an offscreen canvas
|
|
29
|
+
* 2. Rendering the element content via the provided renderFn
|
|
30
|
+
* 3. Drawing the alpha mask with `destination-out` + intensity
|
|
31
|
+
* 4. Drawing the composited result back to the main canvas
|
|
32
|
+
*/
|
|
33
|
+
export declare function applyElementDistressTexture(ctx: ContextLike, distress: DistressEffect, elementBounds: {
|
|
34
|
+
x: number;
|
|
35
|
+
y: number;
|
|
36
|
+
width: number;
|
|
37
|
+
height: number;
|
|
38
|
+
}, renderFn: (offCtx: ContextLike) => void): void;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AnyElementConfig, RenderingContext } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Rendering mode options
|
|
4
|
+
*/
|
|
5
|
+
export type RenderMode = 'fill' | 'stroke' | 'both';
|
|
6
|
+
/**
|
|
7
|
+
* Options for element rendering
|
|
8
|
+
*/
|
|
9
|
+
export interface ElementRenderOptions {
|
|
10
|
+
mode?: RenderMode;
|
|
11
|
+
renderingContext?: RenderingContext;
|
|
12
|
+
loadedImage?: HTMLImageElement;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Main dispatcher: Render any element type based on its transformType
|
|
16
|
+
*/
|
|
17
|
+
export declare function renderElement(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, element: AnyElementConfig, options?: ElementRenderOptions): void;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { AnyElementConfig, ArtboardImageMask } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Register a pre-loaded ImageBitmap for a mask image URL.
|
|
4
|
+
* Call from the export worker after fetching mask images.
|
|
5
|
+
*/
|
|
6
|
+
export declare function registerMaskBitmap(imageUrl: string, bitmap: ImageBitmap): void;
|
|
7
|
+
/**
|
|
8
|
+
* Clear all registered mask bitmaps (call after export completes).
|
|
9
|
+
*/
|
|
10
|
+
export declare function clearMaskBitmaps(): void;
|
|
11
|
+
/**
|
|
12
|
+
* Clear mask cache for an element (call when element or masks change)
|
|
13
|
+
*/
|
|
14
|
+
export declare function invalidateMaskCache(elementId: string): void;
|
|
15
|
+
/**
|
|
16
|
+
* Clear entire mask cache
|
|
17
|
+
*/
|
|
18
|
+
export declare function clearMaskCache(): void;
|
|
19
|
+
/**
|
|
20
|
+
* Render element with masks applied
|
|
21
|
+
* This is the main entry point for masked rendering
|
|
22
|
+
*/
|
|
23
|
+
export declare function renderWithMasks(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, element: AnyElementConfig, renderFn: (ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D) => void): void;
|
|
24
|
+
/**
|
|
25
|
+
* Apply artboard-level image mask.
|
|
26
|
+
*
|
|
27
|
+
* Same algorithm as applyArtboardDistressTexture in DistressTextureRenderer.ts:
|
|
28
|
+
* only masks element pixels — artboard background stays solid.
|
|
29
|
+
*
|
|
30
|
+
* Algorithm:
|
|
31
|
+
* 1. Copy the artboard region to an offscreen canvas
|
|
32
|
+
* 2. Load mask image from ImageCache
|
|
33
|
+
* 3. Apply composite op based on maskType + inverted
|
|
34
|
+
* 4. Clear + redraw background + draw masked result
|
|
35
|
+
*/
|
|
36
|
+
export declare function applyArtboardImageMask(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, config: ArtboardImageMask, artboard: {
|
|
37
|
+
x: number;
|
|
38
|
+
y: number;
|
|
39
|
+
width: number;
|
|
40
|
+
height: number;
|
|
41
|
+
}, artboardBackgroundColor?: string): void;
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { PieceGuide, SvgPath, ZoneShape, GuideLabel } from '../components/VisualGuideOverlay.js';
|
|
2
|
+
export type { PieceGuide, SvgPath, ZoneShape, GuideLabel };
|
|
3
|
+
/** Minimum piece info the renderer needs. Matches the ADR-0054 backend shape. */
|
|
4
|
+
export interface PieceGuideRendererPiece {
|
|
5
|
+
/** Stable piece id (matches placements[].name and pieceGuides keys). */
|
|
6
|
+
id: string;
|
|
7
|
+
/** Piece's top-left position in artboard pixel coords. */
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
/** Piece-local dimensions in px. */
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
/**
|
|
14
|
+
* Fallback safe-area inset (piece-local px) when no authored
|
|
15
|
+
* `pieceGuide.safeArea` is present. Used only if the caller wants the
|
|
16
|
+
* legacy centered-inset fallback; otherwise omit.
|
|
17
|
+
*/
|
|
18
|
+
safeAreaInsetPx?: number;
|
|
19
|
+
/** Clockwise rotation in degrees about the piece center. Default 0. */
|
|
20
|
+
rotation?: number;
|
|
21
|
+
}
|
|
22
|
+
export interface PieceGuideRendererStyle {
|
|
23
|
+
/**
|
|
24
|
+
* Bleed-ring rendering mode. Default `'gradient'` (the original
|
|
25
|
+
* Apple-style vignette: opaque fill softly fading into the design
|
|
26
|
+
* canvas via a blurred destination-out knockout).
|
|
27
|
+
*
|
|
28
|
+
* `'solid'` draws a flat uniform fill over `pieceRect ∖ boundary` at
|
|
29
|
+
* `bleedOpacity`. Useful when the vignette's soft inner edge reads as
|
|
30
|
+
* visual noise against the artwork — e.g. photographic designs where
|
|
31
|
+
* a clean sharp bleed edge is preferred.
|
|
32
|
+
*/
|
|
33
|
+
bleedMode?: 'gradient' | 'solid';
|
|
34
|
+
/**
|
|
35
|
+
* Which shape the bleed ring rings around. Default `'boundary'` (the
|
|
36
|
+
* design-canvas edge — the current behaviour). `'safeArea'` pulls the
|
|
37
|
+
* inner edge inwards to the safe-area shape, so the fade starts from
|
|
38
|
+
* the text-safe zone outward and the region between safe area and
|
|
39
|
+
* boundary is covered too. Falls back to `'boundary'` if the piece
|
|
40
|
+
* has no safeArea authored.
|
|
41
|
+
*/
|
|
42
|
+
bleedInnerEdge?: 'boundary' | 'safeArea';
|
|
43
|
+
/** Bleed-ring fill colour. Defaults to #333. */
|
|
44
|
+
bleedFill?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Bleed-ring opacity (0–1). Default 1.0.
|
|
47
|
+
*
|
|
48
|
+
* Must be 1.0 whenever the main canvas does any per-boundary
|
|
49
|
+
* clipping. Translucent overlays combined with sharp underlying
|
|
50
|
+
* clips produce a visible "halo then jump" at the boundary instead
|
|
51
|
+
* of a smooth vignette — see the rendering contract in this file's
|
|
52
|
+
* header. If you lower this, the bleed band will read as a tinted
|
|
53
|
+
* wash instead of a solid frame.
|
|
54
|
+
*/
|
|
55
|
+
bleedOpacity?: number;
|
|
56
|
+
/**
|
|
57
|
+
* Die-cut rendering mode.
|
|
58
|
+
*
|
|
59
|
+
* - `'blur-tint'` (default) — the current behaviour. The zone's
|
|
60
|
+
* artwork is blurred and a dark tint composites on top so the
|
|
61
|
+
* punched hole reads as a "window" onto the product underneath.
|
|
62
|
+
* - `'knockout'` — the zone's pixels are cleared from the canvas
|
|
63
|
+
* with `destination-out` compositing. Whatever's drawn *beneath*
|
|
64
|
+
* the canvas element (page background, a product mockup layered
|
|
65
|
+
* underneath, etc.) shows through. Useful when the canvas sits
|
|
66
|
+
* on top of a real product mockup and you want the hole to be
|
|
67
|
+
* honestly transparent.
|
|
68
|
+
*/
|
|
69
|
+
dieCutMode?: 'blur-tint' | 'knockout';
|
|
70
|
+
/** Die-cut tint colour. Defaults to --color-bg-tertiary. Only used in `'blur-tint'` mode. */
|
|
71
|
+
dieCutTint?: string;
|
|
72
|
+
/** Alpha applied to the die-cut tint (0–1). Default 0.7 (matches old overlay). */
|
|
73
|
+
dieCutTintAlpha?: number;
|
|
74
|
+
/** Gaussian blur radius (CSS pixels) applied to bleed + die-cut content. Default 4. */
|
|
75
|
+
dieCutBlurPx?: number;
|
|
76
|
+
/**
|
|
77
|
+
* Die-cut outline stroke colour. Empty string (default) disables the
|
|
78
|
+
* stroke — matches the canvas renderer's historical behaviour. Set
|
|
79
|
+
* to e.g. `'#ffffff'` to get a thin rim around the punched hole.
|
|
80
|
+
*/
|
|
81
|
+
dieCutStroke?: string;
|
|
82
|
+
/** Die-cut outline stroke width (CSS pixels). Default 1. */
|
|
83
|
+
dieCutStrokeWidthPx?: number;
|
|
84
|
+
/** Extra blur radius (CSS pixels) for the bleed ring only. Scales with artboard size. */
|
|
85
|
+
bleedBlurScale?: number;
|
|
86
|
+
/** Boundary outline stroke colour. Empty string disables (default). */
|
|
87
|
+
boundaryStroke?: string;
|
|
88
|
+
boundaryStrokeWidthPx?: number;
|
|
89
|
+
/** Legacy dashed safe-area outline. Empty string disables (default). */
|
|
90
|
+
safeAreaStroke?: string;
|
|
91
|
+
safeAreaStrokeWidthPx?: number;
|
|
92
|
+
safeAreaDashPx?: [number, number];
|
|
93
|
+
/** Per-kind zone fill colours (rgba). */
|
|
94
|
+
zoneFill?: Partial<Record<ZoneShape['kind'], string>>;
|
|
95
|
+
/** Per-kind zone stroke colours. */
|
|
96
|
+
zoneStroke?: Partial<Record<ZoneShape['kind'], string>>;
|
|
97
|
+
/** Label text + halo style. */
|
|
98
|
+
labelColor?: string;
|
|
99
|
+
labelFontSizePx?: number;
|
|
100
|
+
labelFontFamily?: string;
|
|
101
|
+
labelHaloColor?: string;
|
|
102
|
+
}
|
|
103
|
+
export interface PieceGuideVisibility {
|
|
104
|
+
bleed?: boolean;
|
|
105
|
+
zones?: boolean;
|
|
106
|
+
boundary?: boolean;
|
|
107
|
+
safeArea?: boolean;
|
|
108
|
+
labels?: boolean;
|
|
109
|
+
}
|
|
110
|
+
export interface PieceGuideRenderParams {
|
|
111
|
+
ctx: CanvasRenderingContext2D;
|
|
112
|
+
/**
|
|
113
|
+
* The artboard-local origin (in world pixels). The render loop has
|
|
114
|
+
* already applied DPR/zoom/padding transforms, so shape coordinates
|
|
115
|
+
* can be used directly after `ctx.translate(artboard.x + piece.x, ...)`
|
|
116
|
+
* — artboardOrigin is just where the artboard itself starts in world
|
|
117
|
+
* space (typically the active artboard's (x, y)).
|
|
118
|
+
*/
|
|
119
|
+
artboardOrigin: {
|
|
120
|
+
x: number;
|
|
121
|
+
y: number;
|
|
122
|
+
};
|
|
123
|
+
artboardWidth: number;
|
|
124
|
+
artboardHeight: number;
|
|
125
|
+
pieces: PieceGuideRendererPiece[];
|
|
126
|
+
pieceGuides?: Record<string, PieceGuide>;
|
|
127
|
+
show?: PieceGuideVisibility;
|
|
128
|
+
style?: PieceGuideRendererStyle;
|
|
129
|
+
/** Canvas CSS pixels per world pixel (from useCanvasLayout). */
|
|
130
|
+
zoom: number;
|
|
131
|
+
/**
|
|
132
|
+
* True while an element is selected, hovered, dragged, or otherwise
|
|
133
|
+
* being manipulated. When set, die-cut zones in `dieCutMode:
|
|
134
|
+
* 'knockout'` skip the `destination-out` fill that erases pixels
|
|
135
|
+
* inside the cut shape — the stroke / outline still renders, but
|
|
136
|
+
* underlying artwork (and any selection chrome the element drew
|
|
137
|
+
* during its own render pass) stays visible. This mirrors the
|
|
138
|
+
* rounded-outer-corner behaviour: idle reads as a hard knockout to
|
|
139
|
+
* the page chrome below, but during interaction the user sees what
|
|
140
|
+
* sits beneath the cutout so resize/drag feedback isn't suddenly
|
|
141
|
+
* "punched out". Idle behaviour (false / undefined) is unchanged.
|
|
142
|
+
*/
|
|
143
|
+
interacting?: boolean;
|
|
144
|
+
/**
|
|
145
|
+
* ADR-0060: id of the piece currently in focus. When set, ONLY that
|
|
146
|
+
* piece's guide chrome (boundary, safe area, bleed ring, die-cut
|
|
147
|
+
* zones, labels) is drawn — every other piece is skipped entirely.
|
|
148
|
+
* The companion narrowing in `useCanvasRenderLoop` filters the
|
|
149
|
+
* artboard's `composite-path` clip to the focused piece's
|
|
150
|
+
* silhouette so element rendering only paints inside that piece
|
|
151
|
+
* either; neighbour artwork and chrome are completely hidden.
|
|
152
|
+
* When `null` / `undefined` every piece renders (spread mode).
|
|
153
|
+
*
|
|
154
|
+
* Earlier this dimmed neighbours to ≈0.3 alpha for "structural
|
|
155
|
+
* context", but the current UX preference is to fully hide them
|
|
156
|
+
* when focused — the focus picker is the affordance to switch back
|
|
157
|
+
* to spread, neighbour pieces don't need to leak through.
|
|
158
|
+
*/
|
|
159
|
+
focusedPieceId?: string | null;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Quick "is this ink dark / light" check used to decide whether to
|
|
163
|
+
* flip an author-supplied colour for the current theme. We only
|
|
164
|
+
* need to handle hex literals (`#rgb`, `#rrggbb`) and `rgb(...)` —
|
|
165
|
+
* the formats Loom emits. CSS colour names / `hsl()` would fall
|
|
166
|
+
* through to "neither" and skip the flip, which is the safe choice
|
|
167
|
+
* (no surprising visual change for unfamiliar inputs).
|
|
168
|
+
*
|
|
169
|
+
* @internal — exposed for tests; not part of the package's public
|
|
170
|
+
* API. Don't import these from outside the canvas package.
|
|
171
|
+
*/
|
|
172
|
+
export declare function isInkDark(css: string): boolean;
|
|
173
|
+
/** @internal */
|
|
174
|
+
export declare function isInkLight(css: string): boolean;
|
|
175
|
+
/** @internal */
|
|
176
|
+
export declare function inkLuminance(css: string): number | null;
|
|
177
|
+
export declare function renderPieceGuides(params: PieceGuideRenderParams): void;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { StrokeConfig, AnyElementConfig, ImageElementConfig, RenderingContext } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Apply stroke style to canvas context
|
|
4
|
+
*/
|
|
5
|
+
export declare function applyStrokeStyle(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, stroke: StrokeConfig): void;
|
|
6
|
+
/**
|
|
7
|
+
* Render stroke for text element
|
|
8
|
+
* Uses ctx.strokeText() for proper text outline stroking
|
|
9
|
+
* Now supports text wrapping for CustomTransform elements
|
|
10
|
+
*
|
|
11
|
+
* When stroke.opacity < 1, renders the entire stroke to a temporary canvas at
|
|
12
|
+
* full opacity, then composites that layer onto the main canvas at the desired
|
|
13
|
+
* opacity. This prevents darkening where adjacent characters' strokes overlap.
|
|
14
|
+
*/
|
|
15
|
+
export declare function renderTextStroke(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, element: AnyElementConfig, renderingContext?: RenderingContext): void;
|
|
16
|
+
/**
|
|
17
|
+
* Render stroke for image element
|
|
18
|
+
*/
|
|
19
|
+
export declare function renderImageStroke(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, element: ImageElementConfig, renderingContext?: RenderingContext): void;
|
|
20
|
+
/**
|
|
21
|
+
* Render stroke for arbitrary path
|
|
22
|
+
* Used for custom shapes and transforms
|
|
23
|
+
*/
|
|
24
|
+
export declare function renderPathStroke(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, stroke: StrokeConfig, pathFn: () => void): void;
|