@bubblydoo/uxp-toolkit 0.0.9 → 0.0.10
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 +5 -5
- package/CHANGELOG.md +6 -0
- package/dist/index.d.ts +8 -48
- package/dist/index.js +16 -4
- package/package.json +6 -5
- package/src/core/executeAsModal.ts +4 -62
- package/src/error-sourcemaps/sourcemaps.ts +6 -7
- package/src/filesystem/isFileOrFolder.ts +9 -0
- package/src/filesystem/openFileByPath.ts +7 -3
- package/src/index.ts +1 -2
- package/typedoc.json +6 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @bubblydoo/uxp-toolkit@0.0.
|
|
2
|
+
> @bubblydoo/uxp-toolkit@0.0.10 build /home/runner/work/uxp-toolkit/uxp-toolkit/packages/uxp-toolkit
|
|
3
3
|
> tsup
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts, src/commands-library/index.ts
|
|
@@ -8,12 +8,12 @@
|
|
|
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/index.js [22m[32m15.
|
|
11
|
+
[32mESM[39m [1mdist/index.js [22m[32m15.95 KB[39m
|
|
12
12
|
[32mESM[39m [1mdist/chunk-JBXCIUBZ.js [22m[32m5.14 KB[39m
|
|
13
13
|
[32mESM[39m [1mdist/commands-library/index.js [22m[32m8.76 KB[39m
|
|
14
|
-
[32mESM[39m ⚡️ Build success in
|
|
14
|
+
[32mESM[39m ⚡️ Build success in 34ms
|
|
15
15
|
[34mDTS[39m Build start
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
17
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 3797ms
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m6.57 KB[39m
|
|
18
18
|
[32mDTS[39m [1mdist/commands-library/index.d.ts [22m[32m4.43 KB[39m
|
|
19
19
|
[32mDTS[39m [1mdist/psLayerRef-CGbTO4a5.d.ts [22m[32m2.86 KB[39m
|
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,58 +1,15 @@
|
|
|
1
1
|
import { c as createModifyingBatchPlayContext, P as PsLayerRef } from './psLayerRef-CGbTO4a5.js';
|
|
2
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-CGbTO4a5.js';
|
|
3
3
|
import * as photoshop from 'photoshop';
|
|
4
|
-
import { Document, Layer } from 'photoshop';
|
|
4
|
+
import { ExecutionContext, ExecuteAsModalOptions, Document, Layer } from 'photoshop';
|
|
5
5
|
import ErrorStackParser from 'error-stack-parser';
|
|
6
|
+
import { Entry, File, Folder } from 'uxp';
|
|
6
7
|
import { z } from 'zod';
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* True if user has cancelled the modal interaction.
|
|
11
|
-
*
|
|
12
|
-
* User can cancel by hitting the Escape key, or by pressing the "Cancel" button in the progress bar.
|
|
13
|
-
*/
|
|
14
|
-
isCancelled: boolean;
|
|
15
|
-
/**
|
|
16
|
-
* If assigned a method, it will be called when user cancels the modal interaction.
|
|
17
|
-
*/
|
|
18
|
-
onCancel: () => void;
|
|
19
|
-
/**
|
|
20
|
-
* Call this to customize the progress bar.
|
|
21
|
-
*/
|
|
22
|
-
reportProgress: (info: {
|
|
23
|
-
value: number;
|
|
24
|
-
commandName?: string;
|
|
25
|
-
}) => void;
|
|
26
|
-
/**
|
|
27
|
-
* Use the methods in here to control Photoshop state
|
|
28
|
-
*/
|
|
29
|
-
hostControl: {
|
|
30
|
-
/**
|
|
31
|
-
* Call to suspend history on a target document, returns the suspension ID which can be used for resumeHistory
|
|
32
|
-
*/
|
|
33
|
-
suspendHistory: (info: {
|
|
34
|
-
documentID: number;
|
|
35
|
-
name: string;
|
|
36
|
-
}) => Promise<number>;
|
|
37
|
-
/**
|
|
38
|
-
* Call to resume history on a target document
|
|
39
|
-
*/
|
|
40
|
-
resumeHistory: (suspensionID: number, commit: boolean) => Promise<void>;
|
|
41
|
-
/** Register a document to be closed when the modal scope exits. See below for details. */
|
|
42
|
-
registerAutoCloseDocument: (documentID: number) => Promise<void>;
|
|
43
|
-
/** Unregister a document from being closed when the modal scope exits */
|
|
44
|
-
unregisterAutoCloseDocument: (documentID: number) => Promise<void>;
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
interface CorrectExecuteAsModalOptions {
|
|
48
|
-
commandName: string;
|
|
49
|
-
interactive?: boolean;
|
|
50
|
-
timeOut?: number;
|
|
51
|
-
}
|
|
52
|
-
type ExtendedExecutionContext = Omit<CorrectExecutionContext, 'onCancel'> & ReturnType<typeof createModifyingBatchPlayContext> & {
|
|
9
|
+
type ExtendedExecutionContext = Omit<ExecutionContext, 'onCancel'> & ReturnType<typeof createModifyingBatchPlayContext> & {
|
|
53
10
|
signal: AbortSignal;
|
|
54
11
|
};
|
|
55
|
-
type OptionsWithoutCommandName = Omit<
|
|
12
|
+
type OptionsWithoutCommandName = Omit<ExecuteAsModalOptions, 'commandName'>;
|
|
56
13
|
declare function executeAsModal<T>(commandName: string, fn: (executionContext: ExtendedExecutionContext) => Promise<T>, opts?: OptionsWithoutCommandName): Promise<T>;
|
|
57
14
|
|
|
58
15
|
interface SuspendHistoryContext {
|
|
@@ -78,6 +35,9 @@ declare function parseUxpErrorSourcemaps(error: Error, opts?: {
|
|
|
78
35
|
}): Promise<BasicStackFrame[]>;
|
|
79
36
|
declare function getBasicStackFrameAbsoluteFilePath(frame: BasicStackFrame): Promise<string>;
|
|
80
37
|
|
|
38
|
+
declare function isFile(entry: Entry): entry is File;
|
|
39
|
+
declare function isFolder(entry: Entry): entry is Folder;
|
|
40
|
+
|
|
81
41
|
declare function openFileByPath(path: string): Promise<photoshop.Document>;
|
|
82
42
|
|
|
83
43
|
declare function flattenTree<T>(tree: Tree<T>): Tree<T>[0][];
|
|
@@ -190,4 +150,4 @@ declare function utLayersToTree(layer: UTLayer[]): Tree<UTLayerWithoutChildren>;
|
|
|
190
150
|
declare function utLayerToDomLayer(layer: UTLayer): Layer;
|
|
191
151
|
declare function utLayersToDomLayers(layers: UTLayer[]): Layer[];
|
|
192
152
|
|
|
193
|
-
export { type BasicStackFrame, type
|
|
153
|
+
export { type BasicStackFrame, 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, isFile, isFolder, mapTree, mapTreeRef, openFileByPath, parseUxpErrorSourcemaps, photoshopDomLayersToTree, photoshopGetApplicationInfo, photoshopLayerDescriptorsToUTLayers, readFromClipboard, suspendHistory, utLayerToDomLayer, utLayersToDomLayers, utLayersToTree, utLayersToText as utTreeToText, uxpEntrypointsSchema };
|
package/dist/index.js
CHANGED
|
@@ -12,11 +12,10 @@ import {
|
|
|
12
12
|
|
|
13
13
|
// src/core/executeAsModal.ts
|
|
14
14
|
import { core } from "photoshop";
|
|
15
|
-
var originalExecuteAsModal = core.executeAsModal;
|
|
16
15
|
async function executeAsModal(commandName, fn, opts) {
|
|
17
16
|
let error;
|
|
18
17
|
let result;
|
|
19
|
-
await
|
|
18
|
+
await core.executeAsModal(async (executionContext) => {
|
|
20
19
|
const abortController = new AbortController();
|
|
21
20
|
executionContext.onCancel = () => {
|
|
22
21
|
abortController.abort();
|
|
@@ -206,13 +205,24 @@ var UTStacktraceParsingError = class extends UTError {
|
|
|
206
205
|
}
|
|
207
206
|
};
|
|
208
207
|
|
|
208
|
+
// src/filesystem/isFileOrFolder.ts
|
|
209
|
+
function isFile(entry) {
|
|
210
|
+
return entry.isFile === true;
|
|
211
|
+
}
|
|
212
|
+
function isFolder(entry) {
|
|
213
|
+
return entry.isFolder === true;
|
|
214
|
+
}
|
|
215
|
+
|
|
209
216
|
// src/filesystem/openFileByPath.ts
|
|
210
217
|
import { app } from "photoshop";
|
|
211
218
|
import { storage as storage2 } from "uxp";
|
|
212
219
|
async function openFileByPath(path) {
|
|
213
220
|
const fs = storage2.localFileSystem;
|
|
214
|
-
const
|
|
215
|
-
|
|
221
|
+
const entry = await fs.getEntryWithUrl(path);
|
|
222
|
+
if (!isFile(entry)) {
|
|
223
|
+
throw new Error("Entry is not a file");
|
|
224
|
+
}
|
|
225
|
+
const doc = await executeAsModal("Open file", () => app.open(entry));
|
|
216
226
|
return doc;
|
|
217
227
|
}
|
|
218
228
|
|
|
@@ -560,6 +570,8 @@ export {
|
|
|
560
570
|
getDocumentLayerDescriptors,
|
|
561
571
|
getFlattenedDomLayersList,
|
|
562
572
|
getLayerEffects,
|
|
573
|
+
isFile,
|
|
574
|
+
isFolder,
|
|
563
575
|
mapTree,
|
|
564
576
|
mapTreeRef,
|
|
565
577
|
openFileByPath,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bubblydoo/uxp-toolkit",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.10",
|
|
5
5
|
"author": "Hans Otto Wirtz <hansottowirtz@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/bubblydoo/uxp-toolkit/tree/main/packages/uxp-toolkit",
|
|
@@ -41,16 +41,17 @@
|
|
|
41
41
|
"typescript": "^5.8.3",
|
|
42
42
|
"vitest": "^4.0.18",
|
|
43
43
|
"zod": "^4.3.6",
|
|
44
|
-
"@adobe-uxp-types/photoshop": "0.1.
|
|
45
|
-
"@adobe-uxp-types/uxp": "0.1.
|
|
44
|
+
"@adobe-uxp-types/photoshop": "0.1.1",
|
|
45
|
+
"@adobe-uxp-types/uxp": "0.1.1",
|
|
46
46
|
"@bubblydoo/tsconfig": "0.0.3",
|
|
47
|
-
"@bubblydoo/uxp-test-framework": "0.0.
|
|
47
|
+
"@bubblydoo/uxp-test-framework": "0.0.10"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "tsup",
|
|
51
51
|
"test": "vitest run",
|
|
52
52
|
"uxp-test:build": "uxp-test build",
|
|
53
53
|
"uxp-test:dev": "uxp-test dev",
|
|
54
|
-
"typecheck": "tsc --noEmit"
|
|
54
|
+
"typecheck": "tsc --noEmit",
|
|
55
|
+
"docs-json": "typedoc --json docs.json"
|
|
55
56
|
}
|
|
56
57
|
}
|
|
@@ -1,75 +1,17 @@
|
|
|
1
|
+
import type { ExecuteAsModalOptions, ExecutionContext } from 'photoshop';
|
|
1
2
|
import { core } from 'photoshop';
|
|
2
3
|
import { createModifyingBatchPlayContext } from './command';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
// hostControl: {suspendHistory: ƒ, resumeHistory: ƒ, registerAutoCloseDocument: ƒ, unregisterAutoCloseDocument: ƒ}
|
|
6
|
-
// mode: "action"
|
|
7
|
-
// uiMode: "never"
|
|
8
|
-
// finalizeArguments: ƒ ()
|
|
9
|
-
// isCancelled: undefined
|
|
10
|
-
// onCancel: undefined
|
|
11
|
-
// reject: ƒ ()
|
|
12
|
-
// reportProgress: ƒ ()
|
|
13
|
-
// resolve: ƒ ()
|
|
14
|
-
|
|
15
|
-
export interface CorrectExecutionContext {
|
|
16
|
-
/**
|
|
17
|
-
* True if user has cancelled the modal interaction.
|
|
18
|
-
*
|
|
19
|
-
* User can cancel by hitting the Escape key, or by pressing the "Cancel" button in the progress bar.
|
|
20
|
-
*/
|
|
21
|
-
isCancelled: boolean;
|
|
22
|
-
/**
|
|
23
|
-
* If assigned a method, it will be called when user cancels the modal interaction.
|
|
24
|
-
*/
|
|
25
|
-
onCancel: () => void;
|
|
26
|
-
/**
|
|
27
|
-
* Call this to customize the progress bar.
|
|
28
|
-
*/
|
|
29
|
-
reportProgress: (info: {
|
|
30
|
-
value: number;
|
|
31
|
-
commandName?: string;
|
|
32
|
-
}) => void;
|
|
33
|
-
/**
|
|
34
|
-
* Use the methods in here to control Photoshop state
|
|
35
|
-
*/
|
|
36
|
-
hostControl: {
|
|
37
|
-
/**
|
|
38
|
-
* Call to suspend history on a target document, returns the suspension ID which can be used for resumeHistory
|
|
39
|
-
*/
|
|
40
|
-
suspendHistory: (info: {
|
|
41
|
-
documentID: number;
|
|
42
|
-
name: string;
|
|
43
|
-
}) => Promise<number>;
|
|
44
|
-
/**
|
|
45
|
-
* Call to resume history on a target document
|
|
46
|
-
*/
|
|
47
|
-
resumeHistory: (suspensionID: number, commit: boolean) => Promise<void>;
|
|
48
|
-
/** Register a document to be closed when the modal scope exits. See below for details. */
|
|
49
|
-
registerAutoCloseDocument: (documentID: number) => Promise<void>;
|
|
50
|
-
/** Unregister a document from being closed when the modal scope exits */
|
|
51
|
-
unregisterAutoCloseDocument: (documentID: number) => Promise<void>;
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export interface CorrectExecuteAsModalOptions {
|
|
56
|
-
commandName: string;
|
|
57
|
-
interactive?: boolean;
|
|
58
|
-
timeOut?: number;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export type ExtendedExecutionContext = Omit<CorrectExecutionContext, 'onCancel'> & ReturnType<typeof createModifyingBatchPlayContext> & {
|
|
5
|
+
export type ExtendedExecutionContext = Omit<ExecutionContext, 'onCancel'> & ReturnType<typeof createModifyingBatchPlayContext> & {
|
|
62
6
|
signal: AbortSignal;
|
|
63
7
|
};
|
|
64
8
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
type OptionsWithoutCommandName = Omit<CorrectExecuteAsModalOptions, 'commandName'>;
|
|
9
|
+
type OptionsWithoutCommandName = Omit<ExecuteAsModalOptions, 'commandName'>;
|
|
68
10
|
|
|
69
11
|
export async function executeAsModal<T>(commandName: string, fn: (executionContext: ExtendedExecutionContext) => Promise<T>, opts?: OptionsWithoutCommandName): Promise<T> {
|
|
70
12
|
let error: unknown;
|
|
71
13
|
let result: T;
|
|
72
|
-
await
|
|
14
|
+
await core.executeAsModal(async (executionContext) => {
|
|
73
15
|
const abortController = new AbortController();
|
|
74
16
|
executionContext.onCancel = () => {
|
|
75
17
|
abortController.abort();
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { File } from 'uxp';
|
|
1
2
|
import ErrorStackParser from 'error-stack-parser';
|
|
2
3
|
import { SourceMapConsumer } from 'source-map-js';
|
|
3
4
|
import { storage } from 'uxp';
|
|
@@ -14,9 +15,9 @@ export async function parseUxpErrorSourcemaps(error: Error, opts: { unsourcemapp
|
|
|
14
15
|
|
|
15
16
|
const unsourcemappedHeaderLines = opts.unsourcemappedHeaderLines ?? 0;
|
|
16
17
|
|
|
17
|
-
const loadedFilesCache: Record<string,
|
|
18
|
+
const loadedFilesCache: Record<string, File> = {};
|
|
18
19
|
|
|
19
|
-
const fs =
|
|
20
|
+
const fs = storage.localFileSystem;
|
|
20
21
|
const parsedMappedError: BasicStackFrame[] = [];
|
|
21
22
|
for (const frame of parsedError) {
|
|
22
23
|
if (!frame.fileName || !frame.lineNumber || !frame.columnNumber) {
|
|
@@ -26,7 +27,7 @@ export async function parseUxpErrorSourcemaps(error: Error, opts: { unsourcemapp
|
|
|
26
27
|
const entryPath = `plugin:${frame.fileName}`;
|
|
27
28
|
const file
|
|
28
29
|
= loadedFilesCache[entryPath]
|
|
29
|
-
?? ((await fs.getEntryWithUrl(entryPath)) as
|
|
30
|
+
?? ((await fs.getEntryWithUrl(entryPath)) as File);
|
|
30
31
|
loadedFilesCache[entryPath] = file;
|
|
31
32
|
if (!file.isFile) {
|
|
32
33
|
parsedMappedError.push(frame);
|
|
@@ -35,7 +36,7 @@ export async function parseUxpErrorSourcemaps(error: Error, opts: { unsourcemapp
|
|
|
35
36
|
const sourcemapFileEntryPath = `${entryPath}.map`;
|
|
36
37
|
const sourcemapFile
|
|
37
38
|
= loadedFilesCache[sourcemapFileEntryPath]
|
|
38
|
-
?? ((await fs.getEntryWithUrl(sourcemapFileEntryPath)) as
|
|
39
|
+
?? ((await fs.getEntryWithUrl(sourcemapFileEntryPath)) as File);
|
|
39
40
|
loadedFilesCache[sourcemapFileEntryPath] = sourcemapFile;
|
|
40
41
|
if (!sourcemapFile.isFile) {
|
|
41
42
|
parsedMappedError.push(frame);
|
|
@@ -82,9 +83,7 @@ function parseErrorIntoBasicStackFrames(error: Error): BasicStackFrame[] {
|
|
|
82
83
|
}
|
|
83
84
|
|
|
84
85
|
export async function getBasicStackFrameAbsoluteFilePath(frame: BasicStackFrame): Promise<string> {
|
|
85
|
-
const pluginFolder = await (
|
|
86
|
-
storage as any
|
|
87
|
-
).localFileSystem.getPluginFolder();
|
|
86
|
+
const pluginFolder = await storage.localFileSystem.getPluginFolder();
|
|
88
87
|
const absoluteFileName = pathResolve(
|
|
89
88
|
pluginFolder.nativePath,
|
|
90
89
|
'index.js',
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { app } from 'photoshop';
|
|
2
2
|
import { storage } from 'uxp';
|
|
3
3
|
import { executeAsModal } from '../core/executeAsModal';
|
|
4
|
+
import { isFile } from './isFileOrFolder';
|
|
4
5
|
|
|
5
6
|
export async function openFileByPath(path: string) {
|
|
6
|
-
const fs =
|
|
7
|
-
const
|
|
8
|
-
|
|
7
|
+
const fs = storage.localFileSystem;
|
|
8
|
+
const entry = await fs.getEntryWithUrl(path);
|
|
9
|
+
if (!isFile(entry)) {
|
|
10
|
+
throw new Error('Entry is not a file');
|
|
11
|
+
}
|
|
12
|
+
const doc = await executeAsModal('Open file', () => app.open(entry));
|
|
9
13
|
return doc;
|
|
10
14
|
}
|
package/src/index.ts
CHANGED
|
@@ -18,8 +18,6 @@ export {
|
|
|
18
18
|
|
|
19
19
|
// Core – execution context
|
|
20
20
|
export {
|
|
21
|
-
type CorrectExecuteAsModalOptions,
|
|
22
|
-
type CorrectExecutionContext,
|
|
23
21
|
executeAsModal,
|
|
24
22
|
type ExtendedExecutionContext,
|
|
25
23
|
} from './core/executeAsModal';
|
|
@@ -40,6 +38,7 @@ export {
|
|
|
40
38
|
parseUxpErrorSourcemaps,
|
|
41
39
|
} from './error-sourcemaps/sourcemaps';
|
|
42
40
|
// Filesystem
|
|
41
|
+
export { isFile, isFolder } from './filesystem/isFileOrFolder';
|
|
43
42
|
export { openFileByPath } from './filesystem/openFileByPath';
|
|
44
43
|
// General tree
|
|
45
44
|
export { flattenTree } from './general-tree/flattenTree';
|