@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/.turbo/turbo-build.log
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
|
|
2
|
-
> @bubblydoo/uxp-toolkit@0.0.
|
|
2
|
+
> @bubblydoo/uxp-toolkit@0.0.7 build /home/runner/work/uxp-toolkit/uxp-toolkit/packages/uxp-toolkit
|
|
3
3
|
> tsup
|
|
4
4
|
|
|
5
|
-
[34mCLI[39m Building entry: src/index.ts
|
|
5
|
+
[34mCLI[39m Building entry: src/index.ts, src/commands-library/index.ts
|
|
6
6
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
7
|
[34mCLI[39m tsup v8.5.1
|
|
8
8
|
[34mCLI[39m Using tsup config: /home/runner/work/uxp-toolkit/uxp-toolkit/packages/uxp-toolkit/tsup.config.ts
|
|
9
9
|
[34mCLI[39m Target: es2022
|
|
10
10
|
[34mESM[39m Build start
|
|
11
|
-
[32mESM[39m [1mdist/
|
|
12
|
-
[32mESM[39m
|
|
11
|
+
[32mESM[39m [1mdist/chunk-3CLJMC63.js [22m[32m6.20 KB[39m
|
|
12
|
+
[32mESM[39m [1mdist/index.js [22m[32m14.84 KB[39m
|
|
13
|
+
[32mESM[39m [1mdist/commands-library/index.js [22m[32m8.76 KB[39m
|
|
14
|
+
[32mESM[39m ⚡️ Build success in 32ms
|
|
13
15
|
[34mDTS[39m Build start
|
|
14
|
-
[32mDTS[39m ⚡️ Build success in
|
|
15
|
-
[32mDTS[39m [1mdist/index.d.ts
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 3738ms
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m8.05 KB[39m
|
|
18
|
+
[32mDTS[39m [1mdist/commands-library/index.d.ts [22m[32m4.46 KB[39m
|
|
19
|
+
[32mDTS[39m [1mdist/psLayerRef-OY3h7srv.d.ts [22m[32m3.02 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
// src/core/batchPlay.ts
|
|
2
|
+
import { action } from "photoshop";
|
|
3
|
+
async function batchPlay(actions, options) {
|
|
4
|
+
return action.batchPlay(actions, {
|
|
5
|
+
...options,
|
|
6
|
+
modalBehavior: "execute",
|
|
7
|
+
dialogOptions: "silent",
|
|
8
|
+
synchronousExecution: false
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// src/core/executeAsModal.ts
|
|
13
|
+
import { core } from "photoshop";
|
|
14
|
+
|
|
15
|
+
// src/core/command.ts
|
|
16
|
+
import "zod";
|
|
17
|
+
import "photoshop";
|
|
18
|
+
function createCommand(obj) {
|
|
19
|
+
return {
|
|
20
|
+
modifying: obj.modifying,
|
|
21
|
+
descriptor: obj.descriptor,
|
|
22
|
+
schema: obj.schema
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
async function batchPlayCommandBase(command, options) {
|
|
26
|
+
const [result] = await batchPlay([command.descriptor], options);
|
|
27
|
+
if (result?._obj === "error") {
|
|
28
|
+
throw new Error("Batch play command failed", { cause: result });
|
|
29
|
+
}
|
|
30
|
+
return command.schema.parse(result);
|
|
31
|
+
}
|
|
32
|
+
async function batchPlayCommandsBase(commands, options) {
|
|
33
|
+
const results = await batchPlay(commands.map((command) => command.descriptor), options);
|
|
34
|
+
if (results[0]?._obj === "error") {
|
|
35
|
+
throw new Error("Batch play command failed", { cause: results[0] });
|
|
36
|
+
}
|
|
37
|
+
return commands.map((command, index) => command.schema.parse(results[index]));
|
|
38
|
+
}
|
|
39
|
+
function batchPlayCommand(command, options) {
|
|
40
|
+
return batchPlayCommandBase(command, options);
|
|
41
|
+
}
|
|
42
|
+
function batchPlayCommands(commands, options) {
|
|
43
|
+
return batchPlayCommandsBase(commands, options);
|
|
44
|
+
}
|
|
45
|
+
function createModifyingBatchPlayContext() {
|
|
46
|
+
return {
|
|
47
|
+
batchPlayCommand: batchPlayCommandBase,
|
|
48
|
+
batchPlayCommands: batchPlayCommandsBase
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// src/core/executeAsModal.ts
|
|
53
|
+
var originalExecuteAsModal = core.executeAsModal;
|
|
54
|
+
async function executeAsModal2(commandName, fn, opts) {
|
|
55
|
+
let error;
|
|
56
|
+
let result;
|
|
57
|
+
await originalExecuteAsModal(async (executionContext) => {
|
|
58
|
+
const abortController = new AbortController();
|
|
59
|
+
executionContext.onCancel = () => {
|
|
60
|
+
abortController.abort();
|
|
61
|
+
};
|
|
62
|
+
const extendedExecutionContext = {
|
|
63
|
+
isCancelled: executionContext.isCancelled,
|
|
64
|
+
reportProgress: executionContext.reportProgress,
|
|
65
|
+
hostControl: executionContext.hostControl,
|
|
66
|
+
signal: abortController.signal,
|
|
67
|
+
...createModifyingBatchPlayContext()
|
|
68
|
+
};
|
|
69
|
+
try {
|
|
70
|
+
result = await fn(extendedExecutionContext);
|
|
71
|
+
} catch (e) {
|
|
72
|
+
console.error("error in executeAsModal");
|
|
73
|
+
console.error(e);
|
|
74
|
+
error = e;
|
|
75
|
+
}
|
|
76
|
+
}, {
|
|
77
|
+
commandName,
|
|
78
|
+
...opts
|
|
79
|
+
});
|
|
80
|
+
if (error) {
|
|
81
|
+
throw error;
|
|
82
|
+
} else {
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// src/commands-library/multiGetDocument.ts
|
|
88
|
+
import { z as z2 } from "zod";
|
|
89
|
+
function createMultiGetDocumentCommand(docId) {
|
|
90
|
+
return createCommand({
|
|
91
|
+
modifying: false,
|
|
92
|
+
descriptor: {
|
|
93
|
+
_obj: "multiGet",
|
|
94
|
+
_target: { _ref: [{ _ref: "document", _id: docId }] },
|
|
95
|
+
extendedReference: [
|
|
96
|
+
["name", "layerID", "visible", "group", "layerSection", "layerKind", "itemIndex", "background", "mode", "layerEffects"],
|
|
97
|
+
{ _obj: "layer", index: 1, count: -1 }
|
|
98
|
+
]
|
|
99
|
+
},
|
|
100
|
+
schema: z2.object({
|
|
101
|
+
list: z2.array(
|
|
102
|
+
z2.object({
|
|
103
|
+
name: z2.string(),
|
|
104
|
+
layerID: z2.number(),
|
|
105
|
+
visible: z2.boolean(),
|
|
106
|
+
group: z2.boolean(),
|
|
107
|
+
layerSection: z2.object({
|
|
108
|
+
_value: z2.enum([
|
|
109
|
+
"layerSectionStart",
|
|
110
|
+
"layerSectionEnd",
|
|
111
|
+
"layerSectionContent"
|
|
112
|
+
]),
|
|
113
|
+
_enum: z2.literal("layerSectionType")
|
|
114
|
+
}),
|
|
115
|
+
layerKind: z2.number(),
|
|
116
|
+
itemIndex: z2.number(),
|
|
117
|
+
background: z2.boolean(),
|
|
118
|
+
mode: z2.object({
|
|
119
|
+
_enum: z2.literal("blendMode"),
|
|
120
|
+
_value: z2.string()
|
|
121
|
+
}),
|
|
122
|
+
layerEffects: z2.record(z2.string(), z2.object({
|
|
123
|
+
// "scale" does not have an "enabled" property, that's why it's optional
|
|
124
|
+
enabled: z2.boolean().optional()
|
|
125
|
+
}).or(z2.array(z2.object({
|
|
126
|
+
enabled: z2.boolean()
|
|
127
|
+
})))).optional()
|
|
128
|
+
})
|
|
129
|
+
)
|
|
130
|
+
})
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// src/commands-library/getDocument.ts
|
|
135
|
+
import z3 from "zod";
|
|
136
|
+
function createGetDocumentCommand(documentId) {
|
|
137
|
+
return createCommand({
|
|
138
|
+
modifying: false,
|
|
139
|
+
descriptor: {
|
|
140
|
+
_obj: "get",
|
|
141
|
+
_target: { _ref: [{ _ref: "document", _id: documentId }] }
|
|
142
|
+
},
|
|
143
|
+
schema: z3.object({
|
|
144
|
+
title: z3.string(),
|
|
145
|
+
documentID: z3.number(),
|
|
146
|
+
visible: z3.boolean(),
|
|
147
|
+
hasBackgroundLayer: z3.boolean()
|
|
148
|
+
})
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
function createGetDocumentHasBackgroundLayerCommand(documentId) {
|
|
152
|
+
return createCommand({
|
|
153
|
+
modifying: false,
|
|
154
|
+
descriptor: {
|
|
155
|
+
_obj: "get",
|
|
156
|
+
_target: {
|
|
157
|
+
_ref: [
|
|
158
|
+
{ _property: "hasBackgroundLayer" },
|
|
159
|
+
{ _ref: "document", _id: documentId }
|
|
160
|
+
]
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
schema: z3.object({
|
|
164
|
+
hasBackgroundLayer: z3.boolean()
|
|
165
|
+
})
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// src/commands-library/getLayer.ts
|
|
170
|
+
import z4 from "zod";
|
|
171
|
+
var layerSchema = z4.object({
|
|
172
|
+
name: z4.string(),
|
|
173
|
+
visible: z4.boolean(),
|
|
174
|
+
group: z4.boolean(),
|
|
175
|
+
layerSection: z4.object({
|
|
176
|
+
_value: z4.enum([
|
|
177
|
+
"layerSectionStart",
|
|
178
|
+
"layerSectionEnd",
|
|
179
|
+
"layerSectionContent"
|
|
180
|
+
]),
|
|
181
|
+
_enum: z4.literal("layerSectionType")
|
|
182
|
+
}),
|
|
183
|
+
layerKind: z4.number(),
|
|
184
|
+
itemIndex: z4.number(),
|
|
185
|
+
background: z4.boolean(),
|
|
186
|
+
mode: z4.object({
|
|
187
|
+
_enum: z4.literal("blendMode"),
|
|
188
|
+
_value: z4.string()
|
|
189
|
+
}),
|
|
190
|
+
layerID: z4.number(),
|
|
191
|
+
layerEffects: z4.record(z4.string(), z4.object({
|
|
192
|
+
// "scale" does not have an "enabled" property, that's why it's optional
|
|
193
|
+
enabled: z4.boolean().optional()
|
|
194
|
+
}).or(z4.array(z4.object({
|
|
195
|
+
enabled: z4.boolean()
|
|
196
|
+
})))).optional()
|
|
197
|
+
});
|
|
198
|
+
function createGetLayerCommand(layerRef) {
|
|
199
|
+
return createCommand({
|
|
200
|
+
modifying: false,
|
|
201
|
+
descriptor: {
|
|
202
|
+
_obj: "get",
|
|
203
|
+
_target: [
|
|
204
|
+
{ _ref: "layer", _id: layerRef.id },
|
|
205
|
+
{ _ref: "document", _id: layerRef.docId }
|
|
206
|
+
]
|
|
207
|
+
},
|
|
208
|
+
schema: layerSchema
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
function createGetBackgroundLayerCommand(docId) {
|
|
212
|
+
return createCommand({
|
|
213
|
+
modifying: false,
|
|
214
|
+
descriptor: {
|
|
215
|
+
_obj: "get",
|
|
216
|
+
_target: { _ref: [{ _ref: "layer", "_property": "background" }, { _ref: "document", _id: docId }] }
|
|
217
|
+
},
|
|
218
|
+
schema: layerSchema
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export {
|
|
223
|
+
batchPlay,
|
|
224
|
+
executeAsModal2 as executeAsModal,
|
|
225
|
+
createCommand,
|
|
226
|
+
batchPlayCommand,
|
|
227
|
+
batchPlayCommands,
|
|
228
|
+
createModifyingBatchPlayContext,
|
|
229
|
+
createMultiGetDocumentCommand,
|
|
230
|
+
createGetDocumentCommand,
|
|
231
|
+
createGetDocumentHasBackgroundLayerCommand,
|
|
232
|
+
createGetLayerCommand,
|
|
233
|
+
createGetBackgroundLayerCommand
|
|
234
|
+
};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { P as PsLayerRef, a as UTCommandModifying, b as UTCommandNonModifying } from '../psLayerRef-OY3h7srv.js';
|
|
2
|
+
export { i as createMultiGetDocumentCommand } from '../psLayerRef-OY3h7srv.js';
|
|
3
|
+
import 'photoshop/dom/CoreModules';
|
|
4
|
+
import 'zod';
|
|
5
|
+
import 'photoshop';
|
|
6
|
+
|
|
7
|
+
declare function createSelectLayerCommand(layerRef: PsLayerRef): UTCommandModifying<unknown>;
|
|
8
|
+
|
|
9
|
+
declare function createAddLayerToSelectionCommand(layerRef: PsLayerRef, previousLayerRef: PsLayerRef): UTCommandModifying<unknown>;
|
|
10
|
+
|
|
11
|
+
declare function createExpandFolderCommand(layerRef: PsLayerRef): UTCommandModifying<unknown>;
|
|
12
|
+
|
|
13
|
+
declare function createGetLayerCommand(layerRef: PsLayerRef): UTCommandNonModifying<{
|
|
14
|
+
name: string;
|
|
15
|
+
visible: boolean;
|
|
16
|
+
group: boolean;
|
|
17
|
+
layerSection: {
|
|
18
|
+
_value: "layerSectionStart" | "layerSectionEnd" | "layerSectionContent";
|
|
19
|
+
_enum: "layerSectionType";
|
|
20
|
+
};
|
|
21
|
+
layerKind: number;
|
|
22
|
+
itemIndex: number;
|
|
23
|
+
background: boolean;
|
|
24
|
+
mode: {
|
|
25
|
+
_enum: "blendMode";
|
|
26
|
+
_value: string;
|
|
27
|
+
};
|
|
28
|
+
layerID: number;
|
|
29
|
+
layerEffects?: Record<string, {
|
|
30
|
+
enabled?: boolean | undefined;
|
|
31
|
+
} | {
|
|
32
|
+
enabled: boolean;
|
|
33
|
+
}[]> | undefined;
|
|
34
|
+
}>;
|
|
35
|
+
declare function createGetBackgroundLayerCommand(docId: number): UTCommandNonModifying<{
|
|
36
|
+
name: string;
|
|
37
|
+
visible: boolean;
|
|
38
|
+
group: boolean;
|
|
39
|
+
layerSection: {
|
|
40
|
+
_value: "layerSectionStart" | "layerSectionEnd" | "layerSectionContent";
|
|
41
|
+
_enum: "layerSectionType";
|
|
42
|
+
};
|
|
43
|
+
layerKind: number;
|
|
44
|
+
itemIndex: number;
|
|
45
|
+
background: boolean;
|
|
46
|
+
mode: {
|
|
47
|
+
_enum: "blendMode";
|
|
48
|
+
_value: string;
|
|
49
|
+
};
|
|
50
|
+
layerID: number;
|
|
51
|
+
layerEffects?: Record<string, {
|
|
52
|
+
enabled?: boolean | undefined;
|
|
53
|
+
} | {
|
|
54
|
+
enabled: boolean;
|
|
55
|
+
}[]> | undefined;
|
|
56
|
+
}>;
|
|
57
|
+
|
|
58
|
+
declare function createRenameLayerCommand(layerRef: PsLayerRef, newName: string): UTCommandModifying<unknown>;
|
|
59
|
+
|
|
60
|
+
declare function createRasterizeLayerStyleCommand(psLayerRef: PsLayerRef): UTCommandModifying<unknown>;
|
|
61
|
+
|
|
62
|
+
declare function createRasterizeVectorMaskCommand(): UTCommandModifying<unknown>;
|
|
63
|
+
|
|
64
|
+
declare function createSelectLayerMaskCommand(layerId: number): UTCommandModifying<unknown>;
|
|
65
|
+
declare function createDeleteChannelAndApplyCommand(): UTCommandModifying<unknown>;
|
|
66
|
+
|
|
67
|
+
declare function createDeleteChannelCommand(): UTCommandModifying<unknown>;
|
|
68
|
+
|
|
69
|
+
declare function createLoadLayerMaskAsSelectionCommand(layerId: number): UTCommandModifying<unknown>;
|
|
70
|
+
|
|
71
|
+
declare function createHasVectorMaskCommand(layerId: number): UTCommandNonModifying<{
|
|
72
|
+
hasVectorMask: boolean;
|
|
73
|
+
}>;
|
|
74
|
+
|
|
75
|
+
declare function createGetDocumentCommand(documentId: number): UTCommandNonModifying<{
|
|
76
|
+
title: string;
|
|
77
|
+
documentID: number;
|
|
78
|
+
visible: boolean;
|
|
79
|
+
hasBackgroundLayer: boolean;
|
|
80
|
+
}>;
|
|
81
|
+
declare function createGetDocumentHasBackgroundLayerCommand(documentId: number): UTCommandNonModifying<{
|
|
82
|
+
hasBackgroundLayer: boolean;
|
|
83
|
+
}>;
|
|
84
|
+
|
|
85
|
+
declare function createConvertModeCommand(depth: 8 | 16): UTCommandModifying<unknown>;
|
|
86
|
+
|
|
87
|
+
declare function createColorLookupAdjustmentLayerCommand(): UTCommandModifying<unknown>;
|
|
88
|
+
|
|
89
|
+
type LUTFormatType = 'LUTFormatCUBE' | 'LUTFormat3DL' | 'LUTFormatCSP';
|
|
90
|
+
interface Set3DLUTColorLookupOptions {
|
|
91
|
+
lutPath: string;
|
|
92
|
+
lutFormat?: LUTFormatType;
|
|
93
|
+
profileBase64?: string;
|
|
94
|
+
lutFileDataBase64?: string;
|
|
95
|
+
}
|
|
96
|
+
declare function createSet3DLUTColorLookupCommand(options: Set3DLUTColorLookupOptions): UTCommandModifying<unknown>;
|
|
97
|
+
|
|
98
|
+
type LUTExportFormat = 'CUBE' | 'ICC' | '3DL' | 'CSP';
|
|
99
|
+
interface ExportLUTsOptions {
|
|
100
|
+
description?: string;
|
|
101
|
+
gridPoints?: number;
|
|
102
|
+
copyright?: string;
|
|
103
|
+
exportFormats?: LUTExportFormat[];
|
|
104
|
+
lowercaseExtension?: boolean;
|
|
105
|
+
}
|
|
106
|
+
declare function createExportLUTsCommand(path: string, options?: ExportLUTsOptions): UTCommandModifying<unknown>;
|
|
107
|
+
|
|
108
|
+
declare function createRenderGridCommand(gridPoints: number): UTCommandModifying<unknown>;
|
|
109
|
+
|
|
110
|
+
export { type ExportLUTsOptions, type LUTExportFormat, type LUTFormatType, type Set3DLUTColorLookupOptions, createAddLayerToSelectionCommand, createColorLookupAdjustmentLayerCommand, createConvertModeCommand, createDeleteChannelAndApplyCommand, createDeleteChannelCommand, createExpandFolderCommand, createExportLUTsCommand, createGetBackgroundLayerCommand, createGetDocumentCommand, createGetDocumentHasBackgroundLayerCommand, createGetLayerCommand, createHasVectorMaskCommand, createLoadLayerMaskAsSelectionCommand, createRasterizeLayerStyleCommand, createRasterizeVectorMaskCommand, createRenameLayerCommand, createRenderGridCommand, createSelectLayerCommand, createSelectLayerMaskCommand, createSet3DLUTColorLookupCommand };
|