@pooder/kit 5.3.0 → 5.3.1

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 (60) 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/feature.js +826 -826
  9. package/.test-dist/src/featureComplete.js +32 -32
  10. package/.test-dist/src/film.js +167 -167
  11. package/.test-dist/src/geometry.js +506 -506
  12. package/.test-dist/src/image.js +1250 -1250
  13. package/.test-dist/src/maskOps.js +270 -270
  14. package/.test-dist/src/mirror.js +104 -104
  15. package/.test-dist/src/renderSpec.js +2 -2
  16. package/.test-dist/src/ruler.js +343 -343
  17. package/.test-dist/src/sceneLayout.js +99 -99
  18. package/.test-dist/src/sceneLayoutModel.js +196 -196
  19. package/.test-dist/src/sceneView.js +40 -40
  20. package/.test-dist/src/sceneVisibility.js +42 -42
  21. package/.test-dist/src/size.js +332 -332
  22. package/.test-dist/src/tracer.js +544 -544
  23. package/.test-dist/src/white-ink.js +829 -829
  24. package/.test-dist/src/wrappedOffsets.js +33 -33
  25. package/CHANGELOG.md +6 -0
  26. package/dist/index.d.mts +6 -0
  27. package/dist/index.d.ts +6 -0
  28. package/dist/index.js +108 -20
  29. package/dist/index.mjs +108 -20
  30. package/package.json +1 -1
  31. package/src/coordinate.ts +106 -106
  32. package/src/extensions/background.ts +230 -230
  33. package/src/extensions/bridgeSelection.ts +17 -17
  34. package/src/extensions/constraints.ts +322 -322
  35. package/src/extensions/dieline.ts +46 -0
  36. package/src/extensions/edgeScale.ts +19 -19
  37. package/src/extensions/feature.ts +1021 -1021
  38. package/src/extensions/featureComplete.ts +46 -46
  39. package/src/extensions/film.ts +194 -194
  40. package/src/extensions/geometry.ts +752 -719
  41. package/src/extensions/image.ts +1926 -1924
  42. package/src/extensions/index.ts +11 -11
  43. package/src/extensions/maskOps.ts +283 -283
  44. package/src/extensions/mirror.ts +128 -128
  45. package/src/extensions/ruler.ts +451 -451
  46. package/src/extensions/sceneLayout.ts +140 -140
  47. package/src/extensions/sceneLayoutModel.ts +352 -342
  48. package/src/extensions/sceneVisibility.ts +71 -71
  49. package/src/extensions/size.ts +389 -389
  50. package/src/extensions/tracer.ts +58 -19
  51. package/src/extensions/white-ink.ts +1400 -1400
  52. package/src/extensions/wrappedOffsets.ts +33 -33
  53. package/src/index.ts +2 -2
  54. package/src/services/CanvasService.ts +300 -300
  55. package/src/services/ViewportSystem.ts +95 -95
  56. package/src/services/index.ts +3 -3
  57. package/src/services/renderSpec.ts +18 -18
  58. package/src/units.ts +27 -27
  59. package/tests/run.ts +118 -118
  60. package/tsconfig.test.json +15 -15
