@bensitu/image-editor 1.5.1 → 2.0.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/README.md +370 -466
- package/dist/cjs/index.cjs +5422 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/esm/animation/animation-queue.js +67 -0
- package/dist/esm/animation/animation-queue.js.map +1 -0
- package/dist/esm/core/callback-reporter.js +23 -0
- package/dist/esm/core/callback-reporter.js.map +1 -0
- package/dist/esm/core/default-options.js +322 -0
- package/dist/esm/core/default-options.js.map +1 -0
- package/dist/esm/core/errors.js +156 -0
- package/dist/esm/core/errors.js.map +1 -0
- package/dist/esm/core/operation-guard.js +129 -0
- package/dist/esm/core/operation-guard.js.map +1 -0
- package/dist/esm/core/public-types.js +4 -0
- package/dist/esm/core/public-types.js.map +1 -0
- package/dist/esm/core/state-serializer.js +251 -0
- package/dist/esm/core/state-serializer.js.map +1 -0
- package/dist/esm/crop/crop-controller.js +403 -0
- package/dist/esm/crop/crop-controller.js.map +1 -0
- package/dist/esm/export/export-format.js +53 -0
- package/dist/esm/export/export-format.js.map +1 -0
- package/dist/esm/export/export-service.js +596 -0
- package/dist/esm/export/export-service.js.map +1 -0
- package/dist/esm/fabric/fabric-adapter.js +37 -0
- package/dist/esm/fabric/fabric-adapter.js.map +1 -0
- package/dist/esm/fabric/fabric-animation.js +37 -0
- package/dist/esm/fabric/fabric-animation.js.map +1 -0
- package/dist/esm/history/command.js +2 -0
- package/dist/esm/history/command.js.map +1 -0
- package/dist/esm/history/history-manager.js +103 -0
- package/dist/esm/history/history-manager.js.map +1 -0
- package/dist/esm/image/image-loader.js +245 -0
- package/dist/esm/image/image-loader.js.map +1 -0
- package/dist/esm/image/image-resampler.js +55 -0
- package/dist/esm/image/image-resampler.js.map +1 -0
- package/dist/esm/image/layout-manager.js +224 -0
- package/dist/esm/image/layout-manager.js.map +1 -0
- package/dist/esm/image/transform-controller.js +132 -0
- package/dist/esm/image/transform-controller.js.map +1 -0
- package/dist/esm/image-editor.js +1740 -0
- package/dist/esm/image-editor.js.map +1 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/mask/mask-factory.js +332 -0
- package/dist/esm/mask/mask-factory.js.map +1 -0
- package/dist/esm/mask/mask-label-manager.js +120 -0
- package/dist/esm/mask/mask-label-manager.js.map +1 -0
- package/dist/esm/mask/mask-list.js +47 -0
- package/dist/esm/mask/mask-list.js.map +1 -0
- package/dist/esm/mask/mask-style.js +182 -0
- package/dist/esm/mask/mask-style.js.map +1 -0
- package/dist/esm/ui/dom-bindings.js +60 -0
- package/dist/esm/ui/dom-bindings.js.map +1 -0
- package/dist/esm/ui/ui-state.js +25 -0
- package/dist/esm/ui/ui-state.js.map +1 -0
- package/dist/esm/ui/visibility-state.js +11 -0
- package/dist/esm/ui/visibility-state.js.map +1 -0
- package/dist/esm/utils/canvas-region.js +100 -0
- package/dist/esm/utils/canvas-region.js.map +1 -0
- package/dist/esm/utils/dom.js +6 -0
- package/dist/esm/utils/dom.js.map +1 -0
- package/dist/esm/utils/file.js +53 -0
- package/dist/esm/utils/file.js.map +1 -0
- package/dist/esm/utils/number.js +24 -0
- package/dist/esm/utils/number.js.map +1 -0
- package/dist/esm/utils/timeout.js +17 -0
- package/dist/esm/utils/timeout.js.map +1 -0
- package/dist/types/animation/animation-queue.d.ts +111 -0
- package/dist/types/animation/animation-queue.d.ts.map +1 -0
- package/dist/types/core/callback-reporter.d.ts +125 -0
- package/dist/types/core/callback-reporter.d.ts.map +1 -0
- package/dist/types/core/default-options.d.ts +56 -0
- package/dist/types/core/default-options.d.ts.map +1 -0
- package/dist/types/core/errors.d.ts +142 -0
- package/dist/types/core/errors.d.ts.map +1 -0
- package/dist/types/core/operation-guard.d.ts +192 -0
- package/dist/types/core/operation-guard.d.ts.map +1 -0
- package/dist/types/core/public-types.d.ts +678 -0
- package/dist/types/core/public-types.d.ts.map +1 -0
- package/dist/types/core/state-serializer.d.ts +301 -0
- package/dist/types/core/state-serializer.d.ts.map +1 -0
- package/dist/types/crop/crop-controller.d.ts +407 -0
- package/dist/types/crop/crop-controller.d.ts.map +1 -0
- package/dist/types/export/export-format.d.ts +136 -0
- package/dist/types/export/export-format.d.ts.map +1 -0
- package/dist/types/export/export-service.d.ts +333 -0
- package/dist/types/export/export-service.d.ts.map +1 -0
- package/dist/types/fabric/fabric-adapter.d.ts +74 -0
- package/dist/types/fabric/fabric-adapter.d.ts.map +1 -0
- package/dist/types/fabric/fabric-animation.d.ts +141 -0
- package/dist/types/fabric/fabric-animation.d.ts.map +1 -0
- package/dist/types/history/command.d.ts +16 -0
- package/dist/types/history/command.d.ts.map +1 -0
- package/dist/types/history/history-manager.d.ts +129 -0
- package/dist/types/history/history-manager.d.ts.map +1 -0
- package/dist/types/image/image-loader.d.ts +265 -0
- package/dist/types/image/image-loader.d.ts.map +1 -0
- package/dist/types/image/image-resampler.d.ts +139 -0
- package/dist/types/image/image-resampler.d.ts.map +1 -0
- package/dist/types/image/layout-manager.d.ts +255 -0
- package/dist/types/image/layout-manager.d.ts.map +1 -0
- package/dist/types/image/transform-controller.d.ts +287 -0
- package/dist/types/image/transform-controller.d.ts.map +1 -0
- package/dist/types/image-editor.d.ts +650 -0
- package/dist/types/image-editor.d.ts.map +1 -0
- package/dist/types/index.d.cts +31 -0
- package/dist/types/index.d.cts.map +1 -0
- package/dist/types/index.d.ts +31 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/mask/mask-factory.d.ts +209 -0
- package/dist/types/mask/mask-factory.d.ts.map +1 -0
- package/dist/types/mask/mask-label-manager.d.ts +171 -0
- package/dist/types/mask/mask-label-manager.d.ts.map +1 -0
- package/dist/types/mask/mask-list.d.ts +144 -0
- package/dist/types/mask/mask-list.d.ts.map +1 -0
- package/dist/types/mask/mask-style.d.ts +338 -0
- package/dist/types/mask/mask-style.d.ts.map +1 -0
- package/dist/types/ui/dom-bindings.d.ts +103 -0
- package/dist/types/ui/dom-bindings.d.ts.map +1 -0
- package/dist/types/ui/ui-state.d.ts +112 -0
- package/dist/types/ui/ui-state.d.ts.map +1 -0
- package/dist/types/ui/visibility-state.d.ts +77 -0
- package/dist/types/ui/visibility-state.d.ts.map +1 -0
- package/dist/types/utils/canvas-region.d.ts +177 -0
- package/dist/types/utils/canvas-region.d.ts.map +1 -0
- package/dist/types/utils/dom.d.ts +26 -0
- package/dist/types/utils/dom.d.ts.map +1 -0
- package/dist/types/utils/file.d.ts +80 -0
- package/dist/types/utils/file.d.ts.map +1 -0
- package/dist/types/utils/number.d.ts +132 -0
- package/dist/types/utils/number.d.ts.map +1 -0
- package/dist/types/utils/timeout.d.ts +84 -0
- package/dist/types/utils/timeout.d.ts.map +1 -0
- package/dist/umd/image-editor.umd.js +2 -0
- package/dist/umd/image-editor.umd.js.map +1 -0
- package/package.json +72 -66
- package/dist/image-editor.cjs +0 -4185
- package/dist/image-editor.cjs.map +0 -7
- package/dist/image-editor.esm.js +0 -4154
- package/dist/image-editor.esm.js.map +0 -7
- package/dist/image-editor.esm.min.js +0 -9
- package/dist/image-editor.esm.min.js.map +0 -7
- package/dist/image-editor.esm.min.mjs +0 -9
- package/dist/image-editor.esm.min.mjs.map +0 -7
- package/dist/image-editor.esm.mjs +0 -4154
- package/dist/image-editor.esm.mjs.map +0 -7
- package/dist/image-editor.js +0 -4151
- package/dist/image-editor.js.map +0 -7
- package/dist/image-editor.min.js +0 -9
- package/dist/image-editor.min.js.map +0 -7
- package/image-editor.d.ts +0 -269
- package/src/browser.js +0 -11
- package/src/esm.js +0 -9
- package/src/image-editor.js +0 -4775
|
@@ -0,0 +1,650 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author Ben Situ
|
|
3
|
+
* @license MIT
|
|
4
|
+
* Lightweight canvas-based image editor built on Fabric.js v7.
|
|
5
|
+
* Provides masking, animated scale/rotate, crop, undo/redo, and export.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import { type CanvasJson } from './core/state-serializer.js';
|
|
10
|
+
import type { Base64ExportOptions, ElementIdMap, FabricModule, ImageEditorOptions, ImageFileExportOptions, LayoutMode, LoadImageOptions, MaskConfig, MaskObject, RemoveAllMasksOptions } from './core/public-types.js';
|
|
11
|
+
/**
|
|
12
|
+
* Lightweight Fabric.js v7 image editor with masking, animated transforms,
|
|
13
|
+
* crop, undo/redo, and multi-format export.
|
|
14
|
+
*
|
|
15
|
+
* ## Quick start (ESM)
|
|
16
|
+
* ```ts
|
|
17
|
+
* import * as fabric from 'fabric';
|
|
18
|
+
* import { ImageEditor } from '@bensitu/image-editor';
|
|
19
|
+
*
|
|
20
|
+
* const editor = new ImageEditor(fabric, { canvasWidth: 1024, canvasHeight: 768 });
|
|
21
|
+
* editor.init({ canvas: 'myCanvas' });
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* ## Quick start (CDN / `<script>` tag)
|
|
25
|
+
* ```ts
|
|
26
|
+
* // Assumes window.fabric is populated by a Fabric.js CDN script
|
|
27
|
+
* const editor = new ImageEditor({ canvasWidth: 1024 });
|
|
28
|
+
* editor.init();
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare class ImageEditor {
|
|
32
|
+
private fabricModule;
|
|
33
|
+
private isFabricLoaded;
|
|
34
|
+
private readonly options;
|
|
35
|
+
private canvas;
|
|
36
|
+
private canvasElement;
|
|
37
|
+
private containerElement;
|
|
38
|
+
private placeholderElement;
|
|
39
|
+
private elements;
|
|
40
|
+
private readonly elementOriginalDisabledMap;
|
|
41
|
+
private readonly elementOriginalAriaDisabledMap;
|
|
42
|
+
private readonly elementOriginalPointerEventsMap;
|
|
43
|
+
private originalImage;
|
|
44
|
+
private baseImageScale;
|
|
45
|
+
private currentScale;
|
|
46
|
+
private currentRotation;
|
|
47
|
+
private isImageLoadedToCanvas;
|
|
48
|
+
private currentImageMimeType;
|
|
49
|
+
private maskCounter;
|
|
50
|
+
private lastMask;
|
|
51
|
+
private lastSnapshot;
|
|
52
|
+
private readonly historyManager;
|
|
53
|
+
/**
|
|
54
|
+
* Single source of truth for `isAnimating` and `isDisposed` flags
|
|
55
|
+
* shared between the facade, the transform controller, and the
|
|
56
|
+
* Fabric animation wrapper. The transform controller calls
|
|
57
|
+
* `runAnimation` to bracket each Fabric tween so the flag is
|
|
58
|
+
* cleared inside a `finally`; the facade reads
|
|
59
|
+
* `isAnimating` for the per-method guard rejections; and the
|
|
60
|
+
* dispose path forwards to
|
|
61
|
+
* `markDisposed` so in-flight animation callbacks short-circuit.
|
|
62
|
+
*/
|
|
63
|
+
private readonly operationGuard;
|
|
64
|
+
private readonly animQueue;
|
|
65
|
+
/**
|
|
66
|
+
* Owns animated `scaleImage`, `rotateImage`, and
|
|
67
|
+
* `resetImageTransform`. The facade enqueues each public method on
|
|
68
|
+
* {@link animQueue} and the controller drives
|
|
69
|
+
* the per-Fabric-animation `runAnimation` bracket through
|
|
70
|
+
* {@link operationGuard}. The controller is constructed in {@link init}
|
|
71
|
+
* once `canvas` is available so its `TransformContext` can hold a
|
|
72
|
+
* stable Fabric canvas reference.
|
|
73
|
+
*/
|
|
74
|
+
private transformController;
|
|
75
|
+
/**
|
|
76
|
+
* Hidden-container viewport cache shared across `loadImage` calls. Owned
|
|
77
|
+
* by the facade so the layout manager can reuse the last visible
|
|
78
|
+
* measurement when the editor is hidden inside a tab, modal, or
|
|
79
|
+
* accordion.
|
|
80
|
+
*/
|
|
81
|
+
private readonly viewportCache;
|
|
82
|
+
/**
|
|
83
|
+
* Live crop session pointer owned by the facade. The crop controller
|
|
84
|
+
* (`crop/crop-controller.ts`) reads and writes this slot through the
|
|
85
|
+
* `getCropSession`/`setCropSession` callbacks bundled into the
|
|
86
|
+
* controller's context, so the controller has no class state of its
|
|
87
|
+
* own and multiple editors on the same page do not share crop state.
|
|
88
|
+
*/
|
|
89
|
+
private cropSession;
|
|
90
|
+
/**
|
|
91
|
+
* Managed registry of DOM event listeners owned by this editor.
|
|
92
|
+
*
|
|
93
|
+
* Constructed lazily by {@link init} so the registry can read the
|
|
94
|
+
* editor's `isDisposed` flag through a closure that captures `this`.
|
|
95
|
+
* `dispose` drains the registry via {@link DomBindings.removeAll}
|
|
96
|
+
* and the wrapped handlers exit early while
|
|
97
|
+
* `isDisposed === true`.
|
|
98
|
+
*/
|
|
99
|
+
private domBindings;
|
|
100
|
+
private isDisposed;
|
|
101
|
+
/**
|
|
102
|
+
* When `true`, {@link saveState} is a no-op. Used by
|
|
103
|
+
* {@link resetImageTransform} (via the transform controller) to
|
|
104
|
+
* suppress the intermediate history entries from {@link scaleImage}
|
|
105
|
+
* and {@link rotateImage} so the entire reset is a single undoable
|
|
106
|
+
* step.
|
|
107
|
+
*/
|
|
108
|
+
private shouldSuppressSaveState;
|
|
109
|
+
private lastEmittedIsBusy;
|
|
110
|
+
private activeStateRestoreOperation;
|
|
111
|
+
private nextSelectionChangeContext;
|
|
112
|
+
/**
|
|
113
|
+
* Creates a new image editor instance.
|
|
114
|
+
*
|
|
115
|
+
* The constructor accepts two argument shapes so the same source ships
|
|
116
|
+
* to both ESM and UMD consumers:
|
|
117
|
+
*
|
|
118
|
+
* - **ESM form** — `new ImageEditor(fabric, options?)`. The first
|
|
119
|
+
* argument is the imported Fabric.js v7 module
|
|
120
|
+
* (`import * as fabric from 'fabric'`).
|
|
121
|
+
* - **UMD / CDN form** — `new ImageEditor(options?)`. The Fabric module
|
|
122
|
+
* is read from `globalThis.fabric` and the first argument is treated
|
|
123
|
+
* as `ImageEditorOptions`.
|
|
124
|
+
*
|
|
125
|
+
* Detection is delegated to `fabric/fabric-adapter.ts`. When neither
|
|
126
|
+
* form yields a usable Fabric module, the adapter logs a single
|
|
127
|
+
* descriptive `console.error` and the constructor returns a degraded
|
|
128
|
+
* instance whose `init` and `loadImage` calls become no-ops
|
|
129
|
+
* resolving to `undefined`.
|
|
130
|
+
*
|
|
131
|
+
* Options are normalized through `core/default-options.ts#resolveOptions`,
|
|
132
|
+
* which deep-merges nested `label`/`crop` configs with the documented
|
|
133
|
+
* defaults, drops unknown keys, and freezes the nested references so
|
|
134
|
+
* post-construction mutation cannot affect the live editor
|
|
135
|
+
* The resolved options object is held on the
|
|
136
|
+
* instance as an internal facade field; nothing on the public surface
|
|
137
|
+
* exposes it directly.
|
|
138
|
+
*
|
|
139
|
+
* @param fabricModuleOrOptions - Fabric.js module (ESM) or options (UMD).
|
|
140
|
+
* @param options - Editor options when the first argument
|
|
141
|
+
* is the Fabric module. Ignored otherwise.
|
|
142
|
+
*/
|
|
143
|
+
constructor(fabricModuleOrOptions?: FabricModule | ImageEditorOptions, options?: ImageEditorOptions);
|
|
144
|
+
/**
|
|
145
|
+
* Initializes the editor: connects to DOM elements, wires events,
|
|
146
|
+
* and optionally loads the `initialImageBase64` from options.
|
|
147
|
+
*
|
|
148
|
+
* Must be called once before any other method is used.
|
|
149
|
+
*
|
|
150
|
+
* @param idMap - Optional mapping from logical names to DOM element IDs.
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```ts
|
|
154
|
+
* editor.init({ canvas: 'myCanvas', downloadImageButton: 'dlBtn'});
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
init(idMap?: ElementIdMap): void;
|
|
158
|
+
private initCanvas;
|
|
159
|
+
private bindDomEvents;
|
|
160
|
+
private bindElementIfExists;
|
|
161
|
+
/**
|
|
162
|
+
* Read a `File` selected via the upload control as a base64 data URL
|
|
163
|
+
* and route it through the transactional `loadImage` pipeline.
|
|
164
|
+
*
|
|
165
|
+
* Routes through `utils/file.ts` so MIME inference (including the
|
|
166
|
+
* empty-`file.type` extension fallback), `FileReader` plumbing, and
|
|
167
|
+
* input reset live in one place. The input is reset on both success
|
|
168
|
+
* and failure so re-selecting the same file fires a fresh `change`
|
|
169
|
+
* event.
|
|
170
|
+
*/
|
|
171
|
+
private loadImageFile;
|
|
172
|
+
/**
|
|
173
|
+
* Loads a Base64-encoded image data URL onto the canvas.
|
|
174
|
+
*
|
|
175
|
+
* The transactional pipeline lives in `image/image-loader.ts`; this
|
|
176
|
+
* facade method delegates to it so all rollback, downsample, layout,
|
|
177
|
+
* and `onImageLoaded` ordering rules are owned in one place.
|
|
178
|
+
*
|
|
179
|
+
* Pipeline contract preserved end-to-end:
|
|
180
|
+
*
|
|
181
|
+
* - Non-`data:image/` strings resolve without mutation.
|
|
182
|
+
* - On a valid data URL, the loader captures a rollback bundle BEFORE
|
|
183
|
+
* the first mutation. Decode, downsample, Fabric, timeout, or layout
|
|
184
|
+
* failures replay the bundle and reject with the original error.
|
|
185
|
+
* - On commit, the loader sets `originalImage`, `currentScale = 1`,
|
|
186
|
+
* `currentRotation = 0`, `baseImageScale`, `maskCounter = 0`,
|
|
187
|
+
* `lastSnapshot`, and `isImageLoadedToCanvas = true`. It also
|
|
188
|
+
* honours `LoadImageOptions.preserveScroll` and invokes
|
|
189
|
+
* `onImageLoaded` exactly once after every scalar is committed.
|
|
190
|
+
*
|
|
191
|
+
* Operation guard: `loadImage` is one of the
|
|
192
|
+
* guarded operations. While `isAnimating === true` the facade rejects
|
|
193
|
+
* the call as a documented no-op so a queued scale/rotate animation
|
|
194
|
+
* cannot be torn down by a concurrent reload.
|
|
195
|
+
*
|
|
196
|
+
* @param base64 - Data URL string starting with `data:image/…`.
|
|
197
|
+
* @param options - Optional {@link LoadImageOptions}; currently only
|
|
198
|
+
* `preserveScroll` is consulted.
|
|
199
|
+
* @returns A promise that resolves once the image is on the canvas, or
|
|
200
|
+
* rejects with the original error after a transactional
|
|
201
|
+
* rollback. Non-data:image inputs and Fabric-unavailable /
|
|
202
|
+
* disposed states resolve without observable mutation.
|
|
203
|
+
*/
|
|
204
|
+
loadImage(base64: string, options?: LoadImageOptions): Promise<void>;
|
|
205
|
+
private getInternalOperationToken;
|
|
206
|
+
private canRunDuringAnimationQueue;
|
|
207
|
+
private withInternalOperationOptions;
|
|
208
|
+
private withAnimationQueueBypass;
|
|
209
|
+
private assertIdleForOperation;
|
|
210
|
+
private canRunIdleOperation;
|
|
211
|
+
private assertCanQueueAnimation;
|
|
212
|
+
/**
|
|
213
|
+
* Returns `true` if a valid image is currently loaded on the canvas.
|
|
214
|
+
*/
|
|
215
|
+
isImageLoaded(): boolean;
|
|
216
|
+
/**
|
|
217
|
+
* Returns `true` while the editor is loading, animating, or in crop mode.
|
|
218
|
+
*/
|
|
219
|
+
isBusy(): boolean;
|
|
220
|
+
/**
|
|
221
|
+
* Selects the layout strategy used by subsequent image loads.
|
|
222
|
+
*
|
|
223
|
+
* The mode maps to the existing layout flags as a mutually exclusive
|
|
224
|
+
* choice:
|
|
225
|
+
*
|
|
226
|
+
* - `'fit'` enables `fitImageToCanvas`.
|
|
227
|
+
* - `'cover'` enables `coverImageToCanvas`.
|
|
228
|
+
* - `'expand'` enables `expandCanvasToImage`.
|
|
229
|
+
*
|
|
230
|
+
* The current canvas is not re-laid out immediately; call this before
|
|
231
|
+
* `loadImage()` to choose how the next image is placed.
|
|
232
|
+
*
|
|
233
|
+
* @param mode - Layout mode to use for future image loads.
|
|
234
|
+
*/
|
|
235
|
+
setLayoutMode(mode: LayoutMode): void;
|
|
236
|
+
private buildCallbackContext;
|
|
237
|
+
private getOperationContext;
|
|
238
|
+
private emitOptionCallback;
|
|
239
|
+
private getImageInfo;
|
|
240
|
+
private getMasks;
|
|
241
|
+
private getMaskCollectionSignature;
|
|
242
|
+
private getEditorState;
|
|
243
|
+
private emitImageChanged;
|
|
244
|
+
private emitMasksChanged;
|
|
245
|
+
private emitBusyChangeIfChanged;
|
|
246
|
+
private buildSelection;
|
|
247
|
+
private withSelectionChangeContext;
|
|
248
|
+
private isSupportedImageMimeType;
|
|
249
|
+
private inferCurrentImageMimeType;
|
|
250
|
+
/**
|
|
251
|
+
* Atomically resize the Fabric canvas. Routes through
|
|
252
|
+
* {@link applyCanvasDimensions} so the canvas's lower (render) and
|
|
253
|
+
* upper (event) layers stay in sync and the surrounding container is
|
|
254
|
+
* reflowed before the next paint — matching the contract enforced
|
|
255
|
+
* across the rest of the layout pipeline (see
|
|
256
|
+
* `image/layout-manager.ts`).
|
|
257
|
+
*/
|
|
258
|
+
private setCanvasSizePx;
|
|
259
|
+
/**
|
|
260
|
+
* Re-align an object so its bounding-box top-left maps to the
|
|
261
|
+
* object's `(left, top)` reference. Used by the transform pipeline's
|
|
262
|
+
* `afterTransformSnap` hook to absorb floating-point drift on the
|
|
263
|
+
* final animation tick.
|
|
264
|
+
*/
|
|
265
|
+
private alignObjectBoundingBoxToCanvasTopLeft;
|
|
266
|
+
private measureLayoutViewport;
|
|
267
|
+
/**
|
|
268
|
+
* Resize the canvas to fit the transformed image bounds. Used by the
|
|
269
|
+
* transform pipeline's `afterTransformSnap` hook so a post-rotation/scale
|
|
270
|
+
* image that exceeds the viewport gets a real scroll range.
|
|
271
|
+
*/
|
|
272
|
+
private updateCanvasSizeToImageBounds;
|
|
273
|
+
private shouldNormalizeCanvasSizeAfterStateRestore;
|
|
274
|
+
private captureImageDisplayGeometry;
|
|
275
|
+
private restoreMergedImageDisplayGeometry;
|
|
276
|
+
/**
|
|
277
|
+
* Build the {@link TransformContext} the controller reads/writes
|
|
278
|
+
* through. The facade is the single owner of `currentScale`,
|
|
279
|
+
* `currentRotation`, `baseImageScale`, `shouldSuppressSaveState`, and
|
|
280
|
+
* the {@link OperationGuard}, so the context's accessors all bind
|
|
281
|
+
* back to `this` rather than duplicating state.
|
|
282
|
+
*
|
|
283
|
+
* The `saveCanvasState` callback delegates to {@link saveState},
|
|
284
|
+
* which already honors `shouldSuppressSaveState`. That lets
|
|
285
|
+
* {@link resetImageTransform} reuse the public scale and rotate paths
|
|
286
|
+
* while suppressing intermediate saves and emitting one final history
|
|
287
|
+
* entry.
|
|
288
|
+
*
|
|
289
|
+
* The `afterTransformSnap` hook re-runs the post-animation UI helpers:
|
|
290
|
+
* expand-to-image canvas sizing, bounding-box re-alignment, and mask
|
|
291
|
+
* label sync.
|
|
292
|
+
*
|
|
293
|
+
*/
|
|
294
|
+
private buildTransformContext;
|
|
295
|
+
/**
|
|
296
|
+
* Animates the image to the given scale factor.
|
|
297
|
+
* The factor is clamped to `[options.minScale, options.maxScale]`.
|
|
298
|
+
*
|
|
299
|
+
* Routed through the {@link animQueue} so concurrent calls are
|
|
300
|
+
* serialized. The actual animation lives
|
|
301
|
+
* in {@link TransformController.scaleImage}, which brackets the
|
|
302
|
+
* Fabric tween in {@link OperationGuard.runAnimation} so
|
|
303
|
+
* `isAnimating` is `false` before this Promise settles
|
|
304
|
+
* and calls {@link saveState} on success.
|
|
305
|
+
*
|
|
306
|
+
* @returns A promise that resolves when the animation finishes.
|
|
307
|
+
*/
|
|
308
|
+
scaleImage(factor: number): Promise<void>;
|
|
309
|
+
/**
|
|
310
|
+
* Animates the image to the given rotation angle.
|
|
311
|
+
*
|
|
312
|
+
* Routed through the {@link animQueue}.
|
|
313
|
+
* Non-finite input is a documented no-op; the controller
|
|
314
|
+
* short-circuits without modifying canvas state.
|
|
315
|
+
*
|
|
316
|
+
* @param degrees - Target rotation angle in degrees.
|
|
317
|
+
* @returns A promise that resolves when the animation finishes.
|
|
318
|
+
*/
|
|
319
|
+
rotateImage(degrees: number): Promise<void>;
|
|
320
|
+
/**
|
|
321
|
+
* Resets the image to scale `1` and rotation `0` (animated) and
|
|
322
|
+
* records exactly one history entry covering the entire reset.
|
|
323
|
+
*
|
|
324
|
+
* Routed through the {@link animQueue} so the chained
|
|
325
|
+
* `scaleImage(1)` and `rotateImage(0)` sub-animations are serialized
|
|
326
|
+
* with any other queued transform. The
|
|
327
|
+
* controller toggles `shouldSuppressSaveState` around the chain so the
|
|
328
|
+
* inner per-operation `saveState` calls collapse into a single
|
|
329
|
+
* post-reset save.
|
|
330
|
+
*
|
|
331
|
+
* @returns A promise that resolves when both sub-animations have
|
|
332
|
+
* settled and the single history entry has been recorded.
|
|
333
|
+
*/
|
|
334
|
+
resetImageTransform(): Promise<void>;
|
|
335
|
+
private refreshUiAfterQueuedAnimation;
|
|
336
|
+
/**
|
|
337
|
+
* Restores a previously serialized canvas state.
|
|
338
|
+
*
|
|
339
|
+
* Delegates the snapshot-format-aware steps (parse, canvas resize,
|
|
340
|
+
* `loadFromJSON`, position-based mask metadata restore) to
|
|
341
|
+
* {@link loadFromStateImpl} in `core/state-serializer.ts` so the
|
|
342
|
+
* facade and the merge/crop pipelines share one production path.
|
|
343
|
+
*
|
|
344
|
+
* Errors are routed through the documented `onError` callback. The
|
|
345
|
+
* promise rejects with the original error so the history manager
|
|
346
|
+
* leaves `currentIndex` untouched on a failed undo/redo restore.
|
|
347
|
+
*
|
|
348
|
+
* @param jsonString - JSON string returned by `saveState` (or parsed object).
|
|
349
|
+
*/
|
|
350
|
+
loadFromState(jsonString: string | CanvasJson): Promise<void>;
|
|
351
|
+
private loadFromStateInternal;
|
|
352
|
+
/**
|
|
353
|
+
* Captures the current canvas state into the undo/redo history.
|
|
354
|
+
* Called automatically after transforms, mask operations, and crop.
|
|
355
|
+
*/
|
|
356
|
+
saveState(): void;
|
|
357
|
+
private saveStateInternal;
|
|
358
|
+
private restoreActiveMaskAfterSnapshot;
|
|
359
|
+
/**
|
|
360
|
+
* Undoes the last recorded action.
|
|
361
|
+
*
|
|
362
|
+
* Routed through {@link animQueue} so that undo is serialized with any
|
|
363
|
+
* in-progress animation and rapid clicks cannot interleave canvas restores.
|
|
364
|
+
* The {@link HistoryManager.isProcessing} lock provides a second line of
|
|
365
|
+
* defence inside the history layer itself.
|
|
366
|
+
*
|
|
367
|
+
* After {@link dispose} the call resolves without touching the canvas.
|
|
368
|
+
* The early return covers the case where dispose has already happened;
|
|
369
|
+
* the inner check covers the case where dispose happens while waiting
|
|
370
|
+
* in the animation queue.
|
|
371
|
+
*/
|
|
372
|
+
undo(): Promise<void>;
|
|
373
|
+
/**
|
|
374
|
+
* Redoes the next recorded action.
|
|
375
|
+
*
|
|
376
|
+
* Same serialization and dispose guarantees as {@link undo}.
|
|
377
|
+
*/
|
|
378
|
+
redo(): Promise<void>;
|
|
379
|
+
/**
|
|
380
|
+
* Creates and adds a mask shape to the canvas.
|
|
381
|
+
*
|
|
382
|
+
* Delegates to {@link createMask} in `mask/mask-factory.ts`, which
|
|
383
|
+
* owns the resolved-config build, polygon bounding-box realignment,
|
|
384
|
+
* falsy-style preservation, monotonic `maskCounter` bookkeeping,
|
|
385
|
+
* and the post-create ordering contract: add to canvas → update
|
|
386
|
+
* list DOM → `setActiveObject` (when `selectable !== false`) →
|
|
387
|
+
* `saveState` → `config.onCreate(mask, canvas)`.
|
|
388
|
+
*
|
|
389
|
+
* @param config - Shape type, dimensions, position, style, and callbacks.
|
|
390
|
+
* @returns The created mask object, or `null` if the canvas is unavailable.
|
|
391
|
+
*
|
|
392
|
+
* @example
|
|
393
|
+
* ```ts
|
|
394
|
+
* // Simple rect mask
|
|
395
|
+
* editor.createMask;
|
|
396
|
+
*
|
|
397
|
+
* // Circle with custom size
|
|
398
|
+
* editor.createMask({ shape: 'circle', radius: 60, color: 'rgba(255,0,0,0.4)'});
|
|
399
|
+
*
|
|
400
|
+
* // Positioned at 20% from the left
|
|
401
|
+
* editor.createMask({ left: '20%', top: 40});
|
|
402
|
+
* ```
|
|
403
|
+
*/
|
|
404
|
+
createMask(config?: MaskConfig): MaskObject | null;
|
|
405
|
+
/**
|
|
406
|
+
* Removes the currently selected mask (and its label).
|
|
407
|
+
*
|
|
408
|
+
* Delegates to {@link removeSelectedMask} in `mask/mask-factory.ts`,
|
|
409
|
+
* which removes the active mask, clears the canvas selection,
|
|
410
|
+
* re-renders the mask list DOM, and pushes a single history entry.
|
|
411
|
+
*/
|
|
412
|
+
removeSelectedMask(): void;
|
|
413
|
+
/**
|
|
414
|
+
* Removes all masks and their labels.
|
|
415
|
+
*
|
|
416
|
+
* Delegates to {@link removeAllMasks} in `mask/mask-factory.ts`,
|
|
417
|
+
* which removes every mask and label in canvas order, clears the
|
|
418
|
+
* `lastMask` reference, re-renders the mask list
|
|
419
|
+
* DOM, and pushes a single history entry by default. Callers can
|
|
420
|
+
* pass `{ saveHistory: false}` to skip the history push — used by
|
|
421
|
+
* the merge and crop pipelines, which already record their own
|
|
422
|
+
* enclosing history entry.
|
|
423
|
+
*
|
|
424
|
+
* Operation guard: while `isAnimating === true`
|
|
425
|
+
* the call is a documented no-op so an in-flight scale/rotate
|
|
426
|
+
* animation cannot have its mask layer torn out from under it. The
|
|
427
|
+
* guard mirrors the loadImage pattern (silent no-op, no throw, no
|
|
428
|
+
* DOM mutation) so the canvas, history stack, and mask list are
|
|
429
|
+
* left untouched.
|
|
430
|
+
*/
|
|
431
|
+
removeAllMasks(options?: RemoveAllMasksOptions): void;
|
|
432
|
+
/**
|
|
433
|
+
* Build the {@link CreateMaskContext} the mask factory reads/writes
|
|
434
|
+
* through. The facade is the single owner of `maskCounter`,
|
|
435
|
+
* `lastMask`, the canvas, and `saveState`, so the context's
|
|
436
|
+
* accessors all bind back to `this` rather than duplicating state.
|
|
437
|
+
*/
|
|
438
|
+
private buildCreateMaskContext;
|
|
439
|
+
/**
|
|
440
|
+
* Build the {@link RemoveMaskContext} the mask factory reads/writes
|
|
441
|
+
* through for `removeSelectedMask` / `removeAllMasks`. The facade
|
|
442
|
+
* is the single owner of the canvas, mask label DOM, mask list
|
|
443
|
+
* DOM, history, and `lastMask`, so the context's accessors bind
|
|
444
|
+
* back to `this`.
|
|
445
|
+
*/
|
|
446
|
+
private buildRemoveMaskContext;
|
|
447
|
+
private buildMaskLabelContext;
|
|
448
|
+
private removeLabelForMask;
|
|
449
|
+
private createLabelForMask;
|
|
450
|
+
private hideAllMaskLabels;
|
|
451
|
+
private syncMaskLabel;
|
|
452
|
+
private showLabelForMask;
|
|
453
|
+
private handleSelectionChanged;
|
|
454
|
+
private buildMaskListContext;
|
|
455
|
+
private updateMaskList;
|
|
456
|
+
private updateMaskListSelection;
|
|
457
|
+
/**
|
|
458
|
+
* Bakes all current masks into the image:
|
|
459
|
+
* exports the masked image, removes the masks, and re-imports the result
|
|
460
|
+
* as the new base image.
|
|
461
|
+
*
|
|
462
|
+
* Operation guard: while `isAnimating === true`
|
|
463
|
+
* the call resolves without mutation so a queued scale/rotate
|
|
464
|
+
* animation cannot have the original image swapped out mid-flight.
|
|
465
|
+
*
|
|
466
|
+
* Delegates the merge pipeline to {@link mergeMasks} in
|
|
467
|
+
* `export/export-service.ts`, which captures the pre-merge snapshot,
|
|
468
|
+
* renders the merged bitmap via the export bake-in bracket, removes
|
|
469
|
+
* masks without history, reloads the merged image transactionally,
|
|
470
|
+
* preserves container scroll, and pushes exactly one history entry.
|
|
471
|
+
* On any failure it restores the pre-merge snapshot and rejects with
|
|
472
|
+
* `MergeMasksError`.
|
|
473
|
+
*
|
|
474
|
+
* @returns A promise that resolves when the merge is complete.
|
|
475
|
+
*/
|
|
476
|
+
mergeMasks(): Promise<void>;
|
|
477
|
+
/**
|
|
478
|
+
* Triggers a browser download of the current canvas.
|
|
479
|
+
*
|
|
480
|
+
* Operation guard: while `isAnimating === true`
|
|
481
|
+
* the call is a no-op (no DOM action, no download triggered).
|
|
482
|
+
*
|
|
483
|
+
* Delegates to {@link downloadImage} in `export/export-service.ts`,
|
|
484
|
+
* which builds the data URL through the same pipeline used by
|
|
485
|
+
* {@link exportImageBase64} and triggers the anchor-driven download.
|
|
486
|
+
*
|
|
487
|
+
* @param fileName - Filename for the downloaded file.
|
|
488
|
+
* @default `options.defaultDownloadFileName`
|
|
489
|
+
*/
|
|
490
|
+
downloadImage(fileName?: string): void;
|
|
491
|
+
/**
|
|
492
|
+
* Exports the canvas as a Base64-encoded data URL.
|
|
493
|
+
*
|
|
494
|
+
* Delegates to {@link exportImageBase64} in `export/export-service.ts`,
|
|
495
|
+
* which discards any active selection, runs the bake-in/restore
|
|
496
|
+
* bracket for image-area exports, and emits a single
|
|
497
|
+
* `canvas.toDataURL` call with the floored image-bounding-box region
|
|
498
|
+
* after temporarily baking masks into the export when requested.
|
|
499
|
+
*
|
|
500
|
+
* Operation guard: while `isAnimating === true`
|
|
501
|
+
* the call resolves to an empty string so an in-flight scale/rotate
|
|
502
|
+
* animation does not see a mid-frame export of the canvas.
|
|
503
|
+
*
|
|
504
|
+
* @param options - Export options.
|
|
505
|
+
* @returns A promise resolving to a data URL on success, or `''` when
|
|
506
|
+
* no image is loaded.
|
|
507
|
+
*/
|
|
508
|
+
exportImageBase64(options?: Base64ExportOptions): Promise<string>;
|
|
509
|
+
/**
|
|
510
|
+
* Exports the canvas as a browser `File` object.
|
|
511
|
+
*
|
|
512
|
+
* Delegates to {@link exportImageFile} in `export/export-service.ts`,
|
|
513
|
+
* which reuses the base64 pipeline, repaints through an offscreen
|
|
514
|
+
* canvas only when the resulting MIME type does not match the
|
|
515
|
+
* requested `fileType`, and resolves with a `File` whose `type`
|
|
516
|
+
* matches the requested format.
|
|
517
|
+
*
|
|
518
|
+
* Operation guard: while `isAnimating === true`
|
|
519
|
+
* the call rejects via `OperationGuard.assertNotAnimating` because
|
|
520
|
+
* `Promise<File>` has no natural no-op shape. The thrown error
|
|
521
|
+
* embeds the operation label so callers can distinguish the guard
|
|
522
|
+
* rejection from an underlying export failure.
|
|
523
|
+
*
|
|
524
|
+
* @param options - Export and file options.
|
|
525
|
+
* @returns A promise resolving to a `File`.
|
|
526
|
+
* @throws `ExportNotReadyError` when no image is loaded.
|
|
527
|
+
*
|
|
528
|
+
* @example
|
|
529
|
+
* ```ts
|
|
530
|
+
* const file = await editor.exportImageFile({ fileType: 'png', mergeMask: false});
|
|
531
|
+
* const formData = new FormData;
|
|
532
|
+
* formData.append('image', file);
|
|
533
|
+
* ```
|
|
534
|
+
*/
|
|
535
|
+
exportImageFile(options?: ImageFileExportOptions): Promise<File>;
|
|
536
|
+
/**
|
|
537
|
+
* Build the {@link ExportServiceContext} the export service reads
|
|
538
|
+
* through. The facade is the single owner of the canvas, options,
|
|
539
|
+
* and the `originalImage` reference.
|
|
540
|
+
*/
|
|
541
|
+
private buildExportServiceContext;
|
|
542
|
+
/**
|
|
543
|
+
* Build the {@link MergeMasksContext} the merge pipeline reads
|
|
544
|
+
* through. Extends the export-service context with the history
|
|
545
|
+
* manager, container element, transactional `loadImage`, and the
|
|
546
|
+
* `saveState`/`loadFromState`/`removeAllMasksNoHistory` callbacks
|
|
547
|
+
* the merge needs.
|
|
548
|
+
*/
|
|
549
|
+
private buildMergeMasksContext;
|
|
550
|
+
/**
|
|
551
|
+
* Capture a snapshot string suitable for `loadFromState` without
|
|
552
|
+
* pushing it onto the history stack. Used by the merge and crop
|
|
553
|
+
* pipelines, which manage their own enclosing history entries and
|
|
554
|
+
* need the same wire format `saveState` writes to history.
|
|
555
|
+
*
|
|
556
|
+
* Routes through `core/state-serializer.ts` so the snapshot wire
|
|
557
|
+
* format has one production path. Does NOT push a history entry
|
|
558
|
+
* and does NOT update `lastSnapshot`.
|
|
559
|
+
*/
|
|
560
|
+
private captureSnapshotInternal;
|
|
561
|
+
private getActiveMaskForSnapshot;
|
|
562
|
+
/**
|
|
563
|
+
* Enters crop mode: adds a resizable selection rect to the canvas.
|
|
564
|
+
* All other controls are disabled until {@link applyCrop} or
|
|
565
|
+
* {@link cancelCrop} is called.
|
|
566
|
+
*
|
|
567
|
+
* Operation guard: while `isAnimating === true`
|
|
568
|
+
* the call is a silent no-op; opening a crop session in the middle
|
|
569
|
+
* of a queued scale/rotate animation would otherwise allow the
|
|
570
|
+
* animation to mutate `originalImage` while a crop rect is bound to
|
|
571
|
+
* the prior coordinate system.
|
|
572
|
+
*
|
|
573
|
+
* Delegates to {@link enterCropMode} in `crop/crop-controller.ts`,
|
|
574
|
+
* which captures the pre-crop canvas snapshot, freezes every other
|
|
575
|
+
* canvas object's `evented`/`selectable`, captures per-mask style
|
|
576
|
+
* backups when `crop.hideMasksDuringCrop` is `true`, and adds the
|
|
577
|
+
* interactive crop rectangle.
|
|
578
|
+
*/
|
|
579
|
+
enterCropMode(): void;
|
|
580
|
+
/**
|
|
581
|
+
* Cancels crop mode and removes the crop rectangle without applying
|
|
582
|
+
* it.
|
|
583
|
+
*
|
|
584
|
+
* Delegates to {@link cancelCrop} in `crop/crop-controller.ts`,
|
|
585
|
+
* which restores the per-object `evented`/`selectable`, restores
|
|
586
|
+
* per-mask style backups, removes the crop rectangle, detaches
|
|
587
|
+
* every crop-bound Fabric handler, and drops the session WITHOUT
|
|
588
|
+
* pushing a history entry.
|
|
589
|
+
*/
|
|
590
|
+
cancelCrop(): void;
|
|
591
|
+
/**
|
|
592
|
+
* Applies the current crop rectangle: crops the image and reloads
|
|
593
|
+
* it. Pushes the operation onto the undo/redo history.
|
|
594
|
+
*
|
|
595
|
+
* Operation guard: while `isAnimating === true`
|
|
596
|
+
* the call resolves without mutation. The crop session is left
|
|
597
|
+
* intact so the user can retry once the queued animation settles.
|
|
598
|
+
*
|
|
599
|
+
* Delegates to {@link applyCrop} in `crop/crop-controller.ts`,
|
|
600
|
+
* which reads the crop region, optionally captures intersecting
|
|
601
|
+
* masks for `crop.preserveMasksAfterCrop`, exports the cropped
|
|
602
|
+
* region, reloads it through the transactional loader, and pushes
|
|
603
|
+
* exactly one history entry. On any failure it restores the
|
|
604
|
+
* pre-crop snapshot and rejects with `CropApplyError`.
|
|
605
|
+
*
|
|
606
|
+
* @returns A promise that resolves when the cropped image is loaded.
|
|
607
|
+
*/
|
|
608
|
+
applyCrop(): Promise<void>;
|
|
609
|
+
/**
|
|
610
|
+
* Build the {@link CropControllerContext} the crop controller reads
|
|
611
|
+
* through. The facade is the single owner of the live crop session
|
|
612
|
+
* pointer (`cropSession`), the canvas, the resolved options, the
|
|
613
|
+
* history manager, and the transactional loader, so the context's
|
|
614
|
+
* accessors all bind back to `this`.
|
|
615
|
+
*/
|
|
616
|
+
private buildCropControllerContext;
|
|
617
|
+
private updateInputs;
|
|
618
|
+
private updateUi;
|
|
619
|
+
private setControlEnabled;
|
|
620
|
+
private recordElementOriginalState;
|
|
621
|
+
private restoreElementOriginalStates;
|
|
622
|
+
private updatePlaceholderStatus;
|
|
623
|
+
/**
|
|
624
|
+
* Cleans up all DOM event listeners and disposes the Fabric.js Canvas.
|
|
625
|
+
* Call this when the editor is no longer needed to prevent memory leaks.
|
|
626
|
+
*
|
|
627
|
+
* Teardown sequence:
|
|
628
|
+
*
|
|
629
|
+
* 1. Short-circuit on a second call so `dispose` is idempotent. This
|
|
630
|
+
* also guards against re-running
|
|
631
|
+
* the teardown path after the canvas reference has already been
|
|
632
|
+
* nulled.
|
|
633
|
+
* 2. Set `isDisposed = true` so in-flight animation `onChange`/
|
|
634
|
+
* `onComplete` callbacks bail before touching the canvas
|
|
635
|
+
* and so disposed-aware DOM handlers
|
|
636
|
+
* exit early.
|
|
637
|
+
* 3. Drain the {@link AnimationQueue} so callers awaiting an enqueued
|
|
638
|
+
* slot do not hang after teardown.
|
|
639
|
+
* The currently-executing entry, if any, is not interrupted but
|
|
640
|
+
* settles promptly because its disposed-aware callbacks see the
|
|
641
|
+
* flag and exit.
|
|
642
|
+
* 4. Detach every DOM listener via the bindings registry's
|
|
643
|
+
* `removeAll`, wrapped in try/catch
|
|
644
|
+
* inside the registry so already-detached listeners do not throw.
|
|
645
|
+
* 5. Drop the crop rectangle if a crop session was open and dispose
|
|
646
|
+
* the underlying Fabric canvas, matching teardown order.
|
|
647
|
+
*/
|
|
648
|
+
dispose(): void;
|
|
649
|
+
}
|
|
650
|
+
//# sourceMappingURL=image-editor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-editor.d.ts","sourceRoot":"","sources":["../../src/image-editor.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,OAAO,EAGH,KAAK,UAAU,EAClB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,KAAK,EACR,mBAAmB,EACnB,YAAY,EACZ,YAAY,EAKZ,kBAAkB,EAClB,sBAAsB,EAGtB,UAAU,EACV,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,qBAAqB,EAExB,MAAM,wBAAwB,CAAC;AA6GhC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,WAAW;IAEpB,OAAO,CAAC,YAAY,CAAe;IACnC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}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical public API barrel for the image-editor library.
|
|
3
|
+
*
|
|
4
|
+
* The package surface consists of:
|
|
5
|
+
* - `ImageEditor` (default and named export) — the only public class.
|
|
6
|
+
* - `isMaskObject` — runtime type guard for mask objects.
|
|
7
|
+
* - The documented public types listed below.
|
|
8
|
+
*
|
|
9
|
+
* Internal helpers (animation queue, command, history manager, controllers,
|
|
10
|
+
* services, managers, and utility modules) are intentionally not re-exported;
|
|
11
|
+
* they are implementation details and may change without notice.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import * as fabric from 'fabric';
|
|
16
|
+
* import { ImageEditor } from '@bensitu/image-editor';
|
|
17
|
+
* import type {
|
|
18
|
+
* ImageEditorOptions,
|
|
19
|
+
* MaskConfig,
|
|
20
|
+
* MaskObject,
|
|
21
|
+
* } from '@bensitu/image-editor';
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @module
|
|
25
|
+
*/
|
|
26
|
+
import { ImageEditor } from './image-editor.js';
|
|
27
|
+
export { ImageEditor };
|
|
28
|
+
export default ImageEditor;
|
|
29
|
+
export { isMaskObject } from './core/public-types.js';
|
|
30
|
+
export type { ImageEditorOptions, ResolvedOptions, LayoutMode, LabelConfig, CropConfig, CropExportFileType, LoadImageOptions, RemoveAllMasksOptions, MaskConfig, MaskObject, MaskNumericProp, ResolvedMaskConfig, ImageMimeType, ImageFileType, NormalizedImageFormat, ExportArea, Base64ExportOptions, ImageFileExportOptions, ImageInfo, ImageEditorState, ImageEditorSelection, ImageEditorCallbackContext, ImageEditorOperation, ElementIdMap, FabricModule, } from './core/public-types.js';
|
|
31
|
+
//# sourceMappingURL=index.d.cts.map
|