@wordpress/media-editor 0.21.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (432) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/build/components/media-editor/index.cjs +586 -686
  3. package/build/components/media-editor/index.cjs.map +1 -7
  4. package/build/components/media-editor/use-crop-options.cjs +42 -57
  5. package/build/components/media-editor/use-crop-options.cjs.map +1 -7
  6. package/build/components/media-editor/use-save-media-editor.cjs +131 -185
  7. package/build/components/media-editor/use-save-media-editor.cjs.map +1 -7
  8. package/build/components/media-editor-canvas/index.cjs +117 -124
  9. package/build/components/media-editor-canvas/index.cjs.map +1 -7
  10. package/build/components/media-editor-crop-panel/index.cjs +81 -72
  11. package/build/components/media-editor-crop-panel/index.cjs.map +1 -7
  12. package/build/components/media-editor-fine-rotation/index.cjs +61 -72
  13. package/build/components/media-editor-fine-rotation/index.cjs.map +1 -7
  14. package/build/components/media-editor-image-controls/index.cjs +181 -257
  15. package/build/components/media-editor-image-controls/index.cjs.map +1 -7
  16. package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs +120 -157
  17. package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs.map +1 -7
  18. package/build/components/media-editor-modal/index.cjs +112 -155
  19. package/build/components/media-editor-modal/index.cjs.map +1 -7
  20. package/build/components/media-editor-provider/index.cjs +32 -55
  21. package/build/components/media-editor-provider/index.cjs.map +1 -7
  22. package/build/components/media-form/index.cjs +82 -77
  23. package/build/components/media-form/index.cjs.map +1 -7
  24. package/build/components/media-preview/index.cjs +113 -114
  25. package/build/components/media-preview/index.cjs.map +1 -7
  26. package/build/components/rotation-ruler/index.cjs +181 -188
  27. package/build/components/rotation-ruler/index.cjs.map +1 -7
  28. package/build/components/rotation-ruler/use-ruler-drag.cjs +132 -149
  29. package/build/components/rotation-ruler/use-ruler-drag.cjs.map +1 -7
  30. package/build/hooks/use-crop-gesture-handlers.cjs +82 -76
  31. package/build/hooks/use-crop-gesture-handlers.cjs.map +1 -7
  32. package/build/index.cjs +45 -39
  33. package/build/lock-unlock.cjs +9 -35
  34. package/build/lock-unlock.cjs.map +1 -7
  35. package/build/private-apis.cjs +16 -37
  36. package/build/private-apis.cjs.map +1 -7
  37. package/build/state/aspect-ratio-presets.cjs +59 -0
  38. package/build/state/aspect-ratio-presets.cjs.map +1 -0
  39. package/build/state/composite-reducer.cjs +100 -113
  40. package/build/state/composite-reducer.cjs.map +1 -7
  41. package/build/state/index.cjs +22 -45
  42. package/build/state/media-editor-state-provider.cjs +35 -48
  43. package/build/state/media-editor-state-provider.cjs.map +1 -7
  44. package/build/state/types.cjs +11 -31
  45. package/build/state/types.cjs.map +1 -7
  46. package/build/state/use-media-editor-state.cjs +227 -296
  47. package/build/state/use-media-editor-state.cjs.map +1 -7
  48. package/build/store/actions.cjs +17 -44
  49. package/build/store/actions.cjs.map +1 -7
  50. package/build/store/constants.cjs +8 -29
  51. package/build/store/constants.cjs.map +1 -7
  52. package/build/store/index.cjs +33 -40
  53. package/build/store/index.cjs.map +1 -7
  54. package/build/store/reducer.cjs +28 -50
  55. package/build/store/reducer.cjs.map +1 -7
  56. package/build/store/selectors.cjs +16 -41
  57. package/build/store/selectors.cjs.map +1 -7
  58. package/build/utils/get-media-type.cjs +18 -41
  59. package/build/utils/get-media-type.cjs.map +1 -7
  60. package/build/utils/index.cjs +9 -28
  61. package/build-module/components/media-editor/index.mjs +545 -675
  62. package/build-module/components/media-editor/index.mjs.map +1 -7
  63. package/build-module/components/media-editor/use-crop-options.mjs +37 -32
  64. package/build-module/components/media-editor/use-crop-options.mjs.map +1 -7
  65. package/build-module/components/media-editor/use-save-media-editor.mjs +109 -157
  66. package/build-module/components/media-editor/use-save-media-editor.mjs.map +1 -7
  67. package/build-module/components/media-editor-canvas/index.mjs +95 -98
  68. package/build-module/components/media-editor-canvas/index.mjs.map +1 -7
  69. package/build-module/components/media-editor-crop-panel/index.mjs +59 -46
  70. package/build-module/components/media-editor-crop-panel/index.mjs.map +1 -7
  71. package/build-module/components/media-editor-fine-rotation/index.mjs +39 -46
  72. package/build-module/components/media-editor-fine-rotation/index.mjs.map +1 -7
  73. package/build-module/components/media-editor-image-controls/index.mjs +171 -238
  74. package/build-module/components/media-editor-image-controls/index.mjs.map +1 -7
  75. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs +113 -137
  76. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs.map +1 -7
  77. package/build-module/components/media-editor-modal/index.mjs +88 -124
  78. package/build-module/components/media-editor-modal/index.mjs.map +1 -7
  79. package/build-module/components/media-editor-provider/index.mjs +26 -29
  80. package/build-module/components/media-editor-provider/index.mjs.map +1 -7
  81. package/build-module/components/media-form/index.mjs +74 -56
  82. package/build-module/components/media-form/index.mjs.map +1 -7
  83. package/build-module/components/media-preview/index.mjs +105 -90
  84. package/build-module/components/media-preview/index.mjs.map +1 -7
  85. package/build-module/components/rotation-ruler/index.mjs +161 -164
  86. package/build-module/components/rotation-ruler/index.mjs.map +1 -7
  87. package/build-module/components/rotation-ruler/use-ruler-drag.mjs +125 -122
  88. package/build-module/components/rotation-ruler/use-ruler-drag.mjs.map +1 -7
  89. package/build-module/hooks/use-crop-gesture-handlers.mjs +76 -50
  90. package/build-module/hooks/use-crop-gesture-handlers.mjs.map +1 -7
  91. package/build-module/index.mjs +3 -10
  92. package/build-module/lock-unlock.mjs +5 -10
  93. package/build-module/lock-unlock.mjs.map +1 -7
  94. package/build-module/private-apis.mjs +8 -9
  95. package/build-module/private-apis.mjs.map +1 -7
  96. package/build-module/state/aspect-ratio-presets.mjs +53 -0
  97. package/build-module/state/aspect-ratio-presets.mjs.map +1 -0
  98. package/build-module/state/composite-reducer.mjs +80 -91
  99. package/build-module/state/composite-reducer.mjs.map +1 -7
  100. package/build-module/state/index.mjs +3 -26
  101. package/build-module/state/media-editor-state-provider.mjs +29 -24
  102. package/build-module/state/media-editor-state-provider.mjs.map +1 -7
  103. package/build-module/state/types.mjs +7 -7
  104. package/build-module/state/types.mjs.map +1 -7
  105. package/build-module/state/use-media-editor-state.mjs +223 -288
  106. package/build-module/state/use-media-editor-state.mjs.map +1 -7
  107. package/build-module/store/actions.mjs +12 -19
  108. package/build-module/store/actions.mjs.map +1 -7
  109. package/build-module/store/constants.mjs +4 -5
  110. package/build-module/store/constants.mjs.map +1 -7
  111. package/build-module/store/index.mjs +8 -9
  112. package/build-module/store/index.mjs.map +1 -7
  113. package/build-module/store/reducer.mjs +23 -26
  114. package/build-module/store/reducer.mjs.map +1 -7
  115. package/build-module/store/selectors.mjs +8 -13
  116. package/build-module/store/selectors.mjs.map +1 -7
  117. package/build-module/utils/get-media-type.mjs +14 -17
  118. package/build-module/utils/get-media-type.mjs.map +1 -7
  119. package/build-module/utils/index.mjs +1 -6
  120. package/build-style/style-rtl.css +145 -61
  121. package/build-style/style.css +144 -61
  122. package/build-types/components/media-editor/index.d.ts +20 -2
  123. package/build-types/components/media-editor/index.d.ts.map +1 -1
  124. package/build-types/components/media-editor/use-crop-options.d.ts +2 -3
  125. package/build-types/components/media-editor/use-crop-options.d.ts.map +1 -1
  126. package/build-types/components/media-editor/use-save-media-editor.d.ts.map +1 -1
  127. package/build-types/components/media-editor-canvas/index.d.ts +3 -3
  128. package/build-types/components/media-editor-canvas/index.d.ts.map +1 -1
  129. package/build-types/components/media-editor-crop-panel/index.d.ts +1 -1
  130. package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -1
  131. package/build-types/components/media-editor-fine-rotation/index.d.ts.map +1 -1
  132. package/build-types/components/media-editor-image-controls/index.d.ts +1 -1
  133. package/build-types/components/media-editor-image-controls/index.d.ts.map +1 -1
  134. package/build-types/components/media-editor-keyboard-shortcuts-modal/index.d.ts.map +1 -1
  135. package/build-types/components/media-editor-modal/index.d.ts +1 -1
  136. package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
  137. package/build-types/components/media-form/index.d.ts.map +1 -1
  138. package/build-types/components/media-preview/index.d.ts.map +1 -1
  139. package/build-types/components/rotation-ruler/use-ruler-drag.d.ts.map +1 -1
  140. package/build-types/state/aspect-ratio-presets.d.ts +24 -0
  141. package/build-types/state/aspect-ratio-presets.d.ts.map +1 -0
  142. package/build-types/state/composite-reducer.d.ts +17 -19
  143. package/build-types/state/composite-reducer.d.ts.map +1 -1
  144. package/build-types/state/index.d.ts +2 -4
  145. package/build-types/state/index.d.ts.map +1 -1
  146. package/build-types/state/types.d.ts +20 -63
  147. package/build-types/state/types.d.ts.map +1 -1
  148. package/build-types/state/use-media-editor-state.d.ts +33 -52
  149. package/build-types/state/use-media-editor-state.d.ts.map +1 -1
  150. package/package.json +22 -23
  151. package/src/components/media-editor/index.tsx +355 -167
  152. package/src/components/media-editor/style.scss +19 -0
  153. package/src/components/media-editor/use-crop-options.ts +9 -10
  154. package/src/components/media-editor/use-save-media-editor.ts +48 -10
  155. package/src/components/media-editor-canvas/index.tsx +30 -51
  156. package/src/components/media-editor-canvas/style.scss +6 -6
  157. package/src/components/media-editor-crop-panel/index.tsx +38 -2
  158. package/src/components/media-editor-crop-panel/style.scss +21 -0
  159. package/src/components/media-editor-fine-rotation/index.tsx +6 -6
  160. package/src/components/media-editor-image-controls/index.tsx +15 -11
  161. package/src/components/media-editor-keyboard-shortcuts-modal/index.tsx +1 -0
  162. package/src/components/media-editor-keyboard-shortcuts-modal/style.scss +1 -1
  163. package/src/components/media-editor-modal/index.tsx +1 -1
  164. package/src/components/media-editor-modal/style.scss +1 -1
  165. package/src/components/media-form/index.tsx +7 -1
  166. package/src/components/media-preview/index.tsx +65 -23
  167. package/src/components/media-preview/style.scss +16 -2
  168. package/src/components/rotation-ruler/style.scss +9 -5
  169. package/src/components/rotation-ruler/use-ruler-drag.ts +6 -11
  170. package/src/state/README.md +32 -0
  171. package/src/state/aspect-ratio-presets.ts +37 -0
  172. package/src/state/composite-reducer.ts +42 -80
  173. package/src/state/index.ts +2 -17
  174. package/src/state/types.ts +18 -72
  175. package/src/state/use-media-editor-state.ts +155 -238
  176. package/src/style.scss +2 -1
  177. package/build/components/media-editor-modal/build-modifiers.cjs +0 -91
  178. package/build/components/media-editor-modal/build-modifiers.cjs.map +0 -7
  179. package/build/image-editor/core/camera.cjs +0 -225
  180. package/build/image-editor/core/camera.cjs.map +0 -7
  181. package/build/image-editor/core/constants.cjs +0 -108
  182. package/build/image-editor/core/constants.cjs.map +0 -7
  183. package/build/image-editor/core/containment.cjs +0 -276
  184. package/build/image-editor/core/containment.cjs.map +0 -7
  185. package/build/image-editor/core/crop-rect.cjs +0 -48
  186. package/build/image-editor/core/crop-rect.cjs.map +0 -7
  187. package/build/image-editor/core/export/canvas-renderer.cjs +0 -151
  188. package/build/image-editor/core/export/canvas-renderer.cjs.map +0 -7
  189. package/build/image-editor/core/index.cjs +0 -62
  190. package/build/image-editor/core/index.cjs.map +0 -7
  191. package/build/image-editor/core/interaction-controller.cjs +0 -654
  192. package/build/image-editor/core/interaction-controller.cjs.map +0 -7
  193. package/build/image-editor/core/math/rotation.cjs +0 -41
  194. package/build/image-editor/core/math/rotation.cjs.map +0 -7
  195. package/build/image-editor/core/math/sanitize.cjs +0 -92
  196. package/build/image-editor/core/math/sanitize.cjs.map +0 -7
  197. package/build/image-editor/core/setter-helpers.cjs +0 -64
  198. package/build/image-editor/core/setter-helpers.cjs.map +0 -7
  199. package/build/image-editor/core/source-region.cjs +0 -206
  200. package/build/image-editor/core/source-region.cjs.map +0 -7
  201. package/build/image-editor/core/state.cjs +0 -283
  202. package/build/image-editor/core/state.cjs.map +0 -7
  203. package/build/image-editor/core/stencil-math.cjs +0 -216
  204. package/build/image-editor/core/stencil-math.cjs.map +0 -7
  205. package/build/image-editor/core/transform-style.cjs +0 -52
  206. package/build/image-editor/core/transform-style.cjs.map +0 -7
  207. package/build/image-editor/core/transforms/pipeline.cjs +0 -43
  208. package/build/image-editor/core/transforms/pipeline.cjs.map +0 -7
  209. package/build/image-editor/core/types.cjs +0 -19
  210. package/build/image-editor/core/types.cjs.map +0 -7
  211. package/build/image-editor/core/viewport-state.cjs +0 -50
  212. package/build/image-editor/core/viewport-state.cjs.map +0 -7
  213. package/build/image-editor/index.cjs +0 -67
  214. package/build/image-editor/index.cjs.map +0 -7
  215. package/build/image-editor/react/components/cropper-provider.cjs +0 -50
  216. package/build/image-editor/react/components/cropper-provider.cjs.map +0 -7
  217. package/build/image-editor/react/components/cropper.cjs +0 -722
  218. package/build/image-editor/react/components/cropper.cjs.map +0 -7
  219. package/build/image-editor/react/components/index.cjs +0 -36
  220. package/build/image-editor/react/components/index.cjs.map +0 -7
  221. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs +0 -172
  222. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs.map +0 -7
  223. package/build/image-editor/react/components/overlays/dimming-overlay.cjs +0 -62
  224. package/build/image-editor/react/components/overlays/dimming-overlay.cjs.map +0 -7
  225. package/build/image-editor/react/components/overlays/grid-overlay.cjs +0 -91
  226. package/build/image-editor/react/components/overlays/grid-overlay.cjs.map +0 -7
  227. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs +0 -426
  228. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +0 -7
  229. package/build/image-editor/react/components/viewport-provider.cjs +0 -51
  230. package/build/image-editor/react/components/viewport-provider.cjs.map +0 -7
  231. package/build/image-editor/react/hooks/build-cropper-setters.cjs +0 -71
  232. package/build/image-editor/react/hooks/build-cropper-setters.cjs.map +0 -7
  233. package/build/image-editor/react/hooks/index.cjs +0 -34
  234. package/build/image-editor/react/hooks/index.cjs.map +0 -7
  235. package/build/image-editor/react/hooks/use-aria-announcer.cjs +0 -160
  236. package/build/image-editor/react/hooks/use-aria-announcer.cjs.map +0 -7
  237. package/build/image-editor/react/hooks/use-cropper-reducer.cjs +0 -113
  238. package/build/image-editor/react/hooks/use-cropper-reducer.cjs.map +0 -7
  239. package/build/image-editor/react/hooks/use-interaction.cjs +0 -213
  240. package/build/image-editor/react/hooks/use-interaction.cjs.map +0 -7
  241. package/build/image-editor/react/hooks/use-transform-style.cjs +0 -38
  242. package/build/image-editor/react/hooks/use-transform-style.cjs.map +0 -7
  243. package/build/image-editor/react/hooks/use-viewport-state.cjs +0 -51
  244. package/build/image-editor/react/hooks/use-viewport-state.cjs.map +0 -7
  245. package/build/image-editor/react/visually-hidden-style.cjs +0 -41
  246. package/build/image-editor/react/visually-hidden-style.cjs.map +0 -7
  247. package/build/index.cjs.map +0 -7
  248. package/build/state/index.cjs.map +0 -7
  249. package/build/utils/index.cjs.map +0 -7
  250. package/build-module/components/media-editor-modal/build-modifiers.mjs +0 -66
  251. package/build-module/components/media-editor-modal/build-modifiers.mjs.map +0 -7
  252. package/build-module/image-editor/core/camera.mjs +0 -198
  253. package/build-module/image-editor/core/camera.mjs.map +0 -7
  254. package/build-module/image-editor/core/constants.mjs +0 -69
  255. package/build-module/image-editor/core/constants.mjs.map +0 -7
  256. package/build-module/image-editor/core/containment.mjs +0 -253
  257. package/build-module/image-editor/core/containment.mjs.map +0 -7
  258. package/build-module/image-editor/core/crop-rect.mjs +0 -23
  259. package/build-module/image-editor/core/crop-rect.mjs.map +0 -7
  260. package/build-module/image-editor/core/export/canvas-renderer.mjs +0 -120
  261. package/build-module/image-editor/core/export/canvas-renderer.mjs.map +0 -7
  262. package/build-module/image-editor/core/index.mjs +0 -36
  263. package/build-module/image-editor/core/index.mjs.map +0 -7
  264. package/build-module/image-editor/core/interaction-controller.mjs +0 -635
  265. package/build-module/image-editor/core/interaction-controller.mjs.map +0 -7
  266. package/build-module/image-editor/core/math/rotation.mjs +0 -15
  267. package/build-module/image-editor/core/math/rotation.mjs.map +0 -7
  268. package/build-module/image-editor/core/math/sanitize.mjs +0 -63
  269. package/build-module/image-editor/core/math/sanitize.mjs.map +0 -7
  270. package/build-module/image-editor/core/setter-helpers.mjs +0 -39
  271. package/build-module/image-editor/core/setter-helpers.mjs.map +0 -7
  272. package/build-module/image-editor/core/source-region.mjs +0 -178
  273. package/build-module/image-editor/core/source-region.mjs.map +0 -7
  274. package/build-module/image-editor/core/state.mjs +0 -260
  275. package/build-module/image-editor/core/state.mjs.map +0 -7
  276. package/build-module/image-editor/core/stencil-math.mjs +0 -187
  277. package/build-module/image-editor/core/stencil-math.mjs.map +0 -7
  278. package/build-module/image-editor/core/transform-style.mjs +0 -27
  279. package/build-module/image-editor/core/transform-style.mjs.map +0 -7
  280. package/build-module/image-editor/core/transforms/pipeline.mjs +0 -17
  281. package/build-module/image-editor/core/transforms/pipeline.mjs.map +0 -7
  282. package/build-module/image-editor/core/types.mjs +0 -1
  283. package/build-module/image-editor/core/types.mjs.map +0 -7
  284. package/build-module/image-editor/core/viewport-state.mjs +0 -24
  285. package/build-module/image-editor/core/viewport-state.mjs.map +0 -7
  286. package/build-module/image-editor/index.mjs +0 -39
  287. package/build-module/image-editor/index.mjs.map +0 -7
  288. package/build-module/image-editor/react/components/cropper-provider.mjs +0 -26
  289. package/build-module/image-editor/react/components/cropper-provider.mjs.map +0 -7
  290. package/build-module/image-editor/react/components/cropper.mjs +0 -704
  291. package/build-module/image-editor/react/components/cropper.mjs.map +0 -7
  292. package/build-module/image-editor/react/components/index.mjs +0 -9
  293. package/build-module/image-editor/react/components/index.mjs.map +0 -7
  294. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs +0 -147
  295. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs.map +0 -7
  296. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs +0 -37
  297. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs.map +0 -7
  298. package/build-module/image-editor/react/components/overlays/grid-overlay.mjs +0 -66
  299. package/build-module/image-editor/react/components/overlays/grid-overlay.mjs.map +0 -7
  300. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs +0 -414
  301. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs.map +0 -7
  302. package/build-module/image-editor/react/components/viewport-provider.mjs +0 -27
  303. package/build-module/image-editor/react/components/viewport-provider.mjs.map +0 -7
  304. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs +0 -46
  305. package/build-module/image-editor/react/hooks/build-cropper-setters.mjs.map +0 -7
  306. package/build-module/image-editor/react/hooks/index.mjs +0 -8
  307. package/build-module/image-editor/react/hooks/index.mjs.map +0 -7
  308. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs +0 -135
  309. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs.map +0 -7
  310. package/build-module/image-editor/react/hooks/use-cropper-reducer.mjs +0 -100
  311. package/build-module/image-editor/react/hooks/use-cropper-reducer.mjs.map +0 -7
  312. package/build-module/image-editor/react/hooks/use-interaction.mjs +0 -190
  313. package/build-module/image-editor/react/hooks/use-interaction.mjs.map +0 -7
  314. package/build-module/image-editor/react/hooks/use-transform-style.mjs +0 -13
  315. package/build-module/image-editor/react/hooks/use-transform-style.mjs.map +0 -7
  316. package/build-module/image-editor/react/hooks/use-viewport-state.mjs +0 -29
  317. package/build-module/image-editor/react/hooks/use-viewport-state.mjs.map +0 -7
  318. package/build-module/image-editor/react/visually-hidden-style.mjs +0 -16
  319. package/build-module/image-editor/react/visually-hidden-style.mjs.map +0 -7
  320. package/build-module/index.mjs.map +0 -7
  321. package/build-module/state/index.mjs.map +0 -7
  322. package/build-module/utils/index.mjs.map +0 -7
  323. package/build-types/components/media-editor-modal/build-modifiers.d.ts +0 -80
  324. package/build-types/components/media-editor-modal/build-modifiers.d.ts.map +0 -1
  325. package/build-types/image-editor/core/camera.d.ts +0 -128
  326. package/build-types/image-editor/core/camera.d.ts.map +0 -1
  327. package/build-types/image-editor/core/constants.d.ts +0 -99
  328. package/build-types/image-editor/core/constants.d.ts.map +0 -1
  329. package/build-types/image-editor/core/containment.d.ts +0 -72
  330. package/build-types/image-editor/core/containment.d.ts.map +0 -1
  331. package/build-types/image-editor/core/crop-rect.d.ts +0 -16
  332. package/build-types/image-editor/core/crop-rect.d.ts.map +0 -1
  333. package/build-types/image-editor/core/export/canvas-renderer.d.ts +0 -103
  334. package/build-types/image-editor/core/export/canvas-renderer.d.ts.map +0 -1
  335. package/build-types/image-editor/core/index.d.ts +0 -10
  336. package/build-types/image-editor/core/index.d.ts.map +0 -1
  337. package/build-types/image-editor/core/interaction-controller.d.ts +0 -191
  338. package/build-types/image-editor/core/interaction-controller.d.ts.map +0 -1
  339. package/build-types/image-editor/core/math/rotation.d.ts +0 -18
  340. package/build-types/image-editor/core/math/rotation.d.ts.map +0 -1
  341. package/build-types/image-editor/core/math/sanitize.d.ts +0 -67
  342. package/build-types/image-editor/core/math/sanitize.d.ts.map +0 -1
  343. package/build-types/image-editor/core/setter-helpers.d.ts +0 -21
  344. package/build-types/image-editor/core/setter-helpers.d.ts.map +0 -1
  345. package/build-types/image-editor/core/source-region.d.ts +0 -94
  346. package/build-types/image-editor/core/source-region.d.ts.map +0 -1
  347. package/build-types/image-editor/core/state.d.ts +0 -51
  348. package/build-types/image-editor/core/state.d.ts.map +0 -1
  349. package/build-types/image-editor/core/stencil-math.d.ts +0 -102
  350. package/build-types/image-editor/core/stencil-math.d.ts.map +0 -1
  351. package/build-types/image-editor/core/transform-style.d.ts +0 -20
  352. package/build-types/image-editor/core/transform-style.d.ts.map +0 -1
  353. package/build-types/image-editor/core/transforms/pipeline.d.ts +0 -24
  354. package/build-types/image-editor/core/transforms/pipeline.d.ts.map +0 -1
  355. package/build-types/image-editor/core/types.d.ts +0 -269
  356. package/build-types/image-editor/core/types.d.ts.map +0 -1
  357. package/build-types/image-editor/core/viewport-state.d.ts +0 -4
  358. package/build-types/image-editor/core/viewport-state.d.ts.map +0 -1
  359. package/build-types/image-editor/index.d.ts +0 -16
  360. package/build-types/image-editor/index.d.ts.map +0 -1
  361. package/build-types/image-editor/react/components/cropper-provider.d.ts +0 -38
  362. package/build-types/image-editor/react/components/cropper-provider.d.ts.map +0 -1
  363. package/build-types/image-editor/react/components/cropper.d.ts +0 -63
  364. package/build-types/image-editor/react/components/cropper.d.ts.map +0 -1
  365. package/build-types/image-editor/react/components/index.d.ts +0 -4
  366. package/build-types/image-editor/react/components/index.d.ts.map +0 -1
  367. package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts +0 -33
  368. package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts.map +0 -1
  369. package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts +0 -17
  370. package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts.map +0 -1
  371. package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts +0 -27
  372. package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts.map +0 -1
  373. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts +0 -33
  374. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts.map +0 -1
  375. package/build-types/image-editor/react/components/viewport-provider.d.ts +0 -6
  376. package/build-types/image-editor/react/components/viewport-provider.d.ts.map +0 -1
  377. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts +0 -44
  378. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts.map +0 -1
  379. package/build-types/image-editor/react/hooks/index.d.ts +0 -5
  380. package/build-types/image-editor/react/hooks/index.d.ts.map +0 -1
  381. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts +0 -14
  382. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts.map +0 -1
  383. package/build-types/image-editor/react/hooks/use-cropper-reducer.d.ts +0 -55
  384. package/build-types/image-editor/react/hooks/use-cropper-reducer.d.ts.map +0 -1
  385. package/build-types/image-editor/react/hooks/use-interaction.d.ts +0 -65
  386. package/build-types/image-editor/react/hooks/use-interaction.d.ts.map +0 -1
  387. package/build-types/image-editor/react/hooks/use-transform-style.d.ts +0 -13
  388. package/build-types/image-editor/react/hooks/use-transform-style.d.ts.map +0 -1
  389. package/build-types/image-editor/react/hooks/use-viewport-state.d.ts +0 -16
  390. package/build-types/image-editor/react/hooks/use-viewport-state.d.ts.map +0 -1
  391. package/build-types/image-editor/react/visually-hidden-style.d.ts +0 -6
  392. package/build-types/image-editor/react/visually-hidden-style.d.ts.map +0 -1
  393. package/src/components/media-editor-modal/build-modifiers.ts +0 -161
  394. package/src/image-editor/README.md +0 -61
  395. package/src/image-editor/core/camera.ts +0 -429
  396. package/src/image-editor/core/constants.ts +0 -150
  397. package/src/image-editor/core/containment.ts +0 -469
  398. package/src/image-editor/core/crop-rect.ts +0 -42
  399. package/src/image-editor/core/export/canvas-renderer.ts +0 -250
  400. package/src/image-editor/core/index.ts +0 -47
  401. package/src/image-editor/core/interaction-controller.ts +0 -976
  402. package/src/image-editor/core/math/rotation.ts +0 -26
  403. package/src/image-editor/core/math/sanitize.ts +0 -155
  404. package/src/image-editor/core/setter-helpers.ts +0 -63
  405. package/src/image-editor/core/source-region.ts +0 -367
  406. package/src/image-editor/core/state.ts +0 -484
  407. package/src/image-editor/core/stencil-math.ts +0 -379
  408. package/src/image-editor/core/transform-style.ts +0 -56
  409. package/src/image-editor/core/transforms/pipeline.ts +0 -40
  410. package/src/image-editor/core/types.ts +0 -230
  411. package/src/image-editor/core/viewport-state.ts +0 -30
  412. package/src/image-editor/docs/architecture.md +0 -63
  413. package/src/image-editor/docs/recipes.md +0 -184
  414. package/src/image-editor/index.ts +0 -52
  415. package/src/image-editor/react/components/cropper-provider.tsx +0 -70
  416. package/src/image-editor/react/components/cropper.scss +0 -259
  417. package/src/image-editor/react/components/cropper.tsx +0 -1116
  418. package/src/image-editor/react/components/index.ts +0 -3
  419. package/src/image-editor/react/components/overlays/dimensions-overlay.tsx +0 -262
  420. package/src/image-editor/react/components/overlays/dimming-overlay.tsx +0 -55
  421. package/src/image-editor/react/components/overlays/grid-overlay.tsx +0 -77
  422. package/src/image-editor/react/components/stencils/rectangle-stencil.tsx +0 -623
  423. package/src/image-editor/react/components/viewport-provider.tsx +0 -32
  424. package/src/image-editor/react/hooks/build-cropper-setters.ts +0 -102
  425. package/src/image-editor/react/hooks/index.ts +0 -4
  426. package/src/image-editor/react/hooks/use-aria-announcer.ts +0 -193
  427. package/src/image-editor/react/hooks/use-cropper-reducer.ts +0 -197
  428. package/src/image-editor/react/hooks/use-interaction.ts +0 -294
  429. package/src/image-editor/react/hooks/use-transform-style.ts +0 -23
  430. package/src/image-editor/react/hooks/use-viewport-state.ts +0 -41
  431. package/src/image-editor/react/visually-hidden-style.ts +0 -15
  432. package/src/image-editor/style.scss +0 -1
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/state/use-media-editor-state.ts"],
4
- "sourcesContent": ["import {\n\tuseCallback,\n\tuseMemo,\n\tuseReducer,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport {\n\tDEFAULT_STATE,\n\tORIGINAL_ASPECT_RATIO,\n\tareCropperStatesEqual,\n\tbuildCropperSetters,\n\tenforceContainment,\n\texportCroppedImage,\n\ttype CropperAction,\n\ttype CropperController,\n\ttype CropperState,\n\ttype NormalizedRect,\n\ttype Size,\n} from '../image-editor';\nimport {\n\tmediaEditorReducer,\n\tareMediaEditorStatesEqual,\n\tbuildInitialMediaEditorState,\n} from './composite-reducer';\nimport type {\n\tCropOptionsSlice,\n\tEditsSlice,\n\tEditValue,\n\tMediaEditorAction,\n\tMediaEditorState,\n} from './types';\n\n/**\n * Resolve an aspect-ratio preset value (the string the dropdown\n * round-trips) into a numeric width/height ratio for the cropper.\n *\n * - `'0'` → `undefined` (Free; no lock)\n * - `'-1'` (Original) → image's natural width / height, or `undefined`\n * if no image is loaded.\n * - Any positive decimal → the parsed number.\n *\n * Centralizing here means the dropdown, the action dispatcher, and\n * the test harness all resolve the same way.\n *\n * @param presetKey Preset value from the dropdown.\n * @param cropperImage The cropper's loaded image, or `null`.\n * @return The resolved ratio, or `undefined` for Free / unresolvable.\n */\nexport function resolveAspectRatio(\n\tpresetKey: string,\n\tcropperImage: CropperState[ 'image' ] | null\n): number | undefined {\n\tconst num = parseFloat( presetKey );\n\tif ( num === 0 || Number.isNaN( num ) ) {\n\t\treturn undefined;\n\t}\n\tif ( num === ORIGINAL_ASPECT_RATIO ) {\n\t\tif (\n\t\t\tcropperImage &&\n\t\t\tcropperImage.naturalWidth > 0 &&\n\t\t\tcropperImage.naturalHeight > 0\n\t\t) {\n\t\t\treturn cropperImage.naturalWidth / cropperImage.naturalHeight;\n\t\t}\n\t\treturn undefined;\n\t}\n\tif ( num > 0 ) {\n\t\treturn num;\n\t}\n\treturn undefined;\n}\n\nfunction areCropperImagesEqual(\n\ta: CropperState[ 'image' ],\n\tb: CropperState[ 'image' ]\n): boolean {\n\treturn (\n\t\ta?.src === b?.src &&\n\t\ta?.naturalWidth === b?.naturalWidth &&\n\t\ta?.naturalHeight === b?.naturalHeight\n\t);\n}\n\n/**\n * The media editor session exposed by `useMediaEditorState`.\n *\n * The session owns what is being edited and how: the source image,\n * every editing slice, the shared undo/redo history, gesture\n * boundaries, and whether the edits change the saved image. The\n * cropper is one participant in the session — `cropper` is a\n * geometry-only controller that a `<Cropper>` takes via its\n * `controller` prop — rather than the session itself.\n */\nexport interface MediaEditorSession {\n\t/**\n\t * Geometry controller for the cropper slice. Its setters record\n\t * history in the session; its `isDirty` covers geometry only.\n\t * Its `setImage` is `setSourceImage`, so the `<Cropper>` reporting\n\t * a newly loaded image starts a fresh session.\n\t */\n\tcropper: CropperController;\n\t/** The cropOptions slice. */\n\tcropOptions: CropOptionsSlice;\n\t/** Set the aspect-ratio preset. Atomic with the cropRect reshape. */\n\tsetAspectRatioValue: ( presetKey: string ) => void;\n\t/**\n\t * Put every slice back to its starting state in one undo entry:\n\t * default geometry and crop options, no edits. Keeps the image.\n\t */\n\treset: () => void;\n\t/** The named edits other than crop, keyed by edit name. */\n\tedits: EditsSlice;\n\t/**\n\t * Set a named edit, or remove it by passing `undefined`. Recorded\n\t * in the session history like any crop change. Setting a value\n\t * equal in content to the current one is a no-op.\n\t */\n\tsetEdit: ( name: string, value: EditValue | undefined ) => void;\n\t/**\n\t * Replace the image being edited. A different image starts a\n\t * fresh session: default geometry and crop options, a clean\n\t * baseline, and no history. Reporting the same image again is a\n\t * no-op.\n\t */\n\tsetSourceImage: ( image: CropperState[ 'image' ] ) => void;\n\t/**\n\t * Whether anything in the session differs from its baseline,\n\t * including editor-only state such as the aspect-ratio preset.\n\t */\n\tisDirty: boolean;\n\t/**\n\t * Whether the edits change the saved image, so saving has to\n\t * produce new image output rather than only metadata.\n\t */\n\thasOutputEdits: boolean;\n\t/** Whether there's an undoable change in history. */\n\thasUndo: boolean;\n\t/** Whether there's a redoable change in history. */\n\thasRedo: boolean;\n\t/** Undo the last committed action across all slices. */\n\tundo: () => void;\n\t/** Redo the last undone action across all slices. */\n\tredo: () => void;\n\t/**\n\t * Open a gesture boundary. During a gesture all state-changing\n\t * actions coalesce into one undo entry — the snapshot taken at\n\t * `beginGesture`. Pair with `endGesture` on pointer-up / key-up.\n\t */\n\tbeginGesture: () => void;\n\t/** Close a gesture boundary and commit the pre-gesture snapshot. */\n\tendGesture: () => void;\n}\n\n/**\n * The media editor session.\n *\n * Owns the only undo/redo history for the editor. Cropper geometry\n * actions, sidebar cropOptions actions and named edits flow through\n * the same reducer and the same history stack.\n *\n * History semantics:\n * - Each action's pre-state is pushed to the undo stack before the\n * action commits, unless a gesture is open or the action is a\n * no-op (post-state value-equal to pre-state).\n * - During a gesture (`beginGesture` → `endGesture`) all mutations\n * coalesce: only the pre-gesture snapshot is pushed, at gesture\n * end. Any pending gesture is flushed on undo/redo.\n * - Viewport-driven cropRect reshapes (window resize) use a\n * dedicated non-recording dispatch path so they never produce\n * undo entries.\n *\n * `isDirty` tracks the full editor session, including undoable UI\n * state. Use `hasOutputEdits` when deciding whether the image output\n * needs saving.\n *\n * The session starts empty. Call `setSourceImage` to load an image.\n *\n * @return The media editor session.\n */\nexport function useMediaEditorState(): MediaEditorSession {\n\tconst [ state, dispatch ] = useReducer( mediaEditorReducer, null, () =>\n\t\tbuildInitialMediaEditorState( { ...DEFAULT_STATE } )\n\t);\n\n\t// The \"clean\" snapshot the current state is compared against for\n\t// `isDirty`. Stored in state (not a ref) so the comparison reads\n\t// a value, not a ref's `current`. `setSourceImage` refreshes this when\n\t// a new image establishes a fresh baseline.\n\tconst [ initialBaseline, setInitialBaseline ] =\n\t\tuseState< MediaEditorState >( () => state );\n\n\t// Latest-state ref used by setters that need to read fresh state\n\t// (focal-point zoom, dispatch wrapper). Every mutation path\n\t// (`dispatchWithHistory`, `setSourceImage`, `undo`, `redo`) writes this\n\t// synchronously, so multiple actions in one event see the latest\n\t// reducer output before React commits.\n\tconst stateRef = useRef( state );\n\tconst visualSizeRef = useRef< Size >( { width: 0, height: 0 } );\n\n\t// History stacks: full composite snapshots. Refs avoid re-renders\n\t// on every push; a boolean state pair drives the enabled/disabled\n\t// indicators for undo/redo buttons.\n\tconst historyRef = useRef< MediaEditorState[] >( [] );\n\tconst redoStackRef = useRef< MediaEditorState[] >( [] );\n\tconst [ hasUndo, setHasUndo ] = useState( false );\n\tconst [ hasRedo, setHasRedo ] = useState( false );\n\n\t// Gesture state. While open, the first non-no-op action captures\n\t// the pre-gesture snapshot; subsequent actions don't push.\n\t// `endGesture` pushes the captured snapshot (or nothing, if the\n\t// gesture produced no changes).\n\tconst isGestureOpenRef = useRef( false );\n\tconst gestureSnapshotRef = useRef< MediaEditorState | null >( null );\n\n\tconst pushSnapshot = useCallback( ( snapshot: MediaEditorState ) => {\n\t\tconst last = historyRef.current[ historyRef.current.length - 1 ];\n\t\tif ( last && areMediaEditorStatesEqual( last, snapshot ) ) {\n\t\t\treturn;\n\t\t}\n\t\thistoryRef.current = [ ...historyRef.current, snapshot ];\n\t\tredoStackRef.current = [];\n\t\tsetHasUndo( true );\n\t\tsetHasRedo( false );\n\t}, [] );\n\n\t// Core dispatch wrapper. Synchronously computes the post-state via\n\t// the pure reducer so we can skip history pushes for no-op actions\n\t// and keep `stateRef` in lockstep with React's pending state.\n\tconst dispatchWithHistory = useCallback(\n\t\t( action: MediaEditorAction, recordHistory = true ) => {\n\t\t\tconst preState = stateRef.current;\n\t\t\tconst postState = mediaEditorReducer( preState, action );\n\t\t\tif ( recordHistory ) {\n\t\t\t\tif ( ! areMediaEditorStatesEqual( preState, postState ) ) {\n\t\t\t\t\tif ( isGestureOpenRef.current ) {\n\t\t\t\t\t\tif ( gestureSnapshotRef.current === null ) {\n\t\t\t\t\t\t\tgestureSnapshotRef.current = preState;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tpushSnapshot( preState );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tstateRef.current = postState;\n\t\t\tdispatch( action );\n\t\t},\n\t\t[ pushSnapshot ]\n\t);\n\n\tconst beginGesture = useCallback( () => {\n\t\tif ( isGestureOpenRef.current ) {\n\t\t\treturn;\n\t\t}\n\t\tisGestureOpenRef.current = true;\n\t\tgestureSnapshotRef.current = null;\n\t}, [] );\n\n\t// Close a gesture (or flush a pending one before undo/redo).\n\t// Pushes the pre-gesture snapshot only if it differs from current\n\t// state. Safe to call when no gesture is open.\n\tconst endGesture = useCallback( () => {\n\t\tconst snapshot = gestureSnapshotRef.current;\n\t\tif (\n\t\t\tsnapshot &&\n\t\t\t! areMediaEditorStatesEqual( snapshot, stateRef.current )\n\t\t) {\n\t\t\tpushSnapshot( snapshot );\n\t\t}\n\t\tgestureSnapshotRef.current = null;\n\t\tisGestureOpenRef.current = false;\n\t}, [ pushSnapshot ] );\n\n\t// =====================================================================\n\t// Cropper-slice setters (built from the shared factory so the pure\n\t// hook and this composite stay in lockstep — add a setter in\n\t// `buildCropperSetters` once and both hooks get it).\n\t// =====================================================================\n\n\tconst dispatchCropperAction = useCallback(\n\t\t( action: CropperAction ) => {\n\t\t\tdispatchWithHistory( { type: 'CROPPER', action } );\n\t\t},\n\t\t[ dispatchWithHistory ]\n\t);\n\n\tconst cropperSetters = useMemo(\n\t\t() =>\n\t\t\tbuildCropperSetters(\n\t\t\t\tdispatchCropperAction,\n\t\t\t\t() => stateRef.current.cropper\n\t\t\t),\n\t\t[ dispatchCropperAction ]\n\t);\n\n\tconst setSourceImage = useCallback( ( image: CropperState[ 'image' ] ) => {\n\t\tif ( areCropperImagesEqual( stateRef.current.cropper.image, image ) ) {\n\t\t\treturn;\n\t\t}\n\t\t// New image = fresh session: default geometry and crop options, a\n\t\t// clean baseline, and no history. Built from defaults rather than\n\t\t// dispatching SET_IMAGE, which keeps the current pan / zoom /\n\t\t// rotation / flip / cropRect — edits made against one image must\n\t\t// not survive onto another.\n\t\tconst next = buildInitialMediaEditorState(\n\t\t\tenforceContainment( { ...DEFAULT_STATE, image } )\n\t\t);\n\t\tstateRef.current = next;\n\t\tdispatch( { type: 'RESTORE_SNAPSHOT', payload: next } );\n\t\tsetInitialBaseline( next );\n\t\tisGestureOpenRef.current = false;\n\t\tgestureSnapshotRef.current = null;\n\t\thistoryRef.current = [];\n\t\tredoStackRef.current = [];\n\t\tsetHasUndo( false );\n\t\tsetHasRedo( false );\n\t}, [] );\n\n\tconst resetCropper = useCallback(\n\t\t( resetState?: Partial< CropperState > ) => {\n\t\t\tdispatchWithHistory( {\n\t\t\t\ttype: 'CROPPER',\n\t\t\t\taction: { type: 'RESET', payload: resetState },\n\t\t\t} );\n\t\t},\n\t\t[ dispatchWithHistory ]\n\t);\n\n\t// =====================================================================\n\t// CropOptions-slice setters\n\t// =====================================================================\n\n\tconst setAspectRatioValue = useCallback(\n\t\t( presetKey: string ) => {\n\t\t\tconst resolved = resolveAspectRatio(\n\t\t\t\tpresetKey,\n\t\t\t\tstateRef.current.cropper.image\n\t\t\t);\n\t\t\tdispatchWithHistory( {\n\t\t\t\ttype: 'SET_ASPECT_RATIO_VALUE',\n\t\t\t\tpayload: {\n\t\t\t\t\tpresetKey,\n\t\t\t\t\tresolved,\n\t\t\t\t\tvisualSize: visualSizeRef.current,\n\t\t\t\t},\n\t\t\t} );\n\t\t},\n\t\t[ dispatchWithHistory ]\n\t);\n\n\t// =====================================================================\n\t// Session\n\t// =====================================================================\n\n\tconst reset = useCallback( () => {\n\t\tdispatchWithHistory( { type: 'RESET' } );\n\t}, [ dispatchWithHistory ] );\n\n\t// =====================================================================\n\t// Edits-slice setters\n\t// =====================================================================\n\n\tconst setEdit = useCallback(\n\t\t( name: string, value: EditValue | undefined ) => {\n\t\t\tdispatchWithHistory( {\n\t\t\t\ttype: 'SET_EDIT',\n\t\t\t\tpayload: { name, value },\n\t\t\t} );\n\t\t},\n\t\t[ dispatchWithHistory ]\n\t);\n\n\t// =====================================================================\n\t// History\n\t// =====================================================================\n\n\tconst undo = useCallback( () => {\n\t\tendGesture();\n\t\tconst prev = historyRef.current[ historyRef.current.length - 1 ];\n\t\tif ( ! prev ) {\n\t\t\treturn;\n\t\t}\n\t\tredoStackRef.current = [ stateRef.current, ...redoStackRef.current ];\n\t\thistoryRef.current = historyRef.current.slice( 0, -1 );\n\t\tsetHasUndo( historyRef.current.length > 0 );\n\t\tsetHasRedo( true );\n\t\tstateRef.current = prev;\n\t\tdispatch( { type: 'RESTORE_SNAPSHOT', payload: prev } );\n\t}, [ endGesture ] );\n\n\tconst redo = useCallback( () => {\n\t\tendGesture();\n\t\tconst next = redoStackRef.current[ 0 ];\n\t\tif ( ! next ) {\n\t\t\treturn;\n\t\t}\n\t\thistoryRef.current = [ ...historyRef.current, stateRef.current ];\n\t\tredoStackRef.current = redoStackRef.current.slice( 1 );\n\t\tsetHasUndo( true );\n\t\tsetHasRedo( redoStackRef.current.length > 0 );\n\t\tstateRef.current = next;\n\t\tdispatch( { type: 'RESTORE_SNAPSHOT', payload: next } );\n\t}, [ endGesture ] );\n\n\t// =====================================================================\n\t// Viewport\n\t// =====================================================================\n\n\tconst setVisualSize = useCallback( ( size: Size ) => {\n\t\tvisualSizeRef.current = size;\n\t}, [] );\n\n\tconst adjustCropRectForViewport = useCallback(\n\t\t( rect: NormalizedRect ) => {\n\t\t\tdispatchWithHistory(\n\t\t\t\t{ type: 'VIEWPORT_ADJUST_CROP_RECT', payload: rect },\n\t\t\t\tfalse\n\t\t\t);\n\t\t},\n\t\t[ dispatchWithHistory ]\n\t);\n\n\t// =====================================================================\n\t// Derived\n\t// =====================================================================\n\n\tconst isDirty = ! areMediaEditorStatesEqual( state, initialBaseline );\n\tconst isCropperDirty = ! areCropperStatesEqual(\n\t\tstate.cropper,\n\t\tinitialBaseline.cropper\n\t);\n\n\tconst getCroppedImage = useCallback(\n\t\t( mimeType?: string, quality?: number ): Promise< Blob > => {\n\t\t\tif ( ! state.cropper.image ) {\n\t\t\t\treturn Promise.reject(\n\t\t\t\t\tnew Error( 'No image loaded — call setSourceImage first.' )\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn exportCroppedImage(\n\t\t\t\tstate.cropper.image.src,\n\t\t\t\tstate.cropper,\n\t\t\t\tmimeType,\n\t\t\t\tquality\n\t\t\t);\n\t\t},\n\t\t[ state.cropper ]\n\t);\n\n\tconst cropper = useMemo< CropperController >(\n\t\t() => ( {\n\t\t\t...cropperSetters,\n\t\t\tstate: state.cropper,\n\t\t\tsetImage: setSourceImage,\n\t\t\treset: resetCropper,\n\t\t\tisDirty: isCropperDirty,\n\t\t\tgetCroppedImage,\n\t\t\tsetVisualSize,\n\t\t\tadjustCropRectForViewport,\n\t\t} ),\n\t\t[\n\t\t\tcropperSetters,\n\t\t\tstate.cropper,\n\t\t\tsetSourceImage,\n\t\t\tresetCropper,\n\t\t\tisCropperDirty,\n\t\t\tgetCroppedImage,\n\t\t\tsetVisualSize,\n\t\t\tadjustCropRectForViewport,\n\t\t]\n\t);\n\n\tconst session = useMemo< MediaEditorSession >(\n\t\t() => ( {\n\t\t\tcropper,\n\t\t\tcropOptions: state.cropOptions,\n\t\t\tsetAspectRatioValue,\n\t\t\tedits: state.edits,\n\t\t\tsetEdit,\n\t\t\tsetSourceImage,\n\t\t\treset,\n\t\t\tisDirty,\n\t\t\t// Only geometry changes the saved image so far.\n\t\t\thasOutputEdits: isCropperDirty,\n\t\t\thasUndo,\n\t\t\thasRedo,\n\t\t\tundo,\n\t\t\tredo,\n\t\t\tbeginGesture,\n\t\t\tendGesture,\n\t\t} ),\n\t\t[\n\t\t\tcropper,\n\t\t\tstate.cropOptions,\n\t\t\tsetAspectRatioValue,\n\t\t\tstate.edits,\n\t\t\tsetEdit,\n\t\t\tsetSourceImage,\n\t\t\treset,\n\t\t\tisDirty,\n\t\t\tisCropperDirty,\n\t\t\thasUndo,\n\t\t\thasRedo,\n\t\t\tundo,\n\t\t\tredo,\n\t\t\tbeginGesture,\n\t\t\tendGesture,\n\t\t]\n\t);\n\treturn session;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAMO;AACP,0BAYO;AACP,+BAIO;AAyBA,SAAS,mBACf,WACA,cACqB;AACrB,QAAM,MAAM,WAAY,SAAU;AAClC,MAAK,QAAQ,KAAK,OAAO,MAAO,GAAI,GAAI;AACvC,WAAO;AAAA,EACR;AACA,MAAK,QAAQ,2CAAwB;AACpC,QACC,gBACA,aAAa,eAAe,KAC5B,aAAa,gBAAgB,GAC5B;AACD,aAAO,aAAa,eAAe,aAAa;AAAA,IACjD;AACA,WAAO;AAAA,EACR;AACA,MAAK,MAAM,GAAI;AACd,WAAO;AAAA,EACR;AACA,SAAO;AACR;AAEA,SAAS,sBACR,GACA,GACU;AACV,SACC,GAAG,QAAQ,GAAG,OACd,GAAG,iBAAiB,GAAG,gBACvB,GAAG,kBAAkB,GAAG;AAE1B;AAkGO,SAAS,sBAA0C;AACzD,QAAM,CAAE,OAAO,QAAS,QAAI;AAAA,IAAY;AAAA,IAAoB;AAAA,IAAM,UACjE,uDAA8B,EAAE,GAAG,kCAAc,CAAE;AAAA,EACpD;AAMA,QAAM,CAAE,iBAAiB,kBAAmB,QAC3C,yBAA8B,MAAM,KAAM;AAO3C,QAAM,eAAW,uBAAQ,KAAM;AAC/B,QAAM,oBAAgB,uBAAgB,EAAE,OAAO,GAAG,QAAQ,EAAE,CAAE;AAK9D,QAAM,iBAAa,uBAA8B,CAAC,CAAE;AACpD,QAAM,mBAAe,uBAA8B,CAAC,CAAE;AACtD,QAAM,CAAE,SAAS,UAAW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,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AACA,SAAO;AACR;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"use-media-editor-state.cjs","names":["ORIGINAL_ASPECT_RATIO","useReducer","mediaEditorReducer","buildInitialMediaEditorState","createImageEditorState","useState","useRef","useCallback","areMediaEditorStatesEqual","useImageEditor","useMemo"],"sources":["../../src/state/use-media-editor-state.ts"],"sourcesContent":["import {\n\tuseCallback,\n\tuseMemo,\n\tuseReducer,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport {\n\tcreateImageEditorState,\n\tuseImageEditor,\n\ttype ImageEditorController,\n\ttype ImageEditorState,\n} from '@wordpress/image-editor';\nimport { ORIGINAL_ASPECT_RATIO } from './aspect-ratio-presets';\nimport {\n\tmediaEditorReducer,\n\tareMediaEditorStatesEqual,\n\tbuildInitialMediaEditorState,\n} from './composite-reducer';\nimport type {\n\tCropOptionsSlice,\n\tEditsSlice,\n\tEditValue,\n\tMediaEditorAction,\n\tMediaEditorState,\n} from './types';\n\n/**\n * Resolve an aspect-ratio preset value (the string the dropdown\n * round-trips) into a numeric width/height ratio for the image editor.\n *\n * - `'0'` → `undefined` (Free; no lock)\n * - `'-1'` (Original) → image's natural width / height, or `undefined`\n * if no image is loaded.\n * - Any positive decimal → the parsed number.\n *\n * @param presetKey Preset value from the dropdown.\n * @param image The image editor's loaded image, or `null`.\n * @return The resolved ratio, or `undefined` for Free / unresolvable.\n */\nfunction resolveAspectRatio(\n\tpresetKey: string,\n\timage: ImageEditorState[ 'image' ] | null\n): number | undefined {\n\tconst num = parseFloat( presetKey );\n\tif ( num === 0 || Number.isNaN( num ) ) {\n\t\treturn undefined;\n\t}\n\tif ( num === ORIGINAL_ASPECT_RATIO ) {\n\t\tif ( image && image.naturalWidth > 0 && image.naturalHeight > 0 ) {\n\t\t\treturn image.naturalWidth / image.naturalHeight;\n\t\t}\n\t\treturn undefined;\n\t}\n\tif ( num > 0 ) {\n\t\treturn num;\n\t}\n\treturn undefined;\n}\n\nfunction areImagesEqual(\n\ta: ImageEditorState[ 'image' ],\n\tb: ImageEditorState[ 'image' ]\n): boolean {\n\treturn (\n\t\ta?.src === b?.src &&\n\t\ta?.naturalWidth === b?.naturalWidth &&\n\t\ta?.naturalHeight === b?.naturalHeight\n\t);\n}\n\n/**\n * The media editor session exposed by `useMediaEditorState`.\n *\n * The session owns what is being edited and how: the source image,\n * every editing slice, the shared undo/redo history, gesture\n * boundaries, and whether the edits change the saved image. The\n * image editor is one participant in the session — `imageEditor` is the\n * controller an `<ImageEditorCanvas>` takes via its `controller` prop — rather\n * than the session itself.\n */\nexport interface MediaEditorSession {\n\t/**\n\t * Controller for the image editor. Its setters record history in the\n\t * session; its `isDirty` covers the crop only. Its `setImage` is\n\t * `setSourceImage`, so the `<ImageEditorCanvas>` reporting a newly loaded\n\t * image starts a fresh session.\n\t */\n\timageEditor: ImageEditorController;\n\t/** The cropOptions slice. */\n\tcropOptions: CropOptionsSlice;\n\t/** Set the aspect-ratio preset and reshape the crop in one undo entry. */\n\tsetAspectRatioValue: ( presetKey: string ) => void;\n\t/**\n\t * Put every slice back to its starting state in one undo entry:\n\t * default crop and crop options, no edits. Keeps the image.\n\t */\n\treset: () => void;\n\t/** The named edits other than crop, keyed by edit name. */\n\tedits: EditsSlice;\n\t/**\n\t * Set a named edit, or remove it by passing `undefined`. Recorded\n\t * in the session history like any crop change. Setting a value\n\t * equal in content to the current one is a no-op.\n\t */\n\tsetEdit: ( name: string, value: EditValue | undefined ) => void;\n\t/**\n\t * Replace the image being edited. A different image starts a\n\t * fresh session: default crop and crop options, a clean baseline,\n\t * and no history. Reporting the same image again is a no-op.\n\t */\n\tsetSourceImage: ( image: ImageEditorState[ 'image' ] ) => void;\n\t/**\n\t * Whether anything in the session differs from its baseline,\n\t * including editor-only state such as the aspect-ratio preset.\n\t */\n\tisDirty: boolean;\n\t/**\n\t * Whether the edits change the saved image, so saving has to\n\t * produce new image output rather than only metadata.\n\t */\n\thasOutputEdits: boolean;\n\t/** Whether there's an undoable change in history. */\n\thasUndo: boolean;\n\t/** Whether there's a redoable change in history. */\n\thasRedo: boolean;\n\t/** Undo the last committed change across all slices. */\n\tundo: () => void;\n\t/** Redo the last undone change across all slices. */\n\tredo: () => void;\n\t/**\n\t * Open a gesture boundary. During a gesture all changes coalesce\n\t * into one undo entry — the snapshot taken at `beginGesture`. Pair\n\t * with `endGesture` on pointer-up / key-up.\n\t */\n\tbeginGesture: () => void;\n\t/** Close a gesture boundary and commit the pre-gesture snapshot. */\n\tendGesture: () => void;\n}\n\n/**\n * The media editor session.\n *\n * Owns the only undo/redo history for the editor. The image editor's state,\n * the sidebar crop options and named edits are slices of one state, so\n * one history stack covers them all. The image editor works out its own\n * changes and reports each next state through `onChange`.\n *\n * History semantics:\n * - Each change pushes its pre-state to the undo stack, unless a\n * gesture is open or the change is a no-op (post-state value-equal\n * to pre-state).\n * - During a gesture (`beginGesture` → `endGesture`) changes coalesce:\n * only the pre-gesture snapshot is pushed, at gesture end. Undo and\n * redo close an open gesture first.\n * - Changes the image editor marks as not edits (an image loading, a refit\n * after a window resize) are never recorded.\n *\n * `isDirty` tracks the full session, including undoable UI state. Use\n * `hasOutputEdits` when deciding whether the image output needs saving.\n *\n * The session starts empty. Call `setSourceImage` to load an image.\n *\n * @return The media editor session.\n */\nexport function useMediaEditorState(): MediaEditorSession {\n\tconst [ state, dispatch ] = useReducer( mediaEditorReducer, null, () =>\n\t\tbuildInitialMediaEditorState( createImageEditorState() )\n\t);\n\n\t// The \"clean\" snapshot the current state is compared against for\n\t// `isDirty`. `setSourceImage` refreshes it when a new image starts a\n\t// fresh session.\n\tconst [ initialBaseline, setInitialBaseline ] =\n\t\tuseState< MediaEditorState >( () => state );\n\n\t// Latest state, so several actions in one event see each other's\n\t// output before React commits. Every mutation path writes it\n\t// synchronously.\n\tconst stateRef = useRef( state );\n\n\t// History stacks: full snapshots. Refs avoid re-renders on every\n\t// push; a boolean state pair drives the undo/redo indicators.\n\tconst historyRef = useRef< MediaEditorState[] >( [] );\n\tconst redoStackRef = useRef< MediaEditorState[] >( [] );\n\tconst [ hasUndo, setHasUndo ] = useState( false );\n\tconst [ hasRedo, setHasRedo ] = useState( false );\n\n\t// Gesture state. While open, the first change captures the\n\t// pre-gesture snapshot; later changes don't push.\n\tconst isGestureOpenRef = useRef( false );\n\tconst gestureSnapshotRef = useRef< MediaEditorState | null >( null );\n\n\tconst pushSnapshot = useCallback( ( snapshot: MediaEditorState ) => {\n\t\tconst last = historyRef.current[ historyRef.current.length - 1 ];\n\t\tif ( last && areMediaEditorStatesEqual( last, snapshot ) ) {\n\t\t\treturn;\n\t\t}\n\t\thistoryRef.current = [ ...historyRef.current, snapshot ];\n\t\tredoStackRef.current = [];\n\t\tsetHasUndo( true );\n\t\tsetHasRedo( false );\n\t}, [] );\n\n\tconst dispatchWithHistory = useCallback(\n\t\t( action: MediaEditorAction, recordHistory = true ) => {\n\t\t\tconst preState = stateRef.current;\n\t\t\tconst postState = mediaEditorReducer( preState, action );\n\t\t\tif (\n\t\t\t\trecordHistory &&\n\t\t\t\t! areMediaEditorStatesEqual( preState, postState )\n\t\t\t) {\n\t\t\t\tif ( isGestureOpenRef.current ) {\n\t\t\t\t\tif ( gestureSnapshotRef.current === null ) {\n\t\t\t\t\t\tgestureSnapshotRef.current = preState;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tpushSnapshot( preState );\n\t\t\t\t}\n\t\t\t}\n\t\t\tstateRef.current = postState;\n\t\t\tdispatch( action );\n\t\t},\n\t\t[ pushSnapshot ]\n\t);\n\n\tconst beginGesture = useCallback( () => {\n\t\tif ( isGestureOpenRef.current ) {\n\t\t\treturn;\n\t\t}\n\t\tisGestureOpenRef.current = true;\n\t\tgestureSnapshotRef.current = null;\n\t}, [] );\n\n\t// Close a gesture (or flush a pending one before undo/redo). Pushes\n\t// the pre-gesture snapshot only if it differs from the current\n\t// state. Safe to call when no gesture is open.\n\tconst endGesture = useCallback( () => {\n\t\tconst snapshot = gestureSnapshotRef.current;\n\t\tif (\n\t\t\tsnapshot &&\n\t\t\t! areMediaEditorStatesEqual( snapshot, stateRef.current )\n\t\t) {\n\t\t\tpushSnapshot( snapshot );\n\t\t}\n\t\tgestureSnapshotRef.current = null;\n\t\tisGestureOpenRef.current = false;\n\t}, [ pushSnapshot ] );\n\n\t// Run several changes as one undo entry, unless a gesture is already\n\t// open, which groups them anyway.\n\tconst asOneUndoEntry = useCallback(\n\t\t( run: () => void ) => {\n\t\t\tif ( isGestureOpenRef.current ) {\n\t\t\t\trun();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tbeginGesture();\n\t\t\trun();\n\t\t\tendGesture();\n\t\t},\n\t\t[ beginGesture, endGesture ]\n\t);\n\n\tconst setSourceImage = useCallback(\n\t\t( image: ImageEditorState[ 'image' ] ) => {\n\t\t\tif ( areImagesEqual( stateRef.current.imageEditor.image, image ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// New image = fresh session: default crop and crop options, a\n\t\t\t// clean baseline, and no history. Edits made against one\n\t\t\t// image must not survive onto another.\n\t\t\tconst next = buildInitialMediaEditorState(\n\t\t\t\tcreateImageEditorState( { image } )\n\t\t\t);\n\t\t\tstateRef.current = next;\n\t\t\tdispatch( { type: 'RESTORE_SNAPSHOT', payload: next } );\n\t\t\tsetInitialBaseline( next );\n\t\t\tisGestureOpenRef.current = false;\n\t\t\tgestureSnapshotRef.current = null;\n\t\t\thistoryRef.current = [];\n\t\t\tredoStackRef.current = [];\n\t\t\tsetHasUndo( false );\n\t\t\tsetHasRedo( false );\n\t\t},\n\t\t[]\n\t);\n\n\tconst handleImageEditorChange = useCallback(\n\t\t( nextState: ImageEditorState, { isEdit }: { isEdit: boolean } ) => {\n\t\t\tif (\n\t\t\t\t! areImagesEqual(\n\t\t\t\t\tstateRef.current.imageEditor.image,\n\t\t\t\t\tnextState.image\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tsetSourceImage( nextState.image );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tdispatchWithHistory(\n\t\t\t\t{ type: 'SET_IMAGE_EDITOR', payload: nextState },\n\t\t\t\tisEdit\n\t\t\t);\n\t\t},\n\t\t[ dispatchWithHistory, setSourceImage ]\n\t);\n\n\tconst imageEditorController = useImageEditor( {\n\t\tstate: state.imageEditor,\n\t\tonChange: handleImageEditorChange,\n\t} );\n\n\t// The locked ratio has two owners: the preset the sidebar shows, and\n\t// the number the image editor holds. This is the only path that sets\n\t// both, so call it rather than `imageEditor.setAspectRatio`, which\n\t// would leave the sidebar showing a ratio the crop no longer has.\n\tconst setAspectRatioValue = useCallback(\n\t\t( presetKey: string ) => {\n\t\t\tasOneUndoEntry( () => {\n\t\t\t\tdispatchWithHistory( {\n\t\t\t\t\ttype: 'SET_ASPECT_RATIO_VALUE',\n\t\t\t\t\tpayload: presetKey,\n\t\t\t\t} );\n\t\t\t\timageEditorController.setAspectRatio(\n\t\t\t\t\tresolveAspectRatio(\n\t\t\t\t\t\tpresetKey,\n\t\t\t\t\t\tstateRef.current.imageEditor.image\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t} );\n\t\t},\n\t\t[ asOneUndoEntry, dispatchWithHistory, imageEditorController ]\n\t);\n\n\tconst reset = useCallback( () => {\n\t\tdispatchWithHistory( { type: 'RESET' } );\n\t}, [ dispatchWithHistory ] );\n\n\tconst setEdit = useCallback(\n\t\t( name: string, value: EditValue | undefined ) => {\n\t\t\tdispatchWithHistory( {\n\t\t\t\ttype: 'SET_EDIT',\n\t\t\t\tpayload: { name, value },\n\t\t\t} );\n\t\t},\n\t\t[ dispatchWithHistory ]\n\t);\n\n\tconst undo = useCallback( () => {\n\t\tendGesture();\n\t\tconst prev = historyRef.current[ historyRef.current.length - 1 ];\n\t\tif ( ! prev ) {\n\t\t\treturn;\n\t\t}\n\t\tredoStackRef.current = [ stateRef.current, ...redoStackRef.current ];\n\t\thistoryRef.current = historyRef.current.slice( 0, -1 );\n\t\tsetHasUndo( historyRef.current.length > 0 );\n\t\tsetHasRedo( true );\n\t\tstateRef.current = prev;\n\t\tdispatch( { type: 'RESTORE_SNAPSHOT', payload: prev } );\n\t}, [ endGesture ] );\n\n\tconst redo = useCallback( () => {\n\t\tendGesture();\n\t\tconst next = redoStackRef.current[ 0 ];\n\t\tif ( ! next ) {\n\t\t\treturn;\n\t\t}\n\t\thistoryRef.current = [ ...historyRef.current, stateRef.current ];\n\t\tredoStackRef.current = redoStackRef.current.slice( 1 );\n\t\tsetHasUndo( true );\n\t\tsetHasRedo( redoStackRef.current.length > 0 );\n\t\tstateRef.current = next;\n\t\tdispatch( { type: 'RESTORE_SNAPSHOT', payload: next } );\n\t}, [ endGesture ] );\n\n\tconst imageEditor = useMemo< ImageEditorController >(\n\t\t() => ( { ...imageEditorController, setImage: setSourceImage } ),\n\t\t[ imageEditorController, setSourceImage ]\n\t);\n\n\tconst isDirty = ! areMediaEditorStatesEqual( state, initialBaseline );\n\n\treturn useMemo(\n\t\t() => ( {\n\t\t\timageEditor,\n\t\t\tcropOptions: state.cropOptions,\n\t\t\tsetAspectRatioValue,\n\t\t\tedits: state.edits,\n\t\t\tsetEdit,\n\t\t\tsetSourceImage,\n\t\t\treset,\n\t\t\tisDirty,\n\t\t\t// Only the crop changes the saved image so far.\n\t\t\t//\n\t\t\t// This reads the image editor's own clean state, not the\n\t\t\t// session's. The two agree because the session only ever\n\t\t\t// replaces the editor's slice with a state the editor handed\n\t\t\t// out, and because a fresh state for an image matches the\n\t\t\t// default one on every field `isDirty` compares. Change\n\t\t\t// either and this has to compare against the session's\n\t\t\t// baseline instead.\n\t\t\thasOutputEdits: imageEditor.isDirty,\n\t\t\thasUndo,\n\t\t\thasRedo,\n\t\t\tundo,\n\t\t\tredo,\n\t\t\tbeginGesture,\n\t\t\tendGesture,\n\t\t} ),\n\t\t[\n\t\t\timageEditor,\n\t\t\tstate.cropOptions,\n\t\t\tsetAspectRatioValue,\n\t\t\tstate.edits,\n\t\t\tsetEdit,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5B;EACA;EACA;EACA;EACA;EACA;CACD,IACA;EACC;EACA,MAAM;EACN;EACA,MAAM;EACN;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD,CACD;AACD"}
@@ -1,49 +1,22 @@
1
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
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
25
5
  });
26
- module.exports = __toCommonJS(actions_exports);
27
- function openMediaEditorModal({
28
- id,
29
- onUpdate,
30
- onUndo,
31
- onClose
32
- }) {
33
- return {
34
- type: "OPEN_MEDIA_EDITOR_MODAL",
35
- id,
36
- onUpdate: onUpdate ?? null,
37
- onUndo: onUndo ?? null,
38
- onClose: onClose ?? null
39
- };
6
+ // packages/media-editor/src/store/actions.ts
7
+ function openMediaEditorModal({ id, onUpdate, onUndo, onClose }) {
8
+ return {
9
+ type: "OPEN_MEDIA_EDITOR_MODAL",
10
+ id,
11
+ onUpdate: onUpdate ?? null,
12
+ onUndo: onUndo ?? null,
13
+ onClose: onClose ?? null
14
+ };
40
15
  }
41
16
  function closeMediaEditorModal() {
42
- return { type: "CLOSE_MEDIA_EDITOR_MODAL" };
17
+ return { type: "CLOSE_MEDIA_EDITOR_MODAL" };
43
18
  }
44
- // Annotate the CommonJS export names for ESM import in node:
45
- 0 && (module.exports = {
46
- closeMediaEditorModal,
47
- openMediaEditorModal
48
- });
49
- //# sourceMappingURL=actions.cjs.map
19
+ exports.closeMediaEditorModal = closeMediaEditorModal;
20
+ exports.openMediaEditorModal = openMediaEditorModal;
21
+
22
+ //# sourceMappingURL=actions.cjs.map
@@ -1,7 +1 @@
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\t/**\n\t * Restore the caller's state after a saved attachment change. May run\n\t * before an asynchronous `onUpdate` finishes; the caller should cancel\n\t * that update. Without this callback, Undo calls `onUpdate` with the\n\t * previous attachment's id and URL.\n\t */\n\tonUndo?: () => void;\n\tonClose?: () => void;\n}\n\nexport function openMediaEditorModal( {\n\tid,\n\tonUpdate,\n\tonUndo,\n\tonClose,\n}: OpenMediaEditorModalArgs ) {\n\treturn {\n\t\ttype: 'OPEN_MEDIA_EDITOR_MODAL' as const,\n\t\tid,\n\t\tonUpdate: onUpdate ?? null,\n\t\tonUndo: onUndo ?? null,\n\t\tonClose: onClose ?? 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;AA2BO,SAAS,qBAAsB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAA8B;AAC7B,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA,UAAU,YAAY;AAAA,IACtB,QAAQ,UAAU;AAAA,IAClB,SAAS,WAAW;AAAA,EACrB;AACD;AAEO,SAAS,wBAAwB;AACvC,SAAO,EAAE,MAAM,2BAAoC;AACpD;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"actions.cjs","names":[],"sources":["../../src/store/actions.ts"],"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\t/**\n\t * Restore the caller's state after a saved attachment change. May run\n\t * before an asynchronous `onUpdate` finishes; the caller should cancel\n\t * that update. Without this callback, Undo calls `onUpdate` with the\n\t * previous attachment's id and URL.\n\t */\n\tonUndo?: () => void;\n\tonClose?: () => void;\n}\n\nexport function openMediaEditorModal( {\n\tid,\n\tonUpdate,\n\tonUndo,\n\tonClose,\n}: OpenMediaEditorModalArgs ) {\n\treturn {\n\t\ttype: 'OPEN_MEDIA_EDITOR_MODAL' as const,\n\t\tid,\n\t\tonUpdate: onUpdate ?? null,\n\t\tonUndo: onUndo ?? null,\n\t\tonClose: onClose ?? null,\n\t};\n}\n\nexport function closeMediaEditorModal() {\n\treturn { type: 'CLOSE_MEDIA_EDITOR_MODAL' as const };\n}\n"],"mappings":";;;;;;AA2BA,SAAgB,qBAAsB,EACrC,IACA,UACA,QACA,WAC6B;CAC7B,OAAO;EACN,MAAM;EACN;EACA,UAAU,YAAY;EACtB,QAAQ,UAAU;EAClB,SAAS,WAAW;CACrB;AACD;AAEA,SAAgB,wBAAwB;CACvC,OAAO,EAAE,MAAM,2BAAoC;AACpD"}
@@ -1,31 +1,10 @@
1
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
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
30
5
  });
