@bubblydoo/uxp-toolkit 0.0.6 → 0.0.7

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.
@@ -0,0 +1,402 @@
1
+ import {
2
+ createCommand,
3
+ createGetBackgroundLayerCommand,
4
+ createGetDocumentCommand,
5
+ createGetDocumentHasBackgroundLayerCommand,
6
+ createGetLayerCommand,
7
+ createMultiGetDocumentCommand
8
+ } from "../chunk-3CLJMC63.js";
9
+
10
+ // src/commands-library/selectLayer.ts
11
+ import { z } from "zod";
12
+ function createSelectLayerCommand(layerRef) {
13
+ return createCommand({
14
+ modifying: true,
15
+ descriptor: {
16
+ _obj: "select",
17
+ _target: [
18
+ {
19
+ _ref: "layer",
20
+ _id: layerRef.id
21
+ },
22
+ {
23
+ _ref: "document",
24
+ _id: layerRef.docId
25
+ }
26
+ ],
27
+ makeVisible: false,
28
+ layerID: [layerRef.id],
29
+ _isCommand: false
30
+ },
31
+ schema: z.unknown()
32
+ });
33
+ }
34
+
35
+ // src/commands-library/addLayerToSelection.ts
36
+ import { z as z2 } from "zod";
37
+ function createAddLayerToSelectionCommand(layerRef, previousLayerRef) {
38
+ return createCommand({
39
+ modifying: true,
40
+ descriptor: {
41
+ _obj: "select",
42
+ _target: [
43
+ {
44
+ _ref: "layer",
45
+ _id: layerRef.id
46
+ },
47
+ {
48
+ _ref: "document",
49
+ _id: layerRef.docId
50
+ }
51
+ ],
52
+ selectionModifier: {
53
+ _enum: "selectionModifierType",
54
+ _value: "addToSelection"
55
+ },
56
+ makeVisible: false,
57
+ layerID: [layerRef.id, previousLayerRef.id],
58
+ _isCommand: true
59
+ },
60
+ schema: z2.unknown()
61
+ });
62
+ }
63
+
64
+ // src/commands-library/expandFolder.ts
65
+ import { z as z3 } from "zod";
66
+ function createExpandFolderCommand(layerRef) {
67
+ return createCommand({
68
+ modifying: true,
69
+ descriptor: {
70
+ _obj: "set",
71
+ _target: {
72
+ _ref: [
73
+ { _property: "layerSectionExpanded" },
74
+ { _ref: "layer", _id: layerRef.id },
75
+ { _ref: "document", _id: layerRef.docId }
76
+ ]
77
+ },
78
+ to: true
79
+ },
80
+ schema: z3.unknown()
81
+ });
82
+ }
83
+
84
+ // src/commands-library/renameLayer.ts
85
+ import { z as z4 } from "zod";
86
+ function createRenameLayerCommand(layerRef, newName) {
87
+ return createCommand({
88
+ modifying: true,
89
+ descriptor: {
90
+ _obj: "set",
91
+ _target: [{ _ref: "layer", _id: layerRef.id }, { _ref: "document", _id: layerRef.docId }],
92
+ to: { _obj: "layer", name: newName }
93
+ },
94
+ schema: z4.unknown()
95
+ });
96
+ }
97
+
98
+ // src/commands-library/rasterizeLayerStyle.ts
99
+ import { z as z5 } from "zod";
100
+ function createRasterizeLayerStyleCommand(psLayerRef) {
101
+ return createCommand({
102
+ modifying: true,
103
+ descriptor: {
104
+ _obj: "rasterizeLayer",
105
+ _target: [{ _ref: "layer", _id: psLayerRef.id }, { _ref: "document", _id: psLayerRef.docId }],
106
+ what: { _enum: "rasterizeItem", _value: "layerStyle" }
107
+ },
108
+ schema: z5.unknown()
109
+ });
110
+ }
111
+
112
+ // src/commands-library/rasterizeVectorMask.ts
113
+ import { z as z6 } from "zod";
114
+ function createRasterizeVectorMaskCommand() {
115
+ return createCommand({
116
+ modifying: true,
117
+ descriptor: {
118
+ _obj: "rasterizeLayer",
119
+ _target: [
120
+ {
121
+ _ref: "layer",
122
+ _enum: "ordinal",
123
+ _value: "targetEnum"
124
+ }
125
+ ],
126
+ what: {
127
+ _enum: "rasterizeItem",
128
+ _value: "vectorMask"
129
+ }
130
+ },
131
+ schema: z6.unknown()
132
+ });
133
+ }
134
+
135
+ // src/commands-library/applyLayerMask.ts
136
+ import { z as z7 } from "zod";
137
+ function createSelectLayerMaskCommand(layerId) {
138
+ return createCommand({
139
+ modifying: true,
140
+ descriptor: {
141
+ _obj: "select",
142
+ _target: [
143
+ {
144
+ _ref: "channel",
145
+ _enum: "channel",
146
+ _value: "mask"
147
+ },
148
+ {
149
+ _ref: "layer",
150
+ _id: layerId
151
+ }
152
+ ],
153
+ makeVisible: false
154
+ },
155
+ schema: z7.unknown()
156
+ });
157
+ }
158
+ function createDeleteChannelAndApplyCommand() {
159
+ return createCommand({
160
+ modifying: true,
161
+ descriptor: {
162
+ _obj: "delete",
163
+ _target: [
164
+ {
165
+ _ref: "channel",
166
+ _enum: "ordinal",
167
+ _value: "targetEnum"
168
+ }
169
+ ],
170
+ apply: true
171
+ },
172
+ schema: z7.unknown()
173
+ });
174
+ }
175
+
176
+ // src/commands-library/removeLayerMask.ts
177
+ import { z as z8 } from "zod";
178
+ function createDeleteChannelCommand() {
179
+ return createCommand({
180
+ modifying: true,
181
+ descriptor: {
182
+ _obj: "delete",
183
+ _target: [
184
+ {
185
+ _ref: "channel",
186
+ _enum: "ordinal",
187
+ _value: "targetEnum"
188
+ }
189
+ ]
190
+ },
191
+ schema: z8.unknown()
192
+ });
193
+ }
194
+
195
+ // src/commands-library/loadLayerMaskAsSelection.ts
196
+ import { z as z9 } from "zod";
197
+ function createLoadLayerMaskAsSelectionCommand(layerId) {
198
+ return createCommand({
199
+ modifying: true,
200
+ descriptor: {
201
+ _obj: "set",
202
+ _target: [
203
+ {
204
+ _ref: "channel",
205
+ _property: "selection"
206
+ }
207
+ ],
208
+ to: {
209
+ _ref: [
210
+ {
211
+ _ref: "channel",
212
+ _enum: "channel",
213
+ _value: "mask"
214
+ },
215
+ {
216
+ _ref: "layer",
217
+ _id: layerId
218
+ }
219
+ ]
220
+ }
221
+ },
222
+ schema: z9.unknown()
223
+ });
224
+ }
225
+
226
+ // src/commands-library/hasVectorMask.ts
227
+ import { z as z10 } from "zod";
228
+ function createHasVectorMaskCommand(layerId) {
229
+ return createCommand({
230
+ modifying: false,
231
+ descriptor: {
232
+ _obj: "get",
233
+ _target: [
234
+ {
235
+ _property: "hasVectorMask"
236
+ },
237
+ {
238
+ _ref: "layer",
239
+ _id: layerId
240
+ }
241
+ ]
242
+ },
243
+ schema: z10.object({
244
+ hasVectorMask: z10.boolean()
245
+ })
246
+ });
247
+ }
248
+
249
+ // src/commands-library/convertMode.ts
250
+ import { z as z11 } from "zod";
251
+ function createConvertModeCommand(depth) {
252
+ return createCommand({
253
+ modifying: true,
254
+ descriptor: {
255
+ _obj: "convertMode",
256
+ depth
257
+ },
258
+ schema: z11.unknown()
259
+ });
260
+ }
261
+
262
+ // src/commands-library/createColorLookupAdjustmentLayer.ts
263
+ import { z as z12 } from "zod";
264
+ function createColorLookupAdjustmentLayerCommand() {
265
+ return createCommand({
266
+ modifying: true,
267
+ descriptor: {
268
+ _obj: "make",
269
+ _target: [
270
+ {
271
+ _ref: "adjustmentLayer"
272
+ }
273
+ ],
274
+ using: {
275
+ _obj: "adjustmentLayer",
276
+ type: {
277
+ _class: "colorLookup"
278
+ }
279
+ },
280
+ _isCommand: true
281
+ },
282
+ schema: z12.unknown()
283
+ });
284
+ }
285
+
286
+ // src/commands-library/set3DLUTColorLookup.ts
287
+ import { z as z13 } from "zod";
288
+ function createSet3DLUTColorLookupCommand(options) {
289
+ const {
290
+ lutPath,
291
+ lutFormat = "LUTFormatCUBE",
292
+ profileBase64,
293
+ lutFileDataBase64
294
+ } = options;
295
+ return createCommand({
296
+ modifying: true,
297
+ descriptor: {
298
+ _obj: "set",
299
+ _target: [
300
+ {
301
+ _enum: "ordinal",
302
+ _ref: "adjustmentLayer",
303
+ _value: "targetEnum"
304
+ }
305
+ ],
306
+ to: {
307
+ _obj: "colorLookup",
308
+ lookupType: {
309
+ _enum: "colorLookupType",
310
+ _value: "3DLUT"
311
+ },
312
+ name: lutPath,
313
+ LUTFormat: {
314
+ _enum: "LUTFormatType",
315
+ _value: lutFormat
316
+ },
317
+ ...profileBase64 && {
318
+ profile: {
319
+ _data: profileBase64,
320
+ _rawData: "base64"
321
+ }
322
+ },
323
+ ...lutFileDataBase64 && {
324
+ LUT3DFileData: {
325
+ _data: lutFileDataBase64,
326
+ _rawData: "base64"
327
+ }
328
+ },
329
+ LUT3DFileName: lutPath
330
+ },
331
+ _isCommand: true
332
+ },
333
+ schema: z13.unknown()
334
+ });
335
+ }
336
+
337
+ // src/commands-library/exportLUTs.ts
338
+ import { z as z14 } from "zod";
339
+ function createExportLUTsCommand(path, options = {}) {
340
+ const {
341
+ description = "Exported LUT",
342
+ gridPoints = 32,
343
+ copyright = "Copyright",
344
+ exportFormats = ["CUBE", "ICC", "3DL", "CSP"],
345
+ lowercaseExtension = false
346
+ } = options;
347
+ return createCommand({
348
+ modifying: true,
349
+ descriptor: {
350
+ _obj: "export",
351
+ using: {
352
+ _obj: "$lut ",
353
+ $fpth: path,
354
+ $dscr: description,
355
+ $gPts: gridPoints,
356
+ copyright,
357
+ $wICC: exportFormats.includes("ICC"),
358
+ $w3DL: exportFormats.includes("3DL"),
359
+ $wCUB: exportFormats.includes("CUBE"),
360
+ $wCSP: exportFormats.includes("CSP"),
361
+ $lcFE: lowercaseExtension
362
+ }
363
+ },
364
+ schema: z14.unknown()
365
+ });
366
+ }
367
+
368
+ // src/commands-library/renderGrid.ts
369
+ import { z as z15 } from "zod";
370
+ function createRenderGridCommand(gridPoints) {
371
+ return createCommand({
372
+ modifying: true,
373
+ descriptor: {
374
+ _obj: "$3grd",
375
+ $grdP: gridPoints
376
+ },
377
+ schema: z15.unknown()
378
+ });
379
+ }
380
+ export {
381
+ createAddLayerToSelectionCommand,
382
+ createColorLookupAdjustmentLayerCommand,
383
+ createConvertModeCommand,
384
+ createDeleteChannelAndApplyCommand,
385
+ createDeleteChannelCommand,
386
+ createExpandFolderCommand,
387
+ createExportLUTsCommand,
388
+ createGetBackgroundLayerCommand,
389
+ createGetDocumentCommand,
390
+ createGetDocumentHasBackgroundLayerCommand,
391
+ createGetLayerCommand,
392
+ createHasVectorMaskCommand,
393
+ createLoadLayerMaskAsSelectionCommand,
394
+ createMultiGetDocumentCommand,
395
+ createRasterizeLayerStyleCommand,
396
+ createRasterizeVectorMaskCommand,
397
+ createRenameLayerCommand,
398
+ createRenderGridCommand,
399
+ createSelectLayerCommand,
400
+ createSelectLayerMaskCommand,
401
+ createSet3DLUTColorLookupCommand
402
+ };
package/dist/index.d.ts CHANGED
@@ -1,45 +1,12 @@
1
- import * as photoshop_dom_CoreModules from 'photoshop/dom/CoreModules';
2
- import { ActionDescriptor } from 'photoshop/dom/CoreModules';
3
- import { action } from 'photoshop';
4
- import { z } from 'zod';
1
+ import { c as createModifyingBatchPlayContext, P as PsLayerRef } from './psLayerRef-OY3h7srv.js';
2
+ export { C as CorrectBatchPlayOptions, U as UTCommandBase, a as UTCommandModifying, b as UTCommandNonModifying, d as UTCommandResult, e as batchPlay, f as batchPlayCommand, g as batchPlayCommands, h as createCommand, i as createMultiGetDocumentCommand } from './psLayerRef-OY3h7srv.js';
5
3
  import * as photoshop_dom_Document from 'photoshop/dom/Document';
