@wordpress/media-editor 0.7.1-next.v.202604201441.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 (300) 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/image-editor/core/camera.cjs +194 -0
  12. package/build/image-editor/core/camera.cjs.map +7 -0
  13. package/build/image-editor/core/constants.cjs +81 -0
  14. package/build/image-editor/core/constants.cjs.map +7 -0
  15. package/build/image-editor/core/containment.cjs +245 -0
  16. package/build/image-editor/core/containment.cjs.map +7 -0
  17. package/build/image-editor/core/export/canvas-renderer.cjs +151 -0
  18. package/build/image-editor/core/export/canvas-renderer.cjs.map +7 -0
  19. package/build/image-editor/core/index.cjs +50 -0
  20. package/build/image-editor/core/index.cjs.map +7 -0
  21. package/build/image-editor/core/interaction-controller.cjs +608 -0
  22. package/build/image-editor/core/interaction-controller.cjs.map +7 -0
  23. package/build/image-editor/core/math/rotation.cjs +41 -0
  24. package/build/image-editor/core/math/rotation.cjs.map +7 -0
  25. package/build/image-editor/core/source-region.cjs +95 -0
  26. package/build/image-editor/core/source-region.cjs.map +7 -0
  27. package/build/image-editor/core/state.cjs +269 -0
  28. package/build/image-editor/core/state.cjs.map +7 -0
  29. package/build/image-editor/core/stencil-math.cjs +197 -0
  30. package/build/image-editor/core/stencil-math.cjs.map +7 -0
  31. package/build/image-editor/core/transform-style.cjs +46 -0
  32. package/build/image-editor/core/transform-style.cjs.map +7 -0
  33. package/build/image-editor/core/transforms/pipeline.cjs +43 -0
  34. package/build/image-editor/core/transforms/pipeline.cjs.map +7 -0
  35. package/build/image-editor/core/types.cjs +19 -0
  36. package/build/image-editor/core/types.cjs.map +7 -0
  37. package/build/image-editor/index.cjs +57 -0
  38. package/build/image-editor/index.cjs.map +7 -0
  39. package/build/image-editor/react/components/cropper-provider.cjs +50 -0
  40. package/build/image-editor/react/components/cropper-provider.cjs.map +7 -0
  41. package/build/image-editor/react/components/cropper.cjs +365 -0
  42. package/build/image-editor/react/components/cropper.cjs.map +7 -0
  43. package/build/image-editor/react/components/index.cjs +36 -0
  44. package/build/image-editor/react/components/index.cjs.map +7 -0
  45. package/build/image-editor/react/components/overlays/dimming-overlay.cjs +58 -0
  46. package/build/image-editor/react/components/overlays/dimming-overlay.cjs.map +7 -0
  47. package/build/image-editor/react/components/overlays/grid-overlay.cjs +91 -0
  48. package/build/image-editor/react/components/overlays/grid-overlay.cjs.map +7 -0
  49. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs +351 -0
  50. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +7 -0
  51. package/build/image-editor/react/hooks/index.cjs +31 -0
  52. package/build/image-editor/react/hooks/index.cjs.map +7 -0
  53. package/build/image-editor/react/hooks/use-aria-announcer.cjs +68 -0
  54. package/build/image-editor/react/hooks/use-aria-announcer.cjs.map +7 -0
  55. package/build/image-editor/react/hooks/use-cropper-state.cjs +158 -0
  56. package/build/image-editor/react/hooks/use-cropper-state.cjs.map +7 -0
  57. package/build/image-editor/react/hooks/use-interaction.cjs +161 -0
  58. package/build/image-editor/react/hooks/use-interaction.cjs.map +7 -0
  59. package/build/image-editor/react/hooks/use-transform-style.cjs +38 -0
  60. package/build/image-editor/react/hooks/use-transform-style.cjs.map +7 -0
  61. package/build/index.cjs +5 -2
  62. package/build/index.cjs.map +2 -2
  63. package/build/lock-unlock.cjs +37 -0
  64. package/build/lock-unlock.cjs.map +7 -0
  65. package/build/private-apis.cjs +38 -0
  66. package/build/private-apis.cjs.map +7 -0
  67. package/build/store/actions.cjs +45 -0
  68. package/build/store/actions.cjs.map +7 -0
  69. package/build/store/constants.cjs +31 -0
  70. package/build/store/constants.cjs.map +7 -0
  71. package/build/store/index.cjs +51 -0
  72. package/build/store/index.cjs.map +7 -0
  73. package/build/store/reducer.cjs +51 -0
  74. package/build/store/reducer.cjs.map +7 -0
  75. package/build/store/selectors.cjs +43 -0
  76. package/build/store/selectors.cjs.map +7 -0
  77. package/build-module/components/media-editor-canvas/index.mjs +33 -0
  78. package/build-module/components/media-editor-canvas/index.mjs.map +7 -0
  79. package/build-module/components/media-editor-crop-panel/index.mjs +100 -0
  80. package/build-module/components/media-editor-crop-panel/index.mjs.map +7 -0
  81. package/build-module/components/media-editor-modal/build-modifiers.mjs +66 -0
  82. package/build-module/components/media-editor-modal/build-modifiers.mjs.map +7 -0
  83. package/build-module/components/media-editor-modal/index.mjs +483 -0
  84. package/build-module/components/media-editor-modal/index.mjs.map +7 -0
  85. package/build-module/components/media-editor-toolbar/index.mjs +130 -0
  86. package/build-module/components/media-editor-toolbar/index.mjs.map +7 -0
  87. package/build-module/image-editor/core/camera.mjs +163 -0
  88. package/build-module/image-editor/core/camera.mjs.map +7 -0
  89. package/build-module/image-editor/core/constants.mjs +51 -0
  90. package/build-module/image-editor/core/constants.mjs.map +7 -0
  91. package/build-module/image-editor/core/containment.mjs +218 -0
  92. package/build-module/image-editor/core/containment.mjs.map +7 -0
  93. package/build-module/image-editor/core/export/canvas-renderer.mjs +120 -0
  94. package/build-module/image-editor/core/export/canvas-renderer.mjs.map +7 -0
  95. package/build-module/image-editor/core/index.mjs +24 -0
  96. package/build-module/image-editor/core/index.mjs.map +7 -0
  97. package/build-module/image-editor/core/interaction-controller.mjs +583 -0
  98. package/build-module/image-editor/core/interaction-controller.mjs.map +7 -0
  99. package/build-module/image-editor/core/math/rotation.mjs +15 -0
  100. package/build-module/image-editor/core/math/rotation.mjs.map +7 -0
  101. package/build-module/image-editor/core/source-region.mjs +69 -0
  102. package/build-module/image-editor/core/source-region.mjs.map +7 -0
  103. package/build-module/image-editor/core/state.mjs +242 -0
  104. package/build-module/image-editor/core/state.mjs.map +7 -0
  105. package/build-module/image-editor/core/stencil-math.mjs +169 -0
  106. package/build-module/image-editor/core/stencil-math.mjs.map +7 -0
  107. package/build-module/image-editor/core/transform-style.mjs +21 -0
  108. package/build-module/image-editor/core/transform-style.mjs.map +7 -0
  109. package/build-module/image-editor/core/transforms/pipeline.mjs +17 -0
  110. package/build-module/image-editor/core/transforms/pipeline.mjs.map +7 -0
  111. package/build-module/image-editor/core/types.mjs +1 -0
  112. package/build-module/image-editor/core/types.mjs.map +7 -0
  113. package/build-module/image-editor/index.mjs +30 -0
  114. package/build-module/image-editor/index.mjs.map +7 -0
  115. package/build-module/image-editor/react/components/cropper-provider.mjs +26 -0
  116. package/build-module/image-editor/react/components/cropper-provider.mjs.map +7 -0
  117. package/build-module/image-editor/react/components/cropper.mjs +337 -0
  118. package/build-module/image-editor/react/components/cropper.mjs.map +7 -0
  119. package/build-module/image-editor/react/components/index.mjs +9 -0
  120. package/build-module/image-editor/react/components/index.mjs.map +7 -0
  121. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs +33 -0
  122. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs.map +7 -0
  123. package/build-module/image-editor/react/components/overlays/grid-overlay.mjs +66 -0
  124. package/build-module/image-editor/react/components/overlays/grid-overlay.mjs.map +7 -0
  125. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs +330 -0
  126. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs.map +7 -0
  127. package/build-module/image-editor/react/hooks/index.mjs +6 -0
  128. package/build-module/image-editor/react/hooks/index.mjs.map +7 -0
  129. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs +43 -0
  130. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs.map +7 -0
  131. package/build-module/image-editor/react/hooks/use-cropper-state.mjs +137 -0
  132. package/build-module/image-editor/react/hooks/use-cropper-state.mjs.map +7 -0
  133. package/build-module/image-editor/react/hooks/use-interaction.mjs +138 -0
  134. package/build-module/image-editor/react/hooks/use-interaction.mjs.map +7 -0
  135. package/build-module/image-editor/react/hooks/use-transform-style.mjs +13 -0
  136. package/build-module/image-editor/react/hooks/use-transform-style.mjs.map +7 -0
  137. package/build-module/index.mjs +3 -1
  138. package/build-module/index.mjs.map +2 -2
  139. package/build-module/lock-unlock.mjs +11 -0
  140. package/build-module/lock-unlock.mjs.map +7 -0
  141. package/build-module/private-apis.mjs +13 -0
  142. package/build-module/private-apis.mjs.map +7 -0
  143. package/build-module/store/actions.mjs +19 -0
  144. package/build-module/store/actions.mjs.map +7 -0
  145. package/build-module/store/constants.mjs +6 -0
  146. package/build-module/store/constants.mjs.map +7 -0
  147. package/build-module/store/index.mjs +16 -0
  148. package/build-module/store/index.mjs.map +7 -0
  149. package/build-module/store/reducer.mjs +26 -0
  150. package/build-module/store/reducer.mjs.map +7 -0
  151. package/build-module/store/selectors.mjs +16 -0
  152. package/build-module/store/selectors.mjs.map +7 -0
  153. package/build-style/style-rtl.css +315 -0
  154. package/build-style/style.css +315 -0
  155. package/build-types/components/media-editor-canvas/index.d.ts +22 -0
  156. package/build-types/components/media-editor-canvas/index.d.ts.map +1 -0
  157. package/build-types/components/media-editor-crop-panel/index.d.ts +45 -0
  158. package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -0
  159. package/build-types/components/media-editor-modal/build-modifiers.d.ts +83 -0
  160. package/build-types/components/media-editor-modal/build-modifiers.d.ts.map +1 -0
  161. package/build-types/components/media-editor-modal/index.d.ts +20 -0
  162. package/build-types/components/media-editor-modal/index.d.ts.map +1 -0
  163. package/build-types/components/media-editor-toolbar/index.d.ts +21 -0
  164. package/build-types/components/media-editor-toolbar/index.d.ts.map +1 -0
  165. package/build-types/image-editor/core/camera.d.ts +107 -0
  166. package/build-types/image-editor/core/camera.d.ts.map +1 -0
  167. package/build-types/image-editor/core/constants.d.ts +46 -0
  168. package/build-types/image-editor/core/constants.d.ts.map +1 -0
  169. package/build-types/image-editor/core/containment.d.ts +61 -0
  170. package/build-types/image-editor/core/containment.d.ts.map +1 -0
  171. package/build-types/image-editor/core/export/canvas-renderer.d.ts +106 -0
  172. package/build-types/image-editor/core/export/canvas-renderer.d.ts.map +1 -0
  173. package/build-types/image-editor/core/index.d.ts +8 -0
  174. package/build-types/image-editor/core/index.d.ts.map +1 -0
  175. package/build-types/image-editor/core/interaction-controller.d.ts +178 -0
  176. package/build-types/image-editor/core/interaction-controller.d.ts.map +1 -0
  177. package/build-types/image-editor/core/math/rotation.d.ts +18 -0
  178. package/build-types/image-editor/core/math/rotation.d.ts.map +1 -0
  179. package/build-types/image-editor/core/source-region.d.ts +75 -0
  180. package/build-types/image-editor/core/source-region.d.ts.map +1 -0
  181. package/build-types/image-editor/core/state.d.ts +42 -0
  182. package/build-types/image-editor/core/state.d.ts.map +1 -0
  183. package/build-types/image-editor/core/stencil-math.d.ts +79 -0
  184. package/build-types/image-editor/core/stencil-math.d.ts.map +1 -0
  185. package/build-types/image-editor/core/transform-style.d.ts +23 -0
  186. package/build-types/image-editor/core/transform-style.d.ts.map +1 -0
  187. package/build-types/image-editor/core/transforms/pipeline.d.ts +27 -0
  188. package/build-types/image-editor/core/transforms/pipeline.d.ts.map +1 -0
  189. package/build-types/image-editor/core/types.d.ts +211 -0
  190. package/build-types/image-editor/core/types.d.ts.map +1 -0
  191. package/build-types/image-editor/index.d.ts +16 -0
  192. package/build-types/image-editor/index.d.ts.map +1 -0
  193. package/build-types/image-editor/react/components/cropper-provider.d.ts +37 -0
  194. package/build-types/image-editor/react/components/cropper-provider.d.ts.map +1 -0
  195. package/build-types/image-editor/react/components/cropper.d.ts +59 -0
  196. package/build-types/image-editor/react/components/cropper.d.ts.map +1 -0
  197. package/build-types/image-editor/react/components/index.d.ts +4 -0
  198. package/build-types/image-editor/react/components/index.d.ts.map +1 -0
  199. package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts +30 -0
  200. package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts.map +1 -0
  201. package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts +30 -0
  202. package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts.map +1 -0
  203. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts +32 -0
  204. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts.map +1 -0
  205. package/build-types/image-editor/react/hooks/index.d.ts +3 -0
  206. package/build-types/image-editor/react/hooks/index.d.ts.map +1 -0
  207. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts +16 -0
  208. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts.map +1 -0
  209. package/build-types/image-editor/react/hooks/use-cropper-state.d.ts +68 -0
  210. package/build-types/image-editor/react/hooks/use-cropper-state.d.ts.map +1 -0
  211. package/build-types/image-editor/react/hooks/use-interaction.d.ts +60 -0
  212. package/build-types/image-editor/react/hooks/use-interaction.d.ts.map +1 -0
  213. package/build-types/image-editor/react/hooks/use-transform-style.d.ts +16 -0
  214. package/build-types/image-editor/react/hooks/use-transform-style.d.ts.map +1 -0
  215. package/build-types/image-editor/stories/rectangle-crop.story.d.ts +16 -0
  216. package/build-types/image-editor/stories/rectangle-crop.story.d.ts.map +1 -0
  217. package/build-types/index.d.ts +1 -0
  218. package/build-types/index.d.ts.map +1 -1
  219. package/build-types/lock-unlock.d.ts +2 -0
  220. package/build-types/lock-unlock.d.ts.map +1 -0
  221. package/build-types/private-apis.d.ts +2 -0
  222. package/build-types/private-apis.d.ts.map +1 -0
  223. package/build-types/store/actions.d.ts +27 -0
  224. package/build-types/store/actions.d.ts.map +1 -0
  225. package/build-types/store/constants.d.ts +2 -0
  226. package/build-types/store/constants.d.ts.map +1 -0
  227. package/build-types/store/index.d.ts +4 -0
  228. package/build-types/store/index.d.ts.map +1 -0
  229. package/build-types/store/reducer.d.ts +23 -0
  230. package/build-types/store/reducer.d.ts.map +1 -0
  231. package/build-types/store/selectors.d.ts +8 -0
  232. package/build-types/store/selectors.d.ts.map +1 -0
  233. package/package.json +21 -7
  234. package/src/components/media-editor-canvas/index.tsx +56 -0
  235. package/src/components/media-editor-canvas/style.scss +9 -0
  236. package/src/components/media-editor-crop-panel/index.tsx +143 -0
  237. package/src/components/media-editor-modal/build-modifiers.ts +164 -0
  238. package/src/components/media-editor-modal/index.tsx +639 -0
  239. package/src/components/media-editor-modal/style.scss +139 -0
  240. package/src/components/media-editor-modal/test/build-modifiers.test.ts +343 -0
  241. package/src/components/media-editor-toolbar/index.tsx +150 -0
  242. package/src/components/media-editor-toolbar/style.scss +21 -0
  243. package/src/image-editor/README.md +162 -0
  244. package/src/image-editor/core/camera.ts +352 -0
  245. package/src/image-editor/core/constants.ts +93 -0
  246. package/src/image-editor/core/containment.ts +435 -0
  247. package/src/image-editor/core/export/canvas-renderer.ts +253 -0
  248. package/src/image-editor/core/export/test/canvas-renderer.ts +813 -0
  249. package/src/image-editor/core/index.ts +35 -0
  250. package/src/image-editor/core/interaction-controller.ts +889 -0
  251. package/src/image-editor/core/math/rotation.ts +26 -0
  252. package/src/image-editor/core/source-region.ts +166 -0
  253. package/src/image-editor/core/state.ts +428 -0
  254. package/src/image-editor/core/stencil-math.ts +330 -0
  255. package/src/image-editor/core/test/camera.ts +593 -0
  256. package/src/image-editor/core/test/interaction-controller.ts +996 -0
  257. package/src/image-editor/core/test/preview-export-parity.ts +242 -0
  258. package/src/image-editor/core/test/render-camera-bridge.ts +348 -0
  259. package/src/image-editor/core/test/state.ts +762 -0
  260. package/src/image-editor/core/test/stencil-math.ts +321 -0
  261. package/src/image-editor/core/transform-style.ts +44 -0
  262. package/src/image-editor/core/transforms/pipeline.ts +43 -0
  263. package/src/image-editor/core/transforms/test/pipeline.ts +269 -0
  264. package/src/image-editor/core/types.ts +177 -0
  265. package/src/image-editor/docs/architecture.md +96 -0
  266. package/src/image-editor/docs/recipes.md +720 -0
  267. package/src/image-editor/docs/roadmap.md +66 -0
  268. package/src/image-editor/index.ts +43 -0
  269. package/src/image-editor/react/components/cropper-provider.tsx +73 -0
  270. package/src/image-editor/react/components/cropper.scss +195 -0
  271. package/src/image-editor/react/components/cropper.tsx +534 -0
  272. package/src/image-editor/react/components/index.ts +3 -0
  273. package/src/image-editor/react/components/overlays/dimming-overlay.tsx +57 -0
  274. package/src/image-editor/react/components/overlays/grid-overlay.tsx +80 -0
  275. package/src/image-editor/react/components/stencils/rectangle-stencil.tsx +513 -0
  276. package/src/image-editor/react/components/stencils/test/rectangle-stencil.tsx +265 -0
  277. package/src/image-editor/react/components/test/cropper.tsx +140 -0
  278. package/src/image-editor/react/hooks/index.ts +2 -0
  279. package/src/image-editor/react/hooks/test/use-cropper-state.ts +913 -0
  280. package/src/image-editor/react/hooks/test/use-interaction.ts +218 -0
  281. package/src/image-editor/react/hooks/test/use-transform-style.ts +146 -0
  282. package/src/image-editor/react/hooks/use-aria-announcer.ts +64 -0
  283. package/src/image-editor/react/hooks/use-cropper-state.ts +238 -0
  284. package/src/image-editor/react/hooks/use-interaction.ts +223 -0
  285. package/src/image-editor/react/hooks/use-transform-style.ts +30 -0
  286. package/src/image-editor/stories/rectangle-crop.story.tsx +1085 -0
  287. package/src/image-editor/stories/style.css +94 -0
  288. package/src/image-editor/style.scss +1 -0
  289. package/src/index.ts +3 -0
  290. package/src/lock-unlock.ts +10 -0
  291. package/src/private-apis.ts +12 -0
  292. package/src/store/actions.ts +33 -0
  293. package/src/store/constants.ts +1 -0
  294. package/src/store/index.ts +20 -0
  295. package/src/store/reducer.ts +48 -0
  296. package/src/store/selectors.ts +16 -0
  297. package/src/store/test/reducer.ts +57 -0
  298. package/src/style.scss +4 -0
  299. package/tsconfig.json +10 -2
  300. package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/image-editor/react/hooks/use-cropper-state.ts"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useReducer, useCallback, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tCropperState,\n\tTransformOperation,\n\tNormalizedPoint,\n\tNormalizedRect,\n\tFlip,\n} from '../../core/types';\nimport { DEFAULT_STATE } from '../../core/constants';\nimport { exportCroppedImage } from '../../core/export/canvas-renderer';\nimport {\n\tcropperReducer,\n\tenforceContainment,\n\tisStateDirty,\n} from '../../core/state';\n\n/**\n * The return type of the useCropperState hook.\n *\n * The hook exposes its state through named setter methods rather\n * than a raw dispatch function. Each setter has a specific\n * behavioral contract (see individual JSDoc) that maps 1:1 to a\n * reducer action internally. Keeping the reducer actions private\n * lets the implementation evolve without breaking consumers.\n */\nexport interface UseCropperStateReturn {\n\t/** The current cropper state (read-only). */\n\tstate: CropperState;\n\t/** Set the loaded image (natural size and src). */\n\tsetImage: ( image: CropperState[ 'image' ] ) => void;\n\t/**\n\t * Set the image pan offset in normalized coordinates. Use\n\t * `setCropRect` for the crop rectangle.\n\t */\n\tsetPan: ( pan: NormalizedPoint ) => void;\n\t/** Set the zoom level. Clamped to [1, 10]. */\n\tsetZoom: ( zoom: number ) => void;\n\t/** Set zoom and pan together so focal-point zoom remains atomic. */\n\tsetZoomAtPoint: ( zoom: number, pan: NormalizedPoint ) => void;\n\t/** Set the rotation in degrees. Normalized to [0, 360). */\n\tsetRotation: ( rotation: number ) => void;\n\t/** Set the flip state. */\n\tsetFlip: ( flip: Flip ) => void;\n\t/** Snap rotate 90\u00B0 preserving the image selection (Google Photos style). */\n\tsnapRotate90: ( direction: 1 | -1 ) => void;\n\t/** Set the crop rectangle in normalized coordinates. */\n\tsetCropRect: ( rect: NormalizedRect ) => void;\n\t/**\n\t * Settle the crop rect after a resize drag: expand to fill the\n\t * available visual area while preserving the framed image region.\n\t * Typically called from a stencil's `onResizeEnd` callback.\n\t */\n\tsettleCrop: () => void;\n\t/** Apply a transform operation through the pipeline. */\n\tapplyOperation: ( op: TransformOperation ) => void;\n\t/** Reset the state. Optionally merge partial state overrides. */\n\treset: ( resetState?: Partial< CropperState > ) => void;\n\t/** Whether the current state differs from the initial state. */\n\tisDirty: boolean;\n\t/**\n\t * Export the cropped image as a Blob. Throws on failure \u2014 see\n\t * `exportCroppedImage` in core for the error semantics (image\n\t * load errors, CORS taint, missing canvas context). Wrap in\n\t * try/catch if you need to recover.\n\t */\n\tgetCroppedImage: ( mimeType?: string, quality?: number ) => Promise< Blob >;\n}\n\n/**\n * Reducer-based state management hook for the image editor.\n *\n * Provides the full cropper state and named setter methods for\n * every supported transition. The reducer and containment logic\n * live in core/state.ts (framework-agnostic); this hook is a thin\n * React wrapper around that pure reducer, with memoized callbacks.\n *\n * @param initialState Optional partial state to merge with DEFAULT_STATE.\n * @return The cropper state, setters, and utilities.\n */\nexport function useCropperState(\n\tinitialState?: Partial< CropperState >\n): UseCropperStateReturn {\n\tconst [ state, dispatch ] = useReducer(\n\t\tcropperReducer,\n\t\tinitialState,\n\t\t( init ) => enforceContainment( { ...DEFAULT_STATE, ...init } )\n\t);\n\n\tconst initialRef = useRef< CropperState >(\n\t\tenforceContainment( { ...DEFAULT_STATE, ...initialState } )\n\t);\n\t// Keep a ref to the latest state so callbacks with stable identity\n\t// (reset, setImage) can read fresh state without re-creating themselves.\n\tconst stateRef = useRef( state );\n\tstateRef.current = state;\n\n\tconst setImage = useCallback(\n\t\t( image: CropperState[ 'image' ] ) => {\n\t\t\tdispatch( { type: 'SET_IMAGE', payload: image } );\n\t\t\t// Refresh the \"clean\" snapshot to match the post-load state\n\t\t\t// produced by the reducer. Otherwise containment can nudge\n\t\t\t// pan/zoom by tiny amounts on load and `isDirty` would\n\t\t\t// report true from the start.\n\t\t\tinitialRef.current = enforceContainment( {\n\t\t\t\t...initialRef.current,\n\t\t\t\timage,\n\t\t\t} );\n\t\t},\n\t\t[ dispatch ]\n\t);\n\n\tconst setPan = useCallback(\n\t\t( pan: NormalizedPoint ) => {\n\t\t\tdispatch( { type: 'SET_PAN', payload: pan } );\n\t\t},\n\t\t[ dispatch ]\n\t);\n\n\tconst setZoom = useCallback(\n\t\t( zoom: number ) => {\n\t\t\tdispatch( { type: 'SET_ZOOM', payload: zoom } );\n\t\t},\n\t\t[ dispatch ]\n\t);\n\n\tconst setZoomAtPoint = useCallback(\n\t\t( zoom: number, pan: NormalizedPoint ) => {\n\t\t\tdispatch( {\n\t\t\t\ttype: 'SET_ZOOM_AT_POINT',\n\t\t\t\tpayload: { zoom, pan },\n\t\t\t} );\n\t\t},\n\t\t[ dispatch ]\n\t);\n\n\tconst setRotation = useCallback(\n\t\t( rotation: number ) => {\n\t\t\tdispatch( { type: 'SET_ROTATION', payload: rotation } );\n\t\t},\n\t\t[ dispatch ]\n\t);\n\n\tconst setFlip = useCallback(\n\t\t( flip: Flip ) => {\n\t\t\tdispatch( { type: 'SET_FLIP', payload: flip } );\n\t\t},\n\t\t[ dispatch ]\n\t);\n\n\tconst snapRotate90 = useCallback(\n\t\t( direction: 1 | -1 ) => {\n\t\t\tdispatch( {\n\t\t\t\ttype: 'SNAP_ROTATE_90',\n\t\t\t\tpayload: { direction },\n\t\t\t} );\n\t\t},\n\t\t[ dispatch ]\n\t);\n\n\tconst setCropRect = useCallback(\n\t\t( rect: NormalizedRect ) => {\n\t\t\tdispatch( { type: 'SET_CROP_RECT', payload: rect } );\n\t\t},\n\t\t[ dispatch ]\n\t);\n\n\tconst settleCrop = useCallback( () => {\n\t\tdispatch( { type: 'SETTLE_CROP' } );\n\t}, [ dispatch ] );\n\n\tconst applyOperation = useCallback(\n\t\t( op: TransformOperation ) => {\n\t\t\tdispatch( { type: 'APPLY_OPERATION', payload: op } );\n\t\t},\n\t\t[ dispatch ]\n\t);\n\n\tconst reset = useCallback(\n\t\t( resetState?: Partial< CropperState > ) => {\n\t\t\tdispatch( { type: 'RESET', payload: resetState } );\n\t\t\t// Mirror the reducer's RESET exactly so isDirty stays in\n\t\t\t// sync. RESET preserves the currently-loaded image; the\n\t\t\t// containment step can tweak pan/zoom/cropRect by float ulp,\n\t\t\t// which we must fold into the \"initial\" snapshot or isDirty\n\t\t\t// would report true after a reset.\n\t\t\tinitialRef.current = enforceContainment( {\n\t\t\t\t...DEFAULT_STATE,\n\t\t\t\timage: stateRef.current.image,\n\t\t\t\t...resetState,\n\t\t\t} );\n\t\t},\n\t\t[ dispatch ]\n\t);\n\n\tconst isDirty = isStateDirty( state, initialRef.current );\n\n\tconst getCroppedImage = useCallback(\n\t\t( mimeType?: string, quality?: number ): Promise< Blob > => {\n\t\t\tif ( ! state.image ) {\n\t\t\t\treturn Promise.reject(\n\t\t\t\t\tnew Error( 'No image loaded \u2014 call setImage first.' )\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn exportCroppedImage(\n\t\t\t\tstate.image.src,\n\t\t\t\tstate,\n\t\t\t\tmimeType,\n\t\t\t\tquality\n\t\t\t);\n\t\t},\n\t\t[ state ]\n\t);\n\n\tconst controller: UseCropperStateReturn = {\n\t\tstate,\n\t\tsetImage,\n\t\tsetPan,\n\t\tsetZoom,\n\t\tsetZoomAtPoint,\n\t\tsetRotation,\n\t\tsetFlip,\n\t\tsnapRotate90,\n\t\tsetCropRect,\n\t\tsettleCrop,\n\t\tapplyOperation,\n\t\treset,\n\t\tisDirty,\n\t\tgetCroppedImage,\n\t};\n\treturn controller;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAgD;AAYhD,uBAA8B;AAC9B,6BAAmC;AACnC,mBAIO;AAiEA,SAAS,gBACf,cACwB;AACxB,QAAM,CAAE,OAAO,QAAS,QAAI;AAAA,IAC3B;AAAA,IACA;AAAA,IACA,CAAE,aAAU,iCAAoB,EAAE,GAAG,gCAAe,GAAG,KAAK,CAAE;AAAA,EAC/D;AAEA,QAAM,iBAAa;AAAA,QAClB,iCAAoB,EAAE,GAAG,gCAAe,GAAG,aAAa,CAAE;AAAA,EAC3D;AAGA,QAAM,eAAW,uBAAQ,KAAM;AAC/B,WAAS,UAAU;AAEnB,QAAM,eAAW;AAAA,IAChB,CAAE,UAAoC;AACrC,eAAU,EAAE,MAAM,aAAa,SAAS,MAAM,CAAE;AAKhD,iBAAW,cAAU,iCAAoB;AAAA,QACxC,GAAG,WAAW;AAAA,QACd;AAAA,MACD,CAAE;AAAA,IACH;AAAA,IACA,CAAE,QAAS;AAAA,EACZ;AAEA,QAAM,aAAS;AAAA,IACd,CAAE,QAA0B;AAC3B,eAAU,EAAE,MAAM,WAAW,SAAS,IAAI,CAAE;AAAA,IAC7C;AAAA,IACA,CAAE,QAAS;AAAA,EACZ;AAEA,QAAM,cAAU;AAAA,IACf,CAAE,SAAkB;AACnB,eAAU,EAAE,MAAM,YAAY,SAAS,KAAK,CAAE;AAAA,IAC/C;AAAA,IACA,CAAE,QAAS;AAAA,EACZ;AAEA,QAAM,qBAAiB;AAAA,IACtB,CAAE,MAAc,QAA0B;AACzC,eAAU;AAAA,QACT,MAAM;AAAA,QACN,SAAS,EAAE,MAAM,IAAI;AAAA,MACtB,CAAE;AAAA,IACH;AAAA,IACA,CAAE,QAAS;AAAA,EACZ;AAEA,QAAM,kBAAc;AAAA,IACnB,CAAE,aAAsB;AACvB,eAAU,EAAE,MAAM,gBAAgB,SAAS,SAAS,CAAE;AAAA,IACvD;AAAA,IACA,CAAE,QAAS;AAAA,EACZ;AAEA,QAAM,cAAU;AAAA,IACf,CAAE,SAAgB;AACjB,eAAU,EAAE,MAAM,YAAY,SAAS,KAAK,CAAE;AAAA,IAC/C;AAAA,IACA,CAAE,QAAS;AAAA,EACZ;AAEA,QAAM,mBAAe;AAAA,IACpB,CAAE,cAAuB;AACxB,eAAU;AAAA,QACT,MAAM;AAAA,QACN,SAAS,EAAE,UAAU;AAAA,MACtB,CAAE;AAAA,IACH;AAAA,IACA,CAAE,QAAS;AAAA,EACZ;AAEA,QAAM,kBAAc;AAAA,IACnB,CAAE,SAA0B;AAC3B,eAAU,EAAE,MAAM,iBAAiB,SAAS,KAAK,CAAE;AAAA,IACpD;AAAA,IACA,CAAE,QAAS;AAAA,EACZ;AAEA,QAAM,iBAAa,4BAAa,MAAM;AACrC,aAAU,EAAE,MAAM,cAAc,CAAE;AAAA,EACnC,GAAG,CAAE,QAAS,CAAE;AAEhB,QAAM,qBAAiB;AAAA,IACtB,CAAE,OAA4B;AAC7B,eAAU,EAAE,MAAM,mBAAmB,SAAS,GAAG,CAAE;AAAA,IACpD;AAAA,IACA,CAAE,QAAS;AAAA,EACZ;AAEA,QAAM,YAAQ;AAAA,IACb,CAAE,eAA0C;AAC3C,eAAU,EAAE,MAAM,SAAS,SAAS,WAAW,CAAE;AAMjD,iBAAW,cAAU,iCAAoB;AAAA,QACxC,GAAG;AAAA,QACH,OAAO,SAAS,QAAQ;AAAA,QACxB,GAAG;AAAA,MACJ,CAAE;AAAA,IACH;AAAA,IACA,CAAE,QAAS;AAAA,EACZ;AAEA,QAAM,cAAU,2BAAc,OAAO,WAAW,OAAQ;AAExD,QAAM,sBAAkB;AAAA,IACvB,CAAE,UAAmB,YAAuC;AAC3D,UAAK,CAAE,MAAM,OAAQ;AACpB,eAAO,QAAQ;AAAA,UACd,IAAI,MAAO,6CAAyC;AAAA,QACrD;AAAA,MACD;AACA,iBAAO;AAAA,QACN,MAAM,MAAM;AAAA,QACZ;AAAA,QACA;AAAA,QACA;AAAA,MACD;AAAA,IACD;AAAA,IACA,CAAE,KAAM;AAAA,EACT;AAEA,QAAM,aAAoC;AAAA,IACzC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACA,SAAO;AACR;",
