@pooder/kit 6.2.2 → 6.3.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.
package/dist/index.d.mts 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,33 @@ 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
+ placementPolicy: ImageSessionPlacementPolicy;
107
+ sessionNotice: ImageSessionNotice | null;
108
+ }
109
+ type ImageSessionPlacementPolicy = "free" | "warn" | "strict";
110
+ interface ImageSessionNotice {
111
+ code: "image-outside-frame";
112
+ level: "warning" | "error";
113
+ message: string;
114
+ imageIds: string[];
115
+ policy: ImageSessionPlacementPolicy;
116
+ }
90
117
  declare class ImageTool implements Extension {
91
118
  id: string;
92
119
  metadata: {
@@ -113,6 +140,7 @@ declare class ImageTool implements Extension {
113
140
  private activeSnapX;
114
141
  private activeSnapY;
115
142
  private movingImageId;
143
+ private sessionNotice;
116
144
  private hasRenderedSnapGuides;
117
145
  private canvasObjectMovingHandler?;
118
146
  private canvasMouseUpHandler?;
@@ -161,6 +189,7 @@ declare class ImageTool implements Extension {
161
189
  interaction: string;
162
190
  commands: {
163
191
  begin: string;
192
+ validate: string;
164
193
  commit: string;
165
194
  rollback: string;
166
195
  };
@@ -175,21 +204,25 @@ declare class ImageTool implements Extension {
175
204
  private normalizeItem;
176
205
  private normalizeItems;
177
206
  private cloneItems;
207
+ private getViewItems;
208
+ private getPlacementPolicy;
209
+ private areSessionNoticesEqual;
210
+ private setSessionNotice;
211
+ private clearSessionNotice;
212
+ private getImageViewState;
213
+ private emitImageStateChange;
178
214
  private emitWorkingChange;
179
215
  private generateId;
180
216
  private hasImageItem;
181
217
  private setImageFocus;
182
218
  private addImageEntry;
183
219
  private upsertImageEntry;
184
- private addItemToWorkingSessionIfNeeded;
185
220
  private updateImage;
186
221
  private getConfig;
187
222
  private applyCommittedItems;
188
223
  private updateConfig;
189
224
  private getFrameRect;
190
225
  private getFrameRectScreen;
191
- private resolveDefaultFitArea;
192
- private fitImageToDefaultArea;
193
226
  private getImageObjects;
194
227
  private getOverlayObjects;
195
228
  private getImageObject;
@@ -200,6 +233,9 @@ declare class ImageTool implements Extension {
200
233
  private ensureSourceSize;
201
234
  private loadImageSize;
202
235
  private getCoverScale;
236
+ private resolvePlacementState;
237
+ private validatePlacementForItem;
238
+ private validateImageSession;
203
239
  private getFrameVisualConfig;
204
240
  private resolveSessionOverlayState;
205
241
  private getCropShapeHatchPattern;
@@ -212,13 +248,16 @@ declare class ImageTool implements Extension {
212
248
  private updateImages;
213
249
  private updateImagesAsync;
214
250
  private clampNormalized;
251
+ private setImageTransform;
252
+ private resetImageSession;
215
253
  private onObjectModified;
216
254
  private updateImageInWorking;
217
255
  private updateImageInConfig;
218
256
  private waitImageLoaded;
219
- private refitImageToFrame;
220
- private fitImageToArea;
257
+ private resolveImageSourceSize;
258
+ private applyImageOperation;
221
259
  private commitWorkingImagesAsCropped;
260
+ private completeImageSession;
222
261
  private exportCroppedImageByIds;
223
262
  private exportUserCroppedImage;
224
263
  }
@@ -227,160 +266,6 @@ declare function createImageCommands(tool: any): CommandContribution[];
227
266
 
228
267
  declare function createImageConfigurations(): ConfigurationContribution[];
229
268
 
230
- interface RectLike$1 {
231
- width: number;
232
- height: number;
233
- }
234
- declare function getCoverScale(frame: RectLike$1, source: RectLike$1): number;
235
-
236
- declare class SizeTool implements Extension {
237
- id: string;
238
- metadata: {
239
- name: string;
240
- };
241
- private context?;
242
- private canvasService?;
243
- activate(context: ExtensionContext): void;
244
- deactivate(_context: ExtensionContext): void;
245
- contribute(): {
246
- [ContributionPointIds.TOOLS]: {
247
- id: string;
248
- name: string;
249
- interaction: string;
250
- }[];
251
- [ContributionPointIds.CONFIGURATIONS]: ConfigurationContribution[];
252
- [ContributionPointIds.COMMANDS]: CommandContribution[];
253
- };
254
- private getConfigService;
255
- private ensureDefaults;
256
- private emitStateChanged;
257
- private getStateForUI;
258
- private updateDimensions;
259
- private setConstraintMode;
260
- private setUnit;
261
- private setCut;
262
- private getSelectedImageSize;
263
- }
264
-
265
- declare const DIELINE_SHAPES: readonly ["rect", "circle", "ellipse", "heart", "custom"];
266
- type DielineShape = (typeof DIELINE_SHAPES)[number];
267
- type ShapeFitMode = "contain" | "stretch";
268
- interface DielineShapeStyle {
269
- fitMode: ShapeFitMode;
270
- [key: string]: unknown;
271
- }
272
-
273
- type FeatureOperation = "add" | "subtract";
274
- type FeatureShape = "rect" | "circle";
275
- interface DielineFeature {
276
- id: string;
277
- groupId?: string;
278
- operation: FeatureOperation;
279
- shape: FeatureShape;
280
- x: number;
281
- y: number;
282
- width?: number;
283
- height?: number;
284
- radius?: number;
285
- rotation?: number;
286
- renderBehavior?: "edge" | "surface";
287
- color?: string;
288
- strokeDash?: number[];
289
- skipCut?: boolean;
290
- bridge?: {
291
- type: "vertical";
292
- };
293
- }
294
-
295
- interface DielineGeometry {
296
- shape: DielineShape;
297
- shapeStyle: DielineShapeStyle;
298
- unit: "px";
299
- x: number;
300
- y: number;
301
- width: number;
302
- height: number;
303
- radius: number;
304
- offset: number;
305
- borderLength?: number;
306
- scale?: number;
307
- strokeWidth?: number;
308
- pathData?: string;
309
- customSourceWidthPx?: number;
310
- customSourceHeightPx?: number;
311
- }
312
- interface LineStyle {
313
- width: number;
314
- color: string;
315
- dashLength: number;
316
- style: "solid" | "dashed" | "hidden";
317
- }
318
- interface DielineState {
319
- shape: DielineShape;
320
- shapeStyle: DielineShapeStyle;
321
- width: number;
322
- height: number;
323
- radius: number;
324
- offset: number;
325
- padding: number | string;
326
- mainLine: LineStyle;
327
- offsetLine: LineStyle;
328
- insideColor: string;
329
- showBleedLines: boolean;
330
- features: DielineFeature[];
331
- pathData?: string;
332
- customSourceWidthPx?: number;
333
- customSourceHeightPx?: number;
334
- }
335
- declare function createDefaultDielineState(): DielineState;
336
- declare function readDielineState(configService: ConfigurationService, fallback?: Partial<DielineState>): DielineState;
337
-
338
- declare class DielineTool implements Extension {
339
- id: string;
340
- metadata: {
341
- name: string;
342
- };
343
- private state;
344
- private canvasService?;
345
- private context?;
346
- private specs;
347
- private effects;
348
- private renderSeq;
349
- private renderProducerDisposable?;
350
- private onCanvasResized;
351
- constructor(options?: Partial<DielineState>);
352
- activate(context: ExtensionContext): void;
353
- deactivate(context: ExtensionContext): void;
354
- contribute(): {
355
- [ContributionPointIds.TOOLS]: {
356
- id: string;
357
- name: string;
358
- interaction: string;
359
- session: {
360
- autoBegin: boolean;
361
- leavePolicy: string;
362
- };
363
- }[];
364
- [ContributionPointIds.CONFIGURATIONS]: _pooder_core.ConfigurationContribution[];
365
- [ContributionPointIds.COMMANDS]: _pooder_core.CommandContribution[];
366
- };
367
- private createHatchPattern;
368
- private getConfigService;
369
- private hasImageItems;
370
- private buildDielineSpecs;
371
- private buildImageClipEffects;
372
- updateDieline(_emitEvent?: boolean): void;
373
- private updateDielineAsync;
374
- getGeometry(): DielineGeometry | null;
375
- exportCutImage(options?: {
376
- debug?: boolean;
377
- }): Promise<string | null>;
378
- }
379
-
380
- declare function createDielineCommands(tool: any, state: any): CommandContribution[];
381
-
382
- declare function createDielineConfigurations(state: any): ConfigurationContribution[];
383
-
384
269
  interface Point {
385
270
  x: number;
386
271
  y: number;
@@ -510,7 +395,7 @@ type RenderProducer = () => RenderProducerResult | undefined | Promise<RenderPro
510
395
  interface RegisterRenderProducerOptions {
511
396
  priority?: number;
512
397
  }
513
- interface RectLike {
398
+ interface RectLike$1 {
514
399
  left: number;
515
400
  top: number;
516
401
  width: number;
@@ -629,7 +514,7 @@ declare class CanvasService implements Service {
629
514
  width: number;
630
515
  height: number;
631
516
  };
632
- getScreenViewportRect(): RectLike;
517
+ getScreenViewportRect(): RectLike$1;
633
518
  private toSpaceRect;
634
519
  private resolveLayoutLength;
635
520
  private resolveLayoutInsets;
@@ -669,6 +554,14 @@ declare class CanvasService implements Service {
669
554
  private createFabricObject;
670
555
  }
671
556
 
557
+ declare const DIELINE_SHAPES: readonly ["rect", "circle", "ellipse", "heart", "custom"];
558
+ type DielineShape = (typeof DIELINE_SHAPES)[number];
559
+ type ShapeFitMode = "contain" | "stretch";
560
+ interface DielineShapeStyle {
561
+ fitMode: ShapeFitMode;
562
+ [key: string]: unknown;
563
+ }
564
+
672
565
  type CutMode = "trim" | "outset" | "inset";
673
566
  interface SceneRect {
674
567
  left: number;
@@ -737,6 +630,220 @@ interface VisibilityEvalContext {
737
630
  }
738
631
  declare function evaluateVisibilityExpr(expr: VisibilityExpr | undefined, context: VisibilityEvalContext): boolean;
739
632
 
633
+ interface FrameRect {
634
+ left: number;
635
+ top: number;
636
+ width: number;
637
+ height: number;
638
+ }
639
+
640
+ interface SourceSize {
641
+ width: number;
642
+ height: number;
643
+ }
644
+ interface RectLike {
645
+ width: number;
646
+ height: number;
647
+ }
648
+ declare function getCoverScale(frame: RectLike, source: RectLike): number;
649
+
650
+ interface ImageOperationArea {
651
+ width: number;
652
+ height: number;
653
+ centerX: number;
654
+ centerY: number;
655
+ }
656
+ interface ImageOperationViewport {
657
+ left: number;
658
+ top: number;
659
+ width: number;
660
+ height: number;
661
+ }
662
+ type ImageOperationAreaSpec = {
663
+ type: "frame";
664
+ } | {
665
+ type: "viewport";
666
+ } | ({
667
+ type: "custom";
668
+ } & ImageOperationArea);
669
+ type ImageOperation = {
670
+ type: "cover";
671
+ area?: ImageOperationAreaSpec;
672
+ } | {
673
+ type: "contain";
674
+ area?: ImageOperationAreaSpec;
675
+ } | {
676
+ type: "maximizeWidth";
677
+ area?: ImageOperationAreaSpec;
678
+ } | {
679
+ type: "maximizeHeight";
680
+ area?: ImageOperationAreaSpec;
681
+ } | {
682
+ type: "center";
683
+ area?: ImageOperationAreaSpec;
684
+ } | {
685
+ type: "resetTransform";
686
+ };
687
+ interface ComputeImageOperationArgs {
688
+ frame: FrameRect;
689
+ source: SourceSize;
690
+ operation: ImageOperation;
691
+ area: ImageOperationArea;
692
+ }
693
+ declare function resolveImageOperationArea(args: {
694
+ frame: FrameRect;
695
+ viewport: ImageOperationViewport;
696
+ area?: ImageOperationAreaSpec;
697
+ }): ImageOperationArea;
698
+ declare function computeImageOperationUpdates(args: ComputeImageOperationArgs): {
699
+ scale?: number;
700
+ left?: number;
701
+ top?: number;
702
+ angle?: number;
703
+ };
704
+
705
+ declare function hasAnyImageInViewState(state: ImageViewState | null | undefined): boolean;
706
+
707
+ declare class SizeTool implements Extension {
708
+ id: string;
709
+ metadata: {
710
+ name: string;
711
+ };
712
+ private context?;
713
+ private canvasService?;
714
+ activate(context: ExtensionContext): void;
715
+ deactivate(_context: ExtensionContext): void;
716
+ contribute(): {
717
+ [ContributionPointIds.TOOLS]: {
718
+ id: string;
719
+ name: string;
720
+ interaction: string;
721
+ }[];
722
+ [ContributionPointIds.CONFIGURATIONS]: ConfigurationContribution[];
723
+ [ContributionPointIds.COMMANDS]: CommandContribution[];
724
+ };
725
+ private getConfigService;
726
+ private ensureDefaults;
727
+ private emitStateChanged;
728
+ private getStateForUI;
729
+ private updateDimensions;
730
+ private setConstraintMode;
731
+ private setUnit;
732
+ private setCut;
733
+ private getSelectedImageSize;
734
+ }
735
+
736
+ type FeatureOperation = "add" | "subtract";
737
+ type FeatureShape = "rect" | "circle";
738
+ interface DielineFeature {
739
+ id: string;
740
+ groupId?: string;
741
+ operation: FeatureOperation;
742
+ shape: FeatureShape;
743
+ x: number;
744
+ y: number;
745
+ width?: number;
746
+ height?: number;
747
+ radius?: number;
748
+ rotation?: number;
749
+ renderBehavior?: "edge" | "surface";
750
+ color?: string;
751
+ strokeDash?: number[];
752
+ skipCut?: boolean;
753
+ bridge?: {
754
+ type: "vertical";
755
+ };
756
+ }
757
+
758
+ interface DielineGeometry {
759
+ shape: DielineShape;
760
+ shapeStyle: DielineShapeStyle;
761
+ unit: "px";
762
+ x: number;
763
+ y: number;
764
+ width: number;
765
+ height: number;
766
+ radius: number;
767
+ offset: number;
768
+ borderLength?: number;
769
+ scale?: number;
770
+ strokeWidth?: number;
771
+ pathData?: string;
772
+ customSourceWidthPx?: number;
773
+ customSourceHeightPx?: number;
774
+ }
775
+ interface LineStyle {
776
+ width: number;
777
+ color: string;
778
+ dashLength: number;
779
+ style: "solid" | "dashed" | "hidden";
780
+ }
781
+ interface DielineState {
782
+ shape: DielineShape;
783
+ shapeStyle: DielineShapeStyle;
784
+ width: number;
785
+ height: number;
786
+ radius: number;
787
+ offset: number;
788
+ padding: number | string;
789
+ mainLine: LineStyle;
790
+ offsetLine: LineStyle;
791
+ insideColor: string;
792
+ showBleedLines: boolean;
793
+ features: DielineFeature[];
794
+ pathData?: string;
795
+ customSourceWidthPx?: number;
796
+ customSourceHeightPx?: number;
797
+ }
798
+ declare function createDefaultDielineState(): DielineState;
799
+ declare function readDielineState(configService: ConfigurationService, fallback?: Partial<DielineState>): DielineState;
800
+
801
+ declare class DielineTool implements Extension {
802
+ id: string;
803
+ metadata: {
804
+ name: string;
805
+ };
806
+ private state;
807
+ private canvasService?;
808
+ private context?;
809
+ private specs;
810
+ private effects;
811
+ private renderSeq;
812
+ private renderProducerDisposable?;
813
+ private onCanvasResized;
814
+ constructor(options?: Partial<DielineState>);
815
+ activate(context: ExtensionContext): void;
816
+ deactivate(context: ExtensionContext): void;
817
+ contribute(): {
818
+ [ContributionPointIds.TOOLS]: {
819
+ id: string;
820
+ name: string;
821
+ interaction: string;
822
+ session: {
823
+ autoBegin: boolean;
824
+ leavePolicy: string;
825
+ };
826
+ }[];
827
+ [ContributionPointIds.CONFIGURATIONS]: _pooder_core.ConfigurationContribution[];
828
+ [ContributionPointIds.COMMANDS]: _pooder_core.CommandContribution[];
829
+ };
830
+ private createHatchPattern;
831
+ private getConfigService;
832
+ private hasImageItems;
833
+ private buildDielineSpecs;
834
+ private buildImageClipEffects;
835
+ updateDieline(_emitEvent?: boolean): void;
836
+ private updateDielineAsync;
837
+ getGeometry(): DielineGeometry | null;
838
+ exportCutImage(options?: {
839
+ debug?: boolean;
840
+ }): Promise<string | null>;
841
+ }
842
+
843
+ declare function createDielineCommands(tool: any, state: any): CommandContribution[];
844
+
845
+ declare function createDielineConfigurations(state: any): ConfigurationContribution[];
846
+
740
847
  interface ConstraintFeature extends DielineFeature {
741
848
  constraints?: Array<{
742
849
  type: string;
@@ -1059,4 +1166,4 @@ declare function createWhiteInkCommands(tool: any): CommandContribution[];
1059
1166
 
1060
1167
  declare function createWhiteInkConfigurations(): ConfigurationContribution[];
1061
1168
 
1062
- 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 };
1169
+ 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, type ImageSessionNotice, type ImageSessionPlacementPolicy, 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 };