@@ -1,203 +1,203 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BackgroundTool = void 0;
4
- const core_1 = require("@pooder/core");
5
- const fabric_1 = require("fabric");
6
- class BackgroundTool {
7
- constructor(options) {
8
- this.id = "pooder.kit.background";
9
- this.metadata = {
10
- name: "BackgroundTool",
11
- };
12
- this.color = "";
13
- this.url = "";
14
- if (options) {
15
- Object.assign(this, options);
16
- }
17
- }
18
- activate(context) {
19
- this.canvasService = context.services.get("CanvasService");
20
- if (!this.canvasService) {
21
- console.warn("CanvasService not found for BackgroundTool");
22
- return;
23
- }
24
- const configService = context.services.get("ConfigurationService");
25
- if (configService) {
26
- // Load initial config
27
- this.color = configService.get("background.color", this.color);
28
- this.url = configService.get("background.url", this.url);
29
- // Listen for changes
30
- configService.onAnyChange((e) => {
31
- if (e.key.startsWith("background.")) {
32
- const prop = e.key.split(".")[1];
33
- console.log(`[BackgroundTool] Config change detected: ${e.key} -> ${e.value}, prop: ${prop}`);
34
- if (prop && prop in this) {
35
- console.log(`[BackgroundTool] Updating option ${prop} to ${e.value}`);
36
- this[prop] = e.value;
37
- this.updateBackground();
38
- }
39
- else {
40
- console.warn(`[BackgroundTool] Property ${prop} not found in options`);
41
- }
42
- }
43
- });
44
- }
45
- this.initLayer();
46
- this.updateBackground();
47
- }
48
- deactivate(context) {
49
- if (this.canvasService) {
50
- const layer = this.canvasService.getLayer("background");
51
- if (layer) {
52
- this.canvasService.canvas.remove(layer);
53
- }
54
- this.canvasService = undefined;
55
- }
56
- }
57
- contribute() {
58
- return {
59
- [core_1.ContributionPointIds.CONFIGURATIONS]: [
60
- {
61
- id: "background.color",
62
- type: "color",
63
- label: "Background Color",
64
- default: "",
65
- },
66
- {
67
- id: "background.url",
68
- type: "string",
69
- label: "Image URL",
70
- default: "",
71
- },
72
- ],
73
- [core_1.ContributionPointIds.COMMANDS]: [
74
- {
75
- command: "reset",
76
- title: "Reset Background",
77
- handler: () => {
78
- this.updateBackground();
79
- return true;
80
- },
81
- },
82
- {
83
- command: "clear",
84
- title: "Clear Background",
85
- handler: () => {
86
- this.color = "transparent";
87
- this.url = "";
88
- this.updateBackground();
89
- return true;
90
- },
91
- },
92
- {
93
- command: "setBackgroundColor",
94
- title: "Set Background Color",
95
- handler: (color) => {
96
- if (this.color === color)
97
- return true;
98
- this.color = color;
99
- this.updateBackground();
100
- return true;
101
- },
102
- },
103
- {
104
- command: "setBackgroundImage",
105
- title: "Set Background Image",
106
- handler: (url) => {
107
- if (this.url === url)
108
- return true;
109
- this.url = url;
110
- this.updateBackground();
111
- return true;
112
- },
113
- },
114
- ],
115
- };
116
- }
117
- initLayer() {
118
- if (!this.canvasService)
119
- return;
120
- let backgroundLayer = this.canvasService.getLayer("background");
121
- if (!backgroundLayer) {
122
- backgroundLayer = this.canvasService.createLayer("background", {
123
- width: this.canvasService.canvas.width,
124
- height: this.canvasService.canvas.height,
125
- selectable: false,
126
- evented: false,
127
- });
128
- this.canvasService.canvas.sendObjectToBack(backgroundLayer);
129
- }
130
- }
131
- async updateBackground() {
132
- if (!this.canvasService)
133
- return;
134
- const layer = this.canvasService.getLayer("background");
135
- if (!layer) {
136
- console.warn("[BackgroundTool] Background layer not found");
137
- return;
138
- }
139
- const { color, url } = this;
140
- const width = this.canvasService.canvas.width || 800;
141
- const height = this.canvasService.canvas.height || 600;
142
- let rect = this.canvasService.getObject("background-color-rect", "background");
143
- if (rect) {
144
- rect.set({
145
- fill: color,
146
- });
147
- }
148
- else {
149
- rect = new fabric_1.Rect({
150
- width,
151
- height,
152
- fill: color,
153
- selectable: false,
154
- evented: false,
155
- data: {
156
- id: "background-color-rect",
157
- },
158
- });
159
- layer.add(rect);
160
- layer.sendObjectToBack(rect);
161
- }
162
- let img = this.canvasService.getObject("background-image", "background");
163
- try {
164
- if (img) {
165
- if (img.getSrc() !== url) {
166
- if (url) {
167
- await img.setSrc(url);
168
- }
169
- else {
170
- layer.remove(img);
171
- }
172
- }
173
- }
174
- else {
175
- if (url) {
176
- img = await fabric_1.FabricImage.fromURL(url, { crossOrigin: "anonymous" });
177
- img.set({
178
- originX: "left",
179
- originY: "top",
180
- left: 0,
181
- top: 0,
182
- selectable: false,
183
- evented: false,
184
- data: {
185
- id: "background-image",
186
- },
187
- });
188
- img.scaleToWidth(width);
189
- if (img.getScaledHeight() < height)
190
- img.scaleToHeight(height);
191
- layer.add(img);
192
- }
193
- }
194
- this.canvasService.requestRenderAll();
195
- }
196
- catch (e) {
197
- console.error("[BackgroundTool] Failed to load image", e);
198
- }
199
- layer.dirty = true;
200
- this.canvasService.requestRenderAll();
201
- }
202
- }
203
- exports.BackgroundTool = BackgroundTool;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BackgroundTool = void 0;
4
+ const core_1 = require("@pooder/core");
5
+ const fabric_1 = require("fabric");
6
+ class BackgroundTool {
7
+ constructor(options) {
8
+ this.id = "pooder.kit.background";
9
+ this.metadata = {
10
+ name: "BackgroundTool",
11
+ };
12
+ this.color = "";
13
+ this.url = "";
14
+ if (options) {
15
+ Object.assign(this, options);
16
+ }
17
+ }
18
+ activate(context) {
19
+ this.canvasService = context.services.get("CanvasService");
20
+ if (!this.canvasService) {
21
+ console.warn("CanvasService not found for BackgroundTool");
22
+ return;
23
+ }
24
+ const configService = context.services.get("ConfigurationService");
25
+ if (configService) {
26
+ // Load initial config
27
+ this.color = configService.get("background.color", this.color);
28
+ this.url = configService.get("background.url", this.url);
29
+ // Listen for changes
30
+ configService.onAnyChange((e) => {
31
+ if (e.key.startsWith("background.")) {
32
+ const prop = e.key.split(".")[1];
33
+ console.log(`[BackgroundTool] Config change detected: ${e.key} -> ${e.value}, prop: ${prop}`);
34
+ if (prop && prop in this) {
35
+ console.log(`[BackgroundTool] Updating option ${prop} to ${e.value}`);
36
+ this[prop] = e.value;
37
+ this.updateBackground();
38
+ }
39
+ else {
40
+ console.warn(`[BackgroundTool] Property ${prop} not found in options`);
41
+ }
42
+ }
43
+ });
44
+ }
45
+ this.initLayer();
46
+ this.updateBackground();
47
+ }
48
+ deactivate(context) {
49
+ if (this.canvasService) {
50
+ const layer = this.canvasService.getLayer("background");
51
+ if (layer) {
52
+ this.canvasService.canvas.remove(layer);
53
+ }
54
+ this.canvasService = undefined;
55
+ }
56
+ }
57
+ contribute() {
58
+ return {
59
+ [core_1.ContributionPointIds.CONFIGURATIONS]: [
60
+ {
61
+ id: "background.color",
62
+ type: "color",
63
+ label: "Background Color",
64
+ default: "",
65
+ },
66
+ {
67
+ id: "background.url",
68
+ type: "string",
69
+ label: "Image URL",
70
+ default: "",
71
+ },
72
+ ],
73
+ [core_1.ContributionPointIds.COMMANDS]: [
74
+ {
75
+ command: "reset",
76
+ title: "Reset Background",
77
+ handler: () => {
78
+ this.updateBackground();
79
+ return true;
80
+ },
81
+ },
82
+ {
83
+ command: "clear",
84
+ title: "Clear Background",
85
+ handler: () => {
86
+ this.color = "transparent";
87
+ this.url = "";
88
+ this.updateBackground();
89
+ return true;
90
+ },
91
+ },
92
+ {
93
+ command: "setBackgroundColor",
94
+ title: "Set Background Color",
95
+ handler: (color) => {
96
+ if (this.color === color)
97
+ return true;
98
+ this.color = color;
99
+ this.updateBackground();
100
+ return true;
101
+ },
102
+ },
103
+ {
104
+ command: "setBackgroundImage",
105
+ title: "Set Background Image",
106
+ handler: (url) => {
107
+ if (this.url === url)
108
+ return true;
109
+ this.url = url;
110
+ this.updateBackground();
111
+ return true;
112
+ },
113
+ },
114
+ ],
115
+ };
116
+ }
117
+ initLayer() {
118
+ if (!this.canvasService)
119
+ return;
120
+ let backgroundLayer = this.canvasService.getLayer("background");
121
+ if (!backgroundLayer) {
122
+ backgroundLayer = this.canvasService.createLayer("background", {
123
+ width: this.canvasService.canvas.width,
124
+ height: this.canvasService.canvas.height,
125
+ selectable: false,
126
+ evented: false,
127
+ });
128
+ this.canvasService.canvas.sendObjectToBack(backgroundLayer);
129
+ }
130
+ }
131
+ async updateBackground() {
132
+ if (!this.canvasService)
133
+ return;
134
+ const layer = this.canvasService.getLayer("background");
135
+ if (!layer) {
136
+ console.warn("[BackgroundTool] Background layer not found");
137
+ return;
138
+ }
139
+ const { color, url } = this;
140
+ const width = this.canvasService.canvas.width || 800;
141
+ const height = this.canvasService.canvas.height || 600;
142
+ let rect = this.canvasService.getObject("background-color-rect", "background");
143
+ if (rect) {
144
+ rect.set({
145
+ fill: color,
146
+ });
147
+ }
148
+ else {
149
+ rect = new fabric_1.Rect({
150
+ width,
151
+ height,
152
+ fill: color,
153
+ selectable: false,
154
+ evented: false,
155
+ data: {
156
+ id: "background-color-rect",
157
+ },
158
+ });
159
+ layer.add(rect);
160
+ layer.sendObjectToBack(rect);
161
+ }
162
+ let img = this.canvasService.getObject("background-image", "background");
163
+ try {
164
+ if (img) {
165
+ if (img.getSrc() !== url) {
166
+ if (url) {
167
+ await img.setSrc(url);
168
+ }
169
+ else {
170
+ layer.remove(img);
171
+ }
172
+ }
173
+ }
174
+ else {
175
+ if (url) {
176
+ img = await fabric_1.FabricImage.fromURL(url, { crossOrigin: "anonymous" });
177
+ img.set({
178
+ originX: "left",
179
+ originY: "top",
180
+ left: 0,
181
+ top: 0,
182
+ selectable: false,
183
+ evented: false,
184
+ data: {
185
+ id: "background-image",
186
+ },
187
+ });
188
+ img.scaleToWidth(width);
189
+ if (img.getScaledHeight() < height)
190
+ img.scaleToHeight(height);
191
+ layer.add(img);
192
+ }
193
+ }
194
+ this.canvasService.requestRenderAll();
195
+ }
196
+ catch (e) {
197
+ console.error("[BackgroundTool] Failed to load image", e);
198
+ }
199
+ layer.dirty = true;
200
+ this.canvasService.requestRenderAll();
201
+ }
202
+ }
203
+ exports.BackgroundTool = BackgroundTool;
@@ -1,20 +1,20 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.pickExitIndex = pickExitIndex;
4
- exports.scoreOutsideAbove = scoreOutsideAbove;
5
- function pickExitIndex(hits) {
6
- for (let i = 0; i < hits.length; i++) {
7
- const h = hits[i];
8
- if (h.insideBelow && !h.insideAbove)
9
- return i;
10
- }
11
- return -1;
12
- }
13
- function scoreOutsideAbove(samples) {
14
- let score = 0;
15
- for (const s of samples) {
16
- if (s.outsideAbove)
17
- score++;
18
- }
19
- return score;
20
- }
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pickExitIndex = pickExitIndex;
4
+ exports.scoreOutsideAbove = scoreOutsideAbove;
5
+ function pickExitIndex(hits) {
6
+ for (let i = 0; i < hits.length; i++) {
7
+ const h = hits[i];
8
+ if (h.insideBelow && !h.insideAbove)
9
+ return i;
10
+ }
11
+ return -1;
12
+ }
13
+ function scoreOutsideAbove(samples) {
14
+ let score = 0;
15
+ for (const s of samples) {
16
+ if (s.outsideAbove)
17
+ score++;
18
+ }
19
+ return score;
20
+ }