@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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @pooder/kit
2
2
 
3
+ ## 4.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - bridge and constraints
8
+
9
+ ## 4.2.0
10
+
11
+ ### Minor Changes
12
+
13
+ - viewport system, constraints and features
14
+
3
15
  ## 4.1.0
4
16
 
5
17
  ### Minor Changes
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
- placement?: "edge" | "internal";
56
+ renderBehavior?: "edge" | "surface";
42
57
  color?: string;
43
58
  strokeDash?: number[];
44
59
  skipCut?: boolean;
45
- constraints?: {
46
- type: string;
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: 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
- unit: Unit;
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 features;
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: DielineFeature[];
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 dielineUnit;
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
- placement?: "edge" | "internal";
56
+ renderBehavior?: "edge" | "surface";
42
57
  color?: string;
43
58
  strokeDash?: number[];
44
59
  skipCut?: boolean;
45
- constraints?: {
46
- type: string;
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: 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
- unit: Unit;
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 features;
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: DielineFeature[];
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 dielineUnit;
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 };