@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,1216 @@
1
+ type DomainSymbol = symbol & { _brand: { domainSymbol: undefined } };
2
+
3
+ type FormatSymbol = symbol & { _brand: { formatSymbol: undefined } };
4
+
5
+ type ModeSymbol = symbol & { _brand: { modeSymbol: undefined } };
6
+
7
+ type TypeSymbol = symbol & { _brand: { typeSymbol: undefined } };
8
+
9
+ /**
10
+ * Metadata for an entry.
11
+ * It includes useful information such as:
12
+ * - size of the file (if a file)
13
+ * - date created
14
+ * - date modified
15
+ * - name
16
+ *
17
+ * Instantiate `EntryMetadata` by using Entry's getMetadata().
18
+ * In order to instantiate `Entry`, you will need to first invoke the `localFileSystem` and then fetch an instance of a File or Folder.
19
+ *
20
+ * @see {@link https://developer.adobe.com/photoshop/uxp/2022/uxp-api/reference-js/Modules/uxp/Persistent%20File%20Storage/EntryMetadata/}
21
+ *
22
+ * @example
23
+ * ```js
24
+ * const fs = require('uxp').storage.localFileSystem;
25
+ * const folder = await fs.getPluginFolder(); // Gets an instance of Folder (or Entry)
26
+ * const entryMetaData = await folder.getMetadata();
27
+ * console.log(entryMetaData.name);
28
+ * ```
29
+ */
30
+ export interface EntryMetadata {
31
+ /**
32
+ * The name of the entry.
33
+ */
34
+ name: string;
35
+ /**
36
+ * The size of the entry, if a file.
37
+ * Zero if a folder.
38
+ */
39
+ size: number;
40
+ /**
41
+ * The date this entry was created.
42
+ */
43
+ dateCreated: Date;
44
+ /**
45
+ * The date this entry was modified.
46
+ */
47
+ dateModified: Date;
48
+ /**
49
+ * Indicates if the entry is a file.
50
+ */
51
+ isFile: boolean;
52
+ /**
53
+ * Indicates if the entry is a folder.
54
+ */
55
+ isFolder: boolean;
56
+ }
57
+
58
+ /**
59
+ * An Entry is the base class for File and Folder.
60
+ * You'll typically never instantiate an Entry directly, but it provides the common fields and methods that both
61
+ * File and Folder share.
62
+ *
63
+ * You can get an instance of Entry via the `localFileSystem` by fetching an instance of a File or Folder.
64
+ *
65
+ * @see {@link https://developer.adobe.com/photoshop/uxp/2022/uxp-api/reference-js/Modules/uxp/Persistent%20File%20Storage/Entry/}
66
+ *
67
+ * @example
68
+ * ```js
69
+ * // Since Entry cannot be called directly we can use a File or Folder object to invoke Entry as shown below
70
+ * const fs = require('uxp').storage.localFileSystem;
71
+ * const folder = await fs.getPluginFolder(); // returns a Folder instance
72
+ * const folderEntry = await folder.getEntry("entryName.txt");
73
+ * // Now we can use folderEntry to invoke the APIs provided by Entry
74
+ * console.log(folderEntry.isEntry); // isEntry is an API of Entry, in this example it will return true
75
+ * ```
76
+ */
77
+ export class Entry {
78
+ /**
79
+ * Creates an instance of Entry.
80
+ * @param name
81
+ * @param provider
82
+ * @param id
83
+ */
84
+ constructor(name: string, provider: FileSystemProvider, id: string);
85
+
86
+ /**
87
+ * Returns the details of the given entry like name, type and native path in a readable string format.
88
+ */
89
+ toString(): string;
90
+
91
+ /**
92
+ * Copies this entry to the specified folder.
93
+ *
94
+ * @param folder The folder to which to copy this entry.
95
+ * @param options Options for the copy operation (all properties are optional)
96
+ * @throws EntryExists If the attempt would overwrite an entry and overwrite is false.
97
+ * @throws PermissionDenied If the underlying file system rejects the attempt.
98
+ * @throws OutOfSpace If the file system is out of storage space.
99
+ *
100
+ * @see {@link https://developer.adobe.com/photoshop/uxp/2022/uxp-api/reference-js/Modules/uxp/Persistent%20File%20Storage/Entry/#copytofolder-options}
101
+ *
102
+ * @example
103
+ * ```js
104
+ * await someFile.copyTo(someFolder);
105
+ * ```
106
+ *
107
+ * @example
108
+ * ```js
109
+ * await someFile.copyTo(someFolder, {overwrite: true});
110
+ * ```
111
+ *
112
+ * @example
113
+ * ```js
114
+ * await someFolder.copyTo(anotherFolder, {overwrite: true, allowFolderCopy: true});
115
+ * ```
116
+ */
117
+ copyTo(
118
+ folder: Folder,
119
+ options?: {
120
+ /**
121
+ * If true, allows overwriting existing entries.
122
+ */
123
+ overwrite?: boolean;
124
+ /**
125
+ * If true, allows copying the folder.
126
+ */
127
+ allowFolderCopy?: boolean;
128
+ },
129
+ ): Promise<File | Folder>;
130
+
131
+ /**
132
+ * Moves this entry to the target folder, optionally specifying a new name.
133
+ *
134
+ * @param folder The folder to which to move this entry.
135
+ * @param options Options for the move operation (all properties are optional)
136
+ *
137
+ * @see {@link https://developer.adobe.com/photoshop/uxp/2022/uxp-api/reference-js/Modules/uxp/Persistent%20File%20Storage/Entry/#movetofolder-options}
138
+ *
139
+ * @example
140
+ * ```js
141
+ * await someFile.moveTo(someFolder);
142
+ * ```
143
+ *
144
+ * @example
145
+ * ```js
146
+ * await someFile.moveTo(someFolder, {overwrite: true});
147
+ * ```
148
+ *
149
+ * @example
150
+ * ```js
151
+ * await someFolder.moveTo(anotherFolder, {overwrite: true});
152
+ * ```
153
+ *
154
+ * @example
155
+ * ```js
156
+ * await someFile.moveTo(someFolder, {newName: 'masterpiece.txt'})
157
+ * ```
158
+ *
159
+ * @example
160
+ * ```js
161
+ * await someFile.moveTo(someFolder, {newName: 'novel.txt', {overwrite: true})
162
+ * ```
163
+ */
164
+ moveTo(
165
+ folder: Folder,
166
+ options?: {
167
+ /**
168
+ * If true allows the move to overwrite existing files.
169
+ */
170
+ overwrite?: boolean;
171
+ /**
172
+ * If specified, the entry is renamed to this name.
173
+ */
174
+ newName?: string;
175
+ },
176
+ ): Promise<void>;
177
+
178
+ /**
179
+ * Removes this entry from the file system.
180
+ * If the entry is a folder, all the contents will also be removed.
181
+ *
182
+ * Note: Currently when using this method, a permission denied error will occur if attempting to delete
183
+ * a folder that was selected from a storage picker or added via drag-and-drop.
184
+ *
185
+ * @returns The number is 0 if succeeded, otherwise throws an Error.
186
+ *
187
+ * @see {@link https://developer.adobe.com/photoshop/uxp/2022/uxp-api/reference-js/Modules/uxp/Persistent%20File%20Storage/Entry/#delete}
188
+ *
189
+ * @example
190
+ * ```js
191
+ * await aFile.delete();
192
+ * ```
193
+ */
194
+ delete(): Promise<number>;
195
+
196
+ /**
197
+ * Returns this entry's metadata.
198
+ *
199
+ * @see {@link https://developer.adobe.com/photoshop/uxp/2022/uxp-api/reference-js/Modules/uxp/Persistent%20File%20Storage/Entry/#getmetadata}
200
+ *
201
+ * @example
202
+ * ```js
203
+ * const metadata = aFile.getMetadata();
204
+ * ```
205
+ */
206
+ getMetadata(): Promise<EntryMetadata>;
207
+
208
+ /**
209
+ * Indicates that this instance is an Entry.
210
+ * Useful for type-checking.
211
+ *
212
+ * @example
213
+ * ```js
214
+ * if (something.isEntry) {
215
+ * return something.getMetadata();
216
+ * }
217
+ * ```
218
+ */
219
+ readonly isEntry: boolean;
220
+
221
+ /**
222
+ * Indicates that this instance is not a File.
223
+ * Useful for type-checking.
224
+ *
225
+ * @example
226
+ * ```js
227
+ * if (!anEntry.isFile) {
228
+ * return "This entry is not a file.";
229
+ * }
230
+ * ```
231
+ */
232
+ readonly isFile: boolean;
233
+
234
+ /**
235
+ * Indicates that this instance is not a folder.
236
+ * Useful for type-checking.
237
+ *
238
+ * @example
239
+ * ```js
240
+ * if (!anEntry.isFolder) {
241
+ * return "This entry is not a folder.";
242
+ * }
243
+ * ```
244
+ */
245
+ readonly isFolder: boolean;
246
+
247
+ /**
248
+ * The name of this entry.
249
+ * Read-only.
250
+ *
251
+ * @example
252
+ * ```js
253
+ * console.log(anEntry.name);
254
+ * ```
255
+ */
256
+ readonly name: string;
257
+
258
+ /**
259
+ * The associated provider that services this entry.
260
+ * Read-only.
261
+ *
262
+ * @example
263
+ * ```js
264
+ * if (entryOne.provider !== entryTwo.provider) {
265
+ * throw new Error("Providers are not the same");
266
+ * }
267
+ * ```
268
+ */
269
+ readonly provider: FileSystemProvider;
270
+
271
+ /**
272
+ * The url of this entry.
273
+ * You can use this url as input to other entities of the extension system like for eg: set as src attribute of a
274
+ * Image widget in UI.
275
+ * Read-only.
276
+ *
277
+ * @example
278
+ * ```js
279
+ * console.log(anEntry.url);
280
+ * ```
281
+ */
282
+ readonly url: string;
283
+
284
+ /**
285
+ * The platform native file-system path of this entry.
286
+ * Read-only
287
+ *
288
+ * @example
289
+ * ```js
290
+ * console.log(anEntry.nativePath);
291
+ * ```
292
+ */
293
+ readonly nativePath: string;
294
+ }
295
+
296
+ /**
297
+ * Represents a file on a file system.
298
+ * Provides methods for reading from and writing to the file.
299
+ * You'll never instantiate a File directly; instead you'll get access via a storage.FileSystemProvider.
300
+ *
301
+ * Keep in mind that `File` as such doesn't need a `require()` statement, however a `localFileSystem` will need it.
302
+ *
303
+ * @see {@link https://developer.adobe.com/photoshop/uxp/2022/uxp-api/reference-js/Modules/uxp/Persistent%20File%20Storage/File/}
304
+ *
305
+ * @example
306
+ * ```js
307
+ * // Get the object of a File instance
308
+ * const fs = require('uxp').storage.localFileSystem;
309
+ * const file = await fs.createEntryWithUrl("file:/Users/user/Documents/tmp"); // Gets a File instance
310
+ * console.log(file.isFile); // returns true
311
+ * ```
312
+ */
313
+ export class File extends Entry {
314
+ /**
315
+ * Determines if the entry is a file or not.
316
+ * This is safe to use even if the entry is null or undefined.
317
+ *
318
+ * @param entry The entry to check.
319
+ * @returns If true, the entry is a file.
320
+ */
321
+ static isFile(entry: Entry): boolean;
322
+
323
+ /**
324
+ * Indicates that this instance is a file.
325
+ *
326
+ * @example
327
+ * ```js
328
+ * if (anEntry.isFile) {
329
+ * await anEntry.read();
330
+ * }
331
+ * ```
332
+ */
333
+ readonly isFile: true;
334
+
335
+ /**
336
+ * Indicates whether this file is read-only or read-write.
337
+ * See readOnly and readWrite.
338
+ *
339
+ * @example
340
+ * ```js
341
+ * if (aFile.mode === modes.readOnly) {
342
+ * throw new Error("Can't write to a file opened as read-only.");
343
+ * }
344
+ * ```
345
+ */
346
+ mode: ModeSymbol;
347
+
348
+ /**
349
+ * Reads data from the file and returns it.
350
+ * The file format can be specified with the format option.
351
+ * If a format is not supplied, the file is assumed to be a text file using UTF8 encoding.
352
+ *
353
+ * @param options Options for the read operation (all properties are optional)
354
+ * @returns The contents of the file.
355
+ *
356
+ * @see {@link https://developer.adobe.com/photoshop/uxp/2022/uxp-api/reference-js/Modules/uxp/Persistent%20File%20Storage/File/#readoptions}
357
+ *
358
+ * @example
359
+ * ```js
360
+ * const text = await myNovel.read();
361
+ * ```
362
+ *
363
+ * @example
364
+ * ```js
365
+ * const data = await myNovel.read({format: formats.binary});
366
+ * ```
367
+ */
368
+ read(options?: {
369
+ /**
370
+ * The format of the file; see utf8 and binary.
371
+ */
372
+ format?: FormatSymbol;
373
+ }): Promise<string | ArrayBuffer>;
374
+
375
+ /**
376
+ * Writes data to a file, appending if desired.
377
+ * The format of the file is controlled via the format option, and defaults to UTF8.
378
+ *
379
+ * @param data The data to write to the file.
380
+ * @param options Options for the write operation (all properties are optional)
381
+ * @returns The length of the contents written to the file.
382
+ * @throws FileIsReadOnly If writing to a read-only file.
383
+ * @throws OutOfSpace If writing to the file causes the file system to exceed the available space (or quota).
384
+ *
385
+ * @see {@link https://developer.adobe.com/photoshop/uxp/2022/uxp-api/reference-js/Modules/uxp/Persistent%20File%20Storage/File/#writedata-options}
386
+ *
387
+ * @example
388
+ * ```js
389
+ * await myNovel.write("It was a dark and stormy night.\n");
390
+ * await myNovel.write("Cliches and tropes aside, it really was.", {append: true});
391
+ * ```
392
+ *
393
+ * @example
394
+ * ```js
395
+ * const data = new ArrayBuffer();
396
+ * await aDataFile.write(data, {format: formats.binary});
397
+ * ```
398
+ */
399
+ write(
400
+ data: string | ArrayBuffer,
401
+ options?: {
402
+ /**
403
+ * The format of the file; see utf8 and binary.
404
+ */
405
+ format?: FormatSymbol;
406
+ /**
407
+ * If true, the data is written to the end of the file.
408
+ */
409
+ append?: boolean;
410
+ },
411
+ ): Promise<number>;
412
+ }
413
+
414
+ /**
415
+ * Represents a folder on a file system.
416
+ * You'll never instantiate this directly, but will get it by calling FileSystemProvider.getTemporaryFolder,
417
+ * FileSystemProvider.getFolder, or via Folder.getEntries.
418
+ *
419
+ * @see {@link https://developer.adobe.com/photoshop/uxp/2022/uxp-api/reference-js/Modules/uxp/Persistent%20File%20Storage/Folder/}
420
+ *
421
+ * @example
422
+ * ```js
423
+ * // Get the Folder instance via localFileSystem
424
+ * const fs = require('uxp').storage.localFileSystem;
425
+ * const folder = await fs.getTemporaryFolder(); // Gets the Folder instance
426
+ * console.log(folder.isFolder); // returns true
427
+ * ```
428
+ */
429
+ export class Folder extends Entry {
430
+ static isFolder(entry: Entry): boolean;
431
+
432
+ /**
433
+ * Indicates that this instance is a folder.
434
+ * Useful for type checking.
435
+ */
436
+ readonly isFolder: true;
437
+
438
+ /**
439
+ * Returns an array of entries contained within this folder.
440
+ *
441
+ * @returns The entries within the folder.
442
+ *
443
+ * @see {@link https://developer.adobe.com/photoshop/uxp/2022/uxp-api/reference-js/Modules/uxp/Persistent%20File%20Storage/Folder/#getentries}
444
+ *
445
+ * @example
446
+ * ```js
447
+ * const entries = await aFolder.getEntries();
448
+ * const allFiles = entries.filter(entry => entry.isFile);
449
+ * ```
450
+ */
451
+ getEntries(): Promise<Entry[]>;
452
+
453
+ /**
454
+ * Creates an entry within this folder and returns the appropriate instance.
455
+ *
456
+ * @param name The name of the entry to create.
457
+ * @param options Options for the create operation (all properties are optional)
458
+ * @returns The created entry.
459
+ *
460
+ * @see {@link https://developer.adobe.com/photoshop/uxp/2022/uxp-api/reference-js/Modules/uxp/Persistent%20File%20Storage/Folder/#createentryname-options}
461
+ *
462
+ * @example
463
+ * ```js
464
+ * const myNovel = await aFolder.createEntry("mynovel.txt");
465
+ * ```
466
+ *
467
+ * @example
468
+ * ```js
469
+ * const catImageCollection = await aFolder.createEntry("cats", {type: types.folder});
470
+ * ```
471
+ */
472
+ createEntry(
473
+ name: string,
474
+ options?: {
475
+ /**
476
+ * Indicates which kind of entry to create.
477
+ * Pass folder to create a new folder.
478
+ * Note that if the type is file then this method just create a file entry object and not the actual file on
479
+ * the disk.
480
+ * The file actually gets created when you call for eg: write method on the file entry object.
481
+ */
482
+ type?: TypeSymbol;
483
+ /**
484
+ * If true, the create attempt can overwrite an existing file.
485
+ */
486
+ overwrite?: boolean;
487
+ },
488
+ ): Promise<File | Folder>;
489
+
490
+ /**
491
+ * Creates a File Entry object within this folder and returns the appropriate instance.
492
+ * Note that this method just create a file entry object and not the actual file on the disk.
493
+ * The file actually gets created when you call for eg: write method on the file entry object.
494
+ *
495
+ * @param name The name of the file to create.
496
+ * @param options Options for the create operation (all properties are optional)
497
+ * @returns The created file entry.
498
+ *
499
+ * @see {@link https://developer.adobe.com/photoshop/uxp/2022/uxp-api/reference-js/Modules/uxp/Persistent%20File%20Storage/Folder/#createfilename-options}
500
+ *
501
+ * @example
502
+ * ```js
503
+ * const myNovelTxtFile = await aFolder.createFile("mynovel.txt");
504
+ * ```
505
+ */
506
+ createFile(
507
+ name: string,
508
+ options?: {
509
+ /**
510
+ * If true, the create attempt can overwrite an existing file.
511
+ */
512
+ overwrite?: boolean;
513
+ },
514
+ ): Promise<File>;
515
+
516
+ /**
517
+ * Creates a Folder within this folder and returns the appropriate instance.
518
+ *
519
+ * @param name The name of the folder to create.
520
+ * @returns The created folder entry object.
521
+ *
522
+ * @see {@link https://developer.adobe.com/photoshop/uxp/2022/uxp-api/reference-js/Modules/uxp/Persistent%20File%20Storage/Folder/#createfoldername}
523
+ *
524
+ * @example
525
+ * ```js
526
+ * const myCollectionsFolder = await aFolder.createFolder("collections");
527
+ * ```
528
+ */
529
+ createFolder(name: string): Promise<Folder>;
530
+
531
+ /**
532
+ * Gets an entry from within this folder and returns the appropriate instance.
533
+ *
534
+ * @param filePath The name/path of the entry to fetch.
535
+ * @returns The fetched entry.
536
+ *
537
+ * @see {@link https://developer.adobe.com/photoshop/uxp/2022/uxp-api/reference-js/Modules/uxp/Persistent%20File%20Storage/Folder/#getentryfilepath}
538
+ *
539
+ * @example
540
+ * ```js
541
+ * const myNovel = await aFolder.getEntry("mynovel.txt");
542
+ * ```
543
+ */
544
+ getEntry(filePath: string): Promise<File | Folder>;
545
+
546
+ /**
547
+ * Renames an entry to a new name.
548
+ *
549
+ * @param entry The entry to rename.
550
+ * @param newName The new name to assign.
551
+ * @param options Options for the rename operation (all properties are optional)
552
+ *
553
+ * @see {@link https://developer.adobe.com/photoshop/uxp/2022/uxp-api/reference-js/Modules/uxp/Persistent%20File%20Storage/Folder/#renameentryentry-newname-options}
554
+ *
555
+ * @example
556
+ * ```js
557
+ * await myNovels.renameEntry(myNovel, "myFantasticNovel.txt");
558
+ * ```
559
+ */
560
+ renameEntry(
561
+ entry: Entry,
562
+ newName: string,
563
+ options?: {
564
+ /**
565
+ * If true, renaming can overwrite an existing entry.
566
+ */
567
+ overwrite?: boolean;
568
+ },
569
+ ): Promise<void>;
570
+ }
571
+
572
+ /**
573
+ * Provides access to files and folders on a file system.
574
+ * You'll never instantiate this directly; instead you'll use an instance of
575
+ * one that has already been created for you by UXP.
576
+ *
577
+ * These APIs work with UXP Manifest version v5 and above.
578
+ *
579
+ * @see {@link https://developer.adobe.com/photoshop/uxp/2022/uxp-api/reference-js/Modules/uxp/Persistent%20File%20Storage/FileSystemProvider/}
580
+ */
581
+ export class FileSystemProvider {
582
+ /**
583
+ * Checks if the supplied object is a FileSystemProvider.
584
+ * It's safe to use even if the object is null or undefined.
585
+ * Useful for type checking.
586
+ *
587
+ * @param fs The object to check.
588
+ * @returns If true, the object is a file system provider.
589
+ */
590
+ static isFileSystemProvider(fs: FileSystemProvider): boolean;
591
+
592
+ /**
593
+ * Indicates that this is a FileSystemProvider.
594
+ * Useful for type-checking.
595
+ */
596
+ isFileSystemProvider: boolean;
597
+
598
+ /**
599
+ * An array of the domains this file system supports.
600
+ * If the file system can open a file picker to the user's documents folder, for example, then userDocuments will
601
+ * be in this list.
602
+ *
603
+ * @example
604
+ * ```js
605
+ * if (fs.supportedDomains.contains(domains.userDocuments)) {
606
+ * console.log("We can open a picker to the user's documents.")
607
+ * }
608
+ * ```
609
+ */
610
+ supportedDomains: DomainSymbol[];
611
+
612
+ /**
613
+ * Gets a file (or files) from the file system provider for the purpose of opening them.
614
+ * Files are read-only.
615
+ *
616
+ * Multiple files can be returned if the `allowMultiple` option is `true`.
617
+ *
618
+ * @param options Options for the file picker (all properties are optional)
619
+ * @returns Based on allowMultiple is true or false, or empty if no file were selected.
620
+ *
621
+ * @see {@link https://developer.adobe.com/photoshop/uxp/2022/uxp-api/reference-js/Modules/uxp/Persistent%20File%20Storage/FileSystemProvider/#getfileforopeningoptions}
622
+ *
623
+ * @example
624
+ * ```js
625
+ * const folder = await fs.getFolder({initialDomain: domains.userDocuments});
626
+ * const file = await fs.getFileForOpening({initialLocation: folder});
627
+ * if (!file) {
628
+ * // no file selected
629
+ * return;
630
+ * }
631
+ * const text = await file.read();
632
+ * ```
633
+ *
634
+ * @example
635
+ * ```js
636
+ * const files = await fs.getFileForOpening({allowMultiple: true, types: fileTypes.images});
637
+ * if (files.length === 0) {
638
+ * // no files selected
639
+ * }
640
+ * ```
641
+ */
642
+ getFileForOpening(options?: {
643
+ /**
644
+ * The preferred initial location of the file picker.
645
+ * If not defined, the most recently used domain from a file picker is used instead.
646
+ */
647
+ initialDomain?: DomainSymbol;
648
+ /**
649
+ * Array of file types that the file open picker displays.
650
+ */
651
+ types?: string[];
652
+ /**
653
+ * The initial location of the file picker.
654
+ * You can pass an existing file or folder entry to suggest the picker to start at this location.
655
+ * If this is a file entry then the method will pick its parent folder as initial location.
656
+ * This will override initialDomain option.
657
+ */
658
+ initialLocation?: File | Folder;
659
+ /**
660
+ * If true, multiple files can be returned (as an array).
661
+ */
662
+ allowMultiple?: boolean;
663
+ }): Promise<File | File[]>;
664
+
665
+ /**
666
+ * Gets a file reference suitable for saving.
667
+ * The file is read-write.
668
+ * Any file picker displayed will be of the "save" variety.
669
+ *
670
+ * If the user attempts to save a file that doesn't exist, the file is created automatically.
671
+ *
672
+ * If the act of writing to the file would overwrite it, the file picker should prompt the user if they are OK
673
+ * with that action.
674
+ * If not, the file should not be returned.
675
+ *
676
+ * @param suggestedName Required when options.types is not defined.
677
+ * @param options Options for the file picker (all properties are optional)
678
+ * @returns Returns the selected file, or null if no file were selected.
679
+ *
680
+ * @see {@link https://developer.adobe.com/photoshop/uxp/2022/uxp-api/reference-js/Modules/uxp/Persistent%20File%20Storage/FileSystemProvider/#getfileforsavingsuggestedname-options}
681
+ *
682
+ * @example
683
+ * ```js
684
+ * const file = await fs.getFileForSaving("output.txt", {types: ["txt"]});
685
+ * if (!file) {
686
+ * // file picker was cancelled
687
+ * return;
688
+ * }
689
+ * await file.write("It was a dark and stormy night");
690
+ * ```
691
+ */
692
+ getFileForSaving(suggestedName: string, options?: {
693
+ /**
694
+ * The preferred initial location of the file picker.
695
+ * If not defined, the most recently used domain from a file picker is used instead.
696
+ */
697
+ initialDomain?: DomainSymbol;
698
+ /**
699
+ * Allowed file extensions, with no "." prefix.
700
+ */
701
+ types?: string[];
702
+ }): Promise<File>;
703
+
704
+ /**
705
+ * Gets a folder from the file system via a folder picker dialog.
706
+ * The files and folders within can be accessed via Folder#getEntries.
707
+ * Any files within are read-write.
708
+ *
709
+ * If the user dismisses the picker, null is returned instead.
710
+ *
711
+ * @param options Options for the folder picker (all properties are optional)
712
+ * @returns The selected folder or null if no folder is selected.
713
+ *
714
+ * @see {@link https://developer.adobe.com/photoshop/uxp/2022/uxp-api/reference-js/Modules/uxp/Persistent%20File%20Storage/FileSystemProvider/#getfolderoptions}
715
+ *
716
+ * @example
717
+ * ```js
718
+ * const folder = await fs.getFolder();
719
+ * const myNovel = (await folder.getEntries()).filter(entry => entry.name.indexOf('novel') > 0);
720
+ * const text = await myNovel.read();
721
+ * ```
722
+ */
723
+ getFolder(options?: {
724
+ /**
725
+ * The preferred initial location of the file picker.
726
+ * If not defined, the most recently used domain from a file picker is used instead.
727
+ */
728
+ initialDomain?: DomainSymbol;
729
+ }): Promise<Folder>;
730
+
731
+ /**
732
+ * Returns a temporary folder.
733
+ * The contents of the folder will be removed when the extension is disposed.
734
+ *
735
+ * @see {@link https://developer.adobe.com/photoshop/uxp/2022/uxp-api/reference-js/Modules/uxp/Persistent%20File%20Storage/FileSystemProvider/#gettemporaryfolder}
736
+ *
737
+ * @example
738
+ * ```js
739
+ * const temp = await fs.getTemporaryFolder();
740
+ * ```
741
+ */
742
+ getTemporaryFolder(): Promise<Folder>;
743
+
744
+ /**
745
+ * Returns a folder that can be used for extension's data storage without user interaction.
746
+ * It is persistent across host-app version upgrades.
747
+ *
748
+ * @see {@link https://developer.adobe.com/photoshop/uxp/2022/uxp-api/reference-js/Modules/uxp/Persistent%20File%20Storage/FileSystemProvider/#getdatafolder}
749
+ */
750
+ getDataFolder(): Promise<Folder>;
751
+
752
+ /**
753
+ * Returns an plugin's folder – this folder and everything within it are read only.
754
+ * This contains all the Plugin related packaged assets.
755
+ *
756
+ * @see {@link https://developer.adobe.com/photoshop/uxp/2022/uxp-api/reference-js/Modules/uxp/Persistent%20File%20Storage/FileSystemProvider/#getpluginfolder}
757
+ */
758
+ getPluginFolder(): Promise<Folder>;
759
+
760
+ /**
761
+ * Returns the fs url of given entry.
762
+ *
763
+ * @param entry
764
+ * @returns The fs url of given entry.
765
+ *
766
+ * @see {@link https://developer.adobe.com/photoshop/uxp/2022/uxp-api/reference-js/Modules/uxp/Persistent%20File%20Storage/FileSystemProvider/#getfsurlentry}
767
+ */
768
+ getFsUrl(entry: Entry): string;
769
+
770
+ /**
771
+ * Returns the platform native file system path of given entry.
772
+ *
773
+ * @param entry
774
+ * @returns The platform native file system path of given entry.
775
+ *
776
+ * @see {@link https://developer.adobe.com/photoshop/uxp/2022/uxp-api/reference-js/Modules/uxp/Persistent%20File%20Storage/FileSystemProvider/#getnativepathentry}
777
+ */
778
+ getNativePath(entry: Entry): string;
779
+
780
+ /**
781
+ * Creates an entry for the given url and returns the appropriate instance.
782
+ *
783
+ * @param url The url to create an Entry object. Note that file: scheme has limited support in UWP due to the strict File access permissions.
784
+ * @param options Options for the create operation (all properties are optional)
785
+ * @returns The File or Folder object which is created for the given url.
786
+ * @throws Error if invalid file url format or value is passed.
787
+ * if the parent folder of the file/folder to be created does not exist.
788
+ * if a folder already exists at the url.
789
+ * if a file already exists at the url and it is requested to create a folder.
790
+ * if a file already exists at the url and the overwrite option is not set to true to create a file.
791
+ *
792
+ * @see {@link https://developer.adobe.com/photoshop/uxp/2022/uxp-api/reference-js/Modules/uxp/Persistent%20File%20Storage/FileSystemProvider/#createentrywithurlurl-options}
793
+ *
794
+ * @example
795
+ * ```js
796
+ * const newImgFolder = await fs.createEntryWithUrl("plugin-temp:/img", {type: types.folder});
797
+ * const newTmpFolder = await fs.createEntryWithUrl("file:/Users/user/Documents/tmp", {type: types.folder});
798
+ * ```
799
+ *
800
+ * @example
801
+ * ```js
802
+ * const newDatFile = await fs.createEntryWithUrl("plugin-temp:/tmp/test.dat", {overwrite: true});
803
+ * const newTxtFile = await fs.createEntryWithUrl("file:/Users/user/Documents/test.txt", {overwrite: true});
804
+ * ```
805
+ */
806
+ createEntryWithUrl(
807
+ url: string,
808
+ options?: {
809
+ /**
810
+ * Indicates which kind of entry to create. Pass types.folder to create a new folder.
811
+ * Note that if the type is file then this method just creates a file entry object and not the actual file on the disk.
812
+ * File on the storage is created when data is written into the file. eg: call write method on the file entry object.
813
+ */
814
+ type?: TypeSymbol;
815
+ /**
816
+ * If true, the create attempt can overwrite an existing file.
817
+ */
818
+ overwrite?: boolean;
819
+ },
820
+ ): Promise<File | Folder>;
821
+
822
+ /**
823
+ * Returns a token suitable for use with certain host-specific APIs (such as Photoshop).
824
+ * This token is valid only for the current plugin session.
825
+ * As such, it is of no use if you serialize the token to persistent storage, as the token will be invalid in the
826
+ * future.
827
+ *
828
+ * Note: When using the Photoshop DOM API, pass the instance of the file instead of a session token -- Photoshop
829
+ * will convert the entry into a session token automatically on your behalf.
830
+ *
831
+ * @param entry
832
+ * @returns The session token for the given entry.
833
+ *
834
+ * @see {@link https://developer.adobe.com/photoshop/uxp/2022/uxp-api/reference-js/Modules/uxp/Persistent%20File%20Storage/FileSystemProvider/#createsessiontokenentry}
835
+ *
836
+ * @example
837
+ * ```js
838
+ * const fs = require('uxp').storage.localFileSystem;
839
+ * let entry = await fs.getFileForOpening();
840
+ * let token = fs.createSessionToken(entry);
841
+ * let result = await require('photoshop').action.batchPlay([{
842
+ * _obj: "open",
843
+ * "target": {
844
+ * _path: token, // Rather than a system path, this expects a session token
845
+ * _kind: "local",
846
+ * }
847
+ * }], {});
848
+ * ```
849
+ */
850
+ createSessionToken(entry: Entry): string;
851
+
852
+ /**
853
+ * Returns the file system Entry that corresponds to the session token obtained from createSessionToken.
854
+ * If an entry cannot be found that matches the token, then a Reference Error: token is not defined error is
855
+ * thrown.
856
+ *
857
+ * @param token
858
+ * @returns The corresponding entry for the session token.
859
+ *
860
+ * @see {@link https://developer.adobe.com/photoshop/uxp/2022/uxp-api/reference-js/Modules/uxp/Persistent%20File%20Storage/FileSystemProvider/#getentryforsessiontokentoken}
861
+ */
862
+ getEntryForSessionToken(token: string): Entry;
863
+
864
+ /**
865
+ * Returns a token suitable for use with host-specific APIs (such as Photoshop), or for storing a persistent
866
+ * reference to an entry (useful if you want to only ask for permission to access a file or folder once).
867
+ * A persistent token is not guaranteed to last forever -- certain scenarios can cause the token to longer work
868
+ * (including moving files, changing permissions, or OS-specific limitations).
869
+ * If a persistent token cannot be reused, you'll get an error at the time of use.
870
+ *
871
+ * @param entry
872
+ * @returns The persistent token for the given entry.
873
+ *
874
+ * @see {@link https://developer.adobe.com/photoshop/uxp/2022/uxp-api/reference-js/Modules/uxp/Persistent%20File%20Storage/FileSystemProvider/#createpersistenttokenentry}
875
+ *
876
+ * @example
877
+ * ```js
878
+ * const fs = require('uxp').storage.localFileSystem;
879
+ * let entry = await fs.getFileForOpening();
880
+ * let token = await fs.createPersistentToken(entry);
881
+ * localStorage.setItem("persistent-file", token);
882
+ * ```
883
+ */
884
+ createPersistentToken(entry: Entry): Promise<string>;
885
+
886
+ /**
887
+ * Returns the file system Entry that corresponds to the persistent token obtained from createPersistentToken.
888
+ * If an entry cannot be found that matches the token, then a Reference Error: token is not defined error is
889
+ * thrown.
890
+ *
891
+ * Note: Retrieving an entry for a persistent token does not guarantee that the entry is valid for use.
892
+ * You'll need to properly handle the case where the entry no longer exists on the disk, or the permissions have
893
+ * changed by catching the appropriate errors.
894
+ * If that occurs, the suggested practice is to prompt the user for the entry again and store the new token.
895
+ *
896
+ * @param token
897
+ * @returns The corresponding entry for the persistent token.
898
+ *
899
+ * @see {@link https://developer.adobe.com/photoshop/uxp/2022/uxp-api/reference-js/Modules/uxp/Persistent%20File%20Storage/FileSystemProvider/#getentryforpersistenttokentoken}
900
+ *
901
+ * @example
902
+ * ```js
903
+ * const fs = require('uxp').storage.localFileSystem;
904
+ * let entry, contents, tries = 3, success = false;
905
+ * while (tries > 0) {
906
+ * try {
907
+ * entry = await fs.getEntryForPersistentToken(localStorage.getItem("persistent-file"));
908
+ * contents = await entry.read();
909
+ * tries = 0;
910
+ * success = true;
911
+ * } catch(err) {
912
+ * entry = await fs.getFileForOpening();
913
+ * localStorage.setItem("persistent-token", await fs.createPersistentToken(entry));
914
+ * tries--;
915
+ * }
916
+ * }
917
+ * if (!success) {
918
+ * // fail gracefully somehow
919
+ * }
920
+ * ```
921
+ */
922
+ getEntryForPersistentToken(token: string): Promise<Entry>;
923
+
924
+ /**
925
+ * Gets an entry of the given url and returns the appropriate instance.
926
+ *
927
+ * @param url
928
+ * @returns The corresponding entry for the given url.
929
+ * @throws Error if invalid file url format or value is passed. if the file/folder does not exist at the url.
930
+ *
931
+ * @see {@link https://developer.adobe.com/photoshop/uxp/2022/uxp-api/reference-js/Modules/uxp/Persistent%20File%20Storage/FileSystemProvider/#getentrywithurlurl}
932
+ *
933
+ * @example
934
+ * ```js
935
+ * const tmpFolder = await fs.getEntryWithUrl("plugin-temp:/tmp");
936
+ * const docFolder = await fs.getEntryWithUrl("file:/Users/user/Documents");
937
+ * const tmpFile = await fs.getEntryWithUrl("plugin-temp:/tmp/test.dat");
938
+ * const docFile = await fs.getEntryWithUrl("file:/Users/user/Documents/test.txt");
939
+ * ```
940
+ */
941
+ getEntryWithUrl(url: string): Promise<Entry>;
942
+ }
943
+
944
+ export class LocalFileSystemProvider extends FileSystemProvider {}
945
+
946
+ /**
947
+ * @see https://developer.adobe.com/photoshop/uxp/2022/uxp/reference-js/Modules/uxp/Persistent%20File%20Storage/
948
+ */
949
+ interface Storage {
950
+
951
+ /**
952
+ * Common locations that we can use when displaying a file picker.
953
+ */
954
+ domains: {
955
+ /**
956
+ * Local application cache directory (persistence not guaranteed).
957
+ */
958
+ appLocalCache: DomainSymbol;
959
+ /**
960
+ * Local application data.
961
+ */
962
+ appLocalData: DomainSymbol;
963
+ /**
964
+ * Local application library.
965
+ */
966
+ appLocalLibrary: DomainSymbol;
967
+ /**
968
+ * Local application shared data folder.
969
+ */
970
+ appLocalShared: DomainSymbol;
971
+ /**
972
+ * Local temporary directory.
973
+ */
974
+ appLocalTemporary: DomainSymbol;
975
+ /**
976
+ * Roaming application data.
977
+ */
978
+ appRoamingData: DomainSymbol;
979
+ /**
980
+ * Roaming application library data.
981
+ */
982
+ appRoamingLibrary: DomainSymbol;
983
+ /**
984
+ * The user's desktop folder.
985
+ */
986
+ userDesktop: DomainSymbol;
987
+ /**
988
+ * The user's documents folder.
989
+ */
990
+ userDocuments: DomainSymbol;
991
+ /**
992
+ * The user's music folder or library.
993
+ */
994
+ userMusic: DomainSymbol;
995
+ /**
996
+ * The user's pictures folder or library.
997
+ */
998
+ userPictures: DomainSymbol;
999
+ /**
1000
+ * The user's videos / movies folder or library.
1001
+ */
1002
+ userVideos: DomainSymbol;
1003
+ };
1004
+
1005
+ /**
1006
+ * This namespace describes the file content formats supported in FS methods like read and write.
1007
+ */
1008
+ formats: {
1009
+ /**
1010
+ * Binary file encoding.
1011
+ */
1012
+ binary: FormatSymbol;
1013
+ /**
1014
+ * UTF8 File encoding.
1015
+ */
1016
+ utf8: FormatSymbol;
1017
+ };
1018
+
1019
+ /**
1020
+ * This namespace describes the file open modes.
1021
+ * For eg: open file in read-only or both read-write.
1022
+ */
1023
+ modes: {
1024
+ /**
1025
+ * The file is read-only; attempts to write will fail.
1026
+ */
1027
+ readOnly: ModeSymbol;
1028
+ /**
1029
+ * The file is read-write.
1030
+ */
1031
+ readWrite: ModeSymbol;
1032
+ };
1033
+
1034
+ /**
1035
+ * This namespace describes the type of the entry.
1036
+ * Whether file or folder etc.
1037
+ */
1038
+ types: {
1039
+ /**
1040
+ * A file; used when creating an entity.
1041
+ */
1042
+ file: TypeSymbol;
1043
+ /**
1044
+ * A folder; used when creating an entity.
1045
+ */
1046
+ folder: TypeSymbol;
1047
+ };
1048
+
1049
+ errors: {
1050
+ /**
1051
+ * Attempted to invoke an abstract method.
1052
+ */
1053
+ AbstractMethodInvocationError: Error;
1054
+
1055
+ /**
1056
+ * Data and Format mismatch.
1057
+ */
1058
+ DataFileFormatMismatchError: Error;
1059
+
1060
+ /**
1061
+ * Domain is not supported by the current FileSystemProvider instance.
1062
+ */
1063
+ DomainNotSupportedError: Error;
1064
+
1065
+ /**
1066
+ * An attempt was made to overwrite an entry without indicating that it was safe to do so via overwrite: true.
1067
+ */
1068
+ EntryExistsError: Error;
1069
+
1070
+ /**
1071
+ * The entry is not a file, but was expected to be.
1072
+ */
1073
+ EntryIsNotAFileError: Error;
1074
+
1075
+ /**
1076
+ * The entry is not a folder, but was expected to be a folder.
1077
+ */
1078
+ EntryIsNotAFolderError: Error;
1079
+
1080
+ /**
1081
+ * The object passed as an entry is not actually an Entry.
1082
+ */
1083
+ EntryIsNotAnEntryError: Error;
1084
+
1085
+ /**
1086
+ * An attempt was made to write to a file that was opened as read-only.
1087
+ */
1088
+ FileIsReadOnlyError: Error;
1089
+
1090
+ /**
1091
+ * Unsupported format type.
1092
+ */
1093
+ InvalidFileFormatError: Error;
1094
+
1095
+ /**
1096
+ * The file name contains invalid characters.
1097
+ */
1098
+ InvalidFileNameError: Error;
1099
+
1100
+ /**
1101
+ * The instance was expected to be a file system, but wasn't.
1102
+ */
1103
+ NotAFileSystemError: Error;
1104
+
1105
+ /**
1106
+ * The file system is out of space (or quota has been exceeded).
1107
+ */
1108
+ OutOfSpaceError: Error;
1109
+
1110
+ /**
1111
+ * The file system revoked permission to complete the requested action.
1112
+ */
1113
+ PermissionDeniedError: Error;
1114
+
1115
+ /**
1116
+ * Attempted to execute a command that required the providers of all entries to match.
1117
+ */
1118
+ ProviderMismatchError: Error;
1119
+ };
1120
+
1121
+ /**
1122
+ * This namespace describes the various file type extensions that can used be used in some FS file open methods.
1123
+ */
1124
+ fileTypes: {
1125
+ /**
1126
+ * All file types.
1127
+ */
1128
+ all: string[];
1129
+ /**
1130
+ * Image file extensions.
1131
+ */
1132
+ images: string[];
1133
+ /**
1134
+ * Text file extensions.
1135
+ */
1136
+ text: string[];
1137
+ };
1138
+
1139
+ localFileSystem: LocalFileSystemProvider;
1140
+
1141
+ /**
1142
+ * SecureStorage provides a protected storage which can be used to store sensitive data per plugin.
1143
+ * SecureStorage takes a key-value pair and encrypts the value before being stored.
1144
+ * After encryption, it stores the key and the encrypted value pair.
1145
+ * When the value is requested with an associated key, it's retrieved after being decrypted.
1146
+ * Please note that the key is not encrypted thus it's not protected by the cryptographic operation.
1147
+ *
1148
+ * Caveats for SecureStorage are as follows:
1149
+ *
1150
+ * 1. Data in SecureStorage can be lost for various reasons. For an example, the user could uninstall the host application
1151
+ * and delete the secure storage. Or, the cryptographic information used by the secure storage could be damaged by the
1152
+ * user accidentally, and it will result in loss of data without the secure storage being removed. SecureStorage should
1153
+ * be regarded as a cache rather than a persistent storage. Data in SecureStorage should be able to be regenerated from
1154
+ * plugins after the time of loss.
1155
+ * 2. SecureStorage is not an appropriate storage for sensitive data which wants to keep secret from the current user.
1156
+ * SecureStorage is protected under the current user's account credential. It means the encrypted data can be at risk
1157
+ * of being decrypted with the current user's privilege.
1158
+ *
1159
+ * @see {@link https://developer.adobe.com/photoshop/uxp/2022/uxp-api/reference-js/Modules/uxp/Key-Value%20Storage/SecureStorage/}
1160
+ */
1161
+ secureStorage: {
1162
+ /**
1163
+ * Returns number of items stored in the secure storage.
1164
+ */
1165
+ length: number;
1166
+
1167
+ /**
1168
+ * Store a key and value pair after the value is encrypted in a secure storage.
1169
+ *
1170
+ * @param key A key to set value.
1171
+ * @param value A value for a key.
1172
+ * @returns Promise that resolves when the value is stored, rejected when the value is empty or not stored.
1173
+ * @throws If either key or value doesn't have one of acceptable types.
1174
+ */
1175
+ setItem: (
1176
+ key: string,
1177
+ value: string | ArrayBuffer | Uint8Array,
1178
+ ) => Promise<void>;
1179
+
1180
+ /**
1181
+ * Retrieve a value associated with a provided key after the value is being decrypted from a secure storage.
1182
+ *
1183
+ * @param key A key to get value.
1184
+ * @returns A value as buffer.
1185
+ * @throws If a key doesn't have an acceptable type.
1186
+ */
1187
+ getItem: (key: string) => Promise<Uint8Array>;
1188
+
1189
+ /**
1190
+ * Remove a value associated with a provided key.
1191
+ *
1192
+ * @param key A key to remove value.
1193
+ * @returns Promise that resolves when the value associated with the key is removed, rejected when the value is neither removed nor found.
1194
+ * @throws If a key doesn't have an acceptable type.
1195
+ */
1196
+ removeItem: (key: string) => Promise<void>;
1197
+
1198
+ /**
1199
+ * Returns a key which is stored at the given index.
1200
+ *
1201
+ * @param index Integer representing the number of the key.
1202
+ * @returns Returns the key which is stored at the given index.
1203
+ */
1204
+ key: (index: number) => string;
1205
+
1206
+ /**
1207
+ * Clear all values in a secure storage.
1208
+ *
1209
+ * @returns Resolved when all the items are cleared.
1210
+ * Rejected when there is no item to clear or clear failed.
1211
+ */
1212
+ clear: () => Promise<void>;
1213
+ };
1214
+ }
1215
+
1216
+ export const storage: Storage;