@wordpress/media-editor 0.3.1-next.v.202602241322.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/build-types/components/media-editor/index.d.ts +42 -0
  2. package/build-types/components/media-editor/index.d.ts.map +1 -0
  3. package/build-types/components/media-editor/use-crop-options.d.ts +35 -0
  4. package/build-types/components/media-editor/use-crop-options.d.ts.map +1 -0
  5. package/build-types/components/media-editor/use-save-media-editor.d.ts +29 -0
  6. package/build-types/components/media-editor/use-save-media-editor.d.ts.map +1 -0
  7. package/build-types/components/media-editor-canvas/index.d.ts +26 -0
  8. package/build-types/components/media-editor-canvas/index.d.ts.map +1 -0
  9. package/build-types/components/media-editor-crop-panel/index.d.ts +31 -0
  10. package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -0
  11. package/build-types/components/media-editor-fine-rotation/index.d.ts +15 -0
  12. package/build-types/components/media-editor-fine-rotation/index.d.ts.map +1 -0
  13. package/build-types/components/media-editor-image-controls/index.d.ts +46 -0
  14. package/build-types/components/media-editor-image-controls/index.d.ts.map +1 -0
  15. package/build-types/components/media-editor-keyboard-shortcuts-modal/index.d.ts +6 -0
  16. package/build-types/components/media-editor-keyboard-shortcuts-modal/index.d.ts.map +1 -0
  17. package/build-types/components/media-editor-modal/build-modifiers.d.ts +83 -0
  18. package/build-types/components/media-editor-modal/build-modifiers.d.ts.map +1 -0
  19. package/build-types/components/media-editor-modal/index.d.ts +20 -0
  20. package/build-types/components/media-editor-modal/index.d.ts.map +1 -0
  21. package/build-types/components/rotation-ruler/index.d.ts +46 -0
  22. package/build-types/components/rotation-ruler/index.d.ts.map +1 -0
  23. package/build-types/components/rotation-ruler/stories/index.story.d.ts +14 -0
  24. package/build-types/components/rotation-ruler/stories/index.story.d.ts.map +1 -0
  25. package/build-types/components/rotation-ruler/use-ruler-drag.d.ts +61 -0
  26. package/build-types/components/rotation-ruler/use-ruler-drag.d.ts.map +1 -0
  27. package/build-types/hooks/use-crop-gesture-handlers.d.ts +41 -0
  28. package/build-types/hooks/use-crop-gesture-handlers.d.ts.map +1 -0
  29. package/build-types/image-editor/core/camera.d.ts +107 -0
  30. package/build-types/image-editor/core/camera.d.ts.map +1 -0
  31. package/build-types/image-editor/core/constants.d.ts +83 -0
  32. package/build-types/image-editor/core/constants.d.ts.map +1 -0
  33. package/build-types/image-editor/core/containment.d.ts +75 -0
  34. package/build-types/image-editor/core/containment.d.ts.map +1 -0
  35. package/build-types/image-editor/core/crop-rect.d.ts +19 -0
  36. package/build-types/image-editor/core/crop-rect.d.ts.map +1 -0
  37. package/build-types/image-editor/core/export/canvas-renderer.d.ts +106 -0
  38. package/build-types/image-editor/core/export/canvas-renderer.d.ts.map +1 -0
  39. package/build-types/image-editor/core/index.d.ts +10 -0
  40. package/build-types/image-editor/core/index.d.ts.map +1 -0
  41. package/build-types/image-editor/core/interaction-controller.d.ts +194 -0
  42. package/build-types/image-editor/core/interaction-controller.d.ts.map +1 -0
  43. package/build-types/image-editor/core/math/rotation.d.ts +18 -0
  44. package/build-types/image-editor/core/math/rotation.d.ts.map +1 -0
  45. package/build-types/image-editor/core/math/sanitize.d.ts +70 -0
  46. package/build-types/image-editor/core/math/sanitize.d.ts.map +1 -0
  47. package/build-types/image-editor/core/setter-helpers.d.ts +24 -0
  48. package/build-types/image-editor/core/setter-helpers.d.ts.map +1 -0
  49. package/build-types/image-editor/core/source-region.d.ts +75 -0
  50. package/build-types/image-editor/core/source-region.d.ts.map +1 -0
  51. package/build-types/image-editor/core/state.d.ts +54 -0
  52. package/build-types/image-editor/core/state.d.ts.map +1 -0
  53. package/build-types/image-editor/core/stencil-math.d.ts +97 -0
  54. package/build-types/image-editor/core/stencil-math.d.ts.map +1 -0
  55. package/build-types/image-editor/core/transform-style.d.ts +23 -0
  56. package/build-types/image-editor/core/transform-style.d.ts.map +1 -0
  57. package/build-types/image-editor/core/transforms/pipeline.d.ts +27 -0
  58. package/build-types/image-editor/core/transforms/pipeline.d.ts.map +1 -0
  59. package/build-types/image-editor/core/types.d.ts +255 -0
  60. package/build-types/image-editor/core/types.d.ts.map +1 -0
  61. package/build-types/image-editor/core/viewport-state.d.ts +7 -0
  62. package/build-types/image-editor/core/viewport-state.d.ts.map +1 -0
  63. package/build-types/image-editor/index.d.ts +16 -0
  64. package/build-types/image-editor/index.d.ts.map +1 -0
  65. package/build-types/image-editor/react/components/cropper-provider.d.ts +41 -0
  66. package/build-types/image-editor/react/components/cropper-provider.d.ts.map +1 -0
  67. package/build-types/image-editor/react/components/cropper.d.ts +62 -0
  68. package/build-types/image-editor/react/components/cropper.d.ts.map +1 -0
  69. package/build-types/image-editor/react/components/index.d.ts +4 -0
  70. package/build-types/image-editor/react/components/index.d.ts.map +1 -0
  71. package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts +36 -0
  72. package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts.map +1 -0
  73. package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts +20 -0
  74. package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts.map +1 -0
  75. package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts +30 -0
  76. package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts.map +1 -0
  77. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts +33 -0
  78. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts.map +1 -0
  79. package/build-types/image-editor/react/components/viewport-provider.d.ts +9 -0
  80. package/build-types/image-editor/react/components/viewport-provider.d.ts.map +1 -0
  81. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts +47 -0
  82. package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts.map +1 -0
  83. package/build-types/image-editor/react/hooks/index.d.ts +5 -0
  84. package/build-types/image-editor/react/hooks/index.d.ts.map +1 -0
  85. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts +16 -0
  86. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts.map +1 -0
  87. package/build-types/image-editor/react/hooks/use-cropper-reducer.d.ts +58 -0
  88. package/build-types/image-editor/react/hooks/use-cropper-reducer.d.ts.map +1 -0
  89. package/build-types/image-editor/react/hooks/use-interaction.d.ts +63 -0
  90. package/build-types/image-editor/react/hooks/use-interaction.d.ts.map +1 -0
  91. package/build-types/image-editor/react/hooks/use-transform-style.d.ts +16 -0
  92. package/build-types/image-editor/react/hooks/use-transform-style.d.ts.map +1 -0
  93. package/build-types/image-editor/react/hooks/use-viewport-state.d.ts +19 -0
  94. package/build-types/image-editor/react/hooks/use-viewport-state.d.ts.map +1 -0
  95. package/build-types/image-editor/react/visually-hidden-style.d.ts +6 -0
  96. package/build-types/image-editor/react/visually-hidden-style.d.ts.map +1 -0
  97. package/build-types/image-editor/stories/rectangle-crop.story.d.ts +16 -0
  98. package/build-types/image-editor/stories/rectangle-crop.story.d.ts.map +1 -0
  99. package/build-types/lock-unlock.d.ts +2 -0
  100. package/build-types/lock-unlock.d.ts.map +1 -0
  101. package/build-types/private-apis.d.ts +2 -0
  102. package/build-types/private-apis.d.ts.map +1 -0
  103. package/build-types/state/composite-reducer.d.ts +39 -0
  104. package/build-types/state/composite-reducer.d.ts.map +1 -0
  105. package/build-types/state/index.d.ts +7 -0
  106. package/build-types/state/index.d.ts.map +1 -0
  107. package/build-types/state/media-editor-state-provider.d.ts +34 -0
  108. package/build-types/state/media-editor-state-provider.d.ts.map +1 -0
  109. package/build-types/state/types.d.ts +96 -0
  110. package/build-types/state/types.d.ts.map +1 -0
  111. package/build-types/state/use-media-editor-state.d.ts +101 -0
  112. package/build-types/state/use-media-editor-state.d.ts.map +1 -0
  113. package/build-types/store/actions.d.ts +29 -0
  114. package/build-types/store/actions.d.ts.map +1 -0
  115. package/build-types/store/constants.d.ts +2 -0
  116. package/build-types/store/constants.d.ts.map +1 -0
  117. package/build-types/store/index.d.ts +4 -0
  118. package/build-types/store/index.d.ts.map +1 -0
  119. package/build-types/store/reducer.d.ts +26 -0
  120. package/build-types/store/reducer.d.ts.map +1 -0
  121. package/build-types/store/selectors.d.ts +9 -0
  122. package/build-types/store/selectors.d.ts.map +1 -0
  123. package/package.json +6 -6
  124. package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import type { CropperState, NormalizedPoint, Size, Camera } from './types';
