@bensitu/image-editor 2.0.0 → 2.2.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 +346 -90
- package/dist/cjs/index.cjs +4883 -1191
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/animation/animation-queue.js +16 -9
- package/dist/esm/animation/animation-queue.js.map +1 -1
- package/dist/esm/annotation/annotation-lock.js +7 -0
- package/dist/esm/annotation/annotation-lock.js.map +1 -0
- package/dist/esm/annotation/annotation-manager.js +217 -0
- package/dist/esm/annotation/annotation-manager.js.map +1 -0
- package/dist/esm/annotation/annotation-style.js +50 -0
- package/dist/esm/annotation/annotation-style.js.map +1 -0
- package/dist/esm/annotation/draw-controller.js +114 -0
- package/dist/esm/annotation/draw-controller.js.map +1 -0
- package/dist/esm/annotation/text-controller.js +234 -0
- package/dist/esm/annotation/text-controller.js.map +1 -0
- package/dist/esm/core/default-options.js +447 -11
- package/dist/esm/core/default-options.js.map +1 -1
- package/dist/esm/core/editor-object-kind.js +37 -0
- package/dist/esm/core/editor-object-kind.js.map +1 -0
- package/dist/esm/core/errors.js +19 -0
- package/dist/esm/core/errors.js.map +1 -1
- package/dist/esm/core/layer-order.js +100 -0
- package/dist/esm/core/layer-order.js.map +1 -0
- package/dist/esm/core/operation-guard.js +28 -0
- package/dist/esm/core/operation-guard.js.map +1 -1
- package/dist/esm/core/public-types.js +34 -1
- package/dist/esm/core/public-types.js.map +1 -1
- package/dist/esm/core/state-serializer.js +108 -27
- package/dist/esm/core/state-serializer.js.map +1 -1
- package/dist/esm/crop/crop-controller.js +6 -2
- package/dist/esm/crop/crop-controller.js.map +1 -1
- package/dist/esm/export/export-format.js.map +1 -1
- package/dist/esm/export/export-service.js +140 -141
- package/dist/esm/export/export-service.js.map +1 -1
- package/dist/esm/export/overlay-merge-service.js +75 -0
- package/dist/esm/export/overlay-merge-service.js.map +1 -0
- package/dist/esm/fabric/fabric-animation.js +56 -4
- package/dist/esm/fabric/fabric-animation.js.map +1 -1
- package/dist/esm/history/history-manager.js +2 -2
- package/dist/esm/history/history-manager.js.map +1 -1
- package/dist/esm/image/image-loader.js +27 -65
- package/dist/esm/image/image-loader.js.map +1 -1
- package/dist/esm/image/image-resampler.js +7 -2
- package/dist/esm/image/image-resampler.js.map +1 -1
- package/dist/esm/image/layout-manager.js +2 -20
- package/dist/esm/image/layout-manager.js.map +1 -1
- package/dist/esm/image/transform-controller.js.map +1 -1
- package/dist/esm/image-editor.js +1474 -135
- package/dist/esm/image-editor.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/mask/mask-factory.js +92 -43
- package/dist/esm/mask/mask-factory.js.map +1 -1
- package/dist/esm/mask/mask-label-manager.js +2 -0
- package/dist/esm/mask/mask-label-manager.js.map +1 -1
- package/dist/esm/mask/mask-list.js +9 -3
- package/dist/esm/mask/mask-list.js.map +1 -1
- package/dist/esm/mask/mask-style.js.map +1 -1
- package/dist/esm/mosaic/mosaic-controller.js +666 -0
- package/dist/esm/mosaic/mosaic-controller.js.map +1 -0
- package/dist/esm/mosaic/mosaic-geometry.js +81 -0
- package/dist/esm/mosaic/mosaic-geometry.js.map +1 -0
- package/dist/esm/mosaic/mosaic-pixelate.js +71 -0
- package/dist/esm/mosaic/mosaic-pixelate.js.map +1 -0
- package/dist/esm/ui/dom-bindings.js +10 -3
- package/dist/esm/ui/dom-bindings.js.map +1 -1
- package/dist/esm/utils/image-element-loader.js +55 -0
- package/dist/esm/utils/image-element-loader.js.map +1 -0
- package/dist/esm/utils/number.js.map +1 -1
- package/dist/esm/utils/pointer.js +28 -0
- package/dist/esm/utils/pointer.js.map +1 -0
- package/dist/types/animation/animation-queue.d.ts.map +1 -1
- package/dist/types/annotation/annotation-lock.d.ts +12 -0
- package/dist/types/annotation/annotation-lock.d.ts.map +1 -0
- package/dist/types/annotation/annotation-manager.d.ts +33 -0
- package/dist/types/annotation/annotation-manager.d.ts.map +1 -0
- package/dist/types/annotation/annotation-style.d.ts +13 -0
- package/dist/types/annotation/annotation-style.d.ts.map +1 -0
- package/dist/types/annotation/draw-controller.d.ts +43 -0
- package/dist/types/annotation/draw-controller.d.ts.map +1 -0
- package/dist/types/annotation/text-controller.d.ts +47 -0
- package/dist/types/annotation/text-controller.d.ts.map +1 -0
- package/dist/types/core/default-options.d.ts +46 -6
- package/dist/types/core/default-options.d.ts.map +1 -1
- package/dist/types/core/editor-object-kind.d.ts +29 -0
- package/dist/types/core/editor-object-kind.d.ts.map +1 -0
- package/dist/types/core/errors.d.ts +12 -2
- package/dist/types/core/errors.d.ts.map +1 -1
- package/dist/types/core/layer-order.d.ts +21 -0
- package/dist/types/core/layer-order.d.ts.map +1 -0
- package/dist/types/core/operation-guard.d.ts +2 -0
- package/dist/types/core/operation-guard.d.ts.map +1 -1
- package/dist/types/core/public-types.d.ts +341 -33
- package/dist/types/core/public-types.d.ts.map +1 -1
- package/dist/types/core/state-serializer.d.ts +32 -5
- package/dist/types/core/state-serializer.d.ts.map +1 -1
- package/dist/types/crop/crop-controller.d.ts +6 -7
- package/dist/types/crop/crop-controller.d.ts.map +1 -1
- package/dist/types/export/export-format.d.ts +5 -33
- package/dist/types/export/export-format.d.ts.map +1 -1
- package/dist/types/export/export-service.d.ts +24 -15
- package/dist/types/export/export-service.d.ts.map +1 -1
- package/dist/types/export/overlay-merge-service.d.ts +38 -0
- package/dist/types/export/overlay-merge-service.d.ts.map +1 -0
- package/dist/types/fabric/fabric-animation.d.ts.map +1 -1
- package/dist/types/history/history-manager.d.ts +11 -14
- package/dist/types/history/history-manager.d.ts.map +1 -1
- package/dist/types/image/image-loader.d.ts +24 -21
- package/dist/types/image/image-loader.d.ts.map +1 -1
- package/dist/types/image/image-resampler.d.ts +2 -2
- package/dist/types/image/image-resampler.d.ts.map +1 -1
- package/dist/types/image/layout-manager.d.ts +5 -49
- package/dist/types/image/layout-manager.d.ts.map +1 -1
- package/dist/types/image/transform-controller.d.ts +6 -9
- package/dist/types/image/transform-controller.d.ts.map +1 -1
- package/dist/types/image-editor.d.ts +93 -14
- package/dist/types/image-editor.d.ts.map +1 -1
- package/dist/types/index.d.cts +3 -3
- package/dist/types/index.d.cts.map +1 -1
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/mask/mask-factory.d.ts +24 -21
- package/dist/types/mask/mask-factory.d.ts.map +1 -1
- package/dist/types/mask/mask-label-manager.d.ts +10 -9
- package/dist/types/mask/mask-label-manager.d.ts.map +1 -1
- package/dist/types/mask/mask-list.d.ts +11 -12
- package/dist/types/mask/mask-list.d.ts.map +1 -1
- package/dist/types/mask/mask-style.d.ts +19 -20
- package/dist/types/mask/mask-style.d.ts.map +1 -1
- package/dist/types/mosaic/mosaic-controller.d.ts +82 -0
- package/dist/types/mosaic/mosaic-controller.d.ts.map +1 -0
- package/dist/types/mosaic/mosaic-geometry.d.ts +29 -0
- package/dist/types/mosaic/mosaic-geometry.d.ts.map +1 -0
- package/dist/types/mosaic/mosaic-pixelate.d.ts +23 -0
- package/dist/types/mosaic/mosaic-pixelate.d.ts.map +1 -0
- package/dist/types/ui/dom-bindings.d.ts +3 -1
- package/dist/types/ui/dom-bindings.d.ts.map +1 -1
- package/dist/types/ui/visibility-state.d.ts +2 -2
- package/dist/types/utils/image-element-loader.d.ts +19 -0
- package/dist/types/utils/image-element-loader.d.ts.map +1 -0
- package/dist/types/utils/number.d.ts +1 -2
- package/dist/types/utils/number.d.ts.map +1 -1
- package/dist/types/utils/pointer.d.ts +16 -0
- package/dist/types/utils/pointer.d.ts.map +1 -0
- package/dist/umd/image-editor.umd.js +1 -1
- package/dist/umd/image-editor.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -43,10 +43,9 @@
|
|
|
43
43
|
* @module
|
|
44
44
|
*/
|
|
45
45
|
import type * as FabricNS from 'fabric';
|
|
46
|
-
import type { ImageMimeType } from './public-types.js';
|
|
46
|
+
import type { AnnotationObject, BaseImageObject, ImageMimeType, MaskObject } from './public-types.js';
|
|
47
47
|
/**
|
|
48
|
-
* Per-object payload inside a {@link CanvasJson} snapshot.
|
|
49
|
-
* Pretty_Printer wire format used by the canvas serializer.
|
|
48
|
+
* Per-object payload inside a {@link CanvasJson} snapshot.
|
|
50
49
|
*
|
|
51
50
|
* The `isCropRect` and `maskLabel` markers are filtered out by
|
|
52
51
|
* {@link saveState}, so a snapshot pushed to history will never contain
|
|
@@ -57,6 +56,10 @@ import type { ImageMimeType } from './public-types.js';
|
|
|
57
56
|
export interface CanvasJsonObject {
|
|
58
57
|
/** Fabric shape type discriminator (`'rect'`, `'circle'`, `'image'`, etc.). */
|
|
59
58
|
type?: string;
|
|
59
|
+
/** Editor-owned object discriminator. */
|
|
60
|
+
editorObjectKind?: string;
|
|
61
|
+
/** Session object subtype discriminator. */
|
|
62
|
+
sessionObjectType?: string;
|
|
60
63
|
/** Left-edge pixel coordinate (Fabric serializes `originX: 'left'` masks here). */
|
|
61
64
|
left?: number;
|
|
62
65
|
/** Top-edge pixel coordinate. */
|
|
@@ -93,6 +96,18 @@ export interface CanvasJsonObject {
|
|
|
93
96
|
isCropRect?: boolean;
|
|
94
97
|
/** Marks a mask label text object; filtered before history push. */
|
|
95
98
|
maskLabel?: boolean;
|
|
99
|
+
/** Marks Mosaic preview objects; filtered before history push. */
|
|
100
|
+
isMosaicPreview?: boolean;
|
|
101
|
+
/** Annotation identifier. */
|
|
102
|
+
annotationId?: number;
|
|
103
|
+
/** Annotation subtype. */
|
|
104
|
+
annotationType?: string;
|
|
105
|
+
/** Annotation display name. */
|
|
106
|
+
annotationName?: string;
|
|
107
|
+
/** Business-level annotation visibility. */
|
|
108
|
+
annotationHidden?: boolean;
|
|
109
|
+
/** Business-level annotation lock state. */
|
|
110
|
+
annotationLocked?: boolean;
|
|
96
111
|
/** Pass-through for every other Fabric-serialized shape property. */
|
|
97
112
|
[key: string]: unknown;
|
|
98
113
|
}
|
|
@@ -110,8 +125,12 @@ export interface EditorStateMeta {
|
|
|
110
125
|
baseImageScale: number;
|
|
111
126
|
/** MIME type of the currently committed image, when known. */
|
|
112
127
|
currentImageMimeType?: ImageMimeType | null;
|
|
128
|
+
/** Active editor-owned object kind when the snapshot was captured, if any. */
|
|
129
|
+
activeObjectKind?: 'mask' | 'annotation' | null;
|
|
113
130
|
/** Mask selected when the snapshot was captured, if any. */
|
|
114
131
|
activeMaskId?: number;
|
|
132
|
+
/** Annotation selected when the snapshot was captured, if any. */
|
|
133
|
+
activeAnnotationId?: number;
|
|
115
134
|
}
|
|
116
135
|
/**
|
|
117
136
|
* Full snapshot envelope. Standard Fabric `toJSON` keys plus the editor
|
|
@@ -139,7 +158,7 @@ export interface CanvasJson {
|
|
|
139
158
|
* cannot mutate the shared array.
|
|
140
159
|
*
|
|
141
160
|
*/
|
|
142
|
-
export declare const SNAPSHOT_CUSTOM_KEYS: readonly ["maskId", "maskUid", "maskName", "isCropRect", "maskLabel", "originalAlpha", "originalStroke", "originalStrokeWidth", "hasControls", "selectable", "strokeUniform", "lockRotation", "transparentCorners", "borderColor", "cornerColor", "cornerSize"];
|
|
161
|
+
export declare const SNAPSHOT_CUSTOM_KEYS: readonly ["editorObjectKind", "sessionObjectType", "maskId", "maskUid", "maskName", "isCropRect", "maskLabel", "originalAlpha", "originalStroke", "originalStrokeWidth", "hasControls", "selectable", "strokeUniform", "lockRotation", "transparentCorners", "borderColor", "cornerColor", "cornerSize", "isMosaicPreview", "annotationId", "annotationType", "annotationName", "annotationHidden", "annotationLocked"];
|
|
143
162
|
/**
|
|
144
163
|
* Inputs to {@link saveState}. The editor facade passes the live canvas
|
|
145
164
|
* plus the three transform fields that make up `_editorState`.
|
|
@@ -149,6 +168,8 @@ export interface SaveStateInput {
|
|
|
149
168
|
canvas: FabricNS.Canvas;
|
|
150
169
|
/** Active mask id supplied by the facade when Fabric active state is unavailable. */
|
|
151
170
|
activeMaskId?: number | null;
|
|
171
|
+
/** Active annotation id supplied by the facade when Fabric active state is unavailable. */
|
|
172
|
+
activeAnnotationId?: number | null;
|
|
152
173
|
/** Current image zoom factor (mirrored into `_editorState.currentScale`). */
|
|
153
174
|
currentScale: number;
|
|
154
175
|
/** Current image rotation in degrees (mirrored into `_editorState.currentRotation`). */
|
|
@@ -237,19 +258,25 @@ export interface LoadFromStateResult {
|
|
|
237
258
|
* `createMask` calls do not collide with restored IDs.
|
|
238
259
|
*/
|
|
239
260
|
maxMaskId: number;
|
|
261
|
+
/** Highest `annotationId` observed on restored annotation objects. */
|
|
262
|
+
maxAnnotationId: number;
|
|
240
263
|
/**
|
|
241
264
|
* The first `'image'` object that is NOT a mask, or `null`. Used by the
|
|
242
265
|
* facade to set `selectable: false`, `evented: false`, and to send the
|
|
243
266
|
* image to the back of the stacking order. The serializer does not
|
|
244
267
|
* mutate the object itself.
|
|
245
268
|
*/
|
|
246
|
-
originalImage:
|
|
269
|
+
originalImage: BaseImageObject | null;
|
|
247
270
|
/**
|
|
248
271
|
* All canvas objects after restore, in `getObjects` order. The facade
|
|
249
272
|
* uses this list to re-attach mask hover handlers and to drive the
|
|
250
273
|
* `isImageLoadedToCanvas` flag.
|
|
251
274
|
*/
|
|
252
275
|
objects: FabricNS.FabricObject[];
|
|
276
|
+
/** Restored mask objects. */
|
|
277
|
+
masks: MaskObject[];
|
|
278
|
+
/** Restored annotation objects. */
|
|
279
|
+
annotations: AnnotationObject[];
|
|
253
280
|
/**
|
|
254
281
|
* The canonical JSON string for the snapshot — equal to the input string
|
|
255
282
|
* if a string was passed, or `JSON.stringify(input)` if a `CanvasJson`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state-serializer.d.ts","sourceRoot":"","sources":["../../../src/core/state-serializer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEH,OAAO,KAAK,KAAK,QAAQ,MAAM,QAAQ,CAAC;AAExC,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"state-serializer.d.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;OAKG;IACH,aAAa,EAAE,eAAe,GAAG,IAAI,CAAC;IACtC;;;;OAIG;IACH,OAAO,EAAE,QAAQ,CAAC,YAAY,EAAE,CAAC;IACjC,6BAA6B;IAC7B,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,mCAAmC;IACnC,WAAW,EAAE,gBAAgB,EAAE,CAAC;IAChC;;;;;OAKG;IACH,UAAU,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAsB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAmG3F"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Crop session lifecycle owner. Implements the
|
|
3
3
|
* `enterCropMode → applyCrop` and
|
|
4
4
|
* `enterCropMode → cancelCrop` transitions atop the
|
|
5
|
-
*
|
|
5
|
+
* crop export/load pipeline, plus the dedicated crop rectangle
|
|
6
6
|
* shape, its drag/scale clamps, and the per-object
|
|
7
7
|
* `evented`/`selectable` freeze that keeps only the crop
|
|
8
8
|
* rectangle interactive while a session is open.
|
|
@@ -66,10 +66,9 @@
|
|
|
66
66
|
* `left` and `top` shifted by `-cropRegion.left, -cropRegion.top`.
|
|
67
67
|
* Per-mask `angle`, `scaleX`, and `scaleY` are restored verbatim so
|
|
68
68
|
* the visible mask shape does not change size or orientation. The
|
|
69
|
-
* cropRegion-relative shift
|
|
69
|
+
* cropRegion-relative shift preserves the historical
|
|
70
70
|
* `_translateObjectByCanvasOffset(mask, -cropRegion.sourceX,
|
|
71
|
-
* -cropRegion.sourceY)`
|
|
72
|
-
* preserve. Because shifting `left` / `top` by a constant translates
|
|
71
|
+
* -cropRegion.sourceY)` behavior. Because shifting `left` / `top` by a constant translates
|
|
73
72
|
* the entire object (including its rotated visual) by the same
|
|
74
73
|
* constant in canvas pixels, the post-crop position relative to the
|
|
75
74
|
* new image bounding box matches the pre-crop position relative to
|
|
@@ -87,7 +86,7 @@
|
|
|
87
86
|
* before export and re-adds the masks shifted by
|
|
88
87
|
* `-cropRegion.left, -cropRegion.top` after
|
|
89
88
|
* `context.loadImage(croppedBase64)` commits. The intersection filter
|
|
90
|
-
* drops masks that do not overlap the crop region, matching
|
|
89
|
+
* drops masks that do not overlap the crop region, matching the documented
|
|
91
90
|
* observable behavior: masks fully outside the cropped region are
|
|
92
91
|
* removed, while intersecting masks are preserved.
|
|
93
92
|
*
|
|
@@ -97,7 +96,7 @@
|
|
|
97
96
|
* {@link CropControllerContext}. The `ImageEditor` facade keeps
|
|
98
97
|
* ownership of the canonical session pointer (`getCropSession` /
|
|
99
98
|
* `setCropSession`) so multiple editors on the same page do not share
|
|
100
|
-
* crop state and
|
|
99
|
+
* crop state and unit tests can exercise the controller
|
|
101
100
|
* without instantiating the full facade.
|
|
102
101
|
* - The crop rectangle's drag/scale handlers clamp `scaleX` / `scaleY`
|
|
103
102
|
* so the rect cannot grow past the available image bounding box and
|
|
@@ -111,7 +110,7 @@
|
|
|
111
110
|
* - The pre-crop snapshot is captured once, in `enterCropMode`, and
|
|
112
111
|
* reused by `applyCrop`'s history command and rollback path. This
|
|
113
112
|
* avoids a re-serialization right before the crop, and — more
|
|
114
|
-
* importantly — avoids the
|
|
113
|
+
* importantly — avoids the historical fragility of filtering `isCropRect`
|
|
115
114
|
* objects out of a post-rect snapshot when Fabric's custom-key
|
|
116
115
|
* serializer occasionally drops the marker.
|
|
117
116
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crop-controller.d.ts","sourceRoot":"","sources":["../../../src/crop/crop-controller.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"crop-controller.d.ts","sourceRoot":"","sources":["../../../src/crop/crop-controller.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;OAKG;IACH,SAAS,IAAI,MAAM,CAAC;IAEpB;;;;OAIG;IACH,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE/C;;;;OAIG;IACH,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1E;;;;;;;;;;OAUG;IACH,cAAc,CAAC,IAAI,MAAM,CAAC;IAE1B;;;OAGG;IACH,cAAc,CAAC,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEjC;;;;;OAKG;IACH,cAAc,CAAC,IAAI,IAAI,CAAC;CAC3B;AA4bD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,qBAAqB,GAAG,IAAI,CA0LlE;AAID;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,qBAAqB,GAAG,IAAI,CAiB/D;AAID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkFG;AACH,wBAAsB,SAAS,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAoJ7E"}
|
|
@@ -1,37 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* one orchestrating function, mirroring the shape of
|
|
8
|
-
* `image/image-resampler.ts`:
|
|
9
|
-
*
|
|
10
|
-
* - {@link normalizeImageFormat} — collapses `'jpg'` to `'jpeg'`, strips
|
|
11
|
-
* the `image/` MIME prefix, and falls back to `'jpeg'` for unknown or
|
|
12
|
-
* omitted input.
|
|
13
|
-
* - {@link mimeTypeFor} — derives the matching `image/...` MIME
|
|
14
|
-
* for a normalized format token.
|
|
15
|
-
* - {@link clampQuality} — coerces input to a finite number and
|
|
16
|
-
* clamps it into `[0, 1]`, falling back to a caller-supplied default
|
|
17
|
-
* when the input is not finite.
|
|
18
|
-
* - {@link resolveExportFormat} — composes the above with the documented
|
|
19
|
-
* `fileType`-wins-over-`format` precedence and drops `quality` for PNG
|
|
20
|
-
* output.
|
|
21
|
-
*
|
|
22
|
-
* legacy parity:
|
|
23
|
-
* - The format mapping table mirrors `_normalizeImageFormat` from
|
|
24
|
-
* `src/image-editor.js@legacy.4.0`, including the lowercase lookup and the
|
|
25
|
-
* `'jpeg'` default for unknown input.
|
|
26
|
-
* - The quality clamp mirrors `_normalizeQuality` from the same legacy file:
|
|
27
|
-
* non-finite input falls back to `options.downsampleQuality`, finite
|
|
28
|
-
* input is clamped to `[0, 1]`.
|
|
29
|
-
*
|
|
30
|
-
* This module is internal — it is NOT re-exported from `src/index.ts`.
|
|
31
|
-
*
|
|
32
|
-
* Fabric.
|
|
33
|
-
* lossless.
|
|
34
|
-
* `quality` defaulting to `options.downsampleQuality`.
|
|
2
|
+
* Export format normalization helpers.
|
|
3
|
+
*
|
|
4
|
+
* Converts public `Base64ExportOptions` and `ImageFileExportOptions` values
|
|
5
|
+
* into the normalized format, MIME type, and quality values consumed by
|
|
6
|
+
* `export/export-service.ts`.
|
|
35
7
|
*
|
|
36
8
|
* @module
|
|
37
9
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export-format.d.ts","sourceRoot":"","sources":["../../../src/export/export-format.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"export-format.d.ts","sourceRoot":"","sources":["../../../src/export/export-format.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACR,mBAAmB,EACnB,sBAAsB,EACtB,aAAa,EACb,qBAAqB,EACxB,MAAM,yBAAyB,CAAC;AAEjC;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACjC,8CAA8C;IAC9C,MAAM,EAAE,qBAAqB,CAAC;IAC9B,gEAAgE;IAChE,QAAQ,EAAE,aAAa,CAAC;IACxB,yDAAyD;IACzD,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B;AA+BD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,qBAAqB,CAEjF;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,qBAAqB,GAAG,IAAI,CAS3F;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,qBAAqB,GAAG,aAAa,CAExE;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAIvE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,mBAAmB,CAC/B,OAAO,EACD,IAAI,CAAC,mBAAmB,EAAE,UAAU,GAAG,QAAQ,GAAG,SAAS,CAAC,GAC5D,IAAI,CAAC,sBAAsB,EAAE,UAAU,GAAG,SAAS,CAAC,GACpD,SAAS,GACT,IAAI,EACV,iBAAiB,EAAE,MAAM,GAC1B,oBAAoB,CA8BtB"}
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* - `exportImageFile(options?: ImageFileExportOptions)`
|
|
22
22
|
* resolves to a `File` whose name comes from `options.fileName` or the
|
|
23
23
|
* editor's `defaultDownloadFileName`.
|
|
24
|
-
* - `downloadImage(
|
|
24
|
+
* - `downloadImage(options?: DownloadImageOptions | string)` triggers a
|
|
25
25
|
* browser download with the resolved filename. The bytes match the same
|
|
26
26
|
* pipeline used by `exportImageBase64`.
|
|
27
27
|
* - When `isImageLoaded` is `false`, the three
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
* No intermediate `<canvas>` element is created, and sub-pixel
|
|
43
43
|
* width/height values are floored to integer pixels through the
|
|
44
44
|
* {@link floorRegion} helper before Fabric receives the region.
|
|
45
|
-
* - When `
|
|
45
|
+
* - When `mergeMasks` is
|
|
46
46
|
* `true`, every mask's live style (`opacity`, `fill`, `stroke`,
|
|
47
47
|
* `strokeWidth`, `selectable`, `lockRotation`) is captured BEFORE the
|
|
48
48
|
* mutator forces the bake-in style (`opacity: 1, fill: '#000',
|
|
@@ -91,8 +91,9 @@
|
|
|
91
91
|
* @module
|
|
92
92
|
*/
|
|
93
93
|
import type * as FabricNS from 'fabric';
|
|
94
|
-
import type { Base64ExportOptions, FabricModule, ImageFileExportOptions, LoadImageOptions, ResolvedOptions } from '../core/public-types.js';
|
|
95
|
-
import {
|
|
94
|
+
import type { Base64ExportOptions, DownloadImageOptions, FabricModule, ImageFileExportOptions, LoadImageOptions, AnnotationObject, MaskObject, ResolvedOptions } from '../core/public-types.js';
|
|
95
|
+
import type { HistoryManager } from '../history/history-manager.js';
|
|
96
|
+
import { type OverlayMergeTransactionContext } from './overlay-merge-service.js';
|
|
96
97
|
/**
|
|
97
98
|
* Dependency bundle passed by the `ImageEditor` facade into every export
|
|
98
99
|
* entry point. The service has no class state of its own — every editor
|
|
@@ -150,7 +151,7 @@ export interface ExportServiceContext {
|
|
|
150
151
|
* 6. **Render** through {@link withMaskExportState} so mask styles are
|
|
151
152
|
* captured, the export bake-in (`opacity: 1, fill: '#000',
|
|
152
153
|
* strokeWidth: 0, stroke: null, selectable: false`) is applied for
|
|
153
|
-
* `
|
|
154
|
+
* `mergeMasks === true` exports, and the live styles are
|
|
154
155
|
* restored in a `finally` block whether the render resolved or
|
|
155
156
|
* threw. The inner step is a single
|
|
156
157
|
* `canvas.toDataURL` call — no intermediate `<canvas>`.
|
|
@@ -199,11 +200,12 @@ export declare function exportImageFile(context: ExportServiceContext, options?:
|
|
|
199
200
|
* `void` and there is no caller-visible promise to reject.
|
|
200
201
|
*
|
|
201
202
|
* @param context - Export context bundle.
|
|
202
|
-
* @param
|
|
203
|
-
*
|
|
203
|
+
* @param options - Optional filename or {@link DownloadImageOptions}.
|
|
204
|
+
* String input is treated as a filename for backwards
|
|
205
|
+
* compatibility.
|
|
204
206
|
*
|
|
205
207
|
*/
|
|
206
|
-
export declare function downloadImage(context: ExportServiceContext,
|
|
208
|
+
export declare function downloadImage(context: ExportServiceContext, options?: DownloadImageOptions | string): void;
|
|
207
209
|
/**
|
|
208
210
|
* Dependency bundle passed by the `ImageEditor` facade into
|
|
209
211
|
* {@link mergeMasks}. Extends {@link ExportServiceContext} with the
|
|
@@ -229,7 +231,7 @@ export declare function downloadImage(context: ExportServiceContext, fileName?:
|
|
|
229
231
|
* this bundle from its own state.
|
|
230
232
|
*
|
|
231
233
|
*/
|
|
232
|
-
export interface MergeMasksContext extends ExportServiceContext {
|
|
234
|
+
export interface MergeMasksContext extends ExportServiceContext, OverlayMergeTransactionContext {
|
|
233
235
|
/** History manager that records the single merge command. */
|
|
234
236
|
readonly historyManager: HistoryManager;
|
|
235
237
|
/**
|
|
@@ -246,12 +248,6 @@ export interface MergeMasksContext extends ExportServiceContext {
|
|
|
246
248
|
* the success path.
|
|
247
249
|
*/
|
|
248
250
|
loadImage(imageBase64: string, options?: LoadImageOptions): Promise<void>;
|
|
249
|
-
/**
|
|
250
|
-
* Capture a snapshot suitable for {@link loadFromStateFn}. Reads the
|
|
251
|
-
* orchestrator's `lastSnapshot`-producing path so the merge stores
|
|
252
|
-
* exactly the same wire format used by `undo` / `redo`.
|
|
253
|
-
*/
|
|
254
|
-
saveState(): string;
|
|
255
251
|
/**
|
|
256
252
|
* Restore a snapshot produced by {@link saveStateFn}. Used both as
|
|
257
253
|
* the `undo` callback of the merge command and
|
|
@@ -265,6 +261,18 @@ export interface MergeMasksContext extends ExportServiceContext {
|
|
|
265
261
|
* of its own history push.
|
|
266
262
|
*/
|
|
267
263
|
removeAllMasksNoHistory(): void;
|
|
264
|
+
getAnnotations(): AnnotationObject[];
|
|
265
|
+
restoreAnnotations(objects: AnnotationObject[]): void | Promise<void>;
|
|
266
|
+
}
|
|
267
|
+
export interface MergeAnnotationsContext extends ExportServiceContext, OverlayMergeTransactionContext {
|
|
268
|
+
readonly historyManager: HistoryManager;
|
|
269
|
+
readonly containerElement: HTMLElement | null;
|
|
270
|
+
loadImage(imageBase64: string, options?: LoadImageOptions): Promise<void>;
|
|
271
|
+
captureSnapshot(): string;
|
|
272
|
+
loadFromState(snapshot: string): Promise<void>;
|
|
273
|
+
removeAllAnnotationsNoHistory(): void;
|
|
274
|
+
getMasks(): MaskObject[];
|
|
275
|
+
restoreMasks(objects: MaskObject[]): void | Promise<void>;
|
|
268
276
|
}
|
|
269
277
|
/**
|
|
270
278
|
* Flatten every mask into the base image and reload the flattened
|
|
@@ -330,4 +338,5 @@ export interface MergeMasksContext extends ExportServiceContext {
|
|
|
330
338
|
*
|
|
331
339
|
*/
|
|
332
340
|
export declare function mergeMasks(context: MergeMasksContext): Promise<void>;
|
|
341
|
+
export declare function mergeAnnotations(context: MergeAnnotationsContext): Promise<void>;
|
|
333
342
|
//# sourceMappingURL=export-service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export-service.d.ts","sourceRoot":"","sources":["../../../src/export/export-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2FG;AAEH,OAAO,KAAK,KAAK,QAAQ,MAAM,QAAQ,CAAC;AAIxC,OAAO,KAAK,EACR,mBAAmB,
|
|
1
|
+
{"version":3,"file":"export-service.d.ts","sourceRoot":"","sources":["../../../src/export/export-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,GAAG,OAAO,CAAC,IAAI,CAAC,CAiB1E;AAED,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBtF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared transaction service for baking editable overlays into the base image.
|
|
3
|
+
*
|
|
4
|
+
* Mask and annotation merges use the same snapshot, export, reload, restore,
|
|
5
|
+
* history, and rollback flow while preserving the opposite overlay group.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import type * as FabricNS from 'fabric';
|
|
10
|
+
import type { AnnotationObject, Base64ExportOptions, LoadImageOptions, MaskObject, ResolvedOptions } from '../core/public-types.js';
|
|
11
|
+
import { type HistoryManager } from '../history/history-manager.js';
|
|
12
|
+
export type OverlayMergeOperation = 'mergeMasks' | 'mergeAnnotations';
|
|
13
|
+
export interface OverlayMergeTransactionContext {
|
|
14
|
+
readonly canvas: FabricNS.Canvas;
|
|
15
|
+
readonly options: ResolvedOptions;
|
|
16
|
+
readonly historyManager: HistoryManager;
|
|
17
|
+
readonly containerElement: HTMLElement | null;
|
|
18
|
+
isImageLoaded(): boolean;
|
|
19
|
+
captureSnapshot(): string;
|
|
20
|
+
loadFromState(snapshot: string): Promise<void>;
|
|
21
|
+
loadImage(imageBase64: string, options?: LoadImageOptions): Promise<void>;
|
|
22
|
+
exportImageBase64(options: Base64ExportOptions): Promise<string>;
|
|
23
|
+
updateUi(): void;
|
|
24
|
+
updateInputs(): void;
|
|
25
|
+
}
|
|
26
|
+
export interface OverlayMergeGroupOptions<TTarget extends FabricNS.FabricObject, TPreserved extends FabricNS.FabricObject> {
|
|
27
|
+
operation: OverlayMergeOperation;
|
|
28
|
+
exportOptions: Base64ExportOptions & {
|
|
29
|
+
exportArea: 'image';
|
|
30
|
+
fileType: 'png';
|
|
31
|
+
};
|
|
32
|
+
getTargets(): TTarget[];
|
|
33
|
+
getPreservedObjects(): TPreserved[];
|
|
34
|
+
removeTargetsNoHistory(): void;
|
|
35
|
+
restorePreservedObjects(objects: TPreserved[]): void | Promise<void>;
|
|
36
|
+
}
|
|
37
|
+
export declare function flattenOverlayGroupToBaseImage<TTarget extends MaskObject | AnnotationObject, TPreserved extends MaskObject | AnnotationObject>(context: OverlayMergeTransactionContext, options: OverlayMergeGroupOptions<TTarget, TPreserved>): Promise<void>;
|
|
38
|
+
//# sourceMappingURL=overlay-merge-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overlay-merge-service.d.ts","sourceRoot":"","sources":["../../../src/export/overlay-merge-service.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,KAAK,QAAQ,MAAM,QAAQ,CAAC;AAIxC,OAAO,KAAK,EACR,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EAChB,UAAU,EACV,eAAe,EAClB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAW,KAAK,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE7E,MAAM,MAAM,qBAAqB,GAAG,YAAY,GAAG,kBAAkB,CAAC;AAEtE,MAAM,WAAW,8BAA8B;IAC3C,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC;IACjC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IACxC,QAAQ,CAAC,gBAAgB,EAAE,WAAW,GAAG,IAAI,CAAC;IAC9C,aAAa,IAAI,OAAO,CAAC;IACzB,eAAe,IAAI,MAAM,CAAC;IAC1B,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1E,iBAAiB,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACjE,QAAQ,IAAI,IAAI,CAAC;IACjB,YAAY,IAAI,IAAI,CAAC;CACxB;AAED,MAAM,WAAW,wBAAwB,CACrC,OAAO,SAAS,QAAQ,CAAC,YAAY,EACrC,UAAU,SAAS,QAAQ,CAAC,YAAY;IAExC,SAAS,EAAE,qBAAqB,CAAC;IACjC,aAAa,EAAE,mBAAmB,GAAG;QACjC,UAAU,EAAE,OAAO,CAAC;QACpB,QAAQ,EAAE,KAAK,CAAC;KACnB,CAAC;IACF,UAAU,IAAI,OAAO,EAAE,CAAC;IACxB,mBAAmB,IAAI,UAAU,EAAE,CAAC;IACpC,sBAAsB,IAAI,IAAI,CAAC;IAC/B,uBAAuB,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACxE;AA0BD,wBAAsB,8BAA8B,CAChD,OAAO,SAAS,UAAU,GAAG,gBAAgB,EAC7C,UAAU,SAAS,UAAU,GAAG,gBAAgB,EAEhD,OAAO,EAAE,8BAA8B,EACvC,OAAO,EAAE,wBAAwB,CAAC,OAAO,EAAE,UAAU,CAAC,GACvD,OAAO,CAAC,IAAI,CAAC,CAuDf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fabric-animation.d.ts","sourceRoot":"","sources":["../../../src/fabric/fabric-animation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,OAAO,KAAK,KAAK,QAAQ,MAAM,QAAQ,CAAC;AACxC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"fabric-animation.d.ts","sourceRoot":"","sources":["../../../src/fabric/fabric-animation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,OAAO,KAAK,KAAK,QAAQ,MAAM,QAAQ,CAAC;AACxC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAQjE;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC3B,gFAAgF;IAChF,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,QAAQ,CAAC,YAAY,EACxD,MAAM,EAAE,CAAC,EACT,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC7B,OAAO,EAAE,cAAc,EACvB,KAAK,EAAE,cAAc,GACtB,OAAO,CAAC,IAAI,CAAC,CAiFf;AAeD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,aAAa,CACzB,MAAM,EAAE,QAAQ,CAAC,YAAY,EAC7B,OAAO,EAAE,QAAQ,CAAC,QAAQ,EAC1B,OAAO,EAAE,QAAQ,CAAC,QAAQ,GAC3B,IAAI,CASN"}
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Behavior contract:
|
|
6
6
|
*
|
|
7
|
-
* • {@link HistoryManager.
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
7
|
+
* • {@link HistoryManager.push} is **synchronous** for the history-push
|
|
8
|
+
* step so callers can immediately inspect {@link HistoryManager.canUndo} /
|
|
9
|
+
* {@link HistoryManager.canRedo} on the next line (e.g. `updateUi` calls
|
|
10
|
+
* that immediately follow `saveState`). {@link HistoryManager.execute}
|
|
11
|
+
* awaits the command before pushing it.
|
|
12
12
|
*
|
|
13
13
|
* • {@link HistoryManager.undo} and {@link HistoryManager.redo} are
|
|
14
14
|
* **async** and protected by an internal `isProcessing` lock. Overlapping
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
* await canvas.loadFromJSON(beforeJson);
|
|
51
51
|
* },
|
|
52
52
|
* );
|
|
53
|
-
* historyManager.execute(cmd);
|
|
53
|
+
* await historyManager.execute(cmd);
|
|
54
54
|
* ```
|
|
55
55
|
*/
|
|
56
56
|
export declare class Command {
|
|
@@ -76,16 +76,13 @@ export declare class HistoryManager {
|
|
|
76
76
|
*/
|
|
77
77
|
constructor(maxSize?: number);
|
|
78
78
|
/**
|
|
79
|
-
*
|
|
80
|
-
*
|
|
79
|
+
* Awaits a command's `execute` closure and records it on the history stack
|
|
80
|
+
* only after the closure succeeds.
|
|
81
81
|
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
* `saveState` pattern, `command.execute` is a no-op on its first
|
|
85
|
-
* invocation (guarded by an `executedOnce` flag inside the closure), so
|
|
86
|
-
* the fire-and-forget is safe and produces no canvas side-effect.
|
|
82
|
+
* Use {@link push} when the operation has already been performed and
|
|
83
|
+
* should become undoable synchronously.
|
|
87
84
|
*/
|
|
88
|
-
execute(command: Command): void
|
|
85
|
+
execute(command: Command): Promise<void>;
|
|
89
86
|
/**
|
|
90
87
|
* Pushes a command onto the history stack **without** calling
|
|
91
88
|
* `execute`. Use this when the operation has already been performed
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"history-manager.d.ts","sourceRoot":"","sources":["../../../src/history/history-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,OAAO;IAChB,4CAA4C;IAC5C,QAAQ,CAAC,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC,0BAA0B;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;gBAEvB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM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,CAAC;IAc3B;;;;;;OAMG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAc3B;;;;;;;;OAQG;IACH,OAAO,CAAC,WAAW;CAgBtB"}
|
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
* loader re-throws. The success path does NOT invoke `onError`.
|
|
22
22
|
* - Strings that do not start with `data:image/`
|
|
23
23
|
* resolve without mutating placeholder visibility, scroll position,
|
|
24
|
-
*
|
|
24
|
+
* image state, or canvas state. The function returns before
|
|
25
25
|
* capturing the rollback bundle, so no observable side effect occurs.
|
|
26
26
|
* - On a valid `data:image/` URL, the loader captures
|
|
27
27
|
* the rollback bundle *before* mutating any of the fields it tracks
|
|
28
28
|
* (placeholder `hidden`, container `scrollTop`/`scrollLeft`, container
|
|
29
|
-
*
|
|
29
|
+
* `originalImage`, `lastSnapshot`, the canvas JSON
|
|
30
30
|
* snapshot, plus the editor transform fields the rollback needs to
|
|
31
31
|
* restore the live canvas to a consistent state).
|
|
32
32
|
* - Decode, Fabric, downsample, and timeout failures
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
* original error.
|
|
35
35
|
* - On success, `isImageLoadedToCanvas` is set to
|
|
36
36
|
* `true`, `lastSnapshot` is replaced with a fresh snapshot derived from
|
|
37
|
-
* the new canvas, and
|
|
37
|
+
* the new canvas, and both overlay counters are reset to `0`.
|
|
38
38
|
* - Either the new image is committed fully, or the
|
|
39
39
|
* prior committed state is restored fully. No partial state is observable
|
|
40
40
|
* after the returned promise settles.
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
* - The 2D-context failure inside
|
|
48
48
|
* {@link resampleImage} surfaces as {@link DownsampleError}; the loader
|
|
49
49
|
* catches it and routes through the rollback path.
|
|
50
|
-
* - On success, `maskCounter`
|
|
50
|
+
* - On success, `maskCounter` and `annotationCounter` are reset to `0`.
|
|
51
51
|
*
|
|
52
52
|
* ## Implementation notes
|
|
53
53
|
*
|
|
@@ -56,15 +56,14 @@
|
|
|
56
56
|
* facade owns all editor state (the canvas reference, the placeholder
|
|
57
57
|
* element, the editor scalar fields), so the loader must read and write
|
|
58
58
|
* that state through a small set of getter/setter callbacks. The class
|
|
59
|
-
* shape
|
|
60
|
-
*
|
|
61
|
-
* the operation has captured.
|
|
59
|
+
* shape stays on the facade; the loader remains stateless so the rollback
|
|
60
|
+
* bundle is the single source of truth for what the operation has captured.
|
|
62
61
|
*
|
|
63
62
|
* The rollback bundle is built before the loader hides the placeholder or
|
|
64
63
|
* touches the canvas. It captures *every* field listed in the documented
|
|
65
64
|
* RollbackBundle definition plus the editor scalar fields
|
|
66
|
-
* (`isImageLoadedToCanvas`, `maskCounter`, `
|
|
67
|
-
* `currentRotation`, `baseImageScale`) the success path mutates. Restoring
|
|
65
|
+
* (`isImageLoadedToCanvas`, `maskCounter`, `annotationCounter`,
|
|
66
|
+
* `currentScale`, `currentRotation`, `baseImageScale`) the success path mutates. Restoring
|
|
68
67
|
* those scalars is required for atomic rollback — without them, a failed
|
|
69
68
|
* load that ran past the scalar reset would leave the editor with
|
|
70
69
|
* `currentScale = 1` and `currentRotation = 0` even though
|
|
@@ -76,7 +75,7 @@
|
|
|
76
75
|
* `loadOptions.preserveScroll === true`; on rollback the bundle is replayed
|
|
77
76
|
* unconditionally, which the rollback contract already requires for
|
|
78
77
|
* transactional rewind. When `preserveScroll` is omitted or `false`, the
|
|
79
|
-
* success path leaves the container scroll untouched, so
|
|
78
|
+
* success path leaves the container scroll untouched, so the documented
|
|
80
79
|
* scroll/viewport behavior for the selected layout mode prevails.
|
|
81
80
|
*
|
|
82
81
|
* The loader does not invoke public success callbacks. It owns
|
|
@@ -93,7 +92,7 @@
|
|
|
93
92
|
* @module
|
|
94
93
|
*/
|
|
95
94
|
import type * as FabricNS from 'fabric';
|
|
96
|
-
import type { FabricModule, ImageMimeType, LoadImageOptions, ResolvedOptions } from '../core/public-types.js';
|
|
95
|
+
import type { BaseImageObject, FabricModule, ImageMimeType, LoadImageOptions, ResolvedOptions } from '../core/public-types.js';
|
|
97
96
|
import { type ViewportCache } from './layout-manager.js';
|
|
98
97
|
/**
|
|
99
98
|
* Snapshot of every field the loader is about to mutate, captured before
|
|
@@ -102,9 +101,9 @@ import { type ViewportCache } from './layout-manager.js';
|
|
|
102
101
|
*
|
|
103
102
|
* Mirrors the documented `RollbackBundle` definition with the addition of
|
|
104
103
|
* the editor scalar fields the success path also rewrites
|
|
105
|
-
* (`isImageLoadedToCanvas`, `maskCounter`, `
|
|
106
|
-
* `currentRotation`, `baseImageScale`). Those scalars must
|
|
107
|
-
* together with the canvas JSON for atomic rewind.
|
|
104
|
+
* (`isImageLoadedToCanvas`, `maskCounter`, `annotationCounter`,
|
|
105
|
+
* `currentScale`, `currentRotation`, `baseImageScale`). Those scalars must
|
|
106
|
+
* be restored together with the canvas JSON for atomic rewind.
|
|
108
107
|
*
|
|
109
108
|
*/
|
|
110
109
|
export interface RollbackBundle {
|
|
@@ -114,10 +113,8 @@ export interface RollbackBundle {
|
|
|
114
113
|
containerScrollTop: number | null;
|
|
115
114
|
/** Container `scrollLeft` immediately before the loader started. */
|
|
116
115
|
containerScrollLeft: number | null;
|
|
117
|
-
/** Container inline `style.overflow` value before any mutation. */
|
|
118
|
-
containerOverflow: string | null;
|
|
119
116
|
/** The previously-committed `originalImage` reference, if any. */
|
|
120
|
-
originalImage:
|
|
117
|
+
originalImage: BaseImageObject | null;
|
|
121
118
|
/** Whether an image was already committed before this call. */
|
|
122
119
|
isImageLoadedToCanvas: boolean;
|
|
123
120
|
/** Snapshot string used as the history baseline before the call. */
|
|
@@ -129,6 +126,8 @@ export interface RollbackBundle {
|
|
|
129
126
|
canvasJson: string;
|
|
130
127
|
/** Mask counter value before the loader reset it to 0. */
|
|
131
128
|
maskCounter: number;
|
|
129
|
+
/** Annotation counter value before the loader reset it to 0. */
|
|
130
|
+
annotationCounter: number;
|
|
132
131
|
/** Image scale factor before the loader reset it to 1. */
|
|
133
132
|
currentScale: number;
|
|
134
133
|
/** Image rotation in degrees before the loader reset it to 0. */
|
|
@@ -168,9 +167,9 @@ export interface LoadImageContext {
|
|
|
168
167
|
/** Hidden-container viewport cache shared with the layout manager. */
|
|
169
168
|
viewportCache: ViewportCache;
|
|
170
169
|
/** Reads the previously-committed `originalImage`. */
|
|
171
|
-
getOriginalImage():
|
|
170
|
+
getOriginalImage(): BaseImageObject | null;
|
|
172
171
|
/** Writes `originalImage` (used both on commit and on rollback). */
|
|
173
|
-
setOriginalImage(imageObject:
|
|
172
|
+
setOriginalImage(imageObject: BaseImageObject | null): void;
|
|
174
173
|
/** Reads `isImageLoadedToCanvas`. */
|
|
175
174
|
getIsImageLoadedToCanvas(): boolean;
|
|
176
175
|
/** Writes `isImageLoadedToCanvas`. */
|
|
@@ -183,6 +182,10 @@ export interface LoadImageContext {
|
|
|
183
182
|
getMaskCounter(): number;
|
|
184
183
|
/** Writes `maskCounter`. */
|
|
185
184
|
setMaskCounter(n: number): void;
|
|
185
|
+
/** Reads `annotationCounter`. */
|
|
186
|
+
getAnnotationCounter(): number;
|
|
187
|
+
/** Writes `annotationCounter`. */
|
|
188
|
+
setAnnotationCounter(n: number): void;
|
|
186
189
|
/** Reads `currentScale`. */
|
|
187
190
|
getCurrentScale(): number;
|
|
188
191
|
/** Writes `currentScale`. */
|
|
@@ -228,8 +231,8 @@ export interface LoadImageContext {
|
|
|
228
231
|
* 7. **Layout** — pick a strategy via {@link selectLayoutStrategy} and
|
|
229
232
|
* apply via {@link applyCanvasDimensions}.
|
|
230
233
|
* 8. **Commit** — set `isImageLoadedToCanvas`,
|
|
231
|
-
* reset
|
|
232
|
-
* `lastSnapshot` via {@link saveState}.
|
|
234
|
+
* reset both overlay counters to 0, reset transforms, and emit a
|
|
235
|
+
* fresh `lastSnapshot` via {@link saveState}.
|
|
233
236
|
*
|
|
234
237
|
* Any rejection between step 3 and step 8 routes through {@link replayRollback}
|
|
235
238
|
* before re-throwing the original error. On the rollback
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-loader.d.ts","sourceRoot":"","sources":["../../../src/image/image-loader.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"image-loader.d.ts","sourceRoot":"","sources":["../../../src/image/image-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4FG;AAEH,OAAO,KAAK,KAAK,QAAQ,MAAM,QAAQ,CAAC;AAExC,OAAO,KAAK,EACR,eAAe,EACf,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,eAAe,EAClB,MAAM,yBAAyB,CAAC;AAOjC,OAAO,EAQH,KAAK,aAAa,EACrB,MAAM,qBAAqB,CAAC;AAS7B;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,cAAc;IAC3B,wEAAwE;IACxE,iBAAiB,EAAE,OAAO,GAAG,IAAI,CAAC;IAClC,mEAAmE;IACnE,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,oEAAoE;IACpE,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,kEAAkE;IAClE,aAAa,EAAE,eAAe,GAAG,IAAI,CAAC;IACtC,+DAA+D;IAC/D,qBAAqB,EAAE,OAAO,CAAC;IAC/B,oEAAoE;IACpE,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB,0DAA0D;IAC1D,WAAW,EAAE,MAAM,CAAC;IACpB,gEAAgE;IAChE,iBAAiB,EAAE,MAAM,CAAC;IAC1B,0DAA0D;IAC1D,YAAY,EAAE,MAAM,CAAC;IACrB,iEAAiE;IACjE,eAAe,EAAE,MAAM,CAAC;IACxB,oEAAoE;IACpE,cAAc,EAAE,MAAM,CAAC;IACvB,gEAAgE;IAChE,oBAAoB,EAAE,aAAa,GAAG,IAAI,CAAC;CAC9C;AAID;;;;;;;;;;;;;;;G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BAA8B;IAC9B,iBAAiB,IAAI,MAAM,CAAC;IAC5B,+BAA+B;IAC/B,iBAAiB,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEnC,4DAA4D;IAC5D,uBAAuB,IAAI,aAAa,GAAG,IAAI,CAAC;IAChD,6DAA6D;IAC7D,uBAAuB,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI,GAAG,IAAI,CAAC;IAE9D;;;;OAIG;IACH,qBAAqB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;CAC9C;AAID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,wBAAsB,SAAS,CAC3B,OAAO,EAAE,gBAAgB,EACzB,WAAW,EAAE,MAAM,EACnB,WAAW,GAAE,gBAAqB,GACnC,OAAO,CAAC,IAAI,CAAC,CA4Kf"}
|
|
@@ -117,7 +117,7 @@ export declare function detectSourceMimeType(dataUrl: string): string | null;
|
|
|
117
117
|
*
|
|
118
118
|
* Failure mode: when `<canvas>.getContext('2d')` returns
|
|
119
119
|
* `null`, this function throws {@link DownsampleError} so
|
|
120
|
-
* `image/image-loader.ts` can replay its
|
|
120
|
+
* `image/image-loader.ts` can replay its rollback bundle
|
|
121
121
|
* before rejecting the public `loadImage` promise.
|
|
122
122
|
*
|
|
123
123
|
* @param imageElement - Decoded source image element.
|
|
@@ -135,5 +135,5 @@ export declare function detectSourceMimeType(dataUrl: string): string | null;
|
|
|
135
135
|
* 2D rendering context.
|
|
136
136
|
*
|
|
137
137
|
*/
|
|
138
|
-
export declare function resampleImage(imageElement: HTMLImageElement, maxWidth: number, maxHeight: number, sourceMime: string | null, preserveSourceFormat: boolean, downsampleMimeType: ImageMimeType | null | undefined, quality: number): ResampleResult;
|
|
138
|
+
export declare function resampleImage(imageElement: HTMLImageElement, maxWidth: number, maxHeight: number, sourceMime: string | null, preserveSourceFormat: boolean, downsampleMimeType: ImageMimeType | null | undefined, quality: number, ownerDocument?: Document): ResampleResult;
|
|
139
139
|
//# sourceMappingURL=image-resampler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-resampler.d.ts","sourceRoot":"","sources":["../../../src/image/image-resampler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAG7D;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC3B,wDAAwD;IACxD,OAAO,EAAE,MAAM,CAAC;IAChB,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAC;IACf,iCAAiC;IACjC,QAAQ,EAAE,aAAa,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,2BAA2B,CACvC,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAClB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,OAAO,CAAA;CAAE,CA8BzD;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,wBAAwB,CACpC,UAAU,EAAE,MAAM,GAAG,IAAI,EACzB,oBAAoB,EAAE,OAAO,EAC7B,kBAAkB,EAAE,aAAa,GAAG,IAAI,GAAG,SAAS,GACrD,aAAa,CAaf;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAGnE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,aAAa,CACzB,YAAY,EAAE,gBAAgB,EAC9B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GAAG,IAAI,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