@pooder/kit 4.3.1 → 5.0.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/CanvasService.js +249 -0
- package/.test-dist/src/ViewportSystem.js +75 -0
- package/.test-dist/src/background.js +203 -0
- package/.test-dist/src/bridgeSelection.js +20 -0
- package/.test-dist/src/constraints.js +237 -0
- package/.test-dist/src/coordinate.js +74 -0
- package/.test-dist/src/dieline.js +723 -0
- package/.test-dist/src/edgeScale.js +12 -0
- package/.test-dist/src/feature.js +752 -0
- package/.test-dist/src/featureComplete.js +32 -0
- package/.test-dist/src/film.js +167 -0
- package/.test-dist/src/geometry.js +506 -0
- package/.test-dist/src/image.js +1234 -0
- package/.test-dist/src/index.js +35 -0
- package/.test-dist/src/maskOps.js +270 -0
- package/.test-dist/src/mirror.js +104 -0
- package/.test-dist/src/renderSpec.js +2 -0
- package/.test-dist/src/ruler.js +343 -0
- package/.test-dist/src/sceneLayout.js +99 -0
- package/.test-dist/src/sceneLayoutModel.js +196 -0
- package/.test-dist/src/sceneView.js +40 -0
- package/.test-dist/src/sceneVisibility.js +42 -0
- package/.test-dist/src/size.js +332 -0
- package/.test-dist/src/tracer.js +544 -0
- package/.test-dist/src/units.js +30 -0
- package/.test-dist/src/white-ink.js +829 -0
- package/.test-dist/src/wrappedOffsets.js +33 -0
- package/.test-dist/tests/run.js +94 -0
- package/CHANGELOG.md +11 -0
- package/dist/index.d.mts +339 -36
- package/dist/index.d.ts +339 -36
- package/dist/index.js +3572 -850
- package/dist/index.mjs +3565 -852
- package/package.json +2 -2
- package/src/CanvasService.ts +300 -96
- package/src/ViewportSystem.ts +92 -92
- package/src/background.ts +230 -230
- package/src/bridgeSelection.ts +17 -0
- package/src/coordinate.ts +106 -106
- package/src/dieline.ts +897 -973
- package/src/edgeScale.ts +19 -0
- package/src/feature.ts +83 -30
- package/src/film.ts +194 -194
- package/src/geometry.ts +242 -84
- package/src/image.ts +1582 -512
- package/src/index.ts +14 -10
- package/src/maskOps.ts +326 -0
- package/src/mirror.ts +128 -128
- package/src/renderSpec.ts +18 -0
- package/src/ruler.ts +449 -508
- package/src/sceneLayout.ts +121 -0
- package/src/sceneLayoutModel.ts +335 -0
- package/src/sceneVisibility.ts +49 -0
- package/src/size.ts +379 -0
- package/src/tracer.ts +719 -570
- package/src/units.ts +27 -27
- package/src/white-ink.ts +1018 -373
- package/src/wrappedOffsets.ts +33 -0
- package/tests/run.ts +118 -0
- package/tsconfig.test.json +15 -15
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.wrappedDistance = wrappedDistance;
|
|
4
|
+
exports.sampleWrappedOffsets = sampleWrappedOffsets;
|
|
5
|
+
function wrappedDistance(total, start, end) {
|
|
6
|
+
if (!Number.isFinite(total) || total <= 0)
|
|
7
|
+
return 0;
|
|
8
|
+
if (!Number.isFinite(start) || !Number.isFinite(end))
|
|
9
|
+
return 0;
|
|
10
|
+
const s = ((start % total) + total) % total;
|
|
11
|
+
const e = ((end % total) + total) % total;
|
|
12
|
+
return e >= s ? e - s : total - s + e;
|
|
13
|
+
}
|
|
14
|
+
function sampleWrappedOffsets(total, start, end, count) {
|
|
15
|
+
if (!Number.isFinite(total) || total <= 0)
|
|
16
|
+
return [];
|
|
17
|
+
if (!Number.isFinite(start) || !Number.isFinite(end))
|
|
18
|
+
return [];
|
|
19
|
+
const n = Math.max(0, Math.floor(count));
|
|
20
|
+
if (n <= 0)
|
|
21
|
+
return [];
|
|
22
|
+
const dist = wrappedDistance(total, start, end);
|
|
23
|
+
if (n === 1)
|
|
24
|
+
return [((start % total) + total) % total];
|
|
25
|
+
const step = dist / (n - 1);
|
|
26
|
+
const offsets = [];
|
|
27
|
+
for (let i = 0; i < n; i++) {
|
|
28
|
+
const raw = start + step * i;
|
|
29
|
+
const wrapped = ((raw % total) + total) % total;
|
|
30
|
+
offsets.push(wrapped);
|
|
31
|
+
}
|
|
32
|
+
return offsets;
|
|
33
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const bridgeSelection_1 = require("../src/bridgeSelection");
|
|
4
|
+
const wrappedOffsets_1 = require("../src/wrappedOffsets");
|
|
5
|
+
const maskOps_1 = require("../src/maskOps");
|
|
6
|
+
const edgeScale_1 = require("../src/edgeScale");
|
|
7
|
+
function assert(condition, message) {
|
|
8
|
+
if (!condition)
|
|
9
|
+
throw new Error(message);
|
|
10
|
+
}
|
|
11
|
+
function testWrappedOffsets() {
|
|
12
|
+
assert((0, wrappedOffsets_1.wrappedDistance)(100, 10, 30) === 20, "distance 10->30 should be 20");
|
|
13
|
+
assert((0, wrappedOffsets_1.wrappedDistance)(100, 90, 10) === 20, "distance 90->10 should wrap to 20");
|
|
14
|
+
const a = (0, wrappedOffsets_1.sampleWrappedOffsets)(100, 10, 30, 5);
|
|
15
|
+
assert(JSON.stringify(a) === JSON.stringify([10, 15, 20, 25, 30]), `unexpected sample: ${JSON.stringify(a)}`);
|
|
16
|
+
const b = (0, wrappedOffsets_1.sampleWrappedOffsets)(100, 90, 10, 3);
|
|
17
|
+
assert(JSON.stringify(b) === JSON.stringify([90, 0, 10]), `unexpected wrap sample: ${JSON.stringify(b)}`);
|
|
18
|
+
}
|
|
19
|
+
function testBridgeSelection() {
|
|
20
|
+
const idx = (0, bridgeSelection_1.pickExitIndex)([
|
|
21
|
+
{ insideAbove: true, insideBelow: true },
|
|
22
|
+
{ insideAbove: false, insideBelow: true },
|
|
23
|
+
{ insideAbove: false, insideBelow: false },
|
|
24
|
+
]);
|
|
25
|
+
assert(idx === 1, `expected exit index 1, got ${idx}`);
|
|
26
|
+
const none = (0, bridgeSelection_1.pickExitIndex)([{ insideAbove: true, insideBelow: true }]);
|
|
27
|
+
assert(none === -1, `expected -1, got ${none}`);
|
|
28
|
+
const score = (0, bridgeSelection_1.scoreOutsideAbove)([
|
|
29
|
+
{ outsideAbove: true },
|
|
30
|
+
{ outsideAbove: false },
|
|
31
|
+
{ outsideAbove: true },
|
|
32
|
+
]);
|
|
33
|
+
assert(score === 2, `expected score 2, got ${score}`);
|
|
34
|
+
}
|
|
35
|
+
function testMaskOps() {
|
|
36
|
+
const width = 50;
|
|
37
|
+
const height = 50;
|
|
38
|
+
const mask = new Uint8Array(width * height);
|
|
39
|
+
mask[10 * width + 10] = 1;
|
|
40
|
+
mask[10 * width + 20] = 1;
|
|
41
|
+
const r = (0, maskOps_1.findMinimalConnectRadius)(mask, width, height, 20);
|
|
42
|
+
const closed = (0, maskOps_1.circularMorphology)(mask, width, height, r, "closing");
|
|
43
|
+
assert((0, maskOps_1.isMaskConnected8)(closed, width, height), `closed mask should be connected (r=${r})`);
|
|
44
|
+
if (r > 0) {
|
|
45
|
+
const closedPrev = (0, maskOps_1.circularMorphology)(mask, width, height, r - 1, "closing");
|
|
46
|
+
assert(!(0, maskOps_1.isMaskConnected8)(closedPrev, width, height), `r should be minimal (r=${r})`);
|
|
47
|
+
}
|
|
48
|
+
const donut = new Uint8Array(9 * 9);
|
|
49
|
+
for (let y = 1; y <= 7; y++) {
|
|
50
|
+
for (let x = 1; x <= 7; x++)
|
|
51
|
+
donut[y * 9 + x] = 1;
|
|
52
|
+
}
|
|
53
|
+
for (let y = 3; y <= 5; y++) {
|
|
54
|
+
for (let x = 3; x <= 5; x++)
|
|
55
|
+
donut[y * 9 + x] = 0;
|
|
56
|
+
}
|
|
57
|
+
const filled = (0, maskOps_1.fillHoles)(donut, 9, 9);
|
|
58
|
+
assert(filled[4 * 9 + 4] === 1, "hole should be filled");
|
|
59
|
+
const imgW = 2;
|
|
60
|
+
const imgH = 1;
|
|
61
|
+
const rgba = new Uint8ClampedArray([
|
|
62
|
+
255, 255, 255, 255, 10, 10, 10, 254,
|
|
63
|
+
]);
|
|
64
|
+
const imageData = { width: imgW, height: imgH, data: rgba };
|
|
65
|
+
const paddedWidth = imgW + 4;
|
|
66
|
+
const paddedHeight = imgH + 4;
|
|
67
|
+
const created = (0, maskOps_1.createMask)(imageData, {
|
|
68
|
+
threshold: 10,
|
|
69
|
+
padding: 2,
|
|
70
|
+
paddedWidth,
|
|
71
|
+
paddedHeight,
|
|
72
|
+
maskMode: "auto",
|
|
73
|
+
alphaOpaqueCutoff: 250,
|
|
74
|
+
});
|
|
75
|
+
assert(created[2 * paddedWidth + 2] === 0, "white pixel should be background");
|
|
76
|
+
assert(created[2 * paddedWidth + 3] === 1, "non-white pixel should be foreground");
|
|
77
|
+
}
|
|
78
|
+
function testEdgeScale() {
|
|
79
|
+
const currentMax = 100;
|
|
80
|
+
const baseBounds = { width: 50, height: 20 };
|
|
81
|
+
const expandedBounds = { width: 70, height: 40 };
|
|
82
|
+
const { width, height, scale } = (0, edgeScale_1.computeDetectEdgeSize)(currentMax, baseBounds, expandedBounds);
|
|
83
|
+
assert(scale === 2, `expected scale 2, got ${scale}`);
|
|
84
|
+
assert(width === 140, `expected width 140, got ${width}`);
|
|
85
|
+
assert(height === 80, `expected height 80, got ${height}`);
|
|
86
|
+
}
|
|
87
|
+
function main() {
|
|
88
|
+
testWrappedOffsets();
|
|
89
|
+
testBridgeSelection();
|
|
90
|
+
testMaskOps();
|
|
91
|
+
testEdgeScale();
|
|
92
|
+
console.log("ok");
|
|
93
|
+
}
|
|
94
|
+
main();
|
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Extension, ExtensionContext, ContributionPointIds, ConfigurationContribution, CommandContribution, Service, EventBus } from '@pooder/core';
|
|
1
|
+
import { Extension, ExtensionContext, ContributionPointIds, ConfigurationContribution, CommandContribution, Service, EventBus, ConfigurationService } from '@pooder/core';
|
|
2
2
|
import { Canvas, Group, FabricObject } from 'fabric';
|
|
3
3
|
|
|
4
4
|
declare class BackgroundTool implements Extension {
|
|
@@ -107,10 +107,20 @@ declare class DielineTool implements Extension {
|
|
|
107
107
|
private state;
|
|
108
108
|
private canvasService?;
|
|
109
109
|
private context?;
|
|
110
|
+
private onCanvasResized;
|
|
110
111
|
constructor(options?: Partial<DielineState>);
|
|
111
112
|
activate(context: ExtensionContext): void;
|
|
112
113
|
deactivate(context: ExtensionContext): void;
|
|
113
114
|
contribute(): {
|
|
115
|
+
[ContributionPointIds.TOOLS]: {
|
|
116
|
+
id: string;
|
|
117
|
+
name: string;
|
|
118
|
+
interaction: string;
|
|
119
|
+
session: {
|
|
120
|
+
autoBegin: boolean;
|
|
121
|
+
leavePolicy: string;
|
|
122
|
+
};
|
|
123
|
+
}[];
|
|
114
124
|
[ContributionPointIds.CONFIGURATIONS]: ConfigurationContribution[];
|
|
115
125
|
[ContributionPointIds.COMMANDS]: CommandContribution[];
|
|
116
126
|
};
|
|
@@ -118,8 +128,10 @@ declare class DielineTool implements Extension {
|
|
|
118
128
|
private createLayer;
|
|
119
129
|
private destroyLayer;
|
|
120
130
|
private createHatchPattern;
|
|
121
|
-
private
|
|
122
|
-
|
|
131
|
+
private getConfigService;
|
|
132
|
+
private syncSizeState;
|
|
133
|
+
private bringFeatureMarkersToFront;
|
|
134
|
+
updateDieline(_emitEvent?: boolean): void;
|
|
123
135
|
getGeometry(): DielineGeometry | null;
|
|
124
136
|
exportCutImage(): Promise<string | null>;
|
|
125
137
|
}
|
|
@@ -164,9 +176,11 @@ declare class FeatureTool implements Extension {
|
|
|
164
176
|
private context?;
|
|
165
177
|
private isUpdatingConfig;
|
|
166
178
|
private isToolActive;
|
|
179
|
+
private hasWorkingChanges;
|
|
180
|
+
private dirtyTrackerDisposable?;
|
|
167
181
|
private handleMoving;
|
|
168
182
|
private handleModified;
|
|
169
|
-
private
|
|
183
|
+
private handleSceneGeometryChange;
|
|
170
184
|
private currentGeometry;
|
|
171
185
|
constructor(options?: Partial<{
|
|
172
186
|
features: ConstraintFeature[];
|
|
@@ -176,6 +190,20 @@ declare class FeatureTool implements Extension {
|
|
|
176
190
|
private onToolActivated;
|
|
177
191
|
private updateVisibility;
|
|
178
192
|
contribute(): {
|
|
193
|
+
[ContributionPointIds.TOOLS]: {
|
|
194
|
+
id: string;
|
|
195
|
+
name: string;
|
|
196
|
+
interaction: string;
|
|
197
|
+
commands: {
|
|
198
|
+
begin: string;
|
|
199
|
+
commit: string;
|
|
200
|
+
rollback: string;
|
|
201
|
+
};
|
|
202
|
+
session: {
|
|
203
|
+
autoBegin: boolean;
|
|
204
|
+
leavePolicy: string;
|
|
205
|
+
};
|
|
206
|
+
}[];
|
|
179
207
|
[ContributionPointIds.COMMANDS]: CommandContribution[];
|
|
180
208
|
};
|
|
181
209
|
private cloneFeatures;
|
|
@@ -203,6 +231,8 @@ interface ImageItem {
|
|
|
203
231
|
angle?: number;
|
|
204
232
|
left?: number;
|
|
205
233
|
top?: number;
|
|
234
|
+
sourceUrl?: string;
|
|
235
|
+
committedUrl?: string;
|
|
206
236
|
}
|
|
207
237
|
declare class ImageTool implements Extension {
|
|
208
238
|
id: string;
|
|
@@ -210,59 +240,182 @@ declare class ImageTool implements Extension {
|
|
|
210
240
|
name: string;
|
|
211
241
|
};
|
|
212
242
|
private items;
|
|
213
|
-
private
|
|
243
|
+
private workingItems;
|
|
244
|
+
private hasWorkingChanges;
|
|
214
245
|
private loadResolvers;
|
|
246
|
+
private sourceSizeBySrc;
|
|
215
247
|
private canvasService?;
|
|
216
248
|
private context?;
|
|
217
249
|
private isUpdatingConfig;
|
|
218
250
|
private isToolActive;
|
|
251
|
+
private isImageSelectionActive;
|
|
252
|
+
private focusedImageId;
|
|
253
|
+
private suppressSelectionClearUntil;
|
|
254
|
+
private renderSeq;
|
|
255
|
+
private dirtyTrackerDisposable?;
|
|
219
256
|
activate(context: ExtensionContext): void;
|
|
220
257
|
deactivate(context: ExtensionContext): void;
|
|
221
258
|
private onToolActivated;
|
|
222
|
-
private
|
|
259
|
+
private onSelectionChanged;
|
|
260
|
+
private onSelectionCleared;
|
|
261
|
+
private onSceneLayoutChanged;
|
|
262
|
+
private syncToolActiveFromWorkbench;
|
|
263
|
+
private isImageEditingVisible;
|
|
264
|
+
private isDebugEnabled;
|
|
265
|
+
private debug;
|
|
223
266
|
contribute(): {
|
|
267
|
+
[ContributionPointIds.TOOLS]: {
|
|
268
|
+
id: string;
|
|
269
|
+
name: string;
|
|
270
|
+
interaction: string;
|
|
271
|
+
commands: {
|
|
272
|
+
begin: string;
|
|
273
|
+
commit: string;
|
|
274
|
+
rollback: string;
|
|
275
|
+
};
|
|
276
|
+
session: {
|
|
277
|
+
autoBegin: boolean;
|
|
278
|
+
leavePolicy: string;
|
|
279
|
+
};
|
|
280
|
+
}[];
|
|
224
281
|
[ContributionPointIds.CONFIGURATIONS]: ConfigurationContribution[];
|
|
225
282
|
[ContributionPointIds.COMMANDS]: CommandContribution[];
|
|
226
283
|
};
|
|
284
|
+
private normalizeItem;
|
|
285
|
+
private normalizeItems;
|
|
286
|
+
private cloneItems;
|
|
227
287
|
private generateId;
|
|
288
|
+
private getImageIdFromActiveObject;
|
|
289
|
+
private resolveReplaceTargetId;
|
|
290
|
+
private addImageEntry;
|
|
291
|
+
private upsertImageEntry;
|
|
292
|
+
private addItemToWorkingSessionIfNeeded;
|
|
293
|
+
private updateImage;
|
|
294
|
+
private getConfig;
|
|
228
295
|
private updateConfig;
|
|
229
|
-
private
|
|
230
|
-
private
|
|
296
|
+
private getFrameRect;
|
|
297
|
+
private resolveDefaultFitArea;
|
|
298
|
+
private fitImageToDefaultArea;
|
|
299
|
+
private getImageObjects;
|
|
300
|
+
private getOverlayObjects;
|
|
301
|
+
private getImageObject;
|
|
302
|
+
private clearRenderedImages;
|
|
303
|
+
private purgeSourceSizeCacheForItem;
|
|
304
|
+
private rememberSourceSize;
|
|
305
|
+
private getSourceSize;
|
|
306
|
+
private getCoverScale;
|
|
307
|
+
private getFrameVisualConfig;
|
|
308
|
+
private resolveRenderImageState;
|
|
309
|
+
private computeCanvasProps;
|
|
310
|
+
private getCurrentSrc;
|
|
311
|
+
private upsertImageObject;
|
|
312
|
+
private syncImageZOrder;
|
|
313
|
+
private buildOverlaySpecs;
|
|
231
314
|
private updateImages;
|
|
232
|
-
private
|
|
233
|
-
private
|
|
234
|
-
private
|
|
315
|
+
private updateImagesAsync;
|
|
316
|
+
private clampNormalized;
|
|
317
|
+
private onObjectModified;
|
|
318
|
+
private updateImageInWorking;
|
|
235
319
|
private updateImageInConfig;
|
|
320
|
+
private waitImageLoaded;
|
|
321
|
+
private refitImageToFrame;
|
|
322
|
+
private focusImageSelection;
|
|
323
|
+
private fitImageToArea;
|
|
324
|
+
private commitWorkingImagesAsCropped;
|
|
325
|
+
private exportCroppedImageByIds;
|
|
326
|
+
private exportImageFrameUrl;
|
|
236
327
|
}
|
|
237
328
|
|
|
329
|
+
interface WhiteInkItem {
|
|
330
|
+
id: string;
|
|
331
|
+
sourceUrl?: string;
|
|
332
|
+
url?: string;
|
|
333
|
+
opacity: number;
|
|
334
|
+
}
|
|
238
335
|
declare class WhiteInkTool implements Extension {
|
|
239
336
|
id: string;
|
|
240
337
|
metadata: {
|
|
241
338
|
name: string;
|
|
242
339
|
};
|
|
243
|
-
private
|
|
244
|
-
private
|
|
245
|
-
private
|
|
340
|
+
private items;
|
|
341
|
+
private workingItems;
|
|
342
|
+
private hasWorkingChanges;
|
|
343
|
+
private sourceSizeBySrc;
|
|
344
|
+
private previewMaskBySource;
|
|
345
|
+
private pendingPreviewMaskBySource;
|
|
246
346
|
private canvasService?;
|
|
247
|
-
private
|
|
248
|
-
private
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
347
|
+
private context?;
|
|
348
|
+
private isUpdatingConfig;
|
|
349
|
+
private isToolActive;
|
|
350
|
+
private printWithWhiteInk;
|
|
351
|
+
private previewImageVisible;
|
|
352
|
+
private renderSeq;
|
|
353
|
+
private dirtyTrackerDisposable?;
|
|
254
354
|
activate(context: ExtensionContext): void;
|
|
255
355
|
deactivate(context: ExtensionContext): void;
|
|
256
356
|
contribute(): {
|
|
357
|
+
[ContributionPointIds.TOOLS]: {
|
|
358
|
+
id: string;
|
|
359
|
+
name: string;
|
|
360
|
+
interaction: string;
|
|
361
|
+
commands: {
|
|
362
|
+
begin: string;
|
|
363
|
+
commit: string;
|
|
364
|
+
rollback: string;
|
|
365
|
+
};
|
|
366
|
+
session: {
|
|
367
|
+
autoBegin: boolean;
|
|
368
|
+
leavePolicy: string;
|
|
369
|
+
};
|
|
370
|
+
}[];
|
|
257
371
|
[ContributionPointIds.CONFIGURATIONS]: ConfigurationContribution[];
|
|
258
372
|
[ContributionPointIds.COMMANDS]: CommandContribution[];
|
|
259
373
|
};
|
|
260
|
-
private
|
|
261
|
-
private
|
|
262
|
-
private
|
|
263
|
-
private
|
|
264
|
-
private
|
|
265
|
-
private
|
|
374
|
+
private onToolActivated;
|
|
375
|
+
private onSceneLayoutChanged;
|
|
376
|
+
private onObjectAdded;
|
|
377
|
+
private migrateLegacyConfigIfNeeded;
|
|
378
|
+
private syncToolActiveFromWorkbench;
|
|
379
|
+
private isPreviewActive;
|
|
380
|
+
private isDebugEnabled;
|
|
381
|
+
private debug;
|
|
382
|
+
private resolveSourceUrl;
|
|
383
|
+
private clampOpacity;
|
|
384
|
+
private normalizeItem;
|
|
385
|
+
private normalizeItems;
|
|
386
|
+
private cloneItems;
|
|
387
|
+
private generateId;
|
|
388
|
+
private getConfig;
|
|
389
|
+
private resolveReplaceTargetId;
|
|
390
|
+
private updateConfig;
|
|
391
|
+
private addWhiteInkEntry;
|
|
392
|
+
private upsertWhiteInkEntry;
|
|
393
|
+
private addItemToWorkingSessionIfNeeded;
|
|
394
|
+
private updateWhiteInkItem;
|
|
395
|
+
private updateWhiteInkInWorking;
|
|
396
|
+
private updateWhiteInkInConfig;
|
|
397
|
+
private removeWhiteInk;
|
|
398
|
+
private clearWhiteInks;
|
|
399
|
+
private completeWhiteInks;
|
|
400
|
+
private getFrameRect;
|
|
401
|
+
private getWhiteInkObjects;
|
|
402
|
+
private getWhiteInkObject;
|
|
403
|
+
private clearRenderedWhiteInks;
|
|
404
|
+
private purgeSourceCaches;
|
|
405
|
+
private rememberSourceSize;
|
|
406
|
+
private getSourceSize;
|
|
407
|
+
private getCoverScale;
|
|
408
|
+
private resolveRenderState;
|
|
409
|
+
private computeCanvasProps;
|
|
410
|
+
private getCurrentSrc;
|
|
411
|
+
private upsertWhiteInkObject;
|
|
412
|
+
private syncZOrder;
|
|
413
|
+
private applyImagePreviewVisibility;
|
|
414
|
+
private updateWhiteInks;
|
|
415
|
+
private updateWhiteInksAsync;
|
|
416
|
+
private getPreviewMaskSource;
|
|
417
|
+
private createOpaqueMaskSource;
|
|
418
|
+
private loadImageElement;
|
|
266
419
|
}
|
|
267
420
|
|
|
268
421
|
declare class RulerTool implements Extension {
|
|
@@ -276,12 +429,9 @@ declare class RulerTool implements Extension {
|
|
|
276
429
|
private textColor;
|
|
277
430
|
private lineColor;
|
|
278
431
|
private fontSize;
|
|
279
|
-
private dielineWidth;
|
|
280
|
-
private dielineHeight;
|
|
281
|
-
private dielineDisplayUnit;
|
|
282
|
-
private dielinePadding;
|
|
283
|
-
private dielineOffset;
|
|
284
432
|
private canvasService?;
|
|
433
|
+
private context?;
|
|
434
|
+
private onCanvasResized;
|
|
285
435
|
constructor(options?: Partial<{
|
|
286
436
|
thickness: number;
|
|
287
437
|
backgroundColor: string;
|
|
@@ -299,7 +449,6 @@ declare class RulerTool implements Extension {
|
|
|
299
449
|
private createLayer;
|
|
300
450
|
private destroyLayer;
|
|
301
451
|
private createArrowLine;
|
|
302
|
-
private resolvePadding;
|
|
303
452
|
private updateRuler;
|
|
304
453
|
}
|
|
305
454
|
|
|
@@ -326,8 +475,56 @@ declare class MirrorTool implements Extension {
|
|
|
326
475
|
private applyMirror;
|
|
327
476
|
}
|
|
328
477
|
|
|
329
|
-
declare
|
|
330
|
-
|
|
478
|
+
declare class SizeTool implements Extension {
|
|
479
|
+
id: string;
|
|
480
|
+
metadata: {
|
|
481
|
+
name: string;
|
|
482
|
+
};
|
|
483
|
+
private context?;
|
|
484
|
+
private canvasService?;
|
|
485
|
+
activate(context: ExtensionContext): void;
|
|
486
|
+
deactivate(_context: ExtensionContext): void;
|
|
487
|
+
contribute(): {
|
|
488
|
+
[ContributionPointIds.TOOLS]: {
|
|
489
|
+
id: string;
|
|
490
|
+
name: string;
|
|
491
|
+
interaction: string;
|
|
492
|
+
}[];
|
|
493
|
+
[ContributionPointIds.CONFIGURATIONS]: ConfigurationContribution[];
|
|
494
|
+
[ContributionPointIds.COMMANDS]: CommandContribution[];
|
|
495
|
+
};
|
|
496
|
+
private getConfigService;
|
|
497
|
+
private ensureDefaults;
|
|
498
|
+
private emitStateChanged;
|
|
499
|
+
private getStateForUI;
|
|
500
|
+
private updateDimensions;
|
|
501
|
+
private setConstraintMode;
|
|
502
|
+
private setUnit;
|
|
503
|
+
private setCut;
|
|
504
|
+
private getSelectedImageSize;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
declare class SceneLayoutService implements Extension {
|
|
508
|
+
id: string;
|
|
509
|
+
metadata: {
|
|
510
|
+
name: string;
|
|
511
|
+
};
|
|
512
|
+
private context?;
|
|
513
|
+
private canvasService?;
|
|
514
|
+
private configService?;
|
|
515
|
+
private lastLayout;
|
|
516
|
+
private lastGeometry;
|
|
517
|
+
private onConfigChange?;
|
|
518
|
+
activate(context: ExtensionContext): void;
|
|
519
|
+
deactivate(context: ExtensionContext): void;
|
|
520
|
+
contribute(): {
|
|
521
|
+
[ContributionPointIds.COMMANDS]: CommandContribution[];
|
|
522
|
+
};
|
|
523
|
+
private onCanvasResized;
|
|
524
|
+
private refresh;
|
|
525
|
+
private getLayout;
|
|
526
|
+
private getGeometry;
|
|
527
|
+
}
|
|
331
528
|
|
|
332
529
|
declare class ViewportSystem {
|
|
333
530
|
private _containerSize;
|
|
@@ -348,6 +545,21 @@ declare class ViewportSystem {
|
|
|
348
545
|
toPhysicalPoint(point: Point): Point;
|
|
349
546
|
}
|
|
350
547
|
|
|
548
|
+
type RenderObjectType = "rect" | "image" | "path";
|
|
549
|
+
type RenderProps = Record<string, any>;
|
|
550
|
+
interface RenderObjectSpec {
|
|
551
|
+
id: string;
|
|
552
|
+
type: RenderObjectType;
|
|
553
|
+
props: RenderProps;
|
|
554
|
+
data?: Record<string, any>;
|
|
555
|
+
src?: string;
|
|
556
|
+
}
|
|
557
|
+
interface RenderLayerSpec {
|
|
558
|
+
id: string;
|
|
559
|
+
objects: RenderObjectSpec[];
|
|
560
|
+
props?: RenderProps;
|
|
561
|
+
}
|
|
562
|
+
|
|
351
563
|
declare class CanvasService implements Service {
|
|
352
564
|
canvas: Canvas;
|
|
353
565
|
viewport: ViewportSystem;
|
|
@@ -370,6 +582,97 @@ declare class CanvasService implements Service {
|
|
|
370
582
|
*/
|
|
371
583
|
getObject(id: string, layerId?: string): FabricObject | undefined;
|
|
372
584
|
requestRenderAll(): void;
|
|
585
|
+
resize(width: number, height: number): void;
|
|
586
|
+
applyLayerSpec(spec: RenderLayerSpec): Promise<void>;
|
|
587
|
+
applyObjectSpecsToLayer(layerId: string, objects: RenderObjectSpec[]): Promise<void>;
|
|
588
|
+
getRootLayerObjects(layerId: string): FabricObject[];
|
|
589
|
+
applyObjectSpecsToRootLayer(layerId: string, specs: RenderObjectSpec[]): Promise<void>;
|
|
590
|
+
private applyObjectSpecsToContainer;
|
|
591
|
+
private patchFabricObject;
|
|
592
|
+
private moveObjectInContainer;
|
|
593
|
+
private createFabricObject;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
type SizeConstraintMode = "free" | "lockAspect" | "equal";
|
|
597
|
+
type CutMode = "trim" | "outset" | "inset";
|
|
598
|
+
interface SizeState {
|
|
599
|
+
unit: Unit;
|
|
600
|
+
actualWidthMm: number;
|
|
601
|
+
actualHeightMm: number;
|
|
602
|
+
constraintMode: SizeConstraintMode;
|
|
603
|
+
aspectRatio: number;
|
|
604
|
+
cutMode: CutMode;
|
|
605
|
+
cutMarginMm: number;
|
|
606
|
+
viewPadding: number | string;
|
|
607
|
+
minMm: number;
|
|
608
|
+
maxMm: number;
|
|
609
|
+
stepMm: number;
|
|
610
|
+
}
|
|
611
|
+
interface SceneRect {
|
|
612
|
+
left: number;
|
|
613
|
+
top: number;
|
|
614
|
+
width: number;
|
|
615
|
+
height: number;
|
|
616
|
+
centerX: number;
|
|
617
|
+
centerY: number;
|
|
618
|
+
}
|
|
619
|
+
interface SceneLayoutSnapshot {
|
|
620
|
+
scale: number;
|
|
621
|
+
canvasWidth: number;
|
|
622
|
+
canvasHeight: number;
|
|
623
|
+
trimRect: SceneRect;
|
|
624
|
+
cutRect: SceneRect;
|
|
625
|
+
bleedRect: SceneRect;
|
|
626
|
+
trimWidthMm: number;
|
|
627
|
+
trimHeightMm: number;
|
|
628
|
+
cutWidthMm: number;
|
|
629
|
+
cutHeightMm: number;
|
|
630
|
+
cutMode: CutMode;
|
|
631
|
+
cutMarginMm: number;
|
|
632
|
+
}
|
|
633
|
+
interface SceneGeometrySnapshot {
|
|
634
|
+
shape: "rect" | "circle" | "ellipse" | "custom";
|
|
635
|
+
unit: "mm";
|
|
636
|
+
displayUnit: Unit;
|
|
637
|
+
x: number;
|
|
638
|
+
y: number;
|
|
639
|
+
width: number;
|
|
640
|
+
height: number;
|
|
641
|
+
radius: number;
|
|
642
|
+
offset: number;
|
|
643
|
+
scale: number;
|
|
644
|
+
pathData?: string;
|
|
645
|
+
}
|
|
646
|
+
declare function sanitizeMmValue(valueMm: number, limits: {
|
|
647
|
+
minMm: number;
|
|
648
|
+
maxMm: number;
|
|
649
|
+
stepMm: number;
|
|
650
|
+
}): number;
|
|
651
|
+
declare function normalizeUnit(value: unknown): Unit;
|
|
652
|
+
declare function normalizeConstraintMode(value: unknown): SizeConstraintMode;
|
|
653
|
+
declare function normalizeCutMode(value: unknown): CutMode;
|
|
654
|
+
declare function toMm(value: number, fromUnit: Unit): number;
|
|
655
|
+
declare function fromMm(valueMm: number, toUnit: Unit): number;
|
|
656
|
+
declare function resolvePaddingPx(raw: number | string, containerWidth: number, containerHeight: number): number;
|
|
657
|
+
declare function readSizeState(configService: ConfigurationService): SizeState;
|
|
658
|
+
declare function computeSceneLayout(canvasService: CanvasService, size: SizeState): SceneLayoutSnapshot | null;
|
|
659
|
+
declare function buildSceneGeometry(configService: ConfigurationService, layout: SceneLayoutSnapshot): SceneGeometrySnapshot;
|
|
660
|
+
|
|
661
|
+
declare class SceneVisibilityService implements Extension {
|
|
662
|
+
id: string;
|
|
663
|
+
metadata: {
|
|
664
|
+
name: string;
|
|
665
|
+
};
|
|
666
|
+
private canvasService?;
|
|
667
|
+
private activeToolId;
|
|
668
|
+
activate(context: ExtensionContext): void;
|
|
669
|
+
deactivate(context: ExtensionContext): void;
|
|
670
|
+
private onToolActivated;
|
|
671
|
+
private onObjectAdded;
|
|
672
|
+
private apply;
|
|
373
673
|
}
|
|
374
674
|
|
|
375
|
-
|
|
675
|
+
declare function parseLengthToMm(input: number | string, defaultUnit: Unit): number;
|
|
676
|
+
declare function formatMm(valueMm: number, displayUnit: Unit, fractionDigits?: number): string;
|
|
677
|
+
|
|
678
|
+
export { BackgroundTool, CanvasService, type CutMode, type DielineGeometry, type DielineState, DielineTool, FeatureTool, FilmTool, type ImageItem, ImageTool, type LineStyle, MirrorTool, RulerTool, type SceneGeometrySnapshot, SceneLayoutService, type SceneLayoutSnapshot, type SceneRect, SceneVisibilityService, type SizeConstraintMode, type SizeState, SizeTool, type WhiteInkItem, WhiteInkTool, buildSceneGeometry, computeSceneLayout, formatMm, fromMm, normalizeConstraintMode, normalizeCutMode, normalizeUnit, parseLengthToMm, readSizeState, resolvePaddingPx, sanitizeMmValue, toMm };
|