@wordpress/media-editor 0.21.0 → 0.23.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 (432) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/build/components/media-editor/index.cjs +586 -686
  3. package/build/components/media-editor/index.cjs.map +1 -7
  4. package/build/components/media-editor/use-crop-options.cjs +42 -57
  5. package/build/components/media-editor/use-crop-options.cjs.map +1 -7
  6. package/build/components/media-editor/use-save-media-editor.cjs +131 -185
  7. package/build/components/media-editor/use-save-media-editor.cjs.map +1 -7
  8. package/build/components/media-editor-canvas/index.cjs +117 -124
  9. package/build/components/media-editor-canvas/index.cjs.map +1 -7
  10. package/build/components/media-editor-crop-panel/index.cjs +81 -72
  11. package/build/components/media-editor-crop-panel/index.cjs.map +1 -7
  12. package/build/components/media-editor-fine-rotation/index.cjs +61 -72
  13. package/build/components/media-editor-fine-rotation/index.cjs.map +1 -7
  14. package/build/components/media-editor-image-controls/index.cjs +181 -257
  15. package/build/components/media-editor-image-controls/index.cjs.map +1 -7
  16. package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs +120 -157
  17. package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs.map +1 -7
  18. package/build/components/media-editor-modal/index.cjs +112 -155
  19. package/build/components/media-editor-modal/index.cjs.map +1 -7
  20. package/build/components/media-editor-provider/index.cjs +32 -55
  21. package/build/components/media-editor-provider/index.cjs.map +1 -7
  22. package/build/components/media-form/index.cjs +82 -77
  23. package/build/components/media-form/index.cjs.map +1 -7
  24. package/build/components/media-preview/index.cjs +113 -114
  25. package/build/components/media-preview/index.cjs.map +1 -7
  26. package/build/components/rotation-ruler/index.cjs +181 -188
  27. package/build/components/rotation-ruler/index.cjs.map +1 -7
  28. package/build/components/rotation-ruler/use-ruler-drag.cjs +132 -149
  29. package/build/components/rotation-ruler/use-ruler-drag.cjs.map +1 -7
  30. package/build/hooks/use-crop-gesture-handlers.cjs +82 -76
  31. package/build/hooks/use-crop-gesture-handlers.cjs.map +1 -7
  32. package/build/index.cjs +45 -39
  33. package/build/lock-unlock.cjs +9 -35
  34. package/build/lock-unlock.cjs.map +1 -7
  35. package/build/private-apis.cjs +16 -37
  36. package/build/private-apis.cjs.map +1 -7
  37. package/build/state/aspect-ratio-presets.cjs +59 -0
  38. package/build/state/aspect-ratio-presets.cjs.map +1 -0
  39. package/build/state/composite-reducer.cjs +100 -113
  40. package/build/state/composite-reducer.cjs.map +1 -7
  41. package/build/state/index.cjs +22 -45
  42. package/build/state/media-editor-state-provider.cjs +35 -48
  43. package/build/state/media-editor-state-provider.cjs.map +1 -7
  44. package/build/state/types.cjs +11 -31
  45. package/build/state/types.cjs.map +1 -7
  46. package/build/state/use-media-editor-state.cjs +227 -296
  47. package/build/state/use-media-editor-state.cjs.map +1 -7
  48. package/build/store/actions.cjs +17 -44
  49. package/build/store/actions.cjs.map +1 -7
  50. package/build/store/constants.cjs +8 -29
  51. package/build/store/constants.cjs.map +1 -7
  52. package/build/store/index.cjs +33 -40
  53. package/build/store/index.cjs.map +1 -7
  54. package/build/store/reducer.cjs +28 -50
  55. package/build/store/reducer.cjs.map +1 -7
  56. package/build/store/selectors.cjs +16 -41
  57. package/build/store/selectors.cjs.map +1 -7
  58. package/build/utils/get-media-type.cjs +18 -41
  59. package/build/utils/get-media-type.cjs.map +1 -7
  60. package/build/utils/index.cjs +9 -28
  61. package/build-module/components/media-editor/index.mjs +545 -675
  62. package/build-module/components/media-editor/index.mjs.map +1 -7
  63. package/build-module/components/media-editor/use-crop-options.mjs +37 -32
  64. package/build-module/components/media-editor/use-crop-options.mjs.map +1 -7
  65. package/build-module/components/media-editor/use-save-media-editor.mjs +109 -157
  66. package/build-module/components/media-editor/use-save-media-editor.mjs.map +1 -7
  67. package/build-module/components/media-editor-canvas/index.mjs +95 -98
  68. package/build-module/components/media-editor-canvas/index.mjs.map +1 -7
  69. package/build-module/components/media-editor-crop-panel/index.mjs +59 -46
  70. package/build-module/components/media-editor-crop-panel/index.mjs.map +1 -7
  71. package/build-module/components/media-editor-fine-rotation/index.mjs +39 -46
  72. package/build-module/components/media-editor-fine-rotation/index.mjs.map +1 -7
  73. package/build-module/components/media-editor-image-controls/index.mjs +171 -238
  74. package/build-module/components/media-editor-image-controls/index.mjs.map +1 -7
  75. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs +113 -137
  76. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs.map +1 -7
  77. package/build-module/components/media-editor-modal/index.mjs +88 -124
  78. package/build-module/components/media-editor-modal/index.mjs.map +1 -7
  79. package/build-module/components/media-editor-provider/index.mjs +26 -29
  80. package/build-module/components/media-editor-provider/index.mjs.map +1 -7
  81. package/build-module/components/media-form/index.mjs +74 -56
  82. package/build-module/components/media-form/index.mjs.map +1 -7
  83. package/build-module/components/media-preview/index.mjs +105 -90
  84. package/build-module/components/media-preview/index.mjs.map +1 -7
  85. package/build-module/components/rotation-ruler/index.mjs +161 -164
  86. package/build-module/components/rotation-ruler/index.mjs.map +1 -7
  87. package/build-module/components/rotation-ruler/use-ruler-drag.mjs +125 -122
  88. package/build-module/components/rotation-ruler/use-ruler-drag.mjs.map +1 -7
  89. package/build-module/hooks/use-crop-gesture-handlers.mjs +76 -50
  90. package/build-module/hooks/use-crop-gesture-handlers.mjs.map +1 -7
  91. package/build-module/index.mjs +3 -10
  92. package/build-module/lock-unlock.mjs +5 -10
  93. package/build-module/lock-unlock.mjs.map +1 -7
  94. package/build-module/private-apis.mjs +8 -9
  95. package/build-module/private-apis.mjs.map +1 -7
  96. package/build-module/state/aspect-ratio-presets.mjs +53 -0
  97. package/build-module/state/aspect-ratio-presets.mjs.map +1 -0
  98. package/build-module/state/composite-reducer.mjs +80 -91
  99. package/build-module/state/composite-reducer.mjs.map +1 -7
  100. package/build-module/state/index.mjs +3 -26
  101. package/build-module/state/media-editor-state-provider.mjs +29 -24
  102. package/build-module/state/media-editor-state-provider.mjs.map +1 -7
  103. package/build-module/state/types.mjs +7 -7
  104. package/build-module/state/types.mjs.map +1 -7
  105. package/build-module/state/use-media-editor-state.mjs +223 -288
  106. package/build-module/state/use-media-editor-state.mjs.map +1 -7
  107. package/build-module/store/actions.mjs +12 -19
  108. package/build-module/store/actions.mjs.map +1 -7
  109. package/build-module/store/constants.mjs +4 -5
  110. package/build-module/store/constants.mjs.map +1 -7
  111. package/build-module/store/index.mjs +8 -9
  112. package/build-module/store/index.mjs.map +1 -7
  113. package/build-module/store/reducer.mjs +23 -26
  114. package/build-module/store/reducer.mjs.map +1 -7
  115. package/build-module/store/selectors.mjs +8 -13
  116. package/build-module/store/selectors.mjs.map +1 -7
  117. package/build-module/utils/get-media-type.mjs +14 -17
  118. package/build-module/utils/get-media-type.mjs.map +1 -7
  119. package/build-module/utils/index.mjs +1 -6
  120. package/build-style/style-rtl.css +145 -61
  121. package/build-style/style.css +144 -61
  122. package/build-types/components/media-editor/index.d.ts +20 -2
  123. package/build-types/components/media-editor/index.d.ts.map +1 -1
  124. package/build-types/components/media-editor/use-crop-options.d.ts +2 -3
  125. package/build-types/components/media-editor/use-crop-options.d.ts.map +1 -1
  126. package/build-types/components/media-editor/use-save-media-editor.d.ts.map +1 -1
  127. package/build-types/components/media-editor-canvas/index.d.ts +3 -3
  128. package/build-types/components/media-editor-canvas/index.d.ts.map +1 -1
  129. package/build-types/components/media-editor-crop-panel/index.d.ts +1 -1
  130. package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -1
  131. package/build-types/components/media-editor-fine-rotation/index.d.ts.map +1 -1
  132. package/build-types/components/media-editor-image-controls/index.d.ts +1 -1
  133. package/build-types/components/media-editor-image-controls/index.d.ts.map +1 -1
  134. package/build-types/components/media-editor-keyboard-shortcuts-modal/index.d.ts.map +1 -1
  135. package/build-types/components/media-editor-modal/index.d.ts +1 -1
  136. package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
  137. package/build-types/components/media-form/index.d.ts.map +1 -1
  138. package/build-types/components/media-preview/index.d.ts.map +1 -1
  139. package/build-types/components/rotation-ruler/use-ruler-drag.d.ts.map +1 -1
  140. package/build-types/state/aspect-ratio-presets.d.ts +24 -0
  141. package/build-types/state/aspect-ratio-presets.d.ts.map +1 -0
  142. package/build-types/state/composite-reducer.d.ts +17 -19
  143. package/build-types/state/composite-reducer.d.ts.map +1 -1
  144. package/build-types/state/index.d.ts +2 -4
  145. package/build-types/state/index.d.ts.map +1 -1
  146. package/build-types/state/types.d.ts +20 -63
  147. package/build-types/state/types.d.ts.map +1 -1
  148. package/build-types/state/use-media-editor-state.d.ts +33 -52
  149. package/build-types/state/use-media-editor-state.d.ts.map +1 -1
  150. package/package.json +22 -23
  151. package/src/components/media-editor/index.tsx +355 -167
  152. package/src/components/media-editor/style.scss +19 -0
  153. package/src/components/media-editor/use-crop-options.ts +9 -10
  154. package/src/components/media-editor/use-save-media-editor.ts +48 -10
  155. package/src/components/media-editor-canvas/index.tsx +30 -51
  156. package/src/components/media-editor-canvas/style.scss +6 -6
  157. package/src/components/media-editor-crop-panel/index.tsx +38 -2
  158. package/src/components/media-editor-crop-panel/style.scss +21 -0
  159. package/src/components/media-editor-fine-rotation/index.tsx +6 -6
  160. package/src/components/media-editor-image-controls/index.tsx +15 -11
  161. package/src/components/media-editor-keyboard-shortcuts-modal/index.tsx +1 -0
  162. package/src/components/media-editor-keyboard-shortcuts-modal/style.scss +1 -1
  163. package/src/components/media-editor-modal/index.tsx +1 -1
  164. package/src/components/media-editor-modal/style.scss +1 -1
  165. package/src/components/media-form/index.tsx +7 -1
  166. package/src/components/media-preview/index.tsx +65 -23
  167. package/src/components/media-preview/style.scss +16 -2
  168. package/src/components/rotation-ruler/style.scss +9 -5
  169. package/src/components/rotation-ruler/use-ruler-drag.ts +6 -11
  170. package/src/state/README.md +32 -0
  171. package/src/state/aspect-ratio-presets.ts +37 -0
  172. package/src/state/composite-reducer.ts +42 -80
  173. package/src/state/index.ts +2 -17
  174. package/src/state/types.ts +18 -72
  175. package/src/state/use-media-editor-state.ts +155 -238
  176. package/src/style.scss +2 -1
  177. package/build/components/media-editor-modal/build-modifiers.cjs +0 -91
  178. package/build/components/media-editor-modal/build-modifiers.cjs.map +0 -7
  179. package/build/image-editor/core/camera.cjs +0 -225
  180. package/build/image-editor/core/camera.cjs.map +0 -7
  181. package/build/image-editor/core/constants.cjs +0 -108
  182. package/build/image-editor/core/constants.cjs.map +0 -7
  183. package/build/image-editor/core/containment.cjs +0 -276
  184. package/build/image-editor/core/containment.cjs.map +0 -7
  185. package/build/image-editor/core/crop-rect.cjs +0 -48
  186. package/build/image-editor/core/crop-rect.cjs.map +0 -7
  187. package/build/image-editor/core/export/canvas-renderer.cjs +0 -151
  188. package/build/image-editor/core/export/canvas-renderer.cjs.map +0 -7
  189. package/build/image-editor/core/index.cjs +0 -62
  190. package/build/image-editor/core/index.cjs.map +0 -7
  191. package/build/image-editor/core/interaction-controller.cjs +0 -654
  192. package/build/image-editor/core/interaction-controller.cjs.map +0 -7
  193. package/build/image-editor/core/math/rotation.cjs +0 -41
  194. package/build/image-editor/core/math/rotation.cjs.map +0 -7
  195. package/build/image-editor/core/math/sanitize.cjs +0 -92
  196. package/build/image-editor/core/math/sanitize.cjs.map +0 -7
  197. package/build/image-editor/core/setter-helpers.cjs +0 -64
  198. package/build/image-editor/core/setter-helpers.cjs.map +0 -7
  199. package/build/image-editor/core/source-region.cjs +0 -206
  200. package/build/image-editor/core/source-region.cjs.map +0 -7
  201. package/build/image-editor/core/state.cjs +0 -283
  202. package/build/image-editor/core/state.cjs.map +0 -7
  203. package/build/image-editor/core/stencil-math.cjs +0 -216
  204. package/build/image-editor/core/stencil-math.cjs.map +0 -7
  205. package/build/image-editor/core/transform-style.cjs +0 -52
  206. package/build/image-editor/core/transform-style.cjs.map +0 -7
  207. package/build/image-editor/core/transforms/pipeline.cjs +0 -43
  208. package/build/image-editor/core/transforms/pipeline.cjs.map +0 -7
  209. package/build/image-editor/core/types.cjs +0 -19
  210. package/build/image-editor/core/types.cjs.map +0 -7
  211. package/build/image-editor/core/viewport-state.cjs +0 -50
  212. package/build/image-editor/core/viewport-state.cjs.map +0 -7
  213. package/build/image-editor/index.cjs +0 -67
  214. package/build/image-editor/index.cjs.map +0 -7
  215. package/build/image-editor/react/components/cropper-provider.cjs +0 -50
  216. package/build/image-editor/react/components/cropper-provider.cjs.map +0 -7
  217. package/build/image-editor/react/components/cropper.cjs +0 -722
  218. package/build/image-editor/react/components/cropper.cjs.map +0 -7
  219. package/build/image-editor/react/components/index.cjs +0 -36
  220. package/build/image-editor/react/components/index.cjs.map +0 -7
  221. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs +0 -172
  222. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs.map +0 -7
  223. package/build/image-editor/react/components/overlays/dimming-overlay.cjs +0 -62
  224. package/build/image-editor/react/components/overlays/dimming-overlay.cjs.map +0 -7
  225. package/build/image-editor/react/components/overlays/grid-overlay.cjs +0 -91
  226. package/build/image-editor/react/components/overlays/grid-overlay.cjs.map +0 -7
  227. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs +0 -426
  228. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +0 -7
  229. package/build/image-editor/react/components/viewport-provider.cjs +0 -51
  230. package/build/image-editor/react/components/viewport-provider.cjs.map +0 -7
  231. package/build/image-editor/react/hooks/build-cropper-setters.cjs +0 -71
  232. package/build/image-editor/react/hooks/build-cropper-setters.cjs.map +0 -7
  233. package/build/image-editor/react/hooks/index.cjs +0 -34
  234. package/build/image-editor/react/hooks/index.cjs.map +0 -7
  235. package/build/image-editor/react/hooks/use-aria-announcer.cjs +0 -160
  236. package/build/image-editor/react/hooks/use-aria-announcer.cjs.map +0 -7
  237. package/build/image-editor/react/hooks/use-cropper-reducer.cjs +0 -113
  238. package/build/image-editor/react/hooks/use-cropper-reducer.cjs.map +0 -7
  239. package/build/image-editor/react/hooks/use-interaction.cjs +0 -213
  240. package/build/image-editor/react/hooks/use-interaction.cjs.map +0 -7
  241. package/build/image-editor/react/hooks/use-transform-style.cjs +0 -38
  242. package/build/image-editor/react/hooks/use-transform-style.cjs.map +0 -7
  243. package/build/image-editor/react/hooks/use-viewport-state.cjs +0 -51
  244. package/build/image-editor/react/hooks/use-viewport-state.cjs.map +0 -7
  245. package/build/image-editor/react/visually-hidden-style.cjs +0 -41
  246. package/build/image-editor/react/visually-hidden-style.cjs.map +0 -7
  247. package/build/index.cjs.map +0 -7
  248. package/build/state/index.cjs.map +0 -7
  249. package/build/utils/index.cjs.map +0 -7
  250. package/build-module/components/media-editor-modal/build-modifiers.mjs +0 -66
  251. package/build-module/components/media-editor-modal/build-modifiers.mjs.map +0 -7
  252. package/build-module/image-editor/core/camera.mjs +0 -198
  253. package/build-module/image-editor/core/camera.mjs.map +0 -7
  254. package/build-module/image-editor/core/constants.mjs +0 -69
  255. package/build-module/image-editor/core/constants.mjs.map +0 -7
  256. package/build-module/image-editor/core/containment.mjs +0 -253
  257. package/build-module/image-editor/core/containment.mjs.map +0 -7
  258. package/build-module/image-editor/core/crop-rect.mjs +0 -23
  259. package/build-module/image-editor/core/crop-rect.mjs.map +0 -7
  260. package/build-module/image-editor/core/export/canvas-renderer.mjs +0 -120
  261. package/build-module/image-editor/core/export/canvas-renderer.mjs.map +0 -7
  262. package/build-module/image-editor/core/index.mjs +0 -36
  263. package/build-module/image-editor/core/index.mjs.map +0 -7
  264. package/build-module/image-editor/core/interaction-controller.mjs +0 -635
  265. package/build-module/image-editor/core/interaction-controller.mjs.map +0 -7
  266. package/build-module/image-editor/core/math/rotation.mjs +0 -15
  267. package/build-module/image-editor/core/math/rotation.mjs.map +0 -7
  268. package/build-module/image-editor/core/math/sanitize.mjs +0 -63
  269. package/build-module/image-editor/core/math/sanitize.mjs.map +0 -7
  270. package/build-module/image-editor/core/setter-helpers.mjs +0 -39
  271. package/build-module/image-editor/core/setter-helpers.mjs.map +0 -7
  272. package/build-module/image-editor/core/source-region.mjs +0 -178
  273. package/build-module/image-editor/core/source-region.mjs.map +0 -7
  274. package/build-module/image-editor/core/state.mjs +0 -260
  275. package/build-module/image-editor/core/state.mjs.map +0 -7
  276. package/build-module/image-editor/core/stencil-math.mjs +0 -187
  277. package/build-module/image-editor/core/stencil-math.mjs.map +0 -7
  278. package/build-module/image-editor/core/transform-style.mjs +0 -27
  279. package/build-module/image-editor/core/transform-style.mjs.map +0 -7
  280. package/build-module/image-editor/core/transforms/pipeline.mjs +0 -17
  281. package/build-module/image-editor/core/transforms/pipeline.mjs.map +0 -7
  282. package/build-module/image-editor/core/types.mjs +0 -1
  283. package/build-module/image-editor/core/types.mjs.map +0 -7
  284. package/build-module/image-editor/core/viewport-state.mjs +0 -24
  285. package/build-module/image-editor/core/viewport-state.mjs.map +0 -7
  286. package/build-module/image-editor/index.mjs +0 -39
  287. package/build-module/image-editor/index.mjs.map +0 -7
  288. package/build-module/image-editor/react/components/cropper-provider.mjs +0 -26
  289. package/build-module/image-editor/react/components/cropper-provider.mjs.map +0 -7
  290. package/build-module/image-editor/react/components/cropper.mjs +0 -704
  291. package/build-module/image-editor/react/components/cropper.mjs.map +0 -7
  292. package/build-module/image-editor/react/components/index.mjs +0 -9
  293. package/build-module/image-editor/react/components/index.mjs.map +0 -7
  294. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs +0 -147
  295. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs.map +0 -7
  296. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs +0 -37
  297. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs.map +0 -7
  298. package/build-module/image-editor/react/components/overlays/grid-overlay.mjs +0 -66
  299. package/build-module/image-editor/react/components/overlays/grid-overlay.mjs.map +0 -7
  300. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs +0 -414
  301. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs.map +0 -7
  302. package/build-module/image-editor/react/components/viewport-provider.mjs +0 -27
  303. package/build-module/image-editor/react/components/viewport-provider.mjs.map +0 -7
  304. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs +0 -46
  305. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs.map +0 -7
  306. package/build-module/image-editor/react/hooks/index.mjs +0 -8
  307. package/build-module/image-editor/react/hooks/index.mjs.map +0 -7
  308. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs +0 -135
  309. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs.map +0 -7
  310. package/build-module/image-editor/react/hooks/use-cropper-reducer.mjs +0 -100
  311. package/build-module/image-editor/react/hooks/use-cropper-reducer.mjs.map +0 -7
  312. package/build-module/image-editor/react/hooks/use-interaction.mjs +0 -190
  313. package/build-module/image-editor/react/hooks/use-interaction.mjs.map +0 -7
  314. package/build-module/image-editor/react/hooks/use-transform-style.mjs +0 -13
  315. package/build-module/image-editor/react/hooks/use-transform-style.mjs.map +0 -7
  316. package/build-module/image-editor/react/hooks/use-viewport-state.mjs +0 -29
  317. package/build-module/image-editor/react/hooks/use-viewport-state.mjs.map +0 -7
  318. package/build-module/image-editor/react/visually-hidden-style.mjs +0 -16
  319. package/build-module/image-editor/react/visually-hidden-style.mjs.map +0 -7
  320. package/build-module/index.mjs.map +0 -7
  321. package/build-module/state/index.mjs.map +0 -7
  322. package/build-module/utils/index.mjs.map +0 -7
  323. package/build-types/components/media-editor-modal/build-modifiers.d.ts +0 -80
  324. package/build-types/components/media-editor-modal/build-modifiers.d.ts.map +0 -1
  325. package/build-types/image-editor/core/camera.d.ts +0 -128
  326. package/build-types/image-editor/core/camera.d.ts.map +0 -1
  327. package/build-types/image-editor/core/constants.d.ts +0 -99
  328. package/build-types/image-editor/core/constants.d.ts.map +0 -1
  329. package/build-types/image-editor/core/containment.d.ts +0 -72
  330. package/build-types/image-editor/core/containment.d.ts.map +0 -1
  331. package/build-types/image-editor/core/crop-rect.d.ts +0 -16
  332. package/build-types/image-editor/core/crop-rect.d.ts.map +0 -1
  333. package/build-types/image-editor/core/export/canvas-renderer.d.ts +0 -103
  334. package/build-types/image-editor/core/export/canvas-renderer.d.ts.map +0 -1
  335. package/build-types/image-editor/core/index.d.ts +0 -10
  336. package/build-types/image-editor/core/index.d.ts.map +0 -1
  337. package/build-types/image-editor/core/interaction-controller.d.ts +0 -191
  338. package/build-types/image-editor/core/interaction-controller.d.ts.map +0 -1
  339. package/build-types/image-editor/core/math/rotation.d.ts +0 -18
  340. package/build-types/image-editor/core/math/rotation.d.ts.map +0 -1
  341. package/build-types/image-editor/core/math/sanitize.d.ts +0 -67
  342. package/build-types/image-editor/core/math/sanitize.d.ts.map +0 -1
  343. package/build-types/image-editor/core/setter-helpers.d.ts +0 -21
  344. package/build-types/image-editor/core/setter-helpers.d.ts.map +0 -1
  345. package/build-types/image-editor/core/source-region.d.ts +0 -94
  346. package/build-types/image-editor/core/source-region.d.ts.map +0 -1
  347. package/build-types/image-editor/core/state.d.ts +0 -51
  348. package/build-types/image-editor/core/state.d.ts.map +0 -1
  349. package/build-types/image-editor/core/stencil-math.d.ts +0 -102
  350. package/build-types/image-editor/core/stencil-math.d.ts.map +0 -1
  351. package/build-types/image-editor/core/transform-style.d.ts +0 -20
  352. package/build-types/image-editor/core/transform-style.d.ts.map +0 -1
  353. package/build-types/image-editor/core/transforms/pipeline.d.ts +0 -24
  354. package/build-types/image-editor/core/transforms/pipeline.d.ts.map +0 -1
  355. package/build-types/image-editor/core/types.d.ts +0 -269
  356. package/build-types/image-editor/core/types.d.ts.map +0 -1
  357. package/build-types/image-editor/core/viewport-state.d.ts +0 -4
  358. package/build-types/image-editor/core/viewport-state.d.ts.map +0 -1
  359. package/build-types/image-editor/index.d.ts +0 -16
  360. package/build-types/image-editor/index.d.ts.map +0 -1
  361. package/build-types/image-editor/react/components/cropper-provider.d.ts +0 -38
  362. package/build-types/image-editor/react/components/cropper-provider.d.ts.map +0 -1
  363. package/build-types/image-editor/react/components/cropper.d.ts +0 -63
  364. package/build-types/image-editor/react/components/cropper.d.ts.map +0 -1
  365. package/build-types/image-editor/react/components/index.d.ts +0 -4
  366. package/build-types/image-editor/react/components/index.d.ts.map +0 -1
  367. package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts +0 -33
  368. package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts.map +0 -1
  369. package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts +0 -17
  370. package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts.map +0 -1
  371. package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts +0 -27
  372. package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts.map +0 -1
  373. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts +0 -33
  374. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts.map +0 -1
  375. package/build-types/image-editor/react/components/viewport-provider.d.ts +0 -6
  376. package/build-types/image-editor/react/components/viewport-provider.d.ts.map +0 -1
  377. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts +0 -44
  378. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts.map +0 -1
  379. package/build-types/image-editor/react/hooks/index.d.ts +0 -5
  380. package/build-types/image-editor/react/hooks/index.d.ts.map +0 -1
  381. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts +0 -14
  382. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts.map +0 -1
  383. package/build-types/image-editor/react/hooks/use-cropper-reducer.d.ts +0 -55
  384. package/build-types/image-editor/react/hooks/use-cropper-reducer.d.ts.map +0 -1
  385. package/build-types/image-editor/react/hooks/use-interaction.d.ts +0 -65
  386. package/build-types/image-editor/react/hooks/use-interaction.d.ts.map +0 -1
  387. package/build-types/image-editor/react/hooks/use-transform-style.d.ts +0 -13
  388. package/build-types/image-editor/react/hooks/use-transform-style.d.ts.map +0 -1
  389. package/build-types/image-editor/react/hooks/use-viewport-state.d.ts +0 -16
  390. package/build-types/image-editor/react/hooks/use-viewport-state.d.ts.map +0 -1
  391. package/build-types/image-editor/react/visually-hidden-style.d.ts +0 -6
  392. package/build-types/image-editor/react/visually-hidden-style.d.ts.map +0 -1
  393. package/src/components/media-editor-modal/build-modifiers.ts +0 -161
  394. package/src/image-editor/README.md +0 -61
  395. package/src/image-editor/core/camera.ts +0 -429
  396. package/src/image-editor/core/constants.ts +0 -150
  397. package/src/image-editor/core/containment.ts +0 -469
  398. package/src/image-editor/core/crop-rect.ts +0 -42
  399. package/src/image-editor/core/export/canvas-renderer.ts +0 -250
  400. package/src/image-editor/core/index.ts +0 -47
  401. package/src/image-editor/core/interaction-controller.ts +0 -976
  402. package/src/image-editor/core/math/rotation.ts +0 -26
  403. package/src/image-editor/core/math/sanitize.ts +0 -155
  404. package/src/image-editor/core/setter-helpers.ts +0 -63
  405. package/src/image-editor/core/source-region.ts +0 -367
  406. package/src/image-editor/core/state.ts +0 -484
  407. package/src/image-editor/core/stencil-math.ts +0 -379
  408. package/src/image-editor/core/transform-style.ts +0 -56
  409. package/src/image-editor/core/transforms/pipeline.ts +0 -40
  410. package/src/image-editor/core/types.ts +0 -230
  411. package/src/image-editor/core/viewport-state.ts +0 -30
  412. package/src/image-editor/docs/architecture.md +0 -63
  413. package/src/image-editor/docs/recipes.md +0 -184
  414. package/src/image-editor/index.ts +0 -52
  415. package/src/image-editor/react/components/cropper-provider.tsx +0 -70
  416. package/src/image-editor/react/components/cropper.scss +0 -259
  417. package/src/image-editor/react/components/cropper.tsx +0 -1116
  418. package/src/image-editor/react/components/index.ts +0 -3
  419. package/src/image-editor/react/components/overlays/dimensions-overlay.tsx +0 -262
  420. package/src/image-editor/react/components/overlays/dimming-overlay.tsx +0 -55
  421. package/src/image-editor/react/components/overlays/grid-overlay.tsx +0 -77
  422. package/src/image-editor/react/components/stencils/rectangle-stencil.tsx +0 -623
  423. package/src/image-editor/react/components/viewport-provider.tsx +0 -32
  424. package/src/image-editor/react/hooks/build-cropper-setters.ts +0 -102
  425. package/src/image-editor/react/hooks/index.ts +0 -4
  426. package/src/image-editor/react/hooks/use-aria-announcer.ts +0 -193
  427. package/src/image-editor/react/hooks/use-cropper-reducer.ts +0 -197
  428. package/src/image-editor/react/hooks/use-interaction.ts +0 -294
  429. package/src/image-editor/react/hooks/use-transform-style.ts +0 -23
  430. package/src/image-editor/react/hooks/use-viewport-state.ts +0 -41
  431. package/src/image-editor/react/visually-hidden-style.ts +0 -15
  432. package/src/image-editor/style.scss +0 -1
