@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.
Files changed (69) hide show
  1. package/.test-dist/src/coordinate.js +74 -0
  2. package/.test-dist/src/extensions/background.js +547 -0
  3. package/.test-dist/src/extensions/bridgeSelection.js +20 -0
  4. package/.test-dist/src/extensions/constraints.js +237 -0
  5. package/.test-dist/src/extensions/dieline.js +931 -0
  6. package/.test-dist/src/extensions/dielineShape.js +66 -0
  7. package/.test-dist/src/extensions/edgeScale.js +12 -0
  8. package/.test-dist/src/extensions/feature.js +910 -0
  9. package/.test-dist/src/extensions/featureComplete.js +32 -0
  10. package/.test-dist/src/extensions/film.js +226 -0
  11. package/.test-dist/src/extensions/geometry.js +609 -0
  12. package/.test-dist/src/extensions/image.js +1613 -0
  13. package/.test-dist/src/extensions/index.js +28 -0
  14. package/.test-dist/src/extensions/maskOps.js +334 -0
  15. package/.test-dist/src/extensions/mirror.js +104 -0
  16. package/.test-dist/src/extensions/ruler.js +442 -0
  17. package/.test-dist/src/extensions/sceneLayout.js +96 -0
  18. package/.test-dist/src/extensions/sceneLayoutModel.js +202 -0
  19. package/.test-dist/src/extensions/sceneVisibility.js +55 -0
  20. package/.test-dist/src/extensions/size.js +331 -0
  21. package/.test-dist/src/extensions/tracer.js +709 -0
  22. package/.test-dist/src/extensions/white-ink.js +1200 -0
  23. package/.test-dist/src/extensions/wrappedOffsets.js +33 -0
  24. package/.test-dist/src/index.js +18 -0
  25. package/.test-dist/src/services/CanvasService.js +1011 -0
  26. package/.test-dist/src/services/ViewportSystem.js +76 -0
  27. package/.test-dist/src/services/index.js +25 -0
  28. package/.test-dist/src/services/renderSpec.js +2 -0
  29. package/.test-dist/src/services/visibility.js +54 -0
  30. package/.test-dist/src/units.js +30 -0
  31. package/.test-dist/tests/run.js +148 -0
  32. package/CHANGELOG.md +6 -0
  33. package/dist/index.d.mts +150 -62
  34. package/dist/index.d.ts +150 -62
  35. package/dist/index.js +2219 -1714
  36. package/dist/index.mjs +2226 -1718
  37. package/package.json +1 -1
  38. package/src/coordinate.ts +106 -106
  39. package/src/extensions/background.ts +716 -323
  40. package/src/extensions/bridgeSelection.ts +17 -17
  41. package/src/extensions/constraints.ts +322 -322
  42. package/src/extensions/dieline.ts +1169 -1149
  43. package/src/extensions/dielineShape.ts +109 -109
  44. package/src/extensions/edgeScale.ts +19 -19
  45. package/src/extensions/feature.ts +1140 -1137
  46. package/src/extensions/featureComplete.ts +46 -46
  47. package/src/extensions/film.ts +270 -266
  48. package/src/extensions/geometry.ts +851 -885
  49. package/src/extensions/image.ts +2007 -2054
  50. package/src/extensions/index.ts +10 -11
  51. package/src/extensions/maskOps.ts +283 -283
  52. package/src/extensions/mirror.ts +128 -128
  53. package/src/extensions/ruler.ts +664 -654
  54. package/src/extensions/sceneLayout.ts +140 -140
  55. package/src/extensions/sceneLayoutModel.ts +364 -364
  56. package/src/extensions/size.ts +389 -389
  57. package/src/extensions/tracer.ts +1019 -1019
  58. package/src/extensions/white-ink.ts +1508 -1575
  59. package/src/extensions/wrappedOffsets.ts +33 -33
  60. package/src/index.ts +2 -2
  61. package/src/services/CanvasService.ts +1286 -832
  62. package/src/services/ViewportSystem.ts +95 -95
  63. package/src/services/index.ts +4 -3
  64. package/src/services/renderSpec.ts +83 -53
  65. package/src/services/visibility.ts +78 -0
  66. package/src/units.ts +27 -27
  67. package/tests/run.ts +253 -118
  68. package/tsconfig.test.json +15 -15
  69. 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, EventBus, ServiceContext } from '@pooder/core';
2
- import { Canvas, Group, FabricObject } from 'fabric';
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 color;
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 renderImageUrl;
34
+ private latestSceneLayout;
16
35
  private sourceSizeBySrc;
17
36
  private pendingSizeBySrc;
18
37
  private onCanvasResized;
19
- constructor(options?: Partial<{
20
- color: string;
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 getViewportSize;
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 applyImageControlVisibility;
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
- interface RenderLayerSpec {
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
- layerSpecs?: Record<string, RenderObjectSpec[]>;
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 managedProducerLayerIds;
712
- private managedProducerRootLayerIds;
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 appendLayerSpecMap;
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
- * Get a layer (Group) by its ID.
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
- setLayerVisibility(layerId: string, visible: boolean): void;
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
- applyLayerSpec(spec: RenderLayerSpec): Promise<void>;
805
- applyObjectSpecsToLayer(layerId: string, objects: RenderObjectSpec[], options?: {
881
+ applyPassSpec(spec: RenderPassSpec, options?: {
806
882
  render?: boolean;
807
883
  }): Promise<void>;
808
- getRootLayerObjects(layerId: string): FabricObject[];
809
- applyObjectSpecsToRootLayer(layerId: string, specs: RenderObjectSpec[], options?: {
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 moveObjectInContainer;
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
- declare class SceneVisibilityService implements Service {
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, EventBus, ServiceContext } from '@pooder/core';
2
- import { Canvas, Group, FabricObject } from 'fabric';
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 color;
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 renderImageUrl;
34
+ private latestSceneLayout;
16
35
  private sourceSizeBySrc;
17
36
  private pendingSizeBySrc;
18
37
  private onCanvasResized;
19
- constructor(options?: Partial<{
20
- color: string;
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 getViewportSize;
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 applyImageControlVisibility;
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
- interface RenderLayerSpec {
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
- layerSpecs?: Record<string, RenderObjectSpec[]>;
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 managedProducerLayerIds;
712
- private managedProducerRootLayerIds;
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 appendLayerSpecMap;
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
- * Get a layer (Group) by its ID.
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
- setLayerVisibility(layerId: string, visible: boolean): void;
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
- applyLayerSpec(spec: RenderLayerSpec): Promise<void>;
805
- applyObjectSpecsToLayer(layerId: string, objects: RenderObjectSpec[], options?: {
881
+ applyPassSpec(spec: RenderPassSpec, options?: {
806
882
  render?: boolean;
807
883
  }): Promise<void>;
808
- getRootLayerObjects(layerId: string): FabricObject[];
809
- applyObjectSpecsToRootLayer(layerId: string, specs: RenderObjectSpec[], options?: {
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 moveObjectInContainer;
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
- declare class SceneVisibilityService implements Service {
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 };