@pooder/kit 2.0.0 → 3.0.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/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @pooder/kit
2
2
 
3
+ ## 3.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @pooder/core@1.1.0
9
+
10
+ ## 3.0.0
11
+
12
+ ### Major Changes
13
+
14
+ - Architecture upgrade
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies
19
+ - @pooder/core@1.0.0
20
+
3
21
  ## 2.0.0
4
22
 
5
23
  ### Major Changes
package/dist/index.d.mts CHANGED
@@ -1,190 +1,302 @@
1
- import { Extension, OptionSchema, Editor, EditorState, Command } from '@pooder/core';
1
+ import { Extension, ExtensionContext, ContributionPointIds, ConfigurationContribution, CommandContribution, Service } from '@pooder/core';
2
+ import { Canvas, Group, FabricObject } from 'fabric';
2
3
 
3
- interface BackgroundToolOptions {
4
- color: string;
5
- url: string;
6
- }
7
- declare class BackgroundTool implements Extension<BackgroundToolOptions> {
8
- name: string;
9
- options: BackgroundToolOptions;
10
- schema: Record<keyof BackgroundToolOptions, OptionSchema>;
4
+ declare class BackgroundTool implements Extension {
5
+ id: string;
6
+ metadata: {
7
+ name: string;
8
+ };
9
+ private color;
10
+ private url;
11
+ private canvasService?;
12
+ constructor(options?: Partial<{
13
+ color: string;
14
+ url: string;
15
+ }>);
16
+ activate(context: ExtensionContext): void;
17
+ deactivate(context: ExtensionContext): void;
18
+ contribute(): {
19
+ [ContributionPointIds.CONFIGURATIONS]: ConfigurationContribution[];
20
+ [ContributionPointIds.COMMANDS]: CommandContribution[];
21
+ };
11
22
  private initLayer;
12
- onMount(editor: Editor): void;
13
- onUnmount(editor: Editor): void;
14
- onUpdate(editor: Editor, state: EditorState): void;
15
23
  private updateBackground;
16
- commands: Record<string, Command>;
17
24
  }
18
25
 
19
- interface DielineToolOptions {
20
- shape: "rect" | "circle" | "ellipse";
21
- width: number;
22
- height: number;
23
- radius: number;
24
- position?: {
25
- x: number;
26
- y: number;
27
- };
28
- borderLength?: number;
29
- offset: number;
30
- style: "solid" | "dashed";
31
- insideColor: string;
32
- outsideColor: string;
33
- showBleedLines?: boolean;
26
+ interface HoleData {
27
+ x: number;
28
+ y: number;
29
+ innerRadius: number;
30
+ outerRadius: number;
34
31
  }
35
- type DielineConfig = DielineToolOptions;
32
+
36
33
  interface DielineGeometry {
37
- shape: "rect" | "circle" | "ellipse";
34
+ shape: "rect" | "circle" | "ellipse" | "custom";
38
35
  x: number;
39
36
  y: number;
40
37
  width: number;
41
38
  height: number;
42
39
  radius: number;
40
+ offset: number;
41
+ borderLength?: number;
42
+ pathData?: string;
43
43
  }
44
- declare class DielineTool implements Extension<DielineToolOptions> {
45
- name: string;
46
- options: DielineToolOptions;
47
- schema: Record<keyof DielineToolOptions, OptionSchema>;
48
- onMount(editor: Editor): void;
49
- onUnmount(editor: Editor): void;
50
- onUpdate(editor: Editor, state: EditorState): void;
51
- onDestroy(editor: Editor): void;
44
+ declare class DielineTool implements Extension {
45
+ id: string;
46
+ metadata: {
47
+ name: string;
48
+ };
49
+ private shape;
50
+ private width;
51
+ private height;
52
+ private radius;
53
+ private offset;
54
+ private style;
55
+ private insideColor;
56
+ private outsideColor;
57
+ private showBleedLines;
58
+ private holes;
59
+ private position?;
60
+ private borderLength?;
61
+ private pathData?;
62
+ private canvasService?;
63
+ private context?;
64
+ constructor(options?: Partial<{
65
+ shape: "rect" | "circle" | "ellipse" | "custom";
66
+ width: number;
67
+ height: number;
68
+ radius: number;
69
+ position: {
70
+ x: number;
71
+ y: number;
72
+ };
73
+ borderLength: number;
74
+ offset: number;
75
+ style: "solid" | "dashed";
76
+ insideColor: string;
77
+ outsideColor: string;
78
+ showBleedLines: boolean;
79
+ holes: HoleData[];
80
+ pathData: string;
81
+ }>);
82
+ activate(context: ExtensionContext): void;
83
+ deactivate(context: ExtensionContext): void;
84
+ contribute(): {
85
+ [ContributionPointIds.CONFIGURATIONS]: ConfigurationContribution[];
86
+ [ContributionPointIds.COMMANDS]: CommandContribution[];
87
+ };
52
88
  private getLayer;
53
89
  private createLayer;
54
90
  private destroyLayer;
55
91
  private createHatchPattern;
56
- updateDieline(editor: Editor): void;
57
- commands: Record<string, Command>;
58
- getGeometry(editor: Editor): DielineGeometry | null;
92
+ updateDieline(emitEvent?: boolean): void;
93
+ getGeometry(): DielineGeometry | null;
94
+ exportCutImage(): string | null;
59
95
  }
60
96
 
61
- interface FilmToolOptions {
62
- url: string;
63
- opacity: number;
64
- }
65
- declare class FilmTool implements Extension<FilmToolOptions> {
66
- name: string;
67
- options: FilmToolOptions;
68
- schema: Record<keyof FilmToolOptions, OptionSchema>;
69
- onMount(editor: Editor): void;
70
- onUnmount(editor: Editor): void;
71
- onUpdate(editor: Editor, state: EditorState): void;
97
+ declare class FilmTool implements Extension {
98
+ id: string;
99
+ metadata: {
100
+ name: string;
101
+ };
102
+ private url;
103
+ private opacity;
104
+ private canvasService?;
105
+ constructor(options?: Partial<{
106
+ url: string;
107
+ opacity: number;
108
+ }>);
109
+ activate(context: ExtensionContext): void;
110
+ deactivate(context: ExtensionContext): void;
111
+ contribute(): {
112
+ [ContributionPointIds.CONFIGURATIONS]: ConfigurationContribution[];
113
+ [ContributionPointIds.COMMANDS]: CommandContribution[];
114
+ };
72
115
  private initLayer;
73
116
  private updateFilm;
74
- commands: Record<string, Command>;
75
117
  }
76
118
 
77
- interface HoleToolOptions {
78
- innerRadius: number;
79
- outerRadius: number;
80
- style: "solid" | "dashed";
81
- holes?: Array<{
82
- x: number;
83
- y: number;
84
- }>;
85
- constraintTarget?: "original" | "bleed";
86
- }
87
- declare class HoleTool implements Extension<HoleToolOptions> {
88
- name: string;
89
- options: HoleToolOptions;
90
- schema: Record<keyof HoleToolOptions, OptionSchema>;
119
+ declare class HoleTool implements Extension {
120
+ id: string;
121
+ metadata: {
122
+ name: string;
123
+ };
124
+ private innerRadius;
125
+ private outerRadius;
126
+ private style;
127
+ private holes;
128
+ private constraintTarget;
129
+ private canvasService?;
130
+ private context?;
131
+ private isUpdatingConfig;
91
132
  private handleMoving;
92
133
  private handleModified;
93
- onMount(editor: Editor): void;
94
- onUnmount(editor: Editor): void;
95
- onDestroy(editor: Editor): void;
96
- private getDielineGeometry;
97
- enforceConstraints(editor: Editor): void;
134
+ private handleDielineChange;
135
+ private currentGeometry;
136
+ constructor(options?: Partial<{
137
+ innerRadius: number;
138
+ outerRadius: number;
139
+ style: "solid" | "dashed";
140
+ holes: Array<{
141
+ x: number;
142
+ y: number;
143
+ }>;
144
+ constraintTarget: "original" | "bleed";
145
+ }>);
146
+ activate(context: ExtensionContext): void;
147
+ deactivate(context: ExtensionContext): void;
148
+ contribute(): {
149
+ [ContributionPointIds.CONFIGURATIONS]: ConfigurationContribution[];
150
+ [ContributionPointIds.COMMANDS]: CommandContribution[];
151
+ };
98
152
  private setup;
153
+ private initializeHoles;
99
154
  private teardown;
100
- onUpdate(editor: Editor, state: EditorState): void;
101
- commands: Record<string, Command>;
102
155
  private syncHolesFromCanvas;
156
+ private syncHolesToDieline;
103
157
  private redraw;
158
+ enforceConstraints(): boolean;
104
159
  private calculateConstrainedPosition;
105
160
  }
106
161
 
107
- interface ImageToolOptions {
108
- url: string;
109
- opacity: number;
110
- width?: number;
111
- height?: number;
112
- angle?: number;
113
- left?: number;
114
- top?: number;
115
- }
116
- declare class ImageTool implements Extension<ImageToolOptions> {
117
- name: string;
162
+ declare class ImageTool implements Extension {
163
+ id: string;
164
+ metadata: {
165
+ name: string;
166
+ };
118
167
  private _loadingUrl;
119
- options: ImageToolOptions;
120
- schema: Record<keyof ImageToolOptions, OptionSchema>;
121
- onMount(editor: Editor): void;
122
- onUnmount(editor: Editor): void;
123
- onUpdate(editor: Editor, state: EditorState): void;
168
+ private url;
169
+ private opacity;
170
+ private width?;
171
+ private height?;
172
+ private angle?;
173
+ private left?;
174
+ private top?;
175
+ private canvasService?;
176
+ private context?;
177
+ constructor(options?: Partial<{
178
+ url: string;
179
+ opacity: number;
180
+ width: number;
181
+ height: number;
182
+ angle: number;
183
+ left: number;
184
+ top: number;
185
+ }>);
186
+ activate(context: ExtensionContext): void;
187
+ deactivate(context: ExtensionContext): void;
188
+ contribute(): {
189
+ [ContributionPointIds.CONFIGURATIONS]: ConfigurationContribution[];
190
+ [ContributionPointIds.COMMANDS]: CommandContribution[];
191
+ };
124
192
  private ensureLayer;
125
193
  private updateImage;
126
194
  private loadImage;
127
- commands: Record<string, Command>;
128
195
  }
129
196
 
130
- interface WhiteInkToolOptions {
131
- customMask: string;
132
- opacity: number;
133
- enableClip: boolean;
134
- }
135
- declare class WhiteInkTool implements Extension<WhiteInkToolOptions> {
136
- name: string;
137
- options: WhiteInkToolOptions;
138
- schema: Record<keyof WhiteInkToolOptions, OptionSchema>;
197
+ declare class WhiteInkTool implements Extension {
198
+ id: string;
199
+ metadata: {
200
+ name: string;
201
+ };
202
+ private customMask;
203
+ private opacity;
204
+ private enableClip;
205
+ private canvasService?;
139
206
  private syncHandler;
140
- onMount(editor: Editor): void;
141
- onUnmount(editor: Editor): void;
142
- onDestroy(editor: Editor): void;
207
+ private _loadingUrl;
208
+ constructor(options?: Partial<{
209
+ customMask: string;
210
+ opacity: number;
211
+ enableClip: boolean;
212
+ }>);
213
+ activate(context: ExtensionContext): void;
214
+ deactivate(context: ExtensionContext): void;
215
+ contribute(): {
216
+ [ContributionPointIds.CONFIGURATIONS]: ConfigurationContribution[];
217
+ [ContributionPointIds.COMMANDS]: CommandContribution[];
218
+ };
143
219
  private setup;
144
220
  private teardown;
145
- onUpdate(editor: Editor, state: EditorState): void;
146
- commands: Record<string, Command>;
147
221
  private updateWhiteInk;
148
222
  private loadWhiteInk;
149
223
  private applyClipPath;
150
224
  private syncWithUserImage;
151
225
  }
152
226
 
153
- interface RulerToolOptions {
154
- unit: "px" | "mm" | "cm" | "in";
155
- thickness: number;
156
- backgroundColor: string;
157
- textColor: string;
158
- lineColor: string;
159
- fontSize: number;
160
- }
161
- declare class RulerTool implements Extension<RulerToolOptions> {
162
- name: string;
163
- options: RulerToolOptions;
164
- schema: Record<keyof RulerToolOptions, OptionSchema>;
165
- onMount(editor: Editor): void;
166
- onUnmount(editor: Editor): void;
167
- onUpdate(editor: Editor, state: EditorState): void;
168
- onDestroy(editor: Editor): void;
227
+ declare class RulerTool implements Extension {
228
+ id: string;
229
+ metadata: {
230
+ name: string;
231
+ };
232
+ private unit;
233
+ private thickness;
234
+ private backgroundColor;
235
+ private textColor;
236
+ private lineColor;
237
+ private fontSize;
238
+ private canvasService?;
239
+ constructor(options?: Partial<{
240
+ unit: "px" | "mm" | "cm" | "in";
241
+ thickness: number;
242
+ backgroundColor: string;
243
+ textColor: string;
244
+ lineColor: string;
245
+ fontSize: number;
246
+ }>);
247
+ activate(context: ExtensionContext): void;
248
+ deactivate(context: ExtensionContext): void;
249
+ contribute(): {
250
+ [ContributionPointIds.CONFIGURATIONS]: ConfigurationContribution[];
251
+ [ContributionPointIds.COMMANDS]: CommandContribution[];
252
+ };
169
253
  private getLayer;
170
254
  private createLayer;
171
255
  private destroyLayer;
172
256
  private updateRuler;
173
- commands: Record<string, Command>;
174
257
  }
175
258
 
176
- interface MirrorToolOptions {
177
- enabled: boolean;
178
- }
179
- declare class MirrorTool implements Extension<MirrorToolOptions> {
180
- name: string;
181
- options: MirrorToolOptions;
182
- schema: Record<keyof MirrorToolOptions, OptionSchema>;
183
- onMount(editor: Editor): void;
184
- onUpdate(editor: Editor): void;
185
- onUnmount(editor: Editor): void;
259
+ declare class MirrorTool implements Extension {
260
+ id: string;
261
+ metadata: {
262
+ name: string;
263
+ };
264
+ private enabled;
265
+ private canvasService?;
266
+ constructor(options?: Partial<{
267
+ enabled: boolean;
268
+ }>);
269
+ toJSON(): {
270
+ enabled: boolean;
271
+ };
272
+ loadFromJSON(json: any): void;
273
+ activate(context: ExtensionContext): void;
274
+ deactivate(context: ExtensionContext): void;
275
+ contribute(): {
276
+ [ContributionPointIds.CONFIGURATIONS]: ConfigurationContribution[];
277
+ [ContributionPointIds.COMMANDS]: CommandContribution[];
278
+ };
186
279
  private applyMirror;
187
- commands: Record<string, Command>;
188
280
  }
189
281
 
190
- export { BackgroundTool, type DielineConfig, type DielineGeometry, DielineTool, type DielineToolOptions, FilmTool, HoleTool, type HoleToolOptions, ImageTool, MirrorTool, type MirrorToolOptions, RulerTool, type RulerToolOptions, WhiteInkTool };
282
+ declare class CanvasService implements Service {
283
+ canvas: Canvas;
284
+ constructor(el: HTMLCanvasElement | string | Canvas, options?: any);
285
+ dispose(): void;
286
+ /**
287
+ * Get a layer (Group) by its ID.
288
+ * We assume layers are Groups directly on the canvas with a data.id property.
289
+ */
290
+ getLayer(id: string): Group | undefined;
291
+ /**
292
+ * Create a layer (Group) with the given ID if it doesn't exist.
293
+ */
294
+ createLayer(id: string, options?: any): Group;
295
+ /**
296
+ * Find an object by ID, optionally within a specific layer.
297
+ */
298
+ getObject(id: string, layerId?: string): FabricObject | undefined;
299
+ requestRenderAll(): void;
300
+ }
301
+
302
+ export { BackgroundTool, CanvasService, type DielineGeometry, DielineTool, FilmTool, HoleTool, ImageTool, MirrorTool, RulerTool, WhiteInkTool };