@wordpress/media-editor 0.22.0 → 0.24.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 (391) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/build/components/media-editor/index.cjs +229 -126
  3. package/build/components/media-editor/index.cjs.map +1 -1
  4. package/build/components/media-editor/use-crop-options.cjs +4 -5
  5. package/build/components/media-editor/use-crop-options.cjs.map +1 -1
  6. package/build/components/media-editor/use-save-media-editor.cjs +41 -11
  7. package/build/components/media-editor/use-save-media-editor.cjs.map +1 -1
  8. package/build/components/media-editor-canvas/index.cjs +15 -18
  9. package/build/components/media-editor-canvas/index.cjs.map +1 -1
  10. package/build/components/media-editor-crop-panel/index.cjs +26 -8
  11. package/build/components/media-editor-crop-panel/index.cjs.map +1 -1
  12. package/build/components/media-editor-fine-rotation/index.cjs +13 -12
  13. package/build/components/media-editor-fine-rotation/index.cjs.map +1 -1
  14. package/build/components/media-editor-image-controls/index.cjs +4 -6
  15. package/build/components/media-editor-image-controls/index.cjs.map +1 -1
  16. package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs +33 -33
  17. package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs.map +1 -1
  18. package/build/components/media-editor-modal/index.cjs +10 -7
  19. package/build/components/media-editor-modal/index.cjs.map +1 -1
  20. package/build/components/media-editor-panel/error-boundary.cjs +68 -0
  21. package/build/components/media-editor-panel/error-boundary.cjs.map +1 -0
  22. package/build/components/media-editor-panel/index.cjs +158 -0
  23. package/build/components/media-editor-panel/index.cjs.map +1 -0
  24. package/build/components/media-form/index.cjs +7 -1
  25. package/build/components/media-form/index.cjs.map +1 -1
  26. package/build/components/media-preview/index.cjs +143 -37
  27. package/build/components/media-preview/index.cjs.map +1 -1
  28. package/build/components/rotation-ruler/index.cjs +9 -7
  29. package/build/components/rotation-ruler/index.cjs.map +1 -1
  30. package/build/components/rotation-ruler/use-ruler-drag.cjs.map +1 -1
  31. package/build/hooks/use-crop-gesture-handlers.cjs.map +1 -1
  32. package/build/index.cjs +10 -8
  33. package/build/private-apis.cjs.map +1 -1
  34. package/build/state/aspect-ratio-presets.cjs +12 -6
  35. package/build/state/aspect-ratio-presets.cjs.map +1 -1
  36. package/build/state/composite-reducer.cjs +41 -74
  37. package/build/state/composite-reducer.cjs.map +1 -1
  38. package/build/state/index.cjs +0 -39
  39. package/build/state/types.cjs +1 -2
  40. package/build/state/types.cjs.map +1 -1
  41. package/build/state/use-media-editor-state.cjs +70 -106
  42. package/build/state/use-media-editor-state.cjs.map +1 -1
  43. package/build/store/index.cjs +11 -9
  44. package/build/store/index.cjs.map +1 -1
  45. package/build/utils/get-media-type.cjs +8 -0
  46. package/build/utils/get-media-type.cjs.map +1 -1
  47. package/build/utils/index.cjs +6 -0
  48. package/build-module/components/media-editor/index.mjs +217 -117
  49. package/build-module/components/media-editor/index.mjs.map +1 -1
  50. package/build-module/components/media-editor/use-crop-options.mjs +4 -5
  51. package/build-module/components/media-editor/use-crop-options.mjs.map +1 -1
  52. package/build-module/components/media-editor/use-save-media-editor.mjs +32 -4
  53. package/build-module/components/media-editor/use-save-media-editor.mjs.map +1 -1
  54. package/build-module/components/media-editor-canvas/index.mjs +8 -13
  55. package/build-module/components/media-editor-canvas/index.mjs.map +1 -1
  56. package/build-module/components/media-editor-crop-panel/index.mjs +17 -1
  57. package/build-module/components/media-editor-crop-panel/index.mjs.map +1 -1
  58. package/build-module/components/media-editor-fine-rotation/index.mjs +4 -5
  59. package/build-module/components/media-editor-fine-rotation/index.mjs.map +1 -1
  60. package/build-module/components/media-editor-image-controls/index.mjs +5 -7
  61. package/build-module/components/media-editor-image-controls/index.mjs.map +1 -1
  62. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs +33 -33
  63. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs.map +1 -1
  64. package/build-module/components/media-editor-modal/index.mjs +1 -0
  65. package/build-module/components/media-editor-modal/index.mjs.map +1 -1
  66. package/build-module/components/media-editor-panel/error-boundary.mjs +63 -0
  67. package/build-module/components/media-editor-panel/error-boundary.mjs.map +1 -0
  68. package/build-module/components/media-editor-panel/index.mjs +123 -0
  69. package/build-module/components/media-editor-panel/index.mjs.map +1 -0
  70. package/build-module/components/media-form/index.mjs +7 -1
  71. package/build-module/components/media-form/index.mjs.map +1 -1
  72. package/build-module/components/media-preview/index.mjs +123 -41
  73. package/build-module/components/media-preview/index.mjs.map +1 -1
  74. package/build-module/state/aspect-ratio-presets.mjs +12 -7
  75. package/build-module/state/aspect-ratio-presets.mjs.map +1 -1
  76. package/build-module/state/composite-reducer.mjs +32 -67
  77. package/build-module/state/composite-reducer.mjs.map +1 -1
  78. package/build-module/state/index.mjs +2 -5
  79. package/build-module/state/types.mjs +1 -2
  80. package/build-module/state/types.mjs.map +1 -1
  81. package/build-module/state/use-media-editor-state.mjs +70 -105
  82. package/build-module/state/use-media-editor-state.mjs.map +1 -1
  83. package/build-module/utils/get-media-type.mjs +8 -1
  84. package/build-module/utils/get-media-type.mjs.map +1 -1
  85. package/build-module/utils/index.mjs +1 -1
  86. package/build-style/style-rtl.css +122 -87
  87. package/build-style/style.css +121 -87
  88. package/build-types/components/media-editor/index.d.ts +25 -3
  89. package/build-types/components/media-editor/index.d.ts.map +1 -1
  90. package/build-types/components/media-editor/use-crop-options.d.ts +2 -3
  91. package/build-types/components/media-editor/use-crop-options.d.ts.map +1 -1
  92. package/build-types/components/media-editor/use-save-media-editor.d.ts.map +1 -1
  93. package/build-types/components/media-editor-canvas/index.d.ts +3 -3
  94. package/build-types/components/media-editor-canvas/index.d.ts.map +1 -1
  95. package/build-types/components/media-editor-crop-panel/index.d.ts +1 -1
  96. package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -1
  97. package/build-types/components/media-editor-fine-rotation/index.d.ts.map +1 -1
  98. package/build-types/components/media-editor-image-controls/index.d.ts +1 -1
  99. package/build-types/components/media-editor-image-controls/index.d.ts.map +1 -1
  100. package/build-types/components/media-editor-keyboard-shortcuts-modal/index.d.ts.map +1 -1
  101. package/build-types/components/media-editor-modal/index.d.ts +1 -1
  102. package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
  103. package/build-types/components/media-editor-panel/error-boundary.d.ts +23 -0
  104. package/build-types/components/media-editor-panel/error-boundary.d.ts.map +1 -0
  105. package/build-types/components/media-editor-panel/index.d.ts +46 -0
  106. package/build-types/components/media-editor-panel/index.d.ts.map +1 -0
  107. package/build-types/components/media-form/index.d.ts.map +1 -1
  108. package/build-types/components/media-preview/index.d.ts.map +1 -1
  109. package/build-types/state/aspect-ratio-presets.d.ts +20 -3
  110. package/build-types/state/aspect-ratio-presets.d.ts.map +1 -1
  111. package/build-types/state/composite-reducer.d.ts +17 -19
  112. package/build-types/state/composite-reducer.d.ts.map +1 -1
  113. package/build-types/state/index.d.ts +2 -5
  114. package/build-types/state/index.d.ts.map +1 -1
  115. package/build-types/state/types.d.ts +20 -64
  116. package/build-types/state/types.d.ts.map +1 -1
  117. package/build-types/state/use-media-editor-state.d.ts +40 -54
  118. package/build-types/state/use-media-editor-state.d.ts.map +1 -1
  119. package/build-types/utils/get-media-type.d.ts +3 -1
  120. package/build-types/utils/get-media-type.d.ts.map +1 -1
  121. package/build-types/utils/index.d.ts +1 -1
  122. package/build-types/utils/index.d.ts.map +1 -1
  123. package/package.json +27 -24
  124. package/src/components/media-editor/index.tsx +372 -142
  125. package/src/components/media-editor/style.scss +21 -1
  126. package/src/components/media-editor/use-crop-options.ts +7 -11
  127. package/src/components/media-editor/use-save-media-editor.ts +48 -6
  128. package/src/components/media-editor-canvas/index.tsx +15 -26
  129. package/src/components/media-editor-canvas/style.scss +6 -6
  130. package/src/components/media-editor-crop-panel/index.tsx +38 -2
  131. package/src/components/media-editor-crop-panel/style.scss +21 -0
  132. package/src/components/media-editor-fine-rotation/index.tsx +6 -6
  133. package/src/components/media-editor-image-controls/index.tsx +11 -9
  134. package/src/components/media-editor-keyboard-shortcuts-modal/index.tsx +56 -63
  135. package/src/components/media-editor-keyboard-shortcuts-modal/style.scss +1 -1
  136. package/src/components/media-editor-modal/index.tsx +4 -1
  137. package/src/components/media-editor-panel/error-boundary.tsx +88 -0
  138. package/src/components/media-editor-panel/index.tsx +211 -0
  139. package/src/components/media-form/index.tsx +7 -1
  140. package/src/components/media-preview/index.tsx +195 -37
  141. package/src/components/media-preview/style.scss +11 -32
  142. package/src/components/rotation-ruler/style.scss +3 -3
  143. package/src/state/README.md +34 -0
  144. package/src/state/aspect-ratio-presets.ts +22 -3
  145. package/src/state/composite-reducer.ts +42 -80
  146. package/src/state/index.ts +2 -18
  147. package/src/state/types.ts +18 -68
  148. package/src/state/use-media-editor-state.ts +162 -242
  149. package/src/style.scss +2 -1
  150. package/src/utils/get-media-type.ts +9 -1
  151. package/src/utils/index.ts +1 -1
  152. package/build/components/media-editor-modal/build-modifiers.cjs +0 -110
  153. package/build/components/media-editor-modal/build-modifiers.cjs.map +0 -1
  154. package/build/image-editor/core/camera.cjs +0 -277
  155. package/build/image-editor/core/camera.cjs.map +0 -1
  156. package/build/image-editor/core/constants.cjs +0 -133
  157. package/build/image-editor/core/constants.cjs.map +0 -1
  158. package/build/image-editor/core/containment.cjs +0 -289
  159. package/build/image-editor/core/containment.cjs.map +0 -1
  160. package/build/image-editor/core/crop-rect.cjs +0 -37
  161. package/build/image-editor/core/crop-rect.cjs.map +0 -1
  162. package/build/image-editor/core/export/canvas-renderer.cjs +0 -181
  163. package/build/image-editor/core/export/canvas-renderer.cjs.map +0 -1
  164. package/build/image-editor/core/index.cjs +0 -89
  165. package/build/image-editor/core/interaction-controller.cjs +0 -591
  166. package/build/image-editor/core/interaction-controller.cjs.map +0 -1
  167. package/build/image-editor/core/math/rotation.cjs +0 -32
  168. package/build/image-editor/core/math/rotation.cjs.map +0 -1
  169. package/build/image-editor/core/math/sanitize.cjs +0 -136
  170. package/build/image-editor/core/math/sanitize.cjs.map +0 -1
  171. package/build/image-editor/core/setter-helpers.cjs +0 -61
  172. package/build/image-editor/core/setter-helpers.cjs.map +0 -1
  173. package/build/image-editor/core/source-region.cjs +0 -236
  174. package/build/image-editor/core/source-region.cjs.map +0 -1
  175. package/build/image-editor/core/state.cjs +0 -296
  176. package/build/image-editor/core/state.cjs.map +0 -1
  177. package/build/image-editor/core/stencil-math.cjs +0 -203
  178. package/build/image-editor/core/stencil-math.cjs.map +0 -1
  179. package/build/image-editor/core/transform-style.cjs +0 -43
  180. package/build/image-editor/core/transform-style.cjs.map +0 -1
  181. package/build/image-editor/core/transforms/pipeline.cjs +0 -41
  182. package/build/image-editor/core/transforms/pipeline.cjs.map +0 -1
  183. package/build/image-editor/core/types.cjs +0 -5
  184. package/build/image-editor/core/viewport-state.cjs +0 -36
  185. package/build/image-editor/core/viewport-state.cjs.map +0 -1
  186. package/build/image-editor/index.cjs +0 -68
  187. package/build/image-editor/react/components/cropper-provider.cjs +0 -49
  188. package/build/image-editor/react/components/cropper-provider.cjs.map +0 -1
  189. package/build/image-editor/react/components/cropper.cjs +0 -595
  190. package/build/image-editor/react/components/cropper.cjs.map +0 -1
  191. package/build/image-editor/react/components/index.cjs +0 -25
  192. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs +0 -147
  193. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs.map +0 -1
  194. package/build/image-editor/react/components/overlays/dimming-overlay.cjs +0 -31
  195. package/build/image-editor/react/components/overlays/dimming-overlay.cjs.map +0 -1
  196. package/build/image-editor/react/components/overlays/grid-overlay.cjs +0 -61
  197. package/build/image-editor/react/components/overlays/grid-overlay.cjs.map +0 -1
  198. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs +0 -367
  199. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +0 -1
  200. package/build/image-editor/react/components/viewport-provider.cjs +0 -26
  201. package/build/image-editor/react/components/viewport-provider.cjs.map +0 -1
  202. package/build/image-editor/react/hooks/build-cropper-setters.cjs +0 -80
  203. package/build/image-editor/react/hooks/build-cropper-setters.cjs.map +0 -1
  204. package/build/image-editor/react/hooks/index.cjs +0 -19
  205. package/build/image-editor/react/hooks/use-aria-announcer.cjs +0 -104
  206. package/build/image-editor/react/hooks/use-aria-announcer.cjs.map +0 -1
  207. package/build/image-editor/react/hooks/use-cropper-controller.cjs +0 -80
  208. package/build/image-editor/react/hooks/use-cropper-controller.cjs.map +0 -1
  209. package/build/image-editor/react/hooks/use-interaction.cjs +0 -187
  210. package/build/image-editor/react/hooks/use-interaction.cjs.map +0 -1
  211. package/build/image-editor/react/hooks/use-transform-style.cjs +0 -24
  212. package/build/image-editor/react/hooks/use-transform-style.cjs.map +0 -1
  213. package/build/image-editor/react/hooks/use-viewport-state.cjs +0 -40
  214. package/build/image-editor/react/hooks/use-viewport-state.cjs.map +0 -1
  215. package/build/image-editor/react/visually-hidden-style.cjs +0 -24
  216. package/build/image-editor/react/visually-hidden-style.cjs.map +0 -1
  217. package/build-module/components/media-editor-modal/build-modifiers.mjs +0 -105
  218. package/build-module/components/media-editor-modal/build-modifiers.mjs.map +0 -1
  219. package/build-module/image-editor/core/camera.mjs +0 -265
  220. package/build-module/image-editor/core/camera.mjs.map +0 -1
  221. package/build-module/image-editor/core/constants.mjs +0 -115
  222. package/build-module/image-editor/core/constants.mjs.map +0 -1
  223. package/build-module/image-editor/core/containment.mjs +0 -281
  224. package/build-module/image-editor/core/containment.mjs.map +0 -1
  225. package/build-module/image-editor/core/crop-rect.mjs +0 -32
  226. package/build-module/image-editor/core/crop-rect.mjs.map +0 -1
  227. package/build-module/image-editor/core/export/canvas-renderer.mjs +0 -170
  228. package/build-module/image-editor/core/export/canvas-renderer.mjs.map +0 -1
  229. package/build-module/image-editor/core/index.mjs +0 -7
  230. package/build-module/image-editor/core/interaction-controller.mjs +0 -586
  231. package/build-module/image-editor/core/interaction-controller.mjs.map +0 -1
  232. package/build-module/image-editor/core/math/rotation.mjs +0 -26
  233. package/build-module/image-editor/core/math/rotation.mjs.map +0 -1
  234. package/build-module/image-editor/core/math/sanitize.mjs +0 -127
  235. package/build-module/image-editor/core/math/sanitize.mjs.map +0 -1
  236. package/build-module/image-editor/core/setter-helpers.mjs +0 -56
  237. package/build-module/image-editor/core/setter-helpers.mjs.map +0 -1
  238. package/build-module/image-editor/core/source-region.mjs +0 -228
  239. package/build-module/image-editor/core/source-region.mjs.map +0 -1
  240. package/build-module/image-editor/core/state.mjs +0 -288
  241. package/build-module/image-editor/core/state.mjs.map +0 -1
  242. package/build-module/image-editor/core/stencil-math.mjs +0 -194
  243. package/build-module/image-editor/core/stencil-math.mjs.map +0 -1
  244. package/build-module/image-editor/core/transform-style.mjs +0 -38
  245. package/build-module/image-editor/core/transform-style.mjs.map +0 -1
  246. package/build-module/image-editor/core/transforms/pipeline.mjs +0 -35
  247. package/build-module/image-editor/core/transforms/pipeline.mjs.map +0 -1
  248. package/build-module/image-editor/core/types.mjs +0 -0
  249. package/build-module/image-editor/core/viewport-state.mjs +0 -30
  250. package/build-module/image-editor/core/viewport-state.mjs.map +0 -1
  251. package/build-module/image-editor/index.mjs +0 -4
  252. package/build-module/image-editor/react/components/cropper-provider.mjs +0 -43
  253. package/build-module/image-editor/react/components/cropper-provider.mjs.map +0 -1
  254. package/build-module/image-editor/react/components/cropper.mjs +0 -568
  255. package/build-module/image-editor/react/components/cropper.mjs.map +0 -1
  256. package/build-module/image-editor/react/components/index.mjs +0 -3
  257. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs +0 -142
  258. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs.map +0 -1
  259. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs +0 -26
  260. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs.map +0 -1
  261. package/build-module/image-editor/react/components/overlays/grid-overlay.mjs +0 -56
  262. package/build-module/image-editor/react/components/overlays/grid-overlay.mjs.map +0 -1
  263. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs +0 -362
  264. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs.map +0 -1
  265. package/build-module/image-editor/react/components/viewport-provider.mjs +0 -20
  266. package/build-module/image-editor/react/components/viewport-provider.mjs.map +0 -1
  267. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs +0 -75
  268. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs.map +0 -1
  269. package/build-module/image-editor/react/hooks/index.mjs +0 -3
  270. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs +0 -99
  271. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs.map +0 -1
  272. package/build-module/image-editor/react/hooks/use-cropper-controller.mjs +0 -75
  273. package/build-module/image-editor/react/hooks/use-cropper-controller.mjs.map +0 -1
  274. package/build-module/image-editor/react/hooks/use-interaction.mjs +0 -182
  275. package/build-module/image-editor/react/hooks/use-interaction.mjs.map +0 -1
  276. package/build-module/image-editor/react/hooks/use-transform-style.mjs +0 -19
  277. package/build-module/image-editor/react/hooks/use-transform-style.mjs.map +0 -1
  278. package/build-module/image-editor/react/hooks/use-viewport-state.mjs +0 -35
  279. package/build-module/image-editor/react/hooks/use-viewport-state.mjs.map +0 -1
  280. package/build-module/image-editor/react/visually-hidden-style.mjs +0 -19
  281. package/build-module/image-editor/react/visually-hidden-style.mjs.map +0 -1
  282. package/build-types/components/media-editor-modal/build-modifiers.d.ts +0 -81
  283. package/build-types/components/media-editor-modal/build-modifiers.d.ts.map +0 -1
  284. package/build-types/image-editor/core/camera.d.ts +0 -128
  285. package/build-types/image-editor/core/camera.d.ts.map +0 -1
  286. package/build-types/image-editor/core/constants.d.ts +0 -98
  287. package/build-types/image-editor/core/constants.d.ts.map +0 -1
  288. package/build-types/image-editor/core/containment.d.ts +0 -72
  289. package/build-types/image-editor/core/containment.d.ts.map +0 -1
  290. package/build-types/image-editor/core/crop-rect.d.ts +0 -16
  291. package/build-types/image-editor/core/crop-rect.d.ts.map +0 -1
  292. package/build-types/image-editor/core/export/canvas-renderer.d.ts +0 -103
  293. package/build-types/image-editor/core/export/canvas-renderer.d.ts.map +0 -1
  294. package/build-types/image-editor/core/index.d.ts +0 -10
  295. package/build-types/image-editor/core/index.d.ts.map +0 -1
  296. package/build-types/image-editor/core/interaction-controller.d.ts +0 -191
  297. package/build-types/image-editor/core/interaction-controller.d.ts.map +0 -1
  298. package/build-types/image-editor/core/math/rotation.d.ts +0 -18
  299. package/build-types/image-editor/core/math/rotation.d.ts.map +0 -1
  300. package/build-types/image-editor/core/math/sanitize.d.ts +0 -67
  301. package/build-types/image-editor/core/math/sanitize.d.ts.map +0 -1
  302. package/build-types/image-editor/core/setter-helpers.d.ts +0 -21
  303. package/build-types/image-editor/core/setter-helpers.d.ts.map +0 -1
  304. package/build-types/image-editor/core/source-region.d.ts +0 -94
  305. package/build-types/image-editor/core/source-region.d.ts.map +0 -1
  306. package/build-types/image-editor/core/state.d.ts +0 -51
  307. package/build-types/image-editor/core/state.d.ts.map +0 -1
  308. package/build-types/image-editor/core/stencil-math.d.ts +0 -102
  309. package/build-types/image-editor/core/stencil-math.d.ts.map +0 -1
  310. package/build-types/image-editor/core/transform-style.d.ts +0 -20
  311. package/build-types/image-editor/core/transform-style.d.ts.map +0 -1
  312. package/build-types/image-editor/core/transforms/pipeline.d.ts +0 -24
  313. package/build-types/image-editor/core/transforms/pipeline.d.ts.map +0 -1
  314. package/build-types/image-editor/core/types.d.ts +0 -269
  315. package/build-types/image-editor/core/types.d.ts.map +0 -1
  316. package/build-types/image-editor/core/viewport-state.d.ts +0 -4
  317. package/build-types/image-editor/core/viewport-state.d.ts.map +0 -1
  318. package/build-types/image-editor/index.d.ts +0 -17
  319. package/build-types/image-editor/index.d.ts.map +0 -1
  320. package/build-types/image-editor/react/components/cropper-provider.d.ts +0 -38
  321. package/build-types/image-editor/react/components/cropper-provider.d.ts.map +0 -1
  322. package/build-types/image-editor/react/components/cropper.d.ts +0 -54
  323. package/build-types/image-editor/react/components/cropper.d.ts.map +0 -1
  324. package/build-types/image-editor/react/components/index.d.ts +0 -4
  325. package/build-types/image-editor/react/components/index.d.ts.map +0 -1
  326. package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts +0 -33
  327. package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts.map +0 -1
  328. package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts +0 -17
  329. package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts.map +0 -1
  330. package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts +0 -27
  331. package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts.map +0 -1
  332. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts +0 -33
  333. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts.map +0 -1
  334. package/build-types/image-editor/react/components/viewport-provider.d.ts +0 -6
  335. package/build-types/image-editor/react/components/viewport-provider.d.ts.map +0 -1
  336. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts +0 -44
  337. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts.map +0 -1
  338. package/build-types/image-editor/react/hooks/index.d.ts +0 -5
  339. package/build-types/image-editor/react/hooks/index.d.ts.map +0 -1
  340. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts +0 -14
  341. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts.map +0 -1
  342. package/build-types/image-editor/react/hooks/use-cropper-controller.d.ts +0 -55
  343. package/build-types/image-editor/react/hooks/use-cropper-controller.d.ts.map +0 -1
  344. package/build-types/image-editor/react/hooks/use-interaction.d.ts +0 -65
  345. package/build-types/image-editor/react/hooks/use-interaction.d.ts.map +0 -1
  346. package/build-types/image-editor/react/hooks/use-transform-style.d.ts +0 -13
  347. package/build-types/image-editor/react/hooks/use-transform-style.d.ts.map +0 -1
  348. package/build-types/image-editor/react/hooks/use-viewport-state.d.ts +0 -16
  349. package/build-types/image-editor/react/hooks/use-viewport-state.d.ts.map +0 -1
  350. package/build-types/image-editor/react/visually-hidden-style.d.ts +0 -6
  351. package/build-types/image-editor/react/visually-hidden-style.d.ts.map +0 -1
  352. package/src/components/media-editor-modal/build-modifiers.ts +0 -167
  353. package/src/image-editor/README.md +0 -61
  354. package/src/image-editor/core/camera.ts +0 -429
  355. package/src/image-editor/core/constants.ts +0 -137
  356. package/src/image-editor/core/containment.ts +0 -469
  357. package/src/image-editor/core/crop-rect.ts +0 -42
  358. package/src/image-editor/core/export/canvas-renderer.ts +0 -250
  359. package/src/image-editor/core/index.ts +0 -43
  360. package/src/image-editor/core/interaction-controller.ts +0 -976
  361. package/src/image-editor/core/math/rotation.ts +0 -26
  362. package/src/image-editor/core/math/sanitize.ts +0 -155
  363. package/src/image-editor/core/setter-helpers.ts +0 -63
  364. package/src/image-editor/core/source-region.ts +0 -367
  365. package/src/image-editor/core/state.ts +0 -484
  366. package/src/image-editor/core/stencil-math.ts +0 -379
  367. package/src/image-editor/core/transform-style.ts +0 -56
  368. package/src/image-editor/core/transforms/pipeline.ts +0 -40
  369. package/src/image-editor/core/types.ts +0 -230
  370. package/src/image-editor/core/viewport-state.ts +0 -30
  371. package/src/image-editor/docs/architecture.md +0 -63
  372. package/src/image-editor/docs/recipes.md +0 -184
  373. package/src/image-editor/index.ts +0 -43
  374. package/src/image-editor/react/components/cropper-provider.tsx +0 -70
  375. package/src/image-editor/react/components/cropper.scss +0 -259
  376. package/src/image-editor/react/components/cropper.tsx +0 -1108
  377. package/src/image-editor/react/components/index.ts +0 -3
  378. package/src/image-editor/react/components/overlays/dimensions-overlay.tsx +0 -262
  379. package/src/image-editor/react/components/overlays/dimming-overlay.tsx +0 -55
  380. package/src/image-editor/react/components/overlays/grid-overlay.tsx +0 -77
  381. package/src/image-editor/react/components/stencils/rectangle-stencil.tsx +0 -623
  382. package/src/image-editor/react/components/viewport-provider.tsx +0 -32
  383. package/src/image-editor/react/hooks/build-cropper-setters.ts +0 -102
  384. package/src/image-editor/react/hooks/index.ts +0 -4
  385. package/src/image-editor/react/hooks/use-aria-announcer.ts +0 -193
  386. package/src/image-editor/react/hooks/use-cropper-controller.ts +0 -197
  387. package/src/image-editor/react/hooks/use-interaction.ts +0 -294
  388. package/src/image-editor/react/hooks/use-transform-style.ts +0 -23
  389. package/src/image-editor/react/hooks/use-viewport-state.ts +0 -41
  390. package/src/image-editor/react/visually-hidden-style.ts +0 -15
  391. package/src/image-editor/style.scss +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"use-ruler-drag.cjs","names":["useRef","useCallback"],"sources":["../../../src/components/rotation-ruler/use-ruler-drag.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from '@wordpress/element';\n\n/**\n * Convert a horizontal pointer delta (px) into a value delta.\n *\n * Negative because dragging the ruler to the right should expose\n * smaller values to the left of the fixed center pointer (and vice\n * versa) — the ruler scrubs *under* the pointer.\n *\n * @param deltaPx Pointer movement in CSS pixels.\n * @param pixelsPerStep CSS pixels of pointer travel per `step`.\n * @param step Value units per step.\n */\nexport function pxToValueDelta(\n\tdeltaPx: number,\n\tpixelsPerStep: number,\n\tstep: number\n): number {\n\treturn ( -deltaPx / pixelsPerStep ) * step;\n}\n\n/**\n * Clamp `value` to the inclusive `[min, max]` interval.\n *\n * @param value Value to clamp.\n * @param min Lower bound (inclusive).\n * @param max Upper bound (inclusive).\n */\nexport function clampValue( value: number, min: number, max: number ): number {\n\tif ( value < min ) {\n\t\treturn min;\n\t}\n\tif ( value > max ) {\n\t\treturn max;\n\t}\n\treturn value;\n}\n\n/**\n * Round `value` to the nearest multiple of `step`.\n *\n * @param value Value to quantize.\n * @param step Step granularity (must be > 0).\n */\nexport function quantize( value: number, step: number ): number {\n\treturn Math.round( value / step ) * step;\n}\n\nexport interface UseRulerDragOptions {\n\tvalue: number;\n\tonChange: ( next: number ) => void;\n\tmin: number;\n\tmax: number;\n\tstep: number;\n\tpixelsPerStep: number;\n\tdisabled: boolean;\n\t/** Called once on pointerdown so the caller can focus the input. */\n\tonPointerDownStart?: () => void;\n}\n\nexport interface RulerDragHandlers {\n\tonPointerDown: ( event: React.PointerEvent< HTMLElement > ) => void;\n\tonPointerMove: ( event: React.PointerEvent< HTMLElement > ) => void;\n\tonPointerUp: ( event: React.PointerEvent< HTMLElement > ) => void;\n\tonPointerCancel: ( event: React.PointerEvent< HTMLElement > ) => void;\n}\n\n/**\n * Drag-the-ruler gesture for a horizontal slider. Translates pointer\n * movement into value changes quantized to `step`; the caller renders\n * the visuals and holds the value.\n *\n * The hook owns no state of its own — every value change is reported\n * through the supplied `onChange`. The \"current value\" is read from a\n * ref so closure staleness during a drag is impossible. Drag continues\n * past the wrapper's bounds (standard slider behaviour); a window-level\n * `pointerup` listener guarantees the drag ends and pointer capture\n * releases even if the underlying captured event never fires on the\n * wrapper.\n *\n * @param options Ruler-drag configuration. See `UseRulerDragOptions`.\n */\nexport function useRulerDrag(\n\toptions: UseRulerDragOptions\n): RulerDragHandlers {\n\tconst {\n\t\tvalue,\n\t\tonChange,\n\t\tmin,\n\t\tmax,\n\t\tstep,\n\t\tpixelsPerStep,\n\t\tdisabled,\n\t\tonPointerDownStart,\n\t} = options;\n\n\t// Per-drag state, including the last emitted value. Pointermove\n\t// handlers fire far faster than React commits, so they cannot read\n\t// `value` from closure. Pointerdown seeds it from the committed `value`.\n\tconst latestRef = useRef< {\n\t\tvalue: number;\n\t\tstartX: number;\n\t\tstartValue: number;\n\t\tactiveStep: number;\n\t\tdragging: boolean;\n\t\tcaptureElement: HTMLElement | null;\n\t\tcapturePointerId: number;\n\t\twindowPointerUp: ( () => void ) | null;\n\t} >( {\n\t\tvalue,\n\t\tstartX: 0,\n\t\tstartValue: 0,\n\t\tactiveStep: step,\n\t\tdragging: false,\n\t\tcaptureElement: null,\n\t\tcapturePointerId: 0,\n\t\twindowPointerUp: null,\n\t} );\n\n\tconst endDrag = useCallback( () => {\n\t\tconst state = latestRef.current;\n\t\tif ( ! state.dragging ) {\n\t\t\treturn;\n\t\t}\n\t\tstate.dragging = false;\n\t\tif (\n\t\t\tstate.captureElement &&\n\t\t\tstate.captureElement.hasPointerCapture( state.capturePointerId )\n\t\t) {\n\t\t\tstate.captureElement.releasePointerCapture(\n\t\t\t\tstate.capturePointerId\n\t\t\t);\n\t\t}\n\t\tstate.captureElement = null;\n\t\tif ( state.windowPointerUp ) {\n\t\t\twindow.removeEventListener( 'pointerup', state.windowPointerUp );\n\t\t\twindow.removeEventListener(\n\t\t\t\t'pointercancel',\n\t\t\t\tstate.windowPointerUp\n\t\t\t);\n\t\t\tstate.windowPointerUp = null;\n\t\t}\n\t}, [] );\n\n\t// Cleanup any in-flight drag on unmount so we never leak window\n\t// listeners or stale pointer capture.\n\tuseEffect( () => endDrag, [ endDrag ] );\n\n\t// Becoming disabled mid-drag ends it, so a rotation cannot keep\n\t// changing after a save has read it.\n\tuseEffect( () => {\n\t\tif ( disabled ) {\n\t\t\tendDrag();\n\t\t}\n\t}, [ disabled, endDrag ] );\n\n\tconst onPointerDown = useCallback(\n\t\t( event: React.PointerEvent< HTMLElement > ) => {\n\t\t\tif ( disabled || event.button !== 0 ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst state = latestRef.current;\n\t\t\tevent.currentTarget.setPointerCapture( event.pointerId );\n\t\t\tstate.captureElement = event.currentTarget;\n\t\t\tstate.capturePointerId = event.pointerId;\n\t\t\tstate.startX = event.clientX;\n\t\t\tstate.value = value;\n\t\t\tstate.startValue = value;\n\t\t\tstate.activeStep = event.shiftKey ? step / 2 : step;\n\t\t\tstate.dragging = true;\n\t\t\tonPointerDownStart?.();\n\n\t\t\t// Window-level backstop. With `setPointerCapture`, the\n\t\t\t// element should always receive `pointerup` even when the\n\t\t\t// cursor is released outside its bounds — but in practice\n\t\t\t// some browsers / window-blur sequences drop the event. The\n\t\t\t// window listener guarantees the drag ends and capture\n\t\t\t// releases.\n\t\t\tconst onWindowUp = () => endDrag();\n\t\t\tstate.windowPointerUp = onWindowUp;\n\t\t\twindow.addEventListener( 'pointerup', onWindowUp );\n\t\t\twindow.addEventListener( 'pointercancel', onWindowUp );\n\t\t},\n\t\t[ disabled, onPointerDownStart, endDrag, step, value ]\n\t);\n\n\tconst onPointerMove = useCallback(\n\t\t( event: React.PointerEvent< HTMLElement > ) => {\n\t\t\tconst state = latestRef.current;\n\t\t\tif ( disabled || ! state.dragging ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Shift toggles fine mode mid-drag. The drag math computes\n\t\t\t// from `startX` / `startValue`, so naively swapping `step`\n\t\t\t// would yank the value backward. Rebase to the current\n\t\t\t// pointer + value so the granularity changes without a\n\t\t\t// jump.\n\t\t\tconst requestedStep = event.shiftKey ? step / 2 : step;\n\t\t\tif ( requestedStep !== state.activeStep ) {\n\t\t\t\tstate.startX = event.clientX;\n\t\t\t\tstate.startValue = state.value;\n\t\t\t\tstate.activeStep = requestedStep;\n\t\t\t}\n\t\t\tconst deltaPx = event.clientX - state.startX;\n\t\t\tconst deltaValue = pxToValueDelta(\n\t\t\t\tdeltaPx,\n\t\t\t\tpixelsPerStep,\n\t\t\t\tstate.activeStep\n\t\t\t);\n\t\t\tconst raw = state.startValue + deltaValue;\n\t\t\tconst stepped = quantize( raw, state.activeStep );\n\t\t\tconst next = clampValue( stepped, min, max );\n\t\t\tif ( next !== state.value ) {\n\t\t\t\t// Update the ref synchronously so consecutive pointermove\n\t\t\t\t// events that fire before React commits still see the\n\t\t\t\t// last *emitted* value as `previous` for the next math.\n\t\t\t\tstate.value = next;\n\t\t\t\tonChange( next );\n\t\t\t}\n\t\t},\n\t\t[ disabled, onChange, min, max, step, pixelsPerStep ]\n\t);\n\n\treturn {\n\t\tonPointerDown,\n\t\tonPointerMove,\n\t\tonPointerUp: endDrag,\n\t\tonPointerCancel: endDrag,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAaA,SAAgB,eACf,SACA,eACA,MACS;CACT,OAAS,CAAC,UAAU,gBAAkB;AACvC;;;;;;;;AASA,SAAgB,WAAY,OAAe,KAAa,KAAsB;CAC7E,IAAK,QAAQ,KACZ,OAAO;CAER,IAAK,QAAQ,KACZ,OAAO;CAER,OAAO;AACR;;;;;;;AAQA,SAAgB,SAAU,OAAe,MAAuB;CAC/D,OAAO,KAAK,MAAO,QAAQ,IAAK,IAAI;AACrC;;;;;;;;;;;;;;;;AAoCA,SAAgB,aACf,SACoB;CACpB,MAAM,EACL,OACA,UACA,KACA,KACA,MACA,eACA,UACA,uBACG;CAKJ,MAAM,aAAA,GAAYA,mBAAAA,OAAAA,CASb;EACJ;EACA,QAAQ;EACR,YAAY;EACZ,YAAY;EACZ,UAAU;EACV,gBAAgB;EAChB,kBAAkB;EAClB,iBAAiB;CAClB,CAAE;CAEF,MAAM,WAAA,GAAUC,mBAAAA,YAAAA,OAAmB;EAClC,MAAM,QAAQ,UAAU;EACxB,IAAK,CAAE,MAAM,UACZ;EAED,MAAM,WAAW;EACjB,IACC,MAAM,kBACN,MAAM,eAAe,kBAAmB,MAAM,gBAAiB,GAE/D,MAAM,eAAe,sBACpB,MAAM,gBACP;EAED,MAAM,iBAAiB;EACvB,IAAK,MAAM,iBAAkB;GAC5B,OAAO,oBAAqB,aAAa,MAAM,eAAgB;GAC/D,OAAO,oBACN,iBACA,MAAM,eACP;GACA,MAAM,kBAAkB;EACzB;CACD,GAAG,CAAC,CAAE;CAIN,CAAA,GAAA,mBAAA,UAAA,OAAiB,SAAS,CAAE,OAAQ,CAAE;CAItC,CAAA,GAAA,mBAAA,UAAA,OAAiB;EAChB,IAAK,UACJ,QAAQ;CAEV,GAAG,CAAE,UAAU,OAAQ,CAAE;CAqEzB,OAAO;EACN,gBAAA,GApEqBA,mBAAAA,YAAAA,EACnB,UAA8C;GAC/C,IAAK,YAAY,MAAM,WAAW,GACjC;GAED,MAAM,QAAQ,UAAU;GACxB,MAAM,cAAc,kBAAmB,MAAM,SAAU;GACvD,MAAM,iBAAiB,MAAM;GAC7B,MAAM,mBAAmB,MAAM;GAC/B,MAAM,SAAS,MAAM;GACrB,MAAM,QAAQ;GACd,MAAM,aAAa;GACnB,MAAM,aAAa,MAAM,WAAW,OAAO,IAAI;GAC/C,MAAM,WAAW;GACjB,qBAAqB;GAQrB,MAAM,mBAAmB,QAAQ;GACjC,MAAM,kBAAkB;GACxB,OAAO,iBAAkB,aAAa,UAAW;GACjD,OAAO,iBAAkB,iBAAiB,UAAW;EACtD,GACA;GAAE;GAAU;GAAoB;GAAS;GAAM;EAAM,CAyCzC;EACZ,gBAAA,GAvCqBA,mBAAAA,YAAAA,EACnB,UAA8C;GAC/C,MAAM,QAAQ,UAAU;GACxB,IAAK,YAAY,CAAE,MAAM,UACxB;GAOD,MAAM,gBAAgB,MAAM,WAAW,OAAO,IAAI;GAClD,IAAK,kBAAkB,MAAM,YAAa;IACzC,MAAM,SAAS,MAAM;IACrB,MAAM,aAAa,MAAM;IACzB,MAAM,aAAa;GACpB;GAEA,MAAM,aAAa,eADH,MAAM,UAAU,MAAM,QAGrC,eACA,MAAM,UACP;GAGA,MAAM,OAAO,WADG,SADJ,MAAM,aAAa,YACA,MAAM,UACN,GAAG,KAAK,GAAI;GAC3C,IAAK,SAAS,MAAM,OAAQ;IAI3B,MAAM,QAAQ;IACd,SAAU,IAAK;GAChB;EACD,GACA;GAAE;GAAU;GAAU;GAAK;GAAK;GAAM;EAAc,CAKxC;EACZ,aAAa;EACb,iBAAiB;CAClB;AACD"}
