@wordpress/media-editor 0.22.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 (353) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/build/components/media-editor/index.cjs +74 -21
  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 +23 -3
  7. package/build/components/media-editor/use-save-media-editor.cjs.map +1 -1
  8. package/build/components/media-editor-canvas/index.cjs +6 -11
  9. package/build/components/media-editor-canvas/index.cjs.map +1 -1
  10. package/build/components/media-editor-crop-panel/index.cjs +17 -1
  11. package/build/components/media-editor-crop-panel/index.cjs.map +1 -1
  12. package/build/components/media-editor-fine-rotation/index.cjs +4 -5
  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 +1 -0
  17. package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs.map +1 -1
  18. package/build/components/media-editor-modal/index.cjs.map +1 -1
  19. package/build/components/media-form/index.cjs +7 -1
  20. package/build/components/media-form/index.cjs.map +1 -1
  21. package/build/components/media-preview/index.cjs +0 -1
  22. package/build/components/media-preview/index.cjs.map +1 -1
  23. package/build/state/aspect-ratio-presets.cjs +10 -4
  24. package/build/state/aspect-ratio-presets.cjs.map +1 -1
  25. package/build/state/composite-reducer.cjs +32 -67
  26. package/build/state/composite-reducer.cjs.map +1 -1
  27. package/build/state/index.cjs +0 -39
  28. package/build/state/types.cjs +1 -2
  29. package/build/state/types.cjs.map +1 -1
  30. package/build/state/use-media-editor-state.cjs +70 -106
  31. package/build/state/use-media-editor-state.cjs.map +1 -1
  32. package/build-module/components/media-editor/index.mjs +78 -25
  33. package/build-module/components/media-editor/index.mjs.map +1 -1
  34. package/build-module/components/media-editor/use-crop-options.mjs +4 -5
  35. package/build-module/components/media-editor/use-crop-options.mjs.map +1 -1
  36. package/build-module/components/media-editor/use-save-media-editor.mjs +23 -3
  37. package/build-module/components/media-editor/use-save-media-editor.mjs.map +1 -1
  38. package/build-module/components/media-editor-canvas/index.mjs +8 -13
  39. package/build-module/components/media-editor-canvas/index.mjs.map +1 -1
  40. package/build-module/components/media-editor-crop-panel/index.mjs +17 -1
  41. package/build-module/components/media-editor-crop-panel/index.mjs.map +1 -1
  42. package/build-module/components/media-editor-fine-rotation/index.mjs +4 -5
  43. package/build-module/components/media-editor-fine-rotation/index.mjs.map +1 -1
  44. package/build-module/components/media-editor-image-controls/index.mjs +5 -7
  45. package/build-module/components/media-editor-image-controls/index.mjs.map +1 -1
  46. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs +1 -0
  47. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs.map +1 -1
  48. package/build-module/components/media-editor-modal/index.mjs.map +1 -1
  49. package/build-module/components/media-form/index.mjs +7 -1
  50. package/build-module/components/media-form/index.mjs.map +1 -1
  51. package/build-module/components/media-preview/index.mjs +0 -1
  52. package/build-module/components/media-preview/index.mjs.map +1 -1
  53. package/build-module/state/aspect-ratio-presets.mjs +10 -5
  54. package/build-module/state/aspect-ratio-presets.mjs.map +1 -1
  55. package/build-module/state/composite-reducer.mjs +32 -67
  56. package/build-module/state/composite-reducer.mjs.map +1 -1
  57. package/build-module/state/index.mjs +2 -5
  58. package/build-module/state/types.mjs +1 -2
  59. package/build-module/state/types.mjs.map +1 -1
  60. package/build-module/state/use-media-editor-state.mjs +70 -105
  61. package/build-module/state/use-media-editor-state.mjs.map +1 -1
  62. package/build-style/style-rtl.css +104 -57
  63. package/build-style/style.css +103 -57
  64. package/build-types/components/media-editor/index.d.ts +17 -3
  65. package/build-types/components/media-editor/index.d.ts.map +1 -1
  66. package/build-types/components/media-editor/use-crop-options.d.ts +2 -3
  67. package/build-types/components/media-editor/use-crop-options.d.ts.map +1 -1
  68. package/build-types/components/media-editor/use-save-media-editor.d.ts.map +1 -1
  69. package/build-types/components/media-editor-canvas/index.d.ts +3 -3
  70. package/build-types/components/media-editor-canvas/index.d.ts.map +1 -1
  71. package/build-types/components/media-editor-crop-panel/index.d.ts +1 -1
  72. package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -1
  73. package/build-types/components/media-editor-fine-rotation/index.d.ts.map +1 -1
  74. package/build-types/components/media-editor-image-controls/index.d.ts +1 -1
  75. package/build-types/components/media-editor-image-controls/index.d.ts.map +1 -1
  76. package/build-types/components/media-editor-keyboard-shortcuts-modal/index.d.ts.map +1 -1
  77. package/build-types/components/media-editor-modal/index.d.ts +1 -1
  78. package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
  79. package/build-types/components/media-form/index.d.ts.map +1 -1
  80. package/build-types/components/media-preview/index.d.ts.map +1 -1
  81. package/build-types/state/aspect-ratio-presets.d.ts +20 -3
  82. package/build-types/state/aspect-ratio-presets.d.ts.map +1 -1
  83. package/build-types/state/composite-reducer.d.ts +17 -19
  84. package/build-types/state/composite-reducer.d.ts.map +1 -1
  85. package/build-types/state/index.d.ts +2 -5
  86. package/build-types/state/index.d.ts.map +1 -1
  87. package/build-types/state/types.d.ts +20 -64
  88. package/build-types/state/types.d.ts.map +1 -1
  89. package/build-types/state/use-media-editor-state.d.ts +33 -52
  90. package/build-types/state/use-media-editor-state.d.ts.map +1 -1
  91. package/package.json +22 -23
  92. package/src/components/media-editor/index.tsx +163 -28
  93. package/src/components/media-editor/use-crop-options.ts +7 -11
  94. package/src/components/media-editor/use-save-media-editor.ts +48 -6
  95. package/src/components/media-editor-canvas/index.tsx +15 -26
  96. package/src/components/media-editor-canvas/style.scss +6 -6
  97. package/src/components/media-editor-crop-panel/index.tsx +38 -2
  98. package/src/components/media-editor-crop-panel/style.scss +21 -0
  99. package/src/components/media-editor-fine-rotation/index.tsx +6 -6
  100. package/src/components/media-editor-image-controls/index.tsx +11 -9
  101. package/src/components/media-editor-keyboard-shortcuts-modal/index.tsx +1 -0
  102. package/src/components/media-editor-keyboard-shortcuts-modal/style.scss +1 -1
  103. package/src/components/media-editor-modal/index.tsx +1 -1
  104. package/src/components/media-form/index.tsx +7 -1
  105. package/src/components/media-preview/index.tsx +0 -1
  106. package/src/components/rotation-ruler/style.scss +3 -3
  107. package/src/state/README.md +32 -0
  108. package/src/state/aspect-ratio-presets.ts +22 -3
  109. package/src/state/composite-reducer.ts +42 -80
  110. package/src/state/index.ts +2 -18
  111. package/src/state/types.ts +18 -68
  112. package/src/state/use-media-editor-state.ts +155 -240
  113. package/src/style.scss +2 -1
  114. package/build/components/media-editor-modal/build-modifiers.cjs +0 -110
  115. package/build/components/media-editor-modal/build-modifiers.cjs.map +0 -1
  116. package/build/image-editor/core/camera.cjs +0 -277
  117. package/build/image-editor/core/camera.cjs.map +0 -1
  118. package/build/image-editor/core/constants.cjs +0 -133
  119. package/build/image-editor/core/constants.cjs.map +0 -1
  120. package/build/image-editor/core/containment.cjs +0 -289
  121. package/build/image-editor/core/containment.cjs.map +0 -1
  122. package/build/image-editor/core/crop-rect.cjs +0 -37
  123. package/build/image-editor/core/crop-rect.cjs.map +0 -1
  124. package/build/image-editor/core/export/canvas-renderer.cjs +0 -181
  125. package/build/image-editor/core/export/canvas-renderer.cjs.map +0 -1
  126. package/build/image-editor/core/index.cjs +0 -89
  127. package/build/image-editor/core/interaction-controller.cjs +0 -591
  128. package/build/image-editor/core/interaction-controller.cjs.map +0 -1
  129. package/build/image-editor/core/math/rotation.cjs +0 -32
  130. package/build/image-editor/core/math/rotation.cjs.map +0 -1
  131. package/build/image-editor/core/math/sanitize.cjs +0 -136
  132. package/build/image-editor/core/math/sanitize.cjs.map +0 -1
  133. package/build/image-editor/core/setter-helpers.cjs +0 -61
  134. package/build/image-editor/core/setter-helpers.cjs.map +0 -1
  135. package/build/image-editor/core/source-region.cjs +0 -236
  136. package/build/image-editor/core/source-region.cjs.map +0 -1
  137. package/build/image-editor/core/state.cjs +0 -296
  138. package/build/image-editor/core/state.cjs.map +0 -1
  139. package/build/image-editor/core/stencil-math.cjs +0 -203
  140. package/build/image-editor/core/stencil-math.cjs.map +0 -1
  141. package/build/image-editor/core/transform-style.cjs +0 -43
  142. package/build/image-editor/core/transform-style.cjs.map +0 -1
  143. package/build/image-editor/core/transforms/pipeline.cjs +0 -41
  144. package/build/image-editor/core/transforms/pipeline.cjs.map +0 -1
  145. package/build/image-editor/core/types.cjs +0 -5
  146. package/build/image-editor/core/viewport-state.cjs +0 -36
  147. package/build/image-editor/core/viewport-state.cjs.map +0 -1
  148. package/build/image-editor/index.cjs +0 -68
  149. package/build/image-editor/react/components/cropper-provider.cjs +0 -49
  150. package/build/image-editor/react/components/cropper-provider.cjs.map +0 -1
  151. package/build/image-editor/react/components/cropper.cjs +0 -595
  152. package/build/image-editor/react/components/cropper.cjs.map +0 -1
  153. package/build/image-editor/react/components/index.cjs +0 -25
  154. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs +0 -147
  155. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs.map +0 -1
  156. package/build/image-editor/react/components/overlays/dimming-overlay.cjs +0 -31
  157. package/build/image-editor/react/components/overlays/dimming-overlay.cjs.map +0 -1
  158. package/build/image-editor/react/components/overlays/grid-overlay.cjs +0 -61
  159. package/build/image-editor/react/components/overlays/grid-overlay.cjs.map +0 -1
  160. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs +0 -367
  161. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +0 -1
  162. package/build/image-editor/react/components/viewport-provider.cjs +0 -26
  163. package/build/image-editor/react/components/viewport-provider.cjs.map +0 -1
  164. package/build/image-editor/react/hooks/build-cropper-setters.cjs +0 -80
  165. package/build/image-editor/react/hooks/build-cropper-setters.cjs.map +0 -1
  166. package/build/image-editor/react/hooks/index.cjs +0 -19
  167. package/build/image-editor/react/hooks/use-aria-announcer.cjs +0 -104
  168. package/build/image-editor/react/hooks/use-aria-announcer.cjs.map +0 -1
  169. package/build/image-editor/react/hooks/use-cropper-controller.cjs +0 -80
  170. package/build/image-editor/react/hooks/use-cropper-controller.cjs.map +0 -1
  171. package/build/image-editor/react/hooks/use-interaction.cjs +0 -187
  172. package/build/image-editor/react/hooks/use-interaction.cjs.map +0 -1
  173. package/build/image-editor/react/hooks/use-transform-style.cjs +0 -24
  174. package/build/image-editor/react/hooks/use-transform-style.cjs.map +0 -1
  175. package/build/image-editor/react/hooks/use-viewport-state.cjs +0 -40
  176. package/build/image-editor/react/hooks/use-viewport-state.cjs.map +0 -1
  177. package/build/image-editor/react/visually-hidden-style.cjs +0 -24
  178. package/build/image-editor/react/visually-hidden-style.cjs.map +0 -1
  179. package/build-module/components/media-editor-modal/build-modifiers.mjs +0 -105
  180. package/build-module/components/media-editor-modal/build-modifiers.mjs.map +0 -1
  181. package/build-module/image-editor/core/camera.mjs +0 -265
  182. package/build-module/image-editor/core/camera.mjs.map +0 -1
  183. package/build-module/image-editor/core/constants.mjs +0 -115
  184. package/build-module/image-editor/core/constants.mjs.map +0 -1
  185. package/build-module/image-editor/core/containment.mjs +0 -281
  186. package/build-module/image-editor/core/containment.mjs.map +0 -1
  187. package/build-module/image-editor/core/crop-rect.mjs +0 -32
  188. package/build-module/image-editor/core/crop-rect.mjs.map +0 -1
  189. package/build-module/image-editor/core/export/canvas-renderer.mjs +0 -170
  190. package/build-module/image-editor/core/export/canvas-renderer.mjs.map +0 -1
  191. package/build-module/image-editor/core/index.mjs +0 -7
  192. package/build-module/image-editor/core/interaction-controller.mjs +0 -586
  193. package/build-module/image-editor/core/interaction-controller.mjs.map +0 -1
  194. package/build-module/image-editor/core/math/rotation.mjs +0 -26
  195. package/build-module/image-editor/core/math/rotation.mjs.map +0 -1
  196. package/build-module/image-editor/core/math/sanitize.mjs +0 -127
  197. package/build-module/image-editor/core/math/sanitize.mjs.map +0 -1
  198. package/build-module/image-editor/core/setter-helpers.mjs +0 -56
  199. package/build-module/image-editor/core/setter-helpers.mjs.map +0 -1
  200. package/build-module/image-editor/core/source-region.mjs +0 -228
  201. package/build-module/image-editor/core/source-region.mjs.map +0 -1
  202. package/build-module/image-editor/core/state.mjs +0 -288
  203. package/build-module/image-editor/core/state.mjs.map +0 -1
  204. package/build-module/image-editor/core/stencil-math.mjs +0 -194
  205. package/build-module/image-editor/core/stencil-math.mjs.map +0 -1
  206. package/build-module/image-editor/core/transform-style.mjs +0 -38
  207. package/build-module/image-editor/core/transform-style.mjs.map +0 -1
  208. package/build-module/image-editor/core/transforms/pipeline.mjs +0 -35
  209. package/build-module/image-editor/core/transforms/pipeline.mjs.map +0 -1
  210. package/build-module/image-editor/core/types.mjs +0 -0
  211. package/build-module/image-editor/core/viewport-state.mjs +0 -30
  212. package/build-module/image-editor/core/viewport-state.mjs.map +0 -1
  213. package/build-module/image-editor/index.mjs +0 -4
  214. package/build-module/image-editor/react/components/cropper-provider.mjs +0 -43
  215. package/build-module/image-editor/react/components/cropper-provider.mjs.map +0 -1
  216. package/build-module/image-editor/react/components/cropper.mjs +0 -568
  217. package/build-module/image-editor/react/components/cropper.mjs.map +0 -1
  218. package/build-module/image-editor/react/components/index.mjs +0 -3
  219. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs +0 -142
  220. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs.map +0 -1
  221. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs +0 -26
  222. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs.map +0 -1
  223. package/build-module/image-editor/react/components/overlays/grid-overlay.mjs +0 -56
  224. package/build-module/image-editor/react/components/overlays/grid-overlay.mjs.map +0 -1
  225. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs +0 -362
  226. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs.map +0 -1
  227. package/build-module/image-editor/react/components/viewport-provider.mjs +0 -20
  228. package/build-module/image-editor/react/components/viewport-provider.mjs.map +0 -1
  229. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs +0 -75
  230. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs.map +0 -1
  231. package/build-module/image-editor/react/hooks/index.mjs +0 -3
  232. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs +0 -99
  233. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs.map +0 -1
  234. package/build-module/image-editor/react/hooks/use-cropper-controller.mjs +0 -75
  235. package/build-module/image-editor/react/hooks/use-cropper-controller.mjs.map +0 -1
  236. package/build-module/image-editor/react/hooks/use-interaction.mjs +0 -182
  237. package/build-module/image-editor/react/hooks/use-interaction.mjs.map +0 -1
  238. package/build-module/image-editor/react/hooks/use-transform-style.mjs +0 -19
  239. package/build-module/image-editor/react/hooks/use-transform-style.mjs.map +0 -1
  240. package/build-module/image-editor/react/hooks/use-viewport-state.mjs +0 -35
  241. package/build-module/image-editor/react/hooks/use-viewport-state.mjs.map +0 -1
  242. package/build-module/image-editor/react/visually-hidden-style.mjs +0 -19
  243. package/build-module/image-editor/react/visually-hidden-style.mjs.map +0 -1
  244. package/build-types/components/media-editor-modal/build-modifiers.d.ts +0 -81
  245. package/build-types/components/media-editor-modal/build-modifiers.d.ts.map +0 -1
  246. package/build-types/image-editor/core/camera.d.ts +0 -128
  247. package/build-types/image-editor/core/camera.d.ts.map +0 -1
  248. package/build-types/image-editor/core/constants.d.ts +0 -98
  249. package/build-types/image-editor/core/constants.d.ts.map +0 -1
  250. package/build-types/image-editor/core/containment.d.ts +0 -72
  251. package/build-types/image-editor/core/containment.d.ts.map +0 -1
  252. package/build-types/image-editor/core/crop-rect.d.ts +0 -16
  253. package/build-types/image-editor/core/crop-rect.d.ts.map +0 -1
  254. package/build-types/image-editor/core/export/canvas-renderer.d.ts +0 -103
  255. package/build-types/image-editor/core/export/canvas-renderer.d.ts.map +0 -1
  256. package/build-types/image-editor/core/index.d.ts +0 -10
  257. package/build-types/image-editor/core/index.d.ts.map +0 -1
  258. package/build-types/image-editor/core/interaction-controller.d.ts +0 -191
  259. package/build-types/image-editor/core/interaction-controller.d.ts.map +0 -1
  260. package/build-types/image-editor/core/math/rotation.d.ts +0 -18
  261. package/build-types/image-editor/core/math/rotation.d.ts.map +0 -1
  262. package/build-types/image-editor/core/math/sanitize.d.ts +0 -67
  263. package/build-types/image-editor/core/math/sanitize.d.ts.map +0 -1
  264. package/build-types/image-editor/core/setter-helpers.d.ts +0 -21
  265. package/build-types/image-editor/core/setter-helpers.d.ts.map +0 -1
  266. package/build-types/image-editor/core/source-region.d.ts +0 -94
  267. package/build-types/image-editor/core/source-region.d.ts.map +0 -1
  268. package/build-types/image-editor/core/state.d.ts +0 -51
  269. package/build-types/image-editor/core/state.d.ts.map +0 -1
  270. package/build-types/image-editor/core/stencil-math.d.ts +0 -102
  271. package/build-types/image-editor/core/stencil-math.d.ts.map +0 -1
  272. package/build-types/image-editor/core/transform-style.d.ts +0 -20
  273. package/build-types/image-editor/core/transform-style.d.ts.map +0 -1
  274. package/build-types/image-editor/core/transforms/pipeline.d.ts +0 -24
  275. package/build-types/image-editor/core/transforms/pipeline.d.ts.map +0 -1
  276. package/build-types/image-editor/core/types.d.ts +0 -269
  277. package/build-types/image-editor/core/types.d.ts.map +0 -1
  278. package/build-types/image-editor/core/viewport-state.d.ts +0 -4
  279. package/build-types/image-editor/core/viewport-state.d.ts.map +0 -1
  280. package/build-types/image-editor/index.d.ts +0 -17
  281. package/build-types/image-editor/index.d.ts.map +0 -1
  282. package/build-types/image-editor/react/components/cropper-provider.d.ts +0 -38
  283. package/build-types/image-editor/react/components/cropper-provider.d.ts.map +0 -1
  284. package/build-types/image-editor/react/components/cropper.d.ts +0 -54
  285. package/build-types/image-editor/react/components/cropper.d.ts.map +0 -1
  286. package/build-types/image-editor/react/components/index.d.ts +0 -4
  287. package/build-types/image-editor/react/components/index.d.ts.map +0 -1
  288. package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts +0 -33
  289. package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts.map +0 -1
  290. package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts +0 -17
  291. package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts.map +0 -1
  292. package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts +0 -27
  293. package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts.map +0 -1
  294. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts +0 -33
  295. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts.map +0 -1
  296. package/build-types/image-editor/react/components/viewport-provider.d.ts +0 -6
  297. package/build-types/image-editor/react/components/viewport-provider.d.ts.map +0 -1
  298. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts +0 -44
  299. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts.map +0 -1
  300. package/build-types/image-editor/react/hooks/index.d.ts +0 -5
  301. package/build-types/image-editor/react/hooks/index.d.ts.map +0 -1
  302. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts +0 -14
  303. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts.map +0 -1
  304. package/build-types/image-editor/react/hooks/use-cropper-controller.d.ts +0 -55
  305. package/build-types/image-editor/react/hooks/use-cropper-controller.d.ts.map +0 -1
  306. package/build-types/image-editor/react/hooks/use-interaction.d.ts +0 -65
  307. package/build-types/image-editor/react/hooks/use-interaction.d.ts.map +0 -1
  308. package/build-types/image-editor/react/hooks/use-transform-style.d.ts +0 -13
  309. package/build-types/image-editor/react/hooks/use-transform-style.d.ts.map +0 -1
  310. package/build-types/image-editor/react/hooks/use-viewport-state.d.ts +0 -16
  311. package/build-types/image-editor/react/hooks/use-viewport-state.d.ts.map +0 -1
  312. package/build-types/image-editor/react/visually-hidden-style.d.ts +0 -6
  313. package/build-types/image-editor/react/visually-hidden-style.d.ts.map +0 -1
  314. package/src/components/media-editor-modal/build-modifiers.ts +0 -167
  315. package/src/image-editor/README.md +0 -61
  316. package/src/image-editor/core/camera.ts +0 -429
  317. package/src/image-editor/core/constants.ts +0 -137
  318. package/src/image-editor/core/containment.ts +0 -469
  319. package/src/image-editor/core/crop-rect.ts +0 -42
  320. package/src/image-editor/core/export/canvas-renderer.ts +0 -250
  321. package/src/image-editor/core/index.ts +0 -43
  322. package/src/image-editor/core/interaction-controller.ts +0 -976
  323. package/src/image-editor/core/math/rotation.ts +0 -26
  324. package/src/image-editor/core/math/sanitize.ts +0 -155
  325. package/src/image-editor/core/setter-helpers.ts +0 -63
  326. package/src/image-editor/core/source-region.ts +0 -367
  327. package/src/image-editor/core/state.ts +0 -484
  328. package/src/image-editor/core/stencil-math.ts +0 -379
  329. package/src/image-editor/core/transform-style.ts +0 -56
  330. package/src/image-editor/core/transforms/pipeline.ts +0 -40
  331. package/src/image-editor/core/types.ts +0 -230
  332. package/src/image-editor/core/viewport-state.ts +0 -30
  333. package/src/image-editor/docs/architecture.md +0 -63
  334. package/src/image-editor/docs/recipes.md +0 -184
  335. package/src/image-editor/index.ts +0 -43
  336. package/src/image-editor/react/components/cropper-provider.tsx +0 -70
  337. package/src/image-editor/react/components/cropper.scss +0 -259
  338. package/src/image-editor/react/components/cropper.tsx +0 -1108
  339. package/src/image-editor/react/components/index.ts +0 -3
  340. package/src/image-editor/react/components/overlays/dimensions-overlay.tsx +0 -262
  341. package/src/image-editor/react/components/overlays/dimming-overlay.tsx +0 -55
  342. package/src/image-editor/react/components/overlays/grid-overlay.tsx +0 -77
  343. package/src/image-editor/react/components/stencils/rectangle-stencil.tsx +0 -623
  344. package/src/image-editor/react/components/viewport-provider.tsx +0 -32
  345. package/src/image-editor/react/hooks/build-cropper-setters.ts +0 -102
  346. package/src/image-editor/react/hooks/index.ts +0 -4
  347. package/src/image-editor/react/hooks/use-aria-announcer.ts +0 -193
  348. package/src/image-editor/react/hooks/use-cropper-controller.ts +0 -197
  349. package/src/image-editor/react/hooks/use-interaction.ts +0 -294
  350. package/src/image-editor/react/hooks/use-transform-style.ts +0 -23
  351. package/src/image-editor/react/hooks/use-viewport-state.ts +0 -41
  352. package/src/image-editor/react/visually-hidden-style.ts +0 -15
  353. package/src/image-editor/style.scss +0 -1