6
4
  import { Document } from 'photoshop/dom/Document';
7
5
  import { Layer } from 'photoshop/dom/Layer';
6
+ import { z } from 'zod';
8
7
  import ErrorStackParser from 'error-stack-parser';
9
-
10
- type P = Parameters<typeof action.batchPlay>;
11
- type CorrectBatchPlayOptions = P[1] & {
12
- immediateRedraw?: boolean;
13
- };
14
- declare function batchPlay(actions: P[0], options?: CorrectBatchPlayOptions): Promise<photoshop_dom_CoreModules.ActionDescriptor[]>;
15
-
16
- interface UTCommandBase<T extends any> {
17
- descriptor: ActionDescriptor;
18
- schema: z.ZodSchema<T>;
19
- }
20
- interface UTCommandModifying<T extends any> extends UTCommandBase<T> {
21
- modifying: true;
22
- }
23
- interface UTCommandNonModifying<T extends any> extends UTCommandBase<T> {
24
- modifying: false;
25
- }
26
- declare function createCommand<TReturn extends any, TModifying extends boolean>(obj: {
27
- descriptor: ActionDescriptor;
28
- schema: z.ZodSchema<TReturn>;
29
- modifying: TModifying;
30
- }): TModifying extends true ? UTCommandModifying<TReturn> : UTCommandNonModifying<TReturn>;
31
- type UTCommandResult<C> = C extends UTCommandBase<infer T> ? T : never;
32
- type BatchPlayOptions = Parameters<typeof batchPlay>[1];
33
- declare function batchPlayCommandBase<T extends any>(command: UTCommandBase<T>, options?: BatchPlayOptions): Promise<T>;
34
- declare function batchPlayCommandsBase<TCommands extends Array<UTCommandBase<any>>>(commands: readonly [...TCommands], options?: BatchPlayOptions): Promise<{
35
- [K in keyof TCommands]: UTCommandResult<TCommands[K]>;
36
- }>;
37
- declare function batchPlayCommand<T extends any>(command: UTCommandNonModifying<T>, options?: BatchPlayOptions): Promise<T>;
38
- declare function batchPlayCommands<TCommands extends Array<UTCommandNonModifying<any>>>(commands: readonly [...TCommands], options?: BatchPlayOptions): Promise<{ [K in keyof TCommands]: UTCommandResult<TCommands[K]>; }>;
39
- declare function createModifyingBatchPlayContext(): {
40
- batchPlayCommand: typeof batchPlayCommandBase;
41
- batchPlayCommands: typeof batchPlayCommandsBase;
42
- };
8
+ import 'photoshop/dom/CoreModules';
9
+ import 'photoshop';
43
10
 
