@pooder/kit 6.1.2 → 6.2.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/.test-dist/src/extensions/background/BackgroundTool.js +177 -5
- package/.test-dist/src/extensions/constraintUtils.js +44 -0
- package/.test-dist/src/extensions/dieline/DielineTool.js +30 -400
- package/.test-dist/src/extensions/dieline/featureResolution.js +29 -0
- package/.test-dist/src/extensions/dieline/model.js +83 -0
- package/.test-dist/src/extensions/dieline/renderBuilder.js +211 -0
- package/.test-dist/src/extensions/feature/FeatureTool.js +136 -42
- package/.test-dist/src/extensions/image/ImageTool.js +281 -25
- package/.test-dist/src/shared/constants/layers.js +3 -1
- package/CHANGELOG.md +6 -0
- package/dist/index.d.mts +45 -13
- package/dist/index.d.ts +45 -13
- package/dist/index.js +851 -663
- package/dist/index.mjs +838 -653
- package/package.json +1 -1
- package/src/extensions/background/BackgroundTool.ts +264 -4
- package/src/extensions/dieline/DielineTool.ts +38 -539
- package/src/extensions/dieline/model.ts +165 -1
- package/src/extensions/dieline/renderBuilder.ts +275 -0
- package/src/extensions/feature/FeatureTool.ts +167 -44
- package/src/extensions/image/ImageTool.ts +139 -157
- package/src/shared/constants/layers.ts +2 -0
package/dist/index.mjs
CHANGED
|
@@ -400,6 +400,7 @@ var WHITE_INK_OBJECT_LAYER_ID = "white-ink.user";
|
|
|
400
400
|
var WHITE_INK_COVER_LAYER_ID = "white-ink.cover";
|
|
401
401
|
var WHITE_INK_OVERLAY_LAYER_ID = "white-ink.overlay";
|
|
402
402
|
var DIELINE_LAYER_ID = "dieline-overlay";
|
|
403
|
+
var FEATURE_DIELINE_LAYER_ID = "feature-dieline-overlay";
|
|
403
404
|
var FEATURE_OVERLAY_LAYER_ID = "feature-overlay";
|
|
404
405
|
var RULER_LAYER_ID = "ruler-overlay";
|
|
405
406
|
var FILM_LAYER_ID = "overlay";
|
|
@@ -541,6 +542,18 @@ function normalizeFitMode2(value, fallback) {
|
|
|
541
542
|
}
|
|
542
543
|
return fallback;
|
|
543
544
|
}
|
|
545
|
+
function normalizeRegionUnit(value, fallback) {
|
|
546
|
+
if (value === "px" || value === "normalized") {
|
|
547
|
+
return value;
|
|
548
|
+
}
|
|
549
|
+
return fallback;
|
|
550
|
+
}
|
|
551
|
+
function normalizeRegistrationFrame(value, fallback) {
|
|
552
|
+
if (value === "trim" || value === "cut" || value === "bleed" || value === "focus" || value === "viewport") {
|
|
553
|
+
return value;
|
|
554
|
+
}
|
|
555
|
+
return fallback;
|
|
556
|
+
}
|
|
544
557
|
function normalizeAnchor(value, fallback) {
|
|
545
558
|
if (typeof value !== "string") return fallback;
|
|
546
559
|
const trimmed = value.trim();
|
|
@@ -551,6 +564,63 @@ function normalizeOrder(value, fallback) {
|
|
|
551
564
|
if (!Number.isFinite(numeric)) return fallback;
|
|
552
565
|
return numeric;
|
|
553
566
|
}
|
|
567
|
+
function normalizeRegionValue(value, fallback) {
|
|
568
|
+
const numeric = Number(value);
|
|
569
|
+
return Number.isFinite(numeric) ? numeric : fallback;
|
|
570
|
+
}
|
|
571
|
+
function normalizeRegistrationRegion(raw, fallback) {
|
|
572
|
+
if (!raw || typeof raw !== "object") {
|
|
573
|
+
return fallback ? { ...fallback } : void 0;
|
|
574
|
+
}
|
|
575
|
+
const input = raw;
|
|
576
|
+
const base = fallback || {
|
|
577
|
+
left: 0,
|
|
578
|
+
top: 0,
|
|
579
|
+
width: 1,
|
|
580
|
+
height: 1,
|
|
581
|
+
unit: "normalized"
|
|
582
|
+
};
|
|
583
|
+
return {
|
|
584
|
+
left: normalizeRegionValue(input.left, base.left),
|
|
585
|
+
top: normalizeRegionValue(input.top, base.top),
|
|
586
|
+
width: normalizeRegionValue(input.width, base.width),
|
|
587
|
+
height: normalizeRegionValue(input.height, base.height),
|
|
588
|
+
unit: normalizeRegionUnit(input.unit, base.unit)
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
function normalizeRegistration(raw, fallback) {
|
|
592
|
+
if (!raw || typeof raw !== "object") {
|
|
593
|
+
return fallback ? {
|
|
594
|
+
sourceRegion: fallback.sourceRegion ? { ...fallback.sourceRegion } : void 0,
|
|
595
|
+
targetFrame: fallback.targetFrame,
|
|
596
|
+
fit: fallback.fit
|
|
597
|
+
} : void 0;
|
|
598
|
+
}
|
|
599
|
+
const input = raw;
|
|
600
|
+
const normalized = {
|
|
601
|
+
sourceRegion: normalizeRegistrationRegion(
|
|
602
|
+
input.sourceRegion,
|
|
603
|
+
fallback == null ? void 0 : fallback.sourceRegion
|
|
604
|
+
),
|
|
605
|
+
targetFrame: normalizeRegistrationFrame(
|
|
606
|
+
input.targetFrame,
|
|
607
|
+
(fallback == null ? void 0 : fallback.targetFrame) || "trim"
|
|
608
|
+
),
|
|
609
|
+
fit: normalizeFitMode2(input.fit, (fallback == null ? void 0 : fallback.fit) || "stretch")
|
|
610
|
+
};
|
|
611
|
+
if (!normalized.sourceRegion) {
|
|
612
|
+
return void 0;
|
|
613
|
+
}
|
|
614
|
+
return normalized;
|
|
615
|
+
}
|
|
616
|
+
function cloneRegistration(registration) {
|
|
617
|
+
if (!registration) return void 0;
|
|
618
|
+
return {
|
|
619
|
+
sourceRegion: registration.sourceRegion ? { ...registration.sourceRegion } : void 0,
|
|
620
|
+
targetFrame: registration.targetFrame,
|
|
621
|
+
fit: registration.fit
|
|
622
|
+
};
|
|
623
|
+
}
|
|
554
624
|
function normalizeLayer(raw, index, fallback) {
|
|
555
625
|
const fallbackLayer = fallback || {
|
|
556
626
|
id: `layer-${index + 1}`,
|
|
@@ -564,7 +634,10 @@ function normalizeLayer(raw, index, fallback) {
|
|
|
564
634
|
src: ""
|
|
565
635
|
};
|
|
566
636
|
if (!raw || typeof raw !== "object") {
|
|
567
|
-
return {
|
|
637
|
+
return {
|
|
638
|
+
...fallbackLayer,
|
|
639
|
+
registration: cloneRegistration(fallbackLayer.registration)
|
|
640
|
+
};
|
|
568
641
|
}
|
|
569
642
|
const input = raw;
|
|
570
643
|
const kind = normalizeLayerKind(input.kind, fallbackLayer.kind);
|
|
@@ -578,7 +651,8 @@ function normalizeLayer(raw, index, fallback) {
|
|
|
578
651
|
enabled: typeof input.enabled === "boolean" ? input.enabled : fallbackLayer.enabled,
|
|
579
652
|
exportable: typeof input.exportable === "boolean" ? input.exportable : fallbackLayer.exportable,
|
|
580
653
|
color: kind === "color" ? typeof input.color === "string" ? input.color : typeof fallbackLayer.color === "string" ? fallbackLayer.color : "#ffffff" : void 0,
|
|
581
|
-
src: kind === "image" ? typeof input.src === "string" ? input.src.trim() : typeof fallbackLayer.src === "string" ? fallbackLayer.src : "" : void 0
|
|
654
|
+
src: kind === "image" ? typeof input.src === "string" ? input.src.trim() : typeof fallbackLayer.src === "string" ? fallbackLayer.src : "" : void 0,
|
|
655
|
+
registration: kind === "image" ? normalizeRegistration(input.registration, fallbackLayer.registration) : void 0
|
|
582
656
|
};
|
|
583
657
|
}
|
|
584
658
|
function normalizeConfig(raw) {
|
|
@@ -608,7 +682,10 @@ function normalizeConfig(raw) {
|
|
|
608
682
|
function cloneConfig(config) {
|
|
609
683
|
return {
|
|
610
684
|
version: config.version,
|
|
611
|
-
layers: (config.layers || []).map((layer) => ({
|
|
685
|
+
layers: (config.layers || []).map((layer) => ({
|
|
686
|
+
...layer,
|
|
687
|
+
registration: cloneRegistration(layer.registration)
|
|
688
|
+
}))
|
|
612
689
|
};
|
|
613
690
|
}
|
|
614
691
|
function mergeConfig(base, patch) {
|
|
@@ -859,6 +936,41 @@ var BackgroundTool = class {
|
|
|
859
936
|
height: layout.trimRect.height
|
|
860
937
|
};
|
|
861
938
|
}
|
|
939
|
+
resolveTargetFrameRect(frame) {
|
|
940
|
+
if (frame === "viewport") {
|
|
941
|
+
return this.getViewportRect();
|
|
942
|
+
}
|
|
943
|
+
const layout = this.resolveSceneLayout();
|
|
944
|
+
if (!layout) {
|
|
945
|
+
return frame === "focus" ? this.getViewportRect() : null;
|
|
946
|
+
}
|
|
947
|
+
switch (frame) {
|
|
948
|
+
case "trim":
|
|
949
|
+
case "focus":
|
|
950
|
+
return {
|
|
951
|
+
left: layout.trimRect.left,
|
|
952
|
+
top: layout.trimRect.top,
|
|
953
|
+
width: layout.trimRect.width,
|
|
954
|
+
height: layout.trimRect.height
|
|
955
|
+
};
|
|
956
|
+
case "cut":
|
|
957
|
+
return {
|
|
958
|
+
left: layout.cutRect.left,
|
|
959
|
+
top: layout.cutRect.top,
|
|
960
|
+
width: layout.cutRect.width,
|
|
961
|
+
height: layout.cutRect.height
|
|
962
|
+
};
|
|
963
|
+
case "bleed":
|
|
964
|
+
return {
|
|
965
|
+
left: layout.bleedRect.left,
|
|
966
|
+
top: layout.bleedRect.top,
|
|
967
|
+
width: layout.bleedRect.width,
|
|
968
|
+
height: layout.bleedRect.height
|
|
969
|
+
};
|
|
970
|
+
default:
|
|
971
|
+
return null;
|
|
972
|
+
}
|
|
973
|
+
}
|
|
862
974
|
resolveAnchorRect(anchor) {
|
|
863
975
|
if (anchor === "focus") {
|
|
864
976
|
return this.resolveFocusRect() || this.getViewportRect();
|
|
@@ -891,6 +1003,53 @@ var BackgroundTool = class {
|
|
|
891
1003
|
scaleY: scale
|
|
892
1004
|
};
|
|
893
1005
|
}
|
|
1006
|
+
resolveRegistrationRegion(region, sourceSize) {
|
|
1007
|
+
const sourceWidth = Math.max(1, Number(sourceSize.width || 0));
|
|
1008
|
+
const sourceHeight = Math.max(1, Number(sourceSize.height || 0));
|
|
1009
|
+
const width = region.unit === "normalized" ? region.width * sourceWidth : region.width;
|
|
1010
|
+
const height = region.unit === "normalized" ? region.height * sourceHeight : region.height;
|
|
1011
|
+
const left = region.unit === "normalized" ? region.left * sourceWidth : region.left;
|
|
1012
|
+
const top = region.unit === "normalized" ? region.top * sourceHeight : region.top;
|
|
1013
|
+
if (!Number.isFinite(left) || !Number.isFinite(top) || !Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0) {
|
|
1014
|
+
return null;
|
|
1015
|
+
}
|
|
1016
|
+
return { left, top, width, height };
|
|
1017
|
+
}
|
|
1018
|
+
resolveRegistrationPlacement(layer, sourceSize) {
|
|
1019
|
+
const registration = layer.registration;
|
|
1020
|
+
if (!(registration == null ? void 0 : registration.sourceRegion)) return null;
|
|
1021
|
+
const targetRect = this.resolveTargetFrameRect(
|
|
1022
|
+
registration.targetFrame || "trim"
|
|
1023
|
+
);
|
|
1024
|
+
if (!targetRect) return null;
|
|
1025
|
+
const sourceRegion = this.resolveRegistrationRegion(
|
|
1026
|
+
registration.sourceRegion,
|
|
1027
|
+
sourceSize
|
|
1028
|
+
);
|
|
1029
|
+
if (!sourceRegion) return null;
|
|
1030
|
+
const fit = registration.fit || "stretch";
|
|
1031
|
+
const baseScaleX = targetRect.width / sourceRegion.width;
|
|
1032
|
+
const baseScaleY = targetRect.height / sourceRegion.height;
|
|
1033
|
+
if (fit === "stretch") {
|
|
1034
|
+
return {
|
|
1035
|
+
left: targetRect.left - sourceRegion.left * baseScaleX,
|
|
1036
|
+
top: targetRect.top - sourceRegion.top * baseScaleY,
|
|
1037
|
+
scaleX: baseScaleX,
|
|
1038
|
+
scaleY: baseScaleY
|
|
1039
|
+
};
|
|
1040
|
+
}
|
|
1041
|
+
const uniformScale = fit === "contain" ? Math.min(baseScaleX, baseScaleY) : Math.max(baseScaleX, baseScaleY);
|
|
1042
|
+
const alignedWidth = sourceRegion.width * uniformScale;
|
|
1043
|
+
const alignedHeight = sourceRegion.height * uniformScale;
|
|
1044
|
+
const offsetLeft = targetRect.left + (targetRect.width - alignedWidth) / 2;
|
|
1045
|
+
const offsetTop = targetRect.top + (targetRect.height - alignedHeight) / 2;
|
|
1046
|
+
return {
|
|
1047
|
+
left: offsetLeft - sourceRegion.left * uniformScale,
|
|
1048
|
+
top: offsetTop - sourceRegion.top * uniformScale,
|
|
1049
|
+
scaleX: uniformScale,
|
|
1050
|
+
scaleY: uniformScale
|
|
1051
|
+
};
|
|
1052
|
+
}
|
|
894
1053
|
buildColorLayerSpec(layer) {
|
|
895
1054
|
const rect = this.resolveAnchorRect(layer.anchor);
|
|
896
1055
|
return {
|
|
@@ -924,8 +1083,11 @@ var BackgroundTool = class {
|
|
|
924
1083
|
if (!src) return [];
|
|
925
1084
|
const sourceSize = this.sourceSizeCache.getSourceSize(src);
|
|
926
1085
|
if (!sourceSize) return [];
|
|
927
|
-
const
|
|
928
|
-
|
|
1086
|
+
const placement = this.resolveRegistrationPlacement(layer, sourceSize) || this.resolveImagePlacement(
|
|
1087
|
+
this.resolveAnchorRect(layer.anchor),
|
|
1088
|
+
sourceSize,
|
|
1089
|
+
layer.fit
|
|
1090
|
+
);
|
|
929
1091
|
return [
|
|
930
1092
|
{
|
|
931
1093
|
id: `background.layer.${layer.id}.image`,
|
|
@@ -1025,7 +1187,6 @@ import {
|
|
|
1025
1187
|
Canvas as FabricCanvas,
|
|
1026
1188
|
Control,
|
|
1027
1189
|
Image as FabricImage2,
|
|
1028
|
-
Path as FabricPath,
|
|
1029
1190
|
Pattern,
|
|
1030
1191
|
Point,
|
|
1031
1192
|
controlsUtils
|
|
@@ -2000,8 +2161,6 @@ var IMAGE_DEFAULT_CONTROL_CAPABILITIES = [
|
|
|
2000
2161
|
"scale"
|
|
2001
2162
|
];
|
|
2002
2163
|
var IMAGE_MOVE_SNAP_THRESHOLD_PX = 6;
|
|
2003
|
-
var IMAGE_MOVE_SNAP_RELEASE_THRESHOLD_PX = 10;
|
|
2004
|
-
var IMAGE_SNAP_GUIDE_LAYER_ID = "image.snapGuide";
|
|
2005
2164
|
var IMAGE_CONTROL_DESCRIPTORS = [
|
|
2006
2165
|
{
|
|
2007
2166
|
key: "tl",
|
|
@@ -2048,13 +2207,15 @@ var ImageTool = class {
|
|
|
2048
2207
|
this.overlaySpecs = [];
|
|
2049
2208
|
this.activeSnapX = null;
|
|
2050
2209
|
this.activeSnapY = null;
|
|
2210
|
+
this.movingImageId = null;
|
|
2211
|
+
this.hasRenderedSnapGuides = false;
|
|
2051
2212
|
this.subscriptions = new SubscriptionBag();
|
|
2052
2213
|
this.imageControlsByCapabilityKey = /* @__PURE__ */ new Map();
|
|
2053
2214
|
this.onToolActivated = (event) => {
|
|
2054
2215
|
const before = this.isToolActive;
|
|
2055
2216
|
this.syncToolActiveFromWorkbench(event.id);
|
|
2056
2217
|
if (!this.isToolActive) {
|
|
2057
|
-
this.
|
|
2218
|
+
this.endMoveSnapInteraction();
|
|
2058
2219
|
this.setImageFocus(null, {
|
|
2059
2220
|
syncCanvasSelection: true,
|
|
2060
2221
|
skipRender: true
|
|
@@ -2105,7 +2266,7 @@ var ImageTool = class {
|
|
|
2105
2266
|
this.updateImages();
|
|
2106
2267
|
};
|
|
2107
2268
|
this.onSelectionCleared = () => {
|
|
2108
|
-
this.
|
|
2269
|
+
this.endMoveSnapInteraction();
|
|
2109
2270
|
this.setImageFocus(null, {
|
|
2110
2271
|
syncCanvasSelection: false,
|
|
2111
2272
|
skipRender: true
|
|
@@ -2114,7 +2275,8 @@ var ImageTool = class {
|
|
|
2114
2275
|
this.updateImages();
|
|
2115
2276
|
};
|
|
2116
2277
|
this.onSceneLayoutChanged = () => {
|
|
2117
|
-
|
|
2278
|
+
var _a;
|
|
2279
|
+
(_a = this.canvasService) == null ? void 0 : _a.requestRenderAll();
|
|
2118
2280
|
this.updateImages();
|
|
2119
2281
|
};
|
|
2120
2282
|
this.onSceneGeometryChanged = () => {
|
|
@@ -2127,11 +2289,12 @@ var ImageTool = class {
|
|
|
2127
2289
|
const id = (_a = target == null ? void 0 : target.data) == null ? void 0 : _a.id;
|
|
2128
2290
|
const layerId = (_b = target == null ? void 0 : target.data) == null ? void 0 : _b.layerId;
|
|
2129
2291
|
if (typeof id !== "string" || layerId !== IMAGE_OBJECT_LAYER_ID) return;
|
|
2292
|
+
if (this.movingImageId === id) {
|
|
2293
|
+
this.applyMoveSnapToTarget(target);
|
|
2294
|
+
}
|
|
2130
2295
|
const frame = this.getFrameRect();
|
|
2296
|
+
this.endMoveSnapInteraction();
|
|
2131
2297
|
if (!frame.width || !frame.height) return;
|
|
2132
|
-
const matches = this.computeMoveSnapMatches(target, frame);
|
|
2133
|
-
this.applySnapMatchesToTarget(target, matches);
|
|
2134
|
-
this.clearSnapGuides();
|
|
2135
2298
|
const center = target.getCenterPoint ? target.getCenterPoint() : new Point((_c = target.left) != null ? _c : 0, (_d = target.top) != null ? _d : 0);
|
|
2136
2299
|
const centerScene = this.canvasService ? this.canvasService.toScenePoint({ x: center.x, y: center.y }) : { x: center.x, y: center.y };
|
|
2137
2300
|
const objectScale = Number.isFinite(target == null ? void 0 : target.scaleX) ? target.scaleX : 1;
|
|
@@ -2272,7 +2435,7 @@ var ImageTool = class {
|
|
|
2272
2435
|
this.imageSpecs = [];
|
|
2273
2436
|
this.overlaySpecs = [];
|
|
2274
2437
|
this.imageControlsByCapabilityKey.clear();
|
|
2275
|
-
this.
|
|
2438
|
+
this.endMoveSnapInteraction();
|
|
2276
2439
|
this.unbindCanvasInteractionHandlers();
|
|
2277
2440
|
this.clearRenderedImages();
|
|
2278
2441
|
(_b = this.renderProducerDisposable) == null ? void 0 : _b.dispose();
|
|
@@ -2285,21 +2448,61 @@ var ImageTool = class {
|
|
|
2285
2448
|
}
|
|
2286
2449
|
bindCanvasInteractionHandlers() {
|
|
2287
2450
|
if (!this.canvasService || this.canvasObjectMovingHandler) return;
|
|
2451
|
+
this.canvasMouseUpHandler = (e) => {
|
|
2452
|
+
var _a;
|
|
2453
|
+
const target = this.getActiveImageTarget(e == null ? void 0 : e.target);
|
|
2454
|
+
if (target && typeof ((_a = target == null ? void 0 : target.data) == null ? void 0 : _a.id) === "string" && target.data.id === this.movingImageId) {
|
|
2455
|
+
this.applyMoveSnapToTarget(target);
|
|
2456
|
+
}
|
|
2457
|
+
this.endMoveSnapInteraction();
|
|
2458
|
+
};
|
|
2288
2459
|
this.canvasObjectMovingHandler = (e) => {
|
|
2289
2460
|
this.handleCanvasObjectMoving(e);
|
|
2290
2461
|
};
|
|
2462
|
+
this.canvasBeforeRenderHandler = () => {
|
|
2463
|
+
this.handleCanvasBeforeRender();
|
|
2464
|
+
};
|
|
2465
|
+
this.canvasAfterRenderHandler = () => {
|
|
2466
|
+
this.handleCanvasAfterRender();
|
|
2467
|
+
};
|
|
2468
|
+
this.canvasService.canvas.on("mouse:up", this.canvasMouseUpHandler);
|
|
2291
2469
|
this.canvasService.canvas.on(
|
|
2292
2470
|
"object:moving",
|
|
2293
2471
|
this.canvasObjectMovingHandler
|
|
2294
2472
|
);
|
|
2473
|
+
this.canvasService.canvas.on(
|
|
2474
|
+
"before:render",
|
|
2475
|
+
this.canvasBeforeRenderHandler
|
|
2476
|
+
);
|
|
2477
|
+
this.canvasService.canvas.on("after:render", this.canvasAfterRenderHandler);
|
|
2295
2478
|
}
|
|
2296
2479
|
unbindCanvasInteractionHandlers() {
|
|
2297
|
-
if (!this.canvasService
|
|
2298
|
-
this.
|
|
2299
|
-
"
|
|
2300
|
-
|
|
2301
|
-
)
|
|
2480
|
+
if (!this.canvasService) return;
|
|
2481
|
+
if (this.canvasMouseUpHandler) {
|
|
2482
|
+
this.canvasService.canvas.off("mouse:up", this.canvasMouseUpHandler);
|
|
2483
|
+
}
|
|
2484
|
+
if (this.canvasObjectMovingHandler) {
|
|
2485
|
+
this.canvasService.canvas.off(
|
|
2486
|
+
"object:moving",
|
|
2487
|
+
this.canvasObjectMovingHandler
|
|
2488
|
+
);
|
|
2489
|
+
}
|
|
2490
|
+
if (this.canvasBeforeRenderHandler) {
|
|
2491
|
+
this.canvasService.canvas.off(
|
|
2492
|
+
"before:render",
|
|
2493
|
+
this.canvasBeforeRenderHandler
|
|
2494
|
+
);
|
|
2495
|
+
}
|
|
2496
|
+
if (this.canvasAfterRenderHandler) {
|
|
2497
|
+
this.canvasService.canvas.off(
|
|
2498
|
+
"after:render",
|
|
2499
|
+
this.canvasAfterRenderHandler
|
|
2500
|
+
);
|
|
2501
|
+
}
|
|
2502
|
+
this.canvasMouseUpHandler = void 0;
|
|
2302
2503
|
this.canvasObjectMovingHandler = void 0;
|
|
2504
|
+
this.canvasBeforeRenderHandler = void 0;
|
|
2505
|
+
this.canvasAfterRenderHandler = void 0;
|
|
2303
2506
|
}
|
|
2304
2507
|
getActiveImageTarget(target) {
|
|
2305
2508
|
var _a, _b;
|
|
@@ -2328,20 +2531,11 @@ var ImageTool = class {
|
|
|
2328
2531
|
if (!this.canvasService) return px;
|
|
2329
2532
|
return this.canvasService.toSceneLength(px);
|
|
2330
2533
|
}
|
|
2331
|
-
pickSnapMatch(candidates
|
|
2534
|
+
pickSnapMatch(candidates) {
|
|
2332
2535
|
if (!candidates.length) return null;
|
|
2333
2536
|
const snapThreshold = this.getSnapThresholdScene(
|
|
2334
2537
|
IMAGE_MOVE_SNAP_THRESHOLD_PX
|
|
2335
2538
|
);
|
|
2336
|
-
const releaseThreshold = this.getSnapThresholdScene(
|
|
2337
|
-
IMAGE_MOVE_SNAP_RELEASE_THRESHOLD_PX
|
|
2338
|
-
);
|
|
2339
|
-
if (previous) {
|
|
2340
|
-
const sticky = candidates.find((candidate) => {
|
|
2341
|
-
return candidate.lineId === previous.lineId && Math.abs(candidate.deltaScene) <= releaseThreshold;
|
|
2342
|
-
});
|
|
2343
|
-
if (sticky) return sticky;
|
|
2344
|
-
}
|
|
2345
2539
|
let best = null;
|
|
2346
2540
|
candidates.forEach((candidate) => {
|
|
2347
2541
|
if (Math.abs(candidate.deltaScene) > snapThreshold) return;
|
|
@@ -2351,8 +2545,7 @@ var ImageTool = class {
|
|
|
2351
2545
|
});
|
|
2352
2546
|
return best;
|
|
2353
2547
|
}
|
|
2354
|
-
computeMoveSnapMatches(
|
|
2355
|
-
const bounds = this.getTargetBoundsScene(target);
|
|
2548
|
+
computeMoveSnapMatches(bounds, frame) {
|
|
2356
2549
|
if (!bounds || frame.width <= 0 || frame.height <= 0) {
|
|
2357
2550
|
return { x: null, y: null };
|
|
2358
2551
|
}
|
|
@@ -2403,8 +2596,8 @@ var ImageTool = class {
|
|
|
2403
2596
|
}
|
|
2404
2597
|
];
|
|
2405
2598
|
return {
|
|
2406
|
-
x: this.pickSnapMatch(xCandidates
|
|
2407
|
-
y: this.pickSnapMatch(yCandidates
|
|
2599
|
+
x: this.pickSnapMatch(xCandidates),
|
|
2600
|
+
y: this.pickSnapMatch(yCandidates)
|
|
2408
2601
|
};
|
|
2409
2602
|
}
|
|
2410
2603
|
areSnapMatchesEqual(a, b) {
|
|
@@ -2413,136 +2606,123 @@ var ImageTool = class {
|
|
|
2413
2606
|
return a.lineId === b.lineId && a.axis === b.axis && a.kind === b.kind;
|
|
2414
2607
|
}
|
|
2415
2608
|
updateSnapMatchState(nextX, nextY) {
|
|
2609
|
+
var _a;
|
|
2416
2610
|
const changed = !this.areSnapMatchesEqual(this.activeSnapX, nextX) || !this.areSnapMatchesEqual(this.activeSnapY, nextY);
|
|
2417
2611
|
this.activeSnapX = nextX;
|
|
2418
2612
|
this.activeSnapY = nextY;
|
|
2419
2613
|
if (changed) {
|
|
2420
|
-
this.
|
|
2614
|
+
(_a = this.canvasService) == null ? void 0 : _a.requestRenderAll();
|
|
2421
2615
|
}
|
|
2422
2616
|
}
|
|
2423
|
-
|
|
2617
|
+
clearSnapPreview() {
|
|
2424
2618
|
var _a;
|
|
2425
2619
|
this.activeSnapX = null;
|
|
2426
2620
|
this.activeSnapY = null;
|
|
2427
|
-
this.
|
|
2428
|
-
this.removeSnapGuideObject("y");
|
|
2621
|
+
this.hasRenderedSnapGuides = false;
|
|
2429
2622
|
(_a = this.canvasService) == null ? void 0 : _a.requestRenderAll();
|
|
2430
2623
|
}
|
|
2431
|
-
|
|
2624
|
+
endMoveSnapInteraction() {
|
|
2625
|
+
this.movingImageId = null;
|
|
2626
|
+
this.clearSnapPreview();
|
|
2627
|
+
}
|
|
2628
|
+
applyMoveSnapToTarget(target) {
|
|
2629
|
+
var _a, _b, _c, _d;
|
|
2630
|
+
if (!this.canvasService) {
|
|
2631
|
+
return { x: null, y: null };
|
|
2632
|
+
}
|
|
2633
|
+
const frame = this.getFrameRect();
|
|
2634
|
+
if (frame.width <= 0 || frame.height <= 0) {
|
|
2635
|
+
return { x: null, y: null };
|
|
2636
|
+
}
|
|
2637
|
+
const bounds = this.getTargetBoundsScene(target);
|
|
2638
|
+
const matches = this.computeMoveSnapMatches(bounds, frame);
|
|
2639
|
+
const deltaScreenX = this.canvasService.toScreenLength(
|
|
2640
|
+
(_b = (_a = matches.x) == null ? void 0 : _a.deltaScene) != null ? _b : 0
|
|
2641
|
+
);
|
|
2642
|
+
const deltaScreenY = this.canvasService.toScreenLength(
|
|
2643
|
+
(_d = (_c = matches.y) == null ? void 0 : _c.deltaScene) != null ? _d : 0
|
|
2644
|
+
);
|
|
2645
|
+
if (deltaScreenX || deltaScreenY) {
|
|
2646
|
+
target.set({
|
|
2647
|
+
left: Number(target.left || 0) + deltaScreenX,
|
|
2648
|
+
top: Number(target.top || 0) + deltaScreenY
|
|
2649
|
+
});
|
|
2650
|
+
target.setCoords();
|
|
2651
|
+
}
|
|
2652
|
+
return matches;
|
|
2653
|
+
}
|
|
2654
|
+
handleCanvasBeforeRender() {
|
|
2432
2655
|
if (!this.canvasService) return;
|
|
2433
|
-
|
|
2434
|
-
const current = axis === "x" ? this.snapGuideXObject : this.snapGuideYObject;
|
|
2435
|
-
if (!current) return;
|
|
2436
|
-
canvas.remove(current);
|
|
2437
|
-
if (axis === "x") {
|
|
2438
|
-
this.snapGuideXObject = void 0;
|
|
2656
|
+
if (!this.hasRenderedSnapGuides && !this.activeSnapX && !this.activeSnapY) {
|
|
2439
2657
|
return;
|
|
2440
2658
|
}
|
|
2441
|
-
this.
|
|
2659
|
+
this.canvasService.canvas.clearContext(
|
|
2660
|
+
this.canvasService.canvas.contextTop
|
|
2661
|
+
);
|
|
2662
|
+
this.hasRenderedSnapGuides = false;
|
|
2442
2663
|
}
|
|
2443
|
-
|
|
2664
|
+
drawSnapGuideLine(from, to) {
|
|
2444
2665
|
if (!this.canvasService) return;
|
|
2445
|
-
const
|
|
2666
|
+
const ctx = this.canvasService.canvas.contextTop;
|
|
2667
|
+
if (!ctx) return;
|
|
2446
2668
|
const color = this.getConfig("image.control.borderColor", "#1677ff") || "#1677ff";
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
selectable: false,
|
|
2456
|
-
evented: false,
|
|
2457
|
-
excludeFromExport: true,
|
|
2458
|
-
objectCaching: false,
|
|
2459
|
-
data: {
|
|
2460
|
-
id: `${IMAGE_SNAP_GUIDE_LAYER_ID}.${axis}`,
|
|
2461
|
-
layerId: IMAGE_SNAP_GUIDE_LAYER_ID,
|
|
2462
|
-
type: "image-snap-guide"
|
|
2463
|
-
}
|
|
2464
|
-
});
|
|
2465
|
-
created.setCoords();
|
|
2466
|
-
canvas.add(created);
|
|
2467
|
-
canvas.bringObjectToFront(created);
|
|
2468
|
-
if (axis === "x") {
|
|
2469
|
-
this.snapGuideXObject = created;
|
|
2470
|
-
return;
|
|
2471
|
-
}
|
|
2472
|
-
this.snapGuideYObject = created;
|
|
2669
|
+
ctx.save();
|
|
2670
|
+
ctx.strokeStyle = color;
|
|
2671
|
+
ctx.lineWidth = 1;
|
|
2672
|
+
ctx.beginPath();
|
|
2673
|
+
ctx.moveTo(from.x, from.y);
|
|
2674
|
+
ctx.lineTo(to.x, to.y);
|
|
2675
|
+
ctx.stroke();
|
|
2676
|
+
ctx.restore();
|
|
2473
2677
|
}
|
|
2474
|
-
|
|
2678
|
+
handleCanvasAfterRender() {
|
|
2475
2679
|
if (!this.canvasService || !this.isImageEditingVisible()) {
|
|
2476
|
-
this.removeSnapGuideObject("x");
|
|
2477
|
-
this.removeSnapGuideObject("y");
|
|
2478
2680
|
return;
|
|
2479
2681
|
}
|
|
2480
2682
|
const frame = this.getFrameRect();
|
|
2481
2683
|
if (frame.width <= 0 || frame.height <= 0) {
|
|
2482
|
-
this.removeSnapGuideObject("x");
|
|
2483
|
-
this.removeSnapGuideObject("y");
|
|
2484
2684
|
return;
|
|
2485
2685
|
}
|
|
2486
2686
|
const frameScreen = this.getFrameRectScreen(frame);
|
|
2687
|
+
let drew = false;
|
|
2487
2688
|
if (this.activeSnapX) {
|
|
2488
2689
|
const x = this.canvasService.toScreenPoint({
|
|
2489
2690
|
x: this.activeSnapX.lineScene,
|
|
2490
2691
|
y: frame.top
|
|
2491
2692
|
}).x;
|
|
2492
|
-
this.
|
|
2493
|
-
|
|
2494
|
-
|
|
2693
|
+
this.drawSnapGuideLine(
|
|
2694
|
+
{ x, y: frameScreen.top },
|
|
2695
|
+
{ x, y: frameScreen.top + frameScreen.height }
|
|
2495
2696
|
);
|
|
2496
|
-
|
|
2497
|
-
this.removeSnapGuideObject("x");
|
|
2697
|
+
drew = true;
|
|
2498
2698
|
}
|
|
2499
2699
|
if (this.activeSnapY) {
|
|
2500
2700
|
const y = this.canvasService.toScreenPoint({
|
|
2501
2701
|
x: frame.left,
|
|
2502
2702
|
y: this.activeSnapY.lineScene
|
|
2503
2703
|
}).y;
|
|
2504
|
-
this.
|
|
2505
|
-
|
|
2506
|
-
|
|
2704
|
+
this.drawSnapGuideLine(
|
|
2705
|
+
{ x: frameScreen.left, y },
|
|
2706
|
+
{ x: frameScreen.left + frameScreen.width, y }
|
|
2507
2707
|
);
|
|
2508
|
-
|
|
2509
|
-
this.removeSnapGuideObject("y");
|
|
2708
|
+
drew = true;
|
|
2510
2709
|
}
|
|
2511
|
-
this.
|
|
2710
|
+
this.hasRenderedSnapGuides = drew;
|
|
2512
2711
|
}
|
|
2513
2712
|
handleCanvasObjectMoving(e) {
|
|
2514
|
-
var _a
|
|
2713
|
+
var _a;
|
|
2515
2714
|
const target = this.getActiveImageTarget(e == null ? void 0 : e.target);
|
|
2516
2715
|
if (!target || !this.canvasService) return;
|
|
2716
|
+
this.movingImageId = typeof ((_a = target == null ? void 0 : target.data) == null ? void 0 : _a.id) === "string" ? target.data.id : null;
|
|
2517
2717
|
const frame = this.getFrameRect();
|
|
2518
2718
|
if (frame.width <= 0 || frame.height <= 0) {
|
|
2519
|
-
this.
|
|
2719
|
+
this.endMoveSnapInteraction();
|
|
2520
2720
|
return;
|
|
2521
2721
|
}
|
|
2522
|
-
const
|
|
2523
|
-
const
|
|
2524
|
-
const deltaY = (_d = (_c = matches.y) == null ? void 0 : _c.deltaScene) != null ? _d : 0;
|
|
2525
|
-
if (deltaX || deltaY) {
|
|
2526
|
-
target.set({
|
|
2527
|
-
left: Number(target.left || 0) + this.canvasService.toScreenLength(deltaX),
|
|
2528
|
-
top: Number(target.top || 0) + this.canvasService.toScreenLength(deltaY)
|
|
2529
|
-
});
|
|
2530
|
-
target.setCoords();
|
|
2531
|
-
}
|
|
2722
|
+
const rawBounds = this.getTargetBoundsScene(target);
|
|
2723
|
+
const matches = this.computeMoveSnapMatches(rawBounds, frame);
|
|
2532
2724
|
this.updateSnapMatchState(matches.x, matches.y);
|
|
2533
2725
|
}
|
|
2534
|
-
applySnapMatchesToTarget(target, matches) {
|
|
2535
|
-
var _a, _b, _c, _d;
|
|
2536
|
-
if (!this.canvasService || !target) return;
|
|
2537
|
-
const deltaX = (_b = (_a = matches.x) == null ? void 0 : _a.deltaScene) != null ? _b : 0;
|
|
2538
|
-
const deltaY = (_d = (_c = matches.y) == null ? void 0 : _c.deltaScene) != null ? _d : 0;
|
|
2539
|
-
if (!deltaX && !deltaY) return;
|
|
2540
|
-
target.set({
|
|
2541
|
-
left: Number(target.left || 0) + this.canvasService.toScreenLength(deltaX),
|
|
2542
|
-
top: Number(target.top || 0) + this.canvasService.toScreenLength(deltaY)
|
|
2543
|
-
});
|
|
2544
|
-
target.setCoords();
|
|
2545
|
-
}
|
|
2546
2726
|
syncToolActiveFromWorkbench(fallbackId) {
|
|
2547
2727
|
var _a;
|
|
2548
2728
|
const wb = (_a = this.context) == null ? void 0 : _a.services.get("WorkbenchService");
|
|
@@ -3166,33 +3346,9 @@ var ImageTool = class {
|
|
|
3166
3346
|
originY: "top",
|
|
3167
3347
|
fill: hatchFill,
|
|
3168
3348
|
opacity: patternFill ? 1 : 0.8,
|
|
3169
|
-
stroke: null,
|
|
3170
|
-
fillRule: "evenodd",
|
|
3171
|
-
selectable: false,
|
|
3172
|
-
evented: false,
|
|
3173
|
-
excludeFromExport: true,
|
|
3174
|
-
objectCaching: false
|
|
3175
|
-
}
|
|
3176
|
-
},
|
|
3177
|
-
{
|
|
3178
|
-
id: "image.cropShapePath",
|
|
3179
|
-
type: "path",
|
|
3180
|
-
data: { id: "image.cropShapePath", zIndex: 6 },
|
|
3181
|
-
layout: {
|
|
3182
|
-
reference: "custom",
|
|
3183
|
-
referenceRect: frameRect,
|
|
3184
|
-
alignX: "start",
|
|
3185
|
-
alignY: "start",
|
|
3186
|
-
offsetX: shapeBounds.x,
|
|
3187
|
-
offsetY: shapeBounds.y
|
|
3188
|
-
},
|
|
3189
|
-
props: {
|
|
3190
|
-
pathData: shapePathData,
|
|
3191
|
-
originX: "left",
|
|
3192
|
-
originY: "top",
|
|
3193
|
-
fill: "rgba(0,0,0,0)",
|
|
3194
3349
|
stroke: "rgba(255, 0, 0, 0.9)",
|
|
3195
3350
|
strokeWidth: (_b = (_a = this.canvasService) == null ? void 0 : _a.toSceneLength(1)) != null ? _b : 1,
|
|
3351
|
+
fillRule: "evenodd",
|
|
3196
3352
|
selectable: false,
|
|
3197
3353
|
evented: false,
|
|
3198
3354
|
excludeFromExport: true,
|
|
@@ -3529,7 +3685,6 @@ var ImageTool = class {
|
|
|
3529
3685
|
isImageSelectionActive: this.isImageSelectionActive,
|
|
3530
3686
|
focusedImageId: this.focusedImageId
|
|
3531
3687
|
});
|
|
3532
|
-
this.updateSnapGuideVisuals();
|
|
3533
3688
|
this.canvasService.requestRenderAll();
|
|
3534
3689
|
}
|
|
3535
3690
|
clampNormalized(value) {
|
|
@@ -4330,225 +4485,392 @@ function createDielineConfigurations(state) {
|
|
|
4330
4485
|
];
|
|
4331
4486
|
}
|
|
4332
4487
|
|
|
4333
|
-
// src/extensions/dieline/
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
this.renderSeq = 0;
|
|
4367
|
-
this.onCanvasResized = () => {
|
|
4368
|
-
this.updateDieline();
|
|
4369
|
-
};
|
|
4370
|
-
if (options) {
|
|
4371
|
-
if (options.mainLine) {
|
|
4372
|
-
Object.assign(this.state.mainLine, options.mainLine);
|
|
4373
|
-
delete options.mainLine;
|
|
4374
|
-
}
|
|
4375
|
-
if (options.offsetLine) {
|
|
4376
|
-
Object.assign(this.state.offsetLine, options.offsetLine);
|
|
4377
|
-
delete options.offsetLine;
|
|
4378
|
-
}
|
|
4379
|
-
if (options.shapeStyle) {
|
|
4380
|
-
this.state.shapeStyle = normalizeShapeStyle(
|
|
4381
|
-
options.shapeStyle,
|
|
4382
|
-
this.state.shapeStyle
|
|
4383
|
-
);
|
|
4384
|
-
delete options.shapeStyle;
|
|
4385
|
-
}
|
|
4386
|
-
Object.assign(this.state, options);
|
|
4387
|
-
this.state.shape = normalizeDielineShape(options.shape, this.state.shape);
|
|
4488
|
+
// src/extensions/dieline/model.ts
|
|
4489
|
+
function createDefaultDielineState() {
|
|
4490
|
+
return {
|
|
4491
|
+
shape: DEFAULT_DIELINE_SHAPE,
|
|
4492
|
+
shapeStyle: { ...DEFAULT_DIELINE_SHAPE_STYLE },
|
|
4493
|
+
width: 500,
|
|
4494
|
+
height: 500,
|
|
4495
|
+
radius: 0,
|
|
4496
|
+
offset: 0,
|
|
4497
|
+
padding: 140,
|
|
4498
|
+
mainLine: {
|
|
4499
|
+
width: 2.7,
|
|
4500
|
+
color: "#FF0000",
|
|
4501
|
+
dashLength: 5,
|
|
4502
|
+
style: "solid"
|
|
4503
|
+
},
|
|
4504
|
+
offsetLine: {
|
|
4505
|
+
width: 2.7,
|
|
4506
|
+
color: "#FF0000",
|
|
4507
|
+
dashLength: 5,
|
|
4508
|
+
style: "solid"
|
|
4509
|
+
},
|
|
4510
|
+
insideColor: "rgba(0,0,0,0)",
|
|
4511
|
+
showBleedLines: true,
|
|
4512
|
+
features: []
|
|
4513
|
+
};
|
|
4514
|
+
}
|
|
4515
|
+
function readDielineState(configService, fallback) {
|
|
4516
|
+
const base = createDefaultDielineState();
|
|
4517
|
+
if (fallback) {
|
|
4518
|
+
Object.assign(base, fallback);
|
|
4519
|
+
if (fallback.mainLine) {
|
|
4520
|
+
base.mainLine = { ...base.mainLine, ...fallback.mainLine };
|
|
4388
4521
|
}
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
var _a;
|
|
4392
|
-
this.context = context;
|
|
4393
|
-
this.canvasService = context.services.get("CanvasService");
|
|
4394
|
-
if (!this.canvasService) {
|
|
4395
|
-
console.warn("CanvasService not found for DielineTool");
|
|
4396
|
-
return;
|
|
4522
|
+
if (fallback.offsetLine) {
|
|
4523
|
+
base.offsetLine = { ...base.offsetLine, ...fallback.offsetLine };
|
|
4397
4524
|
}
|
|
4398
|
-
(
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
"
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
const s = this.state;
|
|
4427
|
-
const sizeState = readSizeState(configService);
|
|
4428
|
-
s.shape = normalizeDielineShape(
|
|
4429
|
-
configService.get("dieline.shape", s.shape),
|
|
4430
|
-
s.shape
|
|
4431
|
-
);
|
|
4432
|
-
s.shapeStyle = normalizeShapeStyle(
|
|
4433
|
-
configService.get("dieline.shapeStyle", s.shapeStyle),
|
|
4434
|
-
s.shapeStyle
|
|
4435
|
-
);
|
|
4436
|
-
s.width = sizeState.actualWidthMm;
|
|
4437
|
-
s.height = sizeState.actualHeightMm;
|
|
4438
|
-
s.radius = parseLengthToMm(
|
|
4439
|
-
configService.get("dieline.radius", s.radius),
|
|
4440
|
-
"mm"
|
|
4441
|
-
);
|
|
4442
|
-
s.padding = sizeState.viewPadding;
|
|
4443
|
-
s.offset = sizeState.cutMode === "outset" ? sizeState.cutMarginMm : sizeState.cutMode === "inset" ? -sizeState.cutMarginMm : 0;
|
|
4444
|
-
s.mainLine.width = configService.get(
|
|
4445
|
-
"dieline.strokeWidth",
|
|
4446
|
-
s.mainLine.width
|
|
4447
|
-
);
|
|
4448
|
-
s.mainLine.color = configService.get(
|
|
4449
|
-
"dieline.strokeColor",
|
|
4450
|
-
s.mainLine.color
|
|
4451
|
-
);
|
|
4452
|
-
s.mainLine.dashLength = configService.get(
|
|
4525
|
+
if (fallback.shapeStyle) {
|
|
4526
|
+
base.shapeStyle = normalizeShapeStyle(fallback.shapeStyle, base.shapeStyle);
|
|
4527
|
+
}
|
|
4528
|
+
}
|
|
4529
|
+
const sizeState = readSizeState(configService);
|
|
4530
|
+
const sourceWidth = Number(configService.get("dieline.customSourceWidthPx", 0));
|
|
4531
|
+
const sourceHeight = Number(
|
|
4532
|
+
configService.get("dieline.customSourceHeightPx", 0)
|
|
4533
|
+
);
|
|
4534
|
+
return {
|
|
4535
|
+
...base,
|
|
4536
|
+
shape: normalizeDielineShape(
|
|
4537
|
+
configService.get("dieline.shape", base.shape),
|
|
4538
|
+
base.shape
|
|
4539
|
+
),
|
|
4540
|
+
shapeStyle: normalizeShapeStyle(
|
|
4541
|
+
configService.get("dieline.shapeStyle", base.shapeStyle),
|
|
4542
|
+
base.shapeStyle
|
|
4543
|
+
),
|
|
4544
|
+
width: sizeState.actualWidthMm,
|
|
4545
|
+
height: sizeState.actualHeightMm,
|
|
4546
|
+
radius: parseLengthToMm(configService.get("dieline.radius", base.radius), "mm"),
|
|
4547
|
+
padding: sizeState.viewPadding,
|
|
4548
|
+
offset: sizeState.cutMode === "outset" ? sizeState.cutMarginMm : sizeState.cutMode === "inset" ? -sizeState.cutMarginMm : 0,
|
|
4549
|
+
mainLine: {
|
|
4550
|
+
width: configService.get("dieline.strokeWidth", base.mainLine.width),
|
|
4551
|
+
color: configService.get("dieline.strokeColor", base.mainLine.color),
|
|
4552
|
+
dashLength: configService.get(
|
|
4453
4553
|
"dieline.dashLength",
|
|
4454
|
-
|
|
4455
|
-
)
|
|
4456
|
-
|
|
4457
|
-
|
|
4554
|
+
base.mainLine.dashLength
|
|
4555
|
+
),
|
|
4556
|
+
style: configService.get("dieline.style", base.mainLine.style)
|
|
4557
|
+
},
|
|
4558
|
+
offsetLine: {
|
|
4559
|
+
width: configService.get(
|
|
4458
4560
|
"dieline.offsetStrokeWidth",
|
|
4459
|
-
|
|
4460
|
-
)
|
|
4461
|
-
|
|
4561
|
+
base.offsetLine.width
|
|
4562
|
+
),
|
|
4563
|
+
color: configService.get(
|
|
4462
4564
|
"dieline.offsetStrokeColor",
|
|
4463
|
-
|
|
4464
|
-
)
|
|
4465
|
-
|
|
4565
|
+
base.offsetLine.color
|
|
4566
|
+
),
|
|
4567
|
+
dashLength: configService.get(
|
|
4466
4568
|
"dieline.offsetDashLength",
|
|
4467
|
-
|
|
4468
|
-
)
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4569
|
+
base.offsetLine.dashLength
|
|
4570
|
+
),
|
|
4571
|
+
style: configService.get("dieline.offsetStyle", base.offsetLine.style)
|
|
4572
|
+
},
|
|
4573
|
+
insideColor: configService.get("dieline.insideColor", base.insideColor),
|
|
4574
|
+
showBleedLines: configService.get(
|
|
4575
|
+
"dieline.showBleedLines",
|
|
4576
|
+
base.showBleedLines
|
|
4577
|
+
),
|
|
4578
|
+
features: configService.get("dieline.features", base.features),
|
|
4579
|
+
pathData: configService.get("dieline.pathData", base.pathData),
|
|
4580
|
+
customSourceWidthPx: Number.isFinite(sourceWidth) && sourceWidth > 0 ? sourceWidth : void 0,
|
|
4581
|
+
customSourceHeightPx: Number.isFinite(sourceHeight) && sourceHeight > 0 ? sourceHeight : void 0
|
|
4582
|
+
};
|
|
4583
|
+
}
|
|
4584
|
+
|
|
4585
|
+
// src/extensions/dieline/renderBuilder.ts
|
|
4586
|
+
var DEFAULT_IDS = {
|
|
4587
|
+
inside: "dieline.inside",
|
|
4588
|
+
bleedZone: "dieline.bleed-zone",
|
|
4589
|
+
offsetBorder: "dieline.offset-border",
|
|
4590
|
+
border: "dieline.border",
|
|
4591
|
+
clip: "dieline.clip.image",
|
|
4592
|
+
clipSource: "dieline.effect.clip-path"
|
|
4593
|
+
};
|
|
4594
|
+
function scaleFeatures(state, scale) {
|
|
4595
|
+
return (state.features || []).map((feature) => ({
|
|
4596
|
+
...feature,
|
|
4597
|
+
x: feature.x,
|
|
4598
|
+
y: feature.y,
|
|
4599
|
+
width: (feature.width || 0) * scale,
|
|
4600
|
+
height: (feature.height || 0) * scale,
|
|
4601
|
+
radius: (feature.radius || 0) * scale
|
|
4602
|
+
}));
|
|
4603
|
+
}
|
|
4604
|
+
function buildDielineRenderBundle(options) {
|
|
4605
|
+
const ids = { ...DEFAULT_IDS, ...options.ids || {} };
|
|
4606
|
+
const {
|
|
4607
|
+
state,
|
|
4608
|
+
sceneLayout,
|
|
4609
|
+
canvasWidth,
|
|
4610
|
+
canvasHeight,
|
|
4611
|
+
hasImages,
|
|
4612
|
+
createHatchPattern,
|
|
4613
|
+
includeImageClipEffect = true,
|
|
4614
|
+
clipTargetPassIds = [IMAGE_OBJECT_LAYER_ID],
|
|
4615
|
+
clipVisibility
|
|
4616
|
+
} = options;
|
|
4617
|
+
const { shape, shapeStyle, radius, mainLine, offsetLine, insideColor } = state;
|
|
4618
|
+
const scale = sceneLayout.scale;
|
|
4619
|
+
const cx = sceneLayout.trimRect.centerX;
|
|
4620
|
+
const cy = sceneLayout.trimRect.centerY;
|
|
4621
|
+
const visualWidth = sceneLayout.trimRect.width;
|
|
4622
|
+
const visualHeight = sceneLayout.trimRect.height;
|
|
4623
|
+
const visualRadius = radius * scale;
|
|
4624
|
+
const cutW = sceneLayout.cutRect.width;
|
|
4625
|
+
const cutH = sceneLayout.cutRect.height;
|
|
4626
|
+
const visualOffset = (cutW - visualWidth) / 2;
|
|
4627
|
+
const cutR = visualRadius === 0 ? 0 : Math.max(0, visualRadius + visualOffset);
|
|
4628
|
+
const absoluteFeatures = scaleFeatures(state, scale);
|
|
4629
|
+
const cutFeatures = absoluteFeatures.filter((feature) => !feature.skipCut);
|
|
4630
|
+
const common = {
|
|
4631
|
+
shape,
|
|
4632
|
+
shapeStyle,
|
|
4633
|
+
pathData: state.pathData,
|
|
4634
|
+
customSourceWidthPx: state.customSourceWidthPx,
|
|
4635
|
+
customSourceHeightPx: state.customSourceHeightPx,
|
|
4636
|
+
canvasWidth,
|
|
4637
|
+
canvasHeight
|
|
4638
|
+
};
|
|
4639
|
+
const specs = [];
|
|
4640
|
+
if (insideColor && insideColor !== "transparent" && insideColor !== "rgba(0,0,0,0)" && !hasImages) {
|
|
4641
|
+
specs.push({
|
|
4642
|
+
id: ids.inside,
|
|
4643
|
+
type: "path",
|
|
4644
|
+
space: "screen",
|
|
4645
|
+
data: { id: ids.inside, type: "dieline" },
|
|
4646
|
+
props: {
|
|
4647
|
+
pathData: generateDielinePath({
|
|
4648
|
+
...common,
|
|
4649
|
+
width: cutW,
|
|
4650
|
+
height: cutH,
|
|
4651
|
+
radius: cutR,
|
|
4652
|
+
x: cx,
|
|
4653
|
+
y: cy,
|
|
4654
|
+
features: cutFeatures
|
|
4655
|
+
}),
|
|
4656
|
+
fill: insideColor,
|
|
4657
|
+
stroke: null,
|
|
4658
|
+
selectable: false,
|
|
4659
|
+
evented: false,
|
|
4660
|
+
originX: "left",
|
|
4661
|
+
originY: "top"
|
|
4662
|
+
}
|
|
4663
|
+
});
|
|
4664
|
+
}
|
|
4665
|
+
if (Math.abs(visualOffset) > 1e-4) {
|
|
4666
|
+
const trimPathInput = {
|
|
4667
|
+
...common,
|
|
4668
|
+
width: visualWidth,
|
|
4669
|
+
height: visualHeight,
|
|
4670
|
+
radius: visualRadius,
|
|
4671
|
+
x: cx,
|
|
4672
|
+
y: cy,
|
|
4673
|
+
features: cutFeatures
|
|
4674
|
+
};
|
|
4675
|
+
const cutPathInput = {
|
|
4676
|
+
...common,
|
|
4677
|
+
width: cutW,
|
|
4678
|
+
height: cutH,
|
|
4679
|
+
radius: cutR,
|
|
4680
|
+
x: cx,
|
|
4681
|
+
y: cy,
|
|
4682
|
+
features: cutFeatures
|
|
4683
|
+
};
|
|
4684
|
+
if (state.showBleedLines !== false) {
|
|
4685
|
+
const pattern = createHatchPattern == null ? void 0 : createHatchPattern(mainLine.color);
|
|
4686
|
+
if (pattern) {
|
|
4687
|
+
specs.push({
|
|
4688
|
+
id: ids.bleedZone,
|
|
4689
|
+
type: "path",
|
|
4690
|
+
space: "screen",
|
|
4691
|
+
data: { id: ids.bleedZone, type: "dieline" },
|
|
4692
|
+
props: {
|
|
4693
|
+
pathData: generateBleedZonePath(
|
|
4694
|
+
trimPathInput,
|
|
4695
|
+
cutPathInput,
|
|
4696
|
+
visualOffset
|
|
4697
|
+
),
|
|
4698
|
+
fill: pattern,
|
|
4699
|
+
stroke: null,
|
|
4700
|
+
selectable: false,
|
|
4701
|
+
evented: false,
|
|
4702
|
+
objectCaching: false,
|
|
4703
|
+
originX: "left",
|
|
4704
|
+
originY: "top"
|
|
4705
|
+
}
|
|
4706
|
+
});
|
|
4707
|
+
}
|
|
4708
|
+
}
|
|
4709
|
+
specs.push({
|
|
4710
|
+
id: ids.offsetBorder,
|
|
4711
|
+
type: "path",
|
|
4712
|
+
space: "screen",
|
|
4713
|
+
data: { id: ids.offsetBorder, type: "dieline" },
|
|
4714
|
+
props: {
|
|
4715
|
+
pathData: generateDielinePath(cutPathInput),
|
|
4716
|
+
fill: null,
|
|
4717
|
+
stroke: offsetLine.style === "hidden" ? null : offsetLine.color,
|
|
4718
|
+
strokeWidth: offsetLine.width,
|
|
4719
|
+
strokeDashArray: offsetLine.style === "dashed" ? [offsetLine.dashLength, offsetLine.dashLength] : void 0,
|
|
4720
|
+
selectable: false,
|
|
4721
|
+
evented: false,
|
|
4722
|
+
originX: "left",
|
|
4723
|
+
originY: "top"
|
|
4724
|
+
}
|
|
4725
|
+
});
|
|
4726
|
+
}
|
|
4727
|
+
specs.push({
|
|
4728
|
+
id: ids.border,
|
|
4729
|
+
type: "path",
|
|
4730
|
+
space: "screen",
|
|
4731
|
+
data: { id: ids.border, type: "dieline" },
|
|
4732
|
+
props: {
|
|
4733
|
+
pathData: generateDielinePath({
|
|
4734
|
+
...common,
|
|
4735
|
+
width: visualWidth,
|
|
4736
|
+
height: visualHeight,
|
|
4737
|
+
radius: visualRadius,
|
|
4738
|
+
x: cx,
|
|
4739
|
+
y: cy,
|
|
4740
|
+
features: absoluteFeatures
|
|
4741
|
+
}),
|
|
4742
|
+
fill: "transparent",
|
|
4743
|
+
stroke: mainLine.style === "hidden" ? null : mainLine.color,
|
|
4744
|
+
strokeWidth: mainLine.width,
|
|
4745
|
+
strokeDashArray: mainLine.style === "dashed" ? [mainLine.dashLength, mainLine.dashLength] : void 0,
|
|
4746
|
+
selectable: false,
|
|
4747
|
+
evented: false,
|
|
4748
|
+
originX: "left",
|
|
4749
|
+
originY: "top"
|
|
4750
|
+
}
|
|
4751
|
+
});
|
|
4752
|
+
if (!includeImageClipEffect) {
|
|
4753
|
+
return { specs, effects: [] };
|
|
4754
|
+
}
|
|
4755
|
+
const clipPathData = generateDielinePath({
|
|
4756
|
+
...common,
|
|
4757
|
+
width: cutW,
|
|
4758
|
+
height: cutH,
|
|
4759
|
+
radius: cutR,
|
|
4760
|
+
x: cx,
|
|
4761
|
+
y: cy,
|
|
4762
|
+
features: cutFeatures
|
|
4763
|
+
});
|
|
4764
|
+
if (!clipPathData) {
|
|
4765
|
+
return { specs, effects: [] };
|
|
4766
|
+
}
|
|
4767
|
+
return {
|
|
4768
|
+
specs,
|
|
4769
|
+
effects: [
|
|
4770
|
+
{
|
|
4771
|
+
type: "clipPath",
|
|
4772
|
+
id: ids.clip,
|
|
4773
|
+
visibility: clipVisibility,
|
|
4774
|
+
targetPassIds: clipTargetPassIds,
|
|
4775
|
+
source: {
|
|
4776
|
+
id: ids.clipSource,
|
|
4777
|
+
type: "path",
|
|
4778
|
+
space: "screen",
|
|
4779
|
+
data: {
|
|
4780
|
+
id: ids.clipSource,
|
|
4781
|
+
type: "dieline-effect",
|
|
4782
|
+
effect: "clipPath"
|
|
4783
|
+
},
|
|
4784
|
+
props: {
|
|
4785
|
+
pathData: clipPathData,
|
|
4786
|
+
fill: "#000000",
|
|
4787
|
+
stroke: null,
|
|
4788
|
+
originX: "left",
|
|
4789
|
+
originY: "top",
|
|
4790
|
+
selectable: false,
|
|
4791
|
+
evented: false,
|
|
4792
|
+
excludeFromExport: true
|
|
4793
|
+
}
|
|
4497
4794
|
}
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4549
|
-
|
|
4550
|
-
|
|
4795
|
+
}
|
|
4796
|
+
]
|
|
4797
|
+
};
|
|
4798
|
+
}
|
|
4799
|
+
|
|
4800
|
+
// src/extensions/dieline/DielineTool.ts
|
|
4801
|
+
var DielineTool = class {
|
|
4802
|
+
constructor(options) {
|
|
4803
|
+
this.id = "pooder.kit.dieline";
|
|
4804
|
+
this.metadata = {
|
|
4805
|
+
name: "DielineTool"
|
|
4806
|
+
};
|
|
4807
|
+
this.state = createDefaultDielineState();
|
|
4808
|
+
this.specs = [];
|
|
4809
|
+
this.effects = [];
|
|
4810
|
+
this.renderSeq = 0;
|
|
4811
|
+
this.onCanvasResized = () => {
|
|
4812
|
+
this.updateDieline();
|
|
4813
|
+
};
|
|
4814
|
+
if (options) {
|
|
4815
|
+
if (options.mainLine) {
|
|
4816
|
+
Object.assign(this.state.mainLine, options.mainLine);
|
|
4817
|
+
delete options.mainLine;
|
|
4818
|
+
}
|
|
4819
|
+
if (options.offsetLine) {
|
|
4820
|
+
Object.assign(this.state.offsetLine, options.offsetLine);
|
|
4821
|
+
delete options.offsetLine;
|
|
4822
|
+
}
|
|
4823
|
+
if (options.shapeStyle) {
|
|
4824
|
+
this.state.shapeStyle = normalizeShapeStyle(
|
|
4825
|
+
options.shapeStyle,
|
|
4826
|
+
this.state.shapeStyle
|
|
4827
|
+
);
|
|
4828
|
+
delete options.shapeStyle;
|
|
4829
|
+
}
|
|
4830
|
+
Object.assign(this.state, options);
|
|
4831
|
+
this.state.shape = normalizeDielineShape(options.shape, this.state.shape);
|
|
4832
|
+
}
|
|
4833
|
+
}
|
|
4834
|
+
activate(context) {
|
|
4835
|
+
var _a;
|
|
4836
|
+
this.context = context;
|
|
4837
|
+
this.canvasService = context.services.get("CanvasService");
|
|
4838
|
+
if (!this.canvasService) {
|
|
4839
|
+
console.warn("CanvasService not found for DielineTool");
|
|
4840
|
+
return;
|
|
4841
|
+
}
|
|
4842
|
+
(_a = this.renderProducerDisposable) == null ? void 0 : _a.dispose();
|
|
4843
|
+
this.renderProducerDisposable = this.canvasService.registerRenderProducer(
|
|
4844
|
+
this.id,
|
|
4845
|
+
() => ({
|
|
4846
|
+
passes: [
|
|
4847
|
+
{
|
|
4848
|
+
id: DIELINE_LAYER_ID,
|
|
4849
|
+
stack: 700,
|
|
4850
|
+
order: 0,
|
|
4851
|
+
replace: true,
|
|
4852
|
+
visibility: {
|
|
4853
|
+
op: "not",
|
|
4854
|
+
expr: {
|
|
4855
|
+
op: "activeToolIn",
|
|
4856
|
+
ids: ["pooder.kit.image", "pooder.kit.white-ink"]
|
|
4857
|
+
}
|
|
4858
|
+
},
|
|
4859
|
+
effects: this.effects,
|
|
4860
|
+
objects: this.specs
|
|
4551
4861
|
}
|
|
4862
|
+
]
|
|
4863
|
+
}),
|
|
4864
|
+
{ priority: 250 }
|
|
4865
|
+
);
|
|
4866
|
+
const configService = context.services.get(
|
|
4867
|
+
"ConfigurationService"
|
|
4868
|
+
);
|
|
4869
|
+
if (configService) {
|
|
4870
|
+
Object.assign(this.state, readDielineState(configService, this.state));
|
|
4871
|
+
configService.onAnyChange((e) => {
|
|
4872
|
+
if (e.key.startsWith("size.") || e.key.startsWith("dieline.")) {
|
|
4873
|
+
Object.assign(this.state, readDielineState(configService, this.state));
|
|
4552
4874
|
this.updateDieline();
|
|
4553
4875
|
}
|
|
4554
4876
|
});
|
|
@@ -4619,272 +4941,34 @@ var DielineTool = class {
|
|
|
4619
4941
|
const items = configService.get("image.items", []);
|
|
4620
4942
|
return Array.isArray(items) && items.length > 0;
|
|
4621
4943
|
}
|
|
4622
|
-
syncSizeState(configService) {
|
|
4623
|
-
const sizeState = readSizeState(configService);
|
|
4624
|
-
this.state.width = sizeState.actualWidthMm;
|
|
4625
|
-
this.state.height = sizeState.actualHeightMm;
|
|
4626
|
-
this.state.padding = sizeState.viewPadding;
|
|
4627
|
-
this.state.offset = sizeState.cutMode === "outset" ? sizeState.cutMarginMm : sizeState.cutMode === "inset" ? -sizeState.cutMarginMm : 0;
|
|
4628
|
-
}
|
|
4629
4944
|
buildDielineSpecs(sceneLayout) {
|
|
4630
4945
|
var _a, _b;
|
|
4631
|
-
const {
|
|
4632
|
-
shape,
|
|
4633
|
-
shapeStyle,
|
|
4634
|
-
radius,
|
|
4635
|
-
mainLine,
|
|
4636
|
-
offsetLine,
|
|
4637
|
-
insideColor,
|
|
4638
|
-
showBleedLines,
|
|
4639
|
-
features
|
|
4640
|
-
} = this.state;
|
|
4641
4946
|
const hasImages = this.hasImageItems();
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
const cutH = sceneLayout.cutRect.height;
|
|
4652
|
-
const visualOffset = (cutW - visualWidth) / 2;
|
|
4653
|
-
const cutR = visualRadius === 0 ? 0 : Math.max(0, visualRadius + visualOffset);
|
|
4654
|
-
const absoluteFeatures = (features || []).map((f) => ({
|
|
4655
|
-
...f,
|
|
4656
|
-
x: f.x,
|
|
4657
|
-
y: f.y,
|
|
4658
|
-
width: (f.width || 0) * scale,
|
|
4659
|
-
height: (f.height || 0) * scale,
|
|
4660
|
-
radius: (f.radius || 0) * scale
|
|
4661
|
-
}));
|
|
4662
|
-
const cutFeatures = absoluteFeatures.filter((f) => !f.skipCut);
|
|
4663
|
-
const specs = [];
|
|
4664
|
-
if (insideColor && insideColor !== "transparent" && insideColor !== "rgba(0,0,0,0)" && !hasImages) {
|
|
4665
|
-
const productPathData = generateDielinePath({
|
|
4666
|
-
shape,
|
|
4667
|
-
width: cutW,
|
|
4668
|
-
height: cutH,
|
|
4669
|
-
radius: cutR,
|
|
4670
|
-
x: cx,
|
|
4671
|
-
y: cy,
|
|
4672
|
-
features: cutFeatures,
|
|
4673
|
-
shapeStyle,
|
|
4674
|
-
pathData: this.state.pathData,
|
|
4675
|
-
customSourceWidthPx: this.state.customSourceWidthPx,
|
|
4676
|
-
customSourceHeightPx: this.state.customSourceHeightPx,
|
|
4677
|
-
canvasWidth: canvasW,
|
|
4678
|
-
canvasHeight: canvasH
|
|
4679
|
-
});
|
|
4680
|
-
specs.push({
|
|
4681
|
-
id: "dieline.inside",
|
|
4682
|
-
type: "path",
|
|
4683
|
-
space: "screen",
|
|
4684
|
-
data: { id: "dieline.inside", type: "dieline" },
|
|
4685
|
-
props: {
|
|
4686
|
-
pathData: productPathData,
|
|
4687
|
-
fill: insideColor,
|
|
4688
|
-
stroke: null,
|
|
4689
|
-
selectable: false,
|
|
4690
|
-
evented: false,
|
|
4691
|
-
originX: "left",
|
|
4692
|
-
originY: "top"
|
|
4693
|
-
}
|
|
4694
|
-
});
|
|
4695
|
-
}
|
|
4696
|
-
if (Math.abs(visualOffset) > 1e-4) {
|
|
4697
|
-
const bleedPathData = generateBleedZonePath(
|
|
4698
|
-
{
|
|
4699
|
-
shape,
|
|
4700
|
-
width: visualWidth,
|
|
4701
|
-
height: visualHeight,
|
|
4702
|
-
radius: visualRadius,
|
|
4703
|
-
x: cx,
|
|
4704
|
-
y: cy,
|
|
4705
|
-
features: cutFeatures,
|
|
4706
|
-
shapeStyle,
|
|
4707
|
-
pathData: this.state.pathData,
|
|
4708
|
-
customSourceWidthPx: this.state.customSourceWidthPx,
|
|
4709
|
-
customSourceHeightPx: this.state.customSourceHeightPx,
|
|
4710
|
-
canvasWidth: canvasW,
|
|
4711
|
-
canvasHeight: canvasH
|
|
4712
|
-
},
|
|
4713
|
-
{
|
|
4714
|
-
shape,
|
|
4715
|
-
width: cutW,
|
|
4716
|
-
height: cutH,
|
|
4717
|
-
radius: cutR,
|
|
4718
|
-
x: cx,
|
|
4719
|
-
y: cy,
|
|
4720
|
-
features: cutFeatures,
|
|
4721
|
-
shapeStyle,
|
|
4722
|
-
pathData: this.state.pathData,
|
|
4723
|
-
customSourceWidthPx: this.state.customSourceWidthPx,
|
|
4724
|
-
customSourceHeightPx: this.state.customSourceHeightPx,
|
|
4725
|
-
canvasWidth: canvasW,
|
|
4726
|
-
canvasHeight: canvasH
|
|
4727
|
-
},
|
|
4728
|
-
visualOffset
|
|
4729
|
-
);
|
|
4730
|
-
if (showBleedLines !== false) {
|
|
4731
|
-
const pattern = this.createHatchPattern(mainLine.color);
|
|
4732
|
-
if (pattern) {
|
|
4733
|
-
specs.push({
|
|
4734
|
-
id: "dieline.bleed-zone",
|
|
4735
|
-
type: "path",
|
|
4736
|
-
space: "screen",
|
|
4737
|
-
data: { id: "dieline.bleed-zone", type: "dieline" },
|
|
4738
|
-
props: {
|
|
4739
|
-
pathData: bleedPathData,
|
|
4740
|
-
fill: pattern,
|
|
4741
|
-
stroke: null,
|
|
4742
|
-
selectable: false,
|
|
4743
|
-
evented: false,
|
|
4744
|
-
objectCaching: false,
|
|
4745
|
-
originX: "left",
|
|
4746
|
-
originY: "top"
|
|
4747
|
-
}
|
|
4748
|
-
});
|
|
4749
|
-
}
|
|
4750
|
-
}
|
|
4751
|
-
const offsetPathData = generateDielinePath({
|
|
4752
|
-
shape,
|
|
4753
|
-
width: cutW,
|
|
4754
|
-
height: cutH,
|
|
4755
|
-
radius: cutR,
|
|
4756
|
-
x: cx,
|
|
4757
|
-
y: cy,
|
|
4758
|
-
features: cutFeatures,
|
|
4759
|
-
shapeStyle,
|
|
4760
|
-
pathData: this.state.pathData,
|
|
4761
|
-
customSourceWidthPx: this.state.customSourceWidthPx,
|
|
4762
|
-
customSourceHeightPx: this.state.customSourceHeightPx,
|
|
4763
|
-
canvasWidth: canvasW,
|
|
4764
|
-
canvasHeight: canvasH
|
|
4765
|
-
});
|
|
4766
|
-
specs.push({
|
|
4767
|
-
id: "dieline.offset-border",
|
|
4768
|
-
type: "path",
|
|
4769
|
-
space: "screen",
|
|
4770
|
-
data: { id: "dieline.offset-border", type: "dieline" },
|
|
4771
|
-
props: {
|
|
4772
|
-
pathData: offsetPathData,
|
|
4773
|
-
fill: null,
|
|
4774
|
-
stroke: offsetLine.style === "hidden" ? null : offsetLine.color,
|
|
4775
|
-
strokeWidth: offsetLine.width,
|
|
4776
|
-
strokeDashArray: offsetLine.style === "dashed" ? [offsetLine.dashLength, offsetLine.dashLength] : void 0,
|
|
4777
|
-
selectable: false,
|
|
4778
|
-
evented: false,
|
|
4779
|
-
originX: "left",
|
|
4780
|
-
originY: "top"
|
|
4781
|
-
}
|
|
4782
|
-
});
|
|
4783
|
-
}
|
|
4784
|
-
const borderPathData = generateDielinePath({
|
|
4785
|
-
shape,
|
|
4786
|
-
width: visualWidth,
|
|
4787
|
-
height: visualHeight,
|
|
4788
|
-
radius: visualRadius,
|
|
4789
|
-
x: cx,
|
|
4790
|
-
y: cy,
|
|
4791
|
-
features: absoluteFeatures,
|
|
4792
|
-
shapeStyle,
|
|
4793
|
-
pathData: this.state.pathData,
|
|
4794
|
-
customSourceWidthPx: this.state.customSourceWidthPx,
|
|
4795
|
-
customSourceHeightPx: this.state.customSourceHeightPx,
|
|
4796
|
-
canvasWidth: canvasW,
|
|
4797
|
-
canvasHeight: canvasH
|
|
4798
|
-
});
|
|
4799
|
-
specs.push({
|
|
4800
|
-
id: "dieline.border",
|
|
4801
|
-
type: "path",
|
|
4802
|
-
space: "screen",
|
|
4803
|
-
data: { id: "dieline.border", type: "dieline" },
|
|
4804
|
-
props: {
|
|
4805
|
-
pathData: borderPathData,
|
|
4806
|
-
fill: "transparent",
|
|
4807
|
-
stroke: mainLine.style === "hidden" ? null : mainLine.color,
|
|
4808
|
-
strokeWidth: mainLine.width,
|
|
4809
|
-
strokeDashArray: mainLine.style === "dashed" ? [mainLine.dashLength, mainLine.dashLength] : void 0,
|
|
4810
|
-
selectable: false,
|
|
4811
|
-
evented: false,
|
|
4812
|
-
originX: "left",
|
|
4813
|
-
originY: "top"
|
|
4814
|
-
}
|
|
4815
|
-
});
|
|
4816
|
-
return specs;
|
|
4947
|
+
return buildDielineRenderBundle({
|
|
4948
|
+
state: this.state,
|
|
4949
|
+
sceneLayout,
|
|
4950
|
+
canvasWidth: sceneLayout.canvasWidth || ((_a = this.canvasService) == null ? void 0 : _a.canvas.width) || 800,
|
|
4951
|
+
canvasHeight: sceneLayout.canvasHeight || ((_b = this.canvasService) == null ? void 0 : _b.canvas.height) || 600,
|
|
4952
|
+
hasImages,
|
|
4953
|
+
createHatchPattern: (color) => this.createHatchPattern(color),
|
|
4954
|
+
includeImageClipEffect: false
|
|
4955
|
+
}).specs;
|
|
4817
4956
|
}
|
|
4818
4957
|
buildImageClipEffects(sceneLayout) {
|
|
4819
4958
|
var _a, _b;
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
const cutR = visualRadius === 0 ? 0 : Math.max(0, visualRadius + visualOffset);
|
|
4832
|
-
const absoluteFeatures = (features || []).map((f) => ({
|
|
4833
|
-
...f,
|
|
4834
|
-
x: f.x,
|
|
4835
|
-
y: f.y,
|
|
4836
|
-
width: (f.width || 0) * scale,
|
|
4837
|
-
height: (f.height || 0) * scale,
|
|
4838
|
-
radius: (f.radius || 0) * scale
|
|
4839
|
-
}));
|
|
4840
|
-
const cutFeatures = absoluteFeatures.filter((f) => !f.skipCut);
|
|
4841
|
-
const clipPathData = generateDielinePath({
|
|
4842
|
-
shape,
|
|
4843
|
-
width: cutW,
|
|
4844
|
-
height: cutH,
|
|
4845
|
-
radius: cutR,
|
|
4846
|
-
x: cx,
|
|
4847
|
-
y: cy,
|
|
4848
|
-
features: cutFeatures,
|
|
4849
|
-
shapeStyle,
|
|
4850
|
-
pathData: this.state.pathData,
|
|
4851
|
-
customSourceWidthPx: this.state.customSourceWidthPx,
|
|
4852
|
-
customSourceHeightPx: this.state.customSourceHeightPx,
|
|
4853
|
-
canvasWidth: canvasW,
|
|
4854
|
-
canvasHeight: canvasH
|
|
4855
|
-
});
|
|
4856
|
-
if (!clipPathData) return [];
|
|
4857
|
-
return [
|
|
4858
|
-
{
|
|
4859
|
-
type: "clipPath",
|
|
4860
|
-
id: "dieline.clip.image",
|
|
4861
|
-
visibility: {
|
|
4862
|
-
op: "not",
|
|
4863
|
-
expr: { op: "anySessionActive" }
|
|
4864
|
-
},
|
|
4865
|
-
targetPassIds: [IMAGE_OBJECT_LAYER_ID],
|
|
4866
|
-
source: {
|
|
4867
|
-
id: "dieline.effect.clip-path",
|
|
4868
|
-
type: "path",
|
|
4869
|
-
space: "screen",
|
|
4870
|
-
data: {
|
|
4871
|
-
id: "dieline.effect.clip-path",
|
|
4872
|
-
type: "dieline-effect",
|
|
4873
|
-
effect: "clipPath"
|
|
4874
|
-
},
|
|
4875
|
-
props: {
|
|
4876
|
-
pathData: clipPathData,
|
|
4877
|
-
fill: "#000000",
|
|
4878
|
-
stroke: null,
|
|
4879
|
-
originX: "left",
|
|
4880
|
-
originY: "top",
|
|
4881
|
-
selectable: false,
|
|
4882
|
-
evented: false,
|
|
4883
|
-
excludeFromExport: true
|
|
4884
|
-
}
|
|
4885
|
-
}
|
|
4959
|
+
return buildDielineRenderBundle({
|
|
4960
|
+
state: this.state,
|
|
4961
|
+
sceneLayout,
|
|
4962
|
+
canvasWidth: sceneLayout.canvasWidth || ((_a = this.canvasService) == null ? void 0 : _a.canvas.width) || 800,
|
|
4963
|
+
canvasHeight: sceneLayout.canvasHeight || ((_b = this.canvasService) == null ? void 0 : _b.canvas.height) || 600,
|
|
4964
|
+
hasImages: this.hasImageItems(),
|
|
4965
|
+
includeImageClipEffect: true,
|
|
4966
|
+
clipTargetPassIds: [IMAGE_OBJECT_LAYER_ID],
|
|
4967
|
+
clipVisibility: {
|
|
4968
|
+
op: "not",
|
|
4969
|
+
expr: { op: "anySessionActive" }
|
|
4886
4970
|
}
|
|
4887
|
-
|
|
4971
|
+
}).effects;
|
|
4888
4972
|
}
|
|
4889
4973
|
updateDieline(_emitEvent = true) {
|
|
4890
4974
|
void this.updateDielineAsync();
|
|
@@ -4894,7 +4978,7 @@ var DielineTool = class {
|
|
|
4894
4978
|
const configService = this.getConfigService();
|
|
4895
4979
|
if (!configService) return;
|
|
4896
4980
|
const seq = ++this.renderSeq;
|
|
4897
|
-
this.
|
|
4981
|
+
Object.assign(this.state, readDielineState(configService, this.state));
|
|
4898
4982
|
const sceneLayout = computeSceneLayout(
|
|
4899
4983
|
this.canvasService,
|
|
4900
4984
|
readSizeState(configService)
|
|
@@ -4949,7 +5033,7 @@ var DielineTool = class {
|
|
|
4949
5033
|
);
|
|
4950
5034
|
return null;
|
|
4951
5035
|
}
|
|
4952
|
-
this.
|
|
5036
|
+
this.state = readDielineState(configService, this.state);
|
|
4953
5037
|
const sceneLayout = computeSceneLayout(
|
|
4954
5038
|
this.canvasService,
|
|
4955
5039
|
readSizeState(configService)
|
|
@@ -5103,6 +5187,7 @@ var DielineTool = class {
|
|
|
5103
5187
|
import {
|
|
5104
5188
|
ContributionPointIds as ContributionPointIds5
|
|
5105
5189
|
} from "@pooder/core";
|
|
5190
|
+
import { Pattern as Pattern3 } from "fabric";
|
|
5106
5191
|
|
|
5107
5192
|
// src/extensions/constraints.ts
|
|
5108
5193
|
var ConstraintRegistry = class {
|
|
@@ -5317,7 +5402,9 @@ var FeatureTool = class {
|
|
|
5317
5402
|
this.isFeatureSessionActive = false;
|
|
5318
5403
|
this.sessionOriginalFeatures = null;
|
|
5319
5404
|
this.hasWorkingChanges = false;
|
|
5320
|
-
this.
|
|
5405
|
+
this.markerSpecs = [];
|
|
5406
|
+
this.sessionDielineSpecs = [];
|
|
5407
|
+
this.sessionDielineEffects = [];
|
|
5321
5408
|
this.renderSeq = 0;
|
|
5322
5409
|
this.subscriptions = new SubscriptionBag();
|
|
5323
5410
|
this.handleMoving = null;
|
|
@@ -5327,7 +5414,7 @@ var FeatureTool = class {
|
|
|
5327
5414
|
this.onToolActivated = (event) => {
|
|
5328
5415
|
this.isToolActive = event.id === this.id;
|
|
5329
5416
|
if (!this.isToolActive) {
|
|
5330
|
-
this.
|
|
5417
|
+
this.suspendFeatureSession();
|
|
5331
5418
|
}
|
|
5332
5419
|
this.updateVisibility();
|
|
5333
5420
|
};
|
|
@@ -5347,16 +5434,38 @@ var FeatureTool = class {
|
|
|
5347
5434
|
(_a = this.renderProducerDisposable) == null ? void 0 : _a.dispose();
|
|
5348
5435
|
this.renderProducerDisposable = this.canvasService.registerRenderProducer(
|
|
5349
5436
|
this.id,
|
|
5350
|
-
() =>
|
|
5351
|
-
passes
|
|
5437
|
+
() => {
|
|
5438
|
+
const passes = [
|
|
5352
5439
|
{
|
|
5353
5440
|
id: FEATURE_OVERLAY_LAYER_ID,
|
|
5354
5441
|
stack: 880,
|
|
5355
5442
|
order: 0,
|
|
5356
|
-
|
|
5443
|
+
replace: true,
|
|
5444
|
+
objects: this.markerSpecs
|
|
5357
5445
|
}
|
|
5358
|
-
]
|
|
5359
|
-
|
|
5446
|
+
];
|
|
5447
|
+
if (this.isSessionVisible()) {
|
|
5448
|
+
passes.push(
|
|
5449
|
+
{
|
|
5450
|
+
id: DIELINE_LAYER_ID,
|
|
5451
|
+
stack: 700,
|
|
5452
|
+
order: 0,
|
|
5453
|
+
replace: false,
|
|
5454
|
+
visibility: { op: "const", value: false },
|
|
5455
|
+
objects: []
|
|
5456
|
+
},
|
|
5457
|
+
{
|
|
5458
|
+
id: FEATURE_DIELINE_LAYER_ID,
|
|
5459
|
+
stack: 705,
|
|
5460
|
+
order: 0,
|
|
5461
|
+
replace: true,
|
|
5462
|
+
effects: this.sessionDielineEffects,
|
|
5463
|
+
objects: this.sessionDielineSpecs
|
|
5464
|
+
}
|
|
5465
|
+
);
|
|
5466
|
+
}
|
|
5467
|
+
return { passes };
|
|
5468
|
+
},
|
|
5360
5469
|
{ priority: 350 }
|
|
5361
5470
|
);
|
|
5362
5471
|
const configService = context.services.get(
|
|
@@ -5371,12 +5480,22 @@ var FeatureTool = class {
|
|
|
5371
5480
|
(e) => {
|
|
5372
5481
|
if (this.isUpdatingConfig) return;
|
|
5373
5482
|
if (e.key === "dieline.features") {
|
|
5374
|
-
if (this.isFeatureSessionActive)
|
|
5483
|
+
if (this.isFeatureSessionActive && this.hasFeatureSessionDraft()) {
|
|
5484
|
+
return;
|
|
5485
|
+
}
|
|
5486
|
+
if (this.hasFeatureSessionDraft()) {
|
|
5487
|
+
this.clearFeatureSessionState();
|
|
5488
|
+
}
|
|
5375
5489
|
const next = e.value || [];
|
|
5376
5490
|
this.workingFeatures = this.cloneFeatures(next);
|
|
5377
5491
|
this.hasWorkingChanges = false;
|
|
5378
5492
|
this.redraw();
|
|
5379
5493
|
this.emitWorkingChange();
|
|
5494
|
+
return;
|
|
5495
|
+
}
|
|
5496
|
+
if (e.key.startsWith("size.") || e.key.startsWith("dieline.")) {
|
|
5497
|
+
void this.refreshGeometry();
|
|
5498
|
+
this.redraw({ enforceConstraints: true });
|
|
5380
5499
|
}
|
|
5381
5500
|
}
|
|
5382
5501
|
);
|
|
@@ -5392,7 +5511,8 @@ var FeatureTool = class {
|
|
|
5392
5511
|
deactivate(context) {
|
|
5393
5512
|
var _a;
|
|
5394
5513
|
this.subscriptions.disposeAll();
|
|
5395
|
-
this.
|
|
5514
|
+
this.restoreCommittedFeaturesToConfig();
|
|
5515
|
+
this.clearFeatureSessionState();
|
|
5396
5516
|
(_a = this.dirtyTrackerDisposable) == null ? void 0 : _a.dispose();
|
|
5397
5517
|
this.dirtyTrackerDisposable = void 0;
|
|
5398
5518
|
this.teardown();
|
|
@@ -5402,6 +5522,9 @@ var FeatureTool = class {
|
|
|
5402
5522
|
updateVisibility() {
|
|
5403
5523
|
this.redraw();
|
|
5404
5524
|
}
|
|
5525
|
+
isSessionVisible() {
|
|
5526
|
+
return this.isToolActive && this.isFeatureSessionActive;
|
|
5527
|
+
}
|
|
5405
5528
|
contribute() {
|
|
5406
5529
|
return {
|
|
5407
5530
|
[ContributionPointIds5.TOOLS]: [
|
|
@@ -5428,15 +5551,16 @@ var FeatureTool = class {
|
|
|
5428
5551
|
if (this.isFeatureSessionActive) {
|
|
5429
5552
|
return { ok: true };
|
|
5430
5553
|
}
|
|
5431
|
-
|
|
5432
|
-
|
|
5554
|
+
if (!this.hasFeatureSessionDraft()) {
|
|
5555
|
+
const original = this.getCommittedFeatures();
|
|
5556
|
+
this.sessionOriginalFeatures = this.cloneFeatures(original);
|
|
5557
|
+
this.setWorkingFeatures(this.cloneFeatures(original));
|
|
5558
|
+
this.hasWorkingChanges = false;
|
|
5559
|
+
}
|
|
5433
5560
|
this.isFeatureSessionActive = true;
|
|
5434
5561
|
await this.refreshGeometry();
|
|
5435
|
-
this.setWorkingFeatures(this.cloneFeatures(original));
|
|
5436
|
-
this.hasWorkingChanges = false;
|
|
5437
5562
|
this.redraw();
|
|
5438
5563
|
this.emitWorkingChange();
|
|
5439
|
-
this.updateCommittedFeatures([]);
|
|
5440
5564
|
return { ok: true };
|
|
5441
5565
|
}
|
|
5442
5566
|
},
|
|
@@ -5472,25 +5596,6 @@ var FeatureTool = class {
|
|
|
5472
5596
|
return true;
|
|
5473
5597
|
}
|
|
5474
5598
|
},
|
|
5475
|
-
{
|
|
5476
|
-
command: "getWorkingFeatures",
|
|
5477
|
-
title: "Get Working Features",
|
|
5478
|
-
handler: () => {
|
|
5479
|
-
return this.cloneFeatures(this.workingFeatures);
|
|
5480
|
-
}
|
|
5481
|
-
},
|
|
5482
|
-
{
|
|
5483
|
-
command: "setWorkingFeatures",
|
|
5484
|
-
title: "Set Working Features",
|
|
5485
|
-
handler: async (features) => {
|
|
5486
|
-
await this.refreshGeometry();
|
|
5487
|
-
this.setWorkingFeatures(this.cloneFeatures(features || []));
|
|
5488
|
-
this.hasWorkingChanges = true;
|
|
5489
|
-
this.redraw();
|
|
5490
|
-
this.emitWorkingChange();
|
|
5491
|
-
return { ok: true };
|
|
5492
|
-
}
|
|
5493
|
-
},
|
|
5494
5599
|
{
|
|
5495
5600
|
command: "rollbackFeatureSession",
|
|
5496
5601
|
title: "Rollback Feature Session",
|
|
@@ -5557,17 +5662,24 @@ var FeatureTool = class {
|
|
|
5557
5662
|
this.isUpdatingConfig = false;
|
|
5558
5663
|
}
|
|
5559
5664
|
}
|
|
5665
|
+
hasFeatureSessionDraft() {
|
|
5666
|
+
return Array.isArray(this.sessionOriginalFeatures);
|
|
5667
|
+
}
|
|
5560
5668
|
clearFeatureSessionState() {
|
|
5561
5669
|
this.isFeatureSessionActive = false;
|
|
5562
5670
|
this.sessionOriginalFeatures = null;
|
|
5563
5671
|
}
|
|
5564
|
-
|
|
5565
|
-
if (!this.
|
|
5672
|
+
restoreCommittedFeaturesToConfig() {
|
|
5673
|
+
if (!this.hasFeatureSessionDraft()) return;
|
|
5566
5674
|
const original = this.cloneFeatures(
|
|
5567
5675
|
this.sessionOriginalFeatures || this.getCommittedFeatures()
|
|
5568
5676
|
);
|
|
5569
5677
|
this.updateCommittedFeatures(original);
|
|
5570
|
-
|
|
5678
|
+
}
|
|
5679
|
+
suspendFeatureSession() {
|
|
5680
|
+
if (!this.isFeatureSessionActive) return;
|
|
5681
|
+
this.restoreCommittedFeaturesToConfig();
|
|
5682
|
+
this.isFeatureSessionActive = false;
|
|
5571
5683
|
}
|
|
5572
5684
|
emitWorkingChange() {
|
|
5573
5685
|
var _a;
|
|
@@ -5589,7 +5701,7 @@ var FeatureTool = class {
|
|
|
5589
5701
|
}
|
|
5590
5702
|
async resetWorkingFeaturesFromSource() {
|
|
5591
5703
|
const next = this.cloneFeatures(
|
|
5592
|
-
this.
|
|
5704
|
+
this.sessionOriginalFeatures || this.getCommittedFeatures()
|
|
5593
5705
|
);
|
|
5594
5706
|
await this.refreshGeometry();
|
|
5595
5707
|
this.setWorkingFeatures(next);
|
|
@@ -5813,11 +5925,35 @@ var FeatureTool = class {
|
|
|
5813
5925
|
this.handleSceneGeometryChange = null;
|
|
5814
5926
|
}
|
|
5815
5927
|
this.renderSeq += 1;
|
|
5816
|
-
this.
|
|
5928
|
+
this.markerSpecs = [];
|
|
5929
|
+
this.sessionDielineSpecs = [];
|
|
5930
|
+
this.sessionDielineEffects = [];
|
|
5817
5931
|
(_a = this.renderProducerDisposable) == null ? void 0 : _a.dispose();
|
|
5818
5932
|
this.renderProducerDisposable = void 0;
|
|
5819
5933
|
void this.canvasService.flushRenderFromProducers();
|
|
5820
5934
|
}
|
|
5935
|
+
createHatchPattern(color = "rgba(0, 0, 0, 0.3)") {
|
|
5936
|
+
if (typeof document === "undefined") {
|
|
5937
|
+
return void 0;
|
|
5938
|
+
}
|
|
5939
|
+
const size = 20;
|
|
5940
|
+
const canvas = document.createElement("canvas");
|
|
5941
|
+
canvas.width = size;
|
|
5942
|
+
canvas.height = size;
|
|
5943
|
+
const ctx = canvas.getContext("2d");
|
|
5944
|
+
if (ctx) {
|
|
5945
|
+
ctx.clearRect(0, 0, size, size);
|
|
5946
|
+
ctx.strokeStyle = color;
|
|
5947
|
+
ctx.lineWidth = 1;
|
|
5948
|
+
ctx.beginPath();
|
|
5949
|
+
ctx.moveTo(0, size);
|
|
5950
|
+
ctx.lineTo(size, 0);
|
|
5951
|
+
ctx.stroke();
|
|
5952
|
+
}
|
|
5953
|
+
return new Pattern3({
|
|
5954
|
+
source: canvas
|
|
5955
|
+
});
|
|
5956
|
+
}
|
|
5821
5957
|
getDraggableMarkerTarget(target) {
|
|
5822
5958
|
var _a, _b;
|
|
5823
5959
|
if (!this.isFeatureSessionActive || !this.isToolActive) return null;
|
|
@@ -5893,6 +6029,7 @@ var FeatureTool = class {
|
|
|
5893
6029
|
next[index] = updatedFeature;
|
|
5894
6030
|
this.setWorkingFeatures(next);
|
|
5895
6031
|
this.hasWorkingChanges = true;
|
|
6032
|
+
this.redraw();
|
|
5896
6033
|
this.emitWorkingChange();
|
|
5897
6034
|
}
|
|
5898
6035
|
syncGroupFromCanvas(target) {
|
|
@@ -5931,6 +6068,7 @@ var FeatureTool = class {
|
|
|
5931
6068
|
if (!changed) return;
|
|
5932
6069
|
this.setWorkingFeatures(next);
|
|
5933
6070
|
this.hasWorkingChanges = true;
|
|
6071
|
+
this.redraw();
|
|
5934
6072
|
this.emitWorkingChange();
|
|
5935
6073
|
}
|
|
5936
6074
|
redraw(options = {}) {
|
|
@@ -5939,7 +6077,10 @@ var FeatureTool = class {
|
|
|
5939
6077
|
async redrawAsync(options = {}) {
|
|
5940
6078
|
if (!this.canvasService) return;
|
|
5941
6079
|
const seq = ++this.renderSeq;
|
|
5942
|
-
this.
|
|
6080
|
+
this.markerSpecs = this.buildMarkerSpecs();
|
|
6081
|
+
const sessionRender = this.buildSessionDielineRender();
|
|
6082
|
+
this.sessionDielineSpecs = sessionRender.specs;
|
|
6083
|
+
this.sessionDielineEffects = sessionRender.effects;
|
|
5943
6084
|
if (seq !== this.renderSeq) return;
|
|
5944
6085
|
await this.canvasService.flushRenderFromProducers();
|
|
5945
6086
|
if (seq !== this.renderSeq) return;
|
|
@@ -5947,7 +6088,49 @@ var FeatureTool = class {
|
|
|
5947
6088
|
this.enforceConstraints();
|
|
5948
6089
|
}
|
|
5949
6090
|
}
|
|
5950
|
-
|
|
6091
|
+
buildSessionDielineRender() {
|
|
6092
|
+
if (!this.isSessionVisible() || !this.canvasService) {
|
|
6093
|
+
return { specs: [], effects: [] };
|
|
6094
|
+
}
|
|
6095
|
+
const configService = this.getConfigService();
|
|
6096
|
+
if (!configService) {
|
|
6097
|
+
return { specs: [], effects: [] };
|
|
6098
|
+
}
|
|
6099
|
+
const sceneLayout = computeSceneLayout(
|
|
6100
|
+
this.canvasService,
|
|
6101
|
+
readSizeState(configService)
|
|
6102
|
+
);
|
|
6103
|
+
if (!sceneLayout) {
|
|
6104
|
+
return { specs: [], effects: [] };
|
|
6105
|
+
}
|
|
6106
|
+
const state = readDielineState(configService);
|
|
6107
|
+
state.features = this.cloneFeatures(this.workingFeatures);
|
|
6108
|
+
return buildDielineRenderBundle({
|
|
6109
|
+
state,
|
|
6110
|
+
sceneLayout,
|
|
6111
|
+
canvasWidth: sceneLayout.canvasWidth || this.canvasService.canvas.width || 800,
|
|
6112
|
+
canvasHeight: sceneLayout.canvasHeight || this.canvasService.canvas.height || 600,
|
|
6113
|
+
hasImages: this.hasImageItems(),
|
|
6114
|
+
createHatchPattern: (color) => this.createHatchPattern(color),
|
|
6115
|
+
clipTargetPassIds: [IMAGE_OBJECT_LAYER_ID],
|
|
6116
|
+
clipVisibility: { op: "const", value: true },
|
|
6117
|
+
ids: {
|
|
6118
|
+
inside: "feature.session.dieline.inside",
|
|
6119
|
+
bleedZone: "feature.session.dieline.bleed-zone",
|
|
6120
|
+
offsetBorder: "feature.session.dieline.offset-border",
|
|
6121
|
+
border: "feature.session.dieline.border",
|
|
6122
|
+
clip: "feature.session.dieline.clip.image",
|
|
6123
|
+
clipSource: "feature.session.dieline.effect.clip-path"
|
|
6124
|
+
}
|
|
6125
|
+
});
|
|
6126
|
+
}
|
|
6127
|
+
hasImageItems() {
|
|
6128
|
+
const configService = this.getConfigService();
|
|
6129
|
+
if (!configService) return false;
|
|
6130
|
+
const items = configService.get("image.items", []);
|
|
6131
|
+
return Array.isArray(items) && items.length > 0;
|
|
6132
|
+
}
|
|
6133
|
+
buildMarkerSpecs() {
|
|
5951
6134
|
if (!this.isFeatureSessionActive || !this.currentGeometry || this.workingFeatures.length === 0) {
|
|
5952
6135
|
return [];
|
|
5953
6136
|
}
|
|
@@ -9534,11 +9717,13 @@ export {
|
|
|
9534
9717
|
WhiteInkTool,
|
|
9535
9718
|
getCoverScale as computeImageCoverScale,
|
|
9536
9719
|
getCoverScale as computeWhiteInkCoverScale,
|
|
9720
|
+
createDefaultDielineState,
|
|
9537
9721
|
createDielineCommands,
|
|
9538
9722
|
createDielineConfigurations,
|
|
9539
9723
|
createImageCommands,
|
|
9540
9724
|
createImageConfigurations,
|
|
9541
9725
|
createWhiteInkCommands,
|
|
9542
9726
|
createWhiteInkConfigurations,
|
|
9543
|
-
evaluateVisibilityExpr
|
|
9727
|
+
evaluateVisibilityExpr,
|
|
9728
|
+
readDielineState
|
|
9544
9729
|
};
|