@pooder/kit 5.1.0 → 5.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.
Files changed (86) hide show
  1. package/.test-dist/src/CanvasService.js +249 -249
  2. package/.test-dist/src/ViewportSystem.js +75 -75
  3. package/.test-dist/src/background.js +203 -203
  4. package/.test-dist/src/bridgeSelection.js +20 -20
  5. package/.test-dist/src/constraints.js +237 -237
  6. package/.test-dist/src/dieline.js +818 -818
  7. package/.test-dist/src/edgeScale.js +12 -12
  8. package/.test-dist/src/extensions/background.js +203 -0
  9. package/.test-dist/src/extensions/bridgeSelection.js +20 -0
  10. package/.test-dist/src/extensions/constraints.js +237 -0
  11. package/.test-dist/src/extensions/dieline.js +828 -0
  12. package/.test-dist/src/extensions/edgeScale.js +12 -0
  13. package/.test-dist/src/extensions/feature.js +825 -0
  14. package/.test-dist/src/extensions/featureComplete.js +32 -0
  15. package/.test-dist/src/extensions/film.js +167 -0
  16. package/.test-dist/src/extensions/geometry.js +545 -0
  17. package/.test-dist/src/extensions/image.js +1529 -0
  18. package/.test-dist/src/extensions/index.js +30 -0
  19. package/.test-dist/src/extensions/maskOps.js +279 -0
  20. package/.test-dist/src/extensions/mirror.js +104 -0
  21. package/.test-dist/src/extensions/ruler.js +345 -0
  22. package/.test-dist/src/extensions/sceneLayout.js +96 -0
  23. package/.test-dist/src/extensions/sceneLayoutModel.js +196 -0
  24. package/.test-dist/src/extensions/sceneVisibility.js +62 -0
  25. package/.test-dist/src/extensions/size.js +331 -0
  26. package/.test-dist/src/extensions/tracer.js +538 -0
  27. package/.test-dist/src/extensions/white-ink.js +1190 -0
  28. package/.test-dist/src/extensions/wrappedOffsets.js +33 -0
  29. package/.test-dist/src/feature.js +826 -826
  30. package/.test-dist/src/featureComplete.js +32 -32
  31. package/.test-dist/src/film.js +167 -167
  32. package/.test-dist/src/geometry.js +506 -506
  33. package/.test-dist/src/image.js +1250 -1250
  34. package/.test-dist/src/index.js +2 -19
  35. package/.test-dist/src/maskOps.js +270 -270
  36. package/.test-dist/src/mirror.js +104 -104
  37. package/.test-dist/src/renderSpec.js +2 -2
  38. package/.test-dist/src/ruler.js +343 -343
  39. package/.test-dist/src/sceneLayout.js +99 -99
  40. package/.test-dist/src/sceneLayoutModel.js +196 -196
  41. package/.test-dist/src/sceneView.js +40 -40
  42. package/.test-dist/src/sceneVisibility.js +42 -42
  43. package/.test-dist/src/services/CanvasService.js +249 -0
  44. package/.test-dist/src/services/ViewportSystem.js +76 -0
  45. package/.test-dist/src/services/index.js +24 -0
  46. package/.test-dist/src/services/renderSpec.js +2 -0
  47. package/.test-dist/src/size.js +332 -332
  48. package/.test-dist/src/tracer.js +544 -544
  49. package/.test-dist/src/white-ink.js +829 -829
  50. package/.test-dist/src/wrappedOffsets.js +33 -33
  51. package/CHANGELOG.md +12 -0
  52. package/dist/index.d.mts +14 -0
  53. package/dist/index.d.ts +14 -0
  54. package/dist/index.js +3521 -3220
  55. package/dist/index.mjs +3532 -3226
  56. package/package.json +1 -1
  57. package/src/coordinate.ts +106 -106
  58. package/src/extensions/background.ts +230 -230
  59. package/src/extensions/bridgeSelection.ts +17 -17
  60. package/src/extensions/constraints.ts +322 -322
  61. package/src/extensions/dieline.ts +20 -17
  62. package/src/extensions/edgeScale.ts +19 -19
  63. package/src/extensions/feature.ts +1021 -1021
  64. package/src/extensions/featureComplete.ts +46 -46
  65. package/src/extensions/film.ts +194 -194
  66. package/src/extensions/geometry.ts +719 -719
  67. package/src/extensions/image.ts +1924 -1594
  68. package/src/extensions/index.ts +11 -11
  69. package/src/extensions/maskOps.ts +365 -299
  70. package/src/extensions/mirror.ts +128 -128
  71. package/src/extensions/ruler.ts +451 -451
  72. package/src/extensions/sceneLayout.ts +140 -140
  73. package/src/extensions/sceneLayoutModel.ts +342 -342
  74. package/src/extensions/sceneVisibility.ts +71 -71
  75. package/src/extensions/size.ts +389 -389
  76. package/src/extensions/tracer.ts +302 -370
  77. package/src/extensions/white-ink.ts +1489 -1366
  78. package/src/extensions/wrappedOffsets.ts +33 -33
  79. package/src/index.ts +2 -2
  80. package/src/services/CanvasService.ts +300 -300
  81. package/src/services/ViewportSystem.ts +95 -95
  82. package/src/services/index.ts +3 -3
  83. package/src/services/renderSpec.ts +18 -18
  84. package/src/units.ts +27 -27
  85. package/tests/run.ts +118 -118
  86. package/tsconfig.test.json +15 -15