@@ -1,34 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // packages/media-editor/src/image-editor/react/hooks/index.ts
21
- var hooks_exports = {};
22
- __export(hooks_exports, {
23
- buildCropperSetters: () => import_build_cropper_setters.buildCropperSetters,
24
- useCropperReducer: () => import_use_cropper_reducer.useCropperReducer
25
- });
26
- module.exports = __toCommonJS(hooks_exports);
27
- var import_use_cropper_reducer = require("./use-cropper-reducer.cjs");
28
- var import_build_cropper_setters = require("./build-cropper-setters.cjs");
29
- // Annotate the CommonJS export names for ESM import in node:
30
- 0 && (module.exports = {
31
- buildCropperSetters,
32
- useCropperReducer
33
- });
34
- //# sourceMappingURL=index.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../src/image-editor/react/hooks/index.ts"],
4
- "sourcesContent": ["export { useCropperReducer } from './use-cropper-reducer';\nexport type { CropperController } from './use-cropper-reducer';\nexport { buildCropperSetters } from './build-cropper-setters';\nexport type { CropperSetters } from './build-cropper-setters';\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iCAAkC;AAElC,mCAAoC;",
6
- "names": []
7
- }
@@ -1,160 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // packages/media-editor/src/image-editor/react/hooks/use-aria-announcer.ts
21
- var use_aria_announcer_exports = {};
22
- __export(use_aria_announcer_exports, {
23
- useAriaAnnouncer: () => useAriaAnnouncer
24
- });
25
- module.exports = __toCommonJS(use_aria_announcer_exports);
26
- var import_a11y = require("@wordpress/a11y");
27
- var import_element = require("@wordpress/element");
28
- var import_i18n = require("@wordpress/i18n");
29
- var import_source_region = require("../../core/source-region.cjs");
30
- var ARIA_DEBOUNCE_MS = 300;
31
- function getFlipAnnouncement(state, previousState) {
32
- if (!previousState || previousState.flip.horizontal === state.flip.horizontal && previousState.flip.vertical === state.flip.vertical) {
33
- return void 0;
34
- }
35
- const { horizontal, vertical } = state.flip;
36
- if (horizontal && vertical) {
37
- return (0, import_i18n.__)("Flipped horizontally and vertically");
38
- }
39
- if (horizontal) {
40
- return (0, import_i18n.__)("Flipped horizontally");
41
- }
42
- if (vertical) {
43
- return (0, import_i18n.__)("Flipped vertically");
44
- }
45
- return (0, import_i18n.__)("Flip removed");
46
- }
47
- function getRotationAnnouncement(state, previousState) {
48
- if (previousState && Math.round(previousState.rotation) === Math.round(state.rotation)) {
49
- return void 0;
50
- }
51
- const singleFlip = state.flip.horizontal !== state.flip.vertical;
52
- const visualDir = singleFlip ? -1 : 1;
53
- let visualRotation = Math.round(state.rotation) * visualDir % 360;
54
- if (visualRotation > 180) {
55
- visualRotation -= 360;
56
- }
57
- if (visualRotation <= -180) {
58
- visualRotation += 360;
59
- }
60
- if (visualRotation === 0) {
61
- return previousState ? (0, import_i18n.__)("Rotation 0 degrees") : void 0;
62
- }
63
- if (visualRotation > 0) {
64
- return (0, import_i18n.sprintf)(
65
- /* translators: %d: rotation angle in degrees. */
66
- (0, import_i18n.__)("Rotated %d degrees clockwise"),
67
- visualRotation
68
- );
69
- }
70
- return (0, import_i18n.sprintf)(
71
- /* translators: %d: rotation angle in degrees. */
72
- (0, import_i18n.__)("Rotated %d degrees counterclockwise"),
73
- Math.abs(visualRotation)
74
- );
75
- }
76
- function getCropAnnouncement(state, previousState) {
77
- if (!state.image) {
78
- return void 0;
79
- }
80
- const imageSize = {
81
- width: state.image.naturalWidth,
82
- height: state.image.naturalHeight
83
- };
84
- const region = (0, import_source_region.getSourceRegion)(state, imageSize);
85
- if (previousState?.image) {
86
- const previousRegion = (0, import_source_region.getSourceRegion)(
87
- { ...state, cropRect: previousState.cropRect },
88
- imageSize
89
- );
90
- if (Math.round(previousRegion.width) === Math.round(region.width) && Math.round(previousRegion.height) === Math.round(region.height)) {
91
- return void 0;
92
- }
93
- }
94
- return (0, import_i18n.sprintf)(
95
- /* translators: 1: crop width in pixels, 2: crop height in pixels. */
96
- (0, import_i18n.__)("Crop %1$d by %2$d pixels"),
97
- Math.round(region.width),
98
- Math.round(region.height)
99
- );
100
- }
101
- function getZoomAnnouncement(state, previousState) {
102
- if (previousState && Math.round(previousState.zoom * 100) === Math.round(state.zoom * 100)) {
103
- return void 0;
104
- }
105
- return (0, import_i18n.sprintf)(
106
- /* translators: %d: zoom level as a percentage. */
107
- (0, import_i18n.__)("Zoom %d%%"),
108
- Math.round(state.zoom * 100)
109
- );
110
- }
111
- function buildAnnouncement(state, previousState) {
112
- const flip = getFlipAnnouncement(state, previousState);
113
- if (flip) {
114
- return flip;
115
- }
116
- const parts = [
117
- getRotationAnnouncement(state, previousState),
118
- getZoomAnnouncement(state, previousState),
119
- getCropAnnouncement(state, previousState)
120
- ].filter((part) => part !== void 0);
121
- return parts.join(", ");
122
- }
123
- function useAriaAnnouncer(state) {
124
- const timerRef = (0, import_element.useRef)(
125
- void 0
126
- );
127
- const prevMessageRef = (0, import_element.useRef)("");
128
- const prevStateRef = (0, import_element.useRef)(null);
129
- const latestStateRef = (0, import_element.useRef)(state);
130
- (0, import_element.useLayoutEffect)(() => {
131
- latestStateRef.current = state;
132
- }, [state]);
133
- (0, import_element.useEffect)(() => {
134
- clearTimeout(timerRef.current);
135
- timerRef.current = setTimeout(() => {
136
- const current = latestStateRef.current;
137
- const msg = buildAnnouncement(current, prevStateRef.current);
138
- prevStateRef.current = current;
139
- if (msg !== prevMessageRef.current) {
140
- prevMessageRef.current = msg;
141
- (0, import_a11y.speak)(msg);
142
- }
143
- }, ARIA_DEBOUNCE_MS);
144
- return () => {
145
- clearTimeout(timerRef.current);
146
- };
147
- }, [
148
- state.zoom,
149
- state.rotation,
150
- state.cropRect.width,
151
- state.cropRect.height,
152
- state.flip.horizontal,
153
- state.flip.vertical
154
- ]);
155
- }
156
- // Annotate the CommonJS export names for ESM import in node:
157
- 0 && (module.exports = {
158
- useAriaAnnouncer
159
- });
160
- //# sourceMappingURL=use-aria-announcer.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../src/image-editor/react/hooks/use-aria-announcer.ts"],
4
- "sourcesContent": ["import { speak } from '@wordpress/a11y';\nimport { useEffect, useLayoutEffect, useRef } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport type { CropperState } from '../../core/types';\nimport { getSourceRegion } from '../../core/source-region';\n\n/** Debounce delay for ARIA live announcements (ms). */\nconst ARIA_DEBOUNCE_MS = 300;\n\nfunction getFlipAnnouncement(\n\tstate: CropperState,\n\tpreviousState: CropperState | null\n): string | undefined {\n\tif (\n\t\t! previousState ||\n\t\t( previousState.flip.horizontal === state.flip.horizontal &&\n\t\t\tpreviousState.flip.vertical === state.flip.vertical )\n\t) {\n\t\treturn undefined;\n\t}\n\tconst { horizontal, vertical } = state.flip;\n\tif ( horizontal && vertical ) {\n\t\treturn __( 'Flipped horizontally and vertically' );\n\t}\n\tif ( horizontal ) {\n\t\treturn __( 'Flipped horizontally' );\n\t}\n\tif ( vertical ) {\n\t\treturn __( 'Flipped vertically' );\n\t}\n\treturn __( 'Flip removed' );\n}\n\nfunction getRotationAnnouncement(\n\tstate: CropperState,\n\tpreviousState: CropperState | null\n): string | undefined {\n\tif (\n\t\tpreviousState &&\n\t\tMath.round( previousState.rotation ) === Math.round( state.rotation )\n\t) {\n\t\treturn undefined;\n\t}\n\t// Announce the visual rotation — what the user perceives on screen. A\n\t// single-axis flip mirrors the image, reversing the entire on-screen\n\t// rotation relative to the stored field (the same S·R·S inversion the\n\t// reducer applies), so negate the whole angle in that case.\n\tconst singleFlip = state.flip.horizontal !== state.flip.vertical;\n\tconst visualDir = singleFlip ? -1 : 1;\n\t// Normalize to (-180, 180] so the sign indicates direction.\n\tlet visualRotation = ( Math.round( state.rotation ) * visualDir ) % 360;\n\tif ( visualRotation > 180 ) {\n\t\tvisualRotation -= 360;\n\t}\n\tif ( visualRotation <= -180 ) {\n\t\tvisualRotation += 360;\n\t}\n\tif ( visualRotation === 0 ) {\n\t\treturn previousState ? __( 'Rotation 0 degrees' ) : undefined;\n\t}\n\tif ( visualRotation > 0 ) {\n\t\treturn sprintf(\n\t\t\t/* translators: %d: rotation angle in degrees. */\n\t\t\t__( 'Rotated %d degrees clockwise' ),\n\t\t\tvisualRotation\n\t\t);\n\t}\n\treturn sprintf(\n\t\t/* translators: %d: rotation angle in degrees. */\n\t\t__( 'Rotated %d degrees counterclockwise' ),\n\t\tMath.abs( visualRotation )\n\t);\n}\n\nfunction getCropAnnouncement(\n\tstate: CropperState,\n\tpreviousState: CropperState | null\n): string | undefined {\n\tif ( ! state.image ) {\n\t\treturn undefined;\n\t}\n\tconst imageSize = {\n\t\twidth: state.image.naturalWidth,\n\t\theight: state.image.naturalHeight,\n\t};\n\tconst region = getSourceRegion( state, imageSize );\n\t// Announce only when the crop's pixel dimensions change. Measuring both the\n\t// previous and current crop rects under the current rotation and zoom keeps\n\t// the comparison in the same pixel units we announce, and leaves a zoom-only\n\t// change — which doesn't move the crop rect — silent.\n\tif ( previousState?.image ) {\n\t\tconst previousRegion = getSourceRegion(\n\t\t\t{ ...state, cropRect: previousState.cropRect },\n\t\t\timageSize\n\t\t);\n\t\tif (\n\t\t\tMath.round( previousRegion.width ) === Math.round( region.width ) &&\n\t\t\tMath.round( previousRegion.height ) === Math.round( region.height )\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\treturn sprintf(\n\t\t/* translators: 1: crop width in pixels, 2: crop height in pixels. */\n\t\t__( 'Crop %1$d by %2$d pixels' ),\n\t\tMath.round( region.width ),\n\t\tMath.round( region.height )\n\t);\n}\n\nfunction getZoomAnnouncement(\n\tstate: CropperState,\n\tpreviousState: CropperState | null\n): string | undefined {\n\tif (\n\t\tpreviousState &&\n\t\tMath.round( previousState.zoom * 100 ) ===\n\t\t\tMath.round( state.zoom * 100 )\n\t) {\n\t\treturn undefined;\n\t}\n\treturn sprintf(\n\t\t/* translators: %d: zoom level as a percentage. */\n\t\t__( 'Zoom %d%%' ),\n\t\tMath.round( state.zoom * 100 )\n\t);\n}\n\nfunction buildAnnouncement(\n\tstate: CropperState,\n\tpreviousState: CropperState | null\n): string {\n\t// Flip changes are announced alone.\n\tconst flip = getFlipAnnouncement( state, previousState );\n\tif ( flip ) {\n\t\treturn flip;\n\t}\n\n\tconst parts = [\n\t\tgetRotationAnnouncement( state, previousState ),\n\t\tgetZoomAnnouncement( state, previousState ),\n\t\tgetCropAnnouncement( state, previousState ),\n\t].filter( ( part ): part is string => part !== undefined );\n\n\treturn parts.join( ', ' );\n}\n\n/**\n * Debounce and dedupe ARIA-live announcements for screen readers as the\n * cropper state changes. Calls `speak()` from `@wordpress/a11y` to use the\n * centralized, persistent live region instead of a local one that may be\n * dynamically mounted.\n *\n * Debouncing avoids flooding announcements during drag/pointermove bursts;\n * deduping avoids re-announcing the same state.\n *\n * @param state The current cropper state to announce.\n */\nexport function useAriaAnnouncer( state: CropperState ): void {\n\tconst timerRef = useRef< ReturnType< typeof setTimeout > | undefined >(\n\t\tundefined\n\t);\n\tconst prevMessageRef = useRef( '' );\n\tconst prevStateRef = useRef< CropperState | null >( null );\n\tconst latestStateRef = useRef( state );\n\tuseLayoutEffect( () => {\n\t\tlatestStateRef.current = state;\n\t}, [ state ] );\n\n\tuseEffect( () => {\n\t\tclearTimeout( timerRef.current );\n\t\ttimerRef.current = setTimeout( () => {\n\t\t\tconst current = latestStateRef.current;\n\t\t\tconst msg = buildAnnouncement( current, prevStateRef.current );\n\t\t\tprevStateRef.current = current;\n\t\t\tif ( msg !== prevMessageRef.current ) {\n\t\t\t\tprevMessageRef.current = msg;\n\t\t\t\tspeak( msg );\n\t\t\t}\n\t\t}, ARIA_DEBOUNCE_MS );\n\n\t\treturn () => {\n\t\t\tclearTimeout( timerRef.current );\n\t\t};\n\t}, [\n\t\tstate.zoom,\n\t\tstate.rotation,\n\t\tstate.cropRect.width,\n\t\tstate.cropRect.height,\n\t\tstate.flip.horizontal,\n\t\tstate.flip.vertical,\n\t] );\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAsB;AACtB,qBAAmD;AACnD,kBAA4B;AAE5B,2BAAgC;AAGhC,IAAM,mBAAmB;AAEzB,SAAS,oBACR,OACA,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CAAW,MAAM;AAChB,iBAAc,SAAS,OAAQ;AAC/B,aAAS,UAAU,WAAY,MAAM;AACpC,YAAM,UAAU,eAAe;AAC/B,YAAM,MAAM,kBAAmB,SAAS,aAAa,OAAQ;AAC7D,mBAAa,UAAU;AACvB,UAAK,QAAQ,eAAe,SAAU;AACrC,uBAAe,UAAU;AACzB,+BAAO,GAAI;AAAA,MACZ;AAAA,IACD,GAAG,gBAAiB;AAEpB,WAAO,MAAM;AACZ,mBAAc,SAAS,OAAQ;AAAA,IAChC;AAAA,EACD,GAAG;AAAA,IACF,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM,SAAS;AAAA,IACf,MAAM,SAAS;AAAA,IACf,MAAM,KAAK;AAAA,IACX,MAAM,KAAK;AAAA,EACZ,CAAE;AACH;",
6
- "names": []
7
- }
@@ -1,113 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // packages/media-editor/src/image-editor/react/hooks/use-cropper-reducer.ts
21
- var use_cropper_reducer_exports = {};
22
- __export(use_cropper_reducer_exports, {
23
- useCropperReducer: () => useCropperReducer
24
- });
25
- module.exports = __toCommonJS(use_cropper_reducer_exports);
26
- var import_element = require("@wordpress/element");
27
- var import_constants = require("../../core/constants.cjs");
28
- var import_canvas_renderer = require("../../core/export/canvas-renderer.cjs");
29
- var import_state = require("../../core/state.cjs");
30
- var import_build_cropper_setters = require("./build-cropper-setters.cjs");
31
- function areCropperImagesEqual(a, b) {
32
- return a?.src === b?.src && a?.naturalWidth === b?.naturalWidth && a?.naturalHeight === b?.naturalHeight;
33
- }
34
- function useCropperReducer(initialState) {
35
- const [state, dispatch] = (0, import_element.useReducer)(
36
- import_state.cropperReducer,
37
- initialState,
38
- (init) => (0, import_state.enforceContainment)({ ...import_constants.DEFAULT_STATE, ...init })
39
- );
40
- const [initialBaseline, setInitialBaseline] = (0, import_element.useState)(
41
- () => (0, import_state.enforceContainment)({ ...import_constants.DEFAULT_STATE, ...initialState })
42
- );
43
- const stateRef = (0, import_element.useRef)(state);
44
- const dispatchAndSync = (0, import_element.useCallback)((action) => {
45
- const next = (0, import_state.cropperReducer)(stateRef.current, action);
46
- stateRef.current = next;
47
- dispatch(action);
48
- return next;
49
- }, []);
50
- const setImage = (0, import_element.useCallback)(
51
- (image) => {
52
- if (areCropperImagesEqual(stateRef.current.image, image)) {
53
- return;
54
- }
55
- const next = dispatchAndSync({
56
- type: "SET_IMAGE",
57
- payload: image
58
- });
59
- setInitialBaseline(next);
60
- },
61
- [dispatchAndSync]
62
- );
63
- const reset = (0, import_element.useCallback)(
64
- (resetState) => {
65
- const nextInitialState = dispatchAndSync({
66
- type: "RESET",
67
- payload: resetState
68
- });
69
- setInitialBaseline(nextInitialState);
70
- },
71
- [dispatchAndSync]
72
- );
73
- const setters = (0, import_element.useMemo)(
74
- () => (0, import_build_cropper_setters.buildCropperSetters)(dispatchAndSync, () => stateRef.current),
75
- [dispatchAndSync]
76
- );
77
- const isDirty = (0, import_state.isStateDirty)(state, initialBaseline);
78
- const getCroppedImage = (0, import_element.useCallback)(
79
- (mimeType, quality) => {
80
- if (!state.image) {
81
- return Promise.reject(
82
- new Error("No image loaded — call setImage first.")
83
- );
84
- }
85
- return (0, import_canvas_renderer.exportCroppedImage)(
86
- state.image.src,
87
- state,
88
- mimeType,
89
- quality
90
- );
91
- },
92
- [state]
93
- );
94
- const setVisualSize = (0, import_element.useCallback)(() => {
95
- }, []);
96
- const adjustCropRectForViewport = setters.setCropRect;
97
- const controller = {
98
- ...setters,
99
- state,
100
- setImage,
101
- reset,
102
- isDirty,
103
- getCroppedImage,
104
- setVisualSize,
105
- adjustCropRectForViewport
106
- };
107
- return controller;
108
- }
109
- // Annotate the CommonJS export names for ESM import in node:
110
- 0 && (module.exports = {
111
- useCropperReducer
112
- });
113
- //# sourceMappingURL=use-cropper-reducer.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../src/image-editor/react/hooks/use-cropper-reducer.ts"],
4
- "sourcesContent": ["import {\n\tuseReducer,\n\tuseCallback,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport type {\n\tCropperState,\n\tCropperAction,\n\tNormalizedRect,\n\tSize,\n} from '../../core/types';\nimport { DEFAULT_STATE } from '../../core/constants';\nimport { exportCroppedImage } from '../../core/export/canvas-renderer';\nimport {\n\tcropperReducer,\n\tenforceContainment,\n\tisStateDirty,\n} from '../../core/state';\nimport {\n\tbuildCropperSetters,\n\ttype CropperSetters,\n} from './build-cropper-setters';\n\n/**\n * The cropper controller surface — the contract the Cropper component\n * and its interaction hooks consume.\n *\n * History (undo / redo / commitHistory) is intentionally NOT part of\n * this interface. The cropper is a pure state machine; history is a\n * higher-layer concern owned by a composite store\n * (see media-editor/src/state).\n */\nexport interface CropperController extends CropperSetters {\n\t/** The current cropper state (read-only). */\n\tstate: CropperState;\n\t/** Set the loaded image (natural size and src). */\n\tsetImage: ( image: CropperState[ 'image' ] ) => void;\n\t/** Reset the state. Optionally merge partial state overrides. */\n\treset: ( resetState?: Partial< CropperState > ) => void;\n\t/** Whether the current state differs from the initial state. */\n\tisDirty: boolean;\n\t/**\n\t * Export the cropped image as a Blob. Throws on failure — see\n\t * `exportCroppedImage` for error semantics.\n\t */\n\tgetCroppedImage: ( mimeType?: string, quality?: number ) => Promise< Blob >;\n\t/**\n\t * Report the current rendered image size to the controller. The\n\t * Cropper component calls this on visualSize changes; composite\n\t * controllers use it to compute aspect-ratio reshapes. The pure\n\t * cropper hook ignores it (no-op).\n\t */\n\tsetVisualSize: ( size: Size ) => void;\n\t/**\n\t * Adjust the cropRect in response to a viewport change (window\n\t * resize, canvas resize). Behaves like `setCropRect` but, in\n\t * composite controllers, does NOT record an undo entry — viewport\n\t * reshapes aren't editor actions. The pure cropper hook aliases\n\t * this to `setCropRect` (history is a composite concern).\n\t */\n\tadjustCropRectForViewport: ( rect: NormalizedRect ) => void;\n}\n\nfunction areCropperImagesEqual(\n\ta: CropperState[ 'image' ],\n\tb: CropperState[ 'image' ]\n): boolean {\n\treturn (\n\t\ta?.src === b?.src &&\n\t\ta?.naturalWidth === b?.naturalWidth &&\n\t\ta?.naturalHeight === b?.naturalHeight\n\t);\n}\n\n/**\n * Pure reducer hook for the image cropper.\n *\n * Wraps the framework-agnostic `cropperReducer` and exposes named\n * setters (built from the shared `buildCropperSetters` factory).\n * Does NOT manage undo/redo history — that responsibility belongs to\n * the surrounding application (see `useMediaEditorState` for the\n * composite store used by the media editor).\n *\n * @param initialState Optional partial state to merge with DEFAULT_STATE.\n * @return The cropper controller — state, setters, and helpers.\n */\nexport function useCropperReducer(\n\tinitialState?: Partial< CropperState >\n): CropperController {\n\tconst [ state, dispatch ] = useReducer(\n\t\tcropperReducer,\n\t\tinitialState,\n\t\t( init ) => enforceContainment( { ...DEFAULT_STATE, ...init } )\n\t);\n\n\t// The \"clean\" snapshot the current state is compared against for\n\t// `isDirty`. Stored in state (not a ref) so the comparison reads\n\t// a value, not a ref's `current`. `setImage` and `reset` refresh\n\t// this when the consumer establishes a new baseline.\n\tconst [ initialBaseline, setInitialBaseline ] = useState< CropperState >(\n\t\t() => enforceContainment( { ...DEFAULT_STATE, ...initialState } )\n\t);\n\t// Latest-state ref used by setters that need to read fresh state\n\t// (focal-point zoom, toggleFlip, reset, setImage). Updated\n\t// synchronously inside `dispatchAndSync` so multiple actions in\n\t// one event see each other's output before React commits.\n\tconst stateRef = useRef( state );\n\n\tconst dispatchAndSync = useCallback( ( action: CropperAction ) => {\n\t\tconst next = cropperReducer( stateRef.current, action );\n\t\tstateRef.current = next;\n\t\tdispatch( action );\n\t\treturn next;\n\t}, [] );\n\n\tconst setImage = useCallback(\n\t\t( image: CropperState[ 'image' ] ) => {\n\t\t\tif ( areCropperImagesEqual( stateRef.current.image, image ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst next = dispatchAndSync( {\n\t\t\t\ttype: 'SET_IMAGE',\n\t\t\t\tpayload: image,\n\t\t\t} );\n\t\t\t// Refresh the \"clean\" snapshot to match the post-load state\n\t\t\t// produced by the reducer. Otherwise containment can nudge\n\t\t\t// pan/zoom by tiny amounts on load and `isDirty` would\n\t\t\t// report true from the start.\n\t\t\tsetInitialBaseline( next );\n\t\t},\n\t\t[ dispatchAndSync ]\n\t);\n\n\tconst reset = useCallback(\n\t\t( resetState?: Partial< CropperState > ) => {\n\t\t\tconst nextInitialState = dispatchAndSync( {\n\t\t\t\ttype: 'RESET',\n\t\t\t\tpayload: resetState,\n\t\t\t} );\n\t\t\t// Mirror the reducer's RESET exactly so isDirty stays in\n\t\t\t// sync. The containment step can tweak pan/zoom/cropRect by\n\t\t\t// float ulp; fold those into the \"initial\" snapshot or\n\t\t\t// isDirty would report true after a reset.\n\t\t\tsetInitialBaseline( nextInitialState );\n\t\t},\n\t\t[ dispatchAndSync ]\n\t);\n\n\tconst setters = useMemo(\n\t\t() => buildCropperSetters( dispatchAndSync, () => stateRef.current ),\n\t\t[ dispatchAndSync ]\n\t);\n\n\tconst isDirty = isStateDirty( state, initialBaseline );\n\n\tconst getCroppedImage = useCallback(\n\t\t( mimeType?: string, quality?: number ): Promise< Blob > => {\n\t\t\tif ( ! state.image ) {\n\t\t\t\treturn Promise.reject(\n\t\t\t\t\tnew Error( 'No image loaded — call setImage first.' )\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn exportCroppedImage(\n\t\t\t\tstate.image.src,\n\t\t\t\tstate,\n\t\t\t\tmimeType,\n\t\t\t\tquality\n\t\t\t);\n\t\t},\n\t\t[ state ]\n\t);\n\n\t// No-op for the pure hook — visualSize matters only when a\n\t// composite store needs to compute aspect-ratio reshapes\n\t// (see useMediaEditorState). Typed to accept a Size so it\n\t// satisfies the controller surface; the value is intentionally\n\t// ignored.\n\tconst setVisualSize = useCallback( () => {}, [] );\n\n\t// In the pure hook, history isn't a concern — viewport-driven\n\t// reshape is identical to setCropRect.\n\tconst adjustCropRectForViewport = setters.setCropRect;\n\n\tconst controller: CropperController = {\n\t\t...setters,\n\t\tstate,\n\t\tsetImage,\n\t\treset,\n\t\tisDirty,\n\t\tgetCroppedImage,\n\t\tsetVisualSize,\n\t\tadjustCropRectForViewport,\n\t};\n\treturn controller;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAMO;AAOP,uBAA8B;AAC9B,6BAAmC;AACnC,mBAIO;AACP,mCAGO;AA0CP,SAAS,sBACR,GACA,GACU;AACV,SACC,GAAG,QAAQ,GAAG,OACd,GAAG,iBAAiB,GAAG,gBACvB,GAAG,kBAAkB,GAAG;AAE1B;AAcO,SAAS,kBACf,cACoB;AACpB,QAAM,CAAE,OAAO,QAAS,QAAI;AAAA,IAC3B;AAAA,IACA;AAAA,IACA,CAAE,aAAU,iCAAoB,EAAE,GAAG,gCAAe,GAAG,KAAK,CAAE;AAAA,EAC/D;AAMA,QAAM,CAAE,iBAAiB,kBAAmB,QAAI;AAAA,IAC/C,UAAM,iCAAoB,EAAE,GAAG,gCAAe,GAAG,aAAa,CAAE;AAAA,EACjE;AAKA,QAAM,eAAW,uBAAQ,KAAM;AAE/B,QAAM,sBAAkB,4BAAa,CAAE,WAA2B;AACjE,UAAM,WAAO,6BAAgB,SAAS,SAAS,MAAO;AAC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1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // packages/media-editor/src/image-editor/react/hooks/use-interaction.ts
21
- var use_interaction_exports = {};
22
- __export(use_interaction_exports, {
23
- useInteraction: () => useInteraction
24
- });
25
- module.exports = __toCommonJS(use_interaction_exports);
26
- var import_element = require("@wordpress/element");
27
- var import_interaction_controller = require("../../core/interaction-controller.cjs");
28
- var KEYBOARD_INTERACTION_IDLE_MS = 300;
29
- function isHandledKeyboardPan(event) {
30
- switch (event.key) {
31
- case "ArrowUp":
32
- case "ArrowDown":
33
- case "ArrowLeft":
34
- case "ArrowRight":
35
- return true;
36
- default:
37
- return false;
38
- }
39
- }
40
- function isHandledKeyboardZoom(event) {
41
- switch (event.key) {
42
- case "+":
43
- case "=":
44
- case "-":
45
- case "_":
46
- return true;
47
- default:
48
- return false;
49
- }
50
- }
51
- function useInteraction(state, actions, containerSize, imageSize, options) {
52
- const [isDragging, setIsDragging] = (0, import_element.useState)(false);
53
- const [isZooming, setIsZooming] = (0, import_element.useState)(false);
54
- const [isGestureActive, setIsGestureActive] = (0, import_element.useState)(false);
55
- const [isKeyboardPanning, setIsKeyboardPanning] = (0, import_element.useState)(false);
56
- const keyboardInteractionTimerRef = (0, import_element.useRef)(void 0);
57
- const isKeyboardGestureActiveRef = (0, import_element.useRef)(false);
58
- const stateRef = (0, import_element.useRef)(state);
59
- stateRef.current = state;
60
- const containerSizeRef = (0, import_element.useRef)(containerSize);
61
- containerSizeRef.current = containerSize;
62
- const imageSizeRef = (0, import_element.useRef)(imageSize);
63
- imageSizeRef.current = imageSize;
64
- const optionsRef = (0, import_element.useRef)(options);
65
- optionsRef.current = options;
66
- const actionsRef = (0, import_element.useRef)(actions);
67
- actionsRef.current = actions;
68
- const controllerRef = (0, import_element.useRef)(null);
69
- const startPlacementGesture = (0, import_element.useCallback)(() => {
70
- setIsGestureActive(true);
71
- }, []);
72
- const stopPlacementGesture = (0, import_element.useCallback)(() => {
73
- setIsGestureActive(false);
74
- }, []);
75
- const signalKeyboardGesture = (0, import_element.useCallback)(() => {
76
- if (!isKeyboardGestureActiveRef.current) {
77
- isKeyboardGestureActiveRef.current = true;
78
- optionsRef.current?.onGestureStart?.();
79
- }
80
- clearTimeout(keyboardInteractionTimerRef.current);
81
- keyboardInteractionTimerRef.current = setTimeout(() => {
82
- isKeyboardGestureActiveRef.current = false;
83
- setIsKeyboardPanning(false);
84
- optionsRef.current?.onGestureEnd?.();
85
- }, KEYBOARD_INTERACTION_IDLE_MS);
86
- }, []);
87
- (0, import_element.useEffect)(() => {
88
- return () => {
89
- clearTimeout(keyboardInteractionTimerRef.current);
90
- };
91
- }, []);
92
- (0, import_element.useEffect)(() => {
93
- const controller = new import_interaction_controller.InteractionController({
94
- getState: () => stateRef.current,
95
- actions: {
96
- setPan: (pan) => actionsRef.current.setPan(pan),
97
- setZoom: (zoom) => actionsRef.current.setZoom(zoom),
98
- setZoomAtPoint: (zoom, pan) => actionsRef.current.setZoomAtPoint(zoom, pan),
99
- snapRotate90: (direction) => actionsRef.current.snapRotate90(direction),
100
- toggleFlip: (direction) => actionsRef.current.toggleFlip?.(direction)
101
- },
102
- getContainerSize: () => containerSizeRef.current,
103
- getImageSize: () => imageSizeRef.current,
104
- get minZoom() {
105
- return optionsRef.current?.minZoom;
106
- },
107
- get maxZoom() {
108
- return optionsRef.current?.maxZoom;
109
- },
110
- get zoomSpeed() {
111
- return optionsRef.current?.zoomSpeed;
112
- },
113
- get keyboardStep() {
114
- return optionsRef.current?.keyboardStep;
115
- },
116
- get doubleTapZoom() {
117
- return optionsRef.current?.doubleTapZoom;
118
- },
119
- onGestureStart: () => {
120
- startPlacementGesture();
121
- optionsRef.current?.onGestureStart?.();
122
- },
123
- onGestureEnd: () => {
124
- stopPlacementGesture();
125
- optionsRef.current?.onGestureEnd?.();
126
- },
127
- onStatusChange: (status) => {
128
- setIsDragging(status.isDragging);
129
- setIsZooming(status.isZooming);
130
- }
131
- });
132
- controllerRef.current = controller;
133
- return () => {
134
- controller.destroy();
135
- controllerRef.current = null;
136
- };
137
- }, [startPlacementGesture, stopPlacementGesture]);
138
- const isDisabled = options?.disabled ?? false;
139
- (0, import_element.useEffect)(() => {
140
- if (!isDisabled) {
141
- return;
142
- }
143
- controllerRef.current?.destroy();
144
- setIsDragging(false);
145
- setIsZooming(false);
146
- setIsKeyboardPanning(false);
147
- const wasGestureOpen = isGestureActive || isKeyboardGestureActiveRef.current;
148
- if (isKeyboardGestureActiveRef.current) {
149
- isKeyboardGestureActiveRef.current = false;
150
- clearTimeout(keyboardInteractionTimerRef.current);
151
- }
152
- stopPlacementGesture();
153
- if (wasGestureOpen) {
154
- optionsRef.current?.onGestureEnd?.();
155
- }
156
- }, [isDisabled, isGestureActive, stopPlacementGesture]);
157
- const onPointerDown = (0, import_element.useCallback)((e) => {
158
- if (optionsRef.current?.disabled) {
159
- return;
160
- }
161
- const el = e.currentTarget;
162
- controllerRef.current?.handlePointerDown(e.nativeEvent, el);
163
- }, []);
164
- const onTouchStart = (0, import_element.useCallback)((e) => {
165
- if (optionsRef.current?.disabled) {
166
- return;
167
- }
168
- const el = e.currentTarget;
169
- const rect = el.getBoundingClientRect();
170
- controllerRef.current?.handleTouchStart(
171
- e.nativeEvent,
172
- rect,
173
- el.ownerDocument
174
- );
175
- }, []);
176
- const onKeyDown = (0, import_element.useCallback)(
177
- (e) => {
178
- if (optionsRef.current?.disabled) {
179
- return;
180
- }
181
- if (isHandledKeyboardPan(e.nativeEvent)) {
182
- setIsKeyboardPanning(true);
183
- signalKeyboardGesture();
184
- } else if (isHandledKeyboardZoom(e.nativeEvent)) {
185
- signalKeyboardGesture();
186
- }
187
- controllerRef.current?.handleKeyDown(e.nativeEvent);
188
- },
189
- [signalKeyboardGesture]
190
- );
191
- const onWheelNative = (0, import_element.useCallback)((e) => {
192
- if (optionsRef.current?.disabled) {
193
- return;
194
- }
195
- controllerRef.current?.handleWheel(e);
196
- }, []);
197
- return {
198
- handlers: {
199
- onPointerDown,
200
- onTouchStart,
201
- onKeyDown
202
- },
203
- onWheelNative,
204
- isDragging,
205
- isZooming,
206
- isPlacementActive: isGestureActive || isKeyboardPanning || isZooming
207
- };
208
- }
209
- // Annotate the CommonJS export names for ESM import in node:
210
- 0 && (module.exports = {
211
- useInteraction
212
- });
213
- //# sourceMappingURL=use-interaction.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../src/image-editor/react/hooks/use-interaction.ts"],
4
- "sourcesContent": ["import { useCallback, useEffect, useRef, useState } from '@wordpress/element';\nimport type { CropperState, Size } from '../../core/types';\nimport {\n\tInteractionController,\n\ttype CropperInteractionActions,\n} from '../../core/interaction-controller';\n\n/**\n * The return type of the useInteraction hook.\n */\nexport interface UseInteractionReturn {\n\t/** Event handler props to spread on the container element. */\n\thandlers: {\n\t\tonPointerDown: ( e: React.PointerEvent ) => void;\n\t\tonTouchStart: ( e: React.TouchEvent ) => void;\n\t\tonKeyDown: ( e: React.KeyboardEvent ) => void;\n\t};\n\t/** Native wheel handler — must be registered with { passive: false }. */\n\tonWheelNative: ( e: WheelEvent ) => void;\n\t/** Whether a drag (pan) interaction is in progress. */\n\tisDragging: boolean;\n\t/** Whether a double-tap zoom animation is in progress. */\n\tisZooming: boolean;\n\t/** Whether the user is currently performing a placement interaction. */\n\tisPlacementActive: boolean;\n}\n\n/**\n * Options for the useInteraction hook.\n */\nexport interface UseInteractionOptions {\n\t/** Minimum zoom level. Defaults to MIN_ZOOM. */\n\tminZoom?: number;\n\t/** Maximum zoom level. Defaults to MAX_ZOOM. */\n\tmaxZoom?: number;\n\t/** Zoom speed multiplier for wheel events. Defaults to 0.0025. */\n\tzoomSpeed?: number;\n\t/**\n\t * Pan step size in normalized coords for keyboard events.\n\t * Defaults to 0.01. Shift multiplies it by 10.\n\t */\n\tkeyboardStep?: number;\n\t/** Zoom level for double-tap zoom. Defaults to 2. */\n\tdoubleTapZoom?: number;\n\t/** Fires when a continuous gesture begins (pan drag, pinch zoom). */\n\tonGestureStart?: () => void;\n\t/** Fires when a continuous gesture ends (pointer release). */\n\tonGestureEnd?: () => void;\n\t/**\n\t * Ignore all interaction. Any gesture already in flight is torn down,\n\t * so a drag started before this flipped cannot keep moving the image.\n\t */\n\tdisabled?: boolean;\n}\n\n/** How long keyboard placement stays active after the latest handled key. */\nconst KEYBOARD_INTERACTION_IDLE_MS = 300;\n\nfunction isHandledKeyboardPan( event: KeyboardEvent ): boolean {\n\tswitch ( event.key ) {\n\t\tcase 'ArrowUp':\n\t\tcase 'ArrowDown':\n\t\tcase 'ArrowLeft':\n\t\tcase 'ArrowRight':\n\t\t\treturn true;\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\nfunction isHandledKeyboardZoom( event: KeyboardEvent ): boolean {\n\tswitch ( event.key ) {\n\t\tcase '+':\n\t\tcase '=':\n\t\tcase '-':\n\t\tcase '_':\n\t\t\treturn true;\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\n/**\n * Mouse, touch, and keyboard event handling for pan, zoom,\n * and crop manipulation.\n *\n * Returns event handler props to spread on the container element.\n * Uses requestAnimationFrame for drag/pinch updates to avoid\n * layout thrashing.\n *\n * @param state The current cropper state.\n * @param actions Named state updates for cropper interactions.\n * @param containerSize The container dimensions in pixels.\n * @param imageSize The rendered image dimensions in pixels.\n * @param options Optional configuration for zoom and keyboard behavior.\n * @return Event handler props for the container element.\n */\nexport function useInteraction(\n\tstate: CropperState,\n\tactions: CropperInteractionActions,\n\tcontainerSize: Size,\n\timageSize?: Size,\n\toptions?: UseInteractionOptions\n): UseInteractionReturn {\n\tconst [ isDragging, setIsDragging ] = useState( false );\n\tconst [ isZooming, setIsZooming ] = useState( false );\n\tconst [ isGestureActive, setIsGestureActive ] = useState( false );\n\tconst [ isKeyboardPanning, setIsKeyboardPanning ] = useState( false );\n\tconst keyboardInteractionTimerRef = useRef<\n\t\tReturnType< typeof setTimeout > | undefined\n\t>( undefined );\n\t// Tracks whether a keyboard gesture (pan or zoom) is currently active so\n\t// onGestureStart is only fired once per gesture, not on every key repeat.\n\tconst isKeyboardGestureActiveRef = useRef( false );\n\n\t// Keep mutable refs so the controller always reads fresh values\n\t// without needing to be recreated.\n\tconst stateRef = useRef( state );\n\tstateRef.current = state;\n\tconst containerSizeRef = useRef( containerSize );\n\tcontainerSizeRef.current = containerSize;\n\tconst imageSizeRef = useRef( imageSize );\n\timageSizeRef.current = imageSize;\n\tconst optionsRef = useRef( options );\n\toptionsRef.current = options;\n\tconst actionsRef = useRef( actions );\n\tactionsRef.current = actions;\n\n\tconst controllerRef = useRef< InteractionController | null >( null );\n\tconst startPlacementGesture = useCallback( () => {\n\t\tsetIsGestureActive( true );\n\t}, [] );\n\tconst stopPlacementGesture = useCallback( () => {\n\t\tsetIsGestureActive( false );\n\t}, [] );\n\t// Shared timer logic for any keyboard gesture (pan or zoom): fires\n\t// onGestureStart once per burst and onGestureEnd after the idle window.\n\tconst signalKeyboardGesture = useCallback( () => {\n\t\tif ( ! isKeyboardGestureActiveRef.current ) {\n\t\t\tisKeyboardGestureActiveRef.current = true;\n\t\t\toptionsRef.current?.onGestureStart?.();\n\t\t}\n\t\tclearTimeout( keyboardInteractionTimerRef.current );\n\t\tkeyboardInteractionTimerRef.current = setTimeout( () => {\n\t\t\tisKeyboardGestureActiveRef.current = false;\n\t\t\tsetIsKeyboardPanning( false );\n\t\t\toptionsRef.current?.onGestureEnd?.();\n\t\t}, KEYBOARD_INTERACTION_IDLE_MS );\n\t}, [] );\n\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tclearTimeout( keyboardInteractionTimerRef.current );\n\t\t};\n\t}, [] );\n\n\t// Create / destroy the controller. The controller reads all volatile\n\t// values through refs, so it can stay mounted across render updates.\n\tuseEffect( () => {\n\t\tconst controller = new InteractionController( {\n\t\t\tgetState: () => stateRef.current,\n\t\t\tactions: {\n\t\t\t\tsetPan: ( pan ) => actionsRef.current.setPan( pan ),\n\t\t\t\tsetZoom: ( zoom ) => actionsRef.current.setZoom( zoom ),\n\t\t\t\tsetZoomAtPoint: ( zoom, pan ) =>\n\t\t\t\t\tactionsRef.current.setZoomAtPoint( zoom, pan ),\n\t\t\t\tsnapRotate90: ( direction ) =>\n\t\t\t\t\tactionsRef.current.snapRotate90( direction ),\n\t\t\t\ttoggleFlip: ( direction ) =>\n\t\t\t\t\tactionsRef.current.toggleFlip?.( direction ),\n\t\t\t},\n\t\t\tgetContainerSize: () => containerSizeRef.current,\n\t\t\tgetImageSize: () => imageSizeRef.current,\n\t\t\tget minZoom() {\n\t\t\t\treturn optionsRef.current?.minZoom;\n\t\t\t},\n\t\t\tget maxZoom() {\n\t\t\t\treturn optionsRef.current?.maxZoom;\n\t\t\t},\n\t\t\tget zoomSpeed() {\n\t\t\t\treturn optionsRef.current?.zoomSpeed;\n\t\t\t},\n\t\t\tget keyboardStep() {\n\t\t\t\treturn optionsRef.current?.keyboardStep;\n\t\t\t},\n\t\t\tget doubleTapZoom() {\n\t\t\t\treturn optionsRef.current?.doubleTapZoom;\n\t\t\t},\n\t\t\tonGestureStart: () => {\n\t\t\t\tstartPlacementGesture();\n\t\t\t\toptionsRef.current?.onGestureStart?.();\n\t\t\t},\n\t\t\tonGestureEnd: () => {\n\t\t\t\tstopPlacementGesture();\n\t\t\t\toptionsRef.current?.onGestureEnd?.();\n\t\t\t},\n\t\t\tonStatusChange: ( status ) => {\n\t\t\t\tsetIsDragging( status.isDragging );\n\t\t\t\tsetIsZooming( status.isZooming );\n\t\t\t},\n\t\t} );\n\t\tcontrollerRef.current = controller;\n\t\treturn () => {\n\t\t\tcontroller.destroy();\n\t\t\tcontrollerRef.current = null;\n\t\t};\n\t}, [ startPlacementGesture, stopPlacementGesture ] );\n\n\t// Cancel any gesture already in flight when interaction is switched off,\n\t// so a drag that started before the flip cannot keep moving the image.\n\t// `destroy()` releases the pointer/touch listeners and the pending rAF;\n\t// the controller keeps working for later gestures once re-enabled.\n\t//\n\t// It does not signal the end of the gesture it just cut short, so that\n\t// is done here: a caller told a gesture began is otherwise left waiting\n\t// for an end that never comes, which keeps undo/redo disabled and leaves\n\t// the cropper's history batch open after a failed save.\n\tconst isDisabled = options?.disabled ?? false;\n\tuseEffect( () => {\n\t\tif ( ! isDisabled ) {\n\t\t\treturn;\n\t\t}\n\t\tcontrollerRef.current?.destroy();\n\t\tsetIsDragging( false );\n\t\tsetIsZooming( false );\n\t\tsetIsKeyboardPanning( false );\n\t\tconst wasGestureOpen =\n\t\t\tisGestureActive || isKeyboardGestureActiveRef.current;\n\t\tif ( isKeyboardGestureActiveRef.current ) {\n\t\t\tisKeyboardGestureActiveRef.current = false;\n\t\t\tclearTimeout( keyboardInteractionTimerRef.current );\n\t\t}\n\t\tstopPlacementGesture();\n\t\tif ( wasGestureOpen ) {\n\t\t\toptionsRef.current?.onGestureEnd?.();\n\t\t}\n\t}, [ isDisabled, isGestureActive, stopPlacementGesture ] );\n\n\tconst onPointerDown = useCallback( ( e: React.PointerEvent ) => {\n\t\tif ( optionsRef.current?.disabled ) {\n\t\t\treturn;\n\t\t}\n\t\tconst el = e.currentTarget as HTMLElement;\n\t\tcontrollerRef.current?.handlePointerDown( e.nativeEvent, el );\n\t}, [] );\n\n\tconst onTouchStart = useCallback( ( e: React.TouchEvent ) => {\n\t\tif ( optionsRef.current?.disabled ) {\n\t\t\treturn;\n\t\t}\n\t\tconst el = e.currentTarget as HTMLElement;\n\t\tconst rect = el.getBoundingClientRect();\n\t\tcontrollerRef.current?.handleTouchStart(\n\t\t\te.nativeEvent,\n\t\t\trect,\n\t\t\tel.ownerDocument\n\t\t);\n\t}, [] );\n\n\tconst onKeyDown = useCallback(\n\t\t( e: React.KeyboardEvent ) => {\n\t\t\tif ( optionsRef.current?.disabled ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ( isHandledKeyboardPan( e.nativeEvent ) ) {\n\t\t\t\tsetIsKeyboardPanning( true );\n\t\t\t\tsignalKeyboardGesture();\n\t\t\t} else if ( isHandledKeyboardZoom( e.nativeEvent ) ) {\n\t\t\t\tsignalKeyboardGesture();\n\t\t\t}\n\t\t\tcontrollerRef.current?.handleKeyDown( e.nativeEvent );\n\t\t},\n\t\t[ signalKeyboardGesture ]\n\t);\n\n\tconst onWheelNative = useCallback( ( e: WheelEvent ) => {\n\t\tif ( optionsRef.current?.disabled ) {\n\t\t\treturn;\n\t\t}\n\t\tcontrollerRef.current?.handleWheel( e );\n\t}, [] );\n\n\treturn {\n\t\thandlers: {\n\t\t\tonPointerDown,\n\t\t\tonTouchStart,\n\t\t\tonKeyDown,\n\t\t},\n\t\tonWheelNative,\n\t\tisDragging,\n\t\tisZooming,\n\t\tisPlacementActive: isGestureActive || isKeyboardPanning || isZooming,\n\t};\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAyD;AAEzD,oCAGO;AAmDP,IAAM,+BAA+B;AAErC,SAAS,qBAAsB,OAAgC;AAC9D,UAAS,MAAM,KAAM;AAAA,IACpB,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACJ,aAAO;AAAA,IACR;AACC,aAAO;AAAA,EACT;AACD;AAEA,SAAS,sBAAuB,OAAgC;AAC/D,UAAS,MAAM,KAAM;AAAA,IACpB,KAAK;AA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AAE,MAAmB;AACvD,QAAK,WAAW,SAAS,UAAW;AACnC;AAAA,IACD;AACA,kBAAc,SAAS,YAAa,CAAE;AAAA,EACvC,GAAG,CAAC,CAAE;AAEN,SAAO;AAAA,IACN,UAAU;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,mBAAmB,mBAAmB,qBAAqB;AAAA,EAC5D;AACD;",
6
- "names": []
7
- }
@@ -1,38 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // packages/media-editor/src/image-editor/react/hooks/use-transform-style.ts
21
- var use_transform_style_exports = {};
22
- __export(use_transform_style_exports, {
23
- useTransformStyle: () => useTransformStyle
24
- });
25
- module.exports = __toCommonJS(use_transform_style_exports);
26
- var import_element = require("@wordpress/element");
27
- var import_transform_style = require("../../core/transform-style.cjs");
28
- function useTransformStyle(state, imageSize) {
29
- return (0, import_element.useMemo)(
30
- () => (0, import_transform_style.computeTransformStyle)(state, imageSize),
31
- [state, imageSize]
32
- );
33
- }
34
- // Annotate the CommonJS export names for ESM import in node:
35
- 0 && (module.exports = {
36
- useTransformStyle
37
- });
38
- //# sourceMappingURL=use-transform-style.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../src/image-editor/react/hooks/use-transform-style.ts"],
4
- "sourcesContent": ["import { useMemo } from '@wordpress/element';\nimport type { CropperState, Size } from '../../core/types';\nimport { computeTransformStyle } from '../../core/transform-style';\n\n/**\n * React hook that computes a memoized CSS matrix() transform string\n * from the cropper state.\n *\n * Delegates to the pure `computeTransformStyle` function in core.\n *\n * @param state The current cropper state.\n * @param imageSize The rendered image dimensions in pixels.\n * @return A CSS transform string.\n */\nexport function useTransformStyle(\n\tstate: CropperState,\n\timageSize: Size\n): string {\n\treturn useMemo(\n\t\t() => computeTransformStyle( state, imageSize ),\n\t\t[ state, imageSize ]\n\t);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAwB;AAExB,6BAAsC;AAY/B,SAAS,kBACf,OACA,WACS;AACT,aAAO;AAAA,IACN,UAAM,8CAAuB,OAAO,SAAU;AAAA,IAC9C,CAAE,OAAO,SAAU;AAAA,EACpB;AACD;",
6
- "names": []
7
- }