@bensitu/image-editor 2.1.0 → 2.3.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 +305 -95
- package/dist/cjs/index.cjs +3460 -843
- package/dist/cjs/index.cjs.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 +240 -9
- 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/public-types.js +34 -1
- package/dist/esm/core/public-types.js.map +1 -1
- package/dist/esm/core/state-serializer.js +112 -24
- package/dist/esm/core/state-serializer.js.map +1 -1
- package/dist/esm/crop/crop-controller.js +220 -10
- 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 +157 -168
- 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/history/history-manager.js +2 -2
- package/dist/esm/history/history-manager.js.map +1 -1
- package/dist/esm/image/image-loader.js +20 -51
- package/dist/esm/image/image-loader.js.map +1 -1
- package/dist/esm/image/transform-controller.js +42 -0
- package/dist/esm/image/transform-controller.js.map +1 -1
- package/dist/esm/image-editor.js +1200 -72
- 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 +39 -14
- 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.map +1 -1
- package/dist/esm/mask/mask-style.js.map +1 -1
- package/dist/esm/mosaic/mosaic-controller.js +24 -28
- package/dist/esm/mosaic/mosaic-controller.js.map +1 -1
- package/dist/esm/utils/file.js +10 -0
- package/dist/esm/utils/file.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/pointer.js +28 -0
- package/dist/esm/utils/pointer.js.map +1 -0
- 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 +14 -2
- 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 +11 -1
- 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/public-types.d.ts +272 -56
- package/dist/types/core/public-types.d.ts.map +1 -1
- package/dist/types/core/state-serializer.d.ts +34 -5
- package/dist/types/core/state-serializer.d.ts.map +1 -1
- package/dist/types/crop/crop-controller.d.ts +18 -14
- package/dist/types/crop/crop-controller.d.ts.map +1 -1
- package/dist/types/export/export-format.d.ts +9 -40
- package/dist/types/export/export-format.d.ts.map +1 -1
- package/dist/types/export/export-service.d.ts +45 -41
- 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/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 +27 -22
- package/dist/types/image/image-loader.d.ts.map +1 -1
- package/dist/types/image/image-resampler.d.ts +1 -1
- package/dist/types/image/transform-controller.d.ts +19 -14
- package/dist/types/image/transform-controller.d.ts.map +1 -1
- package/dist/types/image-editor.d.ts +93 -15
- 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.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 +3 -3
- package/dist/types/mosaic/mosaic-controller.d.ts.map +1 -1
- package/dist/types/ui/visibility-state.d.ts +2 -2
- package/dist/types/utils/file.d.ts +13 -0
- package/dist/types/utils/file.d.ts.map +1 -1
- 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/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
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Per-mask label overlay creation, positioning, show/hide, and
|
|
3
|
-
* removal.
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
3
|
+
* removal.
|
|
4
|
+
*
|
|
5
|
+
* The ImageEditor facade owns the canvas and resolved options; this module
|
|
6
|
+
* receives those dependencies through {@link MaskLabelManagerContext} so
|
|
7
|
+
* label behavior can be tested without the full facade.
|
|
8
8
|
*
|
|
9
9
|
* ## Owned contracts
|
|
10
10
|
*
|
|
11
11
|
* - Label text is computed via
|
|
12
12
|
* `options.label.getText(mask, mask.maskId - 1)`. The index argument is
|
|
13
13
|
* the stable creation index (`maskId - 1`), NOT the live canvas list
|
|
14
|
-
* position.
|
|
15
|
-
* masks were added or removed; the current
|
|
14
|
+
* position. Earlier implementations passed `this.maskCounter` here,
|
|
15
|
+
* which drifted whenever masks were added or removed; the current
|
|
16
|
+
* contract pins the index to the
|
|
16
17
|
* mask's own identity so labels stay consistent across
|
|
17
18
|
* `createMask` / `removeSelectedMask` / `removeAllMasks` / `undo`/`redo`.
|
|
18
19
|
*
|
|
@@ -23,7 +24,7 @@
|
|
|
23
24
|
* re-asserts them on every sync so an externally-mutated label still
|
|
24
25
|
* honors the contract.
|
|
25
26
|
*
|
|
26
|
-
* - **
|
|
27
|
+
* - **State serializer filter** — Every label object is
|
|
27
28
|
* tagged with `maskLabel = true` so `core/state-serializer.ts` can
|
|
28
29
|
* exclude it from history snapshots. Labels are session-only and never
|
|
29
30
|
* persisted.
|
|
@@ -60,7 +61,7 @@ import type { FabricModule, MaskObject, ResolvedOptions } from '../core/public-t
|
|
|
60
61
|
*
|
|
61
62
|
* The module does NOT own any of these slots — it only reads them so
|
|
62
63
|
* ownership of the canvas, Fabric module, and resolved options stays on the
|
|
63
|
-
* orchestrator
|
|
64
|
+
* orchestrator.
|
|
64
65
|
*/
|
|
65
66
|
export interface MaskLabelManagerContext {
|
|
66
67
|
/** Injected Fabric.js v7 module used to construct the label text. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mask-label-manager.d.ts","sourceRoot":"","sources":["../../../src/mask/mask-label-manager.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"mask-label-manager.d.ts","sourceRoot":"","sources":["../../../src/mask/mask-label-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AAEH,OAAO,KAAK,KAAK,QAAQ,MAAM,QAAQ,CAAC;AACxC,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAKzF;;;;;;GAMG;AACH,MAAM,WAAW,uBAAuB;IACpC,qEAAqE;IACrE,MAAM,EAAE,YAAY,CAAC;IACrB,4DAA4D;IAC5D,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC;IACxB,+DAA+D;IAC/D,OAAO,EAAE,eAAe,CAAC;CAC5B;AAUD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,uBAAuB,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI,CAc3F;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,uBAAuB,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI,CAiE3F;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,uBAAuB,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI,CA2BtF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI,CASzF;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,uBAAuB,GAAG,IAAI,CAuBxE"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Mask list DOM rendering
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Mask list DOM rendering and click-to-select behavior.
|
|
3
|
+
*
|
|
4
|
+
* The ImageEditor facade owns canvas selection state; this module rebuilds
|
|
5
|
+
* the list from the current canvas objects and reports user selection through
|
|
5
6
|
* {@link MaskListContext}.
|
|
6
7
|
*
|
|
7
8
|
* ## Owned contracts
|
|
@@ -15,7 +16,7 @@
|
|
|
15
16
|
* - Every `<li>` carries a `data-mask-id` attribute
|
|
16
17
|
* (via `dataset.maskId`) equal to the mask's `maskId`. Clients keying off
|
|
17
18
|
* the list (the click handler below, the test suite under
|
|
18
|
-
* `tests/
|
|
19
|
+
* `tests/mask-list-dom.property.test.mjs`) MUST use this attribute and
|
|
19
20
|
* never the visible label text — the label may be rewritten by the
|
|
20
21
|
* integrator via `options.label.getText`, so it is NOT a stable key.
|
|
21
22
|
*
|
|
@@ -44,8 +45,8 @@
|
|
|
44
45
|
* tested in isolation against a stub Fabric environment plus a JSDOM
|
|
45
46
|
* container.
|
|
46
47
|
* - The DOM contract — `<li class="list-group-item mask-item">` with a
|
|
47
|
-
* `dataset.maskId` —
|
|
48
|
-
*
|
|
48
|
+
* `dataset.maskId` — is stable so existing CSS, theme overrides, and
|
|
49
|
+
* integrator selectors continue to work unchanged.
|
|
49
50
|
* - Each render replaces the container's `innerHTML`. That is intentional:
|
|
50
51
|
* it guarantees the DOM mirrors `canvas.getObjects` exactly, and the
|
|
51
52
|
* Fabric event handlers (`object:added`, `object:removed`, `selection:*`)
|
|
@@ -62,8 +63,7 @@ import type { MaskObject } from '../core/public-types.js';
|
|
|
62
63
|
*
|
|
63
64
|
* The module does NOT own any of these slots — it only reads them so
|
|
64
65
|
* ownership of the canvas, the resolved DOM element ID map, and the
|
|
65
|
-
* selection-changed pipeline stays on the orchestrator
|
|
66
|
-
* them).
|
|
66
|
+
* selection-changed pipeline stays on the orchestrator.
|
|
67
67
|
*/
|
|
68
68
|
export interface MaskListContext {
|
|
69
69
|
/**
|
|
@@ -82,8 +82,7 @@ export interface MaskListContext {
|
|
|
82
82
|
* Invoked by the click handler after `setActiveObject(mask)` has run,
|
|
83
83
|
* so the orchestrator can drive its selection-changed pipeline (label
|
|
84
84
|
* overlay, hover/selection styling, list highlight) the same way it
|
|
85
|
-
* does for canvas-originated selections.
|
|
86
|
-
* `_handleSelectionChanged([mask])` call from `_handleMaskListClick`.
|
|
85
|
+
* does for canvas-originated selections.
|
|
87
86
|
*/
|
|
88
87
|
onMaskSelected(mask: MaskObject): void;
|
|
89
88
|
}
|
|
@@ -105,8 +104,8 @@ export interface MaskListContext {
|
|
|
105
104
|
* listener bookkeeping to track separately.
|
|
106
105
|
* 3. For each {@link MaskObject} returned by `canvas.getObjects` (in
|
|
107
106
|
* canvas object order), build a fresh `<li>`:
|
|
108
|
-
* - class `list-group-item mask-item` (
|
|
109
|
-
* existing CSS keeps working);
|
|
107
|
+
* - class `list-group-item mask-item` (part of the stable DOM
|
|
108
|
+
* contract so existing CSS keeps working);
|
|
110
109
|
* - `textContent` set to `mask.maskName` (the label-text contract
|
|
111
110
|
* owned by `mask/mask-label-manager.ts`; this list shows the same
|
|
112
111
|
* identifier);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mask-list.d.ts","sourceRoot":"","sources":["../../../src/mask/mask-list.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"mask-list.d.ts","sourceRoot":"","sources":["../../../src/mask/mask-list.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AAEH,OAAO,KAAK,KAAK,QAAQ,MAAM,QAAQ,CAAC;AACxC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAG1D;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC5B;;;;OAIG;IACH,MAAM,EAAE,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC;IAC/B;;;;OAIG;IACH,gBAAgB,IAAI,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC9C;;;;;OAKG;IACH,cAAc,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC;CAC1C;AAgBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI,CA2C7D;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,uBAAuB,CACnC,OAAO,EAAE,eAAe,EACxB,YAAY,EAAE,UAAU,GAAG,IAAI,GAChC,IAAI,CAWN"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Hover, selection, and "original style restore" helpers for
|
|
3
|
-
* mask visual state.
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
3
|
+
* mask visual state.
|
|
4
|
+
*
|
|
5
|
+
* The ImageEditor facade owns canvas state; this module receives the live
|
|
6
|
+
* canvas and resolved options through {@link MaskStyleContext} so mask
|
|
7
|
+
* visual behavior stays centralized.
|
|
8
8
|
*
|
|
9
9
|
* Two callers consume the same backup shape:
|
|
10
10
|
*
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
* Centralizing the backup shape, the hover style literals (`#ff5500`,
|
|
22
22
|
* `strokeWidth: 2`, `opacity = originalAlpha + 0.2`), and the
|
|
23
23
|
* selected/unselected stroke literals (`#ff0000`, `mask.originalStroke ||
|
|
24
|
-
* '#ccc'`) here
|
|
25
|
-
*
|
|
24
|
+
* '#ccc'`) here keeps mask visuals consistent and any future tweak in one
|
|
25
|
+
* place.
|
|
26
26
|
*
|
|
27
27
|
* ## Owned contracts
|
|
28
28
|
*
|
|
@@ -51,18 +51,17 @@
|
|
|
51
51
|
* and `lockRotation` from the captured {@link MaskBackup}, matching the current
|
|
52
52
|
* documented `MaskBackup` interface.
|
|
53
53
|
*
|
|
54
|
-
* - **
|
|
55
|
-
* {@link reattachMaskHoverHandlers} bind
|
|
56
|
-
* handlers
|
|
54
|
+
* - **Hover behavior** — {@link attachMaskHoverHandlers} and
|
|
55
|
+
* {@link reattachMaskHoverHandlers} bind `mouseover`/`mouseout`
|
|
56
|
+
* handlers that read
|
|
57
57
|
* `mask.originalAlpha` / `mask.originalStroke` / `mask.originalStrokeWidth`
|
|
58
58
|
* on each invocation so they always reflect the current "live" state
|
|
59
59
|
* (e.g. after a stroke change from a selection event).
|
|
60
60
|
*
|
|
61
|
-
* - **
|
|
61
|
+
* - **Selection styling** — {@link applyMaskSelectedStyle} sets
|
|
62
62
|
* the selection-highlight stroke (`#ff0000`, `strokeWidth: 1`) and
|
|
63
63
|
* {@link applyMaskUnselectedStyle} restores the normal stroke from the
|
|
64
|
-
* per-mask `originalStroke` / `originalStrokeWidth`.
|
|
65
|
-
* legacy's `_handleSelectionChanged`.
|
|
64
|
+
* per-mask `originalStroke` / `originalStrokeWidth`.
|
|
66
65
|
*
|
|
67
66
|
* ## Out of scope (handled by sibling modules)
|
|
68
67
|
*
|
|
@@ -81,10 +80,11 @@
|
|
|
81
80
|
* - Hover handlers do NOT cache the normal/hover style at attach time. They
|
|
82
81
|
* read `mask.originalAlpha` / `mask.originalStroke` / `mask.originalStrokeWidth`
|
|
83
82
|
* on every event so the visual matches the live "original" values even
|
|
84
|
-
* after a stroke or opacity change
|
|
83
|
+
* after a stroke or opacity change.
|
|
85
84
|
* - The handlers are tagged on `mask.imageEditorMaskHandlers` exactly as
|
|
86
|
-
*
|
|
87
|
-
* binding fresh ones, avoiding duplicate listeners after
|
|
85
|
+
* {@link reattachMaskHoverHandlers} expects so it can drop the old pair
|
|
86
|
+
* before binding fresh ones, avoiding duplicate listeners after
|
|
87
|
+
* `loadFromJSON`.
|
|
88
88
|
*
|
|
89
89
|
* @module
|
|
90
90
|
*/
|
|
@@ -94,8 +94,7 @@ import type { MaskBackup, MaskObject, ResolvedOptions } from '../core/public-typ
|
|
|
94
94
|
* State the mask-style helpers read from the `ImageEditor` orchestrator.
|
|
95
95
|
*
|
|
96
96
|
* The module does NOT own any of these slots — it only reads them so
|
|
97
|
-
* ownership of the canvas and resolved options stays on the orchestrator
|
|
98
|
-
* (where legacy left them).
|
|
97
|
+
* ownership of the canvas and resolved options stays on the orchestrator.
|
|
99
98
|
*/
|
|
100
99
|
export interface MaskStyleContext {
|
|
101
100
|
/**
|
|
@@ -202,8 +201,8 @@ export declare function attachMaskHoverHandlers(mask: MaskObject): void;
|
|
|
202
201
|
* Also re-asserts the persisted `original*` metadata when missing — legacy's
|
|
203
202
|
* `_rebindMaskEvents` did the same so a snapshot from an older format that
|
|
204
203
|
* happens to lack `originalStroke`/`originalStrokeWidth` still hovers
|
|
205
|
-
* correctly.
|
|
206
|
-
*
|
|
204
|
+
* correctly. Current snapshots always serialize `originalAlpha`, but we
|
|
205
|
+
* defend against partial payloads here too.
|
|
207
206
|
*
|
|
208
207
|
* @param mask - The mask to refresh handlers on.
|
|
209
208
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mask-style.d.ts","sourceRoot":"","sources":["../../../src/mask/mask-style.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyFG;AAEH,OAAO,KAAK,KAAK,QAAQ,MAAM,QAAQ,CAAC;AACxC,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAwBvF
|
|
1
|
+
{"version":3,"file":"mask-style.d.ts","sourceRoot":"","sources":["../../../src/mask/mask-style.ts"],"names":[],"mappings":"AA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;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAWnE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAiB/D;AAeD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC,CAiC3F;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAsB,mBAAmB,CAAC,CAAC,EACvC,OAAO,EAAE,gBAAgB,EACzB,OAAO,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,EAClD,QAAQ,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GAC/B,OAAO,CAAC,CAAC,CAAC,CAiBZ;AAID;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAM7D"}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @module
|
|
9
9
|
*/
|
|
10
10
|
import type * as FabricNS from 'fabric';
|
|
11
|
-
import type { FabricModule, ImageEditorCallbackContext, ImageEditorOperation, ImageMimeType, ResolvedMosaicConfig, ResolvedOptions } from '../core/public-types.js';
|
|
11
|
+
import type { BaseImageObject, FabricModule, ImageEditorCallbackContext, ImageEditorOperation, ImageMimeType, ResolvedMosaicConfig, ResolvedOptions } from '../core/public-types.js';
|
|
12
12
|
import { type HistoryManager } from '../history/history-manager.js';
|
|
13
13
|
import { type MosaicImagePoint } from './mosaic-geometry.js';
|
|
14
14
|
interface MosaicPreviewCircle extends FabricNS.Circle {
|
|
@@ -49,8 +49,8 @@ export interface MosaicControllerContext {
|
|
|
49
49
|
readonly historyManager: HistoryManager;
|
|
50
50
|
getMosaicConfig(): ResolvedMosaicConfig;
|
|
51
51
|
isImageLoaded(): boolean;
|
|
52
|
-
getOriginalImage():
|
|
53
|
-
setOriginalImage(image:
|
|
52
|
+
getOriginalImage(): BaseImageObject | null;
|
|
53
|
+
setOriginalImage(image: BaseImageObject | null): void;
|
|
54
54
|
getCurrentImageMimeType(): ImageMimeType | null;
|
|
55
55
|
setCurrentImageMimeType(mimeType: ImageMimeType | null): void;
|
|
56
56
|
getLastSnapshot(): string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mosaic-controller.d.ts","sourceRoot":"","sources":["../../../src/mosaic/mosaic-controller.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,KAAK,QAAQ,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"mosaic-controller.d.ts","sourceRoot":"","sources":["../../../src/mosaic/mosaic-controller.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,KAAK,QAAQ,MAAM,QAAQ,CAAC;AAIxC,OAAO,KAAK,EACR,eAAe,EACf,YAAY,EACZ,0BAA0B,EAC1B,oBAAoB,EACpB,aAAa,EACb,oBAAoB,EACpB,eAAe,EAClB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAW,KAAK,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAI7E,OAAO,EAAuB,KAAK,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAGlF,UAAU,mBAAoB,SAAQ,QAAQ,CAAC,MAAM;IACjD,eAAe,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,UAAU,kBAAmB,SAAQ,QAAQ,CAAC,WAAW;IACrD,eAAe,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,MAAM,WAAW,aAAa;IAC1B,aAAa,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAC1C,YAAY,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACxC,aAAa,EAAE,OAAO,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transition used by the ImageEditor facade and image
|
|
4
|
+
* loading pipeline.
|
|
5
5
|
*
|
|
6
6
|
* ## Owned contracts
|
|
7
7
|
*
|
|
@@ -29,6 +29,19 @@
|
|
|
29
29
|
*/
|
|
30
30
|
export declare const SUPPORTED_IMAGE_EXTENSIONS: Record<string, string>;
|
|
31
31
|
export declare const SUPPORTED_IMAGE_MIME_TYPES: Set<string>;
|
|
32
|
+
/**
|
|
33
|
+
* Return true only for image data URLs whose MIME type is accepted by the
|
|
34
|
+
* upload path. This keeps public `loadImage(dataUrl)` validation aligned
|
|
35
|
+
* with file-input validation and rejects unsupported image containers such as
|
|
36
|
+
* SVG before any canvas or lifecycle state is touched.
|
|
37
|
+
*
|
|
38
|
+
* The `data:image/` prefix remains case-sensitive to preserve the previous
|
|
39
|
+
* public no-op contract for non-matching data URL prefixes.
|
|
40
|
+
*
|
|
41
|
+
* @param value - Candidate data URL.
|
|
42
|
+
* @returns True when the data URL carries a supported image MIME type.
|
|
43
|
+
*/
|
|
44
|
+
export declare function isSupportedImageDataUrl(value: unknown): value is string;
|
|
32
45
|
/**
|
|
33
46
|
* Determine whether a `File` is a supported image and return its resolved
|
|
34
47
|
* MIME type, or `null` when it should be rejected.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../../src/utils/file.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,0BAA0B,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAO7D,CAAC;AAEF,eAAO,MAAM,0BAA0B,aAAqD,CAAC;AAE7F;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAO5D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAmB7D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI,GAAG,IAAI,CAOnE"}
|
|
1
|
+
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../../src/utils/file.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,0BAA0B,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAO7D,CAAC;AAEF,eAAO,MAAM,0BAA0B,aAAqD,CAAC;AAE7F;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAMvE;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAO5D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAmB7D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI,GAAG,IAAI,CAOnE"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared browser image element loading primitive.
|
|
3
|
+
*
|
|
4
|
+
* Callers provide their own error factory and validation so image loading and
|
|
5
|
+
* export pipelines can share listener cleanup without sharing domain errors.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
export interface ImageElementLoadHandle {
|
|
10
|
+
promise: Promise<HTMLImageElement>;
|
|
11
|
+
cleanup(clearSource?: boolean): void;
|
|
12
|
+
}
|
|
13
|
+
export interface ImageElementLoadOptions {
|
|
14
|
+
crossOrigin?: string;
|
|
15
|
+
validate?: (imageElement: HTMLImageElement) => Error | null;
|
|
16
|
+
createError: (event: Event | string) => Error;
|
|
17
|
+
}
|
|
18
|
+
export declare function startImageElementLoad(dataUrl: string, options: ImageElementLoadOptions): ImageElementLoadHandle;
|
|
19
|
+
//# sourceMappingURL=image-element-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-element-loader.d.ts","sourceRoot":"","sources":["../../../src/utils/image-element-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,WAAW,sBAAsB;IACnC,OAAO,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACnC,OAAO,CAAC,WAAW,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CACxC;AAED,MAAM,WAAW,uBAAuB;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,CAAC,YAAY,EAAE,gBAAgB,KAAK,KAAK,GAAG,IAAI,CAAC;IAC5D,WAAW,EAAE,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,KAAK,KAAK,CAAC;CACjD;AAED,wBAAgB,qBAAqB,CACjC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,uBAAuB,GACjC,sBAAsB,CAsDxB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fabric event pointer extraction helpers.
|
|
3
|
+
*
|
|
4
|
+
* Supports Fabric v7 `scenePoint`, older pointer fields, and the
|
|
5
|
+
* `canvas.getPointer(event.e)` fallback used by controller event handlers.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import type * as FabricNS from 'fabric';
|
|
10
|
+
export interface CanvasPoint {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
}
|
|
14
|
+
export declare function isFinitePoint(value: unknown): value is CanvasPoint;
|
|
15
|
+
export declare function getPointerFromFabricEvent(canvas: FabricNS.Canvas, event: unknown): CanvasPoint | null;
|
|
16
|
+
//# sourceMappingURL=pointer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pointer.d.ts","sourceRoot":"","sources":["../../../src/utils/pointer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,KAAK,QAAQ,MAAM,QAAQ,CAAC;AAExC,MAAM,WAAW,WAAW;IACxB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACb;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CASlE;AAED,wBAAgB,yBAAyB,CACrC,MAAM,EAAE,QAAQ,CAAC,MAAM,EACvB,KAAK,EAAE,OAAO,GACf,WAAW,GAAG,IAAI,CAwBpB"}
|