@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,640 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var i18n = require('../core/i18n.js');
5
+ var photoFilters = require('./photoFilters.js');
6
+ var photoOverlays = require('./photoOverlays.js');
7
+ var photoEditorActions = require('./photoEditorActions.js');
8
+
9
+ /**
10
+ * usePhotoEditor.ts — Custom hook encapsulating all PhotoEditor state & logic.
11
+ *
12
+ * Extracts ~500 lines of state, effects, callbacks, and memoised values
13
+ * out of the god-component so that the main component file is pure composition.
14
+ */
15
+ // ── Hook ──
16
+ function usePhotoEditor({ src, playerColor = "#00aaff", onSave, onCancel, initialState }) {
17
+ const { t: _t } = i18n.useNiceTranslation();
18
+ const t = (key, def) => _t(key, def);
19
+ // ── State ──
20
+ // Image
21
+ const [image, setImage] = React.useState(null);
22
+ const [loading, setLoading] = React.useState(true);
23
+ // Tabs
24
+ const [activeTab, setActiveTabRaw] = React.useState("filters");
25
+ const [cropMode, setCropMode] = React.useState(false);
26
+ // Filter
27
+ const [selectedFilter, setSelectedFilter] = React.useState("none");
28
+ const [filterIntensity, setFilterIntensity] = React.useState(1);
29
+ const [filterCategory, setFilterCategory] = React.useState("all");
30
+ const [filterParams] = React.useState({});
31
+ // Adjustments
32
+ const [adjustments, setAdjustments] = React.useState({ ...photoFilters.DEFAULT_ADJUSTMENTS });
33
+ // Transform
34
+ const [rotation, setRotation] = React.useState(0);
35
+ const [flipH, setFlipH] = React.useState(false);
36
+ const [flipV, setFlipV] = React.useState(false);
37
+ // Crop
38
+ const [cropRect, setCropRect] = React.useState(null);
39
+ const [cropAspect, setCropAspect] = React.useState(null);
40
+ const [cropDragging, setCropDragging] = React.useState(null);
41
+ const [cropStart, setCropStart] = React.useState(null);
42
+ // Compare
43
+ const [showCompare, setShowCompare] = React.useState(false);
44
+ const [comparePosition, setComparePosition] = React.useState(50);
45
+ const [compareDragging, setCompareDragging] = React.useState(false);
46
+ // Zoom
47
+ const [zoom, setZoom] = React.useState(1);
48
+ // Overlays
49
+ const [overlays, setOverlays] = React.useState([]);
50
+ const [selectedOverlayId, setSelectedOverlayId] = React.useState(null);
51
+ const [overlayDragging, setOverlayDragging] = React.useState(false);
52
+ const [overlayDragStart, setOverlayDragStart] = React.useState(null);
53
+ // Sticker / emoji
54
+ const [emojiCat, setEmojiCat] = React.useState(photoOverlays.EMOJI_CATALOG[0].id);
55
+ // Text overlay
56
+ const [textDraft, setTextDraft] = React.useState("Tekst");
57
+ const [textColor, setTextColor] = React.useState("#ffffff");
58
+ const [textBold, setTextBold] = React.useState(true);
59
+ const [textItalic, setTextItalic] = React.useState(false);
60
+ const [textOutline, setTextOutline] = React.useState(true);
61
+ const [textFontSize, setTextFontSize] = React.useState(36);
62
+ const [textBg, setTextBg] = React.useState(false);
63
+ // Shape
64
+ const [shapeStroke, setShapeStroke] = React.useState("#ffffff");
65
+ const [shapeFill, setShapeFill] = React.useState("");
66
+ const [shapeStrokeW, setShapeStrokeW] = React.useState(3);
67
+ // Frame
68
+ const [frameColor, setFrameColor] = React.useState("#ffffff");
69
+ const [frameThick, setFrameThick] = React.useState(3);
70
+ // Drawing
71
+ const [drawColor, setDrawColor] = React.useState("#ff0000");
72
+ const [drawWidth, setDrawWidth] = React.useState(4);
73
+ const [isDrawing, setIsDrawing] = React.useState(false);
74
+ const [livePoints, setLivePoints] = React.useState([]);
75
+ const drawingOverlayRef = React.useRef(null);
76
+ // History
77
+ const [history, setHistory] = React.useState([]);
78
+ const [historyIdx, setHistoryIdx] = React.useState(-1);
79
+ const suppressHistoryRef = React.useRef(false);
80
+ // Canvas refs
81
+ const mainCanvasRef = React.useRef(null);
82
+ const compareCanvasRef = React.useRef(null);
83
+ const containerRef = React.useRef(null);
84
+ // ── Derived ──
85
+ const accent = playerColor;
86
+ const accentDim = playerColor + "55";
87
+ const selectedOverlay = React.useMemo(() => { var _a; return (_a = overlays.find(o => o.id === selectedOverlayId)) !== null && _a !== void 0 ? _a : null; }, [overlays, selectedOverlayId]);
88
+ // Tab setter (auto-toggle cropMode)
89
+ const setActiveTab = React.useCallback((tab) => {
90
+ setActiveTabRaw(tab);
91
+ setCropMode(tab === "crop");
92
+ }, []);
93
+ // ── History ──
94
+ const pushHistory = React.useCallback(() => {
95
+ if (suppressHistoryRef.current)
96
+ return;
97
+ const state = {
98
+ selectedFilter,
99
+ filterIntensity,
100
+ adjustments: { ...adjustments },
101
+ rotation,
102
+ flipH,
103
+ flipV,
104
+ cropRect: cropRect ? { ...cropRect } : null,
105
+ overlays: overlays.map(o => ({ ...o })),
106
+ };
107
+ setHistory(prev => [...prev.slice(0, historyIdx + 1), state]);
108
+ setHistoryIdx(prev => prev + 1);
109
+ }, [selectedFilter, filterIntensity, adjustments, rotation, flipH, flipV, cropRect, overlays, historyIdx]);
110
+ const restoreState = React.useCallback((s) => {
111
+ suppressHistoryRef.current = true;
112
+ setSelectedFilter(s.selectedFilter);
113
+ setFilterIntensity(s.filterIntensity);
114
+ setAdjustments({ ...s.adjustments });
115
+ setRotation(s.rotation);
116
+ setFlipH(s.flipH);
117
+ setFlipV(s.flipV);
118
+ setCropRect(s.cropRect ? { ...s.cropRect } : null);
119
+ setOverlays(s.overlays.map(o => ({ ...o })));
120
+ setSelectedOverlayId(null);
121
+ setTimeout(() => { suppressHistoryRef.current = false; }, 50);
122
+ }, []);
123
+ const undo = React.useCallback(() => {
124
+ if (historyIdx > 0) {
125
+ const newIdx = historyIdx - 1;
126
+ setHistoryIdx(newIdx);
127
+ restoreState(history[newIdx]);
128
+ }
129
+ }, [historyIdx, history, restoreState]);
130
+ const redo = React.useCallback(() => {
131
+ if (historyIdx < history.length - 1) {
132
+ const newIdx = historyIdx + 1;
133
+ setHistoryIdx(newIdx);
134
+ restoreState(history[newIdx]);
135
+ }
136
+ }, [historyIdx, history, restoreState]);
137
+ // ── Load image ──
138
+ React.useEffect(() => {
139
+ const img = new Image();
140
+ img.onload = () => {
141
+ setImage(img);
142
+ setLoading(false);
143
+ setCropRect({ x: 0, y: 0, w: img.naturalWidth, h: img.naturalHeight });
144
+ };
145
+ img.onerror = () => setLoading(false);
146
+ if (src instanceof File || src instanceof Blob) {
147
+ img.src = URL.createObjectURL(src);
148
+ }
149
+ else {
150
+ img.crossOrigin = "anonymous";
151
+ img.src = src;
152
+ }
153
+ return () => {
154
+ if (img.src.startsWith("blob:"))
155
+ URL.revokeObjectURL(img.src);
156
+ };
157
+ }, [src]);
158
+ // Push initial history once image loads
159
+ React.useEffect(() => {
160
+ if (image && history.length === 0) {
161
+ if (initialState) {
162
+ const prev = photoOverlays.deserializeEditorState(initialState);
163
+ if (prev) {
164
+ suppressHistoryRef.current = true;
165
+ setSelectedFilter(prev.filter);
166
+ setFilterIntensity(prev.filterIntensity);
167
+ setAdjustments({ ...prev.adjustments });
168
+ setRotation(prev.rotation);
169
+ setFlipH(prev.flipH);
170
+ setFlipV(prev.flipV);
171
+ if (prev.cropRect)
172
+ setCropRect(prev.cropRect);
173
+ if (prev.overlays)
174
+ setOverlays(prev.overlays);
175
+ setTimeout(() => { suppressHistoryRef.current = false; }, 50);
176
+ }
177
+ }
178
+ pushHistory();
179
+ }
180
+ // eslint-disable-next-line react-hooks/exhaustive-deps
181
+ }, [image]);
182
+ // ── Render main canvas ──
183
+ const renderMain = React.useCallback(() => {
184
+ if (!image || !mainCanvasRef.current)
185
+ return;
186
+ photoFilters.renderToCanvas(mainCanvasRef.current, image, selectedFilter, { ...filterParams, intensity: filterIntensity }, adjustments, cropMode ? null : cropRect, rotation, flipH, flipV);
187
+ if (overlays.length > 0 || livePoints.length > 1) {
188
+ const ctx = mainCanvasRef.current.getContext("2d");
189
+ if (ctx) {
190
+ const cw = mainCanvasRef.current.width;
191
+ const ch = mainCanvasRef.current.height;
192
+ if (overlays.length > 0)
193
+ photoOverlays.renderAllOverlays(ctx, overlays, cw, ch);
194
+ if (livePoints.length > 1)
195
+ photoOverlays.renderLiveStroke(ctx, livePoints, drawColor, drawWidth, cw, ch);
196
+ }
197
+ }
198
+ }, [image, selectedFilter, filterParams, filterIntensity, adjustments, cropRect, cropMode, rotation, flipH, flipV, overlays, livePoints, drawColor, drawWidth]);
199
+ React.useEffect(() => { renderMain(); }, [renderMain]);
200
+ // Render compare canvas (original)
201
+ React.useEffect(() => {
202
+ if (!image || !compareCanvasRef.current || !showCompare)
203
+ return;
204
+ const canvas = compareCanvasRef.current;
205
+ const ctx = canvas.getContext("2d");
206
+ if (!ctx)
207
+ return;
208
+ const crop = cropRect !== null && cropRect !== void 0 ? cropRect : { x: 0, y: 0, w: image.naturalWidth, h: image.naturalHeight };
209
+ canvas.width = crop.w;
210
+ canvas.height = crop.h;
211
+ ctx.drawImage(image, crop.x, crop.y, crop.w, crop.h, 0, 0, crop.w, crop.h);
212
+ }, [image, showCompare, cropRect]);
213
+ // ── Filter thumbnails ──
214
+ const filteredList = React.useMemo(() => {
215
+ if (filterCategory === "all")
216
+ return photoFilters.PHOTO_FILTERS;
217
+ return photoFilters.PHOTO_FILTERS.filter(f => f.category === filterCategory || f.id === "none");
218
+ }, [filterCategory]);
219
+ const generateThumbnail = React.useCallback((canvas, filter) => {
220
+ if (!image)
221
+ return;
222
+ const size = 64;
223
+ canvas.width = size;
224
+ canvas.height = size;
225
+ const ctx = canvas.getContext("2d", { willReadFrequently: true });
226
+ if (!ctx)
227
+ return;
228
+ const s = Math.min(image.naturalWidth, image.naturalHeight);
229
+ const sx = (image.naturalWidth - s) / 2;
230
+ const sy = (image.naturalHeight - s) / 2;
231
+ ctx.drawImage(image, sx, sy, s, s, 0, 0, size, size);
232
+ if (filter.id !== "none") {
233
+ const imgData = ctx.getImageData(0, 0, size, size);
234
+ const filtered = filter.apply(imgData, { intensity: 1 });
235
+ ctx.putImageData(filtered, 0, 0);
236
+ }
237
+ }, [image]);
238
+ // ── Crop interaction ──
239
+ const getCanvasScale = React.useCallback(() => {
240
+ if (!mainCanvasRef.current || !containerRef.current || !image)
241
+ return { sx: 1, sy: 1, ox: 0, oy: 0 };
242
+ const rect = mainCanvasRef.current.getBoundingClientRect();
243
+ const cw = mainCanvasRef.current.width;
244
+ const ch = mainCanvasRef.current.height;
245
+ return { sx: cw / rect.width, sy: ch / rect.height, ox: rect.left, oy: rect.top };
246
+ }, [image]);
247
+ const handleCropMouseDown = React.useCallback((e, handle) => {
248
+ e.preventDefault();
249
+ e.stopPropagation();
250
+ setCropDragging(handle);
251
+ setCropStart({ mx: e.clientX, my: e.clientY, rect: { ...cropRect } });
252
+ }, [cropRect]);
253
+ React.useEffect(() => {
254
+ if (!cropDragging || !cropStart || !cropRect || !image)
255
+ return;
256
+ const handleMove = (e) => {
257
+ const scale = getCanvasScale();
258
+ const dx = (e.clientX - cropStart.mx) * scale.sx;
259
+ const dy = (e.clientY - cropStart.my) * scale.sy;
260
+ const r = { ...cropStart.rect };
261
+ const minSize = 20;
262
+ if (cropDragging === "move") {
263
+ r.x = Math.max(0, Math.min(image.naturalWidth - r.w, r.x + dx));
264
+ r.y = Math.max(0, Math.min(image.naturalHeight - r.h, r.y + dy));
265
+ }
266
+ else {
267
+ if (cropDragging.includes("w")) {
268
+ r.x += dx;
269
+ r.w -= dx;
270
+ }
271
+ if (cropDragging.includes("e")) {
272
+ r.w += dx;
273
+ }
274
+ if (cropDragging.includes("n")) {
275
+ r.y += dy;
276
+ r.h -= dy;
277
+ }
278
+ if (cropDragging.includes("s")) {
279
+ r.h += dy;
280
+ }
281
+ if (r.w < minSize) {
282
+ r.w = minSize;
283
+ }
284
+ if (r.h < minSize) {
285
+ r.h = minSize;
286
+ }
287
+ if (cropAspect) {
288
+ if (cropDragging.includes("w") || cropDragging.includes("e")) {
289
+ r.h = r.w / cropAspect;
290
+ }
291
+ else {
292
+ r.w = r.h * cropAspect;
293
+ }
294
+ }
295
+ r.x = Math.max(0, r.x);
296
+ r.y = Math.max(0, r.y);
297
+ r.w = Math.min(r.w, image.naturalWidth - r.x);
298
+ r.h = Math.min(r.h, image.naturalHeight - r.y);
299
+ }
300
+ setCropRect(r);
301
+ setCropStart({ mx: e.clientX, my: e.clientY, rect: r });
302
+ };
303
+ const handleUp = () => {
304
+ setCropDragging(null);
305
+ setCropStart(null);
306
+ pushHistory();
307
+ };
308
+ window.addEventListener("mousemove", handleMove);
309
+ window.addEventListener("mouseup", handleUp);
310
+ return () => {
311
+ window.removeEventListener("mousemove", handleMove);
312
+ window.removeEventListener("mouseup", handleUp);
313
+ };
314
+ }, [cropDragging, cropStart, cropRect, image, cropAspect, getCanvasScale, pushHistory]);
315
+ // Compare slider drag
316
+ React.useEffect(() => {
317
+ if (!compareDragging)
318
+ return;
319
+ const handleMove = (e) => {
320
+ if (!containerRef.current)
321
+ return;
322
+ const rect = containerRef.current.getBoundingClientRect();
323
+ const pct = Math.max(0, Math.min(100, ((e.clientX - rect.left) / rect.width) * 100));
324
+ setComparePosition(pct);
325
+ };
326
+ const handleUp = () => setCompareDragging(false);
327
+ window.addEventListener("mousemove", handleMove);
328
+ window.addEventListener("mouseup", handleUp);
329
+ return () => {
330
+ window.removeEventListener("mousemove", handleMove);
331
+ window.removeEventListener("mouseup", handleUp);
332
+ };
333
+ }, [compareDragging]);
334
+ // ── Keyboard shortcuts ──
335
+ React.useEffect(() => {
336
+ const handleKey = (e) => {
337
+ if (e.ctrlKey && e.key === "z") {
338
+ e.preventDefault();
339
+ undo();
340
+ }
341
+ if (e.ctrlKey && e.key === "y") {
342
+ e.preventDefault();
343
+ redo();
344
+ }
345
+ };
346
+ window.addEventListener("keydown", handleKey);
347
+ return () => window.removeEventListener("keydown", handleKey);
348
+ }, [undo, redo]);
349
+ // ── Adjustments ──
350
+ const handleAdjChange = React.useCallback((key, value) => {
351
+ setAdjustments(prev => ({ ...prev, [key]: value }));
352
+ }, []);
353
+ const handleAdjChangeEnd = React.useCallback(() => pushHistory(), [pushHistory]);
354
+ // ── Overlay helpers ──
355
+ const addOverlay = React.useCallback((ov) => {
356
+ setOverlays(prev => [...prev, ov]);
357
+ setSelectedOverlayId(ov.id);
358
+ setTimeout(() => pushHistory(), 30);
359
+ }, [pushHistory]);
360
+ const updateOverlay = React.useCallback((id, patch) => {
361
+ setOverlays(prev => prev.map(o => o.id === id ? { ...o, ...patch } : o));
362
+ }, []);
363
+ const deleteOverlay = React.useCallback((id) => {
364
+ setOverlays(prev => prev.filter(o => o.id !== id));
365
+ if (selectedOverlayId === id)
366
+ setSelectedOverlayId(null);
367
+ setTimeout(() => pushHistory(), 30);
368
+ }, [selectedOverlayId, pushHistory]);
369
+ const moveOverlayForward = React.useCallback((id) => {
370
+ setOverlays(prev => {
371
+ const idx = prev.findIndex(o => o.id === id);
372
+ if (idx < 0 || idx >= prev.length - 1)
373
+ return prev;
374
+ const copy = [...prev];
375
+ [copy[idx], copy[idx + 1]] = [copy[idx + 1], copy[idx]];
376
+ return copy;
377
+ });
378
+ }, []);
379
+ const moveOverlayBack = React.useCallback((id) => {
380
+ setOverlays(prev => {
381
+ const idx = prev.findIndex(o => o.id === id);
382
+ if (idx <= 0)
383
+ return prev;
384
+ const copy = [...prev];
385
+ [copy[idx - 1], copy[idx]] = [copy[idx], copy[idx - 1]];
386
+ return copy;
387
+ });
388
+ }, []);
389
+ // ── Canvas fraction from mouse event ──
390
+ const getCanvasFraction = React.useCallback((e) => {
391
+ if (!mainCanvasRef.current)
392
+ return { fx: 0.5, fy: 0.5 };
393
+ const rect = mainCanvasRef.current.getBoundingClientRect();
394
+ return {
395
+ fx: Math.max(0, Math.min(1, (e.clientX - rect.left) / rect.width)),
396
+ fy: Math.max(0, Math.min(1, (e.clientY - rect.top) / rect.height)),
397
+ };
398
+ }, []);
399
+ // ── Canvas mouse handlers ──
400
+ const handleCanvasMouseDown = React.useCallback((e) => {
401
+ var _a, _b, _c, _d;
402
+ if (cropMode)
403
+ return;
404
+ const { fx, fy } = getCanvasFraction(e);
405
+ if (activeTab === "draw") {
406
+ e.preventDefault();
407
+ setIsDrawing(true);
408
+ setLivePoints([[fx, fy]]);
409
+ return;
410
+ }
411
+ for (let i = overlays.length - 1; i >= 0; i--) {
412
+ const cw = (_b = (_a = mainCanvasRef.current) === null || _a === void 0 ? void 0 : _a.width) !== null && _b !== void 0 ? _b : 1;
413
+ const ch = (_d = (_c = mainCanvasRef.current) === null || _c === void 0 ? void 0 : _c.height) !== null && _d !== void 0 ? _d : 1;
414
+ if (photoOverlays.hitTestOverlay(overlays[i], fx, fy, cw, ch)) {
415
+ setSelectedOverlayId(overlays[i].id);
416
+ setOverlayDragging(true);
417
+ setOverlayDragStart({ mx: fx, my: fy, ox: overlays[i].x, oy: overlays[i].y });
418
+ e.preventDefault();
419
+ return;
420
+ }
421
+ }
422
+ setSelectedOverlayId(null);
423
+ }, [cropMode, activeTab, getCanvasFraction, overlays]);
424
+ const handleCanvasMouseMove = React.useCallback((e) => {
425
+ const { fx, fy } = getCanvasFraction(e);
426
+ if (isDrawing) {
427
+ setLivePoints(prev => [...prev, [fx, fy]]);
428
+ return;
429
+ }
430
+ if (overlayDragging && overlayDragStart && selectedOverlayId) {
431
+ const dx = fx - overlayDragStart.mx;
432
+ const dy = fy - overlayDragStart.my;
433
+ updateOverlay(selectedOverlayId, {
434
+ x: Math.max(0, Math.min(1, overlayDragStart.ox + dx)),
435
+ y: Math.max(0, Math.min(1, overlayDragStart.oy + dy)),
436
+ });
437
+ }
438
+ }, [getCanvasFraction, isDrawing, overlayDragging, overlayDragStart, selectedOverlayId, updateOverlay]);
439
+ const handleCanvasMouseUp = React.useCallback(() => {
440
+ if (isDrawing && livePoints.length > 1) {
441
+ const stroke = { points: [...livePoints], color: drawColor, width: drawWidth, opacity: 1 };
442
+ if (!drawingOverlayRef.current) {
443
+ const dOv = photoOverlays.createDrawingOverlay();
444
+ dOv.strokes.push(stroke);
445
+ drawingOverlayRef.current = dOv;
446
+ setOverlays(prev => [...prev, dOv]);
447
+ }
448
+ else {
449
+ const id = drawingOverlayRef.current.id;
450
+ setOverlays(prev => prev.map(o => o.id === id && o.type === "drawing"
451
+ ? { ...o, strokes: [...o.strokes, stroke] }
452
+ : o));
453
+ }
454
+ setLivePoints([]);
455
+ setIsDrawing(false);
456
+ pushHistory();
457
+ return;
458
+ }
459
+ setIsDrawing(false);
460
+ setLivePoints([]);
461
+ if (overlayDragging) {
462
+ setOverlayDragging(false);
463
+ setOverlayDragStart(null);
464
+ pushHistory();
465
+ }
466
+ }, [isDrawing, livePoints, drawColor, drawWidth, overlayDragging, pushHistory]);
467
+ // ── Actions ──
468
+ const buildExportParams = React.useCallback(() => {
469
+ if (!image)
470
+ return null;
471
+ return { image, selectedFilter, filterParams, filterIntensity, adjustments, cropRect, rotation, flipH, flipV, overlays };
472
+ }, [image, selectedFilter, filterParams, filterIntensity, adjustments, cropRect, rotation, flipH, flipV, overlays]);
473
+ const handleSave = React.useCallback(async () => {
474
+ if (!image || !mainCanvasRef.current)
475
+ return;
476
+ const exportCanvas = document.createElement("canvas");
477
+ photoFilters.renderToCanvas(exportCanvas, image, selectedFilter, { ...filterParams, intensity: filterIntensity }, adjustments, cropRect, rotation, flipH, flipV);
478
+ if (overlays.length > 0) {
479
+ const ctx = exportCanvas.getContext("2d");
480
+ if (ctx)
481
+ photoOverlays.renderAllOverlays(ctx, overlays, exportCanvas.width, exportCanvas.height);
482
+ }
483
+ const file = await photoFilters.canvasToFile(exportCanvas, "player-photo.jpg", 0.92);
484
+ const editorState = photoOverlays.serializeEditorState({
485
+ filter: selectedFilter,
486
+ filterIntensity,
487
+ adjustments: { ...adjustments },
488
+ rotation,
489
+ flipH,
490
+ flipV,
491
+ cropRect: cropRect ? { ...cropRect } : null,
492
+ overlays,
493
+ });
494
+ onSave(file, editorState);
495
+ }, [image, selectedFilter, filterParams, filterIntensity, adjustments, cropRect, rotation, flipH, flipV, overlays, onSave]);
496
+ const handleReset = React.useCallback(() => {
497
+ setSelectedFilter("none");
498
+ setFilterIntensity(1);
499
+ setAdjustments({ ...photoFilters.DEFAULT_ADJUSTMENTS });
500
+ setRotation(0);
501
+ setFlipH(false);
502
+ setFlipV(false);
503
+ setOverlays([]);
504
+ setSelectedOverlayId(null);
505
+ if (image) {
506
+ setCropRect({ x: 0, y: 0, w: image.naturalWidth, h: image.naturalHeight });
507
+ }
508
+ setCropMode(false);
509
+ setZoom(1);
510
+ pushHistory();
511
+ }, [image, pushHistory]);
512
+ const handleDownload = React.useCallback(async () => {
513
+ const p = buildExportParams();
514
+ if (!p)
515
+ return;
516
+ const blob = await photoEditorActions.getExportBlob(p);
517
+ if (blob)
518
+ photoEditorActions.handleDownloadBlob(blob);
519
+ }, [buildExportParams]);
520
+ const handleCopyToClipboard = React.useCallback(async () => {
521
+ const p = buildExportParams();
522
+ if (!p)
523
+ return;
524
+ await photoEditorActions.handleCopyImageToClipboard(p);
525
+ }, [buildExportParams]);
526
+ const handleShareNative = React.useCallback(async () => {
527
+ const p = buildExportParams();
528
+ if (!p)
529
+ return;
530
+ const blob = await photoEditorActions.getExportBlob(p);
531
+ if (blob)
532
+ await photoEditorActions.handleNativeShare(blob);
533
+ }, [buildExportParams]);
534
+ // ── Return ──
535
+ return {
536
+ t,
537
+ playerColor,
538
+ onCancel,
539
+ accent,
540
+ accentDim,
541
+ image,
542
+ loading,
543
+ activeTab,
544
+ setActiveTab,
545
+ setCropMode,
546
+ selectedFilter,
547
+ setSelectedFilter,
548
+ filterIntensity,
549
+ setFilterIntensity,
550
+ filterCategory,
551
+ setFilterCategory,
552
+ filteredList,
553
+ generateThumbnail,
554
+ adjustments,
555
+ handleAdjChange,
556
+ handleAdjChangeEnd,
557
+ rotation,
558
+ setRotation,
559
+ flipH,
560
+ setFlipH,
561
+ flipV,
562
+ setFlipV,
563
+ zoom,
564
+ setZoom,
565
+ cropMode,
566
+ cropRect,
567
+ setCropRect,
568
+ cropAspect,
569
+ setCropAspect,
570
+ handleCropMouseDown,
571
+ showCompare,
572
+ setShowCompare,
573
+ comparePosition,
574
+ setCompareDragging,
575
+ overlays,
576
+ setOverlays,
577
+ selectedOverlayId,
578
+ setSelectedOverlayId,
579
+ selectedOverlay,
580
+ addOverlay,
581
+ updateOverlay,
582
+ deleteOverlay,
583
+ moveOverlayForward,
584
+ moveOverlayBack,
585
+ emojiCat,
586
+ setEmojiCat,
587
+ textDraft,
588
+ setTextDraft,
589
+ textColor,
590
+ setTextColor,
591
+ textBold,
592
+ setTextBold,
593
+ textItalic,
594
+ setTextItalic,
595
+ textOutline,
596
+ setTextOutline,
597
+ textFontSize,
598
+ setTextFontSize,
599
+ textBg,
600
+ setTextBg,
601
+ shapeStroke,
602
+ setShapeStroke,
603
+ shapeFill,
604
+ setShapeFill,
605
+ shapeStrokeW,
606
+ setShapeStrokeW,
607
+ frameColor,
608
+ setFrameColor,
609
+ frameThick,
610
+ setFrameThick,
611
+ drawColor,
612
+ setDrawColor,
613
+ drawWidth,
614
+ setDrawWidth,
615
+ drawingOverlayRef,
616
+ historyIdx,
617
+ historyLength: history.length,
618
+ undo,
619
+ redo,
620
+ pushHistory,
621
+ handleSave,
622
+ handleReset,
623
+ handleDownload,
624
+ handleCopyToClipboard,
625
+ handleShareNative,
626
+ mainCanvasRef,
627
+ compareCanvasRef,
628
+ containerRef,
629
+ handleCanvasMouseDown,
630
+ handleCanvasMouseMove,
631
+ handleCanvasMouseUp,
632
+ createEmojiOverlay: photoOverlays.createEmojiOverlay,
633
+ createTextOverlay: photoOverlays.createTextOverlay,
634
+ createShapeOverlay: photoOverlays.createShapeOverlay,
635
+ createFrameOverlay: photoOverlays.createFrameOverlay,
636
+ };
637
+ }
638
+
639
+ exports.usePhotoEditor = usePhotoEditor;
640
+ //# sourceMappingURL=usePhotoEditor.js.map