@wordpress/media-editor 0.7.0 → 0.8.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 (306) hide show
  1. package/build/components/media-editor-canvas/index.cjs +54 -0
  2. package/build/components/media-editor-canvas/index.cjs.map +7 -0
  3. package/build/components/media-editor-crop-panel/index.cjs +116 -0
  4. package/build/components/media-editor-crop-panel/index.cjs.map +7 -0
  5. package/build/components/media-editor-modal/build-modifiers.cjs +91 -0
  6. package/build/components/media-editor-modal/build-modifiers.cjs.map +7 -0
  7. package/build/components/media-editor-modal/index.cjs +497 -0
  8. package/build/components/media-editor-modal/index.cjs.map +7 -0
  9. package/build/components/media-editor-toolbar/index.cjs +146 -0
  10. package/build/components/media-editor-toolbar/index.cjs.map +7 -0
  11. package/build/components/media-preview/index.cjs +1 -1
  12. package/build/components/media-preview/index.cjs.map +2 -2
  13. package/build/image-editor/core/camera.cjs +194 -0
  14. package/build/image-editor/core/camera.cjs.map +7 -0
  15. package/build/image-editor/core/constants.cjs +81 -0
  16. package/build/image-editor/core/constants.cjs.map +7 -0
  17. package/build/image-editor/core/containment.cjs +245 -0
  18. package/build/image-editor/core/containment.cjs.map +7 -0
  19. package/build/image-editor/core/export/canvas-renderer.cjs +151 -0
  20. package/build/image-editor/core/export/canvas-renderer.cjs.map +7 -0
  21. package/build/image-editor/core/index.cjs +50 -0
  22. package/build/image-editor/core/index.cjs.map +7 -0
  23. package/build/image-editor/core/interaction-controller.cjs +608 -0
  24. package/build/image-editor/core/interaction-controller.cjs.map +7 -0
  25. package/build/image-editor/core/math/rotation.cjs +41 -0
  26. package/build/image-editor/core/math/rotation.cjs.map +7 -0
  27. package/build/image-editor/core/source-region.cjs +95 -0
  28. package/build/image-editor/core/source-region.cjs.map +7 -0
  29. package/build/image-editor/core/state.cjs +269 -0
  30. package/build/image-editor/core/state.cjs.map +7 -0
  31. package/build/image-editor/core/stencil-math.cjs +197 -0
  32. package/build/image-editor/core/stencil-math.cjs.map +7 -0
  33. package/build/image-editor/core/transform-style.cjs +46 -0
  34. package/build/image-editor/core/transform-style.cjs.map +7 -0
  35. package/build/image-editor/core/transforms/pipeline.cjs +43 -0
  36. package/build/image-editor/core/transforms/pipeline.cjs.map +7 -0
  37. package/build/image-editor/core/types.cjs +19 -0
  38. package/build/image-editor/core/types.cjs.map +7 -0
  39. package/build/image-editor/index.cjs +57 -0
  40. package/build/image-editor/index.cjs.map +7 -0
  41. package/build/image-editor/react/components/cropper-provider.cjs +50 -0
  42. package/build/image-editor/react/components/cropper-provider.cjs.map +7 -0
  43. package/build/image-editor/react/components/cropper.cjs +365 -0
  44. package/build/image-editor/react/components/cropper.cjs.map +7 -0
  45. package/build/image-editor/react/components/index.cjs +36 -0
  46. package/build/image-editor/react/components/index.cjs.map +7 -0
  47. package/build/image-editor/react/components/overlays/dimming-overlay.cjs +58 -0
  48. package/build/image-editor/react/components/overlays/dimming-overlay.cjs.map +7 -0
  49. package/build/image-editor/react/components/overlays/grid-overlay.cjs +91 -0
  50. package/build/image-editor/react/components/overlays/grid-overlay.cjs.map +7 -0
  51. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs +351 -0
  52. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +7 -0
  53. package/build/image-editor/react/hooks/index.cjs +31 -0
  54. package/build/image-editor/react/hooks/index.cjs.map +7 -0
  55. package/build/image-editor/react/hooks/use-aria-announcer.cjs +68 -0
  56. package/build/image-editor/react/hooks/use-aria-announcer.cjs.map +7 -0
  57. package/build/image-editor/react/hooks/use-cropper-state.cjs +158 -0
  58. package/build/image-editor/react/hooks/use-cropper-state.cjs.map +7 -0
  59. package/build/image-editor/react/hooks/use-interaction.cjs +161 -0
  60. package/build/image-editor/react/hooks/use-interaction.cjs.map +7 -0
  61. package/build/image-editor/react/hooks/use-transform-style.cjs +38 -0
  62. package/build/image-editor/react/hooks/use-transform-style.cjs.map +7 -0
  63. package/build/index.cjs +5 -2
  64. package/build/index.cjs.map +2 -2
  65. package/build/lock-unlock.cjs +37 -0
  66. package/build/lock-unlock.cjs.map +7 -0
  67. package/build/private-apis.cjs +38 -0
  68. package/build/private-apis.cjs.map +7 -0
  69. package/build/store/actions.cjs +45 -0
  70. package/build/store/actions.cjs.map +7 -0
  71. package/build/store/constants.cjs +31 -0
  72. package/build/store/constants.cjs.map +7 -0
  73. package/build/store/index.cjs +51 -0
  74. package/build/store/index.cjs.map +7 -0
  75. package/build/store/reducer.cjs +51 -0
  76. package/build/store/reducer.cjs.map +7 -0
  77. package/build/store/selectors.cjs +43 -0
  78. package/build/store/selectors.cjs.map +7 -0
  79. package/build-module/components/media-editor-canvas/index.mjs +33 -0
  80. package/build-module/components/media-editor-canvas/index.mjs.map +7 -0
  81. package/build-module/components/media-editor-crop-panel/index.mjs +100 -0
  82. package/build-module/components/media-editor-crop-panel/index.mjs.map +7 -0
  83. package/build-module/components/media-editor-modal/build-modifiers.mjs +66 -0
  84. package/build-module/components/media-editor-modal/build-modifiers.mjs.map +7 -0
  85. package/build-module/components/media-editor-modal/index.mjs +483 -0
  86. package/build-module/components/media-editor-modal/index.mjs.map +7 -0
  87. package/build-module/components/media-editor-toolbar/index.mjs +130 -0
  88. package/build-module/components/media-editor-toolbar/index.mjs.map +7 -0
  89. package/build-module/components/media-preview/index.mjs +1 -1
  90. package/build-module/components/media-preview/index.mjs.map +2 -2
  91. package/build-module/image-editor/core/camera.mjs +163 -0
  92. package/build-module/image-editor/core/camera.mjs.map +7 -0
  93. package/build-module/image-editor/core/constants.mjs +51 -0
  94. package/build-module/image-editor/core/constants.mjs.map +7 -0
  95. package/build-module/image-editor/core/containment.mjs +218 -0
  96. package/build-module/image-editor/core/containment.mjs.map +7 -0
  97. package/build-module/image-editor/core/export/canvas-renderer.mjs +120 -0
  98. package/build-module/image-editor/core/export/canvas-renderer.mjs.map +7 -0
  99. package/build-module/image-editor/core/index.mjs +24 -0
  100. package/build-module/image-editor/core/index.mjs.map +7 -0
  101. package/build-module/image-editor/core/interaction-controller.mjs +583 -0
  102. package/build-module/image-editor/core/interaction-controller.mjs.map +7 -0
  103. package/build-module/image-editor/core/math/rotation.mjs +15 -0
  104. package/build-module/image-editor/core/math/rotation.mjs.map +7 -0
  105. package/build-module/image-editor/core/source-region.mjs +69 -0
  106. package/build-module/image-editor/core/source-region.mjs.map +7 -0
  107. package/build-module/image-editor/core/state.mjs +242 -0
  108. package/build-module/image-editor/core/state.mjs.map +7 -0
  109. package/build-module/image-editor/core/stencil-math.mjs +169 -0
  110. package/build-module/image-editor/core/stencil-math.mjs.map +7 -0
  111. package/build-module/image-editor/core/transform-style.mjs +21 -0
  112. package/build-module/image-editor/core/transform-style.mjs.map +7 -0
  113. package/build-module/image-editor/core/transforms/pipeline.mjs +17 -0
  114. package/build-module/image-editor/core/transforms/pipeline.mjs.map +7 -0
  115. package/build-module/image-editor/core/types.mjs +1 -0
  116. package/build-module/image-editor/core/types.mjs.map +7 -0
  117. package/build-module/image-editor/index.mjs +30 -0
  118. package/build-module/image-editor/index.mjs.map +7 -0
  119. package/build-module/image-editor/react/components/cropper-provider.mjs +26 -0
  120. package/build-module/image-editor/react/components/cropper-provider.mjs.map +7 -0
  121. package/build-module/image-editor/react/components/cropper.mjs +337 -0
  122. package/build-module/image-editor/react/components/cropper.mjs.map +7 -0
  123. package/build-module/image-editor/react/components/index.mjs +9 -0
  124. package/build-module/image-editor/react/components/index.mjs.map +7 -0
  125. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs +33 -0
  126. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs.map +7 -0
  127. package/build-module/image-editor/react/components/overlays/grid-overlay.mjs +66 -0
  128. package/build-module/image-editor/react/components/overlays/grid-overlay.mjs.map +7 -0
  129. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs +330 -0
  130. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs.map +7 -0
  131. package/build-module/image-editor/react/hooks/index.mjs +6 -0
  132. package/build-module/image-editor/react/hooks/index.mjs.map +7 -0
  133. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs +43 -0
  134. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs.map +7 -0
  135. package/build-module/image-editor/react/hooks/use-cropper-state.mjs +137 -0
  136. package/build-module/image-editor/react/hooks/use-cropper-state.mjs.map +7 -0
  137. package/build-module/image-editor/react/hooks/use-interaction.mjs +138 -0
  138. package/build-module/image-editor/react/hooks/use-interaction.mjs.map +7 -0
  139. package/build-module/image-editor/react/hooks/use-transform-style.mjs +13 -0
  140. package/build-module/image-editor/react/hooks/use-transform-style.mjs.map +7 -0
  141. package/build-module/index.mjs +3 -1
  142. package/build-module/index.mjs.map +2 -2
  143. package/build-module/lock-unlock.mjs +11 -0
  144. package/build-module/lock-unlock.mjs.map +7 -0
  145. package/build-module/private-apis.mjs +13 -0
  146. package/build-module/private-apis.mjs.map +7 -0
  147. package/build-module/store/actions.mjs +19 -0
  148. package/build-module/store/actions.mjs.map +7 -0
  149. package/build-module/store/constants.mjs +6 -0
  150. package/build-module/store/constants.mjs.map +7 -0
  151. package/build-module/store/index.mjs +16 -0
  152. package/build-module/store/index.mjs.map +7 -0
  153. package/build-module/store/reducer.mjs +26 -0
  154. package/build-module/store/reducer.mjs.map +7 -0
  155. package/build-module/store/selectors.mjs +16 -0
  156. package/build-module/store/selectors.mjs.map +7 -0
  157. package/build-style/style-rtl.css +315 -0
  158. package/build-style/style.css +315 -0
  159. package/build-types/components/media-editor-canvas/index.d.ts +22 -0
  160. package/build-types/components/media-editor-canvas/index.d.ts.map +1 -0
  161. package/build-types/components/media-editor-crop-panel/index.d.ts +45 -0
  162. package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -0
  163. package/build-types/components/media-editor-modal/build-modifiers.d.ts +83 -0
  164. package/build-types/components/media-editor-modal/build-modifiers.d.ts.map +1 -0
  165. package/build-types/components/media-editor-modal/index.d.ts +20 -0
  166. package/build-types/components/media-editor-modal/index.d.ts.map +1 -0
  167. package/build-types/components/media-editor-toolbar/index.d.ts +21 -0
  168. package/build-types/components/media-editor-toolbar/index.d.ts.map +1 -0
  169. package/build-types/components/media-preview/index.d.ts.map +1 -1
  170. package/build-types/image-editor/core/camera.d.ts +107 -0
  171. package/build-types/image-editor/core/camera.d.ts.map +1 -0
  172. package/build-types/image-editor/core/constants.d.ts +46 -0
  173. package/build-types/image-editor/core/constants.d.ts.map +1 -0
  174. package/build-types/image-editor/core/containment.d.ts +61 -0
  175. package/build-types/image-editor/core/containment.d.ts.map +1 -0
  176. package/build-types/image-editor/core/export/canvas-renderer.d.ts +106 -0
  177. package/build-types/image-editor/core/export/canvas-renderer.d.ts.map +1 -0
  178. package/build-types/image-editor/core/index.d.ts +8 -0
  179. package/build-types/image-editor/core/index.d.ts.map +1 -0
  180. package/build-types/image-editor/core/interaction-controller.d.ts +178 -0
  181. package/build-types/image-editor/core/interaction-controller.d.ts.map +1 -0
  182. package/build-types/image-editor/core/math/rotation.d.ts +18 -0
  183. package/build-types/image-editor/core/math/rotation.d.ts.map +1 -0
  184. package/build-types/image-editor/core/source-region.d.ts +75 -0
  185. package/build-types/image-editor/core/source-region.d.ts.map +1 -0
  186. package/build-types/image-editor/core/state.d.ts +42 -0
  187. package/build-types/image-editor/core/state.d.ts.map +1 -0
  188. package/build-types/image-editor/core/stencil-math.d.ts +79 -0
  189. package/build-types/image-editor/core/stencil-math.d.ts.map +1 -0
  190. package/build-types/image-editor/core/transform-style.d.ts +23 -0
  191. package/build-types/image-editor/core/transform-style.d.ts.map +1 -0
  192. package/build-types/image-editor/core/transforms/pipeline.d.ts +27 -0
  193. package/build-types/image-editor/core/transforms/pipeline.d.ts.map +1 -0
  194. package/build-types/image-editor/core/types.d.ts +211 -0
  195. package/build-types/image-editor/core/types.d.ts.map +1 -0
  196. package/build-types/image-editor/index.d.ts +16 -0
  197. package/build-types/image-editor/index.d.ts.map +1 -0
  198. package/build-types/image-editor/react/components/cropper-provider.d.ts +37 -0
  199. package/build-types/image-editor/react/components/cropper-provider.d.ts.map +1 -0
  200. package/build-types/image-editor/react/components/cropper.d.ts +59 -0
  201. package/build-types/image-editor/react/components/cropper.d.ts.map +1 -0
  202. package/build-types/image-editor/react/components/index.d.ts +4 -0
  203. package/build-types/image-editor/react/components/index.d.ts.map +1 -0
  204. package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts +30 -0
  205. package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts.map +1 -0
  206. package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts +30 -0
  207. package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts.map +1 -0
  208. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts +32 -0
  209. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts.map +1 -0
  210. package/build-types/image-editor/react/hooks/index.d.ts +3 -0
  211. package/build-types/image-editor/react/hooks/index.d.ts.map +1 -0
  212. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts +16 -0
  213. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts.map +1 -0
  214. package/build-types/image-editor/react/hooks/use-cropper-state.d.ts +68 -0
  215. package/build-types/image-editor/react/hooks/use-cropper-state.d.ts.map +1 -0
  216. package/build-types/image-editor/react/hooks/use-interaction.d.ts +60 -0
  217. package/build-types/image-editor/react/hooks/use-interaction.d.ts.map +1 -0
  218. package/build-types/image-editor/react/hooks/use-transform-style.d.ts +16 -0
  219. package/build-types/image-editor/react/hooks/use-transform-style.d.ts.map +1 -0
  220. package/build-types/image-editor/stories/rectangle-crop.story.d.ts +16 -0
  221. package/build-types/image-editor/stories/rectangle-crop.story.d.ts.map +1 -0
  222. package/build-types/index.d.ts +1 -0
  223. package/build-types/index.d.ts.map +1 -1
  224. package/build-types/lock-unlock.d.ts +2 -0
  225. package/build-types/lock-unlock.d.ts.map +1 -0
  226. package/build-types/private-apis.d.ts +2 -0
  227. package/build-types/private-apis.d.ts.map +1 -0
  228. package/build-types/store/actions.d.ts +27 -0
  229. package/build-types/store/actions.d.ts.map +1 -0
  230. package/build-types/store/constants.d.ts +2 -0
  231. package/build-types/store/constants.d.ts.map +1 -0
  232. package/build-types/store/index.d.ts +4 -0
  233. package/build-types/store/index.d.ts.map +1 -0
  234. package/build-types/store/reducer.d.ts +23 -0
  235. package/build-types/store/reducer.d.ts.map +1 -0
  236. package/build-types/store/selectors.d.ts +8 -0
  237. package/build-types/store/selectors.d.ts.map +1 -0
  238. package/package.json +21 -8
  239. package/src/components/media-editor-canvas/index.tsx +56 -0
  240. package/src/components/media-editor-canvas/style.scss +9 -0
  241. package/src/components/media-editor-crop-panel/index.tsx +143 -0
  242. package/src/components/media-editor-modal/build-modifiers.ts +164 -0
  243. package/src/components/media-editor-modal/index.tsx +639 -0
  244. package/src/components/media-editor-modal/style.scss +139 -0
  245. package/src/components/media-editor-modal/test/build-modifiers.test.ts +343 -0
  246. package/src/components/media-editor-toolbar/index.tsx +150 -0
  247. package/src/components/media-editor-toolbar/style.scss +21 -0
  248. package/src/components/media-preview/index.tsx +2 -1
  249. package/src/image-editor/README.md +162 -0
  250. package/src/image-editor/core/camera.ts +352 -0
  251. package/src/image-editor/core/constants.ts +93 -0
  252. package/src/image-editor/core/containment.ts +435 -0
  253. package/src/image-editor/core/export/canvas-renderer.ts +253 -0
  254. package/src/image-editor/core/export/test/canvas-renderer.ts +813 -0
  255. package/src/image-editor/core/index.ts +35 -0
  256. package/src/image-editor/core/interaction-controller.ts +889 -0
  257. package/src/image-editor/core/math/rotation.ts +26 -0
  258. package/src/image-editor/core/source-region.ts +166 -0
  259. package/src/image-editor/core/state.ts +428 -0
  260. package/src/image-editor/core/stencil-math.ts +330 -0
  261. package/src/image-editor/core/test/camera.ts +593 -0
  262. package/src/image-editor/core/test/interaction-controller.ts +996 -0
  263. package/src/image-editor/core/test/preview-export-parity.ts +242 -0
  264. package/src/image-editor/core/test/render-camera-bridge.ts +348 -0
  265. package/src/image-editor/core/test/state.ts +762 -0
  266. package/src/image-editor/core/test/stencil-math.ts +321 -0
  267. package/src/image-editor/core/transform-style.ts +44 -0
  268. package/src/image-editor/core/transforms/pipeline.ts +43 -0
  269. package/src/image-editor/core/transforms/test/pipeline.ts +269 -0
  270. package/src/image-editor/core/types.ts +177 -0
  271. package/src/image-editor/docs/architecture.md +96 -0
  272. package/src/image-editor/docs/recipes.md +720 -0
  273. package/src/image-editor/docs/roadmap.md +66 -0
  274. package/src/image-editor/index.ts +43 -0
  275. package/src/image-editor/react/components/cropper-provider.tsx +73 -0
  276. package/src/image-editor/react/components/cropper.scss +195 -0
  277. package/src/image-editor/react/components/cropper.tsx +534 -0
  278. package/src/image-editor/react/components/index.ts +3 -0
  279. package/src/image-editor/react/components/overlays/dimming-overlay.tsx +57 -0
  280. package/src/image-editor/react/components/overlays/grid-overlay.tsx +80 -0
  281. package/src/image-editor/react/components/stencils/rectangle-stencil.tsx +513 -0
  282. package/src/image-editor/react/components/stencils/test/rectangle-stencil.tsx +265 -0
  283. package/src/image-editor/react/components/test/cropper.tsx +140 -0
  284. package/src/image-editor/react/hooks/index.ts +2 -0
  285. package/src/image-editor/react/hooks/test/use-cropper-state.ts +913 -0
  286. package/src/image-editor/react/hooks/test/use-interaction.ts +218 -0
  287. package/src/image-editor/react/hooks/test/use-transform-style.ts +146 -0
  288. package/src/image-editor/react/hooks/use-aria-announcer.ts +64 -0
  289. package/src/image-editor/react/hooks/use-cropper-state.ts +238 -0
  290. package/src/image-editor/react/hooks/use-interaction.ts +223 -0
  291. package/src/image-editor/react/hooks/use-transform-style.ts +30 -0
  292. package/src/image-editor/stories/rectangle-crop.story.tsx +1085 -0
  293. package/src/image-editor/stories/style.css +94 -0
  294. package/src/image-editor/style.scss +1 -0
  295. package/src/index.ts +3 -0
  296. package/src/lock-unlock.ts +10 -0
  297. package/src/private-apis.ts +12 -0
  298. package/src/store/actions.ts +33 -0
  299. package/src/store/constants.ts +1 -0
  300. package/src/store/index.ts +20 -0
  301. package/src/store/reducer.ts +48 -0
  302. package/src/store/selectors.ts +16 -0
  303. package/src/store/test/reducer.ts +57 -0
  304. package/src/style.scss +4 -0
  305. package/tsconfig.json +10 -2
  306. package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1,211 @@
