@pooder/kit 3.4.0 → 4.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,22 @@
1
1
  # @pooder/kit
2
2
 
3
+ ## 4.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - Virtual Features
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+ - @pooder/core@2.0.0
13
+
14
+ ## 3.5.0
15
+
16
+ ### Minor Changes
17
+
18
+ - edge features
19
+
3
20
  ## 3.4.0
4
21
 
5
22
  ### Minor Changes
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { Extension, ExtensionContext, ContributionPointIds, ConfigurationContribution, CommandContribution, Service } from '@pooder/core';
1
+ import { Extension, ExtensionContext, ContributionPointIds, ConfigurationContribution, CommandContribution, Service, EventBus } from '@pooder/core';
2
2
  import { Canvas, Group, FabricObject } from 'fabric';
3
3
 
4
4
  declare class BackgroundTool implements Extension {
@@ -25,16 +25,23 @@ declare class BackgroundTool implements Extension {
25
25
 
26
26
  type Unit = "px" | "mm" | "cm" | "in";
27
27
 
28
- type PositionAnchor = "top-left" | "top-center" | "top-right" | "center-left" | "center" | "center-right" | "bottom-left" | "bottom-center" | "bottom-right";
29
- interface HoleData {
30
- x?: number;
31
- y?: number;
32
- shape?: "circle" | "square";
33
- anchor?: PositionAnchor;
34
- offsetX?: number;
35
- offsetY?: number;
36
- innerRadius: number;
37
- outerRadius: number;
28
+ type FeatureOperation = "add" | "subtract";
29
+ type FeatureShape = "rect" | "circle";
30
+ interface DielineFeature {
31
+ id: string;
32
+ groupId?: string;
33
+ operation: FeatureOperation;
34
+ shape: FeatureShape;
35
+ x: number;
36
+ y: number;
37
+ width?: number;
38
+ height?: number;
39
+ radius?: number;
40
+ rotation?: number;
41
+ placement?: "edge" | "internal";
42
+ color?: string;
43
+ strokeDash?: number[];
44
+ skipCut?: boolean;
38
45
  }
39
46
 
40
47
  interface DielineGeometry {
@@ -48,6 +55,29 @@ interface DielineGeometry {
48
55
  offset: number;
49
56
  borderLength?: number;
50
57
  scale?: number;
58
+ strokeWidth?: number;
59
+ pathData?: string;
60
+ }
61
+ interface LineStyle {
62
+ width: number;
63
+ color: string;
64
+ dashLength: number;
65
+ style: "solid" | "dashed" | "hidden";
66
+ }
67
+ interface DielineState {
68
+ unit: Unit;
69
+ shape: "rect" | "circle" | "ellipse" | "custom";
70
+ width: number;
71
+ height: number;
72
+ radius: number;
73
+ offset: number;
74
+ padding: number | string;
75
+ mainLine: LineStyle;
76
+ offsetLine: LineStyle;
77
+ insideColor: string;
78
+ outsideColor: string;
79
+ showBleedLines: boolean;
80
+ features: DielineFeature[];
51
81
  pathData?: string;
52
82
  }
53
83
  declare class DielineTool implements Extension {
@@ -55,41 +85,10 @@ declare class DielineTool implements Extension {
55
85
  metadata: {
56
86
  name: string;
57
87
  };
58
- private unit;
59
- private shape;
60
- private width;
61
- private height;
62
- private radius;
63
- private offset;
64
- private style;
65
- private insideColor;
66
- private outsideColor;
67
- private showBleedLines;
68
- private holes;
69
- private position?;
70
- private padding;
71
- private pathData?;
88
+ private state;
72
89
  private canvasService?;
73
90
  private context?;
74
- constructor(options?: Partial<{
75
- unit: Unit;
76
- shape: "rect" | "circle" | "ellipse" | "custom";
77
- width: number;
78
- height: number;
79
- radius: number;
80
- position: {
81
- x: number;
82
- y: number;
83
- };
84
- padding: number | string;
85
- offset: number;
86
- style: "solid" | "dashed";
87
- insideColor: string;
88
- outsideColor: string;
89
- showBleedLines: boolean;
90
- holes: HoleData[];
91
- pathData: string;
92
- }>);
91
+ constructor(options?: Partial<DielineState>);
93
92
  activate(context: ExtensionContext): void;
94
93
  deactivate(context: ExtensionContext): void;
95
94
  contribute(): {
@@ -128,38 +127,39 @@ declare class FilmTool implements Extension {
128
127
  private updateFilm;
129
128
  }
130
129
 
131
- declare class HoleTool implements Extension {
130
+ declare class FeatureTool implements Extension {
132
131
  id: string;
133
132
  metadata: {
134
133
  name: string;
135
134
  };
136
- private holes;
137
- private constraintTarget;
135
+ private features;
138
136
  private canvasService?;
139
137
  private context?;
140
138
  private isUpdatingConfig;
139
+ private isToolActive;
141
140
  private handleMoving;
142
141
  private handleModified;
143
142
  private handleDielineChange;
144
143
  private currentGeometry;
145
144
  constructor(options?: Partial<{
146
- holes: HoleData[];
147
- constraintTarget: "original" | "bleed";
145
+ features: DielineFeature[];
148
146
  }>);
149
147
  activate(context: ExtensionContext): void;
150
148
  deactivate(context: ExtensionContext): void;
149
+ private onToolActivated;
150
+ private updateVisibility;
151
151
  contribute(): {
152
- [ContributionPointIds.CONFIGURATIONS]: ConfigurationContribution[];
153
152
  [ContributionPointIds.COMMANDS]: CommandContribution[];
154
153
  };
154
+ private addFeature;
155
+ private addDoubleLayerHole;
156
+ private getGeometryForFeature;
155
157
  private setup;
156
- private initializeHoles;
157
158
  private teardown;
158
- private syncHolesFromCanvas;
159
- private syncHolesToDieline;
159
+ private constrainPosition;
160
+ private syncFeatureFromCanvas;
160
161
  private redraw;
161
- enforceConstraints(): boolean;
162
- private calculateConstrainedPosition;
162
+ private enforceConstraints;
163
163
  }
164
164
 
165
165
  interface ImageItem {
@@ -182,8 +182,11 @@ declare class ImageTool implements Extension {
182
182
  private canvasService?;
183
183
  private context?;
184
184
  private isUpdatingConfig;
185
+ private isToolActive;
185
186
  activate(context: ExtensionContext): void;
186
187
  deactivate(context: ExtensionContext): void;
188
+ private onToolActivated;
189
+ private updateInteractivity;
187
190
  contribute(): {
188
191
  [ContributionPointIds.CONFIGURATIONS]: ConfigurationContribution[];
189
192
  [ContributionPointIds.COMMANDS]: CommandContribution[];
@@ -292,7 +295,10 @@ declare class MirrorTool implements Extension {
292
295
 
293
296
  declare class CanvasService implements Service {
294
297
  canvas: Canvas;
298
+ private eventBus?;
295
299
  constructor(el: HTMLCanvasElement | string | Canvas, options?: any);
300
+ setEventBus(eventBus: EventBus): void;
301
+ private setupEvents;
296
302
  dispose(): void;
297
303
  /**
298
304
  * Get a layer (Group) by its ID.
@@ -310,4 +316,4 @@ declare class CanvasService implements Service {
310
316
  requestRenderAll(): void;
311
317
  }
312
318
 
313
- export { BackgroundTool, CanvasService, type DielineGeometry, DielineTool, FilmTool, HoleTool, type ImageItem, ImageTool, MirrorTool, RulerTool, WhiteInkTool };
319
+ export { BackgroundTool, CanvasService, type DielineGeometry, type DielineState, DielineTool, FeatureTool, FilmTool, type ImageItem, ImageTool, type LineStyle, MirrorTool, RulerTool, WhiteInkTool };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Extension, ExtensionContext, ContributionPointIds, ConfigurationContribution, CommandContribution, Service } from '@pooder/core';
1
+ import { Extension, ExtensionContext, ContributionPointIds, ConfigurationContribution, CommandContribution, Service, EventBus } from '@pooder/core';
2
2
  import { Canvas, Group, FabricObject } from 'fabric';
3
3
 
4
4
  declare class BackgroundTool implements Extension {
@@ -25,16 +25,23 @@ declare class BackgroundTool implements Extension {
25
25
 
26
26
  type Unit = "px" | "mm" | "cm" | "in";
27
27
 
28
- type PositionAnchor = "top-left" | "top-center" | "top-right" | "center-left" | "center" | "center-right" | "bottom-left" | "bottom-center" | "bottom-right";
29
- interface HoleData {
30
- x?: number;
31
- y?: number;
32
- shape?: "circle" | "square";
33
- anchor?: PositionAnchor;
34
- offsetX?: number;
35
- offsetY?: number;
36
- innerRadius: number;
37
- outerRadius: number;
28
+ type FeatureOperation = "add" | "subtract";
29
+ type FeatureShape = "rect" | "circle";
30
+ interface DielineFeature {
31
+ id: string;
32
+ groupId?: string;
33
+ operation: FeatureOperation;
34
+ shape: FeatureShape;
35
+ x: number;
36
+ y: number;
37
+ width?: number;
38
+ height?: number;
39
+ radius?: number;
40
+ rotation?: number;
41
+ placement?: "edge" | "internal";
42
+ color?: string;
43
+ strokeDash?: number[];
44
+ skipCut?: boolean;
38
45
  }
39
46
 
40
47
  interface DielineGeometry {
@@ -48,6 +55,29 @@ interface DielineGeometry {
48
55
  offset: number;
49
56
  borderLength?: number;
50
57
  scale?: number;
58
+ strokeWidth?: number;
59
+ pathData?: string;
60
+ }
61
+ interface LineStyle {
62
+ width: number;
63
+ color: string;
64
+ dashLength: number;
65
+ style: "solid" | "dashed" | "hidden";
66
+ }
67
+ interface DielineState {
68
+ unit: Unit;
69
+ shape: "rect" | "circle" | "ellipse" | "custom";
70
+ width: number;
71
+ height: number;
72
+ radius: number;
73
+ offset: number;
74
+ padding: number | string;
75
+ mainLine: LineStyle;
76
+ offsetLine: LineStyle;
77
+ insideColor: string;
78
+ outsideColor: string;
79
+ showBleedLines: boolean;
80
+ features: DielineFeature[];
51
81
  pathData?: string;
52
82
  }
53
83
  declare class DielineTool implements Extension {
@@ -55,41 +85,10 @@ declare class DielineTool implements Extension {
55
85
  metadata: {
56
86
  name: string;
57
87
  };
58
- private unit;
59
- private shape;
60
- private width;
61
- private height;
62
- private radius;
63
- private offset;
64
- private style;
65
- private insideColor;
66
- private outsideColor;
67
- private showBleedLines;
68
- private holes;
69
- private position?;
70
- private padding;
71
- private pathData?;
88
+ private state;
72
89
  private canvasService?;
73
90
  private context?;
74
- constructor(options?: Partial<{
75
- unit: Unit;
76
- shape: "rect" | "circle" | "ellipse" | "custom";
77
- width: number;
78
- height: number;
79
- radius: number;
80
- position: {
81
- x: number;
82
- y: number;
83
- };
84
- padding: number | string;
85
- offset: number;
86
- style: "solid" | "dashed";
87
- insideColor: string;
88
- outsideColor: string;
89
- showBleedLines: boolean;
90
- holes: HoleData[];
91
- pathData: string;
92
- }>);
91
+ constructor(options?: Partial<DielineState>);
93
92
  activate(context: ExtensionContext): void;
94
93
  deactivate(context: ExtensionContext): void;
95
94
  contribute(): {
@@ -128,38 +127,39 @@ declare class FilmTool implements Extension {
128
127
  private updateFilm;
129
128
  }
130
129
 
131
- declare class HoleTool implements Extension {
130
+ declare class FeatureTool implements Extension {
132
131
  id: string;
133
132
  metadata: {
134
133
  name: string;
135
134
  };
136
- private holes;
137
- private constraintTarget;
135
+ private features;
138
136
  private canvasService?;
139
137
  private context?;
140
138
  private isUpdatingConfig;
139
+ private isToolActive;
141
140
  private handleMoving;
142
141
  private handleModified;
143
142
  private handleDielineChange;
144
143
  private currentGeometry;
145
144
  constructor(options?: Partial<{
146
- holes: HoleData[];
147
- constraintTarget: "original" | "bleed";
145
+ features: DielineFeature[];
148
146
  }>);
149
147
  activate(context: ExtensionContext): void;
150
148
  deactivate(context: ExtensionContext): void;
149
+ private onToolActivated;
150
+ private updateVisibility;
151
151
  contribute(): {
152
- [ContributionPointIds.CONFIGURATIONS]: ConfigurationContribution[];
153
152
  [ContributionPointIds.COMMANDS]: CommandContribution[];
154
153
  };
154
+ private addFeature;
155
+ private addDoubleLayerHole;
156
+ private getGeometryForFeature;
155
157
  private setup;
156
- private initializeHoles;
157
158
  private teardown;
158
- private syncHolesFromCanvas;
159
- private syncHolesToDieline;
159
+ private constrainPosition;
160
+ private syncFeatureFromCanvas;
160
161
  private redraw;
161
- enforceConstraints(): boolean;
162
- private calculateConstrainedPosition;
162
+ private enforceConstraints;
163
163
  }
164
164
 
165
165
  interface ImageItem {
@@ -182,8 +182,11 @@ declare class ImageTool implements Extension {
182
182
  private canvasService?;
183
183
  private context?;
184
184
  private isUpdatingConfig;
185
+ private isToolActive;
185
186
  activate(context: ExtensionContext): void;
186
187
  deactivate(context: ExtensionContext): void;
188
+ private onToolActivated;
189
+ private updateInteractivity;
187
190
  contribute(): {
188
191
  [ContributionPointIds.CONFIGURATIONS]: ConfigurationContribution[];
189
192
  [ContributionPointIds.COMMANDS]: CommandContribution[];
@@ -292,7 +295,10 @@ declare class MirrorTool implements Extension {
292
295
 
293
296
  declare class CanvasService implements Service {
294
297
  canvas: Canvas;
298
+ private eventBus?;
295
299
  constructor(el: HTMLCanvasElement | string | Canvas, options?: any);
300
+ setEventBus(eventBus: EventBus): void;
301
+ private setupEvents;
296
302
  dispose(): void;
297
303
  /**
298
304
  * Get a layer (Group) by its ID.
@@ -310,4 +316,4 @@ declare class CanvasService implements Service {
310
316
  requestRenderAll(): void;
311
317
  }
312
318
 
313
- export { BackgroundTool, CanvasService, type DielineGeometry, DielineTool, FilmTool, HoleTool, type ImageItem, ImageTool, MirrorTool, RulerTool, WhiteInkTool };
319
+ export { BackgroundTool, CanvasService, type DielineGeometry, type DielineState, DielineTool, FeatureTool, FilmTool, type ImageItem, ImageTool, type LineStyle, MirrorTool, RulerTool, WhiteInkTool };