@bubblydoo/uxp-toolkit 0.0.6 → 0.0.8
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 +6 -104
- package/dist/index.js +43 -269
- package/dist/psLayerRef-OY3h7srv.d.ts +70 -0
- package/package.json +6 -2
- 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/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/renderGrid.ts +13 -0
- package/src/commands-library/selectLayer.ts +26 -0
- package/src/commands-library/set3DLUTColorLookup.ts +61 -0
- package/src/index.ts +1 -9
- 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,62 +170,15 @@ 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/commands-library/multiGetDocument.ts
|
|
358
|
-
import { z as z7 } from "zod";
|
|
359
|
-
function createMultiGetDocumentCommand(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
|
-
}
|
|
403
|
-
|
|
404
182
|
// src/ut-tree/getDocumentLayerDescriptors.ts
|
|
405
183
|
var getDocumentLayerDescriptors = async (documentId) => {
|
|
406
184
|
const [layersResult, documentHasBackgroundLayerResult] = await batchPlayCommands([
|
|
@@ -734,12 +512,8 @@ export {
|
|
|
734
512
|
batchPlayCommands,
|
|
735
513
|
copyToClipboard,
|
|
736
514
|
createCommand,
|
|
737
|
-
createGetBackgroundLayerCommand,
|
|
738
|
-
createGetDocumentCommand,
|
|
739
|
-
createGetDocumentHasBackgroundLayerCommand,
|
|
740
515
|
createModifyingBatchPlayContext,
|
|
741
516
|
createMultiGetDocumentCommand,
|
|
742
|
-
createRenameLayerCommand,
|
|
743
517
|
executeAsModal,
|
|
744
518
|
executeAsModalAndSuspendHistory,
|
|
745
519
|
flattenTree,
|
|
@@ -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.8",
|
|
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": {
|
|
@@ -40,7 +44,7 @@
|
|
|
40
44
|
"vitest": "^4.0.18",
|
|
41
45
|
"zod": "^4.3.6",
|
|
42
46
|
"@bubblydoo/tsconfig": "0.0.3",
|
|
43
|
-
"@bubblydoo/uxp-test-framework": "0.0.
|
|
47
|
+
"@bubblydoo/uxp-test-framework": "0.0.8"
|
|
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
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { createCommand } from "../core/command";
|
|
3
|
+
import type { PsLayerRef } from "../ut-tree/psLayerRef";
|
|
4
|
+
|
|
5
|
+
export function createExpandFolderCommand(layerRef: PsLayerRef) {
|
|
6
|
+
return createCommand({
|
|
7
|
+
modifying: true,
|
|
8
|
+
descriptor: {
|
|
9
|
+
_obj: 'set',
|
|
10
|
+
_target: {
|
|
11
|
+
_ref: [
|
|
12
|
+
{ _property: 'layerSectionExpanded' },
|
|
13
|
+
{ _ref: 'layer', _id: layerRef.id },
|
|
14
|
+
{ _ref: 'document', _id: layerRef.docId }
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
to: true,
|
|
18
|
+
},
|
|
19
|
+
schema: z.unknown(),
|
|
20
|
+
});
|
|
21
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { createCommand } from "../core/command";
|
|
3
|
+
|
|
4
|
+
export type LUTExportFormat = 'CUBE' | 'ICC' | '3DL' | 'CSP';
|
|
5
|
+
|
|
6
|
+
export interface ExportLUTsOptions {
|
|
7
|
+
description?: string;
|
|
8
|
+
gridPoints?: number;
|
|
9
|
+
copyright?: string;
|
|
10
|
+
exportFormats?: LUTExportFormat[];
|
|
11
|
+
lowercaseExtension?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function createExportLUTsCommand(
|
|
15
|
+
path: string,
|
|
16
|
+
options: ExportLUTsOptions = {}
|
|
17
|
+
) {
|
|
18
|
+
const {
|
|
19
|
+
description = 'Exported LUT',
|
|
20
|
+
gridPoints = 32,
|
|
21
|
+
copyright = 'Copyright',
|
|
22
|
+
exportFormats = ['CUBE', 'ICC', '3DL', 'CSP'] as LUTExportFormat[],
|
|
23
|
+
lowercaseExtension = false,
|
|
24
|
+
} = options;
|
|
25
|
+
|
|
26
|
+
return createCommand({
|
|
27
|
+
modifying: true,
|
|
28
|
+
descriptor: {
|
|
29
|
+
_obj: 'export',
|
|
30
|
+
using: {
|
|
31
|
+
_obj: '$lut ',
|
|
32
|
+
$fpth: path,
|
|
33
|
+
$dscr: description,
|
|
34
|
+
$gPts: gridPoints,
|
|
35
|
+
copyright: copyright,
|
|
36
|
+
$wICC: exportFormats.includes('ICC'),
|
|
37
|
+
$w3DL: exportFormats.includes('3DL'),
|
|
38
|
+
$wCUB: exportFormats.includes('CUBE'),
|
|
39
|
+
$wCSP: exportFormats.includes('CSP'),
|
|
40
|
+
$lcFE: lowercaseExtension,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
schema: z.unknown(),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { createCommand } from "../core/command";
|
|
3
|
+
|
|
4
|
+
export function createHasVectorMaskCommand(layerId: number) {
|
|
5
|
+
return createCommand({
|
|
6
|
+
modifying: false,
|
|
7
|
+
descriptor: {
|
|
8
|
+
_obj: 'get',
|
|
9
|
+
_target: [
|
|
10
|
+
{
|
|
11
|
+
_property: 'hasVectorMask',
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
_ref: 'layer',
|
|
15
|
+
_id: layerId,
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
},
|
|
19
|
+
schema: z.object({
|
|
20
|
+
hasVectorMask: z.boolean(),
|
|
21
|
+
}),
|
|
22
|
+
});
|
|
23
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Layer selection and manipulation
|
|
2
|
+
export * from './selectLayer';
|
|
3
|
+
export * from './addLayerToSelection';
|
|
4
|
+
export * from './expandFolder';
|
|
5
|
+
|
|
6
|
+
// Layer operations
|
|
7
|
+
export * from './getLayer';
|
|
8
|
+
export * from './renameLayer';
|
|
9
|
+
export * from './rasterizeLayerStyle';
|
|
10
|
+
export * from './rasterizeVectorMask';
|
|
11
|
+
|
|
12
|
+
// Layer mask operations
|
|
13
|
+
export * from './applyLayerMask';
|
|
14
|
+
export * from './removeLayerMask';
|
|
15
|
+
export * from './loadLayerMaskAsSelection';
|
|
16
|
+
export * from './hasVectorMask';
|
|
17
|
+
|
|
18
|
+
// Document operations
|
|
19
|
+
export * from './getDocument';
|
|
20
|
+
export * from './multiGetDocument';
|
|
21
|
+
export * from './convertMode';
|
|
22
|
+
|
|
23
|
+
// Color and LUT operations
|
|
24
|
+
export * from './createColorLookupAdjustmentLayer';
|
|
25
|
+
export * from './set3DLUTColorLookup';
|
|
26
|
+
export * from './exportLUTs';
|
|
27
|
+
|
|
28
|
+
// Other
|
|
29
|
+
export * from './renderGrid';
|