@nice2dev/ui-graphics 1.0.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 (511) hide show
  1. package/CHANGELOG.md +84 -0
  2. package/LICENSE +21 -0
  3. package/README.md +339 -0
  4. package/dist/cjs/animation/AnimatedPerson.js +153 -0
  5. package/dist/cjs/animation/AnimatedPerson.js.map +1 -0
  6. package/dist/cjs/animation/AnimationEditor.js +106 -0
  7. package/dist/cjs/animation/AnimationEditor.js.map +1 -0
  8. package/dist/cjs/animation/Audience.js +59 -0
  9. package/dist/cjs/animation/Audience.js.map +1 -0
  10. package/dist/cjs/animation/BodyRenderer.js +33 -0
  11. package/dist/cjs/animation/BodyRenderer.js.map +1 -0
  12. package/dist/cjs/animation/animationHelper.js +272 -0
  13. package/dist/cjs/animation/animationHelper.js.map +1 -0
  14. package/dist/cjs/animation/characterTypes.js +75 -0
  15. package/dist/cjs/animation/characterTypes.js.map +1 -0
  16. package/dist/cjs/animation/choreoDSL.js +190 -0
  17. package/dist/cjs/animation/choreoDSL.js.map +1 -0
  18. package/dist/cjs/animation/choreography.js +41 -0
  19. package/dist/cjs/animation/choreography.js.map +1 -0
  20. package/dist/cjs/animation/karaokeIntegration.js +98 -0
  21. package/dist/cjs/animation/karaokeIntegration.js.map +1 -0
  22. package/dist/cjs/animation/lottieExport.js +128 -0
  23. package/dist/cjs/animation/lottieExport.js.map +1 -0
  24. package/dist/cjs/animation/motionPath.js +196 -0
  25. package/dist/cjs/animation/motionPath.js.map +1 -0
  26. package/dist/cjs/animation/physics.js +201 -0
  27. package/dist/cjs/animation/physics.js.map +1 -0
  28. package/dist/cjs/animation/rig/RigPlayer.js +63 -0
  29. package/dist/cjs/animation/rig/RigPlayer.js.map +1 -0
  30. package/dist/cjs/animation/rig/RiggedBody.js +30 -0
  31. package/dist/cjs/animation/rig/RiggedBody.js.map +1 -0
  32. package/dist/cjs/animation/rig/choreoRigBridge.js +63 -0
  33. package/dist/cjs/animation/rig/choreoRigBridge.js.map +1 -0
  34. package/dist/cjs/animation/rig/ik.js +22 -0
  35. package/dist/cjs/animation/rig/ik.js.map +1 -0
  36. package/dist/cjs/animation/rig/poseOps.js +49 -0
  37. package/dist/cjs/animation/rig/poseOps.js.map +1 -0
  38. package/dist/cjs/animation/rig/presets.js +60 -0
  39. package/dist/cjs/animation/rig/presets.js.map +1 -0
  40. package/dist/cjs/animation/rig/rigMath.js +41 -0
  41. package/dist/cjs/animation/rig/rigMath.js.map +1 -0
  42. package/dist/cjs/animation/rig/rigTypes.js +44 -0
  43. package/dist/cjs/animation/rig/rigTypes.js.map +1 -0
  44. package/dist/cjs/animation/shapes/arms.js +15 -0
  45. package/dist/cjs/animation/shapes/arms.js.map +1 -0
  46. package/dist/cjs/animation/shapes/eyes.js +52 -0
  47. package/dist/cjs/animation/shapes/eyes.js.map +1 -0
  48. package/dist/cjs/animation/shapes/hair.js +55 -0
  49. package/dist/cjs/animation/shapes/hair.js.map +1 -0
  50. package/dist/cjs/animation/shapes/heads.js +62 -0
  51. package/dist/cjs/animation/shapes/heads.js.map +1 -0
  52. package/dist/cjs/animation/shapes/headwear.js +44 -0
  53. package/dist/cjs/animation/shapes/headwear.js.map +1 -0
  54. package/dist/cjs/animation/shapes/legs.js +15 -0
  55. package/dist/cjs/animation/shapes/legs.js.map +1 -0
  56. package/dist/cjs/animation/shapes/mouths.js +53 -0
  57. package/dist/cjs/animation/shapes/mouths.js.map +1 -0
  58. package/dist/cjs/animation/shapes/noses.js +31 -0
  59. package/dist/cjs/animation/shapes/noses.js.map +1 -0
  60. package/dist/cjs/animation/shapes/outfits.js +43 -0
  61. package/dist/cjs/animation/shapes/outfits.js.map +1 -0
  62. package/dist/cjs/animation/shapes/torsos.js +13 -0
  63. package/dist/cjs/animation/shapes/torsos.js.map +1 -0
  64. package/dist/cjs/animation/spineExport.js +132 -0
  65. package/dist/cjs/animation/spineExport.js.map +1 -0
  66. package/dist/cjs/core/LocalUI.js +54 -0
  67. package/dist/cjs/core/LocalUI.js.map +1 -0
  68. package/dist/cjs/core/collaboration.js +259 -0
  69. package/dist/cjs/core/collaboration.js.map +1 -0
  70. package/dist/cjs/core/colorBlindness.js +97 -0
  71. package/dist/cjs/core/colorBlindness.js.map +1 -0
  72. package/dist/cjs/core/dragDrop.js +168 -0
  73. package/dist/cjs/core/dragDrop.js.map +1 -0
  74. package/dist/cjs/core/fixes.js +185 -0
  75. package/dist/cjs/core/fixes.js.map +1 -0
  76. package/dist/cjs/core/gridGuides.js +245 -0
  77. package/dist/cjs/core/gridGuides.js.map +1 -0
  78. package/dist/cjs/core/historyVisual.js +124 -0
  79. package/dist/cjs/core/historyVisual.js.map +1 -0
  80. package/dist/cjs/core/i18n.js +16 -0
  81. package/dist/cjs/core/i18n.js.map +1 -0
  82. package/dist/cjs/core/integrations.js +261 -0
  83. package/dist/cjs/core/integrations.js.map +1 -0
  84. package/dist/cjs/core/minimap.js +142 -0
  85. package/dist/cjs/core/minimap.js.map +1 -0
  86. package/dist/cjs/core/plugins.js +129 -0
  87. package/dist/cjs/core/plugins.js.map +1 -0
  88. package/dist/cjs/core/rtl.js +102 -0
  89. package/dist/cjs/core/rtl.js.map +1 -0
  90. package/dist/cjs/core/shortcuts.js +205 -0
  91. package/dist/cjs/core/shortcuts.js.map +1 -0
  92. package/dist/cjs/core/theme.js +171 -0
  93. package/dist/cjs/core/theme.js.map +1 -0
  94. package/dist/cjs/font/NiceFontEditor.js +193 -0
  95. package/dist/cjs/font/NiceFontEditor.js.map +1 -0
  96. package/dist/cjs/game/GameAsset2dEditor.js +371 -0
  97. package/dist/cjs/game/GameAsset2dEditor.js.map +1 -0
  98. package/dist/cjs/game/GameAsset2dEditor.module.css.js +6 -0
  99. package/dist/cjs/game/GameAsset2dEditor.module.css.js.map +1 -0
  100. package/dist/cjs/game/gameAssetTypes.js +20 -0
  101. package/dist/cjs/game/gameAssetTypes.js.map +1 -0
  102. package/dist/cjs/game/gameAssetUtils.js +475 -0
  103. package/dist/cjs/game/gameAssetUtils.js.map +1 -0
  104. package/dist/cjs/game/useGameAssetEditor.js +761 -0
  105. package/dist/cjs/game/useGameAssetEditor.js.map +1 -0
  106. package/dist/cjs/icon/NiceIconEditor.js +249 -0
  107. package/dist/cjs/icon/NiceIconEditor.js.map +1 -0
  108. package/dist/cjs/index.js +264 -0
  109. package/dist/cjs/index.js.map +1 -0
  110. package/dist/cjs/nice2dev-ui/dist/index.js +32070 -0
  111. package/dist/cjs/nice2dev-ui/dist/index.js.map +1 -0
  112. package/dist/cjs/nice2dev-ui-graphics.css +1 -0
  113. package/dist/cjs/photo/FilterThumb.js +29 -0
  114. package/dist/cjs/photo/FilterThumb.js.map +1 -0
  115. package/dist/cjs/photo/PhotoEditor.js +20 -0
  116. package/dist/cjs/photo/PhotoEditor.js.map +1 -0
  117. package/dist/cjs/photo/PhotoEditor.module.css.js +6 -0
  118. package/dist/cjs/photo/PhotoEditor.module.css.js.map +1 -0
  119. package/dist/cjs/photo/PhotoEditorCanvas.js +59 -0
  120. package/dist/cjs/photo/PhotoEditorCanvas.js.map +1 -0
  121. package/dist/cjs/photo/PhotoEditorLeftPanel.js +174 -0
  122. package/dist/cjs/photo/PhotoEditorLeftPanel.js.map +1 -0
  123. package/dist/cjs/photo/PhotoEditorToolbar.js +15 -0
  124. package/dist/cjs/photo/PhotoEditorToolbar.js.map +1 -0
  125. package/dist/cjs/photo/photoEditorActions.js +80 -0
  126. package/dist/cjs/photo/photoEditorActions.js.map +1 -0
  127. package/dist/cjs/photo/photoEditorTypes.js +40 -0
  128. package/dist/cjs/photo/photoEditorTypes.js.map +1 -0
  129. package/dist/cjs/photo/photoFilters.js +880 -0
  130. package/dist/cjs/photo/photoFilters.js.map +1 -0
  131. package/dist/cjs/photo/photoOverlays.js +651 -0
  132. package/dist/cjs/photo/photoOverlays.js.map +1 -0
  133. package/dist/cjs/photo/photoSelection.js +547 -0
  134. package/dist/cjs/photo/photoSelection.js.map +1 -0
  135. package/dist/cjs/photo/usePhotoEditor.js +640 -0
  136. package/dist/cjs/photo/usePhotoEditor.js.map +1 -0
  137. package/dist/cjs/pixel/HSVPicker.js +173 -0
  138. package/dist/cjs/pixel/HSVPicker.js.map +1 -0
  139. package/dist/cjs/pixel/PixelEditor.js +28 -0
  140. package/dist/cjs/pixel/PixelEditor.js.map +1 -0
  141. package/dist/cjs/pixel/PixelEditor.module.css.js +6 -0
  142. package/dist/cjs/pixel/PixelEditor.module.css.js.map +1 -0
  143. package/dist/cjs/pixel/PixelEditorCanvas.js +15 -0
  144. package/dist/cjs/pixel/PixelEditorCanvas.js.map +1 -0
  145. package/dist/cjs/pixel/PixelEditorMenuBar.js +11 -0
  146. package/dist/cjs/pixel/PixelEditorMenuBar.js.map +1 -0
  147. package/dist/cjs/pixel/PixelEditorRightPanel.js +15 -0
  148. package/dist/cjs/pixel/PixelEditorRightPanel.js.map +1 -0
  149. package/dist/cjs/pixel/PixelEditorStatusBar.js +15 -0
  150. package/dist/cjs/pixel/PixelEditorStatusBar.js.map +1 -0
  151. package/dist/cjs/pixel/PixelEditorTimeline.js +11 -0
  152. package/dist/cjs/pixel/PixelEditorTimeline.js.map +1 -0
  153. package/dist/cjs/pixel/PixelEditorToolbar.js +16 -0
  154. package/dist/cjs/pixel/PixelEditorToolbar.js.map +1 -0
  155. package/dist/cjs/pixel/asepriteFormat.js +512 -0
  156. package/dist/cjs/pixel/asepriteFormat.js.map +1 -0
  157. package/dist/cjs/pixel/pixelEditorExports.js +471 -0
  158. package/dist/cjs/pixel/pixelEditorExports.js.map +1 -0
  159. package/dist/cjs/pixel/pixelEditorTypes.js +102 -0
  160. package/dist/cjs/pixel/pixelEditorTypes.js.map +1 -0
  161. package/dist/cjs/pixel/pixelEditorUtils.js +664 -0
  162. package/dist/cjs/pixel/pixelEditorUtils.js.map +1 -0
  163. package/dist/cjs/pixel/usePixelEditor.js +1112 -0
  164. package/dist/cjs/pixel/usePixelEditor.js.map +1 -0
  165. package/dist/cjs/texture/Nice3DTexturePainter.js +236 -0
  166. package/dist/cjs/texture/Nice3DTexturePainter.js.map +1 -0
  167. package/dist/cjs/ui/NiceUIDesigner.js +191 -0
  168. package/dist/cjs/ui/NiceUIDesigner.js.map +1 -0
  169. package/dist/cjs/vector/VectorEditor.js +31 -0
  170. package/dist/cjs/vector/VectorEditor.js.map +1 -0
  171. package/dist/cjs/vector/VectorEditor.module.css.js +6 -0
  172. package/dist/cjs/vector/VectorEditor.module.css.js.map +1 -0
  173. package/dist/cjs/vector/VectorEditorMenuBar.js +16 -0
  174. package/dist/cjs/vector/VectorEditorMenuBar.js.map +1 -0
  175. package/dist/cjs/vector/VectorEditorRightPanel.js +126 -0
  176. package/dist/cjs/vector/VectorEditorRightPanel.js.map +1 -0
  177. package/dist/cjs/vector/VectorEditorShapeRenderer.js +55 -0
  178. package/dist/cjs/vector/VectorEditorShapeRenderer.js.map +1 -0
  179. package/dist/cjs/vector/VectorEditorStatusBar.js +14 -0
  180. package/dist/cjs/vector/VectorEditorStatusBar.js.map +1 -0
  181. package/dist/cjs/vector/useVectorEditor.js +613 -0
  182. package/dist/cjs/vector/useVectorEditor.js.map +1 -0
  183. package/dist/cjs/vector/vectorBooleanOps.js +511 -0
  184. package/dist/cjs/vector/vectorBooleanOps.js.map +1 -0
  185. package/dist/cjs/vector/vectorEditorExport.js +159 -0
  186. package/dist/cjs/vector/vectorEditorExport.js.map +1 -0
  187. package/dist/cjs/vector/vectorEditorImport.js +150 -0
  188. package/dist/cjs/vector/vectorEditorImport.js.map +1 -0
  189. package/dist/cjs/vector/vectorEditorTypes.js +72 -0
  190. package/dist/cjs/vector/vectorEditorTypes.js.map +1 -0
  191. package/dist/cjs/vector/vectorGradients.js +201 -0
  192. package/dist/cjs/vector/vectorGradients.js.map +1 -0
  193. package/dist/esm/animation/AnimatedPerson.js +151 -0
  194. package/dist/esm/animation/AnimatedPerson.js.map +1 -0
  195. package/dist/esm/animation/AnimationEditor.js +104 -0
  196. package/dist/esm/animation/AnimationEditor.js.map +1 -0
  197. package/dist/esm/animation/Audience.js +57 -0
  198. package/dist/esm/animation/Audience.js.map +1 -0
  199. package/dist/esm/animation/BodyRenderer.js +28 -0
  200. package/dist/esm/animation/BodyRenderer.js.map +1 -0
  201. package/dist/esm/animation/animationHelper.js +268 -0
  202. package/dist/esm/animation/animationHelper.js.map +1 -0
  203. package/dist/esm/animation/characterTypes.js +70 -0
  204. package/dist/esm/animation/characterTypes.js.map +1 -0
  205. package/dist/esm/animation/choreoDSL.js +182 -0
  206. package/dist/esm/animation/choreoDSL.js.map +1 -0
  207. package/dist/esm/animation/choreography.js +36 -0
  208. package/dist/esm/animation/choreography.js.map +1 -0
  209. package/dist/esm/animation/karaokeIntegration.js +91 -0
  210. package/dist/esm/animation/karaokeIntegration.js.map +1 -0
  211. package/dist/esm/animation/lottieExport.js +123 -0
  212. package/dist/esm/animation/lottieExport.js.map +1 -0
  213. package/dist/esm/animation/motionPath.js +185 -0
  214. package/dist/esm/animation/motionPath.js.map +1 -0
  215. package/dist/esm/animation/physics.js +192 -0
  216. package/dist/esm/animation/physics.js.map +1 -0
  217. package/dist/esm/animation/rig/RigPlayer.js +61 -0
  218. package/dist/esm/animation/rig/RigPlayer.js.map +1 -0
  219. package/dist/esm/animation/rig/RiggedBody.js +28 -0
  220. package/dist/esm/animation/rig/RiggedBody.js.map +1 -0
  221. package/dist/esm/animation/rig/choreoRigBridge.js +60 -0
  222. package/dist/esm/animation/rig/choreoRigBridge.js.map +1 -0
  223. package/dist/esm/animation/rig/ik.js +20 -0
  224. package/dist/esm/animation/rig/ik.js.map +1 -0
  225. package/dist/esm/animation/rig/poseOps.js +45 -0
  226. package/dist/esm/animation/rig/poseOps.js.map +1 -0
  227. package/dist/esm/animation/rig/presets.js +53 -0
  228. package/dist/esm/animation/rig/presets.js.map +1 -0
  229. package/dist/esm/animation/rig/rigMath.js +37 -0
  230. package/dist/esm/animation/rig/rigMath.js.map +1 -0
  231. package/dist/esm/animation/rig/rigTypes.js +40 -0
  232. package/dist/esm/animation/rig/rigTypes.js.map +1 -0
  233. package/dist/esm/animation/shapes/arms.js +13 -0
  234. package/dist/esm/animation/shapes/arms.js.map +1 -0
  235. package/dist/esm/animation/shapes/eyes.js +45 -0
  236. package/dist/esm/animation/shapes/eyes.js.map +1 -0
  237. package/dist/esm/animation/shapes/hair.js +46 -0
  238. package/dist/esm/animation/shapes/hair.js.map +1 -0
  239. package/dist/esm/animation/shapes/heads.js +52 -0
  240. package/dist/esm/animation/shapes/heads.js.map +1 -0
  241. package/dist/esm/animation/shapes/headwear.js +36 -0
  242. package/dist/esm/animation/shapes/headwear.js.map +1 -0
  243. package/dist/esm/animation/shapes/legs.js +13 -0
  244. package/dist/esm/animation/shapes/legs.js.map +1 -0
  245. package/dist/esm/animation/shapes/mouths.js +45 -0
  246. package/dist/esm/animation/shapes/mouths.js.map +1 -0
  247. package/dist/esm/animation/shapes/noses.js +23 -0
  248. package/dist/esm/animation/shapes/noses.js.map +1 -0
  249. package/dist/esm/animation/shapes/outfits.js +37 -0
  250. package/dist/esm/animation/shapes/outfits.js.map +1 -0
  251. package/dist/esm/animation/shapes/torsos.js +11 -0
  252. package/dist/esm/animation/shapes/torsos.js.map +1 -0
  253. package/dist/esm/animation/spineExport.js +128 -0
  254. package/dist/esm/animation/spineExport.js.map +1 -0
  255. package/dist/esm/core/LocalUI.js +50 -0
  256. package/dist/esm/core/LocalUI.js.map +1 -0
  257. package/dist/esm/core/collaboration.js +252 -0
  258. package/dist/esm/core/collaboration.js.map +1 -0
  259. package/dist/esm/core/colorBlindness.js +90 -0
  260. package/dist/esm/core/colorBlindness.js.map +1 -0
  261. package/dist/esm/core/dragDrop.js +165 -0
  262. package/dist/esm/core/dragDrop.js.map +1 -0
  263. package/dist/esm/core/fixes.js +179 -0
  264. package/dist/esm/core/fixes.js.map +1 -0
  265. package/dist/esm/core/gridGuides.js +232 -0
  266. package/dist/esm/core/gridGuides.js.map +1 -0
  267. package/dist/esm/core/historyVisual.js +121 -0
  268. package/dist/esm/core/historyVisual.js.map +1 -0
  269. package/dist/esm/core/i18n.js +13 -0
  270. package/dist/esm/core/i18n.js.map +1 -0
  271. package/dist/esm/core/integrations.js +254 -0
  272. package/dist/esm/core/integrations.js.map +1 -0
  273. package/dist/esm/core/minimap.js +139 -0
  274. package/dist/esm/core/minimap.js.map +1 -0
  275. package/dist/esm/core/plugins.js +124 -0
  276. package/dist/esm/core/plugins.js.map +1 -0
  277. package/dist/esm/core/rtl.js +95 -0
  278. package/dist/esm/core/rtl.js.map +1 -0
  279. package/dist/esm/core/shortcuts.js +200 -0
  280. package/dist/esm/core/shortcuts.js.map +1 -0
  281. package/dist/esm/core/theme.js +162 -0
  282. package/dist/esm/core/theme.js.map +1 -0
  283. package/dist/esm/font/NiceFontEditor.js +189 -0
  284. package/dist/esm/font/NiceFontEditor.js.map +1 -0
  285. package/dist/esm/game/GameAsset2dEditor.js +369 -0
  286. package/dist/esm/game/GameAsset2dEditor.js.map +1 -0
  287. package/dist/esm/game/GameAsset2dEditor.module.css.js +4 -0
  288. package/dist/esm/game/GameAsset2dEditor.module.css.js.map +1 -0
  289. package/dist/esm/game/gameAssetTypes.js +18 -0
  290. package/dist/esm/game/gameAssetTypes.js.map +1 -0
  291. package/dist/esm/game/gameAssetUtils.js +456 -0
  292. package/dist/esm/game/gameAssetUtils.js.map +1 -0
  293. package/dist/esm/game/useGameAssetEditor.js +759 -0
  294. package/dist/esm/game/useGameAssetEditor.js.map +1 -0
  295. package/dist/esm/icon/NiceIconEditor.js +246 -0
  296. package/dist/esm/icon/NiceIconEditor.js.map +1 -0
  297. package/dist/esm/index.js +59 -0
  298. package/dist/esm/index.js.map +1 -0
  299. package/dist/esm/nice2dev-ui/dist/index.js +31720 -0
  300. package/dist/esm/nice2dev-ui/dist/index.js.map +1 -0
  301. package/dist/esm/nice2dev-ui-graphics.css +1 -0
  302. package/dist/esm/photo/FilterThumb.js +27 -0
  303. package/dist/esm/photo/FilterThumb.js.map +1 -0
  304. package/dist/esm/photo/PhotoEditor.js +18 -0
  305. package/dist/esm/photo/PhotoEditor.js.map +1 -0
  306. package/dist/esm/photo/PhotoEditor.module.css.js +4 -0
  307. package/dist/esm/photo/PhotoEditor.module.css.js.map +1 -0
  308. package/dist/esm/photo/PhotoEditorCanvas.js +57 -0
  309. package/dist/esm/photo/PhotoEditorCanvas.js.map +1 -0
  310. package/dist/esm/photo/PhotoEditorLeftPanel.js +172 -0
  311. package/dist/esm/photo/PhotoEditorLeftPanel.js.map +1 -0
  312. package/dist/esm/photo/PhotoEditorToolbar.js +13 -0
  313. package/dist/esm/photo/PhotoEditorToolbar.js.map +1 -0
  314. package/dist/esm/photo/photoEditorActions.js +75 -0
  315. package/dist/esm/photo/photoEditorActions.js.map +1 -0
  316. package/dist/esm/photo/photoEditorTypes.js +36 -0
  317. package/dist/esm/photo/photoEditorTypes.js.map +1 -0
  318. package/dist/esm/photo/photoFilters.js +871 -0
  319. package/dist/esm/photo/photoFilters.js.map +1 -0
  320. package/dist/esm/photo/photoOverlays.js +636 -0
  321. package/dist/esm/photo/photoOverlays.js.map +1 -0
  322. package/dist/esm/photo/photoSelection.js +535 -0
  323. package/dist/esm/photo/photoSelection.js.map +1 -0
  324. package/dist/esm/photo/usePhotoEditor.js +638 -0
  325. package/dist/esm/photo/usePhotoEditor.js.map +1 -0
  326. package/dist/esm/pixel/HSVPicker.js +171 -0
  327. package/dist/esm/pixel/HSVPicker.js.map +1 -0
  328. package/dist/esm/pixel/PixelEditor.js +26 -0
  329. package/dist/esm/pixel/PixelEditor.js.map +1 -0
  330. package/dist/esm/pixel/PixelEditor.module.css.js +4 -0
  331. package/dist/esm/pixel/PixelEditor.module.css.js.map +1 -0
  332. package/dist/esm/pixel/PixelEditorCanvas.js +13 -0
  333. package/dist/esm/pixel/PixelEditorCanvas.js.map +1 -0
  334. package/dist/esm/pixel/PixelEditorMenuBar.js +9 -0
  335. package/dist/esm/pixel/PixelEditorMenuBar.js.map +1 -0
  336. package/dist/esm/pixel/PixelEditorRightPanel.js +13 -0
  337. package/dist/esm/pixel/PixelEditorRightPanel.js.map +1 -0
  338. package/dist/esm/pixel/PixelEditorStatusBar.js +13 -0
  339. package/dist/esm/pixel/PixelEditorStatusBar.js.map +1 -0
  340. package/dist/esm/pixel/PixelEditorTimeline.js +9 -0
  341. package/dist/esm/pixel/PixelEditorTimeline.js.map +1 -0
  342. package/dist/esm/pixel/PixelEditorToolbar.js +14 -0
  343. package/dist/esm/pixel/PixelEditorToolbar.js.map +1 -0
  344. package/dist/esm/pixel/asepriteFormat.js +505 -0
  345. package/dist/esm/pixel/asepriteFormat.js.map +1 -0
  346. package/dist/esm/pixel/pixelEditorExports.js +461 -0
  347. package/dist/esm/pixel/pixelEditorExports.js.map +1 -0
  348. package/dist/esm/pixel/pixelEditorTypes.js +90 -0
  349. package/dist/esm/pixel/pixelEditorTypes.js.map +1 -0
  350. package/dist/esm/pixel/pixelEditorUtils.js +631 -0
  351. package/dist/esm/pixel/pixelEditorUtils.js.map +1 -0
  352. package/dist/esm/pixel/usePixelEditor.js +1110 -0
  353. package/dist/esm/pixel/usePixelEditor.js.map +1 -0
  354. package/dist/esm/texture/Nice3DTexturePainter.js +233 -0
  355. package/dist/esm/texture/Nice3DTexturePainter.js.map +1 -0
  356. package/dist/esm/ui/NiceUIDesigner.js +187 -0
  357. package/dist/esm/ui/NiceUIDesigner.js.map +1 -0
  358. package/dist/esm/vector/VectorEditor.js +29 -0
  359. package/dist/esm/vector/VectorEditor.js.map +1 -0
  360. package/dist/esm/vector/VectorEditor.module.css.js +4 -0
  361. package/dist/esm/vector/VectorEditor.module.css.js.map +1 -0
  362. package/dist/esm/vector/VectorEditorMenuBar.js +14 -0
  363. package/dist/esm/vector/VectorEditorMenuBar.js.map +1 -0
  364. package/dist/esm/vector/VectorEditorRightPanel.js +124 -0
  365. package/dist/esm/vector/VectorEditorRightPanel.js.map +1 -0
  366. package/dist/esm/vector/VectorEditorShapeRenderer.js +53 -0
  367. package/dist/esm/vector/VectorEditorShapeRenderer.js.map +1 -0
  368. package/dist/esm/vector/VectorEditorStatusBar.js +12 -0
  369. package/dist/esm/vector/VectorEditorStatusBar.js.map +1 -0
  370. package/dist/esm/vector/useVectorEditor.js +611 -0
  371. package/dist/esm/vector/useVectorEditor.js.map +1 -0
  372. package/dist/esm/vector/vectorBooleanOps.js +507 -0
  373. package/dist/esm/vector/vectorBooleanOps.js.map +1 -0
  374. package/dist/esm/vector/vectorEditorExport.js +152 -0
  375. package/dist/esm/vector/vectorEditorExport.js.map +1 -0
  376. package/dist/esm/vector/vectorEditorImport.js +148 -0
  377. package/dist/esm/vector/vectorEditorImport.js.map +1 -0
  378. package/dist/esm/vector/vectorEditorTypes.js +63 -0
  379. package/dist/esm/vector/vectorEditorTypes.js.map +1 -0
  380. package/dist/esm/vector/vectorGradients.js +193 -0
  381. package/dist/esm/vector/vectorGradients.js.map +1 -0
  382. package/dist/types/__benchmarks__/bench.d.ts +13 -0
  383. package/dist/types/__tests__/setup.d.ts +4 -0
  384. package/dist/types/animation/AnimatedPerson.d.ts +14 -0
  385. package/dist/types/animation/AnimationEditor.d.ts +20 -0
  386. package/dist/types/animation/Audience.d.ts +11 -0
  387. package/dist/types/animation/BodyRenderer.d.ts +12 -0
  388. package/dist/types/animation/animationHelper.d.ts +28 -0
  389. package/dist/types/animation/characterTypes.d.ts +37 -0
  390. package/dist/types/animation/choreoDSL.d.ts +88 -0
  391. package/dist/types/animation/choreography.d.ts +8 -0
  392. package/dist/types/animation/karaokeIntegration.d.ts +31 -0
  393. package/dist/types/animation/lottieExport.d.ts +77 -0
  394. package/dist/types/animation/motionPath.d.ts +60 -0
  395. package/dist/types/animation/physics.d.ts +73 -0
  396. package/dist/types/animation/rig/RigPlayer.d.ts +32 -0
  397. package/dist/types/animation/rig/RiggedBody.d.ts +19 -0
  398. package/dist/types/animation/rig/choreoRigBridge.d.ts +9 -0
  399. package/dist/types/animation/rig/ik.d.ts +8 -0
  400. package/dist/types/animation/rig/poseOps.d.ts +14 -0
  401. package/dist/types/animation/rig/presets.d.ts +13 -0
  402. package/dist/types/animation/rig/rigMath.d.ts +7 -0
  403. package/dist/types/animation/rig/rigTypes.d.ts +38 -0
  404. package/dist/types/animation/shapes/arms.d.ts +10 -0
  405. package/dist/types/animation/shapes/eyes.d.ts +17 -0
  406. package/dist/types/animation/shapes/hair.d.ts +17 -0
  407. package/dist/types/animation/shapes/heads.d.ts +18 -0
  408. package/dist/types/animation/shapes/headwear.d.ts +16 -0
  409. package/dist/types/animation/shapes/legs.d.ts +10 -0
  410. package/dist/types/animation/shapes/mouths.d.ts +17 -0
  411. package/dist/types/animation/shapes/noses.d.ts +17 -0
  412. package/dist/types/animation/shapes/outfits.d.ts +14 -0
  413. package/dist/types/animation/shapes/torsos.d.ts +9 -0
  414. package/dist/types/animation/spineExport.d.ts +66 -0
  415. package/dist/types/core/LocalUI.d.ts +21 -0
  416. package/dist/types/core/collaboration.d.ts +164 -0
  417. package/dist/types/core/colorBlindness.d.ts +24 -0
  418. package/dist/types/core/dragDrop.d.ts +46 -0
  419. package/dist/types/core/fixes.d.ts +80 -0
  420. package/dist/types/core/gridGuides.d.ts +70 -0
  421. package/dist/types/core/historyVisual.d.ts +915 -0
  422. package/dist/types/core/i18n.d.ts +27 -0
  423. package/dist/types/core/integrations.d.ts +103 -0
  424. package/dist/types/core/minimap.d.ts +49 -0
  425. package/dist/types/core/plugins.d.ts +111 -0
  426. package/dist/types/core/rtl.d.ts +32 -0
  427. package/dist/types/core/shortcuts.d.ts +150 -0
  428. package/dist/types/core/theme.d.ts +78 -0
  429. package/dist/types/core/useGamepad.d.ts +64 -0
  430. package/dist/types/core/usePointerPressure.d.ts +88 -0
  431. package/dist/types/font/NiceFontEditor.d.ts +62 -0
  432. package/dist/types/game/AnimationPreviewPlayer.d.ts +29 -0
  433. package/dist/types/game/CollisionEditor.d.ts +101 -0
  434. package/dist/types/game/GameAsset2dEditor.d.ts +17 -0
  435. package/dist/types/game/GameAssetExportPanel.d.ts +20 -0
  436. package/dist/types/game/IsometricEditor.d.ts +22 -0
  437. package/dist/types/game/IsometricTilePanel.d.ts +18 -0
  438. package/dist/types/game/gameAssetExport.d.ts +160 -0
  439. package/dist/types/game/gameAssetTypes.d.ts +238 -0
  440. package/dist/types/game/gameAssetUtils.d.ts +23 -0
  441. package/dist/types/game/index.d.ts +8 -0
  442. package/dist/types/game/isometricTiles.d.ts +250 -0
  443. package/dist/types/game/useAnimationPreview.d.ts +63 -0
  444. package/dist/types/game/useCollisionEditor.d.ts +96 -0
  445. package/dist/types/game/useGameAssetEditor.d.ts +79 -0
  446. package/dist/types/game/useGameAssetExport.d.ts +82 -0
  447. package/dist/types/icon/NiceIconEditor.d.ts +79 -0
  448. package/dist/types/index.d.ts +85 -0
  449. package/dist/types/photo/BatchProcessingPanel.d.ts +13 -0
  450. package/dist/types/photo/FaceDetectionPanel.d.ts +18 -0
  451. package/dist/types/photo/FilterThumb.d.ts +14 -0
  452. package/dist/types/photo/PerspectiveCorrectionPanel.d.ts +17 -0
  453. package/dist/types/photo/PhotoEditor.d.ts +2 -0
  454. package/dist/types/photo/PhotoEditorCanvas.d.ts +14 -0
  455. package/dist/types/photo/PhotoEditorLeftPanel.d.ts +13 -0
  456. package/dist/types/photo/PhotoEditorToolbar.d.ts +13 -0
  457. package/dist/types/photo/RawFilePanel.d.ts +14 -0
  458. package/dist/types/photo/StyleTransferPanel.d.ts +15 -0
  459. package/dist/types/photo/aiStyleTransfer.d.ts +58 -0
  460. package/dist/types/photo/batchProcessing.d.ts +95 -0
  461. package/dist/types/photo/faceDetection.d.ts +103 -0
  462. package/dist/types/photo/index.d.ts +17 -0
  463. package/dist/types/photo/perspectiveCorrection.d.ts +134 -0
  464. package/dist/types/photo/photoEditorActions.d.ts +40 -0
  465. package/dist/types/photo/photoEditorTypes.d.ts +34 -0
  466. package/dist/types/photo/photoFilters.d.ts +55 -0
  467. package/dist/types/photo/photoOverlays.d.ts +126 -0
  468. package/dist/types/photo/photoSelection.d.ts +56 -0
  469. package/dist/types/photo/rawFileSupport.d.ts +124 -0
  470. package/dist/types/photo/usePhotoEditor.d.ts +123 -0
  471. package/dist/types/pixel/HSVPicker.d.ts +11 -0
  472. package/dist/types/pixel/PaletteExtractorPanel.d.ts +16 -0
  473. package/dist/types/pixel/PixelEditor.d.ts +17 -0
  474. package/dist/types/pixel/PixelEditorCanvas.d.ts +10 -0
  475. package/dist/types/pixel/PixelEditorMenuBar.d.ts +11 -0
  476. package/dist/types/pixel/PixelEditorRightPanel.d.ts +11 -0
  477. package/dist/types/pixel/PixelEditorStatusBar.d.ts +11 -0
  478. package/dist/types/pixel/PixelEditorTimeline.d.ts +11 -0
  479. package/dist/types/pixel/PixelEditorToolbar.d.ts +11 -0
  480. package/dist/types/pixel/TileMapPanel.d.ts +14 -0
  481. package/dist/types/pixel/asepriteFormat.d.ts +62 -0
  482. package/dist/types/pixel/paletteExtractor.d.ts +73 -0
  483. package/dist/types/pixel/pixelEditorExports.d.ts +31 -0
  484. package/dist/types/pixel/pixelEditorTypes.d.ts +51 -0
  485. package/dist/types/pixel/pixelEditorUtils.d.ts +136 -0
  486. package/dist/types/pixel/tileMapMode.d.ts +122 -0
  487. package/dist/types/pixel/usePixelEditor.d.ts +114 -0
  488. package/dist/types/texture/Nice3DTexturePainter.d.ts +55 -0
  489. package/dist/types/ui/NiceUIDesigner.d.ts +43 -0
  490. package/dist/types/vector/PathSimplificationPanel.d.ts +15 -0
  491. package/dist/types/vector/PdfExportPanel.d.ts +20 -0
  492. package/dist/types/vector/TextOnPathPanel.d.ts +26 -0
  493. package/dist/types/vector/VectorEditor.d.ts +32 -0
  494. package/dist/types/vector/VectorEditorMenuBar.d.ts +8 -0
  495. package/dist/types/vector/VectorEditorRightPanel.d.ts +7 -0
  496. package/dist/types/vector/VectorEditorShapeRenderer.d.ts +9 -0
  497. package/dist/types/vector/VectorEditorStatusBar.d.ts +9 -0
  498. package/dist/types/vector/VectorFilterPanel.d.ts +19 -0
  499. package/dist/types/vector/VectorPatternPanel.d.ts +21 -0
  500. package/dist/types/vector/pathSimplification.d.ts +135 -0
  501. package/dist/types/vector/pdfExport.d.ts +65 -0
  502. package/dist/types/vector/textOnPath.d.ts +145 -0
  503. package/dist/types/vector/useVectorEditor.d.ts +90 -0
  504. package/dist/types/vector/vectorBooleanOps.d.ts +22 -0
  505. package/dist/types/vector/vectorEditorExport.d.ts +8 -0
  506. package/dist/types/vector/vectorEditorImport.d.ts +7 -0
  507. package/dist/types/vector/vectorEditorTypes.d.ts +47 -0
  508. package/dist/types/vector/vectorGradients.d.ts +64 -0
  509. package/dist/types/vector/vectorPatternFills.d.ts +101 -0
  510. package/dist/types/vector/vectorSvgFilters.d.ts +134 -0
  511. package/package.json +93 -0
