@pooder/kit 5.4.0 → 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/coordinate.js +74 -0
- package/.test-dist/src/extensions/background.js +547 -0
- package/.test-dist/src/extensions/bridgeSelection.js +20 -0
- package/.test-dist/src/extensions/constraints.js +237 -0
- package/.test-dist/src/extensions/dieline.js +931 -0
- package/.test-dist/src/extensions/dielineShape.js +66 -0
- package/.test-dist/src/extensions/edgeScale.js +12 -0
- package/.test-dist/src/extensions/feature.js +910 -0
- package/.test-dist/src/extensions/featureComplete.js +32 -0
- package/.test-dist/src/extensions/film.js +226 -0
- package/.test-dist/src/extensions/geometry.js +609 -0
- package/.test-dist/src/extensions/image.js +1613 -0
- package/.test-dist/src/extensions/index.js +28 -0
- package/.test-dist/src/extensions/maskOps.js +334 -0
- package/.test-dist/src/extensions/mirror.js +104 -0
- package/.test-dist/src/extensions/ruler.js +442 -0
- package/.test-dist/src/extensions/sceneLayout.js +96 -0
- package/.test-dist/src/extensions/sceneLayoutModel.js +202 -0
- package/.test-dist/src/extensions/sceneVisibility.js +55 -0
- package/.test-dist/src/extensions/size.js +331 -0
- package/.test-dist/src/extensions/tracer.js +709 -0
- package/.test-dist/src/extensions/white-ink.js +1200 -0
- package/.test-dist/src/extensions/wrappedOffsets.js +33 -0
- package/.test-dist/src/index.js +18 -0
- package/.test-dist/src/services/CanvasService.js +1011 -0
- package/.test-dist/src/services/ViewportSystem.js +76 -0
- package/.test-dist/src/services/index.js +25 -0
- package/.test-dist/src/services/renderSpec.js +2 -0
- package/.test-dist/src/services/visibility.js +54 -0
- package/.test-dist/src/units.js +30 -0
- package/.test-dist/tests/run.js +148 -0
- package/CHANGELOG.md +6 -0
- package/dist/index.d.mts +150 -62
- package/dist/index.d.ts +150 -62
- package/dist/index.js +2219 -1714
- package/dist/index.mjs +2226 -1718
- package/package.json +1 -1
- package/src/coordinate.ts +106 -106
- package/src/extensions/background.ts +716 -323
- package/src/extensions/bridgeSelection.ts +17 -17
- package/src/extensions/constraints.ts +322 -322
- package/src/extensions/dieline.ts +1169 -1149
- package/src/extensions/dielineShape.ts +109 -109
- package/src/extensions/edgeScale.ts +19 -19
- package/src/extensions/feature.ts +1140 -1137
- package/src/extensions/featureComplete.ts +46 -46
- package/src/extensions/film.ts +270 -266
- package/src/extensions/geometry.ts +851 -885
- package/src/extensions/image.ts +2007 -2054
- package/src/extensions/index.ts +10 -11
- package/src/extensions/maskOps.ts +283 -283
- package/src/extensions/mirror.ts +128 -128
- package/src/extensions/ruler.ts +664 -654
- package/src/extensions/sceneLayout.ts +140 -140
- package/src/extensions/sceneLayoutModel.ts +364 -364
- package/src/extensions/size.ts +389 -389
- package/src/extensions/tracer.ts +1019 -1019
- package/src/extensions/white-ink.ts +1508 -1575
- package/src/extensions/wrappedOffsets.ts +33 -33
- package/src/index.ts +2 -2
- package/src/services/CanvasService.ts +1286 -832
- package/src/services/ViewportSystem.ts +95 -95
- package/src/services/index.ts +4 -3
- package/src/services/renderSpec.ts +83 -53
- package/src/services/visibility.ts +78 -0
- package/src/units.ts +27 -27
- package/tests/run.ts +253 -118
- package/tsconfig.test.json +15 -15
- package/src/extensions/sceneVisibility.ts +0 -64
package/dist/index.d.mts
CHANGED
|
@@ -1,33 +1,58 @@
|
|
|
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?;
|
|
29
|
+
private configService?;
|
|
12
30
|
private specs;
|
|
13
31
|
private renderProducerDisposable?;
|
|
32
|
+
private configChangeDisposable?;
|
|
14
33
|
private renderSeq;
|
|
15
|
-
private
|
|
34
|
+
private latestSceneLayout;
|
|
16
35
|
private sourceSizeBySrc;
|
|
17
36
|
private pendingSizeBySrc;
|
|
18
37
|
private onCanvasResized;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
url: string;
|
|
22
|
-
}>);
|
|
38
|
+
private onSceneLayoutChanged;
|
|
39
|
+
constructor(options?: Partial<BackgroundConfig>);
|
|
23
40
|
activate(context: ExtensionContext): void;
|
|
24
41
|
deactivate(context: ExtensionContext): void;
|
|
25
42
|
contribute(): {
|
|
26
43
|
[ContributionPointIds.CONFIGURATIONS]: ConfigurationContribution[];
|
|
27
44
|
[ContributionPointIds.COMMANDS]: CommandContribution[];
|
|
28
45
|
};
|
|
29
|
-
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;
|
|
30
54
|
private buildBackgroundSpecs;
|
|
55
|
+
private collectActiveImageUrls;
|
|
31
56
|
private ensureImageSize;
|
|
32
57
|
private loadImageSize;
|
|
33
58
|
private updateBackground;
|
|
@@ -66,6 +91,7 @@ declare class ImageTool implements Extension {
|
|
|
66
91
|
private cropShapeHatchPattern?;
|
|
67
92
|
private cropShapeHatchPatternColor?;
|
|
68
93
|
private cropShapeHatchPatternKey?;
|
|
94
|
+
private imageSpecs;
|
|
69
95
|
private overlaySpecs;
|
|
70
96
|
private renderProducerDisposable?;
|
|
71
97
|
activate(context: ExtensionContext): void;
|
|
@@ -122,6 +148,7 @@ declare class ImageTool implements Extension {
|
|
|
122
148
|
private purgeSourceSizeCacheForItem;
|
|
123
149
|
private rememberSourceSize;
|
|
124
150
|
private getSourceSize;
|
|
151
|
+
private ensureSourceSize;
|
|
125
152
|
private getCoverScale;
|
|
126
153
|
private getFrameVisualConfig;
|
|
127
154
|
private toSceneGeometryLike;
|
|
@@ -131,12 +158,9 @@ declare class ImageTool implements Extension {
|
|
|
131
158
|
private buildCropShapeOverlaySpecs;
|
|
132
159
|
private resolveRenderImageState;
|
|
133
160
|
private computeCanvasProps;
|
|
134
|
-
private toScreenObjectProps;
|
|
135
161
|
private toSceneObjectScale;
|
|
136
162
|
private getCurrentSrc;
|
|
137
|
-
private
|
|
138
|
-
private upsertImageObject;
|
|
139
|
-
private syncImageZOrder;
|
|
163
|
+
private buildImageSpecs;
|
|
140
164
|
private buildOverlaySpecs;
|
|
141
165
|
private updateImages;
|
|
142
166
|
private updateImagesAsync;
|
|
@@ -245,7 +269,6 @@ interface DielineState {
|
|
|
245
269
|
mainLine: LineStyle;
|
|
246
270
|
offsetLine: LineStyle;
|
|
247
271
|
insideColor: string;
|
|
248
|
-
outsideColor: string;
|
|
249
272
|
showBleedLines: boolean;
|
|
250
273
|
features: DielineFeature[];
|
|
251
274
|
pathData?: string;
|
|
@@ -261,6 +284,7 @@ declare class DielineTool implements Extension {
|
|
|
261
284
|
private canvasService?;
|
|
262
285
|
private context?;
|
|
263
286
|
private specs;
|
|
287
|
+
private effects;
|
|
264
288
|
private renderSeq;
|
|
265
289
|
private renderProducerDisposable?;
|
|
266
290
|
private onCanvasResized;
|
|
@@ -282,10 +306,10 @@ declare class DielineTool implements Extension {
|
|
|
282
306
|
};
|
|
283
307
|
private createHatchPattern;
|
|
284
308
|
private getConfigService;
|
|
309
|
+
private hasImageItems;
|
|
285
310
|
private syncSizeState;
|
|
286
|
-
private bringFeatureMarkersToFront;
|
|
287
|
-
private ensureLayerStacking;
|
|
288
311
|
private buildDielineSpecs;
|
|
312
|
+
private buildImageClipEffects;
|
|
289
313
|
updateDieline(_emitEvent?: boolean): void;
|
|
290
314
|
private updateDielineAsync;
|
|
291
315
|
getGeometry(): DielineGeometry | null;
|
|
@@ -372,7 +396,6 @@ declare class FeatureTool implements Extension {
|
|
|
372
396
|
private syncGroupFromCanvas;
|
|
373
397
|
private redraw;
|
|
374
398
|
private redrawAsync;
|
|
375
|
-
private syncOverlayOrder;
|
|
376
399
|
private buildFeatureSpecs;
|
|
377
400
|
private appendMarkerSpecs;
|
|
378
401
|
private buildMarkerData;
|
|
@@ -587,11 +610,8 @@ declare class WhiteInkTool implements Extension {
|
|
|
587
610
|
private computeCoverOpacity;
|
|
588
611
|
private buildCloneImageSpec;
|
|
589
612
|
private buildFrameSpecs;
|
|
590
|
-
private applyImageVisibilityForWhiteInk;
|
|
591
613
|
private resolveRenderItems;
|
|
592
614
|
private resolveRenderSources;
|
|
593
|
-
private resolveDefaultInsertIndex;
|
|
594
|
-
private syncZOrder;
|
|
595
615
|
private clearRenderedWhiteInks;
|
|
596
616
|
private purgeSourceCaches;
|
|
597
617
|
private updateWhiteInks;
|
|
@@ -677,17 +697,53 @@ interface RenderObjectSpec {
|
|
|
677
697
|
space?: RenderCoordinateSpace;
|
|
678
698
|
layout?: RenderObjectLayoutSpec;
|
|
679
699
|
}
|
|
680
|
-
|
|
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 {
|
|
681
736
|
id: string;
|
|
737
|
+
stack?: number;
|
|
738
|
+
order?: number;
|
|
739
|
+
replace?: boolean;
|
|
740
|
+
visibility?: VisibilityExpr;
|
|
741
|
+
effects?: RenderEffectSpec[];
|
|
682
742
|
objects: RenderObjectSpec[];
|
|
683
|
-
props?: RenderProps;
|
|
684
743
|
}
|
|
685
744
|
|
|
686
745
|
interface RenderProducerResult {
|
|
687
|
-
|
|
688
|
-
rootLayerSpecs?: Record<string, RenderObjectSpec[]>;
|
|
689
|
-
replaceLayerIds?: string[];
|
|
690
|
-
replaceRootLayerIds?: string[];
|
|
746
|
+
passes?: RenderPassSpec[];
|
|
691
747
|
}
|
|
692
748
|
type RenderProducer = () => RenderProducerResult | undefined | Promise<RenderProducerResult | undefined>;
|
|
693
749
|
interface RegisterRenderProducerOptions {
|
|
@@ -702,15 +758,33 @@ interface RectLike {
|
|
|
702
758
|
declare class CanvasService implements Service {
|
|
703
759
|
canvas: Canvas;
|
|
704
760
|
viewport: ViewportSystem;
|
|
761
|
+
private context?;
|
|
705
762
|
private eventBus?;
|
|
763
|
+
private workbenchService?;
|
|
764
|
+
private toolSessionService?;
|
|
706
765
|
private renderProducers;
|
|
707
766
|
private producerOrder;
|
|
708
767
|
private producerFlushRequested;
|
|
709
768
|
private producerLoopPending;
|
|
710
769
|
private producerLoopPromise;
|
|
711
|
-
private
|
|
712
|
-
private
|
|
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;
|
|
713
784
|
constructor(el: HTMLCanvasElement | string | Canvas, options?: any);
|
|
785
|
+
init(context: ServiceContext): void;
|
|
786
|
+
private attachContextEvents;
|
|
787
|
+
private detachContextEvents;
|
|
714
788
|
setEventBus(eventBus: EventBus): void;
|
|
715
789
|
private setupEvents;
|
|
716
790
|
dispose(): void;
|
|
@@ -723,21 +797,22 @@ declare class CanvasService implements Service {
|
|
|
723
797
|
private scheduleProducerLoop;
|
|
724
798
|
private runProducerLoop;
|
|
725
799
|
private sortedRenderProducerEntries;
|
|
726
|
-
private
|
|
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;
|
|
727
813
|
private collectAndApplyProducerSpecs;
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
* We assume layers are Groups directly on the canvas with a data.id property.
|
|
731
|
-
*/
|
|
732
|
-
getLayer(id: string): Group | undefined;
|
|
733
|
-
/**
|
|
734
|
-
* Create a layer (Group) with the given ID if it doesn't exist.
|
|
735
|
-
*/
|
|
736
|
-
createLayer(id: string, options?: any): Group;
|
|
737
|
-
/**
|
|
738
|
-
* Find an object by ID, optionally within a specific layer.
|
|
739
|
-
*/
|
|
740
|
-
getObject(id: string, layerId?: string): FabricObject | undefined;
|
|
814
|
+
private applyManagedPassEffects;
|
|
815
|
+
getObject(id: string, passId?: string): FabricObject | undefined;
|
|
741
816
|
requestRenderAll(): void;
|
|
742
817
|
resize(width: number, height: number): void;
|
|
743
818
|
getSceneScale(): number;
|
|
@@ -799,23 +874,47 @@ declare class CanvasService implements Service {
|
|
|
799
874
|
private normalizeOriginY;
|
|
800
875
|
private originFactor;
|
|
801
876
|
private resolveLayoutProps;
|
|
802
|
-
|
|
877
|
+
setPassVisibility(passId: string, visible: boolean): boolean;
|
|
878
|
+
setLayerVisibility(layerId: string, visible: boolean): boolean;
|
|
879
|
+
bringPassToFront(passId: string): void;
|
|
803
880
|
bringLayerToFront(layerId: string): void;
|
|
804
|
-
|
|
805
|
-
applyObjectSpecsToLayer(layerId: string, objects: RenderObjectSpec[], options?: {
|
|
881
|
+
applyPassSpec(spec: RenderPassSpec, options?: {
|
|
806
882
|
render?: boolean;
|
|
807
883
|
}): Promise<void>;
|
|
808
|
-
|
|
809
|
-
|
|
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?: {
|
|
810
894
|
render?: boolean;
|
|
895
|
+
replace?: boolean;
|
|
811
896
|
}): Promise<void>;
|
|
812
|
-
private applyObjectSpecsToContainer;
|
|
813
897
|
private patchFabricObject;
|
|
898
|
+
private readPathDataFromSpec;
|
|
899
|
+
private hashText;
|
|
900
|
+
private getSpecRenderSourceKey;
|
|
901
|
+
private shouldRecreateObject;
|
|
814
902
|
private resolveFabricProps;
|
|
815
|
-
private
|
|
903
|
+
private moveObjectInCanvas;
|
|
816
904
|
private createFabricObject;
|
|
817
905
|
}
|
|
818
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
|
+
|
|
819
918
|
type CutMode = "trim" | "outset" | "inset";
|
|
820
919
|
interface SceneRect {
|
|
821
920
|
left: number;
|
|
@@ -872,15 +971,4 @@ declare class SceneLayoutService implements Service {
|
|
|
872
971
|
getGeometry(forceRefresh?: boolean): SceneGeometrySnapshot | null;
|
|
873
972
|
}
|
|
874
973
|
|
|
875
|
-
|
|
876
|
-
private context?;
|
|
877
|
-
private activeToolId;
|
|
878
|
-
private canvasService?;
|
|
879
|
-
init(context: ServiceContext): void;
|
|
880
|
-
dispose(context: ServiceContext): void;
|
|
881
|
-
private onToolActivated;
|
|
882
|
-
private onObjectAdded;
|
|
883
|
-
private apply;
|
|
884
|
-
}
|
|
885
|
-
|
|
886
|
-
export { BackgroundTool, CanvasService, type DielineGeometry, type DielineState, DielineTool, FeatureTool, FilmTool, type ImageItem, ImageTool, type LineStyle, MirrorTool, type RenderCoordinateSpace, type RenderLayerSpec, type RenderLayoutAlign, type RenderLayoutInsets, type RenderLayoutLength, type RenderLayoutRect, type RenderLayoutReference, type RenderObjectLayoutSpec, 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,33 +1,58 @@
|
|
|
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?;
|
|
29
|
+
private configService?;
|
|
12
30
|
private specs;
|
|
13
31
|
private renderProducerDisposable?;
|
|
32
|
+
private configChangeDisposable?;
|
|
14
33
|
private renderSeq;
|
|
15
|
-
private
|
|
34
|
+
private latestSceneLayout;
|
|
16
35
|
private sourceSizeBySrc;
|
|
17
36
|
private pendingSizeBySrc;
|
|
18
37
|
private onCanvasResized;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
url: string;
|
|
22
|
-
}>);
|
|
38
|
+
private onSceneLayoutChanged;
|
|
39
|
+
constructor(options?: Partial<BackgroundConfig>);
|
|
23
40
|
activate(context: ExtensionContext): void;
|
|
24
41
|
deactivate(context: ExtensionContext): void;
|
|
25
42
|
contribute(): {
|
|
26
43
|
[ContributionPointIds.CONFIGURATIONS]: ConfigurationContribution[];
|
|
27
44
|
[ContributionPointIds.COMMANDS]: CommandContribution[];
|
|
28
45
|
};
|
|
29
|
-
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;
|
|
30
54
|
private buildBackgroundSpecs;
|
|
55
|
+
private collectActiveImageUrls;
|
|
31
56
|
private ensureImageSize;
|
|
32
57
|
private loadImageSize;
|
|
33
58
|
private updateBackground;
|
|
@@ -66,6 +91,7 @@ declare class ImageTool implements Extension {
|
|
|
66
91
|
private cropShapeHatchPattern?;
|
|
67
92
|
private cropShapeHatchPatternColor?;
|
|
68
93
|
private cropShapeHatchPatternKey?;
|
|
94
|
+
private imageSpecs;
|
|
69
95
|
private overlaySpecs;
|
|
70
96
|
private renderProducerDisposable?;
|
|
71
97
|
activate(context: ExtensionContext): void;
|
|
@@ -122,6 +148,7 @@ declare class ImageTool implements Extension {
|
|
|
122
148
|
private purgeSourceSizeCacheForItem;
|
|
123
149
|
private rememberSourceSize;
|
|
124
150
|
private getSourceSize;
|
|
151
|
+
private ensureSourceSize;
|
|
125
152
|
private getCoverScale;
|
|
126
153
|
private getFrameVisualConfig;
|
|
127
154
|
private toSceneGeometryLike;
|
|
@@ -131,12 +158,9 @@ declare class ImageTool implements Extension {
|
|
|
131
158
|
private buildCropShapeOverlaySpecs;
|
|
132
159
|
private resolveRenderImageState;
|
|
133
160
|
private computeCanvasProps;
|
|
134
|
-
private toScreenObjectProps;
|
|
135
161
|
private toSceneObjectScale;
|
|
136
162
|
private getCurrentSrc;
|
|
137
|
-
private
|
|
138
|
-
private upsertImageObject;
|
|
139
|
-
private syncImageZOrder;
|
|
163
|
+
private buildImageSpecs;
|
|
140
164
|
private buildOverlaySpecs;
|
|
141
165
|
private updateImages;
|
|
142
166
|
private updateImagesAsync;
|
|
@@ -245,7 +269,6 @@ interface DielineState {
|
|
|
245
269
|
mainLine: LineStyle;
|
|
246
270
|
offsetLine: LineStyle;
|
|
247
271
|
insideColor: string;
|
|
248
|
-
outsideColor: string;
|
|
249
272
|
showBleedLines: boolean;
|
|
250
273
|
features: DielineFeature[];
|
|
251
274
|
pathData?: string;
|
|
@@ -261,6 +284,7 @@ declare class DielineTool implements Extension {
|
|
|
261
284
|
private canvasService?;
|
|
262
285
|
private context?;
|
|
263
286
|
private specs;
|
|
287
|
+
private effects;
|
|
264
288
|
private renderSeq;
|
|
265
289
|
private renderProducerDisposable?;
|
|
266
290
|
private onCanvasResized;
|
|
@@ -282,10 +306,10 @@ declare class DielineTool implements Extension {
|
|
|
282
306
|
};
|
|
283
307
|
private createHatchPattern;
|
|
284
308
|
private getConfigService;
|
|
309
|
+
private hasImageItems;
|
|
285
310
|
private syncSizeState;
|
|
286
|
-
private bringFeatureMarkersToFront;
|
|
287
|
-
private ensureLayerStacking;
|
|
288
311
|
private buildDielineSpecs;
|
|
312
|
+
private buildImageClipEffects;
|
|
289
313
|
updateDieline(_emitEvent?: boolean): void;
|
|
290
314
|
private updateDielineAsync;
|
|
291
315
|
getGeometry(): DielineGeometry | null;
|
|
@@ -372,7 +396,6 @@ declare class FeatureTool implements Extension {
|
|
|
372
396
|
private syncGroupFromCanvas;
|
|
373
397
|
private redraw;
|
|
374
398
|
private redrawAsync;
|
|
375
|
-
private syncOverlayOrder;
|
|
376
399
|
private buildFeatureSpecs;
|
|
377
400
|
private appendMarkerSpecs;
|
|
378
401
|
private buildMarkerData;
|
|
@@ -587,11 +610,8 @@ declare class WhiteInkTool implements Extension {
|
|
|
587
610
|
private computeCoverOpacity;
|
|
588
611
|
private buildCloneImageSpec;
|
|
589
612
|
private buildFrameSpecs;
|
|
590
|
-
private applyImageVisibilityForWhiteInk;
|
|
591
613
|
private resolveRenderItems;
|
|
592
614
|
private resolveRenderSources;
|
|
593
|
-
private resolveDefaultInsertIndex;
|
|
594
|
-
private syncZOrder;
|
|
595
615
|
private clearRenderedWhiteInks;
|
|
596
616
|
private purgeSourceCaches;
|
|
597
617
|
private updateWhiteInks;
|
|
@@ -677,17 +697,53 @@ interface RenderObjectSpec {
|
|
|
677
697
|
space?: RenderCoordinateSpace;
|
|
678
698
|
layout?: RenderObjectLayoutSpec;
|
|
679
699
|
}
|
|
680
|
-
|
|
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 {
|
|
681
736
|
id: string;
|
|
737
|
+
stack?: number;
|
|
738
|
+
order?: number;
|
|
739
|
+
replace?: boolean;
|
|
740
|
+
visibility?: VisibilityExpr;
|
|
741
|
+
effects?: RenderEffectSpec[];
|
|
682
742
|
objects: RenderObjectSpec[];
|
|
683
|
-
props?: RenderProps;
|
|
684
743
|
}
|
|
685
744
|
|
|
686
745
|
interface RenderProducerResult {
|
|
687
|
-
|
|
688
|
-
rootLayerSpecs?: Record<string, RenderObjectSpec[]>;
|
|
689
|
-
replaceLayerIds?: string[];
|
|
690
|
-
replaceRootLayerIds?: string[];
|
|
746
|
+
passes?: RenderPassSpec[];
|
|
691
747
|
}
|
|
692
748
|
type RenderProducer = () => RenderProducerResult | undefined | Promise<RenderProducerResult | undefined>;
|
|
693
749
|
interface RegisterRenderProducerOptions {
|
|
@@ -702,15 +758,33 @@ interface RectLike {
|
|
|
702
758
|
declare class CanvasService implements Service {
|
|
703
759
|
canvas: Canvas;
|
|
704
760
|
viewport: ViewportSystem;
|
|
761
|
+
private context?;
|
|
705
762
|
private eventBus?;
|
|
763
|
+
private workbenchService?;
|
|
764
|
+
private toolSessionService?;
|
|
706
765
|
private renderProducers;
|
|
707
766
|
private producerOrder;
|
|
708
767
|
private producerFlushRequested;
|
|
709
768
|
private producerLoopPending;
|
|
710
769
|
private producerLoopPromise;
|
|
711
|
-
private
|
|
712
|
-
private
|
|
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;
|
|
713
784
|
constructor(el: HTMLCanvasElement | string | Canvas, options?: any);
|
|
785
|
+
init(context: ServiceContext): void;
|
|
786
|
+
private attachContextEvents;
|
|
787
|
+
private detachContextEvents;
|
|
714
788
|
setEventBus(eventBus: EventBus): void;
|
|
715
789
|
private setupEvents;
|
|
716
790
|
dispose(): void;
|
|
@@ -723,21 +797,22 @@ declare class CanvasService implements Service {
|
|
|
723
797
|
private scheduleProducerLoop;
|
|
724
798
|
private runProducerLoop;
|
|
725
799
|
private sortedRenderProducerEntries;
|
|
726
|
-
private
|
|
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;
|
|
727
813
|
private collectAndApplyProducerSpecs;
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
* We assume layers are Groups directly on the canvas with a data.id property.
|
|
731
|
-
*/
|
|
732
|
-
getLayer(id: string): Group | undefined;
|
|
733
|
-
/**
|
|
734
|
-
* Create a layer (Group) with the given ID if it doesn't exist.
|
|
735
|
-
*/
|
|
736
|
-
createLayer(id: string, options?: any): Group;
|
|
737
|
-
/**
|
|
738
|
-
* Find an object by ID, optionally within a specific layer.
|
|
739
|
-
*/
|
|
740
|
-
getObject(id: string, layerId?: string): FabricObject | undefined;
|
|
814
|
+
private applyManagedPassEffects;
|
|
815
|
+
getObject(id: string, passId?: string): FabricObject | undefined;
|
|
741
816
|
requestRenderAll(): void;
|
|
742
817
|
resize(width: number, height: number): void;
|
|
743
818
|
getSceneScale(): number;
|
|
@@ -799,23 +874,47 @@ declare class CanvasService implements Service {
|
|
|
799
874
|
private normalizeOriginY;
|
|
800
875
|
private originFactor;
|
|
801
876
|
private resolveLayoutProps;
|
|
802
|
-
|
|
877
|
+
setPassVisibility(passId: string, visible: boolean): boolean;
|
|
878
|
+
setLayerVisibility(layerId: string, visible: boolean): boolean;
|
|
879
|
+
bringPassToFront(passId: string): void;
|
|
803
880
|
bringLayerToFront(layerId: string): void;
|
|
804
|
-
|
|
805
|
-
applyObjectSpecsToLayer(layerId: string, objects: RenderObjectSpec[], options?: {
|
|
881
|
+
applyPassSpec(spec: RenderPassSpec, options?: {
|
|
806
882
|
render?: boolean;
|
|
807
883
|
}): Promise<void>;
|
|
808
|
-
|
|
809
|
-
|
|
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?: {
|
|
810
894
|
render?: boolean;
|
|
895
|
+
replace?: boolean;
|
|
811
896
|
}): Promise<void>;
|
|
812
|
-
private applyObjectSpecsToContainer;
|
|
813
897
|
private patchFabricObject;
|
|
898
|
+
private readPathDataFromSpec;
|
|
899
|
+
private hashText;
|
|
900
|
+
private getSpecRenderSourceKey;
|
|
901
|
+
private shouldRecreateObject;
|
|
814
902
|
private resolveFabricProps;
|
|
815
|
-
private
|
|
903
|
+
private moveObjectInCanvas;
|
|
816
904
|
private createFabricObject;
|
|
817
905
|
}
|
|
818
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
|
+
|
|
819
918
|
type CutMode = "trim" | "outset" | "inset";
|
|
820
919
|
interface SceneRect {
|
|
821
920
|
left: number;
|
|
@@ -872,15 +971,4 @@ declare class SceneLayoutService implements Service {
|
|
|
872
971
|
getGeometry(forceRefresh?: boolean): SceneGeometrySnapshot | null;
|
|
873
972
|
}
|
|
874
973
|
|
|
875
|
-
|
|
876
|
-
private context?;
|
|
877
|
-
private activeToolId;
|
|
878
|
-
private canvasService?;
|
|
879
|
-
init(context: ServiceContext): void;
|
|
880
|
-
dispose(context: ServiceContext): void;
|
|
881
|
-
private onToolActivated;
|
|
882
|
-
private onObjectAdded;
|
|
883
|
-
private apply;
|
|
884
|
-
}
|
|
885
|
-
|
|
886
|
-
export { BackgroundTool, CanvasService, type DielineGeometry, type DielineState, DielineTool, FeatureTool, FilmTool, type ImageItem, ImageTool, type LineStyle, MirrorTool, type RenderCoordinateSpace, type RenderLayerSpec, type RenderLayoutAlign, type RenderLayoutInsets, type RenderLayoutLength, type RenderLayoutRect, type RenderLayoutReference, type RenderObjectLayoutSpec, 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 };
|