1
+ {"version":3,"file":"use-ruler-drag.cjs","names":["useRef","useCallback","useEffect"],"sources":["../../../src/components/rotation-ruler/use-ruler-drag.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from '@wordpress/element';\n\n/**\n * Convert a horizontal pointer delta (px) into a value delta.\n *\n * Negative because dragging the ruler to the right should expose\n * smaller values to the left of the fixed center pointer (and vice\n * versa) — the ruler scrubs *under* the pointer.\n *\n * @param deltaPx Pointer movement in CSS pixels.\n * @param pixelsPerStep CSS pixels of pointer travel per `step`.\n * @param step Value units per step.\n */\nexport function pxToValueDelta(\n\tdeltaPx: number,\n\tpixelsPerStep: number,\n\tstep: number\n): number {\n\treturn ( -deltaPx / pixelsPerStep ) * step;\n}\n\n/**\n * Clamp `value` to the inclusive `[min, max]` interval.\n *\n * @param value Value to clamp.\n * @param min Lower bound (inclusive).\n * @param max Upper bound (inclusive).\n */\nexport function clampValue( value: number, min: number, max: number ): number {\n\tif ( value < min ) {\n\t\treturn min;\n\t}\n\tif ( value > max ) {\n\t\treturn max;\n\t}\n\treturn value;\n}\n\n/**\n * Round `value` to the nearest multiple of `step`.\n *\n * @param value Value to quantize.\n * @param step Step granularity (must be > 0).\n */\nexport function quantize( value: number, step: number ): number {\n\treturn Math.round( value / step ) * step;\n}\n\nexport interface UseRulerDragOptions {\n\tvalue: number;\n\tonChange: ( next: number ) => void;\n\tmin: number;\n\tmax: number;\n\tstep: number;\n\tpixelsPerStep: number;\n\tdisabled: boolean;\n\t/** Called once on pointerdown so the caller can focus the input. */\n\tonPointerDownStart?: () => void;\n}\n\nexport interface RulerDragHandlers {\n\tonPointerDown: ( event: React.PointerEvent< HTMLElement > ) => void;\n\tonPointerMove: ( event: React.PointerEvent< HTMLElement > ) => void;\n\tonPointerUp: ( event: React.PointerEvent< HTMLElement > ) => void;\n\tonPointerCancel: ( event: React.PointerEvent< HTMLElement > ) => void;\n}\n\n/**\n * Drag-the-ruler gesture for a horizontal slider. Translates pointer\n * movement into value changes quantized to `step`; the caller renders\n * the visuals and holds the value.\n *\n * The hook owns no state of its own — every value change is reported\n * through the supplied `onChange`. The \"current value\" is read from a\n * ref so closure staleness during a drag is impossible. Drag continues\n * past the wrapper's bounds (standard slider behaviour); a window-level\n * `pointerup` listener guarantees the drag ends and pointer capture\n * releases even if the underlying captured event never fires on the\n * wrapper.\n *\n * @param options Ruler-drag configuration. See `UseRulerDragOptions`.\n */\nexport function useRulerDrag(\n\toptions: UseRulerDragOptions\n): RulerDragHandlers {\n\tconst {\n\t\tvalue,\n\t\tonChange,\n\t\tmin,\n\t\tmax,\n\t\tstep,\n\t\tpixelsPerStep,\n\t\tdisabled,\n\t\tonPointerDownStart,\n\t} = options;\n\n\t// Per-drag state, including the last emitted value. Pointermove\n\t// handlers fire far faster than React commits, so they cannot read\n\t// `value` from closure. Pointerdown seeds it from the committed `value`.\n\tconst latestRef = useRef< {\n\t\tvalue: number;\n\t\tstartX: number;\n\t\tstartValue: number;\n\t\tactiveStep: number;\n\t\tdragging: boolean;\n\t\tcaptureElement: HTMLElement | null;\n\t\tcapturePointerId: number;\n\t\twindowPointerUp: ( () => void ) | null;\n\t} >( {\n\t\tvalue,\n\t\tstartX: 0,\n\t\tstartValue: 0,\n\t\tactiveStep: step,\n\t\tdragging: false,\n\t\tcaptureElement: null,\n\t\tcapturePointerId: 0,\n\t\twindowPointerUp: null,\n\t} );\n\n\tconst endDrag = useCallback( () => {\n\t\tconst state = latestRef.current;\n\t\tif ( ! state.dragging ) {\n\t\t\treturn;\n\t\t}\n\t\tstate.dragging = false;\n\t\tif (\n\t\t\tstate.captureElement &&\n\t\t\tstate.captureElement.hasPointerCapture( state.capturePointerId )\n\t\t) {\n\t\t\tstate.captureElement.releasePointerCapture(\n\t\t\t\tstate.capturePointerId\n\t\t\t);\n\t\t}\n\t\tstate.captureElement = null;\n\t\tif ( state.windowPointerUp ) {\n\t\t\twindow.removeEventListener( 'pointerup', state.windowPointerUp );\n\t\t\twindow.removeEventListener(\n\t\t\t\t'pointercancel',\n\t\t\t\tstate.windowPointerUp\n\t\t\t);\n\t\t\tstate.windowPointerUp = null;\n\t\t}\n\t}, [] );\n\n\t// Cleanup any in-flight drag on unmount so we never leak window\n\t// listeners or stale pointer capture.\n\tuseEffect( () => endDrag, [ endDrag ] );\n\n\t// Becoming disabled mid-drag ends it, so a rotation cannot keep\n\t// changing after a save has read it.\n\tuseEffect( () => {\n\t\tif ( disabled ) {\n\t\t\tendDrag();\n\t\t}\n\t}, [ disabled, endDrag ] );\n\n\tconst onPointerDown = useCallback(\n\t\t( event: React.PointerEvent< HTMLElement > ) => {\n\t\t\tif ( disabled || event.button !== 0 ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst state = latestRef.current;\n\t\t\tevent.currentTarget.setPointerCapture( event.pointerId );\n\t\t\tstate.captureElement = event.currentTarget;\n\t\t\tstate.capturePointerId = event.pointerId;\n\t\t\tstate.startX = event.clientX;\n\t\t\tstate.value = value;\n\t\t\tstate.startValue = value;\n\t\t\tstate.activeStep = event.shiftKey ? step / 2 : step;\n\t\t\tstate.dragging = true;\n\t\t\tonPointerDownStart?.();\n\n\t\t\t// Window-level backstop. With `setPointerCapture`, the\n\t\t\t// element should always receive `pointerup` even when the\n\t\t\t// cursor is released outside its bounds — but in practice\n\t\t\t// some browsers / window-blur sequences drop the event. The\n\t\t\t// window listener guarantees the drag ends and capture\n\t\t\t// releases.\n\t\t\tconst onWindowUp = () => endDrag();\n\t\t\tstate.windowPointerUp = onWindowUp;\n\t\t\twindow.addEventListener( 'pointerup', onWindowUp );\n\t\t\twindow.addEventListener( 'pointercancel', onWindowUp );\n\t\t},\n\t\t[ disabled, onPointerDownStart, endDrag, step, value ]\n\t);\n\n\tconst onPointerMove = useCallback(\n\t\t( event: React.PointerEvent< HTMLElement > ) => {\n\t\t\tconst state = latestRef.current;\n\t\t\tif ( disabled || ! state.dragging ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Shift toggles fine mode mid-drag. The drag math computes\n\t\t\t// from `startX` / `startValue`, so naively swapping `step`\n\t\t\t// would yank the value backward. Rebase to the current\n\t\t\t// pointer + value so the granularity changes without a\n\t\t\t// jump.\n\t\t\tconst requestedStep = event.shiftKey ? step / 2 : step;\n\t\t\tif ( requestedStep !== state.activeStep ) {\n\t\t\t\tstate.startX = event.clientX;\n\t\t\t\tstate.startValue = state.value;\n\t\t\t\tstate.activeStep = requestedStep;\n\t\t\t}\n\t\t\tconst deltaPx = event.clientX - state.startX;\n\t\t\tconst deltaValue = pxToValueDelta(\n\t\t\t\tdeltaPx,\n\t\t\t\tpixelsPerStep,\n\t\t\t\tstate.activeStep\n\t\t\t);\n\t\t\tconst raw = state.startValue + deltaValue;\n\t\t\tconst stepped = quantize( raw, state.activeStep );\n\t\t\tconst next = clampValue( stepped, min, max );\n\t\t\tif ( next !== state.value ) {\n\t\t\t\t// Update the ref synchronously so consecutive pointermove\n\t\t\t\t// events that fire before React commits still see the\n\t\t\t\t// last *emitted* value as `previous` for the next math.\n\t\t\t\tstate.value = next;\n\t\t\t\tonChange( next );\n\t\t\t}\n\t\t},\n\t\t[ disabled, onChange, min, max, step, pixelsPerStep ]\n\t);\n\n\treturn {\n\t\tonPointerDown,\n\t\tonPointerMove,\n\t\tonPointerUp: endDrag,\n\t\tonPointerCancel: endDrag,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAaA,SAAgB,eACf,SACA,eACA,MACS;CACT,OAAS,CAAC,UAAU,gBAAkB;AACvC;;;;;;;;AASA,SAAgB,WAAY,OAAe,KAAa,KAAsB;CAC7E,IAAK,QAAQ,KACZ,OAAO;CAER,IAAK,QAAQ,KACZ,OAAO;CAER,OAAO;AACR;;;;;;;AAQA,SAAgB,SAAU,OAAe,MAAuB;CAC/D,OAAO,KAAK,MAAO,QAAQ,IAAK,IAAI;AACrC;;;;;;;;;;;;;;;;AAoCA,SAAgB,aACf,SACoB;CACpB,MAAM,EACL,OACA,UACA,KACA,KACA,MACA,eACA,UACA,uBACG;CAKJ,MAAM,aAAA,GAAYA,mBAAAA,OAAAA,CASb;EACJ;EACA,QAAQ;EACR,YAAY;EACZ,YAAY;EACZ,UAAU;EACV,gBAAgB;EAChB,kBAAkB;EAClB,iBAAiB;CAClB,CAAE;CAEF,MAAM,WAAA,GAAUC,mBAAAA,YAAAA,OAAmB;EAClC,MAAM,QAAQ,UAAU;EACxB,IAAK,CAAE,MAAM,UACZ;EAED,MAAM,WAAW;EACjB,IACC,MAAM,kBACN,MAAM,eAAe,kBAAmB,MAAM,gBAAiB,GAE/D,MAAM,eAAe,sBACpB,MAAM,gBACP;EAED,MAAM,iBAAiB;EACvB,IAAK,MAAM,iBAAkB;GAC5B,OAAO,oBAAqB,aAAa,MAAM,eAAgB;GAC/D,OAAO,oBACN,iBACA,MAAM,eACP;GACA,MAAM,kBAAkB;EACzB;CACD,GAAG,CAAC,CAAE;CAINC,CAAAA,GAAAA,mBAAAA,UAAAA,OAAiB,SAAS,CAAE,OAAQ,CAAE;CAItCA,CAAAA,GAAAA,mBAAAA,UAAAA,OAAiB;EAChB,IAAK,UACJ,QAAQ;CAEV,GAAG,CAAE,UAAU,OAAQ,CAAE;CAqEzB,OAAO;EACN,gBAAA,GApEqBD,mBAAAA,YAAAA,EACnB,UAA8C;GAC/C,IAAK,YAAY,MAAM,WAAW,GACjC;GAED,MAAM,QAAQ,UAAU;GACxB,MAAM,cAAc,kBAAmB,MAAM,SAAU;GACvD,MAAM,iBAAiB,MAAM;GAC7B,MAAM,mBAAmB,MAAM;GAC/B,MAAM,SAAS,MAAM;GACrB,MAAM,QAAQ;GACd,MAAM,aAAa;GACnB,MAAM,aAAa,MAAM,WAAW,OAAO,IAAI;GAC/C,MAAM,WAAW;GACjB,qBAAqB;GAQrB,MAAM,mBAAmB,QAAQ;GACjC,MAAM,kBAAkB;GACxB,OAAO,iBAAkB,aAAa,UAAW;GACjD,OAAO,iBAAkB,iBAAiB,UAAW;EACtD,GACA;GAAE;GAAU;GAAoB;GAAS;GAAM;EAAM,CAyCzC;EACZ,gBAAA,GAvCqBA,mBAAAA,YAAAA,EACnB,UAA8C;GAC/C,MAAM,QAAQ,UAAU;GACxB,IAAK,YAAY,CAAE,MAAM,UACxB;GAOD,MAAM,gBAAgB,MAAM,WAAW,OAAO,IAAI;GAClD,IAAK,kBAAkB,MAAM,YAAa;IACzC,MAAM,SAAS,MAAM;IACrB,MAAM,aAAa,MAAM;IACzB,MAAM,aAAa;GACpB;GAEA,MAAM,aAAa,eADH,MAAM,UAAU,MAAM,QAGrC,eACA,MAAM,UACP;GAGA,MAAM,OAAO,WADG,SADJ,MAAM,aAAa,YACA,MAAM,UACN,GAAG,KAAK,GAAI;GAC3C,IAAK,SAAS,MAAM,OAAQ;IAI3B,MAAM,QAAQ;IACd,SAAU,IAAK;GAChB;EACD,GACA;GAAE;GAAU;GAAU;GAAK;GAAK;GAAM;EAAc,CAKxC;EACZ,aAAa;EACb,iBAAiB;CAClB;AACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-crop-gesture-handlers.cjs","names":["useMediaEditor","useRef","useCallback"],"sources":["../../src/hooks/use-crop-gesture-handlers.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from '@wordpress/element';\nimport { useMediaEditor } from '../state';\n\n/**\n * Data attribute applied to crop control wrappers. The modal's keyboard\n * shortcut handler uses this to distinguish crop controls (where custom\n * undo/redo should fire) from metadata text fields (where the browser's\n * native undo should be preserved).\n */\nexport const CROP_CONTROL_ATTR = 'data-crop-control';\n\n/** Idle window used to group repeated keyboard input into one gesture. */\nconst KEYBOARD_GESTURE_IDLE_MS = 300;\n\nexport interface UseCropGestureHandlersOptions {\n\t/**\n\t * When `true` (default), key-up closes the gesture so each\n\t * discrete keypress becomes its own undo step. Set to `false` for\n\t * continuous-input controls (e.g. the rotation ruler) where rapid\n\t * keypresses should coalesce into a single history entry across\n\t * the whole gesture.\n\t */\n\tcommitOnKeyUp?: boolean;\n}\n\n/**\n * Event handler props to spread onto a wrapper element around a crop\n * control. Marks the wrapper as a crop control (via `data-crop-control`)\n * so the modal's Cmd+Z handler can identify it, and wires gesture\n * boundaries on the composite store so a slider drag becomes a single\n * undo entry rather than one per tick.\n *\n * Usage:\n * const gestureHandlers = useCropGestureHandlers();\n * <div role=\"presentation\" { ...gestureHandlers }>\n * <RangeControl ... />\n * </div>\n *\n * @param options Optional behavior flags.\n */\nexport function useCropGestureHandlers(\n\toptions: UseCropGestureHandlersOptions = {}\n) {\n\tconst { commitOnKeyUp = true } = options;\n\tconst { beginGesture, endGesture } = useMediaEditor();\n\tconst keyboardTimerRef = useRef<\n\t\tReturnType< typeof setTimeout > | undefined\n\t>( undefined );\n\n\tconst clearKeyboardTimer = useCallback( () => {\n\t\tclearTimeout( keyboardTimerRef.current );\n\t}, [] );\n\n\tconst scheduleKeyboardEnd = useCallback( () => {\n\t\tclearKeyboardTimer();\n\t\tkeyboardTimerRef.current = setTimeout( () => {\n\t\t\tendGesture();\n\t\t}, KEYBOARD_GESTURE_IDLE_MS );\n\t}, [ clearKeyboardTimer, endGesture ] );\n\n\tuseEffect( () => clearKeyboardTimer, [ clearKeyboardTimer ] );\n\n\tconst handlePointerDownCapture = useCallback( () => {\n\t\tclearKeyboardTimer();\n\t\tbeginGesture();\n\t}, [ beginGesture, clearKeyboardTimer ] );\n\n\tconst handlePointerEnd = useCallback( () => {\n\t\tclearKeyboardTimer();\n\t\tendGesture();\n\t}, [ clearKeyboardTimer, endGesture ] );\n\n\tconst handleKeyDownCapture = useCallback( () => {\n\t\tbeginGesture();\n\t\tif ( ! commitOnKeyUp ) {\n\t\t\tscheduleKeyboardEnd();\n\t\t}\n\t}, [ beginGesture, commitOnKeyUp, scheduleKeyboardEnd ] );\n\n\tconst handleKeyUp = useCallback( () => {\n\t\tif ( commitOnKeyUp ) {\n\t\t\tendGesture();\n\t\t\treturn;\n\t\t}\n\t\tscheduleKeyboardEnd();\n\t}, [ commitOnKeyUp, endGesture, scheduleKeyboardEnd ] );\n\n\treturn {\n\t\t[ CROP_CONTROL_ATTR ]: true,\n\t\tonPointerDownCapture: handlePointerDownCapture,\n\t\tonPointerUp: handlePointerEnd,\n\t\tonPointerCancel: handlePointerEnd,\n\t\tonKeyDownCapture: handleKeyDownCapture,\n\t\tonKeyUp: handleKeyUp,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;AASA,MAAa,oBAAoB;;AAGjC,MAAM,2BAA2B;;;;;;;;;;;;;;;;AA4BjC,SAAgB,uBACf,UAAyC,CAAC,GACzC;CACD,MAAM,EAAE,gBAAgB,SAAS;CACjC,MAAM,EAAE,cAAc,gBAAA,GAAeA,kBAAAA,eAAAA,CAAe;CACpD,MAAM,oBAAA,GAAmBC,mBAAAA,OAAAA,CAEtB,KAAA,CAAU;CAEb,MAAM,sBAAA,GAAqBC,mBAAAA,YAAAA,OAAmB;EAC7C,aAAc,iBAAiB,OAAQ;CACxC,GAAG,CAAC,CAAE;CAEN,MAAM,uBAAA,GAAsBA,mBAAAA,YAAAA,OAAmB;EAC9C,mBAAmB;EACnB,iBAAiB,UAAU,iBAAkB;GAC5C,WAAW;EACZ,GAAG,wBAAyB;CAC7B,GAAG,CAAE,oBAAoB,UAAW,CAAE;CAEtC,CAAA,GAAA,mBAAA,UAAA,OAAiB,oBAAoB,CAAE,kBAAmB,CAAE;CAE5D,MAAM,4BAAA,GAA2BA,mBAAAA,YAAAA,OAAmB;EACnD,mBAAmB;EACnB,aAAa;CACd,GAAG,CAAE,cAAc,kBAAmB,CAAE;CAExC,MAAM,oBAAA,GAAmBA,mBAAAA,YAAAA,OAAmB;EAC3C,mBAAmB;EACnB,WAAW;CACZ,GAAG,CAAE,oBAAoB,UAAW,CAAE;CAEtC,MAAM,wBAAA,GAAuBA,mBAAAA,YAAAA,OAAmB;EAC/C,aAAa;EACb,IAAK,CAAE,eACN,oBAAoB;CAEtB,GAAG;EAAE;EAAc;EAAe;CAAoB,CAAE;CAExD,MAAM,eAAA,GAAcA,mBAAAA,YAAAA,OAAmB;EACtC,IAAK,eAAgB;GACpB,WAAW;GACX;EACD;EACA,oBAAoB;CACrB,GAAG;EAAE;EAAe;EAAY;CAAoB,CAAE;CAEtD,OAAO;GACJ,oBAAqB;EACvB,sBAAsB;EACtB,aAAa;EACb,iBAAiB;EACjB,kBAAkB;EAClB,SAAS;CACV;AACD"}
1
+ {"version":3,"file":"use-crop-gesture-handlers.cjs","names":["useMediaEditor","useRef","useCallback","useEffect"],"sources":["../../src/hooks/use-crop-gesture-handlers.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from '@wordpress/element';\nimport { useMediaEditor } from '../state';\n\n/**\n * Data attribute applied to crop control wrappers. The modal's keyboard\n * shortcut handler uses this to distinguish crop controls (where custom\n * undo/redo should fire) from metadata text fields (where the browser's\n * native undo should be preserved).\n */\nexport const CROP_CONTROL_ATTR = 'data-crop-control';\n\n/** Idle window used to group repeated keyboard input into one gesture. */\nconst KEYBOARD_GESTURE_IDLE_MS = 300;\n\nexport interface UseCropGestureHandlersOptions {\n\t/**\n\t * When `true` (default), key-up closes the gesture so each\n\t * discrete keypress becomes its own undo step. Set to `false` for\n\t * continuous-input controls (e.g. the rotation ruler) where rapid\n\t * keypresses should coalesce into a single history entry across\n\t * the whole gesture.\n\t */\n\tcommitOnKeyUp?: boolean;\n}\n\n/**\n * Event handler props to spread onto a wrapper element around a crop\n * control. Marks the wrapper as a crop control (via `data-crop-control`)\n * so the modal's Cmd+Z handler can identify it, and wires gesture\n * boundaries on the composite store so a slider drag becomes a single\n * undo entry rather than one per tick.\n *\n * Usage:\n * const gestureHandlers = useCropGestureHandlers();\n * <div role=\"presentation\" { ...gestureHandlers }>\n * <RangeControl ... />\n * </div>\n *\n * @param options Optional behavior flags.\n */\nexport function useCropGestureHandlers(\n\toptions: UseCropGestureHandlersOptions = {}\n) {\n\tconst { commitOnKeyUp = true } = options;\n\tconst { beginGesture, endGesture } = useMediaEditor();\n\tconst keyboardTimerRef = useRef<\n\t\tReturnType< typeof setTimeout > | undefined\n\t>( undefined );\n\n\tconst clearKeyboardTimer = useCallback( () => {\n\t\tclearTimeout( keyboardTimerRef.current );\n\t}, [] );\n\n\tconst scheduleKeyboardEnd = useCallback( () => {\n\t\tclearKeyboardTimer();\n\t\tkeyboardTimerRef.current = setTimeout( () => {\n\t\t\tendGesture();\n\t\t}, KEYBOARD_GESTURE_IDLE_MS );\n\t}, [ clearKeyboardTimer, endGesture ] );\n\n\tuseEffect( () => clearKeyboardTimer, [ clearKeyboardTimer ] );\n\n\tconst handlePointerDownCapture = useCallback( () => {\n\t\tclearKeyboardTimer();\n\t\tbeginGesture();\n\t}, [ beginGesture, clearKeyboardTimer ] );\n\n\tconst handlePointerEnd = useCallback( () => {\n\t\tclearKeyboardTimer();\n\t\tendGesture();\n\t}, [ clearKeyboardTimer, endGesture ] );\n\n\tconst handleKeyDownCapture = useCallback( () => {\n\t\tbeginGesture();\n\t\tif ( ! commitOnKeyUp ) {\n\t\t\tscheduleKeyboardEnd();\n\t\t}\n\t}, [ beginGesture, commitOnKeyUp, scheduleKeyboardEnd ] );\n\n\tconst handleKeyUp = useCallback( () => {\n\t\tif ( commitOnKeyUp ) {\n\t\t\tendGesture();\n\t\t\treturn;\n\t\t}\n\t\tscheduleKeyboardEnd();\n\t}, [ commitOnKeyUp, endGesture, scheduleKeyboardEnd ] );\n\n\treturn {\n\t\t[ CROP_CONTROL_ATTR ]: true,\n\t\tonPointerDownCapture: handlePointerDownCapture,\n\t\tonPointerUp: handlePointerEnd,\n\t\tonPointerCancel: handlePointerEnd,\n\t\tonKeyDownCapture: handleKeyDownCapture,\n\t\tonKeyUp: handleKeyUp,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;AASA,MAAa,oBAAoB;;AAGjC,MAAM,2BAA2B;;;;;;;;;;;;;;;;AA4BjC,SAAgB,uBACf,UAAyC,CAAC,GACzC;CACD,MAAM,EAAE,gBAAgB,SAAS;CACjC,MAAM,EAAE,cAAc,gBAAA,GAAeA,kBAAAA,eAAAA,CAAe;CACpD,MAAM,oBAAA,GAAmBC,mBAAAA,OAAAA,CAEtB,KAAA,CAAU;CAEb,MAAM,sBAAA,GAAqBC,mBAAAA,YAAAA,OAAmB;EAC7C,aAAc,iBAAiB,OAAQ;CACxC,GAAG,CAAC,CAAE;CAEN,MAAM,uBAAA,GAAsBA,mBAAAA,YAAAA,OAAmB;EAC9C,mBAAmB;EACnB,iBAAiB,UAAU,iBAAkB;GAC5C,WAAW;EACZ,GAAG,wBAAyB;CAC7B,GAAG,CAAE,oBAAoB,UAAW,CAAE;CAEtCC,CAAAA,GAAAA,mBAAAA,UAAAA,OAAiB,oBAAoB,CAAE,kBAAmB,CAAE;CAE5D,MAAM,4BAAA,GAA2BD,mBAAAA,YAAAA,OAAmB;EACnD,mBAAmB;EACnB,aAAa;CACd,GAAG,CAAE,cAAc,kBAAmB,CAAE;CAExC,MAAM,oBAAA,GAAmBA,mBAAAA,YAAAA,OAAmB;EAC3C,mBAAmB;EACnB,WAAW;CACZ,GAAG,CAAE,oBAAoB,UAAW,CAAE;CAEtC,MAAM,wBAAA,GAAuBA,mBAAAA,YAAAA,OAAmB;EAC/C,aAAa;EACb,IAAK,CAAE,eACN,oBAAoB;CAEtB,GAAG;EAAE;EAAc;EAAe;CAAoB,CAAE;CAExD,MAAM,eAAA,GAAcA,mBAAAA,YAAAA,OAAmB;EACtC,IAAK,eAAgB;GACpB,WAAW;GACX;EACD;EACA,oBAAoB;CACrB,GAAG;EAAE;EAAe;EAAY;CAAoB,CAAE;CAEtD,OAAO;GACJ,oBAAqB;EACvB,sBAAsB;EACtB,aAAa;EACb,iBAAiB;EACjB,kBAAkB;EAClB,SAAS;CACV;AACD"}
package/build/index.cjs CHANGED
@@ -11,12 +11,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
11
11
  var __getProtoOf = Object.getPrototypeOf;
12
12
  var __hasOwnProp = Object.prototype.hasOwnProperty;
13
13
  var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
15
- key = keys[i];
16
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
- get: ((k) => from[k]).bind(null, key),
18
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
- });
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
16
+ desc = __getOwnPropDesc(from, key);
17
+ __defProp(to, key, {
18
+ get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
19
+ enumerable: !desc || desc.enumerable
20
+ });
21
+ }
20
22
  }
