@bensitu/image-editor 1.4.0 → 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/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
- import { Canvas, Image as FabricImage, Object as FabricObject } from 'fabric';
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,7 @@ declare module '@bensitu/image-editor' {
38
49
  downsampleOnLoad?: boolean;
39
50
  downsampleMaxWidth?: number;
40
51
  downsampleMaxHeight?: number;
41
- downsampleQuality?: number;
52
+ downsampleQuality?: number | null;
42
53
  preserveSourceFormat?: boolean;
43
54
  downsampleMimeType?: 'jpeg' | 'jpg' | 'png' | 'webp' | 'image/jpeg' | 'image/png' | 'image/webp' | null;
44
55
  imageLoadTimeoutMs?: number;
@@ -96,17 +107,17 @@ declare module '@bensitu/image-editor' {
96
107
 
97
108
  export interface MaskConfig {
98
109
  shape?: 'rect' | 'circle' | 'ellipse' | 'polygon' | string;
99
- width?: number | string | ((canvas: Canvas, options: ImageEditorOptions) => number);
100
- height?: number | string | ((canvas: Canvas, options: ImageEditorOptions) => number);
101
- radius?: number | string | ((canvas: Canvas, options: ImageEditorOptions) => number);
102
- rx?: number | string | ((canvas: Canvas, options: ImageEditorOptions) => number);
103
- ry?: number | string | ((canvas: Canvas, options: ImageEditorOptions) => number);
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);
104
115
  points?: Array<{ x: number; y: number }> | Array<[number, number]>;
105
116
  color?: string;
106
117
  alpha?: number;
107
118
  gap?: number;
108
- left?: number | string | ((canvas: Canvas, options: ImageEditorOptions) => number);
109
- top?: number | string | ((canvas: Canvas, options: ImageEditorOptions) => number);
119
+ left?: number | string | ((canvas: FabricCanvas, options: ImageEditorOptions) => number);
120
+ top?: number | string | ((canvas: FabricCanvas, options: ImageEditorOptions) => number);
110
121
  angle?: number;
111
122
  selectable?: boolean;
112
123
  hasControls?: boolean;
@@ -116,8 +127,8 @@ declare module '@bensitu/image-editor' {
116
127
  transparentCorners?: boolean;
117
128
  strokeUniform?: boolean;
118
129
  styles?: Record<string, any>;
119
- fabricGenerator?: (config: MaskConfig, canvas: Canvas, options: ImageEditorOptions) => FabricObject;
120
- onCreate?: (mask: MaskObject, canvas: Canvas) => void;
130
+ fabricGenerator?: (config: MaskConfig, canvas: FabricCanvas, options: ImageEditorOptions) => FabricObject;
131
+ onCreate?: (mask: MaskObject, canvas: FabricCanvas) => void;
121
132
  }
122
133
 
123
134
  export interface MaskObject extends FabricObject {
@@ -153,7 +164,7 @@ declare module '@bensitu/image-editor' {
153
164
 
154
165
  export class ImageEditor {
155
166
  readonly options: ImageEditorOptions;
156
- readonly canvas: Canvas | null;
167
+ readonly canvas: FabricCanvas | null;
157
168
  readonly canvasElement: HTMLCanvasElement | null;
158
169
  readonly containerElement: HTMLElement | null;
159
170
  readonly placeholderElement: HTMLElement | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bensitu/image-editor",
3
- "version": "1.4.0",
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",
@@ -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",