@pooder/kit 4.1.0 → 4.3.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 +12 -0
- package/dist/index.d.mts +62 -10
- package/dist/index.d.ts +62 -10
- package/dist/index.js +756 -348
- package/dist/index.mjs +753 -347
- package/package.json +3 -2
- package/src/CanvasService.ts +96 -89
- package/src/ViewportSystem.ts +92 -0
- package/src/background.ts +230 -230
- package/src/constraints.ts +191 -27
- package/src/coordinate.ts +106 -106
- package/src/dieline.ts +955 -871
- package/src/feature.ts +282 -195
- package/src/featureComplete.ts +46 -0
- package/src/film.ts +194 -194
- package/src/geometry.ts +161 -30
- package/src/image.ts +512 -512
- package/src/index.ts +10 -9
- package/src/mirror.ts +128 -128
- package/src/ruler.ts +508 -500
- package/src/tracer.ts +570 -570
- package/src/units.ts +27 -0
- package/src/white-ink.ts +373 -373
- package/tsconfig.test.json +15 -0
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -23,7 +23,22 @@ declare class BackgroundTool implements Extension {
|
|
|
23
23
|
private updateBackground;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
interface Point {
|
|
27
|
+
x: number;
|
|
28
|
+
y: number;
|
|
29
|
+
}
|
|
30
|
+
interface Size {
|
|
31
|
+
width: number;
|
|
32
|
+
height: number;
|
|
33
|
+
}
|
|
26
34
|
type Unit = "px" | "mm" | "cm" | "in";
|
|
35
|
+
interface Layout {
|
|
36
|
+
scale: number;
|
|
37
|
+
offsetX: number;
|
|
38
|
+
offsetY: number;
|
|
39
|
+
width: number;
|
|
40
|
+
height: number;
|
|
41
|
+
}
|
|
27
42
|
|
|
28
43
|
type FeatureOperation = "add" | "subtract";
|
|
29
44
|
type FeatureShape = "rect" | "circle";
|
|
@@ -38,19 +53,19 @@ interface DielineFeature {
|
|
|
38
53
|
height?: number;
|
|
39
54
|
radius?: number;
|
|
40
55
|
rotation?: number;
|
|
41
|
-
|
|
56
|
+
renderBehavior?: "edge" | "surface";
|
|
42
57
|
color?: string;
|
|
43
58
|
strokeDash?: number[];
|
|
44
59
|
skipCut?: boolean;
|
|
45
|
-
|
|
46
|
-
type:
|
|
47
|
-
params?: any;
|
|
60
|
+
bridge?: {
|
|
61
|
+
type: "vertical";
|
|
48
62
|
};
|
|
49
63
|
}
|
|
50
64
|
|
|
51
65
|
interface DielineGeometry {
|
|
52
66
|
shape: "rect" | "circle" | "ellipse" | "custom";
|
|
53
|
-
unit:
|
|
67
|
+
unit: "mm";
|
|
68
|
+
displayUnit: Unit;
|
|
54
69
|
x: number;
|
|
55
70
|
y: number;
|
|
56
71
|
width: number;
|
|
@@ -69,7 +84,7 @@ interface LineStyle {
|
|
|
69
84
|
style: "solid" | "dashed" | "hidden";
|
|
70
85
|
}
|
|
71
86
|
interface DielineState {
|
|
72
|
-
|
|
87
|
+
displayUnit: Unit;
|
|
73
88
|
shape: "rect" | "circle" | "ellipse" | "custom";
|
|
74
89
|
width: number;
|
|
75
90
|
height: number;
|
|
@@ -131,12 +146,20 @@ declare class FilmTool implements Extension {
|
|
|
131
146
|
private updateFilm;
|
|
132
147
|
}
|
|
133
148
|
|
|
149
|
+
interface ConstraintFeature extends DielineFeature {
|
|
150
|
+
constraints?: Array<{
|
|
151
|
+
type: string;
|
|
152
|
+
params?: any;
|
|
153
|
+
validateOnly?: boolean;
|
|
154
|
+
}>;
|
|
155
|
+
}
|
|
156
|
+
|
|
134
157
|
declare class FeatureTool implements Extension {
|
|
135
158
|
id: string;
|
|
136
159
|
metadata: {
|
|
137
160
|
name: string;
|
|
138
161
|
};
|
|
139
|
-
private
|
|
162
|
+
private workingFeatures;
|
|
140
163
|
private canvasService?;
|
|
141
164
|
private context?;
|
|
142
165
|
private isUpdatingConfig;
|
|
@@ -146,7 +169,7 @@ declare class FeatureTool implements Extension {
|
|
|
146
169
|
private handleDielineChange;
|
|
147
170
|
private currentGeometry;
|
|
148
171
|
constructor(options?: Partial<{
|
|
149
|
-
features:
|
|
172
|
+
features: ConstraintFeature[];
|
|
150
173
|
}>);
|
|
151
174
|
activate(context: ExtensionContext): void;
|
|
152
175
|
deactivate(context: ExtensionContext): void;
|
|
@@ -155,6 +178,12 @@ declare class FeatureTool implements Extension {
|
|
|
155
178
|
contribute(): {
|
|
156
179
|
[ContributionPointIds.COMMANDS]: CommandContribution[];
|
|
157
180
|
};
|
|
181
|
+
private cloneFeatures;
|
|
182
|
+
private emitWorkingChange;
|
|
183
|
+
private refreshGeometry;
|
|
184
|
+
private setWorkingFeatures;
|
|
185
|
+
private updateWorkingGroupPosition;
|
|
186
|
+
private completeFeatures;
|
|
158
187
|
private addFeature;
|
|
159
188
|
private addDoubleLayerHole;
|
|
160
189
|
private getGeometryForFeature;
|
|
@@ -249,7 +278,7 @@ declare class RulerTool implements Extension {
|
|
|
249
278
|
private fontSize;
|
|
250
279
|
private dielineWidth;
|
|
251
280
|
private dielineHeight;
|
|
252
|
-
private
|
|
281
|
+
private dielineDisplayUnit;
|
|
253
282
|
private dielinePadding;
|
|
254
283
|
private dielineOffset;
|
|
255
284
|
private canvasService?;
|
|
@@ -297,8 +326,31 @@ declare class MirrorTool implements Extension {
|
|
|
297
326
|
private applyMirror;
|
|
298
327
|
}
|
|
299
328
|
|
|
329
|
+
declare function parseLengthToMm(input: number | string, defaultUnit: Unit): number;
|
|
330
|
+
declare function formatMm(valueMm: number, displayUnit: Unit, fractionDigits?: number): string;
|
|
331
|
+
|
|
332
|
+
declare class ViewportSystem {
|
|
333
|
+
private _containerSize;
|
|
334
|
+
private _physicalSize;
|
|
335
|
+
private _padding;
|
|
336
|
+
private _layout;
|
|
337
|
+
constructor(containerSize?: Size, physicalSize?: Size, padding?: number);
|
|
338
|
+
get layout(): Layout;
|
|
339
|
+
get scale(): number;
|
|
340
|
+
get offset(): Point;
|
|
341
|
+
updateContainer(width: number, height: number): void;
|
|
342
|
+
updatePhysical(width: number, height: number): void;
|
|
343
|
+
setPadding(padding: number): void;
|
|
344
|
+
private updateLayout;
|
|
345
|
+
toPixel(value: number): number;
|
|
346
|
+
toPhysical(value: number): number;
|
|
347
|
+
toPixelPoint(point: Point): Point;
|
|
348
|
+
toPhysicalPoint(point: Point): Point;
|
|
349
|
+
}
|
|
350
|
+
|
|
300
351
|
declare class CanvasService implements Service {
|
|
301
352
|
canvas: Canvas;
|
|
353
|
+
viewport: ViewportSystem;
|
|
302
354
|
private eventBus?;
|
|
303
355
|
constructor(el: HTMLCanvasElement | string | Canvas, options?: any);
|
|
304
356
|
setEventBus(eventBus: EventBus): void;
|
|
@@ -320,4 +372,4 @@ declare class CanvasService implements Service {
|
|
|
320
372
|
requestRenderAll(): void;
|
|
321
373
|
}
|
|
322
374
|
|
|
323
|
-
export { BackgroundTool, CanvasService, type DielineGeometry, type DielineState, DielineTool, FeatureTool, FilmTool, type ImageItem, ImageTool, type LineStyle, MirrorTool, RulerTool, WhiteInkTool };
|
|
375
|
+
export { BackgroundTool, CanvasService, type DielineGeometry, type DielineState, DielineTool, FeatureTool, FilmTool, type ImageItem, ImageTool, type LineStyle, MirrorTool, RulerTool, WhiteInkTool, formatMm, parseLengthToMm };
|
package/dist/index.d.ts
CHANGED
|
@@ -23,7 +23,22 @@ declare class BackgroundTool implements Extension {
|
|
|
23
23
|
private updateBackground;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
interface Point {
|
|
27
|
+
x: number;
|
|
28
|
+
y: number;
|
|
29
|
+
}
|
|
30
|
+
interface Size {
|
|
31
|
+
width: number;
|
|
32
|
+
height: number;
|
|
33
|
+
}
|
|
26
34
|
type Unit = "px" | "mm" | "cm" | "in";
|
|
35
|
+
interface Layout {
|
|
36
|
+
scale: number;
|
|
37
|
+
offsetX: number;
|
|
38
|
+
offsetY: number;
|
|
39
|
+
width: number;
|
|
40
|
+
height: number;
|
|
41
|
+
}
|
|
27
42
|
|
|
28
43
|
type FeatureOperation = "add" | "subtract";
|
|
29
44
|
type FeatureShape = "rect" | "circle";
|
|
@@ -38,19 +53,19 @@ interface DielineFeature {
|
|
|
38
53
|
height?: number;
|
|
39
54
|
radius?: number;
|
|
40
55
|
rotation?: number;
|
|
41
|
-
|
|
56
|
+
renderBehavior?: "edge" | "surface";
|
|
42
57
|
color?: string;
|
|
43
58
|
strokeDash?: number[];
|
|
44
59
|
skipCut?: boolean;
|
|
45
|
-
|
|
46
|
-
type:
|
|
47
|
-
params?: any;
|
|
60
|
+
bridge?: {
|
|
61
|
+
type: "vertical";
|
|
48
62
|
};
|
|
49
63
|
}
|
|
50
64
|
|
|
51
65
|
interface DielineGeometry {
|
|
52
66
|
shape: "rect" | "circle" | "ellipse" | "custom";
|
|
53
|
-
unit:
|
|
67
|
+
unit: "mm";
|
|
68
|
+
displayUnit: Unit;
|
|
54
69
|
x: number;
|
|
55
70
|
y: number;
|
|
56
71
|
width: number;
|
|
@@ -69,7 +84,7 @@ interface LineStyle {
|
|
|
69
84
|
style: "solid" | "dashed" | "hidden";
|
|
70
85
|
}
|
|
71
86
|
interface DielineState {
|
|
72
|
-
|
|
87
|
+
displayUnit: Unit;
|
|
73
88
|
shape: "rect" | "circle" | "ellipse" | "custom";
|
|
74
89
|
width: number;
|
|
75
90
|
height: number;
|
|
@@ -131,12 +146,20 @@ declare class FilmTool implements Extension {
|
|
|
131
146
|
private updateFilm;
|
|
132
147
|
}
|
|
133
148
|
|
|
149
|
+
interface ConstraintFeature extends DielineFeature {
|
|
150
|
+
constraints?: Array<{
|
|
151
|
+
type: string;
|
|
152
|
+
params?: any;
|
|
153
|
+
validateOnly?: boolean;
|
|
154
|
+
}>;
|
|
155
|
+
}
|
|
156
|
+
|
|
134
157
|
declare class FeatureTool implements Extension {
|
|
135
158
|
id: string;
|
|
136
159
|
metadata: {
|
|
137
160
|
name: string;
|
|
138
161
|
};
|
|
139
|
-
private
|
|
162
|
+
private workingFeatures;
|
|
140
163
|
private canvasService?;
|
|
141
164
|
private context?;
|
|
142
165
|
private isUpdatingConfig;
|
|
@@ -146,7 +169,7 @@ declare class FeatureTool implements Extension {
|
|
|
146
169
|
private handleDielineChange;
|
|
147
170
|
private currentGeometry;
|
|
148
171
|
constructor(options?: Partial<{
|
|
149
|
-
features:
|
|
172
|
+
features: ConstraintFeature[];
|
|
150
173
|
}>);
|
|
151
174
|
activate(context: ExtensionContext): void;
|
|
152
175
|
deactivate(context: ExtensionContext): void;
|
|
@@ -155,6 +178,12 @@ declare class FeatureTool implements Extension {
|
|
|
155
178
|
contribute(): {
|
|
156
179
|
[ContributionPointIds.COMMANDS]: CommandContribution[];
|
|
157
180
|
};
|
|
181
|
+
private cloneFeatures;
|
|
182
|
+
private emitWorkingChange;
|
|
183
|
+
private refreshGeometry;
|
|
184
|
+
private setWorkingFeatures;
|
|
185
|
+
private updateWorkingGroupPosition;
|
|
186
|
+
private completeFeatures;
|
|
158
187
|
private addFeature;
|
|
159
188
|
private addDoubleLayerHole;
|
|
160
189
|
private getGeometryForFeature;
|
|
@@ -249,7 +278,7 @@ declare class RulerTool implements Extension {
|
|
|
249
278
|
private fontSize;
|
|
250
279
|
private dielineWidth;
|
|
251
280
|
private dielineHeight;
|
|
252
|
-
private
|
|
281
|
+
private dielineDisplayUnit;
|
|
253
282
|
private dielinePadding;
|
|
254
283
|
private dielineOffset;
|
|
255
284
|
private canvasService?;
|
|
@@ -297,8 +326,31 @@ declare class MirrorTool implements Extension {
|
|
|
297
326
|
private applyMirror;
|
|
298
327
|
}
|
|
299
328
|
|
|
329
|
+
declare function parseLengthToMm(input: number | string, defaultUnit: Unit): number;
|
|
330
|
+
declare function formatMm(valueMm: number, displayUnit: Unit, fractionDigits?: number): string;
|
|
331
|
+
|
|
332
|
+
declare class ViewportSystem {
|
|
333
|
+
private _containerSize;
|
|
334
|
+
private _physicalSize;
|
|
335
|
+
private _padding;
|
|
336
|
+
private _layout;
|
|
337
|
+
constructor(containerSize?: Size, physicalSize?: Size, padding?: number);
|
|
338
|
+
get layout(): Layout;
|
|
339
|
+
get scale(): number;
|
|
340
|
+
get offset(): Point;
|
|
341
|
+
updateContainer(width: number, height: number): void;
|
|
342
|
+
updatePhysical(width: number, height: number): void;
|
|
343
|
+
setPadding(padding: number): void;
|
|
344
|
+
private updateLayout;
|
|
345
|
+
toPixel(value: number): number;
|
|
346
|
+
toPhysical(value: number): number;
|
|
347
|
+
toPixelPoint(point: Point): Point;
|
|
348
|
+
toPhysicalPoint(point: Point): Point;
|
|
349
|
+
}
|
|
350
|
+
|
|
300
351
|
declare class CanvasService implements Service {
|
|
301
352
|
canvas: Canvas;
|
|
353
|
+
viewport: ViewportSystem;
|
|
302
354
|
private eventBus?;
|
|
303
355
|
constructor(el: HTMLCanvasElement | string | Canvas, options?: any);
|
|
304
356
|
setEventBus(eventBus: EventBus): void;
|
|
@@ -320,4 +372,4 @@ declare class CanvasService implements Service {
|
|
|
320
372
|
requestRenderAll(): void;
|
|
321
373
|
}
|
|
322
374
|
|
|
323
|
-
export { BackgroundTool, CanvasService, type DielineGeometry, type DielineState, DielineTool, FeatureTool, FilmTool, type ImageItem, ImageTool, type LineStyle, MirrorTool, RulerTool, WhiteInkTool };
|
|
375
|
+
export { BackgroundTool, CanvasService, type DielineGeometry, type DielineState, DielineTool, FeatureTool, FilmTool, type ImageItem, ImageTool, type LineStyle, MirrorTool, RulerTool, WhiteInkTool, formatMm, parseLengthToMm };
|