@pixerate/editor 0.89.0 → 0.90.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/image-editor/index.cjs +2770 -176
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +439 -8
- package/dist/image-editor/index.d.ts +439 -8
- package/dist/image-editor/index.js +2653 -59
- package/dist/image-editor/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -291,6 +291,31 @@ declare function serializeLayers(layers: readonly ImageLayer[]): {
|
|
|
291
291
|
layers: SerializedLayer[];
|
|
292
292
|
assets: Record<string, string>;
|
|
293
293
|
};
|
|
294
|
+
/**
|
|
295
|
+
* Where a host keeps layer pixels outside the JSON (`toJSON({ assets: 'external', store })`):
|
|
296
|
+
* `put` stores a PNG and returns a reference (a URL, a key) that `get` resolves later.
|
|
297
|
+
*/
|
|
298
|
+
interface ImageEditorAssetStore {
|
|
299
|
+
put(blob: Blob, info: {
|
|
300
|
+
id: string;
|
|
301
|
+
width: number;
|
|
302
|
+
height: number;
|
|
303
|
+
}): Promise<string>;
|
|
304
|
+
get(ref: string): Promise<Blob>;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Serializes a layer tree with its assets in `store`: each PNG is uploaded once per store (by
|
|
308
|
+
* content), and `assets` maps asset ids to the store's references.
|
|
309
|
+
*/
|
|
310
|
+
declare function serializeLayersExternal(layers: readonly ImageLayer[], store: ImageEditorAssetStore): Promise<{
|
|
311
|
+
layers: SerializedLayer[];
|
|
312
|
+
assets: Record<string, string>;
|
|
313
|
+
}>;
|
|
314
|
+
/**
|
|
315
|
+
* Turns external asset references back into data URLs through `store.get` (data URLs pass through),
|
|
316
|
+
* so the document loads like an inline one. References that fail are reported and left out.
|
|
317
|
+
*/
|
|
318
|
+
declare function resolveExternalAssets(assets: Record<string, string>, store: ImageEditorAssetStore | undefined, problems: string[]): Promise<Record<string, string>>;
|
|
294
319
|
interface DeserializeContext {
|
|
295
320
|
assets: Record<string, string>;
|
|
296
321
|
/** Decodes an asset (PNG data URL by default). Throw for an unusable asset. */
|
|
@@ -984,6 +1009,151 @@ declare function parseBlend(value: unknown, allowPassThrough?: boolean): BlendMo
|
|
|
984
1009
|
/** The union of two rectangles (either may be null). */
|
|
985
1010
|
declare function unionRect(a: CropBox | null, b: CropBox | null): CropBox | null;
|
|
986
1011
|
|
|
1012
|
+
interface PlaneLayout {
|
|
1013
|
+
planes: number;
|
|
1014
|
+
width: number;
|
|
1015
|
+
height: number;
|
|
1016
|
+
depth: number;
|
|
1017
|
+
/** PSB: RLE row counts are 4 bytes. */
|
|
1018
|
+
psb: boolean;
|
|
1019
|
+
}
|
|
1020
|
+
/** Decodes planar channel data (`planes` planes of `height` rows each). */
|
|
1021
|
+
declare function decodePlanes(compression: number, data: Uint8Array, l: PlaneLayout): Uint8Array;
|
|
1022
|
+
/** RLE-encodes planar data: row counts (u16, or u32 in PSB), then the packed rows. */
|
|
1023
|
+
declare function encodeRle(decoded: Uint8Array, l: PlaneLayout): Uint8Array;
|
|
1024
|
+
|
|
1025
|
+
interface PsdHeader {
|
|
1026
|
+
psb: boolean;
|
|
1027
|
+
channels: number;
|
|
1028
|
+
height: number;
|
|
1029
|
+
width: number;
|
|
1030
|
+
depth: number;
|
|
1031
|
+
colorMode: number;
|
|
1032
|
+
}
|
|
1033
|
+
interface PsdRect {
|
|
1034
|
+
top: number;
|
|
1035
|
+
left: number;
|
|
1036
|
+
bottom: number;
|
|
1037
|
+
right: number;
|
|
1038
|
+
}
|
|
1039
|
+
interface PsdChannel {
|
|
1040
|
+
id: number;
|
|
1041
|
+
/** `null` for a zero-length channel. */
|
|
1042
|
+
compression: number | null;
|
|
1043
|
+
/** Encoded bytes, without the compression field. */
|
|
1044
|
+
data: Uint8Array;
|
|
1045
|
+
}
|
|
1046
|
+
interface PsdLayerMask {
|
|
1047
|
+
rect: PsdRect;
|
|
1048
|
+
defaultColor: number;
|
|
1049
|
+
flags: number;
|
|
1050
|
+
userDensity?: number;
|
|
1051
|
+
userFeather?: number;
|
|
1052
|
+
vectorDensity?: number;
|
|
1053
|
+
vectorFeather?: number;
|
|
1054
|
+
/** The real (vector-combined) user mask, when present. */
|
|
1055
|
+
real?: {
|
|
1056
|
+
flags: number;
|
|
1057
|
+
background: number;
|
|
1058
|
+
rect: PsdRect;
|
|
1059
|
+
};
|
|
1060
|
+
}
|
|
1061
|
+
interface PsdTaggedBlock {
|
|
1062
|
+
key: string;
|
|
1063
|
+
data: Uint8Array;
|
|
1064
|
+
}
|
|
1065
|
+
interface PsdLayerRecord {
|
|
1066
|
+
rect: PsdRect;
|
|
1067
|
+
channels: PsdChannel[];
|
|
1068
|
+
blendKey: string;
|
|
1069
|
+
opacity: number;
|
|
1070
|
+
clipping: number;
|
|
1071
|
+
flags: number;
|
|
1072
|
+
mask?: PsdLayerMask;
|
|
1073
|
+
/** The legacy (Pascal) name; `layerName` prefers `luni`. */
|
|
1074
|
+
legacyName: string;
|
|
1075
|
+
blocks: PsdTaggedBlock[];
|
|
1076
|
+
}
|
|
1077
|
+
interface PsdResource {
|
|
1078
|
+
id: number;
|
|
1079
|
+
name: string;
|
|
1080
|
+
data: Uint8Array;
|
|
1081
|
+
}
|
|
1082
|
+
interface PsdFile {
|
|
1083
|
+
header: PsdHeader;
|
|
1084
|
+
colorModeData: Uint8Array;
|
|
1085
|
+
resources: PsdResource[];
|
|
1086
|
+
/** Bottom-most first, as stored. */
|
|
1087
|
+
layers: PsdLayerRecord[];
|
|
1088
|
+
/** The layer count was negative: the merged image's first extra channel is its alpha. */
|
|
1089
|
+
mergedAlpha: boolean;
|
|
1090
|
+
globalBlocks: PsdTaggedBlock[];
|
|
1091
|
+
imageCompression: number;
|
|
1092
|
+
imageData: Uint8Array;
|
|
1093
|
+
}
|
|
1094
|
+
/** Parses a PSD or PSB. Throws `PsdError` with what was wrong. */
|
|
1095
|
+
declare function readPsd(bytes: Uint8Array): PsdFile;
|
|
1096
|
+
declare function layerName(rec: PsdLayerRecord): string;
|
|
1097
|
+
interface PsdTreeNode {
|
|
1098
|
+
/** Index into `PsdFile.layers` (the folder record for a group). */
|
|
1099
|
+
index: number;
|
|
1100
|
+
children?: PsdTreeNode[];
|
|
1101
|
+
}
|
|
1102
|
+
/** The layer tree, bottom-most first (the stored order, as in our model), from the `lsct` dividers. */
|
|
1103
|
+
declare function layerTree(file: PsdFile): PsdTreeNode[];
|
|
1104
|
+
/** One layer channel decoded to `depth`-bit planar bytes, or `undefined` if the layer has none. */
|
|
1105
|
+
declare function decodeLayerChannel(file: PsdFile, rec: PsdLayerRecord, id: number): Uint8Array | undefined;
|
|
1106
|
+
/** The merged image's channels decoded, planar. */
|
|
1107
|
+
declare function decodeMergedImage(file: PsdFile): Uint8Array;
|
|
1108
|
+
/** Serializes a file. Channel data must already be encoded; `encodeName` writes legacy (Pascal) names. */
|
|
1109
|
+
declare function writePsd(file: PsdFile, encodeName: (s: string) => Uint8Array): Uint8Array;
|
|
1110
|
+
|
|
1111
|
+
/** PSD blend keys → our blend modes (`diss` is the one we lack). */
|
|
1112
|
+
declare const PSD_BLEND_KEYS: Record<string, LayerBlendMode>;
|
|
1113
|
+
/** What happened to one PSD layer on import. */
|
|
1114
|
+
interface PsdLayerSummary {
|
|
1115
|
+
name: string;
|
|
1116
|
+
/** Our layer type, or `null` when the layer was dropped. */
|
|
1117
|
+
type: 'pixel' | 'adjustment' | 'group' | null;
|
|
1118
|
+
/** `mapped`: held exactly; `approximated`: imported with losses; `dropped`: left out. */
|
|
1119
|
+
status: 'mapped' | 'approximated' | 'dropped';
|
|
1120
|
+
/** What Photoshop calls it (`pixel`, `type`, `smart-object`, `fill`, `shape`, `Levels` …). */
|
|
1121
|
+
psdKind: string;
|
|
1122
|
+
/** Why it is not `mapped`. */
|
|
1123
|
+
notes: string[];
|
|
1124
|
+
/** Our layer id (when imported). */
|
|
1125
|
+
id?: string;
|
|
1126
|
+
depth: number;
|
|
1127
|
+
}
|
|
1128
|
+
interface PsdImportResult {
|
|
1129
|
+
width: number;
|
|
1130
|
+
height: number;
|
|
1131
|
+
/** Bottom to top, as in our model. */
|
|
1132
|
+
layers: ImageLayer[];
|
|
1133
|
+
/** One sentence per problem, naming the affected layers. */
|
|
1134
|
+
warnings: string[];
|
|
1135
|
+
/** Every PSD layer, bottom first, a group before its children. */
|
|
1136
|
+
summary: PsdLayerSummary[];
|
|
1137
|
+
/** Pixels per inch, when the file says. */
|
|
1138
|
+
resolution?: number;
|
|
1139
|
+
info: {
|
|
1140
|
+
psb: boolean;
|
|
1141
|
+
depth: number;
|
|
1142
|
+
colorMode: string;
|
|
1143
|
+
channels: number;
|
|
1144
|
+
};
|
|
1145
|
+
}
|
|
1146
|
+
interface PsdImportOptions {
|
|
1147
|
+
/** Makes layer ids (defaults to `psd-<n>`). */
|
|
1148
|
+
newId?: (hint: string) => string;
|
|
1149
|
+
/** Skip decoding pixels (inspection only). */
|
|
1150
|
+
skipPixels?: boolean;
|
|
1151
|
+
}
|
|
1152
|
+
/** Maps a parsed PSD to our layers. */
|
|
1153
|
+
declare function psdToLayers(file: PsdFile, options?: PsdImportOptions): PsdImportResult;
|
|
1154
|
+
/** Parses and maps PSD / PSB bytes. Throws `PsdError` for files that cannot be read at all. */
|
|
1155
|
+
declare function importPsd(bytes: Uint8Array, options?: PsdImportOptions): PsdImportResult;
|
|
1156
|
+
|
|
987
1157
|
/** Latest serialized schema version (`3`: layers). Documents with the old shape still write 1 or 2. */
|
|
988
1158
|
declare const IMAGE_EDITOR_SCHEMA_VERSION: 3;
|
|
989
1159
|
/** Changes to an adjustment layer; `params` is merged into the current parameters. */
|
|
@@ -1003,8 +1173,18 @@ interface SelectionCommandOptions {
|
|
|
1003
1173
|
/** Feather the new shape by this many pixels before combining (default 0). */
|
|
1004
1174
|
feather?: number;
|
|
1005
1175
|
}
|
|
1176
|
+
/** Where an AI result goes (see `applyInpaintedImage`, `applyBackgroundRemovedImage`). */
|
|
1177
|
+
interface AIResultOptions {
|
|
1178
|
+
/** `new-layer`: a new layer (inpainting) or a mask (background removal); `replace`: the Background's pixels. Default: by `isMultiLayer`. */
|
|
1179
|
+
target?: 'new-layer' | 'replace';
|
|
1180
|
+
}
|
|
1006
1181
|
/** Where the selection tools read colours from. */
|
|
1007
1182
|
interface SampleOptions {
|
|
1183
|
+
/**
|
|
1184
|
+
* `composite` (default): the image, as before (with several layers: the composite of the pixel
|
|
1185
|
+
* layers, or with `sampleMerged` of every layer); `active-layer`: only the active pixel layer.
|
|
1186
|
+
*/
|
|
1187
|
+
sample?: 'composite' | 'active-layer';
|
|
1008
1188
|
/** Sample the adjusted image (base adjustments and layers) instead of the source pixels. */
|
|
1009
1189
|
sampleMerged?: boolean;
|
|
1010
1190
|
/** Pixels to use instead of reading the source image (natural size, RGBA). */
|
|
@@ -1574,6 +1754,13 @@ declare class ImageEditorController {
|
|
|
1574
1754
|
setPan(pan: ImagePoint): void;
|
|
1575
1755
|
setComparing(comparing: boolean): void;
|
|
1576
1756
|
setFit(fit: ImageEditorFit): void;
|
|
1757
|
+
private blankSource;
|
|
1758
|
+
/**
|
|
1759
|
+
* What the renderer draws from: the source image, or, for a document without one (an opened
|
|
1760
|
+
* PSD, a v3 document loaded on its own), a transparent canvas of the document size, since every
|
|
1761
|
+
* pixel then comes from the layers. `null` when there is nothing to draw.
|
|
1762
|
+
*/
|
|
1763
|
+
private drawSource;
|
|
1577
1764
|
render(targetCanvas: HTMLCanvasElement, options?: RenderOptions): Promise<void>;
|
|
1578
1765
|
renderExport(options?: ExportOptions): Promise<HTMLCanvasElement>;
|
|
1579
1766
|
/**
|
|
@@ -1604,17 +1791,72 @@ declare class ImageEditorController {
|
|
|
1604
1791
|
* and the space that `applyInpaintedImage` / `applyBackgroundRemovedImage` expect back.
|
|
1605
1792
|
*/
|
|
1606
1793
|
renderSource(): Promise<HTMLCanvasElement>;
|
|
1794
|
+
/**
|
|
1795
|
+
* The image an AI hook should edit: the source (`toSourceDataURL`) when results replace the
|
|
1796
|
+
* Background, or the composite of the layers without annotations, in the source frame, when
|
|
1797
|
+
* they go to a new layer or mask (see `applyInpaintedImage`).
|
|
1798
|
+
*/
|
|
1799
|
+
toAIInputDataURL(options?: AIResultOptions): Promise<string>;
|
|
1607
1800
|
toSourceDataURL(options?: Pick<ExportOptions, 'format' | 'quality'>): Promise<string>;
|
|
1608
1801
|
/**
|
|
1609
|
-
*
|
|
1610
|
-
*
|
|
1802
|
+
* Whether AI results go to layers: the document has more than one pixel layer or group (adjustment
|
|
1803
|
+
* and annotation layers are edits of the image, not images of their own).
|
|
1611
1804
|
*/
|
|
1612
|
-
|
|
1805
|
+
/** `new-layer` in multi-layer documents and documents without a source image, else `replace`. */
|
|
1806
|
+
private defaultAITarget;
|
|
1807
|
+
/** No source image, and no layer reading one (an opened PSD): the layers are the whole document. */
|
|
1808
|
+
private isSourceless;
|
|
1809
|
+
get isMultiLayer(): boolean;
|
|
1613
1810
|
/**
|
|
1614
|
-
*
|
|
1615
|
-
*
|
|
1811
|
+
* Applies an inpainted result (natural image space, see `toSourceDataURL`) as ONE undoable step.
|
|
1812
|
+
* In a document with several layers (see `isMultiLayer`), or with `target: 'new-layer'`, the
|
|
1813
|
+
* result goes to a new pixel layer above the active layer, limited to the selection. Otherwise
|
|
1814
|
+
* (`target: 'replace'`, the single-layer default) it replaces the Background's pixels and clears
|
|
1815
|
+
* the mask annotations, as before. Resolves to the new layer's id in new-layer mode.
|
|
1616
1816
|
*/
|
|
1617
|
-
|
|
1817
|
+
applyInpaintedImage(newDataUrl: string, options?: AIResultOptions): Promise<string | void>;
|
|
1818
|
+
/**
|
|
1819
|
+
* Applies a background-removed result as ONE undoable step. In a document with several layers
|
|
1820
|
+
* (or with `target: 'new-layer'`) the result's alpha becomes the mask of the active pixel layer
|
|
1821
|
+
* (or the Background), replacing its mask. Otherwise (`target: 'replace'`, the single-layer
|
|
1822
|
+
* default) it replaces the Background's pixels; crop and annotations are kept (rescaled if the
|
|
1823
|
+
* new image has different dimensions). Resolves to the masked layer's id in mask mode.
|
|
1824
|
+
*/
|
|
1825
|
+
applyBackgroundRemovedImage(newDataUrl: string, options?: AIResultOptions): Promise<string | void>;
|
|
1826
|
+
/**
|
|
1827
|
+
* Rasterize Layer: an annotation layer becomes a pixel layer with the same id, name and
|
|
1828
|
+
* properties (needs a canvas), and a pixel layer's filters are baked into its pixels. One undo
|
|
1829
|
+
* step. Returns the layer id.
|
|
1830
|
+
*/
|
|
1831
|
+
rasterizeLayer(id: string): Promise<string>;
|
|
1832
|
+
/** Pixels per inch of the last opened PSD (written back by `toPsd`). */
|
|
1833
|
+
private psdResolution;
|
|
1834
|
+
/**
|
|
1835
|
+
* Opens PSD / PSB bytes as the document (one undo step): the layers replace the stack and the
|
|
1836
|
+
* document has no source image afterwards (every pixel comes from the layers). What the model
|
|
1837
|
+
* cannot hold is approximated or left out; `warnings` says what, naming the layers.
|
|
1838
|
+
* Throws `PsdError` for files that cannot be read at all.
|
|
1839
|
+
*/
|
|
1840
|
+
loadPsd(bytes: Uint8Array): {
|
|
1841
|
+
layerIds: string[];
|
|
1842
|
+
warnings: string[];
|
|
1843
|
+
width: number;
|
|
1844
|
+
height: number;
|
|
1845
|
+
summary: PsdImportResult['summary'];
|
|
1846
|
+
};
|
|
1847
|
+
/**
|
|
1848
|
+
* The document as an 8-bit RGB PSD (PSB above 30 000 px) with real layers, groups, adjustment
|
|
1849
|
+
* layers and masks, in the source frame. Layer filters and parametric (depth) masks are baked
|
|
1850
|
+
* into pixels and masks, annotation layers are rasterized (in a browser; elsewhere they are left
|
|
1851
|
+
* out), and the merged image is our composite. `warnings` lists every such change.
|
|
1852
|
+
*/
|
|
1853
|
+
toPsd(): Promise<{
|
|
1854
|
+
bytes: Uint8Array;
|
|
1855
|
+
warnings: string[];
|
|
1856
|
+
psb: boolean;
|
|
1857
|
+
width: number;
|
|
1858
|
+
height: number;
|
|
1859
|
+
}>;
|
|
1618
1860
|
private replaceSource;
|
|
1619
1861
|
/**
|
|
1620
1862
|
* The serializable state. A document whose layers still have the v1 / v2 shape (the
|
|
@@ -1623,6 +1865,22 @@ declare class ImageEditorController {
|
|
|
1623
1865
|
* assets. `selection` is included (run-length encoded) only when something is selected.
|
|
1624
1866
|
*/
|
|
1625
1867
|
toJSON(): SerializedImageEditorState;
|
|
1868
|
+
/**
|
|
1869
|
+
* With `assets: 'external'`, layer pixels go to `store` (each PNG uploaded once per store) and
|
|
1870
|
+
* the v3 document holds the store's references. Old-shape documents have no assets either way.
|
|
1871
|
+
*/
|
|
1872
|
+
toJSON(options: {
|
|
1873
|
+
assets: 'external';
|
|
1874
|
+
store: ImageEditorAssetStore;
|
|
1875
|
+
}): Promise<SerializedImageEditorState>;
|
|
1876
|
+
/**
|
|
1877
|
+
* Loads a stored state whose v3 assets may live in an asset store (references other than data
|
|
1878
|
+
* URLs are fetched with `store.get`), as one undo step. Assets that cannot be fetched are left
|
|
1879
|
+
* out and listed in `lastLoadProblems`.
|
|
1880
|
+
*/
|
|
1881
|
+
loadJSONAsync(data: SerializedImageEditorState, options?: {
|
|
1882
|
+
store?: ImageEditorAssetStore;
|
|
1883
|
+
}): Promise<void>;
|
|
1626
1884
|
/** Loads a stored state of any version (one undo step). */
|
|
1627
1885
|
loadJSON(data: SerializedImageEditorState): void;
|
|
1628
1886
|
/** Problems found by the last `loadJSON` / `initialState` of a v3 document (unreadable layers or assets). */
|
|
@@ -1630,6 +1888,8 @@ declare class ImageEditorController {
|
|
|
1630
1888
|
private applyStored;
|
|
1631
1889
|
private serializeState;
|
|
1632
1890
|
}
|
|
1891
|
+
/** Bilinear resample of RGBA pixels to `width × height`. */
|
|
1892
|
+
declare function resizePixels(px: PixelBuffer, width: number, height: number): PixelBuffer;
|
|
1633
1893
|
/** A colour as RGBA bytes: `#rgb`, `#rrggbb`, `#rrggbbaa` or `[r, g, b, a?]` (0..255). */
|
|
1634
1894
|
declare function parseColor(value: string | number[]): [number, number, number, number];
|
|
1635
1895
|
/** `#rrggbb` of RGBA bytes (alpha dropped). */
|
|
@@ -2301,6 +2561,10 @@ declare function colorBalanceChannel(tones: readonly [readonly number[], readonl
|
|
|
2301
2561
|
* blues, magentas).
|
|
2302
2562
|
*/
|
|
2303
2563
|
declare function blackWhiteGray(c: readonly number[], weights: readonly number[]): number;
|
|
2564
|
+
/** D50 white (ICC PCS). */
|
|
2565
|
+
declare const D50: readonly [0.96422, 1, 0.82521];
|
|
2566
|
+
/** D50 XYZ → linear sRGB. */
|
|
2567
|
+
declare const XYZ_D50_TO_SRGB: readonly [readonly [3.133856, -1.616867, -0.490615], readonly [-0.978768, 1.916142, 0.033454], readonly [0.071945, -0.228991, 1.405243]];
|
|
2304
2568
|
/**
|
|
2305
2569
|
* Photo Filter's linear-light RGB matrix (row-major 3×3): the pixel's D50 XYZ, relative to white,
|
|
2306
2570
|
* multiplied by the filter colour's mixed in by `density` (0..1). `normalizeY` keeps luminance Y.
|
|
@@ -2511,6 +2775,8 @@ interface SelectionToolOptions {
|
|
|
2511
2775
|
antiAlias: boolean;
|
|
2512
2776
|
/** Sample the adjusted image instead of the source. */
|
|
2513
2777
|
sampleMerged: boolean;
|
|
2778
|
+
/** Sample the whole image (`composite`, default) or only the active pixel layer. */
|
|
2779
|
+
sample?: 'composite' | 'active-layer';
|
|
2514
2780
|
distance: ColorDistance;
|
|
2515
2781
|
}
|
|
2516
2782
|
declare const DEFAULT_SELECTION_TOOL_OPTIONS: SelectionToolOptions;
|
|
@@ -2841,7 +3107,7 @@ type DropZone = 'above' | 'below' | 'inside';
|
|
|
2841
3107
|
declare function dropZone(fraction: number, isGroup: boolean): DropZone;
|
|
2842
3108
|
/** The placement for `move_layer` when `dragId` is dropped on row `targetId` in `zone`, or `null` for a no-op. */
|
|
2843
3109
|
declare function dropPlacement(layers: readonly ImageLayer[], dragId: string, targetId: string, zone: DropZone): LayerPlacement | null;
|
|
2844
|
-
type LayerMenuAction = 'new-layer' | 'new-group' | 'duplicate' | 'delete' | 'group-selected' | 'ungroup' | 'merge-down' | 'merge-visible' | 'flatten' | 'via-copy' | 'via-cut' | 'add-mask' | 'add-mask-selection' | 'apply-mask' | 'delete-mask' | 'toggle-mask' | 'toggle-clip';
|
|
3110
|
+
type LayerMenuAction = 'new-layer' | 'new-group' | 'duplicate' | 'delete' | 'group-selected' | 'ungroup' | 'merge-down' | 'merge-visible' | 'flatten' | 'via-copy' | 'via-cut' | 'add-mask' | 'add-mask-selection' | 'apply-mask' | 'delete-mask' | 'toggle-mask' | 'toggle-clip' | 'rasterize';
|
|
2845
3111
|
interface LayerMenuItem {
|
|
2846
3112
|
action: LayerMenuAction;
|
|
2847
3113
|
label: string;
|
|
@@ -2929,4 +3195,169 @@ declare class PaintGesture {
|
|
|
2929
3195
|
cancel(): void;
|
|
2930
3196
|
}
|
|
2931
3197
|
|
|
2932
|
-
|
|
3198
|
+
/** A malformed or unsupported PSD; the message says what was wrong and where. */
|
|
3199
|
+
declare class PsdError extends Error {
|
|
3200
|
+
constructor(message: string);
|
|
3201
|
+
}
|
|
3202
|
+
|
|
3203
|
+
/**
|
|
3204
|
+
* Photoshop ActionDescriptors (the structured values inside `vibA`, `blwh` and other blocks):
|
|
3205
|
+
* read and write. Keys and class ids are 4-character codes, or longer strings.
|
|
3206
|
+
*/
|
|
3207
|
+
|
|
3208
|
+
interface DescClass {
|
|
3209
|
+
name: string;
|
|
3210
|
+
classId: string;
|
|
3211
|
+
}
|
|
3212
|
+
type ReferenceItem = {
|
|
3213
|
+
type: 'prop';
|
|
3214
|
+
class: DescClass;
|
|
3215
|
+
key: string;
|
|
3216
|
+
} | {
|
|
3217
|
+
type: 'Clss';
|
|
3218
|
+
class: DescClass;
|
|
3219
|
+
} | {
|
|
3220
|
+
type: 'Enmr';
|
|
3221
|
+
class: DescClass;
|
|
3222
|
+
typeId: string;
|
|
3223
|
+
value: string;
|
|
3224
|
+
} | {
|
|
3225
|
+
type: 'rele';
|
|
3226
|
+
class: DescClass;
|
|
3227
|
+
offset: number;
|
|
3228
|
+
} | {
|
|
3229
|
+
type: 'Idnt';
|
|
3230
|
+
class: DescClass;
|
|
3231
|
+
id: number;
|
|
3232
|
+
} | {
|
|
3233
|
+
type: 'indx';
|
|
3234
|
+
class: DescClass;
|
|
3235
|
+
index: number;
|
|
3236
|
+
} | {
|
|
3237
|
+
type: 'name';
|
|
3238
|
+
class: DescClass;
|
|
3239
|
+
name: string;
|
|
3240
|
+
};
|
|
3241
|
+
type DescValue = {
|
|
3242
|
+
type: 'obj ';
|
|
3243
|
+
items: ReferenceItem[];
|
|
3244
|
+
} | {
|
|
3245
|
+
type: 'Objc' | 'GlbO';
|
|
3246
|
+
value: Descriptor;
|
|
3247
|
+
} | {
|
|
3248
|
+
type: 'VlLs';
|
|
3249
|
+
items: DescValue[];
|
|
3250
|
+
} | {
|
|
3251
|
+
type: 'doub';
|
|
3252
|
+
value: number;
|
|
3253
|
+
} | {
|
|
3254
|
+
type: 'UntF';
|
|
3255
|
+
unit: string;
|
|
3256
|
+
value: number;
|
|
3257
|
+
} | {
|
|
3258
|
+
type: 'UnFl';
|
|
3259
|
+
unit: string;
|
|
3260
|
+
values: number[];
|
|
3261
|
+
} | {
|
|
3262
|
+
type: 'TEXT';
|
|
3263
|
+
value: string;
|
|
3264
|
+
} | {
|
|
3265
|
+
type: 'enum';
|
|
3266
|
+
typeId: string;
|
|
3267
|
+
value: string;
|
|
3268
|
+
} | {
|
|
3269
|
+
type: 'long';
|
|
3270
|
+
value: number;
|
|
3271
|
+
} | {
|
|
3272
|
+
type: 'comp';
|
|
3273
|
+
value: number;
|
|
3274
|
+
} | {
|
|
3275
|
+
type: 'bool';
|
|
3276
|
+
value: boolean;
|
|
3277
|
+
} | {
|
|
3278
|
+
type: 'type' | 'GlbC';
|
|
3279
|
+
class: DescClass;
|
|
3280
|
+
} | {
|
|
3281
|
+
type: 'alis' | 'Pth ' | 'tdta';
|
|
3282
|
+
data: Uint8Array;
|
|
3283
|
+
} | {
|
|
3284
|
+
type: 'ObAr';
|
|
3285
|
+
prefix: number;
|
|
3286
|
+
body: Descriptor;
|
|
3287
|
+
};
|
|
3288
|
+
interface Descriptor {
|
|
3289
|
+
name: string;
|
|
3290
|
+
classId: string;
|
|
3291
|
+
items: Array<[string, DescValue]>;
|
|
3292
|
+
}
|
|
3293
|
+
/** A versioned descriptor from the start of `bytes` (trailing bytes are ignored). */
|
|
3294
|
+
declare function parseVersionedDescriptor(bytes: Uint8Array): Descriptor;
|
|
3295
|
+
declare function versionedDescriptorBytes(d: Descriptor): Uint8Array;
|
|
3296
|
+
|
|
3297
|
+
/** Every adjustment block key Photoshop writes. */
|
|
3298
|
+
declare const ADJUSTMENT_KEYS: string[];
|
|
3299
|
+
/** Keys we read and write. */
|
|
3300
|
+
declare const SUPPORTED_ADJUSTMENT_KEYS: Record<string, AdjustmentKind>;
|
|
3301
|
+
type ParsedAdjustment = {
|
|
3302
|
+
[K in AdjustmentKind]: {
|
|
3303
|
+
kind: K;
|
|
3304
|
+
params: AdjustmentParamsMap[K];
|
|
3305
|
+
approximated?: string;
|
|
3306
|
+
};
|
|
3307
|
+
}[AdjustmentKind];
|
|
3308
|
+
/**
|
|
3309
|
+
* Our parameters for an adjustment block, or `null` when the key is not one of our kinds or the
|
|
3310
|
+
* block cannot be read.
|
|
3311
|
+
*/
|
|
3312
|
+
declare function parseAdjustmentBlock(key: string, data: Uint8Array): ParsedAdjustment | null;
|
|
3313
|
+
/** The PSD block (key and data) for one of our adjustment layers. */
|
|
3314
|
+
declare function writeAdjustmentBlock<K extends AdjustmentKind>(kind: K, params: AdjustmentParamsMap[K]): {
|
|
3315
|
+
key: string;
|
|
3316
|
+
data: Uint8Array;
|
|
3317
|
+
};
|
|
3318
|
+
|
|
3319
|
+
interface PsdExportInput {
|
|
3320
|
+
width: number;
|
|
3321
|
+
height: number;
|
|
3322
|
+
/** Prepared stack, bottom to top. */
|
|
3323
|
+
layers: readonly ImageLayer[];
|
|
3324
|
+
/** The composite, `width × height` RGBA, written as the merged image. */
|
|
3325
|
+
merged: ArrayLike<number>;
|
|
3326
|
+
/** Pixels per inch (default 72). */
|
|
3327
|
+
resolution?: number;
|
|
3328
|
+
}
|
|
3329
|
+
interface PsdExportResult {
|
|
3330
|
+
bytes: Uint8Array;
|
|
3331
|
+
psb: boolean;
|
|
3332
|
+
/** Layer records written (group folders and dividers included). */
|
|
3333
|
+
records: number;
|
|
3334
|
+
}
|
|
3335
|
+
/** Writes the prepared stack as PSD (or PSB) bytes. */
|
|
3336
|
+
declare function exportPsd(input: PsdExportInput): PsdExportResult;
|
|
3337
|
+
|
|
3338
|
+
/** Framework-free helpers behind the PSD buttons of the React and Svelte layer panels. */
|
|
3339
|
+
|
|
3340
|
+
/** Types the file pickers accept. */
|
|
3341
|
+
declare const PSD_FILE_ACCEPT = ".psd,.psb,image/vnd.adobe.photoshop,application/x-photoshop";
|
|
3342
|
+
/** Reads a picked file and opens it as the document (one undo step). Returns the import warnings. */
|
|
3343
|
+
declare function openPsdFile(controller: ImageEditorController, file: Blob): Promise<string[]>;
|
|
3344
|
+
/** A file name for the exported document: `name` with a `.psd` / `.psb` extension. */
|
|
3345
|
+
declare function psdFileName(name: string, psb: boolean): string;
|
|
3346
|
+
/**
|
|
3347
|
+
* Writes the document as a PSD and offers it as a download (in a browser). Returns the file
|
|
3348
|
+
* name and the export warnings.
|
|
3349
|
+
*/
|
|
3350
|
+
declare function downloadPsd(controller: ImageEditorController, name?: string): Promise<{
|
|
3351
|
+
fileName: string;
|
|
3352
|
+
warnings: string[];
|
|
3353
|
+
}>;
|
|
3354
|
+
|
|
3355
|
+
/** Base64 (or a data URL) → bytes, refusing anything that is not base64 text. */
|
|
3356
|
+
declare function psdBytesFromBase64(data: unknown): Uint8Array;
|
|
3357
|
+
/**
|
|
3358
|
+
* Agent tools for Photoshop files: `inspect_psd` (what a file holds and how it would map),
|
|
3359
|
+
* `import_psd` (open it as the document) and `export_psd` (the document as a PSD).
|
|
3360
|
+
*/
|
|
3361
|
+
declare function createImagePsdTools(controller: ImageEditorController): AgentTool[];
|
|
3362
|
+
|
|
3363
|
+
export { ADJUSTMENT_KEYS, ADJUSTMENT_KINDS, ADJUSTMENT_LAYER_CONTROLS, ADJUSTMENT_LAYER_OPACITY_CONTROL, ADJUSTMENT_LUT_SIZE, type AIResultOptions, AS_SHOT_KELVIN, type AdjustmentKind, type AdjustmentKindInfo, type AdjustmentLayer, type AdjustmentLayerBase, type AdjustmentLayerInit, type AdjustmentLayerMask, type AdjustmentLayerNode, type AdjustmentLayerOf, type AdjustmentLayerUpdate, type AdjustmentParamsMap, type Annotation, type AnnotationLayer, type AnnotationPlacement, type AnnotationType, type ArrowAnnotation, type AspectRatio, BACKGROUND_LAYER_ID, BACKGROUND_LAYER_NAME, BLUR_FILTER_ID, BRUSH_OPTION_CONTROLS, type BaseAnnotation, type BlackWhiteParams, BlendMode, type BlurFilter, BrushSettings, type Chromaticity, type CircleAnnotation, type ColorBalanceParams, type ColorBalanceTone, type ColorDistance, type ColorRangeOptions, type ColorRangeSample, CompositorOptions, type CompositorSources, type ControlSection, type ControlSpec, type ControlTrack, type CreateAnnotationPayload, type CropBox, type CropHandle, type CurvePoint, type CurvesParams, D50, D65, DEFAULT_ADJUSTMENTS, DEFAULT_DEPTH_MASK, DEFAULT_REFINE_EDGE_PARAMS, DEFAULT_SELECTION_TOOL_OPTIONS, DEFAULT_TRANSFORM, DEVELOP_FILTER_ID, type DepthMaskOptions, type DescValue, type Descriptor, type DeserializeContext, type DevelopFilter, type DevelopSettings, type DropZone, EMPTY_DISTANCE, type ExportOptions, type FillOptions, GUIDED_FILTER_EPS, type GestureModifiers, type GroupLayer, HISTOGRAM_BINS, HUE_RANGE_LABELS, type HistogramChannel, type HistoryEntryHandle, type HueRange, type HueSaturationParams, IDENTITY_MATRIX3, IMAGE_ADJUSTMENT_CONTROLS, IMAGE_EDITOR_SCHEMA_VERSION, IMAGE_EDITOR_STATE_VERSION, type ImageAdjustments, type ImageAnnotation, type ImageDimensions, type ImageEditorAIHooks, type ImageEditorAssetStore, ImageEditorController, type ImageEditorDocumentLoad, type ImageEditorFit, type ImageEditorOptions, ImageEditorRenderer, type ImageEditorState, type ImageEditorTool, type ImageEditorToolProviderOptions, type ImageHistogram, type ImageLayer, type ImageLayerType, type ImagePoint, type ImageProcessVersion, type ImageProjection, type ImageTransform, type InpaintHook, type InpaintOptions, type InvertParams, LATEST_PROCESS_VERSION, LAYERED_SCHEMA_VERSION, LEGACY_PROCESS_VERSION, LUMA_709, type LayerBase, type LayerBlendMode, LayerCompositor, type LayerFilter, type LayerFilterKind, type LayerLocation, LayerLocks, type LayerMaskProps, type LayerMenuAction, type LayerMenuItem, LayerOperationError, type LayerPanelRow, type LayerPlacement, type LayerProperties, type LayerSourcesHost, type LayerStack, type LayerTarget, type LegacyParts, type LegacySerializedImageEditorState, type LegacyViewResult, type LevelsChannel, type LevelsParams, type LineAnnotation, MAX_KELVIN, MIN_KELVIN, MIRED_PER_TEMPERATURE_UNIT, type MagicWandOptions, type Matrix3, type MosaicImageDataLike, type MosaicRegion, PAINT_TOOLS, PSD_BLEND_KEYS, PSD_FILE_ACCEPT, PaintGesture, type PaintOptions, type PaintPointerSample, type PaintStrokeResult, PaintStrokeSession, type PaintTool, type ParsedAdjustment, type PenAnnotation, type PhotoFilterParams, type PixelBuffer, type PixelLayer, type PixelLayerInit, type PixelOp, PixelSurface, type PlaneLayout, type PosterizeParams, type PsdChannel, PsdError, type PsdExportInput, type PsdExportResult, type PsdFile, type PsdHeader, type PsdImportOptions, type PsdImportResult, type PsdLayerMask, type PsdLayerRecord, type PsdLayerSummary, type PsdRect, type PsdResource, type PsdTaggedBlock, type PsdTreeNode, type QuickMaskStyle, REFINE_EDGE_CONTROLS, type RasterMask, type RectAnnotation, type ReferenceItem, type RefineEdgeControl, type RefineEdgeParams, type RemoveBackgroundHook, type RemoveBackgroundOptions, type RenderOptions, type RouteInput, SELECTION_MODES, SELECTION_MODE_LABELS, SELECTION_MODIFY_OPS, SELECTION_TOOLS, SUPPORTED_ADJUSTMENT_KEYS, type SampleOptions, type SelectionChannel, type SelectionCommandOptions, SelectionGesture, type SelectionMask, type SelectionMode, type SelectionModifyOp, type SelectionToolKind, type SelectionToolOptions, type SerializeContext, type SerializedAdjustmentLayer, type SerializedAnnotationLayer, type SerializedGroupLayer, type SerializedImageEditorState, type SerializedLayer, type SerializedLayeredImageEditorState, type SerializedPixelLayer, type SerializedRasterMask, type SerializedSelection, type ShapeSelectionOptions, type ShortcutEvent, StrokeApply, StrokeCoverage, type StrokeInit, StrokePoint, TINT_SCALE, TONE_LUT_SIZE, TONE_RANGE_PRESETS, type TextAnnotation, type ThresholdParams, TiledSurface, type ToneRangePreset, type UnitLevels, VIBRANCE_GREY, type VibranceParams, type ViewportMetrics, XYZ_D50_TO_SRGB, activeAdjustmentLayers, addLayerFilter, addToHistogram, adjustmentKindLabel, adjustmentLayersKey, adjustmentNodeAsLayer, adjustmentNodeFromLegacy, annotationLayerFor, annotationLayerName, applyAdjustmentLayers, applyAdjustments, applyBoxBlur, applyDepthMask, applyImageProjectionToContext, applyLegacyAdjustments, applyMatrix3, applyOutputStage, applyProcess2Adjustments, applyRegionBlur, applyRegionMosaic, backgroundLayer, baseProjection, blackWhiteGray, blurFilter, borderCoverage, boxMean, boxToCurvePoint, bradfordAdaptation, buildLayerMaskPlanes, buildToneLut, calculateCropDrag, canvasToImagePoint, clampControlValue, clampCropToImage, colorBalanceChannel, colorRange, combineSelections, compileAdjustmentLayer, computeHistogram, computeSelectionBounds, contractCoverage, controlPosition, controlTrackBackground, coverageToByte, coveringRect, createAdjustmentLayer, createImageCaptureSurface, createImageEditTools, createImageEditorToolProvider, createImageLayerTools, createImagePaintTools, createImagePsdTools, createImageSelectionTools, createSelectionMask, curveLut, curveLutFromLevels, curvePointToBox, curveSvgPath, decodeLayerChannel, decodeLayerMask, decodeMergedImage, decodePlanes, decodePngDataUrl, decodeSelectionRle, defaultAdjustmentParams, depthMaskAlpha, depthRasterMask, describeLayer, describeSelection, deserializeLayer, deserializeLayers, deserializeSelection, developFilter, developFromAdjustments, developTarget, distanceTransform, downloadPsd, dropPlacement, dropZone, duplicateLayer, edgeWidth, ellipsePoints, ellipseSelection, emptyHistogram, encodeRle, encodeSelectionRle, encodeSurface, evaluateAdjustmentLayers, expandCoverage, exportPsd, featherCoverage, findAdjustmentControl, findLayerControl, formatControlValue, fullSelection, getAnnotationBounds, getControlPath, getCropCursor, getRotatedSize, getViewportMetrics, getViewportProjection, globalImageCache, greyMorphology, groupLayers, guidePlanes, guidedFilterColor, handlePaintShortcut, hasResampledLegacyMask, hashMaskContent, hexToRgb, histogramPath, hitTestAnnotation, hitTestCrop, hitTestCurvePoint, hslToRgb, hueRange, hueRangeTables, hueRangeWeight, hueSaturation, identityCurve, identityLevels, imageEditorStateMigrations, imageToCanvasPoint, importPsd, insertCurvePoint, invertMatrix3, invertSelection, isActiveFilter, isAdjustmentKind, isDefaultDepthMask, isLegacyShape, isPaintTool, isQuarterTurn, isQuarterTurnSwapped, isSelectionEmpty, isSelectionMode, isSpatialFilter, kelvinToTemperature, layerBadge, layerLabel, layerMaskCoverage, layerMaskFromSelection, layerMaskKey, layerMenu, layerName, layerPanelRows, layerTree, layerTypeLabel, layersFromLegacy, legacyAdjustmentLayer, legacyMaskOf, legacyView, levelsValue, linearSrgbToXy, linearToSrgb, loadImageEditorDocument, magicWand, mapCropHandle, maskSummary, migrateSerializedImageEditorState, migrateToLayeredState, modifySelection, moveCurvePoint, moveLayer, mulMatrix3, needsLegacyBase, neutralHueRange, newLayerId, normalizeAdjustmentLayer, normalizeAdjustmentLayers, normalizeAngle, normalizeFilter, normalizeLayerMask, normalizeProcessVersion, normalizeRect, normalizeRefineEdgeParams, normalizeStoredAdjustments, offsetLayer, openPsdFile, parseAdjustmentBlock, parseBlend, parseColor, parseSelectionMode, parseVersionedDescriptor, photoFilterMatrix, pixelLayerBounds, pixelLayers, placeLayer, pointerPressure, polygonCoverage, polygonSelection, posterizeValue, projectImagePoint, projectImageRect, projectMaskCoverage, projectQuarterTurn, psdBytesFromBase64, psdFileName, psdToLayers, quickMaskPixels, rangeLightness, rasterMaskFromLegacy, readAdjustmentControls, readPsd, rectSelection, refineCoverage, refineEdgeHalo, refineSelection, removeAlpha, removeCurvePoint, removeLayer, removeLayerFilter, renderLayeredBase, requireLayer, requireUnlocked, resizePixels, resizeSelection, resolveExternalAssets, resolveMosaicRegionBounds, rgbToGray, rgbToHsl, runLayerMenuAction, sampleLut, sampleToneLut, selectionArea, selectionFromCoverage, selectionFromPixels, selectionModeFromModifiers, selectionOutline, selectionToCoverage, selectionToPixels, selectionValueAt, serializeLayer, serializeLayers, serializeLayersExternal, serializeSelection, setControlPath, setLayerMask, setLayerProperties, shiftCoverage, smoothCoverage, splitOverlayAnnotations, srgb8ToLab, srgbToLinear, sumHistograms, tempTintToXy, temperatureToKelvin, toHex, toneCurve, toneLuts, toneRange, ungroupLayer, unionRect, unprojectCanvasPoint, updateLayerFilter, updateLayerMaskProps, uvToXy, versionedDescriptorBytes, vibranceLinear, vibrancePixel, wbMatrix, whiteBalanceFromSample, whiteBalanceMatrix, withNewIds, writeAdjustmentBlock, writePsd, xyToTempTint, xyToUv };
|