6
+ "names": []
7
+ }
@@ -0,0 +1,161 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // packages/media-editor/src/image-editor/react/hooks/use-interaction.ts
21
+ var use_interaction_exports = {};
22
+ __export(use_interaction_exports, {
23
+ useInteraction: () => useInteraction
24
+ });
25
+ module.exports = __toCommonJS(use_interaction_exports);
26
+ var import_element = require("@wordpress/element");
27
+ var import_interaction_controller = require("../../core/interaction-controller.cjs");
28
+ var KEYBOARD_INTERACTION_IDLE_MS = 300;
29
+ function isHandledKeyboardPan(event) {
30
+ switch (event.key) {
31
+ case "ArrowUp":
32
+ case "ArrowDown":
33
+ case "ArrowLeft":
34
+ case "ArrowRight":
35
+ return true;
36
+ default:
37
+ return false;
38
+ }
39
+ }
40
+ function useInteraction(state, actions, containerSize, imageSize, options) {
41
+ const [isDragging, setIsDragging] = (0, import_element.useState)(false);
42
+ const [isZooming, setIsZooming] = (0, import_element.useState)(false);
43
+ const [isGestureActive, setIsGestureActive] = (0, import_element.useState)(false);
44
+ const [isKeyboardPanning, setIsKeyboardPanning] = (0, import_element.useState)(false);
45
+ const keyboardInteractionTimerRef = (0, import_element.useRef)();
46
+ const stateRef = (0, import_element.useRef)(state);
47
+ stateRef.current = state;
48
+ const containerSizeRef = (0, import_element.useRef)(containerSize);
49
+ containerSizeRef.current = containerSize;
50
+ const imageSizeRef = (0, import_element.useRef)(imageSize);
51
+ imageSizeRef.current = imageSize;
52
+ const optionsRef = (0, import_element.useRef)(options);
53
+ optionsRef.current = options;
54
+ const actionsRef = (0, import_element.useRef)(actions);
55
+ actionsRef.current = actions;
56
+ const controllerRef = (0, import_element.useRef)(null);
57
+ const startPlacementGesture = (0, import_element.useCallback)(() => {
58
+ setIsGestureActive(true);
59
+ }, []);
60
+ const stopPlacementGesture = (0, import_element.useCallback)(() => {
61
+ setIsGestureActive(false);
62
+ }, []);
63
+ const signalKeyboardPlacement = (0, import_element.useCallback)(() => {
64
+ setIsKeyboardPanning(true);
65
+ clearTimeout(keyboardInteractionTimerRef.current);
66
+ keyboardInteractionTimerRef.current = setTimeout(() => {
67
+ setIsKeyboardPanning(false);
68
+ }, KEYBOARD_INTERACTION_IDLE_MS);
69
+ }, []);
70
+ (0, import_element.useEffect)(() => {
71
+ return () => {
72
+ clearTimeout(keyboardInteractionTimerRef.current);
73
+ };
74
+ }, []);
75
+ (0, import_element.useEffect)(() => {
76
+ const controller = new import_interaction_controller.InteractionController({
77
+ getState: () => stateRef.current,
78
+ actions: {
79
+ setPan: (pan) => actionsRef.current.setPan(pan),
80
+ setZoom: (zoom) => actionsRef.current.setZoom(zoom),
81
+ setZoomAtPoint: (zoom, pan) => actionsRef.current.setZoomAtPoint(zoom, pan),
82
+ snapRotate90: (direction) => actionsRef.current.snapRotate90(direction)
83
+ },
84
+ getContainerSize: () => containerSizeRef.current,
85
+ getImageSize: () => imageSizeRef.current,
86
+ get minZoom() {
87
+ return optionsRef.current?.minZoom;
88
+ },
89
+ get maxZoom() {
90
+ return optionsRef.current?.maxZoom;
91
+ },
92
+ get zoomSpeed() {
93
+ return optionsRef.current?.zoomSpeed;
94
+ },
95
+ get keyboardStep() {
96
+ return optionsRef.current?.keyboardStep;
97
+ },
98
+ get doubleTapZoom() {
99
+ return optionsRef.current?.doubleTapZoom;
100
+ },
101
+ onGestureStart: () => {
102
+ startPlacementGesture();
103
+ optionsRef.current?.onGestureStart?.();
104
+ },
105
+ onGestureEnd: () => {
106
+ stopPlacementGesture();
107
+ optionsRef.current?.onGestureEnd?.();
108
+ },
109
+ onStatusChange: (status) => {
110
+ setIsDragging(status.isDragging);
111
+ setIsZooming(status.isZooming);
112
+ }
113
+ });
114
+ controllerRef.current = controller;
115
+ return () => {
116
+ controller.destroy();
117
+ controllerRef.current = null;
118
+ };
119
+ }, [startPlacementGesture, stopPlacementGesture]);
120
+ const onPointerDown = (0, import_element.useCallback)((e) => {
121
+ const el = e.currentTarget;
122
+ controllerRef.current?.handlePointerDown(e.nativeEvent, el);
123
+ }, []);
124
+ const onTouchStart = (0, import_element.useCallback)((e) => {
125
+ const el = e.currentTarget;
126
+ const rect = el.getBoundingClientRect();
127
+ controllerRef.current?.handleTouchStart(
128
+ e.nativeEvent,
129
+ rect,
130
+ el.ownerDocument
131
+ );
132
+ }, []);
133
+ const onKeyDown = (0, import_element.useCallback)(
134
+ (e) => {
135
+ if (isHandledKeyboardPan(e.nativeEvent)) {
136
+ signalKeyboardPlacement();
137
+ }
138
+ controllerRef.current?.handleKeyDown(e.nativeEvent);
139
+ },
140
+ [signalKeyboardPlacement]
141
+ );
142
+ const onWheelNative = (0, import_element.useCallback)((e) => {
143
+ controllerRef.current?.handleWheel(e);
144
+ }, []);
145
+ return {
146
+ handlers: {
147
+ onPointerDown,
148
+ onTouchStart,
149
+ onKeyDown
150
+ },
151
+ onWheelNative,
152
+ isDragging,
153
+ isZooming,
154
+ isPlacementActive: isGestureActive || isKeyboardPanning || isZooming
155
+ };
156
+ }
157
+ // Annotate the CommonJS export names for ESM import in node:
158
+ 0 && (module.exports = {
159
+ useInteraction
160
+ });
161
+ //# sourceMappingURL=use-interaction.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/image-editor/react/hooks/use-interaction.ts"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCallback, useEffect, useRef, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { CropperState, Size } from '../../core/types';\nimport {\n\tInteractionController,\n\ttype CropperInteractionActions,\n} from '../../core/interaction-controller';\n\n/**\n * The return type of the useInteraction hook.\n */\nexport interface UseInteractionReturn {\n\t/** Event handler props to spread on the container element. */\n\thandlers: {\n\t\tonPointerDown: ( e: React.PointerEvent ) => void;\n\t\tonTouchStart: ( e: React.TouchEvent ) => void;\n\t\tonKeyDown: ( e: React.KeyboardEvent ) => void;\n\t};\n\t/** Native wheel handler \u2014 must be registered with { passive: false }. */\n\tonWheelNative: ( e: WheelEvent ) => void;\n\t/** Whether a drag (pan) interaction is in progress. */\n\tisDragging: boolean;\n\t/** Whether a double-tap zoom animation is in progress. */\n\tisZooming: boolean;\n\t/** Whether the user is currently performing a placement interaction. */\n\tisPlacementActive: boolean;\n}\n\n/**\n * Options for the useInteraction hook.\n */\nexport interface UseInteractionOptions {\n\t/** Minimum zoom level. Defaults to MIN_ZOOM. */\n\tminZoom?: number;\n\t/** Maximum zoom level. Defaults to MAX_ZOOM. */\n\tmaxZoom?: number;\n\t/** Zoom speed multiplier for wheel events. Defaults to 0.01. */\n\tzoomSpeed?: number;\n\t/** Pan step size in normalized coords for keyboard events. Defaults to 0.05. */\n\tkeyboardStep?: number;\n\t/** Zoom level for double-tap zoom. Defaults to 2. */\n\tdoubleTapZoom?: number;\n\t/** Fires when a continuous gesture begins (pan drag, pinch zoom). */\n\tonGestureStart?: () => void;\n\t/** Fires when a continuous gesture ends (pointer release). */\n\tonGestureEnd?: () => void;\n}\n\n/** How long keyboard placement stays active after the latest handled key. */\nconst KEYBOARD_INTERACTION_IDLE_MS = 300;\n\nfunction isHandledKeyboardPan( event: KeyboardEvent ): boolean {\n\tswitch ( event.key ) {\n\t\tcase 'ArrowUp':\n\t\tcase 'ArrowDown':\n\t\tcase 'ArrowLeft':\n\t\tcase 'ArrowRight':\n\t\t\treturn true;\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\n/**\n * Mouse, touch, and keyboard event handling for pan, zoom,\n * and crop manipulation.\n *\n * Returns event handler props to spread on the container element.\n * Uses requestAnimationFrame for drag/pinch updates to avoid\n * layout thrashing.\n *\n * @param state The current cropper state.\n * @param actions Named state updates for cropper interactions.\n * @param containerSize The container dimensions in pixels.\n * @param imageSize The rendered image dimensions in pixels.\n * @param options Optional configuration for zoom and keyboard behavior.\n * @return Event handler props for the container element.\n */\nexport function useInteraction(\n\tstate: CropperState,\n\tactions: CropperInteractionActions,\n\tcontainerSize: Size,\n\timageSize?: Size,\n\toptions?: UseInteractionOptions\n): UseInteractionReturn {\n\tconst [ isDragging, setIsDragging ] = useState( false );\n\tconst [ isZooming, setIsZooming ] = useState( false );\n\tconst [ isGestureActive, setIsGestureActive ] = useState( false );\n\tconst [ isKeyboardPanning, setIsKeyboardPanning ] = useState( false );\n\tconst keyboardInteractionTimerRef =\n\t\tuseRef< ReturnType< typeof setTimeout > >();\n\n\t// Keep mutable refs so the controller always reads fresh values\n\t// without needing to be recreated.\n\tconst stateRef = useRef( state );\n\tstateRef.current = state;\n\tconst containerSizeRef = useRef( containerSize );\n\tcontainerSizeRef.current = containerSize;\n\tconst imageSizeRef = useRef( imageSize );\n\timageSizeRef.current = imageSize;\n\tconst optionsRef = useRef( options );\n\toptionsRef.current = options;\n\tconst actionsRef = useRef( actions );\n\tactionsRef.current = actions;\n\n\tconst controllerRef = useRef< InteractionController | null >( null );\n\tconst startPlacementGesture = useCallback( () => {\n\t\tsetIsGestureActive( true );\n\t}, [] );\n\tconst stopPlacementGesture = useCallback( () => {\n\t\tsetIsGestureActive( false );\n\t}, [] );\n\tconst signalKeyboardPlacement = useCallback( () => {\n\t\tsetIsKeyboardPanning( true );\n\t\tclearTimeout( keyboardInteractionTimerRef.current );\n\t\tkeyboardInteractionTimerRef.current = setTimeout( () => {\n\t\t\tsetIsKeyboardPanning( false );\n\t\t}, KEYBOARD_INTERACTION_IDLE_MS );\n\t}, [] );\n\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tclearTimeout( keyboardInteractionTimerRef.current );\n\t\t};\n\t}, [] );\n\n\t// Create / destroy the controller. The controller reads all volatile\n\t// values through refs, so it can stay mounted across render updates.\n\tuseEffect( () => {\n\t\tconst controller = new InteractionController( {\n\t\t\tgetState: () => stateRef.current,\n\t\t\tactions: {\n\t\t\t\tsetPan: ( pan ) => actionsRef.current.setPan( pan ),\n\t\t\t\tsetZoom: ( zoom ) => actionsRef.current.setZoom( zoom ),\n\t\t\t\tsetZoomAtPoint: ( zoom, pan ) =>\n\t\t\t\t\tactionsRef.current.setZoomAtPoint( zoom, pan ),\n\t\t\t\tsnapRotate90: ( direction ) =>\n\t\t\t\t\tactionsRef.current.snapRotate90( direction ),\n\t\t\t},\n\t\t\tgetContainerSize: () => containerSizeRef.current,\n\t\t\tgetImageSize: () => imageSizeRef.current,\n\t\t\tget minZoom() {\n\t\t\t\treturn optionsRef.current?.minZoom;\n\t\t\t},\n\t\t\tget maxZoom() {\n\t\t\t\treturn optionsRef.current?.maxZoom;\n\t\t\t},\n\t\t\tget zoomSpeed() {\n\t\t\t\treturn optionsRef.current?.zoomSpeed;\n\t\t\t},\n\t\t\tget keyboardStep() {\n\t\t\t\treturn optionsRef.current?.keyboardStep;\n\t\t\t},\n\t\t\tget doubleTapZoom() {\n\t\t\t\treturn optionsRef.current?.doubleTapZoom;\n\t\t\t},\n\t\t\tonGestureStart: () => {\n\t\t\t\tstartPlacementGesture();\n\t\t\t\toptionsRef.current?.onGestureStart?.();\n\t\t\t},\n\t\t\tonGestureEnd: () => {\n\t\t\t\tstopPlacementGesture();\n\t\t\t\toptionsRef.current?.onGestureEnd?.();\n\t\t\t},\n\t\t\tonStatusChange: ( status ) => {\n\t\t\t\tsetIsDragging( status.isDragging );\n\t\t\t\tsetIsZooming( status.isZooming );\n\t\t\t},\n\t\t} );\n\t\tcontrollerRef.current = controller;\n\t\treturn () => {\n\t\t\tcontroller.destroy();\n\t\t\tcontrollerRef.current = null;\n\t\t};\n\t}, [ startPlacementGesture, stopPlacementGesture ] );\n\n\tconst onPointerDown = useCallback( ( e: React.PointerEvent ) => {\n\t\tconst el = e.currentTarget as HTMLElement;\n\t\tcontrollerRef.current?.handlePointerDown( e.nativeEvent, el );\n\t}, [] );\n\n\tconst onTouchStart = useCallback( ( e: React.TouchEvent ) => {\n\t\tconst el = e.currentTarget as HTMLElement;\n\t\tconst rect = el.getBoundingClientRect();\n\t\tcontrollerRef.current?.handleTouchStart(\n\t\t\te.nativeEvent,\n\t\t\trect,\n\t\t\tel.ownerDocument\n\t\t);\n\t}, [] );\n\n\tconst onKeyDown = useCallback(\n\t\t( e: React.KeyboardEvent ) => {\n\t\t\tif ( isHandledKeyboardPan( e.nativeEvent ) ) {\n\t\t\t\tsignalKeyboardPlacement();\n\t\t\t}\n\t\t\tcontrollerRef.current?.handleKeyDown( e.nativeEvent );\n\t\t},\n\t\t[ signalKeyboardPlacement ]\n\t);\n\n\tconst onWheelNative = useCallback( ( e: WheelEvent ) => {\n\t\tcontrollerRef.current?.handleWheel( e );\n\t}, [] );\n\n\treturn {\n\t\thandlers: {\n\t\t\tonPointerDown,\n\t\t\tonTouchStart,\n\t\t\tonKeyDown,\n\t\t},\n\t\tonWheelNative,\n\t\tisDragging,\n\t\tisZooming,\n\t\tisPlacementActive: isGestureActive || isKeyboardPanning || isZooming,\n\t};\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAyD;AAMzD,oCAGO;AA2CP,IAAM,+BAA+B;AAErC,SAAS,qBAAsB,OAAgC;AAC9D,UAAS,MAAM,KAAM;AAAA,IACpB,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACJ,aAAO;AAAA,IACR;AACC,aAAO;AAAA,EACT;AACD;AAiBO,SAAS,eACf,OACA,SACA,eACA,WACA,SACuB;AACvB,QAAM,CAAE,YAAY,aAAc,QAAI,yBAAU,KAAM;AACtD,QAAM,CAAE,WAAW,YAAa,QAAI,yBAAU,KAAM;AACpD,QAAM,CAAE,iBAAiB,kBAAmB,QAAI,yBAAU,KAAM;AAChE,QAAM,CAAE,mBAAmB,oBAAqB,QAAI,yBAAU,KAAM;AACpE,QAAM,kCACL,uBAA0C;AAI3C,QAAM,eAAW,uBAAQ,KAAM;AAC/B,WAAS,UAAU;AACnB,QAAM,uBAAmB,uBAAQ,aAAc;AAC/C,mBAAiB,UAAU;AAC3B,QAAM,mBAAe,uBAAQ,SAAU;AACvC,eAAa,UAAU;AACvB,QAAM,iBAAa,uBAAQ,OAAQ;AACnC,aAAW,UAAU;AACrB,QAAM,iBAAa,uBAAQ,OAAQ;AACnC,aAAW,UAAU;AAErB,QAAM,oBAAgB,uBAAwC,IAAK;AACnE,QAAM,4BAAwB,4BAAa,MAAM;AAChD,uBAAoB,IAAK;AAAA,EAC1B,GAAG,CAAC,CAAE;AACN,QAAM,2BAAuB,4BAAa,MAAM;AAC/C,uBAAoB,KAAM;AAAA,EAC3B,GAAG,CAAC,CAAE;AACN,QAAM,8BAA0B,4BAAa,MAAM;AAClD,yBAAsB,IAAK;AAC3B,iBAAc,4BAA4B,OAAQ;AAClD,gCAA4B,UAAU,WAAY,MAAM;AACvD,2BAAsB,KAAM;AAAA,IAC7B,GAAG,4BAA6B;AAAA,EACjC,GAAG,CAAC,CAAE;AAEN,gCAAW,MAAM;AAChB,WAAO,MAAM;AACZ,mBAAc,4BAA4B,OAAQ;AAAA,IACnD;AAAA,EACD,GAAG,CAAC,CAAE;AAIN,gCAAW,MAAM;AAChB,UAAM,aAAa,IAAI,oDAAuB;AAAA,MAC7C,UAAU,MAAM,SAAS;AAAA,MACzB,SAAS;AAAA,QACR,QAAQ,CAAE,QAAS,WAAW,QAAQ,OAAQ,GAAI;AAAA,QAClD,SAAS,CAAE,SAAU,WAAW,QAAQ,QAAS,IAAK;AAAA,QACtD,gBAAgB,CAAE,MAAM,QACvB,WAAW,QAAQ,eAAgB,MAAM,GAAI;AAAA,QAC9C,cAAc,CAAE,cACf,WAAW,QAAQ,aAAc,SAAU;AAAA,MAC7C;AAAA,MACA,kBAAkB,MAAM,iBAAiB;AAAA,MACzC,cAAc,MAAM,aAAa;AAAA,MACjC,IAAI,UAAU;AACb,eAAO,WAAW,SAAS;AAAA,MAC5B;AAAA,MACA,IAAI,UAAU;AACb,eAAO,WAAW,SAAS;AAAA,MAC5B;AAAA,MACA,IAAI,YAAY;AACf,eAAO,WAAW,SAAS;AAAA,MAC5B;AAAA,MACA,IAAI,eAAe;AAClB,eAAO,WAAW,SAAS;AAAA,MAC5B;AAAA,MACA,IAAI,gBAAgB;AACnB,eAAO,WAAW,SAAS;AAAA,MAC5B;AAAA,MACA,gBAAgB,MAAM;AACrB,8BAAsB;AACtB,mBAAW,SAAS,iBAAiB;AAAA,MACtC;AAAA,MACA,cAAc,MAAM;AACnB,6BAAqB;AACrB,mBAAW,SAAS,eAAe;AAAA,MACpC;AAAA,MACA,gBAAgB,CAAE,WAAY;AAC7B,sBAAe,OAAO,UAAW;AACjC,qBAAc,OAAO,SAAU;AAAA,MAChC;AAAA,IACD,CAAE;AACF,kBAAc,UAAU;AACxB,WAAO,MAAM;AACZ,iBAAW,QAAQ;AACnB,oBAAc,UAAU;AAAA,IACzB;AAAA,EACD,GAAG,CAAE,uBAAuB,oBAAqB,CAAE;AAEnD,QAAM,oBAAgB,4BAAa,CAAE,MAA2B;AAC/D,UAAM,KAAK,EAAE;AACb,kBAAc,SAAS,kBAAmB,EAAE,aAAa,EAAG;AAAA,EAC7D,GAAG,CAAC,CAAE;AAEN,QAAM,mBAAe,4BAAa,CAAE,MAAyB;AAC5D,UAAM,KAAK,EAAE;AACb,UAAM,OAAO,GAAG,sBAAsB;AACtC,kBAAc,SAAS;AAAA,MACtB,EAAE;AAAA,MACF;AAAA,MACA,GAAG;AAAA,IACJ;AAAA,EACD,GAAG,CAAC,CAAE;AAEN,QAAM,gBAAY;AAAA,IACjB,CAAE,MAA4B;AAC7B,UAAK,qBAAsB,EAAE,WAAY,GAAI;AAC5C,gCAAwB;AAAA,MACzB;AACA,oBAAc,SAAS,cAAe,EAAE,WAAY;AAAA,IACrD;AAAA,IACA,CAAE,uBAAwB;AAAA,EAC3B;AAEA,QAAM,oBAAgB,4BAAa,CAAE,MAAmB;AACvD,kBAAc,SAAS,YAAa,CAAE;AAAA,EACvC,GAAG,CAAC,CAAE;AAEN,SAAO;AAAA,IACN,UAAU;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,mBAAmB,mBAAmB,qBAAqB;AAAA,EAC5D;AACD;",
6
+ "names": []
7
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // packages/media-editor/src/image-editor/react/hooks/use-transform-style.ts
21
+ var use_transform_style_exports = {};
22
+ __export(use_transform_style_exports, {
23
+ useTransformStyle: () => useTransformStyle
24
+ });
25
+ module.exports = __toCommonJS(use_transform_style_exports);
26
+ var import_element = require("@wordpress/element");
27
+ var import_transform_style = require("../../core/transform-style.cjs");
28
+ function useTransformStyle(state, imageSize) {
29
+ return (0, import_element.useMemo)(
30
+ () => (0, import_transform_style.computeTransformStyle)(state, imageSize),
31
+ [state, imageSize]
32
+ );
33
+ }
34
+ // Annotate the CommonJS export names for ESM import in node:
35
+ 0 && (module.exports = {
36
+ useTransformStyle
37
+ });
38
+ //# sourceMappingURL=use-transform-style.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/image-editor/react/hooks/use-transform-style.ts"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { CropperState, Size } from '../../core/types';\nimport { computeTransformStyle } from '../../core/transform-style';\n\n/**\n * React hook that computes a memoized CSS matrix() transform string\n * from the cropper state.\n *\n * Delegates to the pure `computeTransformStyle` function in core.\n *\n * @param state The current cropper state.\n * @param imageSize The rendered image dimensions in pixels.\n * @return A CSS transform string.\n */\nexport function useTransformStyle(\n\tstate: CropperState,\n\timageSize: Size\n): string {\n\treturn useMemo(\n\t\t() => computeTransformStyle( state, imageSize ),\n\t\t[ state, imageSize ]\n\t);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAwB;AAMxB,6BAAsC;AAY/B,SAAS,kBACf,OACA,WACS;AACT,aAAO;AAAA,IACN,UAAM,8CAAuB,OAAO,SAAU;AAAA,IAC9C,CAAE,OAAO,SAAU;AAAA,EACpB;AACD;",
6
+ "names": []
7
+ }
package/build/index.cjs CHANGED
@@ -32,16 +32,19 @@ var index_exports = {};
32
32
  __export(index_exports, {
33
33
  MediaEditorProvider: () => import_media_editor_provider.MediaEditorProvider,
34
34
  MediaForm: () => import_media_form.default,
35
- MediaPreview: () => import_media_preview.default
35
+ MediaPreview: () => import_media_preview.default,
36
+ privateApis: () => import_private_apis.privateApis
36
37
  });
