@wordpress/media-editor 0.21.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (432) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/build/components/media-editor/index.cjs +586 -686
  3. package/build/components/media-editor/index.cjs.map +1 -7
  4. package/build/components/media-editor/use-crop-options.cjs +42 -57
  5. package/build/components/media-editor/use-crop-options.cjs.map +1 -7
  6. package/build/components/media-editor/use-save-media-editor.cjs +131 -185
  7. package/build/components/media-editor/use-save-media-editor.cjs.map +1 -7
  8. package/build/components/media-editor-canvas/index.cjs +117 -124
  9. package/build/components/media-editor-canvas/index.cjs.map +1 -7
  10. package/build/components/media-editor-crop-panel/index.cjs +81 -72
  11. package/build/components/media-editor-crop-panel/index.cjs.map +1 -7
  12. package/build/components/media-editor-fine-rotation/index.cjs +61 -72
  13. package/build/components/media-editor-fine-rotation/index.cjs.map +1 -7
  14. package/build/components/media-editor-image-controls/index.cjs +181 -257
  15. package/build/components/media-editor-image-controls/index.cjs.map +1 -7
  16. package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs +120 -157
  17. package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs.map +1 -7
  18. package/build/components/media-editor-modal/index.cjs +112 -155
  19. package/build/components/media-editor-modal/index.cjs.map +1 -7
  20. package/build/components/media-editor-provider/index.cjs +32 -55
  21. package/build/components/media-editor-provider/index.cjs.map +1 -7
  22. package/build/components/media-form/index.cjs +82 -77
  23. package/build/components/media-form/index.cjs.map +1 -7
  24. package/build/components/media-preview/index.cjs +113 -114
  25. package/build/components/media-preview/index.cjs.map +1 -7
  26. package/build/components/rotation-ruler/index.cjs +181 -188
  27. package/build/components/rotation-ruler/index.cjs.map +1 -7
  28. package/build/components/rotation-ruler/use-ruler-drag.cjs +132 -149
  29. package/build/components/rotation-ruler/use-ruler-drag.cjs.map +1 -7
  30. package/build/hooks/use-crop-gesture-handlers.cjs +82 -76
  31. package/build/hooks/use-crop-gesture-handlers.cjs.map +1 -7
  32. package/build/index.cjs +45 -39
  33. package/build/lock-unlock.cjs +9 -35
  34. package/build/lock-unlock.cjs.map +1 -7
  35. package/build/private-apis.cjs +16 -37
  36. package/build/private-apis.cjs.map +1 -7
  37. package/build/state/aspect-ratio-presets.cjs +59 -0
  38. package/build/state/aspect-ratio-presets.cjs.map +1 -0
  39. package/build/state/composite-reducer.cjs +100 -113
  40. package/build/state/composite-reducer.cjs.map +1 -7
  41. package/build/state/index.cjs +22 -45
  42. package/build/state/media-editor-state-provider.cjs +35 -48
  43. package/build/state/media-editor-state-provider.cjs.map +1 -7
  44. package/build/state/types.cjs +11 -31
  45. package/build/state/types.cjs.map +1 -7
  46. package/build/state/use-media-editor-state.cjs +227 -296
  47. package/build/state/use-media-editor-state.cjs.map +1 -7
  48. package/build/store/actions.cjs +17 -44
  49. package/build/store/actions.cjs.map +1 -7
  50. package/build/store/constants.cjs +8 -29
  51. package/build/store/constants.cjs.map +1 -7
  52. package/build/store/index.cjs +33 -40
  53. package/build/store/index.cjs.map +1 -7
  54. package/build/store/reducer.cjs +28 -50
  55. package/build/store/reducer.cjs.map +1 -7
  56. package/build/store/selectors.cjs +16 -41
  57. package/build/store/selectors.cjs.map +1 -7
  58. package/build/utils/get-media-type.cjs +18 -41
  59. package/build/utils/get-media-type.cjs.map +1 -7
  60. package/build/utils/index.cjs +9 -28
  61. package/build-module/components/media-editor/index.mjs +545 -675
  62. package/build-module/components/media-editor/index.mjs.map +1 -7
  63. package/build-module/components/media-editor/use-crop-options.mjs +37 -32
  64. package/build-module/components/media-editor/use-crop-options.mjs.map +1 -7
  65. package/build-module/components/media-editor/use-save-media-editor.mjs +109 -157
  66. package/build-module/components/media-editor/use-save-media-editor.mjs.map +1 -7
  67. package/build-module/components/media-editor-canvas/index.mjs +95 -98
  68. package/build-module/components/media-editor-canvas/index.mjs.map +1 -7
  69. package/build-module/components/media-editor-crop-panel/index.mjs +59 -46
  70. package/build-module/components/media-editor-crop-panel/index.mjs.map +1 -7
  71. package/build-module/components/media-editor-fine-rotation/index.mjs +39 -46
  72. package/build-module/components/media-editor-fine-rotation/index.mjs.map +1 -7
  73. package/build-module/components/media-editor-image-controls/index.mjs +171 -238
  74. package/build-module/components/media-editor-image-controls/index.mjs.map +1 -7
  75. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs +113 -137
  76. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs.map +1 -7
  77. package/build-module/components/media-editor-modal/index.mjs +88 -124
  78. package/build-module/components/media-editor-modal/index.mjs.map +1 -7
  79. package/build-module/components/media-editor-provider/index.mjs +26 -29
  80. package/build-module/components/media-editor-provider/index.mjs.map +1 -7
  81. package/build-module/components/media-form/index.mjs +74 -56
  82. package/build-module/components/media-form/index.mjs.map +1 -7
  83. package/build-module/components/media-preview/index.mjs +105 -90
  84. package/build-module/components/media-preview/index.mjs.map +1 -7
  85. package/build-module/components/rotation-ruler/index.mjs +161 -164
  86. package/build-module/components/rotation-ruler/index.mjs.map +1 -7
  87. package/build-module/components/rotation-ruler/use-ruler-drag.mjs +125 -122
  88. package/build-module/components/rotation-ruler/use-ruler-drag.mjs.map +1 -7
  89. package/build-module/hooks/use-crop-gesture-handlers.mjs +76 -50
  90. package/build-module/hooks/use-crop-gesture-handlers.mjs.map +1 -7
  91. package/build-module/index.mjs +3 -10
  92. package/build-module/lock-unlock.mjs +5 -10
  93. package/build-module/lock-unlock.mjs.map +1 -7
  94. package/build-module/private-apis.mjs +8 -9
  95. package/build-module/private-apis.mjs.map +1 -7
  96. package/build-module/state/aspect-ratio-presets.mjs +53 -0
  97. package/build-module/state/aspect-ratio-presets.mjs.map +1 -0
  98. package/build-module/state/composite-reducer.mjs +80 -91
  99. package/build-module/state/composite-reducer.mjs.map +1 -7
  100. package/build-module/state/index.mjs +3 -26
  101. package/build-module/state/media-editor-state-provider.mjs +29 -24
  102. package/build-module/state/media-editor-state-provider.mjs.map +1 -7
  103. package/build-module/state/types.mjs +7 -7
  104. package/build-module/state/types.mjs.map +1 -7
  105. package/build-module/state/use-media-editor-state.mjs +223 -288
  106. package/build-module/state/use-media-editor-state.mjs.map +1 -7
  107. package/build-module/store/actions.mjs +12 -19
  108. package/build-module/store/actions.mjs.map +1 -7
  109. package/build-module/store/constants.mjs +4 -5
  110. package/build-module/store/constants.mjs.map +1 -7
  111. package/build-module/store/index.mjs +8 -9
  112. package/build-module/store/index.mjs.map +1 -7
  113. package/build-module/store/reducer.mjs +23 -26
  114. package/build-module/store/reducer.mjs.map +1 -7
  115. package/build-module/store/selectors.mjs +8 -13
  116. package/build-module/store/selectors.mjs.map +1 -7
  117. package/build-module/utils/get-media-type.mjs +14 -17
  118. package/build-module/utils/get-media-type.mjs.map +1 -7
  119. package/build-module/utils/index.mjs +1 -6
  120. package/build-style/style-rtl.css +145 -61
  121. package/build-style/style.css +144 -61
  122. package/build-types/components/media-editor/index.d.ts +20 -2
  123. package/build-types/components/media-editor/index.d.ts.map +1 -1
  124. package/build-types/components/media-editor/use-crop-options.d.ts +2 -3
  125. package/build-types/components/media-editor/use-crop-options.d.ts.map +1 -1
  126. package/build-types/components/media-editor/use-save-media-editor.d.ts.map +1 -1
  127. package/build-types/components/media-editor-canvas/index.d.ts +3 -3
  128. package/build-types/components/media-editor-canvas/index.d.ts.map +1 -1
  129. package/build-types/components/media-editor-crop-panel/index.d.ts +1 -1
  130. package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -1
  131. package/build-types/components/media-editor-fine-rotation/index.d.ts.map +1 -1
  132. package/build-types/components/media-editor-image-controls/index.d.ts +1 -1
  133. package/build-types/components/media-editor-image-controls/index.d.ts.map +1 -1
  134. package/build-types/components/media-editor-keyboard-shortcuts-modal/index.d.ts.map +1 -1
  135. package/build-types/components/media-editor-modal/index.d.ts +1 -1
  136. package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
  137. package/build-types/components/media-form/index.d.ts.map +1 -1
  138. package/build-types/components/media-preview/index.d.ts.map +1 -1
  139. package/build-types/components/rotation-ruler/use-ruler-drag.d.ts.map +1 -1
  140. package/build-types/state/aspect-ratio-presets.d.ts +24 -0
  141. package/build-types/state/aspect-ratio-presets.d.ts.map +1 -0
  142. package/build-types/state/composite-reducer.d.ts +17 -19
  143. package/build-types/state/composite-reducer.d.ts.map +1 -1
  144. package/build-types/state/index.d.ts +2 -4
  145. package/build-types/state/index.d.ts.map +1 -1
  146. package/build-types/state/types.d.ts +20 -63
  147. package/build-types/state/types.d.ts.map +1 -1
  148. package/build-types/state/use-media-editor-state.d.ts +33 -52
  149. package/build-types/state/use-media-editor-state.d.ts.map +1 -1
  150. package/package.json +22 -23
  151. package/src/components/media-editor/index.tsx +355 -167
  152. package/src/components/media-editor/style.scss +19 -0
  153. package/src/components/media-editor/use-crop-options.ts +9 -10
  154. package/src/components/media-editor/use-save-media-editor.ts +48 -10
  155. package/src/components/media-editor-canvas/index.tsx +30 -51
  156. package/src/components/media-editor-canvas/style.scss +6 -6
  157. package/src/components/media-editor-crop-panel/index.tsx +38 -2
  158. package/src/components/media-editor-crop-panel/style.scss +21 -0
  159. package/src/components/media-editor-fine-rotation/index.tsx +6 -6
  160. package/src/components/media-editor-image-controls/index.tsx +15 -11
  161. package/src/components/media-editor-keyboard-shortcuts-modal/index.tsx +1 -0
  162. package/src/components/media-editor-keyboard-shortcuts-modal/style.scss +1 -1
  163. package/src/components/media-editor-modal/index.tsx +1 -1
  164. package/src/components/media-editor-modal/style.scss +1 -1
  165. package/src/components/media-form/index.tsx +7 -1
  166. package/src/components/media-preview/index.tsx +65 -23
  167. package/src/components/media-preview/style.scss +16 -2
  168. package/src/components/rotation-ruler/style.scss +9 -5
  169. package/src/components/rotation-ruler/use-ruler-drag.ts +6 -11
  170. package/src/state/README.md +32 -0
  171. package/src/state/aspect-ratio-presets.ts +37 -0
  172. package/src/state/composite-reducer.ts +42 -80
  173. package/src/state/index.ts +2 -17
  174. package/src/state/types.ts +18 -72
  175. package/src/state/use-media-editor-state.ts +155 -238
  176. package/src/style.scss +2 -1
  177. package/build/components/media-editor-modal/build-modifiers.cjs +0 -91
  178. package/build/components/media-editor-modal/build-modifiers.cjs.map +0 -7
  179. package/build/image-editor/core/camera.cjs +0 -225
  180. package/build/image-editor/core/camera.cjs.map +0 -7
  181. package/build/image-editor/core/constants.cjs +0 -108
  182. package/build/image-editor/core/constants.cjs.map +0 -7
  183. package/build/image-editor/core/containment.cjs +0 -276
  184. package/build/image-editor/core/containment.cjs.map +0 -7
  185. package/build/image-editor/core/crop-rect.cjs +0 -48
  186. package/build/image-editor/core/crop-rect.cjs.map +0 -7
  187. package/build/image-editor/core/export/canvas-renderer.cjs +0 -151
  188. package/build/image-editor/core/export/canvas-renderer.cjs.map +0 -7
  189. package/build/image-editor/core/index.cjs +0 -62
  190. package/build/image-editor/core/index.cjs.map +0 -7
  191. package/build/image-editor/core/interaction-controller.cjs +0 -654
  192. package/build/image-editor/core/interaction-controller.cjs.map +0 -7
  193. package/build/image-editor/core/math/rotation.cjs +0 -41
  194. package/build/image-editor/core/math/rotation.cjs.map +0 -7
  195. package/build/image-editor/core/math/sanitize.cjs +0 -92
  196. package/build/image-editor/core/math/sanitize.cjs.map +0 -7
  197. package/build/image-editor/core/setter-helpers.cjs +0 -64
  198. package/build/image-editor/core/setter-helpers.cjs.map +0 -7
  199. package/build/image-editor/core/source-region.cjs +0 -206
  200. package/build/image-editor/core/source-region.cjs.map +0 -7
  201. package/build/image-editor/core/state.cjs +0 -283
  202. package/build/image-editor/core/state.cjs.map +0 -7
  203. package/build/image-editor/core/stencil-math.cjs +0 -216
  204. package/build/image-editor/core/stencil-math.cjs.map +0 -7
  205. package/build/image-editor/core/transform-style.cjs +0 -52
  206. package/build/image-editor/core/transform-style.cjs.map +0 -7
  207. package/build/image-editor/core/transforms/pipeline.cjs +0 -43
  208. package/build/image-editor/core/transforms/pipeline.cjs.map +0 -7
  209. package/build/image-editor/core/types.cjs +0 -19
  210. package/build/image-editor/core/types.cjs.map +0 -7
  211. package/build/image-editor/core/viewport-state.cjs +0 -50
  212. package/build/image-editor/core/viewport-state.cjs.map +0 -7
  213. package/build/image-editor/index.cjs +0 -67
  214. package/build/image-editor/index.cjs.map +0 -7
  215. package/build/image-editor/react/components/cropper-provider.cjs +0 -50
  216. package/build/image-editor/react/components/cropper-provider.cjs.map +0 -7
  217. package/build/image-editor/react/components/cropper.cjs +0 -722
  218. package/build/image-editor/react/components/cropper.cjs.map +0 -7
  219. package/build/image-editor/react/components/index.cjs +0 -36
  220. package/build/image-editor/react/components/index.cjs.map +0 -7
  221. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs +0 -172
  222. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs.map +0 -7
  223. package/build/image-editor/react/components/overlays/dimming-overlay.cjs +0 -62
  224. package/build/image-editor/react/components/overlays/dimming-overlay.cjs.map +0 -7
  225. package/build/image-editor/react/components/overlays/grid-overlay.cjs +0 -91
  226. package/build/image-editor/react/components/overlays/grid-overlay.cjs.map +0 -7
  227. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs +0 -426
  228. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +0 -7
  229. package/build/image-editor/react/components/viewport-provider.cjs +0 -51
  230. package/build/image-editor/react/components/viewport-provider.cjs.map +0 -7
  231. package/build/image-editor/react/hooks/build-cropper-setters.cjs +0 -71
  232. package/build/image-editor/react/hooks/build-cropper-setters.cjs.map +0 -7
  233. package/build/image-editor/react/hooks/index.cjs +0 -34
  234. package/build/image-editor/react/hooks/index.cjs.map +0 -7
  235. package/build/image-editor/react/hooks/use-aria-announcer.cjs +0 -160
  236. package/build/image-editor/react/hooks/use-aria-announcer.cjs.map +0 -7
  237. package/build/image-editor/react/hooks/use-cropper-reducer.cjs +0 -113
  238. package/build/image-editor/react/hooks/use-cropper-reducer.cjs.map +0 -7
  239. package/build/image-editor/react/hooks/use-interaction.cjs +0 -213
  240. package/build/image-editor/react/hooks/use-interaction.cjs.map +0 -7
  241. package/build/image-editor/react/hooks/use-transform-style.cjs +0 -38
  242. package/build/image-editor/react/hooks/use-transform-style.cjs.map +0 -7
  243. package/build/image-editor/react/hooks/use-viewport-state.cjs +0 -51
  244. package/build/image-editor/react/hooks/use-viewport-state.cjs.map +0 -7
  245. package/build/image-editor/react/visually-hidden-style.cjs +0 -41
  246. package/build/image-editor/react/visually-hidden-style.cjs.map +0 -7
  247. package/build/index.cjs.map +0 -7
  248. package/build/state/index.cjs.map +0 -7
  249. package/build/utils/index.cjs.map +0 -7
  250. package/build-module/components/media-editor-modal/build-modifiers.mjs +0 -66
  251. package/build-module/components/media-editor-modal/build-modifiers.mjs.map +0 -7
  252. package/build-module/image-editor/core/camera.mjs +0 -198
  253. package/build-module/image-editor/core/camera.mjs.map +0 -7
  254. package/build-module/image-editor/core/constants.mjs +0 -69
  255. package/build-module/image-editor/core/constants.mjs.map +0 -7
  256. package/build-module/image-editor/core/containment.mjs +0 -253
  257. package/build-module/image-editor/core/containment.mjs.map +0 -7
  258. package/build-module/image-editor/core/crop-rect.mjs +0 -23
  259. package/build-module/image-editor/core/crop-rect.mjs.map +0 -7
  260. package/build-module/image-editor/core/export/canvas-renderer.mjs +0 -120
  261. package/build-module/image-editor/core/export/canvas-renderer.mjs.map +0 -7
  262. package/build-module/image-editor/core/index.mjs +0 -36
  263. package/build-module/image-editor/core/index.mjs.map +0 -7
  264. package/build-module/image-editor/core/interaction-controller.mjs +0 -635
  265. package/build-module/image-editor/core/interaction-controller.mjs.map +0 -7
  266. package/build-module/image-editor/core/math/rotation.mjs +0 -15
  267. package/build-module/image-editor/core/math/rotation.mjs.map +0 -7
  268. package/build-module/image-editor/core/math/sanitize.mjs +0 -63
  269. package/build-module/image-editor/core/math/sanitize.mjs.map +0 -7
  270. package/build-module/image-editor/core/setter-helpers.mjs +0 -39
  271. package/build-module/image-editor/core/setter-helpers.mjs.map +0 -7
  272. package/build-module/image-editor/core/source-region.mjs +0 -178
  273. package/build-module/image-editor/core/source-region.mjs.map +0 -7
  274. package/build-module/image-editor/core/state.mjs +0 -260
  275. package/build-module/image-editor/core/state.mjs.map +0 -7
  276. package/build-module/image-editor/core/stencil-math.mjs +0 -187
  277. package/build-module/image-editor/core/stencil-math.mjs.map +0 -7
  278. package/build-module/image-editor/core/transform-style.mjs +0 -27
  279. package/build-module/image-editor/core/transform-style.mjs.map +0 -7
  280. package/build-module/image-editor/core/transforms/pipeline.mjs +0 -17
  281. package/build-module/image-editor/core/transforms/pipeline.mjs.map +0 -7
  282. package/build-module/image-editor/core/types.mjs +0 -1
  283. package/build-module/image-editor/core/types.mjs.map +0 -7
  284. package/build-module/image-editor/core/viewport-state.mjs +0 -24
  285. package/build-module/image-editor/core/viewport-state.mjs.map +0 -7
  286. package/build-module/image-editor/index.mjs +0 -39
  287. package/build-module/image-editor/index.mjs.map +0 -7
  288. package/build-module/image-editor/react/components/cropper-provider.mjs +0 -26
  289. package/build-module/image-editor/react/components/cropper-provider.mjs.map +0 -7
  290. package/build-module/image-editor/react/components/cropper.mjs +0 -704
  291. package/build-module/image-editor/react/components/cropper.mjs.map +0 -7
  292. package/build-module/image-editor/react/components/index.mjs +0 -9
  293. package/build-module/image-editor/react/components/index.mjs.map +0 -7
  294. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs +0 -147
  295. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs.map +0 -7
  296. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs +0 -37
  297. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs.map +0 -7
  298. package/build-module/image-editor/react/components/overlays/grid-overlay.mjs +0 -66
  299. package/build-module/image-editor/react/components/overlays/grid-overlay.mjs.map +0 -7
  300. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs +0 -414
  301. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs.map +0 -7
  302. package/build-module/image-editor/react/components/viewport-provider.mjs +0 -27
  303. package/build-module/image-editor/react/components/viewport-provider.mjs.map +0 -7
  304. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs +0 -46
  305. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs.map +0 -7
  306. package/build-module/image-editor/react/hooks/index.mjs +0 -8
  307. package/build-module/image-editor/react/hooks/index.mjs.map +0 -7
  308. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs +0 -135
  309. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs.map +0 -7
  310. package/build-module/image-editor/react/hooks/use-cropper-reducer.mjs +0 -100
  311. package/build-module/image-editor/react/hooks/use-cropper-reducer.mjs.map +0 -7
  312. package/build-module/image-editor/react/hooks/use-interaction.mjs +0 -190
  313. package/build-module/image-editor/react/hooks/use-interaction.mjs.map +0 -7
  314. package/build-module/image-editor/react/hooks/use-transform-style.mjs +0 -13
  315. package/build-module/image-editor/react/hooks/use-transform-style.mjs.map +0 -7
  316. package/build-module/image-editor/react/hooks/use-viewport-state.mjs +0 -29
  317. package/build-module/image-editor/react/hooks/use-viewport-state.mjs.map +0 -7
  318. package/build-module/image-editor/react/visually-hidden-style.mjs +0 -16
  319. package/build-module/image-editor/react/visually-hidden-style.mjs.map +0 -7
  320. package/build-module/index.mjs.map +0 -7
  321. package/build-module/state/index.mjs.map +0 -7
  322. package/build-module/utils/index.mjs.map +0 -7
  323. package/build-types/components/media-editor-modal/build-modifiers.d.ts +0 -80
  324. package/build-types/components/media-editor-modal/build-modifiers.d.ts.map +0 -1
  325. package/build-types/image-editor/core/camera.d.ts +0 -128
  326. package/build-types/image-editor/core/camera.d.ts.map +0 -1
  327. package/build-types/image-editor/core/constants.d.ts +0 -99
  328. package/build-types/image-editor/core/constants.d.ts.map +0 -1
  329. package/build-types/image-editor/core/containment.d.ts +0 -72
  330. package/build-types/image-editor/core/containment.d.ts.map +0 -1
  331. package/build-types/image-editor/core/crop-rect.d.ts +0 -16
  332. package/build-types/image-editor/core/crop-rect.d.ts.map +0 -1
  333. package/build-types/image-editor/core/export/canvas-renderer.d.ts +0 -103
  334. package/build-types/image-editor/core/export/canvas-renderer.d.ts.map +0 -1
  335. package/build-types/image-editor/core/index.d.ts +0 -10
  336. package/build-types/image-editor/core/index.d.ts.map +0 -1
  337. package/build-types/image-editor/core/interaction-controller.d.ts +0 -191
  338. package/build-types/image-editor/core/interaction-controller.d.ts.map +0 -1
  339. package/build-types/image-editor/core/math/rotation.d.ts +0 -18
  340. package/build-types/image-editor/core/math/rotation.d.ts.map +0 -1
  341. package/build-types/image-editor/core/math/sanitize.d.ts +0 -67
  342. package/build-types/image-editor/core/math/sanitize.d.ts.map +0 -1
  343. package/build-types/image-editor/core/setter-helpers.d.ts +0 -21
  344. package/build-types/image-editor/core/setter-helpers.d.ts.map +0 -1
  345. package/build-types/image-editor/core/source-region.d.ts +0 -94
  346. package/build-types/image-editor/core/source-region.d.ts.map +0 -1
  347. package/build-types/image-editor/core/state.d.ts +0 -51
  348. package/build-types/image-editor/core/state.d.ts.map +0 -1
  349. package/build-types/image-editor/core/stencil-math.d.ts +0 -102
  350. package/build-types/image-editor/core/stencil-math.d.ts.map +0 -1
  351. package/build-types/image-editor/core/transform-style.d.ts +0 -20
  352. package/build-types/image-editor/core/transform-style.d.ts.map +0 -1
  353. package/build-types/image-editor/core/transforms/pipeline.d.ts +0 -24
  354. package/build-types/image-editor/core/transforms/pipeline.d.ts.map +0 -1
  355. package/build-types/image-editor/core/types.d.ts +0 -269
  356. package/build-types/image-editor/core/types.d.ts.map +0 -1
  357. package/build-types/image-editor/core/viewport-state.d.ts +0 -4
  358. package/build-types/image-editor/core/viewport-state.d.ts.map +0 -1
  359. package/build-types/image-editor/index.d.ts +0 -16
  360. package/build-types/image-editor/index.d.ts.map +0 -1
  361. package/build-types/image-editor/react/components/cropper-provider.d.ts +0 -38
  362. package/build-types/image-editor/react/components/cropper-provider.d.ts.map +0 -1
  363. package/build-types/image-editor/react/components/cropper.d.ts +0 -63
  364. package/build-types/image-editor/react/components/cropper.d.ts.map +0 -1
  365. package/build-types/image-editor/react/components/index.d.ts +0 -4
  366. package/build-types/image-editor/react/components/index.d.ts.map +0 -1
  367. package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts +0 -33
  368. package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts.map +0 -1
  369. package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts +0 -17
  370. package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts.map +0 -1
  371. package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts +0 -27
  372. package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts.map +0 -1
  373. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts +0 -33
  374. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts.map +0 -1
  375. package/build-types/image-editor/react/components/viewport-provider.d.ts +0 -6
  376. package/build-types/image-editor/react/components/viewport-provider.d.ts.map +0 -1
  377. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts +0 -44
  378. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts.map +0 -1
  379. package/build-types/image-editor/react/hooks/index.d.ts +0 -5
  380. package/build-types/image-editor/react/hooks/index.d.ts.map +0 -1
  381. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts +0 -14
  382. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts.map +0 -1
  383. package/build-types/image-editor/react/hooks/use-cropper-reducer.d.ts +0 -55
  384. package/build-types/image-editor/react/hooks/use-cropper-reducer.d.ts.map +0 -1
  385. package/build-types/image-editor/react/hooks/use-interaction.d.ts +0 -65
  386. package/build-types/image-editor/react/hooks/use-interaction.d.ts.map +0 -1
  387. package/build-types/image-editor/react/hooks/use-transform-style.d.ts +0 -13
  388. package/build-types/image-editor/react/hooks/use-transform-style.d.ts.map +0 -1
  389. package/build-types/image-editor/react/hooks/use-viewport-state.d.ts +0 -16
  390. package/build-types/image-editor/react/hooks/use-viewport-state.d.ts.map +0 -1
  391. package/build-types/image-editor/react/visually-hidden-style.d.ts +0 -6
  392. package/build-types/image-editor/react/visually-hidden-style.d.ts.map +0 -1
  393. package/src/components/media-editor-modal/build-modifiers.ts +0 -161
  394. package/src/image-editor/README.md +0 -61
  395. package/src/image-editor/core/camera.ts +0 -429
  396. package/src/image-editor/core/constants.ts +0 -150
  397. package/src/image-editor/core/containment.ts +0 -469
  398. package/src/image-editor/core/crop-rect.ts +0 -42
  399. package/src/image-editor/core/export/canvas-renderer.ts +0 -250
  400. package/src/image-editor/core/index.ts +0 -47
  401. package/src/image-editor/core/interaction-controller.ts +0 -976
  402. package/src/image-editor/core/math/rotation.ts +0 -26
  403. package/src/image-editor/core/math/sanitize.ts +0 -155
  404. package/src/image-editor/core/setter-helpers.ts +0 -63
  405. package/src/image-editor/core/source-region.ts +0 -367
  406. package/src/image-editor/core/state.ts +0 -484
  407. package/src/image-editor/core/stencil-math.ts +0 -379
  408. package/src/image-editor/core/transform-style.ts +0 -56
  409. package/src/image-editor/core/transforms/pipeline.ts +0 -40
  410. package/src/image-editor/core/types.ts +0 -230
  411. package/src/image-editor/core/viewport-state.ts +0 -30
  412. package/src/image-editor/docs/architecture.md +0 -63
  413. package/src/image-editor/docs/recipes.md +0 -184
  414. package/src/image-editor/index.ts +0 -52
  415. package/src/image-editor/react/components/cropper-provider.tsx +0 -70
  416. package/src/image-editor/react/components/cropper.scss +0 -259
  417. package/src/image-editor/react/components/cropper.tsx +0 -1116
  418. package/src/image-editor/react/components/index.ts +0 -3
  419. package/src/image-editor/react/components/overlays/dimensions-overlay.tsx +0 -262
  420. package/src/image-editor/react/components/overlays/dimming-overlay.tsx +0 -55
  421. package/src/image-editor/react/components/overlays/grid-overlay.tsx +0 -77
  422. package/src/image-editor/react/components/stencils/rectangle-stencil.tsx +0 -623
  423. package/src/image-editor/react/components/viewport-provider.tsx +0 -32
  424. package/src/image-editor/react/hooks/build-cropper-setters.ts +0 -102
  425. package/src/image-editor/react/hooks/index.ts +0 -4
  426. package/src/image-editor/react/hooks/use-aria-announcer.ts +0 -193
  427. package/src/image-editor/react/hooks/use-cropper-reducer.ts +0 -197
  428. package/src/image-editor/react/hooks/use-interaction.ts +0 -294
  429. package/src/image-editor/react/hooks/use-transform-style.ts +0 -23
  430. package/src/image-editor/react/hooks/use-viewport-state.ts +0 -41
  431. package/src/image-editor/react/visually-hidden-style.ts +0 -15
  432. package/src/image-editor/style.scss +0 -1
