@bubblydoo/uxp-toolkit 0.0.8 → 0.0.9

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 (77) hide show
  1. package/.turbo/turbo-build.log +8 -8
  2. package/CHANGELOG.md +6 -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 +39 -41
  7. package/dist/index.js +189 -150
  8. package/dist/{psLayerRef-OY3h7srv.d.ts → psLayerRef-CGbTO4a5.d.ts} +36 -37
  9. package/package.json +8 -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 +13 -11
  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 +23 -21
  40. package/src/error-sourcemaps/sourcemaps.uxp-test.ts +9 -8
  41. package/src/errors/ut-error.ts +2 -2
  42. package/src/filesystem/openFileByPath.ts +4 -4
  43. package/src/general-tree/flattenTree.ts +1 -1
  44. package/src/general-tree/layerRef.ts +2 -2
  45. package/src/general-tree/mapTree.ts +1 -1
  46. package/src/general-tree/mapTreeRef.ts +1 -1
  47. package/src/general-tree/treeTypes.ts +0 -2
  48. package/src/index.ts +43 -43
  49. package/src/metadata-storage/metadataStorage.ts +31 -31
  50. package/src/metadata-storage/metadataStorage.uxp-test.ts +11 -11
  51. package/src/node-compat/path/resolvePath.ts +6 -4
  52. package/src/other/applicationInfo.ts +11 -11
  53. package/src/other/applicationInfo.uxp-test.ts +6 -6
  54. package/src/other/clipboard.ts +2 -2
  55. package/src/other/clipboard.uxp-test.ts +9 -8
  56. package/src/other/uxpEntrypoints.ts +2 -2
  57. package/src/ut-tree/getDocumentLayerDescriptors.ts +6 -6
  58. package/src/ut-tree/getLayerEffects.ts +5 -5
  59. package/src/ut-tree/hasBackgroundLayer.uxp-test.ts +25 -23
  60. package/src/ut-tree/photoshopLayerDescriptorsToUTLayers.test.ts +29 -29
  61. package/src/ut-tree/photoshopLayerDescriptorsToUTLayers.ts +62 -62
  62. package/src/ut-tree/photoshopLayerDescriptorsToUTLayers.uxp-test.ts +29 -29
  63. package/src/ut-tree/psLayerRef.ts +2 -2
  64. package/src/ut-tree/utLayersToText.test.ts +32 -32
  65. package/src/ut-tree/utLayersToText.ts +19 -19
  66. package/src/ut-tree/utLayersToTree.ts +4 -4
  67. package/src/util/utLayerPickKeysType.ts +3 -3
  68. package/src/util/utLayerToLayer.ts +14 -13
  69. package/test/index.ts +11 -11
  70. package/test/meta-tests/builtinModules.uxp-test.ts +28 -26
  71. package/test/meta-tests/executeAsModal.uxp-test.ts +14 -12
  72. package/test/meta-tests/suspendHistory.uxp-test.ts +10 -9
  73. package/tsconfig.json +5 -5
  74. package/tsup.config.ts +5 -5
  75. package/uxp-tests.json +1 -1
  76. package/vitest-photoshop-alias-plugin.ts +23 -21
  77. package/vitest.config.ts +6 -6
@@ -1,4 +1,4 @@
1
- import { z } from "zod";
1
+ import { z } from 'zod';
2
2
 
3
3
  export const uxpEntrypointsSchema = z.object({
4
4
  _pluginInfo: z.object({
@@ -6,4 +6,4 @@ export const uxpEntrypointsSchema = z.object({
6
6
  name: z.string(),
7
7
  version: z.string(),
8
8
  }),
9
- });
9
+ });
@@ -1,10 +1,10 @@
1
- import { batchPlayCommand, batchPlayCommands } from "../core/command";
2
- import { createMultiGetDocumentCommand } from "../commands-library/multiGetDocument";
3
- import { createGetDocumentHasBackgroundLayerCommand } from "../commands-library/getDocument";
4
- import { createGetBackgroundLayerCommand } from "../commands-library/getLayer";
1
+ import { createGetDocumentHasBackgroundLayerCommand } from '../commands-library/getDocument';
2
+ import { createGetBackgroundLayerCommand } from '../commands-library/getLayer';
3
+ import { createMultiGetDocumentCommand } from '../commands-library/multiGetDocument';
4
+ import { batchPlayCommand, batchPlayCommands } from '../core/command';
5
5
 