44
11
  type CorrectExecutionContext = {
45
12
  /**
@@ -97,46 +64,6 @@ declare function suspendHistory<T>(document: Document, historyStateName: string,
97
64
  type CombinedFn<T> = (executionContext: ExtendedExecutionContext, suspendHistoryContext: SuspendHistoryContext) => Promise<T>;
98
65
  declare const executeAsModalAndSuspendHistory: <T>(commandName: string, document: Document, fn: CombinedFn<T>) => Promise<T>;
99
66
 
100
- type PsLayerRef = {
101
- id: number;
102
- docId: number;
103
- };
104
-
105
- declare function createRenameLayerCommand(layerRef: PsLayerRef, newName: string): UTCommandModifying<unknown>;
106
-
107
- declare function createGetDocumentCommand(documentId: number): UTCommandNonModifying<{
108
- title: string;
109
- documentID: number;
110
- visible: boolean;
111
- hasBackgroundLayer: boolean;
112
- }>;
113
- declare function createGetDocumentHasBackgroundLayerCommand(documentId: number): UTCommandNonModifying<{
114
- hasBackgroundLayer: boolean;
115
- }>;
116
-
117
- declare function createGetBackgroundLayerCommand(docId: number): UTCommandNonModifying<{
118
- name: string;
119
- visible: boolean;
120
- group: boolean;
121
- layerSection: {
122
- _value: "layerSectionStart" | "layerSectionEnd" | "layerSectionContent";
123
- _enum: "layerSectionType";
124
- };
125
- layerKind: number;
126
- itemIndex: number;
127
- background: boolean;
128
- mode: {
129
- _enum: "blendMode";
130
- _value: string;
131
- };
132
- layerID: number;
133
- layerEffects?: Record<string, {
134
- enabled?: boolean | undefined;
135
- } | {
136
- enabled: boolean;
137
- }[]> | undefined;
138
- }>;
139
-
140
67
  declare const getFlattenedDomLayersList: (layers: Layer[]) => Layer[];
141
68
 
142
69
  type Tree<TRef = unknown> = {
@@ -200,31 +127,6 @@ declare const uxpEntrypointsSchema: z.ZodObject<{
200
127
  }, z.core.$strip>;
201
128
  }, z.core.$strip>;
202
129
 
203
- declare function createMultiGetDocumentCommand(docId: number): UTCommandNonModifying<{
204
- list: {
205
- name: string;
206
- layerID: number;
207
- visible: boolean;
208
- group: boolean;
209
- layerSection: {
210
- _value: "layerSectionStart" | "layerSectionEnd" | "layerSectionContent";
211
- _enum: "layerSectionType";
212
- };
213
- layerKind: number;
214
- itemIndex: number;
215
- background: boolean;
216
- mode: {
217
- _enum: "blendMode";
218
- _value: string;
219
- };
220
- layerEffects?: Record<string, {
221
- enabled?: boolean | undefined;
222
- } | {
223
- enabled: boolean;
224
- }[]> | undefined;
225
- }[];
226
- }>;
227
-
228
130
  declare const getDocumentLayerDescriptors: (documentId: number) => Promise<{
229
131
  docId: number;
230
132
  name: string;
@@ -290,4 +192,4 @@ declare function parseUxpErrorSourcemaps(error: Error, opts?: {
290
192
  }): Promise<BasicStackFrame[]>;
291
193
  declare function getBasicStackFrameAbsoluteFilePath(frame: BasicStackFrame): Promise<string>;
292
194
 
293
- export { type BasicStackFrame, type CorrectBatchPlayOptions, type CorrectExecuteAsModalOptions, type CorrectExecutionContext, type ExtendedExecutionContext, type LayerRef, type PsLayerRef, type SuspendHistoryContext, type Tree, type UTCommandBase, type UTCommandModifying, type UTCommandNonModifying, type UTCommandResult, type UTLayer, type UTLayerPickKeys, type UTLayerWithoutChildren, batchPlay, batchPlayCommand, batchPlayCommands, copyToClipboard, createCommand, createGetBackgroundLayerCommand, createGetDocumentCommand, createGetDocumentHasBackgroundLayerCommand, createModifyingBatchPlayContext, createMultiGetDocumentCommand, createRenameLayerCommand, executeAsModal, executeAsModalAndSuspendHistory, flattenTree, getBasicStackFrameAbsoluteFilePath, getDocumentLayerDescriptors, getFlattenedDomLayersList, getLayerEffects, mapTree, mapTreeRef, openFileByPath, parseUxpErrorSourcemaps, photoshopDomLayersToTree, photoshopGetApplicationInfo, photoshopLayerDescriptorsToUTLayers, readFromClipboard, suspendHistory, utLayerToDomLayer, utLayersToDomLayers, utLayersToTree, utLayersToText as utTreeToText, uxpEntrypointsSchema };
195
+ export { type BasicStackFrame, type CorrectExecuteAsModalOptions, type CorrectExecutionContext, type ExtendedExecutionContext, type LayerDescriptor, type LayerRef, PsLayerRef, type SuspendHistoryContext, type Tree, type UTLayer, type UTLayerPickKeys, type UTLayerWithoutChildren, copyToClipboard, createModifyingBatchPlayContext, executeAsModal, executeAsModalAndSuspendHistory, flattenTree, getBasicStackFrameAbsoluteFilePath, getDocumentLayerDescriptors, getFlattenedDomLayersList, getLayerEffects, mapTree, mapTreeRef, openFileByPath, parseUxpErrorSourcemaps, photoshopDomLayersToTree, photoshopGetApplicationInfo, photoshopLayerDescriptorsToUTLayers, readFromClipboard, suspendHistory, utLayerToDomLayer, utLayersToDomLayers, utLayersToTree, utLayersToText as utTreeToText, uxpEntrypointsSchema };