@@ -1,80 +0,0 @@
1
- import type { CropperState, Size } from '../../image-editor';
2
- /**
3
- * A single modifier in the Core REST `/edit` payload. Order is
4
- * significant — the server applies modifiers sequentially (see
5
- * `WP_REST_Attachments_Controller::edit_media_item`).
6
- *
7
- * Shape/units:
8
- * - `flip`: booleans per axis. Applied first in this module's output.
9
- * - `rotate`: `angle` in degrees, clockwise-positive (matches the
10
- * cropper's own convention; Core negates it internally for
11
- * `WP_Image_Editor::rotate`, which is counterclockwise-positive).
12
- * - `crop`: percentages (0–100) of the image's dimensions **at the
13
- * moment the crop is applied**. Because modifiers are applied in
14
- * order, after a preceding `rotate` the server's
15
- * `WP_Image_Editor::get_size()` reports the full post-rotate AABB,
16
- * so the percentages are of that AABB. Origin is top-left.
17
- */
18
- export type Modifier = {
19
- type: 'flip';
20
- args: {
21
- flip: {
22
- horizontal: boolean;
23
- vertical: boolean;
24
- };
25
- };
26
- } | {
27
- type: 'rotate';
28
- args: {
29
- angle: number;
30
- };
31
- } | {
32
- type: 'crop';
33
- args: {
34
- left: number;
35
- top: number;
36
- width: number;
37
- height: number;
38
- };
39
- };
40
- /**
41
- * Build a Core-compatible modifiers array from the cropper state.
42
- *
43
- * Emits `[flip, rotate, crop]` in that order. Identity operations are
44
- * pruned — an absent flip, a rotation that normalizes to 0°, and a crop
45
- * rect that covers (within tolerance) the full post-rotate AABB each
46
- * produce no modifier. An identity state (fresh image, no edits) returns
47
- * an empty array; callers can use that to skip the `/edit` call.
48
- *
49
- * Frames and math:
50
- *
51
- * The cropper's `cropRect` is stored as fractions of the **snap-rotation**
52
- * bounding box (the stencil-reference frame — see `createCamera` /
53
- * `createExportCamera`). Pan is in that frame; zoom scales the image
54
- * beneath a fixed stencil. Two conversions are needed to reach the frame
55
- * Core's crop modifier applies against:
56
- *
57
- * 1. Express the stencil rect in snap-AABB **pixels**:
58
- * Image screen-normalized top-left with zoom/pan is
59
- * `(0.5 + pan - zoom/2)`; the stencil's pixel footprint is the
60
- * inverse of that transform applied to `cropRect`.
61
- *
62
- * 2. Translate from snap-AABB coords to full-AABB coords. Both AABBs
63
- * share the source-image center, so the conversion is a pure
64
- * translation by `(fullCenter - snapCenter)`. Finally, express the
65
- * translated rect as percentages of the full AABB.
66
- *
67
- * Rotation sign: the cropper composes `flip · R(θ)` on the source (see
68
- * `createExportCamera` — rotate then flip). Core's `[flip, rotate]`
69
- * applies the opposite order: `R(θ') · flip`. For both to land on the
70
- * same pixels we invert the rotation sign when exactly one flip axis
71
- * is set (`flip_h · R(θ) = R(-θ) · flip_h`). Both-or-neither flips
72
- * leave the sign alone because `flip_h · flip_v = -I` commutes with
73
- * rotation.
74
- *
75
- * @param state Current cropper state.
76
- * @param imageSize Natural dimensions of the source image.
77
- * @return Ordered modifier array; empty when nothing is server-relevant.
78
- */
79
- export declare function buildModifiers(state: CropperState, imageSize: Size): Modifier[];
80
- //# sourceMappingURL=build-modifiers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build-modifiers.d.ts","sourceRoot":"","sources":["../../../src/components/media-editor-modal/build-modifiers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAG7D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,QAAQ,GACjB;IACA,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE;QAAE,IAAI,EAAE;YAAE,UAAU,EAAE,OAAO,CAAC;YAAC,QAAQ,EAAE,OAAO,CAAA;SAAE,CAAA;KAAE,CAAC;CAC1D,GACD;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GAC3C;IACA,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAClE,CAAC;AAUL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,cAAc,CAC7B,KAAK,EAAE,YAAY,EACnB,SAAS,EAAE,IAAI,GACb,QAAQ,EAAE,CAgFZ"}
@@ -1,128 +0,0 @@
1
- import type { CropperState, NormalizedPoint, NormalizedRect, Size, Camera } from './types';
2
- /**
3
- * Compute the axis-aligned bounding box of a rectangle after rotation.
4
- *
5
- * @param width The width of the rectangle.
6
- * @param height The height of the rectangle.
7
- * @param rotation The rotation angle in degrees.
8
- * @return The bounding box size after rotation.
9
- */
10
- export declare function getRotatedBBox(width: number, height: number, rotation: number): Size;
11
- /**
12
- * Compute the fitted (unrotated) image element dimensions and the visual
13
- * (rotated) bounding box dimensions for a given container, image, and rotation.
14
- *
15
- * This is the same "contain" fit logic used by createCamera, extracted so
16
- * cropper.tsx can size the <img> element and position overlays without
17
- * duplicating the math.
18
- *
19
- * @param containerSize The container dimensions in pixels.
20
- * @param imageSize The natural image dimensions in pixels.
21
- * @param rotation The rotation angle in degrees.
22
- * @return The fitted element size and visual bounding box size.
23
- */
24
- export declare function getImageFit(containerSize: Size, imageSize: Size, rotation: number): {
25
- elementSize: Size;
26
- visualSize: Size;
27
- };
28
- /**
29
- * Resolve the presentational view magnification that makes the crop fill the
30
- * canvas.
31
- *
32
- * The crop overlay is laid out as `cropRect * visualSize` (the contain-fit
33
- * footprint, with no zoom), so its on-screen size is capped by that footprint.
34
- * When a crop's aspect differs from the image's, it can be much smaller than
35
- * the canvas could show (e.g. a square crop in a tall image is bound by the
36
- * footprint's narrow axis). Scaling `elementSize` and `visualSize` together by
37
- * the returned factor uniformly magnifies the whole scene — image, crop
38
- * overlay, and overlays — so the crop reaches `targetFill` of its constraining
39
- * canvas axis, with the image bleeding past the canvas (clipped by the host).
40
- *
41
- * Purely presentational: it does not touch `zoom`/`pan`/`cropRect`/`rotation`,
42
- * so the framed source region — and therefore the export — is unchanged.
43
- *
44
- * @param cropRect The crop rectangle, normalized to the footprint.
45
- * @param canvasSize The canvas size in pixels.
46
- * @param visualSize The contain-fit (rotated) image footprint in pixels.
47
- * @param targetFill Fraction of the constraining canvas axis to fill (0–1].
48
- * @param maxScale Upper bound on the magnification.
49
- * @return A magnification factor in [1, maxScale]; 1 when none is needed.
50
- */
51
- export declare function getViewScale(cropRect: NormalizedRect, canvasSize: Size, visualSize: Size, targetFill: number, maxScale: number): number;
52
- /**
53
- * Compose a camera matrix from cropper state, container, and image dimensions.
54
- *
55
- * The matrix maps normalized world coordinates [0,1] x [0,1] to screen pixels.
56
- * Input (0,0) = image top-left, (1,1) = image bottom-right.
57
- *
58
- * Composition order (left-to-right = outermost first, applied last to point):
59
- * M = T_containerCenter * T_pan * S_flip * R_rotation * S_zoom * T_center * S_toRenderedPixels
60
- *
61
- * Flip is composed outside rotation, so `flip.horizontal` / `flip.vertical`
62
- * are viewport-relative: the image mirrors across the viewport's vertical /
63
- * horizontal axis regardless of current rotation.
64
- *
65
- * @param state The current cropper state (zoom, rotation, flip, crop).
66
- * @param containerSize The size of the container in pixels.
67
- * @param imageSize The natural size of the image in pixels.
68
- * @return The composed camera matrix.
69
- */
70
- export declare function createCamera(state: CropperState, containerSize: Size, imageSize: Size): Camera;
71
- /**
72
- * Transform a normalized world point [0,1] to screen pixels.
73
- *
74
- * @param camera The camera matrix from createCamera.
75
- * @param point The normalized world coordinate to transform.
76
- * @return The screen pixel coordinate.
77
- */
78
- export declare function worldToScreen(camera: Camera, point: NormalizedPoint): {
79
- x: number;
80
- y: number;
81
- };
82
- /**
83
- * Transform a screen pixel point to normalized world coordinates [0,1].
84
- *
85
- * @param camera The camera matrix from createCamera.
86
- * @param point The screen pixel coordinate to transform.
87
- * @param point.x The x component of the screen pixel coordinate.
88
- * @param point.y The y component of the screen pixel coordinate.
89
- * @return The normalized world coordinate.
90
- */
91
- export declare function screenToWorld(camera: Camera, point: {
92
- x: number;
93
- y: number;
94
- }): NormalizedPoint;
95
- /**
96
- * The bounding box of a transformed region in screen (pixel) space.
97
- */
98
- export interface VisualBounds {
99
- left: number;
100
- top: number;
101
- width: number;
102
- height: number;
103
- }
104
- /**
105
- * Returns the axis-aligned bounding box of the full image (normalized [0,1]x[0,1])
106
- * after applying the camera transform.
107
- *
108
- * @param camera The camera matrix from createCamera.
109
- * @return The screen-space bounding box of the full image.
110
- */
111
- export declare function getVisibleBounds(camera: Camera): VisualBounds;
112
- /**
113
- * Compose a camera matrix for exporting to a canvas.
114
- *
115
- * The resulting matrix maps image-pixel coordinates directly to output-canvas
116
- * coordinates. Apply it with `ctx.setTransform( ...camera )` then
117
- * `ctx.drawImage( image, 0, 0 )`.
118
- *
119
- * The transform chain mirrors the `renderToCanvas` function in canvas-renderer.ts:
120
- * translate(visualCenter - cropOffset + outCenter) → flip → rotate → zoom → translate(-imgCenter)
121
- *
122
- * @param state The current cropper state.
123
- * @param imageSize The natural size of the source image in pixels.
124
- * @param outputSize The desired output canvas size in pixels.
125
- * @return The composed export camera matrix.
126
- */
127
- export declare function createExportCamera(state: CropperState, imageSize: Size, outputSize: Size): Camera;
128
- //# sourceMappingURL=camera.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"camera.d.ts","sourceRoot":"","sources":["../../../src/image-editor/core/camera.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,YAAY,EACZ,eAAe,EACf,cAAc,EACd,IAAI,EACJ,MAAM,EACN,MAAM,SAAS,CAAC;AAcjB;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC7B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACd,IAAI,CAqBN;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAC1B,aAAa,EAAE,IAAI,EACnB,SAAS,EAAE,IAAI,EACf,QAAQ,EAAE,MAAM,GACd;IAAE,WAAW,EAAE,IAAI,CAAC;IAAC,UAAU,EAAE,IAAI,CAAA;CAAE,CAqCzC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,YAAY,CAC3B,QAAQ,EAAE,cAAc,EACxB,UAAU,EAAE,IAAI,EAChB,UAAU,EAAE,IAAI,EAChB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACd,MAAM,CAsBR;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,YAAY,CAC3B,KAAK,EAAE,YAAY,EACnB,aAAa,EAAE,IAAI,EACnB,SAAS,EAAE,IAAI,GACb,MAAM,CAgFR;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC5B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,eAAe,GACpB;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAI1B;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC5B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAC7B,eAAe,CAKjB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CACf;AAsCD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAE,MAAM,EAAE,MAAM,GAAI,YAAY,CAO/D;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,YAAY,EACnB,SAAS,EAAE,IAAI,EACf,UAAU,EAAE,IAAI,GACd,MAAM,CA2CR"}
@@ -1,99 +0,0 @@
1
- import type { CropperState } from './types';
2
- /**
3
- * Default/resting zoom. A full, unrotated crop needs at least 1x to cover the
4
- * crop area, but smaller/fine-rotated crops can be valid below 1x — the true
5
- * floor for those comes from `getMinZoom`.
6
- */
7
- export declare const MIN_ZOOM = 1;
8
- /**
9
- * Safety floor for coverage-aware zoom. Degenerate crops can have a geometric
10
- * coverage minimum of 0, but camera and inverse-matrix math need a stable,
11
- * positive scale.
12
- */
13
- export declare const ABSOLUTE_MIN_ZOOM = 0.1;
14
- export declare const MAX_ZOOM = 10;
15
- /**
16
- * Minimum crop rect dimension in source-image pixels, enforced per axis
17
- * during resize. Prevents accidental sub-pixel crops while staying small
18
- * enough to allow tight crops (favicons, icons). Adjust here to tune the
19
- * floor globally.
20
- */
21
- export declare const MIN_CROP_PIXELS = 16;
22
- /**
23
- * Minimum on-screen crop rect dimension in CSS pixels. The source-pixel
24
- * floor (`MIN_CROP_PIXELS`) keeps crops from going sub-pixel, but on a large
25
- * image fit into a small canvas it can render only a few CSS pixels wide —
26
- * too small to grab the resize handles. This floor keeps the crop operable
27
- * regardless of display scale; it binds when zoomed out and yields to the
28
- * source-pixel floor once the image is shown large enough. Sized to one
29
- * handle touch target (`$handle-touch-target-size` in `cropper.scss`).
30
- */
31
- export declare const MIN_CROP_SCREEN_PX = 44;
32
- /**
33
- * Fraction of the constraining canvas axis the settled crop should occupy on
34
- * screen. When a crop is shown smaller than this (e.g. a square crop in a tall
35
- * image, capped by the contain-fit footprint's narrow axis), the view magnifies
36
- * to fill the canvas. `1` = always fill the canvas; lower = rescue only the
37
- * under-filled cases. See `getViewScale`.
38
- */
39
- export declare const SETTLE_TARGET_CANVAS_FILL = 0.8;
40
- /**
41
- * Upper bound on the presentational view magnification (`getViewScale`).
42
- * Prevents a near-degenerate crop from magnifying the scene without limit.
43
- */
44
- export declare const MAX_VIEW_SCALE = 8;
45
- /**
46
- * CSS pixels per source pixel required before resize handles snap the selected
47
- * source region to whole-pixel edges. Below 1:1, a source pixel is sub-pixel on
48
- * screen, so snapping would feel notchy without a visible pixel boundary.
49
- */
50
- export declare const PIXEL_SNAP_DISPLAY_SCALE = 1;
51
- /**
52
- * Wheel zoom sensitivity. A deltaY of 100 changes zoom by 0.25.
53
- * This could be made configurable as a prop to the Cropper component.
54
- */
55
- export declare const DEFAULT_WHEEL_ZOOM_SPEED = 0.0025;
56
- /** Fine step for keyboard-driven cropper movement, in normalized coordinates. */
57
- export declare const DEFAULT_KEYBOARD_STEP = 0.01;
58
- /** Coarse keyboard movement multiplier when Shift is held. */
59
- export declare const KEYBOARD_SHIFT_STEP_MULTIPLIER = 10;
60
- /**
61
- * Maximum free-rotation offset in degrees from the nearest 90° step.
62
- * The rotation slider allows ±45° around the current cardinal angle.
63
- */
64
- export declare const MAX_ROTATION_OFFSET = 45;
65
- export declare const DEFAULT_STATE: CropperState;
66
- /**
67
- * An aspect ratio preset with a human-readable label.
68
- */
69
- export interface AspectRatioPreset {
70
- /** Display label (e.g., "Square (1:1)"). */
71
- label: string;
72
- /** The aspect ratio value (width / height). 0 = free / original. */
73
- value: number;
74
- }
75
- /**
76
- * Default aspect ratio presets. Consumers can use these as-is, override
77
- * with their own list, or extend with additional presets.
78
- *
79
- * @example
80
- * // Use defaults:
81
- * <CropControls presets={ DEFAULT_ASPECT_RATIOS } />
82
- *
83
- * // Custom presets:
84
- * const socialPresets = [
85
- * { label: 'Instagram Post', value: 1 },
86
- * { label: 'Instagram Story', value: 9 / 16 },
87
- * { label: 'YouTube Thumbnail', value: 16 / 9 },
88
- * ];
89
- *
90
- * // Extend defaults:
91
- * const extended = [ ...DEFAULT_ASPECT_RATIOS, { label: 'Cinema (21:9)', value: 21 / 9 } ];
92
- */
93
- /**
94
- * Sentinel value for "Original" aspect ratio — resolved at runtime
95
- * to the image's natural width / height.
96
- */
97
- export declare const ORIGINAL_ASPECT_RATIO = -1;
98
- export declare const DEFAULT_ASPECT_RATIOS: AspectRatioPreset[];
99
- //# sourceMappingURL=constants.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/image-editor/core/constants.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAwB,YAAY,EAAE,MAAM,SAAS,CAAC;AAElE;;;;GAIG;AACH,eAAO,MAAM,QAAQ,IAAI,CAAC;AAC1B;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,eAAO,MAAM,QAAQ,KAAK,CAAC;AAE3B;;;;;GAKG;AACH,eAAO,MAAM,eAAe,KAAK,CAAC;AAElC;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAErC;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAE7C;;;GAGG;AACH,eAAO,MAAM,cAAc,IAAI,CAAC;AAEhC;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAE1C;;;GAGG;AACH,eAAO,MAAM,wBAAwB,SAAS,CAAC;AAE/C,iFAAiF;AACjF,eAAO,MAAM,qBAAqB,OAAO,CAAC;AAE1C,8DAA8D;AAC9D,eAAO,MAAM,8BAA8B,KAAK,CAAC;AAEjD;;;GAGG;AACH,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAmBtC,eAAO,MAAM,aAAa,EAAE,YAU3B,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC,4CAA4C;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,oEAAoE;IACpE,KAAK,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH;;;GAGG;AACH,eAAO,MAAM,qBAAqB,KAAK,CAAC;AAExC,eAAO,MAAM,qBAAqB,EAAE,iBAAiB,EAUpD,CAAC"}
@@ -1,72 +0,0 @@
1
- import type { CropperState, NormalizedRect, Size } from './types';
2
- /**
3
- * Resolves the effective minimum zoom for the current state — the coverage-
4
- * aware floor when an image is loaded, falling back to `MIN_ZOOM` otherwise.
5
- * Used by both the cropper's interaction layer and the zoom slider so the
6
- * floor stays consistent across surfaces.
7
- *
8
- * @param state The current cropper state.
9
- * @return The minimum zoom factor.
10
- */
11
- export declare function getMinZoom(state: CropperState): number;
12
- /**
13
- * Compute the crop handle bounds in normalized visual space — the
14
- * axis-aligned bounding box (AABB) of the actual image footprint at the
15
- * current pan/zoom/rotation.
16
- *
17
- * Returns the full image AABB without intersecting with the container
18
- * viewport. The viewport pan mechanism in the Cropper component allows
19
- * the canvas to scroll so handles can reach the image edge even when it
20
- * lies outside the visible canvas area.
21
- *
22
- * Unlike a static centerline-based calculation, this accounts for the
23
- * current pan position — if the user pans right, the left bound tightens
24
- * because the image's left edge has moved right.
25
- *
26
- * @param state The current cropper state (crop, zoom, rotation, flip).
27
- * @param elementSize The fitted (unrotated) image element dimensions in pixels.
28
- * @param visualSize The visual (rotated) image bounding box in pixels.
29
- * @return The min/max x and y that a crop rect edge can reach in normalized space.
30
- */
31
- export declare function getImageCropBounds(state: CropperState, elementSize: Size, visualSize: Size): {
32
- minX: number;
33
- minY: number;
34
- maxX: number;
35
- maxY: number;
36
- };
37
- /**
38
- * Restricts a crop rectangle so that the rotated, zoomed image can fully cover it.
39
- * If the crop rect is too large for the current zoom and rotation, it is scaled
40
- * down proportionally and re-centered.
41
- *
42
- * Works in pixel-proportional space where the unrotated image is a×1.
43
- *
44
- * @param cropRect The crop rectangle in normalized coordinates.
45
- * @param zoom The current zoom factor.
46
- * @param rotation The rotation angle in degrees.
47
- * @param imageAspectRatio The image width / height ratio.
48
- * @return The restricted crop rectangle.
49
- */
50
- export declare function restrictCropRect(cropRect: NormalizedRect, zoom: number, rotation: number, imageAspectRatio: number): NormalizedRect;
51
- /**
52
- * Clamps pan and adjusts zoom so that the zoomed, rotated image fully covers
53
- * the crop rectangle.
54
- *
55
- * Uses the camera matrix to project: builds a camera from the candidate state,
56
- * maps the stencil corners (axis-aligned in the visual bounding box) to world
57
- * space via the inverse camera, and checks that all world points lie within
58
- * [0,1]×[0,1]. If any point is outside, computes the minimal pan correction.
59
- *
60
- * @param state The current cropper state.
61
- * @param imageSize The natural size of the image in pixels.
62
- * @param cropRect The crop rectangle in normalized coordinates.
63
- * @return The restricted crop pan and zoom values.
64
- */
65
- export declare function restrictPanZoom(state: CropperState, imageSize: Size, cropRect: NormalizedRect): {
66
- pan: {
67
- x: number;
68
- y: number;
69
- };
70
- zoom: number;
71
- };
72
- //# sourceMappingURL=containment.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"containment.d.ts","sourceRoot":"","sources":["../../../src/image-editor/core/containment.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAuFlE;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAE,KAAK,EAAE,YAAY,GAAI,MAAM,CAqBxD;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,YAAY,EACnB,WAAW,EAAE,IAAI,EACjB,UAAU,EAAE,IAAI,GACd;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CA0D5D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAC/B,QAAQ,EAAE,cAAc,EACxB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,gBAAgB,EAAE,MAAM,GACtB,cAAc,CAqDhB;AAcD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAC9B,KAAK,EAAE,YAAY,EACnB,SAAS,EAAE,IAAI,EACf,QAAQ,EAAE,cAAc,GACtB;IAAE,GAAG,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAkKjD"}
@@ -1,16 +0,0 @@
1
- import type { NormalizedRect, Size } from './types';
2
- /**
3
- * Largest rect of the given pixel aspect ratio that fits inside the
4
- * visual bounds, centered in [0,1] × [0,1] normalized space. Returns
5
- * a full-frame rect (1×1) if `aspectRatio` is unset or non-positive.
6
- *
7
- * The returned rect is the same in either freeform or fixed-crop
8
- * mode — it's the canonical "centered crop for this ratio at this
9
- * canvas size".
10
- *
11
- * @param aspectRatio Desired pixel width/height ratio. `undefined`
12
- * (or 0/negative) means no lock — returns full frame.
13
- * @param visualSize Rendered image dimensions in pixels.
14
- */
15
- export declare function computeInscribedRect(aspectRatio: number | undefined, visualSize: Size): NormalizedRect;
16
- //# sourceMappingURL=crop-rect.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"crop-rect.d.ts","sourceRoot":"","sources":["../../../src/image-editor/core/crop-rect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAEpD;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CACnC,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,UAAU,EAAE,IAAI,GACd,cAAc,CAuBhB"}
@@ -1,103 +0,0 @@
1
- import type { CropperState } from '../types';
2
- /**
3
- * Load an image from a URL with CORS support.
4
- *
5
- * @param src - The image URL to load.
6
- * @return A promise that resolves to the loaded HTMLImageElement.
7
- */
8
- export declare function loadImage(src: string): Promise<HTMLImageElement>;
9
- /**
10
- * Apply rectangular crop, rotation, and flip transforms to produce a canvas.
11
- *
12
- * Uses createExportCamera to compose the full transform matrix, then applies
13
- * it in a single ctx.setTransform call before drawing the image.
14
- *
15
- * @param image - The source image element.
16
- * @param state - The full cropper state containing crop, rotation, and flip settings.
17
- * @return A canvas element containing the transformed and cropped image.
18
- */
19
- export declare function renderToCanvas(image: HTMLImageElement, state: CropperState): HTMLCanvasElement;
20
- /**
21
- * Convert a canvas to a Blob with configurable MIME type and quality.
22
- *
23
- * @param canvas - The canvas to export.
24
- * @param mimeType - The output MIME type. Defaults to 'image/png'.
25
- * @param quality - The quality parameter for lossy formats (0-1). Defaults to DEFAULT_QUALITY.
26
- * @return A promise that resolves to the canvas content as a Blob.
27
- */
28
- export declare function canvasToBlob(canvas: HTMLCanvasElement, mimeType?: string, quality?: number): Promise<Blob>;
29
- /**
30
- * Convert a canvas to a data URL string.
31
- *
32
- * @param canvas - The canvas to export.
33
- * @param mimeType - The output MIME type. Defaults to 'image/png'.
34
- * @param quality - The quality parameter for lossy formats (0-1). Defaults to DEFAULT_QUALITY.
35
- * @return The canvas content as a data URL string.
36
- */
37
- export declare function canvasToDataURL(canvas: HTMLCanvasElement, mimeType?: string, quality?: number): string;
38
- /**
39
- * Load an image, render with transforms, and export as a Blob.
40
- *
41
- * Throws on failure so callers can distinguish error cases:
42
- * - Image load failures (network errors, 404s) throw the native
43
- * load error from the Image element.
44
- * - Cross-origin failures manifest as tainted-canvas errors from
45
- * `canvas.toBlob()` — the browser rejects reading pixel data
46
- * from a canvas that drew an image without valid CORS headers.
47
- * Ensure the source server sets `Access-Control-Allow-Origin`.
48
- * - Canvas context creation failures throw a descriptive Error.
49
- *
50
- * Only works in browser environments (needs DOM / HTMLCanvasElement).
51
- *
52
- * @param src - The image URL to load.
53
- * @param state - The cropper state with all transform settings.
54
- * @param mimeType - The output MIME type. Defaults to 'image/png'.
55
- * @param quality - The quality parameter for lossy formats (0-1). Defaults to DEFAULT_QUALITY.
56
- * @return A promise that resolves to the exported Blob.
57
- * @throws If the image fails to load, canvas creation fails, or
58
- * the resulting canvas is tainted by CORS restrictions.
59
- */
60
- export declare function exportCroppedImage(src: string, state: CropperState, mimeType?: string, quality?: number): Promise<Blob>;
61
- /**
62
- * Apply the cropper's transform (crop, rotation, flip, zoom) to an existing
63
- * canvas or image source. This is the bridge for multi-step editing pipelines
64
- * where an upstream tool (e.g., brightness/color adjustment) has already
65
- * processed the image and you want to apply the crop on top.
66
- *
67
- * Accepts any CanvasImageSource: HTMLImageElement, HTMLCanvasElement,
68
- * OffscreenCanvas, ImageBitmap, HTMLVideoElement, etc.
69
- *
70
- * @param source - The image source to crop/transform.
71
- * @param sourceSize - The dimensions of the source (natural width/height).
72
- * @param sourceSize.width - The width of the source in pixels.
73
- * @param sourceSize.height - The height of the source in pixels.
74
- * @param state - The cropper state with all transform settings.
75
- * @param outputSize - Optional output size. Defaults to the crop region's natural pixel size.
76
- * @param outputSize.width - The width of the output in pixels.
77
- * @param outputSize.height - The height of the output in pixels.
78
- * @return A canvas with the transforms applied.
79
- */
80
- export declare function applyToCanvas(source: CanvasImageSource, sourceSize: {
81
- width: number;
82
- height: number;
83
- }, state: CropperState, outputSize?: {
84
- width: number;
85
- height: number;
86
- }): HTMLCanvasElement;
87
- /**
88
- * Download the cropped image as a file.
89
- *
90
- * Loads the source image, applies all transforms, and triggers a
91
- * browser download via exportCroppedImage() + object URL + anchor click.
92
- *
93
- * Throws on export failure (see `exportCroppedImage`).
94
- *
95
- * @param src - The image URL to load.
96
- * @param state - The cropper state with all transform settings.
97
- * @param filename - The download filename. Defaults to 'cropped-image'.
98
- * @param mimeType - The output MIME type. Defaults to 'image/png'.
99
- * @param quality - The quality parameter for lossy formats (0-1). Defaults to DEFAULT_QUALITY.
100
- * @return A promise that resolves when the download is triggered.
101
- */
102
- export declare function downloadCroppedImage(src: string, state: CropperState, filename?: string, mimeType?: string, quality?: number): Promise<void>;
103
- //# sourceMappingURL=canvas-renderer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"canvas-renderer.d.ts","sourceRoot":"","sources":["../../../../src/image-editor/core/export/canvas-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAM7C;;;;;GAKG;AACH,wBAAgB,SAAS,CAAE,GAAG,EAAE,MAAM,GAAI,OAAO,CAAE,gBAAgB,CAAE,CAQpE;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC7B,KAAK,EAAE,gBAAgB,EACvB,KAAK,EAAE,YAAY,GACjB,iBAAiB,CAqCnB;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC3B,MAAM,EAAE,iBAAiB,EACzB,QAAQ,GAAE,MAAoB,EAC9B,OAAO,GAAE,MAAwB,GAC/B,OAAO,CAAE,IAAI,CAAE,CAcjB;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC9B,MAAM,EAAE,iBAAiB,EACzB,QAAQ,GAAE,MAAoB,EAC9B,OAAO,GAAE,MAAwB,GAC/B,MAAM,CAER;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,kBAAkB,CACvC,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,YAAY,EACnB,QAAQ,GAAE,MAAoB,EAC9B,OAAO,GAAE,MAAwB,GAC/B,OAAO,CAAE,IAAI,CAAE,CAIjB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,aAAa,CAC5B,MAAM,EAAE,iBAAiB,EACzB,UAAU,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAC7C,KAAK,EAAE,YAAY,EACnB,UAAU,CAAC,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC5C,iBAAiB,CA0CnB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,oBAAoB,CACzC,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,YAAY,EACnB,QAAQ,GAAE,MAAwB,EAClC,QAAQ,GAAE,MAAoB,EAC9B,OAAO,GAAE,MAAwB,GAC/B,OAAO,CAAE,IAAI,CAAE,CASjB"}
@@ -1,10 +0,0 @@
1
- export type { CropperState, CropperAction, TransformOperation, NormalizedPoint, NormalizedRect, Size, Flip, StencilProps, HandlePosition, } from './types';
2
- export { DEFAULT_STATE, DEFAULT_ASPECT_RATIOS, ORIGINAL_ASPECT_RATIO, } from './constants';
3
- export type { AspectRatioPreset } from './constants';
4
- export { cropperReducer, enforceContainment, areCropperStatesEqual, isStateDirty, } from './state';
5
- export { getSourceRegion, getSourceRegionPercent } from './source-region';
6
- export type { SourceRegion, SourceRegionPercent } from './source-region';
7
- export { computeInscribedRect } from './crop-rect';
8
- export { applyOperationToState, stateFromPipeline, } from './transforms/pipeline';
9
- export { exportCroppedImage, applyToCanvas } from './export/canvas-renderer';
10
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/image-editor/core/index.ts"],"names":[],"mappings":"AACA,YAAY,EACX,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,IAAI,EACJ,IAAI,EACJ,YAAY,EACZ,cAAc,GACd,MAAM,SAAS,CAAC;AAGjB,OAAO,EACN,aAAa,EACb,qBAAqB,EACrB,qBAAqB,GACrB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAMrD,OAAO,EACN,cAAc,EACd,kBAAkB,EAClB,qBAAqB,EACrB,YAAY,GACZ,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAC1E,YAAY,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAGzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAGnD,OAAO,EACN,qBAAqB,EACrB,iBAAiB,GACjB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC"}