@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,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canvas Renderer - Orchestrator module that re-exports from focused sub-modules.
|
|
3
|
+
*
|
|
4
|
+
* Pure rendering functions that work in both main thread and worker.
|
|
5
|
+
* These functions can render to both CanvasRenderingContext2D and OffscreenCanvasRenderingContext2D.
|
|
6
|
+
*
|
|
7
|
+
* Sub-modules:
|
|
8
|
+
* - renderer-types.ts — Shared type definitions (RenderContext, SerializedTextElement, etc.)
|
|
9
|
+
* - text-renderer.ts — Text measurement, plain text rendering, CustomTransform
|
|
10
|
+
* - rich-text-renderer.ts — Rich text / multi-line / span rendering
|
|
11
|
+
* - image-renderer.ts — Image element rendering with crop, flip, border radius
|
|
12
|
+
* - shape-renderer.ts — Shape element rendering (rectangle, circle, star, etc.)
|
|
13
|
+
*/
|
|
14
|
+
export type { SerializedTextElement, SerializedImageElement, SerializedShapeElement, } from './renderer-types.js';
|
|
15
|
+
export { buildFontString, measureTextWidth, getFontMetrics, applySpaceLayoutRules, renderTextFillOnly, wrapText, renderMultilineText, renderCustomTransform, renderTextElement, } from './text-renderer.js';
|
|
16
|
+
export { wrapRichTextSpans, splitRichTextIntoLines, renderRichTextFillOnly, } from './rich-text-renderer.js';
|
|
17
|
+
export { renderImageElement } from './image-renderer.js';
|
|
18
|
+
export { renderShapeElement } from './shape-renderer.js';
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { ArtboardElement } from '../core/ArtboardElement.js';
|
|
2
|
+
import { BaseElement } from '../core/BaseElement.js';
|
|
3
|
+
import { AnyElementConfig, ArtboardDistressTexture, ArtboardImageMask } from '../types/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* Default maximum dimension for image capping (in pixels)
|
|
6
|
+
* Images larger than this on any dimension will be scaled down while preserving aspect ratio.
|
|
7
|
+
* This prevents memory issues with very large images (e.g., 6000x6000 = 144MB per bitmap).
|
|
8
|
+
*/
|
|
9
|
+
export declare const DEFAULT_MAX_BITMAP_DIMENSION = 4000;
|
|
10
|
+
/**
|
|
11
|
+
* Get cache key for an image element
|
|
12
|
+
* Uses element ID and image src to create a unique key
|
|
13
|
+
* Format: "{elementId}:{srcHash}"
|
|
14
|
+
*/
|
|
15
|
+
export declare function getImageCacheKey(elementId: string, imageSrc: string | undefined): string;
|
|
16
|
+
/**
|
|
17
|
+
* Clear all registered bitmap keys.
|
|
18
|
+
* Call this when the worker cache is cleared (e.g., on editor exit).
|
|
19
|
+
* The actual bitmap cleanup happens in the worker via 'clear-all-bitmaps' message.
|
|
20
|
+
*/
|
|
21
|
+
export declare function clearRegisteredBitmapKeys(): void;
|
|
22
|
+
/**
|
|
23
|
+
* Remove a specific element's registration tracking.
|
|
24
|
+
* Call this when an element is removed or its image source changes.
|
|
25
|
+
* The actual bitmap cleanup happens in the worker via 'clear-bitmap' message.
|
|
26
|
+
*/
|
|
27
|
+
export declare function unregisterElementBitmaps(elementId: string): void;
|
|
28
|
+
/**
|
|
29
|
+
* Mark a bitmap as registered with the worker
|
|
30
|
+
*/
|
|
31
|
+
export declare function markBitmapRegistered(cacheKey: string): void;
|
|
32
|
+
/**
|
|
33
|
+
* Check if a bitmap is already registered with the worker
|
|
34
|
+
*/
|
|
35
|
+
export declare function isBitmapRegistered(cacheKey: string): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Create an ImageBitmap with dimension capping.
|
|
38
|
+
* If the source image exceeds maxDimension on any side, it will be scaled down
|
|
39
|
+
* while preserving aspect ratio.
|
|
40
|
+
*
|
|
41
|
+
* @param source - HTMLImageElement to create bitmap from
|
|
42
|
+
* @param maxDimension - Maximum allowed dimension (default: 4000px)
|
|
43
|
+
* @returns Promise<ImageBitmap> - The (potentially scaled) ImageBitmap
|
|
44
|
+
*/
|
|
45
|
+
export declare function createCappedImageBitmap(source: HTMLImageElement, maxDimension?: number): Promise<ImageBitmap>;
|
|
46
|
+
/**
|
|
47
|
+
* Register callbacks for worker cache clearing.
|
|
48
|
+
* Called by WorkerExportManager to enable legacy API to clear worker cache.
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
51
|
+
export declare function registerWorkerCacheCallbacks(clearAll: () => void, clearElement: (elementId: string) => void): void;
|
|
52
|
+
/**
|
|
53
|
+
* Unregister callbacks (e.g., when worker terminates).
|
|
54
|
+
* @internal
|
|
55
|
+
*/
|
|
56
|
+
export declare function unregisterWorkerCacheCallbacks(): void;
|
|
57
|
+
/**
|
|
58
|
+
* Clear all ImageBitmap caches.
|
|
59
|
+
* This clears both the main thread tracking AND the worker cache (if available).
|
|
60
|
+
* Call this when exiting editor mode to free memory.
|
|
61
|
+
*/
|
|
62
|
+
export declare function clearImageBitmapCache(): void;
|
|
63
|
+
/**
|
|
64
|
+
* Remove a specific element's cached bitmaps.
|
|
65
|
+
* This clears both the main thread tracking AND the worker cache (if available).
|
|
66
|
+
* Call this when an element is removed or its image source changes.
|
|
67
|
+
*/
|
|
68
|
+
export declare function removeFromImageBitmapCache(elementId: string): void;
|
|
69
|
+
/**
|
|
70
|
+
* Serialized artboard data for export
|
|
71
|
+
*/
|
|
72
|
+
export interface SerializedArtboardData {
|
|
73
|
+
id: string;
|
|
74
|
+
name: string;
|
|
75
|
+
width: number;
|
|
76
|
+
height: number;
|
|
77
|
+
backgroundColor: string;
|
|
78
|
+
exportBackground: boolean;
|
|
79
|
+
x: number;
|
|
80
|
+
y: number;
|
|
81
|
+
distressTexture?: ArtboardDistressTexture;
|
|
82
|
+
imageMask?: ArtboardImageMask;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Serialized export data sent to worker
|
|
86
|
+
* Note: Images reference worker cache via bitmapCacheKey, not transferred inline
|
|
87
|
+
*/
|
|
88
|
+
export interface SerializedExportData {
|
|
89
|
+
version: string;
|
|
90
|
+
artboard: SerializedArtboardData;
|
|
91
|
+
elements: AnyElementConfig[];
|
|
92
|
+
fonts: string[];
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* A new bitmap that needs to be registered with the worker
|
|
96
|
+
*/
|
|
97
|
+
export interface NewBitmapRegistration {
|
|
98
|
+
cacheKey: string;
|
|
99
|
+
bitmap: ImageBitmap;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Result from serializeForWorkerExport
|
|
103
|
+
*/
|
|
104
|
+
export interface SerializationResult {
|
|
105
|
+
/** Serialized data to send to worker for export */
|
|
106
|
+
data: SerializedExportData;
|
|
107
|
+
/** New bitmaps that need to be registered with worker before export */
|
|
108
|
+
newBitmaps: NewBitmapRegistration[];
|
|
109
|
+
}
|
|
110
|
+
export interface SerializedImageElement {
|
|
111
|
+
id: string;
|
|
112
|
+
type: 'image';
|
|
113
|
+
x: number;
|
|
114
|
+
y: number;
|
|
115
|
+
width: number;
|
|
116
|
+
height: number;
|
|
117
|
+
rotation: number;
|
|
118
|
+
/** Cache key for worker bitmap lookup in format "{elementId}:{srcHash}" */
|
|
119
|
+
bitmapCacheKey: string;
|
|
120
|
+
cropX?: number;
|
|
121
|
+
cropY?: number;
|
|
122
|
+
cropWidth?: number;
|
|
123
|
+
cropHeight?: number;
|
|
124
|
+
flipHorizontal?: boolean;
|
|
125
|
+
flipVertical?: boolean;
|
|
126
|
+
borderRadius?: number;
|
|
127
|
+
opacity?: number;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Serialize artboard and elements for worker export.
|
|
131
|
+
*
|
|
132
|
+
* ARCHITECTURE:
|
|
133
|
+
* - Images are identified by bitmapCacheKey (format: "{elementId}:{srcHash}")
|
|
134
|
+
* - If a bitmap is not yet registered with the worker, it's included in newBitmaps
|
|
135
|
+
* - Caller should register newBitmaps with worker before sending export request
|
|
136
|
+
* - Worker looks up bitmaps from its cache by bitmapCacheKey
|
|
137
|
+
*
|
|
138
|
+
* @param artboard - The artboard to export
|
|
139
|
+
* @param elements - All elements in the canvas
|
|
140
|
+
* @param maxBitmapDimension - Optional max dimension for image capping (default: 4000px)
|
|
141
|
+
* @returns SerializationResult with serialized data and any new bitmaps to register
|
|
142
|
+
*/
|
|
143
|
+
export declare function serializeForWorkerExport(artboard: ArtboardElement, elements: BaseElement[], maxBitmapDimension?: number): Promise<SerializationResult>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { RenderContext, SerializedImageElement } from './renderer-types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Render an image element using ImageBitmap
|
|
4
|
+
* Works in both main thread and worker
|
|
5
|
+
*/
|
|
6
|
+
export declare function renderImageElement(ctx: RenderContext, elementData: SerializedImageElement, imageBitmap: ImageBitmap): void;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { BlendMode, CompositingConfig, CompositingScope, KnockoutConfig, KnockoutScope } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Create default knockout configuration
|
|
4
|
+
*/
|
|
5
|
+
export declare function createKnockoutConfig(fill?: boolean, stroke?: boolean, scope?: CompositingScope): CompositingConfig;
|
|
6
|
+
/**
|
|
7
|
+
* Create stroke knockout configuration (common for t-shirt design)
|
|
8
|
+
*/
|
|
9
|
+
export declare function createStrokeKnockout(scope?: CompositingScope): CompositingConfig;
|
|
10
|
+
/**
|
|
11
|
+
* Create fill knockout configuration
|
|
12
|
+
*/
|
|
13
|
+
export declare function createFillKnockout(scope?: CompositingScope): CompositingConfig;
|
|
14
|
+
/**
|
|
15
|
+
* Check if element has any compositing parts enabled (knockout or clip)
|
|
16
|
+
*/
|
|
17
|
+
export declare function hasCompositing(config: CompositingConfig | undefined): boolean;
|
|
18
|
+
/** @deprecated Use hasCompositing instead */
|
|
19
|
+
export declare function hasKnockout(config: KnockoutConfig | undefined): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Get compositing parts as array of strings
|
|
22
|
+
*/
|
|
23
|
+
export declare function getCompositingParts(config: CompositingConfig | undefined): string[];
|
|
24
|
+
/** @deprecated Use getCompositingParts instead */
|
|
25
|
+
export declare function getKnockoutParts(config: KnockoutConfig | undefined): string[];
|
|
26
|
+
/**
|
|
27
|
+
* Get human-readable description of compositing configuration
|
|
28
|
+
*/
|
|
29
|
+
export declare function describeCompositing(config: CompositingConfig | undefined, mode?: BlendMode): string;
|
|
30
|
+
/** @deprecated Use describeCompositing instead */
|
|
31
|
+
export declare function describeKnockout(config: KnockoutConfig | undefined): string;
|
|
32
|
+
/**
|
|
33
|
+
* Validate knockout configuration
|
|
34
|
+
*/
|
|
35
|
+
export declare function isValidKnockoutConfig(config: KnockoutConfig): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Merge knockout configurations
|
|
38
|
+
* Combines two configs, with priority given to the second one
|
|
39
|
+
*/
|
|
40
|
+
export declare function mergeKnockoutConfigs(config1: KnockoutConfig | undefined, config2: KnockoutConfig | undefined): KnockoutConfig | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Clone knockout configuration
|
|
43
|
+
*/
|
|
44
|
+
export declare function cloneKnockoutConfig(config: KnockoutConfig): KnockoutConfig;
|
|
45
|
+
/**
|
|
46
|
+
* Get recommended scope for use case
|
|
47
|
+
*/
|
|
48
|
+
export declare function getRecommendedScope(useCase: 'tshirt' | 'pillow' | 'pattern' | 'general'): KnockoutScope;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { MaskDefinition, MaskType, AnyElementConfig } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Create a new mask definition
|
|
4
|
+
*/
|
|
5
|
+
export declare function createMask(type: MaskType, maskElement: AnyElementConfig, options?: Partial<Omit<MaskDefinition, 'id' | 'type' | 'maskElement'>>): MaskDefinition;
|
|
6
|
+
/**
|
|
7
|
+
* Create a clip mask from text
|
|
8
|
+
*/
|
|
9
|
+
export declare function createTextClipMask(text: string, fontSize?: number, fontFamily?: string, options?: Partial<Omit<MaskDefinition, 'id' | 'type' | 'maskElement'>>): MaskDefinition;
|
|
10
|
+
/**
|
|
11
|
+
* Create a clip mask from an image.
|
|
12
|
+
* Opaque pixels in the image define the visible area; transparent pixels clip.
|
|
13
|
+
*/
|
|
14
|
+
export declare function createImageClipMask(imageUrl: string, width?: number, height?: number, options?: Partial<Omit<MaskDefinition, 'id' | 'type' | 'maskElement'>>): MaskDefinition;
|
|
15
|
+
/**
|
|
16
|
+
* Create an alpha mask from an image.
|
|
17
|
+
* The image's alpha channel controls element visibility.
|
|
18
|
+
*/
|
|
19
|
+
export declare function createImageAlphaMask(imageUrl: string, width?: number, height?: number, options?: Partial<Omit<MaskDefinition, 'id' | 'type' | 'maskElement'>>): MaskDefinition;
|
|
20
|
+
/**
|
|
21
|
+
* Create a luma mask from an image.
|
|
22
|
+
* Bright pixels = visible, dark pixels = hidden.
|
|
23
|
+
*/
|
|
24
|
+
export declare function createImageLumaMask(imageUrl: string, width?: number, height?: number, options?: Partial<Omit<MaskDefinition, 'id' | 'type' | 'maskElement'>>): MaskDefinition;
|
|
25
|
+
/**
|
|
26
|
+
* Create a distress mask from image/texture
|
|
27
|
+
*/
|
|
28
|
+
export declare function createDistressMask(textureUrl: string, opacity?: number, options?: Partial<Omit<MaskDefinition, 'id' | 'type' | 'maskElement'>>): MaskDefinition;
|
|
29
|
+
/**
|
|
30
|
+
* Calculate relative position for mask element
|
|
31
|
+
* Converts world coordinates to relative coordinates
|
|
32
|
+
*/
|
|
33
|
+
export declare function calculateRelativePosition(parentX: number, parentY: number, maskWorldX: number, maskWorldY: number): {
|
|
34
|
+
x: number;
|
|
35
|
+
y: number;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Calculate world position for mask element
|
|
39
|
+
* Converts relative coordinates to world coordinates
|
|
40
|
+
*/
|
|
41
|
+
export declare function calculateWorldPosition(parentX: number, parentY: number, maskRelativeX: number, maskRelativeY: number): {
|
|
42
|
+
x: number;
|
|
43
|
+
y: number;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Validate mask definition
|
|
47
|
+
*/
|
|
48
|
+
export declare function isValidMask(mask: MaskDefinition): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Compute mask dimensions using object-contain scaling.
|
|
51
|
+
*
|
|
52
|
+
* The mask maintains its natural aspect ratio and scales to fit entirely
|
|
53
|
+
* within the parent element's bounding box, plus an optional oversize bleed.
|
|
54
|
+
* This prevents shape masks (star, heart, etc.) from stretching when
|
|
55
|
+
* applied to non-square images, and ensures the full mask shape is visible
|
|
56
|
+
* (no clipping of star points, heart bumps, etc.).
|
|
57
|
+
*/
|
|
58
|
+
export declare function computeMaskCoverDimensions(parentW: number, parentH: number, maskNaturalW: number, maskNaturalH: number, oversize?: number): {
|
|
59
|
+
width: number;
|
|
60
|
+
height: number;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Clone a mask definition
|
|
64
|
+
*/
|
|
65
|
+
export declare function cloneMask(mask: MaskDefinition): MaskDefinition;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { AnyTransformData, TextAlign, StrokeConfig, OpenTypeFeatures, TextSpan, GlyphOverride } from '../types/index.js';
|
|
2
|
+
export type RenderContext = CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D;
|
|
3
|
+
export interface SerializedTextElement {
|
|
4
|
+
id: string;
|
|
5
|
+
type: string;
|
|
6
|
+
richText?: {
|
|
7
|
+
spans: TextSpan[];
|
|
8
|
+
};
|
|
9
|
+
text: string;
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
rotation: number;
|
|
13
|
+
opacity?: number;
|
|
14
|
+
fontSize: number;
|
|
15
|
+
fontFamily: string;
|
|
16
|
+
color: string;
|
|
17
|
+
textAlign: TextAlign;
|
|
18
|
+
bold: boolean;
|
|
19
|
+
italic: boolean;
|
|
20
|
+
underline: boolean;
|
|
21
|
+
strikethrough: boolean;
|
|
22
|
+
transformData: AnyTransformData;
|
|
23
|
+
stroke?: StrokeConfig;
|
|
24
|
+
openTypeFeatures?: OpenTypeFeatures;
|
|
25
|
+
glyphOverrides?: GlyphOverride[];
|
|
26
|
+
/** Temporary property used during corner resize to lock text wrapping line count */
|
|
27
|
+
_lockedLineCount?: number;
|
|
28
|
+
}
|
|
29
|
+
export interface SerializedImageElement {
|
|
30
|
+
id: string;
|
|
31
|
+
type: 'image';
|
|
32
|
+
x: number;
|
|
33
|
+
y: number;
|
|
34
|
+
width: number;
|
|
35
|
+
height: number;
|
|
36
|
+
rotation: number;
|
|
37
|
+
/** Cache key for worker bitmap lookup in format "{elementId}:{srcHash}" */
|
|
38
|
+
bitmapCacheKey: string;
|
|
39
|
+
cropX?: number;
|
|
40
|
+
cropY?: number;
|
|
41
|
+
cropWidth?: number;
|
|
42
|
+
cropHeight?: number;
|
|
43
|
+
flipHorizontal?: boolean;
|
|
44
|
+
flipVertical?: boolean;
|
|
45
|
+
borderRadius?: number;
|
|
46
|
+
opacity?: number;
|
|
47
|
+
stroke?: StrokeConfig;
|
|
48
|
+
knockoutParts?: {
|
|
49
|
+
fill?: boolean;
|
|
50
|
+
stroke?: boolean;
|
|
51
|
+
scope?: 'group' | 'artboard';
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export interface SerializedShapeElement {
|
|
55
|
+
id: string;
|
|
56
|
+
type: 'shape';
|
|
57
|
+
x: number;
|
|
58
|
+
y: number;
|
|
59
|
+
rotation: number;
|
|
60
|
+
opacity?: number;
|
|
61
|
+
transformData: {
|
|
62
|
+
type: 'shape';
|
|
63
|
+
shapeType: 'rectangle' | 'circle' | 'ellipse' | 'triangle' | 'polygon' | 'star' | 'line';
|
|
64
|
+
width: number;
|
|
65
|
+
height: number;
|
|
66
|
+
borderRadius?: number;
|
|
67
|
+
sides?: number;
|
|
68
|
+
points?: number;
|
|
69
|
+
innerRadius?: number;
|
|
70
|
+
fillColor?: string;
|
|
71
|
+
fillOpacity?: number;
|
|
72
|
+
};
|
|
73
|
+
stroke?: StrokeConfig;
|
|
74
|
+
knockoutParts?: {
|
|
75
|
+
fill?: boolean;
|
|
76
|
+
stroke?: boolean;
|
|
77
|
+
scope?: 'group' | 'artboard';
|
|
78
|
+
};
|
|
79
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { TextAlign, CharacterStyle, RichText } from '../types/index.js';
|
|
2
|
+
import { RenderContext } from './renderer-types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Wrap rich text spans to fit within a given width, preserving character-level formatting
|
|
5
|
+
*
|
|
6
|
+
* This function handles character-level formatting correctly by:
|
|
7
|
+
* 1. First merging consecutive spans with the same style
|
|
8
|
+
* 2. Finding word boundaries (spaces) across spans
|
|
9
|
+
* 3. Wrapping at word boundaries, not at span boundaries
|
|
10
|
+
*/
|
|
11
|
+
export declare function wrapRichTextSpans(spans: Array<{
|
|
12
|
+
text: string;
|
|
13
|
+
style: CharacterStyle;
|
|
14
|
+
}>, maxWidth: number, element: {
|
|
15
|
+
fontSize: number;
|
|
16
|
+
fontFamily: string;
|
|
17
|
+
bold?: boolean;
|
|
18
|
+
italic?: boolean;
|
|
19
|
+
}): Array<{
|
|
20
|
+
text: string;
|
|
21
|
+
style: CharacterStyle;
|
|
22
|
+
}[]>;
|
|
23
|
+
/**
|
|
24
|
+
* Split rich text into lines by explicit newlines, preserving span formatting
|
|
25
|
+
*/
|
|
26
|
+
export declare function splitRichTextIntoLines(richText: RichText): Array<{
|
|
27
|
+
text: string;
|
|
28
|
+
style: CharacterStyle;
|
|
29
|
+
}[]>;
|
|
30
|
+
/**
|
|
31
|
+
* Render rich text with per-span styling (fill only, no effects)
|
|
32
|
+
* Supports multi-line text with line breaks and word wrapping
|
|
33
|
+
*/
|
|
34
|
+
export declare function renderRichTextFillOnly(ctx: RenderContext, richText: RichText, element: {
|
|
35
|
+
fontSize: number;
|
|
36
|
+
fontFamily: string;
|
|
37
|
+
color: string;
|
|
38
|
+
bold?: boolean;
|
|
39
|
+
italic?: boolean;
|
|
40
|
+
underline?: boolean;
|
|
41
|
+
strikethrough?: boolean;
|
|
42
|
+
textAlign?: TextAlign;
|
|
43
|
+
}, maxWidth?: number, lockedLineCount?: number): void;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serialize canvas state (from onChange/toJSON) to the format the export worker expects.
|
|
3
|
+
*
|
|
4
|
+
* This bridges the gap between SnowconeCanvas.onChange() output (element configs with
|
|
5
|
+
* transformType and nested transformData) and the export worker's expected format
|
|
6
|
+
* (elements with 'type' field and flattened image properties).
|
|
7
|
+
*
|
|
8
|
+
* Use this when sending canvas state to a server-side renderer that runs the export
|
|
9
|
+
* worker bundle. The client-side serializeForWorkerExport() requires live element
|
|
10
|
+
* instances; this function works on plain JSON from onChange/toJSON.
|
|
11
|
+
*/
|
|
12
|
+
export interface ServerRenderRequest {
|
|
13
|
+
artboards: Array<{
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
backgroundColor: string;
|
|
21
|
+
exportBackground: boolean;
|
|
22
|
+
elements: any[];
|
|
23
|
+
distressTexture?: any;
|
|
24
|
+
imageMask?: any;
|
|
25
|
+
}>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Convert onChange canvas state to the server render format.
|
|
29
|
+
*
|
|
30
|
+
* @param state - The state from SnowconeCanvas onChange callback
|
|
31
|
+
* @returns ServerRenderRequest ready to send via sendCanvasState()
|
|
32
|
+
*/
|
|
33
|
+
export declare function serializeStateForServer(state: {
|
|
34
|
+
elements?: any[];
|
|
35
|
+
artboards?: Array<{
|
|
36
|
+
name?: string;
|
|
37
|
+
width?: number;
|
|
38
|
+
height?: number;
|
|
39
|
+
backgroundColor?: string;
|
|
40
|
+
clipShape?: any;
|
|
41
|
+
distressTexture?: any;
|
|
42
|
+
imageMask?: any;
|
|
43
|
+
}>;
|
|
44
|
+
activeArtboard?: string;
|
|
45
|
+
}): ServerRenderRequest;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AnyElementConfig, ImageElementConfig, RenderingContext } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Create text path for stroking
|
|
4
|
+
* Handles all text transform types
|
|
5
|
+
*/
|
|
6
|
+
export declare function createTextPath(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, element: AnyElementConfig, _renderingContext?: RenderingContext): void;
|
|
7
|
+
/**
|
|
8
|
+
* Create image boundary path for stroking
|
|
9
|
+
*/
|
|
10
|
+
export declare function createImagePath(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, element: ImageElementConfig): void;
|
|
11
|
+
/**
|
|
12
|
+
* Create circular path (for circle transform or shapes)
|
|
13
|
+
*/
|
|
14
|
+
export declare function createCirclePath(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, x: number, y: number, radius: number): void;
|
|
15
|
+
/**
|
|
16
|
+
* Create rectangular path
|
|
17
|
+
*/
|
|
18
|
+
export declare function createRectPath(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, x: number, y: number, width: number, height: number): void;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { TextAlign, OpenTypeFeatures } from '../types/index.js';
|
|
2
|
+
import { RenderContext, SerializedTextElement } from './renderer-types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Build font string with optional bold and italic
|
|
5
|
+
*/
|
|
6
|
+
export declare function buildFontString(fontSize: number, fontFamily: string, bold?: boolean, italic?: boolean): string;
|
|
7
|
+
/**
|
|
8
|
+
* Measure text width
|
|
9
|
+
*/
|
|
10
|
+
export declare function measureTextWidth(text: string, fontSize: number, fontFamily: string, bold?: boolean, italic?: boolean): number;
|
|
11
|
+
/**
|
|
12
|
+
* Get font metrics for accurate text positioning
|
|
13
|
+
*/
|
|
14
|
+
export declare function getFontMetrics(fontSize: number, fontFamily: string, bold?: boolean, italic?: boolean): {
|
|
15
|
+
ascent: number;
|
|
16
|
+
descent: number;
|
|
17
|
+
height: number;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Apply space layout rules to text lines for rendering
|
|
21
|
+
* Hides leading/trailing spaces based on paragraph boundaries to match HTML/CSS text rendering
|
|
22
|
+
*
|
|
23
|
+
* Rules (matching browser text rendering behavior):
|
|
24
|
+
* - Leading spaces are hidden when NOT at paragraph start
|
|
25
|
+
* - Trailing spaces are hidden when NOT at paragraph end
|
|
26
|
+
* - Paragraph = text separated by explicit \n characters
|
|
27
|
+
*
|
|
28
|
+
* Example:
|
|
29
|
+
* Input: ["Foo ", "Bar"] (from wrapping "Foo Bar", no explicit \n)
|
|
30
|
+
* Output: ["Foo", "Bar"] (trailing space on line 1 hidden)
|
|
31
|
+
*
|
|
32
|
+
* @param lines - Array of text lines (from wrapText or split by \n)
|
|
33
|
+
* @param hasExplicitNewlines - Whether original text contained \n characters
|
|
34
|
+
* @returns Lines with space collapsing applied for rendering
|
|
35
|
+
*/
|
|
36
|
+
export declare function applySpaceLayoutRules(lines: string[], hasExplicitNewlines: boolean): string[];
|
|
37
|
+
/**
|
|
38
|
+
* Render text fill only (without transforms or effects)
|
|
39
|
+
* Shared utility used by main rendering and knockout compositing
|
|
40
|
+
*
|
|
41
|
+
* IMPORTANT: This renders ONLY the fill, positioned and transformed correctly
|
|
42
|
+
* It does NOT render strokes, masks, or other effects
|
|
43
|
+
*/
|
|
44
|
+
export declare function renderTextFillOnly(ctx: RenderContext, element: {
|
|
45
|
+
text: string;
|
|
46
|
+
fontSize: number;
|
|
47
|
+
fontFamily: string;
|
|
48
|
+
bold?: boolean;
|
|
49
|
+
italic?: boolean;
|
|
50
|
+
textAlign?: TextAlign;
|
|
51
|
+
color: string;
|
|
52
|
+
}): void;
|
|
53
|
+
/**
|
|
54
|
+
* Word wrap text to fit within a given width
|
|
55
|
+
*/
|
|
56
|
+
export declare function wrapText(text: string, maxWidth: number, fontSize: number, fontFamily: string, bold?: boolean, italic?: boolean, lockedLineCount?: number): string[];
|
|
57
|
+
/**
|
|
58
|
+
* Render multi-line text with alignment and text decorations
|
|
59
|
+
* Works with both CanvasRenderingContext2D and OffscreenCanvasRenderingContext2D
|
|
60
|
+
*/
|
|
61
|
+
export declare function renderMultilineText(ctx: RenderContext, lines: string[], x: number, y: number, fontSize: number, fontFamily: string, alignment?: CanvasTextAlign, containerWidth?: number, horizontalPadding?: number, lineHeight?: number, bold?: boolean, italic?: boolean, underline?: boolean, strikethrough?: boolean, openTypeFeatures?: OpenTypeFeatures, glyphOverrides?: import('../types/index.js').GlyphOverride[]): void;
|
|
62
|
+
/**
|
|
63
|
+
* Render a CustomTransform (straight text) element
|
|
64
|
+
* Pure function that works in both main thread and worker
|
|
65
|
+
*/
|
|
66
|
+
export declare function renderCustomTransform(ctx: RenderContext, elementData: SerializedTextElement): void;
|
|
67
|
+
/**
|
|
68
|
+
* Render a text element based on its type
|
|
69
|
+
* This is the main entry point for rendering text elements in the worker
|
|
70
|
+
*/
|
|
71
|
+
export declare function renderTextElement(ctx: RenderContext, elementData: SerializedTextElement): void;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { AnyTransformData } from '../types/index.js';
|
|
2
|
+
type RenderContext = CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D;
|
|
3
|
+
export interface SerializedTextTransformElement {
|
|
4
|
+
id: string;
|
|
5
|
+
type: string;
|
|
6
|
+
text: string;
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
rotation: number;
|
|
10
|
+
fontSize: number;
|
|
11
|
+
fontFamily: string;
|
|
12
|
+
color: string;
|
|
13
|
+
bold: boolean;
|
|
14
|
+
italic: boolean;
|
|
15
|
+
transformData: AnyTransformData;
|
|
16
|
+
stroke?: {
|
|
17
|
+
enabled: boolean;
|
|
18
|
+
color: string;
|
|
19
|
+
width: number;
|
|
20
|
+
opacity?: number;
|
|
21
|
+
lineCap?: CanvasLineCap;
|
|
22
|
+
lineJoin?: CanvasLineJoin;
|
|
23
|
+
miterLimit?: number;
|
|
24
|
+
feather?: number;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export declare function renderCircleTransform(ctx: RenderContext, elementData: SerializedTextTransformElement): void;
|
|
28
|
+
export declare function renderWaveTransform(ctx: RenderContext, elementData: SerializedTextTransformElement): void;
|
|
29
|
+
export declare function renderArchTransform(ctx: RenderContext, elementData: SerializedTextTransformElement): void;
|
|
30
|
+
export declare function renderAscendTransform(ctx: RenderContext, elementData: SerializedTextTransformElement): void;
|
|
31
|
+
export declare function renderLeanTransform(ctx: RenderContext, elementData: SerializedTextTransformElement): void;
|
|
32
|
+
export declare function renderFlagTransform(ctx: RenderContext, elementData: SerializedTextTransformElement): void;
|
|
33
|
+
export {};
|