@pooder/kit 5.0.0 → 5.0.2
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/.test-dist/src/dieline.js +118 -23
- package/.test-dist/src/feature.js +2 -0
- package/CHANGELOG.md +12 -0
- package/dist/index.d.mts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +162 -56
- package/dist/index.mjs +165 -59
- package/package.json +1 -1
- package/src/dieline.ts +132 -24
- package/src/image.ts +38 -24
package/src/image.ts
CHANGED
|
@@ -148,10 +148,7 @@ export class ImageTool implements Extension {
|
|
|
148
148
|
context.eventBus.on("selection:created", this.onSelectionChanged);
|
|
149
149
|
context.eventBus.on("selection:updated", this.onSelectionChanged);
|
|
150
150
|
context.eventBus.on("selection:cleared", this.onSelectionCleared);
|
|
151
|
-
context.eventBus.on(
|
|
152
|
-
"scene:layout:change",
|
|
153
|
-
this.onSceneLayoutChanged,
|
|
154
|
-
);
|
|
151
|
+
context.eventBus.on("scene:layout:change", this.onSceneLayoutChanged);
|
|
155
152
|
|
|
156
153
|
const configService = context.services.get<ConfigurationService>(
|
|
157
154
|
"ConfigurationService",
|
|
@@ -198,10 +195,7 @@ export class ImageTool implements Extension {
|
|
|
198
195
|
context.eventBus.off("selection:created", this.onSelectionChanged);
|
|
199
196
|
context.eventBus.off("selection:updated", this.onSelectionChanged);
|
|
200
197
|
context.eventBus.off("selection:cleared", this.onSelectionCleared);
|
|
201
|
-
context.eventBus.off(
|
|
202
|
-
"scene:layout:change",
|
|
203
|
-
this.onSceneLayoutChanged,
|
|
204
|
-
);
|
|
198
|
+
context.eventBus.off("scene:layout:change", this.onSceneLayoutChanged);
|
|
205
199
|
this.dirtyTrackerDisposable?.dispose();
|
|
206
200
|
this.dirtyTrackerDisposable = undefined;
|
|
207
201
|
|
|
@@ -396,7 +390,7 @@ export class ImageTool implements Extension {
|
|
|
396
390
|
id: "image.frame.outerBackground",
|
|
397
391
|
type: "color",
|
|
398
392
|
label: "Image Frame Outer Background",
|
|
399
|
-
default: "
|
|
393
|
+
default: "#f5f5f5",
|
|
400
394
|
},
|
|
401
395
|
] as ConfigurationContribution[],
|
|
402
396
|
[ContributionPointIds.COMMANDS]: [
|
|
@@ -439,6 +433,7 @@ export class ImageTool implements Extension {
|
|
|
439
433
|
this.workingItems = this.cloneItems(this.items);
|
|
440
434
|
this.hasWorkingChanges = false;
|
|
441
435
|
this.updateImages();
|
|
436
|
+
this.emitWorkingChange();
|
|
442
437
|
},
|
|
443
438
|
},
|
|
444
439
|
{
|
|
@@ -578,6 +573,13 @@ export class ImageTool implements Extension {
|
|
|
578
573
|
return this.normalizeItems((items || []).map((i) => ({ ...i })));
|
|
579
574
|
}
|
|
580
575
|
|
|
576
|
+
private emitWorkingChange(changedId: string | null = null) {
|
|
577
|
+
this.context?.eventBus.emit("image:working:change", {
|
|
578
|
+
changedId,
|
|
579
|
+
items: this.cloneItems(this.workingItems),
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
|
|
581
583
|
private generateId(): string {
|
|
582
584
|
return Math.random().toString(36).substring(2, 9);
|
|
583
585
|
}
|
|
@@ -670,6 +672,7 @@ export class ImageTool implements Extension {
|
|
|
670
672
|
if (this.workingItems.some((existing) => existing.id === item.id)) return;
|
|
671
673
|
this.workingItems = this.cloneItems([...this.workingItems, item]);
|
|
672
674
|
this.updateImages();
|
|
675
|
+
this.emitWorkingChange(item.id);
|
|
673
676
|
}
|
|
674
677
|
|
|
675
678
|
private async updateImage(
|
|
@@ -893,11 +896,7 @@ export class ImageTool implements Extension {
|
|
|
893
896
|
"image.frame.innerBackground",
|
|
894
897
|
"rgba(0,0,0,0)",
|
|
895
898
|
) || "rgba(0,0,0,0)",
|
|
896
|
-
outerBackground:
|
|
897
|
-
this.getConfig<string>(
|
|
898
|
-
"image.frame.outerBackground",
|
|
899
|
-
"rgba(0,0,0,0.18)",
|
|
900
|
-
) || "rgba(0,0,0,0.18)",
|
|
899
|
+
outerBackground: "#f5f5f5",
|
|
901
900
|
};
|
|
902
901
|
}
|
|
903
902
|
|
|
@@ -1074,10 +1073,22 @@ export class ImageTool implements Extension {
|
|
|
1074
1073
|
const canvasH = this.canvasService.canvas.height || 0;
|
|
1075
1074
|
const visual = this.getFrameVisualConfig();
|
|
1076
1075
|
|
|
1077
|
-
const
|
|
1078
|
-
const
|
|
1079
|
-
const
|
|
1080
|
-
|
|
1076
|
+
const frameLeft = Math.max(0, Math.min(canvasW, frame.left));
|
|
1077
|
+
const frameTop = Math.max(0, Math.min(canvasH, frame.top));
|
|
1078
|
+
const frameRight = Math.max(
|
|
1079
|
+
frameLeft,
|
|
1080
|
+
Math.min(canvasW, frame.left + frame.width),
|
|
1081
|
+
);
|
|
1082
|
+
const frameBottom = Math.max(
|
|
1083
|
+
frameTop,
|
|
1084
|
+
Math.min(canvasH, frame.top + frame.height),
|
|
1085
|
+
);
|
|
1086
|
+
const visibleFrameH = Math.max(0, frameBottom - frameTop);
|
|
1087
|
+
|
|
1088
|
+
const topH = frameTop;
|
|
1089
|
+
const bottomH = Math.max(0, canvasH - frameBottom);
|
|
1090
|
+
const leftW = frameLeft;
|
|
1091
|
+
const rightW = Math.max(0, canvasW - frameRight);
|
|
1081
1092
|
|
|
1082
1093
|
const mask: RenderObjectSpec[] = [
|
|
1083
1094
|
{
|
|
@@ -1102,7 +1113,7 @@ export class ImageTool implements Extension {
|
|
|
1102
1113
|
data: { id: "image.cropMask.bottom", zIndex: 2 },
|
|
1103
1114
|
props: {
|
|
1104
1115
|
left: canvasW / 2,
|
|
1105
|
-
top:
|
|
1116
|
+
top: frameBottom + bottomH / 2,
|
|
1106
1117
|
width: canvasW,
|
|
1107
1118
|
height: bottomH,
|
|
1108
1119
|
originX: "center",
|
|
@@ -1118,9 +1129,9 @@ export class ImageTool implements Extension {
|
|
|
1118
1129
|
data: { id: "image.cropMask.left", zIndex: 3 },
|
|
1119
1130
|
props: {
|
|
1120
1131
|
left: leftW / 2,
|
|
1121
|
-
top:
|
|
1132
|
+
top: frameTop + visibleFrameH / 2,
|
|
1122
1133
|
width: leftW,
|
|
1123
|
-
height:
|
|
1134
|
+
height: visibleFrameH,
|
|
1124
1135
|
originX: "center",
|
|
1125
1136
|
originY: "center",
|
|
1126
1137
|
fill: visual.outerBackground,
|
|
@@ -1133,10 +1144,10 @@ export class ImageTool implements Extension {
|
|
|
1133
1144
|
type: "rect",
|
|
1134
1145
|
data: { id: "image.cropMask.right", zIndex: 4 },
|
|
1135
1146
|
props: {
|
|
1136
|
-
left:
|
|
1137
|
-
top:
|
|
1147
|
+
left: frameRight + rightW / 2,
|
|
1148
|
+
top: frameTop + visibleFrameH / 2,
|
|
1138
1149
|
width: rightW,
|
|
1139
|
-
height:
|
|
1150
|
+
height: visibleFrameH,
|
|
1140
1151
|
originX: "center",
|
|
1141
1152
|
originY: "center",
|
|
1142
1153
|
fill: visual.outerBackground,
|
|
@@ -1275,6 +1286,7 @@ export class ImageTool implements Extension {
|
|
|
1275
1286
|
if (this.isToolActive) {
|
|
1276
1287
|
this.updateImages();
|
|
1277
1288
|
}
|
|
1289
|
+
this.emitWorkingChange(id);
|
|
1278
1290
|
}
|
|
1279
1291
|
|
|
1280
1292
|
private async updateImageInConfig(id: string, updates: Partial<ImageItem>) {
|
|
@@ -1371,6 +1383,7 @@ export class ImageTool implements Extension {
|
|
|
1371
1383
|
this.isImageSelectionActive = true;
|
|
1372
1384
|
this.focusedImageId = id;
|
|
1373
1385
|
this.updateImages();
|
|
1386
|
+
this.emitWorkingChange(id);
|
|
1374
1387
|
}
|
|
1375
1388
|
|
|
1376
1389
|
private focusImageSelection(id: string) {
|
|
@@ -1489,6 +1502,7 @@ export class ImageTool implements Extension {
|
|
|
1489
1502
|
this.hasWorkingChanges = false;
|
|
1490
1503
|
this.workingItems = this.cloneItems(next);
|
|
1491
1504
|
this.updateConfig(next);
|
|
1505
|
+
this.emitWorkingChange(focusId);
|
|
1492
1506
|
if (focusId) {
|
|
1493
1507
|
this.focusedImageId = focusId;
|
|
1494
1508
|
this.isImageSelectionActive = true;
|