21
23
  return to;
22
24
  };
@@ -26,10 +28,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
28
  }) : target, mod));
27
29
  let __components_media_editor_provider_index_tsx = require("./components/media-editor-provider/index.cjs");
28
30
  let __components_media_preview_index_tsx = require("./components/media-preview/index.cjs");
29
- __components_media_preview_index_tsx = __toESM(__components_media_preview_index_tsx);
30
31
  let __components_media_form_index_tsx = require("./components/media-form/index.cjs");
31
- __components_media_form_index_tsx = __toESM(__components_media_form_index_tsx);
32
32
  let __private_apis_ts = require("./private-apis.cjs");
33
+ __components_media_preview_index_tsx = __toESM(__components_media_preview_index_tsx);
34
+ __components_media_form_index_tsx = __toESM(__components_media_form_index_tsx);
33
35
  Object.defineProperty(exports, "MediaEditorProvider", {
34
36
  enumerable: true,
35
37
  get: function() {
@@ -1 +1 @@
1
- {"version":3,"file":"private-apis.cjs","names":["lock"],"sources":["../src/private-apis.ts"],"sourcesContent":["import { lock } from './lock-unlock';\nimport { store } from './store';\nimport { MediaEditorModal } from './components/media-editor-modal';\nimport { MediaEditor } from './components/media-editor';\n\nexport const privateApis = {};\nlock( privateApis, {\n\tstore,\n\tMediaEditor,\n\tMediaEditorModal,\n} );\n"],"mappings":";;;;;;;;;;AAKA,MAAa,cAAc,CAAC;CAC5BA,GAAAA,iBAAAA,KAAAA,CAAM,aAAa;CAClB,OAAA,iBAAA;CACA,aAAA,oCAAA;CACA,kBAAA,0CAAA;AACD,CAAE"}
1
+ {"version":3,"file":"private-apis.cjs","names":["lock","store","MediaEditor","MediaEditorModal"],"sources":["../src/private-apis.ts"],"sourcesContent":["import { lock } from './lock-unlock';\nimport { store } from './store';\nimport { MediaEditorModal } from './components/media-editor-modal';\nimport { MediaEditor } from './components/media-editor';\n\nexport const privateApis = {};\nlock( privateApis, {\n\tstore,\n\tMediaEditor,\n\tMediaEditorModal,\n} );\n"],"mappings":";;;;;;;;;;AAKA,MAAa,cAAc,CAAC;CAC5BA,GAAAA,iBAAAA,KAAAA,CAAM,aAAa;CAClBC,OAAAA,iBAAAA;CACAC,aAAAA,oCAAAA;CACAC,kBAAAA,0CAAAA;AACD,CAAE"}
@@ -4,11 +4,16 @@ Object.defineProperties(exports, {
4
4
  [Symbol.toStringTag]: { value: "Module" }
5
5
  });
6
6
  let _wordpress_i18n = require("@wordpress/i18n");
7
- let ___image_editor_index_ts = require("../image-editor/index.cjs");
8
7
  // packages/media-editor/src/state/aspect-ratio-presets.ts
9
8
  /**
10
- * The presets the editor offers by default. The labels live here rather
11
- * than in the cropper core, which has no user-facing strings.
9
+ * Sentinel value for "Original" aspect ratio — resolved at runtime
10
+ * to the image's natural width / height.
11
+ */
12
+ const ORIGINAL_ASPECT_RATIO = -1;
13
+ /**
14
+ * The presets the editor offers by default. They live here rather than
15
+ * in the image editor package, because which ratios to offer, and what
16
+ * to call them, is a product choice. The package takes a plain number.
12
17
  */
13
18
  const DEFAULT_ASPECT_RATIOS = [
14
19
  {
@@ -17,7 +22,7 @@ const DEFAULT_ASPECT_RATIOS = [
17
22
  },
18
23
  {
19
24
  label: (0, _wordpress_i18n.__)("Original"),
20
- value: ___image_editor_index_ts.ORIGINAL_ASPECT_RATIO
25
+ value: -1
21
26
  },
22
27
  {
23
28
  label: (0, _wordpress_i18n.__)("Square (1:1)"),
@@ -37,11 +42,11 @@ const DEFAULT_ASPECT_RATIOS = [
37
42
  },
38
43
  {
39
44
  label: (0, _wordpress_i18n.__)("Classic portrait (3:4)"),
40
- value: 3 / 4
45
+ value: .75
41
46
  },
42
47
  {
43
48
  label: (0, _wordpress_i18n.__)("Photo (3:2)"),
44
- value: 3 / 2
49
+ value: 1.5
45
50
  },
46
51
  {
47
52
  label: (0, _wordpress_i18n.__)("Photo portrait (2:3)"),
@@ -49,5 +54,6 @@ const DEFAULT_ASPECT_RATIOS = [
49
54
  }
50
55
  ];
51
56
  exports.DEFAULT_ASPECT_RATIOS = DEFAULT_ASPECT_RATIOS;
57
+ exports.ORIGINAL_ASPECT_RATIO = ORIGINAL_ASPECT_RATIO;
52
58
 
53
59
  //# sourceMappingURL=aspect-ratio-presets.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"aspect-ratio-presets.cjs","names":["__","ORIGINAL_ASPECT_RATIO"],"sources":["../../src/state/aspect-ratio-presets.ts"],"sourcesContent":["import { __ } from '@wordpress/i18n';\nimport { ORIGINAL_ASPECT_RATIO, type AspectRatioPreset } from '../image-editor';\n\n/**\n * The presets the editor offers by default. The labels live here rather\n * than in the cropper core, which has no user-facing strings.\n */\nexport const DEFAULT_ASPECT_RATIOS: AspectRatioPreset[] = [\n\t{ label: __( 'Free' ), value: 0 },\n\t{ label: __( 'Original' ), value: ORIGINAL_ASPECT_RATIO },\n\t{ label: __( 'Square (1:1)' ), value: 1 },\n\t{ label: __( 'Landscape (16:9)' ), value: 16 / 9 },\n\t{ label: __( 'Portrait (9:16)' ), value: 9 / 16 },\n\t{ label: __( 'Classic (4:3)' ), value: 4 / 3 },\n\t{ label: __( 'Classic portrait (3:4)' ), value: 3 / 4 },\n\t{ label: __( 'Photo (3:2)' ), value: 3 / 2 },\n\t{ label: __( 'Photo portrait (2:3)' ), value: 2 / 3 },\n];\n"],"mappings":";;;;;;;;;;;;AAOA,MAAa,wBAA6C;CACzD;EAAE,QAAA,GAAOA,gBAAAA,GAAAA,CAAI,MAAO;EAAG,OAAO;CAAE;CAChC;EAAE,QAAA,GAAOA,gBAAAA,GAAAA,CAAI,UAAW;EAAG,OAAOC,yBAAAA;CAAsB;CACxD;EAAE,QAAA,GAAOD,gBAAAA,GAAAA,CAAI,cAAe;EAAG,OAAO;CAAE;CACxC;EAAE,QAAA,GAAOA,gBAAAA,GAAAA,CAAI,kBAAmB;EAAG,OAAO,KAAK;CAAE;CACjD;EAAE,QAAA,GAAOA,gBAAAA,GAAAA,CAAI,iBAAkB;EAAG,OAAO,IAAI;CAAG;CAChD;EAAE,QAAA,GAAOA,gBAAAA,GAAAA,CAAI,eAAgB;EAAG,OAAO,IAAI;CAAE;CAC7C;EAAE,QAAA,GAAOA,gBAAAA,GAAAA,CAAI,wBAAyB;EAAG,OAAO,IAAI;CAAE;CACtD;EAAE,QAAA,GAAOA,gBAAAA,GAAAA,CAAI,aAAc;EAAG,OAAO,IAAI;CAAE;CAC3C;EAAE,QAAA,GAAOA,gBAAAA,GAAAA,CAAI,sBAAuB;EAAG,OAAO,IAAI;CAAE;AACrD"}
1
+ {"version":3,"file":"aspect-ratio-presets.cjs","names":["__"],"sources":["../../src/state/aspect-ratio-presets.ts"],"sourcesContent":["import { __ } from '@wordpress/i18n';\n\n/**\n * An aspect ratio preset with a human-readable label.\n */\nexport interface AspectRatioPreset {\n\t/** Display label (e.g., \"Square (1:1)\"). */\n\tlabel: string;\n\t/**\n\t * The aspect ratio value (width / height). 0 = free,\n\t * `ORIGINAL_ASPECT_RATIO` = the image's own ratio.\n\t */\n\tvalue: number;\n}\n\n/**\n * Sentinel value for \"Original\" aspect ratio — resolved at runtime\n * to the image's natural width / height.\n */\nexport const ORIGINAL_ASPECT_RATIO = -1;\n\n/**\n * The presets the editor offers by default. They live here rather than\n * in the image editor package, because which ratios to offer, and what\n * to call them, is a product choice. The package takes a plain number.\n */\nexport const DEFAULT_ASPECT_RATIOS: AspectRatioPreset[] = [\n\t{ label: __( 'Free' ), value: 0 },\n\t{ label: __( 'Original' ), value: ORIGINAL_ASPECT_RATIO },\n\t{ label: __( 'Square (1:1)' ), value: 1 },\n\t{ label: __( 'Landscape (16:9)' ), value: 16 / 9 },\n\t{ label: __( 'Portrait (9:16)' ), value: 9 / 16 },\n\t{ label: __( 'Classic (4:3)' ), value: 4 / 3 },\n\t{ label: __( 'Classic portrait (3:4)' ), value: 3 / 4 },\n\t{ label: __( 'Photo (3:2)' ), value: 3 / 2 },\n\t{ label: __( 'Photo portrait (2:3)' ), value: 2 / 3 },\n];\n"],"mappings":";;;;;;;;;;;AAmBA,MAAa,wBAAwB;;;;;;AAOrC,MAAa,wBAA6C;CACzD;EAAE,QAAA,GAAOA,gBAAAA,GAAAA,CAAI,MAAO;EAAG,OAAO;CAAE;CAChC;EAAE,QAAA,GAAOA,gBAAAA,GAAAA,CAAI,UAAW;EAAG,OAAA;CAA6B;CACxD;EAAE,QAAA,GAAOA,gBAAAA,GAAAA,CAAI,cAAe;EAAG,OAAO;CAAE;CACxC;EAAE,QAAA,GAAOA,gBAAAA,GAAAA,CAAI,kBAAmB;EAAG,OAAO,KAAK;CAAE;CACjD;EAAE,QAAA,GAAOA,gBAAAA,GAAAA,CAAI,iBAAkB;EAAG,OAAO,IAAI;CAAG;CAChD;EAAE,QAAA,GAAOA,gBAAAA,GAAAA,CAAI,eAAgB;EAAG,OAAO,IAAI;CAAE;CAC7C;EAAE,QAAA,GAAOA,gBAAAA,GAAAA,CAAI,wBAAyB;EAAG,OAAO;CAAM;CACtD;EAAE,QAAA,GAAOA,gBAAAA,GAAAA,CAAI,aAAc;EAAG,OAAO;CAAM;CAC3C;EAAE,QAAA,GAAOA,gBAAAA,GAAAA,CAAI,sBAAuB;EAAG,OAAO,IAAI;CAAE;AACrD"}
@@ -11,12 +11,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
11
11
  var __getProtoOf = Object.getPrototypeOf;
12
12
  var __hasOwnProp = Object.prototype.hasOwnProperty;
13
13
  var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
15
- key = keys[i];
16
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
- get: ((k) => from[k]).bind(null, key),
18
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
- });
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
16
+ desc = __getOwnPropDesc(from, key);
17
+ __defProp(to, key, {
18
+ get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
19
+ enumerable: !desc || desc.enumerable
20
+ });
21
+ }
20
22
  }
21
23
  return to;
22
24
  };
@@ -25,64 +27,36 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
27
  enumerable: true
26
28
  }) : target, mod));