@@ -0,0 +1,97 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * colorBlindness.ts — Color blindness simulation modes for editors.
5
+ *
6
+ * Simulates various types of color vision deficiency on canvas content
7
+ * to help designers create accessible graphics.
8
+ */
9
+ // ── Info ─────────────────────────────────────────────────────────
10
+ const COLOR_BLINDNESS_TYPES = [
11
+ { type: "none", label: "Normal Vision", description: "Full color vision", prevalence: "~92%" },
12
+ { type: "deuteranomaly", label: "Deuteranomaly", description: "Reduced sensitivity to green (most common)", prevalence: "~5%" },
13
+ { type: "protanomaly", label: "Protanomaly", description: "Reduced sensitivity to red", prevalence: "~1.3%" },
14
+ { type: "deuteranopia", label: "Deuteranopia", description: "No green cone cells", prevalence: "~1.2%" },
15
+ { type: "protanopia", label: "Protanopia", description: "No red cone cells", prevalence: "~1%" },
16
+ { type: "tritanomaly", label: "Tritanomaly", description: "Reduced sensitivity to blue", prevalence: "~0.01%" },
17
+ { type: "tritanopia", label: "Tritanopia", description: "No blue cone cells", prevalence: "~0.003%" },
18
+ { type: "achromatopsia", label: "Achromatopsia", description: "Monochromatic vision (no color)", prevalence: "~0.003%" },
19
+ { type: "achromatomaly", label: "Achromatomaly", description: "Almost no color vision", prevalence: "~0.001%" },
20
+ ];
21
+ const SIMULATION_MATRICES = {
22
+ none: [1, 0, 0, 0, 1, 0, 0, 0, 1],
23
+ protanopia: [0.567, 0.433, 0.000, 0.558, 0.442, 0.000, 0.000, 0.242, 0.758],
24
+ deuteranopia: [0.625, 0.375, 0.000, 0.700, 0.300, 0.000, 0.000, 0.300, 0.700],
25
+ tritanopia: [0.950, 0.050, 0.000, 0.000, 0.433, 0.567, 0.000, 0.475, 0.525],
26
+ protanomaly: [0.817, 0.183, 0.000, 0.333, 0.667, 0.000, 0.000, 0.125, 0.875],
27
+ deuteranomaly: [0.800, 0.200, 0.000, 0.258, 0.742, 0.000, 0.000, 0.142, 0.858],
28
+ tritanomaly: [0.967, 0.033, 0.000, 0.000, 0.733, 0.267, 0.000, 0.183, 0.817],
29
+ achromatopsia: [0.299, 0.587, 0.114, 0.299, 0.587, 0.114, 0.299, 0.587, 0.114],
30
+ achromatomaly: [0.618, 0.320, 0.062, 0.163, 0.775, 0.062, 0.163, 0.320, 0.516],
31
+ };
32
+ // ── Simulation ──────────────────────────────────────────────────
33
+ /** Apply color blindness simulation to ImageData in-place. */
34
+ function simulateColorBlindness(imageData, type) {
35
+ if (type === "none")
36
+ return imageData;
37
+ const m = SIMULATION_MATRICES[type];
38
+ const data = imageData.data;
39
+ for (let i = 0; i < data.length; i += 4) {
40
+ const r = data[i];
41
+ const g = data[i + 1];
42
+ const b = data[i + 2];
43
+ data[i] = Math.min(255, Math.max(0, Math.round(m[0] * r + m[1] * g + m[2] * b)));
44
+ data[i + 1] = Math.min(255, Math.max(0, Math.round(m[3] * r + m[4] * g + m[5] * b)));
45
+ data[i + 2] = Math.min(255, Math.max(0, Math.round(m[6] * r + m[7] * g + m[8] * b)));
46
+ // Alpha unchanged
47
+ }
48
+ return imageData;
49
+ }
50
+ /** Create a new ImageData with color blindness simulation (non-destructive). */
51
+ function simulateColorBlindnessCopy(source, type) {
52
+ const copy = new ImageData(new Uint8ClampedArray(source.data), source.width, source.height);
53
+ return simulateColorBlindness(copy, type);
54
+ }
55
+ /** Apply color blindness filter to a canvas. */
56
+ function applyColorBlindnessFilter(canvas, type) {
57
+ if (type === "none")
58
+ return;
59
+ const ctx = canvas.getContext("2d");
60
+ if (!ctx)
61
+ return;
62
+ const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
63
+ simulateColorBlindness(imageData, type);
64
+ ctx.putImageData(imageData, 0, 0);
65
+ }
66
+ /** Simulate color blindness on a single RGB color. */
67
+ function simulateColor(r, g, b, type) {
68
+ if (type === "none")
69
+ return [r, g, b];
70
+ const m = SIMULATION_MATRICES[type];
71
+ return [
72
+ Math.min(255, Math.max(0, Math.round(m[0] * r + m[1] * g + m[2] * b))),
73
+ Math.min(255, Math.max(0, Math.round(m[3] * r + m[4] * g + m[5] * b))),
74
+ Math.min(255, Math.max(0, Math.round(m[6] * r + m[7] * g + m[8] * b))),
75
+ ];
76
+ }
77
+ /** Generate an SVG filter for color blindness simulation. */
78
+ function colorBlindnessSvgFilter(type, filterId = "cb-filter") {
79
+ if (type === "none")
80
+ return "";
81
+ const m = SIMULATION_MATRICES[type];
82
+ return `<filter id="${filterId}">
83
+ <feColorMatrix type="matrix" values="
84
+ ${m[0]} ${m[1]} ${m[2]} 0 0
85
+ ${m[3]} ${m[4]} ${m[5]} 0 0
86
+ ${m[6]} ${m[7]} ${m[8]} 0 0
87
+ 0 0 0 1 0" />
88
+ </filter>`;
89
+ }
90
+
91
+ exports.COLOR_BLINDNESS_TYPES = COLOR_BLINDNESS_TYPES;
92
+ exports.applyColorBlindnessFilter = applyColorBlindnessFilter;
93
+ exports.colorBlindnessSvgFilter = colorBlindnessSvgFilter;
94
+ exports.simulateColor = simulateColor;
95
+ exports.simulateColorBlindness = simulateColorBlindness;
96
+ exports.simulateColorBlindnessCopy = simulateColorBlindnessCopy;
97
+ //# sourceMappingURL=colorBlindness.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colorBlindness.js","sources":["../../../src/core/colorBlindness.ts"],"sourcesContent":[null],"names":[],"mappings":";;AA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('react');
4
+
5
+ /**
6
+ * dragDrop.ts — External drag & drop support for editors.
7
+ *
8
+ * Handles file/image drops from the OS or other applications
9
+ * into the editor canvas area.
10
+ */
11
+ // ── File Processing ─────────────────────────────────────────────
12
+ async function fileToImageData(file) {
13
+ if (!file.type.startsWith("image/"))
14
+ return null;
15
+ return new Promise((resolve) => {
16
+ const img = new Image();
17
+ const url = URL.createObjectURL(file);
18
+ img.onload = () => {
19
+ const canvas = document.createElement("canvas");
20
+ canvas.width = img.width;
21
+ canvas.height = img.height;
22
+ const ctx = canvas.getContext("2d");
23
+ if (!ctx) {
24
+ resolve(null);
25
+ return;
26
+ }
27
+ ctx.drawImage(img, 0, 0);
28
+ resolve(ctx.getImageData(0, 0, img.width, img.height));
29
+ URL.revokeObjectURL(url);
30
+ };
31
+ img.onerror = () => { resolve(null); URL.revokeObjectURL(url); };
32
+ img.src = url;
33
+ });
34
+ }
35
+ function validateFile(file, config) {
36
+ var _a;
37
+ const maxSize = (_a = config.maxSize) !== null && _a !== void 0 ? _a : 50 * 1024 * 1024;
38
+ if (file.size > maxSize) {
39
+ return `File "${file.name}" exceeds maximum size of ${Math.round(maxSize / 1024 / 1024)}MB`;
40
+ }
41
+ if (config.accept && config.accept.length > 0) {
42
+ const accepted = config.accept.some((mime) => {
43
+ if (mime.endsWith("/*")) {
44
+ return file.type.startsWith(mime.slice(0, -1));
45
+ }
46
+ return file.type === mime;
47
+ });
48
+ if (!accepted) {
49
+ return `File type "${file.type}" is not accepted`;
50
+ }
51
+ }
52
+ return null;
53
+ }
54
+ /** React hook for handling external file/image drag & drop. */
55
+ function useDragDrop(config) {
56
+ const [isDragging, setIsDragging] = React.useState(false);
57
+ const dragCounter = React.useRef(0);
58
+ const handleDragEnter = React.useCallback((e) => {
59
+ var _a;
60
+ e.preventDefault();
61
+ e.stopPropagation();
62
+ dragCounter.current++;
63
+ if (dragCounter.current === 1) {
64
+ setIsDragging(true);
65
+ (_a = config.onDragEnter) === null || _a === void 0 ? void 0 : _a.call(config);
66
+ }
67
+ }, [config]);
68
+ const handleDragOver = React.useCallback((e) => {
69
+ e.preventDefault();
70
+ e.stopPropagation();
71
+ e.dataTransfer.dropEffect = "copy";
72
+ }, []);
73
+ const handleDragLeave = React.useCallback((e) => {
74
+ var _a;
75
+ e.preventDefault();
76
+ e.stopPropagation();
77
+ dragCounter.current--;
78
+ if (dragCounter.current === 0) {
79
+ setIsDragging(false);
80
+ (_a = config.onDragLeave) === null || _a === void 0 ? void 0 : _a.call(config);
81
+ }
82
+ }, [config]);
83
+ const handleDrop = React.useCallback(async (e) => {
84
+ var _a, _b, _c;
85
+ e.preventDefault();
86
+ e.stopPropagation();
87
+ dragCounter.current = 0;
88
+ setIsDragging(false);
89
+ const dt = e.dataTransfer;
90
+ const maxFiles = (_a = config.maxFiles) !== null && _a !== void 0 ? _a : 10;
91
+ const files = [];
92
+ const urls = [];
93
+ // Collect files
94
+ for (let i = 0; i < Math.min(dt.files.length, maxFiles); i++) {
95
+ const file = dt.files[i];
96
+ const error = validateFile(file, config);
97
+ if (error) {
98
+ (_b = config.onError) === null || _b === void 0 ? void 0 : _b.call(config, error);
99
+ return;
100
+ }
101
+ files.push(file);
102
+ }
103
+ // Collect URLs from text/uri-list
104
+ const uriList = dt.getData("text/uri-list");
105
+ if (uriList) {
106
+ for (const line of uriList.split("\n")) {
107
+ const trimmed = line.trim();
108
+ if (trimmed && !trimmed.startsWith("#")) {
109
+ try {
110
+ new URL(trimmed);
111
+ urls.push(trimmed);
112
+ }
113
+ catch ( /* not a valid URL */_d) { /* not a valid URL */ }
114
+ }
115
+ }
116
+ }
117
+ const text = dt.getData("text/plain") || undefined;
118
+ // Convert image files to ImageData
119
+ const images = [];
120
+ for (const file of files) {
121
+ const imgData = await fileToImageData(file);
122
+ if (imgData)
123
+ images.push(imgData);
124
+ }
125
+ (_c = config.onDrop) === null || _c === void 0 ? void 0 : _c.call(config, { files, images, text, urls });
126
+ }, [config]);
127
+ return {
128
+ isDragging,
129
+ dragProps: {
130
+ onDragEnter: handleDragEnter,
131
+ onDragOver: handleDragOver,
132
+ onDragLeave: handleDragLeave,
133
+ onDrop: handleDrop,
134
+ },
135
+ };
136
+ }
137
+ /** Visual overlay shown when dragging files over the editor. */
138
+ const DropZoneOverlay = ({ isDragging, message }) => {
139
+ if (!isDragging)
140
+ return null;
141
+ return React.createElement("div", {
142
+ style: {
143
+ position: "absolute",
144
+ inset: 0,
145
+ display: "flex",
146
+ alignItems: "center",
147
+ justifyContent: "center",
148
+ background: "rgba(59, 130, 246, 0.15)",
149
+ border: "2px dashed rgba(59, 130, 246, 0.6)",
150
+ borderRadius: 8,
151
+ zIndex: 999,
152
+ pointerEvents: "none",
153
+ },
154
+ }, React.createElement("div", {
155
+ style: {
156
+ padding: "16px 32px",
157
+ background: "rgba(255,255,255,0.95)",
158
+ borderRadius: 8,
159
+ fontSize: 14,
160
+ fontWeight: 600,
161
+ color: "#3b82f6",
162
+ },
163
+ }, message !== null && message !== void 0 ? message : "Drop files here"));
164
+ };
165
+
166
+ exports.DropZoneOverlay = DropZoneOverlay;
167
+ exports.useDragDrop = useDragDrop;
168
+ //# sourceMappingURL=dragDrop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dragDrop.js","sources":["../../../src/core/dragDrop.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAAA;;;;;AAKG;AA6BH;AAEA,eAAe,eAAe,CAAC,IAAU,EAAA;IACvC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;AAAE,QAAA,OAAO,IAAI;AAChD,IAAA,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,KAAI;AAC7B,QAAA,MAAM,GAAG,GAAG,IAAI,KAAK,EAAE;QACvB,MAAM,GAAG,GAAG,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC;AACrC,QAAA,GAAG,CAAC,MAAM,GAAG,MAAK;YAChB,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAA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QAAA,SAAS,EAAE;AACT,YAAA,WAAW,EAAE,eAAe;AAC5B,YAAA,UAAU,EAAE,cAAc;AAC1B,YAAA,WAAW,EAAE,eAAe;AAC5B,YAAA,MAAM,EAAE,UAAU;AACnB,SAAA;KACF;AACH;AASA;AACO,MAAM,eAAe,GAAmC,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,KAAI;AACzF,IAAA,IAAI,CAAC,UAAU;AAAE,QAAA,OAAO,IAAI;AAC5B,IAAA,OAAO,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE;AAChC,QAAA,KAAK,EAAE;AACL,YAAA,QAAQ,EAAE,UAAU;AACpB,YAAA,KAAK,EAAE,CAAC;AACR,YAAA,OAAO,EAAE,MAAM;AACf,YAAA,UAAU,EAAE,QAAQ;AACpB,YAAA,cAAc,EAAE,QAAQ;AACxB,YAAA,UAAU,EAAE,0BAA0B;AACtC,YAAA,MAAM,EAAE,oCAAoC;AAC5C,YAAA,YAAY,EAAE,CAAC;AACf,YAAA,MAAM,EAAE,GAAG;AACX,YAAA,aAAa,EAAE,MAAM;AACtB,SAAA;AACF,KAAA,EACC,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE;AACzB,QAAA,KAAK,EAAE;AACL,YAAA,OAAO,EAAE,WAAW;AACpB,YAAA,UAAU,EAAE,wBAAwB;AACpC,YAAA,YAAY,EAAE,CAAC;AACf,YAAA,QAAQ,EAAE,EAAE;AACZ,YAAA,UAAU,EAAE,GAAG;AACf,YAAA,KAAK,EAAE,SAAS;AACjB,SAAA;KACF,EAAE,OAAO,aAAP,OAAO,KAAA,MAAA,GAAP,OAAO,GAAI,iBAAiB,CAAC,CACjC;AACH;;;;;"}
@@ -0,0 +1,185 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * fixes.ts — Bug fixes and performance patches for editors.
5
+ *
6
+ * - PhotoEditor: Retina/HiDPI canvas devicePixelRatio handling
7
+ * - VectorEditor: Shape virtualization for >100 shapes
8
+ * - AnimationEditor: Memory leak prevention (raf/timer cleanup)
9
+ */
10
+ /**
11
+ * Configure a canvas for Retina/HiDPI displays.
12
+ * Scales the backing store while keeping CSS dimensions intact.
13
+ */
14
+ function setupRetinaCanvas(canvas, options) {
15
+ var _a;
16
+ const dpr = (_a = options.dpr) !== null && _a !== void 0 ? _a : (typeof window !== "undefined" ? window.devicePixelRatio : 1);
17
+ canvas.width = Math.round(options.width * dpr);
18
+ canvas.height = Math.round(options.height * dpr);
19
+ canvas.style.width = `${options.width}px`;
20
+ canvas.style.height = `${options.height}px`;
21
+ const ctx = canvas.getContext("2d");
22
+ ctx.scale(dpr, dpr);
23
+ return ctx;
24
+ }
25
+ /**
26
+ * Get the correct mouse position on a Retina canvas.
27
+ */
28
+ function retinaMousePosition(e, canvas) {
29
+ const rect = canvas.getBoundingClientRect();
30
+ return {
31
+ x: e.clientX - rect.left,
32
+ y: e.clientY - rect.top,
33
+ };
34
+ }
35
+ /**
36
+ * Given a list of shapes with bounding boxes and a visible viewport,
37
+ * returns only the shapes intersecting the viewport.
38
+ */
39
+ function virtualizeShapes(shapes, viewport, margin = 50) {
40
+ const vx = viewport.x - margin;
41
+ const vy = viewport.y - margin;
42
+ const vr = viewport.x + viewport.width + margin;
43
+ const vb = viewport.y + viewport.height + margin;
44
+ return shapes
45
+ .filter(({ bounds: b }) => {
46
+ const bx2 = b.x + b.width;
47
+ const by2 = b.y + b.height;
48
+ return bx2 >= vx && b.x <= vr && by2 >= vy && b.y <= vb;
49
+ })
50
+ .map(({ shape }) => shape);
51
+ }
52
+ /**
53
+ * Spatial hash grid for fast shape lookup.
54
+ * Greatly speeds up rendering and hit-testing with many shapes.
55
+ */
56
+ class SpatialHashGrid {
57
+ constructor(cellSize = 200) {
58
+ this.cellSize = cellSize;
59
+ this.cells = new Map();
60
+ }
61
+ cellKey(cx, cy) {
62
+ return `${cx},${cy}`;
63
+ }
64
+ /** Insert a shape into the grid. */
65
+ insert(shape, bounds) {
66
+ const x0 = Math.floor(bounds.x / this.cellSize);
67
+ const y0 = Math.floor(bounds.y / this.cellSize);
68
+ const x1 = Math.floor((bounds.x + bounds.width) / this.cellSize);
69
+ const y1 = Math.floor((bounds.y + bounds.height) / this.cellSize);
70
+ const vs = { shape, bounds };
71
+ for (let cx = x0; cx <= x1; cx++) {
72
+ for (let cy = y0; cy <= y1; cy++) {
73
+ const key = this.cellKey(cx, cy);
74
+ const cell = this.cells.get(key);
75
+ if (cell)
76
+ cell.push(vs);
77
+ else
78
+ this.cells.set(key, [vs]);
79
+ }
80
+ }
81
+ }
82
+ /** Query shapes overlapping the given viewport. */
83
+ query(viewport) {
84
+ const x0 = Math.floor(viewport.x / this.cellSize);
85
+ const y0 = Math.floor(viewport.y / this.cellSize);
86
+ const x1 = Math.floor((viewport.x + viewport.width) / this.cellSize);
87
+ const y1 = Math.floor((viewport.y + viewport.height) / this.cellSize);
88
+ const seen = new Set();
89
+ const result = [];
90
+ for (let cx = x0; cx <= x1; cx++) {
91
+ for (let cy = y0; cy <= y1; cy++) {
92
+ const cell = this.cells.get(this.cellKey(cx, cy));
93
+ if (!cell)
94
+ continue;
95
+ for (const vs of cell) {
96
+ if (!seen.has(vs.shape)) {
97
+ seen.add(vs.shape);
98
+ result.push(vs.shape);
99
+ }
100
+ }
101
+ }
102
+ }
103
+ return result;
104
+ }
105
+ /** Remove all shapes from the grid. */
106
+ clear() {
107
+ this.cells.clear();
108
+ }
109
+ /** Rebuild the grid from a list of shapes. */
110
+ rebuild(shapes) {
111
+ this.clear();
112
+ for (const vs of shapes)
113
+ this.insert(vs.shape, vs.bounds);
114
+ }
115
+ }
116
+ // ── Animation Memory Leak Prevention ────────────────────────────
117
+ /**
118
+ * Track requestAnimationFrame IDs and timers for proper cleanup.
119
+ */
120
+ class AnimationCleanup {
121
+ constructor() {
122
+ this.rafIds = new Set();
123
+ this.timerIds = new Set();
124
+ this.intervalIds = new Set();
125
+ this.disposed = false;
126
+ }
127
+ /** Wraps requestAnimationFrame with tracking. */
128
+ requestAnimationFrame(cb) {
129
+ if (this.disposed)
130
+ return -1;
131
+ const id = window.requestAnimationFrame((time) => {
132
+ this.rafIds.delete(id);
133
+ if (!this.disposed)
134
+ cb(time);
135
+ });
136
+ this.rafIds.add(id);
137
+ return id;
138
+ }
139
+ /** Wraps setTimeout with tracking. */
140
+ setTimeout(cb, ms) {
141
+ if (this.disposed)
142
+ return null;
143
+ const id = setTimeout(() => {
144
+ this.timerIds.delete(id);
145
+ if (!this.disposed)
146
+ cb();
147
+ }, ms);
148
+ this.timerIds.add(id);
149
+ return id;
150
+ }
151
+ /** Wraps setInterval with tracking. */
152
+ setInterval(cb, ms) {
153
+ if (this.disposed)
154
+ return null;
155
+ const id = setInterval(() => {
156
+ if (this.disposed) {
157
+ clearInterval(id);
158
+ return;
159
+ }
160
+ cb();
161
+ }, ms);
162
+ this.intervalIds.add(id);
163
+ return id;
164
+ }
165
+ /** Cancel all tracked timers and animation frames. */
166
+ dispose() {
167
+ this.disposed = true;
168
+ for (const id of this.rafIds)
169
+ window.cancelAnimationFrame(id);
170
+ for (const id of this.timerIds)
171
+ clearTimeout(id);
172
+ for (const id of this.intervalIds)
173
+ clearInterval(id);
174
+ this.rafIds.clear();
175
+ this.timerIds.clear();
176
+ this.intervalIds.clear();
177
+ }
178
+ }
179
+
180
+ exports.AnimationCleanup = AnimationCleanup;
181
+ exports.SpatialHashGrid = SpatialHashGrid;
182
+ exports.retinaMousePosition = retinaMousePosition;
183
+ exports.setupRetinaCanvas = setupRetinaCanvas;
184
+ exports.virtualizeShapes = virtualizeShapes;
185
+ //# sourceMappingURL=fixes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixes.js","sources":["../../../src/core/fixes.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;;;;AAMG;AAaH;;;AAGG;AACG,SAAU,iBAAiB,CAC/B,MAAyB,EACzB,OAA4B,EAAA;;IAE5B,MAAM,GAAG,GAAG,CAAA,EAAA,GAAA,OAAO,CAAC,GAAG,MAAA,IAAA,IA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