@wordpress/media-editor 0.7.1-next.v.202604201441.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/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/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/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 -7
- 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/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,245 @@
|
|
|
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/containment.ts
|
|
21
|
+
var containment_exports = {};
|
|
22
|
+
__export(containment_exports, {
|
|
23
|
+
getCropBounds: () => getCropBounds,
|
|
24
|
+
restrictCropRect: () => restrictCropRect,
|
|
25
|
+
restrictPanZoom: () => restrictPanZoom
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(containment_exports);
|
|
28
|
+
var import_gl_matrix = require("gl-matrix");
|
|
29
|
+
var import_rotation = require("./math/rotation.cjs");
|
|
30
|
+
var import_camera = require("./camera.cjs");
|
|
31
|
+
var EPSILON = 1e-9;
|
|
32
|
+
function getVisualDimensions(rotation, imageAspectRatio) {
|
|
33
|
+
const rad = (0, import_rotation.degreesToRadians)(rotation);
|
|
34
|
+
const absC = Math.abs(Math.cos(rad));
|
|
35
|
+
const absS = Math.abs(Math.sin(rad));
|
|
36
|
+
const bbox = (0, import_camera.getRotatedBBox)(imageAspectRatio, 1, rotation);
|
|
37
|
+
return {
|
|
38
|
+
visualW: bbox.width,
|
|
39
|
+
visualH: bbox.height,
|
|
40
|
+
absC,
|
|
41
|
+
absS
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function getMinZoomForCover(rotation, imageAspectRatio, cropRect) {
|
|
45
|
+
const aspectRatio = Math.max(imageAspectRatio, Number.EPSILON);
|
|
46
|
+
const snapRotation = Math.round(rotation / 90) * 90;
|
|
47
|
+
const { visualW: snapVisualW, visualH: snapVisualH } = getVisualDimensions(
|
|
48
|
+
snapRotation,
|
|
49
|
+
aspectRatio
|
|
50
|
+
);
|
|
51
|
+
const { absC, absS } = getVisualDimensions(rotation, aspectRatio);
|
|
52
|
+
const cropHalfW = cropRect.width * snapVisualW / 2;
|
|
53
|
+
const cropHalfH = cropRect.height * snapVisualH / 2;
|
|
54
|
+
const spanAlpha = cropHalfW * absC + cropHalfH * absS;
|
|
55
|
+
const spanBeta = cropHalfW * absS + cropHalfH * absC;
|
|
56
|
+
const zoomFromAlpha = 2 * spanAlpha / aspectRatio;
|
|
57
|
+
const zoomFromBeta = 2 * spanBeta;
|
|
58
|
+
return Math.max(1, zoomFromAlpha, zoomFromBeta);
|
|
59
|
+
}
|
|
60
|
+
function getCropBounds(state, elementSize, visualSize, containerSize) {
|
|
61
|
+
if (elementSize.width === 0 || elementSize.height === 0 || visualSize.width === 0 || visualSize.height === 0) {
|
|
62
|
+
return { minX: 0, minY: 0, maxX: 1, maxY: 1 };
|
|
63
|
+
}
|
|
64
|
+
const tx = state.pan.x * visualSize.width;
|
|
65
|
+
const ty = state.pan.y * visualSize.height;
|
|
66
|
+
const rad = (0, import_rotation.degreesToRadians)(state.rotation);
|
|
67
|
+
const cos = Math.cos(rad);
|
|
68
|
+
const sin = Math.sin(rad);
|
|
69
|
+
const sx = state.flip.horizontal ? -1 : 1;
|
|
70
|
+
const sy = state.flip.vertical ? -1 : 1;
|
|
71
|
+
const z = state.zoom;
|
|
72
|
+
const ma = sx * cos * z;
|
|
73
|
+
const mb = sy * sin * z;
|
|
74
|
+
const mc = -sx * sin * z;
|
|
75
|
+
const md = sy * cos * z;
|
|
76
|
+
const hw = elementSize.width / 2;
|
|
77
|
+
const hh = elementSize.height / 2;
|
|
78
|
+
const corners = [
|
|
79
|
+
[-hw, -hh],
|
|
80
|
+
[hw, -hh],
|
|
81
|
+
[hw, hh],
|
|
82
|
+
[-hw, hh]
|
|
83
|
+
];
|
|
84
|
+
const offsetX = (containerSize.width - visualSize.width) / 2;
|
|
85
|
+
const offsetY = (containerSize.height - visualSize.height) / 2;
|
|
86
|
+
let imgMinX = Infinity;
|
|
87
|
+
let imgMaxX = -Infinity;
|
|
88
|
+
let imgMinY = Infinity;
|
|
89
|
+
let imgMaxY = -Infinity;
|
|
90
|
+
for (const [cx, cy] of corners) {
|
|
91
|
+
const screenX = ma * cx + mc * cy + tx;
|
|
92
|
+
const screenY = mb * cx + md * cy + ty;
|
|
93
|
+
const nx = screenX / visualSize.width + 0.5;
|
|
94
|
+
const ny = screenY / visualSize.height + 0.5;
|
|
95
|
+
imgMinX = Math.min(imgMinX, nx);
|
|
96
|
+
imgMaxX = Math.max(imgMaxX, nx);
|
|
97
|
+
imgMinY = Math.min(imgMinY, ny);
|
|
98
|
+
imgMaxY = Math.max(imgMaxY, ny);
|
|
99
|
+
}
|
|
100
|
+
const containerMinX = -offsetX / visualSize.width;
|
|
101
|
+
const containerMaxX = (containerSize.width - offsetX) / visualSize.width;
|
|
102
|
+
const containerMinY = -offsetY / visualSize.height;
|
|
103
|
+
const containerMaxY = (containerSize.height - offsetY) / visualSize.height;
|
|
104
|
+
return {
|
|
105
|
+
minX: Math.max(imgMinX, containerMinX),
|
|
106
|
+
minY: Math.max(imgMinY, containerMinY),
|
|
107
|
+
maxX: Math.min(imgMaxX, containerMaxX),
|
|
108
|
+
maxY: Math.min(imgMaxY, containerMaxY)
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function restrictCropRect(cropRect, zoom, rotation, imageAspectRatio) {
|
|
112
|
+
const aspectRatio = Math.max(imageAspectRatio, Number.EPSILON);
|
|
113
|
+
const snapRotation = Math.round(rotation / 90) * 90;
|
|
114
|
+
const { visualW, visualH } = getVisualDimensions(
|
|
115
|
+
snapRotation,
|
|
116
|
+
aspectRatio
|
|
117
|
+
);
|
|
118
|
+
const { absC, absS } = getVisualDimensions(rotation, aspectRatio);
|
|
119
|
+
const W = cropRect.width;
|
|
120
|
+
const H = cropRect.height;
|
|
121
|
+
const cropWPx = W * visualW;
|
|
122
|
+
const cropHPx = H * visualH;
|
|
123
|
+
const spanAlpha = cropWPx * absC + cropHPx * absS;
|
|
124
|
+
const spanBeta = cropWPx * absS + cropHPx * absC;
|
|
125
|
+
const limitAlpha = aspectRatio * zoom;
|
|
126
|
+
const limitBeta = zoom;
|
|
127
|
+
let t = 1;
|
|
128
|
+
if (spanAlpha > 0) {
|
|
129
|
+
t = Math.min(t, limitAlpha / spanAlpha);
|
|
130
|
+
}
|
|
131
|
+
if (spanBeta > 0) {
|
|
132
|
+
t = Math.min(t, limitBeta / spanBeta);
|
|
133
|
+
}
|
|
134
|
+
if (t >= 1 - EPSILON) {
|
|
135
|
+
return cropRect;
|
|
136
|
+
}
|
|
137
|
+
const newW = W * t;
|
|
138
|
+
const newH = H * t;
|
|
139
|
+
const centerX = cropRect.x + W / 2;
|
|
140
|
+
const centerY = cropRect.y + H / 2;
|
|
141
|
+
let newX = centerX - newW / 2;
|
|
142
|
+
let newY = centerY - newH / 2;
|
|
143
|
+
newX = Math.max(0, Math.min(newX, 1 - newW));
|
|
144
|
+
newY = Math.max(0, Math.min(newY, 1 - newH));
|
|
145
|
+
return { x: newX, y: newY, width: newW, height: newH };
|
|
146
|
+
}
|
|
147
|
+
var CANONICAL_CONTAINER = { width: 1e3, height: 1e3 };
|
|
148
|
+
var _scratchMat = import_gl_matrix.mat2d.create();
|
|
149
|
+
var _scratchVec = import_gl_matrix.vec2.create();
|
|
150
|
+
function restrictPanZoom(state, imageSize, cropRect) {
|
|
151
|
+
const aspectRatio = imageSize.width > 0 && imageSize.height > 0 ? imageSize.width / imageSize.height : 1;
|
|
152
|
+
const minZoom = getMinZoomForCover(state.rotation, aspectRatio, cropRect);
|
|
153
|
+
const zoom = Math.max(state.zoom, minZoom);
|
|
154
|
+
const candidateState = { ...state, zoom };
|
|
155
|
+
const camera = (0, import_camera.createCamera)(
|
|
156
|
+
candidateState,
|
|
157
|
+
CANONICAL_CONTAINER,
|
|
158
|
+
imageSize
|
|
159
|
+
);
|
|
160
|
+
const snapRotation = Math.round(state.rotation / 90) * 90;
|
|
161
|
+
const baseCamera = (0, import_camera.createCamera)(
|
|
162
|
+
{
|
|
163
|
+
...candidateState,
|
|
164
|
+
pan: { x: 0, y: 0 },
|
|
165
|
+
zoom: 1,
|
|
166
|
+
rotation: snapRotation
|
|
167
|
+
},
|
|
168
|
+
CANONICAL_CONTAINER,
|
|
169
|
+
imageSize
|
|
170
|
+
);
|
|
171
|
+
const visibleBounds = (0, import_camera.getVisibleBounds)(baseCamera);
|
|
172
|
+
const stencilCorners = [
|
|
173
|
+
[
|
|
174
|
+
visibleBounds.left + cropRect.x * visibleBounds.width,
|
|
175
|
+
visibleBounds.top + cropRect.y * visibleBounds.height
|
|
176
|
+
],
|
|
177
|
+
[
|
|
178
|
+
visibleBounds.left + (cropRect.x + cropRect.width) * visibleBounds.width,
|
|
179
|
+
visibleBounds.top + cropRect.y * visibleBounds.height
|
|
180
|
+
],
|
|
181
|
+
[
|
|
182
|
+
visibleBounds.left + (cropRect.x + cropRect.width) * visibleBounds.width,
|
|
183
|
+
visibleBounds.top + (cropRect.y + cropRect.height) * visibleBounds.height
|
|
184
|
+
],
|
|
185
|
+
[
|
|
186
|
+
visibleBounds.left + cropRect.x * visibleBounds.width,
|
|
187
|
+
visibleBounds.top + (cropRect.y + cropRect.height) * visibleBounds.height
|
|
188
|
+
]
|
|
189
|
+
];
|
|
190
|
+
import_gl_matrix.mat2d.invert(_scratchMat, camera);
|
|
191
|
+
let minWx = Infinity;
|
|
192
|
+
let maxWx = -Infinity;
|
|
193
|
+
let minWy = Infinity;
|
|
194
|
+
let maxWy = -Infinity;
|
|
195
|
+
for (const corner of stencilCorners) {
|
|
196
|
+
import_gl_matrix.vec2.transformMat2d(_scratchVec, corner, _scratchMat);
|
|
197
|
+
const w = _scratchVec;
|
|
198
|
+
if (w[0] < minWx) {
|
|
199
|
+
minWx = w[0];
|
|
200
|
+
}
|
|
201
|
+
if (w[0] > maxWx) {
|
|
202
|
+
maxWx = w[0];
|
|
203
|
+
}
|
|
204
|
+
if (w[1] < minWy) {
|
|
205
|
+
minWy = w[1];
|
|
206
|
+
}
|
|
207
|
+
if (w[1] > maxWy) {
|
|
208
|
+
maxWy = w[1];
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
if (minWx >= -EPSILON && maxWx <= 1 + EPSILON && minWy >= -EPSILON && maxWy <= 1 + EPSILON) {
|
|
212
|
+
return { pan: state.pan, zoom };
|
|
213
|
+
}
|
|
214
|
+
let dwx = 0;
|
|
215
|
+
let dwy = 0;
|
|
216
|
+
if (minWx < 0 && maxWx <= 1 + EPSILON) {
|
|
217
|
+
dwx = -minWx;
|
|
218
|
+
} else if (maxWx > 1 && minWx >= -EPSILON) {
|
|
219
|
+
dwx = 1 - maxWx;
|
|
220
|
+
} else if (minWx < 0 && maxWx > 1) {
|
|
221
|
+
dwx = (1 - maxWx - minWx) / 2;
|
|
222
|
+
}
|
|
223
|
+
if (minWy < 0 && maxWy <= 1 + EPSILON) {
|
|
224
|
+
dwy = -minWy;
|
|
225
|
+
} else if (maxWy > 1 && minWy >= -EPSILON) {
|
|
226
|
+
dwy = 1 - maxWy;
|
|
227
|
+
} else if (minWy < 0 && maxWy > 1) {
|
|
228
|
+
dwy = (1 - maxWy - minWy) / 2;
|
|
229
|
+
}
|
|
230
|
+
const dsx = camera[0] * dwx + camera[2] * dwy;
|
|
231
|
+
const dsy = camera[1] * dwx + camera[3] * dwy;
|
|
232
|
+
const newPanX = state.pan.x - (visibleBounds.width > 0 ? dsx / visibleBounds.width : 0);
|
|
233
|
+
const newPanY = state.pan.y - (visibleBounds.height > 0 ? dsy / visibleBounds.height : 0);
|
|
234
|
+
return {
|
|
235
|
+
pan: { x: newPanX, y: newPanY },
|
|
236
|
+
zoom
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
240
|
+
0 && (module.exports = {
|
|
241
|
+
getCropBounds,
|
|
242
|
+
restrictCropRect,
|
|
243
|
+
restrictPanZoom
|
|
244
|
+
});
|
|
245
|
+
//# sourceMappingURL=containment.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/image-editor/core/containment.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport { mat2d, vec2 } from 'gl-matrix';\n\n/**\n * Internal dependencies\n */\nimport type { CropperState, NormalizedRect, Size } from './types';\nimport { degreesToRadians } from './math/rotation';\nimport { createCamera, getRotatedBBox, getVisibleBounds } from './camera';\n\n/** Floating-point epsilon for \"close enough to equal\" comparisons. */\nconst EPSILON = 1e-9;\n\n/**\n * Compute the visual (rotated) bounding-box dimensions in pixel-proportional\n * units where the unrotated image is `a \u00D7 1` (renderedW = a, renderedH = 1).\n *\n * @param rotation Rotation angle in degrees.\n * @param imageAspectRatio Image width / height ratio.\n * @return Visual dimensions and trig helpers.\n */\nfunction getVisualDimensions(\n\trotation: number,\n\timageAspectRatio: number\n): { visualW: number; visualH: number; absC: number; absS: number } {\n\tconst rad = degreesToRadians( rotation );\n\tconst absC = Math.abs( Math.cos( rad ) );\n\tconst absS = Math.abs( Math.sin( rad ) );\n\tconst bbox = getRotatedBBox( imageAspectRatio, 1, rotation );\n\treturn {\n\t\tvisualW: bbox.width,\n\t\tvisualH: bbox.height,\n\t\tabsC,\n\t\tabsS,\n\t};\n}\n\n/**\n * Calculates the minimum zoom factor needed for the rotated image to fully cover\n * the crop rectangle, using normalized coordinates and imageAspectRatio.\n *\n * Works in pixel-proportional space where the unrotated image is a\u00D71.\n * The crop rect is in visual-normalized space and must be scaled by the\n * rotation-dependent visual dimensions before projecting into the image-local\n * frame.\n *\n * @param rotation Rotation angle in degrees.\n * @param imageAspectRatio Image width / height ratio.\n * @param cropRect The crop rectangle in normalized coordinates.\n * @return The minimum zoom factor (always >= 1).\n */\nfunction getMinZoomForCover(\n\trotation: number,\n\timageAspectRatio: number,\n\tcropRect: NormalizedRect\n): number {\n\tconst aspectRatio = Math.max( imageAspectRatio, Number.EPSILON );\n\t// The crop rect lives in the SNAP-rotation visual bbox \u2014 that's how the\n\t// stencil and preview position it (see createCamera / getImageFit). Use\n\t// the snap-rotation dimensions to convert crop fractions to pixels.\n\tconst snapRotation = Math.round( rotation / 90 ) * 90;\n\tconst { visualW: snapVisualW, visualH: snapVisualH } = getVisualDimensions(\n\t\tsnapRotation,\n\t\taspectRatio\n\t);\n\t// Projection into the image-local frame uses the TRUE rotation angle \u2014\n\t// that's the actual orientation of the image under the stencil.\n\tconst { absC, absS } = getVisualDimensions( rotation, aspectRatio );\n\n\t// Crop half-extents in pixel-proportional space.\n\tconst cropHalfW = ( cropRect.width * snapVisualW ) / 2;\n\tconst cropHalfH = ( cropRect.height * snapVisualH ) / 2;\n\n\t// AABB of the crop rect projected into the image-local (unrotated) frame.\n\tconst spanAlpha = cropHalfW * absC + cropHalfH * absS;\n\tconst spanBeta = cropHalfW * absS + cropHalfH * absC;\n\n\t// Image half-extents at zoom z: (aspectRatio*z/2, z/2).\n\t// Coverage requires: aspectRatio*z/2 >= spanAlpha AND z/2 >= spanBeta.\n\tconst zoomFromAlpha = ( 2 * spanAlpha ) / aspectRatio;\n\tconst zoomFromBeta = 2 * spanBeta;\n\n\treturn Math.max( 1, zoomFromAlpha, zoomFromBeta );\n}\n\n/**\n * Compute the crop handle bounds in normalized visual space by finding the\n * axis-aligned bounding box (AABB) of the actual image footprint at the\n * current pan/zoom/rotation, then intersecting with the container viewport.\n *\n * Unlike a static centerline-based calculation, this accounts for the\n * current pan position \u2014 if the user pans right, the left bound tightens\n * because the image's left edge has moved right.\n *\n * @param state The current cropper state (crop, zoom, rotation, flip).\n * @param elementSize The fitted (unrotated) image element dimensions in pixels.\n * @param visualSize The visual (rotated) image bounding box in pixels.\n * @param containerSize The container dimensions in pixels.\n * @return The min/max x and y that a crop rect edge can reach in normalized space.\n */\nexport function getCropBounds(\n\tstate: CropperState,\n\telementSize: Size,\n\tvisualSize: Size,\n\tcontainerSize: Size\n): { minX: number; minY: number; maxX: number; maxY: number } {\n\tif (\n\t\telementSize.width === 0 ||\n\t\telementSize.height === 0 ||\n\t\tvisualSize.width === 0 ||\n\t\tvisualSize.height === 0\n\t) {\n\t\treturn { minX: 0, minY: 0, maxX: 1, maxY: 1 };\n\t}\n\n\t// Build the same CSS matrix as use-transform-style: flip * rotate * zoom.\n\t// Flip is outside rotation so it acts in viewport axes (see createCamera).\n\tconst tx = state.pan.x * visualSize.width;\n\tconst ty = state.pan.y * visualSize.height;\n\tconst rad = degreesToRadians( state.rotation );\n\tconst cos = Math.cos( rad );\n\tconst sin = Math.sin( rad );\n\tconst sx = state.flip.horizontal ? -1 : 1;\n\tconst sy = state.flip.vertical ? -1 : 1;\n\tconst z = state.zoom;\n\tconst ma = sx * cos * z;\n\tconst mb = sy * sin * z;\n\tconst mc = -sx * sin * z;\n\tconst md = sy * cos * z;\n\n\t// Image element corners relative to element center.\n\tconst hw = elementSize.width / 2;\n\tconst hh = elementSize.height / 2;\n\tconst corners = [\n\t\t[ -hw, -hh ],\n\t\t[ hw, -hh ],\n\t\t[ hw, hh ],\n\t\t[ -hw, hh ],\n\t];\n\n\t// Transform corners through CSS matrix \u2192 screen offsets from element center.\n\t// Screen position = element_center + transformed_offset.\n\t// Element center is at (containerW/2, containerH/2) after CSS centering.\n\t// But we want normalized coords, so work relative to the visual image origin.\n\tconst offsetX = ( containerSize.width - visualSize.width ) / 2;\n\tconst offsetY = ( containerSize.height - visualSize.height ) / 2;\n\n\tlet imgMinX = Infinity;\n\tlet imgMaxX = -Infinity;\n\tlet imgMinY = Infinity;\n\tlet imgMaxY = -Infinity;\n\n\tfor ( const [ cx, cy ] of corners ) {\n\t\t// Screen offset from element center after CSS matrix.\n\t\tconst screenX = ma * cx + mc * cy + tx;\n\t\tconst screenY = mb * cx + md * cy + ty;\n\t\t// Convert to normalized visual space.\n\t\t// The element center is at the visual image center, which is at\n\t\t// normalized (0.5, 0.5). So screen offset / visualSize + 0.5.\n\t\tconst nx = screenX / visualSize.width + 0.5;\n\t\tconst ny = screenY / visualSize.height + 0.5;\n\t\timgMinX = Math.min( imgMinX, nx );\n\t\timgMaxX = Math.max( imgMaxX, nx );\n\t\timgMinY = Math.min( imgMinY, ny );\n\t\timgMaxY = Math.max( imgMaxY, ny );\n\t}\n\n\t// Container bounds in normalized space.\n\tconst containerMinX = -offsetX / visualSize.width;\n\tconst containerMaxX = ( containerSize.width - offsetX ) / visualSize.width;\n\tconst containerMinY = -offsetY / visualSize.height;\n\tconst containerMaxY =\n\t\t( containerSize.height - offsetY ) / visualSize.height;\n\n\t// Crop bounds = intersection of image AABB and container bounds.\n\treturn {\n\t\tminX: Math.max( imgMinX, containerMinX ),\n\t\tminY: Math.max( imgMinY, containerMinY ),\n\t\tmaxX: Math.min( imgMaxX, containerMaxX ),\n\t\tmaxY: Math.min( imgMaxY, containerMaxY ),\n\t};\n}\n\n/**\n * Restricts a crop rectangle so that the rotated, zoomed image can fully cover it.\n * If the crop rect is too large for the current zoom and rotation, it is scaled\n * down proportionally and re-centered.\n *\n * Works in pixel-proportional space where the unrotated image is a\u00D71.\n *\n * @param cropRect The crop rectangle in normalized coordinates.\n * @param zoom The current zoom factor.\n * @param rotation The rotation angle in degrees.\n * @param imageAspectRatio The image width / height ratio.\n * @return The restricted crop rectangle.\n */\nexport function restrictCropRect(\n\tcropRect: NormalizedRect,\n\tzoom: number,\n\trotation: number,\n\timageAspectRatio: number\n): NormalizedRect {\n\tconst aspectRatio = Math.max( imageAspectRatio, Number.EPSILON );\n\t// Crop rect lives in the SNAP-rotation visual bbox (matching the stencil\n\t// layout); projection into the image-local frame uses the TRUE rotation.\n\tconst snapRotation = Math.round( rotation / 90 ) * 90;\n\tconst { visualW, visualH } = getVisualDimensions(\n\t\tsnapRotation,\n\t\taspectRatio\n\t);\n\tconst { absC, absS } = getVisualDimensions( rotation, aspectRatio );\n\tconst W = cropRect.width;\n\tconst H = cropRect.height;\n\n\t// Crop full-extents in pixel-proportional space, projected to image-local frame.\n\tconst cropWPx = W * visualW;\n\tconst cropHPx = H * visualH;\n\tconst spanAlpha = cropWPx * absC + cropHPx * absS;\n\tconst spanBeta = cropWPx * absS + cropHPx * absC;\n\n\t// Image full-extents at zoom z: (aspectRatio*z, z).\n\tconst limitAlpha = aspectRatio * zoom;\n\tconst limitBeta = zoom;\n\n\tlet t = 1;\n\tif ( spanAlpha > 0 ) {\n\t\tt = Math.min( t, limitAlpha / spanAlpha );\n\t}\n\tif ( spanBeta > 0 ) {\n\t\tt = Math.min( t, limitBeta / spanBeta );\n\t}\n\tif ( t >= 1 - EPSILON ) {\n\t\t// Crop fits at the current zoom \u2014 no size change needed.\n\t\t// Position is handled by restrictPanZoom, not here.\n\t\treturn cropRect;\n\t}\n\tconst newW = W * t;\n\tconst newH = H * t;\n\tconst centerX = cropRect.x + W / 2;\n\tconst centerY = cropRect.y + H / 2;\n\tlet newX = centerX - newW / 2;\n\tlet newY = centerY - newH / 2;\n\tnewX = Math.max( 0, Math.min( newX, 1 - newW ) );\n\tnewY = Math.max( 0, Math.min( newY, 1 - newH ) );\n\treturn { x: newX, y: newY, width: newW, height: newH };\n}\n\n/**\n * Canonical container used internally by restrictPanZoom.\n * Containment is scale-invariant, so the actual size doesn't matter \u2014\n * only the relative geometry between stencil and image matters.\n */\nconst CANONICAL_CONTAINER: Size = { width: 1000, height: 1000 };\n\n// Pre-allocated scratch buffers for restrictPanZoom's hot path (runs on\n// every pointermove) to avoid Float32Array allocation per call.\nconst _scratchMat = mat2d.create();\nconst _scratchVec = vec2.create();\n\n/**\n * Clamps pan and adjusts zoom so that the zoomed, rotated image fully covers\n * the crop rectangle.\n *\n * Uses the camera matrix to project: builds a camera from the candidate state,\n * maps the stencil corners (axis-aligned in the visual bounding box) to world\n * space via the inverse camera, and checks that all world points lie within\n * [0,1]\u00D7[0,1]. If any point is outside, computes the minimal pan correction.\n *\n * @param state The current cropper state.\n * @param imageSize The natural size of the image in pixels.\n * @param cropRect The crop rectangle in normalized coordinates.\n * @return The restricted crop pan and zoom values.\n */\nexport function restrictPanZoom(\n\tstate: CropperState,\n\timageSize: Size,\n\tcropRect: NormalizedRect\n): { pan: { x: number; y: number }; zoom: number } {\n\t// Algorithm overview:\n\t// 1. Ensure zoom is high enough for the rotated image to cover the crop.\n\t// 2. Build a camera (world\u2192screen matrix) with the candidate state.\n\t// 3. Build a base camera (no pan, zoom=1) to find where the stencil\n\t// sits in screen space \u2014 the stencil is anchored to the container,\n\t// not the image, so it doesn't move with pan or scale with zoom.\n\t// 4. Project the 4 stencil corners through the INVERSE of the main\n\t// camera to get world-space positions. A world point outside [0,1]\n\t// means that corner of the stencil isn't covered by the image.\n\t// 5. Compute the minimal translation in world space to push all corners\n\t// back inside [0,1].\n\t// 6. Convert the world-space correction to a pan-field correction by\n\t// mapping it through the camera's linear part back to screen space,\n\t// then dividing by the visual bounds.\n\tconst aspectRatio =\n\t\timageSize.width > 0 && imageSize.height > 0\n\t\t\t? imageSize.width / imageSize.height\n\t\t\t: 1;\n\tconst minZoom = getMinZoomForCover( state.rotation, aspectRatio, cropRect );\n\tconst zoom = Math.max( state.zoom, minZoom );\n\n\t// Step 2: build camera with candidate pan and corrected zoom.\n\tconst candidateState = { ...state, zoom };\n\tconst camera = createCamera(\n\t\tcandidateState,\n\t\tCANONICAL_CONTAINER,\n\t\timageSize\n\t);\n\n\t// Build a base camera (zero pan, zoom=1) to get stencil positions.\n\t// The stencil is anchored to the container and laid out using the\n\t// nearest 90\u00B0 rotation (matching `getImageFit`), so it's stable\n\t// through fine rotation. CSS zoom only affects the <img> element,\n\t// not the stencil.\n\tconst snapRotation = Math.round( state.rotation / 90 ) * 90;\n\tconst baseCamera = createCamera(\n\t\t{\n\t\t\t...candidateState,\n\t\t\tpan: { x: 0, y: 0 },\n\t\t\tzoom: 1,\n\t\t\trotation: snapRotation,\n\t\t},\n\t\tCANONICAL_CONTAINER,\n\t\timageSize\n\t);\n\tconst visibleBounds = getVisibleBounds( baseCamera );\n\n\t// Stencil corners in screen space (axis-aligned rect within visual bounds).\n\tconst stencilCorners: [ number, number ][] = [\n\t\t[\n\t\t\tvisibleBounds.left + cropRect.x * visibleBounds.width,\n\t\t\tvisibleBounds.top + cropRect.y * visibleBounds.height,\n\t\t],\n\t\t[\n\t\t\tvisibleBounds.left +\n\t\t\t\t( cropRect.x + cropRect.width ) * visibleBounds.width,\n\t\t\tvisibleBounds.top + cropRect.y * visibleBounds.height,\n\t\t],\n\t\t[\n\t\t\tvisibleBounds.left +\n\t\t\t\t( cropRect.x + cropRect.width ) * visibleBounds.width,\n\t\t\tvisibleBounds.top +\n\t\t\t\t( cropRect.y + cropRect.height ) * visibleBounds.height,\n\t\t],\n\t\t[\n\t\t\tvisibleBounds.left + cropRect.x * visibleBounds.width,\n\t\t\tvisibleBounds.top +\n\t\t\t\t( cropRect.y + cropRect.height ) * visibleBounds.height,\n\t\t],\n\t];\n\n\t// Map stencil corners to world space via inverse camera.\n\t// If a world point is outside [0,1], the image doesn't cover that spot.\n\t// Reuse module-level scratch buffers to avoid allocation per frame.\n\tmat2d.invert( _scratchMat, camera );\n\n\tlet minWx = Infinity;\n\tlet maxWx = -Infinity;\n\tlet minWy = Infinity;\n\tlet maxWy = -Infinity;\n\n\tfor ( const corner of stencilCorners ) {\n\t\tvec2.transformMat2d( _scratchVec, corner, _scratchMat );\n\t\tconst w = _scratchVec;\n\t\tif ( w[ 0 ] < minWx ) {\n\t\t\tminWx = w[ 0 ];\n\t\t}\n\t\tif ( w[ 0 ] > maxWx ) {\n\t\t\tmaxWx = w[ 0 ];\n\t\t}\n\t\tif ( w[ 1 ] < minWy ) {\n\t\t\tminWy = w[ 1 ];\n\t\t}\n\t\tif ( w[ 1 ] > maxWy ) {\n\t\t\tmaxWy = w[ 1 ];\n\t\t}\n\t}\n\n\t// If all world points are in [0,1], no correction needed.\n\tif (\n\t\tminWx >= -EPSILON &&\n\t\tmaxWx <= 1 + EPSILON &&\n\t\tminWy >= -EPSILON &&\n\t\tmaxWy <= 1 + EPSILON\n\t) {\n\t\treturn { pan: state.pan, zoom };\n\t}\n\n\t// Compute world-space correction needed.\n\t// If minWx < 0, we need to shift world points right by |minWx|.\n\t// If maxWx > 1, we need to shift world points left by (maxWx - 1).\n\t// If both, we're over-constrained (crop too big) \u2014 getMinZoomForCover\n\t// should have prevented this.\n\tlet dwx = 0;\n\tlet dwy = 0;\n\n\tif ( minWx < 0 && maxWx <= 1 + EPSILON ) {\n\t\tdwx = -minWx;\n\t} else if ( maxWx > 1 && minWx >= -EPSILON ) {\n\t\tdwx = 1 - maxWx;\n\t} else if ( minWx < 0 && maxWx > 1 ) {\n\t\t// Over-constrained: center it.\n\t\tdwx = ( 1 - maxWx - minWx ) / 2;\n\t}\n\n\tif ( minWy < 0 && maxWy <= 1 + EPSILON ) {\n\t\tdwy = -minWy;\n\t} else if ( maxWy > 1 && minWy >= -EPSILON ) {\n\t\tdwy = 1 - maxWy;\n\t} else if ( minWy < 0 && maxWy > 1 ) {\n\t\tdwy = ( 1 - maxWy - minWy ) / 2;\n\t}\n\n\t// Convert world-space correction to screen-space correction.\n\t// The camera's 2\u00D72 linear part (indices [0,1,2,3]) maps world deltas\n\t// to screen deltas: screenDelta = linear * worldDelta.\n\tconst dsx = camera[ 0 ] * dwx + camera[ 2 ] * dwy;\n\tconst dsy = camera[ 1 ] * dwx + camera[ 3 ] * dwy;\n\n\t// Convert screen-space correction to pan-field correction.\n\t// Pan in screen pixels = pan.x * visualW, pan.y * visualH.\n\t// The correction is subtractive: a positive world shift (dw > 0) means\n\t// the image needs to move opposite to pan direction, so pan decreases.\n\tconst newPanX =\n\t\tstate.pan.x -\n\t\t( visibleBounds.width > 0 ? dsx / visibleBounds.width : 0 );\n\tconst newPanY =\n\t\tstate.pan.y -\n\t\t( visibleBounds.height > 0 ? dsy / visibleBounds.height : 0 );\n\n\treturn {\n\t\tpan: { x: newPanX, y: newPanY },\n\t\tzoom,\n\t};\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uBAA4B;AAM5B,sBAAiC;AACjC,oBAA+D;AAG/D,IAAM,UAAU;AAUhB,SAAS,oBACR,UACA,kBACmE;AACnE,QAAM,UAAM,kCAAkB,QAAS;AACvC,QAAM,OAAO,KAAK,IAAK,KAAK,IAAK,GAAI,CAAE;AACvC,QAAM,OAAO,KAAK,IAAK,KAAK,IAAK,GAAI,CAAE;AACvC,QAAM,WAAO,8BAAgB,kBAAkB,GAAG,QAAS;AAC3D,SAAO;AAAA,IACN,SAAS,KAAK;AAAA,IACd,SAAS,KAAK;AAAA,IACd;AAAA,IACA;AAAA,EACD;AACD;AAg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__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/export/canvas-renderer.ts
|
|
21
|
+
var canvas_renderer_exports = {};
|
|
22
|
+
__export(canvas_renderer_exports, {
|
|
23
|
+
applyToCanvas: () => applyToCanvas,
|
|
24
|
+
canvasToBlob: () => canvasToBlob,
|
|
25
|
+
canvasToDataURL: () => canvasToDataURL,
|
|
26
|
+
downloadCroppedImage: () => downloadCroppedImage,
|
|
27
|
+
exportCroppedImage: () => exportCroppedImage,
|
|
28
|
+
loadImage: () => loadImage,
|
|
29
|
+
renderToCanvas: () => renderToCanvas
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(canvas_renderer_exports);
|
|
32
|
+
var import_camera = require("../camera.cjs");
|
|
33
|
+
var DEFAULT_QUALITY = 0.92;
|
|
34
|
+
function loadImage(src) {
|
|
35
|
+
return new Promise((resolve, reject) => {
|
|
36
|
+
const image = new Image();
|
|
37
|
+
image.addEventListener("load", () => resolve(image));
|
|
38
|
+
image.addEventListener("error", (error) => reject(error));
|
|
39
|
+
image.crossOrigin = "anonymous";
|
|
40
|
+
image.src = src;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function renderToCanvas(image, state) {
|
|
44
|
+
const { naturalWidth, naturalHeight } = image;
|
|
45
|
+
const { rotation, cropRect } = state;
|
|
46
|
+
const imageSize = { width: naturalWidth, height: naturalHeight };
|
|
47
|
+
const snapRotation = Math.round(rotation / 90) * 90;
|
|
48
|
+
const rotBBox = (0, import_camera.getRotatedBBox)(naturalWidth, naturalHeight, snapRotation);
|
|
49
|
+
const outW = Math.round(cropRect.width * rotBBox.width);
|
|
50
|
+
const outH = Math.round(cropRect.height * rotBBox.height);
|
|
51
|
+
const canvas = document.createElement("canvas");
|
|
52
|
+
canvas.width = outW;
|
|
53
|
+
canvas.height = outH;
|
|
54
|
+
const ctx = canvas.getContext("2d");
|
|
55
|
+
if (!ctx) {
|
|
56
|
+
throw new Error(
|
|
57
|
+
"Could not obtain a 2D context for the export canvas."
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
const camera = (0, import_camera.createExportCamera)(state, imageSize, {
|
|
61
|
+
width: outW,
|
|
62
|
+
height: outH
|
|
63
|
+
});
|
|
64
|
+
ctx.setTransform(
|
|
65
|
+
camera[0],
|
|
66
|
+
camera[1],
|
|
67
|
+
camera[2],
|
|
68
|
+
camera[3],
|
|
69
|
+
camera[4],
|
|
70
|
+
camera[5]
|
|
71
|
+
);
|
|
72
|
+
ctx.drawImage(image, 0, 0);
|
|
73
|
+
return canvas;
|
|
74
|
+
}
|
|
75
|
+
function canvasToBlob(canvas, mimeType = "image/png", quality = DEFAULT_QUALITY) {
|
|
76
|
+
return new Promise((resolve, reject) => {
|
|
77
|
+
canvas.toBlob(
|
|
78
|
+
(blob) => {
|
|
79
|
+
if (blob) {
|
|
80
|
+
resolve(blob);
|
|
81
|
+
} else {
|
|
82
|
+
reject(new Error("Canvas toBlob returned null."));
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
mimeType,
|
|
86
|
+
quality
|
|
87
|
+
);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function canvasToDataURL(canvas, mimeType = "image/png", quality = DEFAULT_QUALITY) {
|
|
91
|
+
return canvas.toDataURL(mimeType, quality);
|
|
92
|
+
}
|
|
93
|
+
async function exportCroppedImage(src, state, mimeType = "image/png", quality = DEFAULT_QUALITY) {
|
|
94
|
+
const image = await loadImage(src);
|
|
95
|
+
const canvas = renderToCanvas(image, state);
|
|
96
|
+
return canvasToBlob(canvas, mimeType, quality);
|
|
97
|
+
}
|
|
98
|
+
function applyToCanvas(source, sourceSize, state, outputSize) {
|
|
99
|
+
const snapRotation = Math.round(state.rotation / 90) * 90;
|
|
100
|
+
const rotBBox = (0, import_camera.getRotatedBBox)(
|
|
101
|
+
sourceSize.width,
|
|
102
|
+
sourceSize.height,
|
|
103
|
+
snapRotation
|
|
104
|
+
);
|
|
105
|
+
const outW = outputSize?.width ?? Math.round(state.cropRect.width * rotBBox.width);
|
|
106
|
+
const outH = outputSize?.height ?? Math.round(state.cropRect.height * rotBBox.height);
|
|
107
|
+
const canvas = document.createElement("canvas");
|
|
108
|
+
canvas.width = outW;
|
|
109
|
+
canvas.height = outH;
|
|
110
|
+
const ctx = canvas.getContext("2d");
|
|
111
|
+
if (!ctx) {
|
|
112
|
+
throw new Error(
|
|
113
|
+
"Could not obtain a 2D context for the export canvas."
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
const camera = (0, import_camera.createExportCamera)(state, sourceSize, {
|
|
117
|
+
width: outW,
|
|
118
|
+
height: outH
|
|
119
|
+
});
|
|
120
|
+
ctx.setTransform(
|
|
121
|
+
camera[0],
|
|
122
|
+
camera[1],
|
|
123
|
+
camera[2],
|
|
124
|
+
camera[3],
|
|
125
|
+
camera[4],
|
|
126
|
+
camera[5]
|
|
127
|
+
);
|
|
128
|
+
ctx.drawImage(source, 0, 0);
|
|
129
|
+
return canvas;
|
|
130
|
+
}
|
|
131
|
+
async function downloadCroppedImage(src, state, filename = "cropped-image", mimeType = "image/png", quality = DEFAULT_QUALITY) {
|
|
132
|
+
const blob = await exportCroppedImage(src, state, mimeType, quality);
|
|
133
|
+
const ext = mimeType.split("/")[1] ?? "png";
|
|
134
|
+
const url = URL.createObjectURL(blob);
|
|
135
|
+
const a = document.createElement("a");
|
|
136
|
+
a.href = url;
|
|
137
|
+
a.download = `${filename}.${ext}`;
|
|
138
|
+
a.click();
|
|
139
|
+
URL.revokeObjectURL(url);
|
|
140
|
+
}
|
|
141
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
142
|
+
0 && (module.exports = {
|
|
143
|
+
applyToCanvas,
|
|
144
|
+
canvasToBlob,
|
|
145
|
+
canvasToDataURL,
|
|
146
|
+
downloadCroppedImage,
|
|
147
|
+
exportCroppedImage,
|
|
148
|
+
loadImage,
|
|
149
|
+
renderToCanvas
|
|
150
|
+
});
|
|
151
|
+
//# sourceMappingURL=canvas-renderer.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/image-editor/core/export/canvas-renderer.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { CropperState } from '../types';\nimport { createExportCamera, getRotatedBBox } from '../camera';\n\n/** Default export quality for lossy formats (JPEG, WebP). */\nconst DEFAULT_QUALITY = 0.92;\n\n/**\n * Load an image from a URL with CORS support.\n *\n * @param src - The image URL to load.\n * @return A promise that resolves to the loaded HTMLImageElement.\n */\nexport function loadImage( src: string ): Promise< HTMLImageElement > {\n\treturn new Promise( ( resolve, reject ) => {\n\t\tconst image = new Image();\n\t\timage.addEventListener( 'load', () => resolve( image ) );\n\t\timage.addEventListener( 'error', ( error ) => reject( error ) );\n\t\timage.crossOrigin = 'anonymous';\n\t\timage.src = src;\n\t} );\n}\n\n/**\n * Apply rectangular crop, rotation, and flip transforms to produce a canvas.\n *\n * Uses createExportCamera to compose the full transform matrix, then applies\n * it in a single ctx.setTransform call before drawing the image.\n *\n * @param image - The source image element.\n * @param state - The full cropper state containing crop, rotation, and flip settings.\n * @return A canvas element containing the transformed and cropped image.\n */\nexport function renderToCanvas(\n\timage: HTMLImageElement,\n\tstate: CropperState\n): HTMLCanvasElement {\n\tconst { naturalWidth, naturalHeight } = image;\n\tconst { rotation, cropRect } = state;\n\tconst imageSize = { width: naturalWidth, height: naturalHeight };\n\n\t// Output size is the crop region in the snap-rotation bbox \u2014 matches\n\t// the preview's reference frame so the exported pixels track exactly\n\t// what the stencil framed, even at fine rotation angles.\n\tconst snapRotation = Math.round( rotation / 90 ) * 90;\n\tconst rotBBox = getRotatedBBox( naturalWidth, naturalHeight, snapRotation );\n\tconst outW = Math.round( cropRect.width * rotBBox.width );\n\tconst outH = Math.round( cropRect.height * rotBBox.height );\n\n\tconst canvas = document.createElement( 'canvas' );\n\tcanvas.width = outW;\n\tcanvas.height = outH;\n\tconst ctx = canvas.getContext( '2d' );\n\tif ( ! ctx ) {\n\t\tthrow new Error(\n\t\t\t'Could not obtain a 2D context for the export canvas.'\n\t\t);\n\t}\n\n\tconst camera = createExportCamera( state, imageSize, {\n\t\twidth: outW,\n\t\theight: outH,\n\t} );\n\tctx.setTransform(\n\t\tcamera[ 0 ],\n\t\tcamera[ 1 ],\n\t\tcamera[ 2 ],\n\t\tcamera[ 3 ],\n\t\tcamera[ 4 ],\n\t\tcamera[ 5 ]\n\t);\n\tctx.drawImage( image, 0, 0 );\n\treturn canvas;\n}\n\n/**\n * Convert a canvas to a Blob with configurable MIME type and quality.\n *\n * @param canvas - The canvas to export.\n * @param mimeType - The output MIME type. Defaults to 'image/png'.\n * @param quality - The quality parameter for lossy formats (0-1). Defaults to DEFAULT_QUALITY.\n * @return A promise that resolves to the canvas content as a Blob.\n */\nexport function canvasToBlob(\n\tcanvas: HTMLCanvasElement,\n\tmimeType: string = 'image/png',\n\tquality: number = DEFAULT_QUALITY\n): Promise< Blob > {\n\treturn new Promise( ( resolve, reject ) => {\n\t\tcanvas.toBlob(\n\t\t\t( blob ) => {\n\t\t\t\tif ( blob ) {\n\t\t\t\t\tresolve( blob );\n\t\t\t\t} else {\n\t\t\t\t\treject( new Error( 'Canvas toBlob returned null.' ) );\n\t\t\t\t}\n\t\t\t},\n\t\t\tmimeType,\n\t\t\tquality\n\t\t);\n\t} );\n}\n\n/**\n * Convert a canvas to a data URL string.\n *\n * @param canvas - The canvas to export.\n * @param mimeType - The output MIME type. Defaults to 'image/png'.\n * @param quality - The quality parameter for lossy formats (0-1). Defaults to DEFAULT_QUALITY.\n * @return The canvas content as a data URL string.\n */\nexport function canvasToDataURL(\n\tcanvas: HTMLCanvasElement,\n\tmimeType: string = 'image/png',\n\tquality: number = DEFAULT_QUALITY\n): string {\n\treturn canvas.toDataURL( mimeType, quality );\n}\n\n/**\n * Load an image, render with transforms, and export as a Blob.\n *\n * Throws on failure so callers can distinguish error cases:\n * - Image load failures (network errors, 404s) throw the native\n * load error from the Image element.\n * - Cross-origin failures manifest as tainted-canvas errors from\n * `canvas.toBlob()` \u2014 the browser rejects reading pixel data\n * from a canvas that drew an image without valid CORS headers.\n * Ensure the source server sets `Access-Control-Allow-Origin`.\n * - Canvas context creation failures throw a descriptive Error.\n *\n * Only works in browser environments (needs DOM / HTMLCanvasElement).\n *\n * @param src - The image URL to load.\n * @param state - The cropper state with all transform settings.\n * @param mimeType - The output MIME type. Defaults to 'image/png'.\n * @param quality - The quality parameter for lossy formats (0-1). Defaults to DEFAULT_QUALITY.\n * @return A promise that resolves to the exported Blob.\n * @throws If the image fails to load, canvas creation fails, or\n * the resulting canvas is tainted by CORS restrictions.\n */\nexport async function exportCroppedImage(\n\tsrc: string,\n\tstate: CropperState,\n\tmimeType: string = 'image/png',\n\tquality: number = DEFAULT_QUALITY\n): Promise< Blob > {\n\tconst image = await loadImage( src );\n\tconst canvas = renderToCanvas( image, state );\n\treturn canvasToBlob( canvas, mimeType, quality );\n}\n\n/**\n * Apply the cropper's transform (crop, rotation, flip, zoom) to an existing\n * canvas or image source. This is the bridge for multi-step editing pipelines\n * where an upstream tool (e.g., brightness/color adjustment) has already\n * processed the image and you want to apply the crop on top.\n *\n * Accepts any CanvasImageSource: HTMLImageElement, HTMLCanvasElement,\n * OffscreenCanvas, ImageBitmap, HTMLVideoElement, etc.\n *\n * @param source - The image source to crop/transform.\n * @param sourceSize - The dimensions of the source (natural width/height).\n * @param sourceSize.width - The width of the source in pixels.\n * @param sourceSize.height - The height of the source in pixels.\n * @param state - The cropper state with all transform settings.\n * @param outputSize - Optional output size. Defaults to the crop region's natural pixel size.\n * @param outputSize.width - The width of the output in pixels.\n * @param outputSize.height - The height of the output in pixels.\n * @return A canvas with the transforms applied.\n */\nexport function applyToCanvas(\n\tsource: CanvasImageSource,\n\tsourceSize: { width: number; height: number },\n\tstate: CropperState,\n\toutputSize?: { width: number; height: number }\n): HTMLCanvasElement {\n\t// Use snap-rotation bbox for default sizing so the default output\n\t// matches the preview's reference frame at fine rotation angles\n\t// (see renderToCanvas / createExportCamera).\n\tconst snapRotation = Math.round( state.rotation / 90 ) * 90;\n\tconst rotBBox = getRotatedBBox(\n\t\tsourceSize.width,\n\t\tsourceSize.height,\n\t\tsnapRotation\n\t);\n\n\t// Default output size: the crop region in natural pixels.\n\tconst outW =\n\t\toutputSize?.width ?? Math.round( state.cropRect.width * rotBBox.width );\n\tconst outH =\n\t\toutputSize?.height ??\n\t\tMath.round( state.cropRect.height * rotBBox.height );\n\n\tconst canvas = document.createElement( 'canvas' );\n\tcanvas.width = outW;\n\tcanvas.height = outH;\n\tconst ctx = canvas.getContext( '2d' );\n\tif ( ! ctx ) {\n\t\tthrow new Error(\n\t\t\t'Could not obtain a 2D context for the export canvas.'\n\t\t);\n\t}\n\n\tconst camera = createExportCamera( state, sourceSize, {\n\t\twidth: outW,\n\t\theight: outH,\n\t} );\n\tctx.setTransform(\n\t\tcamera[ 0 ],\n\t\tcamera[ 1 ],\n\t\tcamera[ 2 ],\n\t\tcamera[ 3 ],\n\t\tcamera[ 4 ],\n\t\tcamera[ 5 ]\n\t);\n\tctx.drawImage( source, 0, 0 );\n\treturn canvas;\n}\n\n/**\n * Download the cropped image as a file.\n *\n * Loads the source image, applies all transforms, and triggers a\n * browser download via exportCroppedImage() + object URL + anchor click.\n *\n * Throws on export failure (see `exportCroppedImage`).\n *\n * @param src - The image URL to load.\n * @param state - The cropper state with all transform settings.\n * @param filename - The download filename. Defaults to 'cropped-image'.\n * @param mimeType - The output MIME type. Defaults to 'image/png'.\n * @param quality - The quality parameter for lossy formats (0-1). Defaults to DEFAULT_QUALITY.\n * @return A promise that resolves when the download is triggered.\n */\nexport async function downloadCroppedImage(\n\tsrc: string,\n\tstate: CropperState,\n\tfilename: string = 'cropped-image',\n\tmimeType: string = 'image/png',\n\tquality: number = DEFAULT_QUALITY\n): Promise< void > {\n\tconst blob = await exportCroppedImage( src, state, mimeType, quality );\n\tconst ext = mimeType.split( '/' )[ 1 ] ?? 'png';\n\tconst url = URL.createObjectURL( blob );\n\tconst a = document.createElement( 'a' );\n\ta.href = url;\n\ta.download = `${ filename }.${ ext }`;\n\ta.click();\n\tURL.revokeObjectURL( url );\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,oBAAmD;AAGnD,IAAM,kBAAkB;AAQjB,SAAS,UAAW,KAA2C;AACrE,SAAO,IAAI,QAAS,CAAE,SAAS,WAAY;AAC1C,UAAM,QAAQ,IAAI,MAAM;AACxB,UAAM,iBAAkB,QAAQ,MAAM,QAAS,KAAM,CAAE;AACvD,UAAM,iBAAkB,SAAS,CAAE,UAAW,OAAQ,KAAM,CAAE;AAC9D,UAAM,cAAc;AACpB,UAAM,MAAM;AAAA,EACb,CAAE;AACH;AAYO,SAAS,eACf,OACA,OACoB;AACpB,QAAM,EAAE,cAAc,cAAc,IAAI;AACxC,QAAM,EAAE,UAAU,SAAS,IAAI;AAC/B,QAAM,YAAY,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AAI;AAC1B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
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/index.ts
|
|
21
|
+
var core_exports = {};
|
|
22
|
+
__export(core_exports, {
|
|
23
|
+
DEFAULT_ASPECT_RATIOS: () => import_constants.DEFAULT_ASPECT_RATIOS,
|
|
24
|
+
DEFAULT_STATE: () => import_constants.DEFAULT_STATE,
|
|
25
|
+
ORIGINAL_ASPECT_RATIO: () => import_constants.ORIGINAL_ASPECT_RATIO,
|
|
26
|
+
applyOperationToState: () => import_pipeline.applyOperationToState,
|
|
27
|
+
applyToCanvas: () => import_canvas_renderer.applyToCanvas,
|
|
28
|
+
exportCroppedImage: () => import_canvas_renderer.exportCroppedImage,
|
|
29
|
+
getSourceRegion: () => import_source_region.getSourceRegion,
|
|
30
|
+
getSourceRegionPercent: () => import_source_region.getSourceRegionPercent,
|
|
31
|
+
stateFromPipeline: () => import_pipeline.stateFromPipeline
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(core_exports);
|
|
34
|
+
var import_constants = require("./constants.cjs");
|
|
35
|
+
var import_source_region = require("./source-region.cjs");
|
|
36
|
+
var import_pipeline = require("./transforms/pipeline.cjs");
|
|
37
|
+
var import_canvas_renderer = require("./export/canvas-renderer.cjs");
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
DEFAULT_ASPECT_RATIOS,
|
|
41
|
+
DEFAULT_STATE,
|
|
42
|
+
ORIGINAL_ASPECT_RATIO,
|
|
43
|
+
applyOperationToState,
|
|
44
|
+
applyToCanvas,
|
|
45
|
+
exportCroppedImage,
|
|
46
|
+
getSourceRegion,
|
|
47
|
+
getSourceRegionPercent,
|
|
48
|
+
stateFromPipeline
|
|
49
|
+
});
|
|
50
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/image-editor/core/index.ts"],
|
|
4
|
+
"sourcesContent": ["// Types\nexport type {\n\tCropperState,\n\tTransformOperation,\n\tNormalizedPoint,\n\tNormalizedRect,\n\tSize,\n\tFlip,\n\tStencilProps,\n} from './types';\n// Note: `CropperAction` is intentionally not exported. The reducer's\n// action shape is an internal detail; consumers drive state through\n// the named setters on `UseCropperStateReturn` (setPan, setZoom, etc.).\n// This keeps the public API stable as the reducer evolves.\n\n// Constants\nexport {\n\tDEFAULT_STATE,\n\tDEFAULT_ASPECT_RATIOS,\n\tORIGINAL_ASPECT_RATIO,\n} from './constants';\nexport type { AspectRatioPreset } from './constants';\n\n// Source region (pixel and percentage)\nexport { getSourceRegion, getSourceRegionPercent } from './source-region';\nexport type { SourceRegion, SourceRegionPercent } from './source-region';\n\n// Pipeline\nexport {\n\tapplyOperationToState,\n\tstateFromPipeline,\n} from './transforms/pipeline';\n\n// Export / canvas\nexport { exportCroppedImage, applyToCanvas } from './export/canvas-renderer';\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBA,uBAIO;AAIP,2BAAwD;AAIxD,sBAGO;AAGP,6BAAkD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|