@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,219 @@
1
+ import { n as C, A as P, C as w, o as I, b as R, I as A, R as W, S as E, m as O, W as H, q as F, s as L, t as z, u as B, v as K, w as m, x as X, y as J, z as _, B as q } from "./ElementFactory-uJTXU-nP.js";
2
+ import { ab as l } from "./HybridHistoryManager-BV6XV0nD.js";
3
+ import { ac as V, ad as Y, ae as j, af as G, aa as U, ag as Q, ah as Z, ai as $, aj as x, ak as D, al as oo, am as ro, an as so, ao, ap as io, aq as eo, ar as no, as as to, at as ho, c as co, au as fo, av as lo, aw as po, ax as go, ay as uo, az as ko, aA as To, aB as yo, aC as Mo, aD as bo, aE as So, aF as vo, aG as Co, aH as Po, aI as wo, aJ as Io, aK as Ro } from "./HybridHistoryManager-BV6XV0nD.js";
4
+ import { I as Wo } from "./ImportManager-CxiaRg1N.js";
5
+ import { A as Oo, a as Ho, C as Fo, S as Lo } from "./CanvasStateV1-ejb4d_LM.js";
6
+ function M(o, r, c) {
7
+ var e, n;
8
+ o.save(), o.translate(r.x, r.y), r.rotation && o.rotate(-r.rotation * Math.PI / 180);
9
+ let i = 1, h = 1;
10
+ if (r.flipHorizontal && (i = -1), r.flipVertical && (h = -1), (i !== 1 || h !== 1) && o.scale(i, h), r.opacity !== void 0 && r.opacity !== 1 && (o.globalAlpha = r.opacity), r.borderRadius && r.borderRadius > 0) {
11
+ const a = Math.min(
12
+ r.borderRadius / 100 * Math.min(r.width, r.height),
13
+ r.width / 2,
14
+ r.height / 2
15
+ );
16
+ o.beginPath();
17
+ const s = -r.width / 2, t = -r.height / 2, d = r.width, f = r.height;
18
+ o.moveTo(s + a, t), o.lineTo(s + d - a, t), o.arcTo(s + d, t, s + d, t + a, a), o.lineTo(s + d, t + f - a), o.arcTo(s + d, t + f, s + d - a, t + f, a), o.lineTo(s + a, t + f), o.arcTo(s, t + f, s, t + f - a, a), o.lineTo(s, t + a), o.arcTo(s, t, s + a, t, a), o.closePath(), o.clip();
19
+ }
20
+ if (r.cropX !== void 0 && r.cropWidth !== void 0 ? o.drawImage(
21
+ c,
22
+ r.cropX,
23
+ r.cropY || 0,
24
+ r.cropWidth,
25
+ r.cropHeight || c.height,
26
+ -r.width / 2,
27
+ -r.height / 2,
28
+ r.width,
29
+ r.height
30
+ ) : o.drawImage(c, -r.width / 2, -r.height / 2, r.width, r.height), o.restore(), (e = r.stroke) != null && e.enabled) {
31
+ const a = ((n = r.knockoutParts) == null ? void 0 : n.stroke) === !0, s = {
32
+ x: r.x,
33
+ y: r.y,
34
+ rotation: r.rotation,
35
+ stroke: r.stroke,
36
+ knockoutParts: r.knockoutParts,
37
+ transformData: {
38
+ type: "image",
39
+ width: r.width,
40
+ height: r.height,
41
+ borderRadius: r.borderRadius || 0
42
+ }
43
+ };
44
+ if (a) {
45
+ const t = o.canvas;
46
+ let d;
47
+ if (typeof OffscreenCanvas < "u")
48
+ d = new OffscreenCanvas(t.width, t.height);
49
+ else if (typeof document < "u")
50
+ d = document.createElement("canvas"), d.width = t.width, d.height = t.height;
51
+ else {
52
+ l(o, s);
53
+ return;
54
+ }
55
+ const f = d.getContext("2d");
56
+ if (!f) {
57
+ l(o, s);
58
+ return;
59
+ }
60
+ l(f, s, { isKnockout: !0 }), o.save(), o.globalCompositeOperation = "destination-out", o.drawImage(d, 0, 0), o.restore();
61
+ } else
62
+ l(o, s);
63
+ }
64
+ }
65
+ function k(o, r) {
66
+ if (typeof OffscreenCanvas < "u")
67
+ return new OffscreenCanvas(o, r);
68
+ const c = document.createElement("canvas");
69
+ return c.width = o, c.height = r, c;
70
+ }
71
+ function b(o, r) {
72
+ var e;
73
+ const c = r.opacity ?? 1, i = !!((e = r.stroke) != null && e.enabled);
74
+ c < 1 && i ? T(o, r, c) : p(o, r, c);
75
+ }
76
+ function T(o, r, c) {
77
+ var f;
78
+ const i = r.transformData, e = (((f = r.stroke) == null ? void 0 : f.width) || 2) + 2, n = Math.ceil(i.width + e * 2), a = Math.ceil(i.height + e * 2), s = k(n, a), t = s.getContext("2d");
79
+ if (!t) {
80
+ p(o, r, c);
81
+ return;
82
+ }
83
+ const d = {
84
+ ...r,
85
+ x: n / 2,
86
+ y: a / 2
87
+ };
88
+ p(t, d, 1), o.save(), o.translate(r.x, r.y), r.rotation && o.rotate(-r.rotation * Math.PI / 180), o.globalAlpha = c, o.drawImage(s, -n / 2, -a / 2), o.restore();
89
+ }
90
+ function p(o, r, c) {
91
+ var e;
92
+ const i = r.transformData, h = i.fillOpacity ?? 1;
93
+ if (o.save(), o.translate(r.x, r.y), r.rotation && o.rotate(-r.rotation * Math.PI / 180), o.globalAlpha = c * h, o.fillStyle = i.fillColor || "#3b82f6", o.beginPath(), u(o, i), o.fill(), o.restore(), (e = r.stroke) != null && e.enabled) {
94
+ o.save(), o.translate(r.x, r.y), r.rotation && o.rotate(-r.rotation * Math.PI / 180);
95
+ const n = r.stroke;
96
+ o.globalAlpha = c * (n.opacity ?? 1), o.strokeStyle = n.color || "#000000", o.lineWidth = n.width || 2, o.lineCap = n.lineCap || "round", o.lineJoin = n.lineJoin || "round", o.beginPath(), u(o, i), o.stroke(), o.restore();
97
+ }
98
+ }
99
+ function u(o, r) {
100
+ const { shapeType: c, width: i, height: h } = r;
101
+ switch (c) {
102
+ case "rectangle": {
103
+ const e = r.borderRadius || 0, n = -i / 2, a = -h / 2;
104
+ if (e > 0) {
105
+ const s = Math.min(e / 100 * Math.min(i, h), i / 2, h / 2);
106
+ o.roundRect(n, a, i, h, s);
107
+ } else
108
+ o.rect(n, a, i, h);
109
+ break;
110
+ }
111
+ case "circle": {
112
+ const e = Math.min(i, h) / 2;
113
+ o.arc(0, 0, e, 0, Math.PI * 2);
114
+ break;
115
+ }
116
+ case "ellipse": {
117
+ o.ellipse(0, 0, i / 2, h / 2, 0, 0, Math.PI * 2);
118
+ break;
119
+ }
120
+ case "triangle": {
121
+ const e = i / 2, n = h / 2;
122
+ o.moveTo(0, -n), o.lineTo(e, n), o.lineTo(-e, n), o.closePath();
123
+ break;
124
+ }
125
+ case "polygon": {
126
+ const e = r.sides || 5, n = Math.min(i, h) / 2;
127
+ for (let a = 0; a < e; a++) {
128
+ const s = a * 2 * Math.PI / e - Math.PI / 2, t = n * Math.cos(s), d = n * Math.sin(s);
129
+ a === 0 ? o.moveTo(t, d) : o.lineTo(t, d);
130
+ }
131
+ o.closePath();
132
+ break;
133
+ }
134
+ case "star": {
135
+ const e = r.points || 5, n = Math.min(i, h) / 2, a = n * (r.innerRadius || 0.4);
136
+ for (let s = 0; s < e * 2; s++) {
137
+ const t = s * Math.PI / e - Math.PI / 2, d = s % 2 === 0 ? n : a, f = d * Math.cos(t), g = d * Math.sin(t);
138
+ s === 0 ? o.moveTo(f, g) : o.lineTo(f, g);
139
+ }
140
+ o.closePath();
141
+ break;
142
+ }
143
+ case "line": {
144
+ const e = i / 2, n = h / 2;
145
+ o.rect(-e, -n, i, h);
146
+ break;
147
+ }
148
+ default:
149
+ o.rect(-i / 2, -h / 2, i, h);
150
+ }
151
+ }
152
+ export {
153
+ C as AlignmentSnapSystem,
154
+ Oo as AnyElementConfigSchema,
155
+ Ho as AnyTransformDataSchema,
156
+ V as ArchTransform,
157
+ Y as ArtboardManager,
158
+ P as ArtboardRenderer,
159
+ j as AscendTransform,
160
+ w as CanvasRenderer,
161
+ Fo as CanvasStateV1Schema,
162
+ G as CircleTransform,
163
+ U as CustomTransform,
164
+ I as DEFAULT_MAX_BITMAP_DIMENSION,
165
+ Q as ElementStore,
166
+ R as ExportManager,
167
+ Z as FlagTransform,
168
+ $ as HybridHistoryManager,
169
+ Wo as ImportManager,
170
+ A as InteractionStateMachine,
171
+ x as LeanTransform,
172
+ D as LogLevel,
173
+ W as ResizePipeline,
174
+ Lo as SerializedArtboardSchema,
175
+ E as SpacingSystem,
176
+ O as TransformHandles,
177
+ oo as WaveTransform,
178
+ H as WorkerExportManager,
179
+ ro as applySpaceLayoutRules,
180
+ so as applyStrokeStyle,
181
+ ao as buildFontString,
182
+ io as calculateFixedCornerPosition,
183
+ eo as calculateResizeHandles,
184
+ no as calculateRotationHandlePosition,
185
+ F as clearImageBitmapCache,
186
+ L as clearMaskCache,
187
+ z as clearRegisteredBitmapKeys,
188
+ to as createCirclePath,
189
+ ho as createImagePath,
190
+ co as createLogger,
191
+ fo as createRectPath,
192
+ lo as createTextPath,
193
+ po as getFontMetrics,
194
+ B as getSharedWorkerExportManager,
195
+ go as hitTestCircle,
196
+ uo as hitTestRect,
197
+ K as invalidateMaskCache,
198
+ ko as logger,
199
+ To as measureTextWidth,
200
+ m as removeFromImageBitmapCache,
201
+ yo as renderCustomTransform,
202
+ M as renderImageElement,
203
+ l as renderImageStroke,
204
+ Mo as renderMultilineText,
205
+ bo as renderPathStroke,
206
+ So as renderRichTextFillOnly,
207
+ b as renderShapeElement,
208
+ vo as renderTextElement,
209
+ Co as renderTextFillOnly,
210
+ Po as renderTextStroke,
211
+ X as renderWithKnockout,
212
+ J as renderWithMasks,
213
+ wo as splitRichTextIntoLines,
214
+ _ as terminateSharedWorkerExportManager,
215
+ q as unregisterElementBitmaps,
216
+ Io as wrapRichTextSpans,
217
+ Ro as wrapText
218
+ };
219
+ //# sourceMappingURL=internals.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internals.mjs","sources":["../src/rendering/image-renderer.ts","../src/rendering/shape-renderer.ts"],"sourcesContent":["/**\n * Image Renderer - Image element rendering with crop, flip, border radius, and stroke.\n *\n * Works in both main thread and Web Worker (via OffscreenCanvas).\n */\n\nimport type { ImageElementConfig } from '../types/index.js';\nimport { renderImageStroke } from './StrokeRenderer.js';\nimport type { RenderContext, SerializedImageElement } from './renderer-types.js';\n\n/**\n * Render an image element using ImageBitmap\n * Works in both main thread and worker\n */\nexport function renderImageElement(\n ctx: RenderContext,\n elementData: SerializedImageElement,\n imageBitmap: ImageBitmap\n): void {\n ctx.save();\n\n // Translate to element position\n ctx.translate(elementData.x, elementData.y);\n\n // Apply rotation (negative for clockwise)\n if (elementData.rotation) {\n ctx.rotate((-elementData.rotation * Math.PI) / 180);\n }\n\n // Apply flip transformations\n let scaleX = 1;\n let scaleY = 1;\n if (elementData.flipHorizontal) scaleX = -1;\n if (elementData.flipVertical) scaleY = -1;\n if (scaleX !== 1 || scaleY !== 1) {\n ctx.scale(scaleX, scaleY);\n }\n\n // Apply opacity if specified\n if (elementData.opacity !== undefined && elementData.opacity !== 1) {\n ctx.globalAlpha = elementData.opacity;\n }\n\n // Apply border radius if specified (borderRadius is stored as percentage 0-100)\n if (elementData.borderRadius && elementData.borderRadius > 0) {\n const radius = Math.min(\n (elementData.borderRadius / 100) * Math.min(elementData.width, elementData.height),\n elementData.width / 2,\n elementData.height / 2\n );\n\n // Create clipping path for rounded corners\n ctx.beginPath();\n const x = -elementData.width / 2;\n const y = -elementData.height / 2;\n const w = elementData.width;\n const h = elementData.height;\n\n ctx.moveTo(x + radius, y);\n ctx.lineTo(x + w - radius, y);\n ctx.arcTo(x + w, y, x + w, y + radius, radius);\n ctx.lineTo(x + w, y + h - radius);\n ctx.arcTo(x + w, y + h, x + w - radius, y + h, radius);\n ctx.lineTo(x + radius, y + h);\n ctx.arcTo(x, y + h, x, y + h - radius, radius);\n ctx.lineTo(x, y + radius);\n ctx.arcTo(x, y, x + radius, y, radius);\n ctx.closePath();\n ctx.clip();\n }\n\n // Draw the image\n if (elementData.cropX !== undefined && elementData.cropWidth !== undefined) {\n // Draw with crop\n ctx.drawImage(\n imageBitmap,\n elementData.cropX,\n elementData.cropY || 0,\n elementData.cropWidth,\n elementData.cropHeight || imageBitmap.height,\n -elementData.width / 2,\n -elementData.height / 2,\n elementData.width,\n elementData.height\n );\n } else {\n // Draw without crop (centered)\n ctx.drawImage(imageBitmap, -elementData.width / 2, -elementData.height / 2, elementData.width, elementData.height);\n }\n\n ctx.restore();\n\n // Render stroke if enabled (after restore to apply fresh transforms)\n if (elementData.stroke?.enabled) {\n const hasKnockoutStroke = elementData.knockoutParts?.stroke === true;\n\n const imageConfig: ImageElementConfig = {\n transformType: 'image',\n x: elementData.x,\n y: elementData.y,\n rotation: elementData.rotation,\n stroke: elementData.stroke,\n knockoutParts: elementData.knockoutParts,\n transformData: {\n type: 'image',\n width: elementData.width,\n height: elementData.height,\n borderRadius: elementData.borderRadius || 0,\n },\n };\n\n if (hasKnockoutStroke) {\n // For knockout stroke, use offscreen canvas approach\n const canvas = ctx.canvas;\n let offscreen: HTMLCanvasElement | OffscreenCanvas;\n\n if (typeof OffscreenCanvas !== 'undefined') {\n offscreen = new OffscreenCanvas(canvas.width, canvas.height);\n } else if (typeof document !== 'undefined') {\n offscreen = document.createElement('canvas');\n offscreen.width = canvas.width;\n offscreen.height = canvas.height;\n } else {\n renderImageStroke(ctx, imageConfig);\n return;\n }\n\n const offCtx = offscreen.getContext('2d');\n if (!offCtx) {\n renderImageStroke(ctx, imageConfig);\n return;\n }\n\n // Render the stroke to the offscreen canvas with knockout flag\n renderImageStroke(offCtx, imageConfig, { isKnockout: true });\n\n // Composite with destination-out\n ctx.save();\n ctx.globalCompositeOperation = 'destination-out';\n ctx.drawImage(offscreen as CanvasImageSource, 0, 0);\n ctx.restore();\n } else {\n // Normal stroke\n renderImageStroke(ctx, imageConfig);\n }\n }\n}\n","/**\n * Shape Renderer - Shape element rendering (rectangle, circle, ellipse, triangle, etc.)\n *\n * Works in both main thread and Web Worker (via OffscreenCanvas).\n *\n * Opacity strategy: When a shape has both element-level opacity AND a stroke,\n * we render fill+stroke at full opacity on a temporary canvas, then composite\n * the result at the element's opacity. This prevents fill/stroke overlap from\n * compounding (e.g., 50% fill + 50% stroke overlap ≠ 75% opaque).\n */\n\nimport type { RenderContext, SerializedShapeElement } from './renderer-types.js';\n\ntype CanvasLike = HTMLCanvasElement | OffscreenCanvas;\n\nfunction createTempCanvas(width: number, height: number): CanvasLike {\n if (typeof OffscreenCanvas !== 'undefined') {\n return new OffscreenCanvas(width, height);\n }\n const canvas = document.createElement('canvas');\n canvas.width = width;\n canvas.height = height;\n return canvas;\n}\n\n/**\n * Render a shape element\n * Works in both main thread and worker\n */\nexport function renderShapeElement(ctx: RenderContext, elementData: SerializedShapeElement): void {\n const elementOpacity = elementData.opacity ?? 1;\n const hasStroke = !!elementData.stroke?.enabled;\n const needsOffscreen = elementOpacity < 1 && hasStroke;\n\n if (needsOffscreen) {\n // Render fill+stroke at full opacity on a temp canvas, then composite\n renderShapeWithOffscreen(ctx, elementData, elementOpacity);\n } else {\n // No compounding risk — render directly\n renderShapeDirect(ctx, elementData, elementOpacity);\n }\n}\n\n/**\n * Render shape via temporary canvas to avoid fill/stroke opacity compounding.\n */\nfunction renderShapeWithOffscreen(\n ctx: RenderContext,\n elementData: SerializedShapeElement,\n elementOpacity: number\n): void {\n const td = elementData.transformData;\n const strokeWidth = elementData.stroke?.width || 2;\n // Pad temp canvas to fit the stroke (strokes extend beyond the shape bounds)\n const padding = strokeWidth + 2;\n const offW = Math.ceil(td.width + padding * 2);\n const offH = Math.ceil(td.height + padding * 2);\n\n const offCanvas = createTempCanvas(offW, offH);\n const offCtx = offCanvas.getContext('2d') as RenderContext;\n if (!offCtx) {\n // Fallback to direct render\n renderShapeDirect(ctx, elementData, elementOpacity);\n return;\n }\n\n // Render at center of temp canvas with full opacity (elementOpacity = 1)\n const tempData: SerializedShapeElement = {\n ...elementData,\n x: offW / 2,\n y: offH / 2,\n opacity: 1,\n };\n renderShapeDirect(offCtx, tempData, 1);\n\n // Composite temp canvas onto main canvas at element opacity\n ctx.save();\n\n // Position: elementData.(x,y) is the shape center, temp canvas center is (offW/2, offH/2)\n // We need to account for rotation around the element center\n ctx.translate(elementData.x, elementData.y);\n if (elementData.rotation) {\n ctx.rotate((-elementData.rotation * Math.PI) / 180);\n }\n\n ctx.globalAlpha = elementOpacity;\n ctx.drawImage(offCanvas, -offW / 2, -offH / 2);\n ctx.restore();\n}\n\n/**\n * Render shape directly onto ctx (no offscreen). Used when there's no\n * compounding risk, or as the inner render for the offscreen path.\n */\nfunction renderShapeDirect(\n ctx: RenderContext,\n elementData: SerializedShapeElement,\n elementOpacity: number\n): void {\n const transformData = elementData.transformData;\n const fillOpacity = transformData.fillOpacity ?? 1;\n\n ctx.save();\n ctx.translate(elementData.x, elementData.y);\n\n if (elementData.rotation) {\n ctx.rotate((-elementData.rotation * Math.PI) / 180);\n }\n\n // Fill\n ctx.globalAlpha = elementOpacity * fillOpacity;\n ctx.fillStyle = transformData.fillColor || '#3b82f6';\n ctx.beginPath();\n traceShapePath(ctx, transformData);\n ctx.fill();\n ctx.restore();\n\n // Stroke\n if (elementData.stroke?.enabled) {\n ctx.save();\n ctx.translate(elementData.x, elementData.y);\n if (elementData.rotation) {\n ctx.rotate((-elementData.rotation * Math.PI) / 180);\n }\n\n const stroke = elementData.stroke;\n ctx.globalAlpha = elementOpacity * (stroke.opacity ?? 1);\n ctx.strokeStyle = stroke.color || '#000000';\n ctx.lineWidth = stroke.width || 2;\n ctx.lineCap = stroke.lineCap || 'round';\n ctx.lineJoin = stroke.lineJoin || 'round';\n\n ctx.beginPath();\n traceShapePath(ctx, transformData);\n ctx.stroke();\n ctx.restore();\n }\n}\n\n/**\n * Trace the shape path (without fill/stroke) — reusable for both fill and stroke passes.\n */\nfunction traceShapePath(\n ctx: RenderContext,\n transformData: SerializedShapeElement['transformData']\n): void {\n const { shapeType, width, height } = transformData;\n\n switch (shapeType) {\n case 'rectangle': {\n const borderRadius = transformData.borderRadius || 0;\n const x = -width / 2;\n const y = -height / 2;\n\n if (borderRadius > 0) {\n const radius = Math.min((borderRadius / 100) * Math.min(width, height), width / 2, height / 2);\n ctx.roundRect(x, y, width, height, radius);\n } else {\n ctx.rect(x, y, width, height);\n }\n break;\n }\n\n case 'circle': {\n const radius = Math.min(width, height) / 2;\n ctx.arc(0, 0, radius, 0, Math.PI * 2);\n break;\n }\n\n case 'ellipse': {\n ctx.ellipse(0, 0, width / 2, height / 2, 0, 0, Math.PI * 2);\n break;\n }\n\n case 'triangle': {\n const halfWidth = width / 2;\n const halfHeight = height / 2;\n ctx.moveTo(0, -halfHeight);\n ctx.lineTo(halfWidth, halfHeight);\n ctx.lineTo(-halfWidth, halfHeight);\n ctx.closePath();\n break;\n }\n\n case 'polygon': {\n const sides = transformData.sides || 5;\n const radius = Math.min(width, height) / 2;\n for (let i = 0; i < sides; i++) {\n const angle = (i * 2 * Math.PI) / sides - Math.PI / 2;\n const px = radius * Math.cos(angle);\n const py = radius * Math.sin(angle);\n if (i === 0) {\n ctx.moveTo(px, py);\n } else {\n ctx.lineTo(px, py);\n }\n }\n ctx.closePath();\n break;\n }\n\n case 'star': {\n const points = transformData.points || 5;\n const outerRadius = Math.min(width, height) / 2;\n const innerRadius = outerRadius * (transformData.innerRadius || 0.4);\n for (let i = 0; i < points * 2; i++) {\n const angle = (i * Math.PI) / points - Math.PI / 2;\n const r = i % 2 === 0 ? outerRadius : innerRadius;\n const px = r * Math.cos(angle);\n const py = r * Math.sin(angle);\n if (i === 0) {\n ctx.moveTo(px, py);\n } else {\n ctx.lineTo(px, py);\n }\n }\n ctx.closePath();\n break;\n }\n\n case 'line': {\n const halfWidth = width / 2;\n const halfHeight = height / 2;\n ctx.rect(-halfWidth, -halfHeight, width, height);\n break;\n }\n\n default:\n ctx.rect(-width / 2, -height / 2, width, height);\n }\n}\n"],"names":["renderImageElement","ctx","elementData","imageBitmap","scaleX","scaleY","radius","x","y","w","h","_a","hasKnockoutStroke","_b","imageConfig","canvas","offscreen","renderImageStroke","offCtx","createTempCanvas","width","height","renderShapeElement","elementOpacity","hasStroke","renderShapeWithOffscreen","renderShapeDirect","td","padding","offW","offH","offCanvas","tempData","transformData","fillOpacity","traceShapePath","stroke","shapeType","borderRadius","halfWidth","halfHeight","sides","i","angle","px","py","points","outerRadius","innerRadius","r"],"mappings":";;;;;AAcO,SAASA,EACdC,GACAC,GACAC,GACM;;AACN,EAAAF,EAAI,KAAA,GAGJA,EAAI,UAAUC,EAAY,GAAGA,EAAY,CAAC,GAGtCA,EAAY,YACdD,EAAI,OAAQ,CAACC,EAAY,WAAW,KAAK,KAAM,GAAG;AAIpD,MAAIE,IAAS,GACTC,IAAS;AAab,MAZIH,EAAY,mBAAgBE,IAAS,KACrCF,EAAY,iBAAcG,IAAS,MACnCD,MAAW,KAAKC,MAAW,MAC7BJ,EAAI,MAAMG,GAAQC,CAAM,GAItBH,EAAY,YAAY,UAAaA,EAAY,YAAY,MAC/DD,EAAI,cAAcC,EAAY,UAI5BA,EAAY,gBAAgBA,EAAY,eAAe,GAAG;AAC5D,UAAMI,IAAS,KAAK;AAAA,MACjBJ,EAAY,eAAe,MAAO,KAAK,IAAIA,EAAY,OAAOA,EAAY,MAAM;AAAA,MACjFA,EAAY,QAAQ;AAAA,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GAChCJ,IAAKK,IAAI,KAAK,IAAIN,CAAK,GACvBE,IAAKI,IAAI,KAAK,IAAIN,CAAK;AAC7B,QAAID,MAAM,IACRzC,EAAI,OAAO2C,GAAIC,CAAE,IAEjB5C,EAAI,OAAO2C,GAAIC,CAAE;AAAA,MAErB;AACA,MAAA5C,EAAI,UAAA;AACJ;AAAA,IACF;AAAA,IAEA,KAAK,QAAQ;AACX,YAAMsC,IAAYnB,IAAQ,GACpBoB,IAAanB,IAAS;AAC5B,MAAApB,EAAI,KAAK,CAACsC,GAAW,CAACC,GAAYpB,GAAOC,CAAM;AAC/C;AAAA,IACF;AAAA,IAEA;AACE,MAAApB,EAAI,KAAK,CAACmB,IAAQ,GAAG,CAACC,IAAS,GAAGD,GAAOC,CAAM;AAAA,EAAA;AAErD;"}
@@ -0,0 +1,69 @@
1
+ import { KitDefinition } from './types.js';
2
+ /** Utility type for deep partial objects */
3
+ type DeepPartial<T> = {
4
+ [P in keyof T]?: T[P] extends (infer U)[] ? U[] : T[P] extends object ? DeepPartial<T[P]> : T[P];
5
+ };
6
+ /**
7
+ * Deep-merges overrides into a base kit definition to create a new customized kit.
8
+ *
9
+ * Merge behavior by field type:
10
+ * - **Arrays** (layout slots, capability lists) — union/concatenate with deduplication
11
+ * - **Objects** (behavior, style, content, features) — shallow merge (override wins per key)
12
+ * - **Primitives** (name, strings, numbers, booleans) — override replaces base
13
+ * - **Undefined fields** — base value is kept
14
+ *
15
+ * @param base - The base kit to extend (not mutated)
16
+ * @param overrides - Partial overrides to apply on top
17
+ * @returns A new KitDefinition with the merged result
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * const myKit = extendKit(COMPACT_CUSTOMIZER, {
22
+ * name: 'my-customizer',
23
+ * layout: { slots: { right: ['my-effects-panel'] } },
24
+ * capabilities: { effects: ['stroke', 'mask'] },
25
+ * behavior: { autoExport: true },
26
+ * });
27
+ * ```
28
+ */
29
+ export declare function extendKit(base: KitDefinition, overrides: DeepPartial<KitDefinition>): KitDefinition;
30
+ /**
31
+ * Creates a kit definition from minimal input with sensible defaults.
32
+ *
33
+ * Only the `name` field is required. All other fields fall back to minimal
34
+ * defaults suitable for a simple product customizer: canvas-only layout,
35
+ * text + image elements, contextual toolbar, single selection.
36
+ *
37
+ * Internally delegates to `extendKit()` using the minimal defaults as the
38
+ * base, so the same merge semantics apply (arrays are union-merged, objects
39
+ * are shallow-merged, etc.).
40
+ *
41
+ * @param partial - Kit configuration with at least a `name`.
42
+ * @returns A complete KitDefinition
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * const simpleKit = createKit({
47
+ * name: 'text-only',
48
+ * capabilities: { elements: ['text'] },
49
+ * });
50
+ * ```
51
+ *
52
+ * @example
53
+ * ```ts
54
+ * const proKit = createKit({
55
+ * name: 'pro-lite',
56
+ * layout: { slots: { left: ['layers-panel'] } },
57
+ * capabilities: {
58
+ * elements: ['text', 'image', 'shape'],
59
+ * effects: ['stroke', 'mask'],
60
+ * panels: ['layers', 'effects'],
61
+ * },
62
+ * behavior: { selection: 'multi', panelMode: 'sidebar' },
63
+ * });
64
+ * ```
65
+ */
66
+ export declare function createKit(partial: {
67
+ name: string;
68
+ } & DeepPartial<Omit<KitDefinition, 'name'>>): KitDefinition;
69
+ export {};
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Kit System - Barrel Export
3
+ *
4
+ * The kit system provides pre-configured editor setups for common use cases.
5
+ * Import from here to access types, presets, and the resolver.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * import { resolveKit, COMPACT_CUSTOMIZER, type KitDefinition } from '@snowcone-app/canvas';
10
+ * ```
11
+ */
12
+ export type { KitDefinition, KitPresetId, RuntimeTheme } from './types.js';
13
+ export { COMPACT_CUSTOMIZER, PRO_STUDIO, EMBED_ONLY } from './presets.js';
14
+ export { KIT_PRESETS, resolveKit } from './registry.js';
15
+ export { extendKit, createKit } from './compose.js';
16
+ export { validateKit } from './validation.js';
17
+ export type { KitValidationResult } from './validation.js';
18
+ export { registerSection, getSection, getSectionIds, getAllSections, unregisterSection, registerBuiltinSections, registerBuiltinSectionsSync, } from './sections.js';
19
+ export type { SectionConfig, SectionComponent } from './sections.js';
20
+ export { serializeKit, loadKitFromJSON } from './serialization.js';
21
+ export type { KitJSON } from './serialization.js';
@@ -0,0 +1,40 @@
1
+ import { KitDefinition } from './types.js';
2
+ /**
3
+ * Compact customizer -- minimal UI for product customization.
4
+ *
5
+ * Includes a contextual toolbar and single-selection mode.
6
+ * Best for e-commerce product customization flows where the user
7
+ * adds text or uploads an image onto a product.
8
+ *
9
+ * @example
10
+ * ```tsx
11
+ * <KitRenderer kit={COMPACT_CUSTOMIZER} />
12
+ * ```
13
+ */
14
+ export declare const COMPACT_CUSTOMIZER: KitDefinition;
15
+ /**
16
+ * Pro studio -- full editor with all panels and features.
17
+ *
18
+ * Includes layers panel, effects panel, multi-selection, and all
19
+ * transform/effect types. Best for design professionals or admin
20
+ * interfaces where full editing power is needed.
21
+ *
22
+ * @example
23
+ * ```tsx
24
+ * <KitRenderer kit={PRO_STUDIO} />
25
+ * ```
26
+ */
27
+ export declare const PRO_STUDIO: KitDefinition;
28
+ /**
29
+ * Embed only -- canvas with no UI chrome, for embedding in other apps.
30
+ *
31
+ * No toolbar, no panels, auto-export enabled. Best for headless
32
+ * integration where the host app provides all UI and just needs
33
+ * the canvas rendering engine.
34
+ *
35
+ * @example
36
+ * ```tsx
37
+ * <KitRenderer kit={EMBED_ONLY} />
38
+ * ```
39
+ */
40
+ export declare const EMBED_ONLY: KitDefinition;
@@ -0,0 +1,33 @@
1
+ import { KitDefinition, KitPresetId } from './types.js';
2
+ /**
3
+ * Map of all registered kit presets, keyed by their preset ID.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * const kit = KIT_PRESETS.get('compact-customizer');
8
+ * // kit === COMPACT_CUSTOMIZER
9
+ * ```
10
+ */
11
+ export declare const KIT_PRESETS: ReadonlyMap<KitPresetId, KitDefinition>;
12
+ /**
13
+ * Resolve a kit from either a preset ID string or a full KitDefinition.
14
+ *
15
+ * This is the primary entry point for consumers. It allows components
16
+ * like `<KitRenderer>` to accept a `kit` prop that is either a string
17
+ * shorthand or a fully custom definition.
18
+ *
19
+ * @param kit - A preset ID string (e.g., 'compact-customizer') or a full KitDefinition object
20
+ * @returns The resolved KitDefinition
21
+ * @throws {Error} If a string is passed that does not match any registered preset
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * // Using a preset ID
26
+ * const kit = resolveKit('pro-studio');
27
+ *
28
+ * // Using a custom definition (passed through unchanged)
29
+ * const custom: KitDefinition = { name: 'my-kit', ... };
30
+ * const kit = resolveKit(custom);
31
+ * ```
32
+ */
33
+ export declare function resolveKit(kit: KitPresetId | KitDefinition): KitDefinition;
@@ -0,0 +1,119 @@
1
+ import { default as React } from 'react';
2
+ /**
3
+ * Configuration for a registered section.
4
+ *
5
+ * Each section maps a string ID to a React component, a display label,
6
+ * and the layout position where it is typically rendered.
7
+ */
8
+ /**
9
+ * Type alias for section components in the registry.
10
+ *
11
+ * Section components read their state from context providers,
12
+ * so they can be rendered with no props: `<Component />`.
13
+ */
14
+ export type SectionComponent = React.ComponentType<{}>;
15
+ export interface SectionConfig {
16
+ /**
17
+ * The React component to render for this section.
18
+ *
19
+ * Section components read their state from EditorContext and other context
20
+ * providers, so they are rendered with no explicit props: `<Component />`.
21
+ *
22
+ * If registering a component that has required props (e.g. for direct use),
23
+ * cast it: `component: MyPanel as SectionComponent`.
24
+ */
25
+ component: SectionComponent;
26
+ /** Human-readable label for UI display (e.g., panel headers, settings) */
27
+ label: string;
28
+ /** Optional icon identifier (e.g., an Iconify icon string) */
29
+ icon?: string;
30
+ /** The layout position where this section is typically placed */
31
+ position: 'topbar' | 'left' | 'canvas' | 'right' | 'bottombar';
32
+ }
33
+ /**
34
+ * Register a section in the global section registry.
35
+ *
36
+ * If a section with the same ID is already registered, it will be
37
+ * silently overwritten. This allows consumers to replace built-in
38
+ * sections with custom implementations.
39
+ *
40
+ * @param id - Unique section identifier (e.g., 'layers-panel')
41
+ * @param config - Section configuration including component, label, and position
42
+ */
43
+ export declare function registerSection(id: string, config: SectionConfig): void;
44
+ /**
45
+ * Retrieve a registered section by ID.
46
+ *
47
+ * @param id - The section identifier to look up
48
+ * @returns The section config if found, or undefined
49
+ */
50
+ export declare function getSection(id: string): SectionConfig | undefined;
51
+ /**
52
+ * Get all registered section IDs.
53
+ *
54
+ * @returns An array of all registered section ID strings
55
+ */
56
+ export declare function getSectionIds(): string[];
57
+ /**
58
+ * Get all registered sections as `[id, config]` pairs.
59
+ *
60
+ * Useful for iterating over the full registry to build dynamic layouts,
61
+ * settings UIs, or debug views.
62
+ *
63
+ * @returns An array of `[sectionId, SectionConfig]` tuples
64
+ *
65
+ * @example List all registered sections
66
+ * ```ts
67
+ * for (const [id, config] of getAllSections()) {
68
+ * console.log(`${id}: ${config.label} (${config.position})`);
69
+ * }
70
+ * ```
71
+ */
72
+ export declare function getAllSections(): Array<[string, SectionConfig]>;
73
+ /**
74
+ * Remove a section from the registry.
75
+ *
76
+ * @param id - The section identifier to unregister
77
+ */
78
+ export declare function unregisterSection(id: string): void;
79
+ /**
80
+ * Register all built-in sections from the editor's component library.
81
+ *
82
+ * This function lazily imports the component modules to avoid circular
83
+ * dependencies and is idempotent — calling it multiple times has no
84
+ * additional effect after the first call.
85
+ *
86
+ * Built-in sections registered:
87
+ * - `layers-panel` — LayersPanel (left)
88
+ * - `effects-panel` — EffectsPanel (right)
89
+ * - `export-panel` — ExportPanel (right)
90
+ * - `images-panel` — ImagePanel (right)
91
+ * - `glyph-panel` — GlyphPanel (right)
92
+ * - `artboard-tabs` — ArtboardTabs (topbar)
93
+ * - `contextual-toolbar` — ContextualToolbars (topbar)
94
+ * - `zoom-controls` — ZoomControls (bottombar)
95
+ * - `menu-button` — MenuButton (topbar)
96
+ * - `crop-panel` — CropPanel (right)
97
+ */
98
+ export declare function registerBuiltinSections(): Promise<void>;
99
+ /**
100
+ * Synchronously register built-in sections using direct component references.
101
+ *
102
+ * Unlike `registerBuiltinSections()` which uses lazy imports, this function
103
+ * requires that components be passed in directly. Use this when you have
104
+ * already imported the components and want to avoid async registration.
105
+ *
106
+ * @param components - Object mapping section IDs to their component references
107
+ */
108
+ export declare function registerBuiltinSectionsSync(components: {
109
+ LayersPanel: SectionComponent;
110
+ EffectsPanel: SectionComponent;
111
+ ExportPanel: SectionComponent;
112
+ ImagePanel: SectionComponent;
113
+ GlyphPanel: SectionComponent;
114
+ ArtboardTabs: SectionComponent;
115
+ ContextualToolbars: SectionComponent;
116
+ ZoomControls: SectionComponent;
117
+ MenuButton: SectionComponent;
118
+ CropPanel: SectionComponent;
119
+ }): void;
@@ -0,0 +1,78 @@
1
+ import { EditorCapabilities } from '../types/capabilities.js';
2
+ import { KitDefinition, KitPresetId } from './types.js';
3
+ /**
4
+ * JSON-safe representation of a KitDefinition.
5
+ *
6
+ * When `extends` is provided, the kit is built by resolving the base
7
+ * preset and applying the remaining fields as overrides. When `extends`
8
+ * is omitted, a new kit is created from scratch using `createKit`.
9
+ */
10
+ export interface KitJSON {
11
+ /** Kit name (required) */
12
+ name: string;
13
+ /** Optional base preset to extend from */
14
+ extends?: KitPresetId;
15
+ /** Partial capability overrides */
16
+ capabilities?: Partial<EditorCapabilities>;
17
+ /** Partial behavior overrides */
18
+ behavior?: Partial<KitDefinition['behavior']>;
19
+ /** Partial layout overrides */
20
+ layout?: Partial<KitDefinition['layout']>;
21
+ /** Partial style overrides */
22
+ style?: Partial<KitDefinition['style']>;
23
+ /** Content configuration */
24
+ content?: KitDefinition['content'];
25
+ }
26
+ /**
27
+ * Serialize a KitDefinition to a JSON-safe format.
28
+ *
29
+ * The resulting object can be safely passed to `JSON.stringify()` and
30
+ * later restored with `loadKitFromJSON()`. All fields from the kit
31
+ * are included in the output for a complete, self-contained representation.
32
+ *
33
+ * @param kit - The KitDefinition to serialize
34
+ * @returns A JSON-safe KitJSON object
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * const json = serializeKit(myKit);
39
+ * localStorage.setItem('kit', JSON.stringify(json));
40
+ * ```
41
+ */
42
+ export declare function serializeKit(kit: KitDefinition): KitJSON;
43
+ /**
44
+ * Load a KitDefinition from a JSON representation.
45
+ *
46
+ * If `extends` is provided, the corresponding preset is resolved and the
47
+ * remaining fields are applied as overrides via `extendKit`. If `extends`
48
+ * is omitted, a new kit is created from scratch via `createKit`.
49
+ *
50
+ * The result is validated with `validateKit`. If validation produces
51
+ * errors (fatal issues), an error is thrown. Warnings are logged to
52
+ * the console but do not prevent loading.
53
+ *
54
+ * @param json - The KitJSON object to deserialize
55
+ * @returns A complete, validated KitDefinition
56
+ * @throws {Error} If the kit name is missing
57
+ * @throws {Error} If a preset ID in `extends` is invalid
58
+ * @throws {Error} If the resulting kit fails validation (has errors)
59
+ *
60
+ * @example Extend a preset
61
+ * ```ts
62
+ * const kit = loadKitFromJSON({
63
+ * name: 'my-pro-variant',
64
+ * extends: 'pro-studio',
65
+ * behavior: { autoExport: true },
66
+ * });
67
+ * ```
68
+ *
69
+ * @example Create from scratch
70
+ * ```ts
71
+ * const kit = loadKitFromJSON({
72
+ * name: 'minimal-editor',
73
+ * capabilities: { elements: ['text'] },
74
+ * behavior: { toolbar: 'none', selection: 'single', panelMode: 'inline', onEmptyClick: 'noop', autoExport: false },
75
+ * });
76
+ * ```
77
+ */
78
+ export declare function loadKitFromJSON(json: KitJSON): KitDefinition;