@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,117 @@
1
+ /**
2
+ * TextMetrics - Shared utilities for text measurement and layout
3
+ * Reduces duplication across transform types
4
+ */
5
+ /**
6
+ * Build font string with optional bold and italic
7
+ * @param {number} fontSize - Font size
8
+ * @param {string} fontFamily - Font family name
9
+ * @param {boolean} bold - Whether to use bold weight
10
+ * @param {boolean} italic - Whether to use italic style
11
+ * @returns {string} Font string for ctx.font
12
+ */
13
+ export declare function buildFontString(fontSize: number, fontFamily: string, bold?: boolean, italic?: boolean): string;
14
+ /**
15
+ * Word wrap text to fit within a given width
16
+ * @param {string} text - Text to wrap
17
+ * @param {number} maxWidth - Maximum width in pixels
18
+ * @param {number} fontSize - Font size
19
+ * @param {string} fontFamily - Font family name
20
+ * @param {boolean} bold - Whether text is bold
21
+ * @param {boolean} italic - Whether text is italic
22
+ * @param {number} lockedLineCount - Optional locked line count (forces exact number of lines during corner resize)
23
+ * @param {boolean} strict - If true, disable tolerance (wrap exactly at maxWidth, matching richText behavior)
24
+ * @returns {string[]} Array of lines
25
+ */
26
+ export declare function wrapText(text: string, maxWidth: number, fontSize: number, fontFamily: string, bold?: boolean, italic?: boolean, lockedLineCount?: number, strict?: boolean): string[];
27
+ /**
28
+ * Measure width of text
29
+ * @param {string} text - Text to measure
30
+ * @param {number} fontSize - Font size
31
+ * @param {string} fontFamily - Font family name
32
+ * @param {boolean} bold - Whether text is bold
33
+ * @param {boolean} italic - Whether text is italic
34
+ * @returns {number} Width in pixels
35
+ */
36
+ export declare function measureTextWidth(text: string, fontSize: number, fontFamily: string, bold?: boolean, italic?: boolean): number;
37
+ /**
38
+ * Get font metrics for accurate text positioning
39
+ * @param {number} fontSize - Font size
40
+ * @param {string} fontFamily - Font family name
41
+ * @param {boolean} bold - Whether text is bold
42
+ * @param {boolean} italic - Whether text is italic
43
+ * @returns {Object} {ascent, descent, height}
44
+ */
45
+ export declare function getFontMetrics(fontSize: number, fontFamily: string, bold?: boolean, italic?: boolean): {
46
+ ascent: number;
47
+ descent: number;
48
+ height: number;
49
+ };
50
+ /**
51
+ * Calculate visual bounds for multi-line text
52
+ * @param {string[]} lines - Array of text lines
53
+ * @param {number} fontSize - Font size
54
+ * @param {string} fontFamily - Font family name
55
+ * @param {number} lineHeight - Line height multiplier (e.g., 1.2)
56
+ * @returns {Object} {width, height}
57
+ */
58
+ export declare function calculateTextBounds(lines: string[], fontSize: number, fontFamily: string, lineHeight?: number): {
59
+ width: number;
60
+ height: number;
61
+ };
62
+ /**
63
+ * Render multi-line text with alignment and text decorations
64
+ * @param {CanvasRenderingContext2D} ctx - Canvas context
65
+ * @param {string[]} lines - Array of text lines
66
+ * @param {number} x - X position (meaning depends on alignment)
67
+ * @param {number} y - Y position (top of first line baseline)
68
+ * @param {number} fontSize - Font size
69
+ * @param {string} fontFamily - Font family name
70
+ * @param {string} alignment - 'left', 'center', or 'right'
71
+ * @param {number} containerWidth - Width of text container (for alignment)
72
+ * @param {number} horizontalPadding - Padding on sides
73
+ * @param {number} lineHeight - Line height multiplier
74
+ * @param {boolean} bold - Whether text is bold
75
+ * @param {boolean} italic - Whether text is italic
76
+ * @param {boolean} underline - Whether text is underlined
77
+ * @param {boolean} strikethrough - Whether text has strikethrough
78
+ */
79
+ export declare function renderMultilineText(ctx: CanvasRenderingContext2D, lines: string[], x: number, y: number, fontSize: number, fontFamily: string, alignment?: CanvasTextAlign, containerWidth?: number, horizontalPadding?: number, lineHeight?: number, bold?: boolean, italic?: boolean, underline?: boolean, strikethrough?: boolean): void;
80
+ /**
81
+ * Calculate container height for text with given line count
82
+ * @param {number} lineCount - Number of lines
83
+ * @param {number} fontSize - Font size
84
+ * @param {string} fontFamily - Font family name
85
+ * @param {number} lineHeight - Line height multiplier
86
+ * @returns {number} Container height in pixels
87
+ */
88
+ export declare function calculateContainerHeight(lineCount: number, fontSize: number, fontFamily: string, lineHeight?: number): number;
89
+ /**
90
+ * Calculate visual bounds for wrapped text with space collapsing applied
91
+ * This matches the actual rendering behavior where trailing spaces on wrapped lines are hidden
92
+ *
93
+ * @param {string} text - Text to measure
94
+ * @param {number} maxWidth - Maximum width for wrapping (or Infinity for no wrapping)
95
+ * @param {number} fontSize - Font size
96
+ * @param {string} fontFamily - Font family name
97
+ * @param {boolean} bold - Whether text is bold
98
+ * @param {boolean} italic - Whether text is italic
99
+ * @param {number} lockedLineCount - Optional locked line count (forces exact number of lines during corner resize)
100
+ * @param {boolean} strict - If true, disable tolerance (wrap exactly at maxWidth)
101
+ * @returns {Object} {width, height, lines} - Adjusted dimensions and line array
102
+ */
103
+ export declare function calculateVisualBoundsWithSpaceCollapsing(text: string, maxWidth: number, fontSize: number, fontFamily: string, bold?: boolean, italic?: boolean, lockedLineCount?: number, strict?: boolean): {
104
+ width: number;
105
+ height: number;
106
+ lines: string[];
107
+ };
108
+ declare const _default: {
109
+ wrapText: typeof wrapText;
110
+ measureTextWidth: typeof measureTextWidth;
111
+ getFontMetrics: typeof getFontMetrics;
112
+ calculateTextBounds: typeof calculateTextBounds;
113
+ renderMultilineText: typeof renderMultilineText;
114
+ calculateContainerHeight: typeof calculateContainerHeight;
115
+ calculateVisualBoundsWithSpaceCollapsing: typeof calculateVisualBoundsWithSpaceCollapsing;
116
+ };
117
+ export default _default;
@@ -0,0 +1,158 @@
1
+ /**
2
+ * Transform - Centralized coordinate transformation utilities
3
+ *
4
+ * ROTATION CONVENTION:
5
+ * -------------------
6
+ * - UI: Positive rotation = CLOCKWISE (e.g., +45° rotates 45° clockwise)
7
+ * - Canvas rendering: Uses ctx.rotate() with NEGATIVE angle (negative = clockwise in canvas)
8
+ * - Mathematical convention: Standard rotation matrices
9
+ *
10
+ * COORDINATE SPACES:
11
+ * -----------------
12
+ * - WORLD space: The canvas coordinate system (absolute positions)
13
+ * - LOCAL space: The element's own coordinate system (relative to element center, unrotated)
14
+ *
15
+ * TRANSFORMS:
16
+ * ----------
17
+ * - FORWARD transform (local → world): Used for rendering, uses NEGATIVE angle
18
+ * - INVERSE transform (world → local): Used for hit testing and input, uses POSITIVE angle
19
+ *
20
+ * WHY THE SIGN DIFFERENCE?
21
+ * -----------------------
22
+ * Canvas rotation is counter-clockwise by default. To make positive rotations appear
23
+ * clockwise in the UI, we negate the angle when rendering. For coordinate transforms:
24
+ * - To go from local→world (rendering), we use the RENDERING angle (negative)
25
+ * - To go from world→local (input), we UNDO the rendering rotation (positive)
26
+ *
27
+ * EXAMPLE:
28
+ * -------
29
+ * An element at (100, 100) rotated 45° clockwise:
30
+ * - Rendering: ctx.rotate((-45 * Math.PI) / 180) // negative = clockwise
31
+ * - Mouse at (150, 120) in world coords
32
+ * - Convert to local: use +45° to undo the -45° rendering rotation
33
+ * - Result: local coordinates relative to element's center
34
+ */
35
+ /** Minimal interface for objects that can be used with Transform */
36
+ export interface Transformable {
37
+ x: number;
38
+ y: number;
39
+ rotation: number;
40
+ [key: string]: any;
41
+ }
42
+ export declare class Transform {
43
+ element: Transformable;
44
+ /**
45
+ * Create a transform helper for an element
46
+ * @param element - Element with x, y, rotation properties
47
+ */
48
+ constructor(element: Transformable);
49
+ /**
50
+ * Convert a point from world coordinates to local coordinates
51
+ * This is an INVERSE transform (world → local)
52
+ * Uses positive angle with standard rotation matrix formula
53
+ *
54
+ * @param worldX - X coordinate in world space
55
+ * @param worldY - Y coordinate in world space
56
+ * @returns Point in local coordinates
57
+ */
58
+ worldToLocal(worldX: number, worldY: number): {
59
+ x: number;
60
+ y: number;
61
+ };
62
+ /**
63
+ * Convert a point from local coordinates to world coordinates
64
+ * This is a FORWARD transform (local → world)
65
+ * Uses NEGATIVE angle matching the rendering convention
66
+ *
67
+ * @param localX - X coordinate in local space
68
+ * @param localY - Y coordinate in local space
69
+ * @returns Point in world coordinates
70
+ */
71
+ localToWorld(localX: number, localY: number): {
72
+ x: number;
73
+ y: number;
74
+ };
75
+ /**
76
+ * Convert a delta (movement/offset) from world space to local space
77
+ * This is useful for drag operations - no translation, just rotation
78
+ * Uses positive angle with standard rotation matrix formula
79
+ *
80
+ * @param dx - Delta X in world space
81
+ * @param dy - Delta Y in world space
82
+ * @returns Delta in local space
83
+ */
84
+ worldDeltaToLocal(dx: number, dy: number): {
85
+ dx: number;
86
+ dy: number;
87
+ };
88
+ /**
89
+ * Convert a delta (movement/offset) from local space to world space
90
+ * Uses NEGATIVE angle (forward transform, matches rendering)
91
+ *
92
+ * @param dx - Delta X in local space
93
+ * @param dy - Delta Y in local space
94
+ * @returns Delta in world space
95
+ */
96
+ localDeltaToWorld(dx: number, dy: number): {
97
+ dx: number;
98
+ dy: number;
99
+ };
100
+ /**
101
+ * Rotate a point around a custom anchor point
102
+ * Useful for rotation handles and pivot-based operations
103
+ *
104
+ * @param pointX - Point X in world space
105
+ * @param pointY - Point Y in world space
106
+ * @param anchorX - Anchor X in world space
107
+ * @param anchorY - Anchor Y in world space
108
+ * @param angleDegrees - Rotation angle in degrees (positive = clockwise in UI)
109
+ * @returns Rotated point in world space
110
+ */
111
+ static rotatePointAroundAnchor(pointX: number, pointY: number, anchorX: number, anchorY: number, angleDegrees: number): {
112
+ x: number;
113
+ y: number;
114
+ };
115
+ /**
116
+ * Get rotation angle in radians for rendering (forward transform)
117
+ * Returns NEGATIVE angle (positive UI rotation → clockwise canvas rotation)
118
+ *
119
+ * @returns Rotation in radians for use with ctx.rotate()
120
+ */
121
+ getRenderingAngle(): number;
122
+ /**
123
+ * Get rotation angle in radians for inverse transforms
124
+ * Returns POSITIVE angle (for converting world → local)
125
+ *
126
+ * @returns Rotation in radians for inverse transforms
127
+ */
128
+ getInverseAngle(): number;
129
+ /**
130
+ * Get precomputed cos/sin for rendering (forward transform)
131
+ * Useful when you need to do multiple transformations with the same angle
132
+ *
133
+ * @returns Cosine and sine of rendering angle
134
+ */
135
+ getRenderingCosSin(): {
136
+ cos: number;
137
+ sin: number;
138
+ };
139
+ /**
140
+ * Get precomputed cos/sin for inverse transforms
141
+ * Useful when you need to do multiple transformations with the same angle
142
+ *
143
+ * @returns Cosine and sine of inverse angle
144
+ */
145
+ getInverseCosSin(): {
146
+ cos: number;
147
+ sin: number;
148
+ };
149
+ /**
150
+ * Create a transform for an element snapshot (from startData)
151
+ * Useful during drag operations when you need to use the original rotation
152
+ *
153
+ * @param elementSnapshot - Object with x, y, rotation properties
154
+ * @returns Transform instance for the snapshot
155
+ */
156
+ static fromSnapshot(elementSnapshot: Transformable): Transform;
157
+ }
158
+ export default Transform;
@@ -0,0 +1,16 @@
1
+ import { TextElement } from './TextElement.js';
2
+ import { TransformType } from '../types/index.js';
3
+ /**
4
+ * Convert an element from one transform type to another
5
+ * Maintains visual size and position during conversion
6
+ *
7
+ * @param sourceElement - Element to convert from
8
+ * @param targetType - Target transform type id
9
+ * @param TargetClass - Target transform class constructor
10
+ * @returns New element with target transform type
11
+ */
12
+ export declare function convertTransform(sourceElement: TextElement, targetType: TransformType, TargetClass: new (config: Record<string, unknown>) => TextElement): TextElement;
13
+ declare const _default: {
14
+ convertTransform: typeof convertTransform;
15
+ };
16
+ export default _default;
@@ -0,0 +1,55 @@
1
+ import { BaseElement } from './BaseElement.js';
2
+ import { HandleInfo, Point } from '../types/index.js';
3
+ export declare class TransformHandles {
4
+ resizeHandles: HandleInfo[];
5
+ rotationHandle: Point | null;
6
+ elementRotation: number;
7
+ rotationAnchor: Point;
8
+ constructor();
9
+ /**
10
+ * Update handle positions for an element
11
+ * @param element - The element to update handles for
12
+ * @param zoom - Current zoom level (used to maintain consistent rotation handle distance in screen space)
13
+ */
14
+ update(element: BaseElement, zoom?: number): void;
15
+ /**
16
+ * Render all handles
17
+ * @param renderRotationInCanvas - If false, skip canvas rendering of rotation handle (for React-based rendering)
18
+ */
19
+ render(ctx: CanvasRenderingContext2D, showRotationHandle?: boolean, rotationAngle?: number, isRotating?: boolean, isHoveringRotation?: boolean, hoveredResizeHandle?: HandleInfo | null, isResizing?: boolean, activeResizeHandle?: HandleInfo | null, zoom?: number, renderRotationInCanvas?: boolean): void;
20
+ /**
21
+ * Render a single resize handle
22
+ * Corner handles are circles, side handles are rounded rectangles
23
+ */
24
+ renderResizeHandle(ctx: CanvasRenderingContext2D, handle: HandleInfo, isHovered?: boolean, isActive?: boolean, zoom?: number): void;
25
+ /**
26
+ * Render the rotation handle (with refresh-ccw icon)
27
+ * Works in screen space (positions multiplied by zoom, fixed pixel sizes)
28
+ */
29
+ renderRotationHandle(ctx: CanvasRenderingContext2D, handle: Point, isHovering?: boolean, zoom?: number): void;
30
+ /**
31
+ * Render rotation tooltip (angle display while rotating)
32
+ */
33
+ renderRotationTooltip(ctx: CanvasRenderingContext2D, handle: Point, angle: number, zoom?: number): void;
34
+ /**
35
+ * Test if a point hits any resize handle
36
+ * @param zoom - Current zoom level (radius scales inversely with zoom)
37
+ */
38
+ hitTestResize(x: number, y: number, zoom?: number): HandleInfo | null;
39
+ /**
40
+ * Test if a point hits the rotation handle
41
+ * @param zoom - Current zoom level (radius scales inversely with zoom)
42
+ */
43
+ hitTestRotation(x: number, y: number, zoom?: number): boolean;
44
+ /**
45
+ * Get rotation handle position (for React-based rendering)
46
+ */
47
+ getRotationHandlePosition(): Point | null;
48
+ /**
49
+ * Get cursor style for a resize handle, adjusted for the element's current rotation.
50
+ * @param handle - The resize handle to get cursor for
51
+ * @param rotation - Element rotation in degrees
52
+ */
53
+ getCursor(handle: HandleInfo, rotation: number): string;
54
+ }
55
+ export default TransformHandles;
@@ -0,0 +1,46 @@
1
+ import { ArtboardElement } from './ArtboardElement.js';
2
+ import { ArtboardConfig } from '../types/index.js';
3
+ export interface ArtboardState {
4
+ /** All artboards in creation order. */
5
+ artboards: ArtboardElement[];
6
+ /** Currently active artboard ID (or null if none). */
7
+ activeArtboardId: string | null;
8
+ /** Map from elementId to artboardId for fast lookups. */
9
+ elementToArtboard: Map<string, string>;
10
+ /**
11
+ * Monotonically increasing version counter.
12
+ * Bumped on every state change so React components can depend on it
13
+ * for cache-busting without deep-comparing artboard arrays.
14
+ */
15
+ version: number;
16
+ }
17
+ /** Create the initial (empty) artboard state. */
18
+ export declare function createInitialArtboardState(): ArtboardState;
19
+ export type ArtboardAction = {
20
+ type: 'CREATE';
21
+ artboard: ArtboardElement;
22
+ } | {
23
+ type: 'DELETE';
24
+ artboardId: string;
25
+ } | {
26
+ type: 'UPDATE';
27
+ artboardId: string;
28
+ updates: Partial<ArtboardConfig>;
29
+ } | {
30
+ type: 'SET_ACTIVE';
31
+ artboardId: string | null;
32
+ } | {
33
+ type: 'ASSIGN_ELEMENT';
34
+ elementId: string;
35
+ artboardId: string;
36
+ } | {
37
+ type: 'REMOVE_ELEMENT';
38
+ elementId: string;
39
+ } | {
40
+ type: 'LOAD';
41
+ artboards: ArtboardElement[];
42
+ activeId: string | null;
43
+ } | {
44
+ type: 'CLEAR';
45
+ };
46
+ export declare function artboardReducer(state: ArtboardState, action: ArtboardAction): ArtboardState;
@@ -0,0 +1,26 @@
1
+ import { DistressEffect } from '../types/index.js';
2
+ /**
3
+ * Generate worn/vintage distress effect
4
+ * Uses Perlin noise for organic edge wear
5
+ */
6
+ export declare function generateWornEffect(width: number, height: number, intensity: number, seed?: number): ImageData;
7
+ /**
8
+ * Generate cracked/fractured distress effect
9
+ * Creates crack patterns using branching algorithm
10
+ */
11
+ export declare function generateCrackedEffect(width: number, height: number, intensity: number, seed?: number): ImageData;
12
+ /**
13
+ * Generate grunge/heavy texture effect
14
+ * Dense noise pattern for heavy distress
15
+ */
16
+ export declare function generateGrungeEffect(width: number, height: number, intensity: number, seed?: number): ImageData;
17
+ /**
18
+ * Generate retro/halftone distress effect
19
+ * Dot pattern with fade
20
+ */
21
+ export declare function generateRetroEffect(width: number, height: number, intensity: number, seed?: number): ImageData;
22
+ /**
23
+ * Apply distress effect to existing canvas
24
+ * Composites distress onto rendered content
25
+ */
26
+ export declare function applyDistressEffect(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, distress: DistressEffect): void;
@@ -0,0 +1,49 @@
1
+ /**
2
+ * DistressTextureCache - Loads grayscale JPEG textures and converts them to alpha masks.
3
+ *
4
+ * Dark pixels in the texture → high alpha (will knock out design pixels)
5
+ * Light pixels in the texture → low alpha (will preserve design pixels)
6
+ *
7
+ * Shared between artboard-level and per-element distress texture rendering.
8
+ * Works with both HTMLCanvasElement (preview) and OffscreenCanvas (export worker).
9
+ */
10
+ type CanvasLike = HTMLCanvasElement | OffscreenCanvas;
11
+ interface CacheEntry {
12
+ alphaMask: CanvasLike;
13
+ width: number;
14
+ height: number;
15
+ }
16
+ /**
17
+ * Get a cached alpha mask for the given texture URL.
18
+ * Returns the cached canvas synchronously if available, or null if still loading.
19
+ * Automatically starts loading if the URL hasn't been requested before.
20
+ */
21
+ export declare function getAlphaMask(url: string): CacheEntry | null;
22
+ /**
23
+ * Get a cached alpha mask synchronously (no auto-loading).
24
+ * Returns null if not cached.
25
+ */
26
+ export declare function getAlphaMaskSync(url: string): CacheEntry | null;
27
+ /**
28
+ * Preload a texture URL so it's ready when needed.
29
+ * Returns a promise that resolves when the texture is cached.
30
+ */
31
+ export declare function preloadTexture(url: string): Promise<void>;
32
+ /**
33
+ * Register an already-loaded ImageBitmap as a distress texture (for worker export).
34
+ */
35
+ export declare function registerBitmap(url: string, bitmap: ImageBitmap): void;
36
+ /**
37
+ * Register a pre-built alpha mask directly (no luminance conversion).
38
+ * Used by procedural generators that already output white RGB + alpha format.
39
+ */
40
+ export declare function registerAlphaMask(key: string, canvas: CanvasLike, width: number, height: number): void;
41
+ /**
42
+ * Clear the entire cache (e.g., on project reset).
43
+ */
44
+ export declare function clearDistressTextureCache(): void;
45
+ /**
46
+ * Remove a specific URL from the cache.
47
+ */
48
+ export declare function invalidateTexture(url: string): void;
49
+ export {};
@@ -0,0 +1,86 @@
1
+ import { DistressEffect } from '../types/index.js';
2
+ /**
3
+ * Vintage worn preset - Light edge wear
4
+ */
5
+ export declare const WORN_LIGHT: DistressEffect;
6
+ /**
7
+ * Vintage worn preset - Medium wear
8
+ */
9
+ export declare const WORN_MEDIUM: DistressEffect;
10
+ /**
11
+ * Vintage worn preset - Heavy wear
12
+ */
13
+ export declare const WORN_HEAVY: DistressEffect;
14
+ /**
15
+ * Cracked preset - Light cracks
16
+ */
17
+ export declare const CRACKED_LIGHT: DistressEffect;
18
+ /**
19
+ * Cracked preset - Medium cracks
20
+ */
21
+ export declare const CRACKED_MEDIUM: DistressEffect;
22
+ /**
23
+ * Cracked preset - Heavy cracks
24
+ */
25
+ export declare const CRACKED_HEAVY: DistressEffect;
26
+ /**
27
+ * Grunge preset - Light texture
28
+ */
29
+ export declare const GRUNGE_LIGHT: DistressEffect;
30
+ /**
31
+ * Grunge preset - Medium texture
32
+ */
33
+ export declare const GRUNGE_MEDIUM: DistressEffect;
34
+ /**
35
+ * Grunge preset - Heavy texture
36
+ */
37
+ export declare const GRUNGE_HEAVY: DistressEffect;
38
+ /**
39
+ * Retro preset - Light halftone
40
+ */
41
+ export declare const RETRO_LIGHT: DistressEffect;
42
+ /**
43
+ * Retro preset - Medium halftone
44
+ */
45
+ export declare const RETRO_MEDIUM: DistressEffect;
46
+ /**
47
+ * Retro preset - Heavy halftone
48
+ */
49
+ export declare const RETRO_HEAVY: DistressEffect;
50
+ /**
51
+ * All presets organized by category
52
+ */
53
+ export declare const DISTRESS_PRESETS: {
54
+ worn: {
55
+ light: DistressEffect;
56
+ medium: DistressEffect;
57
+ heavy: DistressEffect;
58
+ };
59
+ cracked: {
60
+ light: DistressEffect;
61
+ medium: DistressEffect;
62
+ heavy: DistressEffect;
63
+ };
64
+ grunge: {
65
+ light: DistressEffect;
66
+ medium: DistressEffect;
67
+ heavy: DistressEffect;
68
+ };
69
+ retro: {
70
+ light: DistressEffect;
71
+ medium: DistressEffect;
72
+ heavy: DistressEffect;
73
+ };
74
+ };
75
+ /**
76
+ * Get preset by name
77
+ */
78
+ export declare function getPreset(category: 'worn' | 'cracked' | 'grunge' | 'retro', level: 'light' | 'medium' | 'heavy'): DistressEffect;
79
+ /**
80
+ * Get all preset names
81
+ */
82
+ export declare function getAllPresetNames(): Array<{
83
+ category: string;
84
+ level: string;
85
+ name: string;
86
+ }>;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Built-in distress texture presets — procedurally generated
3
+ *
4
+ * Each preset uses generators from DistressGenerator.ts to create
5
+ * textures at runtime. No external JPG files needed.
6
+ *
7
+ * Alpha mask convention: RGB=255 (white), A=opacity of knockout.
8
+ * Dark/opaque pixels knock out design pixels, transparent preserves them.
9
+ */
10
+ export interface DistressTexturePreset {
11
+ id: string;
12
+ name: string;
13
+ /** Synthetic key used for cache lookup (e.g. "builtin:grunge-heavy") */
14
+ textureUrl: string;
15
+ /** Data URL thumbnail (populated by ensureBuiltinTexturesReady) */
16
+ thumbnailUrl: string;
17
+ /** Brief description of the texture style */
18
+ description: string;
19
+ /** Generator function for this preset's texture */
20
+ generate: (w: number, h: number) => ImageData;
21
+ }
22
+ /**
23
+ * Built-in distress texture presets.
24
+ */
25
+ export declare const DISTRESS_TEXTURE_PRESETS: DistressTexturePreset[];
26
+ /**
27
+ * Get a texture preset by ID
28
+ */
29
+ export declare function getDistressTexturePreset(id: string): DistressTexturePreset | undefined;
30
+ /**
31
+ * Lazily generate all built-in textures, register them in the cache,
32
+ * and populate thumbnail data URLs. No-ops on subsequent calls.
33
+ */
34
+ export declare function ensureBuiltinTexturesReady(): void;
@@ -0,0 +1,39 @@
1
+ import { DistressEffect } from '../types/index.js';
2
+ /**
3
+ * Load custom distress texture from URL
4
+ */
5
+ export declare function loadDistressTexture(url: string): Promise<HTMLImageElement | ImageBitmap>;
6
+ /**
7
+ * Blend distress texture onto canvas
8
+ */
9
+ export declare function blendTexture(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, texture: HTMLImageElement | ImageBitmap | HTMLCanvasElement | OffscreenCanvas, blendMode?: 'multiply' | 'screen' | 'overlay', opacity?: number): void;
10
+ /**
11
+ * Generate distress texture based on effect configuration
12
+ */
13
+ export declare function generateDistressTexture(width: number, height: number, effect: DistressEffect): ImageData | null;
14
+ /**
15
+ * Apply distress texture to canvas
16
+ */
17
+ export declare function applyDistressTexture(ctx: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, distressData: ImageData): void;
18
+ /**
19
+ * Combine multiple distress effects
20
+ */
21
+ export declare function combineDistressEffects(width: number, height: number, effects: DistressEffect[]): ImageData | null;
22
+ /**
23
+ * Create preview of distress effect
24
+ * Generates a small preview thumbnail
25
+ */
26
+ export declare function createDistressPreview(effect: DistressEffect, width?: number, height?: number): HTMLCanvasElement | OffscreenCanvas;
27
+ /**
28
+ * Validate distress effect configuration
29
+ */
30
+ export declare function isValidDistressEffect(effect: DistressEffect): boolean;
31
+ /**
32
+ * Clone distress effect with new seed
33
+ */
34
+ export declare function cloneDistressEffect(effect: DistressEffect): DistressEffect;
35
+ /**
36
+ * Interpolate between two distress effects
37
+ * Useful for animations or transitions
38
+ */
39
+ export declare function lerpDistressEffects(effect1: DistressEffect, effect2: DistressEffect, t: number): DistressEffect;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Built-in mask image presets — procedurally generated SVG shapes
3
+ *
4
+ * Each preset renders an SVG path to a canvas to produce a data URL.
5
+ * The data URL is stored as `imageUrl` and registered with ImageCache
6
+ * so MaskRenderer can find them. A 64x64 thumbnail is also generated.
7
+ */
8
+ export interface MaskImagePreset {
9
+ id: string;
10
+ name: string;
11
+ description: string;
12
+ /** Synthetic key — also used as imageUrl for masks */
13
+ imageUrl: string;
14
+ /** Data URL thumbnail (populated by ensureMaskPresetsReady) */
15
+ thumbnailUrl: string;
16
+ category: 'geometric' | 'organic';
17
+ /** SVG path draw function */
18
+ draw: (ctx: CanvasRenderingContext2D, size: number) => void;
19
+ }
20
+ export declare const MASK_IMAGE_PRESETS: MaskImagePreset[];
21
+ /**
22
+ * Generate all mask preset images, register in ImageCache, populate thumbnails.
23
+ * Safe to call during render — idempotent and synchronous.
24
+ * Skips silently during SSR (no document), but will run on client.
25
+ */
26
+ export declare function ensureMaskPresetsReady(): void;
27
+ /**
28
+ * Get a mask preset by ID.
29
+ */
30
+ export declare function getMaskPreset(id: string): MaskImagePreset | undefined;
31
+ /**
32
+ * Generate an ImageBitmap for a builtin mask preset.
33
+ * Works in Web Worker contexts (uses OffscreenCanvas, no DOM).
34
+ * Returns null if the preset ID is not found or OffscreenCanvas is unavailable.
35
+ */
36
+ export declare function generateMaskBitmap(builtinUrl: string): ImageBitmap | null;