@pooder/kit 5.3.1 → 6.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/extensions/background.js +475 -131
- package/.test-dist/src/extensions/dieline.js +283 -180
- package/.test-dist/src/extensions/dielineShape.js +66 -0
- package/.test-dist/src/extensions/feature.js +388 -303
- package/.test-dist/src/extensions/film.js +133 -74
- package/.test-dist/src/extensions/geometry.js +120 -56
- package/.test-dist/src/extensions/image.js +296 -212
- package/.test-dist/src/extensions/index.js +1 -3
- package/.test-dist/src/extensions/maskOps.js +75 -20
- package/.test-dist/src/extensions/ruler.js +312 -215
- package/.test-dist/src/extensions/sceneLayoutModel.js +9 -3
- package/.test-dist/src/extensions/sceneVisibility.js +3 -10
- package/.test-dist/src/extensions/tracer.js +229 -58
- package/.test-dist/src/extensions/white-ink.js +139 -129
- package/.test-dist/src/services/CanvasService.js +888 -126
- package/.test-dist/src/services/index.js +1 -0
- package/.test-dist/src/services/visibility.js +54 -0
- package/.test-dist/tests/run.js +58 -4
- package/CHANGELOG.md +12 -0
- package/dist/index.d.mts +377 -82
- package/dist/index.d.ts +377 -82
- package/dist/index.js +3920 -2178
- package/dist/index.mjs +3992 -2247
- package/package.json +1 -1
- package/src/extensions/background.ts +631 -145
- package/src/extensions/dieline.ts +280 -187
- package/src/extensions/dielineShape.ts +109 -0
- package/src/extensions/feature.ts +485 -366
- package/src/extensions/film.ts +152 -76
- package/src/extensions/geometry.ts +203 -104
- package/src/extensions/image.ts +319 -238
- package/src/extensions/index.ts +0 -1
- package/src/extensions/ruler.ts +481 -268
- package/src/extensions/sceneLayoutModel.ts +18 -6
- package/src/extensions/white-ink.ts +157 -171
- package/src/services/CanvasService.ts +1126 -140
- package/src/services/index.ts +1 -0
- package/src/services/renderSpec.ts +69 -4
- package/src/services/visibility.ts +78 -0
- package/tests/run.ts +139 -4
- package/.test-dist/src/CanvasService.js +0 -249
- package/.test-dist/src/ViewportSystem.js +0 -75
- package/.test-dist/src/background.js +0 -203
- package/.test-dist/src/bridgeSelection.js +0 -20
- package/.test-dist/src/constraints.js +0 -237
- package/.test-dist/src/dieline.js +0 -818
- package/.test-dist/src/edgeScale.js +0 -12
- package/.test-dist/src/feature.js +0 -826
- package/.test-dist/src/featureComplete.js +0 -32
- package/.test-dist/src/film.js +0 -167
- package/.test-dist/src/geometry.js +0 -506
- package/.test-dist/src/image.js +0 -1250
- package/.test-dist/src/maskOps.js +0 -270
- package/.test-dist/src/mirror.js +0 -104
- package/.test-dist/src/renderSpec.js +0 -2
- package/.test-dist/src/ruler.js +0 -343
- package/.test-dist/src/sceneLayout.js +0 -99
- package/.test-dist/src/sceneLayoutModel.js +0 -196
- package/.test-dist/src/sceneView.js +0 -40
- package/.test-dist/src/sceneVisibility.js +0 -42
- package/.test-dist/src/size.js +0 -332
- package/.test-dist/src/tracer.js +0 -544
- package/.test-dist/src/white-ink.js +0 -829
- package/.test-dist/src/wrappedOffsets.js +0 -33
- package/src/extensions/sceneVisibility.ts +0 -71
package/dist/index.d.mts
CHANGED
|
@@ -1,26 +1,62 @@
|
|
|
1
|
-
import { Extension, ExtensionContext, ContributionPointIds, ConfigurationContribution, CommandContribution, Service,
|
|
2
|
-
import { Canvas,
|
|
1
|
+
import { Extension, ExtensionContext, ContributionPointIds, ConfigurationContribution, CommandContribution, Service, ServiceContext, EventBus } from '@pooder/core';
|
|
2
|
+
import { Canvas, FabricObject } from 'fabric';
|
|
3
3
|
|
|
4
|
+
type BackgroundLayerKind = "color" | "image";
|
|
5
|
+
type BackgroundFitMode = "cover" | "contain" | "stretch";
|
|
6
|
+
interface BackgroundLayer {
|
|
7
|
+
id: string;
|
|
8
|
+
kind: BackgroundLayerKind;
|
|
9
|
+
anchor: string;
|
|
10
|
+
fit: BackgroundFitMode;
|
|
11
|
+
opacity: number;
|
|
12
|
+
order: number;
|
|
13
|
+
enabled: boolean;
|
|
14
|
+
exportable: boolean;
|
|
15
|
+
color?: string;
|
|
16
|
+
src?: string;
|
|
17
|
+
}
|
|
18
|
+
interface BackgroundConfig {
|
|
19
|
+
version: number;
|
|
20
|
+
layers: BackgroundLayer[];
|
|
21
|
+
}
|
|
4
22
|
declare class BackgroundTool implements Extension {
|
|
5
23
|
id: string;
|
|
6
24
|
metadata: {
|
|
7
25
|
name: string;
|
|
8
26
|
};
|
|
9
|
-
private
|
|
10
|
-
private url;
|
|
27
|
+
private config;
|
|
11
28
|
private canvasService?;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
29
|
+
private configService?;
|
|
30
|
+
private specs;
|
|
31
|
+
private renderProducerDisposable?;
|
|
32
|
+
private configChangeDisposable?;
|
|
33
|
+
private renderSeq;
|
|
34
|
+
private latestSceneLayout;
|
|
35
|
+
private sourceSizeBySrc;
|
|
36
|
+
private pendingSizeBySrc;
|
|
37
|
+
private onCanvasResized;
|
|
38
|
+
private onSceneLayoutChanged;
|
|
39
|
+
constructor(options?: Partial<BackgroundConfig>);
|
|
16
40
|
activate(context: ExtensionContext): void;
|
|
17
41
|
deactivate(context: ExtensionContext): void;
|
|
18
42
|
contribute(): {
|
|
19
43
|
[ContributionPointIds.CONFIGURATIONS]: ConfigurationContribution[];
|
|
20
44
|
[ContributionPointIds.COMMANDS]: CommandContribution[];
|
|
21
45
|
};
|
|
22
|
-
private
|
|
46
|
+
private commitConfig;
|
|
47
|
+
private getViewportRect;
|
|
48
|
+
private resolveSceneLayout;
|
|
49
|
+
private resolveFocusRect;
|
|
50
|
+
private resolveAnchorRect;
|
|
51
|
+
private resolveImagePlacement;
|
|
52
|
+
private buildColorLayerSpec;
|
|
53
|
+
private buildImageLayerSpec;
|
|
54
|
+
private buildBackgroundSpecs;
|
|
55
|
+
private collectActiveImageUrls;
|
|
56
|
+
private ensureImageSize;
|
|
57
|
+
private loadImageSize;
|
|
23
58
|
private updateBackground;
|
|
59
|
+
private updateBackgroundAsync;
|
|
24
60
|
}
|
|
25
61
|
|
|
26
62
|
interface ImageItem {
|
|
@@ -54,6 +90,10 @@ declare class ImageTool implements Extension {
|
|
|
54
90
|
private dirtyTrackerDisposable?;
|
|
55
91
|
private cropShapeHatchPattern?;
|
|
56
92
|
private cropShapeHatchPatternColor?;
|
|
93
|
+
private cropShapeHatchPatternKey?;
|
|
94
|
+
private imageSpecs;
|
|
95
|
+
private overlaySpecs;
|
|
96
|
+
private renderProducerDisposable?;
|
|
57
97
|
activate(context: ExtensionContext): void;
|
|
58
98
|
deactivate(context: ExtensionContext): void;
|
|
59
99
|
private onToolActivated;
|
|
@@ -97,6 +137,8 @@ declare class ImageTool implements Extension {
|
|
|
97
137
|
private getConfig;
|
|
98
138
|
private updateConfig;
|
|
99
139
|
private getFrameRect;
|
|
140
|
+
private getFrameRectScreen;
|
|
141
|
+
private toLayoutSceneRect;
|
|
100
142
|
private resolveDefaultFitArea;
|
|
101
143
|
private fitImageToDefaultArea;
|
|
102
144
|
private getImageObjects;
|
|
@@ -106,6 +148,7 @@ declare class ImageTool implements Extension {
|
|
|
106
148
|
private purgeSourceSizeCacheForItem;
|
|
107
149
|
private rememberSourceSize;
|
|
108
150
|
private getSourceSize;
|
|
151
|
+
private ensureSourceSize;
|
|
109
152
|
private getCoverScale;
|
|
110
153
|
private getFrameVisualConfig;
|
|
111
154
|
private toSceneGeometryLike;
|
|
@@ -115,10 +158,9 @@ declare class ImageTool implements Extension {
|
|
|
115
158
|
private buildCropShapeOverlaySpecs;
|
|
116
159
|
private resolveRenderImageState;
|
|
117
160
|
private computeCanvasProps;
|
|
161
|
+
private toSceneObjectScale;
|
|
118
162
|
private getCurrentSrc;
|
|
119
|
-
private
|
|
120
|
-
private upsertImageObject;
|
|
121
|
-
private syncImageZOrder;
|
|
163
|
+
private buildImageSpecs;
|
|
122
164
|
private buildOverlaySpecs;
|
|
123
165
|
private updateImages;
|
|
124
166
|
private updateImagesAsync;
|
|
@@ -163,21 +205,12 @@ declare class SizeTool implements Extension {
|
|
|
163
205
|
private getSelectedImageSize;
|
|
164
206
|
}
|
|
165
207
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
height: number;
|
|
173
|
-
}
|
|
174
|
-
type Unit = "px" | "mm" | "cm" | "in";
|
|
175
|
-
interface Layout {
|
|
176
|
-
scale: number;
|
|
177
|
-
offsetX: number;
|
|
178
|
-
offsetY: number;
|
|
179
|
-
width: number;
|
|
180
|
-
height: number;
|
|
208
|
+
declare const DIELINE_SHAPES: readonly ["rect", "circle", "ellipse", "heart", "custom"];
|
|
209
|
+
type DielineShape = (typeof DIELINE_SHAPES)[number];
|
|
210
|
+
type ShapeFitMode = "contain" | "stretch";
|
|
211
|
+
interface DielineShapeStyle {
|
|
212
|
+
fitMode: ShapeFitMode;
|
|
213
|
+
[key: string]: unknown;
|
|
181
214
|
}
|
|
182
215
|
|
|
183
216
|
type FeatureOperation = "add" | "subtract";
|
|
@@ -203,9 +236,9 @@ interface DielineFeature {
|
|
|
203
236
|
}
|
|
204
237
|
|
|
205
238
|
interface DielineGeometry {
|
|
206
|
-
shape:
|
|
207
|
-
|
|
208
|
-
|
|
239
|
+
shape: DielineShape;
|
|
240
|
+
shapeStyle: DielineShapeStyle;
|
|
241
|
+
unit: "px";
|
|
209
242
|
x: number;
|
|
210
243
|
y: number;
|
|
211
244
|
width: number;
|
|
@@ -226,8 +259,8 @@ interface LineStyle {
|
|
|
226
259
|
style: "solid" | "dashed" | "hidden";
|
|
227
260
|
}
|
|
228
261
|
interface DielineState {
|
|
229
|
-
|
|
230
|
-
|
|
262
|
+
shape: DielineShape;
|
|
263
|
+
shapeStyle: DielineShapeStyle;
|
|
231
264
|
width: number;
|
|
232
265
|
height: number;
|
|
233
266
|
radius: number;
|
|
@@ -236,7 +269,6 @@ interface DielineState {
|
|
|
236
269
|
mainLine: LineStyle;
|
|
237
270
|
offsetLine: LineStyle;
|
|
238
271
|
insideColor: string;
|
|
239
|
-
outsideColor: string;
|
|
240
272
|
showBleedLines: boolean;
|
|
241
273
|
features: DielineFeature[];
|
|
242
274
|
pathData?: string;
|
|
@@ -251,6 +283,10 @@ declare class DielineTool implements Extension {
|
|
|
251
283
|
private state;
|
|
252
284
|
private canvasService?;
|
|
253
285
|
private context?;
|
|
286
|
+
private specs;
|
|
287
|
+
private effects;
|
|
288
|
+
private renderSeq;
|
|
289
|
+
private renderProducerDisposable?;
|
|
254
290
|
private onCanvasResized;
|
|
255
291
|
constructor(options?: Partial<DielineState>);
|
|
256
292
|
activate(context: ExtensionContext): void;
|
|
@@ -268,14 +304,14 @@ declare class DielineTool implements Extension {
|
|
|
268
304
|
[ContributionPointIds.CONFIGURATIONS]: ConfigurationContribution[];
|
|
269
305
|
[ContributionPointIds.COMMANDS]: CommandContribution[];
|
|
270
306
|
};
|
|
271
|
-
private getLayer;
|
|
272
|
-
private createLayer;
|
|
273
|
-
private destroyLayer;
|
|
274
307
|
private createHatchPattern;
|
|
275
308
|
private getConfigService;
|
|
309
|
+
private hasImageItems;
|
|
276
310
|
private syncSizeState;
|
|
277
|
-
private
|
|
311
|
+
private buildDielineSpecs;
|
|
312
|
+
private buildImageClipEffects;
|
|
278
313
|
updateDieline(_emitEvent?: boolean): void;
|
|
314
|
+
private updateDielineAsync;
|
|
279
315
|
getGeometry(): DielineGeometry | null;
|
|
280
316
|
exportCutImage(options?: {
|
|
281
317
|
debug?: boolean;
|
|
@@ -304,6 +340,9 @@ declare class FeatureTool implements Extension {
|
|
|
304
340
|
private sessionOriginalFeatures;
|
|
305
341
|
private hasWorkingChanges;
|
|
306
342
|
private dirtyTrackerDisposable?;
|
|
343
|
+
private renderProducerDisposable?;
|
|
344
|
+
private specs;
|
|
345
|
+
private renderSeq;
|
|
307
346
|
private handleMoving;
|
|
308
347
|
private handleModified;
|
|
309
348
|
private handleSceneGeometryChange;
|
|
@@ -349,9 +388,24 @@ declare class FeatureTool implements Extension {
|
|
|
349
388
|
private getGeometryForFeature;
|
|
350
389
|
private setup;
|
|
351
390
|
private teardown;
|
|
391
|
+
private getDraggableMarkerTarget;
|
|
392
|
+
private getFeatureForMarker;
|
|
352
393
|
private constrainPosition;
|
|
394
|
+
private toNormalizedPoint;
|
|
353
395
|
private syncFeatureFromCanvas;
|
|
396
|
+
private syncGroupFromCanvas;
|
|
354
397
|
private redraw;
|
|
398
|
+
private redrawAsync;
|
|
399
|
+
private buildFeatureSpecs;
|
|
400
|
+
private appendMarkerSpecs;
|
|
401
|
+
private buildMarkerData;
|
|
402
|
+
private markerId;
|
|
403
|
+
private bridgeIndicatorId;
|
|
404
|
+
private toFeatureIndex;
|
|
405
|
+
private readGroupIndices;
|
|
406
|
+
private readGroupMemberOffsets;
|
|
407
|
+
private syncMarkerVisualsByTarget;
|
|
408
|
+
private syncMarkerVisualObjectsToCenter;
|
|
355
409
|
private enforceConstraints;
|
|
356
410
|
}
|
|
357
411
|
|
|
@@ -363,6 +417,13 @@ declare class FilmTool implements Extension {
|
|
|
363
417
|
private url;
|
|
364
418
|
private opacity;
|
|
365
419
|
private canvasService?;
|
|
420
|
+
private specs;
|
|
421
|
+
private renderProducerDisposable?;
|
|
422
|
+
private renderSeq;
|
|
423
|
+
private renderImageUrl;
|
|
424
|
+
private sourceSizeBySrc;
|
|
425
|
+
private pendingSizeBySrc;
|
|
426
|
+
private onCanvasResized;
|
|
366
427
|
constructor(options?: Partial<{
|
|
367
428
|
url: string;
|
|
368
429
|
opacity: number;
|
|
@@ -373,8 +434,13 @@ declare class FilmTool implements Extension {
|
|
|
373
434
|
[ContributionPointIds.CONFIGURATIONS]: ConfigurationContribution[];
|
|
374
435
|
[ContributionPointIds.COMMANDS]: CommandContribution[];
|
|
375
436
|
};
|
|
376
|
-
private
|
|
437
|
+
private getViewportSize;
|
|
438
|
+
private clampOpacity;
|
|
439
|
+
private buildFilmSpecs;
|
|
440
|
+
private ensureImageSize;
|
|
441
|
+
private loadImageSize;
|
|
377
442
|
private updateFilm;
|
|
443
|
+
private updateFilmAsync;
|
|
378
444
|
}
|
|
379
445
|
|
|
380
446
|
declare class MirrorTool implements Extension {
|
|
@@ -411,6 +477,10 @@ declare class RulerTool implements Extension {
|
|
|
411
477
|
private textColor;
|
|
412
478
|
private lineColor;
|
|
413
479
|
private fontSize;
|
|
480
|
+
private renderSeq;
|
|
481
|
+
private readonly numericProps;
|
|
482
|
+
private specs;
|
|
483
|
+
private renderProducerDisposable?;
|
|
414
484
|
private canvasService?;
|
|
415
485
|
private context?;
|
|
416
486
|
private onCanvasResized;
|
|
@@ -420,6 +490,7 @@ declare class RulerTool implements Extension {
|
|
|
420
490
|
textColor: string;
|
|
421
491
|
lineColor: string;
|
|
422
492
|
fontSize: number;
|
|
493
|
+
gap: number;
|
|
423
494
|
}>);
|
|
424
495
|
activate(context: ExtensionContext): void;
|
|
425
496
|
deactivate(context: ExtensionContext): void;
|
|
@@ -427,11 +498,19 @@ declare class RulerTool implements Extension {
|
|
|
427
498
|
[ContributionPointIds.CONFIGURATIONS]: ConfigurationContribution[];
|
|
428
499
|
[ContributionPointIds.COMMANDS]: CommandContribution[];
|
|
429
500
|
};
|
|
430
|
-
private
|
|
431
|
-
private
|
|
432
|
-
private
|
|
433
|
-
private
|
|
501
|
+
private log;
|
|
502
|
+
private syncConfig;
|
|
503
|
+
private toFiniteNumber;
|
|
504
|
+
private toSceneDisplayLength;
|
|
505
|
+
private formatLengthMm;
|
|
506
|
+
private buildLinePath;
|
|
507
|
+
private buildStartArrowPath;
|
|
508
|
+
private buildEndArrowPath;
|
|
509
|
+
private createPathSpec;
|
|
510
|
+
private createTextSpec;
|
|
511
|
+
private buildRulerSpecs;
|
|
434
512
|
private updateRuler;
|
|
513
|
+
private updateRulerAsync;
|
|
435
514
|
}
|
|
436
515
|
|
|
437
516
|
interface WhiteInkItem {
|
|
@@ -459,6 +538,10 @@ declare class WhiteInkTool implements Extension {
|
|
|
459
538
|
private previewImageVisible;
|
|
460
539
|
private renderSeq;
|
|
461
540
|
private dirtyTrackerDisposable?;
|
|
541
|
+
private whiteSpecs;
|
|
542
|
+
private coverSpecs;
|
|
543
|
+
private overlaySpecs;
|
|
544
|
+
private renderProducerDisposable?;
|
|
462
545
|
activate(context: ExtensionContext): void;
|
|
463
546
|
deactivate(context: ExtensionContext): void;
|
|
464
547
|
contribute(): {
|
|
@@ -509,6 +592,7 @@ declare class WhiteInkTool implements Extension {
|
|
|
509
592
|
private clearWhiteInks;
|
|
510
593
|
private completeWhiteInks;
|
|
511
594
|
private getFrameRect;
|
|
595
|
+
private toLayoutSceneRect;
|
|
512
596
|
private getImageObjects;
|
|
513
597
|
private getPrimaryImageObject;
|
|
514
598
|
private getPrimaryImageSource;
|
|
@@ -526,11 +610,8 @@ declare class WhiteInkTool implements Extension {
|
|
|
526
610
|
private computeCoverOpacity;
|
|
527
611
|
private buildCloneImageSpec;
|
|
528
612
|
private buildFrameSpecs;
|
|
529
|
-
private applyImageVisibilityForWhiteInk;
|
|
530
613
|
private resolveRenderItems;
|
|
531
614
|
private resolveRenderSources;
|
|
532
|
-
private resolveDefaultInsertIndex;
|
|
533
|
-
private syncZOrder;
|
|
534
615
|
private clearRenderedWhiteInks;
|
|
535
616
|
private purgeSourceCaches;
|
|
536
617
|
private updateWhiteInks;
|
|
@@ -542,6 +623,22 @@ declare class WhiteInkTool implements Extension {
|
|
|
542
623
|
private loadImageElement;
|
|
543
624
|
}
|
|
544
625
|
|
|
626
|
+
interface Point {
|
|
627
|
+
x: number;
|
|
628
|
+
y: number;
|
|
629
|
+
}
|
|
630
|
+
interface Size {
|
|
631
|
+
width: number;
|
|
632
|
+
height: number;
|
|
633
|
+
}
|
|
634
|
+
interface Layout {
|
|
635
|
+
scale: number;
|
|
636
|
+
offsetX: number;
|
|
637
|
+
offsetY: number;
|
|
638
|
+
width: number;
|
|
639
|
+
height: number;
|
|
640
|
+
}
|
|
641
|
+
|
|
545
642
|
declare class ViewportSystem {
|
|
546
643
|
private _containerSize;
|
|
547
644
|
private _physicalSize;
|
|
@@ -561,54 +658,263 @@ declare class ViewportSystem {
|
|
|
561
658
|
toPhysicalPoint(point: Point): Point;
|
|
562
659
|
}
|
|
563
660
|
|
|
564
|
-
type RenderObjectType = "rect" | "image" | "path";
|
|
661
|
+
type RenderObjectType = "rect" | "image" | "path" | "text";
|
|
565
662
|
type RenderProps = Record<string, any>;
|
|
663
|
+
type RenderCoordinateSpace = "scene" | "screen";
|
|
664
|
+
type RenderLayoutLength = number | string;
|
|
665
|
+
type RenderLayoutAlign = "start" | "center" | "end";
|
|
666
|
+
type RenderLayoutReference = "sceneViewport" | "screenViewport" | "custom";
|
|
667
|
+
interface RenderLayoutInsets {
|
|
668
|
+
top?: RenderLayoutLength;
|
|
669
|
+
right?: RenderLayoutLength;
|
|
670
|
+
bottom?: RenderLayoutLength;
|
|
671
|
+
left?: RenderLayoutLength;
|
|
672
|
+
}
|
|
673
|
+
interface RenderLayoutRect {
|
|
674
|
+
left: number;
|
|
675
|
+
top: number;
|
|
676
|
+
width: number;
|
|
677
|
+
height: number;
|
|
678
|
+
space?: RenderCoordinateSpace;
|
|
679
|
+
}
|
|
680
|
+
interface RenderObjectLayoutSpec {
|
|
681
|
+
reference?: RenderLayoutReference;
|
|
682
|
+
referenceRect?: RenderLayoutRect;
|
|
683
|
+
inset?: RenderLayoutLength | RenderLayoutInsets;
|
|
684
|
+
alignX?: RenderLayoutAlign;
|
|
685
|
+
alignY?: RenderLayoutAlign;
|
|
686
|
+
offsetX?: RenderLayoutLength;
|
|
687
|
+
offsetY?: RenderLayoutLength;
|
|
688
|
+
width?: RenderLayoutLength;
|
|
689
|
+
height?: RenderLayoutLength;
|
|
690
|
+
}
|
|
566
691
|
interface RenderObjectSpec {
|
|
567
692
|
id: string;
|
|
568
693
|
type: RenderObjectType;
|
|
569
694
|
props: RenderProps;
|
|
570
695
|
data?: Record<string, any>;
|
|
571
696
|
src?: string;
|
|
697
|
+
space?: RenderCoordinateSpace;
|
|
698
|
+
layout?: RenderObjectLayoutSpec;
|
|
572
699
|
}
|
|
573
|
-
|
|
700
|
+
type LayerObjectCountComparator = ">" | ">=" | "==" | "<" | "<=";
|
|
701
|
+
type VisibilityExpr = {
|
|
702
|
+
op: "const";
|
|
703
|
+
value: boolean;
|
|
704
|
+
} | {
|
|
705
|
+
op: "activeToolIn";
|
|
706
|
+
ids: string[];
|
|
707
|
+
} | {
|
|
708
|
+
op: "sessionActive";
|
|
709
|
+
toolId: string;
|
|
710
|
+
} | {
|
|
711
|
+
op: "layerExists";
|
|
712
|
+
layerId: string;
|
|
713
|
+
} | {
|
|
714
|
+
op: "layerObjectCount";
|
|
715
|
+
layerId: string;
|
|
716
|
+
cmp: LayerObjectCountComparator;
|
|
717
|
+
value: number;
|
|
718
|
+
} | {
|
|
719
|
+
op: "not";
|
|
720
|
+
expr: VisibilityExpr;
|
|
721
|
+
} | {
|
|
722
|
+
op: "all";
|
|
723
|
+
exprs: VisibilityExpr[];
|
|
724
|
+
} | {
|
|
725
|
+
op: "any";
|
|
726
|
+
exprs: VisibilityExpr[];
|
|
727
|
+
};
|
|
728
|
+
interface RenderClipPathEffectSpec {
|
|
729
|
+
type: "clipPath";
|
|
730
|
+
id?: string;
|
|
731
|
+
source: RenderObjectSpec;
|
|
732
|
+
targetPassIds: string[];
|
|
733
|
+
}
|
|
734
|
+
type RenderEffectSpec = RenderClipPathEffectSpec;
|
|
735
|
+
interface RenderPassSpec {
|
|
574
736
|
id: string;
|
|
737
|
+
stack?: number;
|
|
738
|
+
order?: number;
|
|
739
|
+
replace?: boolean;
|
|
740
|
+
visibility?: VisibilityExpr;
|
|
741
|
+
effects?: RenderEffectSpec[];
|
|
575
742
|
objects: RenderObjectSpec[];
|
|
576
|
-
props?: RenderProps;
|
|
577
743
|
}
|
|
578
744
|
|
|
745
|
+
interface RenderProducerResult {
|
|
746
|
+
passes?: RenderPassSpec[];
|
|
747
|
+
}
|
|
748
|
+
type RenderProducer = () => RenderProducerResult | undefined | Promise<RenderProducerResult | undefined>;
|
|
749
|
+
interface RegisterRenderProducerOptions {
|
|
750
|
+
priority?: number;
|
|
751
|
+
}
|
|
752
|
+
interface RectLike {
|
|
753
|
+
left: number;
|
|
754
|
+
top: number;
|
|
755
|
+
width: number;
|
|
756
|
+
height: number;
|
|
757
|
+
}
|
|
579
758
|
declare class CanvasService implements Service {
|
|
580
759
|
canvas: Canvas;
|
|
581
760
|
viewport: ViewportSystem;
|
|
761
|
+
private context?;
|
|
582
762
|
private eventBus?;
|
|
763
|
+
private workbenchService?;
|
|
764
|
+
private toolSessionService?;
|
|
765
|
+
private renderProducers;
|
|
766
|
+
private producerOrder;
|
|
767
|
+
private producerFlushRequested;
|
|
768
|
+
private producerLoopPending;
|
|
769
|
+
private producerLoopPromise;
|
|
770
|
+
private producerApplyInProgress;
|
|
771
|
+
private visibilityRefreshScheduled;
|
|
772
|
+
private managedProducerPassIds;
|
|
773
|
+
private managedPassMetas;
|
|
774
|
+
private canvasForwardersBound;
|
|
775
|
+
private readonly forwardSelectionCreated;
|
|
776
|
+
private readonly forwardSelectionUpdated;
|
|
777
|
+
private readonly forwardSelectionCleared;
|
|
778
|
+
private readonly forwardObjectModified;
|
|
779
|
+
private readonly forwardObjectAdded;
|
|
780
|
+
private readonly forwardObjectRemoved;
|
|
781
|
+
private readonly onToolActivated;
|
|
782
|
+
private readonly onToolSessionChanged;
|
|
783
|
+
private readonly onCanvasObjectChanged;
|
|
583
784
|
constructor(el: HTMLCanvasElement | string | Canvas, options?: any);
|
|
785
|
+
init(context: ServiceContext): void;
|
|
786
|
+
private attachContextEvents;
|
|
787
|
+
private detachContextEvents;
|
|
584
788
|
setEventBus(eventBus: EventBus): void;
|
|
585
789
|
private setupEvents;
|
|
586
790
|
dispose(): void;
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
791
|
+
registerRenderProducer(toolId: string, producer: RenderProducer, options?: RegisterRenderProducerOptions): {
|
|
792
|
+
dispose: () => void;
|
|
793
|
+
};
|
|
794
|
+
unregisterRenderProducer(toolId: string): boolean;
|
|
795
|
+
requestRenderFromProducers(): void;
|
|
796
|
+
flushRenderFromProducers(): Promise<void>;
|
|
797
|
+
private scheduleProducerLoop;
|
|
798
|
+
private runProducerLoop;
|
|
799
|
+
private sortedRenderProducerEntries;
|
|
800
|
+
private normalizePassSpecValue;
|
|
801
|
+
private normalizeClipPathEffectSpec;
|
|
802
|
+
private mergePassSpec;
|
|
803
|
+
private comparePassMeta;
|
|
804
|
+
private getPassObjectOrder;
|
|
805
|
+
private getPassCanvasObjects;
|
|
806
|
+
getPassObjects(passId: string): FabricObject[];
|
|
807
|
+
getRootLayerObjects(layerId: string): FabricObject[];
|
|
808
|
+
private isManagedPassObject;
|
|
809
|
+
private syncManagedPassStacking;
|
|
810
|
+
private getPassRuntimeState;
|
|
811
|
+
private applyManagedPassVisibility;
|
|
812
|
+
private scheduleManagedPassVisibilityRefresh;
|
|
813
|
+
private collectAndApplyProducerSpecs;
|
|
814
|
+
private applyManagedPassEffects;
|
|
815
|
+
getObject(id: string, passId?: string): FabricObject | undefined;
|
|
600
816
|
requestRenderAll(): void;
|
|
601
817
|
resize(width: number, height: number): void;
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
818
|
+
getSceneScale(): number;
|
|
819
|
+
getSceneOffset(): {
|
|
820
|
+
x: number;
|
|
821
|
+
y: number;
|
|
822
|
+
};
|
|
823
|
+
toScreenPoint(point: {
|
|
824
|
+
x: number;
|
|
825
|
+
y: number;
|
|
826
|
+
}): {
|
|
827
|
+
x: number;
|
|
828
|
+
y: number;
|
|
829
|
+
};
|
|
830
|
+
toScenePoint(point: {
|
|
831
|
+
x: number;
|
|
832
|
+
y: number;
|
|
833
|
+
}): {
|
|
834
|
+
x: number;
|
|
835
|
+
y: number;
|
|
836
|
+
};
|
|
837
|
+
toScreenLength(value: number): number;
|
|
838
|
+
toSceneLength(value: number): number;
|
|
839
|
+
toScreenRect(rect: {
|
|
840
|
+
left: number;
|
|
841
|
+
top: number;
|
|
842
|
+
width: number;
|
|
843
|
+
height: number;
|
|
844
|
+
}): {
|
|
845
|
+
left: number;
|
|
846
|
+
top: number;
|
|
847
|
+
width: number;
|
|
848
|
+
height: number;
|
|
849
|
+
};
|
|
850
|
+
toSceneRect(rect: {
|
|
851
|
+
left: number;
|
|
852
|
+
top: number;
|
|
853
|
+
width: number;
|
|
854
|
+
height: number;
|
|
855
|
+
}): {
|
|
856
|
+
left: number;
|
|
857
|
+
top: number;
|
|
858
|
+
width: number;
|
|
859
|
+
height: number;
|
|
860
|
+
};
|
|
861
|
+
getSceneViewportRect(): {
|
|
862
|
+
left: number;
|
|
863
|
+
top: number;
|
|
864
|
+
width: number;
|
|
865
|
+
height: number;
|
|
866
|
+
};
|
|
867
|
+
getScreenViewportRect(): RectLike;
|
|
868
|
+
private toSpaceRect;
|
|
869
|
+
private resolveLayoutLength;
|
|
870
|
+
private resolveLayoutInsets;
|
|
871
|
+
private resolveLayoutReferenceRect;
|
|
872
|
+
private alignFactor;
|
|
873
|
+
private normalizeOriginX;
|
|
874
|
+
private normalizeOriginY;
|
|
875
|
+
private originFactor;
|
|
876
|
+
private resolveLayoutProps;
|
|
877
|
+
setPassVisibility(passId: string, visible: boolean): boolean;
|
|
878
|
+
setLayerVisibility(layerId: string, visible: boolean): boolean;
|
|
879
|
+
bringPassToFront(passId: string): void;
|
|
880
|
+
bringLayerToFront(layerId: string): void;
|
|
881
|
+
applyPassSpec(spec: RenderPassSpec, options?: {
|
|
882
|
+
render?: boolean;
|
|
883
|
+
}): Promise<void>;
|
|
884
|
+
applyObjectSpecsToRootLayer(passId: string, specs: RenderObjectSpec[], options?: {
|
|
885
|
+
render?: boolean;
|
|
886
|
+
}): Promise<void>;
|
|
887
|
+
private normalizeObjectSpecs;
|
|
888
|
+
private cloneFabricObject;
|
|
889
|
+
private createClipPathTemplate;
|
|
890
|
+
private isClipPathEffectManaged;
|
|
891
|
+
private clearClipPathEffectFromObject;
|
|
892
|
+
private applyClipPathEffectToObject;
|
|
893
|
+
applyObjectSpecsToPass(passId: string, specs: RenderObjectSpec[], options?: {
|
|
894
|
+
render?: boolean;
|
|
895
|
+
replace?: boolean;
|
|
896
|
+
}): Promise<void>;
|
|
607
897
|
private patchFabricObject;
|
|
608
|
-
private
|
|
898
|
+
private readPathDataFromSpec;
|
|
899
|
+
private hashText;
|
|
900
|
+
private getSpecRenderSourceKey;
|
|
901
|
+
private shouldRecreateObject;
|
|
902
|
+
private resolveFabricProps;
|
|
903
|
+
private moveObjectInCanvas;
|
|
609
904
|
private createFabricObject;
|
|
610
905
|
}
|
|
611
906
|
|
|
907
|
+
interface VisibilityLayerState {
|
|
908
|
+
exists: boolean;
|
|
909
|
+
objectCount: number;
|
|
910
|
+
}
|
|
911
|
+
interface VisibilityEvalContext {
|
|
912
|
+
activeToolId?: string | null;
|
|
913
|
+
isSessionActive?: (toolId: string) => boolean;
|
|
914
|
+
layers: Map<string, VisibilityLayerState>;
|
|
915
|
+
}
|
|
916
|
+
declare function evaluateVisibilityExpr(expr: VisibilityExpr | undefined, context: VisibilityEvalContext): boolean;
|
|
917
|
+
|
|
612
918
|
type CutMode = "trim" | "outset" | "inset";
|
|
613
919
|
interface SceneRect {
|
|
614
920
|
left: number;
|
|
@@ -633,9 +939,9 @@ interface SceneLayoutSnapshot {
|
|
|
633
939
|
cutMarginMm: number;
|
|
634
940
|
}
|
|
635
941
|
interface SceneGeometrySnapshot {
|
|
636
|
-
shape:
|
|
637
|
-
|
|
638
|
-
|
|
942
|
+
shape: DielineShape;
|
|
943
|
+
shapeStyle: DielineShapeStyle;
|
|
944
|
+
unit: "px";
|
|
639
945
|
x: number;
|
|
640
946
|
y: number;
|
|
641
947
|
width: number;
|
|
@@ -665,15 +971,4 @@ declare class SceneLayoutService implements Service {
|
|
|
665
971
|
getGeometry(forceRefresh?: boolean): SceneGeometrySnapshot | null;
|
|
666
972
|
}
|
|
667
973
|
|
|
668
|
-
|
|
669
|
-
private context?;
|
|
670
|
-
private activeToolId;
|
|
671
|
-
private canvasService?;
|
|
672
|
-
init(context: ServiceContext): void;
|
|
673
|
-
dispose(context: ServiceContext): void;
|
|
674
|
-
private onToolActivated;
|
|
675
|
-
private onObjectAdded;
|
|
676
|
-
private apply;
|
|
677
|
-
}
|
|
678
|
-
|
|
679
|
-
export { BackgroundTool, CanvasService, type DielineGeometry, type DielineState, DielineTool, FeatureTool, FilmTool, type ImageItem, ImageTool, type LineStyle, MirrorTool, type RenderLayerSpec, type RenderObjectSpec, type RenderObjectType, type RenderProps, RulerTool, SceneLayoutService, SceneVisibilityService, SizeTool, ViewportSystem, type WhiteInkItem, WhiteInkTool };
|
|
974
|
+
export { type BackgroundConfig, type BackgroundFitMode, type BackgroundLayer, type BackgroundLayerKind, BackgroundTool, CanvasService, type DielineGeometry, type DielineState, DielineTool, FeatureTool, FilmTool, type ImageItem, ImageTool, 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, evaluateVisibilityExpr };
|