1
+ import type { mat2d } from 'gl-matrix';
2
+ /**
3
+ * A 2D camera represented as a 2×3 affine transformation matrix (`mat2d`).
4
+ *
5
+ * This is not a camera object with properties — it's a raw 6-element matrix
6
+ * `[a, b, c, d, tx, ty]` that maps normalized world coordinates [0,1] to
7
+ * screen pixels. It composes pan, rotation, flip, zoom, and contain-fit
8
+ * into a single transform.
9
+ *
10
+ * Use `createCamera()` to build one from `CropperState`, then pass it to
11
+ * `worldToScreen()` / `screenToWorld()` for coordinate conversion.
12
+ *
13
+ * A 3D camera would use `mat4`; this is strictly 2D (no perspective).
14
+ */
15
+ export type Camera = mat2d;
16
+ /**
17
+ * A point with normalized coordinates (0-1 range relative to image dimensions).
18
+ */
19
+ export interface NormalizedPoint {
20
+ x: number;
21
+ y: number;
22
+ }
23
+ /**
24
+ * A rectangle with normalized coordinates (0-1 range).
25
+ * Origin is the top-left corner of the image.
26
+ */
27
+ export interface NormalizedRect {
28
+ x: number;
29
+ y: number;
30
+ width: number;
31
+ height: number;
32
+ }
33
+ /**
34
+ * Width and height dimensions.
35
+ */
36
+ export interface Size {
37
+ width: number;
38
+ height: number;
39
+ }
40
+ /**
41
+ * Flip state for horizontal and vertical axes.
42
+ */
43
+ export interface Flip {
44
+ horizontal: boolean;
45
+ vertical: boolean;
46
+ }
47
+ /**
48
+ * A JSON-serializable transform operation for the non-destructive pipeline.
49
+ */
50
+ export type TransformOperation = {
51
+ type: 'crop';
52
+ rect: NormalizedRect;
53
+ } | {
54
+ type: 'rotate';
55
+ degrees: number;
56
+ } | {
57
+ type: 'flip';
58
+ direction: 'horizontal' | 'vertical';
59
+ } | {
60
+ type: 'zoom';
61
+ factor: number;
62
+ };
63
+ /**
64
+ * Full cropper state.
65
+ */
66
+ export interface CropperState {
67
+ /** The source image information. Null until an image is loaded. */
68
+ image: {
69
+ src: string;
70
+ naturalWidth: number;
71
+ naturalHeight: number;
72
+ } | null;
73
+ /**
74
+ * Image pan offset in normalized coordinates. Not the crop
75
+ * rectangle — that's `cropRect` below.
76
+ */
77
+ pan: NormalizedPoint;
78
+ /** Zoom level. 1 = no zoom. */
79
+ zoom: number;
80
+ /** Rotation in degrees, normalized to 0-360. */
81
+ rotation: number;
82
+ /**
83
+ * Base pan/zoom/rotation — the pose the user last explicitly set.
84
+ *
85
+ * During continuous fine rotation (SET_ROTATION), every tick
86
+ * re-derives the transient `pan`/`zoom` from these base values
87
+ * rather than compounding on the previous tick. This prevents
88
+ * drift from accumulated containment clamping near image edges:
89
+ * rotating 0°→30°→0° returns to the exact starting pan, not a
90
+ * slightly-nudged version of it.
91
+ *
92
+ * These are updated by every action except SET_ROTATION itself —
93
+ * explicit zoom, pan, crop-rect, flip, and 90° snap all commit
94
+ * the post-containment state into base. SET_ROTATION reads from
95
+ * `basePan` and `baseRotation` to compute the new pan, and reads
96
+ * `baseZoom` as the zoom floor (enforceContainment may bump it up
97
+ * to cover the rotated crop, but never leaves it above baseZoom).
98
+ */
99
+ basePan: NormalizedPoint;
100
+ baseZoom: number;
101
+ baseRotation: number;
102
+ /** Flip state. */
103
+ flip: Flip;
104
+ /** The crop rectangle in normalized coordinates. */
105
+ cropRect: NormalizedRect;
106
+ }
107
+ /**
108
+ * Internal reducer action union.
109
+ *
110
+ * This type is intentionally not exported from the image-editor public barrel.
111
+ * Consumers should drive state through the controller returned by
112
+ * `useCropperState()` or through serializable `TransformOperation` values.
113
+ */
114
+ export type CropperAction =
115
+ /** Sets the loaded image metadata (natural size, src). */
116
+ {
117
+ type: 'SET_IMAGE';
118
+ payload: CropperState['image'];
119
+ }
120
+ /** Sets the image pan offset. (Crop rectangle is SET_CROP_RECT.) */
121
+ | {
122
+ type: 'SET_PAN';
123
+ payload: NormalizedPoint;
124
+ }
125
+ /** Sets the zoom level, clamped to [1, MAX_ZOOM]. */
126
+ | {
127
+ type: 'SET_ZOOM';
128
+ payload: number;
129
+ }
130
+ /**
131
+ * Sets zoom and pan together atomically. Used by focal-point
132
+ * zoom (wheel, pinch) to keep a target point stationary while
133
+ * zoom changes.
134
+ */
135
+ | {
136
+ type: 'SET_ZOOM_AT_POINT';
137
+ payload: {
138
+ zoom: number;
139
+ pan: NormalizedPoint;
140
+ };
141
+ }
142
+ /** Sets the absolute rotation angle in degrees. */
143
+ | {
144
+ type: 'SET_ROTATION';
145
+ payload: number;
146
+ }
147
+ /** Rotates by +/-90 degrees (snap). */
148
+ | {
149
+ type: 'SNAP_ROTATE_90';
150
+ payload: {
151
+ direction: 1 | -1;
152
+ };
153
+ }
154
+ /** Sets the flip state. */
155
+ | {
156
+ type: 'SET_FLIP';
157
+ payload: Flip;
158
+ }
159
+ /** Sets the crop rectangle. */
160
+ | {
161
+ type: 'SET_CROP_RECT';
162
+ payload: NormalizedRect;
163
+ }
164
+ /** Settle animation after resize drag, recentering the crop rect. */
165
+ | {
166
+ type: 'SETTLE_CROP';
167
+ }
168
+ /** Applies a single pipeline transform via the reducer. */
169
+ | {
170
+ type: 'APPLY_OPERATION';
171
+ payload: TransformOperation;
172
+ }
173
+ /** Resets to DEFAULT_STATE, optionally merging a partial override. */
174
+ | {
175
+ type: 'RESET';
176
+ payload?: Partial<CropperState>;
177
+ };
178
+ /**
179
+ * The contract for a pluggable stencil component.
180
+ * Stencils render the crop area overlay and handle resize interactions.
181
+ */
182
+ export interface StencilProps {
183
+ /** The current crop rectangle in normalized coordinates. */
184
+ cropRect: NormalizedRect;
185
+ /** The container element dimensions in pixels. */
186
+ containerSize: Size;
187
+ /** The rendered image dimensions in pixels within the container. */
188
+ imageSize: Size;
189
+ /** Callback when the crop rectangle changes (during drag). */
190
+ onCropChange: (rect: NormalizedRect) => void;
191
+ /** Callback when a resize drag starts (pointerdown on handle). */
192
+ onResizeStart?: () => void;
193
+ /** Callback when a resize drag ends (mouseup after handle drag). */
194
+ onResizeEnd?: () => void;
195
+ /** Optional fixed aspect ratio (width / height) in pixel space. */
196
+ aspectRatio?: number;
197
+ /** Whether the crop handles are shown for freeform resizing. */
198
+ freeformCrop?: boolean;
199
+ /** CSS transition string for settle animation. */
200
+ stencilTransition?: string;
201
+ /** Maximum crop rect bounds based on current zoom/rotation. */
202
+ cropBounds?: {
203
+ minX: number;
204
+ minY: number;
205
+ maxX: number;
206
+ maxY: number;
207
+ };
208
+ /** Called when Escape is pressed on a resize handle. */
209
+ onEscape?: () => void;
210
+ }
211
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/image-editor/core/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAEvC;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,MAAM,GAAG,KAAK,CAAC;AAE3B;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACV;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC9B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,IAAI;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,IAAI;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAC3B;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,cAAc,CAAA;CAAE,GACtC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACnC;IAAE,IAAI,EAAE,MAAM,CAAC;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,CAAC;KACb,CAAC;IACF,wDAAwD;IACxD,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Public image editor contract.
3
+ *
4
+ * Keep this barrel explicit so implementation details from `core/`,
5
+ * `react/hooks/`, or `react/components/` do not become supported API by
6
+ * accident. Internal modules may export additional helpers for local tests or
7
+ * React wiring; consumers should import through this file.
8
+ */
9
+ export { useCropperState } from './react/hooks';
10
+ export { Cropper, CropperProvider, useCropper } from './react/components';
11
+ export type { UseCropperStateReturn } from './react/hooks';
12
+ export type { CropperProps } from './react/components';
13
+ export type { CropperState, TransformOperation, NormalizedPoint, NormalizedRect, Size, Flip, StencilProps, } from './core';
14
+ export { DEFAULT_STATE, DEFAULT_ASPECT_RATIOS, ORIGINAL_ASPECT_RATIO, getSourceRegion, getSourceRegionPercent, applyOperationToState, stateFromPipeline, exportCroppedImage, applyToCanvas, } from './core';
15
+ export type { AspectRatioPreset, SourceRegion, SourceRegionPercent, } from './core';
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/image-editor/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC1E,YAAY,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAC3D,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGvD,YAAY,EACX,YAAY,EACZ,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,IAAI,EACJ,IAAI,EACJ,YAAY,GACZ,MAAM,QAAQ,CAAC;AAGhB,OAAO,EACN,aAAa,EACb,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,EACf,sBAAsB,EACtB,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,GACb,MAAM,QAAQ,CAAC;AAChB,YAAY,EACX,iBAAiB,EACjB,YAAY,EACZ,mBAAmB,GACnB,MAAM,QAAQ,CAAC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import { type UseCropperStateReturn } from '../hooks/use-cropper-state';
5
+ import type { CropperState } from '../../core/types';
6
+ /**
7
+ * Props for the CropperProvider component.
8
+ */
9
+ interface CropperProviderProps {
10
+ /** Optional partial initial state to merge with defaults. */
11
+ initialState?: Partial<CropperState>;
12
+ /** Child components. */
13
+ children: React.ReactNode;
14
+ }
15
+ /**
16
+ * Convenience context provider that wraps useCropperState.
17
+ *
18
+ * Provides the full cropper state and action creators to all
19
+ * descendant components via React context.
20
+ *
21
+ * @param props Provider props.
22
+ * @param props.initialState
23
+ * @param props.children
24
+ * @return The provider element wrapping children.
25
+ */
26
+ export declare function CropperProvider({ initialState, children, }: CropperProviderProps): import("react").JSX.Element;
27
+ /**
28
+ * Hook to consume the CropperProvider context.
29
+ *
30
+ * Must be used within a CropperProvider. Throws if used outside
31
+ * of the provider tree.
32
+ *
33
+ * @return The cropper state and action creators.
34
+ */
35
+ export declare function useCropper(): UseCropperStateReturn;
36
+ export {};
37
+ //# sourceMappingURL=cropper-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cropper-provider.d.ts","sourceRoot":"","sources":["../../../../src/image-editor/react/components/cropper-provider.tsx"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,EAEN,KAAK,qBAAqB,EAC1B,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAUrD;;GAEG;AACH,UAAU,oBAAoB;IAC7B,6DAA6D;IAC7D,YAAY,CAAC,EAAE,OAAO,CAAE,YAAY,CAAE,CAAC;IACvC,wBAAwB;IACxB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC1B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAE,EAChC,YAAY,EACZ,QAAQ,GACR,EAAE,oBAAoB,+BAQtB;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,IAAI,qBAAqB,CAQlD"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ /**
5
+ * Internal dependencies
6
+ */
7
+ import type { CropperState, StencilProps, Size } from '../../core/types';
8
+ import type { UseCropperStateReturn } from '../hooks/use-cropper-state';
9
+ import './cropper.scss';
10
+ /**
11
+ * Props for the Cropper component.
12
+ */
13
+ export interface CropperProps {
14
+ /** Image source URL. */
15
+ src: string;
16
+ /** The full state/setter object from `useCropperState`. */
17
+ controller: UseCropperStateReturn;
18
+ /** Stencil component for the crop area. Defaults to RectangleStencil. */
19
+ stencil?: React.ComponentType<StencilProps>;
20
+ /** Show the rule-of-thirds grid overlay, or only during interactions. */
21
+ showGrid?: boolean | 'interactive';
22
+ /** Whether external placement activity should keep the grid visible. */
23
+ isPlacementActive?: boolean;
24
+ /** Show the dimming overlay outside the crop area. */
25
+ showDimming?: boolean;
26
+ /** Minimum zoom level. */
27
+ minZoom?: number;
28
+ /** Maximum zoom level. */
29
+ maxZoom?: number;
30
+ /** Fixed aspect ratio (width / height) in pixel space for the crop area. */
31
+ aspectRatio?: number;
32
+ /**
33
+ * Enable freeform crop mode with resizable handles.
34
+ * When false (default), the crop area is fixed and centered.
35
+ * When true, the crop area has resize handles and can be freely repositioned.
36
+ */
37
+ freeformCrop?: boolean;
38
+ /** Callback fired when the image is loaded. */
39
+ onImageLoaded?: (size: Size) => void;
40
+ /**
41
+ * Callback fired on every state change. Fires at pointermove rate
42
+ * during drags, so keep the handler light — no heavy work, no
43
+ * expensive parent re-renders. For commit-style events (drag end,
44
+ * settled crop), use `onGestureEnd` instead.
45
+ *
46
+ * Useful for lightweight syncing with external tools, analytics,
47
+ * or AI agents. Receives the full state so consumers can derive
48
+ * whatever they need.
49
+ */
50
+ onStateChange?: (state: CropperState) => void;
51
+ /** Fires when a continuous gesture begins (pan drag, handle resize, pinch zoom). */
52
+ onGestureStart?: () => void;
53
+ /** Fires when a continuous gesture ends (pointerup, resize settle). */
54
+ onGestureEnd?: () => void;
55
+ /** Additional className for the container. */
56
+ className?: string;
57
+ }
58
+ export declare const Cropper: import("react").ForwardRefExoticComponent<CropperProps & import("react").RefAttributes<HTMLDivElement>>;
59
+ //# sourceMappingURL=cropper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cropper.d.ts","sourceRoot":"","sources":["../../../../src/image-editor/react/components/cropper.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAiBH;;GAEG;AACH,OAAO,KAAK,EACX,YAAY,EACZ,YAAY,EACZ,IAAI,EAEJ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AASxE,OAAO,gBAAgB,CAAC;AAoCxB;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,wBAAwB;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,2DAA2D;IAC3D,UAAU,EAAE,qBAAqB,CAAC;IAClC,yEAAyE;IACzE,OAAO,CAAC,EAAE,KAAK,CAAC,aAAa,CAAE,YAAY,CAAE,CAAC;IAC9C,yEAAyE;IACzE,QAAQ,CAAC,EAAE,OAAO,GAAG,aAAa,CAAC;IACnC,wEAAwE;IACxE,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,sDAAsD;IACtD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,0BAA0B;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,0BAA0B;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4EAA4E;IAC5E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,+CAA+C;IAC/C,aAAa,CAAC,EAAE,CAAE,IAAI,EAAE,IAAI,KAAM,IAAI,CAAC;IACvC;;;;;;;;;OASG;IACH,aAAa,CAAC,EAAE,CAAE,KAAK,EAAE,YAAY,KAAM,IAAI,CAAC;IAChD,oFAAoF;IACpF,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,uEAAuE;IACvE,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,8CAA8C;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AA2ZD,eAAO,MAAM,OAAO,yGAEnB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { Cropper } from './cropper';
2
+ export type { CropperProps } from './cropper';
3
+ export { CropperProvider, useCropper } from './cropper-provider';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/image-editor/react/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import type { NormalizedRect, Size } from '../../../core/types';
5
+ /**
6
+ * Props for the DimmingOverlay component.
7
+ */
8
+ interface DimmingOverlayProps {
9
+ /** The crop rectangle in normalized coordinates. */
10
+ cropRect: NormalizedRect;
11
+ /** The container element dimensions in pixels. */
12
+ containerSize: Size;
13
+ /** The rendered image dimensions in pixels within the container. */
14
+ imageSize: Size;
15
+ }
16
+ /**
17
+ * Renders a semi-transparent overlay outside the crop rectangle.
18
+ *
19
+ * Uses the box-shadow approach: a div matching the crop rect position
20
+ * with a large box-shadow that dims everything outside it.
21
+ *
22
+ * @param props Component props.
23
+ * @param props.cropRect The crop rectangle in normalized coordinates.
24
+ * @param props.containerSize The container element dimensions in pixels.
25
+ * @param props.imageSize The rendered image dimensions in pixels.
26
+ * @return The dimming overlay element.
27
+ */
28
+ export declare function DimmingOverlay({ cropRect, containerSize, imageSize, }: DimmingOverlayProps): import("react").JSX.Element | null;
29
+ export {};
30
+ //# sourceMappingURL=dimming-overlay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dimming-overlay.d.ts","sourceRoot":"","sources":["../../../../../src/image-editor/react/components/overlays/dimming-overlay.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAEhE;;GAEG;AACH,UAAU,mBAAmB;IAC5B,oDAAoD;IACpD,QAAQ,EAAE,cAAc,CAAC;IACzB,kDAAkD;IAClD,aAAa,EAAE,IAAI,CAAC;IACpB,oEAAoE;IACpE,SAAS,EAAE,IAAI,CAAC;CAChB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAE,EAC/B,QAAQ,EACR,aAAa,EACb,SAAS,GACT,EAAE,mBAAmB,sCAuBrB"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import type { NormalizedRect, Size } from '../../../core/types';
5
+ /**
6
+ * Props for the GridOverlay component.
7
+ */
8
+ interface GridOverlayProps {
9
+ /** The crop rectangle in normalized coordinates. */
10
+ cropRect: NormalizedRect;
11
+ /** The container element dimensions in pixels. */
12
+ containerSize: Size;
13
+ /** The rendered image dimensions in pixels within the container. */
14
+ imageSize: Size;
15
+ }
16
+ /**
17
+ * Renders a rule-of-thirds grid inside the crop rectangle.
18
+ *
19
+ * Displays 2 horizontal and 2 vertical lines at 1/3 and 2/3
20
+ * positions within the crop area.
21
+ *
22
+ * @param props Component props.
23
+ * @param props.cropRect The crop rectangle in normalized coordinates.
24
+ * @param props.containerSize The container element dimensions in pixels.
25
+ * @param props.imageSize The rendered image dimensions in pixels.
26
+ * @return The grid overlay element.
27
+ */
28
+ export declare function GridOverlay({ cropRect, containerSize, imageSize, }: GridOverlayProps): import("react").JSX.Element | null;
29
+ export {};
30
+ //# sourceMappingURL=grid-overlay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grid-overlay.d.ts","sourceRoot":"","sources":["../../../../../src/image-editor/react/components/overlays/grid-overlay.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAEhE;;GAEG;AACH,UAAU,gBAAgB;IACzB,oDAAoD;IACpD,QAAQ,EAAE,cAAc,CAAC;IACzB,kDAAkD;IAClD,aAAa,EAAE,IAAI,CAAC;IACpB,oEAAoE;IACpE,SAAS,EAAE,IAAI,CAAC;CAChB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAE,EAC5B,QAAQ,EACR,aAAa,EACb,SAAS,GACT,EAAE,gBAAgB,sCA8ClB"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import type { StencilProps } from '../../../core/types';
5
+ /**
6
+ * Props for the RectangleStencil component.
7
+ */
8
+ type RectangleStencilProps = StencilProps;
9
+ /**
10
+ * A rectangular crop stencil with resize handles.
11
+ *
12
+ * In freeform mode, handles resize the crop area. Clicks inside the
13
+ * crop pass through to the container for image panning. The crop
14
+ * auto-centers after resize via SETTLE_CROP.
15
+ *
16
+ * @param props Component props implementing StencilProps.
17
+ * @param props.cropRect The crop rectangle in normalized coordinates.
18
+ * @param props.containerSize The container element dimensions in pixels.
19
+ * @param props.imageSize The rendered image dimensions in pixels.
20
+ * @param props.onCropChange Callback fired when the crop rect changes.
21
+ * @param props.onResizeStart Callback fired when a resize drag starts.
22
+ * @param props.onResizeEnd Callback fired when a resize drag ends (mouseup).
23
+ * @param props.aspectRatio Optional fixed aspect ratio (width / height).
24
+ * @param props.freeformCrop Whether resize handles are shown.
25
+ * @param props.stencilTransition CSS transition string for settle animation.
26
+ * @param props.cropBounds Maximum crop rect bounds from camera (zoom/rotation-aware).
27
+ * @param props.onEscape Called when Escape is pressed on a resize handle.
28
+ * @return The rectangle stencil element.
29
+ */
30
+ export declare function RectangleStencil({ cropRect, containerSize, imageSize, onCropChange, onResizeStart, onResizeEnd, aspectRatio, freeformCrop, stencilTransition, cropBounds, onEscape, }: RectangleStencilProps): import("react").JSX.Element | null;
31
+ export {};
32
+ //# sourceMappingURL=rectangle-stencil.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rectangle-stencil.d.ts","sourceRoot":"","sources":["../../../../../src/image-editor/react/components/stencils/rectangle-stencil.tsx"],"names":[],"mappings":"AAMA;;GAEG;AACH,OAAO,KAAK,EAAE,YAAY,EAAkB,MAAM,qBAAqB,CAAC;AAmExE;;GAEG;AACH,KAAK,qBAAqB,GAAG,YAAY,CAAC;AAE1C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,gBAAgB,CAAE,EACjC,QAAQ,EACR,aAAa,EACb,SAAS,EACT,YAAY,EACZ,aAAa,EACb,WAAW,EACX,WAAW,EACX,YAAoB,EACpB,iBAAiB,EACjB,UAAU,EACV,QAAQ,GACR,EAAE,qBAAqB,sCA8YvB"}
@@ -0,0 +1,3 @@
1
+ export { useCropperState } from './use-cropper-state';
2
+ export type { UseCropperStateReturn } from './use-cropper-state';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/image-editor/react/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,YAAY,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import type { CropperState } from '../../core/types';
5
+ /**
6
+ * Debounce and dedupe ARIA-live announcements for screen readers as the
7
+ * cropper state changes. Returns the current announcement message to render
8
+ * inside an `aria-live="polite"` region.
9
+ *
10
+ * Debouncing avoids flooding the live region during drag/pointermove bursts;
11
+ * deduping avoids re-announcing the same state.
12
+ *
13
+ * @param state The current cropper state to announce.
14
+ */
15
+ export declare function useAriaAnnouncer(state: CropperState): string;
16
+ //# sourceMappingURL=use-aria-announcer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-aria-announcer.d.ts","sourceRoot":"","sources":["../../../../src/image-editor/react/hooks/use-aria-announcer.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAkBrD;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAE,KAAK,EAAE,YAAY,GAAI,MAAM,CA2B9D"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import type { CropperState, TransformOperation, NormalizedPoint, NormalizedRect, Flip } from '../../core/types';
5
+ /**
6
+ * The return type of the useCropperState hook.
7
+ *
8
+ * The hook exposes its state through named setter methods rather
9
+ * than a raw dispatch function. Each setter has a specific
10
+ * behavioral contract (see individual JSDoc) that maps 1:1 to a
11
+ * reducer action internally. Keeping the reducer actions private
12
+ * lets the implementation evolve without breaking consumers.
13
+ */
14
+ export interface UseCropperStateReturn {
15
+ /** The current cropper state (read-only). */
16
+ state: CropperState;
17
+ /** Set the loaded image (natural size and src). */
18
+ setImage: (image: CropperState['image']) => void;
19
+ /**
20
+ * Set the image pan offset in normalized coordinates. Use
21
+ * `setCropRect` for the crop rectangle.
22
+ */
23
+ setPan: (pan: NormalizedPoint) => void;
24
+ /** Set the zoom level. Clamped to [1, 10]. */
25
+ setZoom: (zoom: number) => void;
26
+ /** Set zoom and pan together so focal-point zoom remains atomic. */
27
+ setZoomAtPoint: (zoom: number, pan: NormalizedPoint) => void;
28
+ /** Set the rotation in degrees. Normalized to [0, 360). */
29
+ setRotation: (rotation: number) => void;
30
+ /** Set the flip state. */
31
+ setFlip: (flip: Flip) => void;
32
+ /** Snap rotate 90° preserving the image selection (Google Photos style). */
33
+ snapRotate90: (direction: 1 | -1) => void;
34
+ /** Set the crop rectangle in normalized coordinates. */
35
+ setCropRect: (rect: NormalizedRect) => void;
36
+ /**
37
+ * Settle the crop rect after a resize drag: expand to fill the
38
+ * available visual area while preserving the framed image region.
39
+ * Typically called from a stencil's `onResizeEnd` callback.
40
+ */
41
+ settleCrop: () => void;
42
+ /** Apply a transform operation through the pipeline. */
43
+ applyOperation: (op: TransformOperation) => void;
44
+ /** Reset the state. Optionally merge partial state overrides. */
45
+ reset: (resetState?: Partial<CropperState>) => void;
46
+ /** Whether the current state differs from the initial state. */
47
+ isDirty: boolean;
48
+ /**
49
+ * Export the cropped image as a Blob. Throws on failure — see
50
+ * `exportCroppedImage` in core for the error semantics (image
51
+ * load errors, CORS taint, missing canvas context). Wrap in
52
+ * try/catch if you need to recover.
53
+ */
54
+ getCroppedImage: (mimeType?: string, quality?: number) => Promise<Blob>;
55
+ }
56
+ /**
57
+ * Reducer-based state management hook for the image editor.
58
+ *
59
+ * Provides the full cropper state and named setter methods for
60
+ * every supported transition. The reducer and containment logic
61
+ * live in core/state.ts (framework-agnostic); this hook is a thin
62
+ * React wrapper around that pure reducer, with memoized callbacks.
63
+ *
64
+ * @param initialState Optional partial state to merge with DEFAULT_STATE.
65
+ * @return The cropper state, setters, and utilities.
66
+ */
67
+ export declare function useCropperState(initialState?: Partial<CropperState>): UseCropperStateReturn;
68
+ //# sourceMappingURL=use-cropper-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-cropper-state.d.ts","sourceRoot":"","sources":["../../../../src/image-editor/react/hooks/use-cropper-state.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,KAAK,EACX,YAAY,EACZ,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,IAAI,EACJ,MAAM,kBAAkB,CAAC;AAS1B;;;;;;;;GAQG;AACH,MAAM,WAAW,qBAAqB;IACrC,6CAA6C;IAC7C,KAAK,EAAE,YAAY,CAAC;IACpB,mDAAmD;IACnD,QAA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, Size } from '../../core/types';
5
+ import { type CropperInteractionActions } from '../../core/interaction-controller';
6
+ /**
7
+ * The return type of the useInteraction hook.
8
+ */
9
+ export interface UseInteractionReturn {
10
+ /** Event handler props to spread on the container element. */
11
+ handlers: {
12
+ onPointerDown: (e: React.PointerEvent) => void;
13
+ onTouchStart: (e: React.TouchEvent) => void;
14
+ onKeyDown: (e: React.KeyboardEvent) => void;
15
+ };
16
+ /** Native wheel handler — must be registered with { passive: false }. */
17
+ onWheelNative: (e: WheelEvent) => void;
18
+ /** Whether a drag (pan) interaction is in progress. */
19
+ isDragging: boolean;
20
+ /** Whether a double-tap zoom animation is in progress. */
21
+ isZooming: boolean;
22
+ /** Whether the user is currently performing a placement interaction. */
23
+ isPlacementActive: boolean;
24
+ }
25
+ /**
26
+ * Options for the useInteraction hook.
27
+ */
28
+ export interface UseInteractionOptions {
29
+ /** Minimum zoom level. Defaults to MIN_ZOOM. */
30
+ minZoom?: number;
31
+ /** Maximum zoom level. Defaults to MAX_ZOOM. */
32
+ maxZoom?: number;
33
+ /** Zoom speed multiplier for wheel events. Defaults to 0.01. */
34
+ zoomSpeed?: number;
35
+ /** Pan step size in normalized coords for keyboard events. Defaults to 0.05. */
36
+ keyboardStep?: number;
37
+ /** Zoom level for double-tap zoom. Defaults to 2. */
38
+ doubleTapZoom?: number;
39
+ /** Fires when a continuous gesture begins (pan drag, pinch zoom). */
40
+ onGestureStart?: () => void;
41
+ /** Fires when a continuous gesture ends (pointer release). */
42
+ onGestureEnd?: () => void;
43
+ }
44
+ /**
45
+ * Mouse, touch, and keyboard event handling for pan, zoom,
46
+ * and crop manipulation.
47
+ *
48
+ * Returns event handler props to spread on the container element.
49
+ * Uses requestAnimationFrame for drag/pinch updates to avoid
50
+ * layout thrashing.
51
+ *
52
+ * @param state The current cropper state.
53
+ * @param actions Named state updates for cropper interactions.
54
+ * @param containerSize The container dimensions in pixels.
55
+ * @param imageSize The rendered image dimensions in pixels.
56
+ * @param options Optional configuration for zoom and keyboard behavior.
57
+ * @return Event handler props for the container element.
58
+ */
59
+ export declare function useInteraction(state: CropperState, actions: CropperInteractionActions, containerSize: Size, imageSize?: Size, options?: UseInteractionOptions): UseInteractionReturn;
60
+ //# sourceMappingURL=use-interaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-interaction.d.ts","sourceRoot":"","sources":["../../../../src/image-editor/react/hooks/use-interaction.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAEN,KAAK,yBAAyB,EAC9B,MAAM,mCAAmC,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC,8DAA8D;IAC9D,QAAQ,EAAE;QACT,aAAa,EAAE,CAAE,CAAC,EAAE,KAAK,CAAC,YAAY,KAAM,IAAI,CAAC;QACjD,YAAY,EAAE,CAAE,CAAC,EAAE,KAAK,CAAC,UAAU,KAAM,IAAI,CAAC;QAC9C,SAAS,EAAE,CAAE,CAAC,EAAE,KAAK,CAAC,aAAa,KAAM,IAAI,CAAC;KAC9C,CAAC;IACF,yEAAyE;IACzE,aAAa,EAAE,CAAE,CAAC,EAAE,UAAU,KAAM,IAAI,CAAC;IACzC,uDAAuD;IACvD,UAAU,EAAE,OAAO,CAAC;IACpB,0DAA0D;IAC1D,SAAS,EAAE,OAAO,CAAC;IACnB,wEAAwE;IACxE,iBAAiB,EAAE,OAAO,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACrC,gDAAgD;IAChD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gDAAgD;IAChD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gEAAgE;IAChE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gFAAgF;IAChF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qDAAqD;IACrD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qEAAqE;IACrE,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,8DAA8D;IAC9D,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;CAC1B;AAiBD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAC7B,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,yBAAyB,EAClC,aAAa,EAAE,IAAI,EACnB,SAAS,CAAC,EAAE,IAAI,EAChB,OAAO,CAAC,EAAE,qBAAqB,GAC7B,oBAAoB,CAoItB"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import type { CropperState, Size } from '../../core/types';
5
+ /**
6
+ * React hook that computes a memoized CSS matrix() transform string
7
+ * from the cropper state.
8
+ *
9
+ * Delegates to the pure `computeTransformStyle` function in core.
10
+ *
11
+ * @param state The current cropper state.
12
+ * @param imageSize The rendered image dimensions in pixels.
13
+ * @return A CSS transform string.
14
+ */
15
+ export declare function useTransformStyle(state: CropperState, imageSize: Size): string;
16
+ //# sourceMappingURL=use-transform-style.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-transform-style.d.ts","sourceRoot":"","sources":["../../../../src/image-editor/react/hooks/use-transform-style.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAG3D;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAChC,KAAK,EAAE,YAAY,EACnB,SAAS,EAAE,IAAI,GACb,MAAM,CAKR"}