@bubblydoo/uxp-toolkit 0.0.5 → 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.
- package/.turbo/turbo-build.log +10 -6
- package/CHANGELOG.md +12 -0
- package/dist/chunk-3CLJMC63.js +234 -0
- package/dist/commands-library/index.d.ts +110 -0
- package/dist/commands-library/index.js +402 -0
- package/dist/index.d.ts +8 -103
- package/dist/index.js +156 -271
- package/dist/psLayerRef-OY3h7srv.d.ts +70 -0
- package/package.json +7 -3
- package/src/commands-library/addLayerToSelection.ts +33 -0
- package/src/commands-library/applyLayerMask.ts +42 -0
- package/src/commands-library/convertMode.ts +13 -0
- package/src/commands-library/createColorLookupAdjustmentLayer.ts +24 -0
- package/src/commands-library/expandFolder.ts +21 -0
- package/src/commands-library/exportLUTs.ts +45 -0
- package/src/commands-library/hasVectorMask.ts +23 -0
- package/src/commands-library/index.ts +29 -0
- package/src/commands-library/loadLayerMaskAsSelection.ts +31 -0
- package/src/{ut-tree/getLayerProperties.ts → commands-library/multiGetDocument.ts} +2 -29
- package/src/commands-library/rasterizeLayerStyle.ts +15 -0
- package/src/commands-library/rasterizeVectorMask.ts +23 -0
- package/src/commands-library/removeLayerMask.ts +19 -0
- package/src/commands-library/renameLayer.uxp-test.ts +1 -1
- package/src/commands-library/renderGrid.ts +13 -0
- package/src/commands-library/selectLayer.ts +26 -0
- package/src/commands-library/set3DLUTColorLookup.ts +61 -0
- package/src/index.ts +6 -10
- package/src/ut-tree/getDocumentLayerDescriptors.ts +29 -0
- package/src/ut-tree/photoshopLayerDescriptorsToUTLayers.ts +1 -1
- package/src/ut-tree/photoshopLayerDescriptorsToUTLayers.uxp-test.ts +1 -1
- package/tsup.config.ts +9 -9
package/dist/index.js
CHANGED
|
@@ -1,88 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
import "zod";
|
|
14
|
-
|
|
15
|
-
// src/core/executeAsModal.ts
|
|
16
|
-
import { core } from "photoshop";
|
|
17
|
-
var originalExecuteAsModal = core.executeAsModal;
|
|
18
|
-
async function executeAsModal(commandName, fn, opts) {
|
|
19
|
-
let error;
|
|
20
|
-
let result;
|
|
21
|
-
await originalExecuteAsModal(async (executionContext) => {
|
|
22
|
-
const abortController = new AbortController();
|
|
23
|
-
executionContext.onCancel = () => {
|
|
24
|
-
abortController.abort();
|
|
25
|
-
};
|
|
26
|
-
const extendedExecutionContext = {
|
|
27
|
-
isCancelled: executionContext.isCancelled,
|
|
28
|
-
reportProgress: executionContext.reportProgress,
|
|
29
|
-
hostControl: executionContext.hostControl,
|
|
30
|
-
signal: abortController.signal,
|
|
31
|
-
...createModifyingBatchPlayContext()
|
|
32
|
-
};
|
|
33
|
-
try {
|
|
34
|
-
result = await fn(extendedExecutionContext);
|
|
35
|
-
} catch (e) {
|
|
36
|
-
console.error("error in executeAsModal");
|
|
37
|
-
console.error(e);
|
|
38
|
-
error = e;
|
|
39
|
-
}
|
|
40
|
-
}, {
|
|
41
|
-
commandName,
|
|
42
|
-
...opts
|
|
43
|
-
});
|
|
44
|
-
if (error) {
|
|
45
|
-
throw error;
|
|
46
|
-
} else {
|
|
47
|
-
return result;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// src/core/command.ts
|
|
52
|
-
import "photoshop";
|
|
53
|
-
function createCommand(obj) {
|
|
54
|
-
return {
|
|
55
|
-
modifying: obj.modifying,
|
|
56
|
-
descriptor: obj.descriptor,
|
|
57
|
-
schema: obj.schema
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
async function batchPlayCommandBase(command, options) {
|
|
61
|
-
const [result] = await batchPlay([command.descriptor], options);
|
|
62
|
-
if (result?._obj === "error") {
|
|
63
|
-
throw new Error("Batch play command failed", { cause: result });
|
|
64
|
-
}
|
|
65
|
-
return command.schema.parse(result);
|
|
66
|
-
}
|
|
67
|
-
async function batchPlayCommandsBase(commands, options) {
|
|
68
|
-
const results = await batchPlay(commands.map((command) => command.descriptor), options);
|
|
69
|
-
if (results[0]?._obj === "error") {
|
|
70
|
-
throw new Error("Batch play command failed", { cause: results[0] });
|
|
71
|
-
}
|
|
72
|
-
return commands.map((command, index) => command.schema.parse(results[index]));
|
|
73
|
-
}
|
|
74
|
-
function batchPlayCommand(command, options) {
|
|
75
|
-
return batchPlayCommandBase(command, options);
|
|
76
|
-
}
|
|
77
|
-
function batchPlayCommands(commands, options) {
|
|
78
|
-
return batchPlayCommandsBase(commands, options);
|
|
79
|
-
}
|
|
80
|
-
function createModifyingBatchPlayContext() {
|
|
81
|
-
return {
|
|
82
|
-
batchPlayCommand: batchPlayCommandBase,
|
|
83
|
-
batchPlayCommands: batchPlayCommandsBase
|
|
84
|
-
};
|
|
85
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
batchPlay,
|
|
3
|
+
batchPlayCommand,
|
|
4
|
+
batchPlayCommands,
|
|
5
|
+
createCommand,
|
|
6
|
+
createGetBackgroundLayerCommand,
|
|
7
|
+
createGetDocumentHasBackgroundLayerCommand,
|
|
8
|
+
createGetLayerCommand,
|
|
9
|
+
createModifyingBatchPlayContext,
|
|
10
|
+
createMultiGetDocumentCommand,
|
|
11
|
+
executeAsModal
|
|
12
|
+
} from "./chunk-3CLJMC63.js";
|
|
86
13
|
|
|
87
14
|
// src/core/suspendHistory.ts
|
|
88
15
|
async function suspendHistory(document, historyStateName, fn) {
|
|
@@ -100,108 +27,6 @@ var executeAsModalAndSuspendHistory = async (commandName, document, fn) => {
|
|
|
100
27
|
});
|
|
101
28
|
};
|
|
102
29
|
|
|
103
|
-
// src/commands-library/renameLayer.ts
|
|
104
|
-
import { z as z2 } from "zod";
|
|
105
|
-
function createRenameLayerCommand(layerRef, newName) {
|
|
106
|
-
return createCommand({
|
|
107
|
-
modifying: true,
|
|
108
|
-
descriptor: {
|
|
109
|
-
_obj: "set",
|
|
110
|
-
_target: [{ _ref: "layer", _id: layerRef.id }, { _ref: "document", _id: layerRef.docId }],
|
|
111
|
-
to: { _obj: "layer", name: newName }
|
|
112
|
-
},
|
|
113
|
-
schema: z2.unknown()
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// src/commands-library/getDocument.ts
|
|
118
|
-
import z3 from "zod";
|
|
119
|
-
function createGetDocumentCommand(documentId) {
|
|
120
|
-
return createCommand({
|
|
121
|
-
modifying: false,
|
|
122
|
-
descriptor: {
|
|
123
|
-
_obj: "get",
|
|
124
|
-
_target: { _ref: [{ _ref: "document", _id: documentId }] }
|
|
125
|
-
},
|
|
126
|
-
schema: z3.object({
|
|
127
|
-
title: z3.string(),
|
|
128
|
-
documentID: z3.number(),
|
|
129
|
-
visible: z3.boolean(),
|
|
130
|
-
hasBackgroundLayer: z3.boolean()
|
|
131
|
-
})
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
function createGetDocumentHasBackgroundLayerCommand(documentId) {
|
|
135
|
-
return createCommand({
|
|
136
|
-
modifying: false,
|
|
137
|
-
descriptor: {
|
|
138
|
-
_obj: "get",
|
|
139
|
-
_target: {
|
|
140
|
-
_ref: [
|
|
141
|
-
{ _property: "hasBackgroundLayer" },
|
|
142
|
-
{ _ref: "document", _id: documentId }
|
|
143
|
-
]
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
|
-
schema: z3.object({
|
|
147
|
-
hasBackgroundLayer: z3.boolean()
|
|
148
|
-
})
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
// src/commands-library/getLayer.ts
|
|
153
|
-
import z4 from "zod";
|
|
154
|
-
var layerSchema = z4.object({
|
|
155
|
-
name: z4.string(),
|
|
156
|
-
visible: z4.boolean(),
|
|
157
|
-
group: z4.boolean(),
|
|
158
|
-
layerSection: z4.object({
|
|
159
|
-
_value: z4.enum([
|
|
160
|
-
"layerSectionStart",
|
|
161
|
-
"layerSectionEnd",
|
|
162
|
-
"layerSectionContent"
|
|
163
|
-
]),
|
|
164
|
-
_enum: z4.literal("layerSectionType")
|
|
165
|
-
}),
|
|
166
|
-
layerKind: z4.number(),
|
|
167
|
-
itemIndex: z4.number(),
|
|
168
|
-
background: z4.boolean(),
|
|
169
|
-
mode: z4.object({
|
|
170
|
-
_enum: z4.literal("blendMode"),
|
|
171
|
-
_value: z4.string()
|
|
172
|
-
}),
|
|
173
|
-
layerID: z4.number(),
|
|
174
|
-
layerEffects: z4.record(z4.string(), z4.object({
|
|
175
|
-
// "scale" does not have an "enabled" property, that's why it's optional
|
|
176
|
-
enabled: z4.boolean().optional()
|
|
177
|
-
}).or(z4.array(z4.object({
|
|
178
|
-
enabled: z4.boolean()
|
|
179
|
-
})))).optional()
|
|
180
|
-
});
|
|
181
|
-
function createGetLayerCommand(layerRef) {
|
|
182
|
-
return createCommand({
|
|
183
|
-
modifying: false,
|
|
184
|
-
descriptor: {
|
|
185
|
-
_obj: "get",
|
|
186
|
-
_target: [
|
|
187
|
-
{ _ref: "layer", _id: layerRef.id },
|
|
188
|
-
{ _ref: "document", _id: layerRef.docId }
|
|
189
|
-
]
|
|
190
|
-
},
|
|
191
|
-
schema: layerSchema
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
function createGetBackgroundLayerCommand(docId) {
|
|
195
|
-
return createCommand({
|
|
196
|
-
modifying: false,
|
|
197
|
-
descriptor: {
|
|
198
|
-
_obj: "get",
|
|
199
|
-
_target: { _ref: [{ _ref: "layer", "_property": "background" }, { _ref: "document", _id: docId }] }
|
|
200
|
-
},
|
|
201
|
-
schema: layerSchema
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
|
|
205
30
|
// src/dom/getFlattenedDomLayersList.ts
|
|
206
31
|
import { constants } from "photoshop";
|
|
207
32
|
var getFlattenedDomLayersList = (layers) => {
|
|
@@ -284,37 +109,37 @@ function mapTreeRef(tree, mapFn) {
|
|
|
284
109
|
}
|
|
285
110
|
|
|
286
111
|
// src/other/applicationInfo.ts
|
|
287
|
-
import { z
|
|
112
|
+
import { z } from "zod";
|
|
288
113
|
async function photoshopGetApplicationInfo() {
|
|
289
114
|
return await batchPlayCommand(photoshopApplicationInfoCommand);
|
|
290
115
|
}
|
|
291
|
-
var photoshopAppInfoSchema =
|
|
292
|
-
active:
|
|
293
|
-
autoShowHomeScreen:
|
|
294
|
-
available:
|
|
295
|
-
buildNumber:
|
|
296
|
-
documentArea:
|
|
297
|
-
left:
|
|
298
|
-
top:
|
|
299
|
-
right:
|
|
300
|
-
bottom:
|
|
116
|
+
var photoshopAppInfoSchema = z.object({
|
|
117
|
+
active: z.boolean(),
|
|
118
|
+
autoShowHomeScreen: z.boolean(),
|
|
119
|
+
available: z.number(),
|
|
120
|
+
buildNumber: z.string(),
|
|
121
|
+
documentArea: z.object({
|
|
122
|
+
left: z.number(),
|
|
123
|
+
top: z.number(),
|
|
124
|
+
right: z.number(),
|
|
125
|
+
bottom: z.number()
|
|
301
126
|
}),
|
|
302
|
-
hostName:
|
|
303
|
-
hostVersion:
|
|
304
|
-
versionMajor:
|
|
305
|
-
versionMinor:
|
|
306
|
-
versionFix:
|
|
127
|
+
hostName: z.string(),
|
|
128
|
+
hostVersion: z.object({
|
|
129
|
+
versionMajor: z.number(),
|
|
130
|
+
versionMinor: z.number(),
|
|
131
|
+
versionFix: z.number()
|
|
307
132
|
}),
|
|
308
|
-
localeInfo:
|
|
309
|
-
decimalPoint:
|
|
133
|
+
localeInfo: z.object({
|
|
134
|
+
decimalPoint: z.string()
|
|
310
135
|
}),
|
|
311
|
-
osVersion:
|
|
312
|
-
panelList:
|
|
313
|
-
|
|
314
|
-
ID:
|
|
315
|
-
name:
|
|
316
|
-
obscured:
|
|
317
|
-
visible:
|
|
136
|
+
osVersion: z.string(),
|
|
137
|
+
panelList: z.array(
|
|
138
|
+
z.object({
|
|
139
|
+
ID: z.string(),
|
|
140
|
+
name: z.string(),
|
|
141
|
+
obscured: z.boolean(),
|
|
142
|
+
visible: z.boolean()
|
|
318
143
|
})
|
|
319
144
|
)
|
|
320
145
|
});
|
|
@@ -345,64 +170,19 @@ async function readFromClipboard() {
|
|
|
345
170
|
}
|
|
346
171
|
|
|
347
172
|
// src/other/uxpEntrypoints.ts
|
|
348
|
-
import { z as
|
|
349
|
-
var uxpEntrypointsSchema =
|
|
350
|
-
_pluginInfo:
|
|
351
|
-
id:
|
|
352
|
-
name:
|
|
353
|
-
version:
|
|
173
|
+
import { z as z2 } from "zod";
|
|
174
|
+
var uxpEntrypointsSchema = z2.object({
|
|
175
|
+
_pluginInfo: z2.object({
|
|
176
|
+
id: z2.string(),
|
|
177
|
+
name: z2.string(),
|
|
178
|
+
version: z2.string()
|
|
354
179
|
})
|
|
355
180
|
});
|
|
356
181
|
|
|
357
|
-
// src/ut-tree/
|
|
358
|
-
import { z as z7 } from "zod";
|
|
359
|
-
function createGetLayerPropertiesCommand(docId) {
|
|
360
|
-
return createCommand({
|
|
361
|
-
modifying: false,
|
|
362
|
-
descriptor: {
|
|
363
|
-
_obj: "multiGet",
|
|
364
|
-
_target: { _ref: [{ _ref: "document", _id: docId }] },
|
|
365
|
-
extendedReference: [
|
|
366
|
-
["name", "layerID", "visible", "group", "layerSection", "layerKind", "itemIndex", "background", "mode", "layerEffects"],
|
|
367
|
-
{ _obj: "layer", index: 1, count: -1 }
|
|
368
|
-
]
|
|
369
|
-
},
|
|
370
|
-
schema: z7.object({
|
|
371
|
-
list: z7.array(
|
|
372
|
-
z7.object({
|
|
373
|
-
name: z7.string(),
|
|
374
|
-
layerID: z7.number(),
|
|
375
|
-
visible: z7.boolean(),
|
|
376
|
-
group: z7.boolean(),
|
|
377
|
-
layerSection: z7.object({
|
|
378
|
-
_value: z7.enum([
|
|
379
|
-
"layerSectionStart",
|
|
380
|
-
"layerSectionEnd",
|
|
381
|
-
"layerSectionContent"
|
|
382
|
-
]),
|
|
383
|
-
_enum: z7.literal("layerSectionType")
|
|
384
|
-
}),
|
|
385
|
-
layerKind: z7.number(),
|
|
386
|
-
itemIndex: z7.number(),
|
|
387
|
-
background: z7.boolean(),
|
|
388
|
-
mode: z7.object({
|
|
389
|
-
_enum: z7.literal("blendMode"),
|
|
390
|
-
_value: z7.string()
|
|
391
|
-
}),
|
|
392
|
-
layerEffects: z7.record(z7.string(), z7.object({
|
|
393
|
-
// "scale" does not have an "enabled" property, that's why it's optional
|
|
394
|
-
enabled: z7.boolean().optional()
|
|
395
|
-
}).or(z7.array(z7.object({
|
|
396
|
-
enabled: z7.boolean()
|
|
397
|
-
})))).optional()
|
|
398
|
-
})
|
|
399
|
-
)
|
|
400
|
-
})
|
|
401
|
-
});
|
|
402
|
-
}
|
|
182
|
+
// src/ut-tree/getDocumentLayerDescriptors.ts
|
|
403
183
|
var getDocumentLayerDescriptors = async (documentId) => {
|
|
404
184
|
const [layersResult, documentHasBackgroundLayerResult] = await batchPlayCommands([
|
|
405
|
-
|
|
185
|
+
createMultiGetDocumentCommand(documentId),
|
|
406
186
|
createGetDocumentHasBackgroundLayerCommand(documentId)
|
|
407
187
|
]);
|
|
408
188
|
const backgroundLayerResult = documentHasBackgroundLayerResult.hasBackgroundLayer ? await batchPlayCommand(createGetBackgroundLayerCommand(documentId)) : null;
|
|
@@ -429,6 +209,114 @@ async function getLayerEffects(layerRef) {
|
|
|
429
209
|
return effects;
|
|
430
210
|
}
|
|
431
211
|
|
|
212
|
+
// src/ut-tree/photoshopLayerDescriptorsToUTLayers.ts
|
|
213
|
+
var layerKindMap = /* @__PURE__ */ new Map([
|
|
214
|
+
[1, "pixel"],
|
|
215
|
+
[2, "adjustment-layer"],
|
|
216
|
+
// All adjustment layers
|
|
217
|
+
[3, "text"],
|
|
218
|
+
[4, "curves"],
|
|
219
|
+
[5, "smartObject"],
|
|
220
|
+
[6, "video"],
|
|
221
|
+
[7, "group"],
|
|
222
|
+
[8, "threeD"],
|
|
223
|
+
[9, "gradientFill"],
|
|
224
|
+
[10, "pattern"],
|
|
225
|
+
[11, "solidColor"],
|
|
226
|
+
[12, "background"]
|
|
227
|
+
// according to the internet but the actual value is undefined
|
|
228
|
+
]);
|
|
229
|
+
var blendModes = [
|
|
230
|
+
"normal",
|
|
231
|
+
"dissolve",
|
|
232
|
+
"darken",
|
|
233
|
+
"multiply",
|
|
234
|
+
"colorBurn",
|
|
235
|
+
"linearBurn",
|
|
236
|
+
"darkerColor",
|
|
237
|
+
"lighten",
|
|
238
|
+
"screen",
|
|
239
|
+
"colorDodge",
|
|
240
|
+
"linearDodge",
|
|
241
|
+
"lighterColor",
|
|
242
|
+
"overlay",
|
|
243
|
+
"softLight",
|
|
244
|
+
"hardLight",
|
|
245
|
+
"vividLight",
|
|
246
|
+
"linearLight",
|
|
247
|
+
"pinLight",
|
|
248
|
+
"hardMix",
|
|
249
|
+
"difference",
|
|
250
|
+
"exclusion",
|
|
251
|
+
"blendSubtraction",
|
|
252
|
+
"blendDivide",
|
|
253
|
+
"hue",
|
|
254
|
+
"saturation",
|
|
255
|
+
"color",
|
|
256
|
+
"luminosity",
|
|
257
|
+
"passThrough"
|
|
258
|
+
];
|
|
259
|
+
var getLayerKind = (layer) => {
|
|
260
|
+
const kind = layerKindMap.get(layer.layerKind);
|
|
261
|
+
if (!kind) {
|
|
262
|
+
throw new Error(`Unknown layer kind: ${layer.layerKind}`);
|
|
263
|
+
}
|
|
264
|
+
return kind;
|
|
265
|
+
};
|
|
266
|
+
var getBlendMode = (layer) => {
|
|
267
|
+
const mode = layer.mode._value;
|
|
268
|
+
if (!blendModes.includes(mode)) {
|
|
269
|
+
throw new Error(`Unknown blend mode: ${mode}`);
|
|
270
|
+
}
|
|
271
|
+
return mode;
|
|
272
|
+
};
|
|
273
|
+
function photoshopLayerDescriptorsToUTLayers(layers) {
|
|
274
|
+
const root = [];
|
|
275
|
+
const stack = [{ layers: root }];
|
|
276
|
+
for (const layer of layers) {
|
|
277
|
+
const sectionType = determineLayerSection(layer);
|
|
278
|
+
if (sectionType === "end") {
|
|
279
|
+
if (stack.length > 1) {
|
|
280
|
+
stack.pop();
|
|
281
|
+
}
|
|
282
|
+
continue;
|
|
283
|
+
}
|
|
284
|
+
const node = {
|
|
285
|
+
name: layer.name,
|
|
286
|
+
docId: layer.docId,
|
|
287
|
+
id: layer.layerID,
|
|
288
|
+
visible: layer.visible,
|
|
289
|
+
kind: getLayerKind(layer),
|
|
290
|
+
blendMode: getBlendMode(layer),
|
|
291
|
+
isClippingMask: layer.group,
|
|
292
|
+
effects: getEffects(layer),
|
|
293
|
+
background: layer.background
|
|
294
|
+
};
|
|
295
|
+
const current = stack[stack.length - 1];
|
|
296
|
+
current.layers.push(node);
|
|
297
|
+
if (sectionType === "start") {
|
|
298
|
+
node.layers = [];
|
|
299
|
+
stack.push({ layers: node.layers });
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
return root;
|
|
303
|
+
}
|
|
304
|
+
var determineLayerSection = (layer) => {
|
|
305
|
+
const section = layer.layerSection._value;
|
|
306
|
+
const isGroupEnd = layer.name === "</Layer group>" || layer.name === "</Layer set>" || section === "layerSectionEnd";
|
|
307
|
+
const isGroupStart = section === "layerSectionStart";
|
|
308
|
+
return isGroupStart ? "start" : isGroupEnd ? "end" : "normal";
|
|
309
|
+
};
|
|
310
|
+
function getEffects(layer) {
|
|
311
|
+
const effects = {};
|
|
312
|
+
if (layer.layerEffects) {
|
|
313
|
+
for (const effect in layer.layerEffects) {
|
|
314
|
+
effects[effect] = Array.isArray(layer.layerEffects[effect]) ? layer.layerEffects[effect].some((e) => e.enabled) : !!layer.layerEffects[effect]?.enabled;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
return effects;
|
|
318
|
+
}
|
|
319
|
+
|
|
432
320
|
// src/ut-tree/utLayersToTree.ts
|
|
433
321
|
function utLayersToTree(layer) {
|
|
434
322
|
return layer.map((layer2) => ({
|
|
@@ -624,25 +512,22 @@ export {
|
|
|
624
512
|
batchPlayCommands,
|
|
625
513
|
copyToClipboard,
|
|
626
514
|
createCommand,
|
|
627
|
-
createGetBackgroundLayerCommand,
|
|
628
|
-
createGetDocumentCommand,
|
|
629
|
-
createGetDocumentHasBackgroundLayerCommand,
|
|
630
|
-
createGetLayerPropertiesCommand,
|
|
631
515
|
createModifyingBatchPlayContext,
|
|
632
|
-
|
|
516
|
+
createMultiGetDocumentCommand,
|
|
633
517
|
executeAsModal,
|
|
634
518
|
executeAsModalAndSuspendHistory,
|
|
635
519
|
flattenTree,
|
|
636
520
|
getBasicStackFrameAbsoluteFilePath,
|
|
521
|
+
getDocumentLayerDescriptors,
|
|
637
522
|
getFlattenedDomLayersList,
|
|
638
523
|
getLayerEffects,
|
|
639
|
-
getDocumentLayerDescriptors as getLayerPropertiesFromUtTree,
|
|
640
524
|
mapTree,
|
|
641
525
|
mapTreeRef,
|
|
642
526
|
openFileByPath,
|
|
643
527
|
parseUxpErrorSourcemaps,
|
|
644
528
|
photoshopDomLayersToTree,
|
|
645
529
|
photoshopGetApplicationInfo,
|
|
530
|
+
photoshopLayerDescriptorsToUTLayers,
|
|
646
531
|
readFromClipboard,
|
|
647
532
|
suspendHistory,
|
|
648
533
|
utLayerToDomLayer,
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import * as photoshop_dom_CoreModules from 'photoshop/dom/CoreModules';
|
|
2
|
+
import { ActionDescriptor } from 'photoshop/dom/CoreModules';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { action } from 'photoshop';
|
|
5
|
+
|
|
6
|
+
type P = Parameters<typeof action.batchPlay>;
|
|
7
|
+
type CorrectBatchPlayOptions = P[1] & {
|
|
8
|
+
immediateRedraw?: boolean;
|
|
9
|
+
};
|
|
10
|
+
declare function batchPlay(actions: P[0], options?: CorrectBatchPlayOptions): Promise<photoshop_dom_CoreModules.ActionDescriptor[]>;
|
|
11
|
+
|
|
12
|
+
interface UTCommandBase<T extends any> {
|
|
13
|
+
descriptor: ActionDescriptor;
|
|
14
|
+
schema: z.ZodSchema<T>;
|
|
15
|
+
}
|
|
16
|
+
interface UTCommandModifying<T extends any> extends UTCommandBase<T> {
|
|
17
|
+
modifying: true;
|
|
18
|
+
}
|
|
19
|
+
interface UTCommandNonModifying<T extends any> extends UTCommandBase<T> {
|
|
20
|
+
modifying: false;
|
|
21
|
+
}
|
|
22
|
+
declare function createCommand<TReturn extends any, TModifying extends boolean>(obj: {
|
|
23
|
+
descriptor: ActionDescriptor;
|
|
24
|
+
schema: z.ZodSchema<TReturn>;
|
|
25
|
+
modifying: TModifying;
|
|
26
|
+
}): TModifying extends true ? UTCommandModifying<TReturn> : UTCommandNonModifying<TReturn>;
|
|
27
|
+
type UTCommandResult<C> = C extends UTCommandBase<infer T> ? T : never;
|
|
28
|
+
type BatchPlayOptions = Parameters<typeof batchPlay>[1];
|
|
29
|
+
declare function batchPlayCommandBase<T extends any>(command: UTCommandBase<T>, options?: BatchPlayOptions): Promise<T>;
|
|
30
|
+
declare function batchPlayCommandsBase<TCommands extends Array<UTCommandBase<any>>>(commands: readonly [...TCommands], options?: BatchPlayOptions): Promise<{
|
|
31
|
+
[K in keyof TCommands]: UTCommandResult<TCommands[K]>;
|
|
32
|
+
}>;
|
|
33
|
+
declare function batchPlayCommand<T extends any>(command: UTCommandNonModifying<T>, options?: BatchPlayOptions): Promise<T>;
|
|
34
|
+
declare function batchPlayCommands<TCommands extends Array<UTCommandNonModifying<any>>>(commands: readonly [...TCommands], options?: BatchPlayOptions): Promise<{ [K in keyof TCommands]: UTCommandResult<TCommands[K]>; }>;
|
|
35
|
+
declare function createModifyingBatchPlayContext(): {
|
|
36
|
+
batchPlayCommand: typeof batchPlayCommandBase;
|
|
37
|
+
batchPlayCommands: typeof batchPlayCommandsBase;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
declare function createMultiGetDocumentCommand(docId: number): UTCommandNonModifying<{
|
|
41
|
+
list: {
|
|
42
|
+
name: string;
|
|
43
|
+
layerID: number;
|
|
44
|
+
visible: boolean;
|
|
45
|
+
group: boolean;
|
|
46
|
+
layerSection: {
|
|
47
|
+
_value: "layerSectionStart" | "layerSectionEnd" | "layerSectionContent";
|
|
48
|
+
_enum: "layerSectionType";
|
|
49
|
+
};
|
|
50
|
+
layerKind: number;
|
|
51
|
+
itemIndex: number;
|
|
52
|
+
background: boolean;
|
|
53
|
+
mode: {
|
|
54
|
+
_enum: "blendMode";
|
|
55
|
+
_value: string;
|
|
56
|
+
};
|
|
57
|
+
layerEffects?: Record<string, {
|
|
58
|
+
enabled?: boolean | undefined;
|
|
59
|
+
} | {
|
|
60
|
+
enabled: boolean;
|
|
61
|
+
}[]> | undefined;
|
|
62
|
+
}[];
|
|
63
|
+
}>;
|
|
64
|
+
|
|
65
|
+
type PsLayerRef = {
|
|
66
|
+
id: number;
|
|
67
|
+
docId: number;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export { type CorrectBatchPlayOptions as C, type PsLayerRef as P, type UTCommandBase as U, type UTCommandModifying as a, type UTCommandNonModifying as b, createModifyingBatchPlayContext as c, type UTCommandResult as d, batchPlay as e, batchPlayCommand as f, batchPlayCommands as g, createCommand as h, createMultiGetDocumentCommand as i };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bubblydoo/uxp-toolkit",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Hans Otto Wirtz <hansottowirtz@gmail.com>",
|
|
@@ -14,6 +14,10 @@
|
|
|
14
14
|
"types": "./dist/index.d.ts",
|
|
15
15
|
"import": "./dist/index.js"
|
|
16
16
|
},
|
|
17
|
+
"./commands": {
|
|
18
|
+
"types": "./dist/commands-library/index.d.ts",
|
|
19
|
+
"import": "./dist/commands-library/index.js"
|
|
20
|
+
},
|
|
17
21
|
"./package.json": "./package.json"
|
|
18
22
|
},
|
|
19
23
|
"publishConfig": {
|
|
@@ -39,8 +43,8 @@
|
|
|
39
43
|
"typescript": "^5.8.3",
|
|
40
44
|
"vitest": "^4.0.18",
|
|
41
45
|
"zod": "^4.3.6",
|
|
42
|
-
"@bubblydoo/
|
|
43
|
-
"@bubblydoo/
|
|
46
|
+
"@bubblydoo/tsconfig": "0.0.3",
|
|
47
|
+
"@bubblydoo/uxp-test-framework": "0.0.7"
|
|
44
48
|
},
|
|
45
49
|
"scripts": {
|
|
46
50
|
"build": "tsup",
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { createCommand } from "../core/command";
|
|
3
|
+
import type { PsLayerRef } from "../ut-tree/psLayerRef";
|
|
4
|
+
|
|
5
|
+
export function createAddLayerToSelectionCommand(
|
|
6
|
+
layerRef: PsLayerRef,
|
|
7
|
+
previousLayerRef: PsLayerRef
|
|
8
|
+
) {
|
|
9
|
+
return createCommand({
|
|
10
|
+
modifying: true,
|
|
11
|
+
descriptor: {
|
|
12
|
+
_obj: 'select',
|
|
13
|
+
_target: [
|
|
14
|
+
{
|
|
15
|
+
_ref: 'layer',
|
|
16
|
+
_id: layerRef.id,
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
_ref: 'document',
|
|
20
|
+
_id: layerRef.docId,
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
selectionModifier: {
|
|
24
|
+
_enum: 'selectionModifierType',
|
|
25
|
+
_value: 'addToSelection',
|
|
26
|
+
},
|
|
27
|
+
makeVisible: false,
|
|
28
|
+
layerID: [layerRef.id, previousLayerRef.id],
|
|
29
|
+
_isCommand: true,
|
|
30
|
+
},
|
|
31
|
+
schema: z.unknown(),
|
|
32
|
+
});
|
|
33
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { createCommand } from "../core/command";
|
|
3
|
+
|
|
4
|
+
export function createSelectLayerMaskCommand(layerId: number) {
|
|
5
|
+
return createCommand({
|
|
6
|
+
modifying: true,
|
|
7
|
+
descriptor: {
|
|
8
|
+
_obj: 'select',
|
|
9
|
+
_target: [
|
|
10
|
+
{
|
|
11
|
+
_ref: 'channel',
|
|
12
|
+
_enum: 'channel',
|
|
13
|
+
_value: 'mask',
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
_ref: 'layer',
|
|
17
|
+
_id: layerId,
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
makeVisible: false,
|
|
21
|
+
},
|
|
22
|
+
schema: z.unknown(),
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function createDeleteChannelAndApplyCommand() {
|
|
27
|
+
return createCommand({
|
|
28
|
+
modifying: true,
|
|
29
|
+
descriptor: {
|
|
30
|
+
_obj: 'delete',
|
|
31
|
+
_target: [
|
|
32
|
+
{
|
|
33
|
+
_ref: 'channel',
|
|
34
|
+
_enum: 'ordinal',
|
|
35
|
+
_value: 'targetEnum',
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
apply: true,
|
|
39
|
+
},
|
|
40
|
+
schema: z.unknown(),
|
|
41
|
+
});
|
|
42
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { createCommand } from "../core/command";
|
|
3
|
+
|
|
4
|
+
export function createConvertModeCommand(depth: 8 | 16) {
|
|
5
|
+
return createCommand({
|
|
6
|
+
modifying: true,
|
|
7
|
+
descriptor: {
|
|
8
|
+
_obj: 'convertMode',
|
|
9
|
+
depth,
|
|
10
|
+
},
|
|
11
|
+
schema: z.unknown(),
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { createCommand } from "../core/command";
|
|
3
|
+
|
|
4
|
+
export function createColorLookupAdjustmentLayerCommand() {
|
|
5
|
+
return createCommand({
|
|
6
|
+
modifying: true,
|
|
7
|
+
descriptor: {
|
|
8
|
+
_obj: 'make',
|
|
9
|
+
_target: [
|
|
10
|
+
{
|
|
11
|
+
_ref: 'adjustmentLayer',
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
using: {
|
|
15
|
+
_obj: 'adjustmentLayer',
|
|
16
|
+
type: {
|
|
17
|
+
_class: 'colorLookup',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
_isCommand: true,
|
|
21
|
+
},
|
|
22
|
+
schema: z.unknown(),
|
|
23
|
+
});
|
|
24
|
+
}
|