@bubblydoo/uxp-toolkit 0.0.8 → 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.
Files changed (79) hide show
  1. package/.turbo/turbo-build.log +8 -8
  2. package/CHANGELOG.md +12 -0
  3. package/dist/{chunk-3CLJMC63.js → chunk-JBXCIUBZ.js} +49 -90
  4. package/dist/commands-library/index.d.ts +38 -39
  5. package/dist/commands-library/index.js +171 -171
  6. package/dist/index.d.ts +41 -83
  7. package/dist/index.js +203 -152
  8. package/dist/{psLayerRef-OY3h7srv.d.ts → psLayerRef-CGbTO4a5.d.ts} +36 -37
  9. package/package.json +9 -7
  10. package/src/commands-library/addLayerToSelection.ts +4 -4
  11. package/src/commands-library/applyLayerMask.ts +2 -2
  12. package/src/commands-library/convertMode.ts +2 -2
  13. package/src/commands-library/createColorLookupAdjustmentLayer.ts +2 -2
  14. package/src/commands-library/expandFolder.ts +4 -4
  15. package/src/commands-library/exportLUTs.ts +4 -4
  16. package/src/commands-library/getDocument.ts +7 -7
  17. package/src/commands-library/getLayer.ts +13 -13
  18. package/src/commands-library/hasVectorMask.ts +2 -2
  19. package/src/commands-library/index.ts +18 -18
  20. package/src/commands-library/loadLayerMaskAsSelection.ts +2 -2
  21. package/src/commands-library/multiGetDocument.ts +14 -14
  22. package/src/commands-library/rasterizeLayerStyle.ts +3 -3
  23. package/src/commands-library/rasterizeVectorMask.ts +2 -2
  24. package/src/commands-library/removeLayerMask.ts +2 -2
  25. package/src/commands-library/renameLayer.ts +6 -6
  26. package/src/commands-library/renameLayer.uxp-test.ts +13 -13
  27. package/src/commands-library/renderGrid.ts +2 -2
  28. package/src/commands-library/selectLayer.ts +3 -3
  29. package/src/commands-library/set3DLUTColorLookup.ts +2 -2
  30. package/src/core/batchPlay.ts +3 -3
  31. package/src/core/command.test-d.ts +11 -8
  32. package/src/core/command.ts +20 -23
  33. package/src/core/executeAsModal.ts +11 -67
  34. package/src/core/suspendHistory.ts +3 -3
  35. package/src/core/suspendHistory.uxp-test.ts +8 -8
  36. package/src/core-wrappers/executeAsModalAndSuspendHistory.ts +8 -6
  37. package/src/dom/getFlattenedDomLayersList.ts +6 -7
  38. package/src/dom/photoshopDomLayersToTree.ts +5 -5
  39. package/src/error-sourcemaps/sourcemaps.ts +27 -26
  40. package/src/error-sourcemaps/sourcemaps.uxp-test.ts +9 -8
  41. package/src/errors/ut-error.ts +2 -2
  42. package/src/filesystem/isFileOrFolder.ts +9 -0
  43. package/src/filesystem/openFileByPath.ts +10 -6
  44. package/src/general-tree/flattenTree.ts +1 -1
  45. package/src/general-tree/layerRef.ts +2 -2
  46. package/src/general-tree/mapTree.ts +1 -1
  47. package/src/general-tree/mapTreeRef.ts +1 -1
  48. package/src/general-tree/treeTypes.ts +0 -2
  49. package/src/index.ts +42 -43
  50. package/src/metadata-storage/metadataStorage.ts +31 -31
  51. package/src/metadata-storage/metadataStorage.uxp-test.ts +11 -11
  52. package/src/node-compat/path/resolvePath.ts +6 -4
  53. package/src/other/applicationInfo.ts +11 -11
  54. package/src/other/applicationInfo.uxp-test.ts +6 -6
  55. package/src/other/clipboard.ts +2 -2
  56. package/src/other/clipboard.uxp-test.ts +9 -8
  57. package/src/other/uxpEntrypoints.ts +2 -2
  58. package/src/ut-tree/getDocumentLayerDescriptors.ts +6 -6
  59. package/src/ut-tree/getLayerEffects.ts +5 -5
  60. package/src/ut-tree/hasBackgroundLayer.uxp-test.ts +25 -23
  61. package/src/ut-tree/photoshopLayerDescriptorsToUTLayers.test.ts +29 -29
  62. package/src/ut-tree/photoshopLayerDescriptorsToUTLayers.ts +62 -62
  63. package/src/ut-tree/photoshopLayerDescriptorsToUTLayers.uxp-test.ts +29 -29
  64. package/src/ut-tree/psLayerRef.ts +2 -2
  65. package/src/ut-tree/utLayersToText.test.ts +32 -32
  66. package/src/ut-tree/utLayersToText.ts +19 -19
  67. package/src/ut-tree/utLayersToTree.ts +4 -4
  68. package/src/util/utLayerPickKeysType.ts +3 -3
  69. package/src/util/utLayerToLayer.ts +14 -13
  70. package/test/index.ts +11 -11
  71. package/test/meta-tests/builtinModules.uxp-test.ts +28 -26
  72. package/test/meta-tests/executeAsModal.uxp-test.ts +14 -12
  73. package/test/meta-tests/suspendHistory.uxp-test.ts +10 -9
  74. package/tsconfig.json +5 -5
  75. package/tsup.config.ts +5 -5
  76. package/typedoc.json +6 -0
  77. package/uxp-tests.json +1 -1
  78. package/vitest-photoshop-alias-plugin.ts +23 -21
  79. package/vitest.config.ts +6 -6
