@pooder/kit 6.3.0 → 6.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.
- package/.test-dist/src/extensions/image/ImageTool.js +116 -0
- package/.test-dist/src/extensions/image/commands.js +9 -1
- package/.test-dist/src/extensions/image/config.js +7 -0
- package/.test-dist/src/extensions/image/imagePlacement.js +44 -0
- package/.test-dist/tests/run.js +12 -4
- package/CHANGELOG.md +8 -0
- package/dist/index.d.mts +21 -1
- package/dist/index.d.ts +21 -1
- package/dist/index.js +195 -4
- package/dist/index.mjs +195 -4
- package/package.json +2 -2
- package/src/extensions/image/ImageTool.ts +180 -1
- package/src/extensions/image/commands.ts +9 -1
- package/src/extensions/image/config.ts +7 -0
- package/src/extensions/image/imagePlacement.ts +78 -0
- package/tests/run.ts +48 -15
|
@@ -12,6 +12,7 @@ const layers_1 = require("../../shared/constants/layers");
|
|
|
12
12
|
const commands_1 = require("./commands");
|
|
13
13
|
const config_1 = require("./config");
|
|
14
14
|
const imageOperations_1 = require("./imageOperations");
|
|
15
|
+
const imagePlacement_1 = require("./imagePlacement");
|
|
15
16
|
const sessionOverlay_1 = require("./sessionOverlay");
|
|
16
17
|
const IMAGE_DEFAULT_CONTROL_CAPABILITIES = [
|
|
17
18
|
"rotate",
|
|
@@ -63,6 +64,7 @@ class ImageTool {
|
|
|
63
64
|
this.activeSnapX = null;
|
|
64
65
|
this.activeSnapY = null;
|
|
65
66
|
this.movingImageId = null;
|
|
67
|
+
this.sessionNotice = null;
|
|
66
68
|
this.hasRenderedSnapGuides = false;
|
|
67
69
|
this.subscriptions = new subscriptions_1.SubscriptionBag();
|
|
68
70
|
this.imageControlsByCapabilityKey = new Map();
|
|
@@ -228,7 +230,11 @@ class ImageTool {
|
|
|
228
230
|
}
|
|
229
231
|
if (e.key.startsWith("size.") ||
|
|
230
232
|
e.key.startsWith("image.frame.") ||
|
|
233
|
+
e.key.startsWith("image.session.") ||
|
|
231
234
|
e.key.startsWith("image.control.")) {
|
|
235
|
+
if (e.key === "image.session.placementPolicy") {
|
|
236
|
+
this.clearSessionNotice();
|
|
237
|
+
}
|
|
232
238
|
if (e.key.startsWith("image.control.")) {
|
|
233
239
|
this.imageControlsByCapabilityKey.clear();
|
|
234
240
|
}
|
|
@@ -648,6 +654,7 @@ class ImageTool {
|
|
|
648
654
|
interaction: "session",
|
|
649
655
|
commands: {
|
|
650
656
|
begin: "imageSessionReset",
|
|
657
|
+
validate: "validateImageSession",
|
|
651
658
|
commit: "completeImages",
|
|
652
659
|
rollback: "imageSessionReset",
|
|
653
660
|
},
|
|
@@ -690,6 +697,34 @@ class ImageTool {
|
|
|
690
697
|
getViewItems() {
|
|
691
698
|
return this.isToolActive ? this.workingItems : this.items;
|
|
692
699
|
}
|
|
700
|
+
getPlacementPolicy() {
|
|
701
|
+
const policy = this.getConfig("image.session.placementPolicy", "free");
|
|
702
|
+
return policy === "warn" || policy === "strict" ? policy : "free";
|
|
703
|
+
}
|
|
704
|
+
areSessionNoticesEqual(a, b) {
|
|
705
|
+
if (!a && !b)
|
|
706
|
+
return true;
|
|
707
|
+
if (!a || !b)
|
|
708
|
+
return false;
|
|
709
|
+
return (a.code === b.code &&
|
|
710
|
+
a.level === b.level &&
|
|
711
|
+
a.message === b.message &&
|
|
712
|
+
a.policy === b.policy &&
|
|
713
|
+
JSON.stringify(a.imageIds) === JSON.stringify(b.imageIds));
|
|
714
|
+
}
|
|
715
|
+
setSessionNotice(notice, options = {}) {
|
|
716
|
+
if (this.areSessionNoticesEqual(this.sessionNotice, notice)) {
|
|
717
|
+
return;
|
|
718
|
+
}
|
|
719
|
+
this.sessionNotice = notice;
|
|
720
|
+
if (options.emit !== false) {
|
|
721
|
+
this.context?.eventBus.emit("image:session:notice", this.sessionNotice);
|
|
722
|
+
this.emitImageStateChange();
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
clearSessionNotice(options = {}) {
|
|
726
|
+
this.setSessionNotice(null, options);
|
|
727
|
+
}
|
|
693
728
|
getImageViewState() {
|
|
694
729
|
this.syncToolActiveFromWorkbench();
|
|
695
730
|
const items = this.cloneItems(this.getViewItems());
|
|
@@ -705,6 +740,8 @@ class ImageTool {
|
|
|
705
740
|
isImageSelectionActive: this.isImageSelectionActive,
|
|
706
741
|
hasWorkingChanges: this.hasWorkingChanges,
|
|
707
742
|
source: this.isToolActive ? "working" : "committed",
|
|
743
|
+
placementPolicy: this.getPlacementPolicy(),
|
|
744
|
+
sessionNotice: this.sessionNotice,
|
|
708
745
|
};
|
|
709
746
|
}
|
|
710
747
|
emitImageStateChange() {
|
|
@@ -754,6 +791,7 @@ class ImageTool {
|
|
|
754
791
|
}
|
|
755
792
|
async addImageEntry(url, options, operation) {
|
|
756
793
|
this.syncToolActiveFromWorkbench();
|
|
794
|
+
this.clearSessionNotice({ emit: false });
|
|
757
795
|
const id = this.generateId();
|
|
758
796
|
const newItem = this.normalizeItem({
|
|
759
797
|
id,
|
|
@@ -855,6 +893,7 @@ class ImageTool {
|
|
|
855
893
|
updateConfig(newItems, skipCanvasUpdate = false) {
|
|
856
894
|
if (!this.context)
|
|
857
895
|
return;
|
|
896
|
+
this.clearSessionNotice({ emit: false });
|
|
858
897
|
this.applyCommittedItems(newItems);
|
|
859
898
|
(0, sessionState_1.runDeferredConfigUpdate)(this, () => {
|
|
860
899
|
const configService = this.context?.services.get("ConfigurationService");
|
|
@@ -947,6 +986,72 @@ class ImageTool {
|
|
|
947
986
|
getCoverScale(frame, size) {
|
|
948
987
|
return (0, sourceSizeCache_1.getCoverScale)(frame, size);
|
|
949
988
|
}
|
|
989
|
+
resolvePlacementState(item) {
|
|
990
|
+
return {
|
|
991
|
+
left: Number.isFinite(item.left) ? item.left : 0.5,
|
|
992
|
+
top: Number.isFinite(item.top) ? item.top : 0.5,
|
|
993
|
+
scale: Math.max(0.05, item.scale ?? 1),
|
|
994
|
+
angle: Number.isFinite(item.angle) ? item.angle : 0,
|
|
995
|
+
};
|
|
996
|
+
}
|
|
997
|
+
async validatePlacementForItem(item) {
|
|
998
|
+
const frame = this.getFrameRect();
|
|
999
|
+
if (!frame.width || !frame.height) {
|
|
1000
|
+
return true;
|
|
1001
|
+
}
|
|
1002
|
+
const src = item.sourceUrl || item.url;
|
|
1003
|
+
if (!src) {
|
|
1004
|
+
return true;
|
|
1005
|
+
}
|
|
1006
|
+
const source = await this.resolveImageSourceSize(item.id, src);
|
|
1007
|
+
if (!source) {
|
|
1008
|
+
return true;
|
|
1009
|
+
}
|
|
1010
|
+
return (0, imagePlacement_1.validateImagePlacement)({
|
|
1011
|
+
frame,
|
|
1012
|
+
source,
|
|
1013
|
+
placement: this.resolvePlacementState(item),
|
|
1014
|
+
}).ok;
|
|
1015
|
+
}
|
|
1016
|
+
async validateImageSession() {
|
|
1017
|
+
const policy = this.getPlacementPolicy();
|
|
1018
|
+
if (policy === "free") {
|
|
1019
|
+
this.clearSessionNotice();
|
|
1020
|
+
return { ok: true, policy };
|
|
1021
|
+
}
|
|
1022
|
+
const invalidImageIds = [];
|
|
1023
|
+
for (const item of this.workingItems) {
|
|
1024
|
+
const valid = await this.validatePlacementForItem(item);
|
|
1025
|
+
if (!valid) {
|
|
1026
|
+
invalidImageIds.push(item.id);
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
if (!invalidImageIds.length) {
|
|
1030
|
+
this.clearSessionNotice();
|
|
1031
|
+
return { ok: true, policy };
|
|
1032
|
+
}
|
|
1033
|
+
const notice = {
|
|
1034
|
+
code: "image-outside-frame",
|
|
1035
|
+
level: policy === "strict" ? "error" : "warning",
|
|
1036
|
+
message: policy === "strict"
|
|
1037
|
+
? "图片位置不能超出 frame,请调整后再提交。"
|
|
1038
|
+
: "图片位置已超出 frame,建议调整后再提交。",
|
|
1039
|
+
imageIds: invalidImageIds,
|
|
1040
|
+
policy,
|
|
1041
|
+
};
|
|
1042
|
+
this.setSessionNotice(notice);
|
|
1043
|
+
this.setImageFocus(invalidImageIds[0], {
|
|
1044
|
+
syncCanvasSelection: true,
|
|
1045
|
+
skipRender: true,
|
|
1046
|
+
});
|
|
1047
|
+
return {
|
|
1048
|
+
ok: policy !== "strict",
|
|
1049
|
+
reason: notice.code,
|
|
1050
|
+
message: notice.message,
|
|
1051
|
+
imageIds: notice.imageIds,
|
|
1052
|
+
policy: notice.policy,
|
|
1053
|
+
};
|
|
1054
|
+
}
|
|
950
1055
|
getFrameVisualConfig() {
|
|
951
1056
|
const strokeStyleRaw = (this.getConfig("image.frame.strokeStyle", "dashed") || "dashed");
|
|
952
1057
|
const strokeStyle = strokeStyleRaw === "dashed" || strokeStyleRaw === "hidden"
|
|
@@ -1228,6 +1333,7 @@ class ImageTool {
|
|
|
1228
1333
|
await this.updateImage(id, next, options);
|
|
1229
1334
|
}
|
|
1230
1335
|
resetImageSession() {
|
|
1336
|
+
this.clearSessionNotice({ emit: false });
|
|
1231
1337
|
this.workingItems = this.cloneItems(this.items);
|
|
1232
1338
|
this.hasWorkingChanges = false;
|
|
1233
1339
|
this.updateImages();
|
|
@@ -1237,6 +1343,7 @@ class ImageTool {
|
|
|
1237
1343
|
const index = this.workingItems.findIndex((item) => item.id === id);
|
|
1238
1344
|
if (index < 0)
|
|
1239
1345
|
return;
|
|
1346
|
+
this.clearSessionNotice({ emit: false });
|
|
1240
1347
|
const next = [...this.workingItems];
|
|
1241
1348
|
next[index] = this.normalizeItem({ ...next[index], ...updates });
|
|
1242
1349
|
this.workingItems = next;
|
|
@@ -1254,6 +1361,7 @@ class ImageTool {
|
|
|
1254
1361
|
const index = this.items.findIndex((item) => item.id === id);
|
|
1255
1362
|
if (index < 0)
|
|
1256
1363
|
return;
|
|
1364
|
+
this.clearSessionNotice({ emit: false });
|
|
1257
1365
|
const replacingSource = typeof updates.url === "string" && updates.url.length > 0;
|
|
1258
1366
|
const next = [...this.items];
|
|
1259
1367
|
const base = next[index];
|
|
@@ -1372,11 +1480,19 @@ class ImageTool {
|
|
|
1372
1480
|
}
|
|
1373
1481
|
}
|
|
1374
1482
|
this.hasWorkingChanges = false;
|
|
1483
|
+
this.clearSessionNotice({ emit: false });
|
|
1375
1484
|
this.workingItems = this.cloneItems(next);
|
|
1376
1485
|
this.updateConfig(next);
|
|
1377
1486
|
this.emitWorkingChange(this.focusedImageId);
|
|
1378
1487
|
return { ok: true };
|
|
1379
1488
|
}
|
|
1489
|
+
async completeImageSession() {
|
|
1490
|
+
const validation = await this.validateImageSession();
|
|
1491
|
+
if (!validation.ok) {
|
|
1492
|
+
return validation;
|
|
1493
|
+
}
|
|
1494
|
+
return await this.commitWorkingImagesAsCropped();
|
|
1495
|
+
}
|
|
1380
1496
|
async exportCroppedImageByIds(imageIds, options) {
|
|
1381
1497
|
if (!this.canvasService) {
|
|
1382
1498
|
throw new Error("CanvasService not initialized");
|
|
@@ -55,12 +55,20 @@ function createImageCommands(tool) {
|
|
|
55
55
|
tool.resetImageSession();
|
|
56
56
|
},
|
|
57
57
|
},
|
|
58
|
+
{
|
|
59
|
+
command: "validateImageSession",
|
|
60
|
+
id: "validateImageSession",
|
|
61
|
+
title: "Validate Image Session",
|
|
62
|
+
handler: async () => {
|
|
63
|
+
return await tool.validateImageSession();
|
|
64
|
+
},
|
|
65
|
+
},
|
|
58
66
|
{
|
|
59
67
|
command: "completeImages",
|
|
60
68
|
id: "completeImages",
|
|
61
69
|
title: "Complete Images",
|
|
62
70
|
handler: async () => {
|
|
63
|
-
return await tool.
|
|
71
|
+
return await tool.completeImageSession();
|
|
64
72
|
},
|
|
65
73
|
},
|
|
66
74
|
{
|
|
@@ -125,5 +125,12 @@ function createImageConfigurations() {
|
|
|
125
125
|
label: "Image Frame Outer Background",
|
|
126
126
|
default: "#f5f5f5",
|
|
127
127
|
},
|
|
128
|
+
{
|
|
129
|
+
id: "image.session.placementPolicy",
|
|
130
|
+
type: "select",
|
|
131
|
+
label: "Image Session Placement Policy",
|
|
132
|
+
options: ["free", "warn", "strict"],
|
|
133
|
+
default: "free",
|
|
134
|
+
},
|
|
128
135
|
];
|
|
129
136
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateImagePlacement = validateImagePlacement;
|
|
4
|
+
const sourceSizeCache_1 = require("../../shared/imaging/sourceSizeCache");
|
|
5
|
+
function toRadians(angle) {
|
|
6
|
+
return (angle * Math.PI) / 180;
|
|
7
|
+
}
|
|
8
|
+
function validateImagePlacement(args) {
|
|
9
|
+
const { frame, source, placement } = args;
|
|
10
|
+
if (frame.width <= 0 ||
|
|
11
|
+
frame.height <= 0 ||
|
|
12
|
+
source.width <= 0 ||
|
|
13
|
+
source.height <= 0) {
|
|
14
|
+
return { ok: true };
|
|
15
|
+
}
|
|
16
|
+
const coverScale = (0, sourceSizeCache_1.getCoverScale)(frame, source);
|
|
17
|
+
const imageWidth = source.width * coverScale * Math.max(0.05, Number(placement.scale || 1));
|
|
18
|
+
const imageHeight = source.height * coverScale * Math.max(0.05, Number(placement.scale || 1));
|
|
19
|
+
if (imageWidth <= 0 || imageHeight <= 0) {
|
|
20
|
+
return { ok: true };
|
|
21
|
+
}
|
|
22
|
+
const centerX = frame.left + placement.left * frame.width;
|
|
23
|
+
const centerY = frame.top + placement.top * frame.height;
|
|
24
|
+
const halfWidth = imageWidth / 2;
|
|
25
|
+
const halfHeight = imageHeight / 2;
|
|
26
|
+
const radians = toRadians(placement.angle || 0);
|
|
27
|
+
const cos = Math.cos(radians);
|
|
28
|
+
const sin = Math.sin(radians);
|
|
29
|
+
const frameCorners = [
|
|
30
|
+
{ x: frame.left, y: frame.top },
|
|
31
|
+
{ x: frame.left + frame.width, y: frame.top },
|
|
32
|
+
{ x: frame.left + frame.width, y: frame.top + frame.height },
|
|
33
|
+
{ x: frame.left, y: frame.top + frame.height },
|
|
34
|
+
];
|
|
35
|
+
const coversFrame = frameCorners.every((corner) => {
|
|
36
|
+
const dx = corner.x - centerX;
|
|
37
|
+
const dy = corner.y - centerY;
|
|
38
|
+
const localX = dx * cos + dy * sin;
|
|
39
|
+
const localY = -dx * sin + dy * cos;
|
|
40
|
+
return (Math.abs(localX) <= halfWidth + 1e-6 &&
|
|
41
|
+
Math.abs(localY) <= halfHeight + 1e-6);
|
|
42
|
+
});
|
|
43
|
+
return { ok: coversFrame };
|
|
44
|
+
}
|
package/.test-dist/tests/run.js
CHANGED
|
@@ -67,10 +67,12 @@ function testMaskOps() {
|
|
|
67
67
|
assert(filled[4 * 9 + 4] === 1, "hole should be filled");
|
|
68
68
|
const imgW = 2;
|
|
69
69
|
const imgH = 1;
|
|
70
|
-
const rgba = new Uint8ClampedArray([
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
const rgba = new Uint8ClampedArray([255, 255, 255, 255, 10, 10, 10, 254]);
|
|
71
|
+
const imageData = {
|
|
72
|
+
width: imgW,
|
|
73
|
+
height: imgH,
|
|
74
|
+
data: rgba,
|
|
75
|
+
};
|
|
74
76
|
const paddedWidth = imgW + 4;
|
|
75
77
|
const paddedHeight = imgH + 4;
|
|
76
78
|
const created = (0, maskOps_1.createMask)(imageData, {
|
|
@@ -181,6 +183,8 @@ function testImageViewStateHelper() {
|
|
|
181
183
|
isImageSelectionActive: false,
|
|
182
184
|
hasWorkingChanges: false,
|
|
183
185
|
source: "committed",
|
|
186
|
+
placementPolicy: "free",
|
|
187
|
+
sessionNotice: null,
|
|
184
188
|
}) === false, "empty image state should report false");
|
|
185
189
|
assert((0, model_1.hasAnyImageInViewState)({
|
|
186
190
|
items: [
|
|
@@ -201,6 +205,8 @@ function testImageViewStateHelper() {
|
|
|
201
205
|
isImageSelectionActive: true,
|
|
202
206
|
hasWorkingChanges: true,
|
|
203
207
|
source: "working",
|
|
208
|
+
placementPolicy: "free",
|
|
209
|
+
sessionNotice: null,
|
|
204
210
|
}) === true, "non-empty image state should report true");
|
|
205
211
|
}
|
|
206
212
|
function testContributionCompatibility() {
|
|
@@ -217,6 +223,7 @@ function testContributionCompatibility() {
|
|
|
217
223
|
"getImageViewState",
|
|
218
224
|
"setImageTransform",
|
|
219
225
|
"imageSessionReset",
|
|
226
|
+
"validateImageSession",
|
|
220
227
|
"completeImages",
|
|
221
228
|
"exportUserCroppedImage",
|
|
222
229
|
"focusImage",
|
|
@@ -282,6 +289,7 @@ function testContributionCompatibility() {
|
|
|
282
289
|
"image.frame.dashLength",
|
|
283
290
|
"image.frame.innerBackground",
|
|
284
291
|
"image.frame.outerBackground",
|
|
292
|
+
"image.session.placementPolicy",
|
|
285
293
|
];
|
|
286
294
|
const expectedWhiteInkConfigKeys = [
|
|
287
295
|
"whiteInk.items",
|
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -103,6 +103,16 @@ interface ImageViewState {
|
|
|
103
103
|
isImageSelectionActive: boolean;
|
|
104
104
|
hasWorkingChanges: boolean;
|
|
105
105
|
source: "working" | "committed";
|
|
106
|
+
placementPolicy: ImageSessionPlacementPolicy;
|
|
107
|
+
sessionNotice: ImageSessionNotice | null;
|
|
108
|
+
}
|
|
109
|
+
type ImageSessionPlacementPolicy = "free" | "warn" | "strict";
|
|
110
|
+
interface ImageSessionNotice {
|
|
111
|
+
code: "image-outside-frame";
|
|
112
|
+
level: "warning" | "error";
|
|
113
|
+
message: string;
|
|
114
|
+
imageIds: string[];
|
|
115
|
+
policy: ImageSessionPlacementPolicy;
|
|
106
116
|
}
|
|
107
117
|
declare class ImageTool implements Extension {
|
|
108
118
|
id: string;
|
|
@@ -130,6 +140,7 @@ declare class ImageTool implements Extension {
|
|
|
130
140
|
private activeSnapX;
|
|
131
141
|
private activeSnapY;
|
|
132
142
|
private movingImageId;
|
|
143
|
+
private sessionNotice;
|
|
133
144
|
private hasRenderedSnapGuides;
|
|
134
145
|
private canvasObjectMovingHandler?;
|
|
135
146
|
private canvasMouseUpHandler?;
|
|
@@ -178,6 +189,7 @@ declare class ImageTool implements Extension {
|
|
|
178
189
|
interaction: string;
|
|
179
190
|
commands: {
|
|
180
191
|
begin: string;
|
|
192
|
+
validate: string;
|
|
181
193
|
commit: string;
|
|
182
194
|
rollback: string;
|
|
183
195
|
};
|
|
@@ -193,6 +205,10 @@ declare class ImageTool implements Extension {
|
|
|
193
205
|
private normalizeItems;
|
|
194
206
|
private cloneItems;
|
|
195
207
|
private getViewItems;
|
|
208
|
+
private getPlacementPolicy;
|
|
209
|
+
private areSessionNoticesEqual;
|
|
210
|
+
private setSessionNotice;
|
|
211
|
+
private clearSessionNotice;
|
|
196
212
|
private getImageViewState;
|
|
197
213
|
private emitImageStateChange;
|
|
198
214
|
private emitWorkingChange;
|
|
@@ -217,6 +233,9 @@ declare class ImageTool implements Extension {
|
|
|
217
233
|
private ensureSourceSize;
|
|
218
234
|
private loadImageSize;
|
|
219
235
|
private getCoverScale;
|
|
236
|
+
private resolvePlacementState;
|
|
237
|
+
private validatePlacementForItem;
|
|
238
|
+
private validateImageSession;
|
|
220
239
|
private getFrameVisualConfig;
|
|
221
240
|
private resolveSessionOverlayState;
|
|
222
241
|
private getCropShapeHatchPattern;
|
|
@@ -238,6 +257,7 @@ declare class ImageTool implements Extension {
|
|
|
238
257
|
private resolveImageSourceSize;
|
|
239
258
|
private applyImageOperation;
|
|
240
259
|
private commitWorkingImagesAsCropped;
|
|
260
|
+
private completeImageSession;
|
|
241
261
|
private exportCroppedImageByIds;
|
|
242
262
|
private exportUserCroppedImage;
|
|
243
263
|
}
|
|
@@ -1146,4 +1166,4 @@ declare function createWhiteInkCommands(tool: any): CommandContribution[];
|
|
|
1146
1166
|
|
|
1147
1167
|
declare function createWhiteInkConfigurations(): ConfigurationContribution[];
|
|
1148
1168
|
|
|
1149
|
-
export { type BackgroundConfig, type BackgroundFitMode, type BackgroundLayer, type BackgroundLayerKind, type BackgroundRegionUnit, type BackgroundRegistration, type BackgroundRegistrationFrame, type BackgroundRegistrationRegion, BackgroundTool, CanvasService, type ComputeImageOperationArgs, type DielineGeometry, type DielineState, DielineTool, FeatureTool, FilmTool, type ImageItem, type ImageOperation, type ImageOperationArea, type ImageOperationAreaSpec, type ImageOperationViewport, ImageTool, type ImageTransformUpdates, type ImageViewState, type LayerObjectCountComparator, type LineStyle, MirrorTool, type RenderClipPathEffectSpec, type RenderCoordinateSpace, type RenderEffectSpec, type RenderLayoutAlign, type RenderLayoutInsets, type RenderLayoutLength, type RenderLayoutRect, type RenderLayoutReference, type RenderObjectLayoutSpec, type RenderObjectSpec, type RenderObjectType, type RenderPassSpec, type RenderProps, RulerTool, SceneLayoutService, SizeTool, ViewportSystem, type VisibilityEvalContext, type VisibilityExpr, type VisibilityLayerState, type WhiteInkItem, WhiteInkTool, getCoverScale as computeImageCoverScale, computeImageOperationUpdates, getCoverScale as computeWhiteInkCoverScale, createDefaultDielineState, createDielineCommands, createDielineConfigurations, createImageCommands, createImageConfigurations, createWhiteInkCommands, createWhiteInkConfigurations, evaluateVisibilityExpr, hasAnyImageInViewState, readDielineState, resolveImageOperationArea };
|
|
1169
|
+
export { type BackgroundConfig, type BackgroundFitMode, type BackgroundLayer, type BackgroundLayerKind, type BackgroundRegionUnit, type BackgroundRegistration, type BackgroundRegistrationFrame, type BackgroundRegistrationRegion, BackgroundTool, CanvasService, type ComputeImageOperationArgs, type DielineGeometry, type DielineState, DielineTool, FeatureTool, FilmTool, type ImageItem, type ImageOperation, type ImageOperationArea, type ImageOperationAreaSpec, type ImageOperationViewport, type ImageSessionNotice, type ImageSessionPlacementPolicy, ImageTool, type ImageTransformUpdates, type ImageViewState, type LayerObjectCountComparator, type LineStyle, MirrorTool, type RenderClipPathEffectSpec, type RenderCoordinateSpace, type RenderEffectSpec, type RenderLayoutAlign, type RenderLayoutInsets, type RenderLayoutLength, type RenderLayoutRect, type RenderLayoutReference, type RenderObjectLayoutSpec, type RenderObjectSpec, type RenderObjectType, type RenderPassSpec, type RenderProps, RulerTool, SceneLayoutService, SizeTool, ViewportSystem, type VisibilityEvalContext, type VisibilityExpr, type VisibilityLayerState, type WhiteInkItem, WhiteInkTool, getCoverScale as computeImageCoverScale, computeImageOperationUpdates, getCoverScale as computeWhiteInkCoverScale, createDefaultDielineState, createDielineCommands, createDielineConfigurations, createImageCommands, createImageConfigurations, createWhiteInkCommands, createWhiteInkConfigurations, evaluateVisibilityExpr, hasAnyImageInViewState, readDielineState, resolveImageOperationArea };
|
package/dist/index.d.ts
CHANGED
|
@@ -103,6 +103,16 @@ interface ImageViewState {
|
|
|
103
103
|
isImageSelectionActive: boolean;
|
|
104
104
|
hasWorkingChanges: boolean;
|
|
105
105
|
source: "working" | "committed";
|
|
106
|
+
placementPolicy: ImageSessionPlacementPolicy;
|
|
107
|
+
sessionNotice: ImageSessionNotice | null;
|
|
108
|
+
}
|
|
109
|
+
type ImageSessionPlacementPolicy = "free" | "warn" | "strict";
|
|
110
|
+
interface ImageSessionNotice {
|
|
111
|
+
code: "image-outside-frame";
|
|
112
|
+
level: "warning" | "error";
|
|
113
|
+
message: string;
|
|
114
|
+
imageIds: string[];
|
|
115
|
+
policy: ImageSessionPlacementPolicy;
|
|
106
116
|
}
|
|
107
117
|
declare class ImageTool implements Extension {
|
|
108
118
|
id: string;
|
|
@@ -130,6 +140,7 @@ declare class ImageTool implements Extension {
|
|
|
130
140
|
private activeSnapX;
|
|
131
141
|
private activeSnapY;
|
|
132
142
|
private movingImageId;
|
|
143
|
+
private sessionNotice;
|
|
133
144
|
private hasRenderedSnapGuides;
|
|
134
145
|
private canvasObjectMovingHandler?;
|
|
135
146
|
private canvasMouseUpHandler?;
|
|
@@ -178,6 +189,7 @@ declare class ImageTool implements Extension {
|
|
|
178
189
|
interaction: string;
|
|
179
190
|
commands: {
|
|
180
191
|
begin: string;
|
|
192
|
+
validate: string;
|
|
181
193
|
commit: string;
|
|
182
194
|
rollback: string;
|
|
183
195
|
};
|
|
@@ -193,6 +205,10 @@ declare class ImageTool implements Extension {
|
|
|
193
205
|
private normalizeItems;
|
|
194
206
|
private cloneItems;
|
|
195
207
|
private getViewItems;
|
|
208
|
+
private getPlacementPolicy;
|
|
209
|
+
private areSessionNoticesEqual;
|
|
210
|
+
private setSessionNotice;
|
|
211
|
+
private clearSessionNotice;
|
|
196
212
|
private getImageViewState;
|
|
197
213
|
private emitImageStateChange;
|
|
198
214
|
private emitWorkingChange;
|
|
@@ -217,6 +233,9 @@ declare class ImageTool implements Extension {
|
|
|
217
233
|
private ensureSourceSize;
|
|
218
234
|
private loadImageSize;
|
|
219
235
|
private getCoverScale;
|
|
236
|
+
private resolvePlacementState;
|
|
237
|
+
private validatePlacementForItem;
|
|
238
|
+
private validateImageSession;
|
|
220
239
|
private getFrameVisualConfig;
|
|
221
240
|
private resolveSessionOverlayState;
|
|
222
241
|
private getCropShapeHatchPattern;
|
|
@@ -238,6 +257,7 @@ declare class ImageTool implements Extension {
|
|
|
238
257
|
private resolveImageSourceSize;
|
|
239
258
|
private applyImageOperation;
|
|
240
259
|
private commitWorkingImagesAsCropped;
|
|
260
|
+
private completeImageSession;
|
|
241
261
|
private exportCroppedImageByIds;
|
|
242
262
|
private exportUserCroppedImage;
|
|
243
263
|
}
|
|
@@ -1146,4 +1166,4 @@ declare function createWhiteInkCommands(tool: any): CommandContribution[];
|
|
|
1146
1166
|
|
|
1147
1167
|
declare function createWhiteInkConfigurations(): ConfigurationContribution[];
|
|
1148
1168
|
|
|
1149
|
-
export { type BackgroundConfig, type BackgroundFitMode, type BackgroundLayer, type BackgroundLayerKind, type BackgroundRegionUnit, type BackgroundRegistration, type BackgroundRegistrationFrame, type BackgroundRegistrationRegion, BackgroundTool, CanvasService, type ComputeImageOperationArgs, type DielineGeometry, type DielineState, DielineTool, FeatureTool, FilmTool, type ImageItem, type ImageOperation, type ImageOperationArea, type ImageOperationAreaSpec, type ImageOperationViewport, ImageTool, type ImageTransformUpdates, type ImageViewState, type LayerObjectCountComparator, type LineStyle, MirrorTool, type RenderClipPathEffectSpec, type RenderCoordinateSpace, type RenderEffectSpec, type RenderLayoutAlign, type RenderLayoutInsets, type RenderLayoutLength, type RenderLayoutRect, type RenderLayoutReference, type RenderObjectLayoutSpec, type RenderObjectSpec, type RenderObjectType, type RenderPassSpec, type RenderProps, RulerTool, SceneLayoutService, SizeTool, ViewportSystem, type VisibilityEvalContext, type VisibilityExpr, type VisibilityLayerState, type WhiteInkItem, WhiteInkTool, getCoverScale as computeImageCoverScale, computeImageOperationUpdates, getCoverScale as computeWhiteInkCoverScale, createDefaultDielineState, createDielineCommands, createDielineConfigurations, createImageCommands, createImageConfigurations, createWhiteInkCommands, createWhiteInkConfigurations, evaluateVisibilityExpr, hasAnyImageInViewState, readDielineState, resolveImageOperationArea };
|
|
1169
|
+
export { type BackgroundConfig, type BackgroundFitMode, type BackgroundLayer, type BackgroundLayerKind, type BackgroundRegionUnit, type BackgroundRegistration, type BackgroundRegistrationFrame, type BackgroundRegistrationRegion, BackgroundTool, CanvasService, type ComputeImageOperationArgs, type DielineGeometry, type DielineState, DielineTool, FeatureTool, FilmTool, type ImageItem, type ImageOperation, type ImageOperationArea, type ImageOperationAreaSpec, type ImageOperationViewport, type ImageSessionNotice, type ImageSessionPlacementPolicy, ImageTool, type ImageTransformUpdates, type ImageViewState, type LayerObjectCountComparator, type LineStyle, MirrorTool, type RenderClipPathEffectSpec, type RenderCoordinateSpace, type RenderEffectSpec, type RenderLayoutAlign, type RenderLayoutInsets, type RenderLayoutLength, type RenderLayoutRect, type RenderLayoutReference, type RenderObjectLayoutSpec, type RenderObjectSpec, type RenderObjectType, type RenderPassSpec, type RenderProps, RulerTool, SceneLayoutService, SizeTool, ViewportSystem, type VisibilityEvalContext, type VisibilityExpr, type VisibilityLayerState, type WhiteInkItem, WhiteInkTool, getCoverScale as computeImageCoverScale, computeImageOperationUpdates, getCoverScale as computeWhiteInkCoverScale, createDefaultDielineState, createDielineCommands, createDielineConfigurations, createImageCommands, createImageConfigurations, createWhiteInkCommands, createWhiteInkConfigurations, evaluateVisibilityExpr, hasAnyImageInViewState, readDielineState, resolveImageOperationArea };
|