@pooder/kit 6.2.1 → 6.3.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/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _pooder_core from '@pooder/core';
2
- import { Extension, ExtensionContext, ContributionPointIds, ConfigurationContribution, CommandContribution, ConfigurationService, Service, ServiceContext, EventBus } from '@pooder/core';
2
+ import { Extension, ExtensionContext, ContributionPointIds, ConfigurationContribution, CommandContribution, Service, ServiceContext, EventBus, ConfigurationService } from '@pooder/core';
3
3
  import { Canvas, FabricObject } from 'fabric';
4
4
 
5
5
  type BackgroundLayerKind = "color" | "image";
@@ -87,6 +87,23 @@ interface ImageItem {
87
87
  sourceUrl?: string;
88
88
  committedUrl?: string;
89
89
  }
90
+ interface ImageTransformUpdates {
91
+ scale?: number;
92
+ angle?: number;
93
+ left?: number;
94
+ top?: number;
95
+ opacity?: number;
96
+ }
97
+ interface ImageViewState {
98
+ items: ImageItem[];
99
+ hasAnyImage: boolean;
100
+ focusedId: string | null;
101
+ focusedItem: ImageItem | null;
102
+ isToolActive: boolean;
103
+ isImageSelectionActive: boolean;
104
+ hasWorkingChanges: boolean;
105
+ source: "working" | "committed";
106
+ }
90
107
  declare class ImageTool implements Extension {
91
108
  id: string;
92
109
  metadata: {
@@ -137,6 +154,7 @@ declare class ImageTool implements Extension {
137
154
  private computeMoveSnapMatches;
138
155
  private areSnapMatchesEqual;
139
156
  private updateSnapMatchState;
157
+ private clearSnapGuideContext;
140
158
  private clearSnapPreview;
141
159
  private endMoveSnapInteraction;
142
160
  private applyMoveSnapToTarget;
@@ -174,22 +192,21 @@ declare class ImageTool implements Extension {
174
192
  private normalizeItem;
175
193
  private normalizeItems;
176
194
  private cloneItems;
195
+ private getViewItems;
196
+ private getImageViewState;
197
+ private emitImageStateChange;
177
198
  private emitWorkingChange;
178
199
  private generateId;
179
200
  private hasImageItem;
180
201
  private setImageFocus;
181
202
  private addImageEntry;
182
203
  private upsertImageEntry;
183
- private addItemToWorkingSessionIfNeeded;
184
204
  private updateImage;
185
205
  private getConfig;
186
206
  private applyCommittedItems;
187
207
  private updateConfig;
188
208
  private getFrameRect;
189
209
  private getFrameRectScreen;
190
- private toLayoutSceneRect;
191
- private resolveDefaultFitArea;
192
- private fitImageToDefaultArea;
193
210
  private getImageObjects;
194
211
  private getOverlayObjects;
195
212
  private getImageObject;
@@ -201,11 +218,8 @@ declare class ImageTool implements Extension {
201
218
  private loadImageSize;
202
219
  private getCoverScale;
203
220
  private getFrameVisualConfig;
204
- private toSceneGeometryLike;
205
- private resolveSceneGeometryForOverlay;
206
- private resolveCutShapeRadius;
221
+ private resolveSessionOverlayState;
207
222
  private getCropShapeHatchPattern;
208
- private buildCropShapeOverlaySpecs;
209
223
  private resolveRenderImageState;
210
224
  private computeCanvasProps;
211
225
  private toSceneObjectScale;
@@ -215,12 +229,14 @@ declare class ImageTool implements Extension {
215
229
  private updateImages;
216
230
  private updateImagesAsync;
217
231
  private clampNormalized;
232
+ private setImageTransform;
233
+ private resetImageSession;
218
234
  private onObjectModified;
219
235
  private updateImageInWorking;
220
236
  private updateImageInConfig;
221
237
  private waitImageLoaded;
222
- private refitImageToFrame;
223
- private fitImageToArea;
238
+ private resolveImageSourceSize;
239
+ private applyImageOperation;
224
240
  private commitWorkingImagesAsCropped;
225
241
  private exportCroppedImageByIds;
226
242
  private exportUserCroppedImage;
@@ -230,160 +246,6 @@ declare function createImageCommands(tool: any): CommandContribution[];
230
246
 
231
247
  declare function createImageConfigurations(): ConfigurationContribution[];
232
248
 
233
- interface RectLike$1 {
234
- width: number;
235
- height: number;
236
- }
237
- declare function getCoverScale(frame: RectLike$1, source: RectLike$1): number;
238
-
239
- declare class SizeTool implements Extension {
240
- id: string;
241
- metadata: {
242
- name: string;
243
- };
244
- private context?;
245
- private canvasService?;
246
- activate(context: ExtensionContext): void;
247
- deactivate(_context: ExtensionContext): void;
248
- contribute(): {
249
- [ContributionPointIds.TOOLS]: {
250
- id: string;
251
- name: string;
252
- interaction: string;
253
- }[];
254
- [ContributionPointIds.CONFIGURATIONS]: ConfigurationContribution[];
255
- [ContributionPointIds.COMMANDS]: CommandContribution[];
256
- };
257
- private getConfigService;
258
- private ensureDefaults;
259
- private emitStateChanged;
260
- private getStateForUI;
261
- private updateDimensions;
262
- private setConstraintMode;
263
- private setUnit;
264
- private setCut;
265
- private getSelectedImageSize;
266
- }
267
-
268
- declare const DIELINE_SHAPES: readonly ["rect", "circle", "ellipse", "heart", "custom"];
269
- type DielineShape = (typeof DIELINE_SHAPES)[number];
270
- type ShapeFitMode = "contain" | "stretch";
271
- interface DielineShapeStyle {
272
- fitMode: ShapeFitMode;
273
- [key: string]: unknown;
274
- }
275
-
276
- type FeatureOperation = "add" | "subtract";
277
- type FeatureShape = "rect" | "circle";
278
- interface DielineFeature {
279
- id: string;
280
- groupId?: string;
281
- operation: FeatureOperation;
282
- shape: FeatureShape;
283
- x: number;
284
- y: number;
285
- width?: number;
286
- height?: number;
287
- radius?: number;
288
- rotation?: number;
289
- renderBehavior?: "edge" | "surface";
290
- color?: string;
291
- strokeDash?: number[];
292
- skipCut?: boolean;
293
- bridge?: {
294
- type: "vertical";
295
- };
296
- }
297
-
298
- interface DielineGeometry {
299
- shape: DielineShape;
300
- shapeStyle: DielineShapeStyle;
301
- unit: "px";
302
- x: number;
303
- y: number;
304
- width: number;
305
- height: number;
306
- radius: number;
307
- offset: number;
308
- borderLength?: number;
309
- scale?: number;
310
- strokeWidth?: number;
311
- pathData?: string;
312
- customSourceWidthPx?: number;
313
- customSourceHeightPx?: number;
314
- }
315
- interface LineStyle {
316
- width: number;
317
- color: string;
318
- dashLength: number;
319
- style: "solid" | "dashed" | "hidden";
320
- }
321
- interface DielineState {
322
- shape: DielineShape;
323
- shapeStyle: DielineShapeStyle;
324
- width: number;
325
- height: number;
326
- radius: number;
327
- offset: number;
328
- padding: number | string;
329
- mainLine: LineStyle;
330
- offsetLine: LineStyle;
331
- insideColor: string;
332
- showBleedLines: boolean;
333
- features: DielineFeature[];
334
- pathData?: string;
335
- customSourceWidthPx?: number;
336
- customSourceHeightPx?: number;
337
- }
338
- declare function createDefaultDielineState(): DielineState;
339
- declare function readDielineState(configService: ConfigurationService, fallback?: Partial<DielineState>): DielineState;
340
-
341
- declare class DielineTool implements Extension {
342
- id: string;
343
- metadata: {
344
- name: string;
345
- };
346
- private state;
347
- private canvasService?;
348
- private context?;
349
- private specs;
350
- private effects;
351
- private renderSeq;
352
- private renderProducerDisposable?;
353
- private onCanvasResized;
354
- constructor(options?: Partial<DielineState>);
355
- activate(context: ExtensionContext): void;
356
- deactivate(context: ExtensionContext): void;
357
- contribute(): {
358
- [ContributionPointIds.TOOLS]: {
359
- id: string;
360
- name: string;
361
- interaction: string;
362
- session: {
363
- autoBegin: boolean;
364
- leavePolicy: string;
365
- };
366
- }[];
367
- [ContributionPointIds.CONFIGURATIONS]: _pooder_core.ConfigurationContribution[];
368
- [ContributionPointIds.COMMANDS]: _pooder_core.CommandContribution[];
369
- };
370
- private createHatchPattern;
371
- private getConfigService;
372
- private hasImageItems;
373
- private buildDielineSpecs;
374
- private buildImageClipEffects;
375
- updateDieline(_emitEvent?: boolean): void;
376
- private updateDielineAsync;
377
- getGeometry(): DielineGeometry | null;
378
- exportCutImage(options?: {
379
- debug?: boolean;
380
- }): Promise<string | null>;
381
- }
382
-
383
- declare function createDielineCommands(tool: any, state: any): CommandContribution[];
384
-
385
- declare function createDielineConfigurations(state: any): ConfigurationContribution[];
386
-
387
249
  interface Point {
388
250
  x: number;
389
251
  y: number;
@@ -513,7 +375,7 @@ type RenderProducer = () => RenderProducerResult | undefined | Promise<RenderPro
513
375
  interface RegisterRenderProducerOptions {
514
376
  priority?: number;
515
377
  }
516
- interface RectLike {
378
+ interface RectLike$1 {
517
379
  left: number;
518
380
  top: number;
519
381
  width: number;
@@ -632,7 +494,7 @@ declare class CanvasService implements Service {
632
494
  width: number;
633
495
  height: number;
634
496
  };
635
- getScreenViewportRect(): RectLike;
497
+ getScreenViewportRect(): RectLike$1;
636
498
  private toSpaceRect;
637
499
  private resolveLayoutLength;
638
500
  private resolveLayoutInsets;
@@ -672,6 +534,14 @@ declare class CanvasService implements Service {
672
534
  private createFabricObject;
673
535
  }
674
536
 
537
+ declare const DIELINE_SHAPES: readonly ["rect", "circle", "ellipse", "heart", "custom"];
538
+ type DielineShape = (typeof DIELINE_SHAPES)[number];
539
+ type ShapeFitMode = "contain" | "stretch";
540
+ interface DielineShapeStyle {
541
+ fitMode: ShapeFitMode;
542
+ [key: string]: unknown;
543
+ }
544
+
675
545
  type CutMode = "trim" | "outset" | "inset";
676
546
  interface SceneRect {
677
547
  left: number;
@@ -740,6 +610,220 @@ interface VisibilityEvalContext {
740
610
  }
741
611
  declare function evaluateVisibilityExpr(expr: VisibilityExpr | undefined, context: VisibilityEvalContext): boolean;
742
612
 
613
+ interface FrameRect {
614
+ left: number;
615
+ top: number;
616
+ width: number;
617
+ height: number;
618
+ }
619
+
620
+ interface SourceSize {
621
+ width: number;
622
+ height: number;
623
+ }
624
+ interface RectLike {
625
+ width: number;
626
+ height: number;
627
+ }
628
+ declare function getCoverScale(frame: RectLike, source: RectLike): number;
629
+
630
+ interface ImageOperationArea {
631
+ width: number;
632
+ height: number;
633
+ centerX: number;
634
+ centerY: number;
635
+ }
636
+ interface ImageOperationViewport {
637
+ left: number;
638
+ top: number;
639
+ width: number;
640
+ height: number;
641
+ }
642
+ type ImageOperationAreaSpec = {
643
+ type: "frame";
644
+ } | {
645
+ type: "viewport";
646
+ } | ({
647
+ type: "custom";
648
+ } & ImageOperationArea);
649
+ type ImageOperation = {
650
+ type: "cover";
651
+ area?: ImageOperationAreaSpec;
652
+ } | {
653
+ type: "contain";
654
+ area?: ImageOperationAreaSpec;
655
+ } | {
656
+ type: "maximizeWidth";
657
+ area?: ImageOperationAreaSpec;
658
+ } | {
659
+ type: "maximizeHeight";
660
+ area?: ImageOperationAreaSpec;
661
+ } | {
662
+ type: "center";
663
+ area?: ImageOperationAreaSpec;
664
+ } | {
665
+ type: "resetTransform";
666
+ };
667
+ interface ComputeImageOperationArgs {
668
+ frame: FrameRect;
669
+ source: SourceSize;
670
+ operation: ImageOperation;
671
+ area: ImageOperationArea;
672
+ }
673
+ declare function resolveImageOperationArea(args: {
674
+ frame: FrameRect;
675
+ viewport: ImageOperationViewport;
676
+ area?: ImageOperationAreaSpec;
677
+ }): ImageOperationArea;
678
+ declare function computeImageOperationUpdates(args: ComputeImageOperationArgs): {
679
+ scale?: number;
680
+ left?: number;
681
+ top?: number;
682
+ angle?: number;
683
+ };
684
+
685
+ declare function hasAnyImageInViewState(state: ImageViewState | null | undefined): boolean;
686
+
687
+ declare class SizeTool implements Extension {
688
+ id: string;
689
+ metadata: {
690
+ name: string;
691
+ };
692
+ private context?;
693
+ private canvasService?;
694
+ activate(context: ExtensionContext): void;
695
+ deactivate(_context: ExtensionContext): void;
696
+ contribute(): {
697
+ [ContributionPointIds.TOOLS]: {
698
+ id: string;
699
+ name: string;
700
+ interaction: string;
701
+ }[];
702
+ [ContributionPointIds.CONFIGURATIONS]: ConfigurationContribution[];
703
+ [ContributionPointIds.COMMANDS]: CommandContribution[];
704
+ };
705
+ private getConfigService;
706
+ private ensureDefaults;
707
+ private emitStateChanged;
708
+ private getStateForUI;
709
+ private updateDimensions;
710
+ private setConstraintMode;
711
+ private setUnit;
712
+ private setCut;
713
+ private getSelectedImageSize;
714
+ }
715
+
716
+ type FeatureOperation = "add" | "subtract";
717
+ type FeatureShape = "rect" | "circle";
718
+ interface DielineFeature {
719
+ id: string;
720
+ groupId?: string;
721
+ operation: FeatureOperation;
722
+ shape: FeatureShape;
723
+ x: number;
724
+ y: number;
725
+ width?: number;
726
+ height?: number;
727
+ radius?: number;
728
+ rotation?: number;
729
+ renderBehavior?: "edge" | "surface";
730
+ color?: string;
731
+ strokeDash?: number[];
732
+ skipCut?: boolean;
733
+ bridge?: {
734
+ type: "vertical";
735
+ };
736
+ }
737
+
738
+ interface DielineGeometry {
739
+ shape: DielineShape;
740
+ shapeStyle: DielineShapeStyle;
741
+ unit: "px";
742
+ x: number;
743
+ y: number;
744
+ width: number;
745
+ height: number;
746
+ radius: number;
747
+ offset: number;
748
+ borderLength?: number;
749
+ scale?: number;
750
+ strokeWidth?: number;
751
+ pathData?: string;
752
+ customSourceWidthPx?: number;
753
+ customSourceHeightPx?: number;
754
+ }
755
+ interface LineStyle {
756
+ width: number;
757
+ color: string;
758
+ dashLength: number;
759
+ style: "solid" | "dashed" | "hidden";
760
+ }
761
+ interface DielineState {
762
+ shape: DielineShape;
763
+ shapeStyle: DielineShapeStyle;
764
+ width: number;
765
+ height: number;
766
+ radius: number;
767
+ offset: number;
768
+ padding: number | string;
769
+ mainLine: LineStyle;
770
+ offsetLine: LineStyle;
771
+ insideColor: string;
772
+ showBleedLines: boolean;
773
+ features: DielineFeature[];
774
+ pathData?: string;
775
+ customSourceWidthPx?: number;
776
+ customSourceHeightPx?: number;
777
+ }
778
+ declare function createDefaultDielineState(): DielineState;
779
+ declare function readDielineState(configService: ConfigurationService, fallback?: Partial<DielineState>): DielineState;
780
+
781
+ declare class DielineTool implements Extension {
782
+ id: string;
783
+ metadata: {
784
+ name: string;
785
+ };
786
+ private state;
787
+ private canvasService?;
788
+ private context?;
789
+ private specs;
790
+ private effects;
791
+ private renderSeq;
792
+ private renderProducerDisposable?;
793
+ private onCanvasResized;
794
+ constructor(options?: Partial<DielineState>);
795
+ activate(context: ExtensionContext): void;
796
+ deactivate(context: ExtensionContext): void;
797
+ contribute(): {
798
+ [ContributionPointIds.TOOLS]: {
799
+ id: string;
800
+ name: string;
801
+ interaction: string;
802
+ session: {
803
+ autoBegin: boolean;
804
+ leavePolicy: string;
805
+ };
806
+ }[];
807
+ [ContributionPointIds.CONFIGURATIONS]: _pooder_core.ConfigurationContribution[];
808
+ [ContributionPointIds.COMMANDS]: _pooder_core.CommandContribution[];
809
+ };
810
+ private createHatchPattern;
811
+ private getConfigService;
812
+ private hasImageItems;
813
+ private buildDielineSpecs;
814
+ private buildImageClipEffects;
815
+ updateDieline(_emitEvent?: boolean): void;
816
+ private updateDielineAsync;
817
+ getGeometry(): DielineGeometry | null;
818
+ exportCutImage(options?: {
819
+ debug?: boolean;
820
+ }): Promise<string | null>;
821
+ }
822
+
823
+ declare function createDielineCommands(tool: any, state: any): CommandContribution[];
824
+
825
+ declare function createDielineConfigurations(state: any): ConfigurationContribution[];
826
+
743
827
  interface ConstraintFeature extends DielineFeature {
744
828
  constraints?: Array<{
745
829
  type: string;
@@ -1062,4 +1146,4 @@ declare function createWhiteInkCommands(tool: any): CommandContribution[];
1062
1146
 
1063
1147
  declare function createWhiteInkConfigurations(): ConfigurationContribution[];
1064
1148
 
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 };
1149
+ export { type BackgroundConfig, type BackgroundFitMode, type BackgroundLayer, type BackgroundLayerKind, type BackgroundRegionUnit, type BackgroundRegistration, type BackgroundRegistrationFrame, type BackgroundRegistrationRegion, BackgroundTool, CanvasService, type ComputeImageOperationArgs, type DielineGeometry, type DielineState, DielineTool, FeatureTool, FilmTool, type ImageItem, type ImageOperation, type ImageOperationArea, type ImageOperationAreaSpec, type ImageOperationViewport, ImageTool, type ImageTransformUpdates, type ImageViewState, 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, computeImageOperationUpdates, getCoverScale as computeWhiteInkCoverScale, createDefaultDielineState, createDielineCommands, createDielineConfigurations, createImageCommands, createImageConfigurations, createWhiteInkCommands, createWhiteInkConfigurations, evaluateVisibilityExpr, hasAnyImageInViewState, readDielineState, resolveImageOperationArea };