@@ -1,128 +1,128 @@
1
- import {
2
- Extension,
3
- ExtensionContext,
4
- ContributionPointIds,
5
- CommandContribution,
6
- ConfigurationContribution,
7
- } from "@pooder/core";
8
- import { CanvasService } from "../services";
9
-
10
- export class MirrorTool implements Extension {
11
- id = "pooder.kit.mirror";
12
-
13
- public metadata = {
14
- name: "MirrorTool",
15
- };
16
- private enabled = false;
17
-
18
- private canvasService?: CanvasService;
19
-
20
- constructor(
21
- options?: Partial<{
22
- enabled: boolean;
23
- }>,
24
- ) {
25
- if (options) {
26
- Object.assign(this, options);
27
- }
28
- }
29
-
30
- toJSON() {
31
- return {
32
- enabled: this.enabled,
33
- };
34
- }
35
-
36
- loadFromJSON(json: any) {
37
- this.enabled = json.enabled;
38
- }
39
-
40
- activate(context: ExtensionContext) {
41
- this.canvasService = context.services.get<CanvasService>("CanvasService");
42
- if (!this.canvasService) {
43
- console.warn("CanvasService not found for MirrorTool");
44
- return;
45
- }
46
-
47
- const configService = context.services.get<any>("ConfigurationService");
48
- if (configService) {
49
- // Load initial config
50
- this.enabled = configService.get("mirror.enabled", this.enabled);
51
-
52
- // Listen for changes
53
- configService.onAnyChange((e: { key: string; value: any }) => {
54
- if (e.key === "mirror.enabled") {
55
- this.applyMirror(e.value);
56
- }
57
- });
58
- }
59
-
60
- // Initialize with current state (if enabled was persisted)
61
- if (this.enabled) {
62
- this.applyMirror(true);
63
- }
64
- }
65
-
66
- deactivate(context: ExtensionContext) {
67
- this.applyMirror(false);
68
- this.canvasService = undefined;
69
- }
70
-
71
- contribute() {
72
- return {
73
- [ContributionPointIds.CONFIGURATIONS]: [
74
- {
75
- id: "mirror.enabled",
76
- type: "boolean",
77
- label: "Enable Mirror",
78
- default: false,
79
- },
80
- ] as ConfigurationContribution[],
81
- [ContributionPointIds.COMMANDS]: [
82
- {
83
- command: "setMirror",
84
- title: "Set Mirror",
85
- handler: (enabled: boolean) => {
86
- this.applyMirror(enabled);
87
- return true;
88
- },
89
- },
90
- ] as CommandContribution[],
91
- };
92
- }
93
-
94
- private applyMirror(enabled: boolean) {
95
- if (!this.canvasService) return;
96
- const canvas = this.canvasService.canvas;
97
- if (!canvas) return;
98
-
99
- const width = canvas.width || 800;
100
-
101
- // Fabric.js v6+ uses viewportTransform property
102
- let vpt = canvas.viewportTransform || [1, 0, 0, 1, 0, 0];
103
- // Create a copy to avoid mutating the reference directly before setting
104
- vpt = [...vpt];
105
-
106
- // If we are enabling and currently not flipped (scaleX > 0)
107
- // Or disabling and currently flipped (scaleX < 0)
108
- const isFlipped = vpt[0] < 0;
109
-
110
- if (enabled && !isFlipped) {
111
- // Flip scale X
112
- vpt[0] = -vpt[0]; // Flip scale
113
- vpt[4] = width - vpt[4]; // Adjust pan X
114
-
115
- canvas.setViewportTransform(vpt as any);
116
- canvas.requestRenderAll();
117
- this.enabled = true;
118
- } else if (!enabled && isFlipped) {
119
- // Restore
120
- vpt[0] = -vpt[0]; // Unflip scale
121
- vpt[4] = width - vpt[4]; // Restore pan X
122
-
123
- canvas.setViewportTransform(vpt as any);
124
- canvas.requestRenderAll();
125
- this.enabled = false;
126
- }
127
- }
128
- }
1
+ import {
2
+ Extension,
3
+ ExtensionContext,
4
+ ContributionPointIds,
5
+ CommandContribution,
6
+ ConfigurationContribution,
7
+ } from "@pooder/core";
8
+ import { CanvasService } from "../services";
9
+
10
+ export class MirrorTool implements Extension {
11
+ id = "pooder.kit.mirror";
12
+
13
+ public metadata = {
14
+ name: "MirrorTool",
15
+ };
16
+ private enabled = false;
17
+
18
+ private canvasService?: CanvasService;
19
+
20
+ constructor(
21
+ options?: Partial<{
22
+ enabled: boolean;
23
+ }>,
24
+ ) {
25
+ if (options) {
26
+ Object.assign(this, options);
27
+ }
28
+ }
29
+
30
+ toJSON() {
31
+ return {
32
+ enabled: this.enabled,
33
+ };
34
+ }
35
+
36
+ loadFromJSON(json: any) {
37
+ this.enabled = json.enabled;
38
+ }
39
+
40
+ activate(context: ExtensionContext) {
41
+ this.canvasService = context.services.get<CanvasService>("CanvasService");
42
+ if (!this.canvasService) {
43
+ console.warn("CanvasService not found for MirrorTool");
44
+ return;
45
+ }
46
+
47
+ const configService = context.services.get<any>("ConfigurationService");
48
+ if (configService) {
49
+ // Load initial config
50
+ this.enabled = configService.get("mirror.enabled", this.enabled);
51
+
52
+ // Listen for changes
53
+ configService.onAnyChange((e: { key: string; value: any }) => {
54
+ if (e.key === "mirror.enabled") {
55
+ this.applyMirror(e.value);
56
+ }
57
+ });
58
+ }
59
+
60
+ // Initialize with current state (if enabled was persisted)
61
+ if (this.enabled) {
62
+ this.applyMirror(true);
63
+ }
64
+ }
65
+
66
+ deactivate(context: ExtensionContext) {
67
+ this.applyMirror(false);
68
+ this.canvasService = undefined;
69
+ }
70
+
71
+ contribute() {
72
+ return {
73
+ [ContributionPointIds.CONFIGURATIONS]: [
74
+ {
75
+ id: "mirror.enabled",
76
+ type: "boolean",
77
+ label: "Enable Mirror",
78
+ default: false,
79
+ },
80
+ ] as ConfigurationContribution[],
81
+ [ContributionPointIds.COMMANDS]: [
82
+ {
83
+ command: "setMirror",
84
+ title: "Set Mirror",
85
+ handler: (enabled: boolean) => {
86
+ this.applyMirror(enabled);
87
+ return true;
88
+ },
89
+ },
90
+ ] as CommandContribution[],
91
+ };
92
+ }
93
+
94
+ private applyMirror(enabled: boolean) {
95
+ if (!this.canvasService) return;
96
+ const canvas = this.canvasService.canvas;
97
+ if (!canvas) return;
98
+
99
+ const width = canvas.width || 800;
100
+
101
+ // Fabric.js v6+ uses viewportTransform property
102
+ let vpt = canvas.viewportTransform || [1, 0, 0, 1, 0, 0];
103
+ // Create a copy to avoid mutating the reference directly before setting
104
+ vpt = [...vpt];
105
+
106
+ // If we are enabling and currently not flipped (scaleX > 0)
107
+ // Or disabling and currently flipped (scaleX < 0)
108
+ const isFlipped = vpt[0] < 0;
109
+
110
+ if (enabled && !isFlipped) {
111
+ // Flip scale X
112
+ vpt[0] = -vpt[0]; // Flip scale
113
+ vpt[4] = width - vpt[4]; // Adjust pan X
114
+
115
+ canvas.setViewportTransform(vpt as any);
116
+ canvas.requestRenderAll();
117
+ this.enabled = true;
118
+ } else if (!enabled && isFlipped) {
119
+ // Restore
120
+ vpt[0] = -vpt[0]; // Unflip scale
121
+ vpt[4] = width - vpt[4]; // Restore pan X
122
+
123
+ canvas.setViewportTransform(vpt as any);
124
+ canvas.requestRenderAll();
125
+ this.enabled = false;
126
+ }
127
+ }
128
+ }