6
6
  // get layer properties like name and layerID for all layers in the document (by index)
7
- export const getDocumentLayerDescriptors = async (documentId: number) => {
7
+ export async function getDocumentLayerDescriptors(documentId: number) {
8
8
  const [layersResult, documentHasBackgroundLayerResult] = await batchPlayCommands([
9
9
  createMultiGetDocumentCommand(documentId),
10
10
  createGetDocumentHasBackgroundLayerCommand(documentId),
@@ -24,6 +24,6 @@ export const getDocumentLayerDescriptors = async (documentId: number) => {
24
24
  docId: documentId,
25
25
  };
26
26
  });
27
- };
27
+ }
28
28
 
29
29
  export type LayerDescriptor = Awaited<ReturnType<typeof getDocumentLayerDescriptors>>[number];
@@ -1,7 +1,6 @@
1
-
2
- import { type PsLayerRef } from "./psLayerRef";
3
- import { batchPlayCommand } from "../core/command";
4
- import { createGetLayerCommand } from "../commands-library/getLayer";
1
+ import type { PsLayerRef } from './psLayerRef';
2
+ import { createGetLayerCommand } from '../commands-library/getLayer';
3
+ import { batchPlayCommand } from '../core/command';
5
4
 
6
5
  export async function getLayerEffects(layerRef: PsLayerRef) {
7
6
  const result = await batchPlayCommand(createGetLayerCommand(layerRef));
@@ -11,7 +10,8 @@ export async function getLayerEffects(layerRef: PsLayerRef) {
11
10
  const effects: Record<string, boolean> = {};
12
11
 
13
12
  for (const effect in data) {
14
- if (effect !== "scale") effects[effect] = Array.isArray(data[effect]) ? data[effect].some((e) => e.enabled) : !!data[effect]?.enabled;
13
+ if (effect !== 'scale')
14
+ effects[effect] = Array.isArray(data[effect]) ? data[effect].some(e => e.enabled) : !!data[effect]?.enabled;
15
15
  }
16
16
 
17
17
  return effects;
@@ -1,42 +1,44 @@
1
- import { app } from "photoshop";
2
- import { openFileByPath } from "../filesystem/openFileByPath";
3
- import { batchPlayCommand } from "../core/command";
4
- import { expect } from "chai";
5
- import { createGetDocumentHasBackgroundLayerCommand } from "../commands-library/getDocument";
6
- import type { Test } from "@bubblydoo/uxp-test-framework";
7
- import { createGetBackgroundLayerCommand } from "../commands-library/getLayer";
8
- import { executeAsModal } from "../core/executeAsModal";
1
+ /* eslint-disable ts/no-unused-expressions */
2
+ import type { Test } from '@bubblydoo/uxp-test-framework';
3
+ import { expect } from 'chai';
4
+ import { app } from 'photoshop';
5
+ import { createGetDocumentHasBackgroundLayerCommand } from '../commands-library/getDocument';
6
+ import { createGetBackgroundLayerCommand } from '../commands-library/getLayer';
7
+ import { batchPlayCommand } from '../core/command';
8
+ import { executeAsModal } from '../core/executeAsModal';
9
+ import { openFileByPath } from '../filesystem/openFileByPath';
9
10
 
10
11
  export const backgroundLayerTest: Test = {
11
- name: "Has/Get Background Layer",
12
+ name: 'Has/Get Background Layer',
12
13
  async run() {
13
- const doc = await openFileByPath("plugin:/fixtures/one-layer-with-bg.psd");
14
+ const doc = await openFileByPath('plugin:/fixtures/one-layer-with-bg.psd');
14
15
  const hasBackgroundLayer = await batchPlayCommand(
15
- createGetDocumentHasBackgroundLayerCommand(doc.id)
16
- )
16
+ createGetDocumentHasBackgroundLayerCommand(doc.id),
17
+ );
17
18
  expect(hasBackgroundLayer.hasBackgroundLayer).to.be.true;
18
19
  const layer = await batchPlayCommand(
19
- createGetBackgroundLayerCommand(app.activeDocument.id)
20
- )
21
- expect(layer.name).to.equal("Background");
22
- await executeAsModal("Close Document", async () => await doc.close(0));
20
+ createGetBackgroundLayerCommand(app.activeDocument.id),
21
+ );
22
+ expect(layer.name).to.equal('Background');
23
+ await executeAsModal('Close Document', async () => await doc.close(0));
23
24
 
24
- const doc2 = await openFileByPath("plugin:/fixtures/one-layer.psd");
25
+ const doc2 = await openFileByPath('plugin:/fixtures/one-layer.psd');
25
26
 
26
27
  const hasBackgroundLayer2 = await batchPlayCommand(
27
- createGetDocumentHasBackgroundLayerCommand(doc2.id)
28
- )
28
+ createGetDocumentHasBackgroundLayerCommand(doc2.id),
29
+ );
29
30
  expect(hasBackgroundLayer2.hasBackgroundLayer).to.be.false;
30
31
  let rejected = false;
31
32
  try {
32
33
  await batchPlayCommand(
33
- createGetBackgroundLayerCommand(doc2.id)
34
- )
35
- } catch (e) {
34
+ createGetBackgroundLayerCommand(doc2.id),
35
+ );
36
+ }
37
+ catch (e) {
36
38
  rejected = true;
37
39
  }
