@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.
Files changed (370) hide show
  1. package/LICENSE.txt +70 -0
  2. package/README.md +357 -0
  3. package/dist/CanvasStateV1-D5GzvmnY.cjs +65 -0
  4. package/dist/CanvasStateV1-D5GzvmnY.cjs.map +1 -0
  5. package/dist/CanvasStateV1-ejb4d_LM.js +3692 -0
  6. package/dist/CanvasStateV1-ejb4d_LM.js.map +1 -0
  7. package/dist/ElementFactory-B7UOaJSD.cjs +23865 -0
  8. package/dist/ElementFactory-B7UOaJSD.cjs.map +1 -0
  9. package/dist/ElementFactory-uJTXU-nP.js +29615 -0
  10. package/dist/ElementFactory-uJTXU-nP.js.map +1 -0
  11. package/dist/HybridHistoryManager-BV6XV0nD.js +8048 -0
  12. package/dist/HybridHistoryManager-BV6XV0nD.js.map +1 -0
  13. package/dist/HybridHistoryManager-BXD93pp8.cjs +8 -0
  14. package/dist/HybridHistoryManager-BXD93pp8.cjs.map +1 -0
  15. package/dist/ImportManager-BYwuK6n4.cjs +2 -0
  16. package/dist/ImportManager-BYwuK6n4.cjs.map +1 -0
  17. package/dist/ImportManager-CxiaRg1N.js +222 -0
  18. package/dist/ImportManager-CxiaRg1N.js.map +1 -0
  19. package/dist/ThemeContext-4mJ_y0Me.cjs +2 -0
  20. package/dist/ThemeContext-4mJ_y0Me.cjs.map +1 -0
  21. package/dist/ThemeContext-H0Z-MqqR.js +1077 -0
  22. package/dist/ThemeContext-H0Z-MqqR.js.map +1 -0
  23. package/dist/advanced.d.ts +2 -0
  24. package/dist/advanced.js +48 -0
  25. package/dist/advanced.js.map +1 -0
  26. package/dist/advanced.mjs +15679 -0
  27. package/dist/advanced.mjs.map +1 -0
  28. package/dist/api/advanced.d.ts +110 -0
  29. package/dist/api/internals.d.ts +39 -0
  30. package/dist/api/stable.d.ts +44 -0
  31. package/dist/api/testing.d.ts +25 -0
  32. package/dist/browser-module-D0gHY9rY.cjs +9 -0
  33. package/dist/browser-module-D0gHY9rY.cjs.map +1 -0
  34. package/dist/browser-module-DFvKXBUE.js +15474 -0
  35. package/dist/browser-module-DFvKXBUE.js.map +1 -0
  36. package/dist/components/ArtboardDistressPanel.d.ts +7 -0
  37. package/dist/components/ArtboardImageMaskPanel.d.ts +7 -0
  38. package/dist/components/ArtboardPropertiesToolbar.d.ts +19 -0
  39. package/dist/components/ArtboardToolbar.d.ts +10 -0
  40. package/dist/components/BackButton.d.ts +7 -0
  41. package/dist/components/BackgroundPickerDropdown.d.ts +11 -0
  42. package/dist/components/BackgroundSwitcher.d.ts +7 -0
  43. package/dist/components/CanvasA11yFallback.d.ts +62 -0
  44. package/dist/components/CanvasEditor/CanvasRendererComponent.d.ts +51 -0
  45. package/dist/components/CanvasEditor/handlers/cropModeHandlers.d.ts +114 -0
  46. package/dist/components/CanvasEditor/handlers/groupChildHandlers.d.ts +65 -0
  47. package/dist/components/CanvasEditor/handlers/index.d.ts +10 -0
  48. package/dist/components/CanvasEditor/handlers/multiSelectionHandlers.d.ts +86 -0
  49. package/dist/components/CanvasEditor/hooks/buildSpreadClipShape.d.ts +20 -0
  50. package/dist/components/CanvasEditor/hooks/index.d.ts +24 -0
  51. package/dist/components/CanvasEditor/hooks/useActiveChild.d.ts +23 -0
  52. package/dist/components/CanvasEditor/hooks/useAnimatedFocusRect.d.ts +17 -0
  53. package/dist/components/CanvasEditor/hooks/useCanvasInteraction.d.ts +284 -0
  54. package/dist/components/CanvasEditor/hooks/useCanvasLayout.d.ts +50 -0
  55. package/dist/components/CanvasEditor/hooks/useCanvasRenderLoop.d.ts +140 -0
  56. package/dist/components/CanvasEditor/hooks/useCropMode.d.ts +4 -0
  57. package/dist/components/CanvasEditor/hooks/useHoverState.d.ts +9 -0
  58. package/dist/components/CanvasEditor/hooks/useInteractionState.d.ts +23 -0
  59. package/dist/components/CanvasEditor/hooks/useKeyboardHandlers.d.ts +16 -0
  60. package/dist/components/CanvasEditor/hooks/useMarqueeSelection.d.ts +22 -0
  61. package/dist/components/CanvasEditor/hooks/useMultiSelection.d.ts +5 -0
  62. package/dist/components/CanvasEditor/hooks/usePenTool.d.ts +10 -0
  63. package/dist/components/CanvasEditor/hooks/useRenderState.d.ts +31 -0
  64. package/dist/components/CanvasEditor/hooks/useSnapAndSpacing.d.ts +42 -0
  65. package/dist/components/CanvasEditor/hooks/useTextEditing.d.ts +56 -0
  66. package/dist/components/CanvasEditor/hooks/useTextEditingHandlers.d.ts +75 -0
  67. package/dist/components/CanvasEditor/renderers/hoverRenderer.d.ts +12 -0
  68. package/dist/components/CanvasEditor/renderers/index.d.ts +10 -0
  69. package/dist/components/CanvasEditor/renderers/marqueeRenderer.d.ts +21 -0
  70. package/dist/components/CanvasEditor/renderers/multiSelectionRenderer.d.ts +52 -0
  71. package/dist/components/CanvasEditor/renderers/renderingConstants.d.ts +59 -0
  72. package/dist/components/CanvasEditor/types/index.d.ts +11 -0
  73. package/dist/components/CanvasEditor.d.ts +102 -0
  74. package/dist/components/ColorPickerDropdown.d.ts +29 -0
  75. package/dist/components/CompositingPanel.d.ts +8 -0
  76. package/dist/components/ContextualToolbars.d.ts +150 -0
  77. package/dist/components/CropPanel.d.ts +20 -0
  78. package/dist/components/DistressPanel.d.ts +7 -0
  79. package/dist/components/DocsPage.d.ts +6 -0
  80. package/dist/components/Drawer.d.ts +39 -0
  81. package/dist/components/EffectsPanel.d.ts +14 -0
  82. package/dist/components/ExportTestPanel.d.ts +16 -0
  83. package/dist/components/FontBrowserDrawer.d.ts +20 -0
  84. package/dist/components/FontSizeDropdown.d.ts +12 -0
  85. package/dist/components/GlyphBrowserDrawer.d.ts +13 -0
  86. package/dist/components/GlyphPicker.d.ts +14 -0
  87. package/dist/components/IconMatchTest.d.ts +3 -0
  88. package/dist/components/IconSizeTest.d.ts +3 -0
  89. package/dist/components/ImageBrowserDrawer.d.ts +27 -0
  90. package/dist/components/ImageToolbar.d.ts +47 -0
  91. package/dist/components/LayerEffects.d.ts +11 -0
  92. package/dist/components/LayerLeadingChip.d.ts +9 -0
  93. package/dist/components/LayersPanel.d.ts +30 -0
  94. package/dist/components/MaskItem.d.ts +12 -0
  95. package/dist/components/MasksPanel.d.ts +7 -0
  96. package/dist/components/MonotypeDemoPage.d.ts +2 -0
  97. package/dist/components/MoreMenu.d.ts +15 -0
  98. package/dist/components/OpenTypeFeaturesPanel.d.ts +12 -0
  99. package/dist/components/PathToolbar.d.ts +10 -0
  100. package/dist/components/PenToolDemo.d.ts +3 -0
  101. package/dist/components/ProgressiveBlur.d.ts +25 -0
  102. package/dist/components/RotationHandle.d.ts +47 -0
  103. package/dist/components/SaveLoadMenu.d.ts +15 -0
  104. package/dist/components/ShapeToolbar.d.ts +71 -0
  105. package/dist/components/ShapeTypeDrawer.d.ts +10 -0
  106. package/dist/components/StrokePanel.d.ts +7 -0
  107. package/dist/components/TailwindDemo.d.ts +3 -0
  108. package/dist/components/TextEffectsDropdown.d.ts +14 -0
  109. package/dist/components/TextToolbar.d.ts +47 -0
  110. package/dist/components/TextTypeDrawer.d.ts +8 -0
  111. package/dist/components/ThemeToggle.d.ts +2 -0
  112. package/dist/components/TransformControlPanel.d.ts +12 -0
  113. package/dist/components/VisualGuideOverlay.d.ts +156 -0
  114. package/dist/components/embed/ArtboardTabs.d.ts +74 -0
  115. package/dist/components/embed/Canvas.d.ts +72 -0
  116. package/dist/components/embed/EffectsPanel.d.ts +76 -0
  117. package/dist/components/embed/ErrorBoundary.d.ts +34 -0
  118. package/dist/components/embed/ExportPanel.d.ts +51 -0
  119. package/dist/components/embed/GlyphPanel.d.ts +70 -0
  120. package/dist/components/embed/ImagePanel.d.ts +58 -0
  121. package/dist/components/embed/LayersPanel.d.ts +13 -0
  122. package/dist/components/embed/LoadingStates.d.ts +32 -0
  123. package/dist/components/embed/MenuButton.d.ts +47 -0
  124. package/dist/components/embed/SnowconeCanvas.d.ts +844 -0
  125. package/dist/components/embed/ZoomControls.d.ts +16 -0
  126. package/dist/components/embed/index.d.ts +129 -0
  127. package/dist/components/embed/primitives/index.d.ts +42 -0
  128. package/dist/components/embed/ui/index.d.ts +52 -0
  129. package/dist/components/embed/utils/index.d.ts +31 -0
  130. package/dist/components/embedded/ArtboardEmbed.d.ts +70 -0
  131. package/dist/components/embedded/MerchifyThemeWrapper.d.ts +30 -0
  132. package/dist/components/embedded/ProductPreviewCard.d.ts +8 -0
  133. package/dist/components/embedded/index.d.ts +7 -0
  134. package/dist/components/primitives/ButtonGroup.d.ts +27 -0
  135. package/dist/components/primitives/ControlGroup.d.ts +15 -0
  136. package/dist/components/primitives/Dropdown.d.ts +27 -0
  137. package/dist/components/primitives/DropdownMenu.d.ts +9 -0
  138. package/dist/components/primitives/MenuItem.d.ts +13 -0
  139. package/dist/components/primitives/Panel.d.ts +25 -0
  140. package/dist/components/primitives/SecondaryToolbar.d.ts +9 -0
  141. package/dist/components/primitives/Switch.d.ts +10 -0
  142. package/dist/components/primitives/Toggle.d.ts +17 -0
  143. package/dist/components/primitives/index.d.ts +22 -0
  144. package/dist/components/stories/utils/MockEditorProvider.d.ts +32 -0
  145. package/dist/components/stories/utils/QACanvasCard.d.ts +41 -0
  146. package/dist/components/stories/utils/VisualQACard.d.ts +24 -0
  147. package/dist/components/stories/utils/element-factories.d.ts +188 -0
  148. package/dist/components/stories/utils/spec-to-elements.d.ts +74 -0
  149. package/dist/components/stories/utils/themeDecorator.d.ts +45 -0
  150. package/dist/components/stories/utils/unified-test-cases.d.ts +27 -0
  151. package/dist/components/text-toolbar/BoldButton.d.ts +5 -0
  152. package/dist/components/text-toolbar/FontColorButton.d.ts +6 -0
  153. package/dist/components/text-toolbar/FontSizeGroup.d.ts +5 -0
  154. package/dist/components/text-toolbar/ItalicButton.d.ts +5 -0
  155. package/dist/components/text-toolbar/TextAlignButton.d.ts +5 -0
  156. package/dist/components/text-toolbar/TextMoreMenu.d.ts +7 -0
  157. package/dist/components/text-toolbar/UnderlineButton.d.ts +5 -0
  158. package/dist/components/text-toolbar/UppercaseButton.d.ts +5 -0
  159. package/dist/components/text-toolbar/index.d.ts +25 -0
  160. package/dist/components/toolbars/EmbeddedToolbarLayout.d.ts +49 -0
  161. package/dist/components/toolbars/ExpandedPanelIcon.d.ts +13 -0
  162. package/dist/components/toolbars/FloatingPanels.d.ts +23 -0
  163. package/dist/components/toolbars/GroupElementToolbar.d.ts +35 -0
  164. package/dist/components/toolbars/SecondaryPanels.d.ts +125 -0
  165. package/dist/components/toolbars/index.d.ts +18 -0
  166. package/dist/components/toolbars/shared/ColorPanelWrapper.d.ts +9 -0
  167. package/dist/components/toolbars/shared/SecondaryPanelWrapper.d.ts +9 -0
  168. package/dist/components/ui/PresetCarousel.d.ts +21 -0
  169. package/dist/components/ui/SecondaryPanel.d.ts +28 -0
  170. package/dist/components/ui/SliderRow.d.ts +30 -0
  171. package/dist/components/ui/collapsed-toolbar-header.d.ts +14 -0
  172. package/dist/components/ui/custom-icons.d.ts +25 -0
  173. package/dist/components/ui/icons.d.ts +100 -0
  174. package/dist/components/ui/index.d.ts +48 -0
  175. package/dist/components/ui/normalized-icon.d.ts +63 -0
  176. package/dist/components/ui/toolbar-button.d.ts +24 -0
  177. package/dist/compose-Bo108juW.cjs +33 -0
  178. package/dist/compose-Bo108juW.cjs.map +1 -0
  179. package/dist/compose-DQ1FZS3O.js +7690 -0
  180. package/dist/compose-DQ1FZS3O.js.map +1 -0
  181. package/dist/constants.d.ts +121 -0
  182. package/dist/contexts/CommandContext.d.ts +87 -0
  183. package/dist/contexts/EditorContext.d.ts +190 -0
  184. package/dist/contexts/ElementsContext.d.ts +104 -0
  185. package/dist/contexts/HistoryContext.d.ts +60 -0
  186. package/dist/contexts/KitContext.d.ts +50 -0
  187. package/dist/contexts/SelectionContext.d.ts +51 -0
  188. package/dist/contexts/ThemeContext.d.ts +55 -0
  189. package/dist/contexts/ToolStateContext.d.ts +60 -0
  190. package/dist/contexts/ViewportContext.d.ts +87 -0
  191. package/dist/core/AlignmentSnapSystem.d.ts +270 -0
  192. package/dist/core/ArtboardElement.d.ts +106 -0
  193. package/dist/core/ArtboardManager.d.ts +130 -0
  194. package/dist/core/ArtboardRenderer.d.ts +97 -0
  195. package/dist/core/BaseElement.d.ts +94 -0
  196. package/dist/core/CanvasRenderer.d.ts +237 -0
  197. package/dist/core/CommandHistory.d.ts +173 -0
  198. package/dist/core/CoordinateTransform.d.ts +69 -0
  199. package/dist/core/CropModeController.d.ts +90 -0
  200. package/dist/core/EditModeRenderer.d.ts +51 -0
  201. package/dist/core/ElementFactory.d.ts +73 -0
  202. package/dist/core/ElementStore.d.ts +69 -0
  203. package/dist/core/EventBus.d.ts +163 -0
  204. package/dist/core/GeometryUtils.d.ts +247 -0
  205. package/dist/core/GroupElement.d.ts +134 -0
  206. package/dist/core/HoverRenderer.d.ts +103 -0
  207. package/dist/core/HybridHistoryManager.d.ts +137 -0
  208. package/dist/core/ImageCache.d.ts +63 -0
  209. package/dist/core/ImageElement.d.ts +226 -0
  210. package/dist/core/ImageLoadEvents.d.ts +23 -0
  211. package/dist/core/InteractionFeedbackRenderer.d.ts +15 -0
  212. package/dist/core/InteractionStateMachine.d.ts +199 -0
  213. package/dist/core/PathElement.d.ts +84 -0
  214. package/dist/core/PenToolManager.d.ts +112 -0
  215. package/dist/core/PinchHandler.d.ts +32 -0
  216. package/dist/core/ResizeHandler.d.ts +51 -0
  217. package/dist/core/ResizePipeline.d.ts +83 -0
  218. package/dist/core/ResizeUtils.d.ts +17 -0
  219. package/dist/core/RotationAnchorResolver.d.ts +60 -0
  220. package/dist/core/RotationUtils.d.ts +28 -0
  221. package/dist/core/SelectionRenderer.d.ts +24 -0
  222. package/dist/core/ShapeElement.d.ts +121 -0
  223. package/dist/core/SpacingSystem.d.ts +73 -0
  224. package/dist/core/SpatialGrid.d.ts +53 -0
  225. package/dist/core/TextElement.d.ts +80 -0
  226. package/dist/core/TextMetrics.d.ts +117 -0
  227. package/dist/core/Transform.d.ts +158 -0
  228. package/dist/core/TransformConverter.d.ts +16 -0
  229. package/dist/core/TransformHandles.d.ts +55 -0
  230. package/dist/core/artboardReducer.d.ts +46 -0
  231. package/dist/effects/DistressGenerator.d.ts +26 -0
  232. package/dist/effects/DistressTextureCache.d.ts +49 -0
  233. package/dist/effects/distress-presets.d.ts +86 -0
  234. package/dist/effects/distress-textures.d.ts +34 -0
  235. package/dist/effects/distress-utils.d.ts +39 -0
  236. package/dist/effects/mask-presets.d.ts +36 -0
  237. package/dist/fonts/google-fonts.d.ts +48 -0
  238. package/dist/google-fonts.json +1 -0
  239. package/dist/hooks/index.d.ts +42 -0
  240. package/dist/hooks/useArtboards.d.ts +71 -0
  241. package/dist/hooks/useAutoExport.d.ts +66 -0
  242. package/dist/hooks/useBreakpoint.d.ts +53 -0
  243. package/dist/hooks/useCanvasEvents.d.ts +8 -0
  244. package/dist/hooks/useCanvasReady.d.ts +22 -0
  245. package/dist/hooks/useClickOutside.d.ts +3 -0
  246. package/dist/hooks/useCommandHistory.d.ts +39 -0
  247. package/dist/hooks/useCommands.d.ts +47 -0
  248. package/dist/hooks/useContentReady.d.ts +18 -0
  249. package/dist/hooks/useElementById.d.ts +20 -0
  250. package/dist/hooks/useElementByName.d.ts +10 -0
  251. package/dist/hooks/useElementProperties.d.ts +29 -0
  252. package/dist/hooks/useExport.d.ts +89 -0
  253. package/dist/hooks/useImageBinding.d.ts +34 -0
  254. package/dist/hooks/useKeyboardShortcuts.d.ts +13 -0
  255. package/dist/hooks/useLayerDndKit.d.ts +24 -0
  256. package/dist/hooks/useLayerDragDrop.d.ts +58 -0
  257. package/dist/hooks/useLayerPreview.d.ts +31 -0
  258. package/dist/hooks/useLayerSelection.d.ts +76 -0
  259. package/dist/hooks/useLayers.d.ts +91 -0
  260. package/dist/hooks/usePerformance.d.ts +48 -0
  261. package/dist/hooks/useProjectLoader.d.ts +64 -0
  262. package/dist/hooks/useSelectedElement.d.ts +17 -0
  263. package/dist/hooks/useTextBinding.d.ts +26 -0
  264. package/dist/hooks/useTextToolbar.d.ts +61 -0
  265. package/dist/hooks/useViewport.d.ts +46 -0
  266. package/dist/icons/icon-data.d.ts +2 -0
  267. package/dist/icons/registry.d.ts +28 -0
  268. package/dist/index.d.ts +6 -0
  269. package/dist/index.js +2 -0
  270. package/dist/index.js.map +1 -0
  271. package/dist/index.mjs +1138 -0
  272. package/dist/index.mjs.map +1 -0
  273. package/dist/internals.d.ts +2 -0
  274. package/dist/internals.js +2 -0
  275. package/dist/internals.js.map +1 -0
  276. package/dist/internals.mjs +219 -0
  277. package/dist/internals.mjs.map +1 -0
  278. package/dist/kits/compose.d.ts +69 -0
  279. package/dist/kits/index.d.ts +21 -0
  280. package/dist/kits/presets.d.ts +40 -0
  281. package/dist/kits/registry.d.ts +33 -0
  282. package/dist/kits/sections.d.ts +119 -0
  283. package/dist/kits/serialization.d.ts +78 -0
  284. package/dist/kits/types.d.ts +129 -0
  285. package/dist/kits/validation.d.ts +36 -0
  286. package/dist/lib/utils.d.ts +2 -0
  287. package/dist/plugins/ElementTypePlugin.d.ts +90 -0
  288. package/dist/presets/artboard-color-presets.d.ts +22 -0
  289. package/dist/presets/tshirt-presets.d.ts +60 -0
  290. package/dist/rendering/CompositingRenderer.d.ts +33 -0
  291. package/dist/rendering/DistressTextureRenderer.d.ts +39 -0
  292. package/dist/rendering/ElementRenderUtils.d.ts +17 -0
  293. package/dist/rendering/MaskRenderer.d.ts +41 -0
  294. package/dist/rendering/PieceGuideRenderer.d.ts +177 -0
  295. package/dist/rendering/StrokeRenderer.d.ts +24 -0
  296. package/dist/rendering/canvas-renderer.d.ts +18 -0
  297. package/dist/rendering/element-serializer.d.ts +143 -0
  298. package/dist/rendering/image-renderer.d.ts +6 -0
  299. package/dist/rendering/knockout-utils.d.ts +48 -0
  300. package/dist/rendering/mask-utils.d.ts +65 -0
  301. package/dist/rendering/renderer-types.d.ts +79 -0
  302. package/dist/rendering/rich-text-renderer.d.ts +43 -0
  303. package/dist/rendering/serialize-for-server.d.ts +45 -0
  304. package/dist/rendering/shape-renderer.d.ts +6 -0
  305. package/dist/rendering/stroke-utils.d.ts +18 -0
  306. package/dist/rendering/text-renderer.d.ts +71 -0
  307. package/dist/rendering/transform-renderer.d.ts +33 -0
  308. package/dist/services/AutoExportManager.d.ts +107 -0
  309. package/dist/services/falApi.d.ts +63 -0
  310. package/dist/services/nounProjectApi.d.ts +90 -0
  311. package/dist/services/recraftApi.d.ts +65 -0
  312. package/dist/services/runwareApi.d.ts +69 -0
  313. package/dist/state/CanvasStateV1.d.ts +373 -0
  314. package/dist/state/index.d.ts +10 -0
  315. package/dist/style.css +1 -0
  316. package/dist/taco-reference-cropped.jpg +0 -0
  317. package/dist/testing/MockEditorProvider.d.ts +49 -0
  318. package/dist/testing/index.d.ts +25 -0
  319. package/dist/testing/utils.d.ts +128 -0
  320. package/dist/testing.d.ts +2 -0
  321. package/dist/testing.js +2 -0
  322. package/dist/testing.js.map +1 -0
  323. package/dist/testing.mjs +140 -0
  324. package/dist/testing.mjs.map +1 -0
  325. package/dist/textures/glass-frame.svg +32 -0
  326. package/dist/theme.d.ts +99 -0
  327. package/dist/themes/index.d.ts +23 -0
  328. package/dist/transforms/ArchTransform.d.ts +14 -0
  329. package/dist/transforms/AscendTransform.d.ts +14 -0
  330. package/dist/transforms/CircleTransform.d.ts +51 -0
  331. package/dist/transforms/CustomTransform.d.ts +81 -0
  332. package/dist/transforms/FlagTransform.d.ts +14 -0
  333. package/dist/transforms/LeanTransform.d.ts +14 -0
  334. package/dist/transforms/WaveTransform.d.ts +16 -0
  335. package/dist/transforms/defaults.d.ts +33 -0
  336. package/dist/transforms/index.d.ts +10 -0
  337. package/dist/transforms/registry.d.ts +51 -0
  338. package/dist/types/capabilities.d.ts +50 -0
  339. package/dist/types/guards.d.ts +31 -0
  340. package/dist/types/index.d.ts +765 -0
  341. package/dist/types/public.d.ts +31 -0
  342. package/dist/types/react.d.ts +132 -0
  343. package/dist/utils/ArtworkPlacement.d.ts +97 -0
  344. package/dist/utils/ElementPreviewRenderer.d.ts +19 -0
  345. package/dist/utils/ExportManager.d.ts +208 -0
  346. package/dist/utils/FontAnalyzer.d.ts +137 -0
  347. package/dist/utils/GlyphRenderer.d.ts +55 -0
  348. package/dist/utils/GoogleFontsService.d.ts +37 -0
  349. package/dist/utils/ImageLoader.d.ts +124 -0
  350. package/dist/utils/ImportManager.d.ts +72 -0
  351. package/dist/utils/MonotypeCategoryMapping.d.ts +36 -0
  352. package/dist/utils/MonotypeService.d.ts +148 -0
  353. package/dist/utils/PerformanceMonitor.d.ts +54 -0
  354. package/dist/utils/TextureManager.d.ts +60 -0
  355. package/dist/utils/UnifiedFontService.d.ts +117 -0
  356. package/dist/utils/WorkerExportManager.d.ts +185 -0
  357. package/dist/utils/clickProtection.d.ts +39 -0
  358. package/dist/utils/cn.d.ts +4 -0
  359. package/dist/utils/colorConversion.d.ts +101 -0
  360. package/dist/utils/documentColors.d.ts +108 -0
  361. package/dist/utils/featureApplied.d.ts +14 -0
  362. package/dist/utils/google-fonts-loader.d.ts +67 -0
  363. package/dist/utils/logger.d.ts +66 -0
  364. package/dist/utils/selectionPreservation.d.ts +42 -0
  365. package/dist/utils/textCursorUtils.d.ts +39 -0
  366. package/dist/utils/textUtils.d.ts +11 -0
  367. package/dist/workers/export-protocol.d.ts +119 -0
  368. package/dist/workers/export-worker.bundle.string.d.ts +2 -0
  369. package/dist/workers/export-worker.d.ts +5 -0
  370. package/package.json +201 -0
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Central constants file for theme values, colors, and magic numbers
3
+ * Eliminates duplication across the codebase
4
+ */
5
+ /**
6
+ * Get the current theme's accent color from HeroUI CSS variables
7
+ * Returns oklch() color from --accent variable
8
+ */
9
+ export declare function getThemeAccentColor(element?: HTMLElement): string;
10
+ /**
11
+ * Get the current theme's accent foreground color from HeroUI CSS variables
12
+ * This is the contrasting color for text/icons on accent backgrounds
13
+ */
14
+ export declare function getThemeAccentForegroundColor(element?: HTMLElement): string;
15
+ /**
16
+ * Get the current theme name from the data-theme attribute
17
+ */
18
+ export declare function getCurrentTheme(element?: HTMLElement): string;
19
+ /**
20
+ * Get the default shape fill color based on the current theme
21
+ * Returns colors that complement each theme's aesthetic
22
+ */
23
+ export declare function getThemeShapeFillColor(): string;
24
+ /**
25
+ * Get the spacing indicator color from the current theme
26
+ */
27
+ export declare function getThemeSpacingColor(element?: HTMLElement): string;
28
+ /**
29
+ * Get the current theme's accent color with alpha transparency
30
+ * Handles both oklch() colors (from HeroUI theme) and hex colors (legacy)
31
+ */
32
+ export declare function getThemeAccentColorWithAlpha(alpha?: number, element?: HTMLElement): string;
33
+ /**
34
+ * Get the current theme's text selection color from CSS variables
35
+ * Returns the theme-specific selection highlight color (already includes opacity)
36
+ */
37
+ export declare function getThemeTextSelectionColor(element?: HTMLElement): string;
38
+ /**
39
+ * Get the current theme's hover accent color
40
+ */
41
+ export declare function getThemeAccentHoverColor(element?: HTMLElement): string;
42
+ /**
43
+ * Get the current theme's hover accent color with alpha channel
44
+ */
45
+ export declare function getThemeAccentHoverColorWithAlpha(alpha?: number, element?: HTMLElement): string;
46
+ /**
47
+ * Get the background color for canvas-rendered tooltips.
48
+ * Uses --foreground so the tooltip is dark in light mode and light in dark mode,
49
+ * ensuring contrast against the typically light artboard canvas.
50
+ */
51
+ export declare function getThemeTooltipBackground(element?: HTMLElement): string;
52
+ /**
53
+ * Get the text color for canvas-rendered tooltips.
54
+ * Uses --background so text contrasts with getThemeTooltipBackground().
55
+ */
56
+ export declare function getThemeTooltipForeground(element?: HTMLElement): string;
57
+ /**
58
+ * Get the shadow color for canvas-rendered tooltips.
59
+ * Derives from the tooltip background at 0.2 opacity.
60
+ */
61
+ export declare function getThemeTooltipShadowColor(element?: HTMLElement): string;
62
+ /**
63
+ * Get the border color for artboard outlines.
64
+ * Uses --divider for a theme-appropriate muted border that adapts to light/dark mode.
65
+ */
66
+ export declare function getThemeArtboardBorderColor(element?: HTMLElement): string;
67
+ /**
68
+ * Get the label text color for artboard names.
69
+ * Uses --foreground at 50% opacity for a muted appearance that adapts to light/dark mode.
70
+ */
71
+ export declare function getThemeArtboardLabelColor(element?: HTMLElement): string;
72
+ /**
73
+ * Get the current theme's hover border color (uses hover accent color)
74
+ */
75
+ export declare function getThemeHoverBorderColor(element?: HTMLElement): string;
76
+ /**
77
+ * Get the pen tool path stroke color.
78
+ * Uses --foreground so the path line is dark in light mode and light in dark mode,
79
+ * ensuring visibility against both white and dark artboard backgrounds.
80
+ */
81
+ export declare function getThemePenPathColor(element?: HTMLElement): string;
82
+ /**
83
+ * Get the fill color for pen tool anchor points.
84
+ * Uses --background so anchor circles are visible against the accent-color stroke on both light and dark themes.
85
+ */
86
+ export declare function getThemePenAnchorFillColor(element?: HTMLElement): string;
87
+ /**
88
+ * Get the pen tool bezier handle color (control lines and dots).
89
+ * Uses --foreground at 50% opacity for a muted appearance that adapts to light/dark mode.
90
+ */
91
+ export declare function getThemePenHandleColor(element?: HTMLElement): string;
92
+ export declare function getSelectionColor(): string;
93
+ export declare function getSelectionFillColor(): string;
94
+ export declare const HOVER_COLOR = "#fbbf24";
95
+ export declare const PREVIEW_ELEMENT_OPACITY = 1;
96
+ export declare const DEFAULT_ARTBOARD_COLOR = "#ffffff";
97
+ export declare const DEFAULT_SHAPE_FILL_COLOR = "#3b82f6";
98
+ export declare const HANDLE_SIZE = 12;
99
+ export declare const HANDLE_RADIUS = 6;
100
+ export declare const ROTATION_HANDLE_DISTANCE = 20;
101
+ export declare const HANDLE_HIT_TOLERANCE = 8;
102
+ export declare const CORNER_HANDLE_VISUAL_RADIUS = 6;
103
+ export declare const EDGE_HANDLE_VISUAL_LENGTH = 24;
104
+ export declare const CORNER_HANDLE_HIT_RADIUS = 16;
105
+ export declare const EDGE_HANDLE_LENGTH = 36;
106
+ export declare const EDGE_HANDLE_HIT_WIDTH = 24;
107
+ export declare const ALIGNMENT_SNAP_THRESHOLD = 2;
108
+ export declare const SPACING_SNAP_THRESHOLD = 4;
109
+ export declare const SPACING_LABEL_TEXT_COLOR = "#FFFFFF";
110
+ export declare const SPACING_LABEL_BORDER_RADIUS = 2;
111
+ export declare const MIN_CROP_SIZE = 0.1;
112
+ export declare const FONT_FAMILIES: string[];
113
+ export declare const FONT_SIZES: number[];
114
+ export declare const HORIZONTAL_PADDING = 0;
115
+ export declare const LINE_HEIGHT_MULTIPLIER = 1.2;
116
+ export declare const MIN_WIDTH = 50;
117
+ export declare const MIN_FONT_SIZE = 8;
118
+ export declare const MAX_FONT_SIZE = 999;
119
+ export declare const SYSTEM_FONTS: Set<string>;
120
+ export declare const WAVE_SKEW_FACTOR = 0.3;
121
+ export declare const WAVE_PATH_STEPS = 100;
@@ -0,0 +1,87 @@
1
+ import { default as React, ReactNode } from 'react';
2
+ import { useCommandHistory } from '../hooks/useCommandHistory.js';
3
+ /** Value exposed by CommandContext. */
4
+ export interface CommandContextValue {
5
+ /** Execute an element update (old -> new) through command history */
6
+ executeElementUpdate: ReturnType<typeof useCommandHistory>['executeElementUpdate'];
7
+ /** Execute adding a new element through command history */
8
+ executeAddElement: ReturnType<typeof useCommandHistory>['executeAddElement'];
9
+ /** Execute removing an element through command history */
10
+ executeRemoveElement: ReturnType<typeof useCommandHistory>['executeRemoveElement'];
11
+ /** Execute reordering an element through command history */
12
+ executeReorderElement: ReturnType<typeof useCommandHistory>['executeReorderElement'];
13
+ /** Execute creating an artboard through command history */
14
+ executeCreateArtboard: ReturnType<typeof useCommandHistory>['executeCreateArtboard'];
15
+ /** Execute deleting an artboard through command history */
16
+ executeDeleteArtboard: ReturnType<typeof useCommandHistory>['executeDeleteArtboard'];
17
+ /** Execute updating an artboard through command history */
18
+ executeUpdateArtboard: ReturnType<typeof useCommandHistory>['executeUpdateArtboard'];
19
+ /** Execute a batch of commands as a single undo entry */
20
+ executeCommandBatch: ReturnType<typeof useCommandHistory>['executeCommandBatch'];
21
+ /** Undo the last operation (global scope) */
22
+ undo: () => void;
23
+ /** Redo the last undone operation (global scope) */
24
+ redo: () => void;
25
+ /** Whether there is an operation to undo (global scope) */
26
+ canUndo: boolean;
27
+ /** Whether there is an operation to redo (global scope) */
28
+ canRedo: boolean;
29
+ /** Undo the last operation on the active artboard */
30
+ undoActiveArtboard: () => void;
31
+ /** Redo the last undone operation on the active artboard */
32
+ redoActiveArtboard: () => void;
33
+ /** Whether there is an operation to undo on the active artboard */
34
+ canUndoActiveArtboard: boolean;
35
+ /** Whether there is an operation to redo on the active artboard */
36
+ canRedoActiveArtboard: boolean;
37
+ /** The underlying history manager instance */
38
+ historyManager: ReturnType<typeof useCommandHistory>['historyManager'];
39
+ }
40
+ /** Props for {@link CommandProvider}. */
41
+ export interface CommandProviderProps {
42
+ children: ReactNode;
43
+ /**
44
+ * The actual command execution functions and undo/redo state.
45
+ * Provided by InternalEditorProvider which owns the command history.
46
+ */
47
+ value: CommandContextValue;
48
+ }
49
+ /**
50
+ * Provides command execution and undo/redo state to all descendants.
51
+ *
52
+ * This is a "pass-through" provider: the actual state is computed by
53
+ * EditorProvider (via useCommandHistory) and passed in as props. This
54
+ * allows components to subscribe to command state without subscribing
55
+ * to all of EditorContext.
56
+ */
57
+ export declare const CommandProvider: React.FC<CommandProviderProps>;
58
+ /**
59
+ * Access command execution and undo/redo state.
60
+ *
61
+ * Prefer this over `useEditor()` in components that only need to execute
62
+ * commands or check undo/redo availability (e.g., toolbar buttons that
63
+ * add/remove elements, undo/redo controls).
64
+ *
65
+ * Note: For undo/redo-only access (without execute functions), prefer
66
+ * `useHistoryContext()` which is even more focused.
67
+ *
68
+ * @throws {Error} If called outside of a `CommandProvider` (or `EditorProvider`)
69
+ *
70
+ * @example
71
+ * ```tsx
72
+ * function DeleteButton() {
73
+ * const { executeRemoveElement } = useCommandContext();
74
+ * const { selectedElement } = useEditor();
75
+ *
76
+ * return (
77
+ * <button
78
+ * onClick={() => selectedElement && executeRemoveElement(selectedElement)}
79
+ * disabled={!selectedElement}
80
+ * >
81
+ * Delete
82
+ * </button>
83
+ * );
84
+ * }
85
+ * ```
86
+ */
87
+ export declare function useCommandContext(): CommandContextValue;
@@ -0,0 +1,190 @@
1
+ import { default as React, ReactNode } from 'react';
2
+ import { ArtboardElement } from '../core/ArtboardElement.js';
3
+ import { ArtboardManager } from '../core/ArtboardManager.js';
4
+ import { TextElement } from '../core/TextElement.js';
5
+ import { ImageElement } from '../core/ImageElement.js';
6
+ import { GroupElement } from '../core/GroupElement.js';
7
+ import { ShapeElement } from '../core/ShapeElement.js';
8
+ import { PathElement } from '../core/PathElement.js';
9
+ import { ElementStore } from '../core/ElementStore.js';
10
+ import { useCommandHistory } from '../hooks/useCommandHistory.js';
11
+ import { CanvasEditorHandle } from '../components/CanvasEditor.jsx';
12
+ import { TextAlign, ShapeType } from '../types/index.js';
13
+ export type { PanOffset } from './ViewportContext.js';
14
+ export type { ExpandedPanelType } from './ToolStateContext.js';
15
+ export type EditorElement = TextElement | ImageElement | GroupElement | ShapeElement | PathElement;
16
+ /**
17
+ * Full value exposed by EditorContext.
18
+ *
19
+ * Contains core state (elements, selection, artboards, zoom), refs to the
20
+ * canvas DOM and imperative editor handle, setter functions, command history
21
+ * operations (undo/redo), and element property helpers.
22
+ */
23
+ export interface EditorContextValue {
24
+ artboardManager: ArtboardManager;
25
+ artboards: ArtboardElement[];
26
+ elements: EditorElement[];
27
+ /** Normalized element store for O(1) lookups. Use getElementById() for convenience. */
28
+ elementStore: ElementStore;
29
+ selectedId: string | null;
30
+ multiSelection: string[];
31
+ selectedElement: EditorElement | undefined;
32
+ activeChildElement: EditorElement | null;
33
+ hoveredElementId: string | null;
34
+ hideHandles: boolean;
35
+ zoom: number;
36
+ panOffset: import('./ViewportContext.js').PanOffset;
37
+ isPanning: boolean;
38
+ isRotating: boolean;
39
+ /** O(1) element lookup by ID. Returns undefined if not found. */
40
+ getElementById: (id: string) => EditorElement | undefined;
41
+ expandedPanelType: import('./ToolStateContext.js').ExpandedPanelType;
42
+ setExpandedPanelType: React.Dispatch<React.SetStateAction<import('./ToolStateContext.js').ExpandedPanelType>>;
43
+ clearExpandedPanel: () => void;
44
+ isToolbarMenuOpen: boolean;
45
+ setIsToolbarMenuOpen: React.Dispatch<React.SetStateAction<boolean>>;
46
+ canvasRef: React.RefObject<HTMLCanvasElement | null>;
47
+ canvasEditorRef: React.RefObject<CanvasEditorHandle | null>;
48
+ setElements: React.Dispatch<React.SetStateAction<EditorElement[]>>;
49
+ setSelectedId: React.Dispatch<React.SetStateAction<string | null>>;
50
+ setZoom: React.Dispatch<React.SetStateAction<number>>;
51
+ setPanOffset: React.Dispatch<React.SetStateAction<import('./ViewportContext.js').PanOffset>>;
52
+ setIsPanning: React.Dispatch<React.SetStateAction<boolean>>;
53
+ setHoveredElementId: React.Dispatch<React.SetStateAction<string | null>>;
54
+ setHideHandles: React.Dispatch<React.SetStateAction<boolean>>;
55
+ setMultiSelection: React.Dispatch<React.SetStateAction<string[]>>;
56
+ setTextSelectionVersion: React.Dispatch<React.SetStateAction<number>>;
57
+ setIsRotating: React.Dispatch<React.SetStateAction<boolean>>;
58
+ zoomIn: () => void;
59
+ zoomOut: () => void;
60
+ zoomToFit: () => void;
61
+ resetView: () => void;
62
+ /**
63
+ * Version counter that increments on every artboard mutation.
64
+ * Components can depend on this to re-render when artboard state changes,
65
+ * even though ArtboardManager is a mutable class instance.
66
+ */
67
+ artboardVersion: number;
68
+ refreshArtboards: () => void;
69
+ handleSelectionChange: (id: string | null) => void;
70
+ handleActiveChildChange: (child: EditorElement | null) => void;
71
+ handleElementUpdate: (updatedElement: EditorElement) => void;
72
+ handleAddElement: (elementType: string, opts?: {
73
+ shapeType?: ShapeType;
74
+ }) => Promise<void>;
75
+ handleLoadWorkspace: (loadedArtboards: ArtboardElement[], loadedElements: EditorElement[], activeArtboardId: string | null) => void;
76
+ handleCopyElements: () => void;
77
+ handlePasteElements: () => void;
78
+ historyManager: ReturnType<typeof useCommandHistory>['historyManager'];
79
+ executeElementUpdate: ReturnType<typeof useCommandHistory>['executeElementUpdate'];
80
+ executeAddElement: ReturnType<typeof useCommandHistory>['executeAddElement'];
81
+ executeRemoveElement: ReturnType<typeof useCommandHistory>['executeRemoveElement'];
82
+ executeReorderElement: ReturnType<typeof useCommandHistory>['executeReorderElement'];
83
+ executeCreateArtboard: ReturnType<typeof useCommandHistory>['executeCreateArtboard'];
84
+ executeDeleteArtboard: ReturnType<typeof useCommandHistory>['executeDeleteArtboard'];
85
+ executeUpdateArtboard: ReturnType<typeof useCommandHistory>['executeUpdateArtboard'];
86
+ executeCommandBatch: ReturnType<typeof useCommandHistory>['executeCommandBatch'];
87
+ undo: () => void;
88
+ redo: () => void;
89
+ canUndo: boolean;
90
+ canRedo: boolean;
91
+ undoActiveArtboard: () => void;
92
+ redoActiveArtboard: () => void;
93
+ canUndoActiveArtboard: boolean;
94
+ canRedoActiveArtboard: boolean;
95
+ fontSize: number;
96
+ fontColor: string;
97
+ fontFamily: string;
98
+ textAlign: TextAlign;
99
+ updateFontSize: (delta: number) => void;
100
+ setFontSizeValue: (size: number) => void;
101
+ updateFontColor: (color: string) => void;
102
+ updateFontFamily: (fontFamily: string) => void;
103
+ updateTextAlign: (textAlign: TextAlign) => void;
104
+ textSelectionVersion: number;
105
+ isCanvasReady: boolean;
106
+ setCanvasReady: (ready: boolean) => void;
107
+ }
108
+ /** Props for {@link EditorProvider}. */
109
+ export interface EditorProviderProps {
110
+ children: ReactNode;
111
+ /** Configuration for the default artboard created on mount. */
112
+ initialArtboardConfig?: {
113
+ name?: string;
114
+ x?: number;
115
+ y?: number;
116
+ width?: number;
117
+ height?: number;
118
+ backgroundColor?: string;
119
+ };
120
+ /**
121
+ * Controls how much of the container the artboard fills when using fitToArtboard.
122
+ * Value between 0 and 1, where 1 means the artboard fills 100% of the container.
123
+ * Default is 0.9 (90%), leaving 5% padding on each side.
124
+ * Use smaller values (e.g., 0.8) to show more canvas area around the artboard.
125
+ */
126
+ viewPadding?: number;
127
+ }
128
+ /**
129
+ * Provides editor state and operations to all descendant components.
130
+ *
131
+ * Composes sub-providers (ViewportProvider, SelectionProvider, ToolStateProvider,
132
+ * HistoryProvider) around an internal EditorProvider. This gives each sub-context
133
+ * its own React context, so changes to viewport state (e.g., zoom) won't re-render
134
+ * components that only subscribe to selection state, and vice versa.
135
+ *
136
+ * Must wrap any component that calls `useEditor()` or any of the convenience
137
+ * hooks (`useArtboards`, `useLayers`, `useViewportContext`, etc.).
138
+ *
139
+ * @example
140
+ * ```tsx
141
+ * import { EditorProvider, Canvas, useEditor } from '@snowcone-app/canvas';
142
+ *
143
+ * function MyEditor() {
144
+ * return (
145
+ * <EditorProvider initialArtboardConfig={{ width: 1200, height: 1200 }}>
146
+ * <Canvas style={{ width: '100%' }} />
147
+ * <CustomToolbar />
148
+ * </EditorProvider>
149
+ * );
150
+ * }
151
+ * ```
152
+ */
153
+ export declare const EditorProvider: React.FC<EditorProviderProps>;
154
+ /**
155
+ * Access the full editor context: elements, selection, artboards, history, and operations.
156
+ *
157
+ * Must be called inside an `EditorProvider`. For focused access, prefer the
158
+ * sub-context hooks which expose smaller slices of state and cause fewer re-renders:
159
+ *
160
+ * - `useViewportContext()` - zoom, pan
161
+ * - `useSelectionContext()` - selection, hover
162
+ * - `useHistoryContext()` - undo, redo
163
+ * - `useToolStateContext()` - panel state, toolbar menus
164
+ * - `useElementsContext()` - elements, artboards, element operations, font properties
165
+ * - `useCommandContext()` - command execution (execute*), undo/redo, historyManager
166
+ *
167
+ * Or the convenience hooks:
168
+ * - `useArtboards()`, `useLayers()`, `useExport()`, `useCommands()`
169
+ * - `useSelectedElement()`, `useElementById()`, `useCanvasReady()`, `useViewport()`
170
+ *
171
+ * @returns The complete editor context value
172
+ * @throws {Error} If called outside of an `EditorProvider`
173
+ *
174
+ * @example
175
+ * ```tsx
176
+ * function StatusBar() {
177
+ * const { elements, selectedId, zoom, canUndo, canRedo, undo, redo } = useEditor();
178
+ *
179
+ * return (
180
+ * <div>
181
+ * <span>{elements.length} elements</span>
182
+ * <span>Zoom: {Math.round(zoom * 100)}%</span>
183
+ * <button onClick={undo} disabled={!canUndo}>Undo</button>
184
+ * <button onClick={redo} disabled={!canRedo}>Redo</button>
185
+ * </div>
186
+ * );
187
+ * }
188
+ * ```
189
+ */
190
+ export declare const useEditor: () => EditorContextValue;
@@ -0,0 +1,104 @@
1
+ import { default as React, ReactNode } from 'react';
2
+ import { ArtboardElement } from '../core/ArtboardElement.js';
3
+ import { ArtboardManager } from '../core/ArtboardManager.js';
4
+ import { ElementStore } from '../core/ElementStore.js';
5
+ import { CanvasEditorHandle } from '../components/CanvasEditor.jsx';
6
+ import { EditorElement } from './EditorContext.js';
7
+ import { TextAlign } from '../types/index.js';
8
+ /** Value exposed by ElementsContext. */
9
+ export interface ElementsContextValue {
10
+ /** All elements in the editor */
11
+ elements: EditorElement[];
12
+ /** Normalized element store for O(1) lookups */
13
+ elementStore: ElementStore;
14
+ /** All artboards */
15
+ artboards: ArtboardElement[];
16
+ /** Artboard manager instance */
17
+ artboardManager: ArtboardManager;
18
+ /**
19
+ * Version counter that increments on every artboard mutation.
20
+ * Components can depend on this to re-render when artboard state changes.
21
+ */
22
+ artboardVersion: number;
23
+ /** Set elements (same SetStateAction signature as before) */
24
+ setElements: React.Dispatch<React.SetStateAction<EditorElement[]>>;
25
+ /** Refresh artboards from the artboard manager */
26
+ refreshArtboards: () => void;
27
+ /** O(1) element lookup by ID. Returns undefined if not found. */
28
+ getElementById: (id: string) => EditorElement | undefined;
29
+ /** Add an element by type (text, image, shape, etc.) */
30
+ handleAddElement: (elementType: string) => Promise<void>;
31
+ /** Update an element */
32
+ handleElementUpdate: (updatedElement: EditorElement) => void;
33
+ /** Load a workspace (artboards + elements) */
34
+ handleLoadWorkspace: (loadedArtboards: ArtboardElement[], loadedElements: EditorElement[], activeArtboardId: string | null) => void;
35
+ /** Copy selected elements to clipboard */
36
+ handleCopyElements: () => void;
37
+ /** Paste elements from clipboard */
38
+ handlePasteElements: () => void;
39
+ /** Current font size of selected element */
40
+ fontSize: number;
41
+ /** Current font color of selected element */
42
+ fontColor: string;
43
+ /** Current font family of selected element */
44
+ fontFamily: string;
45
+ /** Current text alignment of selected element */
46
+ textAlign: TextAlign;
47
+ /** Update font size by delta */
48
+ updateFontSize: (delta: number) => void;
49
+ /** Set font size to exact value */
50
+ setFontSizeValue: (size: number) => void;
51
+ /** Update font color */
52
+ updateFontColor: (color: string) => void;
53
+ /** Update font family */
54
+ updateFontFamily: (fontFamily: string) => void;
55
+ /** Update text alignment */
56
+ updateTextAlign: (textAlign: TextAlign) => void;
57
+ /** Ref to the canvas HTML element */
58
+ canvasRef: React.RefObject<HTMLCanvasElement | null>;
59
+ /** Ref to the imperative canvas editor handle */
60
+ canvasEditorRef: React.RefObject<CanvasEditorHandle | null>;
61
+ }
62
+ /** Props for {@link ElementsProvider}. */
63
+ export interface ElementsProviderProps {
64
+ children: ReactNode;
65
+ /**
66
+ * The actual element/artboard state from the editor.
67
+ * Provided by InternalEditorProvider which owns all state.
68
+ */
69
+ value: ElementsContextValue;
70
+ }
71
+ /**
72
+ * Provides element and artboard state to all descendants.
73
+ *
74
+ * This is a "pass-through" provider: the actual state is computed by
75
+ * EditorProvider (via InternalEditorProvider) and passed in as props.
76
+ * This allows components to subscribe to element changes without
77
+ * subscribing to all of EditorContext.
78
+ */
79
+ export declare const ElementsProvider: React.FC<ElementsProviderProps>;
80
+ /**
81
+ * Access element and artboard state: elements, artboards, element operations,
82
+ * font properties, and canvas refs.
83
+ *
84
+ * Prefer this over `useEditor()` in components that only need element/artboard
85
+ * information (e.g., layers panel, effects panel, property inspectors).
86
+ * Changes to non-element state (viewport, selection, tool state) won't
87
+ * trigger re-renders in components using this hook.
88
+ *
89
+ * @throws {Error} If called outside of an `ElementsProvider` (or `EditorProvider`)
90
+ *
91
+ * @example
92
+ * ```tsx
93
+ * function ElementCount() {
94
+ * const { elements, artboards } = useElementsContext();
95
+ * return (
96
+ * <div>
97
+ * <span>{elements.length} elements</span>
98
+ * <span>{artboards.length} artboards</span>
99
+ * </div>
100
+ * );
101
+ * }
102
+ * ```
103
+ */
104
+ export declare function useElementsContext(): ElementsContextValue;
@@ -0,0 +1,60 @@
1
+ import { default as React, ReactNode } from 'react';
2
+ /** Value exposed by HistoryContext. */
3
+ export interface HistoryContextValue {
4
+ /** Undo the last operation (global scope) */
5
+ undo: () => void;
6
+ /** Redo the last undone operation (global scope) */
7
+ redo: () => void;
8
+ /** Whether there is an operation to undo (global scope) */
9
+ canUndo: boolean;
10
+ /** Whether there is an operation to redo (global scope) */
11
+ canRedo: boolean;
12
+ /** Undo the last operation on the active artboard */
13
+ undoActiveArtboard: () => void;
14
+ /** Redo the last undone operation on the active artboard */
15
+ redoActiveArtboard: () => void;
16
+ /** Whether there is an operation to undo on the active artboard */
17
+ canUndoActiveArtboard: boolean;
18
+ /** Whether there is an operation to redo on the active artboard */
19
+ canRedoActiveArtboard: boolean;
20
+ }
21
+ /** Props for {@link HistoryProvider}. */
22
+ export interface HistoryProviderProps {
23
+ children: ReactNode;
24
+ /**
25
+ * The actual undo/redo functions and state from the command history system.
26
+ * These are provided by EditorProvider which owns the command history.
27
+ */
28
+ value: HistoryContextValue;
29
+ }
30
+ /**
31
+ * Provides undo/redo state and actions to all descendants.
32
+ *
33
+ * This is a "pass-through" provider: the actual history state is computed
34
+ * by EditorProvider (via useCommandHistory) and passed in as props. This
35
+ * allows components to subscribe to history changes without subscribing
36
+ * to all of EditorContext.
37
+ */
38
+ export declare const HistoryProvider: React.FC<HistoryProviderProps>;
39
+ /**
40
+ * Access undo/redo state and actions.
41
+ *
42
+ * Prefer this over `useEditor()` in components that only need undo/redo
43
+ * controls (e.g., undo/redo buttons in a toolbar).
44
+ *
45
+ * @throws {Error} If called outside of a `HistoryProvider` (or `EditorProvider`)
46
+ *
47
+ * @example
48
+ * ```tsx
49
+ * function UndoRedoButtons() {
50
+ * const { undo, redo, canUndo, canRedo } = useHistoryContext();
51
+ * return (
52
+ * <>
53
+ * <button onClick={undo} disabled={!canUndo}>Undo</button>
54
+ * <button onClick={redo} disabled={!canRedo}>Redo</button>
55
+ * </>
56
+ * );
57
+ * }
58
+ * ```
59
+ */
60
+ export declare function useHistoryContext(): HistoryContextValue;
@@ -0,0 +1,50 @@
1
+ import { KitDefinition, KitPresetId } from '../kits/types.js';
2
+ /**
3
+ * The value provided by KitContext, including the current kit
4
+ * and a function to switch kits at runtime.
5
+ */
6
+ export interface KitContextValue {
7
+ /** The current resolved KitDefinition */
8
+ kit: KitDefinition;
9
+ /** Switch the active kit. Accepts a preset ID string or a full KitDefinition. */
10
+ setKit: (kit: KitPresetId | KitDefinition) => void;
11
+ }
12
+ /**
13
+ * Props for the KitProvider component.
14
+ */
15
+ export interface KitProviderProps {
16
+ /** The initial kit definition to provide. Updates to this prop will sync the internal state. */
17
+ kit: KitDefinition;
18
+ children: React.ReactNode;
19
+ }
20
+ /**
21
+ * Provides a resolved KitDefinition to all child components via context.
22
+ * Supports runtime kit switching: children can call `setKit` from `useKit()`
23
+ * to dynamically change the active kit. If the parent passes a new `kit` prop,
24
+ * the internal state is synced to match.
25
+ */
26
+ export declare function KitProvider({ kit: initialKit, children }: KitProviderProps): import("react/jsx-runtime").JSX.Element;
27
+ /**
28
+ * Returns the current kit context value, including the active KitDefinition
29
+ * and a `setKit` function for runtime kit switching.
30
+ *
31
+ * Must be called within a KitProvider.
32
+ *
33
+ * @throws {Error} If called outside of a KitProvider
34
+ *
35
+ * @example
36
+ * ```tsx
37
+ * const { kit, setKit } = useKit();
38
+ * console.log(kit.name);
39
+ * setKit('pro-studio'); // switch to a preset
40
+ * setKit(myCustomKit); // switch to a custom kit
41
+ * ```
42
+ */
43
+ export declare function useKit(): KitContextValue;
44
+ /**
45
+ * Convenience hook that returns just the capabilities from the current kit.
46
+ * Equivalent to `useKit().kit.capabilities`.
47
+ *
48
+ * @throws {Error} If called outside of a KitProvider
49
+ */
50
+ export declare function useCapabilities(): import('../types/capabilities.js').EditorCapabilities;
@@ -0,0 +1,51 @@
1
+ import { default as React, ReactNode } from 'react';
2
+ import { EditorElement } from './EditorContext.js';
3
+ /** Value exposed by SelectionContext. */
4
+ export interface SelectionContextValue {
5
+ /** ID of the currently selected element, or null if nothing is selected */
6
+ selectedId: string | null;
7
+ /** IDs of elements in the current multi-selection */
8
+ multiSelection: string[];
9
+ /** The child element being directly edited inside a group */
10
+ activeChildElement: EditorElement | null;
11
+ /** ID of the element currently being hovered */
12
+ hoveredElementId: string | null;
13
+ /** Whether to hide selection handles (e.g., during text editing) */
14
+ hideHandles: boolean;
15
+ /** Set the selected element ID */
16
+ setSelectedId: React.Dispatch<React.SetStateAction<string | null>>;
17
+ /** Set multi-selection IDs */
18
+ setMultiSelection: React.Dispatch<React.SetStateAction<string[]>>;
19
+ /** Set the hovered element ID */
20
+ setHoveredElementId: React.Dispatch<React.SetStateAction<string | null>>;
21
+ /** Set whether to hide selection handles */
22
+ setHideHandles: React.Dispatch<React.SetStateAction<boolean>>;
23
+ /** Handler for element selection changes */
24
+ handleSelectionChange: (id: string | null) => void;
25
+ /** Handler for active child element changes (group editing) */
26
+ handleActiveChildChange: (child: EditorElement | null) => void;
27
+ }
28
+ /** Props for {@link SelectionProvider}. */
29
+ export interface SelectionProviderProps {
30
+ children: ReactNode;
31
+ }
32
+ /**
33
+ * Provides selection state and handlers to all descendants.
34
+ *
35
+ * Manages which element is selected, multi-selection, hover state,
36
+ * and active child element for group editing.
37
+ */
38
+ export declare const SelectionProvider: React.FC<SelectionProviderProps>;
39
+ /**
40
+ * Access selection state: selected element ID, multi-selection, hover, and handlers.
41
+ *
42
+ * Prefer this over `useEditor()` in components that only need selection information
43
+ * (e.g., layers panel highlighting, toolbar enable/disable logic).
44
+ *
45
+ * Note: This does NOT provide `selectedElement` (the resolved element object).
46
+ * Use `useEditor()` or `useSelectedElement()` for that, as it requires
47
+ * cross-referencing with element state.
48
+ *
49
+ * @throws {Error} If called outside of a `SelectionProvider` (or `EditorProvider`)
50
+ */
51
+ export declare function useSelectionContext(): SelectionContextValue;