@bubblydoo/photoshop-mcp 0.0.2

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 (88) hide show
  1. package/README.md +138 -0
  2. package/dist/index.d.ts +1 -0
  3. package/dist/index.js +7049 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist-readmes/README.md +383 -0
  6. package/dist-runtime/runtime-code.cjs +17124 -0
  7. package/dist-runtime/runtime-code.d.cts +9 -0
  8. package/dist-schemas/@adobe-uxp-types/photoshop/src/index.d.ts +16 -0
  9. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/all-types.d.ts +65 -0
  10. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/Actions.d.ts +230 -0
  11. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/Channel.d.ts +120 -0
  12. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/ColorSampler.d.ts +105 -0
  13. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/Constants.d.ts +1648 -0
  14. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/CoreModules.d.ts +922 -0
  15. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/CountItem.d.ts +86 -0
  16. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/Document.d.ts +931 -0
  17. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/Guide.d.ts +105 -0
  18. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/HistoryState.d.ts +74 -0
  19. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/ImagingModule.d.ts +559 -0
  20. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/Layer.d.ts +1073 -0
  21. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/LayerComp.d.ts +219 -0
  22. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/Objects.d.ts +7 -0
  23. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/PathItem.d.ts +243 -0
  24. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/PathPoint.d.ts +78 -0
  25. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/Photoshop.d.ts +317 -0
  26. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/Selection.d.ts +557 -0
  27. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/SubPathItem.d.ts +69 -0
  28. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/TextItem.d.ts +213 -0
  29. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/collections/Channels.d.ts +81 -0
  30. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/collections/ColorSamplers.d.ts +97 -0
  31. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/collections/CountItems.d.ts +130 -0
  32. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/collections/Documents.d.ts +95 -0
  33. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/collections/Guides.d.ts +76 -0
  34. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/collections/HistoryStates.d.ts +56 -0
  35. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/collections/LayerComps.d.ts +92 -0
  36. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/collections/Layers.d.ts +68 -0
  37. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/collections/PathItems.d.ts +65 -0
  38. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/collections/PathPoints.d.ts +50 -0
  39. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/collections/SubPathItems.d.ts +50 -0
  40. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/collections/TextFonts.d.ts +43 -0
  41. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/objects/Colors.d.ts +225 -0
  42. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/objects/ConversionOptions.d.ts +213 -0
  43. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/objects/ImagingBounds.d.ts +53 -0
  44. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/objects/PathPointInfo.d.ts +84 -0
  45. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/objects/SaveOptions.d.ts +376 -0
  46. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/objects/SolidColor.d.ts +118 -0
  47. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/objects/SubPathInfo.d.ts +47 -0
  48. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/objects/TextFont.d.ts +49 -0
  49. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/objects/Tool.d.ts +23 -0
  50. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/preferences/Preferences.d.ts +121 -0
  51. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/preferences/PreferencesBase.d.ts +9 -0
  52. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/preferences/PreferencesCursors.d.ts +37 -0
  53. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/preferences/PreferencesFileHandling.d.ts +58 -0
  54. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/preferences/PreferencesGeneral.d.ts +77 -0
  55. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/preferences/PreferencesGuidesGridsAndSlices.d.ts +51 -0
  56. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/preferences/PreferencesHistory.d.ts +69 -0
  57. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/preferences/PreferencesInterface.d.ts +46 -0
  58. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/preferences/PreferencesPerformance.d.ts +42 -0
  59. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/preferences/PreferencesTools.d.ts +44 -0
  60. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/preferences/PreferencesTransparencyAndGamut.d.ts +38 -0
  61. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/preferences/PreferencesType.d.ts +44 -0
  62. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/preferences/PreferencesUnitsAndRulers.d.ts +44 -0
  63. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/text/CharacterStyle.d.ts +254 -0
  64. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/text/ParagraphStyle.d.ts +114 -0
  65. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/text/TextWarpStyle.d.ts +48 -0
  66. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/types/ApplyImageTypes.d.ts +107 -0
  67. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/types/CalculationsTypes.d.ts +119 -0
  68. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/types/DocumentTypes.d.ts +80 -0
  69. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/types/LayerCompTypes.d.ts +91 -0
  70. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/types/LayerTypes.d.ts +153 -0
  71. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/types/SharedTypes.d.ts +6 -0
  72. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/dom/types/TextTypes.d.ts +218 -0
  73. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/util/colorTypes.d.ts +61 -0
  74. package/dist-schemas/@adobe-uxp-types/photoshop/src/internal/util/unit.d.ts +45 -0
  75. package/dist-schemas/@adobe-uxp-types/uxp/src/index.d.ts +21 -0
  76. package/dist-schemas/@adobe-uxp-types/uxp/src/internal/all-types.d.ts +3 -0
  77. package/dist-schemas/@adobe-uxp-types/uxp/src/internal/dialog.d.ts +26 -0
  78. package/dist-schemas/@adobe-uxp-types/uxp/src/internal/entrypoints.d.ts +385 -0
  79. package/dist-schemas/@adobe-uxp-types/uxp/src/internal/host.d.ts +28 -0
  80. package/dist-schemas/@adobe-uxp-types/uxp/src/internal/os.d.ts +56 -0
  81. package/dist-schemas/@adobe-uxp-types/uxp/src/internal/other.d.ts +7 -0
  82. package/dist-schemas/@adobe-uxp-types/uxp/src/internal/shell.d.ts +54 -0
  83. package/dist-schemas/@adobe-uxp-types/uxp/src/internal/storage.d.ts +1216 -0
  84. package/dist-schemas/@adobe-uxp-types/uxp/src/internal/versions.d.ts +18 -0
  85. package/dist-schemas/@bubblydoo/uxp-toolkit/dist/commands-library/index.d.ts +109 -0
  86. package/dist-schemas/@bubblydoo/uxp-toolkit/dist/index.d.ts +153 -0
  87. package/dist-schemas/@bubblydoo/uxp-toolkit/dist/psLayerRef-BJKcxKbm.d.ts +66 -0
  88. package/package.json +51 -0