38
40
  expect(rejected).to.be.true;
39
41
 
40
- await executeAsModal("Close Document", async () => await doc2.close(0));
42
+ await executeAsModal('Close Document', async () => await doc2.close(0));
41
43
  },
42
44
  };
@@ -1,102 +1,102 @@
1
- import { expect, it } from "vitest";
2
- import { photoshopLayerDescriptorsToUTLayers } from "./photoshopLayerDescriptorsToUTLayers";
3
- import { utLayersToText } from "./utLayersToText";
1
+ import { expect, it } from 'vitest';
2
+ import { photoshopLayerDescriptorsToUTLayers } from './photoshopLayerDescriptorsToUTLayers';
3
+ import { utLayersToText } from './utLayersToText';
4
4
 
5
- it("parses a flat list correctly", async () => {
5
+ it('parses a flat list correctly', async () => {
6
6
  expect(
7
7
  utLayersToText(
8
8
  photoshopLayerDescriptorsToUTLayers(
9
9
  [
10
10
  {
11
- name: "circle",
11
+ name: 'circle',
12
12
  layerID: 4,
13
13
  mode: {
14
- _enum: "blendMode",
15
- _value: "normal",
14
+ _enum: 'blendMode',
15
+ _value: 'normal',
16
16
  },
17
17
  background: false,
18
18
  itemIndex: 5,
19
19
  visible: true,
20
20
  layerKind: 1,
21
21
  layerSection: {
22
- _value: "layerSectionContent",
23
- _enum: "layerSectionType",
22
+ _value: 'layerSectionContent',
23
+ _enum: 'layerSectionType',
24
24
  },
25
25
  docId: 70,
26
26
  layerEffects: {},
27
27
  group: true,
28
28
  },
29
29
  {
30
- name: "group",
30
+ name: 'group',
31
31
  layerID: 6,
32
32
  mode: {
33
- _enum: "blendMode",
34
- _value: "passThrough",
33
+ _enum: 'blendMode',
34
+ _value: 'passThrough',
35
35
  },
36
36
  background: false,
37
37
  itemIndex: 4,
38
38
  visible: true,
39
39
  layerKind: 7,
40
40
  layerSection: {
41
- _value: "layerSectionStart",
42
- _enum: "layerSectionType",
41
+ _value: 'layerSectionStart',
42
+ _enum: 'layerSectionType',
43
43
  },
44
44
  docId: 70,
45
45
  layerEffects: {},
46
46
  group: false,
47
47
  },
48
48
  {
49
- name: "green square",
49
+ name: 'green square',
50
50
  layerID: 3,
51
51
  mode: {
52
- _enum: "blendMode",
53
- _value: "normal",
52
+ _enum: 'blendMode',
53
+ _value: 'normal',
54
54
  },
55
55
  background: false,
56
56
  itemIndex: 3,
57
57
  visible: true,
58
58
  layerKind: 1,
59
59
  layerSection: {
60
- _value: "layerSectionContent",
61
- _enum: "layerSectionType",
60
+ _value: 'layerSectionContent',
61
+ _enum: 'layerSectionType',
62
62
  },
63
63
  docId: 70,
64
64
  layerEffects: {},
65
65
  group: true,
66
66
  },
67
67
  {
68
- name: "red square",
68
+ name: 'red square',
69
69
  layerID: 2,
70
70
  mode: {
71
- _enum: "blendMode",
72
- _value: "normal",
71
+ _enum: 'blendMode',
72
+ _value: 'normal',
73
73
  },
74
74
  background: false,
75
75
  itemIndex: 2,
76
76
  visible: true,
77
77
  layerKind: 1,
78
78
  layerSection: {
79
- _value: "layerSectionContent",
80
- _enum: "layerSectionType",
79
+ _value: 'layerSectionContent',
80
+ _enum: 'layerSectionType',
81
81
  },
82
82
  docId: 70,
83
83
  layerEffects: {},
84
84
  group: false,
85
85
  },
86
86
  {
87
- name: "</Layer group>",
87
+ name: '</Layer group>',
88
88
  layerID: 7,
89
89
  mode: {
90
- _enum: "blendMode",
91
- _value: "passThrough",
90
+ _enum: 'blendMode',
91
+ _value: 'passThrough',
92
92
  },
93
93
  background: false,
94
94
  itemIndex: 1,
95
95
  visible: true,
96
96
  layerKind: 13,
97
97
  layerSection: {
98
- _value: "layerSectionEnd",
99
- _enum: "layerSectionType",
98
+ _value: 'layerSectionEnd',
99
+ _enum: 'layerSectionType',
100
100
  },
101
101
  docId: 70,
102
102
  layerEffects: {},
@@ -1,10 +1,10 @@
1
- import type { LayerDescriptor } from "./getDocumentLayerDescriptors";
1
+ import type { LayerDescriptor } from './getDocumentLayerDescriptors';
2
2
 
3
- type UTLayerKind = "pixel" | "adjustment-layer" | "text" | "curves" | "smartObject" | "video" | "group" | "threeD" | "gradientFill" | "pattern" | "solidColor" | "background";
3
+ type UTLayerKind = 'pixel' | 'adjustment-layer' | 'text' | 'curves' | 'smartObject' | 'video' | 'group' | 'threeD' | 'gradientFill' | 'pattern' | 'solidColor' | 'background';
4
4
 
5
- type UTBlendMode = "normal" | "dissolve" | "darken" | "multiply" | "colorBurn" | "linearBurn" | "darkerColor" | "lighten" | "screen" | "colorDodge" | "linearDodge" | "lighterColor" | "overlay" | "softLight" | "hardLight" | "vividLight" | "linearLight" | "pinLight" | "hardMix" | "difference" | "exclusion" | "blendSubtraction" | "blendDivide" | "hue" | "saturation" | "color" | "luminosity" | "passThrough";
5
+ type UTBlendMode = 'normal' | 'dissolve' | 'darken' | 'multiply' | 'colorBurn' | 'linearBurn' | 'darkerColor' | 'lighten' | 'screen' | 'colorDodge' | 'linearDodge' | 'lighterColor' | 'overlay' | 'softLight' | 'hardLight' | 'vividLight' | 'linearLight' | 'pinLight' | 'hardMix' | 'difference' | 'exclusion' | 'blendSubtraction' | 'blendDivide' | 'hue' | 'saturation' | 'color' | 'luminosity' | 'passThrough';
6
6
 
7
- type UTLayerBuilder = {
7
+ interface UTLayerBuilder {
8
8
  name: string;
9
9
  docId: number;
10
10
  id: number;
@@ -15,75 +15,75 @@ type UTLayerBuilder = {
15
15
  isClippingMask: boolean;
16
16
  background: boolean;
17
17
  layers?: UTLayerBuilder[];
18
- };
18
+ }
19
19
 
20
- export type UTLayer = Readonly<Omit<UTLayerBuilder, "layers">> & {
20
+ export type UTLayer = Readonly<Omit<UTLayerBuilder, 'layers'>> & {
21
21
  layers?: UTLayer[];
22
22
  };
23
23
 
24
- export type UTLayerMultiGetOnly = Omit<UTLayer, "effects">;
24
+ export type UTLayerMultiGetOnly = Omit<UTLayer, 'effects'>;
25
25
 
26
26
  const layerKindMap = new Map<number, UTLayerKind>([
27
- [1, "pixel"],
28
- [2, "adjustment-layer"], // All adjustment layers
29
- [3, "text"],
30
- [4, "curves"],
31
- [5, "smartObject"],
32
- [6, "video"],
33
- [7, "group"],
34
- [8, "threeD"],
35
- [9, "gradientFill"],
36
- [10, "pattern"],
37
- [11, "solidColor"],
38
- [12, "background"], // according to the internet but the actual value is undefined
27
+ [1, 'pixel'],
28
+ [2, 'adjustment-layer'], // All adjustment layers
29
+ [3, 'text'],
30
+ [4, 'curves'],
31
+ [5, 'smartObject'],
32
+ [6, 'video'],
33
+ [7, 'group'],
34
+ [8, 'threeD'],
35
+ [9, 'gradientFill'],
36
+ [10, 'pattern'],
37
+ [11, 'solidColor'],
38
+ [12, 'background'], // according to the internet but the actual value is undefined
39
39
  ]);
40
40
 
41
41
  const blendModes: string[] = [
42
- "normal",
43
- "dissolve",
44
- "darken",
45
- "multiply",
46
- "colorBurn",
47
- "linearBurn",
48
- "darkerColor",
49
- "lighten",
50
- "screen",
51
- "colorDodge",
52
- "linearDodge",
53
- "lighterColor",
54
- "overlay",
55
- "softLight",
56
- "hardLight",
57
- "vividLight",
58
- "linearLight",
59
- "pinLight",
60
- "hardMix",
61
- "difference",
62
- "exclusion",
63
- "blendSubtraction",
64
- "blendDivide",
65
- "hue",
66
- "saturation",
67
- "color",
68
- "luminosity",
69
- "passThrough",
42
+ 'normal',
43
+ 'dissolve',
44
+ 'darken',
45
+ 'multiply',
46
+ 'colorBurn',
47
+ 'linearBurn',
48
+ 'darkerColor',
49
+ 'lighten',
50
+ 'screen',
51
+ 'colorDodge',
52
+ 'linearDodge',
53
+ 'lighterColor',
54
+ 'overlay',
55
+ 'softLight',
56
+ 'hardLight',
57
+ 'vividLight',
58
+ 'linearLight',
59
+ 'pinLight',
60
+ 'hardMix',
61
+ 'difference',
62
+ 'exclusion',
63
+ 'blendSubtraction',
64
+ 'blendDivide',
65
+ 'hue',
66
+ 'saturation',
67
+ 'color',
68
+ 'luminosity',
69
+ 'passThrough',
70
70
  ] satisfies UTBlendMode[];
71
71
 
72
- const getLayerKind = (layer: LayerDescriptor): UTLayerKind => {
72
+ function getLayerKind(layer: LayerDescriptor): UTLayerKind {
73
73
  const kind = layerKindMap.get(layer.layerKind);
74
74
  if (!kind) {
75
75
  throw new Error(`Unknown layer kind: ${layer.layerKind}`);
76
76
  }
77
77
  return kind;
78
- };
78
+ }
79
79
 
80
- const getBlendMode = (layer: LayerDescriptor): UTBlendMode => {
80
+ function getBlendMode(layer: LayerDescriptor): UTBlendMode {
81
81
  const mode = layer.mode._value;
82
82
  if (!blendModes.includes(mode)) {
83
83
  throw new Error(`Unknown blend mode: ${mode}`);
84
84
  }
85
85
  return mode as UTBlendMode;
86
- };
86
+ }
87
87
 
88
88
  export function photoshopLayerDescriptorsToUTLayers(layers: LayerDescriptor[]): UTLayer[] {
89
89
  const root: UTLayerBuilder[] = [];
@@ -96,7 +96,7 @@ export function photoshopLayerDescriptorsToUTLayers(layers: LayerDescriptor[]):
96
96
  const sectionType = determineLayerSection(layer);
97
97
 
98
98
  // Handle group end
99
- if (sectionType === "end") {
99
+ if (sectionType === 'end') {
100
100
  if (stack.length > 1) {
101
101
  stack.pop();
102
102
  }
@@ -121,7 +121,7 @@ export function photoshopLayerDescriptorsToUTLayers(layers: LayerDescriptor[]):
121
121
  current!.layers.push(node);
122
122
 
123
123
  // Handle group start
124
- if (sectionType === "start") {
124
+ if (sectionType === 'start') {
125
125
  node.layers = [];
126
126
  // Push children array to stack to process content
127
127
  stack.push({ layers: node.layers });
@@ -132,22 +132,22 @@ export function photoshopLayerDescriptorsToUTLayers(layers: LayerDescriptor[]):
132
132
  return root as UTLayer[];
133
133
  };
134
134
 
135
- const determineLayerSection = (layer: LayerDescriptor): "start" | "end" | "normal" => {
135
+ function determineLayerSection(layer: LayerDescriptor): 'start' | 'end' | 'normal' {
136
136
  const section = layer.layerSection._value;
137
- const isGroupEnd =
138
- layer.name === "</Layer group>" ||
139
- layer.name === "</Layer set>" ||
140
- section === "layerSectionEnd";
137
+ const isGroupEnd
138
+ = layer.name === '</Layer group>'
139
+ || layer.name === '</Layer set>'
140
+ || section === 'layerSectionEnd';
141
141
 
142
- const isGroupStart = section === "layerSectionStart";
143
- return isGroupStart ? "start" : isGroupEnd ? "end" : "normal";
144
- };
142
+ const isGroupStart = section === 'layerSectionStart';
143
+ return isGroupStart ? 'start' : isGroupEnd ? 'end' : 'normal';
144
+ }
145
145
 
146
146
  function getEffects(layer: LayerDescriptor): Record<string, boolean> {
147
147
  const effects: Record<string, boolean> = {};
148
148
  if (layer.layerEffects) {
149
149
  for (const effect in layer.layerEffects) {
150
- effects[effect] = Array.isArray(layer.layerEffects[effect]) ? layer.layerEffects[effect].some((e) => e.enabled) : !!layer.layerEffects[effect]?.enabled;
150
+ effects[effect] = Array.isArray(layer.layerEffects[effect]) ? layer.layerEffects[effect].some(e => e.enabled) : !!layer.layerEffects[effect]?.enabled;
151
151
  }
152
152
  }
153
153
  return effects;
@@ -1,14 +1,14 @@
1
- import type { Test } from "@bubblydoo/uxp-test-framework";
2
- import { photoshopLayerDescriptorsToUTLayers } from "./photoshopLayerDescriptorsToUTLayers";
3
- import { openFileByPath } from "../filesystem/openFileByPath";
4
- import { expect } from "chai";
5
- import { getDocumentLayerDescriptors } from "./getDocumentLayerDescriptors";
1
+ import type { Test } from '@bubblydoo/uxp-test-framework';
2
+ import { expect } from 'chai';
3
+ import { openFileByPath } from '../filesystem/openFileByPath';
4
+ import { getDocumentLayerDescriptors } from './getDocumentLayerDescriptors';
5
+ import { photoshopLayerDescriptorsToUTLayers } from './photoshopLayerDescriptorsToUTLayers';
6
6
 
7
7
  export const photoshopLayerDescriptorsToUTLayersTest: Test = {
8
- name: "photoshopLayerDescriptorsToUTLayers",
9
- description: "Test the photoshopLayerDescriptorsToUTLayers function",
8
+ name: 'photoshopLayerDescriptorsToUTLayers',
9
+ description: 'Test the photoshopLayerDescriptorsToUTLayers function',
10
10
  run: async () => {
11
- const doc = await openFileByPath("plugin:/fixtures/clipping-layers.psd");
11
+ const doc = await openFileByPath('plugin:/fixtures/clipping-layers.psd');
12
12
  const descriptors = await getDocumentLayerDescriptors(doc.id);
13
13
 
14
14
  console.log(descriptors);
@@ -16,35 +16,35 @@ export const photoshopLayerDescriptorsToUTLayersTest: Test = {
16
16
  const layers = photoshopLayerDescriptorsToUTLayers(descriptors);
17
17
  expect(layers).to.containSubset([
18
18
  {
19
- name: "circle",
19
+ name: 'circle',
20
20
  visible: true,
21
- kind: "pixel",
22
- blendMode: "normal",
21
+ kind: 'pixel',
22
+ blendMode: 'normal',
23
23
  isClippingMask: true,
24
24
  effects: {},
25
25
  },
26
26
  {
27
- name: "group",
27
+ name: 'group',
28
28
  visible: true,
29
- kind: "group",
30
- blendMode: "passThrough",
29
+ kind: 'group',
30
+ blendMode: 'passThrough',
31
31
  isClippingMask: false,
32
32
  effects: {},
33
33
  layers: [
34
34
  {
35
- name: "green square",
35
+ name: 'green square',
36
36
  visible: true,
37
- kind: "pixel",
38
- blendMode: "normal",
37
+ kind: 'pixel',
38
+ blendMode: 'normal',
39
39
  isClippingMask: true,
40
40
  effects: {},
41
41
  },
42
42
  {
43
- name: "red square",
43
+ name: 'red square',
44
44
  id: 2,
45
45
  visible: true,
46
- kind: "pixel",
47
- blendMode: "normal",
46
+ kind: 'pixel',
47
+ blendMode: 'normal',
48
48
  isClippingMask: false,
49
49
  effects: {},
50
50
  },
@@ -55,28 +55,28 @@ export const photoshopLayerDescriptorsToUTLayersTest: Test = {
55
55
  };
56
56
 
57
57
  export const photoshopLayerDescriptorsToUTLayersTest2: Test = {
58
- name: "photoshopLayerDescriptorsToUTLayers",
59
- description: "Test the photoshopLayerDescriptorsToUTLayers function",
58
+ name: 'photoshopLayerDescriptorsToUTLayers',
59
+ description: 'Test the photoshopLayerDescriptorsToUTLayers function',
60
60
  run: async () => {
61
- const doc = await openFileByPath("plugin:/fixtures/one-layer-with-bg.psd");
61
+ const doc = await openFileByPath('plugin:/fixtures/one-layer-with-bg.psd');
62
62
  const descriptors = await getDocumentLayerDescriptors(doc.id);
63
63
  console.log(descriptors);
64
64
  const layers = photoshopLayerDescriptorsToUTLayers(descriptors);
65
65
  console.log(layers);
66
66
  expect(layers).to.containSubset([
67
67
  {
68
- name: "Layer 1",
68
+ name: 'Layer 1',
69
69
  visible: true,
70
- kind: "pixel",
71
- blendMode: "normal",
70
+ kind: 'pixel',
71
+ blendMode: 'normal',
72
72
  isClippingMask: false,
73
73
  effects: {},
74
74
  },
75
75
  {
76
- name: "Background",
76
+ name: 'Background',
77
77
  visible: true,
78
- kind: "background",
79
- blendMode: "normal",
78
+ kind: 'background',
79
+ blendMode: 'normal',
80
80
  isClippingMask: false,
81
81
  effects: {},
82
82
  },
@@ -1,4 +1,4 @@
1
- export type PsLayerRef = {
1
+ export interface PsLayerRef {
2
2
  id: number;
3
3
  docId: number;
4
- };
4
+ }