@pooder/kit 6.1.2 → 6.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/.test-dist/src/extensions/background/BackgroundTool.js +177 -5
  2. package/.test-dist/src/extensions/constraintUtils.js +44 -0
  3. package/.test-dist/src/extensions/dieline/DielineTool.js +52 -409
  4. package/.test-dist/src/extensions/dieline/featureResolution.js +29 -0
  5. package/.test-dist/src/extensions/dieline/model.js +83 -0
  6. package/.test-dist/src/extensions/dieline/renderBuilder.js +227 -0
  7. package/.test-dist/src/extensions/feature/FeatureTool.js +156 -45
  8. package/.test-dist/src/extensions/featureCoordinates.js +21 -0
  9. package/.test-dist/src/extensions/featurePlacement.js +46 -0
  10. package/.test-dist/src/extensions/image/ImageTool.js +281 -25
  11. package/.test-dist/src/extensions/ruler/RulerTool.js +24 -1
  12. package/.test-dist/src/shared/constants/layers.js +3 -1
  13. package/.test-dist/tests/run.js +25 -0
  14. package/CHANGELOG.md +12 -0
  15. package/dist/index.d.mts +47 -13
  16. package/dist/index.d.ts +47 -13
  17. package/dist/index.js +1325 -977
  18. package/dist/index.mjs +1311 -966
  19. package/package.json +1 -1
  20. package/src/extensions/background/BackgroundTool.ts +264 -4
  21. package/src/extensions/dieline/DielineTool.ts +67 -548
  22. package/src/extensions/dieline/model.ts +165 -1
  23. package/src/extensions/dieline/renderBuilder.ts +301 -0
  24. package/src/extensions/feature/FeatureTool.ts +190 -47
  25. package/src/extensions/featureCoordinates.ts +35 -0
  26. package/src/extensions/featurePlacement.ts +118 -0
  27. package/src/extensions/image/ImageTool.ts +139 -157
  28. package/src/extensions/ruler/RulerTool.ts +24 -2
  29. package/src/shared/constants/layers.ts +2 -0
  30. package/tests/run.ts +37 -0
package/dist/index.d.mts CHANGED
@@ -1,9 +1,23 @@
1
1
  import * as _pooder_core from '@pooder/core';
2
- import { Extension, ExtensionContext, ContributionPointIds, ConfigurationContribution, CommandContribution, Service, ServiceContext, EventBus } from '@pooder/core';
2
+ import { Extension, ExtensionContext, ContributionPointIds, ConfigurationContribution, CommandContribution, ConfigurationService, Service, ServiceContext, EventBus } from '@pooder/core';
3
3
  import { Canvas, FabricObject } from 'fabric';
4
4
 
5
5
  type BackgroundLayerKind = "color" | "image";
6
6
  type BackgroundFitMode = "cover" | "contain" | "stretch";