@@ -0,0 +1,922 @@
1
+ import type {
2
+ CMYKColorDescriptor,
3
+ ColorConversionModel,
4
+ ColorDescriptor,
5
+ GrayscaleColorDescriptor,
6
+ HSBColorDescriptor,
7
+ LabColorDescriptor,
8
+ RGB32ColorDescriptor,
9
+ RGBColorDescriptor,
10
+ } from '../util/colorTypes';
11
+ /** @ignore */
12
+ declare type NotificationListener = (name: string, descriptor: ActionDescriptor) => void;
13
+ /** @ignore */
14
+ export interface ActionReference {
15
+ [index: string]: number | string;
16
+ }
17
+ /** @ignore */
18
+ export interface ActionDescriptor {
19
+ _obj: string;
20
+ [prop: string]: any;
21
+ }
22
+ /**
23
+ * @targetfolder objects/returnobjects
24
+ * @minVersion 22.5
25
+ */
26
+ interface Scheduling {
27
+ playLevel?: number;
28
+ eventLevel?: number;
29
+ timeOut?: number;
30
+ }
31
+ /**
32
+ * @optionobject
33
+ * @targetfolder objects/options
34
+ * @minVersion 23.0
35
+ */
36
+ export interface BatchPlayCommandOptions {
37
+ /**
38
+ * @minVersion 23.0
39
+ */
40
+ commandEnablement?: 'normal' | 'never' | 'always';
41
+ /**
42
+ * @minVersion 23.0
43
+ */
44
+ dialogOptions?: 'silent' | 'dontDisplay' | 'display';
45
+ /**
46
+ * @minVersion 23.0
47
+ */
48
+ propagateErrorToDefaultHandler?: boolean;
49
+ /**
50
+ * @minVersion 23.0
51
+ */
52
+ synchronousExecution?: boolean;
53
+ /**
54
+ * @minVersion 23.0
55
+ */
56
+ modalBehavior?: 'wait' | 'execute' | 'fail';
57
+ /**
58
+ * @minVersion 23.0
59
+ */
60
+ useMultiGet?: boolean;
61
+ /**
62
+ * @minVersion 23.0
63
+ */
64
+ suppressPlayLevelIncrease?: boolean;
65
+ /**
66
+ * Do not stop a batchPlay when a descriptor fails and continue with remaining descriptors in batch.
67
+ * @minVersion 24.5
68
+ */
69
+ continueOnError?: boolean;
70
+ /**
71
+ * When true, then Photoshop will update its UI after all the descriptors have been executed.
72
+ */
73
+ immediateRedraw?: boolean;
74
+ }
75
+ export type CPUVendorKind = 'Intel' | 'AMD' | 'ARM' | 'Unknown';
76
+ /**
77
+ * @targetfolder objects/returnobjects
78
+ * @minVersion 23.0
79
+ */
80
+ export interface CPUInfo {
81
+ /**
82
+ * @minVersion 23.0
83
+ */
84
+ vendor: CPUVendorKind;
85
+ /**
86
+ * @minVersion 23.0
87
+ */
88
+ physicalCores: number;
89
+ /**
90
+ * @minVersion 23.0
91
+ */
92
+ logicalCores: number;
93
+ /**
94
+ * @minVersion 23.0
95
+ */
96
+ frequencyMhz: number;
97
+ /**
98
+ * @minVersion 23.0
99
+ */
100
+ emulationMode?: 'rosetta2';
101
+ }
102
+ /**
103
+ * @targetfolder objects/returnobjects
104
+ * @minVersion 23.0
105
+ */
106
+ export interface OpenGLDeviceInfo {
107
+ /**
108
+ * @minVersion 23.0
109
+ */
110
+ version: string;
111
+ /**
112
+ * @minVersion 23.0
113
+ */
114
+ memoryMB: number;
115
+ /**
116
+ * @minVersion 23.0
117
+ */
118
+ name: string;
119
+ /**
120
+ * @minVersion 23.0
121
+ */
122
+ driverVersion: string;
123
+ /**
124
+ * @minVersion 23.0
125
+ */
126
+ vendor: string;
127
+ /**
128
+ * @minVersion 23.0
129
+ */
130
+ isIntegrated: string;
131
+ /**
132
+ * @minVersion 23.0
133
+ */
134
+ glDriver: string;
135
+ }
136
+ /**
137
+ * @targetfolder objects/returnobjects
138
+ * @minVersion 23.0
139
+ */
140
+ export interface OpenCLDeviceInfo {
141
+ /**
142
+ * @minVersion 23.0
143
+ */
144
+ version: string;
145
+ /**
146
+ * @minVersion 23.0
147
+ */
148
+ memoryMB: number;
149
+ /**
150
+ * @minVersion 23.0
151
+ */
152
+ name: string;
153
+ /**
154
+ * @minVersion 23.0
155
+ */
156
+ driverVersion: string;
157
+ /**
158
+ * @minVersion 23.0
159
+ */
160
+ vendor: string;
161
+ /**
162
+ * @minVersion 23.0
163
+ */
164
+ isIntegrated: string;
165
+ /**
166
+ * @minVersion 23.0
167
+ */
168
+ oclBandwidth: number;
169
+ /**
170
+ * @minVersion 23.0
171
+ */
172
+ oclCompute: number;
173
+ /**
174
+ * @minVersion 23.0
175
+ */
176
+ clDeviceVersion: string;
177
+ /**
178
+ * @minVersion 23.0
179
+ */
180
+ clPlatformVersion: string;
181
+ }
182
+ /**
183
+ * @targetfolder objects/returnobjects
184
+ * @minVersion 23.0
185
+ */
186
+ export interface GPUInfo {
187
+ /**
188
+ * @minVersion 23.0
189
+ */
190
+ gpuInfoList?: OpenGLDeviceInfo[];
191
+ /**
192
+ * @minVersion 23.0
193
+ */
194
+ clgpuInfoList?: OpenCLDeviceInfo[];
195
+ }
196
+ /**
197
+ * @targetfolder objects/returnobjects
198
+ * @minVersion 23.0
199
+ */
200
+ interface LayerTreeInfo {
201
+ /**
202
+ * @minVersion 23.0
203
+ */
204
+ name: string;
205
+ /**
206
+ * @minVersion 23.0
207
+ */
208
+ layerID: number;
209
+ /**
210
+ * @minVersion 23.0
211
+ */
212
+ kind: string;
213
+ /**
214
+ * @minVersion 23.0
215
+ */
216
+ layers?: LayerTreeInfo[];
217
+ }
218
+ /**
219
+ * The module that facilitates Actions being performed in the
220
+ * UXP-Photoshop world. You may perform your own `batchPlay` commands,
221
+ * or attach listeners using this module.
222
+ *
223
+ * ```javascript
224
+ * var action = require('photoshop').action;
225
+ * ```
226
+ *
227
+ * @targetfolder media
228
+ */
229
+ export interface ActionModule {
230
+ /**
231
+ * Performs a batchPlay call with the provided commands. Equivalent
232
+ * to an `executeAction` in ExtendScript.
233
+ * ```javascript
234
+ * var target = { _ref: 'layer', _enum: 'ordinal', _value: 'targetEnum'}
235
+ * var commands = [{ _obj: 'hide', _target: target }]
236
+ * await action.batchPlay(commands)
237
+ * ```
238
+ * @minVersion 23.0
239
+ */
240
+ batchPlay: (
241
+ commands: ActionDescriptor[],
242
+ options?: BatchPlayCommandOptions,
243
+ ) => Promise<ActionDescriptor[]>;
244
+ /**
245
+ * Attach a listener to a Photoshop event. A callback in the form
246
+ * of `(eventName: string, descriptor: Descriptor) => void` will be performed.
247
+ * ```javascript
248
+ * await action.addNotificationListener(['open'], onOpenNewDocument)
249
+ * ```
250
+ * @minVersion 23.0
251
+ */
252
+ addNotificationListener: (events: string[], notifier: NotificationListener) => Promise<void>;
253
+ /**
254
+ * Detaches a listener from a Photoshop event.
255
+ * See [addNotificationListener](#addNotificationListener)
256
+ * ```javascript
257
+ * await action.removeNotificationListener(['open'], onOpenNewDocument)
258
+ * ```
259
+ * @minVersion 23.0
260
+ */
261
+ removeNotificationListener: (events: string[], notifier: NotificationListener) => Promise<void>;
262
+ /**
263
+ * Synchronously validates the given action reference, returning true if it still
264
+ * exists. For example, calling this with a closed document would return false.
265
+ *
266
+ * This feature is intended for advanced developers who understand well how batchPlay works.
267
+ * Validate reference could get handy when you want to add new DOM functionality or use low-level code for
268
+ * performance optimization.
269
+ *
270
+ * See [Action references](../batchplay#action-references) for details.
271
+ *
272
+ * Supported reference classes:
273
+ * `action`,
274
+ * `document`,
275
+ * `channel`,
276
+ * `layer`,
277
+ * `guide`,
278
+ * `historyState`,
279
+ * `compsClass`,
280
+ * `path`,
281
+ * `actionSet`
282
+ *
283
+ * @minVersion 23.1
284
+ */
285
+ validateReference: (ref: ActionReference | ActionReference[]) => boolean;
286
+ /**
287
+ * Return the identifier number assigned to an action string value.
288
+ * If the string is not already registered, a new ID will be created and returned.
289
+ * @minVersion 24.0
290
+ */
291
+ getIDFromString: (value: string) => number;
292
+ }
293
+
294
+ /**
295
+ * The set of lower level APIs for interfacing with the action system, including `batchPlay`,
296
+ * evolution of `executeAction`
297
+ */
298
+ export const action: ActionModule;
299
+
300
+ /**
301
+ * The module that allows access to specialized commands
302
+ * within the application. Various application state can be
303
+ * modified or queried here.
304
+ *
305
+ * ```javascript
306
+ * var PhotoshopCore = require('photoshop').core;
307
+ * ```
308
+ *
309
+ * @targetfolder media
310
+ */
311
+ export interface Core {
312
+ /**
313
+ * API Version declared by the plugin's manifest.json under `host.data.apiVersion` field.
314
+ *
315
+ * If value 1, you will have access to Photoshop 22.0 DOM and be able to make mutable calls outside a modal state.
316
+ * If 2, you will have access to latest DOM, modal execution and everything else new we're adding.
317
+ * @minVersion 22.5
318
+ */
319
+ apiVersion: number;
320
+ /**
321
+ * Returns true if the plugin is currently in a modal state using {@link executeAsModal}
322
+ * @minVersion 23.1
323
+ */
324
+ isModal: () => boolean;
325
+ /**
326
+ * Given a Photoshop ZString (of format `"$$$/slash/separated/key=english default value"`),
327
+ * will return the translated string for the current UI language
328
+ * @minVersion 22.5
329
+ */
330
+ translateUIString: (zstring: string) => string;
331
+ /**
332
+ * Invokes the menu command via its `commandID`. Returns false
333
+ * on failure, or if the command is not available.
334
+ * ```javascript
335
+ * // select all
336
+ * await PhotoshopCore.performMenuCommand({ commandID: 1017 })
337
+ * ```
338
+ * @minVersion 22.5
339
+ * @async
340
+ */
341
+ performMenuCommand: (options: MenuCommandOptions) => Promise<PerformMenuCommandResult>;
342
+ /**
343
+ * Returns whether a command menu item is available for invoking.
344
+ * ```javascript
345
+ * // can a Fill be performed?
346
+ * var canFill = await PhotoshopCore.getMenuCommandState({ commandID: 1042 })
347
+ * ```
348
+ * @minVersion 22.5
349
+ * @async
350
+ */
351
+ getMenuCommandState: (options: MenuCommandOptions) => Promise<[boolean]>;
352
+ /**
353
+ * Returns the localized menu title of the menu command item.
354
+ * ```javascript
355
+ * var renameLayerStr = await PhotoshopCore.getMenuCommandTitle({ commandID: 2983 })
356
+ * ```
357
+ * @minVersion 22.5
358
+ * @async
359
+ */
360
+ getMenuCommandTitle: (options: MenuCommandMenuIDOptions) => any;
361
+ getMenuCommandTitle: (options: MenuCommandOptions) => any;
362
+ /**
363
+ * Returns information about the active Photoshop tool.
364
+ * ```javascript
365
+ * { title } = await PhotoshopCore.getActiveTool()
366
+ * ```
367
+ * @minVersion 22.5
368
+ * @async
369
+ */
370
+ getActiveTool: () => Promise<GetActiveToolResult>;
371
+ /**
372
+ * Returns information about the host CPU.
373
+ * ```javascript
374
+ * { logicalCores, frequencyMhz, vendor } = PhotoshopCore.getCPUInfo()
375
+ * var isAMD = vendor === "AMD"
376
+ * var isARM = vendor === "ARM"
377
+ * ```
378
+ * @minVersion 23.1
379
+ */
380
+ getCPUInfo: () => CPUInfo;
381
+ /**
382
+ * Returns OpenGL and OpenCL information about the available graphics processor.
383
+ * ```javascript
384
+ * { gpuInfoList, clgpuInfoList } = PhotoshopCore.getGPUInfo()
385
+ * console.log(JSON.stringify(gpuInfoList))
386
+ * // > [{"version":"2.1 ATI-4.5.14","memoryMB":8192,"name":"16915464", ...}]
387
+ * console.log(JSON.stringify(clgpuInfoList))
388
+ * // > [{"version":"OpenCL 1.2 ","memoryMB":8589,"name":"AMD Radeon Pro 580X Compute Engine", ...}]
389
+ * ```
390
+ * @minVersion 23.1
391
+ */
392
+ getGPUInfo: () => GPUInfo;
393
+ /**
394
+ * End the current modal tool editing state.
395
+ * ```javascript
396
+ * // close the modal dialog, cancelling changes
397
+ * await PhotoshopCore.endModalToolState(false)
398
+ * ```
399
+ * @minVersion 22.5
400
+ * @async
401
+ */
402
+ endModalToolState: (commit: boolean) => Promise<void>;
403
+ /**
404
+ * Request that Photoshop redraws (updates) a document immediately.
405
+ * This method can be used to ensure that the document is updated
406
+ * immediately while a user is interacting with a UI element (such as a slider).
407
+ * This can provide a more responsive interaction.
408
+ * Updating a document can be time consuming, and will often happen at a lower frequency
409
+ * than UI events are received.
410
+ * Plugins may therefore want to implement a throttle between UI events and calls to
411
+ * redrawDocument.
412
+ * A throttle could be implemented by using a timer, or by avoiding to call redrawDocument
413
+ * for a small amount of time after a previous request completes.
414
+ * redrawDocument returns the time that it took Photoshop to update the target document
415
+ * in seconds. This number can be used to refine the throttle.
416
+ * redrawDocument is only available to a plugin that is using apiVersion 2 or higher.
417
+ * ```javascript
418
+ * await PhotoshopCore.redrawDocument({ documentID: 123})
419
+ * ```
420
+ *
421
+ * Note: This is not available if DOM API version is set to `1`.
422
+ *
423
+ * @minVersion 24.1
424
+ * @async
425
+ */
426
+ redrawDocument: (options: RedrawDocumentOptions) => Promise<number>;
427
+ /**
428
+ * Show a generic alert box to the user. 'OK' to dismiss.
429
+ * ```javascript
430
+ * // script has completed.
431
+ * await PhotoshopCore.showAlert({ message: 'Operation successful'})
432
+ * ```
433
+ * @minVersion 22.5
434
+ * @async
435
+ */
436
+ showAlert: (
437
+ options: string | {
438
+ message: string;
439
+ },
440
+ ) => Promise<void>;
441
+ /**
442
+ * Returns the effective size of a dialog.
443
+ * ```javascript
444
+ * var idealSize = { width: 200, height: 500 }
445
+ * { width, height} = await PhotoshopCore.calculateDialogSize(idealSize)
446
+ * ```
447
+ * @minVersion 22.5
448
+ * @async
449
+ */
450
+ calculateDialogSize: (options: {
451
+ preferredSize: {
452
+ width: number;
453
+ height: number;
454
+ };
455
+ identifier?: string;
456
+ minimumSize?: {
457
+ width: number;
458
+ height: number;
459
+ };
460
+ }) => Promise<{
461
+ width: number;
462
+ height: number;
463
+ }>;
464
+ /**
465
+ * ExecuteAsModal is needed when a plugin wants to make modifications to the Photoshop state.
466
+ * This includes scenarios where the plugin wants to create or modify documents,
467
+ * or the plugin wants to update UI or preference state.
468
+ *
469
+ * ExecuteAsModal is only available to plugin that is using apiVersion 2 or higher.
470
+ *
471
+ * See [Modal Execution](../executeasmodal) for details
472
+ *
473
+ * ***Fixes in Photoshop 24.0:***
474
+ * - *Returned values can now be instances of classes and contain functions*
475
+ *
476
+ * @minVersion 22.5
477
+ * @async
478
+ */
479
+ executeAsModal: <T>(
480
+ targetFunction: (executionContext: ExecutionContext, descriptor?: object) => Promise<T>,
481
+ options: ExecuteAsModalOptions,
482
+ ) => Promise<T>;
483
+ /**
484
+ * Converts the given color (in descriptor form) to RGB,
485
+ * returning the color descriptor.
486
+ *
487
+ * This is an internal API that is used for {@link SolidColor}
488
+ * and all the other color classes.
489
+ *
490
+ * Currently, this API uses the application color settings
491
+ * for conversion (Edit > Color Settings...). '
492
+ * In the future, we will provide color conversion
493
+ * based on embedded color profiles.
494
+ * @minVersion 23.0
495
+ */
496
+ convertColor: (
497
+ sourceColor: ColorDescriptor,
498
+ targetModel: ColorConversionModel.RGB,
499
+ ) => RGBColorDescriptor | RGB32ColorDescriptor;
500
+ /**
501
+ * Convert to Lab
502
+ * @minVersion 23.0
503
+ */
504
+ convertColor: (sourceColor: ColorDescriptor, targetModel: ColorConversionModel.Lab) => LabColorDescriptor;
505
+ /**
506
+ * Convert to HSB
507
+ * @minVersion 23.0
508
+ */
509
+ convertColor: (sourceColor: ColorDescriptor, targetModel: ColorConversionModel.HSB) => HSBColorDescriptor;
510
+ /**
511
+ * Convert to Grayscale
512
+ * @minVersion 23.0
513
+ */
514
+ convertColor: (
515
+ sourceColor: ColorDescriptor,
516
+ targetModel: ColorConversionModel.Gray,
517
+ ) => GrayscaleColorDescriptor;
518
+ /**
519
+ * Convert to CMYK
520
+ * @minVersion 23.0
521
+ */
522
+ convertColor: (sourceColor: ColorDescriptor, targetModel: ColorConversionModel.CMYK) => CMYKColorDescriptor;
523
+ /**
524
+ * The execution mode can be used while debugging a plugin. It is only available
525
+ * when the developer mode is enabled.
526
+ *
527
+ * The following example illustrate how to enable stacktraces for batchPlay commands
528
+ * that fail. When stacktraces are enabled, then an error result descriptor from a
529
+ * batchPlay request will include a stacktrace property. The property can be used when
530
+ * reporting bugs to Adobe.
531
+ * ```javascript
532
+ * await PhotoshopCore.setExecutionMode({ enableErrorStacktraces: true })
533
+ * ```
534
+ * The following illustrates how to enable console warnings when a promise is rejected:
535
+ * ```javascript
536
+ * await PhotoshopCore.setExecutionMode({ logRejections: true })
537
+ * ```
538
+ * @minVersion 23.2
539
+ * @async
540
+ */
541
+ setExecutionMode: (options: SetExecutionModeOptions) => Promise<void>;
542
+ /**
543
+ * Return information about the execution of the plugin.
544
+ * This method is intended for developing plugins.
545
+ * Shipping code should not use this method.
546
+ *
547
+ * The returned information include the following properties:
548
+ *
549
+ * `numberOfPendingMainThreadTasks`: Number of pending promises.
550
+ *
551
+ * `batchPlayCount`: Number of `batchPlay` calls since the plugin was loaded.
552
+ *
553
+ * `mainThreadTimeOutCount`: Number of JavaScript calls that have timed out.
554
+ * This is typically caused by executing commands while Photoshop is modal without using
555
+ * `executeAsModal`.
556
+ *
557
+ * `v8HeapSize`: V8 heap allocated for the plugin. This number is only accurate
558
+ * when loading plugins through the UXP Developer Tool.
559
+ *
560
+ * ```javascript
561
+ * await PhotoshopCore.getPluginInfo()
562
+ * ```
563
+ * @minVersion 23.2
564
+ * @async
565
+ */
566
+ getPluginInfo: () => Promise<GetPluginInfoResult>;
567
+ /**
568
+ * Attach a listener to a Photoshop core event. A callback in the form
569
+ * of `(eventName: string, descriptor: Descriptor) => void` will be performed.
570
+ * The event(s) below are supported:
571
+ *
572
+ * group: '`UI`', event: '`userIdle`'
573
+ *
574
+ * - Invoked after the Photoshop user idles for a specified number of seconds. See {@link setUserIdleTime}.
575
+ * - Invoked a second time with the descriptor `{idleEnd: true}` if the user is no longer idle. This signal can
576
+ * be used to finish up tasks being performed during the idle time.
577
+ * ```javascript
578
+ * await PhotoshopCore.addNotificationListener('UI', ['userIdle'], onUserIdle)
579
+ * ```
580
+ * @minVersion 23.3
581
+ * @async
582
+ */
583
+ addNotificationListener: (group: string, events: string[], notifier: NotificationListener) => Promise<void>;
584
+ /**
585
+ * Specifies the number of seconds a user must be idle on Photoshop before invoking the
586
+ * userIdle event handler defined with {@link addNotificationListener}. An idleTime of 0
587
+ * turns off idle notifications.
588
+ *
589
+ * ```javascript
590
+ * await PhotoshopCore.setUserIdleTime(3)
591
+ * ```
592
+ * @minVersion 23.3
593
+ */
594
+ setUserIdleTime: (idleTime: number) => Promise<void>;
595
+ /**
596
+ * Changes visibility of resize gripper in bottom right corner of panel. This can be useful when resize gripper
597
+ * is obstructing the view o panel content.
598
+ */
599
+ suppressResizeGripper: (options: SuppressResizeGripperOptions) => Promise<void>;
600
+ /**
601
+ * Returns display configuration with information about each display
602
+ */
603
+ getDisplayConfiguration: (options: DisplayConfigurationOptions) => Promise<DisplayConfiguration[]>;
604
+ /**
605
+ * Gets the number of seconds a user must be idle on Photoshop before invoking the
606
+ * userIdle event handler defined with {@link addNotificationListener}. An idleTime of 0
607
+ * means turned off idle notifications.
608
+ */
609
+ getUserIdleTime: () => Promise<number>;
610
+ }
611
+
612
+ /**
613
+ * The set of lower level APIs for directly interfacing with Photoshop UI and user
614
+ */
615
+ export const core: Core;
616
+
617
+ /**
618
+ * @targetfolder objects/returnobjects
619
+ */
620
+ export interface GetPluginInfoResult {
621
+ _obj: 'pluginInfo';
622
+ batchPlayCount: number;
623
+ isFirstParty: boolean;
624
+ launchTimeImpact: number;
625
+ mainThreadTimeOutCount: number;
626
+ mainThreadUnhandledExceptionCount: number;
627
+ name?: string;
628
+ numberOfPendingMainThreadTasks: number;
629
+ path?: string;
630
+ pendingDeferralCount: number;
631
+ pluginLoadTime: number;
632
+ usedMainThreadTime: number;
633
+ v8HeapSize: number;
634
+ version?: string;
635
+ }
636
+ /**
637
+ * @targetfolder objects/returnobjects
638
+ */
639
+ export interface LayerTreeList {
640
+ list: LayerTreeInfo[];
641
+ }
642
+ /**
643
+ * @optionobject
644
+ * @targetfolder objects/options
645
+ */
646
+ export type GetLayerGroupContentsOptions = GetLayerParentOptions;
647
+ /**
648
+ * @optionobject
649
+ * @targetfolder objects/options
650
+ */
651
+ export type HistorySuspendedOptions = DocumentCoreOptions;
652
+ /**
653
+ * @optionobject
654
+ * @targetfolder objects/options
655
+ */
656
+ export type GetLayerTreeOptions = DocumentCoreOptions;
657
+ interface DocumentCoreOptions {
658
+ documentID: number;
659
+ }
660
+ interface GetLayerParentOptions {
661
+ documentID: number;
662
+ layerID: number;
663
+ }
664
+ /**
665
+ * @targetfolder objects/returnobjects
666
+ */
667
+ export type GetLayerParentResult = object | {
668
+ index: number;
669
+ layerID: number;
670
+ layerKind: number;
671
+ name: string;
672
+ };
673
+ export interface DisplayConfigurationOptions {
674
+ physicalResolution?: boolean;
675
+ }
676
+ /**
677
+ * @targetfolder objects/returnobjects
678
+ */
679
+ export interface PerformMenuCommandResult {
680
+ /** If true then the menu command was available and was executed. If false, then Photoshop was in a state where the requested command was not available. */
681
+ available: boolean;
682
+ /** If the menu command was executed (if available is true), then this value is true if the user cancelled the request. */
683
+ userCancelled: boolean;
684
+ }
685
+ /**
686
+ * @targetfolder objects/returnobjects
687
+ */
688
+ export interface DisplayConfiguration {
689
+ isPrimary: boolean;
690
+ scaleFactor: number;
691
+ globalBounds: DisplayConfigurationBounds;
692
+ globalWorkingBounds: DisplayConfigurationBounds;
693
+ physicalResolution: DisplayConfigurationPhysical;
694
+ }
695
+ /**
696
+ * @targetfolder objects/returnobjects
697
+ */
698
+ export interface DisplayConfigurationBounds {
699
+ bottom: number;
700
+ left: number;
701
+ right: number;
702
+ top: number;
703
+ }
704
+ /**
705
+ * @targetfolder objects/returnobjects
706
+ */
707
+ export interface GetActiveToolResult {
708
+ title: string;
709
+ isModal: boolean;
710
+ key: string;
711
+ classId: string;
712
+ }
713
+ /**
714
+ * @targetfolder objects/returnobjects
715
+ */
716
+ export interface DisplayConfigurationPhysical {
717
+ horizontal: number;
718
+ vertical: number;
719
+ }
720
+ /**
721
+ * @optionobject
722
+ * @targetfolder objects/options
723
+ */
724
+ export interface SetExecutionModeOptions {
725
+ enableErrorStacktraces?: boolean;
726
+ logRejections?: boolean;
727
+ }
728
+ /**
729
+ * @optionobject
730
+ * @targetfolder objects/options
731
+ */
732
+ export type RedrawDocumentOptions = DocumentCoreOptions;
733
+ /**
734
+ * @optionobject
735
+ * @targetfolder objects/options
736
+ */
737
+ export type DeleteTemporaryDocumentOptions = DocumentCoreOptions;
738
+ /**
739
+ * @optionobject
740
+ * @targetfolder objects/options
741
+ */
742
+ export type CreateTemporaryDocumentOptions = DocumentCoreOptions;
743
+ /**
744
+ * @targetfolder objects/returnobjects
745
+ */
746
+ export type CreateTemporaryDocumentResult = DocumentCoreOptions;
747
+ /**
748
+ * Object to be passed as argument into `suppressResizeGripper()`. `type` and `target` arguments should match
749
+ * witch some entrypoint specified in manifest file.
750
+ * @optionobject
751
+ * @targetfolder objects/options
752
+ */
753
+ export interface SuppressResizeGripperOptions {
754
+ /** Type of entrypoint e.g. `panel` */
755
+ type: string;
756
+ /** Id of entrypoint in manifest file */
757
+ target: string;
758
+ /** Set true to hide resize gripper */
759
+ value: boolean;
760
+ }
761
+ /**
762
+ * Object to be passed as argument into `getMenuCommandTitle()`, `performMenuCommand()` and `getMenuCommandState()`
763
+ * @optionobject
764
+ * @targetfolder objects/options
765
+ */
766
+ export interface MenuCommandOptions {
767
+ commandID: number;
768
+ scheduling?: Scheduling;
769
+ }
770
+ /**
771
+ * Object to be passed as argument into `getMenuCommandTitle()`
772
+ * @optionobject
773
+ * @targetfolder objects/options
774
+ */
775
+ export interface MenuCommandMenuIDOptions {
776
+ menuID: number;
777
+ scheduling?: Scheduling;
778
+ }
779
+ /**
780
+ * @targetfolder objects/returnobjects
781
+ */
782
+ export interface ExecuteAsModalOptions {
783
+ /**
784
+ * Name of the command. It will be shown in the progress bar if the operation takes a noticeable amount of time.
785
+ * @minVersion 22.5
786
+ */
787
+ commandName: string;
788
+ /**
789
+ * Optional mode where UI interactions are permissible within the executeAsModal state. Useful for allowing users to input
790
+ * data into invoked dialogs or workspaces. See [Modal Execution](../executeasmodal).
791
+ * @minVersion 23.3
792
+ */
793
+ interactive?: boolean;
794
+ timeOut?: number;
795
+ }
796
+ /**
797
+ * Options for the history state that {@link Document.suspendHistory} will create.
798
+ * @optionobject
799
+ * @targetfolder objects/options
800
+ */
801
+ export interface HistoryStateInfo {
802
+ /**
803
+ * Name of the history state to be shown in History panel
804
+ * @minVersion 23.0
805
+ */
806
+ name: string;
807
+ /**
808
+ * The target document's ID that will have its history suspended with suspendHistory.
809
+ * @minVersion 23.0
810
+ */
811
+ documentID: number;
812
+ }
813
+ /**
814
+ * This object is provided by the `suspendHistory` API when a document's history state is suspended, and is
815
+ * needed to `resumeHistory`.
816
+ * @targetfolder objects/returnobjects
817
+ * @minVersion 23.0
818
+ */
819
+ export interface HistorySuspension {
820
+ /**
821
+ * An identifier generated by Photoshop to identify the history suspension.
822
+ * @minVersion 23.0
823
+ */
824
+ historySuspensionID: number;
825
+ }
826
+ /**
827
+ * @optionobject
828
+ * @targetfolder objects/options
829
+ */
830
+ export interface ResumeHistorySuspensionOptions extends HistorySuspension {
831
+ /**
832
+ * The desired name of the resulting history state when successfully resumed and committed.
833
+ * @minVersion 23.0
834
+ */
835
+ finalName?: string;
836
+ }
837
+
838
+ // copied from devtools:
839
+ // hostControl: {suspendHistory: ƒ, resumeHistory: ƒ, registerAutoCloseDocument: ƒ, unregisterAutoCloseDocument: ƒ}
840
+ // mode: "action"
841
+ // uiMode: "never"
842
+ // finalizeArguments: ƒ ()
843
+ // isCancelled: undefined
844
+ // onCancel: undefined
845
+ // reject: ƒ ()
846
+ // reportProgress: ƒ ()
847
+ // resolve: ƒ ()
848
+
849
+ /**
850
+ * This object is passed to the callback of `core.executeAsModal` for modality related APIs.
851
+ * @optionobject
852
+ * @targetfolder objects/options
853
+ * @minVersion 23.0
854
+ */
855
+ export interface ExecutionContext {
856
+ /**
857
+ * True if user has cancelled the modal interaction.
858
+ *
859
+ * User can cancel by hitting the Escape key, or by pressing the "Cancel" button in the progress bar.
860
+ * @minVersion 23.0
861
+ */
862
+ isCancelled: boolean;
863
+ /**
864
+ * If assigned a method, it will be called when user cancels the modal interaction.
865
+ * @minVersion 23.0
866
+ */
867
+ onCancel: undefined | ((e?: OnCancelCbArgument) => void);
868
+ /**
869
+ * Call this to customize the progress bar.
870
+ * @minVersion 23.0
871
+ */
872
+ reportProgress: (params: ReportProgressOptions) => void;
873
+ /**
874
+ * Use the methods in here to control Photoshop state.
875
+ * @minVersion 23.0
876
+ */
877
+ hostControl: {
878
+ /**
879
+ * Call to suspend history on a target document, returns the suspension ID which can be used for resumeHistory.
880
+ * @minVersion 23.0
881
+ */
882
+ suspendHistory: (params: HistoryStateInfo) => Promise<HistorySuspension>;
883
+ /**
884
+ * Call to resume history on a target document.
885
+ * commit (optional): if false, the current modified document state is dropped, and the document returns to
886
+ * the state when `suspendHistory` was invoked.
887
+ * @minVersion 23.0
888
+ */
889
+ resumeHistory: (params: ResumeHistorySuspensionOptions, commit?: boolean) => Promise<void>;
890
+ /**
891
+ * Register a document to be closed when the modal scope exits.
892
+ * @param documentID
893
+ */
894
+ registerAutoCloseDocument: (documentID: number) => Promise<void>;
895
+ /**
896
+ * Unregister a document from being closed when the modal scope exits.
897
+ * @param documentID
898
+ */
899
+ unregisterAutoCloseDocument: (documentID: number) => Promise<void>;
900
+ };
901
+ }
902
+
903
+ export interface OnCancelCbArgument {
904
+ reason: string;
905
+ }
906
+ /**
907
+ * Object to be passed as an argument into `reportProgress()`
908
+ *
909
+ * @optionobject
910
+ * @targetfolder objects/options
911
+ */
912
+ export interface ReportProgressOptions {
913
+ /**
914
+ * Value in range [0,1] where 0 is 0% and 1 is 100%
915
+ */
916
+ value?: number;
917
+ /**
918
+ * Text shown in progress bar dialog. Usually explaining the current progress
919
+ */
920
+ commandName?: string;
921
+ }
922
+ export {};