@pixerate/editor 0.209.0 → 0.211.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 (46) hide show
  1. package/dist/{chunk-QE7D7TZR.cjs → chunk-H65IBXFI.cjs} +74 -25
  2. package/dist/{chunk-X4LUGTQX.cjs → chunk-L52VMQZS.cjs} +21 -10
  3. package/dist/{chunk-DWYQPL2A.js → chunk-LQ5SALHK.js} +13 -2
  4. package/dist/chunk-MQDIP4CF.cjs +462 -0
  5. package/dist/{chunk-KFIOEOCQ.js → chunk-W3TOZTL7.js} +55 -6
  6. package/dist/chunk-XI2NV5U7.js +462 -0
  7. package/dist/{chunk-3EHPLDFQ.cjs → chunk-YF3YZZ6G.cjs} +16 -453
  8. package/dist/{chunk-USQCKRZG.js → chunk-ZGJGSCUW.js} +8 -445
  9. package/dist/image-editor/content-aware-fill-session.d.cts +109 -0
  10. package/dist/image-editor/content-aware-fill-session.d.ts +109 -0
  11. package/dist/image-editor/controller.d.cts +111 -1
  12. package/dist/image-editor/controller.d.ts +111 -1
  13. package/dist/image-editor/index.cjs +1879 -1052
  14. package/dist/image-editor/index.d.cts +2 -0
  15. package/dist/image-editor/index.d.ts +2 -0
  16. package/dist/image-editor/index.js +869 -42
  17. package/dist/image-editor/layers/serialize.d.cts +5 -8
  18. package/dist/image-editor/layers/serialize.d.ts +5 -8
  19. package/dist/image-editor/paths.d.cts +41 -0
  20. package/dist/image-editor/paths.d.ts +41 -0
  21. package/dist/image-editor/psd/export.d.cts +8 -1
  22. package/dist/image-editor/psd/export.d.ts +8 -1
  23. package/dist/image-editor/psd/import.d.cts +7 -0
  24. package/dist/image-editor/psd/import.d.ts +7 -0
  25. package/dist/image-editor/psd/paths.d.cts +11 -0
  26. package/dist/image-editor/psd/paths.d.ts +11 -0
  27. package/dist/image-editor/selection/gesture.d.cts +10 -2
  28. package/dist/image-editor/selection/gesture.d.ts +10 -2
  29. package/dist/image-editor/selection/select-and-mask.d.cts +5 -0
  30. package/dist/image-editor/selection/select-and-mask.d.ts +5 -0
  31. package/dist/image-editor/selection/worker.d.cts +10 -0
  32. package/dist/image-editor/selection/worker.d.ts +10 -0
  33. package/dist/image-editor/selection-worker.cjs +4 -3
  34. package/dist/image-editor/selection-worker.js +2 -1
  35. package/dist/image-editor/types.d.cts +12 -0
  36. package/dist/image-editor/types.d.ts +12 -0
  37. package/dist/paint/heal.d.cts +3 -1
  38. package/dist/paint/heal.d.ts +3 -1
  39. package/dist/paint/index.cjs +4 -2
  40. package/dist/paint/index.js +10 -8
  41. package/dist/paint-editor/index.cjs +6 -6
  42. package/dist/paint-editor/index.js +1 -1
  43. package/package.json +1 -1
  44. package/skills/pixerate-image-editor/SKILL.md +20 -22
  45. package/skills/pixerate-image-editor/references/layer-effects.md +24 -0
  46. package/skills/pixerate-image-selection-masking/SKILL.md +2 -1
