@ps-generator-bridge/sdk 0.1.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/LICENSE +21 -0
- package/dist/PsPhotoshopProxy-BjnvziWn.d.cts +879 -0
- package/dist/PsPhotoshopProxy-BjnvziWn.d.ts +879 -0
- package/dist/index.cjs +1131 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +210 -0
- package/dist/index.d.ts +210 -0
- package/dist/index.js +1117 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin.cjs +915 -0
- package/dist/plugin.cjs.map +1 -0
- package/dist/plugin.d.cts +457 -0
- package/dist/plugin.d.ts +457 -0
- package/dist/plugin.js +902 -0
- package/dist/plugin.js.map +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,879 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The wire contract shared by the SDK client and the server.
|
|
3
|
+
*
|
|
4
|
+
* This package is the single source of truth for the protocol (ADR 0001): the
|
|
5
|
+
* server depends on this module type-only and implements the same shapes. To add
|
|
6
|
+
* a server capability, model it here first (a new entry in `ProtocolMethods`),
|
|
7
|
+
* then implement it on the server and expose a method on the client.
|
|
8
|
+
*/
|
|
9
|
+
/** Bumped on any breaking change to the envelope or method shapes. */
|
|
10
|
+
declare const PROTOCOL_VERSION = 1;
|
|
11
|
+
/**
|
|
12
|
+
* Request method names shared by the sdk type surface and generator registration.
|
|
13
|
+
* Keep new built-in/module Request names here first, then reference these
|
|
14
|
+
* constants from server decorators so the Protocol remains the source of truth.
|
|
15
|
+
*/
|
|
16
|
+
declare const ProtocolMethod: {
|
|
17
|
+
readonly GetServerInfo: "getServerInfo";
|
|
18
|
+
readonly JsxRun: "jsx:run";
|
|
19
|
+
readonly JsxExecute: "jsx:execute";
|
|
20
|
+
readonly EventSubscribe: "event:subscribe";
|
|
21
|
+
readonly EventUnsubscribe: "event:unsubscribe";
|
|
22
|
+
readonly ActionAutoCutout: "action:autoCutout";
|
|
23
|
+
readonly ActionRemoveBackground: "action:removeBackground";
|
|
24
|
+
readonly LayerGetInfo: "layer:getInfo";
|
|
25
|
+
readonly LayerGetInfoById: "layer:getInfoById";
|
|
26
|
+
readonly LayerGetInfoByIndex: "layer:getInfoByIndex";
|
|
27
|
+
readonly DocumentCurrent: "document:current";
|
|
28
|
+
readonly DocumentExport: "document:export";
|
|
29
|
+
readonly DocumentSave: "document:save";
|
|
30
|
+
readonly ImageExportLayer: "image:exportLayer";
|
|
31
|
+
readonly ImageGetPreview: "image:getPreview";
|
|
32
|
+
readonly ImageExportDocument: "image:exportDocument";
|
|
33
|
+
};
|
|
34
|
+
type ProtocolMethod = (typeof ProtocolMethod)[keyof typeof ProtocolMethod];
|
|
35
|
+
/** Every method the server exposes, keyed by name -> { params, result }. */
|
|
36
|
+
interface ProtocolMethods {
|
|
37
|
+
[ProtocolMethod.GetServerInfo]: {
|
|
38
|
+
params: Record<string, never>;
|
|
39
|
+
result: ServerInfo;
|
|
40
|
+
};
|
|
41
|
+
[ProtocolMethod.JsxRun]: {
|
|
42
|
+
params: {
|
|
43
|
+
script: string;
|
|
44
|
+
};
|
|
45
|
+
result: unknown;
|
|
46
|
+
};
|
|
47
|
+
[ProtocolMethod.JsxExecute]: {
|
|
48
|
+
params: {
|
|
49
|
+
name: string;
|
|
50
|
+
params?: Record<string, unknown>;
|
|
51
|
+
};
|
|
52
|
+
result: unknown;
|
|
53
|
+
};
|
|
54
|
+
[ProtocolMethod.EventSubscribe]: {
|
|
55
|
+
params: {
|
|
56
|
+
type: PhotoshopEventName;
|
|
57
|
+
};
|
|
58
|
+
result: {
|
|
59
|
+
ok: true;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
[ProtocolMethod.EventUnsubscribe]: {
|
|
63
|
+
params: {
|
|
64
|
+
type: PhotoshopEventName;
|
|
65
|
+
};
|
|
66
|
+
result: {
|
|
67
|
+
ok: true;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
[ProtocolMethod.ActionAutoCutout]: {
|
|
71
|
+
params: Record<string, never>;
|
|
72
|
+
result: boolean;
|
|
73
|
+
};
|
|
74
|
+
[ProtocolMethod.ActionRemoveBackground]: {
|
|
75
|
+
params: Record<string, never>;
|
|
76
|
+
result: {
|
|
77
|
+
success: boolean;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
[ProtocolMethod.LayerGetInfo]: {
|
|
81
|
+
params?: {
|
|
82
|
+
id?: number;
|
|
83
|
+
index?: number;
|
|
84
|
+
getChildren?: boolean;
|
|
85
|
+
getGeneratorSettings?: boolean;
|
|
86
|
+
};
|
|
87
|
+
result: PsLayer;
|
|
88
|
+
};
|
|
89
|
+
[ProtocolMethod.LayerGetInfoById]: {
|
|
90
|
+
params: {
|
|
91
|
+
layerID: number;
|
|
92
|
+
options?: {
|
|
93
|
+
getChildren: boolean;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
result: PsLayer;
|
|
97
|
+
};
|
|
98
|
+
[ProtocolMethod.LayerGetInfoByIndex]: {
|
|
99
|
+
params: {
|
|
100
|
+
layerIndex: number;
|
|
101
|
+
options?: {
|
|
102
|
+
getChildren: boolean;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
result: PsLayer;
|
|
106
|
+
};
|
|
107
|
+
[ProtocolMethod.DocumentCurrent]: {
|
|
108
|
+
params: Record<string, never>;
|
|
109
|
+
result: PsDocument;
|
|
110
|
+
};
|
|
111
|
+
[ProtocolMethod.DocumentExport]: {
|
|
112
|
+
params: {
|
|
113
|
+
filePath: string;
|
|
114
|
+
} & Record<string, unknown>;
|
|
115
|
+
result: unknown;
|
|
116
|
+
};
|
|
117
|
+
[ProtocolMethod.DocumentSave]: {
|
|
118
|
+
params: {
|
|
119
|
+
savePath?: string;
|
|
120
|
+
};
|
|
121
|
+
result: unknown;
|
|
122
|
+
};
|
|
123
|
+
[ProtocolMethod.ImageExportLayer]: {
|
|
124
|
+
params: {
|
|
125
|
+
documentId?: number;
|
|
126
|
+
layerSpec: LayerSpec;
|
|
127
|
+
settings?: Record<string, unknown>;
|
|
128
|
+
};
|
|
129
|
+
result: WsImageResult;
|
|
130
|
+
};
|
|
131
|
+
[ProtocolMethod.ImageGetPreview]: {
|
|
132
|
+
params: {
|
|
133
|
+
documentId?: number;
|
|
134
|
+
layerSpec: number;
|
|
135
|
+
};
|
|
136
|
+
result: WsImageResult;
|
|
137
|
+
};
|
|
138
|
+
[ProtocolMethod.ImageExportDocument]: {
|
|
139
|
+
params: {
|
|
140
|
+
documentId?: number;
|
|
141
|
+
settings?: Record<string, unknown>;
|
|
142
|
+
};
|
|
143
|
+
result: WsImageResult;
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
type MethodName = keyof ProtocolMethods;
|
|
147
|
+
/**
|
|
148
|
+
* A layer spec: either a layer id, or an index range plus the indices of layers
|
|
149
|
+
* to hide (the form Photoshop's `getLayerPixmap.jsx` accepts). Modeled here as a
|
|
150
|
+
* wire type (RFC 0008) so the protocol is self-contained; the generator's image
|
|
151
|
+
* module re-exports it for its plugin-facing API.
|
|
152
|
+
*/
|
|
153
|
+
type LayerSpec = number | {
|
|
154
|
+
firstLayerIndex: number;
|
|
155
|
+
lastLayerIndex: number;
|
|
156
|
+
hidden: number[];
|
|
157
|
+
};
|
|
158
|
+
interface PsRect {
|
|
159
|
+
x: number;
|
|
160
|
+
y: number;
|
|
161
|
+
width: number;
|
|
162
|
+
height: number;
|
|
163
|
+
}
|
|
164
|
+
interface PsLayer {
|
|
165
|
+
id: number;
|
|
166
|
+
index: number;
|
|
167
|
+
name: string;
|
|
168
|
+
type: number;
|
|
169
|
+
visible: boolean;
|
|
170
|
+
bounds: PsBounds$1;
|
|
171
|
+
rect: PsRect;
|
|
172
|
+
clip: boolean;
|
|
173
|
+
children?: PsLayer[];
|
|
174
|
+
}
|
|
175
|
+
interface PsDocument {
|
|
176
|
+
id: number;
|
|
177
|
+
name: string;
|
|
178
|
+
width: number;
|
|
179
|
+
height: number;
|
|
180
|
+
resolution: number;
|
|
181
|
+
isDirty: boolean;
|
|
182
|
+
filePath?: string;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* The result of an image `@ws` method (RFC 0008). `data` is an out-of-the-box
|
|
186
|
+
* image string the client can drop straight into an `<img src>`:
|
|
187
|
+
* `data:image/png;base64,...` when inlined, or `https://...` when a `CosService`
|
|
188
|
+
* uploaded it. The client tells them apart by the `data`/`http` prefix — there
|
|
189
|
+
* is deliberately no separate discriminator field. `bounds`/`width`/`height`
|
|
190
|
+
* carry the same geometry as the module-internal `ImageResult`.
|
|
191
|
+
*/
|
|
192
|
+
interface WsImageResult {
|
|
193
|
+
data: string;
|
|
194
|
+
bounds: PsBounds$1;
|
|
195
|
+
width: number;
|
|
196
|
+
height: number;
|
|
197
|
+
}
|
|
198
|
+
interface PsBounds$1 {
|
|
199
|
+
left: number;
|
|
200
|
+
right: number;
|
|
201
|
+
top: number;
|
|
202
|
+
bottom: number;
|
|
203
|
+
}
|
|
204
|
+
interface ServerInfo {
|
|
205
|
+
name: string;
|
|
206
|
+
version: string;
|
|
207
|
+
/** Photoshop version, when the server is connected to PS; omitted otherwise. */
|
|
208
|
+
psVersion?: string;
|
|
209
|
+
plugins?: PluginInfo[];
|
|
210
|
+
}
|
|
211
|
+
interface PluginInfo {
|
|
212
|
+
id: string;
|
|
213
|
+
}
|
|
214
|
+
interface Bounds {
|
|
215
|
+
top: number;
|
|
216
|
+
left: number;
|
|
217
|
+
bottom: number;
|
|
218
|
+
right: number;
|
|
219
|
+
}
|
|
220
|
+
interface ImageChangedLayer {
|
|
221
|
+
id: number;
|
|
222
|
+
pixels?: boolean;
|
|
223
|
+
removed?: boolean;
|
|
224
|
+
bounds?: Bounds;
|
|
225
|
+
}
|
|
226
|
+
interface ImageChangedEvent {
|
|
227
|
+
version: string;
|
|
228
|
+
timeStamp: number;
|
|
229
|
+
count: number;
|
|
230
|
+
id: number;
|
|
231
|
+
active?: boolean;
|
|
232
|
+
file?: string;
|
|
233
|
+
closed?: boolean;
|
|
234
|
+
metaDataOnly?: boolean;
|
|
235
|
+
selection?: number[];
|
|
236
|
+
layers?: ImageChangedLayer[];
|
|
237
|
+
}
|
|
238
|
+
interface PhotoshopEventMap {
|
|
239
|
+
workspaceChanged: string;
|
|
240
|
+
toolChanged: string;
|
|
241
|
+
quickMaskStateChanged: string;
|
|
242
|
+
documentChanged: number;
|
|
243
|
+
closedDocument: number;
|
|
244
|
+
newDocumentViewCreated: number;
|
|
245
|
+
activeViewChanged: number;
|
|
246
|
+
currentDocumentChanged: number;
|
|
247
|
+
backgroundColorChanged: string;
|
|
248
|
+
foregroundColorChanged: string;
|
|
249
|
+
imageChanged: ImageChangedEvent;
|
|
250
|
+
}
|
|
251
|
+
type PhotoshopEventName = keyof PhotoshopEventMap;
|
|
252
|
+
/** A request envelope sent client -> server. */
|
|
253
|
+
interface RequestEnvelope<M extends MethodName = MethodName> {
|
|
254
|
+
id: string;
|
|
255
|
+
method: M;
|
|
256
|
+
params: ProtocolMethods[M]["params"];
|
|
257
|
+
}
|
|
258
|
+
/** A response envelope sent server -> client. */
|
|
259
|
+
type ResponseEnvelope<M extends MethodName = MethodName> = {
|
|
260
|
+
id: string;
|
|
261
|
+
ok: true;
|
|
262
|
+
result: ProtocolMethods[M]["result"];
|
|
263
|
+
} | {
|
|
264
|
+
id: string;
|
|
265
|
+
ok: false;
|
|
266
|
+
error: ProtocolError;
|
|
267
|
+
};
|
|
268
|
+
/**
|
|
269
|
+
* Every server -> client push event, keyed by type -> data payload. Open-ended
|
|
270
|
+
* (ADR 0006): declared keys are strongly typed; an undeclared `type` still flows
|
|
271
|
+
* through the looser `on(type: string, ...)` / `EventEnvelope` overloads.
|
|
272
|
+
*/
|
|
273
|
+
interface ProtocolEvents {
|
|
274
|
+
/** Handshake: the first event after a socket opens, carrying the clientId. */
|
|
275
|
+
connected: {
|
|
276
|
+
clientId: string;
|
|
277
|
+
};
|
|
278
|
+
workspaceChanged: PhotoshopEventMap["workspaceChanged"];
|
|
279
|
+
toolChanged: PhotoshopEventMap["toolChanged"];
|
|
280
|
+
quickMaskStateChanged: PhotoshopEventMap["quickMaskStateChanged"];
|
|
281
|
+
documentChanged: PhotoshopEventMap["documentChanged"];
|
|
282
|
+
closedDocument: PhotoshopEventMap["closedDocument"];
|
|
283
|
+
newDocumentViewCreated: PhotoshopEventMap["newDocumentViewCreated"];
|
|
284
|
+
activeViewChanged: PhotoshopEventMap["activeViewChanged"];
|
|
285
|
+
currentDocumentChanged: PhotoshopEventMap["currentDocumentChanged"];
|
|
286
|
+
backgroundColorChanged: PhotoshopEventMap["backgroundColorChanged"];
|
|
287
|
+
foregroundColorChanged: PhotoshopEventMap["foregroundColorChanged"];
|
|
288
|
+
imageChanged: PhotoshopEventMap["imageChanged"];
|
|
289
|
+
}
|
|
290
|
+
type EventName = keyof ProtocolEvents;
|
|
291
|
+
/** A one-way event envelope sent server -> client (no id, no response). */
|
|
292
|
+
interface EventEnvelope<E extends EventName = EventName> {
|
|
293
|
+
type: E;
|
|
294
|
+
data: ProtocolEvents[E];
|
|
295
|
+
}
|
|
296
|
+
interface ProtocolError {
|
|
297
|
+
/**
|
|
298
|
+
* Error code. Server-level codes are values of `ErrorCode`; a plugin may throw
|
|
299
|
+
* its own code (defined in its package), which the server surfaces verbatim
|
|
300
|
+
* (open-ended contract, RFC 0006). Typed here as `string` to admit both.
|
|
301
|
+
*/
|
|
302
|
+
code: string;
|
|
303
|
+
message: string;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Server-level error codes. Plugin-specific codes (e.g. SidePaint's
|
|
307
|
+
* `PAINT_GONE`/`IMPORT_FAILED`/`VALUE_RESOLVE`/`UNSUPPORTED_SCHEME`) live in
|
|
308
|
+
* their plugin package since RFC 0006 and are surfaced verbatim by the server.
|
|
309
|
+
*/
|
|
310
|
+
declare const ErrorCode: {
|
|
311
|
+
readonly UnknownMethod: "UNKNOWN_METHOD";
|
|
312
|
+
readonly BadRequest: "BAD_REQUEST";
|
|
313
|
+
readonly Internal: "INTERNAL";
|
|
314
|
+
};
|
|
315
|
+
type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];
|
|
316
|
+
/**
|
|
317
|
+
* Frame discriminators shared by both ends (ADR 0005). The three envelope kinds
|
|
318
|
+
* are told apart by characteristic fields: Request has `method`, Response has a
|
|
319
|
+
* boolean `ok`, Event has `type` and no `id`.
|
|
320
|
+
*/
|
|
321
|
+
declare function isRequest(value: unknown): value is RequestEnvelope;
|
|
322
|
+
declare function isResponse(value: unknown): value is ResponseEnvelope;
|
|
323
|
+
declare function isEvent(value: unknown): value is EventEnvelope;
|
|
324
|
+
/** Decode a raw text frame. Throws on invalid JSON. Shared by both ends. */
|
|
325
|
+
declare function parseFrame(data: string): unknown;
|
|
326
|
+
/** Encode a value into a text frame. Shared by both ends. */
|
|
327
|
+
declare function serializeFrame(value: unknown): string;
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* The minimal slice of a JSX runner the Photoshop DOM proxy depends on: run a
|
|
331
|
+
* raw ExtendScript string and resolve its evaluation result. Defined locally
|
|
332
|
+
* (not imported from the generator contract) so the proxy stays transport- and
|
|
333
|
+
* host-agnostic and can be wired to any backend that can evaluate a script.
|
|
334
|
+
*
|
|
335
|
+
* The server's `JsxRunnerApi` satisfies this structurally (`plugin.jsx`), so a
|
|
336
|
+
* plugin passes `this.jsx` straight in. A future client-side backend would
|
|
337
|
+
* supply its own adapter.
|
|
338
|
+
*/
|
|
339
|
+
interface PsJsxRunner {
|
|
340
|
+
run<T = unknown>(script: string): Promise<T>;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Photoshop DOM enum constants. Each value is the ExtendScript global enum name
|
|
345
|
+
* string, embeddable directly into a JSX fragment.
|
|
346
|
+
*
|
|
347
|
+
* @example
|
|
348
|
+
* await this.photoshop.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
|
|
349
|
+
* // emits JSX: app.activeDocument.close(SaveOptions.DONOTSAVECHANGES)
|
|
350
|
+
*/
|
|
351
|
+
declare const SaveOptions: {
|
|
352
|
+
/** Do not save changes. */
|
|
353
|
+
readonly DONOTSAVECHANGES: "SaveOptions.DONOTSAVECHANGES";
|
|
354
|
+
/** Prompt the user. */
|
|
355
|
+
readonly PROMPTTOSAVECHANGES: "SaveOptions.PROMPTTOSAVECHANGES";
|
|
356
|
+
/** Save changes. */
|
|
357
|
+
readonly SAVECHANGES: "SaveOptions.SAVECHANGES";
|
|
358
|
+
};
|
|
359
|
+
type SaveOptionsValue = (typeof SaveOptions)[keyof typeof SaveOptions];
|
|
360
|
+
declare const LayerKind: {
|
|
361
|
+
readonly NORMAL: "LayerKind.NORMAL";
|
|
362
|
+
readonly TEXT: "LayerKind.TEXT";
|
|
363
|
+
readonly SMARTOBJECT: "LayerKind.SMARTOBJECT";
|
|
364
|
+
readonly SOLIDFILL: "LayerKind.SOLIDFILL";
|
|
365
|
+
/**
|
|
366
|
+
* @remarks In `enums.d.ts`, GRADIENTFILL=4 and PATTERNFILL=4 share a value
|
|
367
|
+
* (an Adobe enum conflict); a kind of 4 always maps back to GRADIENTFILL and
|
|
368
|
+
* the two cannot be told apart at runtime (disambiguate by layer name etc.).
|
|
369
|
+
*/
|
|
370
|
+
readonly GRADIENTFILL: "LayerKind.GRADIENTFILL";
|
|
371
|
+
readonly PATTERNFILL: "LayerKind.PATTERNFILL";
|
|
372
|
+
readonly LEVELS: "LayerKind.LEVELS";
|
|
373
|
+
readonly CURVES: "LayerKind.CURVES";
|
|
374
|
+
readonly BRIGHTNESSCONTRAST: "LayerKind.BRIGHTNESSCONTRAST";
|
|
375
|
+
readonly HUESATURATION: "LayerKind.HUESATURATION";
|
|
376
|
+
readonly COLORBALANCE: "LayerKind.COLORBALANCE";
|
|
377
|
+
readonly INVERSION: "LayerKind.INVERSION";
|
|
378
|
+
readonly POSTERIZE: "LayerKind.POSTERIZE";
|
|
379
|
+
readonly THRESHOLD: "LayerKind.THRESHOLD";
|
|
380
|
+
readonly EXPOSURE: "LayerKind.EXPOSURE";
|
|
381
|
+
readonly VIBRANCE: "LayerKind.VIBRANCE";
|
|
382
|
+
readonly VIDEO: "LayerKind.VIDEO";
|
|
383
|
+
readonly LAYER3D: "LayerKind.LAYER3D";
|
|
384
|
+
readonly BLACKANDWHITE: "LayerKind.BLACKANDWHITE";
|
|
385
|
+
readonly CHANNELMIXER: "LayerKind.CHANNELMIXER";
|
|
386
|
+
readonly GRADIENTMAP: "LayerKind.GRADIENTMAP";
|
|
387
|
+
readonly SELECTIVECOLOR: "LayerKind.SELECTIVECOLOR";
|
|
388
|
+
readonly PHOTOFILTER: "LayerKind.PHOTOFILTER";
|
|
389
|
+
readonly COLORLOOKUP: "LayerKind.COLORLOOKUP";
|
|
390
|
+
};
|
|
391
|
+
type LayerKindValue = (typeof LayerKind)[keyof typeof LayerKind];
|
|
392
|
+
declare const BlendMode: {
|
|
393
|
+
readonly NORMAL: "BlendMode.NORMAL";
|
|
394
|
+
readonly DISSOLVE: "BlendMode.DISSOLVE";
|
|
395
|
+
readonly DARKEN: "BlendMode.DARKEN";
|
|
396
|
+
readonly MULTIPLY: "BlendMode.MULTIPLY";
|
|
397
|
+
readonly COLORBURN: "BlendMode.COLORBURN";
|
|
398
|
+
readonly LINEARBURN: "BlendMode.LINEARBURN";
|
|
399
|
+
readonly DARKERCOLOR: "BlendMode.DARKERCOLOR";
|
|
400
|
+
readonly LIGHTEN: "BlendMode.LIGHTEN";
|
|
401
|
+
readonly SCREEN: "BlendMode.SCREEN";
|
|
402
|
+
readonly COLORDODGE: "BlendMode.COLORDODGE";
|
|
403
|
+
readonly LINEARDODGE: "BlendMode.LINEARDODGE";
|
|
404
|
+
readonly LIGHTERCOLOR: "BlendMode.LIGHTERCOLOR";
|
|
405
|
+
readonly OVERLAY: "BlendMode.OVERLAY";
|
|
406
|
+
readonly SOFTLIGHT: "BlendMode.SOFTLIGHT";
|
|
407
|
+
readonly HARDLIGHT: "BlendMode.HARDLIGHT";
|
|
408
|
+
readonly VIVIDLIGHT: "BlendMode.VIVIDLIGHT";
|
|
409
|
+
readonly LINEARLIGHT: "BlendMode.LINEARLIGHT";
|
|
410
|
+
readonly PINLIGHT: "BlendMode.PINLIGHT";
|
|
411
|
+
readonly HARDMIX: "BlendMode.HARDMIX";
|
|
412
|
+
readonly DIFFERENCE: "BlendMode.DIFFERENCE";
|
|
413
|
+
readonly EXCLUSION: "BlendMode.EXCLUSION";
|
|
414
|
+
readonly SUBTRACT: "BlendMode.SUBTRACT";
|
|
415
|
+
readonly DIVIDE: "BlendMode.DIVIDE";
|
|
416
|
+
readonly HUE: "BlendMode.HUE";
|
|
417
|
+
readonly SATURATION: "BlendMode.SATURATION";
|
|
418
|
+
readonly COLORBLEND: "BlendMode.COLORBLEND";
|
|
419
|
+
readonly LUMINOSITY: "BlendMode.LUMINOSITY";
|
|
420
|
+
readonly PASSTHROUGH: "BlendMode.PASSTHROUGH";
|
|
421
|
+
};
|
|
422
|
+
type BlendModeValue = (typeof BlendMode)[keyof typeof BlendMode];
|
|
423
|
+
declare const ElementPlacement: {
|
|
424
|
+
readonly PLACEATBEGINNING: "ElementPlacement.PLACEATBEGINNING";
|
|
425
|
+
readonly PLACEINSIDE: "ElementPlacement.PLACEINSIDE";
|
|
426
|
+
readonly PLACEBEFORE: "ElementPlacement.PLACEBEFORE";
|
|
427
|
+
readonly PLACEAFTER: "ElementPlacement.PLACEAFTER";
|
|
428
|
+
readonly PLACEATEND: "ElementPlacement.PLACEATEND";
|
|
429
|
+
};
|
|
430
|
+
type ElementPlacementValue = (typeof ElementPlacement)[keyof typeof ElementPlacement];
|
|
431
|
+
declare const AnchorPosition: {
|
|
432
|
+
readonly TOPLEFT: "AnchorPosition.TOPLEFT";
|
|
433
|
+
readonly TOPCENTER: "AnchorPosition.TOPCENTER";
|
|
434
|
+
readonly TOPRIGHT: "AnchorPosition.TOPRIGHT";
|
|
435
|
+
readonly MIDDLELEFT: "AnchorPosition.MIDDLELEFT";
|
|
436
|
+
readonly MIDDLECENTER: "AnchorPosition.MIDDLECENTER";
|
|
437
|
+
readonly MIDDLERIGHT: "AnchorPosition.MIDDLERIGHT";
|
|
438
|
+
readonly BOTTOMLEFT: "AnchorPosition.BOTTOMLEFT";
|
|
439
|
+
readonly BOTTOMCENTER: "AnchorPosition.BOTTOMCENTER";
|
|
440
|
+
readonly BOTTOMRIGHT: "AnchorPosition.BOTTOMRIGHT";
|
|
441
|
+
};
|
|
442
|
+
type AnchorPositionValue = (typeof AnchorPosition)[keyof typeof AnchorPosition];
|
|
443
|
+
declare const DocumentMode: {
|
|
444
|
+
readonly BITMAP: "DocumentMode.BITMAP";
|
|
445
|
+
readonly GRAYSCALE: "DocumentMode.GRAYSCALE";
|
|
446
|
+
readonly RGB: "DocumentMode.RGB";
|
|
447
|
+
readonly CMYK: "DocumentMode.CMYK";
|
|
448
|
+
readonly LAB: "DocumentMode.LAB";
|
|
449
|
+
readonly INDEXEDCOLOR: "DocumentMode.INDEXEDCOLOR";
|
|
450
|
+
readonly MULTICHANNEL: "DocumentMode.MULTICHANNEL";
|
|
451
|
+
readonly DUOTONE: "DocumentMode.DUOTONE";
|
|
452
|
+
};
|
|
453
|
+
type DocumentModeValue = (typeof DocumentMode)[keyof typeof DocumentMode];
|
|
454
|
+
declare const SelectionType: {
|
|
455
|
+
readonly REPLACE: "SelectionType.REPLACE";
|
|
456
|
+
readonly EXTEND: "SelectionType.EXTEND";
|
|
457
|
+
readonly DIMINISH: "SelectionType.DIMINISH";
|
|
458
|
+
readonly INTERSECT: "SelectionType.INTERSECT";
|
|
459
|
+
};
|
|
460
|
+
type SelectionTypeValue = (typeof SelectionType)[keyof typeof SelectionType];
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* A bounding rectangle `[left, top, right, bottom]`.
|
|
464
|
+
*
|
|
465
|
+
* @remarks Units follow Photoshop's current `rulerUnits` setting; values are not
|
|
466
|
+
* guaranteed to be pixels unless `rulerUnits` is `Units.PIXELS`.
|
|
467
|
+
*/
|
|
468
|
+
type PsBounds = [number, number, number, number];
|
|
469
|
+
/**
|
|
470
|
+
* A simplified SolidColor representation. The first version only fills `rgb`;
|
|
471
|
+
* in CMYK/Lab documents that RGB is Photoshop's automatic approximation. The
|
|
472
|
+
* `cmyk` field is reserved for a later version and is currently always omitted.
|
|
473
|
+
*/
|
|
474
|
+
interface PsColor {
|
|
475
|
+
model: "rgb" | "cmyk" | "hsb" | "lab" | "gray";
|
|
476
|
+
rgb?: {
|
|
477
|
+
red: number;
|
|
478
|
+
green: number;
|
|
479
|
+
blue: number;
|
|
480
|
+
hexValue?: string;
|
|
481
|
+
};
|
|
482
|
+
cmyk?: {
|
|
483
|
+
cyan: number;
|
|
484
|
+
magenta: number;
|
|
485
|
+
yellow: number;
|
|
486
|
+
black: number;
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* Wraps an ExtendScript Layer / ArtLayer / LayerSet: the shared Layer
|
|
492
|
+
* properties and methods plus ArtLayer-only members such as `kind`.
|
|
493
|
+
*
|
|
494
|
+
* @remarks
|
|
495
|
+
* `activeLayer` may be an ArtLayer or a LayerSet. Read `typename` before
|
|
496
|
+
* touching ArtLayer-only members:
|
|
497
|
+
* - "ArtLayer" -> a normal layer, `kind` is valid
|
|
498
|
+
* - "LayerSet" -> a group, `kind` is unavailable
|
|
499
|
+
*
|
|
500
|
+
* @example
|
|
501
|
+
* const layer = this.photoshop.activeDocument.activeLayer;
|
|
502
|
+
* const name = await layer.name;
|
|
503
|
+
* await layer.setName("Background");
|
|
504
|
+
* await layer.setVisible(false);
|
|
505
|
+
*/
|
|
506
|
+
declare class PhotoshopLayer {
|
|
507
|
+
private readonly _jsx;
|
|
508
|
+
private readonly _path;
|
|
509
|
+
constructor(_jsx: PsJsxRunner, _path: string);
|
|
510
|
+
/** Unique layer id. */
|
|
511
|
+
get id(): Promise<number>;
|
|
512
|
+
/** Layer name. */
|
|
513
|
+
get name(): Promise<string>;
|
|
514
|
+
/** Layer visibility. */
|
|
515
|
+
get visible(): Promise<boolean>;
|
|
516
|
+
/** Layer opacity (0-100). */
|
|
517
|
+
get opacity(): Promise<number>;
|
|
518
|
+
/** BlendMode code -> enum-name map (all 27 members, plus newer ones). */
|
|
519
|
+
private static readonly _BLEND_MODE_MAP;
|
|
520
|
+
/**
|
|
521
|
+
* Blend mode as an enum-name string (e.g. "BlendMode.NORMAL"). ExtendScript
|
|
522
|
+
* yields the numeric code; the static map turns it into a readable name.
|
|
523
|
+
*/
|
|
524
|
+
get blendMode(): Promise<string>;
|
|
525
|
+
/** Whether the layer is fully locked. */
|
|
526
|
+
get allLocked(): Promise<boolean>;
|
|
527
|
+
/**
|
|
528
|
+
* Layer bounds `[left, top, right, bottom]`.
|
|
529
|
+
*
|
|
530
|
+
* @remarks Units follow `rulerUnits`; values are not pixels unless it is
|
|
531
|
+
* `Units.PIXELS`.
|
|
532
|
+
*/
|
|
533
|
+
get bounds(): Promise<PsBounds>;
|
|
534
|
+
/** LayerKind code -> enum-name map. */
|
|
535
|
+
private static readonly _LAYER_KIND_MAP;
|
|
536
|
+
/**
|
|
537
|
+
* Layer kind as an enum-name string (e.g. "LayerKind.NORMAL"). ArtLayer only;
|
|
538
|
+
* reading it on a LayerSet throws. Check `typename` first.
|
|
539
|
+
*
|
|
540
|
+
* @remarks GRADIENTFILL=4 and PATTERNFILL=4 collide in Adobe's enums, so a
|
|
541
|
+
* kind of 4 always maps to GRADIENTFILL.
|
|
542
|
+
*/
|
|
543
|
+
get kind(): Promise<string>;
|
|
544
|
+
/** Object type name ("ArtLayer" or "LayerSet"). */
|
|
545
|
+
get typename(): Promise<string>;
|
|
546
|
+
/** Set the layer name. */
|
|
547
|
+
setName(value: string): Promise<void>;
|
|
548
|
+
/** Set layer visibility. */
|
|
549
|
+
setVisible(value: boolean): Promise<void>;
|
|
550
|
+
/** Set layer opacity (0-100). */
|
|
551
|
+
setOpacity(value: number): Promise<void>;
|
|
552
|
+
/**
|
|
553
|
+
* Set the blend mode.
|
|
554
|
+
*
|
|
555
|
+
* @example
|
|
556
|
+
* import { BlendMode } from "@ps-generator-bridge/sdk/plugin";
|
|
557
|
+
* await layer.setBlendMode(BlendMode.MULTIPLY);
|
|
558
|
+
*/
|
|
559
|
+
setBlendMode(value: BlendModeValue): Promise<void>;
|
|
560
|
+
/** Set whether the layer is fully locked. */
|
|
561
|
+
setAllLocked(value: boolean): Promise<void>;
|
|
562
|
+
/** Delete this layer. */
|
|
563
|
+
remove(): Promise<void>;
|
|
564
|
+
/** Duplicate this layer (the copy becomes `activeLayer`). */
|
|
565
|
+
duplicate(): Promise<PhotoshopLayer>;
|
|
566
|
+
/**
|
|
567
|
+
* Move this layer relative to another.
|
|
568
|
+
*
|
|
569
|
+
* @param relativeObjectJsxPath JSX path of the reference layer (e.g.
|
|
570
|
+
* "app.activeDocument.layers[0]").
|
|
571
|
+
* @param insertionLocation placement enum.
|
|
572
|
+
*
|
|
573
|
+
* @remarks Pass a bare JSX path expression. A `PhotoshopLayers.getByName()`
|
|
574
|
+
* path contains quotes and cannot be used as a reference expression here.
|
|
575
|
+
*
|
|
576
|
+
* @example
|
|
577
|
+
* import { ElementPlacement } from "@ps-generator-bridge/sdk/plugin";
|
|
578
|
+
* await layer.move("app.activeDocument.layers[0]", ElementPlacement.PLACEBEFORE);
|
|
579
|
+
*/
|
|
580
|
+
move(relativeObjectJsxPath: string, insertionLocation: ElementPlacementValue): Promise<void>;
|
|
581
|
+
/** Translate the layer by a pixel delta. */
|
|
582
|
+
translate(deltaX: number, deltaY: number): Promise<void>;
|
|
583
|
+
/**
|
|
584
|
+
* Scale the layer.
|
|
585
|
+
*
|
|
586
|
+
* @param horizontal horizontal scale percent (150 = 150%).
|
|
587
|
+
* @param vertical vertical scale percent.
|
|
588
|
+
* @param anchor scaling anchor (optional).
|
|
589
|
+
*/
|
|
590
|
+
resize(horizontal: number, vertical: number, anchor?: AnchorPositionValue): Promise<void>;
|
|
591
|
+
/**
|
|
592
|
+
* Rotate the layer.
|
|
593
|
+
*
|
|
594
|
+
* @param angle degrees, clockwise positive.
|
|
595
|
+
* @param anchor rotation anchor (optional).
|
|
596
|
+
*/
|
|
597
|
+
rotate(angle: number, anchor?: AnchorPositionValue): Promise<void>;
|
|
598
|
+
/** Move the layer to the end of its stack. */
|
|
599
|
+
moveToEnd(): Promise<void>;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
/**
|
|
603
|
+
* Wraps an ExtendScript Layers collection (`Document.layers` or
|
|
604
|
+
* `LayerSet.layers`).
|
|
605
|
+
*
|
|
606
|
+
* @example
|
|
607
|
+
* const layers = this.photoshop.activeDocument.layers;
|
|
608
|
+
* const count = await layers.length;
|
|
609
|
+
* const first = layers.at(0);
|
|
610
|
+
* const named = layers.getByName("Background");
|
|
611
|
+
*/
|
|
612
|
+
declare class PhotoshopLayers {
|
|
613
|
+
private readonly _jsx;
|
|
614
|
+
private readonly _path;
|
|
615
|
+
constructor(_jsx: PsJsxRunner, _path: string);
|
|
616
|
+
/** Number of layers in the collection. */
|
|
617
|
+
get length(): Promise<number>;
|
|
618
|
+
/**
|
|
619
|
+
* Access a layer by index. The collection is 0-based, matching JavaScript;
|
|
620
|
+
* `layers[0]` is the top-most layer.
|
|
621
|
+
*/
|
|
622
|
+
at(index: number): PhotoshopLayer;
|
|
623
|
+
/**
|
|
624
|
+
* Look up a layer by name (case-sensitive). The returned wrapper works for
|
|
625
|
+
* property reads/writes but its path contains a `getByName(...)` call, so it
|
|
626
|
+
* must not be passed as `PhotoshopLayer.move()`'s reference path.
|
|
627
|
+
*/
|
|
628
|
+
getByName(name: string): PhotoshopLayer;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* Wraps `Document.selection`.
|
|
633
|
+
*
|
|
634
|
+
* @example
|
|
635
|
+
* const sel = this.photoshop.activeDocument.selection;
|
|
636
|
+
* await sel.selectAll();
|
|
637
|
+
* const bounds = await sel.bounds;
|
|
638
|
+
* await sel.deselect();
|
|
639
|
+
*/
|
|
640
|
+
declare class PhotoshopSelection {
|
|
641
|
+
private readonly _jsx;
|
|
642
|
+
private readonly _path;
|
|
643
|
+
constructor(_jsx: PsJsxRunner, _path: string);
|
|
644
|
+
/**
|
|
645
|
+
* Selection bounds `[left, top, right, bottom]`. Throws when there is no
|
|
646
|
+
* selection.
|
|
647
|
+
*
|
|
648
|
+
* @remarks Units follow `rulerUnits`.
|
|
649
|
+
*/
|
|
650
|
+
get bounds(): Promise<PsBounds>;
|
|
651
|
+
/** Whether the selection is a solid (un-feathered) rectangle. */
|
|
652
|
+
get solid(): Promise<boolean>;
|
|
653
|
+
/** Select the whole canvas. */
|
|
654
|
+
selectAll(): Promise<void>;
|
|
655
|
+
/** Deselect. */
|
|
656
|
+
deselect(): Promise<void>;
|
|
657
|
+
/** Invert the selection. */
|
|
658
|
+
invert(): Promise<void>;
|
|
659
|
+
/**
|
|
660
|
+
* Create a selection from a region of points.
|
|
661
|
+
*
|
|
662
|
+
* @param region polygon points, e.g. `[[0,0],[100,0],[100,100],[0,100]]`.
|
|
663
|
+
* @param type selection operation (optional, defaults to replace).
|
|
664
|
+
* @param feather feather radius in pixels (optional).
|
|
665
|
+
* @param antiAlias anti-alias the edges (optional).
|
|
666
|
+
*
|
|
667
|
+
* @example
|
|
668
|
+
* import { SelectionType } from "@ps-generator-bridge/sdk/plugin";
|
|
669
|
+
* await sel.select([[0,0],[100,0],[100,100],[0,100]], SelectionType.REPLACE, 0, true);
|
|
670
|
+
*/
|
|
671
|
+
select(region: number[][], type?: SelectionTypeValue, feather?: number, antiAlias?: boolean): Promise<void>;
|
|
672
|
+
/** Grow the selection by `by` pixels. */
|
|
673
|
+
expand(by: number): Promise<void>;
|
|
674
|
+
/** Shrink the selection by `by` pixels. */
|
|
675
|
+
contract(by: number): Promise<void>;
|
|
676
|
+
/** Feather the selection edge by `by` pixels. */
|
|
677
|
+
feather(by: number): Promise<void>;
|
|
678
|
+
/** Translate the selection boundary (content stays put). */
|
|
679
|
+
translateBoundary(deltaX: number, deltaY: number): Promise<void>;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* Wraps an ExtendScript Document.
|
|
684
|
+
*
|
|
685
|
+
* @example
|
|
686
|
+
* const doc = this.photoshop.activeDocument;
|
|
687
|
+
* const name = await doc.name;
|
|
688
|
+
* const [width, height] = await Promise.all([doc.width, doc.height]);
|
|
689
|
+
* await doc.save();
|
|
690
|
+
*/
|
|
691
|
+
declare class PhotoshopDocument {
|
|
692
|
+
private readonly _jsx;
|
|
693
|
+
private readonly _path;
|
|
694
|
+
constructor(_jsx: PsJsxRunner, _path: string);
|
|
695
|
+
/** Document name (file name, without directory). */
|
|
696
|
+
get name(): Promise<string>;
|
|
697
|
+
/** Unique document id. */
|
|
698
|
+
get id(): Promise<number>;
|
|
699
|
+
/**
|
|
700
|
+
* Document width.
|
|
701
|
+
*
|
|
702
|
+
* @remarks The unit follows Photoshop's current `app.preferences.rulerUnits`.
|
|
703
|
+
* For guaranteed pixels, set `rulerUnits` to `Units.PIXELS` first (e.g. via
|
|
704
|
+
* `this.jsx.run(...)`).
|
|
705
|
+
*/
|
|
706
|
+
get width(): Promise<number>;
|
|
707
|
+
/**
|
|
708
|
+
* Document height.
|
|
709
|
+
*
|
|
710
|
+
* @remarks The unit follows `rulerUnits` (see {@link width}).
|
|
711
|
+
*/
|
|
712
|
+
get height(): Promise<number>;
|
|
713
|
+
/** Document resolution (PPI). */
|
|
714
|
+
get resolution(): Promise<number>;
|
|
715
|
+
/** Document color mode as an enum-name string (e.g. "DocumentMode.RGB"). */
|
|
716
|
+
get mode(): Promise<string>;
|
|
717
|
+
/** Whether the document is saved since its last change. */
|
|
718
|
+
get saved(): Promise<boolean>;
|
|
719
|
+
/**
|
|
720
|
+
* Full document path (native `fsName`). For an unsaved document this may
|
|
721
|
+
* return a temporary path or throw.
|
|
722
|
+
*/
|
|
723
|
+
get fullName(): Promise<string>;
|
|
724
|
+
/** Directory containing the document (native `fsName`). */
|
|
725
|
+
get path(): Promise<string>;
|
|
726
|
+
/** The active layer. */
|
|
727
|
+
get activeLayer(): PhotoshopLayer;
|
|
728
|
+
/** The Layers collection (ArtLayers + LayerSets). */
|
|
729
|
+
get layers(): PhotoshopLayers;
|
|
730
|
+
/** The selection. */
|
|
731
|
+
get selection(): PhotoshopSelection;
|
|
732
|
+
/** Save the document in its current format. */
|
|
733
|
+
save(): Promise<void>;
|
|
734
|
+
/**
|
|
735
|
+
* Close the document.
|
|
736
|
+
*
|
|
737
|
+
* @param saving save behavior before closing (defaults to not saving).
|
|
738
|
+
*
|
|
739
|
+
* @example
|
|
740
|
+
* import { SaveOptions } from "@ps-generator-bridge/sdk/plugin";
|
|
741
|
+
* await doc.close(SaveOptions.DONOTSAVECHANGES);
|
|
742
|
+
*/
|
|
743
|
+
close(saving?: SaveOptionsValue): Promise<void>;
|
|
744
|
+
/**
|
|
745
|
+
* Save to a path. Mirrors ExtendScript
|
|
746
|
+
* `saveAs(saveIn, options?, asCopy?, extensionType?)`; only `saveIn` and
|
|
747
|
+
* `asCopy` are exposed, `options` is undefined and `extensionType` is left to
|
|
748
|
+
* the Photoshop default.
|
|
749
|
+
*
|
|
750
|
+
* @param saveIn destination path.
|
|
751
|
+
* @param asCopy save as a copy (does not change the document's saved state).
|
|
752
|
+
*/
|
|
753
|
+
saveAs(saveIn: string, asCopy?: boolean): Promise<void>;
|
|
754
|
+
/** Flatten all layers into a single background layer. */
|
|
755
|
+
flatten(): Promise<void>;
|
|
756
|
+
/** Merge all visible layers. */
|
|
757
|
+
mergeVisibleLayers(): Promise<void>;
|
|
758
|
+
/** Rasterize all layers. */
|
|
759
|
+
rasterizeAllLayers(): Promise<void>;
|
|
760
|
+
/**
|
|
761
|
+
* Duplicate the document.
|
|
762
|
+
*
|
|
763
|
+
* @param name optional name for the copy.
|
|
764
|
+
* @returns the duplicated document.
|
|
765
|
+
*
|
|
766
|
+
* @remarks Assumes `duplicate()` makes the copy the active document, so the
|
|
767
|
+
* result points at `app.activeDocument`.
|
|
768
|
+
*/
|
|
769
|
+
duplicate(name?: string): Promise<PhotoshopDocument>;
|
|
770
|
+
/**
|
|
771
|
+
* Resize the canvas.
|
|
772
|
+
*
|
|
773
|
+
* @param width new width in pixels.
|
|
774
|
+
* @param height new height in pixels.
|
|
775
|
+
* @param anchor anchor position (optional, defaults to center).
|
|
776
|
+
*
|
|
777
|
+
* @example
|
|
778
|
+
* import { AnchorPosition } from "@ps-generator-bridge/sdk/plugin";
|
|
779
|
+
* await doc.resizeCanvas(1920, 1080, AnchorPosition.MIDDLECENTER);
|
|
780
|
+
*/
|
|
781
|
+
resizeCanvas(width: number, height: number, anchor?: string): Promise<void>;
|
|
782
|
+
/**
|
|
783
|
+
* Resize the image.
|
|
784
|
+
*
|
|
785
|
+
* @param width new width in pixels (optional).
|
|
786
|
+
* @param height new height in pixels (optional).
|
|
787
|
+
* @param resolution new resolution in PPI (optional).
|
|
788
|
+
*/
|
|
789
|
+
resizeImage(width?: number, height?: number, resolution?: number): Promise<void>;
|
|
790
|
+
/** Rotate the canvas by `angle` degrees. */
|
|
791
|
+
rotateCanvas(angle: number): Promise<void>;
|
|
792
|
+
/**
|
|
793
|
+
* Crop the document to `bounds` `[left, top, right, bottom]` (pixels).
|
|
794
|
+
*
|
|
795
|
+
* @remarks Only `bounds` is exposed; ExtendScript `crop()` also takes angle,
|
|
796
|
+
* width and height — reach those via `this.jsx.run(...)` if needed.
|
|
797
|
+
*/
|
|
798
|
+
crop(bounds: PsBounds): Promise<void>;
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
/**
|
|
802
|
+
* Wraps the ExtendScript global `app` object.
|
|
803
|
+
*
|
|
804
|
+
* @example
|
|
805
|
+
* const version = await this.photoshop.app.version; // "25.0"
|
|
806
|
+
* await this.photoshop.app.open("/path/to/design.psd");
|
|
807
|
+
*/
|
|
808
|
+
declare class PhotoshopApp {
|
|
809
|
+
private readonly _jsx;
|
|
810
|
+
private readonly _path;
|
|
811
|
+
constructor(_jsx: PsJsxRunner);
|
|
812
|
+
/** Photoshop version (e.g. "25.0"). */
|
|
813
|
+
get version(): Promise<string>;
|
|
814
|
+
/** Application locale (e.g. "zh_CN"). */
|
|
815
|
+
get locale(): Promise<string>;
|
|
816
|
+
/** Application name (e.g. "Adobe Photoshop"). */
|
|
817
|
+
get name(): Promise<string>;
|
|
818
|
+
/** Internal build number. */
|
|
819
|
+
get build(): Promise<string>;
|
|
820
|
+
/**
|
|
821
|
+
* Install path (native `fsName`). `app.path` is a File in ExtendScript, so the
|
|
822
|
+
* string comes from `.fsName`.
|
|
823
|
+
*/
|
|
824
|
+
get path(): Promise<string>;
|
|
825
|
+
/**
|
|
826
|
+
* Current foreground color (RGB).
|
|
827
|
+
*
|
|
828
|
+
* @remarks The first version returns only the RGB approximation; in CMYK/Lab
|
|
829
|
+
* documents this is Photoshop's converted RGB and may lose precision. The
|
|
830
|
+
* `cmyk` field is reserved and currently always undefined.
|
|
831
|
+
*/
|
|
832
|
+
get foregroundColor(): Promise<PsColor>;
|
|
833
|
+
/** Shortcut for `activeDocument` reached through the `app` path. */
|
|
834
|
+
get activeDocument(): PhotoshopDocument;
|
|
835
|
+
/**
|
|
836
|
+
* Open a file and return its Document wrapper. The opened document becomes the
|
|
837
|
+
* active document.
|
|
838
|
+
*
|
|
839
|
+
* @param filePath native or POSIX path.
|
|
840
|
+
*
|
|
841
|
+
* @example
|
|
842
|
+
* const doc = await this.photoshop.app.open("/Users/me/design.psd");
|
|
843
|
+
*/
|
|
844
|
+
open(filePath: string): Promise<PhotoshopDocument>;
|
|
845
|
+
/** Emit a beep. */
|
|
846
|
+
beep(): Promise<void>;
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
/**
|
|
850
|
+
* Entry point of the Photoshop DOM proxy. A plugin reaches it through
|
|
851
|
+
* `this.photoshop`:
|
|
852
|
+
*
|
|
853
|
+
* ```ts
|
|
854
|
+
* const version = await this.photoshop.app.version;
|
|
855
|
+
* const name = await this.photoshop.activeDocument.name;
|
|
856
|
+
* ```
|
|
857
|
+
*
|
|
858
|
+
* Transport-agnostic: every property read and method call lowers to an
|
|
859
|
+
* ExtendScript string run through the injected {@link PsJsxRunner}. The proxy
|
|
860
|
+
* holds no PS state of its own.
|
|
861
|
+
*
|
|
862
|
+
* @remarks
|
|
863
|
+
* - `app` maps to the ExtendScript global `app` (Application).
|
|
864
|
+
* - `activeDocument` is a shortcut for `app.activeDocument`.
|
|
865
|
+
* - With no active document, reading any property of `activeDocument` throws.
|
|
866
|
+
*/
|
|
867
|
+
declare class PsPhotoshopProxy {
|
|
868
|
+
/** Application wrapper; its path is fixed to "app". */
|
|
869
|
+
readonly app: PhotoshopApp;
|
|
870
|
+
private readonly _jsx;
|
|
871
|
+
constructor(jsx: PsJsxRunner);
|
|
872
|
+
/**
|
|
873
|
+
* The active document (shortcut for `app.activeDocument`). A fresh wrapper is
|
|
874
|
+
* created on each access; wrappers are lightweight and stateless.
|
|
875
|
+
*/
|
|
876
|
+
get activeDocument(): PhotoshopDocument;
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
export { AnchorPosition as A, type Bounds as B, ElementPlacement as C, DocumentMode as D, type EventName as E, type ElementPlacementValue as F, LayerKind as G, type LayerKindValue as H, type ImageChangedEvent as I, PhotoshopApp as J, PhotoshopDocument as K, type LayerSpec as L, type MethodName as M, PhotoshopLayer as N, PhotoshopLayers as O, type ProtocolMethods as P, PhotoshopSelection as Q, type RequestEnvelope as R, type ServerInfo as S, type PsBounds as T, type PsColor as U, SaveOptions as V, type WsImageResult as W, type SaveOptionsValue as X, SelectionType as Y, type SelectionTypeValue as Z, type ProtocolEvents as a, type PhotoshopEventName as b, type PhotoshopEventMap as c, type PsJsxRunner as d, PsPhotoshopProxy as e, type PluginInfo as f, ProtocolMethod as g, type PsLayer as h, type PsDocument as i, ErrorCode as j, type EventEnvelope as k, type ImageChangedLayer as l, PROTOCOL_VERSION as m, type ProtocolError as n, type PsBounds$1 as o, type PsRect as p, type ResponseEnvelope as q, isEvent as r, isRequest as s, isResponse as t, parseFrame as u, serializeFrame as v, type AnchorPositionValue as w, BlendMode as x, type BlendModeValue as y, type DocumentModeValue as z };
|