@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,185 @@
1
+ import { ExportConfig } from '../workers/export-protocol';
2
+ import { ArtboardElement } from '../core/ArtboardElement';
3
+ import { BaseElement } from '../core/BaseElement';
4
+ /** Result of a worker export operation returning a data URL string. */
5
+ export interface WorkerExportResult {
6
+ /** Base64-encoded data URL of the exported image. */
7
+ dataUrl: string;
8
+ artboardId: string;
9
+ artboardName: string;
10
+ /** Time spent rendering in the worker (ms). */
11
+ renderTime: number;
12
+ /** Total round-trip time including serialization and messaging (ms). */
13
+ totalTime: number;
14
+ /** Time the main thread was blocked during the export (should be near 0ms). */
15
+ mainThreadBlockTime: number;
16
+ }
17
+ /** Result of a worker export operation returning a Blob. More efficient for API uploads. */
18
+ export interface WorkerBlobExportResult {
19
+ /** Binary Blob of the exported image. */
20
+ blob: Blob;
21
+ artboardId: string;
22
+ artboardName: string;
23
+ /** Time spent rendering in the worker (ms). */
24
+ renderTime: number;
25
+ /** Total round-trip time including serialization and messaging (ms). */
26
+ totalTime: number;
27
+ /** Time the main thread was blocked during the export (should be near 0ms). */
28
+ mainThreadBlockTime: number;
29
+ }
30
+ export interface ProgressEvent {
31
+ requestId: string;
32
+ progress: number;
33
+ message: string;
34
+ }
35
+ export type ProgressListener = (event: ProgressEvent) => void;
36
+ /**
37
+ * Manages a Web Worker for non-blocking artboard export using OffscreenCanvas.
38
+ *
39
+ * Features:
40
+ * - Promise-based export API (data URL and Blob)
41
+ * - Request queuing for concurrent export operations
42
+ * - Bitmap caching in the worker (reduces main-thread memory by ~50%)
43
+ * - Automatic crash recovery with fallback to main-thread rendering
44
+ * - Idle timeout for worker cleanup (30s default)
45
+ * - Progress reporting via listeners
46
+ */
47
+ export declare class WorkerExportManager {
48
+ private worker;
49
+ private workerBlobUrl;
50
+ private pendingRequests;
51
+ private requestQueue;
52
+ private blobRequestQueue;
53
+ private isProcessingQueue;
54
+ private isReady;
55
+ private readyPromise;
56
+ private requestIdCounter;
57
+ private workerCrashCount;
58
+ private readonly MAX_CRASHES_BEFORE_FALLBACK;
59
+ private lastCrashTime;
60
+ private readonly CRASH_RESET_TIMEOUT;
61
+ private progressListeners;
62
+ private idleTimeout;
63
+ private readonly IDLE_TIMEOUT_MS;
64
+ /**
65
+ * Add progress listener
66
+ */
67
+ onProgress(listener: ProgressListener): () => void;
68
+ /**
69
+ * Remove progress listener
70
+ */
71
+ offProgress(listener: ProgressListener): void;
72
+ /**
73
+ * Emit progress event to all listeners
74
+ */
75
+ private emitProgress;
76
+ /**
77
+ * Reset idle timer
78
+ */
79
+ private resetIdleTimer;
80
+ /**
81
+ * Register bitmaps with the worker's cache.
82
+ * This transfers the bitmaps to the worker (zero-copy) where they are cached.
83
+ */
84
+ private registerBitmapsWithWorker;
85
+ /**
86
+ * Clear all bitmaps from the worker's cache.
87
+ * Also clears the main thread's registration tracking.
88
+ * Call this when exiting editor mode to free memory.
89
+ */
90
+ clearWorkerBitmapCache(): void;
91
+ /**
92
+ * Clear a specific element's bitmaps from the worker's cache.
93
+ * Call this when an element is removed or its image source changes.
94
+ */
95
+ clearWorkerBitmap(elementId: string): void;
96
+ /**
97
+ * Check if browser supports OffscreenCanvas and Web Workers
98
+ */
99
+ static supportsWorkerExport(): boolean;
100
+ /**
101
+ * Initialize the worker
102
+ */
103
+ initialize(): Promise<void>;
104
+ /**
105
+ * Restart worker after crash
106
+ */
107
+ private restartWorker;
108
+ /**
109
+ * Export artboard to data URL using worker
110
+ * Uses request queue for concurrent exports
111
+ */
112
+ exportArtboardToDataURL(artboard: ArtboardElement, elements: BaseElement[], config?: ExportConfig): Promise<WorkerExportResult>;
113
+ /**
114
+ * Export artboard to Blob using worker
115
+ * Returns a Blob directly - more efficient for API uploads
116
+ * Uses request queue for concurrent exports
117
+ */
118
+ exportArtboardToBlob(artboard: ArtboardElement, elements: BaseElement[], config?: ExportConfig): Promise<WorkerBlobExportResult>;
119
+ /**
120
+ * Process the request queue
121
+ */
122
+ private processQueue;
123
+ /**
124
+ * Execute a single export request
125
+ */
126
+ private executeExportRequest;
127
+ /**
128
+ * Process the blob request queue
129
+ */
130
+ private processBlobQueue;
131
+ /**
132
+ * Execute a single blob export request
133
+ */
134
+ private executeBlobExportRequest;
135
+ /**
136
+ * Handle messages from worker
137
+ */
138
+ private handleWorkerMessage;
139
+ /**
140
+ * Handle successful export completion (dataUrl)
141
+ */
142
+ private handleExportComplete;
143
+ /**
144
+ * Handle successful blob export completion
145
+ */
146
+ private handleBlobExportComplete;
147
+ /**
148
+ * Handle export error
149
+ */
150
+ private handleExportError;
151
+ /**
152
+ * Handle worker errors
153
+ */
154
+ private handleWorkerError;
155
+ /**
156
+ * Terminate the worker
157
+ */
158
+ terminate(): void;
159
+ /**
160
+ * Get worker status
161
+ */
162
+ getStatus(): {
163
+ isReady: boolean;
164
+ pendingRequests: number;
165
+ queuedRequests: number;
166
+ crashCount: number;
167
+ };
168
+ }
169
+ /**
170
+ * Get the shared singleton `WorkerExportManager` instance.
171
+ *
172
+ * Creates the instance on first call. The shared instance is used internally
173
+ * by `ExportManager` and is the recommended way to access the worker for
174
+ * advanced cache control (e.g., `getSharedWorkerExportManager().clearWorkerBitmapCache()`).
175
+ *
176
+ * @returns The shared WorkerExportManager instance
177
+ */
178
+ export declare function getSharedWorkerExportManager(): WorkerExportManager;
179
+ /**
180
+ * Terminate the shared `WorkerExportManager` instance and release its Web Worker.
181
+ *
182
+ * Call this during app cleanup to free worker resources. The next call to
183
+ * `getSharedWorkerExportManager()` will create a fresh instance.
184
+ */
185
+ export declare function terminateSharedWorkerExportManager(): void;
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Click Protection Utility
3
+ *
4
+ * Provides a mechanism to prevent deselection when clicking on overlays
5
+ * like color pickers, context menus, etc.
6
+ *
7
+ * Usage:
8
+ * 1. Call `protectNextClick()` before showing an overlay
9
+ * 2. In your click handler, check `shouldProtectClick()` before deselecting
10
+ * 3. The protection automatically expires after one click or a timeout
11
+ */
12
+ declare class ClickProtectionManager {
13
+ isProtectedFlag: boolean;
14
+ timeout: ReturnType<typeof setTimeout> | null;
15
+ timeoutDuration: number;
16
+ constructor();
17
+ /**
18
+ * Protect the next click from triggering deselection
19
+ * Automatically expires after one check or timeout
20
+ */
21
+ protectNextClick(): void;
22
+ /**
23
+ * Check if the current click should be protected
24
+ * This consumes the protection (one-time use)
25
+ * @returns {boolean} true if click should be protected, false otherwise
26
+ */
27
+ shouldProtectClick(): boolean;
28
+ /**
29
+ * Manually clear protection (useful for cleanup)
30
+ */
31
+ clearProtection(): void;
32
+ /**
33
+ * Check if protection is currently active (without consuming it)
34
+ * @returns {boolean} true if protection is active
35
+ */
36
+ isProtected(): boolean;
37
+ }
38
+ export declare const clickProtection: ClickProtectionManager;
39
+ export {};
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Simple utility for conditionally joining classNames together
3
+ */
4
+ export declare function cn(...inputs: (string | undefined | null | false)[]): string;
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Color Conversion Utilities for HeroUI v3 Migration
3
+ *
4
+ * Converts hex/rgba colors to oklch format required by HeroUI v3.
5
+ * Uses the culori library for accurate color space transformations.
6
+ *
7
+ * @see https://culori.js.org/
8
+ * @see docs/THEME_COLOR_MAPPING.md for color documentation
9
+ */
10
+ /**
11
+ * Convert a hex color to oklch format
12
+ *
13
+ * @param hex - Hex color string (e.g., "#a4e636", "#fff", "a4e636")
14
+ * @returns oklch string (e.g., "oklch(0.85 0.18 125)")
15
+ *
16
+ * @example
17
+ * hexToOklch("#a4e636") // "oklch(0.85 0.18 125)"
18
+ * hexToOklch("#ffffff") // "oklch(1 0 0)"
19
+ * hexToOklch("#000000") // "oklch(0 0 0)"
20
+ */
21
+ export declare function hexToOklch(hex: string): string;
22
+ /**
23
+ * Convert an rgba color to oklch format
24
+ *
25
+ * @param r - Red component (0-255)
26
+ * @param g - Green component (0-255)
27
+ * @param b - Blue component (0-255)
28
+ * @param a - Alpha component (0-1), optional
29
+ * @returns oklch string with alpha channel if provided (e.g., "oklch(0.85 0.18 125 / 0.2)")
30
+ *
31
+ * @example
32
+ * rgbaToOklch(164, 230, 54) // "oklch(0.85 0.18 125)"
33
+ * rgbaToOklch(164, 230, 54, 0.2) // "oklch(0.85 0.18 125 / 0.2)"
34
+ * rgbaToOklch(255, 255, 255, 1) // "oklch(1 0 0)"
35
+ */
36
+ export declare function rgbaToOklch(r: number, g: number, b: number, a?: number): string;
37
+ /**
38
+ * Parse a CSS color string (hex or rgba) and convert to oklch
39
+ *
40
+ * @param cssColor - CSS color string (e.g., "#a4e636", "rgba(164, 230, 54, 0.2)")
41
+ * @returns oklch string
42
+ *
43
+ * @example
44
+ * cssToOklch("#a4e636") // "oklch(0.85 0.18 125)"
45
+ * cssToOklch("rgba(164, 230, 54, 0.2)") // "oklch(0.85 0.18 125 / 0.2)"
46
+ * cssToOklch("rgb(255, 255, 255)") // "oklch(1 0 0)"
47
+ */
48
+ export declare function cssToOklch(cssColor: string): string;
49
+ /**
50
+ * Batch convert all theme colors from hex/rgba to oklch
51
+ *
52
+ * @param themeColors - Object with CSS color values (hex/rgba strings)
53
+ * @returns Object with same keys but oklch values
54
+ *
55
+ * @example
56
+ * const lightTheme = {
57
+ * "--color-bg-primary": "#ffffff",
58
+ * "--color-accent-primary": "#a4e636",
59
+ * "--color-accent-light": "rgba(164, 230, 54, 0.2)"
60
+ * };
61
+ *
62
+ * const oklchTheme = convertThemeToOklch(lightTheme);
63
+ * // {
64
+ * // "--color-bg-primary": "oklch(1 0 0)",
65
+ * // "--color-accent-primary": "oklch(0.85 0.18 125)",
66
+ * // "--color-accent-light": "oklch(0.85 0.18 125 / 0.2)"
67
+ * // }
68
+ */
69
+ export declare function convertThemeToOklch(themeColors: Record<string, string>): Record<string, string>;
70
+ /**
71
+ * Generate a CSS variable declaration for oklch color
72
+ *
73
+ * @param varName - CSS variable name (with or without -- prefix)
74
+ * @param cssColor - CSS color string (hex/rgba)
75
+ * @returns CSS variable declaration string
76
+ *
77
+ * @example
78
+ * generateCssVar("color-accent-primary", "#a4e636")
79
+ * // "--color-accent-primary: oklch(0.85 0.18 125);"
80
+ */
81
+ export declare function generateCssVar(varName: string, cssColor: string): string;
82
+ /**
83
+ * Generate complete CSS theme file with oklch colors
84
+ *
85
+ * @param themeName - Name of the theme (e.g., "light", "dark", "ocean")
86
+ * @param themeColors - Object with CSS color values
87
+ * @returns Complete CSS theme file content
88
+ *
89
+ * @example
90
+ * const lightColors = {
91
+ * "color-bg-primary": "#ffffff",
92
+ * "color-accent-primary": "#a4e636"
93
+ * };
94
+ *
95
+ * const css = generateThemeCss("light", lightColors);
96
+ * // [data-theme="light"] {
97
+ * // --color-bg-primary: oklch(1 0 0);
98
+ * // --color-accent-primary: oklch(0.85 0.18 125);
99
+ * // }
100
+ */
101
+ export declare function generateThemeCss(themeName: string, themeColors: Record<string, string>): string;
@@ -0,0 +1,108 @@
1
+ import { BaseElement } from '../core/BaseElement.js';
2
+ import { ArtboardElement } from '../core/ArtboardElement.js';
3
+ /**
4
+ * Collect every vector colour in the design. Synchronous.
5
+ *
6
+ * @param elements - Top-level elements (groups recurse internally)
7
+ * @param artboards - Optional. When provided, `backgroundColor` from
8
+ * each artboard is included (real exported background; the UI-only
9
+ * `previewBackgroundColor` is intentionally skipped — it's the
10
+ * shirt-colour preview, not part of the artwork).
11
+ */
12
+ export declare function collectDocumentColors(elements: ReadonlyArray<BaseElement>, artboards?: ReadonlyArray<ArtboardElement>): Set<string>;
13
+ type RGB = {
14
+ r: number;
15
+ g: number;
16
+ b: number;
17
+ };
18
+ /**
19
+ * Median-cut quantisation. Returns the average colour of each box.
20
+ *
21
+ * Why this beats a frequency histogram for our use case: a frequency
22
+ * histogram returns the most-populated buckets, which means a smooth
23
+ * gradient (sunset reds spread across many adjacent buckets) loses
24
+ * to a flat region (solid black sky) even when the gradient is the
25
+ * visually salient subject. Median cut splits by *spread* in colour
26
+ * space, so red, orange, and yellow each get their own bucket.
27
+ *
28
+ * @internal exported for tests
29
+ */
30
+ export declare function medianCut(pixels: RGB[], targetBuckets: number): RGB[];
31
+ /**
32
+ * Redmean ΔE — a cheap perceptual-distance approximation. Pure
33
+ * Euclidean RGB distance treats (50,0,0) vs (0,0,50) as identical,
34
+ * which is wrong because the eye is more sensitive to green than red
35
+ * or blue. Redmean weights each channel by the average of the two
36
+ * reds, which biases the metric toward perceived difference at low
37
+ * cost. See https://www.compuphase.com/cmetric.htm.
38
+ *
39
+ * Returned distance is roughly comparable to a CIE-76 ΔE: ~25 means
40
+ * "noticeably different," ~50+ means "obviously different."
41
+ *
42
+ * @internal exported for tests
43
+ */
44
+ export declare function redmeanDistance(a: RGB, b: RGB): number;
45
+ /**
46
+ * Drop palette entries that are visually indistinguishable from one
47
+ * we already kept. Walks in input order, so callers should pre-sort
48
+ * by importance (we sort by population — bigger boxes first — so
49
+ * the most-prominent shade in a "near-duplicate" cluster wins).
50
+ *
51
+ * @internal exported for tests
52
+ */
53
+ export declare function dedupeByPerceptualDistance(palette: RGB[], threshold: number): RGB[];
54
+ /**
55
+ * Pick a diverse palette from a population-sorted candidate list via
56
+ * furthest-point sampling. The first candidate is taken as the anchor
57
+ * (most populous). Each subsequent pick maximises the minimum redmean
58
+ * distance to every already-picked colour, so the row spans the image's
59
+ * actual colour variation instead of N shades of whatever hue dominates.
60
+ *
61
+ * Candidates closer than `threshold` to an already-picked colour are
62
+ * skipped — that's the dedupe step folded into the same pass. Stops
63
+ * when there are no further candidates above the threshold.
64
+ *
65
+ * @internal exported for tests
66
+ */
67
+ export declare function furthestPointPalette(candidates: RGB[], paletteSize: number, threshold: number): RGB[];
68
+ /**
69
+ * Extract up to `paletteSize` dominant colours from an image URL.
70
+ *
71
+ * Implementation:
72
+ * 1. Draw the image into a small offscreen canvas (48×48). Smaller
73
+ * than the source, but enough resolution for dominant colours
74
+ * and *much* faster than walking the full image.
75
+ * 2. Sample every pixel; skip fully-transparent and near-white
76
+ * (background swamps the palette and isn't useful for matching).
77
+ * 3. Run median cut to produce ~2× the requested palette size
78
+ * (gives dedupe headroom).
79
+ * 4. Sort by box population so visually-prominent shades come first
80
+ * within near-duplicate clusters.
81
+ * 5. Drop near-duplicates by redmean-weighted ΔE — without this
82
+ * step a photo with a big black region returns 3 indistinguishable
83
+ * blacks instead of black + the actual subject colours.
84
+ * 6. Truncate to `paletteSize`.
85
+ *
86
+ * Cached per URL in module-scope (cache survives component unmount;
87
+ * wiped on hard reload).
88
+ *
89
+ * Requires `crossOrigin="anonymous"` on the source image. If the
90
+ * image is CORS-tainted, `getImageData` throws and we cache an empty
91
+ * array. Per CLAUDE.md "CORS Cache Poisoning" all canvas images
92
+ * already set this.
93
+ */
94
+ export declare function extractImagePalette(imageUrl: string, paletteSize?: number): Promise<string[]>;
95
+ /**
96
+ * Walk every ImageElement (recursing into groups), pull the unique
97
+ * URLs, extract a small palette per image, and return the deduped
98
+ * union. Order is "first image first, top-N per image" so the row
99
+ * has predictable colours. Returns [] if no images.
100
+ */
101
+ export declare function collectImageColors(elements: ReadonlyArray<BaseElement>, paletteSize?: number): Promise<string[]>;
102
+ /**
103
+ * Test-only: clear the in-memory palette caches so unit tests start
104
+ * from a known state.
105
+ * @internal
106
+ */
107
+ export declare function _resetImagePaletteCache(): void;
108
+ export {};
@@ -0,0 +1,14 @@
1
+ import { BaseElement } from '../core/BaseElement.js';
2
+ export interface FeatureAppliedFlags {
3
+ rotation: boolean;
4
+ opacity: boolean;
5
+ stroke: boolean;
6
+ knockout: boolean;
7
+ distress: boolean;
8
+ imageMask: boolean;
9
+ /** Image: `transformData.borderRadius`. */
10
+ cornerRadius: boolean;
11
+ /** Shape: `transformData.fillOpacity`. */
12
+ shapeTransparency: boolean;
13
+ }
14
+ export declare function getFeatureApplied(element: BaseElement | null | undefined): FeatureAppliedFlags;
@@ -0,0 +1,67 @@
1
+ /**
2
+ * google-fonts-loader — fetch a Google Font's @font-face CSS for the
3
+ * weights we care about (regular + bold) and return the concatenated CSS.
4
+ *
5
+ * The per-weight fetch shape exists to dodge a Google Fonts CSS2 quirk:
6
+ * a request for `wght@400;700` returns an *empty* HTTP-200 body when the
7
+ * font doesn't have all the requested weights — single-weight display
8
+ * fonts like Bangers (only 400) trip this and silently lose their CSS,
9
+ * leaving canvas/export rendering with the serif fallback. Browsers
10
+ * don't hit it because Chrome's User-Agent gets a different server code
11
+ * path; `fetch()` from a Web Worker uses a minimal UA and Google takes
12
+ * the strict path.
13
+ *
14
+ * Solution: ask for each weight individually. Available weights return
15
+ * their CSS, missing weights return empty (HTTP 200 + no body, or HTTP
16
+ * 400), and we concatenate whatever survived. The downstream parser is
17
+ * happy with one or many `@font-face` blocks.
18
+ *
19
+ * Used by: `workers/export-worker.ts` (the bundle inlines this helper
20
+ * so the worker can be a single self-contained file).
21
+ */
22
+ /** Build the Google Fonts CSS2 URL for one weight. */
23
+ export declare function buildGoogleFontUrl(family: string, weight: number): string;
24
+ /**
25
+ * Fetch the @font-face CSS for `family` at every weight in `WEIGHTS_TO_REQUEST`,
26
+ * concatenating successful responses with newlines. Failures (network error,
27
+ * non-2xx, empty body) become empty strings — the result is only "" when
28
+ * *every* weight failed, which signals "this font genuinely isn't on Google
29
+ * Fonts" to the caller.
30
+ */
31
+ export declare function fetchGoogleFontCss(family: string, fetchImpl?: typeof fetch): Promise<string>;
32
+ /** Parsed @font-face block — what `parseFontFaces` extracts from CSS. */
33
+ export interface ParsedFontFace {
34
+ /** URL of the WOFF2/TTF — extracted from `src: url(...)`. */
35
+ fontFileUrl: string;
36
+ /** FontFace descriptors derived from the CSS rule. */
37
+ descriptors: FontFaceDescriptors;
38
+ }
39
+ /**
40
+ * Parse the concatenated CSS returned by `fetchGoogleFontCss` into a list of
41
+ * @font-face descriptors. Handles the multi-block shape Google returns
42
+ * (one rule per `unicode-range` subset) and preserves all relevant
43
+ * descriptor fields the FontFace constructor accepts.
44
+ */
45
+ export declare function parseFontFaces(css: string): ParsedFontFace[];
46
+ /**
47
+ * Fetch a font file as bytes and construct a FontFace from the binary.
48
+ *
49
+ * Why not just `new FontFace(family, 'url(...)').load()`?
50
+ *
51
+ * iOS Safari's FontFace API uses an internal fetch path for `url(...)` srcs
52
+ * that doesn't reliably honor cross-origin font assets — even when the
53
+ * server (e.g. fonts.gstatic.com) returns `Access-Control-Allow-Origin: *`,
54
+ * Safari logs `Cannot load <woff2>` and silently fails the activation. The
55
+ * symptom in production: the live editor canvas eventually renders the
56
+ * correct face (the `<link>` path activates DOM-side), but the export
57
+ * worker — which only has the FontFace API to work with — silently falls
58
+ * back to serif. Fetching the bytes ourselves with `fetch()` (Safari's
59
+ * cross-origin fetch CORS handling is correct) and passing the
60
+ * `ArrayBuffer` to `new FontFace(family, buffer)` skips Safari's broken
61
+ * url-fetch path and the activation works reliably.
62
+ *
63
+ * Returns `null` if the binary fetch fails (CORS, 404, network) — caller
64
+ * should treat that as "this subset isn't available" and continue with the
65
+ * other subsets. A font with at least one loaded subset still renders.
66
+ */
67
+ export declare function loadFontFaceFromUrl(family: string, parsed: ParsedFontFace, fetchImpl?: typeof fetch): Promise<FontFace | null>;
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Centralized debug logger utility
3
+ * Replaces scattered console.log statements with a consistent, filterable logging system
4
+ */
5
+ export declare enum LogLevel {
6
+ DEBUG = 0,
7
+ INFO = 1,
8
+ WARN = 2,
9
+ ERROR = 3,
10
+ NONE = 4
11
+ }
12
+ declare class Logger {
13
+ private level;
14
+ private enabled;
15
+ /**
16
+ * Set the minimum log level to display
17
+ */
18
+ setLevel(level: LogLevel): void;
19
+ /**
20
+ * Enable or disable logging globally
21
+ */
22
+ setEnabled(enabled: boolean): void;
23
+ /**
24
+ * Get current log level
25
+ */
26
+ getLevel(): LogLevel;
27
+ /**
28
+ * Check if logging is enabled
29
+ */
30
+ isEnabled(): boolean;
31
+ /**
32
+ * Log debug message (verbose, development only)
33
+ */
34
+ debug(_message: string, ..._args: unknown[]): void;
35
+ /**
36
+ * Log info message (general information)
37
+ */
38
+ info(message: string, ...args: unknown[]): void;
39
+ /**
40
+ * Log warning message (potential issues)
41
+ */
42
+ warn(message: string, ...args: unknown[]): void;
43
+ /**
44
+ * Log error message (critical issues)
45
+ */
46
+ error(message: string, ...args: unknown[]): void;
47
+ /**
48
+ * Create a scoped logger with a prefix for a specific module
49
+ */
50
+ scope(scopeName: string): ScopedLogger;
51
+ }
52
+ /**
53
+ * Scoped logger for specific modules/components
54
+ */
55
+ declare class ScopedLogger {
56
+ private logger;
57
+ private scopeName;
58
+ constructor(logger: Logger, scopeName: string);
59
+ debug(message: string, ...args: unknown[]): void;
60
+ info(message: string, ...args: unknown[]): void;
61
+ warn(message: string, ...args: unknown[]): void;
62
+ error(message: string, ...args: unknown[]): void;
63
+ }
64
+ export declare const logger: Logger;
65
+ export declare const createLogger: (scopeName: string) => ScopedLogger;
66
+ export {};
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Selection Preservation Utility
3
+ *
4
+ * Provides a declarative way to mark UI elements that should NOT
5
+ * trigger canvas deselection when clicked.
6
+ *
7
+ * Usage:
8
+ * 1. Add data-preserve-selection attribute to any UI container
9
+ * 2. The document-level handler in EditorContext checks for this attribute
10
+ *
11
+ * @example
12
+ * // Direct attribute
13
+ * <div data-preserve-selection>
14
+ * <MyToolbar />
15
+ * </div>
16
+ *
17
+ * // Spread helper
18
+ * <div {...preserveSelectionProps}>
19
+ * <MySettings />
20
+ * </div>
21
+ */
22
+ /** Data attribute name for marking selection-preserving elements */
23
+ export declare const PRESERVE_SELECTION_ATTR = "data-preserve-selection";
24
+ /**
25
+ * Check if a click event should preserve the current selection.
26
+ * Walks up the DOM tree from the click target checking for the
27
+ * data-preserve-selection attribute.
28
+ *
29
+ * Performance: O(depth) where depth is typically 10-20 nodes.
30
+ * This is negligible compared to other click handling operations.
31
+ *
32
+ * @param target - The event target element
33
+ * @returns true if selection should be preserved, false otherwise
34
+ */
35
+ export declare function shouldPreserveSelection(target: EventTarget | null): boolean;
36
+ /**
37
+ * React props helper - spread this on containers that should preserve selection
38
+ * @example <div {...preserveSelectionProps}>...</div>
39
+ */
40
+ export declare const preserveSelectionProps: {
41
+ readonly "data-preserve-selection": "";
42
+ };
@@ -0,0 +1,39 @@
1
+ import { TextElement } from '../core/TextElement';
2
+ /**
3
+ * Get word boundaries at a given character index.
4
+ * Returns the start and end indices of the word containing the given index.
5
+ * Words are separated by whitespace.
6
+ *
7
+ * @param text The text to search in
8
+ * @param index The character index to find the word at
9
+ * @returns Object with start and end indices of the word
10
+ */
11
+ export declare function getWordBoundaryAt(text: string, index: number): {
12
+ start: number;
13
+ end: number;
14
+ };
15
+ /**
16
+ * Get line info for a cursor position - which line it's on and the X position within that line
17
+ */
18
+ export declare function getCursorLineInfo(element: TextElement, cursorIndex: number): {
19
+ lineIndex: number;
20
+ lineCount: number;
21
+ xPositionInLine: number;
22
+ lineStartIndex: number;
23
+ };
24
+ /**
25
+ * Move cursor up or down by one line, trying to maintain the same X position
26
+ */
27
+ export declare function moveCursorVertically(element: TextElement, cursorIndex: number, direction: 'up' | 'down'): number;
28
+ /**
29
+ * Calculates the cursor character index based on a point relative to the text element's
30
+ * top-left corner (local coordinates).
31
+ *
32
+ * @param element The text element
33
+ * @param point Local coordinates {x, y} relative to the element's visual bounding box top-left
34
+ * @returns The character index closest to the point
35
+ */
36
+ export declare function getCursorIndexFromPoint(element: TextElement, point: {
37
+ x: number;
38
+ y: number;
39
+ }): number;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Text utility functions
3
+ */
4
+ /**
5
+ * Strip glyph characters from text for display purposes
6
+ * Removes PUA (Private Use Area) characters used for alternate glyphs
7
+ *
8
+ * @param text - Text that may contain glyph characters
9
+ * @returns Text with glyph characters removed
10
+ */
11
+ export declare function stripGlyphs(text: string): string;