@pooder/kit 1.0.0 → 3.0.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/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @pooder/kit
2
2
 
3
+ ## 3.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - Architecture upgrade
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+ - @pooder/core@1.0.0
13
+
14
+ ## 2.0.0
15
+
16
+ ### Major Changes
17
+
18
+ - update
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies
23
+ - @pooder/core@0.1.0
24
+
3
25
  ## 1.0.0
4
26
 
5
27
  ### Major Changes
package/dist/index.d.mts CHANGED
@@ -1,167 +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;
26
+ interface HoleData {
27
+ x: number;
28
+ y: number;
29
+ innerRadius: number;
30
+ outerRadius: number;
33
31
  }
34
- type DielineConfig = DielineToolOptions;
32
+
35
33
  interface DielineGeometry {
36
- shape: 'rect' | 'circle' | 'ellipse';
34
+ shape: "rect" | "circle" | "ellipse" | "custom";
37
35
  x: number;
38
36
  y: number;
39
37
  width: number;
40
38
  height: number;
41
39
  radius: number;
40
+ offset: number;
41
+ borderLength?: number;
42
+ pathData?: string;
42
43
  }
43
- declare class DielineTool implements Extension<DielineToolOptions> {
44
- name: string;
45
- options: DielineToolOptions;
46
- schema: Record<keyof DielineToolOptions, OptionSchema>;
47
- onMount(editor: Editor): void;
48
- onUnmount(editor: Editor): void;
49
- onUpdate(editor: Editor, state: EditorState): void;
50
- 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
+ };
51
88
  private getLayer;
52
89
  private createLayer;
53
90
  private destroyLayer;
54
91
  private createHatchPattern;
55
- updateDieline(editor: Editor): void;
56
- commands: Record<string, Command>;
57
- getGeometry(editor: Editor): DielineGeometry | null;
92
+ updateDieline(emitEvent?: boolean): void;
93
+ getGeometry(): DielineGeometry | null;
94
+ exportCutImage(): string | null;
58
95
  }
59
96
 
60
- interface FilmToolOptions {
61
- url: string;
62
- opacity: number;
63
- }
64
- declare class FilmTool implements Extension<FilmToolOptions> {
65
- name: string;
66
- options: FilmToolOptions;
67
- schema: Record<keyof FilmToolOptions, OptionSchema>;
68
- onMount(editor: Editor): void;
69
- onUnmount(editor: Editor): void;
70
- 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
+ };
71
115
  private initLayer;
72
116
  private updateFilm;
73
- commands: Record<string, Command>;
74
117
  }
75
118
 
76
- interface HoleToolOptions {
77
- innerRadius: number;
78
- outerRadius: number;
79
- style: 'solid' | 'dashed';
80
- holes?: Array<{
81
- x: number;
82
- y: number;
83
- }>;
84
- }
85
- declare class HoleTool implements Extension<HoleToolOptions> {
86
- name: string;
87
- options: HoleToolOptions;
88
- 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;
89
132
  private handleMoving;
90
133
  private handleModified;
91
- onMount(editor: Editor): void;
92
- onUnmount(editor: Editor): void;
93
- onDestroy(editor: Editor): void;
94
- private getDielineGeometry;
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
+ };
95
152
  private setup;
153
+ private initializeHoles;
96
154
  private teardown;
97
- onUpdate(editor: Editor, state: EditorState): void;
98
- commands: Record<string, Command>;
99
155
  private syncHolesFromCanvas;
156
+ private syncHolesToDieline;
100
157
  private redraw;
158
+ enforceConstraints(): boolean;
101
159
  private calculateConstrainedPosition;
102
160
  }
103
161
 
104
- interface ImageToolOptions {
105
- url: string;
106
- opacity: number;
107
- }
108
- declare class ImageTool implements Extension<ImageToolOptions> {
109
- name: string;
110
- options: ImageToolOptions;
111
- schema: Record<keyof ImageToolOptions, OptionSchema>;
112
- onMount(editor: Editor): void;
113
- onUnmount(editor: Editor): void;
114
- onUpdate(editor: Editor, state: EditorState): void;
162
+ declare class ImageTool implements Extension {
163
+ id: string;
164
+ metadata: {
165
+ name: string;
166
+ };
167
+ private _loadingUrl;
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
+ };
115
192
  private ensureLayer;
116
193
  private updateImage;
117
194
  private loadImage;
118
- commands: Record<string, Command>;
119
195
  }
120
196
 
121
- interface WhiteInkToolOptions {
122
- customMask: string;
123
- opacity: number;
124
- enableClip: boolean;
125
- }
126
- declare class WhiteInkTool implements Extension<WhiteInkToolOptions> {
127
- name: string;
128
- options: WhiteInkToolOptions;
129
- 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?;
130
206
  private syncHandler;
131
- onMount(editor: Editor): void;
132
- onUnmount(editor: Editor): void;
133
- 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
+ };
134
219
  private setup;
135
220
  private teardown;
136
- onUpdate(editor: Editor, state: EditorState): void;
137
- commands: Record<string, Command>;
138
221
  private updateWhiteInk;
139
222
  private loadWhiteInk;
140
223
  private applyClipPath;
141
224
  private syncWithUserImage;
142
225
  }
143
226
 
144
- interface RulerToolOptions {
145
- unit: 'px' | 'mm' | 'cm' | 'in';
146
- thickness: number;
147
- backgroundColor: string;
148
- textColor: string;
149
- lineColor: string;
150
- fontSize: number;
151
- }
152
- declare class RulerTool implements Extension<RulerToolOptions> {
153
- name: string;
154
- options: RulerToolOptions;
155
- schema: Record<keyof RulerToolOptions, OptionSchema>;
156
- onMount(editor: Editor): void;
157
- onUnmount(editor: Editor): void;
158
- onUpdate(editor: Editor, state: EditorState): void;
159
- 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
+ };
160
253
  private getLayer;
161
254
  private createLayer;
162
255
  private destroyLayer;
163
256
  private updateRuler;
164
- commands: Record<string, Command>;
165
257
  }
166
258
 
167
- export { BackgroundTool, type DielineConfig, type DielineGeometry, DielineTool, type DielineToolOptions, FilmTool, HoleTool, type HoleToolOptions, ImageTool, RulerTool, type RulerToolOptions, WhiteInkTool };
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
+ };
279
+ private applyMirror;
280
+ }
281
+
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 };