37
38
  module.exports = __toCommonJS(index_exports);
38
39
  var import_media_editor_provider = require("./components/media-editor-provider/index.cjs");
39
40
  var import_media_preview = __toESM(require("./components/media-preview/index.cjs"));
40
41
  var import_media_form = __toESM(require("./components/media-form/index.cjs"));
42
+ var import_private_apis = require("./private-apis.cjs");
41
43
  // Annotate the CommonJS export names for ESM import in node:
42
44
  0 && (module.exports = {
43
45
  MediaEditorProvider,
44
46
  MediaForm,
45
- MediaPreview
47
+ MediaPreview,
48
+ privateApis
46
49
  });
47
50
  //# sourceMappingURL=index.cjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts"],
4
- "sourcesContent": ["// Components\nexport { MediaEditorProvider } from './components/media-editor-provider';\nexport { default as MediaPreview } from './components/media-preview';\nexport { default as MediaForm } from './components/media-form';\n\n// Types\nexport type {\n\tMedia,\n\tMediaEditorProviderProps,\n} from './components/media-editor-provider';\nexport type { MediaPreviewProps } from './components/media-preview';\nexport type { MediaFormProps } from './components/media-form';\n\n// Re-export commonly used dataviews types for convenience\nexport type { Field, Form } from '@wordpress/dataviews';\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mCAAoC;AACpC,2BAAwC;AACxC,wBAAqC;",
4
+ "sourcesContent": ["// Components\nexport { MediaEditorProvider } from './components/media-editor-provider';\nexport { default as MediaPreview } from './components/media-preview';\nexport { default as MediaForm } from './components/media-form';\n\n// Types\nexport type {\n\tMedia,\n\tMediaEditorProviderProps,\n} from './components/media-editor-provider';\nexport type { MediaPreviewProps } from './components/media-preview';\nexport type { MediaFormProps } from './components/media-form';\n\n// Re-export commonly used dataviews types for convenience\nexport type { Field, Form } from '@wordpress/dataviews';\n\n// Private APIs (experimental \u2014 not for use outside of core packages).\nexport { privateApis } from './private-apis';\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mCAAoC;AACpC,2BAAwC;AACxC,wBAAqC;AAcrC,0BAA4B;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // packages/media-editor/src/lock-unlock.ts
21
+ var lock_unlock_exports = {};
22
+ __export(lock_unlock_exports, {
23
+ lock: () => lock,
24
+ unlock: () => unlock
25
+ });
26
+ module.exports = __toCommonJS(lock_unlock_exports);
27
+ var import_private_apis = require("@wordpress/private-apis");
28
+ var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
29
+ "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
30
+ "@wordpress/media-editor"
31
+ );
32
+ // Annotate the CommonJS export names for ESM import in node:
33
+ 0 && (module.exports = {
34
+ lock,
35
+ unlock
36
+ });
37
+ //# sourceMappingURL=lock-unlock.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/lock-unlock.ts"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.',\n\t\t'@wordpress/media-editor'\n\t);\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAAiE;AAE1D,IAAM,EAAE,MAAM,OAAO,QAC3B;AAAA,EACC;AAAA,EACA;AACD;",
6
+ "names": []
7
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // packages/media-editor/src/private-apis.ts
21
+ var private_apis_exports = {};
22
+ __export(private_apis_exports, {
23
+ privateApis: () => privateApis
24
+ });
25
+ module.exports = __toCommonJS(private_apis_exports);
26
+ var import_lock_unlock = require("./lock-unlock.cjs");
27
+ var import_store = require("./store/index.cjs");
28
+ var import_media_editor_modal = require("./components/media-editor-modal/index.cjs");
29
+ var privateApis = {};
30
+ (0, import_lock_unlock.lock)(privateApis, {
31
+ store: import_store.store,
32
+ MediaEditorModal: import_media_editor_modal.MediaEditorModal
33
+ });
34
+ // Annotate the CommonJS export names for ESM import in node:
35
+ 0 && (module.exports = {
36
+ privateApis
37
+ });
38
+ //# sourceMappingURL=private-apis.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/private-apis.ts"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport { lock } from './lock-unlock';\nimport { store } from './store';\nimport { MediaEditorModal } from './components/media-editor-modal';\n\nexport const privateApis = {};\nlock( privateApis, {\n\tstore,\n\tMediaEditorModal,\n} );\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,yBAAqB;AACrB,mBAAsB;AACtB,gCAAiC;AAE1B,IAAM,cAAc,CAAC;AAAA,IAC5B,yBAAM,aAAa;AAAA,EAClB;AAAA,EACA;AACD,CAAE;",
6
+ "names": []
7
+ }
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // packages/media-editor/src/store/actions.ts
21
+ var actions_exports = {};
22
+ __export(actions_exports, {
23
+ closeMediaEditorModal: () => closeMediaEditorModal,
24
+ openMediaEditorModal: () => openMediaEditorModal
25
+ });
26
+ module.exports = __toCommonJS(actions_exports);
27
+ function openMediaEditorModal({
28
+ id,
29
+ onUpdate
30
+ }) {
31
+ return {
32
+ type: "OPEN_MEDIA_EDITOR_MODAL",
33
+ id,
34
+ onUpdate: onUpdate ?? null
35
+ };
36
+ }
37
+ function closeMediaEditorModal() {
38
+ return { type: "CLOSE_MEDIA_EDITOR_MODAL" };
39
+ }
40
+ // Annotate the CommonJS export names for ESM import in node:
41
+ 0 && (module.exports = {
42
+ closeMediaEditorModal,
43
+ openMediaEditorModal
44
+ });
45
+ //# sourceMappingURL=actions.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/store/actions.ts"],
4
+ "sourcesContent": ["/**\n * Shape passed to `onUpdate` after a successful save. Deliberately normalized\n * and minimal: `url` instead of REST's `source_url`, so consumers can drop\n * it straight into block attributes (matches the legacy `ImageEditor`'s\n * `onSaveImage` shape at\n * `packages/block-editor/src/components/image-editor/use-save-image.js`).\n * Keeping this decoupled from the REST field names also leaves room to reuse\n * the modal outside a WordPress REST context (e.g. native/Electron hosts).\n */\nexport interface MediaEditorModalUpdate {\n\tid: number;\n\turl?: string;\n}\n\ninterface OpenMediaEditorModalArgs {\n\tid: number;\n\tonUpdate?: ( updated: MediaEditorModalUpdate ) => void;\n}\n\nexport function openMediaEditorModal( {\n\tid,\n\tonUpdate,\n}: OpenMediaEditorModalArgs ) {\n\treturn {\n\t\ttype: 'OPEN_MEDIA_EDITOR_MODAL' as const,\n\t\tid,\n\t\tonUpdate: onUpdate ?? null,\n\t};\n}\n\nexport function closeMediaEditorModal() {\n\treturn { type: 'CLOSE_MEDIA_EDITOR_MODAL' as const };\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmBO,SAAS,qBAAsB;AAAA,EACrC;AAAA,EACA;AACD,GAA8B;AAC7B,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA,UAAU,YAAY;AAAA,EACvB;AACD;AAEO,SAAS,wBAAwB;AACvC,SAAO,EAAE,MAAM,2BAAoC;AACpD;",
6
+ "names": []
7
+ }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // packages/media-editor/src/store/constants.ts
21
+ var constants_exports = {};
22
+ __export(constants_exports, {
23
+ STORE_NAME: () => STORE_NAME
24
+ });
25
+ module.exports = __toCommonJS(constants_exports);
26
+ var STORE_NAME = "core/media-editor";
27
+ // Annotate the CommonJS export names for ESM import in node:
28
+ 0 && (module.exports = {
29
+ STORE_NAME
30
+ });
31
+ //# sourceMappingURL=constants.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/store/constants.ts"],
4
+ "sourcesContent": ["export const STORE_NAME = 'core/media-editor';\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,IAAM,aAAa;",
6
+ "names": []
7
+ }
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // packages/media-editor/src/store/index.ts
31
+ var store_exports = {};
32
+ __export(store_exports, {
33
+ store: () => store
34
+ });
35
+ module.exports = __toCommonJS(store_exports);
36
+ var import_data = require("@wordpress/data");
37
+ var import_reducer = __toESM(require("./reducer.cjs"));
38
+ var actions = __toESM(require("./actions.cjs"));
39
+ var selectors = __toESM(require("./selectors.cjs"));
40
+ var import_constants = require("./constants.cjs");
41
+ var store = (0, import_data.createReduxStore)(import_constants.STORE_NAME, {
42
+ reducer: import_reducer.default,
43
+ actions,
44
+ selectors
45
+ });
46
+ (0, import_data.register)(store);
47
+ // Annotate the CommonJS export names for ESM import in node:
48
+ 0 && (module.exports = {
49
+ store
50
+ });
51
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/store/index.ts"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as actions from './actions';\nimport * as selectors from './selectors';\nimport { STORE_NAME } from './constants';\n\nexport const store = createReduxStore( STORE_NAME, {\n\treducer,\n\tactions,\n\tselectors,\n} );\n\nregister( store );\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA2C;AAK3C,qBAAoB;AACpB,cAAyB;AACzB,gBAA2B;AAC3B,uBAA2B;AAEpB,IAAM,YAAQ,8BAAkB,6BAAY;AAAA,EAClD,wBAAAA;AAAA,EACA;AAAA,EACA;AACD,CAAE;AAAA,IAEF,sBAAU,KAAM;",
6
+ "names": ["reducer"]
7
+ }
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // packages/media-editor/src/store/reducer.ts
21
+ var reducer_exports = {};
22
+ __export(reducer_exports, {
23
+ DEFAULT_STATE: () => DEFAULT_STATE,
24
+ default: () => reducer
25
+ });
26
+ module.exports = __toCommonJS(reducer_exports);
27
+ var DEFAULT_STATE = {
28
+ isOpen: false,
29
+ id: null,
30
+ onUpdate: null
31
+ };
32
+ function reducer(state = DEFAULT_STATE, action) {
33
+ switch (action.type) {
34
+ case "OPEN_MEDIA_EDITOR_MODAL": {
35
+ const { id, onUpdate } = action;
36
+ return {
37
+ isOpen: true,
38
+ id,
39
+ onUpdate
40
+ };
41
+ }
42
+ case "CLOSE_MEDIA_EDITOR_MODAL":
43
+ return DEFAULT_STATE;
44
+ }
45
+ return state;
46
+ }
47
+ // Annotate the CommonJS export names for ESM import in node:
48
+ 0 && (module.exports = {
49
+ DEFAULT_STATE
50
+ });
51
+ //# sourceMappingURL=reducer.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/store/reducer.ts"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { MediaEditorModalUpdate } from './actions';\n\ntype OnUpdateCallback = ( updated: MediaEditorModalUpdate ) => void;\n\nexport interface State {\n\tisOpen: boolean;\n\tid: number | null;\n\tonUpdate: OnUpdateCallback | null;\n}\n\nexport const DEFAULT_STATE: State = {\n\tisOpen: false,\n\tid: null,\n\tonUpdate: null,\n};\n\ntype Action =\n\t| {\n\t\t\ttype: 'OPEN_MEDIA_EDITOR_MODAL';\n\t\t\tid: number;\n\t\t\tonUpdate: OnUpdateCallback | null;\n\t }\n\t| { type: 'CLOSE_MEDIA_EDITOR_MODAL' };\n\nexport default function reducer(\n\tstate: State = DEFAULT_STATE,\n\taction: Action | { type: string }\n): State {\n\tswitch ( action.type ) {\n\t\tcase 'OPEN_MEDIA_EDITOR_MODAL': {\n\t\t\tconst { id, onUpdate } = action as Extract<\n\t\t\t\tAction,\n\t\t\t\t{ type: 'OPEN_MEDIA_EDITOR_MODAL' }\n\t\t\t>;\n\t\t\treturn {\n\t\t\t\tisOpen: true,\n\t\t\t\tid,\n\t\t\t\tonUpdate,\n\t\t\t};\n\t\t}\n\t\tcase 'CLOSE_MEDIA_EDITOR_MODAL':\n\t\t\treturn DEFAULT_STATE;\n\t}\n\treturn state;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAaO,IAAM,gBAAuB;AAAA,EACnC,QAAQ;AAAA,EACR,IAAI;AAAA,EACJ,UAAU;AACX;AAUe,SAAR,QACN,QAAe,eACf,QACQ;AACR,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK,2BAA2B;AAC/B,YAAM,EAAE,IAAI,SAAS,IAAI;AAIzB,aAAO;AAAA,QACN,QAAQ;AAAA,QACR;AAAA,QACA;AAAA,MACD;AAAA,IACD;AAAA,IACA,KAAK;AACJ,aAAO;AAAA,EACT;AACA,SAAO;AACR;",
6
+ "names": []
7
+ }