@@ -1,281 +0,0 @@
1
- import { mat2d, vec2 } from "gl-matrix";
2
- import { ABSOLUTE_MIN_ZOOM, MAX_ZOOM, MIN_ZOOM } from "./constants.mjs";
3
- import { degreesToRadians } from "./math/rotation.mjs";
4
- import { isValidSize, safeBoundedNumber, sanitizeCropperState, sanitizeRect } from "./math/sanitize.mjs";
5
- import { createCamera, getRotatedBBox, getVisibleBounds } from "./camera.mjs";
6
- // packages/media-editor/src/image-editor/core/containment.ts
7
- /**
8
- * Compute the visual (rotated) bounding-box dimensions in pixel-proportional
9
- * units where the unrotated image is `a × 1` (renderedW = a, renderedH = 1).
10
- *
11
- * @param rotation Rotation angle in degrees.
12
- * @param imageAspectRatio Image width / height ratio.
13
- * @return Visual dimensions and trig helpers.
14
- */
15
- function getVisualDimensions(rotation, imageAspectRatio) {
16
- const rad = degreesToRadians(rotation);
17
- const absC = Math.abs(Math.cos(rad));
18
- const absS = Math.abs(Math.sin(rad));
19
- const bbox = getRotatedBBox(imageAspectRatio, 1, rotation);
20
- return {
21
- visualW: bbox.width,
22
- visualH: bbox.height,
23
- absC,
24
- absS
25
- };
26
- }
27
- /**
28
- * The geometric minimum zoom required for the rotated image to fully cover the
29
- * crop rectangle. Works in pixel-proportional space where the unrotated image
30
- * is a×1; the crop rect lives in visual-normalized space and is scaled by the
31
- * rotation-dependent visual dimensions before projecting into the image-local
32
- * frame.
33
- *
34
- * Returns 0 for a degenerate (zero-area) crop — callers compose the result
35
- * with their own floor (typically the current zoom or `MIN_ZOOM`).
36
- *
37
- * @param rotation Rotation angle in degrees.
38
- * @param imageAspectRatio Image width / height ratio.
39
- * @param cropRect The crop rectangle in normalized coordinates.
40
- * @return The minimum zoom factor needed for coverage.
41
- */
42
- function getMinZoomForCover(rotation, imageAspectRatio, cropRect) {
43
- const aspectRatio = Math.max(imageAspectRatio, Number.EPSILON);
44
- const { visualW: snapVisualW, visualH: snapVisualH } = getVisualDimensions(Math.round(rotation / 90) * 90, aspectRatio);
45
- const { absC, absS } = getVisualDimensions(rotation, aspectRatio);
46
- const cropHalfW = cropRect.width * snapVisualW / 2;
47
- const cropHalfH = cropRect.height * snapVisualH / 2;
48
- const spanAlpha = cropHalfW * absC + cropHalfH * absS;
49
- const spanBeta = cropHalfW * absS + cropHalfH * absC;
50
- const zoomFromAlpha = 2 * spanAlpha / aspectRatio;
51
- const zoomFromBeta = 2 * spanBeta;
52
- return Math.max(zoomFromAlpha, zoomFromBeta);
53
- }
54
- /**
55
- * Resolves the effective minimum zoom for the current state — the coverage-
56
- * aware floor when an image is loaded, falling back to `MIN_ZOOM` otherwise.
57
- * Used by both the cropper's interaction layer and the zoom slider so the
58
- * floor stays consistent across surfaces.
59
- *
60
- * @param state The current cropper state.
61
- * @return The minimum zoom factor.
62
- */
63
- function getMinZoom(state) {
64
- if (!state.image) return MIN_ZOOM;
65
- const imageSize = {
66
- width: state.image.naturalWidth,
67
- height: state.image.naturalHeight
68
- };
69
- if (!isValidSize(imageSize)) return MIN_ZOOM;
70
- const safeState = sanitizeCropperState(state);
71
- const aspectRatio = imageSize.width / imageSize.height;
72
- return Math.max(ABSOLUTE_MIN_ZOOM, getMinZoomForCover(safeState.rotation, aspectRatio, safeState.cropRect));
73
- }
74
- /**
75
- * Compute the crop handle bounds in normalized visual space — the
76
- * axis-aligned bounding box (AABB) of the actual image footprint at the
77
- * current pan/zoom/rotation.
78
- *
79
- * Returns the full image AABB without intersecting with the container
80
- * viewport. The viewport pan mechanism in the Cropper component allows
81
- * the canvas to scroll so handles can reach the image edge even when it
82
- * lies outside the visible canvas area.
83
- *
84
- * Unlike a static centerline-based calculation, this accounts for the
85
- * current pan position — if the user pans right, the left bound tightens
86
- * because the image's left edge has moved right.
87
- *
88
- * @param state The current cropper state (crop, zoom, rotation, flip).
89
- * @param elementSize The fitted (unrotated) image element dimensions in pixels.
90
- * @param visualSize The visual (rotated) image bounding box in pixels.
91
- * @return The min/max x and y that a crop rect edge can reach in normalized space.
92
- */
93
- function getImageCropBounds(state, elementSize, visualSize) {
94
- if (!isValidSize(elementSize) || !isValidSize(visualSize)) return {
95
- minX: 0,
96
- minY: 0,
97
- maxX: 1,
98
- maxY: 1
99
- };
100
- const safeState = sanitizeCropperState(state);
101
- const tx = safeState.pan.x * visualSize.width;
102
- const ty = safeState.pan.y * visualSize.height;
103
- const rad = degreesToRadians(safeState.rotation);
104
- const cos = Math.cos(rad);
105
- const sin = Math.sin(rad);
106
- const sx = safeState.flip.horizontal ? -1 : 1;
107
- const sy = safeState.flip.vertical ? -1 : 1;
108
- const z = safeState.zoom;
109
- const ma = sx * cos * z;
110
- const mb = sy * sin * z;
111
- const mc = -sx * sin * z;
112
- const md = sy * cos * z;
113
- const hw = elementSize.width / 2;
114
- const hh = elementSize.height / 2;
115
- const corners = [
116
- [-hw, -hh],
117
- [hw, -hh],
118
- [hw, hh],
119
- [-hw, hh]
120
- ];
121
- let imgMinX = Infinity;
122
- let imgMaxX = -Infinity;
123
- let imgMinY = Infinity;
124
- let imgMaxY = -Infinity;
125
- for (const [cx, cy] of corners) {
126
- const screenX = ma * cx + mc * cy + tx;
127
- const screenY = mb * cx + md * cy + ty;
128
- const nx = screenX / visualSize.width + .5;
129
- const ny = screenY / visualSize.height + .5;
130
- imgMinX = Math.min(imgMinX, nx);
131
- imgMaxX = Math.max(imgMaxX, nx);
132
- imgMinY = Math.min(imgMinY, ny);
133
- imgMaxY = Math.max(imgMaxY, ny);
134
- }
135
- return {
136
- minX: imgMinX,
137
- minY: imgMinY,
138
- maxX: imgMaxX,
139
- maxY: imgMaxY
140
- };
141
- }
142
- /**
143
- * Restricts a crop rectangle so that the rotated, zoomed image can fully cover it.
144
- * If the crop rect is too large for the current zoom and rotation, it is scaled
145
- * down proportionally and re-centered.
146
- *
147
- * Works in pixel-proportional space where the unrotated image is a×1.
148
- *
149
- * @param cropRect The crop rectangle in normalized coordinates.
150
- * @param zoom The current zoom factor.
151
- * @param rotation The rotation angle in degrees.
152
- * @param imageAspectRatio The image width / height ratio.
153
- * @return The restricted crop rectangle.
154
- */
155
- function restrictCropRect(cropRect, zoom, rotation, imageAspectRatio) {
156
- const safeRect = sanitizeRect(cropRect);
157
- const zoomCandidate = safeBoundedNumber(zoom, 1);
158
- const safeZoom = zoomCandidate >= Number.EPSILON ? zoomCandidate : 1;
159
- const safeRotation = safeBoundedNumber(rotation, 0);
160
- const safeAspect = safeBoundedNumber(imageAspectRatio, 1);
161
- const aspectRatio = Math.max(safeAspect, Number.EPSILON);
162
- const { visualW, visualH } = getVisualDimensions(Math.round(safeRotation / 90) * 90, aspectRatio);
163
- const { absC, absS } = getVisualDimensions(safeRotation, aspectRatio);
164
- const W = safeRect.width;
165
- const H = safeRect.height;
166
- const cropWPx = W * visualW;
167
- const cropHPx = H * visualH;
168
- const spanAlpha = cropWPx * absC + cropHPx * absS;
169
- const spanBeta = cropWPx * absS + cropHPx * absC;
170
- const limitAlpha = aspectRatio * safeZoom;
171
- const limitBeta = safeZoom;
172
- let t = 1;
173
- if (spanAlpha > 0) t = Math.min(t, limitAlpha / spanAlpha);
174
- if (spanBeta > 0) t = Math.min(t, limitBeta / spanBeta);
175
- if (t >= .999999999) return safeRect;
176
- const newW = W * t;
177
- const newH = H * t;
178
- const centerX = safeRect.x + W / 2;
179
- const centerY = safeRect.y + H / 2;
180
- let newX = centerX - newW / 2;
181
- let newY = centerY - newH / 2;
182
- newX = Math.max(0, Math.min(newX, 1 - newW));
183
- newY = Math.max(0, Math.min(newY, 1 - newH));
184
- return {
185
- x: newX,
186
- y: newY,
187
- width: newW,
188
- height: newH
189
- };
190
- }
191
- /**
192
- * Canonical container used internally by restrictPanZoom.
193
- * Containment is scale-invariant, so the actual size doesn't matter —
194
- * only the relative geometry between stencil and image matters.
195
- */
196
- const CANONICAL_CONTAINER = {
197
- width: 1e3,
198
- height: 1e3
199
- };
200
- const _scratchMat = mat2d.create();
201
- const _scratchVec = vec2.create();
202
- /**
203
- * Clamps pan and adjusts zoom so that the zoomed, rotated image fully covers
204
- * the crop rectangle.
205
- *
206
- * Uses the camera matrix to project: builds a camera from the candidate state,
207
- * maps the stencil corners (axis-aligned in the visual bounding box) to world
208
- * space via the inverse camera, and checks that all world points lie within
209
- * [0,1]×[0,1]. If any point is outside, computes the minimal pan correction.
210
- *
211
- * @param state The current cropper state.
212
- * @param imageSize The natural size of the image in pixels.
213
- * @param cropRect The crop rectangle in normalized coordinates.
214
- * @return The restricted crop pan and zoom values.
215
- */
216
- function restrictPanZoom(state, imageSize, cropRect) {
217
- const safeState = sanitizeCropperState(state);
218
- const safeCropRect = sanitizeRect(cropRect);
219
- const aspectRatio = isValidSize(imageSize) ? imageSize.width / imageSize.height : 1;
220
- const minZoom = Math.max(ABSOLUTE_MIN_ZOOM, getMinZoomForCover(safeState.rotation, aspectRatio, safeCropRect));
221
- const zoom = Math.min(MAX_ZOOM, Math.max(safeState.zoom, minZoom));
222
- const candidateState = {
223
- ...safeState,
224
- zoom
225
- };
226
- const camera = createCamera(candidateState, CANONICAL_CONTAINER, imageSize);
227
- const snapRotation = Math.round(safeState.rotation / 90) * 90;
228
- const baseCamera = createCamera({
229
- ...candidateState,
230
- pan: {
231
- x: 0,
232
- y: 0
233
- },
234
- zoom: 1,
235
- rotation: snapRotation
236
- }, CANONICAL_CONTAINER, imageSize);
237
- const visibleBounds = getVisibleBounds(baseCamera);
238
- const stencilCorners = [
239
- [visibleBounds.left + safeCropRect.x * visibleBounds.width, visibleBounds.top + safeCropRect.y * visibleBounds.height],
240
- [visibleBounds.left + (safeCropRect.x + safeCropRect.width) * visibleBounds.width, visibleBounds.top + safeCropRect.y * visibleBounds.height],
241
- [visibleBounds.left + (safeCropRect.x + safeCropRect.width) * visibleBounds.width, visibleBounds.top + (safeCropRect.y + safeCropRect.height) * visibleBounds.height],
242
- [visibleBounds.left + safeCropRect.x * visibleBounds.width, visibleBounds.top + (safeCropRect.y + safeCropRect.height) * visibleBounds.height]
243
- ];
244
- mat2d.invert(_scratchMat, camera);
245
- let minWx = Infinity;
246
- let maxWx = -Infinity;
247
- let minWy = Infinity;
248
- let maxWy = -Infinity;
249
- for (const corner of stencilCorners) {
250
- vec2.transformMat2d(_scratchVec, corner, _scratchMat);
251
- const w = _scratchVec;
252
- if (w[0] < minWx) minWx = w[0];
253
- if (w[0] > maxWx) maxWx = w[0];
254
- if (w[1] < minWy) minWy = w[1];
255
- if (w[1] > maxWy) maxWy = w[1];
256
- }
257
- if (minWx >= -1e-9 && maxWx <= 1.000000001 && minWy >= -1e-9 && maxWy <= 1.000000001) return {
258
- pan: safeState.pan,
259
- zoom
260
- };
261
- let dwx = 0;
262
- let dwy = 0;
263
- if (minWx < 0 && maxWx <= 1.000000001) dwx = -minWx;
264
- else if (maxWx > 1 && minWx >= -1e-9) dwx = 1 - maxWx;
265
- else if (minWx < 0 && maxWx > 1) dwx = (1 - maxWx - minWx) / 2;
266
- if (minWy < 0 && maxWy <= 1.000000001) dwy = -minWy;
267
- else if (maxWy > 1 && minWy >= -1e-9) dwy = 1 - maxWy;
268
- else if (minWy < 0 && maxWy > 1) dwy = (1 - maxWy - minWy) / 2;
269
- const dsx = camera[0] * dwx + camera[2] * dwy;
270
- const dsy = camera[1] * dwx + camera[3] * dwy;
271
- return {
272
- pan: {
273
- x: safeState.pan.x - (visibleBounds.width > 0 ? dsx / visibleBounds.width : 0),
274
- y: safeState.pan.y - (visibleBounds.height > 0 ? dsy / visibleBounds.height : 0)
275
- },
276
- zoom
277
- };
278
- }
279
- export { getImageCropBounds, getMinZoom, restrictCropRect, restrictPanZoom };
280
-
281
- //# sourceMappingURL=containment.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"containment.mjs","names":[],"sources":["../../../src/image-editor/core/containment.ts"],"sourcesContent":["import { mat2d, vec2 } from 'gl-matrix';\nimport type { CropperState, NormalizedRect, Size } from './types';\nimport { ABSOLUTE_MIN_ZOOM, MAX_ZOOM, MIN_ZOOM } from './constants';\nimport { degreesToRadians } from './math/rotation';\nimport {\n\tisValidSize,\n\tsafeBoundedNumber,\n\tsanitizeCropperState,\n\tsanitizeRect,\n} from './math/sanitize';\nimport { createCamera, getRotatedBBox, getVisibleBounds } from './camera';\n\n/** Floating-point epsilon for \"close enough to equal\" comparisons. */\nconst EPSILON = 1e-9;\n\n/**\n * Compute the visual (rotated) bounding-box dimensions in pixel-proportional\n * units where the unrotated image is `a × 1` (renderedW = a, renderedH = 1).\n *\n * @param rotation Rotation angle in degrees.\n * @param imageAspectRatio Image width / height ratio.\n * @return Visual dimensions and trig helpers.\n */\nfunction getVisualDimensions(\n\trotation: number,\n\timageAspectRatio: number\n): { visualW: number; visualH: number; absC: number; absS: number } {\n\tconst rad = degreesToRadians( rotation );\n\tconst absC = Math.abs( Math.cos( rad ) );\n\tconst absS = Math.abs( Math.sin( rad ) );\n\tconst bbox = getRotatedBBox( imageAspectRatio, 1, rotation );\n\treturn {\n\t\tvisualW: bbox.width,\n\t\tvisualH: bbox.height,\n\t\tabsC,\n\t\tabsS,\n\t};\n}\n\n/**\n * The geometric minimum zoom required for the rotated image to fully cover the\n * crop rectangle. Works in pixel-proportional space where the unrotated image\n * is a×1; the crop rect lives in visual-normalized space and is scaled by the\n * rotation-dependent visual dimensions before projecting into the image-local\n * frame.\n *\n * Returns 0 for a degenerate (zero-area) crop — callers compose the result\n * with their own floor (typically the current zoom or `MIN_ZOOM`).\n *\n * @param rotation Rotation angle in degrees.\n * @param imageAspectRatio Image width / height ratio.\n * @param cropRect The crop rectangle in normalized coordinates.\n * @return The minimum zoom factor needed for coverage.\n */\nfunction getMinZoomForCover(\n\trotation: number,\n\timageAspectRatio: number,\n\tcropRect: NormalizedRect\n): number {\n\tconst aspectRatio = Math.max( imageAspectRatio, Number.EPSILON );\n\t// The crop rect lives in the SNAP-rotation visual bbox — that's how the\n\t// stencil and preview position it (see createCamera / getImageFit). Use\n\t// the snap-rotation dimensions to convert crop fractions to pixels.\n\tconst snapRotation = Math.round( rotation / 90 ) * 90;\n\tconst { visualW: snapVisualW, visualH: snapVisualH } = getVisualDimensions(\n\t\tsnapRotation,\n\t\taspectRatio\n\t);\n\t// Projection into the image-local frame uses the TRUE rotation angle —\n\t// that's the actual orientation of the image under the stencil.\n\tconst { absC, absS } = getVisualDimensions( rotation, aspectRatio );\n\n\t// Crop half-extents in pixel-proportional space.\n\tconst cropHalfW = ( cropRect.width * snapVisualW ) / 2;\n\tconst cropHalfH = ( cropRect.height * snapVisualH ) / 2;\n\n\t// AABB of the crop rect projected into the image-local (unrotated) frame.\n\tconst spanAlpha = cropHalfW * absC + cropHalfH * absS;\n\tconst spanBeta = cropHalfW * absS + cropHalfH * absC;\n\n\t// Image half-extents at zoom z: (aspectRatio*z/2, z/2).\n\t// Coverage requires: aspectRatio*z/2 >= spanAlpha AND z/2 >= spanBeta.\n\tconst zoomFromAlpha = ( 2 * spanAlpha ) / aspectRatio;\n\tconst zoomFromBeta = 2 * spanBeta;\n\n\treturn Math.max( zoomFromAlpha, zoomFromBeta );\n}\n\n/**\n * Resolves the effective minimum zoom for the current state — the coverage-\n * aware floor when an image is loaded, falling back to `MIN_ZOOM` otherwise.\n * Used by both the cropper's interaction layer and the zoom slider so the\n * floor stays consistent across surfaces.\n *\n * @param state The current cropper state.\n * @return The minimum zoom factor.\n */\nexport function getMinZoom( state: CropperState ): number {\n\tif ( ! state.image ) {\n\t\treturn MIN_ZOOM;\n\t}\n\tconst imageSize = {\n\t\twidth: state.image.naturalWidth,\n\t\theight: state.image.naturalHeight,\n\t};\n\tif ( ! isValidSize( imageSize ) ) {\n\t\treturn MIN_ZOOM;\n\t}\n\tconst safeState = sanitizeCropperState( state );\n\tconst aspectRatio = imageSize.width / imageSize.height;\n\treturn Math.max(\n\t\tABSOLUTE_MIN_ZOOM,\n\t\tgetMinZoomForCover(\n\t\t\tsafeState.rotation,\n\t\t\taspectRatio,\n\t\t\tsafeState.cropRect\n\t\t)\n\t);\n}\n\n/**\n * Compute the crop handle bounds in normalized visual space — the\n * axis-aligned bounding box (AABB) of the actual image footprint at the\n * current pan/zoom/rotation.\n *\n * Returns the full image AABB without intersecting with the container\n * viewport. The viewport pan mechanism in the Cropper component allows\n * the canvas to scroll so handles can reach the image edge even when it\n * lies outside the visible canvas area.\n *\n * Unlike a static centerline-based calculation, this accounts for the\n * current pan position — if the user pans right, the left bound tightens\n * because the image's left edge has moved right.\n *\n * @param state The current cropper state (crop, zoom, rotation, flip).\n * @param elementSize The fitted (unrotated) image element dimensions in pixels.\n * @param visualSize The visual (rotated) image bounding box in pixels.\n * @return The min/max x and y that a crop rect edge can reach in normalized space.\n */\nexport function getImageCropBounds(\n\tstate: CropperState,\n\telementSize: Size,\n\tvisualSize: Size\n): { minX: number; minY: number; maxX: number; maxY: number } {\n\tif ( ! isValidSize( elementSize ) || ! isValidSize( visualSize ) ) {\n\t\treturn { minX: 0, minY: 0, maxX: 1, maxY: 1 };\n\t}\n\n\tconst safeState = sanitizeCropperState( state );\n\n\t// Build the same CSS matrix as use-transform-style: flip * rotate * zoom.\n\t// Flip is outside rotation so it acts in viewport axes (see createCamera).\n\tconst tx = safeState.pan.x * visualSize.width;\n\tconst ty = safeState.pan.y * visualSize.height;\n\tconst rad = degreesToRadians( safeState.rotation );\n\tconst cos = Math.cos( rad );\n\tconst sin = Math.sin( rad );\n\tconst sx = safeState.flip.horizontal ? -1 : 1;\n\tconst sy = safeState.flip.vertical ? -1 : 1;\n\tconst z = safeState.zoom;\n\tconst ma = sx * cos * z;\n\tconst mb = sy * sin * z;\n\tconst mc = -sx * sin * z;\n\tconst md = sy * cos * z;\n\n\t// Image element corners relative to element center.\n\tconst hw = elementSize.width / 2;\n\tconst hh = elementSize.height / 2;\n\tconst corners = [\n\t\t[ -hw, -hh ],\n\t\t[ hw, -hh ],\n\t\t[ hw, hh ],\n\t\t[ -hw, hh ],\n\t];\n\n\tlet imgMinX = Infinity;\n\tlet imgMaxX = -Infinity;\n\tlet imgMinY = Infinity;\n\tlet imgMaxY = -Infinity;\n\n\tfor ( const [ cx, cy ] of corners ) {\n\t\t// Screen offset from element center after CSS matrix.\n\t\tconst screenX = ma * cx + mc * cy + tx;\n\t\tconst screenY = mb * cx + md * cy + ty;\n\t\t// Convert to normalized visual space.\n\t\t// The element center is at the visual image center, which is at\n\t\t// normalized (0.5, 0.5). So screen offset / visualSize + 0.5.\n\t\tconst nx = screenX / visualSize.width + 0.5;\n\t\tconst ny = screenY / visualSize.height + 0.5;\n\t\timgMinX = Math.min( imgMinX, nx );\n\t\timgMaxX = Math.max( imgMaxX, nx );\n\t\timgMinY = Math.min( imgMinY, ny );\n\t\timgMaxY = Math.max( imgMaxY, ny );\n\t}\n\n\treturn {\n\t\tminX: imgMinX,\n\t\tminY: imgMinY,\n\t\tmaxX: imgMaxX,\n\t\tmaxY: imgMaxY,\n\t};\n}\n\n/**\n * Restricts a crop rectangle so that the rotated, zoomed image can fully cover it.\n * If the crop rect is too large for the current zoom and rotation, it is scaled\n * down proportionally and re-centered.\n *\n * Works in pixel-proportional space where the unrotated image is a×1.\n *\n * @param cropRect The crop rectangle in normalized coordinates.\n * @param zoom The current zoom factor.\n * @param rotation The rotation angle in degrees.\n * @param imageAspectRatio The image width / height ratio.\n * @return The restricted crop rectangle.\n */\nexport function restrictCropRect(\n\tcropRect: NormalizedRect,\n\tzoom: number,\n\trotation: number,\n\timageAspectRatio: number\n): NormalizedRect {\n\t// Guard against non-finite inputs. The reducer normalizes these, but\n\t// programmatic callers or deserialized state could still send NaN/±Infinity\n\t// through here, where it would silently propagate into the crop rect.\n\tconst safeRect = sanitizeRect( cropRect );\n\tconst zoomCandidate = safeBoundedNumber( zoom, 1 );\n\tconst safeZoom = zoomCandidate >= Number.EPSILON ? zoomCandidate : 1;\n\tconst safeRotation = safeBoundedNumber( rotation, 0 );\n\tconst safeAspect = safeBoundedNumber( imageAspectRatio, 1 );\n\tconst aspectRatio = Math.max( safeAspect, Number.EPSILON );\n\t// Crop rect lives in the SNAP-rotation visual bbox (matching the stencil\n\t// layout); projection into the image-local frame uses the TRUE rotation.\n\tconst snapRotation = Math.round( safeRotation / 90 ) * 90;\n\tconst { visualW, visualH } = getVisualDimensions(\n\t\tsnapRotation,\n\t\taspectRatio\n\t);\n\tconst { absC, absS } = getVisualDimensions( safeRotation, aspectRatio );\n\tconst W = safeRect.width;\n\tconst H = safeRect.height;\n\n\t// Crop full-extents in pixel-proportional space, projected to image-local frame.\n\tconst cropWPx = W * visualW;\n\tconst cropHPx = H * visualH;\n\tconst spanAlpha = cropWPx * absC + cropHPx * absS;\n\tconst spanBeta = cropWPx * absS + cropHPx * absC;\n\n\t// Image full-extents at zoom z: (aspectRatio*z, z).\n\tconst limitAlpha = aspectRatio * safeZoom;\n\tconst limitBeta = safeZoom;\n\n\tlet t = 1;\n\tif ( spanAlpha > 0 ) {\n\t\tt = Math.min( t, limitAlpha / spanAlpha );\n\t}\n\tif ( spanBeta > 0 ) {\n\t\tt = Math.min( t, limitBeta / spanBeta );\n\t}\n\tif ( t >= 1 - EPSILON ) {\n\t\t// Crop fits at the current zoom — no size change needed.\n\t\t// Return the sanitized rect (not the raw arg) so non-finite fields\n\t\t// don't slip through this path. Position is handled by restrictPanZoom.\n\t\treturn safeRect;\n\t}\n\tconst newW = W * t;\n\tconst newH = H * t;\n\tconst centerX = safeRect.x + W / 2;\n\tconst centerY = safeRect.y + H / 2;\n\tlet newX = centerX - newW / 2;\n\tlet newY = centerY - newH / 2;\n\tnewX = Math.max( 0, Math.min( newX, 1 - newW ) );\n\tnewY = Math.max( 0, Math.min( newY, 1 - newH ) );\n\treturn { x: newX, y: newY, width: newW, height: newH };\n}\n\n/**\n * Canonical container used internally by restrictPanZoom.\n * Containment is scale-invariant, so the actual size doesn't matter —\n * only the relative geometry between stencil and image matters.\n */\nconst CANONICAL_CONTAINER: Size = { width: 1000, height: 1000 };\n\n// Pre-allocated scratch buffers for restrictPanZoom's hot path (runs on\n// every pointermove) to avoid Float32Array allocation per call.\nconst _scratchMat = mat2d.create();\nconst _scratchVec = vec2.create();\n\n/**\n * Clamps pan and adjusts zoom so that the zoomed, rotated image fully covers\n * the crop rectangle.\n *\n * Uses the camera matrix to project: builds a camera from the candidate state,\n * maps the stencil corners (axis-aligned in the visual bounding box) to world\n * space via the inverse camera, and checks that all world points lie within\n * [0,1]×[0,1]. If any point is outside, computes the minimal pan correction.\n *\n * @param state The current cropper state.\n * @param imageSize The natural size of the image in pixels.\n * @param cropRect The crop rectangle in normalized coordinates.\n * @return The restricted crop pan and zoom values.\n */\nexport function restrictPanZoom(\n\tstate: CropperState,\n\timageSize: Size,\n\tcropRect: NormalizedRect\n): { pan: { x: number; y: number }; zoom: number } {\n\t// Algorithm overview:\n\t// 1. Ensure zoom is high enough for the rotated image to cover the crop.\n\t// 2. Build a camera (world→screen matrix) with the candidate state.\n\t// 3. Build a base camera (no pan, zoom=1) to find where the stencil\n\t// sits in screen space — the stencil is anchored to the container,\n\t// not the image, so it doesn't move with pan or scale with zoom.\n\t// 4. Project the 4 stencil corners through the INVERSE of the main\n\t// camera to get world-space positions. A world point outside [0,1]\n\t// means that corner of the stencil isn't covered by the image.\n\t// 5. Compute the minimal translation in world space to push all corners\n\t// back inside [0,1].\n\t// 6. Convert the world-space correction to a pan-field correction by\n\t// mapping it through the camera's linear part back to screen space,\n\t// then dividing by the visual bounds.\n\tconst safeState = sanitizeCropperState( state );\n\tconst safeCropRect = sanitizeRect( cropRect );\n\t// Use `isValidSize` rather than a bare `> 0` check so Infinity dims\n\t// don't drive `Infinity / Infinity = NaN` into `getMinZoomForCover`\n\t// and leak as `zoom: NaN` through the no-correction early return.\n\tconst aspectRatio = isValidSize( imageSize )\n\t\t? imageSize.width / imageSize.height\n\t\t: 1;\n\tconst minZoom = Math.max(\n\t\tABSOLUTE_MIN_ZOOM,\n\t\tgetMinZoomForCover( safeState.rotation, aspectRatio, safeCropRect )\n\t);\n\tconst zoom = Math.min( MAX_ZOOM, Math.max( safeState.zoom, minZoom ) );\n\n\t// Step 2: build camera with candidate pan and corrected zoom.\n\tconst candidateState = { ...safeState, zoom };\n\tconst camera = createCamera(\n\t\tcandidateState,\n\t\tCANONICAL_CONTAINER,\n\t\timageSize\n\t);\n\n\t// Build a base camera (zero pan, zoom=1) to get stencil positions.\n\t// The stencil is anchored to the container and laid out using the\n\t// nearest 90° rotation (matching `getImageFit`), so it's stable\n\t// through fine rotation. CSS zoom only affects the <img> element,\n\t// not the stencil.\n\tconst snapRotation = Math.round( safeState.rotation / 90 ) * 90;\n\tconst baseCamera = createCamera(\n\t\t{\n\t\t\t...candidateState,\n\t\t\tpan: { x: 0, y: 0 },\n\t\t\tzoom: 1,\n\t\t\trotation: snapRotation,\n\t\t},\n\t\tCANONICAL_CONTAINER,\n\t\timageSize\n\t);\n\tconst visibleBounds = getVisibleBounds( baseCamera );\n\n\t// Stencil corners in screen space (axis-aligned rect within visual bounds).\n\tconst stencilCorners: [ number, number ][] = [\n\t\t[\n\t\t\tvisibleBounds.left + safeCropRect.x * visibleBounds.width,\n\t\t\tvisibleBounds.top + safeCropRect.y * visibleBounds.height,\n\t\t],\n\t\t[\n\t\t\tvisibleBounds.left +\n\t\t\t\t( safeCropRect.x + safeCropRect.width ) * visibleBounds.width,\n\t\t\tvisibleBounds.top + safeCropRect.y * visibleBounds.height,\n\t\t],\n\t\t[\n\t\t\tvisibleBounds.left +\n\t\t\t\t( safeCropRect.x + safeCropRect.width ) * visibleBounds.width,\n\t\t\tvisibleBounds.top +\n\t\t\t\t( safeCropRect.y + safeCropRect.height ) * visibleBounds.height,\n\t\t],\n\t\t[\n\t\t\tvisibleBounds.left + safeCropRect.x * visibleBounds.width,\n\t\t\tvisibleBounds.top +\n\t\t\t\t( safeCropRect.y + safeCropRect.height ) * visibleBounds.height,\n\t\t],\n\t];\n\n\t// Map stencil corners to world space via inverse camera.\n\t// If a world point is outside [0,1], the image doesn't cover that spot.\n\t// Reuse module-level scratch buffers to avoid allocation per frame.\n\tmat2d.invert( _scratchMat, camera );\n\n\tlet minWx = Infinity;\n\tlet maxWx = -Infinity;\n\tlet minWy = Infinity;\n\tlet maxWy = -Infinity;\n\n\tfor ( const corner of stencilCorners ) {\n\t\tvec2.transformMat2d( _scratchVec, corner, _scratchMat );\n\t\tconst w = _scratchVec;\n\t\tif ( w[ 0 ] < minWx ) {\n\t\t\tminWx = w[ 0 ];\n\t\t}\n\t\tif ( w[ 0 ] > maxWx ) {\n\t\t\tmaxWx = w[ 0 ];\n\t\t}\n\t\tif ( w[ 1 ] < minWy ) {\n\t\t\tminWy = w[ 1 ];\n\t\t}\n\t\tif ( w[ 1 ] > maxWy ) {\n\t\t\tmaxWy = w[ 1 ];\n\t\t}\n\t}\n\n\t// If all world points are in [0,1], no correction needed.\n\tif (\n\t\tminWx >= -EPSILON &&\n\t\tmaxWx <= 1 + EPSILON &&\n\t\tminWy >= -EPSILON &&\n\t\tmaxWy <= 1 + EPSILON\n\t) {\n\t\treturn { pan: safeState.pan, zoom };\n\t}\n\n\t// Compute world-space correction needed.\n\t// If minWx < 0, we need to shift world points right by |minWx|.\n\t// If maxWx > 1, we need to shift world points left by (maxWx - 1).\n\t// If both, we're over-constrained (crop too big) — getMinZoomForCover\n\t// should have prevented this.\n\tlet dwx = 0;\n\tlet dwy = 0;\n\n\tif ( minWx < 0 && maxWx <= 1 + EPSILON ) {\n\t\tdwx = -minWx;\n\t} else if ( maxWx > 1 && minWx >= -EPSILON ) {\n\t\tdwx = 1 - maxWx;\n\t} else if ( minWx < 0 && maxWx > 1 ) {\n\t\t// Over-constrained: center it.\n\t\tdwx = ( 1 - maxWx - minWx ) / 2;\n\t}\n\n\tif ( minWy < 0 && maxWy <= 1 + EPSILON ) {\n\t\tdwy = -minWy;\n\t} else if ( maxWy > 1 && minWy >= -EPSILON ) {\n\t\tdwy = 1 - maxWy;\n\t} else if ( minWy < 0 && maxWy > 1 ) {\n\t\tdwy = ( 1 - maxWy - minWy ) / 2;\n\t}\n\n\t// Convert world-space correction to screen-space correction.\n\t// The camera's 2×2 linear part (indices [0,1,2,3]) maps world deltas\n\t// to screen deltas: screenDelta = linear * worldDelta.\n\tconst dsx = camera[ 0 ] * dwx + camera[ 2 ] * dwy;\n\tconst dsy = camera[ 1 ] * dwx + camera[ 3 ] * dwy;\n\n\t// Convert screen-space correction to pan-field correction.\n\t// Pan in screen pixels = pan.x * visualW, pan.y * visualH.\n\t// The correction is subtractive: a positive world shift (dw > 0) means\n\t// the image needs to move opposite to pan direction, so pan decreases.\n\tconst newPanX =\n\t\tsafeState.pan.x -\n\t\t( visibleBounds.width > 0 ? dsx / visibleBounds.width : 0 );\n\tconst newPanY =\n\t\tsafeState.pan.y -\n\t\t( visibleBounds.height > 0 ? dsy / visibleBounds.height : 0 );\n\n\treturn {\n\t\tpan: { x: newPanX, y: newPanY },\n\t\tzoom,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;AAuBA,SAAS,oBACR,UACA,kBACmE;CACnE,MAAM,MAAM,iBAAkB,QAAS;CACvC,MAAM,OAAO,KAAK,IAAK,KAAK,IAAK,GAAI,CAAE;CACvC,MAAM,OAAO,KAAK,IAAK,KAAK,IAAK,GAAI,CAAE;CACvC,MAAM,OAAO,eAAgB,kBAAkB,GAAG,QAAS;CAC3D,OAAO;EACN,SAAS,KAAK;EACd,SAAS,KAAK;EACd;EACA;CACD;AACD;;;;;;;;;;;;;;;;AAiBA,SAAS,mBACR,UACA,kBACA,UACS;CACT,MAAM,cAAc,KAAK,IAAK,kBAAkB,OAAO,OAAQ;CAK/D,MAAM,EAAE,SAAS,aAAa,SAAS,gBAAgB,oBADlC,KAAK,MAAO,WAAW,EAAG,IAAI,IAGlD,WACD;CAGA,MAAM,EAAE,MAAM,SAAS,oBAAqB,UAAU,WAAY;CAGlE,MAAM,YAAc,SAAS,QAAQ,cAAgB;CACrD,MAAM,YAAc,SAAS,SAAS,cAAgB;CAGtD,MAAM,YAAY,YAAY,OAAO,YAAY;CACjD,MAAM,WAAW,YAAY,OAAO,YAAY;CAIhD,MAAM,gBAAkB,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AAU;CAM/B,MAAM,MAAM,OAAQ,KAAM,MAAM,OAAQ,KAAM;CAC9C,MAAM,MAAM,OAAQ,KAAM,MAAM,OAAQ,KAAM;CAa9C,OAAO;EACN,KAAK;GAAE,GAPP,UAAU,IAAI,KACZ,cAAc,QAAQ,IAAI,MAAM,cAAc,QAAQ;GAMrC,GAJnB,UAAU,IAAI,KACZ,cAAc,SAAS,IAAI,MAAM,cAAc,SAAS;EAG5B;EAC9B;CACD;AACD"}
@@ -1,32 +0,0 @@
1
- // packages/media-editor/src/image-editor/core/crop-rect.ts
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
- function computeInscribedRect(aspectRatio, visualSize) {
16
- let w = 1;
17
- let h = 1;
18
- if (aspectRatio && aspectRatio > 0 && visualSize.width > 0) {
19
- const normalizedRatio = aspectRatio * visualSize.height / visualSize.width;
20
- if (normalizedRatio <= 1) w = normalizedRatio;
21
- else h = 1 / normalizedRatio;
22
- }
23
- return {
24
- x: (1 - w) / 2,
25
- y: (1 - h) / 2,
26
- width: w,
27
- height: h
28
- };
29
- }
30
- export { computeInscribedRect };
31
-
32
- //# sourceMappingURL=crop-rect.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"crop-rect.mjs","names":[],"sources":["../../../src/image-editor/core/crop-rect.ts"],"sourcesContent":["import type { NormalizedRect, Size } from './types';\n\n/**\n * Largest rect of the given pixel aspect ratio that fits inside the\n * visual bounds, centered in [0,1] × [0,1] normalized space. Returns\n * a full-frame rect (1×1) if `aspectRatio` is unset or non-positive.\n *\n * The returned rect is the same in either freeform or fixed-crop\n * mode — it's the canonical \"centered crop for this ratio at this\n * canvas size\".\n *\n * @param aspectRatio Desired pixel width/height ratio. `undefined`\n * (or 0/negative) means no lock — returns full frame.\n * @param visualSize Rendered image dimensions in pixels.\n */\nexport function computeInscribedRect(\n\taspectRatio: number | undefined,\n\tvisualSize: Size\n): NormalizedRect {\n\tlet w = 1;\n\tlet h = 1;\n\tif ( aspectRatio && aspectRatio > 0 && visualSize.width > 0 ) {\n\t\t// normalizedRatio = w/h in normalized space that produces the\n\t\t// desired pixel aspect ratio.\n\t\t// pixelW = w * visualW, pixelH = h * visualH\n\t\t// pixelW / pixelH = aspectRatio\n\t\t// => w / h = aspectRatio * visualH / visualW\n\t\tconst normalizedRatio =\n\t\t\t( aspectRatio * visualSize.height ) / visualSize.width;\n\t\tif ( normalizedRatio <= 1 ) {\n\t\t\tw = normalizedRatio;\n\t\t} else {\n\t\t\th = 1 / normalizedRatio;\n\t\t}\n\t}\n\treturn {\n\t\tx: ( 1 - w ) / 2,\n\t\ty: ( 1 - h ) / 2,\n\t\twidth: w,\n\t\theight: h,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;AAeA,SAAgB,qBACf,aACA,YACiB;CACjB,IAAI,IAAI;CACR,IAAI,IAAI;CACR,IAAK,eAAe,cAAc,KAAK,WAAW,QAAQ,GAAI;EAM7D,MAAM,kBACH,cAAc,WAAW,SAAW,WAAW;EAClD,IAAK,mBAAmB,GACvB,IAAI;OAEJ,IAAI,IAAI;CAEV;CACA,OAAO;EACN,IAAK,IAAI,KAAM;EACf,IAAK,IAAI,KAAM;EACf,OAAO;EACP,QAAQ;CACT;AACD"}
@@ -1,170 +0,0 @@
1
- import { createExportCamera, getRotatedBBox } from "../camera.mjs";
2
- // packages/media-editor/src/image-editor/core/export/canvas-renderer.ts
3
- /** Default export quality for lossy formats (JPEG, WebP). */
4
- const DEFAULT_QUALITY = .92;
5
- /**
6
- * Load an image from a URL with CORS support.
7
- *
8
- * @param src - The image URL to load.
9
- * @return A promise that resolves to the loaded HTMLImageElement.
10
- */
11
- function loadImage(src) {
12
- return new Promise((resolve, reject) => {
13
- const image = new Image();
14
- image.addEventListener("load", () => resolve(image));
15
- image.addEventListener("error", (error) => reject(error));
16
- image.crossOrigin = "anonymous";
17
- image.src = src;
18
- });
19
- }
20
- /**
21
- * Apply rectangular crop, rotation, and flip transforms to produce a canvas.
22
- *
23
- * Uses createExportCamera to compose the full transform matrix, then applies
24
- * it in a single ctx.setTransform call before drawing the image.
25
- *
26
- * @param image - The source image element.
27
- * @param state - The full cropper state containing crop, rotation, and flip settings.
28
- * @return A canvas element containing the transformed and cropped image.
29
- */
30
- function renderToCanvas(image, state) {
31
- const { naturalWidth, naturalHeight } = image;
32
- const { rotation, cropRect } = state;
33
- const imageSize = {
34
- width: naturalWidth,
35
- height: naturalHeight
36
- };
37
- const snapRotation = Math.round(rotation / 90) * 90;
38
- const rotBBox = getRotatedBBox(naturalWidth, naturalHeight, snapRotation);
39
- const outW = Math.round(cropRect.width * rotBBox.width);
40
- const outH = Math.round(cropRect.height * rotBBox.height);
41
- const canvas = document.createElement("canvas");
42
- canvas.width = outW;
43
- canvas.height = outH;
44
- const ctx = canvas.getContext("2d");
45
- if (!ctx) throw new Error("Could not obtain a 2D context for the export canvas.");
46
- const camera = createExportCamera(state, imageSize, {
47
- width: outW,
48
- height: outH
49
- });
50
- ctx.setTransform(camera[0], camera[1], camera[2], camera[3], camera[4], camera[5]);
51
- ctx.drawImage(image, 0, 0);
52
- return canvas;
53
- }
54
- /**
55
- * Convert a canvas to a Blob with configurable MIME type and quality.
56
- *
57
- * @param canvas - The canvas to export.
58
- * @param mimeType - The output MIME type. Defaults to 'image/png'.
59
- * @param quality - The quality parameter for lossy formats (0-1). Defaults to DEFAULT_QUALITY.
60
- * @return A promise that resolves to the canvas content as a Blob.
61
- */
62
- function canvasToBlob(canvas, mimeType = "image/png", quality = DEFAULT_QUALITY) {
63
- return new Promise((resolve, reject) => {
64
- canvas.toBlob((blob) => {
65
- if (blob) resolve(blob);
66
- else reject(/* @__PURE__ */ new Error("Canvas toBlob returned null."));
67
- }, mimeType, quality);
68
- });
69
- }
70
- /**
71
- * Convert a canvas to a data URL string.
72
- *
73
- * @param canvas - The canvas to export.
74
- * @param mimeType - The output MIME type. Defaults to 'image/png'.
75
- * @param quality - The quality parameter for lossy formats (0-1). Defaults to DEFAULT_QUALITY.
76
- * @return The canvas content as a data URL string.
77
- */
78
- function canvasToDataURL(canvas, mimeType = "image/png", quality = DEFAULT_QUALITY) {
79
- return canvas.toDataURL(mimeType, quality);
80
- }
81
- /**
82
- * Load an image, render with transforms, and export as a Blob.
83
- *
84
- * Throws on failure so callers can distinguish error cases:
85
- * - Image load failures (network errors, 404s) throw the native
86
- * load error from the Image element.
87
- * - Cross-origin failures manifest as tainted-canvas errors from
88
- * `canvas.toBlob()` — the browser rejects reading pixel data
89
- * from a canvas that drew an image without valid CORS headers.
90
- * Ensure the source server sets `Access-Control-Allow-Origin`.
91
- * - Canvas context creation failures throw a descriptive Error.
92
- *
93
- * Only works in browser environments (needs DOM / HTMLCanvasElement).
94
- *
95
- * @param src - The image URL to load.
96
- * @param state - The cropper state with all transform settings.
97
- * @param mimeType - The output MIME type. Defaults to 'image/png'.
98
- * @param quality - The quality parameter for lossy formats (0-1). Defaults to DEFAULT_QUALITY.
99
- * @return A promise that resolves to the exported Blob.
100
- * @throws If the image fails to load, canvas creation fails, or
101
- * the resulting canvas is tainted by CORS restrictions.
102
- */
103
- async function exportCroppedImage(src, state, mimeType = "image/png", quality = DEFAULT_QUALITY) {
104
- return canvasToBlob(renderToCanvas(await loadImage(src), state), mimeType, quality);
105
- }
106
- /**
107
- * Apply the cropper's transform (crop, rotation, flip, zoom) to an existing
108
- * canvas or image source. This is the bridge for multi-step editing pipelines
109
- * where an upstream tool (e.g., brightness/color adjustment) has already
110
- * processed the image and you want to apply the crop on top.
111
- *
112
- * Accepts any CanvasImageSource: HTMLImageElement, HTMLCanvasElement,
113
- * OffscreenCanvas, ImageBitmap, HTMLVideoElement, etc.
114
- *
115
- * @param source - The image source to crop/transform.
116
- * @param sourceSize - The dimensions of the source (natural width/height).
117
- * @param sourceSize.width - The width of the source in pixels.
118
- * @param sourceSize.height - The height of the source in pixels.
119
- * @param state - The cropper state with all transform settings.
120
- * @param outputSize - Optional output size. Defaults to the crop region's natural pixel size.
121
- * @param outputSize.width - The width of the output in pixels.
122
- * @param outputSize.height - The height of the output in pixels.
123
- * @return A canvas with the transforms applied.
124
- */
125
- function applyToCanvas(source, sourceSize, state, outputSize) {
126
- const snapRotation = Math.round(state.rotation / 90) * 90;
127
- const rotBBox = getRotatedBBox(sourceSize.width, sourceSize.height, snapRotation);
128
- const outW = outputSize?.width ?? Math.round(state.cropRect.width * rotBBox.width);
129
- const outH = outputSize?.height ?? Math.round(state.cropRect.height * rotBBox.height);
130
- const canvas = document.createElement("canvas");
131
- canvas.width = outW;
132
- canvas.height = outH;
133
- const ctx = canvas.getContext("2d");
134
- if (!ctx) throw new Error("Could not obtain a 2D context for the export canvas.");
135
- const camera = createExportCamera(state, sourceSize, {
136
- width: outW,
137
- height: outH
138
- });
139
- ctx.setTransform(camera[0], camera[1], camera[2], camera[3], camera[4], camera[5]);
140
- ctx.drawImage(source, 0, 0);
141
- return canvas;
142
- }
143
- /**
144
- * Download the cropped image as a file.
145
- *
146
- * Loads the source image, applies all transforms, and triggers a
147
- * browser download via exportCroppedImage() + object URL + anchor click.
148
- *
149
- * Throws on export failure (see `exportCroppedImage`).
150
- *
151
- * @param src - The image URL to load.
152
- * @param state - The cropper state with all transform settings.
153
- * @param filename - The download filename. Defaults to 'cropped-image'.
154
- * @param mimeType - The output MIME type. Defaults to 'image/png'.
155
- * @param quality - The quality parameter for lossy formats (0-1). Defaults to DEFAULT_QUALITY.
156
- * @return A promise that resolves when the download is triggered.
157
- */
158
- async function downloadCroppedImage(src, state, filename = "cropped-image", mimeType = "image/png", quality = DEFAULT_QUALITY) {
159
- const blob = await exportCroppedImage(src, state, mimeType, quality);
160
- const ext = mimeType.split("/")[1] ?? "png";
161
- const url = URL.createObjectURL(blob);
162
- const a = document.createElement("a");
163
- a.href = url;
164
- a.download = `${filename}.${ext}`;
165
- a.click();
166
- URL.revokeObjectURL(url);
167
- }
168
- export { applyToCanvas, canvasToBlob, canvasToDataURL, downloadCroppedImage, exportCroppedImage, loadImage, renderToCanvas };
169
-
170
- //# sourceMappingURL=canvas-renderer.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"canvas-renderer.mjs","names":[],"sources":["../../../../src/image-editor/core/export/canvas-renderer.ts"],"sourcesContent":["import type { CropperState } from '../types';\nimport { createExportCamera, getRotatedBBox } from '../camera';\n\n/** Default export quality for lossy formats (JPEG, WebP). */\nconst DEFAULT_QUALITY = 0.92;\n\n/**\n * Load an image from a URL with CORS support.\n *\n * @param src - The image URL to load.\n * @return A promise that resolves to the loaded HTMLImageElement.\n */\nexport function loadImage( src: string ): Promise< HTMLImageElement > {\n\treturn new Promise( ( resolve, reject ) => {\n\t\tconst image = new Image();\n\t\timage.addEventListener( 'load', () => resolve( image ) );\n\t\timage.addEventListener( 'error', ( error ) => reject( error ) );\n\t\timage.crossOrigin = 'anonymous';\n\t\timage.src = src;\n\t} );\n}\n\n/**\n * Apply rectangular crop, rotation, and flip transforms to produce a canvas.\n *\n * Uses createExportCamera to compose the full transform matrix, then applies\n * it in a single ctx.setTransform call before drawing the image.\n *\n * @param image - The source image element.\n * @param state - The full cropper state containing crop, rotation, and flip settings.\n * @return A canvas element containing the transformed and cropped image.\n */\nexport function renderToCanvas(\n\timage: HTMLImageElement,\n\tstate: CropperState\n): HTMLCanvasElement {\n\tconst { naturalWidth, naturalHeight } = image;\n\tconst { rotation, cropRect } = state;\n\tconst imageSize = { width: naturalWidth, height: naturalHeight };\n\n\t// Output size is the crop region in the snap-rotation bbox — matches\n\t// the preview's reference frame so the exported pixels track exactly\n\t// what the stencil framed, even at fine rotation angles.\n\tconst snapRotation = Math.round( rotation / 90 ) * 90;\n\tconst rotBBox = getRotatedBBox( naturalWidth, naturalHeight, snapRotation );\n\tconst outW = Math.round( cropRect.width * rotBBox.width );\n\tconst outH = Math.round( cropRect.height * rotBBox.height );\n\n\tconst canvas = document.createElement( 'canvas' );\n\tcanvas.width = outW;\n\tcanvas.height = outH;\n\tconst ctx = canvas.getContext( '2d' );\n\tif ( ! ctx ) {\n\t\tthrow new Error(\n\t\t\t'Could not obtain a 2D context for the export canvas.'\n\t\t);\n\t}\n\n\tconst camera = createExportCamera( state, imageSize, {\n\t\twidth: outW,\n\t\theight: outH,\n\t} );\n\tctx.setTransform(\n\t\tcamera[ 0 ],\n\t\tcamera[ 1 ],\n\t\tcamera[ 2 ],\n\t\tcamera[ 3 ],\n\t\tcamera[ 4 ],\n\t\tcamera[ 5 ]\n\t);\n\tctx.drawImage( image, 0, 0 );\n\treturn canvas;\n}\n\n/**\n * Convert a canvas to a Blob with configurable MIME type and quality.\n *\n * @param canvas - The canvas to export.\n * @param mimeType - The output MIME type. Defaults to 'image/png'.\n * @param quality - The quality parameter for lossy formats (0-1). Defaults to DEFAULT_QUALITY.\n * @return A promise that resolves to the canvas content as a Blob.\n */\nexport function canvasToBlob(\n\tcanvas: HTMLCanvasElement,\n\tmimeType: string = 'image/png',\n\tquality: number = DEFAULT_QUALITY\n): Promise< Blob > {\n\treturn new Promise( ( resolve, reject ) => {\n\t\tcanvas.toBlob(\n\t\t\t( blob ) => {\n\t\t\t\tif ( blob ) {\n\t\t\t\t\tresolve( blob );\n\t\t\t\t} else {\n\t\t\t\t\treject( new Error( 'Canvas toBlob returned null.' ) );\n\t\t\t\t}\n\t\t\t},\n\t\t\tmimeType,\n\t\t\tquality\n\t\t);\n\t} );\n}\n\n/**\n * Convert a canvas to a data URL string.\n *\n * @param canvas - The canvas to export.\n * @param mimeType - The output MIME type. Defaults to 'image/png'.\n * @param quality - The quality parameter for lossy formats (0-1). Defaults to DEFAULT_QUALITY.\n * @return The canvas content as a data URL string.\n */\nexport function canvasToDataURL(\n\tcanvas: HTMLCanvasElement,\n\tmimeType: string = 'image/png',\n\tquality: number = DEFAULT_QUALITY\n): string {\n\treturn canvas.toDataURL( mimeType, quality );\n}\n\n/**\n * Load an image, render with transforms, and export as a Blob.\n *\n * Throws on failure so callers can distinguish error cases:\n * - Image load failures (network errors, 404s) throw the native\n * load error from the Image element.\n * - Cross-origin failures manifest as tainted-canvas errors from\n * `canvas.toBlob()` — the browser rejects reading pixel data\n * from a canvas that drew an image without valid CORS headers.\n * Ensure the source server sets `Access-Control-Allow-Origin`.\n * - Canvas context creation failures throw a descriptive Error.\n *\n * Only works in browser environments (needs DOM / HTMLCanvasElement).\n *\n * @param src - The image URL to load.\n * @param state - The cropper state with all transform settings.\n * @param mimeType - The output MIME type. Defaults to 'image/png'.\n * @param quality - The quality parameter for lossy formats (0-1). Defaults to DEFAULT_QUALITY.\n * @return A promise that resolves to the exported Blob.\n * @throws If the image fails to load, canvas creation fails, or\n * the resulting canvas is tainted by CORS restrictions.\n */\nexport async function exportCroppedImage(\n\tsrc: string,\n\tstate: CropperState,\n\tmimeType: string = 'image/png',\n\tquality: number = DEFAULT_QUALITY\n): Promise< Blob > {\n\tconst image = await loadImage( src );\n\tconst canvas = renderToCanvas( image, state );\n\treturn canvasToBlob( canvas, mimeType, quality );\n}\n\n/**\n * Apply the cropper's transform (crop, rotation, flip, zoom) to an existing\n * canvas or image source. This is the bridge for multi-step editing pipelines\n * where an upstream tool (e.g., brightness/color adjustment) has already\n * processed the image and you want to apply the crop on top.\n *\n * Accepts any CanvasImageSource: HTMLImageElement, HTMLCanvasElement,\n * OffscreenCanvas, ImageBitmap, HTMLVideoElement, etc.\n *\n * @param source - The image source to crop/transform.\n * @param sourceSize - The dimensions of the source (natural width/height).\n * @param sourceSize.width - The width of the source in pixels.\n * @param sourceSize.height - The height of the source in pixels.\n * @param state - The cropper state with all transform settings.\n * @param outputSize - Optional output size. Defaults to the crop region's natural pixel size.\n * @param outputSize.width - The width of the output in pixels.\n * @param outputSize.height - The height of the output in pixels.\n * @return A canvas with the transforms applied.\n */\nexport function applyToCanvas(\n\tsource: CanvasImageSource,\n\tsourceSize: { width: number; height: number },\n\tstate: CropperState,\n\toutputSize?: { width: number; height: number }\n): HTMLCanvasElement {\n\t// Use snap-rotation bbox for default sizing so the default output\n\t// matches the preview's reference frame at fine rotation angles\n\t// (see renderToCanvas / createExportCamera).\n\tconst snapRotation = Math.round( state.rotation / 90 ) * 90;\n\tconst rotBBox = getRotatedBBox(\n\t\tsourceSize.width,\n\t\tsourceSize.height,\n\t\tsnapRotation\n\t);\n\n\t// Default output size: the crop region in natural pixels.\n\tconst outW =\n\t\toutputSize?.width ?? Math.round( state.cropRect.width * rotBBox.width );\n\tconst outH =\n\t\toutputSize?.height ??\n\t\tMath.round( state.cropRect.height * rotBBox.height );\n\n\tconst canvas = document.createElement( 'canvas' );\n\tcanvas.width = outW;\n\tcanvas.height = outH;\n\tconst ctx = canvas.getContext( '2d' );\n\tif ( ! ctx ) {\n\t\tthrow new Error(\n\t\t\t'Could not obtain a 2D context for the export canvas.'\n\t\t);\n\t}\n\n\tconst camera = createExportCamera( state, sourceSize, {\n\t\twidth: outW,\n\t\theight: outH,\n\t} );\n\tctx.setTransform(\n\t\tcamera[ 0 ],\n\t\tcamera[ 1 ],\n\t\tcamera[ 2 ],\n\t\tcamera[ 3 ],\n\t\tcamera[ 4 ],\n\t\tcamera[ 5 ]\n\t);\n\tctx.drawImage( source, 0, 0 );\n\treturn canvas;\n}\n\n/**\n * Download the cropped image as a file.\n *\n * Loads the source image, applies all transforms, and triggers a\n * browser download via exportCroppedImage() + object URL + anchor click.\n *\n * Throws on export failure (see `exportCroppedImage`).\n *\n * @param src - The image URL to load.\n * @param state - The cropper state with all transform settings.\n * @param filename - The download filename. Defaults to 'cropped-image'.\n * @param mimeType - The output MIME type. Defaults to 'image/png'.\n * @param quality - The quality parameter for lossy formats (0-1). Defaults to DEFAULT_QUALITY.\n * @return A promise that resolves when the download is triggered.\n */\nexport async function downloadCroppedImage(\n\tsrc: string,\n\tstate: CropperState,\n\tfilename: string = 'cropped-image',\n\tmimeType: string = 'image/png',\n\tquality: number = DEFAULT_QUALITY\n): Promise< void > {\n\tconst blob = await exportCroppedImage( src, state, mimeType, quality );\n\tconst ext = mimeType.split( '/' )[ 1 ] ?? 'png';\n\tconst url = URL.createObjectURL( blob );\n\tconst a = document.createElement( 'a' );\n\ta.href = url;\n\ta.download = `${ filename }.${ ext }`;\n\ta.click();\n\tURL.revokeObjectURL( url );\n}\n"],"mappings":";;;AAIA,MAAM,kBAAkB;;;;;;;AAQxB,SAAgB,UAAW,KAA2C;CACrE,OAAO,IAAI,SAAW,SAAS,WAAY;EAC1C,MAAM,QAAQ,IAAI,MAAM;EACxB,MAAM,iBAAkB,cAAc,QAAS,KAAM,CAAE;EACvD,MAAM,iBAAkB,UAAW,UAAW,OAAQ,KAAM,CAAE;EAC9D,MAAM,cAAc;EACpB,MAAM,MAAM;CACb,CAAE;AACH;;;;;;;;;;;AAYA,SAAgB,eACf,OACA,OACoB;CACpB,MAAM,EAAE,cAAc,kBAAkB;CACxC,MAAM,EAAE,UAAU,aAAa;CAC/B,MAAM,YAAY;EAAE,OAAO;EAAc,QAAQ;CAAc;CAK/D,MAAM,eAAe,KAAK,MAAO,WAAW,EAAG,IAAI;CACnD,MAAM,UAAU,eAAgB,cAAc,eAAe,YAAa;CAC1E,MAAM,OAAO,KAAK,MAAO,SAAS,QAAQ,QAAQ,KAAM;CACxD,MAAM,OAAO,KAAK,MAAO,SAAS,SAAS,QAAQ,MAAO;CAE1D,MAAM,SAAS,SAAS,cAAe,QAAS;CAChD,OAAO,QAAQ;CACf,OAAO,SAAS;CAChB,MAAM,MAAM,OAAO,WAAY,IAAK;CACpC,IAAK,CAAE,KACN,MAAM,IAAI,MACT,sDACD;CAGD,MAAM,SAAS,mBAAoB,OAAO,WAAW;EACpD,OAAO;EACP,QAAQ;CACT,CAAE;CACF,IAAI,aACH,OAAQ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OAAQ,EACT;CACA,IAAI,UAAW,QAAQ,GAAG,CAAE;CAC5B,OAAO;AACR;;;;;;;;;;;;;;;;AAiBA,eAAsB,qBACrB,KACA,OACA,WAAmB,iBACnB,WAAmB,aACnB,UAAkB,iBACA;CAClB,MAAM,OAAO,MAAM,mBAAoB,KAAK,OAAO,UAAU,OAAQ;CACrE,MAAM,MAAM,SAAS,MAAO,GAAI,CAAC,CAAE,MAAO;CAC1C,MAAM,MAAM,IAAI,gBAAiB,IAAK;CACtC,MAAM,IAAI,SAAS,cAAe,GAAI;CACtC,EAAE,OAAO;CACT,EAAE,WAAW,GAAI,SAAU,GAAI;CAC/B,EAAE,MAAM;CACR,IAAI,gBAAiB,GAAI;AAC1B"}
@@ -1,7 +0,0 @@
1
- import { DEFAULT_STATE, ORIGINAL_ASPECT_RATIO } from "./constants.mjs";
2
- import { areCropperStatesEqual, cropperReducer, enforceContainment, isStateDirty } from "./state.mjs";
3
- import { getSourceRegion, getSourceRegionPercent } from "./source-region.mjs";
4
- import { computeInscribedRect } from "./crop-rect.mjs";
5
- import { applyOperationToState, stateFromPipeline } from "./transforms/pipeline.mjs";
6
- import { applyToCanvas, exportCroppedImage } from "./export/canvas-renderer.mjs";
7
- export { DEFAULT_STATE, ORIGINAL_ASPECT_RATIO, applyOperationToState, applyToCanvas, areCropperStatesEqual, computeInscribedRect, cropperReducer, enforceContainment, exportCroppedImage, getSourceRegion, getSourceRegionPercent, isStateDirty, stateFromPipeline };