@@ -2,6 +2,7 @@ import { AdjustmentKind, AdjustmentLayer, AdjustmentParamsMap, Annotation, Creat
2
2
  import { type PathToSelectionOptions, type SelectionToPathOptions } from './selection/path.cjs';
3
3
  import { type MagneticEdgeOptions } from './selection/magnetic.cjs';
4
4
  import type { ObjectTarget } from './selection/segment/grabcut.cjs';
5
+ import { type DocumentPath } from './paths.cjs';
5
6
  import { type SelectionJob, type SelectionJobResult, type SelectionWorkerFactory } from './selection/worker.cjs';
6
7
  import type { SelectionProgress } from './selection/segment/work.cjs';
7
8
  import type { FocusAreaOptions } from './selection/segment/focus.cjs';
@@ -488,6 +489,31 @@ export interface ContentAwareFillOptions {
488
489
  sampleRadius?: number;
489
490
  /** Random seed: the same seed gives the same fill (default 0). */
490
491
  seed?: number;
492
+ /**
493
+ * Where the fill may copy from (natural pixels), instead of the automatic ring around the
494
+ * selection: a mask (the Content-Aware Fill workspace's painted area), an alpha channel, or
495
+ * rectangles. `excludeRects` are never copied from, whichever way the area is given.
496
+ */
497
+ samplingArea?: SelectionMask | null;
498
+ samplingChannelId?: string;
499
+ sampleRects?: CropBox[];
500
+ excludeRects?: CropBox[];
501
+ }
502
+ /** What a Content-Aware Fill works on: the selection's window of a pixel layer (see `prepareContentAwareFill`). */
503
+ export interface ContentAwareFillPlan {
504
+ layerId: string;
505
+ /** The window it fills and samples in (document pixels). */
506
+ window: CropBox;
507
+ /** The selection's bounds. */
508
+ bounds: CropBox;
509
+ /** The layer's pixels in the window, RGBA. */
510
+ before: Uint8ClampedArray;
511
+ /** 1 where the selection covers (the hole), per window pixel. */
512
+ hole: Uint8Array;
513
+ /** The selection's coverage 0..255 per window pixel. */
514
+ coverage: Uint8Array;
515
+ /** 1 where the fill may not copy from, per window pixel (null: everywhere outside the hole). */
516
+ exclude: Uint8Array | null;
491
517
  }
492
518
  /** Pixels on the editor's clipboard: RGBA, and where they were copied from (document pixels). */
493
519
  export interface ClipboardImage extends PixelBuffer {
@@ -1062,6 +1088,50 @@ export declare class ImageEditorController {
1062
1088
  pathToSelection(path: VectorMaskPathInput, options?: PathToSelectionOptions & {
1063
1089
  mode?: SelectionMode;
1064
1090
  }): boolean;
1091
+ /** The document's paths: saved paths and the Work Path, in panel order. */
1092
+ getPaths(): readonly DocumentPath[];
1093
+ getPath(id: string): DocumentPath | null;
1094
+ private requirePath;
1095
+ /** Selects a path in the Paths panel (or none). View state: no undo step. */
1096
+ setActivePath(id: string | null): void;
1097
+ private commitPaths;
1098
+ /**
1099
+ * Paths › Make Work Path: the selection's outline, traced, becomes the Work Path (replacing the
1100
+ * last one, unless it was saved). One undo step. Returns the path.
1101
+ */
1102
+ makeWorkPath(options?: SelectionToPathOptions): DocumentPath;
1103
+ /** A new saved path from geometry (`shape`, `subpaths` or `components`). One undo step. */
1104
+ addPath(input: VectorMaskPathInput & {
1105
+ name?: string;
1106
+ }): DocumentPath;
1107
+ /** Replaces a path's geometry (its name is kept). One undo step. */
1108
+ setPathGeometry(id: string, input: VectorMaskPathInput): DocumentPath;
1109
+ /** Renames a path; renaming the Work Path saves it (Photoshop's Save Path). One undo step. */
1110
+ renamePath(id: string, name: string): DocumentPath;
1111
+ /** Duplicates a path as a saved path. One undo step. */
1112
+ duplicatePath(id: string, name?: string): DocumentPath;
1113
+ /** Deletes a path. One undo step. */
1114
+ deletePath(id: string): void;
1115
+ /** The area a path fills over the image, as a selection mask. */
1116
+ private pathArea;
1117
+ /** Paths › Make Selection: loads a path as the selection, combined by `mode`. One undo step. */
1118
+ loadPathAsSelection(id: string, options?: PathToSelectionOptions & {
1119
+ mode?: SelectionMode;
1120
+ }): boolean;
1121
+ /**
1122
+ * Paths › Fill Path: fills the path's area on a pixel layer (default the active one) with a
1123
+ * colour (default the foreground). The selection is not changed. One undo step.
1124
+ */
1125
+ fillPath(id: string, options?: Omit<FillOptions, 'useSelection'>): PaintStrokeResult;
1126
+ /**
1127
+ * Paths › Stroke Path: strokes along the path's outline on a pixel layer (default the active
1128
+ * one), `width` px wide and centred on it. The selection is not changed. One undo step.
1129
+ */
1130
+ strokePath(id: string, options: Omit<StrokeSelectionOptions, 'location'>): PaintStrokeResult;
1131
+ /** Paths › Add Vector Mask: masks a layer (default the active one) with a document path. One undo step. */
1132
+ addVectorMaskFromPath(pathId: string, layerId?: string): VectorMask;
1133
+ /** Runs `fn` with `mask` as the selection, then puts the selection back, all as one undo step. */
1134
+ private withSelection;
1065
1135
  /** Replaces a vector mask's path (its properties are kept). One undo step. Returns the vector mask. */
1066
1136
  setVectorMaskPath(id: string, path: VectorMaskPathInput): VectorMask;
1067
1137
  /** Changes a vector mask's enabled, linked, inverted, density or feather (the path is kept). One undo step. */
@@ -1452,13 +1522,47 @@ export declare class ImageEditorController {
1452
1522
  * (PatchMatch, as the Spot Healing Brush's content-aware mode), blended by the selection's
1453
1523
  * coverage. `output` `current` paints into the layer; `new-layer` puts the fill on a new layer
1454
1524
  * above it. Samples within `sampleRadius` px of the selection (default its larger side, at
1455
- * least 32). Deterministic for a `seed`. One undo step. 8-bit documents only for now.
1525
+ * least 32), or from the given sampling area. Deterministic for a `seed`. One undo step.
1526
+ * 8-bit documents only for now. Runs here; see `contentAwareFillAsync` for the worker.
1456
1527
  */
1457
1528
  contentAwareFill(options?: ContentAwareFillOptions): {
1458
1529
  layerId: string;
1459
1530
  bounds: CropBox;
1460
1531
  output: 'current' | 'new-layer';
1461
1532
  };
1533
+ /**
1534
+ * `contentAwareFill` with the synthesis in the selection worker when there is one, with
1535
+ * `signal` and `onProgress`. The layer is checked again before the result lands.
1536
+ */
1537
+ contentAwareFillAsync(options?: ContentAwareFillOptions & {
1538
+ signal?: AbortSignal;
1539
+ onProgress?: SelectionProgress;
1540
+ }): Promise<{
1541
+ layerId: string;
1542
+ bounds: CropBox;
1543
+ output: 'current' | 'new-layer';
1544
+ }>;
1545
+ /**
1546
+ * The fill without changing anything: the window, its pixels before and after (RGBA, the fill
1547
+ * blended by the selection's coverage) and the sampling area used, for a preview.
1548
+ */
1549
+ previewContentAwareFill(options?: ContentAwareFillOptions & {
1550
+ signal?: AbortSignal;
1551
+ onProgress?: SelectionProgress;
1552
+ }): Promise<{
1553
+ plan: ContentAwareFillPlan;
1554
+ after: Uint8ClampedArray;
1555
+ }>;
1556
+ private synthesiseFill;
1557
+ /**
1558
+ * Checks and gathers what a Content-Aware Fill needs: the selection, the 8-bit pixel layer, the
1559
+ * window around the selection (and the sampling area), and which pixels it may copy from.
1560
+ */
1561
+ prepareContentAwareFill(options?: ContentAwareFillOptions): ContentAwareFillPlan;
1562
+ /** The window's pixels with `filled` blended in by the coverage (`current`), or the fill alone, its alpha by the coverage (`new-layer`). */
1563
+ private blendFill;
1564
+ /** Puts a computed fill into the document as one undo step. */
1565
+ private applyContentAwareFill;
1462
1566
  /** The pixel clipboard (Copy / Cut), or null. */
1463
1567
  private clipboard;
1464
1568
  /** What Copy or Cut last put on the editor's clipboard, or null. */
@@ -1568,6 +1672,12 @@ export declare class ImageEditorController {
1568
1672
  * Returns false when nothing changed.
1569
1673
  */
1570
1674
  setSelection(mask: SelectionMask | null, mode?: SelectionMode): boolean;
1675
+ /**
1676
+ * Shows `mask` in place of the selection while a gesture runs (Quick Selection as the brush
1677
+ * moves; `null` shows nothing selected), or with `undefined` stops. View state only: no undo
1678
+ * step, not saved.
1679
+ */
1680
+ setSelectionPreview(mask: SelectionMask | null | undefined): void;
1571
1681
  /** Select › All. */
1572
1682
  selectAll(): boolean;
1573
1683
  /** Select › Deselect. */
@@ -2,6 +2,7 @@ import { AdjustmentKind, AdjustmentLayer, AdjustmentParamsMap, Annotation, Creat
2
2
  import { type PathToSelectionOptions, type SelectionToPathOptions } from './selection/path.js';
3
3
  import { type MagneticEdgeOptions } from './selection/magnetic.js';
4
4
  import type { ObjectTarget } from './selection/segment/grabcut.js';
5
+ import { type DocumentPath } from './paths.js';
5
6
  import { type SelectionJob, type SelectionJobResult, type SelectionWorkerFactory } from './selection/worker.js';
6
7
  import type { SelectionProgress } from './selection/segment/work.js';
7
8
  import type { FocusAreaOptions } from './selection/segment/focus.js';
@@ -488,6 +489,31 @@ export interface ContentAwareFillOptions {
488
489
  sampleRadius?: number;
489
490
  /** Random seed: the same seed gives the same fill (default 0). */
490
491
  seed?: number;
492
+ /**
493
+ * Where the fill may copy from (natural pixels), instead of the automatic ring around the
494
+ * selection: a mask (the Content-Aware Fill workspace's painted area), an alpha channel, or
495
+ * rectangles. `excludeRects` are never copied from, whichever way the area is given.
496
+ */
497
+ samplingArea?: SelectionMask | null;
498
+ samplingChannelId?: string;
499
+ sampleRects?: CropBox[];
500
+ excludeRects?: CropBox[];
501
+ }
502
+ /** What a Content-Aware Fill works on: the selection's window of a pixel layer (see `prepareContentAwareFill`). */
503
+ export interface ContentAwareFillPlan {
504
+ layerId: string;
505
+ /** The window it fills and samples in (document pixels). */
506
+ window: CropBox;
507
+ /** The selection's bounds. */
508
+ bounds: CropBox;
509
+ /** The layer's pixels in the window, RGBA. */
510
+ before: Uint8ClampedArray;
511
+ /** 1 where the selection covers (the hole), per window pixel. */
512
+ hole: Uint8Array;
513
+ /** The selection's coverage 0..255 per window pixel. */
514
+ coverage: Uint8Array;
515
+ /** 1 where the fill may not copy from, per window pixel (null: everywhere outside the hole). */
516
+ exclude: Uint8Array | null;
491
517
  }
492
518
  /** Pixels on the editor's clipboard: RGBA, and where they were copied from (document pixels). */
493
519
  export interface ClipboardImage extends PixelBuffer {
@@ -1062,6 +1088,50 @@ export declare class ImageEditorController {
1062
1088
  pathToSelection(path: VectorMaskPathInput, options?: PathToSelectionOptions & {
1063
1089
  mode?: SelectionMode;
1064
1090
  }): boolean;
1091
+ /** The document's paths: saved paths and the Work Path, in panel order. */
1092
+ getPaths(): readonly DocumentPath[];
1093
+ getPath(id: string): DocumentPath | null;
1094
+ private requirePath;
1095
+ /** Selects a path in the Paths panel (or none). View state: no undo step. */
1096
+ setActivePath(id: string | null): void;
1097
+ private commitPaths;
1098
+ /**
1099
+ * Paths › Make Work Path: the selection's outline, traced, becomes the Work Path (replacing the
1100
+ * last one, unless it was saved). One undo step. Returns the path.
1101
+ */
1102
+ makeWorkPath(options?: SelectionToPathOptions): DocumentPath;
1103
+ /** A new saved path from geometry (`shape`, `subpaths` or `components`). One undo step. */
1104
+ addPath(input: VectorMaskPathInput & {
1105
+ name?: string;
1106
+ }): DocumentPath;
1107
+ /** Replaces a path's geometry (its name is kept). One undo step. */
1108
+ setPathGeometry(id: string, input: VectorMaskPathInput): DocumentPath;
1109
+ /** Renames a path; renaming the Work Path saves it (Photoshop's Save Path). One undo step. */
1110
+ renamePath(id: string, name: string): DocumentPath;
1111
+ /** Duplicates a path as a saved path. One undo step. */
1112
+ duplicatePath(id: string, name?: string): DocumentPath;
1113
+ /** Deletes a path. One undo step. */
1114
+ deletePath(id: string): void;
1115
+ /** The area a path fills over the image, as a selection mask. */
1116
+ private pathArea;
1117
+ /** Paths › Make Selection: loads a path as the selection, combined by `mode`. One undo step. */
1118
+ loadPathAsSelection(id: string, options?: PathToSelectionOptions & {
1119
+ mode?: SelectionMode;
1120
+ }): boolean;
1121
+ /**
1122
+ * Paths › Fill Path: fills the path's area on a pixel layer (default the active one) with a
1123
+ * colour (default the foreground). The selection is not changed. One undo step.
1124
+ */
1125
+ fillPath(id: string, options?: Omit<FillOptions, 'useSelection'>): PaintStrokeResult;
1126
+ /**
1127
+ * Paths › Stroke Path: strokes along the path's outline on a pixel layer (default the active
1128
+ * one), `width` px wide and centred on it. The selection is not changed. One undo step.
1129
+ */
1130
+ strokePath(id: string, options: Omit<StrokeSelectionOptions, 'location'>): PaintStrokeResult;
1131
+ /** Paths › Add Vector Mask: masks a layer (default the active one) with a document path. One undo step. */
1132
+ addVectorMaskFromPath(pathId: string, layerId?: string): VectorMask;
1133
+ /** Runs `fn` with `mask` as the selection, then puts the selection back, all as one undo step. */
1134
+ private withSelection;
1065
1135
  /** Replaces a vector mask's path (its properties are kept). One undo step. Returns the vector mask. */
1066
1136
  setVectorMaskPath(id: string, path: VectorMaskPathInput): VectorMask;
1067
1137
  /** Changes a vector mask's enabled, linked, inverted, density or feather (the path is kept). One undo step. */
@@ -1452,13 +1522,47 @@ export declare class ImageEditorController {
1452
1522
  * (PatchMatch, as the Spot Healing Brush's content-aware mode), blended by the selection's
1453
1523
  * coverage. `output` `current` paints into the layer; `new-layer` puts the fill on a new layer
1454
1524
  * above it. Samples within `sampleRadius` px of the selection (default its larger side, at
1455
- * least 32). Deterministic for a `seed`. One undo step. 8-bit documents only for now.
1525
+ * least 32), or from the given sampling area. Deterministic for a `seed`. One undo step.
1526
+ * 8-bit documents only for now. Runs here; see `contentAwareFillAsync` for the worker.
1456
1527
  */
1457
1528
  contentAwareFill(options?: ContentAwareFillOptions): {
1458
1529
  layerId: string;
1459
1530
  bounds: CropBox;
1460
1531
  output: 'current' | 'new-layer';
1461
1532
  };
1533
+ /**
1534
+ * `contentAwareFill` with the synthesis in the selection worker when there is one, with
1535
+ * `signal` and `onProgress`. The layer is checked again before the result lands.
1536
+ */
1537
+ contentAwareFillAsync(options?: ContentAwareFillOptions & {
1538
+ signal?: AbortSignal;
1539
+ onProgress?: SelectionProgress;
1540
+ }): Promise<{
1541
+ layerId: string;
1542
+ bounds: CropBox;
1543
+ output: 'current' | 'new-layer';
1544
+ }>;
1545
+ /**
1546
+ * The fill without changing anything: the window, its pixels before and after (RGBA, the fill
1547
+ * blended by the selection's coverage) and the sampling area used, for a preview.
1548
+ */
1549
+ previewContentAwareFill(options?: ContentAwareFillOptions & {
1550
+ signal?: AbortSignal;
1551
+ onProgress?: SelectionProgress;
1552
+ }): Promise<{
1553
+ plan: ContentAwareFillPlan;
1554
+ after: Uint8ClampedArray;
1555
+ }>;
1556
+ private synthesiseFill;
1557
+ /**
1558
+ * Checks and gathers what a Content-Aware Fill needs: the selection, the 8-bit pixel layer, the
1559
+ * window around the selection (and the sampling area), and which pixels it may copy from.
1560
+ */
1561
+ prepareContentAwareFill(options?: ContentAwareFillOptions): ContentAwareFillPlan;
1562
+ /** The window's pixels with `filled` blended in by the coverage (`current`), or the fill alone, its alpha by the coverage (`new-layer`). */
1563
+ private blendFill;
1564
+ /** Puts a computed fill into the document as one undo step. */
1565
+ private applyContentAwareFill;
1462
1566
  /** The pixel clipboard (Copy / Cut), or null. */
1463
1567
  private clipboard;
1464
1568
  /** What Copy or Cut last put on the editor's clipboard, or null. */
@@ -1568,6 +1672,12 @@ export declare class ImageEditorController {
1568
1672
  * Returns false when nothing changed.
1569
1673
  */
1570
1674
  setSelection(mask: SelectionMask | null, mode?: SelectionMode): boolean;
1675
+ /**
1676
+ * Shows `mask` in place of the selection while a gesture runs (Quick Selection as the brush
1677
+ * moves; `null` shows nothing selected), or with `undefined` stops. View state only: no undo
1678
+ * step, not saved.
1679
+ */
1680
+ setSelectionPreview(mask: SelectionMask | null | undefined): void;
1571
1681
  /** Select › All. */
1572
1682
  selectAll(): boolean;
1573
1683
  /** Select › Deselect. */