5
+ /**
6
+ * Compute the axis-aligned bounding box of a rectangle after rotation.
7
+ *
8
+ * @param width The width of the rectangle.
9
+ * @param height The height of the rectangle.
10
+ * @param rotation The rotation angle in degrees.
11
+ * @return The bounding box size after rotation.
12
+ */
13
+ export declare function getRotatedBBox(width: number, height: number, rotation: number): Size;
14
+ /**
15
+ * Compute the fitted (unrotated) image element dimensions and the visual
16
+ * (rotated) bounding box dimensions for a given container, image, and rotation.
17
+ *
18
+ * This is the same "contain" fit logic used by createCamera, extracted so
19
+ * cropper.tsx can size the <img> element and position overlays without
20
+ * duplicating the math.
21
+ *
22
+ * @param containerSize The container dimensions in pixels.
23
+ * @param imageSize The natural image dimensions in pixels.
24
+ * @param rotation The rotation angle in degrees.
25
+ * @return The fitted element size and visual bounding box size.
26
+ */
27
+ export declare function getImageFit(containerSize: Size, imageSize: Size, rotation: number): {
28
+ elementSize: Size;
29
+ visualSize: Size;
30
+ };
31
+ /**
32
+ * Compose a camera matrix from cropper state, container, and image dimensions.
33
+ *
34
+ * The matrix maps normalized world coordinates [0,1] x [0,1] to screen pixels.
35
+ * Input (0,0) = image top-left, (1,1) = image bottom-right.
36
+ *
37
+ * Composition order (left-to-right = outermost first, applied last to point):
38
+ * M = T_containerCenter * T_pan * S_flip * R_rotation * S_zoom * T_center * S_toRenderedPixels
39
+ *
40
+ * Flip is composed outside rotation, so `flip.horizontal` / `flip.vertical`
41
+ * are viewport-relative: the image mirrors across the viewport's vertical /
42
+ * horizontal axis regardless of current rotation.
43
+ *
44
+ * @param state The current cropper state (zoom, rotation, flip, crop).
45
+ * @param containerSize The size of the container in pixels.
46
+ * @param imageSize The natural size of the image in pixels.
47
+ * @return The composed camera matrix.
48
+ */
49
+ export declare function createCamera(state: CropperState, containerSize: Size, imageSize: Size): Camera;
50
+ /**
51
+ * Transform a normalized world point [0,1] to screen pixels.
52
+ *
53
+ * @param camera The camera matrix from createCamera.
54
+ * @param point The normalized world coordinate to transform.
55
+ * @return The screen pixel coordinate.
56
+ */
57
+ export declare function worldToScreen(camera: Camera, point: NormalizedPoint): {
58
+ x: number;
59
+ y: number;
60
+ };
61
+ /**
62
+ * Transform a screen pixel point to normalized world coordinates [0,1].
63
+ *
64
+ * @param camera The camera matrix from createCamera.
65
+ * @param point The screen pixel coordinate to transform.
66
+ * @param point.x The x component of the screen pixel coordinate.
67
+ * @param point.y The y component of the screen pixel coordinate.
68
+ * @return The normalized world coordinate.
69
+ */
70
+ export declare function screenToWorld(camera: Camera, point: {
71
+ x: number;
72
+ y: number;
73
+ }): NormalizedPoint;
74
+ /**
75
+ * The bounding box of a transformed region in screen (pixel) space.
76
+ */
77
+ export interface VisualBounds {
78
+ left: number;
79
+ top: number;
80
+ width: number;
81
+ height: number;
82
+ }
83
+ /**
84
+ * Returns the axis-aligned bounding box of the full image (normalized [0,1]x[0,1])
85
+ * after applying the camera transform.
86
+ *
87
+ * @param camera The camera matrix from createCamera.
88
+ * @return The screen-space bounding box of the full image.
89
+ */
90
+ export declare function getVisibleBounds(camera: Camera): VisualBounds;
91
+ /**
92
+ * Compose a camera matrix for exporting to a canvas.
93
+ *
94
+ * The resulting matrix maps image-pixel coordinates directly to output-canvas
95
+ * coordinates. Apply it with `ctx.setTransform( ...camera )` then
96
+ * `ctx.drawImage( image, 0, 0 )`.
97
+ *
98
+ * The transform chain mirrors the `renderToCanvas` function in canvas-renderer.ts:
99
+ * translate(visualCenter - cropOffset + outCenter) → flip → rotate → zoom → translate(-imgCenter)
100
+ *
101
+ * @param state The current cropper state.
102
+ * @param imageSize The natural size of the source image in pixels.
103
+ * @param outputSize The desired output canvas size in pixels.
104
+ * @return The composed export camera matrix.
105
+ */
106
+ export declare function createExportCamera(state: CropperState, imageSize: Size, outputSize: Size): Camera;
107
+ //# sourceMappingURL=camera.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"camera.d.ts","sourceRoot":"","sources":["../../../src/image-editor/core/camera.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAc3E;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC7B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACd,IAAI,CAqBN;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAC1B,aAAa,EAAE,IAAI,EACnB,SAAS,EAAE,IAAI,EACf,QAAQ,EAAE,MAAM,GACd;IAAE,WAAW,EAAE,IAAI,CAAC;IAAC,UAAU,EAAE,IAAI,CAAA;CAAE,CAqCzC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,YAAY,CAC3B,KAAK,EAAE,YAAY,EACnB,aAAa,EAAE,IAAI,EACnB,SAAS,EAAE,IAAI,GACb,MAAM,CAgFR;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC5B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,eAAe,GACpB;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAI1B;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC5B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAC7B,eAAe,CAKjB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CACf;AAsCD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAE,MAAM,EAAE,MAAM,GAAI,YAAY,CAO/D;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,YAAY,EACnB,SAAS,EAAE,IAAI,EACf,UAAU,EAAE,IAAI,GACd,MAAM,CA2CR"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import type { CropperState } from './types';
5
+ /**
6
+ * Default/resting zoom. A full, unrotated crop needs at least 1x to cover the
7
+ * crop area, but smaller/fine-rotated crops can be valid below 1x — the true
8
+ * floor for those comes from `getMinZoom`.
9
+ */
10
+ export declare const MIN_ZOOM = 1;
11
+ /**
12
+ * Safety floor for coverage-aware zoom. Degenerate crops can have a geometric
13
+ * coverage minimum of 0, but camera and inverse-matrix math need a stable,
14
+ * positive scale.
15
+ */
16
+ export declare const ABSOLUTE_MIN_ZOOM = 0.1;
17
+ export declare const MAX_ZOOM = 10;
18
+ /**
19
+ * Minimum crop rect dimension in source-image pixels, enforced per axis
20
+ * during resize. Prevents accidental sub-pixel crops while staying small
21
+ * enough to allow tight crops (favicons, icons). Adjust here to tune the
22
+ * floor globally.
23
+ */
24
+ export declare const MIN_CROP_PIXELS = 24;
25
+ /**
26
+ * Minimum on-screen crop rect dimension in CSS pixels. The source-pixel
27
+ * floor (`MIN_CROP_PIXELS`) keeps crops from going sub-pixel, but on a large
28
+ * image fit into a small canvas it can render only a few CSS pixels wide —
29
+ * too small to grab the resize handles. This floor keeps the crop operable
30
+ * regardless of display scale; it binds when zoomed out and yields to the
31
+ * source-pixel floor once the image is shown large enough. Sized to one
32
+ * handle touch target (`$handle-touch-target-size` in `cropper.scss`).
33
+ */
34
+ export declare const MIN_CROP_SCREEN_PX = 44;
35
+ /**
36
+ * Wheel zoom sensitivity. A deltaY of 100 changes zoom by 0.25.
37
+ * This could be made configurable as a prop to the Cropper component.
38
+ */
39
+ export declare const DEFAULT_WHEEL_ZOOM_SPEED = 0.0025;
40
+ /** Fine step for keyboard-driven cropper movement, in normalized coordinates. */
41
+ export declare const DEFAULT_KEYBOARD_STEP = 0.01;
42
+ /** Coarse keyboard movement multiplier when Shift is held. */
43
+ export declare const KEYBOARD_SHIFT_STEP_MULTIPLIER = 10;
44
+ /**
45
+ * Maximum free-rotation offset in degrees from the nearest 90° step.
46
+ * The rotation slider allows ±45° around the current cardinal angle.
47
+ */
48
+ export declare const MAX_ROTATION_OFFSET = 45;
49
+ export declare const DEFAULT_STATE: CropperState;
50
+ /**
51
+ * An aspect ratio preset with a human-readable label.
52
+ */
53
+ export interface AspectRatioPreset {
54
+ /** Display label (e.g., "Square (1:1)"). */
55
+ label: string;
56
+ /** The aspect ratio value (width / height). 0 = free / original. */
57
+ value: number;
58
+ }
59
+ /**
60
+ * Default aspect ratio presets. Consumers can use these as-is, override
61
+ * with their own list, or extend with additional presets.
62
+ *
63
+ * @example
64
+ * // Use defaults:
65
+ * <CropControls presets={ DEFAULT_ASPECT_RATIOS } />
66
+ *
67
+ * // Custom presets:
68
+ * const socialPresets = [
69
+ * { label: 'Instagram Post', value: 1 },
70
+ * { label: 'Instagram Story', value: 9 / 16 },
71
+ * { label: 'YouTube Thumbnail', value: 16 / 9 },
72
+ * ];
73
+ *
74
+ * // Extend defaults:
75
+ * const extended = [ ...DEFAULT_ASPECT_RATIOS, { label: 'Cinema (21:9)', value: 21 / 9 } ];
76
+ */
77
+ /**
78
+ * Sentinel value for "Original" aspect ratio — resolved at runtime
79
+ * to the image's natural width / height.
80
+ */
81
+ export declare const ORIGINAL_ASPECT_RATIO = -1;
82
+ export declare const DEFAULT_ASPECT_RATIOS: AspectRatioPreset[];
83
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/image-editor/core/constants.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,KAAK,EAAwB,YAAY,EAAE,MAAM,SAAS,CAAC;AAElE;;;;GAIG;AACH,eAAO,MAAM,QAAQ,IAAI,CAAC;AAC1B;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,eAAO,MAAM,QAAQ,KAAK,CAAC;AAE3B;;;;;GAKG;AACH,eAAO,MAAM,eAAe,KAAK,CAAC;AAElC;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAErC;;;GAGG;AACH,eAAO,MAAM,wBAAwB,SAAS,CAAC;AAE/C,iFAAiF;AACjF,eAAO,MAAM,qBAAqB,OAAO,CAAC;AAE1C,8DAA8D;AAC9D,eAAO,MAAM,8BAA8B,KAAK,CAAC;AAEjD;;;GAGG;AACH,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAmBtC,eAAO,MAAM,aAAa,EAAE,YAU3B,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC,4CAA4C;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,oEAAoE;IACpE,KAAK,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH;;;GAGG;AACH,eAAO,MAAM,qBAAqB,KAAK,CAAC;AAExC,eAAO,MAAM,qBAAqB,EAAE,iBAAiB,EAUpD,CAAC"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import type { CropperState, NormalizedRect, Size } from './types';
5
+ /**
6
+ * Resolves the effective minimum zoom for the current state — the coverage-
7
+ * aware floor when an image is loaded, falling back to `MIN_ZOOM` otherwise.
8
+ * Used by both the cropper's interaction layer and the zoom slider so the
9
+ * floor stays consistent across surfaces.
10
+ *
11
+ * @param state The current cropper state.
12
+ * @return The minimum zoom factor.
13
+ */
14
+ export declare function getMinZoom(state: CropperState): number;
15
+ /**
16
+ * Compute the crop handle bounds in normalized visual space — the
17
+ * axis-aligned bounding box (AABB) of the actual image footprint at the
18
+ * current pan/zoom/rotation.
19
+ *
20
+ * Returns the full image AABB without intersecting with the container
21
+ * viewport. The viewport pan mechanism in the Cropper component allows
22
+ * the canvas to scroll so handles can reach the image edge even when it
23
+ * lies outside the visible canvas area.
24
+ *
25
+ * Unlike a static centerline-based calculation, this accounts for the
26
+ * current pan position — if the user pans right, the left bound tightens
27
+ * because the image's left edge has moved right.
28
+ *
29
+ * @param state The current cropper state (crop, zoom, rotation, flip).
30
+ * @param elementSize The fitted (unrotated) image element dimensions in pixels.
31
+ * @param visualSize The visual (rotated) image bounding box in pixels.
32
+ * @return The min/max x and y that a crop rect edge can reach in normalized space.
33
+ */
34
+ export declare function getImageCropBounds(state: CropperState, elementSize: Size, visualSize: Size): {
35
+ minX: number;
36
+ minY: number;
37
+ maxX: number;
38
+ maxY: number;
39
+ };
40
+ /**
41
+ * Restricts a crop rectangle so that the rotated, zoomed image can fully cover it.
42
+ * If the crop rect is too large for the current zoom and rotation, it is scaled
43
+ * down proportionally and re-centered.
44
+ *
45
+ * Works in pixel-proportional space where the unrotated image is a×1.
46
+ *
47
+ * @param cropRect The crop rectangle in normalized coordinates.
48
+ * @param zoom The current zoom factor.
49
+ * @param rotation The rotation angle in degrees.
50
+ * @param imageAspectRatio The image width / height ratio.
51
+ * @return The restricted crop rectangle.
52
+ */
53
+ export declare function restrictCropRect(cropRect: NormalizedRect, zoom: number, rotation: number, imageAspectRatio: number): NormalizedRect;
54
+ /**
55
+ * Clamps pan and adjusts zoom so that the zoomed, rotated image fully covers
56
+ * the crop rectangle.
57
+ *
58
+ * Uses the camera matrix to project: builds a camera from the candidate state,
59
+ * maps the stencil corners (axis-aligned in the visual bounding box) to world
60
+ * space via the inverse camera, and checks that all world points lie within
61
+ * [0,1]×[0,1]. If any point is outside, computes the minimal pan correction.
62
+ *
63
+ * @param state The current cropper state.
64
+ * @param imageSize The natural size of the image in pixels.
65
+ * @param cropRect The crop rectangle in normalized coordinates.
66
+ * @return The restricted crop pan and zoom values.
67
+ */
68
+ export declare function restrictPanZoom(state: CropperState, imageSize: Size, cropRect: NormalizedRect): {
69
+ pan: {
70
+ x: number;
71
+ y: number;
72
+ };
73
+ zoom: number;
74
+ };
75
+ //# sourceMappingURL=containment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"containment.d.ts","sourceRoot":"","sources":["../../../src/image-editor/core/containment.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAuFlE;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAE,KAAK,EAAE,YAAY,GAAI,MAAM,CAqBxD;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,YAAY,EACnB,WAAW,EAAE,IAAI,EACjB,UAAU,EAAE,IAAI,GACd;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CA0D5D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAC/B,QAAQ,EAAE,cAAc,EACxB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,gBAAgB,EAAE,MAAM,GACtB,cAAc,CAqDhB;AAcD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAC9B,KAAK,EAAE,YAAY,EACnB,SAAS,EAAE,IAAI,EACf,QAAQ,EAAE,cAAc,GACtB;IAAE,GAAG,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAkKjD"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import type { NormalizedRect, Size } from './types';
5
+ /**
6
+ * Largest rect of the given pixel aspect ratio that fits inside the
7
+ * visual bounds, centered in [0,1] × [0,1] normalized space. Returns
8
+ * a full-frame rect (1×1) if `aspectRatio` is unset or non-positive.
9
+ *
10
+ * The returned rect is the same in either freeform or fixed-crop
11
+ * mode — it's the canonical "centered crop for this ratio at this
12
+ * canvas size".
13
+ *
14
+ * @param aspectRatio Desired pixel width/height ratio. `undefined`
15
+ * (or 0/negative) means no lock — returns full frame.
16
+ * @param visualSize Rendered image dimensions in pixels.
17
+ */
18
+ export declare function computeInscribedRect(aspectRatio: number | undefined, visualSize: Size): NormalizedRect;
19
+ //# sourceMappingURL=crop-rect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crop-rect.d.ts","sourceRoot":"","sources":["../../../src/image-editor/core/crop-rect.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAEpD;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CACnC,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,UAAU,EAAE,IAAI,GACd,cAAc,CAuBhB"}
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import type { CropperState } from '../types';
5
+ /**
6
+ * Load an image from a URL with CORS support.
7
+ *
8
+ * @param src - The image URL to load.
9
+ * @return A promise that resolves to the loaded HTMLImageElement.
10
+ */
11
+ export declare function loadImage(src: string): Promise<HTMLImageElement>;
12
+ /**
13
+ * Apply rectangular crop, rotation, and flip transforms to produce a canvas.
14
+ *
15
+ * Uses createExportCamera to compose the full transform matrix, then applies
16
+ * it in a single ctx.setTransform call before drawing the image.
17
+ *
18
+ * @param image - The source image element.
19
+ * @param state - The full cropper state containing crop, rotation, and flip settings.
20
+ * @return A canvas element containing the transformed and cropped image.
21
+ */
22
+ export declare function renderToCanvas(image: HTMLImageElement, state: CropperState): HTMLCanvasElement;
23
+ /**
24
+ * Convert a canvas to a Blob with configurable MIME type and quality.
25
+ *
26
+ * @param canvas - The canvas to export.
27
+ * @param mimeType - The output MIME type. Defaults to 'image/png'.
28
+ * @param quality - The quality parameter for lossy formats (0-1). Defaults to DEFAULT_QUALITY.
29
+ * @return A promise that resolves to the canvas content as a Blob.
30
+ */
31
+ export declare function canvasToBlob(canvas: HTMLCanvasElement, mimeType?: string, quality?: number): Promise<Blob>;
32
+ /**
33
+ * Convert a canvas to a data URL string.
34
+ *
35
+ * @param canvas - The canvas to export.
36
+ * @param mimeType - The output MIME type. Defaults to 'image/png'.
37
+ * @param quality - The quality parameter for lossy formats (0-1). Defaults to DEFAULT_QUALITY.
38
+ * @return The canvas content as a data URL string.
39
+ */
40
+ export declare function canvasToDataURL(canvas: HTMLCanvasElement, mimeType?: string, quality?: number): string;
41
+ /**
42
+ * Load an image, render with transforms, and export as a Blob.
43
+ *
44
+ * Throws on failure so callers can distinguish error cases:
45
+ * - Image load failures (network errors, 404s) throw the native
46
+ * load error from the Image element.
47
+ * - Cross-origin failures manifest as tainted-canvas errors from
48
+ * `canvas.toBlob()` — the browser rejects reading pixel data
49
+ * from a canvas that drew an image without valid CORS headers.
50
+ * Ensure the source server sets `Access-Control-Allow-Origin`.
51
+ * - Canvas context creation failures throw a descriptive Error.
52
+ *
53
+ * Only works in browser environments (needs DOM / HTMLCanvasElement).
54
+ *
55
+ * @param src - The image URL to load.
56
+ * @param state - The cropper state with all transform settings.
57
+ * @param mimeType - The output MIME type. Defaults to 'image/png'.
58
+ * @param quality - The quality parameter for lossy formats (0-1). Defaults to DEFAULT_QUALITY.
59
+ * @return A promise that resolves to the exported Blob.
60
+ * @throws If the image fails to load, canvas creation fails, or
61
+ * the resulting canvas is tainted by CORS restrictions.
62
+ */
63
+ export declare function exportCroppedImage(src: string, state: CropperState, mimeType?: string, quality?: number): Promise<Blob>;
64
+ /**
65
+ * Apply the cropper's transform (crop, rotation, flip, zoom) to an existing
66
+ * canvas or image source. This is the bridge for multi-step editing pipelines
67
+ * where an upstream tool (e.g., brightness/color adjustment) has already
68
+ * processed the image and you want to apply the crop on top.
69
+ *
70
+ * Accepts any CanvasImageSource: HTMLImageElement, HTMLCanvasElement,
71
+ * OffscreenCanvas, ImageBitmap, HTMLVideoElement, etc.
72
+ *
73
+ * @param source - The image source to crop/transform.
74
+ * @param sourceSize - The dimensions of the source (natural width/height).
75
+ * @param sourceSize.width - The width of the source in pixels.
76
+ * @param sourceSize.height - The height of the source in pixels.
77
+ * @param state - The cropper state with all transform settings.
78
+ * @param outputSize - Optional output size. Defaults to the crop region's natural pixel size.
79
+ * @param outputSize.width - The width of the output in pixels.
80
+ * @param outputSize.height - The height of the output in pixels.
81
+ * @return A canvas with the transforms applied.
82
+ */
83
+ export declare function applyToCanvas(source: CanvasImageSource, sourceSize: {
84
+ width: number;
85
+ height: number;
86
+ }, state: CropperState, outputSize?: {
87
+ width: number;
88
+ height: number;
89
+ }): HTMLCanvasElement;
90
+ /**
91
+ * Download the cropped image as a file.
92
+ *
93
+ * Loads the source image, applies all transforms, and triggers a
94
+ * browser download via exportCroppedImage() + object URL + anchor click.
95
+ *
96
+ * Throws on export failure (see `exportCroppedImage`).
97
+ *
98
+ * @param src - The image URL to load.
99
+ * @param state - The cropper state with all transform settings.
100
+ * @param filename - The download filename. Defaults to 'cropped-image'.
101
+ * @param mimeType - The output MIME type. Defaults to 'image/png'.
102
+ * @param quality - The quality parameter for lossy formats (0-1). Defaults to DEFAULT_QUALITY.
103
+ * @return A promise that resolves when the download is triggered.
104
+ */
105
+ export declare function downloadCroppedImage(src: string, state: CropperState, filename?: string, mimeType?: string, quality?: number): Promise<void>;
106
+ //# sourceMappingURL=canvas-renderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canvas-renderer.d.ts","sourceRoot":"","sources":["../../../../src/image-editor/core/export/canvas-renderer.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAM7C;;;;;GAKG;AACH,wBAAgB,SAAS,CAAE,GAAG,EAAE,MAAM,GAAI,OAAO,CAAE,gBAAgB,CAAE,CAQpE;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC7B,KAAK,EAAE,gBAAgB,EACvB,KAAK,EAAE,YAAY,GACjB,iBAAiB,CAqCnB;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC3B,MAAM,EAAE,iBAAiB,EACzB,QAAQ,GAAE,MAAoB,EAC9B,OAAO,GAAE,MAAwB,GAC/B,OAAO,CAAE,IAAI,CAAE,CAcjB;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC9B,MAAM,EAAE,iBAAiB,EACzB,QAAQ,GAAE,MAAoB,EAC9B,OAAO,GAAE,MAAwB,GAC/B,MAAM,CAER;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,kBAAkB,CACvC,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,YAAY,EACnB,QAAQ,GAAE,MAAoB,EAC9B,OAAO,GAAE,MAAwB,GAC/B,OAAO,CAAE,IAAI,CAAE,CAIjB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,aAAa,CAC5B,MAAM,EAAE,iBAAiB,EACzB,UAAU,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAC7C,KAAK,EAAE,YAAY,EACnB,UAAU,CAAC,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC5C,iBAAiB,CA0CnB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,oBAAoB,CACzC,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,YAAY,EACnB,QAAQ,GAAE,MAAwB,EAClC,QAAQ,GAAE,MAAoB,EAC9B,OAAO,GAAE,MAAwB,GAC/B,OAAO,CAAE,IAAI,CAAE,CASjB"}
@@ -0,0 +1,10 @@
1
+ export type { CropperState, CropperAction, TransformOperation, NormalizedPoint, NormalizedRect, Size, Flip, StencilProps, HandlePosition, } from './types';
2
+ export { DEFAULT_STATE, DEFAULT_ASPECT_RATIOS, ORIGINAL_ASPECT_RATIO, } from './constants';
3
+ export type { AspectRatioPreset } from './constants';
4
+ export { cropperReducer, enforceContainment, areCropperStatesEqual, isStateDirty, } from './state';
5
+ export { getSourceRegion, getSourceRegionPercent } from './source-region';
6
+ export type { SourceRegion, SourceRegionPercent } from './source-region';
7
+ export { computeInscribedRect } from './crop-rect';
8
+ export { applyOperationToState, stateFromPipeline, } from './transforms/pipeline';
9
+ export { exportCroppedImage, applyToCanvas } from './export/canvas-renderer';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/image-editor/core/index.ts"],"names":[],"mappings":"AACA,YAAY,EACX,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,IAAI,EACJ,IAAI,EACJ,YAAY,EACZ,cAAc,GACd,MAAM,SAAS,CAAC;AAGjB,OAAO,EACN,aAAa,EACb,qBAAqB,EACrB,qBAAqB,GACrB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAMrD,OAAO,EACN,cAAc,EACd,kBAAkB,EAClB,qBAAqB,EACrB,YAAY,GACZ,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAC1E,YAAY,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAGzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAGnD,OAAO,EACN,qBAAqB,EACrB,iBAAiB,GACjB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,194 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import type { CropperState, NormalizedPoint, Size } from './types';
5
+ /**
6
+ * Status reported by the interaction controller when drag/zoom state changes.
7
+ */
8
+ export interface InteractionStatus {
9
+ /** Whether a drag (pan) interaction is in progress. */
10
+ isDragging: boolean;
11
+ /** Whether a double-tap zoom animation is in progress. */
12
+ isZooming: boolean;
13
+ }
14
+ /**
15
+ * State updates the interaction controller can request from its host UI.
16
+ */
17
+ export interface CropperInteractionActions {
18
+ /** Set the image pan offset in normalized coordinates. */
19
+ setPan: (pan: NormalizedPoint) => void;
20
+ /**
21
+ * Set the zoom level. Cursorless surfaces (slider, keyboard `+`/`-`)
22
+ * rely on this anchoring at the crop center; pointer-driven zoom
23
+ * paths use `setZoomAtPoint` with an explicit focal point instead.
24
+ */
25
+ setZoom: (zoom: number) => void;
26
+ /** Set zoom and pan together for focal-point zoom. */
27
+ setZoomAtPoint: (zoom: number, pan: NormalizedPoint) => void;
28
+ /** Snap rotate by 90 degrees. */
29
+ snapRotate90: (direction: 1 | -1) => void;
30
+ /** Toggle flip on the given axis. */
31
+ toggleFlip?: (direction: 'horizontal' | 'vertical') => void;
32
+ }
33
+ /**
34
+ * Options for creating an InteractionController.
35
+ *
36
+ * Scalar options (minZoom, maxZoom, etc.) are read lazily on each
37
+ * interaction, so changes to the options object take effect immediately
38
+ * without recreating the controller.
39
+ */
40
+ export interface InteractionControllerOptions {
41
+ /** Returns the current cropper state. Called on every interaction. */
42
+ getState: () => CropperState;
43
+ /** State updates the interaction controller can request from its host UI. */
44
+ actions: CropperInteractionActions;
45
+ /** Returns the container dimensions in pixels. */
46
+ getContainerSize: () => Size;
47
+ /** Returns the rendered image dimensions in pixels, if available. */
48
+ getImageSize: () => Size | undefined;
49
+ /** Minimum zoom level. Defaults to MIN_ZOOM. Read lazily. */
50
+ minZoom?: number;
51
+ /** Maximum zoom level. Defaults to MAX_ZOOM. Read lazily. */
52
+ maxZoom?: number;
53
+ /** Zoom speed multiplier for wheel events. Defaults to 0.0025. Read lazily. */
54
+ zoomSpeed?: number;
55
+ /**
56
+ * Pan step size in normalized coords for keyboard events.
57
+ * Defaults to 0.01. Read lazily. Shift multiplies it by 10.
58
+ */
59
+ keyboardStep?: number;
60
+ /** Zoom level for double-tap zoom. Defaults to 2. Read lazily. */
61
+ doubleTapZoom?: number;
62
+ /** Fires when a continuous gesture begins (pan drag, pinch zoom). */
63
+ onGestureStart?: () => void;
64
+ /** Fires when a continuous gesture ends (pointer release). */
65
+ onGestureEnd?: () => void;
66
+ /** Called when isDragging or isZooming changes. */
67
+ onStatusChange?: (status: InteractionStatus) => void;
68
+ }
69
+ /**
70
+ * Framework-agnostic imperative controller for image cropper interactions.
71
+ *
72
+ * Handles mouse, touch, and keyboard event processing for pan, zoom,
73
+ * and crop manipulation. Uses requestAnimationFrame for drag/pinch
74
+ * updates to avoid layout thrashing.
75
+ *
76
+ * The controller does not register DOM event listeners itself — that is the
77
+ * responsibility of the UI layer (React hook, Vue directive, or vanilla JS).
78
+ * Instead it exposes `handlePointerDown`, `handleWheel`, `handleTouchStart`,
79
+ * and `handleKeyDown` methods that the UI layer calls with native DOM events.
80
+ *
81
+ * Scalar options (minZoom, maxZoom, zoomSpeed, keyboardStep, doubleTapZoom)
82
+ * are read lazily from `this.options` on each interaction, so the UI layer
83
+ * can update them without recreating the controller.
84
+ *
85
+ * Call `destroy()` to clean up timers and pending animation frames.
86
+ */
87
+ export declare class InteractionController {
88
+ private readonly options;
89
+ /** Current drag/zoom status. */
90
+ private isDragging;
91
+ private isZooming;
92
+ /** Active drag state during pointer interactions. */
93
+ private drag;
94
+ /** Active touch state during touch interactions. */
95
+ private touch;
96
+ /** Cleanup function for active touch listeners on document. */
97
+ private touchCleanup;
98
+ /**
99
+ * Cleanup function for active pointer-drag listeners on the
100
+ * captured element. Set while a pointer drag is in progress so
101
+ * `destroy()` can tear the drag down cleanly if the consumer
102
+ * unmounts mid-drag. Cleared on pointerup/lostpointercapture.
103
+ */
104
+ private pointerCleanup;
105
+ /** Last tap info for double-tap detection. */
106
+ private lastTap;
107
+ /** Timer for the zoom animation state (double-tap). */
108
+ private zoomTimer;
109
+ /** Timer for wheel gesture debounce. */
110
+ private wheelGestureTimer;
111
+ /** Whether a wheel gesture is currently active. */
112
+ private wheelGestureActive;
113
+ /** Current requestAnimationFrame ID. */
114
+ private rafId;
115
+ constructor(options: InteractionControllerOptions);
116
+ /** Read minZoom lazily so option changes take effect immediately. */
117
+ private get minZoom();
118
+ /** Read maxZoom lazily so option changes take effect immediately. */
119
+ private get maxZoom();
120
+ /** Read zoomSpeed lazily so option changes take effect immediately. */
121
+ private get zoomSpeed();
122
+ /** Read keyboardStep lazily so option changes take effect immediately. */
123
+ private get keyboardStep();
124
+ /**
125
+ * Get the keyboard pan step, including modifier-based coarse movement.
126
+ *
127
+ * @param event The native KeyboardEvent.
128
+ * @return The normalized pan step.
129
+ */
130
+ private getKeyboardStep;
131
+ /** Read doubleTapZoom lazily so option changes take effect immediately. */
132
+ private get doubleTapZoom();
133
+ /**
134
+ * Update the drag/zoom status and notify via callback if changed.
135
+ *
136
+ * @param update Partial status with isDragging and/or isZooming.
137
+ */
138
+ private setStatus;
139
+ /**
140
+ * Handle a pointer-down event on the container element.
141
+ *
142
+ * Initiates a drag (pan) interaction. Captures the pointer on the
143
+ * provided element and registers pointermove/pointerup/lostpointercapture
144
+ * listeners for the duration of the drag.
145
+ *
146
+ * @param e The native PointerEvent.
147
+ * @param el The DOM element to capture the pointer on.
148
+ */
149
+ handlePointerDown(e: PointerEvent, el: HTMLElement): void;
150
+ /**
151
+ * Handle a wheel event on the container element.
152
+ *
153
+ * Implements focal-point zoom: the point under the cursor stays
154
+ * stationary on screen while the zoom level changes.
155
+ *
156
+ * Must be registered with `{ passive: false }` to allow preventDefault.
157
+ *
158
+ * @param e The native WheelEvent.
159
+ */
160
+ handleWheel(e: WheelEvent): void;
161
+ /**
162
+ * Handle a touch-start event on the container element.
163
+ *
164
+ * Supports single-finger pan, two-finger pinch zoom, and
165
+ * double-tap to toggle between fit and 2x zoom. Registers
166
+ * touchmove/touchend/touchcancel on the provided document for the
167
+ * duration of the gesture.
168
+ *
169
+ * @param e The native TouchEvent.
170
+ * @param containerRect The bounding rect of the container element.
171
+ * @param doc The document to register move/end listeners on.
172
+ * Defaults to globalThis.document. Pass the iframe's
173
+ * contentDocument when running inside an iframe.
174
+ */
175
+ handleTouchStart(e: TouchEvent, containerRect: DOMRect, doc?: Document): void;
176
+ private handleTouchMove;
177
+ private tryDoubleTap;
178
+ /**
179
+ * Handle a keydown event on the container element.
180
+ *
181
+ * Supports arrow keys for panning, +/- for zoom, and r/R for rotation.
182
+ *
183
+ * @param e The native KeyboardEvent.
184
+ */
185
+ handleKeyDown(e: KeyboardEvent): void;
186
+ /**
187
+ * Clean up all timers, animation frames, and active touch listeners.
188
+ *
189
+ * Must be called when the controller is no longer needed (e.g., on
190
+ * component unmount or element removal).
191
+ */
192
+ destroy(): void;
193
+ }
194
+ //# sourceMappingURL=interaction-controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interaction-controller.d.ts","sourceRoot":"","sources":["../../../src/image-editor/core/interaction-controller.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Normalizes a rotation value to the range [0, 360).
3
+ *
4
+ * Negative rotations are converted to their positive clockwise equivalent.
5
+ * For example, -90 becomes 270, -45 becomes 315, and 450 becomes 90.
6
+ *
7
+ * @param degrees The rotation value in degrees.
8
+ * @return The normalized rotation in the range [0, 360).
9
+ */
10
+ export declare function normalizeRotation(degrees: number): number;
11
+ /**
12
+ * Converts an angle from degrees to radians.
13
+ *
14
+ * @param degrees The angle in degrees.
15
+ * @return The angle in radians.
16
+ */
17
+ export declare function degreesToRadians(degrees: number): number;
18
+ //# sourceMappingURL=rotation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rotation.d.ts","sourceRoot":"","sources":["../../../../src/image-editor/core/math/rotation.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAE,OAAO,EAAE,MAAM,GAAI,MAAM,CAM3D;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAE,OAAO,EAAE,MAAM,GAAI,MAAM,CAE1D"}