27
29
  let fast_deep_equal_es6_index_js = require("fast-deep-equal/es6/index.js");
28
- fast_deep_equal_es6_index_js = __toESM(fast_deep_equal_es6_index_js);
29
- let ___image_editor_core_index_ts = require("../image-editor/core/index.cjs");
30
+ let _wordpress_image_editor = require("@wordpress/image-editor");
30
31
  let __types_ts = require("./types.cjs");
32
+ fast_deep_equal_es6_index_js = __toESM(fast_deep_equal_es6_index_js);
31
33
  // packages/media-editor/src/state/composite-reducer.ts
32
34
  /**
33
- * Pure composite reducer for the media editor.
35
+ * Pure reducer for the media editor.
34
36
  *
35
- * Delegates `CROPPER`-tagged actions to the framework-agnostic
36
- * `cropperReducer` and owns first-class transitions for the sidebar
37
- * `cropOptions` slice. `RESTORE_SNAPSHOT` replaces the whole composite
38
- * in one transaction (used by undo/redo).
37
+ * The image editor works out its own next state (through the controller from
38
+ * `@wordpress/image-editor`) and this reducer stores it. The reducer
39
+ * also owns the sidebar crop options and the named edits.
39
40
  *
40
- * Note: this reducer carries NO history of its own. Snapshots and
41
- * stacks live in the `useMediaEditorState` hook that wraps it.
41
+ * This reducer keeps no history; `useMediaEditorState` does.
42
42
  *
43
- * @param state Current composite state.
43
+ * @param state Current state.
44
44
  * @param action Action to apply.
45
- * @return Next composite state.
45
+ * @return Next state.
46
46
  */
