@wordpress/media-editor 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/media-editor-canvas/index.cjs +54 -0
- package/build/components/media-editor-canvas/index.cjs.map +7 -0
- package/build/components/media-editor-crop-panel/index.cjs +116 -0
- package/build/components/media-editor-crop-panel/index.cjs.map +7 -0
- package/build/components/media-editor-modal/build-modifiers.cjs +91 -0
- package/build/components/media-editor-modal/build-modifiers.cjs.map +7 -0
- package/build/components/media-editor-modal/index.cjs +497 -0
- package/build/components/media-editor-modal/index.cjs.map +7 -0
- package/build/components/media-editor-toolbar/index.cjs +146 -0
- package/build/components/media-editor-toolbar/index.cjs.map +7 -0
- package/build/components/media-preview/index.cjs +1 -1
- package/build/components/media-preview/index.cjs.map +2 -2
- package/build/image-editor/core/camera.cjs +194 -0
- package/build/image-editor/core/camera.cjs.map +7 -0
- package/build/image-editor/core/constants.cjs +81 -0
- package/build/image-editor/core/constants.cjs.map +7 -0
- package/build/image-editor/core/containment.cjs +245 -0
- package/build/image-editor/core/containment.cjs.map +7 -0
- package/build/image-editor/core/export/canvas-renderer.cjs +151 -0
- package/build/image-editor/core/export/canvas-renderer.cjs.map +7 -0
- package/build/image-editor/core/index.cjs +50 -0
- package/build/image-editor/core/index.cjs.map +7 -0
- package/build/image-editor/core/interaction-controller.cjs +608 -0
- package/build/image-editor/core/interaction-controller.cjs.map +7 -0
- package/build/image-editor/core/math/rotation.cjs +41 -0
- package/build/image-editor/core/math/rotation.cjs.map +7 -0
- package/build/image-editor/core/source-region.cjs +95 -0
- package/build/image-editor/core/source-region.cjs.map +7 -0
- package/build/image-editor/core/state.cjs +269 -0
- package/build/image-editor/core/state.cjs.map +7 -0
- package/build/image-editor/core/stencil-math.cjs +197 -0
- package/build/image-editor/core/stencil-math.cjs.map +7 -0
- package/build/image-editor/core/transform-style.cjs +46 -0
- package/build/image-editor/core/transform-style.cjs.map +7 -0
- package/build/image-editor/core/transforms/pipeline.cjs +43 -0
- package/build/image-editor/core/transforms/pipeline.cjs.map +7 -0
- package/build/image-editor/core/types.cjs +19 -0
- package/build/image-editor/core/types.cjs.map +7 -0
- package/build/image-editor/index.cjs +57 -0
- package/build/image-editor/index.cjs.map +7 -0
- package/build/image-editor/react/components/cropper-provider.cjs +50 -0
- package/build/image-editor/react/components/cropper-provider.cjs.map +7 -0
- package/build/image-editor/react/components/cropper.cjs +365 -0
- package/build/image-editor/react/components/cropper.cjs.map +7 -0
- package/build/image-editor/react/components/index.cjs +36 -0
- package/build/image-editor/react/components/index.cjs.map +7 -0
- package/build/image-editor/react/components/overlays/dimming-overlay.cjs +58 -0
- package/build/image-editor/react/components/overlays/dimming-overlay.cjs.map +7 -0
- package/build/image-editor/react/components/overlays/grid-overlay.cjs +91 -0
- package/build/image-editor/react/components/overlays/grid-overlay.cjs.map +7 -0
- package/build/image-editor/react/components/stencils/rectangle-stencil.cjs +351 -0
- package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +7 -0
- package/build/image-editor/react/hooks/index.cjs +31 -0
- package/build/image-editor/react/hooks/index.cjs.map +7 -0
- package/build/image-editor/react/hooks/use-aria-announcer.cjs +68 -0
- package/build/image-editor/react/hooks/use-aria-announcer.cjs.map +7 -0
- package/build/image-editor/react/hooks/use-cropper-state.cjs +158 -0
- package/build/image-editor/react/hooks/use-cropper-state.cjs.map +7 -0
- package/build/image-editor/react/hooks/use-interaction.cjs +161 -0
- package/build/image-editor/react/hooks/use-interaction.cjs.map +7 -0
- package/build/image-editor/react/hooks/use-transform-style.cjs +38 -0
- package/build/image-editor/react/hooks/use-transform-style.cjs.map +7 -0
- package/build/index.cjs +5 -2
- package/build/index.cjs.map +2 -2
- package/build/lock-unlock.cjs +37 -0
- package/build/lock-unlock.cjs.map +7 -0
- package/build/private-apis.cjs +38 -0
- package/build/private-apis.cjs.map +7 -0
- package/build/store/actions.cjs +45 -0
- package/build/store/actions.cjs.map +7 -0
- package/build/store/constants.cjs +31 -0
- package/build/store/constants.cjs.map +7 -0
- package/build/store/index.cjs +51 -0
- package/build/store/index.cjs.map +7 -0
- package/build/store/reducer.cjs +51 -0
- package/build/store/reducer.cjs.map +7 -0
- package/build/store/selectors.cjs +43 -0
- package/build/store/selectors.cjs.map +7 -0
- package/build-module/components/media-editor-canvas/index.mjs +33 -0
- package/build-module/components/media-editor-canvas/index.mjs.map +7 -0
- package/build-module/components/media-editor-crop-panel/index.mjs +100 -0
- package/build-module/components/media-editor-crop-panel/index.mjs.map +7 -0
- package/build-module/components/media-editor-modal/build-modifiers.mjs +66 -0
- package/build-module/components/media-editor-modal/build-modifiers.mjs.map +7 -0
- package/build-module/components/media-editor-modal/index.mjs +483 -0
- package/build-module/components/media-editor-modal/index.mjs.map +7 -0
- package/build-module/components/media-editor-toolbar/index.mjs +130 -0
- package/build-module/components/media-editor-toolbar/index.mjs.map +7 -0
- package/build-module/components/media-preview/index.mjs +1 -1
- package/build-module/components/media-preview/index.mjs.map +2 -2
- package/build-module/image-editor/core/camera.mjs +163 -0
- package/build-module/image-editor/core/camera.mjs.map +7 -0
- package/build-module/image-editor/core/constants.mjs +51 -0
- package/build-module/image-editor/core/constants.mjs.map +7 -0
- package/build-module/image-editor/core/containment.mjs +218 -0
- package/build-module/image-editor/core/containment.mjs.map +7 -0
- package/build-module/image-editor/core/export/canvas-renderer.mjs +120 -0
- package/build-module/image-editor/core/export/canvas-renderer.mjs.map +7 -0
- package/build-module/image-editor/core/index.mjs +24 -0
- package/build-module/image-editor/core/index.mjs.map +7 -0
- package/build-module/image-editor/core/interaction-controller.mjs +583 -0
- package/build-module/image-editor/core/interaction-controller.mjs.map +7 -0
- package/build-module/image-editor/core/math/rotation.mjs +15 -0
- package/build-module/image-editor/core/math/rotation.mjs.map +7 -0
- package/build-module/image-editor/core/source-region.mjs +69 -0
- package/build-module/image-editor/core/source-region.mjs.map +7 -0
- package/build-module/image-editor/core/state.mjs +242 -0
- package/build-module/image-editor/core/state.mjs.map +7 -0
- package/build-module/image-editor/core/stencil-math.mjs +169 -0
- package/build-module/image-editor/core/stencil-math.mjs.map +7 -0
- package/build-module/image-editor/core/transform-style.mjs +21 -0
- package/build-module/image-editor/core/transform-style.mjs.map +7 -0
- package/build-module/image-editor/core/transforms/pipeline.mjs +17 -0
- package/build-module/image-editor/core/transforms/pipeline.mjs.map +7 -0
- package/build-module/image-editor/core/types.mjs +1 -0
- package/build-module/image-editor/core/types.mjs.map +7 -0
- package/build-module/image-editor/index.mjs +30 -0
- package/build-module/image-editor/index.mjs.map +7 -0
- package/build-module/image-editor/react/components/cropper-provider.mjs +26 -0
- package/build-module/image-editor/react/components/cropper-provider.mjs.map +7 -0
- package/build-module/image-editor/react/components/cropper.mjs +337 -0
- package/build-module/image-editor/react/components/cropper.mjs.map +7 -0
- package/build-module/image-editor/react/components/index.mjs +9 -0
- package/build-module/image-editor/react/components/index.mjs.map +7 -0
- package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs +33 -0
- package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs.map +7 -0
- package/build-module/image-editor/react/components/overlays/grid-overlay.mjs +66 -0
- package/build-module/image-editor/react/components/overlays/grid-overlay.mjs.map +7 -0
- package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs +330 -0
- package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs.map +7 -0
- package/build-module/image-editor/react/hooks/index.mjs +6 -0
- package/build-module/image-editor/react/hooks/index.mjs.map +7 -0
- package/build-module/image-editor/react/hooks/use-aria-announcer.mjs +43 -0
- package/build-module/image-editor/react/hooks/use-aria-announcer.mjs.map +7 -0
- package/build-module/image-editor/react/hooks/use-cropper-state.mjs +137 -0
- package/build-module/image-editor/react/hooks/use-cropper-state.mjs.map +7 -0
- package/build-module/image-editor/react/hooks/use-interaction.mjs +138 -0
- package/build-module/image-editor/react/hooks/use-interaction.mjs.map +7 -0
- package/build-module/image-editor/react/hooks/use-transform-style.mjs +13 -0
- package/build-module/image-editor/react/hooks/use-transform-style.mjs.map +7 -0
- package/build-module/index.mjs +3 -1
- package/build-module/index.mjs.map +2 -2
- package/build-module/lock-unlock.mjs +11 -0
- package/build-module/lock-unlock.mjs.map +7 -0
- package/build-module/private-apis.mjs +13 -0
- package/build-module/private-apis.mjs.map +7 -0
- package/build-module/store/actions.mjs +19 -0
- package/build-module/store/actions.mjs.map +7 -0
- package/build-module/store/constants.mjs +6 -0
- package/build-module/store/constants.mjs.map +7 -0
- package/build-module/store/index.mjs +16 -0
- package/build-module/store/index.mjs.map +7 -0
- package/build-module/store/reducer.mjs +26 -0
- package/build-module/store/reducer.mjs.map +7 -0
- package/build-module/store/selectors.mjs +16 -0
- package/build-module/store/selectors.mjs.map +7 -0
- package/build-style/style-rtl.css +315 -0
- package/build-style/style.css +315 -0
- package/build-types/components/media-editor-canvas/index.d.ts +22 -0
- package/build-types/components/media-editor-canvas/index.d.ts.map +1 -0
- package/build-types/components/media-editor-crop-panel/index.d.ts +45 -0
- package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -0
- package/build-types/components/media-editor-modal/build-modifiers.d.ts +83 -0
- package/build-types/components/media-editor-modal/build-modifiers.d.ts.map +1 -0
- package/build-types/components/media-editor-modal/index.d.ts +20 -0
- package/build-types/components/media-editor-modal/index.d.ts.map +1 -0
- package/build-types/components/media-editor-toolbar/index.d.ts +21 -0
- package/build-types/components/media-editor-toolbar/index.d.ts.map +1 -0
- package/build-types/components/media-preview/index.d.ts.map +1 -1
- package/build-types/image-editor/core/camera.d.ts +107 -0
- package/build-types/image-editor/core/camera.d.ts.map +1 -0
- package/build-types/image-editor/core/constants.d.ts +46 -0
- package/build-types/image-editor/core/constants.d.ts.map +1 -0
- package/build-types/image-editor/core/containment.d.ts +61 -0
- package/build-types/image-editor/core/containment.d.ts.map +1 -0
- package/build-types/image-editor/core/export/canvas-renderer.d.ts +106 -0
- package/build-types/image-editor/core/export/canvas-renderer.d.ts.map +1 -0
- package/build-types/image-editor/core/index.d.ts +8 -0
- package/build-types/image-editor/core/index.d.ts.map +1 -0
- package/build-types/image-editor/core/interaction-controller.d.ts +178 -0
- package/build-types/image-editor/core/interaction-controller.d.ts.map +1 -0
- package/build-types/image-editor/core/math/rotation.d.ts +18 -0
- package/build-types/image-editor/core/math/rotation.d.ts.map +1 -0
- package/build-types/image-editor/core/source-region.d.ts +75 -0
- package/build-types/image-editor/core/source-region.d.ts.map +1 -0
- package/build-types/image-editor/core/state.d.ts +42 -0
- package/build-types/image-editor/core/state.d.ts.map +1 -0
- package/build-types/image-editor/core/stencil-math.d.ts +79 -0
- package/build-types/image-editor/core/stencil-math.d.ts.map +1 -0
- package/build-types/image-editor/core/transform-style.d.ts +23 -0
- package/build-types/image-editor/core/transform-style.d.ts.map +1 -0
- package/build-types/image-editor/core/transforms/pipeline.d.ts +27 -0
- package/build-types/image-editor/core/transforms/pipeline.d.ts.map +1 -0
- package/build-types/image-editor/core/types.d.ts +211 -0
- package/build-types/image-editor/core/types.d.ts.map +1 -0
- package/build-types/image-editor/index.d.ts +16 -0
- package/build-types/image-editor/index.d.ts.map +1 -0
- package/build-types/image-editor/react/components/cropper-provider.d.ts +37 -0
- package/build-types/image-editor/react/components/cropper-provider.d.ts.map +1 -0
- package/build-types/image-editor/react/components/cropper.d.ts +59 -0
- package/build-types/image-editor/react/components/cropper.d.ts.map +1 -0
- package/build-types/image-editor/react/components/index.d.ts +4 -0
- package/build-types/image-editor/react/components/index.d.ts.map +1 -0
- package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts +30 -0
- package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts.map +1 -0
- package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts +30 -0
- package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts.map +1 -0
- package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts +32 -0
- package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts.map +1 -0
- package/build-types/image-editor/react/hooks/index.d.ts +3 -0
- package/build-types/image-editor/react/hooks/index.d.ts.map +1 -0
- package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts +16 -0
- package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts.map +1 -0
- package/build-types/image-editor/react/hooks/use-cropper-state.d.ts +68 -0
- package/build-types/image-editor/react/hooks/use-cropper-state.d.ts.map +1 -0
- package/build-types/image-editor/react/hooks/use-interaction.d.ts +60 -0
- package/build-types/image-editor/react/hooks/use-interaction.d.ts.map +1 -0
- package/build-types/image-editor/react/hooks/use-transform-style.d.ts +16 -0
- package/build-types/image-editor/react/hooks/use-transform-style.d.ts.map +1 -0
- package/build-types/image-editor/stories/rectangle-crop.story.d.ts +16 -0
- package/build-types/image-editor/stories/rectangle-crop.story.d.ts.map +1 -0
- package/build-types/index.d.ts +1 -0
- package/build-types/index.d.ts.map +1 -1
- package/build-types/lock-unlock.d.ts +2 -0
- package/build-types/lock-unlock.d.ts.map +1 -0
- package/build-types/private-apis.d.ts +2 -0
- package/build-types/private-apis.d.ts.map +1 -0
- package/build-types/store/actions.d.ts +27 -0
- package/build-types/store/actions.d.ts.map +1 -0
- package/build-types/store/constants.d.ts +2 -0
- package/build-types/store/constants.d.ts.map +1 -0
- package/build-types/store/index.d.ts +4 -0
- package/build-types/store/index.d.ts.map +1 -0
- package/build-types/store/reducer.d.ts +23 -0
- package/build-types/store/reducer.d.ts.map +1 -0
- package/build-types/store/selectors.d.ts +8 -0
- package/build-types/store/selectors.d.ts.map +1 -0
- package/package.json +21 -8
- package/src/components/media-editor-canvas/index.tsx +56 -0
- package/src/components/media-editor-canvas/style.scss +9 -0
- package/src/components/media-editor-crop-panel/index.tsx +143 -0
- package/src/components/media-editor-modal/build-modifiers.ts +164 -0
- package/src/components/media-editor-modal/index.tsx +639 -0
- package/src/components/media-editor-modal/style.scss +139 -0
- package/src/components/media-editor-modal/test/build-modifiers.test.ts +343 -0
- package/src/components/media-editor-toolbar/index.tsx +150 -0
- package/src/components/media-editor-toolbar/style.scss +21 -0
- package/src/components/media-preview/index.tsx +2 -1
- package/src/image-editor/README.md +162 -0
- package/src/image-editor/core/camera.ts +352 -0
- package/src/image-editor/core/constants.ts +93 -0
- package/src/image-editor/core/containment.ts +435 -0
- package/src/image-editor/core/export/canvas-renderer.ts +253 -0
- package/src/image-editor/core/export/test/canvas-renderer.ts +813 -0
- package/src/image-editor/core/index.ts +35 -0
- package/src/image-editor/core/interaction-controller.ts +889 -0
- package/src/image-editor/core/math/rotation.ts +26 -0
- package/src/image-editor/core/source-region.ts +166 -0
- package/src/image-editor/core/state.ts +428 -0
- package/src/image-editor/core/stencil-math.ts +330 -0
- package/src/image-editor/core/test/camera.ts +593 -0
- package/src/image-editor/core/test/interaction-controller.ts +996 -0
- package/src/image-editor/core/test/preview-export-parity.ts +242 -0
- package/src/image-editor/core/test/render-camera-bridge.ts +348 -0
- package/src/image-editor/core/test/state.ts +762 -0
- package/src/image-editor/core/test/stencil-math.ts +321 -0
- package/src/image-editor/core/transform-style.ts +44 -0
- package/src/image-editor/core/transforms/pipeline.ts +43 -0
- package/src/image-editor/core/transforms/test/pipeline.ts +269 -0
- package/src/image-editor/core/types.ts +177 -0
- package/src/image-editor/docs/architecture.md +96 -0
- package/src/image-editor/docs/recipes.md +720 -0
- package/src/image-editor/docs/roadmap.md +66 -0
- package/src/image-editor/index.ts +43 -0
- package/src/image-editor/react/components/cropper-provider.tsx +73 -0
- package/src/image-editor/react/components/cropper.scss +195 -0
- package/src/image-editor/react/components/cropper.tsx +534 -0
- package/src/image-editor/react/components/index.ts +3 -0
- package/src/image-editor/react/components/overlays/dimming-overlay.tsx +57 -0
- package/src/image-editor/react/components/overlays/grid-overlay.tsx +80 -0
- package/src/image-editor/react/components/stencils/rectangle-stencil.tsx +513 -0
- package/src/image-editor/react/components/stencils/test/rectangle-stencil.tsx +265 -0
- package/src/image-editor/react/components/test/cropper.tsx +140 -0
- package/src/image-editor/react/hooks/index.ts +2 -0
- package/src/image-editor/react/hooks/test/use-cropper-state.ts +913 -0
- package/src/image-editor/react/hooks/test/use-interaction.ts +218 -0
- package/src/image-editor/react/hooks/test/use-transform-style.ts +146 -0
- package/src/image-editor/react/hooks/use-aria-announcer.ts +64 -0
- package/src/image-editor/react/hooks/use-cropper-state.ts +238 -0
- package/src/image-editor/react/hooks/use-interaction.ts +223 -0
- package/src/image-editor/react/hooks/use-transform-style.ts +30 -0
- package/src/image-editor/stories/rectangle-crop.story.tsx +1085 -0
- package/src/image-editor/stories/style.css +94 -0
- package/src/image-editor/style.scss +1 -0
- package/src/index.ts +3 -0
- package/src/lock-unlock.ts +10 -0
- package/src/private-apis.ts +12 -0
- package/src/store/actions.ts +33 -0
- package/src/store/constants.ts +1 -0
- package/src/store/index.ts +20 -0
- package/src/store/reducer.ts +48 -0
- package/src/store/selectors.ts +16 -0
- package/src/store/test/reducer.ts +57 -0
- package/src/style.scss +4 -0
- package/tsconfig.json +10 -2
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/image-editor/core/interaction-controller.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { CropperState, NormalizedPoint, Size } from './types';\nimport { MIN_ZOOM, MAX_ZOOM } from './constants';\nimport { restrictPanZoom } from './containment';\n\n/** Time window for detecting a double-tap gesture (ms). */\nconst DOUBLE_TAP_TIME = 300;\n/** Max distance between taps to count as a double-tap (px). */\nconst DOUBLE_TAP_DISTANCE = 30;\n/** Duration of the zoom animation state (ms). */\nconst ZOOM_ANIMATION_DURATION = 200;\n\n/**\n * Get the natural image dimensions from cropper state, falling back to 1x1.\n *\n * @param state The current cropper state.\n * @return The image dimensions.\n */\nfunction getImageSizeFromState( state: CropperState ): {\n\twidth: number;\n\theight: number;\n} {\n\treturn state.image\n\t\t? { width: state.image.naturalWidth, height: state.image.naturalHeight }\n\t\t: { width: 1, height: 1 };\n}\n\n/**\n * Get the distance between two touch points.\n *\n * @param t1 The first touch.\n * @param t2 The second touch.\n * @return The pixel distance between the two touches.\n */\nfunction getTouchDistance( t1: Touch, t2: Touch ): number {\n\tconst dx = t1.clientX - t2.clientX;\n\tconst dy = t1.clientY - t2.clientY;\n\treturn Math.sqrt( dx * dx + dy * dy );\n}\n\n/**\n * Status reported by the interaction controller when drag/zoom state changes.\n */\nexport interface InteractionStatus {\n\t/** Whether a drag (pan) interaction is in progress. */\n\tisDragging: boolean;\n\t/** Whether a double-tap zoom animation is in progress. */\n\tisZooming: boolean;\n}\n\n/**\n * State updates the interaction controller can request from its host UI.\n */\nexport interface CropperInteractionActions {\n\t/** Set the image pan offset in normalized coordinates. */\n\tsetPan: ( pan: NormalizedPoint ) => void;\n\t/** Set the zoom level. */\n\tsetZoom: ( zoom: number ) => void;\n\t/** Set zoom and pan together for focal-point zoom. */\n\tsetZoomAtPoint: ( zoom: number, pan: NormalizedPoint ) => void;\n\t/** Snap rotate by 90 degrees. */\n\tsnapRotate90: ( direction: 1 | -1 ) => void;\n}\n\n/**\n * Options for creating an InteractionController.\n *\n * Scalar options (minZoom, maxZoom, etc.) are read lazily on each\n * interaction, so changes to the options object take effect immediately\n * without recreating the controller.\n */\nexport interface InteractionControllerOptions {\n\t/** Returns the current cropper state. Called on every interaction. */\n\tgetState: () => CropperState;\n\t/** State updates the interaction controller can request from its host UI. */\n\tactions: CropperInteractionActions;\n\t/** Returns the container dimensions in pixels. */\n\tgetContainerSize: () => Size;\n\t/** Returns the rendered image dimensions in pixels, if available. */\n\tgetImageSize: () => Size | undefined;\n\t/** Minimum zoom level. Defaults to MIN_ZOOM. Read lazily. */\n\tminZoom?: number;\n\t/** Maximum zoom level. Defaults to MAX_ZOOM. Read lazily. */\n\tmaxZoom?: number;\n\t/** Zoom speed multiplier for wheel events. Defaults to 0.01. Read lazily. */\n\tzoomSpeed?: number;\n\t/** Pan step size in normalized coords for keyboard events. Defaults to 0.05. Read lazily. */\n\tkeyboardStep?: number;\n\t/** Zoom level for double-tap zoom. Defaults to 2. Read lazily. */\n\tdoubleTapZoom?: number;\n\t/** Fires when a continuous gesture begins (pan drag, pinch zoom). */\n\tonGestureStart?: () => void;\n\t/** Fires when a continuous gesture ends (pointer release). */\n\tonGestureEnd?: () => void;\n\t/** Called when isDragging or isZooming changes. */\n\tonStatusChange?: ( status: InteractionStatus ) => void;\n}\n\n/**\n * Framework-agnostic imperative controller for image cropper interactions.\n *\n * Handles mouse, touch, and keyboard event processing for pan, zoom,\n * and crop manipulation. Uses requestAnimationFrame for drag/pinch\n * updates to avoid layout thrashing.\n *\n * The controller does not register DOM event listeners itself \u2014 that is the\n * responsibility of the UI layer (React hook, Vue directive, or vanilla JS).\n * Instead it exposes `handlePointerDown`, `handleWheel`, `handleTouchStart`,\n * and `handleKeyDown` methods that the UI layer calls with native DOM events.\n *\n * Scalar options (minZoom, maxZoom, zoomSpeed, keyboardStep, doubleTapZoom)\n * are read lazily from `this.options` on each interaction, so the UI layer\n * can update them without recreating the controller.\n *\n * Call `destroy()` to clean up timers and pending animation frames.\n */\nexport class InteractionController {\n\tprivate readonly options: InteractionControllerOptions;\n\n\t/** Current drag/zoom status. */\n\tprivate isDragging = false;\n\tprivate isZooming = false;\n\n\t/** Active drag state during pointer interactions. */\n\tprivate drag: {\n\t\tstartX: number;\n\t\tstartY: number;\n\t\tstartPanX: number;\n\t\tstartPanY: number;\n\t} | null = null;\n\n\t/** Active touch state during touch interactions. */\n\tprivate touch: {\n\t\t/** Finger distance at pinch start (0 until pinch detected). */\n\t\tstartDistance: number;\n\t\t/** Zoom level when pinch was detected. */\n\t\tstartZoom: number;\n\t\t/** First touch X/Y (for single-finger pan delta). */\n\t\tlastTouchX: number;\n\t\tlastTouchY: number;\n\t\t/** Pan when gesture started. */\n\t\tstartPanX: number;\n\t\tstartPanY: number;\n\t\t/** Container rect snapshot for focal-point math. */\n\t\tcontainerRect?: DOMRect;\n\t\t/** Midpoint of two fingers when pinch was detected. */\n\t\tstartMidX: number;\n\t\tstartMidY: number;\n\t\t/** Whether pinch was ever detected during this gesture. */\n\t\tdidPinch: boolean;\n\t\t/** Whether any dispatch has occurred (prevents dispatching before first move). */\n\t\tmoved: boolean;\n\t} | null = null;\n\n\t/** Cleanup function for active touch listeners on document. */\n\tprivate touchCleanup: ( () => void ) | null = null;\n\n\t/**\n\t * Cleanup function for active pointer-drag listeners on the\n\t * captured element. Set while a pointer drag is in progress so\n\t * `destroy()` can tear the drag down cleanly if the consumer\n\t * unmounts mid-drag. Cleared on pointerup/lostpointercapture.\n\t */\n\tprivate pointerCleanup: ( () => void ) | null = null;\n\n\t/** Last tap info for double-tap detection. */\n\tprivate lastTap: {\n\t\ttime: number;\n\t\tx: number;\n\t\ty: number;\n\t} | null = null;\n\n\t/** Timer for the zoom animation state (double-tap). */\n\tprivate zoomTimer: ReturnType< typeof setTimeout > | undefined;\n\n\t/** Timer for wheel gesture debounce. */\n\tprivate wheelGestureTimer: ReturnType< typeof setTimeout > | undefined;\n\n\t/** Whether a wheel gesture is currently active. */\n\tprivate wheelGestureActive = false;\n\n\t/** Current requestAnimationFrame ID. */\n\tprivate rafId = 0;\n\n\tconstructor( options: InteractionControllerOptions ) {\n\t\tthis.options = options;\n\t}\n\n\t/** Read minZoom lazily so option changes take effect immediately. */\n\tprivate get minZoom(): number {\n\t\treturn this.options.minZoom ?? MIN_ZOOM;\n\t}\n\n\t/** Read maxZoom lazily so option changes take effect immediately. */\n\tprivate get maxZoom(): number {\n\t\treturn this.options.maxZoom ?? MAX_ZOOM;\n\t}\n\n\t/** Read zoomSpeed lazily so option changes take effect immediately. */\n\tprivate get zoomSpeed(): number {\n\t\treturn this.options.zoomSpeed ?? 0.01;\n\t}\n\n\t/** Read keyboardStep lazily so option changes take effect immediately. */\n\tprivate get keyboardStep(): number {\n\t\treturn this.options.keyboardStep ?? 0.05;\n\t}\n\n\t/** Read doubleTapZoom lazily so option changes take effect immediately. */\n\tprivate get doubleTapZoom(): number {\n\t\treturn this.options.doubleTapZoom ?? 2;\n\t}\n\n\t/**\n\t * Update the drag/zoom status and notify via callback if changed.\n\t *\n\t * @param update Partial status with isDragging and/or isZooming.\n\t */\n\tprivate setStatus(\n\t\tupdate: Partial< { isDragging: boolean; isZooming: boolean } >\n\t): void {\n\t\tlet changed = false;\n\t\tif (\n\t\t\tupdate.isDragging !== undefined &&\n\t\t\tupdate.isDragging !== this.isDragging\n\t\t) {\n\t\t\tthis.isDragging = update.isDragging;\n\t\t\tchanged = true;\n\t\t}\n\t\tif (\n\t\t\tupdate.isZooming !== undefined &&\n\t\t\tupdate.isZooming !== this.isZooming\n\t\t) {\n\t\t\tthis.isZooming = update.isZooming;\n\t\t\tchanged = true;\n\t\t}\n\t\tif ( changed ) {\n\t\t\tthis.options.onStatusChange?.( {\n\t\t\t\tisDragging: this.isDragging,\n\t\t\t\tisZooming: this.isZooming,\n\t\t\t} );\n\t\t}\n\t}\n\n\t/**\n\t * Handle a pointer-down event on the container element.\n\t *\n\t * Initiates a drag (pan) interaction. Captures the pointer on the\n\t * provided element and registers pointermove/pointerup/lostpointercapture\n\t * listeners for the duration of the drag.\n\t *\n\t * @param e The native PointerEvent.\n\t * @param el The DOM element to capture the pointer on.\n\t */\n\thandlePointerDown( e: PointerEvent, el: HTMLElement ): void {\n\t\t// Only handle primary button (left click / first touch).\n\t\tif ( e.button !== 0 ) {\n\t\t\treturn;\n\t\t}\n\t\te.preventDefault();\n\n\t\t// Blur any focused handle so its focus ring doesn't linger,\n\t\t// but leave the canvas itself alone so keyboard control works after drag.\n\t\tconst ownerDoc = el.ownerDocument;\n\t\tif (\n\t\t\townerDoc?.activeElement instanceof HTMLElement &&\n\t\t\townerDoc.activeElement !== el\n\t\t) {\n\t\t\townerDoc.activeElement.blur();\n\t\t}\n\n\t\tel.focus();\n\n\t\t// Capture pointer so drag works across iframe boundaries.\n\t\tel.setPointerCapture( e.pointerId );\n\n\t\tthis.setStatus( { isDragging: true } );\n\t\tthis.options.onGestureStart?.();\n\n\t\tconst currentState = this.options.getState();\n\t\tthis.drag = {\n\t\t\tstartX: e.clientX,\n\t\t\tstartY: e.clientY,\n\t\t\tstartPanX: currentState.pan.x,\n\t\t\tstartPanY: currentState.pan.y,\n\t\t};\n\n\t\tconst onPointerMove = ( moveEvent: Event ) => {\n\t\t\tconst drag = this.drag;\n\t\t\tif ( ! drag ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst pe = moveEvent as PointerEvent;\n\n\t\t\tcancelAnimationFrame( this.rafId );\n\t\t\tthis.rafId = requestAnimationFrame( () => {\n\t\t\t\tconst s = this.options.getState();\n\t\t\t\tconst imgSize = this.options.getImageSize();\n\t\t\t\tconst containerSize = this.options.getContainerSize();\n\t\t\t\tconst panSize = imgSize ?? containerSize;\n\t\t\t\tconst deltaX =\n\t\t\t\t\tpanSize.width > 0\n\t\t\t\t\t\t? ( pe.clientX - drag.startX ) / panSize.width\n\t\t\t\t\t\t: 0;\n\t\t\t\tconst deltaY =\n\t\t\t\t\tpanSize.height > 0\n\t\t\t\t\t\t? ( pe.clientY - drag.startY ) / panSize.height\n\t\t\t\t\t\t: 0;\n\n\t\t\t\tconst { pan: newCrop } = restrictPanZoom(\n\t\t\t\t\t{\n\t\t\t\t\t\t...s,\n\t\t\t\t\t\tpan: {\n\t\t\t\t\t\t\tx: drag.startPanX + deltaX,\n\t\t\t\t\t\t\ty: drag.startPanY + deltaY,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tgetImageSizeFromState( s ),\n\t\t\t\t\ts.cropRect\n\t\t\t\t);\n\n\t\t\t\tthis.options.actions.setPan( newCrop );\n\t\t\t} );\n\t\t};\n\n\t\tconst removeListeners = () => {\n\t\t\tel.removeEventListener( 'pointermove', onPointerMove );\n\t\t\tel.removeEventListener( 'pointerup', onPointerUp );\n\t\t\tel.removeEventListener( 'lostpointercapture', onPointerUp );\n\t\t};\n\n\t\tconst onPointerUp = () => {\n\t\t\tthis.setStatus( { isDragging: false } );\n\t\t\tthis.options.onGestureEnd?.();\n\t\t\tthis.drag = null;\n\t\t\tcancelAnimationFrame( this.rafId );\n\t\t\tremoveListeners();\n\t\t\tthis.pointerCleanup = null;\n\t\t};\n\n\t\tel.addEventListener( 'pointermove', onPointerMove );\n\t\tel.addEventListener( 'pointerup', onPointerUp );\n\t\tel.addEventListener( 'lostpointercapture', onPointerUp );\n\t\t// Expose cleanup to destroy() in case the consumer unmounts\n\t\t// mid-drag. The pending rAF is cancelled in destroy().\n\t\tthis.pointerCleanup = removeListeners;\n\t}\n\n\t/**\n\t * Handle a wheel event on the container element.\n\t *\n\t * Implements focal-point zoom: the point under the cursor stays\n\t * stationary on screen while the zoom level changes.\n\t *\n\t * Must be registered with `{ passive: false }` to allow preventDefault.\n\t *\n\t * @param e The native WheelEvent.\n\t */\n\thandleWheel( e: WheelEvent ): void {\n\t\te.preventDefault();\n\n\t\t// Debounced gesture boundaries for wheel zoom.\n\t\t// Start on first wheel event, end after 300ms of no events.\n\t\tif ( ! this.wheelGestureActive ) {\n\t\t\tthis.wheelGestureActive = true;\n\t\t\tthis.options.onGestureStart?.();\n\t\t}\n\t\tclearTimeout( this.wheelGestureTimer );\n\t\tthis.wheelGestureTimer = setTimeout( () => {\n\t\t\tthis.wheelGestureActive = false;\n\t\t\tthis.options.onGestureEnd?.();\n\t\t}, DOUBLE_TAP_TIME );\n\n\t\tconst s = this.options.getState();\n\t\tconst delta = -e.deltaY * this.zoomSpeed;\n\t\tconst newZoom = Math.min(\n\t\t\tthis.maxZoom,\n\t\t\tMath.max( this.minZoom, s.zoom + delta )\n\t\t);\n\n\t\tif ( newZoom === s.zoom ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Focal-point zoom: keep the point under the cursor stationary.\n\t\tconst containerSize = this.options.getContainerSize();\n\t\tconst imgSize = this.options.getImageSize();\n\t\tconst visSize = imgSize ?? containerSize;\n\t\tconst target = e.currentTarget;\n\t\tconst rect =\n\t\t\ttarget instanceof Element\n\t\t\t\t? target.getBoundingClientRect()\n\t\t\t\t: undefined;\n\t\tif ( visSize.width > 0 && visSize.height > 0 && rect ) {\n\t\t\tconst fx = e.clientX - rect.left - containerSize.width / 2;\n\t\t\tconst fy = e.clientY - rect.top - containerSize.height / 2;\n\n\t\t\tconst zoomRatio = 1 - newZoom / s.zoom;\n\t\t\tconst focalNormX = fx / visSize.width;\n\t\t\tconst focalNormY = fy / visSize.height;\n\t\t\tconst newCropX = s.pan.x + ( focalNormX - s.pan.x ) * zoomRatio;\n\t\t\tconst newCropY = s.pan.y + ( focalNormY - s.pan.y ) * zoomRatio;\n\n\t\t\tconst { pan: clampedCrop } = restrictPanZoom(\n\t\t\t\t{ ...s, zoom: newZoom, pan: { x: newCropX, y: newCropY } },\n\t\t\t\tgetImageSizeFromState( s ),\n\t\t\t\ts.cropRect\n\t\t\t);\n\t\t\tthis.options.actions.setZoomAtPoint( newZoom, clampedCrop );\n\t\t} else {\n\t\t\tthis.options.actions.setZoom( newZoom );\n\t\t}\n\t}\n\n\t/**\n\t * Handle a touch-start event on the container element.\n\t *\n\t * Supports single-finger pan, two-finger pinch zoom, and\n\t * double-tap to toggle between fit and 2x zoom. Registers\n\t * touchmove/touchend/touchcancel on the provided document for the\n\t * duration of the gesture.\n\t *\n\t * @param e The native TouchEvent.\n\t * @param containerRect The bounding rect of the container element.\n\t * @param doc The document to register move/end listeners on.\n\t * Defaults to globalThis.document. Pass the iframe's\n\t * contentDocument when running inside an iframe.\n\t */\n\thandleTouchStart(\n\t\te: TouchEvent,\n\t\tcontainerRect: DOMRect,\n\t\tdoc: Document = document\n\t): void {\n\t\t// Second finger arriving during an existing gesture \u2014 snapshot\n\t\t// pinch start values. handleTouchMove will detect 2 touches and\n\t\t// handle pinch automatically.\n\t\tif ( this.touch && e.touches.length === 2 ) {\n\t\t\tconst s = this.options.getState();\n\t\t\tconst distance = getTouchDistance( e.touches[ 0 ], e.touches[ 1 ] );\n\t\t\tconst midX =\n\t\t\t\t( e.touches[ 0 ].clientX + e.touches[ 1 ].clientX ) / 2;\n\t\t\tconst midY =\n\t\t\t\t( e.touches[ 0 ].clientY + e.touches[ 1 ].clientY ) / 2;\n\t\t\tthis.touch.didPinch = true;\n\t\t\tthis.touch.startDistance = distance;\n\t\t\tthis.touch.startZoom = s.zoom;\n\t\t\tthis.touch.startPanX = s.pan.x;\n\t\t\tthis.touch.startPanY = s.pan.y;\n\t\t\tthis.touch.startMidX = midX;\n\t\t\tthis.touch.startMidY = midY;\n\t\t\tthis.touch.containerRect = containerRect;\n\t\t\tthis.setStatus( { isDragging: false } );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( e.touches.length === 1 ) {\n\t\t\tconst tapX = e.touches[ 0 ].clientX;\n\t\t\tconst tapY = e.touches[ 0 ].clientY;\n\t\t\tif ( this.tryDoubleTap( e, tapX, tapY, containerRect ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst currentState = this.options.getState();\n\n\t\t\t// Record touch state. Don't decide pan vs pinch yet \u2014\n\t\t\t// that happens in handleTouchMove based on touches.length.\n\t\t\tthis.touch = {\n\t\t\t\tstartDistance: 0,\n\t\t\t\tstartZoom: currentState.zoom,\n\t\t\t\tlastTouchX: e.touches[ 0 ].clientX,\n\t\t\t\tlastTouchY: e.touches[ 0 ].clientY,\n\t\t\t\tstartPanX: currentState.pan.x,\n\t\t\t\tstartPanY: currentState.pan.y,\n\t\t\t\tcontainerRect,\n\t\t\t\tstartMidX: 0,\n\t\t\t\tstartMidY: 0,\n\t\t\t\tdidPinch: false,\n\t\t\t\tmoved: false,\n\t\t\t};\n\t\t\tthis.options.onGestureStart?.();\n\t\t} else if ( e.touches.length === 2 ) {\n\t\t\t// Both fingers landed simultaneously (rare but possible).\n\t\t\tconst currentState = this.options.getState();\n\t\t\tconst distance = getTouchDistance( e.touches[ 0 ], e.touches[ 1 ] );\n\t\t\tconst midX =\n\t\t\t\t( e.touches[ 0 ].clientX + e.touches[ 1 ].clientX ) / 2;\n\t\t\tconst midY =\n\t\t\t\t( e.touches[ 0 ].clientY + e.touches[ 1 ].clientY ) / 2;\n\t\t\tthis.touch = {\n\t\t\t\tstartDistance: distance,\n\t\t\t\tstartZoom: currentState.zoom,\n\t\t\t\tlastTouchX: 0,\n\t\t\t\tlastTouchY: 0,\n\t\t\t\tstartPanX: currentState.pan.x,\n\t\t\t\tstartPanY: currentState.pan.y,\n\t\t\t\tcontainerRect,\n\t\t\t\tstartMidX: midX,\n\t\t\t\tstartMidY: midY,\n\t\t\t\tdidPinch: true,\n\t\t\t\tmoved: false,\n\t\t\t};\n\t\t\tthis.options.onGestureStart?.();\n\t\t}\n\n\t\tconst onTouchEnd = () => {\n\t\t\tthis.touch = null;\n\t\t\tthis.touchCleanup = null;\n\t\t\tcancelAnimationFrame( this.rafId );\n\t\t\tdoc.removeEventListener( 'touchmove', this.handleTouchMove );\n\t\t\tdoc.removeEventListener( 'touchend', onTouchEnd );\n\t\t\tdoc.removeEventListener( 'touchcancel', onTouchEnd );\n\t\t\tthis.setStatus( { isDragging: false } );\n\t\t\tthis.options.onGestureEnd?.();\n\t\t};\n\n\t\t// Clean up any previous touch listeners before registering new ones.\n\t\tthis.touchCleanup?.();\n\n\t\tdoc.addEventListener( 'touchmove', this.handleTouchMove, {\n\t\t\tpassive: false,\n\t\t} );\n\t\tdoc.addEventListener( 'touchend', onTouchEnd );\n\t\tdoc.addEventListener( 'touchcancel', onTouchEnd );\n\n\t\tthis.touchCleanup = onTouchEnd;\n\t}\n\n\t// Handle a touchmove event during an active touch gesture. Decides pinch\n\t// vs. pan based on current `moveEvent.touches.length`, so the gesture\n\t// can transition between modes without timing sensitivity (e.g. fingers\n\t// landing 0ms vs 200ms apart). Arrow-property binding so `this` stays\n\t// attached when used as an event listener.\n\tprivate handleTouchMove = ( moveEvent: TouchEvent ): void => {\n\t\tconst touch = this.touch;\n\t\tif ( ! touch ) {\n\t\t\treturn;\n\t\t}\n\n\t\tcancelAnimationFrame( this.rafId );\n\t\tthis.rafId = requestAnimationFrame( () => {\n\t\t\tconst s = this.options.getState();\n\n\t\t\tif ( moveEvent.touches.length === 2 ) {\n\t\t\t\t// Two fingers \u2192 always pinch, regardless of how gesture\n\t\t\t\t// started. Initialize pinch state on first 2-finger move.\n\t\t\t\tif ( ! touch.didPinch ) {\n\t\t\t\t\ttouch.didPinch = true;\n\t\t\t\t\ttouch.startDistance = getTouchDistance(\n\t\t\t\t\t\tmoveEvent.touches[ 0 ],\n\t\t\t\t\t\tmoveEvent.touches[ 1 ]\n\t\t\t\t\t);\n\t\t\t\t\ttouch.startZoom = s.zoom;\n\t\t\t\t\ttouch.startPanX = s.pan.x;\n\t\t\t\t\ttouch.startPanY = s.pan.y;\n\t\t\t\t\ttouch.startMidX =\n\t\t\t\t\t\t( moveEvent.touches[ 0 ].clientX +\n\t\t\t\t\t\t\tmoveEvent.touches[ 1 ].clientX ) /\n\t\t\t\t\t\t2;\n\t\t\t\t\ttouch.startMidY =\n\t\t\t\t\t\t( moveEvent.touches[ 0 ].clientY +\n\t\t\t\t\t\t\tmoveEvent.touches[ 1 ].clientY ) /\n\t\t\t\t\t\t2;\n\t\t\t\t\tthis.setStatus( { isDragging: false } );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst latestContainerSize = this.options.getContainerSize();\n\t\t\t\tconst latestImageSize = this.options.getImageSize();\n\n\t\t\t\t// Pinch zoom with focal point at finger midpoint,\n\t\t\t\t// plus simultaneous pan from midpoint drift.\n\t\t\t\tconst t0 = moveEvent.touches[ 0 ];\n\t\t\t\tconst t1 = moveEvent.touches[ 1 ];\n\t\t\t\tconst currentDistance = getTouchDistance( t0, t1 );\n\t\t\t\tconst ratio = currentDistance / touch.startDistance;\n\t\t\t\tconst newZoom = Math.min(\n\t\t\t\t\tthis.maxZoom,\n\t\t\t\t\tMath.max( this.minZoom, touch.startZoom * ratio )\n\t\t\t\t);\n\n\t\t\t\tconst visSize = latestImageSize ?? latestContainerSize;\n\t\t\t\tconst rect = touch.containerRect;\n\t\t\t\tif ( visSize.width > 0 && visSize.height > 0 && rect ) {\n\t\t\t\t\t// Current midpoint.\n\t\t\t\t\tconst mx =\n\t\t\t\t\t\t( t0.clientX + t1.clientX ) / 2 -\n\t\t\t\t\t\trect.left -\n\t\t\t\t\t\tlatestContainerSize.width / 2;\n\t\t\t\t\tconst my =\n\t\t\t\t\t\t( t0.clientY + t1.clientY ) / 2 -\n\t\t\t\t\t\trect.top -\n\t\t\t\t\t\tlatestContainerSize.height / 2;\n\n\t\t\t\t\t// Pan from midpoint drift (fingers moving together).\n\t\t\t\t\tconst startMx =\n\t\t\t\t\t\ttouch.startMidX -\n\t\t\t\t\t\trect.left -\n\t\t\t\t\t\tlatestContainerSize.width / 2;\n\t\t\t\t\tconst startMy =\n\t\t\t\t\t\ttouch.startMidY -\n\t\t\t\t\t\trect.top -\n\t\t\t\t\t\tlatestContainerSize.height / 2;\n\t\t\t\t\tconst panDx =\n\t\t\t\t\t\tvisSize.width > 0\n\t\t\t\t\t\t\t? ( mx - startMx ) / visSize.width\n\t\t\t\t\t\t\t: 0;\n\t\t\t\t\tconst panDy =\n\t\t\t\t\t\tvisSize.height > 0\n\t\t\t\t\t\t\t? ( my - startMy ) / visSize.height\n\t\t\t\t\t\t\t: 0;\n\n\t\t\t\t\t// Focal-point zoom correction.\n\t\t\t\t\tconst zoomRatio = s.zoom !== 0 ? 1 - newZoom / s.zoom : 0;\n\t\t\t\t\tconst focalNormX = mx / visSize.width;\n\t\t\t\t\tconst focalNormY = my / visSize.height;\n\t\t\t\t\tconst zoomCropX =\n\t\t\t\t\t\ts.pan.x + ( focalNormX - s.pan.x ) * zoomRatio;\n\t\t\t\t\tconst zoomCropY =\n\t\t\t\t\t\ts.pan.y + ( focalNormY - s.pan.y ) * zoomRatio;\n\n\t\t\t\t\t// Combined: pan drift + zoom correction.\n\t\t\t\t\tconst newCropX =\n\t\t\t\t\t\ttouch.startPanX + panDx + ( zoomCropX - s.pan.x );\n\t\t\t\t\tconst newCropY =\n\t\t\t\t\t\ttouch.startPanY + panDy + ( zoomCropY - s.pan.y );\n\n\t\t\t\t\tconst { pan: clampedCrop } = restrictPanZoom(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t...s,\n\t\t\t\t\t\t\tzoom: newZoom,\n\t\t\t\t\t\t\tpan: { x: newCropX, y: newCropY },\n\t\t\t\t\t\t},\n\t\t\t\t\t\tgetImageSizeFromState( s ),\n\t\t\t\t\t\ts.cropRect\n\t\t\t\t\t);\n\t\t\t\t\tthis.options.actions.setZoomAtPoint( newZoom, clampedCrop );\n\t\t\t\t} else if ( newZoom !== s.zoom ) {\n\t\t\t\t\tthis.options.actions.setZoom( newZoom );\n\t\t\t\t}\n\t\t\t} else if ( moveEvent.touches.length === 1 && ! touch.didPinch ) {\n\t\t\t\t// One finger and no pinch ever detected \u2192 pan.\n\t\t\t\t// If fingers went 2\u21921 (didPinch is true), we do NOT\n\t\t\t\t// switch to pan \u2014 avoids accidental pan after releasing\n\t\t\t\t// one finger from a pinch.\n\t\t\t\tif ( ! touch.moved ) {\n\t\t\t\t\ttouch.moved = true;\n\t\t\t\t\tthis.setStatus( { isDragging: true } );\n\t\t\t\t}\n\t\t\t\tconst panImageSize = this.options.getImageSize();\n\t\t\t\tconst panContainerSize = this.options.getContainerSize();\n\t\t\t\tconst panSize = panImageSize ?? panContainerSize;\n\t\t\t\tconst deltaX =\n\t\t\t\t\tpanSize.width > 0\n\t\t\t\t\t\t? ( moveEvent.touches[ 0 ].clientX -\n\t\t\t\t\t\t\t\ttouch.lastTouchX ) /\n\t\t\t\t\t\t panSize.width\n\t\t\t\t\t\t: 0;\n\t\t\t\tconst deltaY =\n\t\t\t\t\tpanSize.height > 0\n\t\t\t\t\t\t? ( moveEvent.touches[ 0 ].clientY -\n\t\t\t\t\t\t\t\ttouch.lastTouchY ) /\n\t\t\t\t\t\t panSize.height\n\t\t\t\t\t\t: 0;\n\n\t\t\t\tconst { pan: newCrop } = restrictPanZoom(\n\t\t\t\t\t{\n\t\t\t\t\t\t...s,\n\t\t\t\t\t\tpan: {\n\t\t\t\t\t\t\tx: touch.startPanX + deltaX,\n\t\t\t\t\t\t\ty: touch.startPanY + deltaY,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tgetImageSizeFromState( s ),\n\t\t\t\t\ts.cropRect\n\t\t\t\t);\n\n\t\t\t\tthis.options.actions.setPan( newCrop );\n\t\t\t}\n\t\t} );\n\t};\n\n\t// Handle double-tap-to-toggle-zoom. On a second tap within the configured\n\t// time/distance threshold, toggles zoom between `minZoom` and\n\t// `doubleTapZoom` around the tap point and dispatches. Returns `true` if\n\t// the tap was handled as a double-tap (caller should early-return),\n\t// `false` otherwise (caller proceeds with normal single-tap handling).\n\t// Either way, records the tap for next time.\n\tprivate tryDoubleTap(\n\t\te: TouchEvent,\n\t\ttapX: number,\n\t\ttapY: number,\n\t\tcontainerRect: DOMRect\n\t): boolean {\n\t\tconst now = Date.now();\n\t\tconst lastTap = this.lastTap;\n\t\tif ( ! lastTap ) {\n\t\t\tthis.lastTap = { time: now, x: tapX, y: tapY };\n\t\t\treturn false;\n\t\t}\n\t\tconst timeDelta = now - lastTap.time;\n\t\tconst distDelta = Math.sqrt(\n\t\t\t( tapX - lastTap.x ) ** 2 + ( tapY - lastTap.y ) ** 2\n\t\t);\n\t\tconst isDoubleTap =\n\t\t\ttimeDelta < DOUBLE_TAP_TIME && distDelta < DOUBLE_TAP_DISTANCE;\n\t\tif ( ! isDoubleTap ) {\n\t\t\tthis.lastTap = { time: now, x: tapX, y: tapY };\n\t\t\treturn false;\n\t\t}\n\n\t\t// It's a double-tap \u2014 suppress browser zoom.\n\t\te.preventDefault();\n\t\tthis.lastTap = null;\n\n\t\tconst currentState = this.options.getState();\n\t\tconst containerSize = this.options.getContainerSize();\n\t\tconst imgSize = this.options.getImageSize();\n\n\t\t// Toggle: if past halfway to doubleTapZoom, go back to 1x.\n\t\tconst targetZoom =\n\t\t\tcurrentState.zoom > ( this.minZoom + this.doubleTapZoom ) / 2\n\t\t\t\t? this.minZoom\n\t\t\t\t: this.doubleTapZoom;\n\t\tconst visSize = imgSize ?? containerSize;\n\n\t\t// Enable zoom animation before dispatching.\n\t\tthis.setStatus( { isZooming: true } );\n\t\tclearTimeout( this.zoomTimer );\n\t\tthis.zoomTimer = setTimeout( () => {\n\t\t\tthis.setStatus( { isZooming: false } );\n\t\t}, ZOOM_ANIMATION_DURATION );\n\n\t\tif ( visSize.width > 0 && visSize.height > 0 ) {\n\t\t\tconst fx = tapX - containerRect.left - containerSize.width / 2;\n\t\t\tconst fy = tapY - containerRect.top - containerSize.height / 2;\n\n\t\t\tconst zoomRatio = 1 - targetZoom / currentState.zoom;\n\t\t\tconst focalNormX = fx / visSize.width;\n\t\t\tconst focalNormY = fy / visSize.height;\n\t\t\tconst newCropX =\n\t\t\t\tcurrentState.pan.x +\n\t\t\t\t( focalNormX - currentState.pan.x ) * zoomRatio;\n\t\t\tconst newCropY =\n\t\t\t\tcurrentState.pan.y +\n\t\t\t\t( focalNormY - currentState.pan.y ) * zoomRatio;\n\n\t\t\tconst { pan: clampedCrop } = restrictPanZoom(\n\t\t\t\t{\n\t\t\t\t\t...currentState,\n\t\t\t\t\tzoom: targetZoom,\n\t\t\t\t\tpan: { x: newCropX, y: newCropY },\n\t\t\t\t},\n\t\t\t\tgetImageSizeFromState( currentState ),\n\t\t\t\tcurrentState.cropRect\n\t\t\t);\n\t\t\tthis.options.actions.setZoomAtPoint( targetZoom, clampedCrop );\n\t\t} else {\n\t\t\tthis.options.actions.setZoom( targetZoom );\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t * Handle a keydown event on the container element.\n\t *\n\t * Supports arrow keys for panning, +/- for zoom, and r/R for rotation.\n\t *\n\t * @param e The native KeyboardEvent.\n\t */\n\thandleKeyDown( e: KeyboardEvent ): void {\n\t\tconst currentState = this.options.getState();\n\n\t\tswitch ( e.key ) {\n\t\t\tcase 'ArrowUp': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst { pan: newCrop } = restrictPanZoom(\n\t\t\t\t\t{\n\t\t\t\t\t\t...currentState,\n\t\t\t\t\t\tpan: {\n\t\t\t\t\t\t\tx: currentState.pan.x,\n\t\t\t\t\t\t\ty: currentState.pan.y + this.keyboardStep,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tgetImageSizeFromState( currentState ),\n\t\t\t\t\tcurrentState.cropRect\n\t\t\t\t);\n\t\t\t\tthis.options.actions.setPan( newCrop );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'ArrowDown': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst { pan: newCrop } = restrictPanZoom(\n\t\t\t\t\t{\n\t\t\t\t\t\t...currentState,\n\t\t\t\t\t\tpan: {\n\t\t\t\t\t\t\tx: currentState.pan.x,\n\t\t\t\t\t\t\ty: currentState.pan.y - this.keyboardStep,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tgetImageSizeFromState( currentState ),\n\t\t\t\t\tcurrentState.cropRect\n\t\t\t\t);\n\t\t\t\tthis.options.actions.setPan( newCrop );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'ArrowLeft': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst { pan: newCrop } = restrictPanZoom(\n\t\t\t\t\t{\n\t\t\t\t\t\t...currentState,\n\t\t\t\t\t\tpan: {\n\t\t\t\t\t\t\tx: currentState.pan.x + this.keyboardStep,\n\t\t\t\t\t\t\ty: currentState.pan.y,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tgetImageSizeFromState( currentState ),\n\t\t\t\t\tcurrentState.cropRect\n\t\t\t\t);\n\t\t\t\tthis.options.actions.setPan( newCrop );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'ArrowRight': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst { pan: newCrop } = restrictPanZoom(\n\t\t\t\t\t{\n\t\t\t\t\t\t...currentState,\n\t\t\t\t\t\tpan: {\n\t\t\t\t\t\t\tx: currentState.pan.x - this.keyboardStep,\n\t\t\t\t\t\t\ty: currentState.pan.y,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tgetImageSizeFromState( currentState ),\n\t\t\t\t\tcurrentState.cropRect\n\t\t\t\t);\n\t\t\t\tthis.options.actions.setPan( newCrop );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase '+':\n\t\t\tcase '=': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst newZoom = Math.min(\n\t\t\t\t\tthis.maxZoom,\n\t\t\t\t\tMath.max( this.minZoom, currentState.zoom + 0.5 )\n\t\t\t\t);\n\t\t\t\tthis.options.actions.setZoom( newZoom );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase '-':\n\t\t\tcase '_': {\n\t\t\t\te.preventDefault();\n\t\t\t\tconst newZoom = Math.min(\n\t\t\t\t\tthis.maxZoom,\n\t\t\t\t\tMath.max( this.minZoom, currentState.zoom - 0.5 )\n\t\t\t\t);\n\t\t\t\tthis.options.actions.setZoom( newZoom );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'r':\n\t\t\tcase 'R': {\n\t\t\t\tif ( e.metaKey || e.ctrlKey || e.altKey || e.shiftKey ) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\te.preventDefault();\n\t\t\t\tthis.options.actions.snapRotate90( 1 );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Clean up all timers, animation frames, and active touch listeners.\n\t *\n\t * Must be called when the controller is no longer needed (e.g., on\n\t * component unmount or element removal).\n\t */\n\tdestroy(): void {\n\t\tcancelAnimationFrame( this.rafId );\n\t\tclearTimeout( this.zoomTimer );\n\t\tclearTimeout( this.wheelGestureTimer );\n\t\tthis.touchCleanup?.();\n\t\tthis.touchCleanup = null;\n\t\tthis.pointerCleanup?.();\n\t\tthis.pointerCleanup = null;\n\t\tthis.drag = null;\n\t\tthis.touch = null;\n\t\tthis.lastTap = null;\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MACA,KAAK;AAAA,MACL,KAAK,KAAK;AACT,UAAE,eAAe;AACjB,cAAM,UAAU,KAAK;AAAA,UACpB,KAAK;AAAA,UACL,KAAK,IAAK,KAAK,SAAS,aAAa,OAAO,GAAI;AAAA,QACjD;AACA,aAAK,QAAQ,QAAQ,QAAS,OAAQ;AACtC;AAAA,MACD;AAAA,MACA,KAAK;AAAA,MACL,KAAK,KAAK;AACT,YAAK,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,UAAW;AACvD;AAAA,QACD;AACA,UAAE,eAAe;AACjB,aAAK,QAAQ,QAAQ,aAAc,CAAE;AACrC;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,UAAgB;AACf,yBAAsB,KAAK,KAAM;AACjC,iBAAc,KAAK,SAAU;AAC7B,iBAAc,KAAK,iBAAkB;AACrC,SAAK,eAAe;AACpB,SAAK,eAAe;AACpB,SAAK,iBAAiB;AACtB,SAAK,iBAAiB;AACtB,SAAK,OAAO;AACZ,SAAK,QAAQ;AACb,SAAK,UAAU;AAAA,EAChB;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// packages/media-editor/src/image-editor/core/math/rotation.ts
|
|
21
|
+
var rotation_exports = {};
|
|
22
|
+
__export(rotation_exports, {
|
|
23
|
+
degreesToRadians: () => degreesToRadians,
|
|
24
|
+
normalizeRotation: () => normalizeRotation
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(rotation_exports);
|
|
27
|
+
function normalizeRotation(degrees) {
|
|
28
|
+
if (degrees >= 0) {
|
|
29
|
+
return degrees % 360;
|
|
30
|
+
}
|
|
31
|
+
return (360 + degrees % 360) % 360;
|
|
32
|
+
}
|
|
33
|
+
function degreesToRadians(degrees) {
|
|
34
|
+
return degrees * Math.PI / 180;
|
|
35
|
+
}
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
degreesToRadians,
|
|
39
|
+
normalizeRotation
|
|
40
|
+
});
|
|
41
|
+
//# sourceMappingURL=rotation.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/image-editor/core/math/rotation.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Normalizes a rotation value to the range [0, 360).\n *\n * Negative rotations are converted to their positive clockwise equivalent.\n * For example, -90 becomes 270, -45 becomes 315, and 450 becomes 90.\n *\n * @param degrees The rotation value in degrees.\n * @return The normalized rotation in the range [0, 360).\n */\nexport function normalizeRotation( degrees: number ): number {\n\tif ( degrees >= 0 ) {\n\t\treturn degrees % 360;\n\t}\n\t// For negative rotations, convert to positive clockwise equivalent.\n\treturn ( 360 + ( degrees % 360 ) ) % 360;\n}\n\n/**\n * Converts an angle from degrees to radians.\n *\n * @param degrees The angle in degrees.\n * @return The angle in radians.\n */\nexport function degreesToRadians( degrees: number ): number {\n\treturn ( degrees * Math.PI ) / 180;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASO,SAAS,kBAAmB,SAA0B;AAC5D,MAAK,WAAW,GAAI;AACnB,WAAO,UAAU;AAAA,EAClB;AAEA,UAAS,MAAQ,UAAU,OAAU;AACtC;AAQO,SAAS,iBAAkB,SAA0B;AAC3D,SAAS,UAAU,KAAK,KAAO;AAChC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// packages/media-editor/src/image-editor/core/source-region.ts
|
|
21
|
+
var source_region_exports = {};
|
|
22
|
+
__export(source_region_exports, {
|
|
23
|
+
getSourceRegion: () => getSourceRegion,
|
|
24
|
+
getSourceRegionPercent: () => getSourceRegionPercent
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(source_region_exports);
|
|
27
|
+
var import_gl_matrix = require("gl-matrix");
|
|
28
|
+
var import_camera = require("./camera.cjs");
|
|
29
|
+
function getSourceRegion(state, imageSize) {
|
|
30
|
+
if (imageSize.width === 0 || imageSize.height === 0) {
|
|
31
|
+
return {
|
|
32
|
+
x: 0,
|
|
33
|
+
y: 0,
|
|
34
|
+
width: 0,
|
|
35
|
+
height: 0,
|
|
36
|
+
rotation: state.rotation,
|
|
37
|
+
flip: { ...state.flip },
|
|
38
|
+
zoom: state.zoom
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
const syntheticContainer = { width: 1e3, height: 1e3 };
|
|
42
|
+
const camera = (0, import_camera.createCamera)(state, syntheticContainer, imageSize);
|
|
43
|
+
const inv = import_gl_matrix.mat2d.create();
|
|
44
|
+
import_gl_matrix.mat2d.invert(inv, camera);
|
|
45
|
+
const baseCamera = (0, import_camera.createCamera)(
|
|
46
|
+
{ ...state, pan: { x: 0, y: 0 }, zoom: 1 },
|
|
47
|
+
syntheticContainer,
|
|
48
|
+
imageSize
|
|
49
|
+
);
|
|
50
|
+
const visibleBounds = (0, import_camera.getVisibleBounds)(baseCamera);
|
|
51
|
+
const cropRect = state.cropRect;
|
|
52
|
+
const cropCenterScreenX = visibleBounds.left + (cropRect.x + cropRect.width / 2) * visibleBounds.width;
|
|
53
|
+
const cropCenterScreenY = visibleBounds.top + (cropRect.y + cropRect.height / 2) * visibleBounds.height;
|
|
54
|
+
const srcCenter = import_gl_matrix.vec2.create();
|
|
55
|
+
import_gl_matrix.vec2.transformMat2d(
|
|
56
|
+
srcCenter,
|
|
57
|
+
[cropCenterScreenX, cropCenterScreenY],
|
|
58
|
+
inv
|
|
59
|
+
);
|
|
60
|
+
const snapRotation = Math.round(state.rotation / 90) * 90;
|
|
61
|
+
const { width: rotW, height: rotH } = (0, import_camera.getRotatedBBox)(
|
|
62
|
+
imageSize.width,
|
|
63
|
+
imageSize.height,
|
|
64
|
+
snapRotation
|
|
65
|
+
);
|
|
66
|
+
const sourceW = cropRect.width * rotW / state.zoom;
|
|
67
|
+
const sourceH = cropRect.height * rotH / state.zoom;
|
|
68
|
+
return {
|
|
69
|
+
x: srcCenter[0] * imageSize.width - sourceW / 2,
|
|
70
|
+
y: srcCenter[1] * imageSize.height - sourceH / 2,
|
|
71
|
+
width: sourceW,
|
|
72
|
+
height: sourceH,
|
|
73
|
+
rotation: state.rotation,
|
|
74
|
+
flip: { ...state.flip },
|
|
75
|
+
zoom: state.zoom
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function getSourceRegionPercent(state, imageSize) {
|
|
79
|
+
if (imageSize.width === 0 || imageSize.height === 0) {
|
|
80
|
+
return { x: 0, y: 0, width: 0, height: 0 };
|
|
81
|
+
}
|
|
82
|
+
const region = getSourceRegion(state, imageSize);
|
|
83
|
+
return {
|
|
84
|
+
x: region.x / imageSize.width * 100,
|
|
85
|
+
y: region.y / imageSize.height * 100,
|
|
86
|
+
width: region.width / imageSize.width * 100,
|
|
87
|
+
height: region.height / imageSize.height * 100
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
91
|
+
0 && (module.exports = {
|
|
92
|
+
getSourceRegion,
|
|
93
|
+
getSourceRegionPercent
|
|
94
|
+
});
|
|
95
|
+
//# sourceMappingURL=source-region.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/image-editor/core/source-region.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport { mat2d, vec2 } from 'gl-matrix';\n\n/**\n * Internal dependencies\n */\nimport type { CropperState, Size } from './types';\nimport { createCamera, getRotatedBBox, getVisibleBounds } from './camera';\n\n/**\n * The selected image region in source-pixel coordinates.\n */\nexport interface SourceRegion {\n\t/** X offset in source pixels. */\n\tx: number;\n\t/** Y offset in source pixels. */\n\ty: number;\n\t/** Width in source pixels. */\n\twidth: number;\n\t/** Height in source pixels. */\n\theight: number;\n\t/** Rotation in degrees (0-360). */\n\trotation: number;\n\t/** Flip state. */\n\tflip: { horizontal: boolean; vertical: boolean };\n\t/** Zoom factor applied. */\n\tzoom: number;\n}\n\n/**\n * Get the selected image region in source-pixel coordinates.\n *\n * Converts the current crop state (normalized visual space) to the actual\n * region of the original image that's selected. This is the bridge between\n * the cropper's internal coordinate system and external tools (image\n * processing libraries, AI APIs, server-side processing) that work in\n * source-pixel coordinates.\n *\n * The returned rectangle accounts for pan, zoom, and the crop rect position,\n * but expresses the crop in the unrotated image's coordinate space. Rotation\n * and flip are included as separate fields since they represent transforms,\n * not a region.\n *\n * @param state The current cropper state.\n * @param imageSize The natural dimensions of the source image.\n * @return The selected region in source pixels plus rotation/flip metadata.\n */\nexport function getSourceRegion(\n\tstate: CropperState,\n\timageSize: Size\n): SourceRegion {\n\tif ( imageSize.width === 0 || imageSize.height === 0 ) {\n\t\treturn {\n\t\t\tx: 0,\n\t\t\ty: 0,\n\t\t\twidth: 0,\n\t\t\theight: 0,\n\t\t\trotation: state.rotation,\n\t\t\tflip: { ...state.flip },\n\t\t\tzoom: state.zoom,\n\t\t};\n\t}\n\n\t// Use a synthetic 1:1 container so the camera maps normalized coords\n\t// to a known pixel space. The container size cancels out.\n\tconst syntheticContainer: Size = { width: 1000, height: 1000 };\n\tconst camera = createCamera( state, syntheticContainer, imageSize );\n\n\t// Inverse camera maps screen pixels back to normalized [0,1] world coords.\n\tconst inv = mat2d.create();\n\tmat2d.invert( inv, camera );\n\n\t// The crop rect center in screen space. We need the base camera\n\t// (zoom=1, no pan) to locate the visual bounds, then place the\n\t// crop rect within them.\n\tconst baseCamera = createCamera(\n\t\t{ ...state, pan: { x: 0, y: 0 }, zoom: 1 },\n\t\tsyntheticContainer,\n\t\timageSize\n\t);\n\tconst visibleBounds = getVisibleBounds( baseCamera );\n\n\tconst cropRect = state.cropRect;\n\tconst cropCenterScreenX =\n\t\tvisibleBounds.left +\n\t\t( cropRect.x + cropRect.width / 2 ) * visibleBounds.width;\n\tconst cropCenterScreenY =\n\t\tvisibleBounds.top +\n\t\t( cropRect.y + cropRect.height / 2 ) * visibleBounds.height;\n\n\t// Transform crop center through inverse camera to get source position.\n\tconst srcCenter = vec2.create();\n\tvec2.transformMat2d(\n\t\tsrcCenter,\n\t\t[ cropCenterScreenX, cropCenterScreenY ],\n\t\tinv\n\t);\n\n\t// Crop rect size in the snap-rotation visual space, divided by zoom\n\t// for source-pixel dimensions. Matches the stencil's reference frame.\n\tconst snapRotation = Math.round( state.rotation / 90 ) * 90;\n\tconst { width: rotW, height: rotH } = getRotatedBBox(\n\t\timageSize.width,\n\t\timageSize.height,\n\t\tsnapRotation\n\t);\n\tconst sourceW = ( cropRect.width * rotW ) / state.zoom;\n\tconst sourceH = ( cropRect.height * rotH ) / state.zoom;\n\n\treturn {\n\t\tx: srcCenter[ 0 ] * imageSize.width - sourceW / 2,\n\t\ty: srcCenter[ 1 ] * imageSize.height - sourceH / 2,\n\t\twidth: sourceW,\n\t\theight: sourceH,\n\t\trotation: state.rotation,\n\t\tflip: { ...state.flip },\n\t\tzoom: state.zoom,\n\t};\n}\n\n/**\n * The selected crop region expressed as percentages of the source image.\n */\nexport interface SourceRegionPercent {\n\t/** X offset as a percentage (0\u2013100) of the source image width. */\n\tx: number;\n\t/** Y offset as a percentage (0\u2013100) of the source image height. */\n\ty: number;\n\t/** Width as a percentage (0\u2013100) of the source image width. */\n\twidth: number;\n\t/** Height as a percentage (0\u2013100) of the source image height. */\n\theight: number;\n}\n\n/**\n * Get the selected image region as percentages of the source image dimensions.\n *\n * Returns `{ x, y, width, height }` where each value is a percentage (0\u2013100)\n * of the source image's natural width or height. This format is compatible\n * with the WordPress REST API attachments `/edit` endpoint and CSS-based\n * crop workflows.\n *\n * Internally delegates to `getSourceRegion` and divides by the image\n * dimensions, so accuracy is identical.\n *\n * @param state The current cropper state.\n * @param imageSize The natural dimensions of the source image.\n * @return The crop region as percentages (0\u2013100).\n */\nexport function getSourceRegionPercent(\n\tstate: CropperState,\n\timageSize: Size\n): SourceRegionPercent {\n\tif ( imageSize.width === 0 || imageSize.height === 0 ) {\n\t\treturn { x: 0, y: 0, width: 0, height: 0 };\n\t}\n\tconst region = getSourceRegion( state, imageSize );\n\treturn {\n\t\tx: ( region.x / imageSize.width ) * 100,\n\t\ty: ( region.y / imageSize.height ) * 100,\n\t\twidth: ( region.width / imageSize.width ) * 100,\n\t\theight: ( region.height / imageSize.height ) * 100,\n\t};\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uBAA4B;AAM5B,oBAA+D;AAwCxD,SAAS,gBACf,OACA,WACe;AACf,MAAK,UAAU,UAAU,KAAK,UAAU,WAAW,GAAI;AACtD,WAAO;AAAA,MACN,GAAG;AAAA,MACH,GAAG;AAAA,MACH,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,UAAU,MAAM;AAAA,MAChB,MAAM,EAAE,GAAG,MAAM,KAAK;AAAA,MACtB,MAAM,MAAM;AAAA,IACb;AAAA,EACD;AAIA,QAAM,qBAA2B,EAAE,OAAO,KAAM,QAAQ,IAAK;AAC7D,QAAM,aAAS,4BAAc,OAAO,oBAAoB,SAAU;AAGlE,QAAM,MAAM,uBAAM,OAAO;AACzB,yBAAM,OAAQ,KAAK,MAAO;AAK1B,QAAM,iBAAa;AAAA,IAClB,EAAE,GAAG,OAAO,KAAK,EAAE,GAAG,GAAG,GAAG,EAAE,GAAG,MAAM,EAAE;AAAA,IACzC;AAAA,IACA;AAAA,EACD;AACA,QAAM,oBAAgB,gCAAkB,UAAW;AAEnD,QAAM,WAAW,MAAM;AACvB,QAAM,oBACL,cAAc,QACZ,SAAS,IAAI,SAAS,QAAQ,KAAM,cAAc;AACrD,QAAM,oBACL,cAAc,OACZ,SAAS,IAAI,SAAS,SAAS,KAAM,cAAc;AAGtD,QAAM,YAAY,sBAAK,OAAO;AAC9B,wBAAK;AAAA,IACJ;AAAA,IACA,CAAE,mBAAmB,iBAAkB;AAAA,IACvC;AAAA,EACD;AAIA,QAAM,eAAe,KAAK,MAAO,MAAM,WAAW,EAAG,IAAI;AACzD,QAAM,EAAE,OAAO,MAAM,QAAQ,KAAK,QAAI;AAAA,IACrC,UAAU;AAAA,IACV,UAAU;AAAA,IACV;AAAA,EACD;AACA,QAAM,UAAY,SAAS,QAAQ,OAAS,MAAM;AAClD,QAAM,UAAY,SAAS,SAAS,OAAS,MAAM;AAEnD,SAAO;AAAA,IACN,GAAG,UAAW,CAAE,IAAI,UAAU,QAAQ,UAAU;AAAA,IAChD,GAAG,UAAW,CAAE,IAAI,UAAU,SAAS,UAAU;AAAA,IACjD,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,UAAU,MAAM;AAAA,IAChB,MAAM,EAAE,GAAG,MAAM,KAAK;AAAA,IACtB,MAAM,MAAM;AAAA,EACb;AACD;AA+BO,SAAS,uBACf,OACA,WACsB;AACtB,MAAK,UAAU,UAAU,KAAK,UAAU,WAAW,GAAI;AACtD,WAAO,EAAE,GAAG,GAAG,GAAG,GAAG,OAAO,GAAG,QAAQ,EAAE;AAAA,EAC1C;AACA,QAAM,SAAS,gBAAiB,OAAO,SAAU;AACjD,SAAO;AAAA,IACN,GAAK,OAAO,IAAI,UAAU,QAAU;AAAA,IACpC,GAAK,OAAO,IAAI,UAAU,SAAW;AAAA,IACrC,OAAS,OAAO,QAAQ,UAAU,QAAU;AAAA,IAC5C,QAAU,OAAO,SAAS,UAAU,SAAW;AAAA,EAChD;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// packages/media-editor/src/image-editor/core/state.ts
|
|
21
|
+
var state_exports = {};
|
|
22
|
+
__export(state_exports, {
|
|
23
|
+
cropperReducer: () => cropperReducer,
|
|
24
|
+
enforceContainment: () => enforceContainment,
|
|
25
|
+
isStateDirty: () => isStateDirty
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(state_exports);
|
|
28
|
+
var import_constants = require("./constants.cjs");
|
|
29
|
+
var import_rotation = require("./math/rotation.cjs");
|
|
30
|
+
var import_containment = require("./containment.cjs");
|
|
31
|
+
function operationToAction(state, op) {
|
|
32
|
+
switch (op.type) {
|
|
33
|
+
case "crop":
|
|
34
|
+
return { type: "SET_CROP_RECT", payload: { ...op.rect } };
|
|
35
|
+
case "rotate": {
|
|
36
|
+
const singleFlip = state.flip.horizontal !== state.flip.vertical;
|
|
37
|
+
const fieldDelta = singleFlip ? -op.degrees : op.degrees;
|
|
38
|
+
return {
|
|
39
|
+
type: "SET_ROTATION",
|
|
40
|
+
payload: (0, import_rotation.normalizeRotation)(state.rotation + fieldDelta)
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
case "flip":
|
|
44
|
+
return {
|
|
45
|
+
type: "SET_FLIP",
|
|
46
|
+
payload: {
|
|
47
|
+
...state.flip,
|
|
48
|
+
[op.direction]: !state.flip[op.direction]
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
case "zoom":
|
|
52
|
+
return { type: "SET_ZOOM", payload: op.factor };
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function enforceContainment(state) {
|
|
56
|
+
if (!state.image) {
|
|
57
|
+
return state;
|
|
58
|
+
}
|
|
59
|
+
const imageSize = {
|
|
60
|
+
width: state.image.naturalWidth,
|
|
61
|
+
height: state.image.naturalHeight
|
|
62
|
+
};
|
|
63
|
+
const imageAspectRatio = imageSize.width / imageSize.height;
|
|
64
|
+
const { pan: panAfterZoom, zoom } = (0, import_containment.restrictPanZoom)(
|
|
65
|
+
state,
|
|
66
|
+
imageSize,
|
|
67
|
+
state.cropRect
|
|
68
|
+
);
|
|
69
|
+
const cropRect = (0, import_containment.restrictCropRect)(
|
|
70
|
+
state.cropRect,
|
|
71
|
+
zoom,
|
|
72
|
+
state.rotation,
|
|
73
|
+
imageAspectRatio
|
|
74
|
+
);
|
|
75
|
+
let pan = panAfterZoom;
|
|
76
|
+
if (cropRect !== state.cropRect) {
|
|
77
|
+
({ pan } = (0, import_containment.restrictPanZoom)(
|
|
78
|
+
{ ...state, zoom, cropRect },
|
|
79
|
+
imageSize,
|
|
80
|
+
cropRect
|
|
81
|
+
));
|
|
82
|
+
}
|
|
83
|
+
if (pan.x === state.pan.x && pan.y === state.pan.y && zoom === state.zoom && cropRect === state.cropRect) {
|
|
84
|
+
return state;
|
|
85
|
+
}
|
|
86
|
+
return { ...state, pan, zoom, cropRect };
|
|
87
|
+
}
|
|
88
|
+
function commitBase(next) {
|
|
89
|
+
if (next.basePan.x === next.pan.x && next.basePan.y === next.pan.y && next.baseZoom === next.zoom && next.baseRotation === next.rotation) {
|
|
90
|
+
return next;
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
...next,
|
|
94
|
+
basePan: { x: next.pan.x, y: next.pan.y },
|
|
95
|
+
baseZoom: next.zoom,
|
|
96
|
+
baseRotation: next.rotation
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function cropperReducer(state, action) {
|
|
100
|
+
switch (action.type) {
|
|
101
|
+
case "SET_IMAGE":
|
|
102
|
+
return commitBase(
|
|
103
|
+
enforceContainment({
|
|
104
|
+
...state,
|
|
105
|
+
image: action.payload
|
|
106
|
+
})
|
|
107
|
+
);
|
|
108
|
+
case "SET_PAN":
|
|
109
|
+
return commitBase(
|
|
110
|
+
enforceContainment({
|
|
111
|
+
...state,
|
|
112
|
+
pan: action.payload
|
|
113
|
+
})
|
|
114
|
+
);
|
|
115
|
+
case "SET_ZOOM": {
|
|
116
|
+
const z = Math.min(import_constants.MAX_ZOOM, Math.max(1, action.payload));
|
|
117
|
+
return commitBase(
|
|
118
|
+
enforceContainment({
|
|
119
|
+
...state,
|
|
120
|
+
zoom: z
|
|
121
|
+
})
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
case "SET_ZOOM_AT_POINT": {
|
|
125
|
+
const z = Math.min(import_constants.MAX_ZOOM, Math.max(1, action.payload.zoom));
|
|
126
|
+
return commitBase(
|
|
127
|
+
enforceContainment({
|
|
128
|
+
...state,
|
|
129
|
+
zoom: z,
|
|
130
|
+
pan: action.payload.pan
|
|
131
|
+
})
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
case "SET_ROTATION": {
|
|
135
|
+
const newRotation = (0, import_rotation.normalizeRotation)(action.payload);
|
|
136
|
+
const singleFlip = state.flip.horizontal !== state.flip.vertical;
|
|
137
|
+
const deltaRad = (0, import_rotation.degreesToRadians)(
|
|
138
|
+
newRotation - state.baseRotation
|
|
139
|
+
);
|
|
140
|
+
const cos = Math.cos(deltaRad);
|
|
141
|
+
const sin = Math.sin(deltaRad) * (singleFlip ? -1 : 1);
|
|
142
|
+
const cropCx = state.cropRect.x + state.cropRect.width / 2;
|
|
143
|
+
const cropCy = state.cropRect.y + state.cropRect.height / 2;
|
|
144
|
+
const ox = cropCx - 0.5;
|
|
145
|
+
const oy = cropCy - 0.5;
|
|
146
|
+
const dx = state.basePan.x - ox;
|
|
147
|
+
const dy = state.basePan.y - oy;
|
|
148
|
+
return enforceContainment({
|
|
149
|
+
...state,
|
|
150
|
+
rotation: newRotation,
|
|
151
|
+
zoom: state.baseZoom,
|
|
152
|
+
pan: {
|
|
153
|
+
x: ox + cos * dx - sin * dy,
|
|
154
|
+
y: oy + sin * dx + cos * dy
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
case "SNAP_ROTATE_90": {
|
|
159
|
+
const rawDir = action.payload.direction;
|
|
160
|
+
const singleFlip = state.flip.horizontal !== state.flip.vertical;
|
|
161
|
+
const fieldDir = singleFlip ? -rawDir : rawDir;
|
|
162
|
+
const rot90 = (0, import_rotation.normalizeRotation)(state.rotation + fieldDir * 90);
|
|
163
|
+
const rect = state.cropRect;
|
|
164
|
+
const cx = rect.x + rect.width / 2;
|
|
165
|
+
const cy = rect.y + rect.height / 2;
|
|
166
|
+
const newPanX = rawDir === 1 ? -state.pan.y : state.pan.y;
|
|
167
|
+
const newPanY = rawDir === 1 ? state.pan.x : -state.pan.x;
|
|
168
|
+
return commitBase(
|
|
169
|
+
enforceContainment({
|
|
170
|
+
...state,
|
|
171
|
+
rotation: rot90,
|
|
172
|
+
zoom: state.baseZoom,
|
|
173
|
+
pan: { x: newPanX, y: newPanY },
|
|
174
|
+
cropRect: {
|
|
175
|
+
x: cx - rect.height / 2,
|
|
176
|
+
y: cy - rect.width / 2,
|
|
177
|
+
width: rect.height,
|
|
178
|
+
height: rect.width
|
|
179
|
+
}
|
|
180
|
+
})
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
case "SET_FLIP": {
|
|
184
|
+
const oldFlip = state.flip;
|
|
185
|
+
const newFlip = action.payload;
|
|
186
|
+
const flippedH = oldFlip.horizontal !== newFlip.horizontal;
|
|
187
|
+
const flippedV = oldFlip.vertical !== newFlip.vertical;
|
|
188
|
+
const rect = state.cropRect;
|
|
189
|
+
return commitBase(
|
|
190
|
+
enforceContainment({
|
|
191
|
+
...state,
|
|
192
|
+
flip: newFlip,
|
|
193
|
+
pan: {
|
|
194
|
+
x: flippedH ? -state.pan.x : state.pan.x,
|
|
195
|
+
y: flippedV ? -state.pan.y : state.pan.y
|
|
196
|
+
},
|
|
197
|
+
cropRect: {
|
|
198
|
+
x: flippedH ? 1 - rect.x - rect.width : rect.x,
|
|
199
|
+
y: flippedV ? 1 - rect.y - rect.height : rect.y,
|
|
200
|
+
width: rect.width,
|
|
201
|
+
height: rect.height
|
|
202
|
+
}
|
|
203
|
+
})
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
case "SET_CROP_RECT":
|
|
207
|
+
return commitBase(
|
|
208
|
+
enforceContainment({
|
|
209
|
+
...state,
|
|
210
|
+
cropRect: action.payload
|
|
211
|
+
})
|
|
212
|
+
);
|
|
213
|
+
case "SETTLE_CROP": {
|
|
214
|
+
const rect = state.cropRect;
|
|
215
|
+
if (rect.width === 0 || rect.height === 0 || !state.image) {
|
|
216
|
+
return state;
|
|
217
|
+
}
|
|
218
|
+
const normalizedRatio = rect.width / rect.height;
|
|
219
|
+
let newH = 1;
|
|
220
|
+
let newW = normalizedRatio;
|
|
221
|
+
if (newW > 1) {
|
|
222
|
+
newW = 1;
|
|
223
|
+
newH = 1 / normalizedRatio;
|
|
224
|
+
}
|
|
225
|
+
const s = newH / rect.height;
|
|
226
|
+
const oldCx = rect.x + rect.width / 2;
|
|
227
|
+
const oldCy = rect.y + rect.height / 2;
|
|
228
|
+
return commitBase(
|
|
229
|
+
enforceContainment({
|
|
230
|
+
...state,
|
|
231
|
+
zoom: state.zoom * s,
|
|
232
|
+
pan: {
|
|
233
|
+
x: (state.pan.x - oldCx + 0.5) * s,
|
|
234
|
+
y: (state.pan.y - oldCy + 0.5) * s
|
|
235
|
+
},
|
|
236
|
+
cropRect: {
|
|
237
|
+
x: (1 - newW) / 2,
|
|
238
|
+
y: (1 - newH) / 2,
|
|
239
|
+
width: newW,
|
|
240
|
+
height: newH
|
|
241
|
+
}
|
|
242
|
+
})
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
case "APPLY_OPERATION":
|
|
246
|
+
return cropperReducer(
|
|
247
|
+
state,
|
|
248
|
+
operationToAction(state, action.payload)
|
|
249
|
+
);
|
|
250
|
+
case "RESET":
|
|
251
|
+
return commitBase(
|
|
252
|
+
enforceContainment({
|
|
253
|
+
...import_constants.DEFAULT_STATE,
|
|
254
|
+
image: state.image,
|
|
255
|
+
...action.payload
|
|
256
|
+
})
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
function isStateDirty(current, initial) {
|
|
261
|
+
return current.pan.x !== initial.pan.x || current.pan.y !== initial.pan.y || current.zoom !== initial.zoom || current.rotation !== initial.rotation || current.flip.horizontal !== initial.flip.horizontal || current.flip.vertical !== initial.flip.vertical || current.cropRect.x !== initial.cropRect.x || current.cropRect.y !== initial.cropRect.y || current.cropRect.width !== initial.cropRect.width || current.cropRect.height !== initial.cropRect.height;
|
|
262
|
+
}
|
|
263
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
264
|
+
0 && (module.exports = {
|
|
265
|
+
cropperReducer,
|
|
266
|
+
enforceContainment,
|
|
267
|
+
isStateDirty
|
|
268
|
+
});
|
|
269
|
+
//# sourceMappingURL=state.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/image-editor/core/state.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { CropperAction, CropperState, TransformOperation } from './types';\nimport { DEFAULT_STATE, MAX_ZOOM } from './constants';\nimport { normalizeRotation, degreesToRadians } from './math/rotation';\nimport { restrictPanZoom, restrictCropRect } from './containment';\n\n/**\n * Translate a pipeline transform operation into the equivalent\n * reducer action. Pipeline ops aren't 1:1 with reducer actions \u2014\n * `rotate` is a delta here, whereas SET_ROTATION takes an absolute\n * angle \u2014 so deltas are resolved against the current state.\n *\n * Used by APPLY_OPERATION (and by the pipeline module's\n * `applyOperationToState`, which is now a thin wrapper around the\n * reducer) so that pipeline replay produces identical bounded\n * state to UI interaction or direct setters.\n *\n * @param state The current cropper state.\n * @param op The pipeline operation.\n * @return The equivalent reducer action.\n */\nfunction operationToAction(\n\tstate: CropperState,\n\top: TransformOperation\n): CropperAction {\n\tswitch ( op.type ) {\n\t\tcase 'crop':\n\t\t\treturn { type: 'SET_CROP_RECT', payload: { ...op.rect } };\n\t\tcase 'rotate': {\n\t\t\t// `op.degrees` is the visual rotation the caller wants (positive\n\t\t\t// = CW on screen). A single-axis flip inverts on-screen rotation\n\t\t\t// relative to the rotation field, so negate the field delta in\n\t\t\t// that case \u2014 this keeps `{ type: 'rotate', degrees: 90 }` a\n\t\t\t// reliable \"90\u00B0 clockwise visually\" instruction across flip\n\t\t\t// states, matching the SNAP_ROTATE_90 convention.\n\t\t\tconst singleFlip = state.flip.horizontal !== state.flip.vertical;\n\t\t\tconst fieldDelta = singleFlip ? -op.degrees : op.degrees;\n\t\t\treturn {\n\t\t\t\ttype: 'SET_ROTATION',\n\t\t\t\tpayload: normalizeRotation( state.rotation + fieldDelta ),\n\t\t\t};\n\t\t}\n\t\tcase 'flip':\n\t\t\treturn {\n\t\t\t\ttype: 'SET_FLIP',\n\t\t\t\tpayload: {\n\t\t\t\t\t...state.flip,\n\t\t\t\t\t[ op.direction ]: ! state.flip[ op.direction ],\n\t\t\t\t},\n\t\t\t};\n\t\tcase 'zoom':\n\t\t\treturn { type: 'SET_ZOOM', payload: op.factor };\n\t}\n}\n\n/**\n * Enforces containment: restricts the crop rect to fit within the\n * rotated image, computes minimum zoom, clamps zoom, and restricts\n * the pan position so the image always covers the crop area.\n * Called after every relevant state transition.\n *\n * @param state The state to enforce containment on.\n * @return The state with cropRect, zoom, and position restricted.\n */\nexport function enforceContainment( state: CropperState ): CropperState {\n\tif ( ! state.image ) {\n\t\treturn state;\n\t}\n\tconst imageSize = {\n\t\twidth: state.image.naturalWidth,\n\t\theight: state.image.naturalHeight,\n\t};\n\tconst imageAspectRatio = imageSize.width / imageSize.height;\n\n\t// 1. First bump zoom so the image can cover the crop rect as-is.\n\t// This ensures that explicit crop rect changes (e.g., fixed-crop\n\t// mode during rotation) get zoom accommodation, not crop shrinkage.\n\tconst { pan: panAfterZoom, zoom } = restrictPanZoom(\n\t\tstate,\n\t\timageSize,\n\t\tstate.cropRect\n\t);\n\n\t// 2. Now restrict the crop rect at the (possibly bumped) zoom.\n\t// This handles cases where the crop rect is still too large\n\t// (e.g., if zoom hit MAX_ZOOM).\n\tconst cropRect = restrictCropRect(\n\t\tstate.cropRect,\n\t\tzoom,\n\t\tstate.rotation,\n\t\timageAspectRatio\n\t);\n\n\t// 3. If the crop rect was shrunk, re-restrict pan for the new rect.\n\tlet pan = panAfterZoom;\n\tif ( cropRect !== state.cropRect ) {\n\t\t( { pan } = restrictPanZoom(\n\t\t\t{ ...state, zoom, cropRect },\n\t\t\timageSize,\n\t\t\tcropRect\n\t\t) );\n\t}\n\n\tif (\n\t\tpan.x === state.pan.x &&\n\t\tpan.y === state.pan.y &&\n\t\tzoom === state.zoom &&\n\t\tcropRect === state.cropRect\n\t) {\n\t\treturn state;\n\t}\n\treturn { ...state, pan, zoom, cropRect };\n}\n\n/**\n * Snapshot the current `crop`, `zoom`, and `rotation` into the\n * corresponding `basePan`, `baseZoom`, `baseRotation` fields. Called\n * by every committing action so that the next SET_ROTATION derives\n * its transient pan from a fresh base (not from a drifted one).\n *\n * SET_ROTATION is the only action that does NOT commit base \u2014 it\n * reads the base, computes a transient pan, and leaves the base\n * alone. This is what eliminates rotation drift near edges.\n *\n * @param next The post-containment state to commit.\n * @return The state with base fields synced to current.\n */\nfunction commitBase( next: CropperState ): CropperState {\n\tif (\n\t\tnext.basePan.x === next.pan.x &&\n\t\tnext.basePan.y === next.pan.y &&\n\t\tnext.baseZoom === next.zoom &&\n\t\tnext.baseRotation === next.rotation\n\t) {\n\t\treturn next;\n\t}\n\treturn {\n\t\t...next,\n\t\tbasePan: { x: next.pan.x, y: next.pan.y },\n\t\tbaseZoom: next.zoom,\n\t\tbaseRotation: next.rotation,\n\t};\n}\n\n/**\n * Reducer function for cropper state management.\n *\n * Every state transition that could invalidate the containment invariant\n * (crop, zoom, rotation, cropRect, flip) is followed by enforceContainment\n * to ensure the image always covers the crop area.\n *\n * Committing actions (everything except SET_ROTATION) also call\n * `commitBase` to snapshot the post-containment state as the new\n * base pose. SET_ROTATION derives from that base without mutating\n * it, which prevents accumulated-clamp drift during continuous fine\n * rotation.\n *\n * @param state The current cropper state.\n * @param action The action to process.\n * @return The new cropper state.\n */\nexport function cropperReducer(\n\tstate: CropperState,\n\taction: CropperAction\n): CropperState {\n\t// Every action runs through enforceContainment to maintain the invariant:\n\t// the image always fully covers the crop area.\n\tswitch ( action.type ) {\n\t\tcase 'SET_IMAGE':\n\t\t\treturn commitBase(\n\t\t\t\tenforceContainment( {\n\t\t\t\t\t...state,\n\t\t\t\t\timage: action.payload,\n\t\t\t\t} )\n\t\t\t);\n\n\t\tcase 'SET_PAN':\n\t\t\treturn commitBase(\n\t\t\t\tenforceContainment( {\n\t\t\t\t\t...state,\n\t\t\t\t\tpan: action.payload,\n\t\t\t\t} )\n\t\t\t);\n\n\t\tcase 'SET_ZOOM': {\n\t\t\tconst z = Math.min( MAX_ZOOM, Math.max( 1, action.payload ) );\n\t\t\treturn commitBase(\n\t\t\t\tenforceContainment( {\n\t\t\t\t\t...state,\n\t\t\t\t\tzoom: z,\n\t\t\t\t} )\n\t\t\t);\n\t\t}\n\n\t\tcase 'SET_ZOOM_AT_POINT': {\n\t\t\tconst z = Math.min( MAX_ZOOM, Math.max( 1, action.payload.zoom ) );\n\t\t\treturn commitBase(\n\t\t\t\tenforceContainment( {\n\t\t\t\t\t...state,\n\t\t\t\t\tzoom: z,\n\t\t\t\t\tpan: action.payload.pan,\n\t\t\t\t} )\n\t\t\t);\n\t\t}\n\n\t\tcase 'SET_ROTATION': {\n\t\t\t// Rotate the base pan around the crop-rect center by the\n\t\t\t// delta from the base rotation. Deriving each tick from\n\t\t\t// the fixed base \u2014 rather than compounding on the previous\n\t\t\t// tick \u2014 prevents accumulated-clamp drift. Rotating\n\t\t\t// 0\u00B0\u219230\u00B0\u21920\u00B0 now returns to the exact base pan.\n\t\t\t//\n\t\t\t// Zoom starts from baseZoom; enforceContainment may bump it\n\t\t\t// up to cover the rotated crop, but never raises the base.\n\t\t\t//\n\t\t\t// SET_ROTATION is the only action that does NOT call\n\t\t\t// commitBase \u2014 the base pose stays pinned at the user's\n\t\t\t// last committed pan/zoom/rotation.\n\t\t\tconst newRotation = normalizeRotation( action.payload );\n\t\t\t// With viewport-relative flip, pan rotation is conjugated by\n\t\t\t// the flip (S * R * S) \u2014 which reverses direction when exactly\n\t\t\t// one axis is flipped. Negate sin in that case so the crop\n\t\t\t// stays framed on the same image content through rotation.\n\t\t\tconst singleFlip = state.flip.horizontal !== state.flip.vertical;\n\t\t\tconst deltaRad = degreesToRadians(\n\t\t\t\tnewRotation - state.baseRotation\n\t\t\t);\n\t\t\tconst cos = Math.cos( deltaRad );\n\t\t\tconst sin = Math.sin( deltaRad ) * ( singleFlip ? -1 : 1 );\n\t\t\tconst cropCx = state.cropRect.x + state.cropRect.width / 2;\n\t\t\tconst cropCy = state.cropRect.y + state.cropRect.height / 2;\n\t\t\tconst ox = cropCx - 0.5;\n\t\t\tconst oy = cropCy - 0.5;\n\t\t\tconst dx = state.basePan.x - ox;\n\t\t\tconst dy = state.basePan.y - oy;\n\t\t\treturn enforceContainment( {\n\t\t\t\t...state,\n\t\t\t\trotation: newRotation,\n\t\t\t\tzoom: state.baseZoom,\n\t\t\t\tpan: {\n\t\t\t\t\tx: ox + cos * dx - sin * dy,\n\t\t\t\t\ty: oy + sin * dx + cos * dy,\n\t\t\t\t},\n\t\t\t} );\n\t\t}\n\n\t\tcase 'SNAP_ROTATE_90': {\n\t\t\t// 90\u00B0 snap: the crop rect rotates 90\u00B0 around its own center\n\t\t\t// (width/height swap), and the pan rotates 90\u00B0 around the\n\t\t\t// pan-space origin. The combination keeps the same image\n\t\t\t// slice framed \u2014 just viewed through a rotated window.\n\t\t\t//\n\t\t\t// `direction` is the visual rotation the caller wants: +1\n\t\t\t// means \"rotate the image CW on screen\", \u22121 means \"CCW\".\n\t\t\t// With a single-axis flip active, rotation on screen appears\n\t\t\t// reversed relative to the rotation field (S\u00B7R\u00B7S conjugation),\n\t\t\t// so internally we negate the direction applied to the\n\t\t\t// `rotation` field. Pan rotates in the caller's direction \u2014\n\t\t\t// that way the same image content stays framed after the\n\t\t\t// snap regardless of flip state.\n\t\t\tconst rawDir = action.payload.direction;\n\t\t\tconst singleFlip = state.flip.horizontal !== state.flip.vertical;\n\t\t\tconst fieldDir = singleFlip ? -rawDir : rawDir;\n\t\t\tconst rot90 = normalizeRotation( state.rotation + fieldDir * 90 );\n\t\t\tconst rect = state.cropRect;\n\t\t\tconst cx = rect.x + rect.width / 2;\n\t\t\tconst cy = rect.y + rect.height / 2;\n\n\t\t\t// Rotate pan vector 90\u00B0 around origin.\n\t\t\t// CW (rawDir=+1): (px, py) \u2192 (-py, px)\n\t\t\t// CCW (rawDir=-1): (px, py) \u2192 (py, -px)\n\t\t\tconst newPanX = rawDir === 1 ? -state.pan.y : state.pan.y;\n\t\t\tconst newPanY = rawDir === 1 ? state.pan.x : -state.pan.x;\n\n\t\t\treturn commitBase(\n\t\t\t\tenforceContainment( {\n\t\t\t\t\t...state,\n\t\t\t\t\trotation: rot90,\n\t\t\t\t\tzoom: state.baseZoom,\n\t\t\t\t\tpan: { x: newPanX, y: newPanY },\n\t\t\t\t\tcropRect: {\n\t\t\t\t\t\tx: cx - rect.height / 2,\n\t\t\t\t\t\ty: cy - rect.width / 2,\n\t\t\t\t\t\twidth: rect.height,\n\t\t\t\t\t\theight: rect.width,\n\t\t\t\t\t},\n\t\t\t\t} )\n\t\t\t);\n\t\t}\n\n\t\tcase 'SET_FLIP': {\n\t\t\t// Mirror the crop rect and pan so the same image content stays\n\t\t\t// framed after a flip. Flip in the camera matrix is composed\n\t\t\t// outside rotation (viewport-relative), so both `pan` and\n\t\t\t// `cropRect` live in viewport-aligned space: negating the flipped\n\t\t\t// axis on each is enough \u2014 no rotation math needed.\n\t\t\tconst oldFlip = state.flip;\n\t\t\tconst newFlip = action.payload;\n\t\t\tconst flippedH = oldFlip.horizontal !== newFlip.horizontal;\n\t\t\tconst flippedV = oldFlip.vertical !== newFlip.vertical;\n\t\t\tconst rect = state.cropRect;\n\n\t\t\treturn commitBase(\n\t\t\t\tenforceContainment( {\n\t\t\t\t\t...state,\n\t\t\t\t\tflip: newFlip,\n\t\t\t\t\tpan: {\n\t\t\t\t\t\tx: flippedH ? -state.pan.x : state.pan.x,\n\t\t\t\t\t\ty: flippedV ? -state.pan.y : state.pan.y,\n\t\t\t\t\t},\n\t\t\t\t\tcropRect: {\n\t\t\t\t\t\tx: flippedH ? 1 - rect.x - rect.width : rect.x,\n\t\t\t\t\t\ty: flippedV ? 1 - rect.y - rect.height : rect.y,\n\t\t\t\t\t\twidth: rect.width,\n\t\t\t\t\t\theight: rect.height,\n\t\t\t\t\t},\n\t\t\t\t} )\n\t\t\t);\n\t\t}\n\n\t\tcase 'SET_CROP_RECT':\n\t\t\treturn commitBase(\n\t\t\t\tenforceContainment( {\n\t\t\t\t\t...state,\n\t\t\t\t\tcropRect: action.payload,\n\t\t\t\t} )\n\t\t\t);\n\n\t\tcase 'SETTLE_CROP': {\n\t\t\t// After a resize drag ends: expand the crop to fill the\n\t\t\t// available height (maintaining its aspect ratio), center it,\n\t\t\t// and adjust zoom/pan so the exact same image content that\n\t\t\t// was visible inside the old crop is visible in the new one.\n\t\t\tconst rect = state.cropRect;\n\t\t\tif ( rect.width === 0 || rect.height === 0 || ! state.image ) {\n\t\t\t\treturn state;\n\t\t\t}\n\n\t\t\t// New crop: fill height (or width), maintain aspect ratio, center.\n\t\t\tconst normalizedRatio = rect.width / rect.height;\n\t\t\tlet newH = 1;\n\t\t\tlet newW = normalizedRatio;\n\t\t\tif ( newW > 1 ) {\n\t\t\t\tnewW = 1;\n\t\t\t\tnewH = 1 / normalizedRatio;\n\t\t\t}\n\n\t\t\t// Scale factor: how much the crop grew.\n\t\t\tconst s = newH / rect.height;\n\n\t\t\t// The old crop center in normalized visual space.\n\t\t\tconst oldCx = rect.x + rect.width / 2;\n\t\t\tconst oldCy = rect.y + rect.height / 2;\n\n\t\t\t// Zoom scales by s so the same image region fills the\n\t\t\t// larger crop at the same relative size.\n\t\t\t// Pan: the visible content center was at\n\t\t\t// (cropCx - crop.x, cropCy - crop.y)\n\t\t\t// in visual-normalized space. After centering the crop to\n\t\t\t// (0.5, 0.5), the pan must place that same content at\n\t\t\t// the new center. Both pan and zoom scale by s because\n\t\t\t// the CSS translate is independent of zoom.\n\t\t\treturn commitBase(\n\t\t\t\tenforceContainment( {\n\t\t\t\t\t...state,\n\t\t\t\t\tzoom: state.zoom * s,\n\t\t\t\t\tpan: {\n\t\t\t\t\t\tx: ( state.pan.x - oldCx + 0.5 ) * s,\n\t\t\t\t\t\ty: ( state.pan.y - oldCy + 0.5 ) * s,\n\t\t\t\t\t},\n\t\t\t\t\tcropRect: {\n\t\t\t\t\t\tx: ( 1 - newW ) / 2,\n\t\t\t\t\t\ty: ( 1 - newH ) / 2,\n\t\t\t\t\t\twidth: newW,\n\t\t\t\t\t\theight: newH,\n\t\t\t\t\t},\n\t\t\t\t} )\n\t\t\t);\n\t\t}\n\n\t\tcase 'APPLY_OPERATION':\n\t\t\t// Route through the action equivalent so a pipeline replay\n\t\t\t// yields the same bounded state as the matching UI/setter\n\t\t\t// path (containment, baseZoom relaxation, pan rotation\n\t\t\t// around crop center, etc.).\n\t\t\treturn cropperReducer(\n\t\t\t\tstate,\n\t\t\t\toperationToAction( state, action.payload )\n\t\t\t);\n\n\t\tcase 'RESET':\n\t\t\treturn commitBase(\n\t\t\t\tenforceContainment( {\n\t\t\t\t\t...DEFAULT_STATE,\n\t\t\t\t\timage: state.image,\n\t\t\t\t\t...action.payload,\n\t\t\t\t} )\n\t\t\t);\n\t}\n}\n\n/**\n * Shallow comparison of key cropper state fields to determine if\n * the state has been modified from an initial snapshot.\n *\n * @param current The current cropper state.\n * @param initial The initial cropper state snapshot.\n * @return True if any tracked field differs.\n */\nexport function isStateDirty(\n\tcurrent: CropperState,\n\tinitial: CropperState\n): boolean {\n\treturn (\n\t\tcurrent.pan.x !== initial.pan.x ||\n\t\tcurrent.pan.y !== initial.pan.y ||\n\t\tcurrent.zoom !== initial.zoom ||\n\t\tcurrent.rotation !== initial.rotation ||\n\t\tcurrent.flip.horizontal !== initial.flip.horizontal ||\n\t\tcurrent.flip.vertical !== initial.flip.vertical ||\n\t\tcurrent.cropRect.x !== initial.cropRect.x ||\n\t\tcurrent.cropRect.y !== initial.cropRect.y ||\n\t\tcurrent.cropRect.width !== initial.cropRect.width ||\n\t\tcurrent.cropRect.height !== initial.cropRect.height\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,uBAAwC;AACxC,sBAAoD;AACpD,yBAAkD;AAiBlD,SAAS,kBACR,OACA,IACgB;AAChB,UAAS,GAAG,MAAO;AAAA,IAClB,KAAK;AACJ,aAAO,EAAE,MAAM,iBAAiB,SAAS,EAAE,GAAG,GAAG,KAAK,EAAE;AAAA,IACzD,KAAK,UAAU;AAOd,YAAM,aAAa,MAAM,KAAK,eAAe,MAAM,KAAK;AACxD,YAAM,aAAa,aAAa,CAAC,GAAG,UAAU,GAAG;AACjD,aAAO;AAAA,QACN,MAAM;AAAA,QACN,aAAS,mCAAmB,MAAM,WAAW,UAAW;AAAA,MACzD;AAAA,IACD;AAAA,IACA,KAAK;AACJ,aAAO;AAAA,QACN,MAAM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