7
+ type BackgroundRegionUnit = "normalized" | "px";
8
+ type BackgroundRegistrationFrame = "trim" | "cut" | "bleed" | "focus" | "viewport";
9
+ interface BackgroundRegistrationRegion {
10
+ left: number;
11
+ top: number;
12
+ width: number;
13
+ height: number;
14
+ unit: BackgroundRegionUnit;
15
+ }
16
+ interface BackgroundRegistration {
17
+ sourceRegion?: BackgroundRegistrationRegion;
18
+ targetFrame?: BackgroundRegistrationFrame;
19
+ fit?: BackgroundFitMode;
20
+ }
7
21
  interface BackgroundLayer {
8
22
  id: string;
9
23
  kind: BackgroundLayerKind;
@@ -15,6 +29,7 @@ interface BackgroundLayer {
15
29
  exportable: boolean;
16
30
  color?: string;
17
31
  src?: string;
32
+ registration?: BackgroundRegistration;
18
33
  }
19
34
  interface BackgroundConfig {
20
35
  version: number;
@@ -47,8 +62,11 @@ declare class BackgroundTool implements Extension {
47
62
  private getViewportRect;
48
63
  private resolveSceneLayout;
49
64
  private resolveFocusRect;
65
+ private resolveTargetFrameRect;
50
66
  private resolveAnchorRect;
51
67
  private resolveImagePlacement;
68
+ private resolveRegistrationRegion;
69
+ private resolveRegistrationPlacement;
52
70
  private buildColorLayerSpec;
53
71
  private buildImageLayerSpec;
54
72
  private buildBackgroundSpecs;
@@ -94,9 +112,12 @@ declare class ImageTool implements Extension {
94
112
  private overlaySpecs;
95
113
  private activeSnapX;
96
114
  private activeSnapY;
97
- private snapGuideXObject?;
98
- private snapGuideYObject?;
115
+ private movingImageId;
116
+ private hasRenderedSnapGuides;
99
117
  private canvasObjectMovingHandler?;
118
+ private canvasMouseUpHandler?;
119
+ private canvasBeforeRenderHandler?;
120
+ private canvasAfterRenderHandler?;
100
121
  private renderProducerDisposable?;
101
122
  private readonly subscriptions;
102
123
  private imageControlsByCapabilityKey;
@@ -116,12 +137,13 @@ declare class ImageTool implements Extension {
116
137
  private computeMoveSnapMatches;
117
138
  private areSnapMatchesEqual;
118
139
  private updateSnapMatchState;
119
- private clearSnapGuides;
120
- private removeSnapGuideObject;
121
- private createOrUpdateSnapGuideObject;
122
- private updateSnapGuideVisuals;
140
+ private clearSnapPreview;
141
+ private endMoveSnapInteraction;
142
+ private applyMoveSnapToTarget;
143
+ private handleCanvasBeforeRender;
144
+ private drawSnapGuideLine;
145
+ private handleCanvasAfterRender;
123
146
  private handleCanvasObjectMoving;
124
- private applySnapMatchesToTarget;
125
147
  private syncToolActiveFromWorkbench;
126
148
  private isImageEditingVisible;
127
149
  private getEnabledImageControlCapabilities;
@@ -313,6 +335,9 @@ interface DielineState {
313
335
  customSourceWidthPx?: number;
314
336
  customSourceHeightPx?: number;
315
337
  }
338
+ declare function createDefaultDielineState(): DielineState;
339
+ declare function readDielineState(configService: ConfigurationService, fallback?: Partial<DielineState>): DielineState;
340
+
316
341
  declare class DielineTool implements Extension {
317
342
  id: string;
318
343
  metadata: {
@@ -345,7 +370,6 @@ declare class DielineTool implements Extension {
345
370
  private createHatchPattern;
346
371
  private getConfigService;
347
372
  private hasImageItems;
348
- private syncSizeState;
349
373
  private buildDielineSpecs;
350
374
  private buildImageClipEffects;
351
375
  updateDieline(_emitEvent?: boolean): void;
@@ -739,7 +763,9 @@ declare class FeatureTool implements Extension {
739
763
  private hasWorkingChanges;
740
764
  private dirtyTrackerDisposable?;
741
765
  private renderProducerDisposable?;
742
- private specs;
766
+ private markerSpecs;
767
+ private sessionDielineSpecs;
768
+ private sessionDielineEffects;
743
769
  private renderSeq;
744
770
  private readonly subscriptions;
745
771
  private handleMoving;
@@ -753,6 +779,7 @@ declare class FeatureTool implements Extension {
753
779
  deactivate(context: ExtensionContext): void;
754
780
  private onToolActivated;
755
781
  private updateVisibility;
782
+ private isSessionVisible;
756
783
  contribute(): {
757
784
  [ContributionPointIds.TOOLS]: {
758
785
  id: string;
@@ -774,8 +801,10 @@ declare class FeatureTool implements Extension {
774
801
  private getConfigService;
775
802
  private getCommittedFeatures;
776
803
  private updateCommittedFeatures;
804
+ private hasFeatureSessionDraft;
777
805
  private clearFeatureSessionState;
778
- private restoreSessionFeaturesToConfig;
806
+ private restoreCommittedFeaturesToConfig;
807
+ private suspendFeatureSession;
779
808
  private emitWorkingChange;
780
809
  private refreshGeometry;
781
810
  private resetWorkingFeaturesFromSource;
@@ -787,6 +816,7 @@ declare class FeatureTool implements Extension {
787
816
  private getGeometryForFeature;
788
817
  private setup;
789
818
  private teardown;
819
+ private createHatchPattern;
790
820
  private getDraggableMarkerTarget;
791
821
  private getFeatureForMarker;
792
822
  private constrainPosition;
@@ -795,7 +825,9 @@ declare class FeatureTool implements Extension {
795
825
  private syncGroupFromCanvas;
796
826
  private redraw;
797
827
  private redrawAsync;
798
- private buildFeatureSpecs;
828
+ private buildSessionDielineRender;
829
+ private hasImageItems;
830
+ private buildMarkerSpecs;
799
831
  private appendMarkerSpecs;
800
832
  private buildMarkerData;
801
833
  private markerId;
@@ -875,6 +907,7 @@ declare class RulerTool implements Extension {
875
907
  private textColor;
876
908
  private lineColor;
877
909
  private fontSize;
910
+ private debugEnabled;
878
911
  private renderSeq;
879
912
  private readonly numericProps;
880
913
  private specs;
@@ -896,6 +929,7 @@ declare class RulerTool implements Extension {
896
929
  [ContributionPointIds.CONFIGURATIONS]: ConfigurationContribution[];
897
930
  [ContributionPointIds.COMMANDS]: CommandContribution[];
898
931
  };
932
+ private isDebugEnabled;
899
933
  private log;
900
934
  private syncConfig;
901
935
  private toFiniteNumber;
@@ -1028,4 +1062,4 @@ declare function createWhiteInkCommands(tool: any): CommandContribution[];
1028
1062
 
1029
1063
  declare function createWhiteInkConfigurations(): ConfigurationContribution[];
1030
1064
 
1031
- 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, getCoverScale as computeImageCoverScale, getCoverScale as computeWhiteInkCoverScale, createDielineCommands, createDielineConfigurations, createImageCommands, createImageConfigurations, createWhiteInkCommands, createWhiteInkConfigurations, evaluateVisibilityExpr };
1065
+ export { type BackgroundConfig, type BackgroundFitMode, type BackgroundLayer, type BackgroundLayerKind, type BackgroundRegionUnit, type BackgroundRegistration, type BackgroundRegistrationFrame, type BackgroundRegistrationRegion, 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, getCoverScale as computeImageCoverScale, getCoverScale as computeWhiteInkCoverScale, createDefaultDielineState, createDielineCommands, createDielineConfigurations, createImageCommands, createImageConfigurations, createWhiteInkCommands, createWhiteInkConfigurations, evaluateVisibilityExpr, readDielineState };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,23 @@
1
1
  import * as _pooder_core from '@pooder/core';
2
- import { Extension, ExtensionContext, ContributionPointIds, ConfigurationContribution, CommandContribution, Service, ServiceContext, EventBus } from '@pooder/core';
2
+ import { Extension, ExtensionContext, ContributionPointIds, ConfigurationContribution, CommandContribution, ConfigurationService, Service, ServiceContext, EventBus } from '@pooder/core';
3
3
  import { Canvas, FabricObject } from 'fabric';
4
4
 
5
5
  type BackgroundLayerKind = "color" | "image";
6
6
  type BackgroundFitMode = "cover" | "contain" | "stretch";
7
+ type BackgroundRegionUnit = "normalized" | "px";
8
+ type BackgroundRegistrationFrame = "trim" | "cut" | "bleed" | "focus" | "viewport";
9
+ interface BackgroundRegistrationRegion {
10
+ left: number;
11
+ top: number;
12
+ width: number;
13
+ height: number;
14
+ unit: BackgroundRegionUnit;
15
+ }
16
+ interface BackgroundRegistration {
17
+ sourceRegion?: BackgroundRegistrationRegion;
18
+ targetFrame?: BackgroundRegistrationFrame;
19
+ fit?: BackgroundFitMode;
20
+ }
7
21
  interface BackgroundLayer {
8
22
  id: string;
9
23
  kind: BackgroundLayerKind;
@@ -15,6 +29,7 @@ interface BackgroundLayer {
15
29
  exportable: boolean;
16
30
  color?: string;
17
31
  src?: string;
32
+ registration?: BackgroundRegistration;
18
33
  }
19
34
  interface BackgroundConfig {
20
35
  version: number;
@@ -47,8 +62,11 @@ declare class BackgroundTool implements Extension {
47
62
  private getViewportRect;
48
63
  private resolveSceneLayout;
49
64
  private resolveFocusRect;
65
+ private resolveTargetFrameRect;
50
66
  private resolveAnchorRect;
51
67
  private resolveImagePlacement;
68
+ private resolveRegistrationRegion;
69
+ private resolveRegistrationPlacement;
52
70
  private buildColorLayerSpec;
53
71
  private buildImageLayerSpec;
54
72
  private buildBackgroundSpecs;
@@ -94,9 +112,12 @@ declare class ImageTool implements Extension {
94
112
  private overlaySpecs;
95
113
  private activeSnapX;
96
114
  private activeSnapY;
97
- private snapGuideXObject?;
98
- private snapGuideYObject?;
115
+ private movingImageId;
116
+ private hasRenderedSnapGuides;
99
117
  private canvasObjectMovingHandler?;
118
+ private canvasMouseUpHandler?;
119
+ private canvasBeforeRenderHandler?;
120
+ private canvasAfterRenderHandler?;
100
121
  private renderProducerDisposable?;
101
122
  private readonly subscriptions;
102
123
  private imageControlsByCapabilityKey;
@@ -116,12 +137,13 @@ declare class ImageTool implements Extension {
116
137
  private computeMoveSnapMatches;
117
138
  private areSnapMatchesEqual;
118
139
  private updateSnapMatchState;
119
- private clearSnapGuides;
120
- private removeSnapGuideObject;
121
- private createOrUpdateSnapGuideObject;
122
- private updateSnapGuideVisuals;
140
+ private clearSnapPreview;
141
+ private endMoveSnapInteraction;
142
+ private applyMoveSnapToTarget;
143
+ private handleCanvasBeforeRender;
144
+ private drawSnapGuideLine;
145
+ private handleCanvasAfterRender;
123
146
  private handleCanvasObjectMoving;
124
- private applySnapMatchesToTarget;
125
147
  private syncToolActiveFromWorkbench;
126
148
  private isImageEditingVisible;
127
149
  private getEnabledImageControlCapabilities;
@@ -313,6 +335,9 @@ interface DielineState {
313
335
  customSourceWidthPx?: number;
314
336
  customSourceHeightPx?: number;
315
337
  }
338
+ declare function createDefaultDielineState(): DielineState;
339
+ declare function readDielineState(configService: ConfigurationService, fallback?: Partial<DielineState>): DielineState;
340
+
316
341
  declare class DielineTool implements Extension {
317
342
  id: string;
318
343
  metadata: {
@@ -345,7 +370,6 @@ declare class DielineTool implements Extension {
345
370
  private createHatchPattern;
346
371
  private getConfigService;
347
372
  private hasImageItems;
348
- private syncSizeState;
349
373
  private buildDielineSpecs;
350
374
  private buildImageClipEffects;
351
375
  updateDieline(_emitEvent?: boolean): void;
@@ -739,7 +763,9 @@ declare class FeatureTool implements Extension {
739
763
  private hasWorkingChanges;
740
764
  private dirtyTrackerDisposable?;
741
765
  private renderProducerDisposable?;
742
- private specs;
766
+ private markerSpecs;
767
+ private sessionDielineSpecs;
768
+ private sessionDielineEffects;
743
769
  private renderSeq;
744
770
  private readonly subscriptions;
745
771
  private handleMoving;
@@ -753,6 +779,7 @@ declare class FeatureTool implements Extension {
753
779
  deactivate(context: ExtensionContext): void;
754
780
  private onToolActivated;
755
781
  private updateVisibility;
782
+ private isSessionVisible;
756
783
  contribute(): {
757
784
  [ContributionPointIds.TOOLS]: {
758
785
  id: string;
@@ -774,8 +801,10 @@ declare class FeatureTool implements Extension {
774
801
  private getConfigService;
775
802
  private getCommittedFeatures;
776
803
  private updateCommittedFeatures;
804
+ private hasFeatureSessionDraft;
777
805
  private clearFeatureSessionState;
778
- private restoreSessionFeaturesToConfig;
806
+ private restoreCommittedFeaturesToConfig;
807
+ private suspendFeatureSession;
779
808
  private emitWorkingChange;
780
809
  private refreshGeometry;
781
810
  private resetWorkingFeaturesFromSource;
@@ -787,6 +816,7 @@ declare class FeatureTool implements Extension {
787
816
  private getGeometryForFeature;
788
817
  private setup;
789
818
  private teardown;
819
+ private createHatchPattern;
790
820
  private getDraggableMarkerTarget;
791
821
  private getFeatureForMarker;
792
822
  private constrainPosition;
@@ -795,7 +825,9 @@ declare class FeatureTool implements Extension {
795
825
  private syncGroupFromCanvas;
796
826
  private redraw;
797
827
  private redrawAsync;
798
- private buildFeatureSpecs;
828
+ private buildSessionDielineRender;
829
+ private hasImageItems;
830
+ private buildMarkerSpecs;
799
831
  private appendMarkerSpecs;
800
832
  private buildMarkerData;
801
833
  private markerId;
@@ -875,6 +907,7 @@ declare class RulerTool implements Extension {
875
907
  private textColor;
876
908
  private lineColor;
877
909
  private fontSize;
910
+ private debugEnabled;
878
911
  private renderSeq;
879
912
  private readonly numericProps;
880
913
  private specs;
@@ -896,6 +929,7 @@ declare class RulerTool implements Extension {
896
929
  [ContributionPointIds.CONFIGURATIONS]: ConfigurationContribution[];
897
930
  [ContributionPointIds.COMMANDS]: CommandContribution[];
898
931
  };
932
+ private isDebugEnabled;
899
933
  private log;
900
934
  private syncConfig;
901
935
  private toFiniteNumber;
@@ -1028,4 +1062,4 @@ declare function createWhiteInkCommands(tool: any): CommandContribution[];
1028
1062
 
1029
1063
  declare function createWhiteInkConfigurations(): ConfigurationContribution[];
1030
1064
 
1031
- 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, getCoverScale as computeImageCoverScale, getCoverScale as computeWhiteInkCoverScale, createDielineCommands, createDielineConfigurations, createImageCommands, createImageConfigurations, createWhiteInkCommands, createWhiteInkConfigurations, evaluateVisibilityExpr };
1065
+ export { type BackgroundConfig, type BackgroundFitMode, type BackgroundLayer, type BackgroundLayerKind, type BackgroundRegionUnit, type BackgroundRegistration, type BackgroundRegistrationFrame, type BackgroundRegistrationRegion, 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, getCoverScale as computeImageCoverScale, getCoverScale as computeWhiteInkCoverScale, createDefaultDielineState, createDielineCommands, createDielineConfigurations, createImageCommands, createImageConfigurations, createWhiteInkCommands, createWhiteInkConfigurations, evaluateVisibilityExpr, readDielineState };