31
- //# sourceMappingURL=constants.cjs.map
6
+ // packages/media-editor/src/store/constants.ts
7
+ const STORE_NAME = "core/media-editor";
8
+ exports.STORE_NAME = STORE_NAME;
9
+
10
+ //# sourceMappingURL=constants.cjs.map
@@ -1,7 +1 @@
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
- }
1
+ {"version":3,"file":"constants.cjs","names":[],"sources":["../../src/store/constants.ts"],"sourcesContent":["export const STORE_NAME = 'core/media-editor';\n"],"mappings":";;;;;;AAAA,MAAa,aAAa"}
@@ -1,51 +1,44 @@
1
1
  "use strict";
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
5
+ });
6
+ // \0rolldown/runtime.js
2
7
  var __create = Object.create;
3
8
  var __defProp = Object.defineProperty;
4
9
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
10
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
11
  var __getProtoOf = Object.getPrototypeOf;
7
12
  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
13
  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;
14
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
15
+ key = keys[i];
16
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
+ get: ((k) => from[k]).bind(null, key),
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ return to;
19
22
  };
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
-
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
24
+ value: mod,
25
+ enumerable: true
26
+ }) : target, mod));
27
+ let _wordpress_data = require("@wordpress/data");
28
+ let __reducer_ts = require("./reducer.cjs");
29
+ __reducer_ts = __toESM(__reducer_ts);
30
+ let __actions_ts = require("./actions.cjs");
31
+ __actions_ts = __toESM(__actions_ts);
32
+ let __selectors_ts = require("./selectors.cjs");
33
+ __selectors_ts = __toESM(__selectors_ts);
34
+ let __constants_ts = require("./constants.cjs");
30
35
  // packages/media-editor/src/store/index.ts