47
47
  function mediaEditorReducer(state, action) {
48
48
  switch (action.type) {
49
- case "CROPPER": {
50
- const nextCropper = (0, ___image_editor_core_index_ts.cropperReducer)(state.cropper, action.action);
51
- if (nextCropper === state.cropper) return state;
52
- return {
53
- ...state,
54
- cropper: nextCropper
55
- };
56
- }
57
- case "SET_ASPECT_RATIO_VALUE": {
58
- const { presetKey, resolved, visualSize } = action.payload;
59
- const shouldReshape = resolved !== void 0 && resolved > 0 && visualSize.width > 0 && visualSize.height > 0;
60
- const nextCropOptions = {
49
+ case "SET_IMAGE_EDITOR": return action.payload === state.imageEditor ? state : {
50
+ ...state,
51
+ imageEditor: action.payload
52
+ };
53
+ case "SET_ASPECT_RATIO_VALUE": return state.cropOptions.aspectRatioValue === action.payload ? state : {
54
+ ...state,
55
+ cropOptions: {
61
56
  ...state.cropOptions,
62
- aspectRatioValue: presetKey
63
- };
64
- if (!shouldReshape) {
65
- if (state.cropOptions.aspectRatioValue === presetKey) return state;
66
- return {
67
- ...state,
68
- cropOptions: nextCropOptions
69
- };
57
+ aspectRatioValue: action.payload
70
58
  }
71
- const newCropRect = (0, ___image_editor_core_index_ts.computeInscribedRect)(resolved, visualSize);
72
- const nextCropper = (0, ___image_editor_core_index_ts.cropperReducer)(state.cropper, {
73
- type: "SET_CROP_RECT",
74
- payload: newCropRect
75
- });
76
- return {
77
- ...state,
78
- cropper: nextCropper,
79
- cropOptions: nextCropOptions
80
- };
81
- }
82
- case "RESET": {
83
- const next = buildInitialMediaEditorState((0, ___image_editor_core_index_ts.cropperReducer)(state.cropper, { type: "RESET" }));
84
- return areMediaEditorStatesEqual(state, next) ? state : next;
85
- }
59
+ };
86
60
  case "SET_EDIT": {
87
61
  const { name, value } = action.payload;
88
62
  if (value === void 0) {
@@ -103,42 +77,35 @@ function mediaEditorReducer(state, action) {
103
77
  }
104
78
  };
105
79
  }
106
- case "RESTORE_SNAPSHOT": return action.payload;
107
- case "VIEWPORT_ADJUST_CROP_RECT": {
108
- const nextCropper = (0, ___image_editor_core_index_ts.cropperReducer)(state.cropper, {
109
- type: "SET_CROP_RECT",
110
- payload: action.payload
111
- });
112
- if (nextCropper === state.cropper) return state;
113
- return {
114
- ...state,
115
- cropper: nextCropper
116
- };
80
+ case "RESET": {
81
+ const next = buildInitialMediaEditorState((0, _wordpress_image_editor.createImageEditorState)({ image: state.imageEditor.image }));
82
+ return areMediaEditorStatesEqual(state, next) ? state : next;
117
83
  }
84
+ case "RESTORE_SNAPSHOT": return action.payload;
118
85
  }
119
86
  }
120
87
  /**
121
- * Value-equality check for two composite states. Used by the history
122
- * machinery to dedup snapshots when an action turned out to be a no-op.
88
+ * Value-equality check for two media editor states. The history uses it
89
+ * to skip snapshots when an action turned out to be a no-op.
123
90
  *
124
- * @param a First composite state.
125
- * @param b Second composite state.
91
+ * @param a First state.
92
+ * @param b Second state.
126
93
  * @return Whether `a` and `b` are value-equal across all slices.
127
94
  */
128
95
  function areMediaEditorStatesEqual(a, b) {
129
96
  if (a === b) return true;
130
- return (0, ___image_editor_core_index_ts.areCropperStatesEqual)(a.cropper, b.cropper) && a.cropOptions.aspectRatioValue === b.cropOptions.aspectRatioValue && (0, fast_deep_equal_es6_index_js.default)(a.edits, b.edits);
97
+ return (0, _wordpress_image_editor.areImageEditorStatesEqual)(a.imageEditor, b.imageEditor) && a.cropOptions.aspectRatioValue === b.cropOptions.aspectRatioValue && (0, fast_deep_equal_es6_index_js.default)(a.edits, b.edits);
131
98
  }
132
99
  /**
133
- * Build the composite state a session starts from: the given cropper
134
- * slice, default crop options, and no edits.
100
+ * Build the state a session starts from: the given image editor state,
101
+ * default crop options, and no edits.
135
102
  *
136
- * @param cropper The cropper slice.
137
- * @return Composite initial state.
103
+ * @param imageEditor The image editor state.
104
+ * @return Initial state.
138
105
  */
139
- function buildInitialMediaEditorState(cropper) {
106
+ function buildInitialMediaEditorState(imageEditor) {
140
107
  return {
141
- cropper,
108
+ imageEditor,
142
109
  cropOptions: { ...__types_ts.DEFAULT_CROP_OPTIONS },
143
110
  edits: {}
144
111
  };
@@ -1 +1 @@
1
- {"version":3,"file":"composite-reducer.cjs","names":["cropperReducer","computeInscribedRect","fastDeepEqual","areCropperStatesEqual","DEFAULT_CROP_OPTIONS"],"sources":["../../src/state/composite-reducer.ts"],"sourcesContent":["import fastDeepEqual from 'fast-deep-equal/es6/index.js';\nimport type { CropperState } from '../image-editor';\nimport {\n\tcropperReducer,\n\tareCropperStatesEqual,\n\tcomputeInscribedRect,\n} from '../image-editor/core';\nimport {\n\tDEFAULT_CROP_OPTIONS,\n\ttype CropOptionsSlice,\n\ttype MediaEditorAction,\n\ttype MediaEditorState,\n} from './types';\n\n/**\n * Pure composite reducer for the media editor.\n *\n * Delegates `CROPPER`-tagged actions to the framework-agnostic\n * `cropperReducer` and owns first-class transitions for the sidebar\n * `cropOptions` slice. `RESTORE_SNAPSHOT` replaces the whole composite\n * in one transaction (used by undo/redo).\n *\n * Note: this reducer carries NO history of its own. Snapshots and\n * stacks live in the `useMediaEditorState` hook that wraps it.\n *\n * @param state Current composite state.\n * @param action Action to apply.\n * @return Next composite state.\n */\nexport function mediaEditorReducer(\n\tstate: MediaEditorState,\n\taction: MediaEditorAction\n): MediaEditorState {\n\tswitch ( action.type ) {\n\t\tcase 'CROPPER': {\n\t\t\tconst nextCropper = cropperReducer( state.cropper, action.action );\n\t\t\tif ( nextCropper === state.cropper ) {\n\t\t\t\treturn state;\n\t\t\t}\n\t\t\treturn { ...state, cropper: nextCropper };\n\t\t}\n\t\tcase 'SET_ASPECT_RATIO_VALUE': {\n\t\t\tconst { presetKey, resolved, visualSize } = action.payload;\n\t\t\t// Atomically: update the preset key AND reshape the\n\t\t\t// cropRect (when the ratio is non-Free and we have a\n\t\t\t// visualSize). One transaction = one undo entry.\n\t\t\tconst shouldReshape =\n\t\t\t\tresolved !== undefined &&\n\t\t\t\tresolved > 0 &&\n\t\t\t\tvisualSize.width > 0 &&\n\t\t\t\tvisualSize.height > 0;\n\t\t\tconst nextCropOptions: CropOptionsSlice = {\n\t\t\t\t...state.cropOptions,\n\t\t\t\taspectRatioValue: presetKey,\n\t\t\t};\n\t\t\tif ( ! shouldReshape ) {\n\t\t\t\tif ( state.cropOptions.aspectRatioValue === presetKey ) {\n\t\t\t\t\treturn state;\n\t\t\t\t}\n\t\t\t\treturn { ...state, cropOptions: nextCropOptions };\n\t\t\t}\n\t\t\tconst newCropRect = computeInscribedRect( resolved, visualSize );\n\t\t\tconst nextCropper = cropperReducer( state.cropper, {\n\t\t\t\ttype: 'SET_CROP_RECT',\n\t\t\t\tpayload: newCropRect,\n\t\t\t} );\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tcropper: nextCropper,\n\t\t\t\tcropOptions: nextCropOptions,\n\t\t\t};\n\t\t}\n\t\tcase 'RESET': {\n\t\t\tconst next = buildInitialMediaEditorState(\n\t\t\t\tcropperReducer( state.cropper, { type: 'RESET' } )\n\t\t\t);\n\t\t\treturn areMediaEditorStatesEqual( state, next ) ? state : next;\n\t\t}\n\t\tcase 'SET_EDIT': {\n\t\t\tconst { name, value } = action.payload;\n\t\t\tif ( value === undefined ) {\n\t\t\t\tif ( ! Object.hasOwn( state.edits, name ) ) {\n\t\t\t\t\treturn state;\n\t\t\t\t}\n\t\t\t\tconst edits = { ...state.edits };\n\t\t\t\tdelete edits[ name ];\n\t\t\t\treturn { ...state, edits };\n\t\t\t}\n\t\t\tif ( fastDeepEqual( state.edits[ name ], value ) ) {\n\t\t\t\treturn state;\n\t\t\t}\n\t\t\treturn { ...state, edits: { ...state.edits, [ name ]: value } };\n\t\t}\n\t\tcase 'RESTORE_SNAPSHOT':\n\t\t\treturn action.payload;\n\t\tcase 'VIEWPORT_ADJUST_CROP_RECT': {\n\t\t\tconst nextCropper = cropperReducer( state.cropper, {\n\t\t\t\ttype: 'SET_CROP_RECT',\n\t\t\t\tpayload: action.payload,\n\t\t\t} );\n\t\t\tif ( nextCropper === state.cropper ) {\n\t\t\t\treturn state;\n\t\t\t}\n\t\t\treturn { ...state, cropper: nextCropper };\n\t\t}\n\t}\n}\n\n/**\n * Value-equality check for two composite states. Used by the history\n * machinery to dedup snapshots when an action turned out to be a no-op.\n *\n * @param a First composite state.\n * @param b Second composite state.\n * @return Whether `a` and `b` are value-equal across all slices.\n */\nexport function areMediaEditorStatesEqual(\n\ta: MediaEditorState,\n\tb: MediaEditorState\n): boolean {\n\tif ( a === b ) {\n\t\treturn true;\n\t}\n\treturn (\n\t\tareCropperStatesEqual( a.cropper, b.cropper ) &&\n\t\ta.cropOptions.aspectRatioValue === b.cropOptions.aspectRatioValue &&\n\t\tfastDeepEqual( a.edits, b.edits )\n\t);\n}\n\n/**\n * Build the composite state a session starts from: the given cropper\n * slice, default crop options, and no edits.\n *\n * @param cropper The cropper slice.\n * @return Composite initial state.\n */\nexport function buildInitialMediaEditorState(\n\tcropper: CropperState\n): MediaEditorState {\n\treturn {\n\t\tcropper,\n\t\tcropOptions: { ...DEFAULT_CROP_OPTIONS },\n\t\tedits: {},\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,SAAgB,mBACf,OACA,QACmB;CACnB,QAAS,OAAO,MAAhB;EACC,KAAK,WAAW;GACf,MAAM,eAAA,GAAcA,8BAAAA,eAAAA,CAAgB,MAAM,SAAS,OAAO,MAAO;GACjE,IAAK,gBAAgB,MAAM,SAC1B,OAAO;GAER,OAAO;IAAE,GAAG;IAAO,SAAS;GAAY;EACzC;EACA,KAAK,0BAA0B;GAC9B,MAAM,EAAE,WAAW,UAAU,eAAe,OAAO;GAInD,MAAM,gBACL,aAAa,KAAA,KACb,WAAW,KACX,WAAW,QAAQ,KACnB,WAAW,SAAS;GACrB,MAAM,kBAAoC;IACzC,GAAG,MAAM;IACT,kBAAkB;GACnB;GACA,IAAK,CAAE,eAAgB;IACtB,IAAK,MAAM,YAAY,qBAAqB,WAC3C,OAAO;IAER,OAAO;KAAE,GAAG;KAAO,aAAa;IAAgB;GACjD;GACA,MAAM,eAAA,GAAcC,8BAAAA,qBAAAA,CAAsB,UAAU,UAAW;GAC/D,MAAM,eAAA,GAAcD,8BAAAA,eAAAA,CAAgB,MAAM,SAAS;IAClD,MAAM;IACN,SAAS;GACV,CAAE;GACF,OAAO;IACN,GAAG;IACH,SAAS;IACT,aAAa;GACd;EACD;EACA,KAAK,SAAS;GACb,MAAM,OAAO,8BAAA,GACZA,8BAAAA,eAAAA,CAAgB,MAAM,SAAS,EAAE,MAAM,QAAQ,CAAE,CAClD;GACA,OAAO,0BAA2B,OAAO,IAAK,IAAI,QAAQ;EAC3D;EACA,KAAK,YAAY;GAChB,MAAM,EAAE,MAAM,UAAU,OAAO;GAC/B,IAAK,UAAU,KAAA,GAAY;IAC1B,IAAK,CAAE,OAAO,OAAQ,MAAM,OAAO,IAAK,GACvC,OAAO;IAER,MAAM,QAAQ,EAAE,GAAG,MAAM,MAAM;IAC/B,OAAO,MAAO;IACd,OAAO;KAAE,GAAG;KAAO;IAAM;GAC1B;GACA,KAAA,GAAKE,6BAAAA,QAAAA,CAAe,MAAM,MAAO,OAAQ,KAAM,GAC9C,OAAO;GAER,OAAO;IAAE,GAAG;IAAO,OAAO;KAAE,GAAG,MAAM;MAAS,OAAQ;IAAM;GAAE;EAC/D;EACA,KAAK,oBACJ,OAAO,OAAO;EACf,KAAK,6BAA6B;GACjC,MAAM,eAAA,GAAcF,8BAAAA,eAAAA,CAAgB,MAAM,SAAS;IAClD,MAAM;IACN,SAAS,OAAO;GACjB,CAAE;GACF,IAAK,gBAAgB,MAAM,SAC1B,OAAO;GAER,OAAO;IAAE,GAAG;IAAO,SAAS;GAAY;EACzC;CACD;AACD;;;;;;;;;AAUA,SAAgB,0BACf,GACA,GACU;CACV,IAAK,MAAM,GACV,OAAO;CAER,QAAA,GACCG,8BAAAA,sBAAAA,CAAuB,EAAE,SAAS,EAAE,OAAQ,KAC5C,EAAE,YAAY,qBAAqB,EAAE,YAAY,qBAAA,GACjDD,6BAAAA,QAAAA,CAAe,EAAE,OAAO,EAAE,KAAM;AAElC;;;;;;;;AASA,SAAgB,6BACf,SACmB;CACnB,OAAO;EACN;EACA,aAAa,EAAE,GAAGE,WAAAA,qBAAqB;EACvC,OAAO,CAAC;CACT;AACD"}
1
+ {"version":3,"file":"composite-reducer.cjs","names":["fastDeepEqual","createImageEditorState","areImageEditorStatesEqual","DEFAULT_CROP_OPTIONS"],"sources":["../../src/state/composite-reducer.ts"],"sourcesContent":["import fastDeepEqual from 'fast-deep-equal/es6/index.js';\nimport {\n\tareImageEditorStatesEqual,\n\tcreateImageEditorState,\n\ttype ImageEditorState,\n} from '@wordpress/image-editor';\nimport {\n\tDEFAULT_CROP_OPTIONS,\n\ttype MediaEditorAction,\n\ttype MediaEditorState,\n} from './types';\n\n/**\n * Pure reducer for the media editor.\n *\n * The image editor works out its own next state (through the controller from\n * `@wordpress/image-editor`) and this reducer stores it. The reducer\n * also owns the sidebar crop options and the named edits.\n *\n * This reducer keeps no history; `useMediaEditorState` does.\n *\n * @param state Current state.\n * @param action Action to apply.\n * @return Next state.\n */\nexport function mediaEditorReducer(\n\tstate: MediaEditorState,\n\taction: MediaEditorAction\n): MediaEditorState {\n\tswitch ( action.type ) {\n\t\tcase 'SET_IMAGE_EDITOR':\n\t\t\treturn action.payload === state.imageEditor\n\t\t\t\t? state\n\t\t\t\t: { ...state, imageEditor: action.payload };\n\t\tcase 'SET_ASPECT_RATIO_VALUE':\n\t\t\treturn state.cropOptions.aspectRatioValue === action.payload\n\t\t\t\t? state\n\t\t\t\t: {\n\t\t\t\t\t\t...state,\n\t\t\t\t\t\tcropOptions: {\n\t\t\t\t\t\t\t...state.cropOptions,\n\t\t\t\t\t\t\taspectRatioValue: action.payload,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\tcase 'SET_EDIT': {\n\t\t\tconst { name, value } = action.payload;\n\t\t\tif ( value === undefined ) {\n\t\t\t\tif ( ! Object.hasOwn( state.edits, name ) ) {\n\t\t\t\t\treturn state;\n\t\t\t\t}\n\t\t\t\tconst edits = { ...state.edits };\n\t\t\t\tdelete edits[ name ];\n\t\t\t\treturn { ...state, edits };\n\t\t\t}\n\t\t\tif ( fastDeepEqual( state.edits[ name ], value ) ) {\n\t\t\t\treturn state;\n\t\t\t}\n\t\t\treturn { ...state, edits: { ...state.edits, [ name ]: value } };\n\t\t}\n\t\tcase 'RESET': {\n\t\t\tconst next = buildInitialMediaEditorState(\n\t\t\t\tcreateImageEditorState( { image: state.imageEditor.image } )\n\t\t\t);\n\t\t\treturn areMediaEditorStatesEqual( state, next ) ? state : next;\n\t\t}\n\t\tcase 'RESTORE_SNAPSHOT':\n\t\t\treturn action.payload;\n\t}\n}\n\n/**\n * Value-equality check for two media editor states. The history uses it\n * to skip snapshots when an action turned out to be a no-op.\n *\n * @param a First state.\n * @param b Second state.\n * @return Whether `a` and `b` are value-equal across all slices.\n */\nexport function areMediaEditorStatesEqual(\n\ta: MediaEditorState,\n\tb: MediaEditorState\n): boolean {\n\tif ( a === b ) {\n\t\treturn true;\n\t}\n\treturn (\n\t\tareImageEditorStatesEqual( a.imageEditor, b.imageEditor ) &&\n\t\ta.cropOptions.aspectRatioValue === b.cropOptions.aspectRatioValue &&\n\t\tfastDeepEqual( a.edits, b.edits )\n\t);\n}\n\n/**\n * Build the state a session starts from: the given image editor state,\n * default crop options, and no edits.\n *\n * @param imageEditor The image editor state.\n * @return Initial state.\n */\nexport function buildInitialMediaEditorState(\n\timageEditor: ImageEditorState\n): MediaEditorState {\n\treturn {\n\t\timageEditor,\n\t\tcropOptions: { ...DEFAULT_CROP_OPTIONS },\n\t\tedits: {},\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,mBACf,OACA,QACmB;CACnB,QAAS,OAAO,MAAhB;EACC,KAAK,oBACJ,OAAO,OAAO,YAAY,MAAM,cAC7B,QACA;GAAE,GAAG;GAAO,aAAa,OAAO;EAAQ;EAC5C,KAAK,0BACJ,OAAO,MAAM,YAAY,qBAAqB,OAAO,UAClD,QACA;GACA,GAAG;GACH,aAAa;IACZ,GAAG,MAAM;IACT,kBAAkB,OAAO;GAC1B;EACD;EACH,KAAK,YAAY;GAChB,MAAM,EAAE,MAAM,UAAU,OAAO;GAC/B,IAAK,UAAU,KAAA,GAAY;IAC1B,IAAK,CAAE,OAAO,OAAQ,MAAM,OAAO,IAAK,GACvC,OAAO;IAER,MAAM,QAAQ,EAAE,GAAG,MAAM,MAAM;IAC/B,OAAO,MAAO;IACd,OAAO;KAAE,GAAG;KAAO;IAAM;GAC1B;GACA,KAAA,GAAKA,6BAAAA,QAAAA,CAAe,MAAM,MAAO,OAAQ,KAAM,GAC9C,OAAO;GAER,OAAO;IAAE,GAAG;IAAO,OAAO;KAAE,GAAG,MAAM;MAAS,OAAQ;IAAM;GAAE;EAC/D;EACA,KAAK,SAAS;GACb,MAAM,OAAO,8BAAA,GACZC,wBAAAA,uBAAAA,CAAwB,EAAE,OAAO,MAAM,YAAY,MAAM,CAAE,CAC5D;GACA,OAAO,0BAA2B,OAAO,IAAK,IAAI,QAAQ;EAC3D;EACA,KAAK,oBACJ,OAAO,OAAO;CAChB;AACD;;;;;;;;;AAUA,SAAgB,0BACf,GACA,GACU;CACV,IAAK,MAAM,GACV,OAAO;CAER,QAAA,GACCC,wBAAAA,0BAAAA,CAA2B,EAAE,aAAa,EAAE,WAAY,KACxD,EAAE,YAAY,qBAAqB,EAAE,YAAY,qBAAA,GACjDF,6BAAAA,QAAAA,CAAe,EAAE,OAAO,EAAE,KAAM;AAElC;;;;;;;;AASA,SAAgB,6BACf,aACmB;CACnB,OAAO;EACN;EACA,aAAa,EAAE,GAAGG,WAAAA,qBAAqB;EACvC,OAAO,CAAC;CACT;AACD"}
@@ -5,51 +5,12 @@ Object.defineProperties(exports, {
5
5
  });
6
6
  let __use_media_editor_state_ts = require("./use-media-editor-state.cjs");
7
7
  let __media_editor_state_provider_tsx = require("./media-editor-state-provider.cjs");
8
- let __composite_reducer_ts = require("./composite-reducer.cjs");
9
- let __types_ts = require("./types.cjs");
10
- let __aspect_ratio_presets_ts = require("./aspect-ratio-presets.cjs");
11
- Object.defineProperty(exports, "DEFAULT_ASPECT_RATIOS", {
12
- enumerable: true,
13
- get: function() {
14
- return __aspect_ratio_presets_ts.DEFAULT_ASPECT_RATIOS;
15
- }
16
- });
17
- Object.defineProperty(exports, "DEFAULT_CROP_OPTIONS", {
18
- enumerable: true,
19
- get: function() {
20
- return __types_ts.DEFAULT_CROP_OPTIONS;
21
- }
22
- });
23
8
  Object.defineProperty(exports, "MediaEditorStateProvider", {
24
9
  enumerable: true,
25
10
  get: function() {
26
11
  return __media_editor_state_provider_tsx.MediaEditorStateProvider;
27
12
  }
28
13
  });
29
- Object.defineProperty(exports, "areMediaEditorStatesEqual", {
30
- enumerable: true,
31
- get: function() {
32
- return __composite_reducer_ts.areMediaEditorStatesEqual;
33
- }
34
- });
35
- Object.defineProperty(exports, "buildInitialMediaEditorState", {
36
- enumerable: true,
37
- get: function() {
38
- return __composite_reducer_ts.buildInitialMediaEditorState;
39
- }
40
- });
41
- Object.defineProperty(exports, "mediaEditorReducer", {
42
- enumerable: true,
43
- get: function() {
44
- return __composite_reducer_ts.mediaEditorReducer;
45
- }
46
- });
47
- Object.defineProperty(exports, "resolveAspectRatio", {
48
- enumerable: true,
49
- get: function() {
50
- return __use_media_editor_state_ts.resolveAspectRatio;
51
- }
52
- });
53
14
  Object.defineProperty(exports, "useMediaEditor", {
54
15
  enumerable: true,
55
16
  get: function() {
@@ -5,8 +5,7 @@ Object.defineProperties(exports, {
5
5
  });
6
6
  // packages/media-editor/src/state/types.ts
7
7
  /**
8
- * Default values for the crop-options slice. Mirrors the initial state
9
- * used by the sidebar before the user has touched anything.
8
+ * The crop options a session starts from.
10
9
  */
11
10
  const DEFAULT_CROP_OPTIONS = { aspectRatioValue: "0" };
12
11
  exports.DEFAULT_CROP_OPTIONS = DEFAULT_CROP_OPTIONS;
@@ -1 +1 @@
1
- {"version":3,"file":"types.cjs","names":[],"sources":["../../src/state/types.ts"],"sourcesContent":["import type { CropperState, NormalizedRect, Size } from '../image-editor';\nimport type { CropperAction } from '../image-editor/core';\n\n/**\n * Sidebar control state for the cropper. Lives in the composite store\n * so it participates in the same undo history as cropper geometry.\n */\nexport interface CropOptionsSlice {\n\t/**\n\t * Selected aspect-ratio preset as a string (round-trippable through\n\t * `<SelectControl>`). `'0'` = Free, `'-1'` = Original, any positive\n\t * decimal = fixed ratio.\n\t */\n\taspectRatioValue: string;\n}\n\n/**\n * Default values for the crop-options slice. Mirrors the initial state\n * used by the sidebar before the user has touched anything.\n */\nexport const DEFAULT_CROP_OPTIONS: CropOptionsSlice = {\n\taspectRatioValue: '0',\n};\n\n/**\n * A value an edit can hold: plain data only, because the session\n * compares values by content to tell a real change from a no-op.\n * Anything else, such as a `Blob`, would compare equal to any other\n * and the change would be dropped — keep bytes behind a URL instead.\n *\n * Objects must satisfy the index signature, so type a value with a\n * `type` alias rather than an `interface`.\n */\nexport type EditValue =\n\t| string\n\t| number\n\t| boolean\n\t| null\n\t| EditValue[]\n\t| { [ key: string ]: EditValue };\n\n/**\n * Named edits other than crop, keyed by edit name (for example\n * `my-plugin/vignette`). An edit that is not present means \"no edit\".\n */\nexport type EditsSlice = Record< string, EditValue >;\n\n/**\n * The full composite state for the media editor — cropper geometry,\n * the sidebar control slice, and named edits.\n *\n * Every undo/redo snapshot is a full `MediaEditorState`. Slices stay\n * referentially equal across actions that don't touch them.\n */\nexport interface MediaEditorState {\n\tcropper: CropperState;\n\tcropOptions: CropOptionsSlice;\n\tedits: EditsSlice;\n}\n\n/**\n * Composite reducer action union.\n *\n * Cropper geometry actions are wrapped in a `CROPPER` envelope and\n * delegated to the pure `cropperReducer`. Sidebar and history\n * concerns are first-class actions on this reducer.\n */\nexport type MediaEditorAction =\n\t/**\n\t * Delegate to the underlying cropper reducer. Used for every\n\t * geometry transition (pan / zoom / rotation / flip / cropRect /\n\t * settle / etc.).\n\t */\n\t| {\n\t\t\ttype: 'CROPPER';\n\t\t\taction: CropperAction;\n\t }\n\t/**\n\t * Set the aspect-ratio preset. Atomically updates the preset key\n\t * and the cropRect (computed from the resolved ratio and the\n\t * current visualSize). One transaction = one undo entry.\n\t */\n\t| {\n\t\t\ttype: 'SET_ASPECT_RATIO_VALUE';\n\t\t\tpayload: {\n\t\t\t\t/** Preset key as it appears in the dropdown. */\n\t\t\t\tpresetKey: string;\n\t\t\t\t/**\n\t\t\t\t * Resolved width/height ratio. `undefined` = Free\n\t\t\t\t * (no lock; cropRect stays where it is).\n\t\t\t\t */\n\t\t\t\tresolved: number | undefined;\n\t\t\t\t/**\n\t\t\t\t * Rendered image size used to compute the inscribed\n\t\t\t\t * rect. Caller supplies it because the reducer is\n\t\t\t\t * framework-agnostic and has no DOM access.\n\t\t\t\t */\n\t\t\t\tvisualSize: Size;\n\t\t\t};\n\t }\n\t/**\n\t * Put every slice back to its starting state, keeping the image:\n\t * default geometry, default crop options, no edits. One action,\n\t * so one undo entry.\n\t */\n\t| { type: 'RESET' }\n\t/** Set a named edit, or remove it when `value` is `undefined`. */\n\t| {\n\t\t\ttype: 'SET_EDIT';\n\t\t\tpayload: { name: string; value: EditValue | undefined };\n\t }\n\t/**\n\t * Replace the entire composite state with `payload`. Used by\n\t * undo/redo to restore a full snapshot atomically.\n\t */\n\t| { type: 'RESTORE_SNAPSHOT'; payload: MediaEditorState }\n\t/**\n\t * Adjust the cropper's cropRect in response to a viewport change\n\t * (e.g., window resize). Behaviorally identical to a `CROPPER\n\t * SET_CROP_RECT` dispatch, but tagged so the hook layer can skip\n\t * history recording — viewport reshapes aren't editor actions.\n\t */\n\t| {\n\t\t\ttype: 'VIEWPORT_ADJUST_CROP_RECT';\n\t\t\tpayload: NormalizedRect;\n\t };\n"],"mappings":";;;;;;;;;;AAoBA,MAAa,uBAAyC,EACrD,kBAAkB,IACnB"}
1
+ {"version":3,"file":"types.cjs","names":[],"sources":["../../src/state/types.ts"],"sourcesContent":["import type { ImageEditorState } from '@wordpress/image-editor';\n\n/**\n * Sidebar control state for the image editor, kept in the same undo history\n * as the crop.\n */\nexport interface CropOptionsSlice {\n\t/**\n\t * Selected aspect-ratio preset as a string (round-trippable through\n\t * `<SelectControl>`). `'0'` = Free, `'-1'` = Original, any positive\n\t * decimal = fixed ratio. The image editor holds the resolved ratio itself.\n\t */\n\taspectRatioValue: string;\n}\n\n/**\n * The crop options a session starts from.\n */\nexport const DEFAULT_CROP_OPTIONS: CropOptionsSlice = {\n\taspectRatioValue: '0',\n};\n\n/**\n * A value an edit can hold: plain data only, because the session\n * compares values by content to tell a real change from a no-op.\n * Anything else, such as a `Blob`, would compare equal to any other\n * and the change would be dropped — keep bytes behind a URL instead.\n *\n * Objects must satisfy the index signature, so type a value with a\n * `type` alias rather than an `interface`.\n */\nexport type EditValue =\n\t| string\n\t| number\n\t| boolean\n\t| null\n\t| EditValue[]\n\t| { [ key: string ]: EditValue };\n\n/**\n * Named edits other than crop, keyed by edit name (for example\n * `my-plugin/vignette`). An edit that is not present means \"no edit\".\n */\nexport type EditsSlice = Record< string, EditValue >;\n\n/**\n * The full state of the media editor: the image editor's state, the sidebar\n * crop options and named edits.\n *\n * Every undo/redo snapshot is a full `MediaEditorState`. Slices stay\n * referentially equal across actions that don't touch them.\n */\nexport interface MediaEditorState {\n\timageEditor: ImageEditorState;\n\tcropOptions: CropOptionsSlice;\n\tedits: EditsSlice;\n}\n\n/** Actions the media editor reducer handles. */\nexport type MediaEditorAction =\n\t/** Replace the image editor's state with the next one it reports. */\n\t| { type: 'SET_IMAGE_EDITOR'; payload: ImageEditorState }\n\t/** Set the aspect-ratio preset the dropdown shows. */\n\t| { type: 'SET_ASPECT_RATIO_VALUE'; payload: string }\n\t/** Set a named edit, or remove it when `value` is `undefined`. */\n\t| {\n\t\t\ttype: 'SET_EDIT';\n\t\t\tpayload: { name: string; value: EditValue | undefined };\n\t }\n\t/**\n\t * Put every slice back to its starting state, keeping the image. One\n\t * action, so one undo entry.\n\t */\n\t| { type: 'RESET' }\n\t/** Replace the whole state with a snapshot (undo/redo). */\n\t| { type: 'RESTORE_SNAPSHOT'; payload: MediaEditorState };\n"],"mappings":";;;;;;;;;AAkBA,MAAa,uBAAyC,EACrD,kBAAkB,IACnB"}