@wordpress/media-editor 0.8.1-next.v.202605131032.0 → 0.10.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.
- package/build/components/media-editor/index.cjs +34 -135
- package/build/components/media-editor/index.cjs.map +3 -3
- package/build/components/media-editor/use-crop-options.cjs +87 -0
- package/build/components/media-editor/use-crop-options.cjs.map +7 -0
- package/build/components/media-editor/use-save-media-editor.cjs +185 -0
- package/build/components/media-editor/use-save-media-editor.cjs.map +7 -0
- package/build/components/media-editor-canvas/index.cjs +32 -11
- package/build/components/media-editor-canvas/index.cjs.map +2 -2
- package/build/components/media-editor-crop-panel/index.cjs +66 -83
- package/build/components/media-editor-crop-panel/index.cjs.map +2 -2
- package/build/components/media-editor-modal/index.cjs +40 -11
- package/build/components/media-editor-modal/index.cjs.map +3 -3
- package/build/components/media-editor-toolbar/index.cjs +7 -3
- package/build/components/media-editor-toolbar/index.cjs.map +2 -2
- package/build/components/media-form/index.cjs +19 -1
- package/build/components/media-form/index.cjs.map +3 -3
- package/build/components/media-form/sidebar-datetime-view.cjs +53 -0
- package/build/components/media-form/sidebar-datetime-view.cjs.map +7 -0
- package/build/components/rotation-ruler/index.cjs +8 -2
- package/build/components/rotation-ruler/index.cjs.map +2 -2
- package/build/hooks/use-crop-gesture-handlers.cjs +41 -4
- package/build/hooks/use-crop-gesture-handlers.cjs.map +2 -2
- package/build/image-editor/core/camera.cjs +29 -11
- package/build/image-editor/core/camera.cjs.map +2 -2
- package/build/image-editor/core/constants.cjs +6 -0
- package/build/image-editor/core/constants.cjs.map +2 -2
- package/build/image-editor/core/containment.cjs +71 -34
- package/build/image-editor/core/containment.cjs.map +2 -2
- package/build/image-editor/core/crop-rect.cjs +48 -0
- package/build/image-editor/core/crop-rect.cjs.map +7 -0
- package/build/image-editor/core/index.cjs +12 -0
- package/build/image-editor/core/index.cjs.map +2 -2
- package/build/image-editor/core/interaction-controller.cjs.map +2 -2
- package/build/image-editor/core/math/sanitize.cjs +92 -0
- package/build/image-editor/core/math/sanitize.cjs.map +7 -0
- package/build/image-editor/core/setter-helpers.cjs +64 -0
- package/build/image-editor/core/setter-helpers.cjs.map +7 -0
- package/build/image-editor/core/source-region.cjs +16 -14
- package/build/image-editor/core/source-region.cjs.map +2 -2
- package/build/image-editor/core/state.cjs +20 -10
- package/build/image-editor/core/state.cjs.map +2 -2
- package/build/image-editor/core/stencil-math.cjs +31 -20
- package/build/image-editor/core/stencil-math.cjs.map +2 -2
- package/build/image-editor/core/transform-style.cjs +12 -6
- package/build/image-editor/core/transform-style.cjs.map +2 -2
- package/build/image-editor/core/types.cjs.map +1 -1
- package/build/image-editor/index.cjs +12 -2
- package/build/image-editor/index.cjs.map +2 -2
- package/build/image-editor/react/components/cropper-provider.cjs +2 -2
- package/build/image-editor/react/components/cropper-provider.cjs.map +2 -2
- package/build/image-editor/react/components/cropper.cjs +121 -48
- package/build/image-editor/react/components/cropper.cjs.map +2 -2
- package/build/image-editor/react/components/overlays/dimensions-overlay.cjs +172 -0
- package/build/image-editor/react/components/overlays/dimensions-overlay.cjs.map +7 -0
- package/build/image-editor/react/components/stencils/rectangle-stencil.cjs +20 -10
- package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +2 -2
- package/build/image-editor/react/hooks/build-cropper-setters.cjs +71 -0
- package/build/image-editor/react/hooks/build-cropper-setters.cjs.map +7 -0
- package/build/image-editor/react/hooks/index.cjs +6 -3
- package/build/image-editor/react/hooks/index.cjs.map +2 -2
- package/build/image-editor/react/hooks/use-aria-announcer.cjs +3 -1
- package/build/image-editor/react/hooks/use-aria-announcer.cjs.map +2 -2
- package/build/image-editor/react/hooks/use-cropper-reducer.cjs +113 -0
- package/build/image-editor/react/hooks/use-cropper-reducer.cjs.map +7 -0
- package/build/image-editor/react/hooks/use-interaction.cjs +1 -1
- package/build/image-editor/react/hooks/use-interaction.cjs.map +2 -2
- package/build/state/composite-reducer.cjs +115 -0
- package/build/state/composite-reducer.cjs.map +7 -0
- package/build/state/index.cjs +48 -0
- package/build/state/index.cjs.map +7 -0
- package/build/state/media-editor-state-provider.cjs +58 -0
- package/build/state/media-editor-state-provider.cjs.map +7 -0
- package/build/state/types.cjs +34 -0
- package/build/state/types.cjs.map +7 -0
- package/build/state/use-media-editor-state.cjs +298 -0
- package/build/state/use-media-editor-state.cjs.map +7 -0
- package/build-module/components/media-editor/index.mjs +40 -140
- package/build-module/components/media-editor/index.mjs.map +2 -2
- package/build-module/components/media-editor/use-crop-options.mjs +61 -0
- package/build-module/components/media-editor/use-crop-options.mjs.map +7 -0
- package/build-module/components/media-editor/use-save-media-editor.mjs +151 -0
- package/build-module/components/media-editor/use-save-media-editor.mjs.map +7 -0
- package/build-module/components/media-editor-canvas/index.mjs +33 -12
- package/build-module/components/media-editor-canvas/index.mjs.map +2 -2
- package/build-module/components/media-editor-crop-panel/index.mjs +68 -83
- package/build-module/components/media-editor-crop-panel/index.mjs.map +2 -2
- package/build-module/components/media-editor-modal/index.mjs +40 -11
- package/build-module/components/media-editor-modal/index.mjs.map +2 -2
- package/build-module/components/media-editor-toolbar/index.mjs +7 -3
- package/build-module/components/media-editor-toolbar/index.mjs.map +2 -2
- package/build-module/components/media-form/index.mjs +9 -1
- package/build-module/components/media-form/index.mjs.map +2 -2
- package/build-module/components/media-form/sidebar-datetime-view.mjs +32 -0
- package/build-module/components/media-form/sidebar-datetime-view.mjs.map +7 -0
- package/build-module/components/rotation-ruler/index.mjs +8 -2
- package/build-module/components/rotation-ruler/index.mjs.map +2 -2
- package/build-module/hooks/use-crop-gesture-handlers.mjs +41 -4
- package/build-module/hooks/use-crop-gesture-handlers.mjs.map +2 -2
- package/build-module/image-editor/core/camera.mjs +34 -11
- package/build-module/image-editor/core/camera.mjs.map +2 -2
- package/build-module/image-editor/core/constants.mjs +4 -0
- package/build-module/image-editor/core/constants.mjs.map +2 -2
- package/build-module/image-editor/core/containment.mjs +75 -34
- package/build-module/image-editor/core/containment.mjs.map +2 -2
- package/build-module/image-editor/core/crop-rect.mjs +23 -0
- package/build-module/image-editor/core/crop-rect.mjs.map +7 -0
- package/build-module/image-editor/core/index.mjs +12 -0
- package/build-module/image-editor/core/index.mjs.map +2 -2
- package/build-module/image-editor/core/interaction-controller.mjs.map +2 -2
- package/build-module/image-editor/core/math/sanitize.mjs +63 -0
- package/build-module/image-editor/core/math/sanitize.mjs.map +7 -0
- package/build-module/image-editor/core/setter-helpers.mjs +39 -0
- package/build-module/image-editor/core/setter-helpers.mjs.map +7 -0
- package/build-module/image-editor/core/source-region.mjs +16 -14
- package/build-module/image-editor/core/source-region.mjs.map +2 -2
- package/build-module/image-editor/core/state.mjs +25 -11
- package/build-module/image-editor/core/state.mjs.map +2 -2
- package/build-module/image-editor/core/stencil-math.mjs +30 -19
- package/build-module/image-editor/core/stencil-math.mjs.map +2 -2
- package/build-module/image-editor/core/transform-style.mjs +12 -6
- package/build-module/image-editor/core/transform-style.mjs.map +2 -2
- package/build-module/image-editor/index.mjs +11 -2
- package/build-module/image-editor/index.mjs.map +2 -2
- package/build-module/image-editor/react/components/cropper-provider.mjs +3 -3
- package/build-module/image-editor/react/components/cropper-provider.mjs.map +2 -2
- package/build-module/image-editor/react/components/cropper.mjs +122 -49
- package/build-module/image-editor/react/components/cropper.mjs.map +2 -2
- package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs +147 -0
- package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs.map +7 -0
- package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs +20 -10
- package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs.map +2 -2
- package/build-module/image-editor/react/hooks/build-cropper-setters.mjs +46 -0
- package/build-module/image-editor/react/hooks/build-cropper-setters.mjs.map +7 -0
- package/build-module/image-editor/react/hooks/index.mjs +4 -2
- package/build-module/image-editor/react/hooks/index.mjs.map +2 -2
- package/build-module/image-editor/react/hooks/use-aria-announcer.mjs +3 -1
- package/build-module/image-editor/react/hooks/use-aria-announcer.mjs.map +2 -2
- package/build-module/image-editor/react/hooks/use-cropper-reducer.mjs +100 -0
- package/build-module/image-editor/react/hooks/use-cropper-reducer.mjs.map +7 -0
- package/build-module/image-editor/react/hooks/use-interaction.mjs +1 -1
- package/build-module/image-editor/react/hooks/use-interaction.mjs.map +2 -2
- package/build-module/state/composite-reducer.mjs +94 -0
- package/build-module/state/composite-reducer.mjs.map +7 -0
- package/build-module/state/index.mjs +26 -0
- package/build-module/state/index.mjs.map +7 -0
- package/build-module/state/media-editor-state-provider.mjs +34 -0
- package/build-module/state/media-editor-state-provider.mjs.map +7 -0
- package/build-module/state/types.mjs +9 -0
- package/build-module/state/types.mjs.map +7 -0
- package/build-module/state/use-media-editor-state.mjs +289 -0
- package/build-module/state/use-media-editor-state.mjs.map +7 -0
- package/build-style/style-rtl.css +46 -9
- package/build-style/style.css +46 -9
- package/build-types/components/media-editor/index.d.ts +4 -7
- package/build-types/components/media-editor/index.d.ts.map +1 -1
- package/build-types/components/media-editor/use-crop-options.d.ts +37 -0
- package/build-types/components/media-editor/use-crop-options.d.ts.map +1 -0
- package/build-types/components/media-editor/use-save-media-editor.d.ts +29 -0
- package/build-types/components/media-editor/use-save-media-editor.d.ts.map +1 -0
- package/build-types/components/media-editor-canvas/index.d.ts +5 -10
- package/build-types/components/media-editor-canvas/index.d.ts.map +1 -1
- package/build-types/components/media-editor-crop-panel/index.d.ts +4 -16
- package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -1
- package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
- package/build-types/components/media-editor-toolbar/index.d.ts.map +1 -1
- package/build-types/components/media-form/index.d.ts.map +1 -1
- package/build-types/components/media-form/sidebar-datetime-view.d.ts +10 -0
- package/build-types/components/media-form/sidebar-datetime-view.d.ts.map +1 -0
- package/build-types/components/rotation-ruler/index.d.ts.map +1 -1
- package/build-types/hooks/use-crop-gesture-handlers.d.ts +13 -14
- package/build-types/hooks/use-crop-gesture-handlers.d.ts.map +1 -1
- package/build-types/image-editor/core/camera.d.ts.map +1 -1
- package/build-types/image-editor/core/constants.d.ts +18 -0
- package/build-types/image-editor/core/constants.d.ts.map +1 -1
- package/build-types/image-editor/core/containment.d.ts +10 -0
- package/build-types/image-editor/core/containment.d.ts.map +1 -1
- package/build-types/image-editor/core/crop-rect.d.ts +19 -0
- package/build-types/image-editor/core/crop-rect.d.ts.map +1 -0
- package/build-types/image-editor/core/index.d.ts +3 -1
- package/build-types/image-editor/core/index.d.ts.map +1 -1
- package/build-types/image-editor/core/interaction-controller.d.ts +5 -1
- package/build-types/image-editor/core/interaction-controller.d.ts.map +1 -1
- package/build-types/image-editor/core/math/sanitize.d.ts +70 -0
- package/build-types/image-editor/core/math/sanitize.d.ts.map +1 -0
- package/build-types/image-editor/core/setter-helpers.d.ts +24 -0
- package/build-types/image-editor/core/setter-helpers.d.ts.map +1 -0
- package/build-types/image-editor/core/source-region.d.ts.map +1 -1
- package/build-types/image-editor/core/state.d.ts +12 -0
- package/build-types/image-editor/core/state.d.ts.map +1 -1
- package/build-types/image-editor/core/stencil-math.d.ts +23 -18
- package/build-types/image-editor/core/stencil-math.d.ts.map +1 -1
- package/build-types/image-editor/core/transform-style.d.ts.map +1 -1
- package/build-types/image-editor/core/types.d.ts +23 -4
- package/build-types/image-editor/core/types.d.ts.map +1 -1
- package/build-types/image-editor/index.d.ts +4 -4
- package/build-types/image-editor/index.d.ts.map +1 -1
- package/build-types/image-editor/react/components/cropper-provider.d.ts +11 -7
- package/build-types/image-editor/react/components/cropper-provider.d.ts.map +1 -1
- package/build-types/image-editor/react/components/cropper.d.ts +6 -4
- package/build-types/image-editor/react/components/cropper.d.ts.map +1 -1
- package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts +36 -0
- package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts.map +1 -0
- package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts +2 -1
- package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts.map +1 -1
- package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts +47 -0
- package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts.map +1 -0
- package/build-types/image-editor/react/hooks/index.d.ts +4 -2
- package/build-types/image-editor/react/hooks/index.d.ts.map +1 -1
- package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts.map +1 -1
- package/build-types/image-editor/react/hooks/use-cropper-reducer.d.ts +58 -0
- package/build-types/image-editor/react/hooks/use-cropper-reducer.d.ts.map +1 -0
- package/build-types/image-editor/react/hooks/use-interaction.d.ts.map +1 -1
- package/build-types/image-editor/stories/rectangle-crop.story.d.ts.map +1 -1
- package/build-types/state/composite-reducer.d.ts +39 -0
- package/build-types/state/composite-reducer.d.ts.map +1 -0
- package/build-types/state/index.d.ts +7 -0
- package/build-types/state/index.d.ts.map +1 -0
- package/build-types/state/media-editor-state-provider.d.ts +34 -0
- package/build-types/state/media-editor-state-provider.d.ts.map +1 -0
- package/build-types/state/types.d.ts +104 -0
- package/build-types/state/types.d.ts.map +1 -0
- package/build-types/state/use-media-editor-state.d.ts +104 -0
- package/build-types/state/use-media-editor-state.d.ts.map +1 -0
- package/package.json +19 -17
- package/src/components/media-editor/index.tsx +52 -188
- package/src/components/media-editor/test/use-crop-options.tsx +164 -0
- package/src/components/media-editor/use-crop-options.ts +115 -0
- package/src/components/media-editor/use-save-media-editor.ts +214 -0
- package/src/components/media-editor-canvas/index.tsx +56 -24
- package/src/components/media-editor-crop-panel/index.tsx +25 -61
- package/src/components/media-editor-crop-panel/test/index.tsx +17 -43
- package/src/components/media-editor-modal/index.tsx +50 -12
- package/src/components/media-editor-modal/test/build-modifiers.test.ts +14 -0
- package/src/components/media-editor-modal/test/index.tsx +143 -0
- package/src/components/media-editor-toolbar/index.tsx +9 -5
- package/src/components/media-form/index.tsx +15 -1
- package/src/components/media-form/sidebar-datetime-view.tsx +47 -0
- package/src/components/media-form/test/sidebar-datetime-view.test.tsx +96 -0
- package/src/components/rotation-ruler/README.md +11 -25
- package/src/components/rotation-ruler/index.tsx +17 -2
- package/src/components/rotation-ruler/style.scss +49 -13
- package/src/hooks/use-crop-gesture-handlers.ts +66 -17
- package/src/image-editor/README.md +28 -129
- package/src/image-editor/core/camera.ts +51 -26
- package/src/image-editor/core/constants.ts +19 -0
- package/src/image-editor/core/containment.ts +102 -49
- package/src/image-editor/core/crop-rect.ts +45 -0
- package/src/image-editor/core/index.ts +16 -4
- package/src/image-editor/core/interaction-controller.ts +5 -1
- package/src/image-editor/core/math/sanitize.ts +158 -0
- package/src/image-editor/core/math/test/sanitize.ts +244 -0
- package/src/image-editor/core/setter-helpers.ts +66 -0
- package/src/image-editor/core/source-region.ts +21 -14
- package/src/image-editor/core/state.ts +67 -15
- package/src/image-editor/core/stencil-math.ts +55 -35
- package/src/image-editor/core/test/camera.ts +367 -1
- package/src/image-editor/core/test/state.ts +101 -8
- package/src/image-editor/core/test/stencil-math.ts +193 -0
- package/src/image-editor/core/transform-style.ts +21 -6
- package/src/image-editor/core/types.ts +24 -4
- package/src/image-editor/docs/architecture.md +48 -89
- package/src/image-editor/docs/recipes.md +123 -659
- package/src/image-editor/index.ts +12 -3
- package/src/image-editor/react/components/cropper-provider.tsx +16 -12
- package/src/image-editor/react/components/cropper.scss +23 -4
- package/src/image-editor/react/components/cropper.tsx +197 -90
- package/src/image-editor/react/components/overlays/dimensions-overlay.tsx +269 -0
- package/src/image-editor/react/components/stencils/rectangle-stencil.tsx +22 -9
- package/src/image-editor/react/components/test/cropper.tsx +55 -13
- package/src/image-editor/react/hooks/build-cropper-setters.ts +105 -0
- package/src/image-editor/react/hooks/index.ts +4 -2
- package/src/image-editor/react/hooks/test/{use-cropper-state.ts → use-cropper-reducer.ts} +142 -286
- package/src/image-editor/react/hooks/use-aria-announcer.ts +3 -1
- package/src/image-editor/react/hooks/use-cropper-reducer.ts +204 -0
- package/src/image-editor/react/hooks/use-interaction.ts +3 -2
- package/src/image-editor/stories/rectangle-crop.story.tsx +7 -17
- package/src/state/composite-reducer.ts +152 -0
- package/src/state/index.ts +20 -0
- package/src/state/media-editor-state-provider.tsx +70 -0
- package/src/state/test/use-media-editor-state.ts +402 -0
- package/src/state/types.ts +107 -0
- package/src/state/use-media-editor-state.ts +488 -0
- package/tsconfig.json +2 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/image-editor/react/hooks/use-cropper-state.cjs +0 -277
- package/build/image-editor/react/hooks/use-cropper-state.cjs.map +0 -7
- package/build-module/image-editor/react/hooks/use-cropper-state.mjs +0 -262
- package/build-module/image-editor/react/hooks/use-cropper-state.mjs.map +0 -7
- package/build-types/image-editor/react/hooks/use-cropper-state.d.ts +0 -97
- package/build-types/image-editor/react/hooks/use-cropper-state.d.ts.map +0 -1
- package/src/image-editor/docs/roadmap.md +0 -66
- package/src/image-editor/react/hooks/use-cropper-state.ts +0 -457
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { CropperState, NormalizedRect, Size } from '../types';
|
|
5
|
+
/**
|
|
6
|
+
* Returns `value` if it's finite and within `[-MAX_SAFE_MAGNITUDE,
|
|
7
|
+
* MAX_SAFE_MAGNITUDE]`, otherwise `fallback`. Stricter than `Number.isFinite`
|
|
8
|
+
* because extreme finite magnitudes (e.g. `Number.MAX_VALUE`) overflow
|
|
9
|
+
* downstream trig/matrix math even though the spec reports them as finite.
|
|
10
|
+
*
|
|
11
|
+
* Note: sub-normal denormals (e.g. `Number.MIN_VALUE`) are accepted by this
|
|
12
|
+
* function — they don't overflow on their own. Protection against divisions
|
|
13
|
+
* by sub-normal values lives in `sanitizeCropperState`'s zoom guard.
|
|
14
|
+
*
|
|
15
|
+
* @param value The candidate value.
|
|
16
|
+
* @param fallback The replacement to return when `value` is unsafe.
|
|
17
|
+
* @return Either `value` or `fallback`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function safeBoundedNumber(value: number, fallback: number): number;
|
|
20
|
+
/**
|
|
21
|
+
* Returns `true` when `value` is finite and within `[-MAX_SAFE_MAGNITUDE,
|
|
22
|
+
* MAX_SAFE_MAGNITUDE]`. The predicate companion to {@link safeBoundedNumber}
|
|
23
|
+
* for callers that need to short-circuit rather than substitute a fallback.
|
|
24
|
+
*
|
|
25
|
+
* @param value The candidate value.
|
|
26
|
+
* @return Whether `value` is safe to use in math.
|
|
27
|
+
*/
|
|
28
|
+
export declare function isSafeNumber(value: number): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Returns `true` when both dimensions are finite and within the safe
|
|
31
|
+
* range `[Number.EPSILON, MAX_SAFE_MAGNITUDE]`. The lower bound matters
|
|
32
|
+
* because sub-normal dimensions (e.g. `Number.MIN_VALUE`) pass `> 0` but
|
|
33
|
+
* make `container / dim` overflow to `Infinity` downstream in
|
|
34
|
+
* `getImageFit` / `createCamera`. Use this to short-circuit math that
|
|
35
|
+
* would otherwise produce non-finite output.
|
|
36
|
+
*
|
|
37
|
+
* @param size The size to check.
|
|
38
|
+
* @return Whether `size` is safe to use in math.
|
|
39
|
+
*/
|
|
40
|
+
export declare function isValidSize(size: Size): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Returns a copy of `rect` with every numeric field replaced by a safe
|
|
43
|
+
* value via {@link safeBoundedNumber}. Returns the same reference when no
|
|
44
|
+
* field needed substitution so callers can keep their reference-equality
|
|
45
|
+
* short-circuits intact for clean inputs.
|
|
46
|
+
*
|
|
47
|
+
* @param rect The rect to sanitize.
|
|
48
|
+
* @return A rect with all numeric fields finite.
|
|
49
|
+
*/
|
|
50
|
+
export declare function sanitizeRect(rect: NormalizedRect): NormalizedRect;
|
|
51
|
+
/**
|
|
52
|
+
* Returns a copy of `state` with the cropper-math numeric fields replaced
|
|
53
|
+
* by safe defaults. Covers `pan`, `zoom`, `rotation`, the matching base
|
|
54
|
+
* pose, and `cropRect`. The `state.image` numeric fields (naturalWidth /
|
|
55
|
+
* naturalHeight) are intentionally NOT sanitized — image dimensions reach
|
|
56
|
+
* the math layer as a separate `imageSize` argument, and cloning the
|
|
57
|
+
* image object here would break the reducer's reference-equality
|
|
58
|
+
* short-circuit.
|
|
59
|
+
*
|
|
60
|
+
* Returns the same `state` reference when no field needed substitution
|
|
61
|
+
* so callers in hot paths (every pointermove via `restrictPanZoom`) can
|
|
62
|
+
* keep their reference-equality optimizations. Sub-object references
|
|
63
|
+
* (`pan`, `basePan`, `cropRect`) are also preserved when their fields
|
|
64
|
+
* are individually clean.
|
|
65
|
+
*
|
|
66
|
+
* @param state The cropper state to sanitize.
|
|
67
|
+
* @return A cropper state with the math-relevant numeric fields finite.
|
|
68
|
+
*/
|
|
69
|
+
export declare function sanitizeCropperState(state: CropperState): CropperState;
|
|
70
|
+
//# sourceMappingURL=sanitize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../../../src/image-editor/core/math/sanitize.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAUnE;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAI,MAAM,CAQ3E;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAE,KAAK,EAAE,MAAM,GAAI,OAAO,CAErD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAE,IAAI,EAAE,IAAI,GAAI,OAAO,CASjD;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAE,IAAI,EAAE,cAAc,GAAI,cAAc,CAcnE;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,oBAAoB,CAAE,KAAK,EAAE,YAAY,GAAI,YAAY,CA2CxE"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { CropperState, CropperAction } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* Build the reducer action that produces a "cursorless" zoom — zoom
|
|
7
|
+
* anchored at the current crop-rect center, with pan clamped to keep
|
|
8
|
+
* the image covering the crop.
|
|
9
|
+
*
|
|
10
|
+
* The slider, the `+`/`-` keys, and the toolbar buttons have no
|
|
11
|
+
* natural focal point (unlike wheel/pinch zoom), so they default to
|
|
12
|
+
* the crop center. Returns `null` when the clamped zoom matches the
|
|
13
|
+
* current zoom (no-op).
|
|
14
|
+
*
|
|
15
|
+
* Extracted so multiple hooks (the pure `useCropperReducer` and the
|
|
16
|
+
* composite `useMediaEditorState`) can share the math without
|
|
17
|
+
* duplicating it.
|
|
18
|
+
*
|
|
19
|
+
* @param state The current cropper state.
|
|
20
|
+
* @param requestedZoom The zoom value the caller asked for.
|
|
21
|
+
* @return A `SET_ZOOM_AT_POINT` action, or `null` if no change is required.
|
|
22
|
+
*/
|
|
23
|
+
export declare function buildFocalPointZoomAction(state: CropperState, requestedZoom: number): CropperAction | null;
|
|
24
|
+
//# sourceMappingURL=setter-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setter-helpers.d.ts","sourceRoot":"","sources":["../../../src/image-editor/core/setter-helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,YAAY,EAAmB,aAAa,EAAE,MAAM,SAAS,CAAC;AAI5E;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,yBAAyB,CACxC,KAAK,EAAE,YAAY,EACnB,aAAa,EAAE,MAAM,GACnB,aAAa,GAAG,IAAI,CAqCtB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source-region.d.ts","sourceRoot":"","sources":["../../../src/image-editor/core/source-region.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"source-region.d.ts","sourceRoot":"","sources":["../../../src/image-editor/core/source-region.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAIlD;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,iCAAiC;IACjC,CAAC,EAAE,MAAM,CAAC;IACV,iCAAiC;IACjC,CAAC,EAAE,MAAM,CAAC;IACV,8BAA8B;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,+BAA+B;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,mCAAmC;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB;IAClB,IAAI,EAAE;QAAE,UAAU,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC;IACjD,2BAA2B;IAC3B,IAAI,EAAE,MAAM,CAAC;CACb;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,eAAe,CAC9B,KAAK,EAAE,YAAY,EACnB,SAAS,EAAE,IAAI,GACb,YAAY,CA0Ed;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC,kEAAkE;IAClE,CAAC,EAAE,MAAM,CAAC;IACV,mEAAmE;IACnE,CAAC,EAAE,MAAM,CAAC;IACV,+DAA+D;IAC/D,KAAK,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,MAAM,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,CACrC,KAAK,EAAE,YAAY,EACnB,SAAS,EAAE,IAAI,GACb,mBAAmB,CAWrB"}
|
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
4
|
import type { CropperAction, CropperState } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* Value-equality check for two cropper states.
|
|
7
|
+
*
|
|
8
|
+
* Used by history machinery to dedup snapshots and detect no-op
|
|
9
|
+
* transitions. Compares every field that participates in the rendered
|
|
10
|
+
* output; ignores reference identity.
|
|
11
|
+
*
|
|
12
|
+
* @param a First cropper state.
|
|
13
|
+
* @param b Second cropper state.
|
|
14
|
+
* @return Whether the two states are value-equal across all tracked fields.
|
|
15
|
+
*/
|
|
16
|
+
export declare function areCropperStatesEqual(a: CropperState, b: CropperState): boolean;
|
|
5
17
|
/**
|
|
6
18
|
* Enforces containment: restricts the crop rect to fit within the
|
|
7
19
|
* rotated image, computes minimum zoom, clamps zoom, and restricts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../src/image-editor/core/state.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAsB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../src/image-editor/core/state.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAsB,MAAM,SAAS,CAAC;AAiB/E;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CACpC,CAAC,EAAE,YAAY,EACf,CAAC,EAAE,YAAY,GACb,OAAO,CAkBT;AA6DD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAE,KAAK,EAAE,YAAY,GAAI,YAAY,CAgDtE;AAgCD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,cAAc,CAC7B,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,aAAa,GACnB,YAAY,CA8Od;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC3B,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,YAAY,GACnB,OAAO,CAaT"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
|
-
import type { NormalizedRect, Size } from './types';
|
|
5
|
-
|
|
6
|
-
export declare const MIN_CROP_SIZE = 0.05;
|
|
4
|
+
import type { HandlePosition, NormalizedRect, Size } from './types';
|
|
5
|
+
export type { HandlePosition };
|
|
7
6
|
/**
|
|
8
|
-
*
|
|
7
|
+
* Default minimum crop rect dimension in normalized space, used when no
|
|
8
|
+
* explicit per-axis minimum is supplied (e.g. before the source image
|
|
9
|
+
* has loaded). Real usage derives a pixel-based min from the source
|
|
10
|
+
* image dimensions and `MIN_CROP_PIXELS` in `constants.ts`.
|
|
9
11
|
*/
|
|
10
|
-
export
|
|
12
|
+
export declare const DEFAULT_MIN_CROP_SIZE: Size;
|
|
11
13
|
/**
|
|
12
14
|
* Bounds within which the crop rect must stay.
|
|
13
15
|
*/
|
|
@@ -35,14 +37,15 @@ export interface ResizeDragState {
|
|
|
35
37
|
* Each edge moves independently based on the handle being dragged.
|
|
36
38
|
* Edges are clamped to the provided bounds and maintain a minimum size.
|
|
37
39
|
*
|
|
38
|
-
* @param drag
|
|
39
|
-
* @param clientX
|
|
40
|
-
* @param clientY
|
|
41
|
-
* @param imageSize
|
|
42
|
-
* @param bounds
|
|
40
|
+
* @param drag The current drag state.
|
|
41
|
+
* @param clientX Current mouse/touch X position in pixels.
|
|
42
|
+
* @param clientY Current mouse/touch Y position in pixels.
|
|
43
|
+
* @param imageSize The rendered image dimensions in pixels.
|
|
44
|
+
* @param bounds The allowed crop area bounds.
|
|
45
|
+
* @param minCropSize Minimum crop rect dimension in normalized space, per axis.
|
|
43
46
|
* @return The new crop rect in normalized coordinates.
|
|
44
47
|
*/
|
|
45
|
-
export declare function computeFreeResizeRect(drag: ResizeDragState, clientX: number, clientY: number, imageSize: Size, bounds: CropBounds): NormalizedRect;
|
|
48
|
+
export declare function computeFreeResizeRect(drag: ResizeDragState, clientX: number, clientY: number, imageSize: Size, bounds: CropBounds, minCropSize?: Size): NormalizedRect;
|
|
46
49
|
/**
|
|
47
50
|
* Compute the new crop rect for a locked-aspect-ratio corner resize.
|
|
48
51
|
*
|
|
@@ -56,9 +59,10 @@ export declare function computeFreeResizeRect(drag: ResizeDragState, clientX: nu
|
|
|
56
59
|
* @param imageSize The rendered image dimensions in pixels.
|
|
57
60
|
* @param bounds The allowed crop area bounds.
|
|
58
61
|
* @param normalizedRatio The locked aspect ratio (width / height in normalized space).
|
|
62
|
+
* @param minCropSize Minimum crop rect dimension in normalized space, per axis.
|
|
59
63
|
* @return The new crop rect in normalized coordinates.
|
|
60
64
|
*/
|
|
61
|
-
export declare function computeLockedResizeRect(drag: ResizeDragState, clientX: number, clientY: number, imageSize: Size, bounds: CropBounds, normalizedRatio: number): NormalizedRect;
|
|
65
|
+
export declare function computeLockedResizeRect(drag: ResizeDragState, clientX: number, clientY: number, imageSize: Size, bounds: CropBounds, normalizedRatio: number, minCropSize?: Size): NormalizedRect;
|
|
62
66
|
/**
|
|
63
67
|
* Compute the new crop rect for a resize that temporarily locks the
|
|
64
68
|
* aspect ratio to `drag.startRect`'s ratio (e.g. while Shift is held).
|
|
@@ -68,12 +72,13 @@ export declare function computeLockedResizeRect(drag: ResizeDragState, clientX:
|
|
|
68
72
|
* axis symmetrically around the rect's center to preserve the ratio,
|
|
69
73
|
* clamping symmetrically so the rect stays within bounds.
|
|
70
74
|
*
|
|
71
|
-
* @param drag
|
|
72
|
-
* @param clientX
|
|
73
|
-
* @param clientY
|
|
74
|
-
* @param imageSize
|
|
75
|
-
* @param bounds
|
|
75
|
+
* @param drag The current drag state.
|
|
76
|
+
* @param clientX Current mouse/touch X position in pixels.
|
|
77
|
+
* @param clientY Current mouse/touch Y position in pixels.
|
|
78
|
+
* @param imageSize The rendered image dimensions in pixels.
|
|
79
|
+
* @param bounds The allowed crop area bounds.
|
|
80
|
+
* @param minCropSize Minimum crop rect dimension in normalized space, per axis.
|
|
76
81
|
* @return The new crop rect in normalized coordinates.
|
|
77
82
|
*/
|
|
78
|
-
export declare function computeShiftLockedResizeRect(drag: ResizeDragState, clientX: number, clientY: number, imageSize: Size, bounds: CropBounds): NormalizedRect;
|
|
83
|
+
export declare function computeShiftLockedResizeRect(drag: ResizeDragState, clientX: number, clientY: number, imageSize: Size, bounds: CropBounds, minCropSize?: Size): NormalizedRect;
|
|
79
84
|
//# sourceMappingURL=stencil-math.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stencil-math.d.ts","sourceRoot":"","sources":["../../../src/image-editor/core/stencil-math.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"stencil-math.d.ts","sourceRoot":"","sources":["../../../src/image-editor/core/stencil-math.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAEpE,YAAY,EAAE,cAAc,EAAE,CAAC;AAE/B;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,EAAE,IAAoC,CAAC;AAEzE;;GAEG;AACH,MAAM,WAAW,UAAU;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B,qCAAqC;IACrC,MAAM,EAAE,cAAc,CAAC;IACvB,yDAAyD;IACzD,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,wDAAwD;IACxD,SAAS,EAAE,cAAc,CAAC;CAC1B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CACpC,IAAI,EAAE,eAAe,EACrB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,IAAI,EACf,MAAM,EAAE,UAAU,EAClB,WAAW,GAAE,IAA4B,GACvC,cAAc,CA6ChB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,uBAAuB,CACtC,IAAI,EAAE,eAAe,EACrB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,IAAI,EACf,MAAM,EAAE,UAAU,EAClB,eAAe,EAAE,MAAM,EACvB,WAAW,GAAE,IAA4B,GACvC,cAAc,CAuFhB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,4BAA4B,CAC3C,IAAI,EAAE,eAAe,EACrB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,IAAI,EACf,MAAM,EAAE,UAAU,EAClB,WAAW,GAAE,IAA4B,GACvC,cAAc,CA0GhB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform-style.d.ts","sourceRoot":"","sources":["../../../src/image-editor/core/transform-style.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"transform-style.d.ts","sourceRoot":"","sources":["../../../src/image-editor/core/transform-style.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAOlD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,qBAAqB,CACpC,KAAK,EAAE,YAAY,EACnB,SAAS,EAAE,IAAI,GACb,MAAM,CA4BR"}
|
|
@@ -109,7 +109,8 @@ export interface CropperState {
|
|
|
109
109
|
*
|
|
110
110
|
* This type is intentionally not exported from the image-editor public barrel.
|
|
111
111
|
* Consumers should drive state through the controller returned by
|
|
112
|
-
* `
|
|
112
|
+
* `useCropperReducer()` (or a composite store) or through serializable
|
|
113
|
+
* `TransformOperation` values.
|
|
113
114
|
*/
|
|
114
115
|
export type CropperAction =
|
|
115
116
|
/** Sets the loaded image metadata (natural size, src). */
|
|
@@ -122,7 +123,7 @@ export type CropperAction =
|
|
|
122
123
|
type: 'SET_PAN';
|
|
123
124
|
payload: NormalizedPoint;
|
|
124
125
|
}
|
|
125
|
-
/** Sets the zoom level, clamped to [
|
|
126
|
+
/** Sets the zoom level, clamped to [coverage-aware min, MAX_ZOOM]. */
|
|
126
127
|
| {
|
|
127
128
|
type: 'SET_ZOOM';
|
|
128
129
|
payload: number;
|
|
@@ -200,6 +201,12 @@ export type ViewportAction = {
|
|
|
200
201
|
} | {
|
|
201
202
|
type: 'RESET_VIEWPORT';
|
|
202
203
|
};
|
|
204
|
+
/**
|
|
205
|
+
* Direction of a crop resize handle. Eight compass positions: four
|
|
206
|
+
* corners and four edge midpoints. Used by stencil callbacks and any
|
|
207
|
+
* overlay that needs to know which handle the user is dragging.
|
|
208
|
+
*/
|
|
209
|
+
export type HandlePosition = 'n' | 's' | 'e' | 'w' | 'nw' | 'ne' | 'sw' | 'se';
|
|
203
210
|
/**
|
|
204
211
|
* The contract for a pluggable stencil component.
|
|
205
212
|
* Stencils render the crop area overlay and handle resize interactions.
|
|
@@ -213,8 +220,14 @@ export interface StencilProps {
|
|
|
213
220
|
imageSize: Size;
|
|
214
221
|
/** Callback when the crop rectangle changes (during drag). */
|
|
215
222
|
onCropChange: (rect: NormalizedRect) => void;
|
|
216
|
-
/**
|
|
217
|
-
|
|
223
|
+
/**
|
|
224
|
+
* Callback when a resize interaction starts — pointerdown on a handle
|
|
225
|
+
* or the first arrow-key press on a focused handle. The handle direction
|
|
226
|
+
* is passed so downstream overlays can anchor to it. The argument is
|
|
227
|
+
* optional to keep custom stencils that don't track a direction
|
|
228
|
+
* backward-compatible.
|
|
229
|
+
*/
|
|
230
|
+
onResizeStart?: (handle?: HandlePosition) => void;
|
|
218
231
|
/** Callback when a resize drag ends (mouseup after handle drag). */
|
|
219
232
|
onResizeEnd?: () => void;
|
|
220
233
|
/** Optional fixed aspect ratio (width / height) in pixel space. */
|
|
@@ -232,5 +245,11 @@ export interface StencilProps {
|
|
|
232
245
|
};
|
|
233
246
|
/** Called when Escape is pressed on a resize handle. */
|
|
234
247
|
onEscape?: () => void;
|
|
248
|
+
/**
|
|
249
|
+
* Minimum crop rect dimension in normalized space, per axis. Derived
|
|
250
|
+
* by the host from a pixel-based floor (see `MIN_CROP_PIXELS`) and
|
|
251
|
+
* the source image dimensions. Omit to use the stencil's default.
|
|
252
|
+
*/
|
|
253
|
+
minCropSize?: Size;
|
|
235
254
|
}
|
|
236
255
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/image-editor/core/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAEvC;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,MAAM,GAAG,KAAK,CAAC;AAE3B;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACV;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC9B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,IAAI;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,IAAI;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAC3B;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,cAAc,CAAA;CAAE,GACtC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACnC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,YAAY,GAAG,UAAU,CAAA;CAAE,GACtD;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEpC;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,mEAAmE;IACnE,KAAK,EAAE;QACN,GAAG,EAAE,MAAM,CAAC;QACZ,YAAY,EAAE,MAAM,CAAC;QACrB,aAAa,EAAE,MAAM,CAAC;KACtB,GAAG,IAAI,CAAC;IACT;;;OAGG;IACH,GAAG,EAAE,eAAe,CAAC;IACrB,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,gDAAgD;IAChD,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;;;;;;;;;;;;;OAgBG;IACH,OAAO,EAAE,eAAe,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB;IAClB,IAAI,EAAE,IAAI,CAAC;IACX,oDAAoD;IACpD,QAAQ,EAAE,cAAc,CAAC;CACzB;AAED
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/image-editor/core/types.ts"],"names":[],"mappings":"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"}
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
* accident. Internal modules may export additional helpers for local tests or
|
|
7
7
|
* React wiring; consumers should import through this file.
|
|
8
8
|
*/
|
|
9
|
-
export {
|
|
9
|
+
export { useCropperReducer, buildCropperSetters } from './react/hooks';
|
|
10
10
|
export { Cropper, CropperProvider, useCropper } from './react/components';
|
|
11
|
-
export type {
|
|
11
|
+
export type { CropperController, CropperSetters } from './react/hooks';
|
|
12
12
|
export type { CropperProps } from './react/components';
|
|
13
|
-
export type { CropperState, TransformOperation, NormalizedPoint, NormalizedRect, Size, Flip, StencilProps, } from './core';
|
|
14
|
-
export { DEFAULT_STATE, DEFAULT_ASPECT_RATIOS, ORIGINAL_ASPECT_RATIO, getSourceRegion, getSourceRegionPercent, applyOperationToState, stateFromPipeline, exportCroppedImage, applyToCanvas, } from './core';
|
|
13
|
+
export type { CropperState, CropperAction, TransformOperation, NormalizedPoint, NormalizedRect, Size, Flip, StencilProps, HandlePosition, } from './core';
|
|
14
|
+
export { DEFAULT_STATE, DEFAULT_ASPECT_RATIOS, ORIGINAL_ASPECT_RATIO, cropperReducer, enforceContainment, areCropperStatesEqual, computeInscribedRect, getSourceRegion, getSourceRegionPercent, applyOperationToState, stateFromPipeline, exportCroppedImage, applyToCanvas, } from './core';
|
|
15
15
|
export type { AspectRatioPreset, SourceRegion, SourceRegionPercent, } from './core';
|
|
16
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/image-editor/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/image-editor/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC1E,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACvE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGvD,YAAY,EACX,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,IAAI,EACJ,IAAI,EACJ,YAAY,EACZ,cAAc,GACd,MAAM,QAAQ,CAAC;AAMhB,OAAO,EACN,aAAa,EACb,qBAAqB,EACrB,qBAAqB,EACrB,cAAc,EACd,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,EACf,sBAAsB,EACtB,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,GACb,MAAM,QAAQ,CAAC;AAChB,YAAY,EACX,iBAAiB,EACjB,YAAY,EACZ,mBAAmB,GACnB,MAAM,QAAQ,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { type
|
|
4
|
+
import { type CropperController } from '../hooks/use-cropper-reducer';
|
|
5
5
|
import type { CropperState } from '../../core/types';
|
|
6
6
|
/**
|
|
7
7
|
* Props for the CropperProvider component.
|
|
@@ -13,12 +13,16 @@ interface CropperProviderProps {
|
|
|
13
13
|
children: React.ReactNode;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* Convenience context provider that wraps
|
|
16
|
+
* Convenience context provider that wraps `useCropperReducer`.
|
|
17
17
|
*
|
|
18
|
-
* Provides the
|
|
19
|
-
* descendant components via React context.
|
|
18
|
+
* Provides the pure cropper controller (state + setters, NO undo
|
|
19
|
+
* history) to all descendant components via React context.
|
|
20
20
|
*
|
|
21
|
-
*
|
|
21
|
+
* History is a higher-layer concern owned by composite stores
|
|
22
|
+
* (see `useMediaEditorState` in media-editor/state for the media
|
|
23
|
+
* editor's composite controller with undo/redo).
|
|
24
|
+
*
|
|
25
|
+
* @param props
|
|
22
26
|
* @param props.initialState
|
|
23
27
|
* @param props.children
|
|
24
28
|
* @return The provider element wrapping children.
|
|
@@ -30,8 +34,8 @@ export declare function CropperProvider({ initialState, children }: CropperProvi
|
|
|
30
34
|
* Must be used within a CropperProvider. Throws if used outside
|
|
31
35
|
* of the provider tree.
|
|
32
36
|
*
|
|
33
|
-
* @return The cropper
|
|
37
|
+
* @return The cropper controller.
|
|
34
38
|
*/
|
|
35
|
-
export declare function useCropper():
|
|
39
|
+
export declare function useCropper(): CropperController;
|
|
36
40
|
export {};
|
|
37
41
|
//# sourceMappingURL=cropper-provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cropper-provider.d.ts","sourceRoot":"","sources":["../../../../src/image-editor/react/components/cropper-provider.tsx"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,EAEN,KAAK,
|
|
1
|
+
{"version":3,"file":"cropper-provider.d.ts","sourceRoot":"","sources":["../../../../src/image-editor/react/components/cropper-provider.tsx"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,EAEN,KAAK,iBAAiB,EACtB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAUrD;;GAEG;AACH,UAAU,oBAAoB;IAC7B,6DAA6D;IAC7D,YAAY,CAAC,EAAE,OAAO,CAAE,YAAY,CAAE,CAAC;IACvC,wBAAwB;IACxB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC1B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAAE,EAChC,YAAY,EACZ,QAAQ,EACR,EAAE,oBAAoB,+BAQtB;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,IAAI,iBAAiB,CAQ9C"}
|
|
@@ -5,15 +5,15 @@
|
|
|
5
5
|
* Internal dependencies
|
|
6
6
|
*/
|
|
7
7
|
import type { CropperState, StencilProps, Size } from '../../core/types';
|
|
8
|
-
import type {
|
|
8
|
+
import type { CropperController } from '../hooks/use-cropper-reducer';
|
|
9
9
|
/**
|
|
10
10
|
* Props for the Cropper component.
|
|
11
11
|
*/
|
|
12
12
|
export interface CropperProps {
|
|
13
13
|
/** Image source URL. */
|
|
14
14
|
src: string;
|
|
15
|
-
/** The
|
|
16
|
-
controller:
|
|
15
|
+
/** The cropper controller from `useCropperReducer` or a composite store. */
|
|
16
|
+
controller: CropperController;
|
|
17
17
|
/** Stencil component for the crop area. Defaults to RectangleStencil. */
|
|
18
18
|
stencil?: React.ComponentType<StencilProps>;
|
|
19
19
|
/** Show the rule-of-thirds grid overlay, or only during interactions. */
|
|
@@ -22,7 +22,9 @@ export interface CropperProps {
|
|
|
22
22
|
isPlacementActive?: boolean;
|
|
23
23
|
/** Show the dimming overlay outside the crop area. */
|
|
24
24
|
showDimming?: boolean;
|
|
25
|
-
/**
|
|
25
|
+
/** Show the live output dimensions tooltip during a resize. */
|
|
26
|
+
showDimensions?: boolean;
|
|
27
|
+
/** Minimum zoom level override. Defaults to the coverage-aware minimum. */
|
|
26
28
|
minZoom?: number;
|
|
27
29
|
/** Maximum zoom level. */
|
|
28
30
|
maxZoom?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cropper.d.ts","sourceRoot":"","sources":["../../../../src/image-editor/react/components/cropper.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAmBH;;GAEG;AACH,OAAO,KAAK,EACX,YAAY,
|
|
1
|
+
{"version":3,"file":"cropper.d.ts","sourceRoot":"","sources":["../../../../src/image-editor/react/components/cropper.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAmBH;;GAEG;AACH,OAAO,KAAK,EACX,YAAY,EAEZ,YAAY,EACZ,IAAI,EAEJ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAmBtE;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,wBAAwB;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,4EAA4E;IAC5E,UAAU,EAAE,iBAAiB,CAAC;IAC9B,yEAAyE;IACzE,OAAO,CAAC,EAAE,KAAK,CAAC,aAAa,CAAE,YAAY,CAAE,CAAC;IAC9C,yEAAyE;IACzE,QAAQ,CAAC,EAAE,OAAO,GAAG,aAAa,CAAC;IACnC,wEAAwE;IACxE,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,sDAAsD;IACtD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,+DAA+D;IAC/D,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,2EAA2E;IAC3E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,0BAA0B;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4EAA4E;IAC5E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,mDAAmD;IACnD,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,+CAA+C;IAC/C,aAAa,CAAC,EAAE,CAAE,IAAI,EAAE,IAAI,KAAM,IAAI,CAAC;IACvC;;;;;;;;;OASG;IACH,aAAa,CAAC,EAAE,CAAE,KAAK,EAAE,YAAY,KAAM,IAAI,CAAC;IAChD,oFAAoF;IACpF,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,uEAAuE;IACvE,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,8CAA8C;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAytBD,eAAO,MAAM,OAAO,yGAMnB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { HandlePosition, NormalizedRect, Size } from '../../../core/types';
|
|
5
|
+
interface DimensionsOverlayProps {
|
|
6
|
+
/** Crop rectangle in normalized coordinates. */
|
|
7
|
+
cropRect: NormalizedRect;
|
|
8
|
+
/** Container element dimensions in pixels. */
|
|
9
|
+
containerSize: Size;
|
|
10
|
+
/** Rendered image dimensions in pixels within the container. */
|
|
11
|
+
imageSize: Size;
|
|
12
|
+
/** Currently-dragged handle, or null when no pointer drag is active. */
|
|
13
|
+
activeHandle: HandlePosition | null;
|
|
14
|
+
/** Output crop width in source pixels. */
|
|
15
|
+
outputWidth: number;
|
|
16
|
+
/** Output crop height in source pixels. */
|
|
17
|
+
outputHeight: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Tooltip that follows the active resize handle during a pointer drag,
|
|
21
|
+
* showing the current output dimensions of the crop in source pixels.
|
|
22
|
+
*
|
|
23
|
+
* Renders nothing outside of a pointer-driven resize, so keyboard
|
|
24
|
+
* arrow-key adjustments and pan/zoom gestures stay quiet.
|
|
25
|
+
*
|
|
26
|
+
* @param props
|
|
27
|
+
* @param props.cropRect
|
|
28
|
+
* @param props.containerSize
|
|
29
|
+
* @param props.imageSize
|
|
30
|
+
* @param props.activeHandle
|
|
31
|
+
* @param props.outputWidth
|
|
32
|
+
* @param props.outputHeight
|
|
33
|
+
*/
|
|
34
|
+
export declare function DimensionsOverlay({ cropRect, containerSize, imageSize, activeHandle, outputWidth, outputHeight }: DimensionsOverlayProps): import("react").JSX.Element | null;
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=dimensions-overlay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dimensions-overlay.d.ts","sourceRoot":"","sources":["../../../../../src/image-editor/react/components/overlays/dimensions-overlay.tsx"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAgIhF,UAAU,sBAAsB;IAC/B,gDAAgD;IAChD,QAAQ,EAAE,cAAc,CAAC;IACzB,8CAA8C;IAC9C,aAAa,EAAE,IAAI,CAAC;IACpB,gEAAgE;IAChE,SAAS,EAAE,IAAI,CAAC;IAChB,wEAAwE;IACxE,YAAY,EAAE,cAAc,GAAG,IAAI,CAAC;IACpC,0CAA0C;IAC1C,WAAW,EAAE,MAAM,CAAC;IACpB,2CAA2C;IAC3C,YAAY,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAAE,EAClC,QAAQ,EACR,aAAa,EACb,SAAS,EACT,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,EAAE,sBAAsB,sCA+FxB"}
|
|
@@ -25,8 +25,9 @@ type RectangleStencilProps = StencilProps;
|
|
|
25
25
|
* @param props.stencilTransition CSS transition string for settle animation.
|
|
26
26
|
* @param props.cropBounds Maximum crop rect bounds from camera (zoom/rotation-aware).
|
|
27
27
|
* @param props.onEscape Called when Escape is pressed on a resize handle.
|
|
28
|
+
* @param props.minCropSize Minimum crop rect dimension in normalized space, per axis.
|
|
28
29
|
* @return The rectangle stencil element.
|
|
29
30
|
*/
|
|
30
|
-
export declare function RectangleStencil({ cropRect, containerSize, imageSize, onCropChange, onResizeStart, onResizeEnd, aspectRatio, freeformCrop, stencilTransition, cropBounds, onEscape }: RectangleStencilProps): import("react").JSX.Element | null;
|
|
31
|
+
export declare function RectangleStencil({ cropRect, containerSize, imageSize, onCropChange, onResizeStart, onResizeEnd, aspectRatio, freeformCrop, stencilTransition, cropBounds, onEscape, minCropSize }: RectangleStencilProps): import("react").JSX.Element | null;
|
|
31
32
|
export {};
|
|
32
33
|
//# sourceMappingURL=rectangle-stencil.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rectangle-stencil.d.ts","sourceRoot":"","sources":["../../../../../src/image-editor/react/components/stencils/rectangle-stencil.tsx"],"names":[],"mappings":"AAYA;;GAEG;AACH,OAAO,KAAK,EAAE,YAAY,EAAkB,MAAM,qBAAqB,CAAC;AAkExE;;GAEG;AACH,KAAK,qBAAqB,GAAG,YAAY,CAAC;AAE1C
|
|
1
|
+
{"version":3,"file":"rectangle-stencil.d.ts","sourceRoot":"","sources":["../../../../../src/image-editor/react/components/stencils/rectangle-stencil.tsx"],"names":[],"mappings":"AAYA;;GAEG;AACH,OAAO,KAAK,EAAE,YAAY,EAAkB,MAAM,qBAAqB,CAAC;AAkExE;;GAEG;AACH,KAAK,qBAAqB,GAAG,YAAY,CAAC;AAE1C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,gBAAgB,CAAE,EACjC,QAAQ,EACR,aAAa,EACb,SAAS,EACT,YAAY,EACZ,aAAa,EACb,WAAW,EACX,WAAW,EACX,YAAoB,EACpB,iBAAiB,EACjB,UAAU,EACV,QAAQ,EACR,WAAW,EACX,EAAE,qBAAqB,sCAuavB"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { CropperAction, CropperState, Flip, NormalizedPoint, NormalizedRect, TransformOperation } from '../../core/types';
|
|
5
|
+
/**
|
|
6
|
+
* The named cropper setters shared by every hook that drives the
|
|
7
|
+
* cropper reducer — the pure `useCropperReducer` and any composite
|
|
8
|
+
* store that delegates cropper actions (e.g. `useMediaEditorState`).
|
|
9
|
+
*
|
|
10
|
+
* `setImage` and `reset` are intentionally NOT included: each hook
|
|
11
|
+
* has additional bookkeeping for them (dirty-baseline, history clear)
|
|
12
|
+
* that doesn't fit a shared factory.
|
|
13
|
+
*/
|
|
14
|
+
export interface CropperSetters {
|
|
15
|
+
setPan: (pan: NormalizedPoint) => void;
|
|
16
|
+
setZoom: (zoom: number) => void;
|
|
17
|
+
setZoomAtPoint: (zoom: number, pan: NormalizedPoint) => void;
|
|
18
|
+
setRotation: (rotation: number) => void;
|
|
19
|
+
setFlip: (flip: Flip) => void;
|
|
20
|
+
toggleFlip: (direction: 'horizontal' | 'vertical') => void;
|
|
21
|
+
snapRotate90: (direction: 1 | -1) => void;
|
|
22
|
+
setCropRect: (rect: NormalizedRect) => void;
|
|
23
|
+
settleCrop: () => void;
|
|
24
|
+
applyOperation: (op: TransformOperation) => void;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Build the named cropper setters from a dispatch function and a
|
|
28
|
+
* state getter. The two consuming hooks differ in how they dispatch:
|
|
29
|
+
*
|
|
30
|
+
* - `useCropperReducer` dispatches directly into its `useReducer`.
|
|
31
|
+
* - `useMediaEditorState` wraps cropper actions in a composite
|
|
32
|
+
* `CROPPER` envelope so the history machinery can record them.
|
|
33
|
+
*
|
|
34
|
+
* Both pass their own dispatch function and a getter that returns
|
|
35
|
+
* the current `CropperState`. The factory shape keeps the two hooks
|
|
36
|
+
* in lockstep — add a setter here once, both hooks get it.
|
|
37
|
+
*
|
|
38
|
+
* @param dispatchCropperAction Apply a `CropperAction` to the
|
|
39
|
+
* underlying reducer.
|
|
40
|
+
* @param getCropperState Return the current `CropperState`.
|
|
41
|
+
* Used by setters that need to read
|
|
42
|
+
* the latest state to compute their
|
|
43
|
+
* payload (focal-point zoom, flip toggle).
|
|
44
|
+
* @return The named cropper setters.
|
|
45
|
+
*/
|
|
46
|
+
export declare function buildCropperSetters(dispatchCropperAction: (action: CropperAction) => void, getCropperState: () => CropperState): CropperSetters;
|
|
47
|
+
//# sourceMappingURL=build-cropper-setters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-cropper-setters.d.ts","sourceRoot":"","sources":["../../../../src/image-editor/react/hooks/build-cropper-setters.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EACX,aAAa,EACb,YAAY,EACZ,IAAI,EACJ,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,MAAM,kBAAkB,CAAC;AAG1B;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAc;IAC9B,MAAM,EAAE,CAAE,GAAG,EAAE,eAAe,KAAM,IAAI,CAAC;IACzC,OAAO,EAAE,CAAE,IAAI,EAAE,MAAM,KAAM,IAAI,CAAC;IAClC,cAAc,EAAE,CAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,eAAe,KAAM,IAAI,CAAC;IAC/D,WAAW,EAAE,CAAE,QAAQ,EAAE,MAAM,KAAM,IAAI,CAAC;IAC1C,OAAO,EAAE,CAAE,IAAI,EAAE,IAAI,KAAM,IAAI,CAAC;IAChC,UAAU,EAAE,CAAE,SAAS,EAAE,YAAY,GAAG,UAAU,KAAM,IAAI,CAAC;IAC7D,YAAY,EAAE,CAAE,SAAS,EAAE,CAAC,GAAG,CAAC,CAAC,KAAM,IAAI,CAAC;IAC5C,WAAW,EAAE,CAAE,IAAI,EAAE,cAAc,KAAM,IAAI,CAAC;IAC9C,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,cAAc,EAAE,CAAE,EAAE,EAAE,kBAAkB,KAAM,IAAI,CAAC;CACnD;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,mBAAmB,CAClC,qBAAqB,EAAE,CAAE,MAAM,EAAE,aAAa,KAAM,IAAI,EACxD,eAAe,EAAE,MAAM,YAAY,GACjC,cAAc,CA8ChB"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export type {
|
|
1
|
+
export { useCropperReducer } from './use-cropper-reducer';
|
|
2
|
+
export type { CropperController } from './use-cropper-reducer';
|
|
3
|
+
export { buildCropperSetters } from './build-cropper-setters';
|
|
4
|
+
export type { CropperSetters } from './build-cropper-setters';
|
|
3
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/image-editor/react/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/image-editor/react/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,YAAY,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,YAAY,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-aria-announcer.d.ts","sourceRoot":"","sources":["../../../../src/image-editor/react/hooks/use-aria-announcer.ts"],"names":[],"mappings":"AAWA;;GAEG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAiErD;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAE,KAAK,EAAE,YAAY,GAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"use-aria-announcer.d.ts","sourceRoot":"","sources":["../../../../src/image-editor/react/hooks/use-aria-announcer.ts"],"names":[],"mappings":"AAWA;;GAEG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAiErD;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAE,KAAK,EAAE,YAAY,GAAI,MAAM,CAqC9D"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { CropperState, NormalizedRect, Size } from '../../core/types';
|
|
5
|
+
import { type CropperSetters } from './build-cropper-setters';
|
|
6
|
+
/**
|
|
7
|
+
* The cropper controller surface — the contract the Cropper component
|
|
8
|
+
* and its interaction hooks consume.
|
|
9
|
+
*
|
|
10
|
+
* History (undo / redo / commitHistory) is intentionally NOT part of
|
|
11
|
+
* this interface. The cropper is a pure state machine; history is a
|
|
12
|
+
* higher-layer concern owned by a composite store
|
|
13
|
+
* (see media-editor/src/state).
|
|
14
|
+
*/
|
|
15
|
+
export interface CropperController extends CropperSetters {
|
|
16
|
+
/** The current cropper state (read-only). */
|
|
17
|
+
state: CropperState;
|
|
18
|
+
/** Set the loaded image (natural size and src). */
|
|
19
|
+
setImage: (image: CropperState['image']) => void;
|
|
20
|
+
/** Reset the state. Optionally merge partial state overrides. */
|
|
21
|
+
reset: (resetState?: Partial<CropperState>) => void;
|
|
22
|
+
/** Whether the current state differs from the initial state. */
|
|
23
|
+
isDirty: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Export the cropped image as a Blob. Throws on failure — see
|
|
26
|
+
* `exportCroppedImage` for error semantics.
|
|
27
|
+
*/
|
|
28
|
+
getCroppedImage: (mimeType?: string, quality?: number) => Promise<Blob>;
|
|
29
|
+
/**
|
|
30
|
+
* Report the current rendered image size to the controller. The
|
|
31
|
+
* Cropper component calls this on visualSize changes; composite
|
|
32
|
+
* controllers use it to compute aspect-ratio reshapes. The pure
|
|
33
|
+
* cropper hook ignores it (no-op).
|
|
34
|
+
*/
|
|
35
|
+
setVisualSize: (size: Size) => void;
|
|
36
|
+
/**
|
|
37
|
+
* Adjust the cropRect in response to a viewport change (window
|
|
38
|
+
* resize, canvas resize). Behaves like `setCropRect` but, in
|
|
39
|
+
* composite controllers, does NOT record an undo entry — viewport
|
|
40
|
+
* reshapes aren't editor actions. The pure cropper hook aliases
|
|
41
|
+
* this to `setCropRect` (history is a composite concern).
|
|
42
|
+
*/
|
|
43
|
+
adjustCropRectForViewport: (rect: NormalizedRect) => void;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Pure reducer hook for the image cropper.
|
|
47
|
+
*
|
|
48
|
+
* Wraps the framework-agnostic `cropperReducer` and exposes named
|
|
49
|
+
* setters (built from the shared `buildCropperSetters` factory).
|
|
50
|
+
* Does NOT manage undo/redo history — that responsibility belongs to
|
|
51
|
+
* the surrounding application (see `useMediaEditorState` for the
|
|
52
|
+
* composite store used by the media editor).
|
|
53
|
+
*
|
|
54
|
+
* @param initialState Optional partial state to merge with DEFAULT_STATE.
|
|
55
|
+
* @return The cropper controller — state, setters, and helpers.
|
|
56
|
+
*/
|
|
57
|
+
export declare function useCropperReducer(initialState?: Partial<CropperState>): CropperController;
|
|
58
|
+
//# sourceMappingURL=use-cropper-reducer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-cropper-reducer.d.ts","sourceRoot":"","sources":["../../../../src/image-editor/react/hooks/use-cropper-reducer.ts"],"names":[],"mappings":"AAWA;;GAEG;AACH,OAAO,KAAK,EACX,YAAY,EAEZ,cAAc,EACd,IAAI,EACJ,MAAM,kBAAkB,CAAC;AAQ1B,OAAO,EAEN,KAAK,cAAc,EACnB,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;GAQG;AACH,MAAM,WAAW,iBAAkB,SAAQ,cAAc;IACxD,6CAA6C;IAC7C,KAAK,EAAE,YAAY,CAAC;IACpB,mDAAmD;IACnD,QAAQ,EAAE,CAAE,KAAK,EAAE,YAAY,CAAE,OAAO,CAAE,KAAM,IAAI,CAAC;IACrD,iEAAiE;IACjE,KAAK,EAAE,CAAE,UAAU,CAAC,EAAE,OAAO,CAAE,YAAY,CAAE,KAAM,IAAI,CAAC;IACxD,gEAAgE;IAChE,OAAO,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,eAAe,EAAE,CAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,KAAM,OAAO,CAAE,IAAI,CAAE,CAAC;IAC5E;;;;;OAKG;IACH,aAAa,EAAE,CAAE,IAAI,EAAE,IAAI,KAAM,IAAI,CAAC;IACtC;;;;;;OAMG;IACH,yBAAyB,EAAE,CAAE,IAAI,EAAE,cAAc,KAAM,IAAI,CAAC;CAC5D;AAaD;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAChC,YAAY,CAAC,EAAE,OAAO,CAAE,YAAY,CAAE,GACpC,iBAAiB,CA0GnB"}
|