31
- var store_exports = {};
32
- __export(store_exports, {
33
- store: () => store
36
+ const store = (0, _wordpress_data.createReduxStore)(__constants_ts.STORE_NAME, {
37
+ reducer: __reducer_ts.default,
38
+ actions: __actions_ts,
39
+ selectors: __selectors_ts
34
40
  });
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
41
+ (0, _wordpress_data.register)(store);
42
+ exports.store = store;
43
+
44
+ //# sourceMappingURL=index.cjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/store/index.ts"],
4
- "sourcesContent": ["import { createReduxStore, register } from '@wordpress/data';\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;AAAA,kBAA2C;AAC3C,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
- }
1
+ {"version":3,"file":"index.cjs","names":["createReduxStore","STORE_NAME","register"],"sources":["../../src/store/index.ts"],"sourcesContent":["import { createReduxStore, register } from '@wordpress/data';\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAa,SAAA,GAAQA,gBAAAA,iBAAAA,CAAkBC,eAAAA,YAAY;CAClD,SAAA,aAAA;CACA,SAAA;CACA,WAAA;AACD,CAAE;CAEFC,GAAAA,gBAAAA,SAAAA,CAAU,KAAM"}
@@ -1,55 +1,33 @@
1
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
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
25
5
  });
26
- module.exports = __toCommonJS(reducer_exports);
27
- var DEFAULT_STATE = {
28
- isOpen: false,
29
- id: null,
30
- onUpdate: null,
31
- onUndo: null,
32
- onClose: null
6
+ // packages/media-editor/src/store/reducer.ts
7
+ const DEFAULT_STATE = {
8
+ isOpen: false,
9
+ id: null,
10
+ onUpdate: null,
11
+ onUndo: null,
12
+ onClose: null
33
13
  };
34
14
  function reducer(state = DEFAULT_STATE, action) {
35
- switch (action.type) {
36
- case "OPEN_MEDIA_EDITOR_MODAL": {
37
- const { id, onUpdate, onUndo, onClose } = action;
38
- return {
39
- isOpen: true,
40
- id,
41
- onUpdate,
42
- onUndo,
43
- onClose
44
- };
45
- }
46
- case "CLOSE_MEDIA_EDITOR_MODAL":
47
- return DEFAULT_STATE;
48
- }
49
- return state;
15
+ switch (action.type) {
16
+ case "OPEN_MEDIA_EDITOR_MODAL": {
17
+ const { id, onUpdate, onUndo, onClose } = action;
18
+ return {
19
+ isOpen: true,
20
+ id,
21
+ onUpdate,
22
+ onUndo,
23
+ onClose
24
+ };
25
+ }
26
+ case "CLOSE_MEDIA_EDITOR_MODAL": return DEFAULT_STATE;
27
+ }
28
+ return state;
50
29
  }
51
- // Annotate the CommonJS export names for ESM import in node:
52
- 0 && (module.exports = {
53
- DEFAULT_STATE
54
- });
55
- //# sourceMappingURL=reducer.cjs.map
30
+ exports.DEFAULT_STATE = DEFAULT_STATE;
31
+ exports.default = reducer;
32
+
33
+ //# sourceMappingURL=reducer.cjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/store/reducer.ts"],
4
- "sourcesContent": ["import type { MediaEditorModalUpdate } from './actions';\n\ntype OnUpdateCallback = ( updated: MediaEditorModalUpdate ) => void;\ntype OnUndoCallback = () => void;\ntype OnCloseCallback = () => void;\n\nexport interface State {\n\tisOpen: boolean;\n\tid: number | null;\n\tonUpdate: OnUpdateCallback | null;\n\tonUndo: OnUndoCallback | null;\n\tonClose: OnCloseCallback | null;\n}\n\nexport const DEFAULT_STATE: State = {\n\tisOpen: false,\n\tid: null,\n\tonUpdate: null,\n\tonUndo: null,\n\tonClose: 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\t\tonUndo: OnUndoCallback | null;\n\t\t\tonClose: OnCloseCallback | 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, onUndo, onClose } = 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\tonUndo,\n\t\t\t\tonClose,\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;AAcO,IAAM,gBAAuB;AAAA,EACnC,QAAQ;AAAA,EACR,IAAI;AAAA,EACJ,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,SAAS;AACV;AAYe,SAAR,QACN,QAAe,eACf,QACQ;AACR,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK,2BAA2B;AAC/B,YAAM,EAAE,IAAI,UAAU,QAAQ,QAAQ,IAAI;AAI1C,aAAO;AAAA,QACN,QAAQ;AAAA,QACR;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACD;AAAA,IACD;AAAA,IACA,KAAK;AACJ,aAAO;AAAA,EACT;AACA,SAAO;AACR;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"reducer.cjs","names":[],"sources":["../../src/store/reducer.ts"],"sourcesContent":["import type { MediaEditorModalUpdate } from './actions';\n\ntype OnUpdateCallback = ( updated: MediaEditorModalUpdate ) => void;\ntype OnUndoCallback = () => void;\ntype OnCloseCallback = () => void;\n\nexport interface State {\n\tisOpen: boolean;\n\tid: number | null;\n\tonUpdate: OnUpdateCallback | null;\n\tonUndo: OnUndoCallback | null;\n\tonClose: OnCloseCallback | null;\n}\n\nexport const DEFAULT_STATE: State = {\n\tisOpen: false,\n\tid: null,\n\tonUpdate: null,\n\tonUndo: null,\n\tonClose: 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\t\tonUndo: OnUndoCallback | null;\n\t\t\tonClose: OnCloseCallback | 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, onUndo, onClose } = 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\tonUndo,\n\t\t\t\tonClose,\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"],"mappings":";;;;;;AAcA,MAAa,gBAAuB;CACnC,QAAQ;CACR,IAAI;CACJ,UAAU;CACV,QAAQ;CACR,SAAS;AACV;AAYA,SAAwB,QACvB,QAAe,eACf,QACQ;CACR,QAAS,OAAO,MAAhB;EACC,KAAK,2BAA2B;GAC/B,MAAM,EAAE,IAAI,UAAU,QAAQ,YAAY;GAI1C,OAAO;IACN,QAAQ;IACR;IACA;IACA;IACA;GACD;EACD;EACA,KAAK,4BACJ,OAAO;CACT;CACA,OAAO;AACR"}
@@ -1,53 +1,28 @@
1
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/selectors.ts
21
- var selectors_exports = {};
22
- __export(selectors_exports, {
23
- getId: () => getId,
24
- getOnClose: () => getOnClose,
25
- getOnUndo: () => getOnUndo,
26
- getOnUpdate: () => getOnUpdate,
27
- isOpen: () => isOpen
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
28
5
  });
29
- module.exports = __toCommonJS(selectors_exports);
6
+ // packages/media-editor/src/store/selectors.ts
30
7
  function isOpen(state) {
31
- return state.isOpen;
8
+ return state.isOpen;
32
9
  }
33
10
  function getId(state) {
34
- return state.id;
11
+ return state.id;
35
12
  }
36
13
  function getOnUpdate(state) {
37
- return state.onUpdate;
14
+ return state.onUpdate;
38
15
  }
39
16
  function getOnUndo(state) {
40
- return state.onUndo;
17
+ return state.onUndo;
41
18
  }
42
19
  function getOnClose(state) {
43
- return state.onClose;
20
+ return state.onClose;
44
21
  }
45
- // Annotate the CommonJS export names for ESM import in node:
46
- 0 && (module.exports = {
47
- getId,
48
- getOnClose,
49
- getOnUndo,
50
- getOnUpdate,
51
- isOpen
52
- });
53
- //# sourceMappingURL=selectors.cjs.map
22
+ exports.getId = getId;
23
+ exports.getOnClose = getOnClose;
24
+ exports.getOnUndo = getOnUndo;
25
+ exports.getOnUpdate = getOnUpdate;
26
+ exports.isOpen = isOpen;
27
+
28
+ //# sourceMappingURL=selectors.cjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/store/selectors.ts"],
4
- "sourcesContent": ["import type { State } from './reducer';\n\nexport function isOpen( state: State ): boolean {\n\treturn state.isOpen;\n}\n\nexport function getId( state: State ): number | null {\n\treturn state.id;\n}\n\nexport function getOnUpdate( state: State ) {\n\treturn state.onUpdate;\n}\n\nexport function getOnUndo( state: State ) {\n\treturn state.onUndo;\n}\n\nexport function getOnClose( state: State ) {\n\treturn state.onClose;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,SAAS,OAAQ,OAAwB;AAC/C,SAAO,MAAM;AACd;AAEO,SAAS,MAAO,OAA8B;AACpD,SAAO,MAAM;AACd;AAEO,SAAS,YAAa,OAAe;AAC3C,SAAO,MAAM;AACd;AAEO,SAAS,UAAW,OAAe;AACzC,SAAO,MAAM;AACd;AAEO,SAAS,WAAY,OAAe;AAC1C,SAAO,MAAM;AACd;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"selectors.cjs","names":[],"sources":["../../src/store/selectors.ts"],"sourcesContent":["import type { State } from './reducer';\n\nexport function isOpen( state: State ): boolean {\n\treturn state.isOpen;\n}\n\nexport function getId( state: State ): number | null {\n\treturn state.id;\n}\n\nexport function getOnUpdate( state: State ) {\n\treturn state.onUpdate;\n}\n\nexport function getOnUndo( state: State ) {\n\treturn state.onUndo;\n}\n\nexport function getOnClose( state: State ) {\n\treturn state.onClose;\n}\n"],"mappings":";;;;;;AAEA,SAAgB,OAAQ,OAAwB;CAC/C,OAAO,MAAM;AACd;AAEA,SAAgB,MAAO,OAA8B;CACpD,OAAO,MAAM;AACd;AAEA,SAAgB,YAAa,OAAe;CAC3C,OAAO,MAAM;AACd;AAEA,SAAgB,UAAW,OAAe;CACzC,OAAO,MAAM;AACd;AAEA,SAAgB,WAAY,OAAe;CAC1C,OAAO,MAAM;AACd"}
@@ -1,45 +1,22 @@
1
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/utils/get-media-type.ts
21
- var get_media_type_exports = {};
22
- __export(get_media_type_exports, {
23
- getMediaTypeFromMimeType: () => getMediaTypeFromMimeType
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
24
5
  });
25
- module.exports = __toCommonJS(get_media_type_exports);
6
+ // packages/media-editor/src/utils/get-media-type.ts
7
+ /**
8
+ * Determines the media type from a MIME type string.
9
+ *
10
+ * @param mimeType - The MIME type to check.
11
+ * @return Object with type property ('image', 'video', 'audio', or 'application').
12
+ */
26
13
  function getMediaTypeFromMimeType(mimeType) {
27
- if (!mimeType) {
28
- return { type: "application" };
29
- }
30
- if (mimeType.startsWith("image/")) {
31
- return { type: "image" };
32
- }
33
- if (mimeType.startsWith("video/")) {
34
- return { type: "video" };
35
- }
36
- if (mimeType.startsWith("audio/")) {
37
- return { type: "audio" };
38
- }
39
- return { type: "application" };
14
+ if (!mimeType) return { type: "application" };
15
+ if (mimeType.startsWith("image/")) return { type: "image" };
16
+ if (mimeType.startsWith("video/")) return { type: "video" };
17
+ if (mimeType.startsWith("audio/")) return { type: "audio" };
18
+ return { type: "application" };
40
19
  }
41
- // Annotate the CommonJS export names for ESM import in node:
42
- 0 && (module.exports = {
43
- getMediaTypeFromMimeType
44
- });
45
- //# sourceMappingURL=get-media-type.cjs.map
20
+ exports.getMediaTypeFromMimeType = getMediaTypeFromMimeType;
21
+
22
+ //# sourceMappingURL=get-media-type.cjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/utils/get-media-type.ts"],
4
- "sourcesContent": ["/**\n * Media type result.\n */\nexport interface MediaType {\n\ttype: 'image' | 'video' | 'audio' | 'application';\n}\n\n/**\n * Determines the media type from a MIME type string.\n *\n * @param mimeType - The MIME type to check.\n * @return Object with type property ('image', 'video', 'audio', or 'application').\n */\nexport function getMediaTypeFromMimeType( mimeType?: string ): MediaType {\n\tif ( ! mimeType ) {\n\t\treturn { type: 'application' };\n\t}\n\n\tif ( mimeType.startsWith( 'image/' ) ) {\n\t\treturn { type: 'image' };\n\t}\n\tif ( mimeType.startsWith( 'video/' ) ) {\n\t\treturn { type: 'video' };\n\t}\n\tif ( mimeType.startsWith( 'audio/' ) ) {\n\t\treturn { type: 'audio' };\n\t}\n\treturn { type: 'application' };\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAaO,SAAS,yBAA0B,UAA+B;AACxE,MAAK,CAAE,UAAW;AACjB,WAAO,EAAE,MAAM,cAAc;AAAA,EAC9B;AAEA,MAAK,SAAS,WAAY,QAAS,GAAI;AACtC,WAAO,EAAE,MAAM,QAAQ;AAAA,EACxB;AACA,MAAK,SAAS,WAAY,QAAS,GAAI;AACtC,WAAO,EAAE,MAAM,QAAQ;AAAA,EACxB;AACA,MAAK,SAAS,WAAY,QAAS,GAAI;AACtC,WAAO,EAAE,MAAM,QAAQ;AAAA,EACxB;AACA,SAAO,EAAE,MAAM,cAAc;AAC9B;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"get-media-type.cjs","names":[],"sources":["../../src/utils/get-media-type.ts"],"sourcesContent":["/**\n * Media type result.\n */\nexport interface MediaType {\n\ttype: 'image' | 'video' | 'audio' | 'application';\n}\n\n/**\n * Determines the media type from a MIME type string.\n *\n * @param mimeType - The MIME type to check.\n * @return Object with type property ('image', 'video', 'audio', or 'application').\n */\nexport function getMediaTypeFromMimeType( mimeType?: string ): MediaType {\n\tif ( ! mimeType ) {\n\t\treturn { type: 'application' };\n\t}\n\n\tif ( mimeType.startsWith( 'image/' ) ) {\n\t\treturn { type: 'image' };\n\t}\n\tif ( mimeType.startsWith( 'video/' ) ) {\n\t\treturn { type: 'video' };\n\t}\n\tif ( mimeType.startsWith( 'audio/' ) ) {\n\t\treturn { type: 'audio' };\n\t}\n\treturn { type: 'application' };\n}\n"],"mappings":";;;;;;;;;;;;AAaA,SAAgB,yBAA0B,UAA+B;CACxE,IAAK,CAAE,UACN,OAAO,EAAE,MAAM,cAAc;CAG9B,IAAK,SAAS,WAAY,QAAS,GAClC,OAAO,EAAE,MAAM,QAAQ;CAExB,IAAK,SAAS,WAAY,QAAS,GAClC,OAAO,EAAE,MAAM,QAAQ;CAExB,IAAK,SAAS,WAAY,QAAS,GAClC,OAAO,EAAE,MAAM,QAAQ;CAExB,OAAO,EAAE,MAAM,cAAc;AAC9B"}