@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 +18 -0
- package/dist/index.d.mts +246 -134
- package/dist/index.d.ts +246 -134
- package/dist/index.js +2051 -1045
- package/dist/index.mjs +2042 -1050
- package/package.json +3 -2
- package/src/CanvasService.ts +65 -0
- package/src/background.ts +156 -109
- package/src/coordinate.ts +49 -0
- package/src/dieline.ts +536 -336
- package/src/film.ts +120 -89
- package/src/geometry.ts +251 -38
- package/src/hole.ts +422 -286
- package/src/image.ts +374 -174
- package/src/index.ts +1 -0
- package/src/mirror.ts +86 -49
- package/src/ruler.ts +188 -118
- package/src/tracer.ts +372 -0
- package/src/white-ink.ts +186 -142
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,
|
|
1
|
+
import { Extension, ExtensionContext, ContributionPointIds, ConfigurationContribution, CommandContribution, Service } from '@pooder/core';
|
|
2
|
+
import { Canvas, Group, FabricObject } from 'fabric';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
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
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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(
|
|
57
|
-
|
|
58
|
-
|
|
92
|
+
updateDieline(emitEvent?: boolean): void;
|
|
93
|
+
getGeometry(): DielineGeometry | null;
|
|
94
|
+
exportCutImage(): string | null;
|
|
59
95
|
}
|
|
60
96
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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
|
-
|
|
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 };
|