@bensitu/image-editor 1.3.1 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/image-editor.esm.js +1019 -375
- package/dist/image-editor.esm.js.map +2 -2
- package/dist/image-editor.esm.min.js +3 -3
- package/dist/image-editor.esm.min.js.map +3 -3
- package/dist/image-editor.esm.min.mjs +3 -3
- package/dist/image-editor.esm.min.mjs.map +3 -3
- package/dist/image-editor.esm.mjs +1019 -375
- package/dist/image-editor.esm.mjs.map +2 -2
- package/dist/image-editor.js +1019 -375
- package/dist/image-editor.js.map +2 -2
- package/dist/image-editor.min.js +2 -2
- package/dist/image-editor.min.js.map +3 -3
- package/image-editor.d.ts +25 -12
- package/package.json +3 -5
- package/src/image-editor.js +1105 -396
package/image-editor.d.ts
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
// image-editor.d.ts - TypeScript declarations for @bensitu/image-editor
|
|
2
2
|
|
|
3
3
|
declare module '@bensitu/image-editor' {
|
|
4
|
-
|
|
4
|
+
export interface FabricCanvas {
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface FabricObject {
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface FabricImage extends FabricObject {
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
}
|
|
5
16
|
|
|
6
17
|
export interface LabelOptions {
|
|
7
18
|
/** Receives the mask and its stable zero-based creation index (`mask.maskId - 1`). */
|
|
@@ -38,7 +49,9 @@ declare module '@bensitu/image-editor' {
|
|
|
38
49
|
downsampleOnLoad?: boolean;
|
|
39
50
|
downsampleMaxWidth?: number;
|
|
40
51
|
downsampleMaxHeight?: number;
|
|
41
|
-
downsampleQuality?: number;
|
|
52
|
+
downsampleQuality?: number | null;
|
|
53
|
+
preserveSourceFormat?: boolean;
|
|
54
|
+
downsampleMimeType?: 'jpeg' | 'jpg' | 'png' | 'webp' | 'image/jpeg' | 'image/png' | 'image/webp' | null;
|
|
42
55
|
imageLoadTimeoutMs?: number;
|
|
43
56
|
|
|
44
57
|
exportMultiplier?: number;
|
|
@@ -94,17 +107,17 @@ declare module '@bensitu/image-editor' {
|
|
|
94
107
|
|
|
95
108
|
export interface MaskConfig {
|
|
96
109
|
shape?: 'rect' | 'circle' | 'ellipse' | 'polygon' | string;
|
|
97
|
-
width?: number | string | ((canvas:
|
|
98
|
-
height?: number | string | ((canvas:
|
|
99
|
-
radius?: number | string | ((canvas:
|
|
100
|
-
rx?: number | string | ((canvas:
|
|
101
|
-
ry?: number | string | ((canvas:
|
|
110
|
+
width?: number | string | ((canvas: FabricCanvas, options: ImageEditorOptions) => number);
|
|
111
|
+
height?: number | string | ((canvas: FabricCanvas, options: ImageEditorOptions) => number);
|
|
112
|
+
radius?: number | string | ((canvas: FabricCanvas, options: ImageEditorOptions) => number);
|
|
113
|
+
rx?: number | string | ((canvas: FabricCanvas, options: ImageEditorOptions) => number);
|
|
114
|
+
ry?: number | string | ((canvas: FabricCanvas, options: ImageEditorOptions) => number);
|
|
102
115
|
points?: Array<{ x: number; y: number }> | Array<[number, number]>;
|
|
103
116
|
color?: string;
|
|
104
117
|
alpha?: number;
|
|
105
118
|
gap?: number;
|
|
106
|
-
left?: number | string | ((canvas:
|
|
107
|
-
top?: number | string | ((canvas:
|
|
119
|
+
left?: number | string | ((canvas: FabricCanvas, options: ImageEditorOptions) => number);
|
|
120
|
+
top?: number | string | ((canvas: FabricCanvas, options: ImageEditorOptions) => number);
|
|
108
121
|
angle?: number;
|
|
109
122
|
selectable?: boolean;
|
|
110
123
|
hasControls?: boolean;
|
|
@@ -114,8 +127,8 @@ declare module '@bensitu/image-editor' {
|
|
|
114
127
|
transparentCorners?: boolean;
|
|
115
128
|
strokeUniform?: boolean;
|
|
116
129
|
styles?: Record<string, any>;
|
|
117
|
-
fabricGenerator?: (config: MaskConfig, canvas:
|
|
118
|
-
onCreate?: (mask: MaskObject, canvas:
|
|
130
|
+
fabricGenerator?: (config: MaskConfig, canvas: FabricCanvas, options: ImageEditorOptions) => FabricObject;
|
|
131
|
+
onCreate?: (mask: MaskObject, canvas: FabricCanvas) => void;
|
|
119
132
|
}
|
|
120
133
|
|
|
121
134
|
export interface MaskObject extends FabricObject {
|
|
@@ -151,7 +164,7 @@ declare module '@bensitu/image-editor' {
|
|
|
151
164
|
|
|
152
165
|
export class ImageEditor {
|
|
153
166
|
readonly options: ImageEditorOptions;
|
|
154
|
-
readonly canvas:
|
|
167
|
+
readonly canvas: FabricCanvas | null;
|
|
155
168
|
readonly canvasElement: HTMLCanvasElement | null;
|
|
156
169
|
readonly containerElement: HTMLElement | null;
|
|
157
170
|
readonly placeholderElement: HTMLElement | null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bensitu/image-editor",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "Lightweight canvas-based image editor",
|
|
5
5
|
"main": "./dist/image-editor.js",
|
|
6
6
|
"module": "./dist/image-editor.esm.mjs",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"dev": "node esbuild.config.mjs --watch",
|
|
17
17
|
"build": "node esbuild.config.mjs",
|
|
18
18
|
"build:babel": "babel src --out-dir dist --copy-files",
|
|
19
|
-
"lint": "eslint src",
|
|
19
|
+
"lint": "eslint src docs/js",
|
|
20
20
|
"test": "npm run build && node --test tests/image-editor.test.mjs tests/package.test.mjs"
|
|
21
21
|
},
|
|
22
22
|
"repository": {
|
|
@@ -33,9 +33,6 @@
|
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"fabric": "^5.5.2"
|
|
35
35
|
},
|
|
36
|
-
"overrides": {
|
|
37
|
-
"canvas": "^3.2.3"
|
|
38
|
-
},
|
|
39
36
|
"publishConfig": {
|
|
40
37
|
"access": "public"
|
|
41
38
|
},
|
|
@@ -44,6 +41,7 @@
|
|
|
44
41
|
"@babel/core": "^7.22.9",
|
|
45
42
|
"@babel/preset-env": "^7.22.9",
|
|
46
43
|
"@eslint/js": "^10.0.1",
|
|
44
|
+
"canvas": "^3.2.3",
|
|
47
45
|
"esbuild": "^0.28.0",
|
|
48
46
|
"esbuild-plugin-babel": "^0.2.3",
|
|
49
47
|
"eslint": "^10.4.0",
|