@@ -1,59 +1,59 @@
1
- import { expect, it } from "vitest";
2
- import { utLayersToText } from "./utLayersToText";
1
+ import { expect, it } from 'vitest';
2
+ import { utLayersToText } from './utLayersToText';
3
3
 
4
- it("converts a single layer to text", () => {
4
+ it('converts a single layer to text', () => {
5
5
  expect(utLayersToText([
6
6
  {
7
- name: "circle",
7
+ name: 'circle',
8
8
  effects: {},
9
- blendMode: "normal",
9
+ blendMode: 'normal',
10
10
  isClippingMask: false,
11
- kind: "pixel",
11
+ kind: 'pixel',
12
12
  visible: true,
13
13
  },
14
- ])).toMatchInlineSnapshot(`"◯ circle"`)
14
+ ])).toMatchInlineSnapshot(`"◯ circle"`);
15
15
  });
16
16
 
17
- it("converts a nested layer to text", () => {
17
+ it('converts a nested layer to text', () => {
18
18
  expect(utLayersToText([
19
19
  {
20
- name: "group",
20
+ name: 'group',
21
21
  effects: {},
22
- blendMode: "passThrough",
22
+ blendMode: 'passThrough',
23
23
  isClippingMask: false,
24
- kind: "group",
24
+ kind: 'group',
25
25
  visible: true,
26
26
  layers: [
27
27
  {
28
- name: "circle",
28
+ name: 'circle',
29
29
  effects: {},
30
- blendMode: "normal",
30
+ blendMode: 'normal',
31
31
  isClippingMask: false,
32
- kind: "pixel",
32
+ kind: 'pixel',
33
33
  visible: true,
34
34
  },
35
35
  {
36
- name: "square",
36
+ name: 'square',
37
37
  effects: {},
38
- blendMode: "normal",
38
+ blendMode: 'normal',
39
39
  isClippingMask: false,
40
- kind: "pixel",
40
+ kind: 'pixel',
41
41
  visible: true,
42
42
  },
43
43
  {
44
- name: "other",
44
+ name: 'other',
45
45
  effects: {},
46
- blendMode: "passThrough",
46
+ blendMode: 'passThrough',
47
47
  isClippingMask: false,
48
- kind: "group",
48
+ kind: 'group',
49
49
  visible: true,
50
50
  layers: [
51
51
  {
52
- name: "nested",
52
+ name: 'nested',
53
53
  effects: {},
54
- blendMode: "normal",
54
+ blendMode: 'normal',
55
55
  isClippingMask: false,
56
- kind: "pixel",
56
+ kind: 'pixel',
57
57
  visible: true,
58
58
  },
59
59
  ],
@@ -66,29 +66,29 @@ it("converts a nested layer to text", () => {
66
66
  ◯ square
67
67
  ◯ ▾ other
68
68
  ◯ nested"
69
- `)
69
+ `);
70
70
  });
71
71
 
72
- it("converts a nested layer with a clipping mask to text", () => {
72
+ it('converts a nested layer with a clipping mask to text', () => {
73
73
  expect(utLayersToText([
74
74
  {
75
- name: "clipper",
75
+ name: 'clipper',
76
76
  effects: {},
77
- blendMode: "normal",
77
+ blendMode: 'normal',
78
78
  isClippingMask: true,
79
- kind: "pixel",
79
+ kind: 'pixel',
80
80
  visible: true,
81
81
  },
82
82
  {
83
- name: "circle",
83
+ name: 'circle',
84
84
  effects: {},
85
- blendMode: "normal",
85
+ blendMode: 'normal',
86
86
  isClippingMask: false,
87
- kind: "pixel",
87
+ kind: 'pixel',
88
88
  visible: true,
89
89
  },
90
90
  ])).toMatchInlineSnapshot(`
91
91
  "◯ ⬐ clipper
92
92
  ◯ circle"
93
- `)
93
+ `);
94
94
  });
@@ -1,32 +1,32 @@
1
- import type { UTLayerPickKeys } from "../util/utLayerPickKeysType";
2
- import type { UTLayer } from "./photoshopLayerDescriptorsToUTLayers";
1
+ import type { UTLayerPickKeys } from '../util/utLayerPickKeysType';
2
+ import type { UTLayer } from './photoshopLayerDescriptorsToUTLayers';
3
3
 
4
- const VISIBLE_ICON = "";
5
- const INVISIBLE_ICON = "";
6
- const CLIPPING_MASK_ICON = "";
7
- const GROUP_ICON = "";
8
- const EFFECTS_ICON = "ƒ";
9
- const BLEND_ICON = ""
4
+ const VISIBLE_ICON = '';
5
+ const INVISIBLE_ICON = '';
6
+ const CLIPPING_MASK_ICON = '';
7
+ const GROUP_ICON = '';
8
+ const EFFECTS_ICON = 'ƒ';
9
+ const BLEND_ICON = '';
10
10
 
11
- type MinimalUTLayer = UTLayerPickKeys<"effects" | "visible" | "isClippingMask" | "kind" | "blendMode" | "name">;
11
+ type MinimalUTLayer = UTLayerPickKeys<'effects' | 'visible' | 'isClippingMask' | 'kind' | 'blendMode' | 'name'>;
12
12
 
13
13
  export function utLayersToText(tree: MinimalUTLayer[], depth = 0): string {
14
14
  return tree.map((layer) => {
15
- const prefix = " ".repeat(depth * 2);
15
+ const prefix = ' '.repeat(depth * 2);
16
16
  const name = layer.name;
17
- const effects = Object.keys(layer.effects).length > 0 ? EFFECTS_ICON : "";
18
- const blend = isSpecialBlendMode(layer) ? BLEND_ICON : "";
19
- const clippingMask = layer.isClippingMask ? CLIPPING_MASK_ICON : "";
20
- const group = layer.kind === "group" ? GROUP_ICON : "";
17
+ const effects = Object.keys(layer.effects).length > 0 ? EFFECTS_ICON : '';
18
+ const blend = isSpecialBlendMode(layer) ? BLEND_ICON : '';
19
+ const clippingMask = layer.isClippingMask ? CLIPPING_MASK_ICON : '';
20
+ const group = layer.kind === 'group' ? GROUP_ICON : '';
21
21
  const visible = layer.visible ? VISIBLE_ICON : INVISIBLE_ICON;
22
- const line = [visible, prefix, clippingMask, group, name, effects, blend].filter(Boolean).join(" ");
22
+ const line = [visible, prefix, clippingMask, group, name, effects, blend].filter(Boolean).join(' ');
23
23
  if (layer.layers) {
24
- return line + "\n" + utLayersToText(layer.layers, depth + 1);
24
+ return `${line}\n${utLayersToText(layer.layers, depth + 1)}`;
25
25
  }
26
26
  return line;
27
- }).join("\n");
27
+ }).join('\n');
28
28
  }
29
29
 
30
- function isSpecialBlendMode(layer: Pick<UTLayer, "kind" | "blendMode">): boolean {
31
- return layer.kind === "group" ? layer.blendMode !== "passThrough" : layer.blendMode !== "normal";
30
+ function isSpecialBlendMode(layer: Pick<UTLayer, 'kind' | 'blendMode'>): boolean {
31
+ return layer.kind === 'group' ? layer.blendMode !== 'passThrough' : layer.blendMode !== 'normal';
32
32
  }
@@ -1,10 +1,10 @@
1
- import type { Tree } from "../general-tree/treeTypes";
2
- import type { UTLayer } from "./photoshopLayerDescriptorsToUTLayers";
1
+ import type { Tree } from '../general-tree/treeTypes';
2
+ import type { UTLayer } from './photoshopLayerDescriptorsToUTLayers';
3
3
 
4
- export type UTLayerWithoutChildren = Omit<UTLayer, "layers">;
4
+ export type UTLayerWithoutChildren = Omit<UTLayer, 'layers'>;
5
5
 
6
6
  export function utLayersToTree(layer: UTLayer[]): Tree<UTLayerWithoutChildren> {
7
- return layer.map((layer) => ({
7
+ return layer.map(layer => ({
8
8
  ref: {
9
9
  name: layer.name,
10
10
  docId: layer.docId,
@@ -1,5 +1,5 @@
1
- import type { UTLayer } from "../ut-tree/photoshopLayerDescriptorsToUTLayers";
1
+ import type { UTLayer } from '../ut-tree/photoshopLayerDescriptorsToUTLayers';
2
2
 
3
- export type UTLayerPickKeys<TKey extends keyof Omit<UTLayer, "layers">> = Pick<Omit<UTLayer, "layers">, TKey> & {
3
+ export type UTLayerPickKeys<TKey extends keyof Omit<UTLayer, 'layers'>> = Pick<Omit<UTLayer, 'layers'>, TKey> & {
4
4
  layers?: UTLayerPickKeys<TKey>[];
5
- }
5
+ };
@@ -1,39 +1,40 @@
1
- import type { Layer as DomLayer } from "photoshop/dom/Layer";
2
- import type { UTLayer } from "../ut-tree/photoshopLayerDescriptorsToUTLayers";
3
- import { app } from "photoshop";
4
- import { getFlattenedDomLayersList } from "../dom/getFlattenedDomLayersList";
1
+ import type { Layer as DomLayer } from 'photoshop';
2
+ import type { UTLayer } from '../ut-tree/photoshopLayerDescriptorsToUTLayers';
3
+ import { app } from 'photoshop';
4
+ import { getFlattenedDomLayersList } from '../dom/getFlattenedDomLayersList';
5
5
 
6
6
  export function utLayerToDomLayer(layer: UTLayer): DomLayer {
7
- const doc = app.documents.find((d) => d.id === layer.docId);
7
+ const doc = app.documents.find(d => d.id === layer.docId);
8
8
  if (!doc) {
9
9
  throw new Error(`Document with id ${layer.docId} not found.`);
10
10
  }
11
11
  const allLayers = getFlattenedDomLayersList(doc.layers);
12
- const domLayer = allLayers.find((l) => l.id === layer.id);
12
+ const domLayer = allLayers.find(l => l.id === layer.id);
13
13
  if (!domLayer) {
14
14
  throw new Error(
15
- `Layer with id ${layer.id} not found in document ${layer.docId}.`
15
+ `Layer with id ${layer.id} not found in document ${layer.docId}.`,
16
16
  );
17
17
  }
18
18
  return domLayer;
19
19
  }
20
20
 
21
21
  export function utLayersToDomLayers(layers: UTLayer[]): DomLayer[] {
22
- if (layers.length === 0) return [];
22
+ if (layers.length === 0)
23
+ return [];
23
24
  const docId = layers[0]!.docId;
24
- if (!layers.every((l) => l.docId === docId)) {
25
- throw new Error("All layers must be from the same document.");
25
+ if (!layers.every(l => l.docId === docId)) {
26
+ throw new Error('All layers must be from the same document.');
26
27
  }
27
- const doc = app.documents.find((d) => d.id === docId);
28
+ const doc = app.documents.find(d => d.id === docId);
28
29
  if (!doc) {
29
30
  throw new Error(`Document with id ${docId} not found.`);
30
31
  }
31
32
  const allLayers = getFlattenedDomLayersList(doc.layers);
32
33
  return layers.map((l) => {
33
- const domLayer = allLayers.find((dl) => dl.id === l.id);
34
+ const domLayer = allLayers.find(dl => dl.id === l.id);
34
35
  if (!domLayer) {
35
36
  throw new Error(
36
- `Layer with id ${l.id} not found in document ${docId}.`
37
+ `Layer with id ${l.id} not found in document ${docId}.`,
37
38
  );
38
39
  }
39
40
  return domLayer;
package/test/index.ts CHANGED
@@ -1,14 +1,14 @@
1
- import { applicationInfoTest } from "../src/other/applicationInfo.uxp-test";
2
- import { renameLayerTest } from "../src/commands-library/renameLayer.uxp-test";
3
- import { suspendHistoryErrorTest } from "./meta-tests/suspendHistory.uxp-test";
4
- import { executeAsModalErrorTest } from "./meta-tests/executeAsModal.uxp-test";
5
- import { suspendHistoryTest } from "../src/core/suspendHistory.uxp-test";
6
- import { sourcemapsTest } from "../src/error-sourcemaps/sourcemaps.uxp-test";
7
- import { clipboardTest } from "../src/other/clipboard.uxp-test";
8
- import { photoshopLayerDescriptorsToUTLayersTest, photoshopLayerDescriptorsToUTLayersTest2 } from "../src/ut-tree/photoshopLayerDescriptorsToUTLayers.uxp-test";
9
- import { metadataStorageTest } from "../src/metadata-storage/metadataStorage.uxp-test";
10
- import { builtinModulesTest } from "./meta-tests/builtinModules.uxp-test";
11
- import { backgroundLayerTest } from "../src/ut-tree/hasBackgroundLayer.uxp-test";
1
+ import { renameLayerTest } from '../src/commands-library/renameLayer.uxp-test';
2
+ import { suspendHistoryTest } from '../src/core/suspendHistory.uxp-test';
3
+ import { sourcemapsTest } from '../src/error-sourcemaps/sourcemaps.uxp-test';
4
+ import { metadataStorageTest } from '../src/metadata-storage/metadataStorage.uxp-test';
5
+ import { applicationInfoTest } from '../src/other/applicationInfo.uxp-test';
6
+ import { clipboardTest } from '../src/other/clipboard.uxp-test';
7
+ import { backgroundLayerTest } from '../src/ut-tree/hasBackgroundLayer.uxp-test';
8
+ import { photoshopLayerDescriptorsToUTLayersTest, photoshopLayerDescriptorsToUTLayersTest2 } from '../src/ut-tree/photoshopLayerDescriptorsToUTLayers.uxp-test';
9
+ import { builtinModulesTest } from './meta-tests/builtinModules.uxp-test';
10
+ import { executeAsModalErrorTest } from './meta-tests/executeAsModal.uxp-test';
11
+ import { suspendHistoryErrorTest } from './meta-tests/suspendHistory.uxp-test';
12
12
 
13
13
  export const tests = [
14
14
  applicationInfoTest,
@@ -1,42 +1,44 @@
1
- import type { Test } from "@bubblydoo/uxp-test-framework";
2
- import { expect } from "chai";
1
+ import type { Test } from '@bubblydoo/uxp-test-framework';
2
+ import { expect } from 'chai';
3
3
 
4
4
  export const builtinModulesTest: Test = {
5
- name: "meta: some builtin modules should be available",
5
+ name: 'meta: some builtin modules should be available',
6
6
  async run() {
7
7
  const testModules = [
8
- "photoshop",
9
- "uxp",
10
- "fs",
11
- "os",
12
- "path",
13
- "process",
14
- "shell",
15
- "http",
16
- "https",
17
- "url",
18
- "util",
19
- "crypto",
20
- "stream",
21
- "zlib",
8
+ 'photoshop',
9
+ 'uxp',
10
+ 'fs',
11
+ 'os',
12
+ 'path',
13
+ 'process',
14
+ 'shell',
15
+ 'http',
16
+ 'https',
17
+ 'url',
18
+ 'util',
19
+ 'crypto',
20
+ 'stream',
21
+ 'zlib',
22
22
  ];
23
23
  const successModules = testModules.filter(module => doesImportExist(module));
24
24
  expect(successModules).to.deep.eq([
25
- "photoshop",
26
- "uxp",
27
- "fs",
28
- "os",
29
- "path",
30
- "process",
31
- ]);
25
+ 'photoshop',
26
+ 'uxp',
27
+ 'fs',
28
+ 'os',
29
+ 'path',
30
+ 'process',
31
+ ]);
32
32
  },
33
33
  };
34
34
 
35
35
  function doesImportExist(module: string) {
36
36
  try {
37
+ // eslint-disable-next-line ts/no-require-imports
37
38
  require(module);
38
39
  return true;
39
- } catch {
40
+ }
41
+ catch {
40
42
  return false;
41
43
  }
42
- }
44
+ }
@@ -1,37 +1,39 @@
1
- import { core } from "photoshop";
2
- import type { Test } from "@bubblydoo/uxp-test-framework";
3
- import { expect } from "chai";
1
+ import type { Test } from '@bubblydoo/uxp-test-framework';
2
+ import { expect } from 'chai';
3
+ import { core } from 'photoshop';
4
4
 
5
5
  export const executeAsModalErrorTest: Test = {
6
- name: "meta: executeAsModal should throw correctly",
6
+ name: 'meta: executeAsModal should throw correctly',
7
7
  async run() {
8
8
  let threw = false;
9
9
  try {
10
10
  await core.executeAsModal(
11
11
  async () => {
12
- throw new Error("Uncaught error");
12
+ throw new Error('Uncaught error');
13
13
  },
14
14
  {
15
- commandName: "Test",
16
- }
15
+ commandName: 'Test',
16
+ },
17
17
  );
18
- } catch (e) {
18
+ }
19
+ catch (_e) {
19
20
  threw = true;
20
21
  }
22
+ // eslint-disable-next-line ts/no-unused-expressions
21
23
  expect(threw).to.be.true;
22
24
  },
23
25
  };
24
26
 
25
27
  export const executeAsModalReturnTest: Test = {
26
- name: "meta: executeAsModal should return correctly",
28
+ name: 'meta: executeAsModal should return correctly',
27
29
  async run() {
28
30
  const result = await core.executeAsModal(
29
31
  async () => {
30
- return 'test'
32
+ return 'test';
31
33
  },
32
34
  {
33
- commandName: "Test",
34
- }
35
+ commandName: 'Test',
36
+ },
35
37
  );
36
38
  expect(result).to.equal('test');
37
39
  },
@@ -1,27 +1,28 @@
1
- import { app } from "photoshop";
2
- import type { Test } from "@bubblydoo/uxp-test-framework";
3
- import { expect } from "chai";
1
+ import type { Test } from '@bubblydoo/uxp-test-framework';
2
+ import { expect } from 'chai';
3
+ import { app } from 'photoshop';
4
4
 
5
5
  export const suspendHistoryErrorTest: Test = {
6
- name: "meta: suspendHistory should throw correctly",
6
+ name: 'meta: suspendHistory should throw correctly',
7
7
  async run() {
8
8
  const document = app.activeDocument;
9
9
  if (!document) {
10
- throw new Error("No active document");
10
+ throw new Error('No active document');
11
11
  }
12
12
 
13
13
  let threw = false;
14
14
  try {
15
15
  await document.suspendHistory(
16
16
  async (context) => {
17
- throw new Error("Uncaught error");
17
+ throw new Error('Uncaught error');
18
18
  },
19
- "Test"
19
+ 'Test',
20
20
  );
21
- } catch (e) {
21
+ }
22
+ catch (_e) {
22
23
  threw = true;
23
24
  }
25
+ // eslint-disable-next-line ts/no-unused-expressions
24
26
  expect(threw).to.be.true;
25
27
  },
26
28
  };
27
-
package/tsconfig.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "extends": "@bubblydoo/tsconfig/tsconfig.base.json",
3
3
  "compilerOptions": {
4
- "allowJs": true,
5
4
  "moduleDetection": "force",
6
- "verbatimModuleSyntax": true,
7
- "noUncheckedIndexedAccess": true,
8
- "noImplicitOverride": true,
9
5
  "rootDir": ".",
10
- "typeRoots": ["./node_modules/@adobe-uxp-types", "./node_modules/@types"]
6
+ "typeRoots": ["./node_modules/@adobe-uxp-types", "./node_modules/@types"],
7
+ "allowJs": true,
8
+ "noImplicitOverride": true,
9
+ "noUncheckedIndexedAccess": true,
10
+ "verbatimModuleSyntax": true
11
11
  },
12
12
  "include": ["src", "test"]
13
13
  }
package/tsup.config.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { defineConfig } from "tsup";
1
+ import { defineConfig } from 'tsup';
2
2
 
3
3
  export default defineConfig({
4
- entry: ["src/index.ts", "src/commands-library/index.ts"],
5
- format: "esm",
4
+ entry: ['src/index.ts', 'src/commands-library/index.ts'],
5
+ format: 'esm',
6
6
  dts: true,
7
- external: ["photoshop", "uxp"],
8
- outDir: "dist",
7
+ external: ['photoshop', 'uxp'],
8
+ outDir: 'dist',
9
9
  });
package/typedoc.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "$schema": "https://typedoc.org/schema.json",
3
+ "extends": ["../../typedoc.base.jsonc"],
4
+ "entryPoints": ["./src/index.ts"],
5
+ "tsconfig": "./tsconfig.json"
6
+ }
package/uxp-tests.json CHANGED
@@ -11,4 +11,4 @@
11
11
  "hotReloadPort": 8081,
12
12
  "enableTsconfigPathsPlugin": true
13
13
  }
14
- }
14
+ }
@@ -1,12 +1,12 @@
1
- import { Plugin } from "vitest/config";
2
- import dedent from "dedent";
1
+ import type { Plugin } from 'vitest/config';
2
+ import dedent from 'dedent';
3
3
 
4
4
  const nativeModules = [
5
- "photoshop",
6
- "uxp",
5
+ 'photoshop',
6
+ 'uxp',
7
7
  ];
8
8
 
9
- const pluginPrefix = "photoshop-builtin"
9
+ const pluginPrefix = 'photoshop-builtin';
10
10
 
11
11
  const minimalModules = {
12
12
  photoshop: dedent`
@@ -18,24 +18,26 @@ export const app = UNIMPLEMENTED;
18
18
  export const entrypoints = UNIMPLEMENTED;
19
19
  export const storage = UNIMPLEMENTED;
20
20
  `,
21
- }
21
+ };
22
22
 
23
- export const vitestPhotoshopAliasPlugin = (): Plugin => ({
24
- name: "vitest-photoshop-alias",
25
- resolveId(id) {
26
- if (nativeModules.includes(id)) {
27
- return `${id}?${pluginPrefix}`
28
- }
29
- },
30
- load(id) {
31
- if (id.endsWith(`?${pluginPrefix}`)) {
32
- const origModuleId = id.replace(`?${pluginPrefix}`, "");
33
- const mod = dedent`
23
+ export function vitestPhotoshopAliasPlugin(): Plugin {
24
+ return {
25
+ name: 'vitest-photoshop-alias',
26
+ resolveId(id) {
27
+ if (nativeModules.includes(id)) {
28
+ return `${id}?${pluginPrefix}`;
29
+ }
30
+ },
31
+ load(id) {
32
+ if (id.endsWith(`?${pluginPrefix}`)) {
33
+ const origModuleId = id.replace(`?${pluginPrefix}`, '');
34
+ const mod = dedent`
34
35
  // This is a photoshop builtin module, not available in Vitest. This is an alias to provide minimal compatibility.
35
36
  const UNIMPLEMENTED = { __vitest_photoshop_alias_unimplemented__: true };
36
37
  ${minimalModules[origModuleId]}
37
38
  `;
38
- return mod;
39
- }
40
- }
41
- });
39
+ return mod;
40
+ }
41
+ },
42
+ };
43
+ }
package/vitest.config.ts CHANGED
@@ -1,16 +1,16 @@
1
- import { defineConfig } from "vitest/config";
2
- import { vitestPhotoshopAliasPlugin } from "./vitest-photoshop-alias-plugin";
1
+ import { defineConfig } from 'vitest/config';
2
+ import { vitestPhotoshopAliasPlugin } from './vitest-photoshop-alias-plugin';
3
3
 
4
4
  export default defineConfig({
5
5
  test: {
6
- include: ["src/**/*.test.ts"],
7
- reporters: process.env.CI ? ["default", "junit"] : ["default"],
6
+ include: ['src/**/*.test.ts'],
7
+ reporters: process.env.CI ? ['default', 'junit'] : ['default'],
8
8
  outputFile: {
9
- junit: "./test-results/junit.xml",
9
+ junit: './test-results/junit.xml',
10
10
  },
11
11
  typecheck: {
12
12
  enabled: true,
13
- include: ["src/**/*.test-d.ts"],
13
+ include: ['src/**/*.test-d.ts'],
14
14
  },
15
15
  },
16
16
  plugins: [vitestPhotoshopAliasPlugin()],