@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 +22 -0
- package/dist/index.d.mts +250 -115
- package/dist/index.d.ts +250 -115
- package/dist/index.js +2177 -831
- package/dist/index.mjs +2182 -826
- package/package.json +3 -2
- package/src/CanvasService.ts +65 -0
- package/src/background.ts +230 -172
- package/src/coordinate.ts +49 -0
- package/src/dieline.ts +780 -421
- package/src/film.ts +194 -156
- package/src/geometry.ts +464 -244
- package/src/hole.ts +629 -413
- package/src/image.ts +504 -147
- package/src/index.ts +9 -7
- package/src/mirror.ts +128 -0
- package/src/ruler.ts +325 -239
- package/src/tracer.ts +372 -0
- package/src/white-ink.ts +373 -301
- package/tsconfig.json +13 -13
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,
|
|
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;
|
|
26
|
+
interface HoleData {
|
|
27
|
+
x: number;
|
|
28
|
+
y: number;
|
|
29
|
+
innerRadius: number;
|
|
30
|
+
outerRadius: number;
|
|
33
31
|
}
|
|
34
|
-
|
|
32
|
+
|
|
35
33
|
interface DielineGeometry {
|
|
36
|
-
shape:
|
|
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
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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(
|
|
56
|
-
|
|
57
|
-
|
|
92
|
+
updateDieline(emitEvent?: boolean): void;
|
|
93
|
+
getGeometry(): DielineGeometry | null;
|
|
94
|
+
exportCutImage(): string | null;
|
|
58
95
|
}
|
|
59
96
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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
|
-
|
|
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 };
|