@pixerate/editor 0.246.0 → 0.249.0

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 (105) hide show
  1. package/README.md +1 -0
  2. package/dist/animation-editor/index.cjs +64 -61
  3. package/dist/animation-editor/index.js +8 -5
  4. package/dist/{brushstrokeRender-ZDHMXJAE.cjs → brushstrokeRender-GCKK7V2I.cjs} +14 -11
  5. package/dist/{brushstrokeRender-AKUI3SEJ.js → brushstrokeRender-T3JZST44.js} +7 -4
  6. package/dist/canvas/index.cjs +8 -8
  7. package/dist/canvas/index.js +1 -1
  8. package/dist/{chunk-UVPD55UZ.cjs → chunk-2SMMZDMG.cjs} +35 -35
  9. package/dist/chunk-2VJAVXLI.js +192 -0
  10. package/dist/{chunk-OLNIPTB3.cjs → chunk-2VX55NFM.cjs} +1 -320
  11. package/dist/chunk-3K6HWEXZ.cjs +92 -0
  12. package/dist/{chunk-UOOK7HTX.js → chunk-3PPJRMIG.js} +1 -1
  13. package/dist/chunk-4D6KP5BV.js +92 -0
  14. package/dist/chunk-5RH3VXAK.js +269 -0
  15. package/dist/{chunk-LDPLEZ5T.js → chunk-6BIDVPED.js} +1 -1
  16. package/dist/{chunk-2ONK3ERD.cjs → chunk-75K3W4D6.cjs} +20 -20
  17. package/dist/chunk-BOHDJJ2O.cjs +192 -0
  18. package/dist/{chunk-2PBZBRP5.js → chunk-D5KGAO4Z.js} +10 -92
  19. package/dist/{chunk-DQWPMGH2.js → chunk-DOIU7VJG.js} +1 -1
  20. package/dist/{chunk-HB4ICNNA.cjs → chunk-DPYAO5U6.cjs} +42 -42
  21. package/dist/chunk-EJLRBS5Q.js +301 -0
  22. package/dist/{chunk-Q2UYUWAZ.cjs → chunk-H4AOUUBE.cjs} +679 -164
  23. package/dist/{chunk-PQ3H2AAN.cjs → chunk-I7NJPHWV.cjs} +122 -204
  24. package/dist/{chunk-FK5LTDOO.cjs → chunk-IOFVM3L3.cjs} +7 -7
  25. package/dist/{chunk-42TWUPNJ.js → chunk-IRSTHLQQ.js} +1 -320
  26. package/dist/{chunk-VDAWA546.js → chunk-J7T5QZ45.js} +614 -99
  27. package/dist/{chunk-VMROIWLL.cjs → chunk-KBYB7OWB.cjs} +3 -3
  28. package/dist/{chunk-5MFDD7SP.cjs → chunk-KYX7NZ5V.cjs} +1 -1
  29. package/dist/chunk-LJRCU3BJ.cjs +301 -0
  30. package/dist/{chunk-XTWXBQD4.cjs → chunk-LP2MCSBE.cjs} +593 -236
  31. package/dist/{chunk-A23PSOBB.js → chunk-O75V4ZS3.js} +1 -1
  32. package/dist/chunk-OTTT5N3K.js +322 -0
  33. package/dist/{chunk-N6WUB3Y5.js → chunk-PZP2SZIZ.js} +2 -2
  34. package/dist/{chunk-4PMCMWQS.js → chunk-UBRJOIR5.js} +367 -10
  35. package/dist/chunk-W5M3J7PV.cjs +322 -0
  36. package/dist/{chunk-4P6H35HU.js → chunk-WA44NKPF.js} +2 -2
  37. package/dist/{chunk-CEPKXLBS.cjs → chunk-WLJZZHUZ.cjs} +23 -23
  38. package/dist/{chunk-P3NIPIKS.js → chunk-WQCNC4DK.js} +1 -1
  39. package/dist/chunk-ZEYMKDYS.cjs +269 -0
  40. package/dist/image-editor/effect-tools.d.cts +37 -4
  41. package/dist/image-editor/effect-tools.d.ts +37 -4
  42. package/dist/image-editor/index.cjs +1340 -1828
  43. package/dist/image-editor/index.d.cts +1 -1
  44. package/dist/image-editor/index.d.ts +1 -1
  45. package/dist/image-editor/index.js +298 -786
  46. package/dist/paint/index.cjs +8 -5
  47. package/dist/paint/index.js +13 -10
  48. package/dist/paint-editor/controller.d.cts +71 -2
  49. package/dist/paint-editor/controller.d.ts +71 -2
  50. package/dist/paint-editor/index.cjs +901 -589
  51. package/dist/paint-editor/index.d.cts +3 -0
  52. package/dist/paint-editor/index.d.ts +3 -0
  53. package/dist/paint-editor/index.js +365 -53
  54. package/dist/paint-editor/procedural.d.cts +82 -5
  55. package/dist/paint-editor/procedural.d.ts +82 -5
  56. package/dist/paint-editor/sticker-art.d.cts +55 -0
  57. package/dist/paint-editor/sticker-art.d.ts +55 -0
  58. package/dist/paint-editor/stickers.d.cts +30 -17
  59. package/dist/paint-editor/stickers.d.ts +30 -17
  60. package/dist/paint-editor/stroke.d.cts +4 -0
  61. package/dist/paint-editor/stroke.d.ts +4 -0
  62. package/dist/paint-editor/tools.d.cts +1 -1
  63. package/dist/paint-editor/tools.d.ts +1 -1
  64. package/dist/paint-editor/ui.d.cts +25 -4
  65. package/dist/paint-editor/ui.d.ts +25 -4
  66. package/dist/{image-editor/layers/effects-ui.d.cts → raster/effects/ui.d.cts} +32 -5
  67. package/dist/{image-editor/layers/effects-ui.d.ts → raster/effects/ui.d.ts} +32 -5
  68. package/dist/raster/index.cjs +17 -3
  69. package/dist/raster/index.d.cts +1 -0
  70. package/dist/raster/index.d.ts +1 -0
  71. package/dist/raster/index.js +23 -9
  72. package/dist/stickers/browser.d.cts +48 -0
  73. package/dist/stickers/browser.d.ts +48 -0
  74. package/dist/stickers/combine.d.cts +10 -0
  75. package/dist/stickers/combine.d.ts +10 -0
  76. package/dist/stickers/conformance.d.cts +18 -0
  77. package/dist/stickers/conformance.d.ts +18 -0
  78. package/dist/stickers/editor.d.cts +14 -0
  79. package/dist/stickers/editor.d.ts +14 -0
  80. package/dist/stickers/errors.d.cts +6 -0
  81. package/dist/stickers/errors.d.ts +6 -0
  82. package/dist/stickers/fake.d.cts +16 -0
  83. package/dist/stickers/fake.d.ts +16 -0
  84. package/dist/stickers/helpers.d.cts +51 -0
  85. package/dist/stickers/helpers.d.ts +51 -0
  86. package/dist/stickers/index.cjs +331 -0
  87. package/dist/stickers/index.d.cts +16 -0
  88. package/dist/stickers/index.d.ts +16 -0
  89. package/dist/stickers/index.js +331 -0
  90. package/dist/stickers/stamps.d.cts +13 -0
  91. package/dist/stickers/stamps.d.ts +13 -0
  92. package/dist/stickers/tools.d.cts +25 -0
  93. package/dist/stickers/tools.d.ts +25 -0
  94. package/dist/stickers/types.d.cts +123 -0
  95. package/dist/stickers/types.d.ts +123 -0
  96. package/dist/vector/index.cjs +978 -975
  97. package/dist/vector/index.js +9 -6
  98. package/package.json +11 -1
  99. package/skills/README.md +1 -0
  100. package/skills/pixerate-paint-editor/SKILL.md +26 -32
  101. package/skills/pixerate-paint-editor/references/gradient-paint.md +23 -0
  102. package/skills/pixerate-paint-editor/references/layer-effects.md +28 -0
  103. package/skills/pixerate-paint-editor/references/light-paint.md +10 -2
  104. package/skills/pixerate-paint-editor/references/particle-brushes.md +66 -0
  105. package/skills/pixerate-stickers/SKILL.md +45 -0
@@ -22,6 +22,7 @@ import {
22
22
  TransformTooLargeError,
23
23
  blendTile,
24
24
  builtinPattern,
25
+ builtinPatternIds,
25
26
  curveLut,
26
27
  defaultLayerEffect,
27
28
  effectColorHex,
@@ -35,6 +36,7 @@ import {
35
36
  isInterpolation,
36
37
  isLayerEffectKind,
37
38
  isLayerLocked,
39
+ layerEffectLabel,
38
40
  mapLayer,
39
41
  mergeLayerEffect,
40
42
  newEffectId,
@@ -46,7 +48,7 @@ import {
46
48
  validateEffectGradient,
47
49
  validateLayerEffects,
48
50
  warpSurface
49
- } from "./chunk-UOOK7HTX.js";
51
+ } from "./chunk-3PPJRMIG.js";
50
52
  import {
51
53
  affineFromHomography,
52
54
  applyHomography,
@@ -104,7 +106,7 @@ import {
104
106
  transformTextRect,
105
107
  translateMatrix,
106
108
  warpPresetMesh
107
- } from "./chunk-N6WUB3Y5.js";
109
+ } from "./chunk-PZP2SZIZ.js";
108
110
  import {
109
111
  bezierPathBounds,
110
112
  outlineStroke,
@@ -114,22 +116,25 @@ import {
114
116
  transformBezierPath
115
117
  } from "./chunk-WEIK3UYB.js";
116
118
  import {
117
- base64ToBytes,
119
+ BLEND_MODES,
118
120
  blendRgb,
119
- bytesToBase64,
120
- decodePng,
121
- encodePng,
122
121
  isBlendMode,
123
122
  mixPigmentRgb,
124
123
  normalizeBlendMode,
125
- parseDataUrl,
126
- pngDataUrl,
127
124
  readDeepRegion,
128
125
  setLum,
129
126
  surfaceDepth,
130
127
  surfaceFromDeepPixels,
131
128
  writeDeepRegion
132
- } from "./chunk-42TWUPNJ.js";
129
+ } from "./chunk-IRSTHLQQ.js";
130
+ import {
131
+ base64ToBytes,
132
+ bytesToBase64,
133
+ decodePng,
134
+ encodePng,
135
+ parseDataUrl,
136
+ pngDataUrl
137
+ } from "./chunk-OTTT5N3K.js";
133
138
  import {
134
139
  TILE,
135
140
  TiledSurface,
@@ -11723,6 +11728,355 @@ function exportPsd(input) {
11723
11728
  return { bytes, psb, records: records.length, warnings };
11724
11729
  }
11725
11730
 
11731
+ // src/image-editor/effect-tools.ts
11732
+ var READ = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false };
11733
+ var WRITE = { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false };
11734
+ var WRITE_IDEMPOTENT = { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false };
11735
+ var DESTRUCTIVE = { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false };
11736
+ var EFFECT_ID = { type: "string", description: "Effect id from list_layer_effects or add_layer_effect." };
11737
+ var BLEND_IDS = BLEND_MODES.map((m) => m.id).filter((id) => id !== "pigment");
11738
+ var DEFS = {
11739
+ color: { type: "string", pattern: "^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$", description: "Colour as #rrggbb." },
11740
+ contour: {
11741
+ type: "object",
11742
+ description: "A transfer curve over the effect coverage: points { input, output } from 0 to 1 (at least 2), sorted by input. Linear is [{0,0},{1,1}].",
11743
+ properties: {
11744
+ name: { type: "string", description: 'Display name (e.g. "Cone", "Gaussian").' },
11745
+ points: {
11746
+ type: "array",
11747
+ minItems: 2,
11748
+ description: "Curve points.",
11749
+ items: {
11750
+ type: "object",
11751
+ properties: {
11752
+ input: { type: "number", minimum: 0, maximum: 1, description: "Coverage in (0..1)." },
11753
+ output: { type: "number", minimum: 0, maximum: 1, description: "Coverage out (0..1)." },
11754
+ corner: { type: "boolean", description: "Sharp corner instead of a smooth point (default false)." }
11755
+ },
11756
+ required: ["input", "output"],
11757
+ additionalProperties: false
11758
+ }
11759
+ }
11760
+ },
11761
+ required: ["name", "points"],
11762
+ additionalProperties: false
11763
+ },
11764
+ gradient: {
11765
+ type: "object",
11766
+ description: "A gradient: colour stops, optional opacity stops and its layout.",
11767
+ properties: {
11768
+ stops: {
11769
+ type: "array",
11770
+ minItems: 1,
11771
+ description: "Colour stops { position 0..1, color #rrggbb }.",
11772
+ items: {
11773
+ type: "object",
11774
+ properties: { position: { type: "number", minimum: 0, maximum: 1, description: "0..1 along the gradient." }, color: { $ref: "#/$defs/color" } },
11775
+ required: ["position", "color"],
11776
+ additionalProperties: false
11777
+ }
11778
+ },
11779
+ opacityStops: {
11780
+ type: "array",
11781
+ description: "Opacity stops { position 0..1, opacity 0..1 } (default opaque).",
11782
+ items: {
11783
+ type: "object",
11784
+ properties: {
11785
+ position: { type: "number", minimum: 0, maximum: 1, description: "0..1 along the gradient." },
11786
+ opacity: { type: "number", minimum: 0, maximum: 1, description: "0..1." }
11787
+ },
11788
+ required: ["position", "opacity"],
11789
+ additionalProperties: false
11790
+ }
11791
+ },
11792
+ style: { type: "string", enum: ["linear", "radial", "angle", "reflected", "diamond"], description: "Geometry." },
11793
+ angle: { type: "number", minimum: -360, maximum: 360, description: "Degrees, 90 = bottom to top." },
11794
+ scale: { type: "number", minimum: 0.1, maximum: 1.5, description: "1 = 100 %." },
11795
+ reverse: { type: "boolean", description: "Swap the ends." },
11796
+ align: { type: "boolean", description: "Lay out over the layer bounds (true) or the canvas." },
11797
+ offset: {
11798
+ type: "object",
11799
+ description: "Centre offset as fractions of the bounds.",
11800
+ properties: { x: { type: "number", minimum: -1, maximum: 1, description: "Fraction of the width." }, y: { type: "number", minimum: -1, maximum: 1, description: "Fraction of the height." } },
11801
+ required: ["x", "y"],
11802
+ additionalProperties: false
11803
+ }
11804
+ },
11805
+ required: ["stops", "style", "angle", "scale", "reverse", "align", "offset"],
11806
+ additionalProperties: false
11807
+ },
11808
+ phase: {
11809
+ type: "object",
11810
+ description: "Pattern origin offset in px.",
11811
+ properties: { x: { type: "number", description: "px." }, y: { type: "number", description: "px." } },
11812
+ required: ["x", "y"],
11813
+ additionalProperties: false
11814
+ },
11815
+ fill: {
11816
+ description: "What a stroke or glow paints with. Glows take color or gradient only.",
11817
+ anyOf: [
11818
+ {
11819
+ type: "object",
11820
+ properties: { type: { const: "color", description: "Solid colour." }, color: { $ref: "#/$defs/color" } },
11821
+ required: ["type", "color"],
11822
+ additionalProperties: false
11823
+ },
11824
+ {
11825
+ type: "object",
11826
+ properties: { type: { const: "gradient", description: "Gradient." }, gradient: { $ref: "#/$defs/gradient" } },
11827
+ required: ["type", "gradient"],
11828
+ additionalProperties: false
11829
+ },
11830
+ {
11831
+ type: "object",
11832
+ properties: {
11833
+ type: { const: "pattern", description: "Pattern (strokes only)." },
11834
+ patternId: { type: "string", description: "Pattern id from list_layer_effects.patterns." },
11835
+ name: { type: "string", description: "Display name." },
11836
+ scale: { type: "number", minimum: 0.01, maximum: 10, description: "1 = 100 %." },
11837
+ angle: { type: "number", minimum: -360, maximum: 360, description: "Rotation in degrees (default 0)." },
11838
+ link: { type: "boolean", description: "Tile from the layer (default true) or the canvas origin." },
11839
+ phase: { $ref: "#/$defs/phase" }
11840
+ },
11841
+ required: ["type", "patternId", "scale"],
11842
+ additionalProperties: false
11843
+ }
11844
+ ]
11845
+ }
11846
+ };
11847
+ var nullable = (schema, description) => ({ anyOf: [schema, { type: "null" }], description });
11848
+ function settingsSchema(forUpdate) {
11849
+ const opt = (schema, description) => forUpdate ? nullable(schema, `${description} null removes it.`) : { ...schema, description };
11850
+ return {
11851
+ type: "object",
11852
+ description: forUpdate ? "Settings to change (only these; nested objects are replaced whole). Which settings a kind takes: see add_layer_effect." : "Settings to change from Photoshop's defaults (all optional). Unknown settings for the kind are refused with the list of its settings.",
11853
+ properties: {
11854
+ enabled: { type: "boolean", description: "All kinds: false keeps the effect but hides it (default true)." },
11855
+ blend: { type: "string", enum: BLEND_IDS, description: "All but bevel-emboss: blend mode (shadows multiply, glows screen, others normal)." },
11856
+ opacity: { type: "number", minimum: 0, maximum: 1, description: "All but bevel-emboss: 0..1 (shadows / glows 0.75, satin 0.5, others 1)." },
11857
+ color: { $ref: "#/$defs/color", description: "drop-shadow, inner-shadow, satin, color-overlay: #rrggbb." },
11858
+ angle: { type: "number", minimum: -360, maximum: 360, description: "Shadows, satin, bevel-emboss: light direction in degrees, counter-clockwise from 3 o'clock (default 120; satin 19)." },
11859
+ useGlobalLight: { type: "boolean", description: "Shadows, bevel-emboss: follow the document global light instead of angle (default true)." },
11860
+ distance: { type: "number", minimum: 0, maximum: 3e4, description: "Shadows, satin: offset in px (default 5; satin 11)." },
11861
+ spread: { type: "number", minimum: 0, maximum: 1, description: "drop-shadow, outer-glow: 0..1 of the size made solid (default 0)." },
11862
+ choke: { type: "number", minimum: 0, maximum: 1, description: "inner-shadow, inner-glow: 0..1 of the size made solid (default 0)." },
11863
+ size: { type: "number", minimum: 0, maximum: 250, description: "Shadows, glows, satin, bevel-emboss: blur / size in px (default 5; satin 14); stroke: width in px (default 3)." },
11864
+ contour: opt({ $ref: "#/$defs/contour" }, "Shadows, glows, satin: coverage contour (default linear)."),
11865
+ antiAlias: { type: "boolean", description: "Shadows, glows, satin: smooth the contour (default false; satin true)." },
11866
+ noise: { type: "number", minimum: 0, maximum: 1, description: "Shadows, glows: speckle 0..1 (default 0)." },
11867
+ knocksOut: { type: "boolean", description: "drop-shadow: the layer hides the shadow beneath its see-through fill (default true)." },
11868
+ fill: { $ref: "#/$defs/fill", description: "outer-glow, inner-glow (color or gradient), stroke (color, gradient or pattern)." },
11869
+ technique: { type: "string", enum: ["softer", "precise", "smooth", "chisel-hard", "chisel-soft"], description: "Glows: softer | precise (default softer); bevel-emboss: smooth | chisel-hard | chisel-soft (default smooth)." },
11870
+ range: { type: "number", minimum: 0.01, maximum: 1, description: "Glows: the part of the glow the contour spans (default 0.5)." },
11871
+ jitter: { type: "number", minimum: 0, maximum: 1, description: "Glows: gradient jitter 0..1 (stored, not rendered; default 0)." },
11872
+ source: { type: "string", enum: ["edge", "center"], description: "inner-glow: glow from the edge (default) or the centre." },
11873
+ style: { type: "string", enum: ["inner-bevel", "outer-bevel", "emboss", "pillow-emboss", "stroke-emboss"], description: "bevel-emboss: style (default inner-bevel)." },
11874
+ depth: { type: "number", minimum: 0, maximum: 10, description: "bevel-emboss: depth, 1 = 100 % (default 1)." },
11875
+ direction: { type: "string", enum: ["up", "down"], description: "bevel-emboss: raised (up, default) or sunk (down)." },
11876
+ soften: { type: "number", minimum: 0, maximum: 16, description: "bevel-emboss: blur of the height in px (default 0)." },
11877
+ altitude: { type: "number", minimum: 0, maximum: 90, description: "bevel-emboss: light altitude in degrees (default 30)." },
11878
+ glossContour: opt({ $ref: "#/$defs/contour" }, "bevel-emboss: gloss contour over the shading (default linear)."),
11879
+ highlightColor: { $ref: "#/$defs/color", description: "bevel-emboss: highlight colour (default #ffffff)." },
11880
+ highlightBlend: { type: "string", enum: BLEND_IDS, description: "bevel-emboss: highlight mode (default screen)." },
11881
+ highlightOpacity: { type: "number", minimum: 0, maximum: 1, description: "bevel-emboss: highlight opacity (default 0.75)." },
11882
+ shadowColor: { $ref: "#/$defs/color", description: "bevel-emboss: shadow colour (default #000000)." },
11883
+ shadowBlend: { type: "string", enum: BLEND_IDS, description: "bevel-emboss: shadow mode (default multiply)." },
11884
+ shadowOpacity: { type: "number", minimum: 0, maximum: 1, description: "bevel-emboss: shadow opacity (default 0.75)." },
11885
+ contourElement: opt(
11886
+ {
11887
+ type: "object",
11888
+ properties: {
11889
+ contour: { $ref: "#/$defs/contour" },
11890
+ range: { type: "number", minimum: 0, maximum: 1, description: "Stored range (default 0.5)." },
11891
+ antiAlias: { type: "boolean", description: "Smooth the contour." }
11892
+ },
11893
+ required: ["contour", "range", "antiAlias"],
11894
+ additionalProperties: false
11895
+ },
11896
+ "bevel-emboss: the Contour element, shaping the bevel's height profile (default off)."
11897
+ ),
11898
+ texture: opt(
11899
+ {
11900
+ type: "object",
11901
+ properties: {
11902
+ patternId: { type: "string", description: "Pattern id from list_layer_effects.patterns." },
11903
+ name: { type: "string", description: "Display name." },
11904
+ scale: { type: "number", minimum: 0.01, maximum: 10, description: "1 = 100 %." },
11905
+ depth: { type: "number", minimum: -10, maximum: 10, description: "1 = +100 %; negative carves the pattern in." },
11906
+ invert: { type: "boolean", description: "Invert the pattern." },
11907
+ link: { type: "boolean", description: "Tile from the layer (default true)." },
11908
+ phase: { $ref: "#/$defs/phase" }
11909
+ },
11910
+ required: ["patternId", "scale", "depth", "invert"],
11911
+ additionalProperties: false
11912
+ },
11913
+ "bevel-emboss: the Texture element, a pattern's luminance as extra height (default off)."
11914
+ ),
11915
+ invert: { type: "boolean", description: "satin: invert (default true)." },
11916
+ gradient: { $ref: "#/$defs/gradient", description: "gradient-overlay: the gradient (default black to white, 90\xB0)." },
11917
+ dither: { type: "boolean", description: "gradient-overlay: dither (stored; default false)." },
11918
+ patternId: { type: "string", description: "pattern-overlay: pattern id from list_layer_effects.patterns (default checker)." },
11919
+ name: { type: "string", description: "pattern-overlay: pattern display name." },
11920
+ scale: { type: "number", minimum: 0.01, maximum: 10, description: "pattern-overlay: 1 = 100 % (default 1)." },
11921
+ link: { type: "boolean", description: "pattern-overlay: tile from the layer (default true) or the canvas origin." },
11922
+ phase: { $ref: "#/$defs/phase", description: "pattern-overlay: origin offset in px (default 0, 0)." },
11923
+ position: { type: "string", enum: ["outside", "inside", "center"], description: "stroke: where the stroke sits on the edge (default outside)." }
11924
+ },
11925
+ additionalProperties: false
11926
+ };
11927
+ }
11928
+ function patternList(documentPatterns) {
11929
+ const doc = documentPatterns.map((p) => ({ id: p.id, name: p.name, width: p.width, height: p.height, builtin: false }));
11930
+ const builtins = builtinPatternIds().map((id) => {
11931
+ const p = builtinPattern(id);
11932
+ return { id, name: p.name, width: p.width, height: p.height, builtin: true };
11933
+ });
11934
+ return [...doc, ...builtins];
11935
+ }
11936
+ function describeLayerEffects(effects) {
11937
+ return {
11938
+ enabled: effects.enabled,
11939
+ scale: effects.scale ?? 1,
11940
+ margin: effectsMargin(effects),
11941
+ fromPsd: Boolean(effects.psd),
11942
+ effects: effects.items.map((e) => ({ ...JSON.parse(JSON.stringify(e)), label: layerEffectLabel(e.kind) }))
11943
+ };
11944
+ }
11945
+ function createImageEffectTools(controller) {
11946
+ return createLayerEffectTools(
11947
+ {
11948
+ requireLayer: (id) => void requireLayer(controller.getLayers(), id),
11949
+ getLayerEffects: (id) => controller.getLayerEffects(id),
11950
+ addLayerEffect: (id, kind, settings, index) => controller.addLayerEffect(id, kind, settings, index),
11951
+ updateLayerEffect: (id, effectId, changes) => controller.updateLayerEffect(id, effectId, changes),
11952
+ removeLayerEffect: (id, effectId) => controller.removeLayerEffect(id, effectId),
11953
+ setLayerEffectsEnabled: (id, enabled, scale) => controller.setLayerEffectsEnabled(id, enabled, scale),
11954
+ getGlobalLight: () => controller.getGlobalLight(),
11955
+ setGlobalLight: (light) => controller.setGlobalLight(light),
11956
+ getDocumentPatterns: () => controller.getDocumentPatterns()
11957
+ },
11958
+ { layers: "a pixel, shape, type, smart object, annotation or group layer" }
11959
+ );
11960
+ }
11961
+ function createLayerEffectTools(host, options) {
11962
+ const error = options.error ?? ((m) => new LayerOperationError(m));
11963
+ const LAYER_ID = { type: "string", description: `Layer id from list_layers (${options.layers}).` };
11964
+ const layerArg = (id) => {
11965
+ if (typeof id !== "string" || !id) throw error("layerId is required (a layer id from list_layers).");
11966
+ host.requireLayer(id);
11967
+ return id;
11968
+ };
11969
+ const result = (layerId, extra = {}) => ({ layerId, ...extra, ...describeLayerEffects(host.getLayerEffects(layerId)) });
11970
+ const globalLight = () => host.getGlobalLight?.() ?? { ...DEFAULT_GLOBAL_LIGHT };
11971
+ const list2 = {
11972
+ name: "list_layer_effects",
11973
+ title: "List layer effects",
11974
+ description: "Returns a layer's effects: the master switch (enabled), Scale Effects (scale, 1 = 100 %), margin (px the effects reach beyond the shape), whether they came from a PSD, and every effect with its id, kind, label and all settings. Also returns the document global light and the pattern ids pattern effects can use.",
11975
+ inputSchema: { type: "object", properties: { layerId: LAYER_ID }, required: ["layerId"], additionalProperties: false },
11976
+ annotations: { title: "List layer effects", ...READ },
11977
+ handler: ({ layerId }) => result(layerArg(layerId), { globalLight: globalLight(), patterns: patternList(host.getDocumentPatterns?.() ?? []), kinds: [...LAYER_EFFECT_KINDS] })
11978
+ };
11979
+ const add = {
11980
+ name: "add_layer_effect",
11981
+ title: "Add a layer effect",
11982
+ description: `Adds a live effect to ${options.layers} with Photoshop's defaults, changed by settings: drop-shadow, inner-shadow, outer-glow, inner-glow, bevel-emboss, satin, color-overlay, gradient-overlay, pattern-overlay or stroke. Several of one kind are allowed (the first listed is on top). The effect is drawn from the layer's pixels, so it follows later changes. One undo step. Returns the new effect's id and the layer's effects.`,
11983
+ inputSchema: {
11984
+ type: "object",
11985
+ $defs: DEFS,
11986
+ properties: {
11987
+ layerId: LAYER_ID,
11988
+ kind: { type: "string", enum: [...LAYER_EFFECT_KINDS], description: "Effect kind." },
11989
+ settings: settingsSchema(false),
11990
+ index: { type: "integer", minimum: 0, description: "Position in the layer's effect list (default the end)." }
11991
+ },
11992
+ required: ["layerId", "kind"],
11993
+ additionalProperties: false
11994
+ },
11995
+ annotations: { title: "Add a layer effect", ...WRITE },
11996
+ handler: ({ layerId, kind, settings, index }) => {
11997
+ const id = layerArg(layerId);
11998
+ if (!isLayerEffectKind(kind)) throw error(`kind must be one of ${LAYER_EFFECT_KINDS.join(", ")}.`);
11999
+ const { effect } = host.addLayerEffect(id, kind, settings ?? {}, index);
12000
+ return result(id, { effectId: effect.id });
12001
+ }
12002
+ };
12003
+ const update = {
12004
+ name: "update_layer_effect",
12005
+ title: "Change a layer effect",
12006
+ description: "Changes settings of one effect (only the given ones; fill, gradient, contour and texture objects are replaced whole, null removes an optional contour or texture). The kind cannot change. Validates everything before changing anything. One undo step. Returns the layer's effects.",
12007
+ inputSchema: {
12008
+ type: "object",
12009
+ $defs: DEFS,
12010
+ properties: { layerId: LAYER_ID, effectId: EFFECT_ID, settings: settingsSchema(true) },
12011
+ required: ["layerId", "effectId", "settings"],
12012
+ additionalProperties: false
12013
+ },
12014
+ annotations: { title: "Change a layer effect", ...WRITE_IDEMPOTENT },
12015
+ handler: ({ layerId, effectId, settings }) => {
12016
+ const id = layerArg(layerId);
12017
+ const changes = settings ?? {};
12018
+ if (!Object.keys(changes).length) throw error("Give at least one setting to change.");
12019
+ host.updateLayerEffect(id, effectId, changes);
12020
+ return result(id);
12021
+ }
12022
+ };
12023
+ const remove = {
12024
+ name: "remove_layer_effect",
12025
+ title: "Remove a layer effect",
12026
+ description: "Removes one effect from a layer (to hide it but keep its settings, set enabled false with update_layer_effect instead). One undo step. Returns the layer's remaining effects.",
12027
+ inputSchema: { type: "object", properties: { layerId: LAYER_ID, effectId: EFFECT_ID }, required: ["layerId", "effectId"], additionalProperties: false },
12028
+ annotations: { title: "Remove a layer effect", ...DESTRUCTIVE },
12029
+ handler: ({ layerId, effectId }) => {
12030
+ const id = layerArg(layerId);
12031
+ host.removeLayerEffect(id, effectId);
12032
+ return result(id);
12033
+ }
12034
+ };
12035
+ const setEnabled = {
12036
+ name: "set_layer_effects_enabled",
12037
+ title: "Switch layer effects on or off",
12038
+ description: "Turns all of a layer's effects on or off at once (the master switch; each effect keeps its own enabled flag) and optionally sets Scale Effects, which multiplies every size, distance and pattern scale. One undo step. Returns the layer's effects.",
12039
+ inputSchema: {
12040
+ type: "object",
12041
+ properties: {
12042
+ layerId: LAYER_ID,
12043
+ enabled: { type: "boolean", description: "true renders the enabled effects; false hides them all." },
12044
+ scale: { type: "number", minimum: 0.01, maximum: 10, description: "Scale Effects, 1 = 100 % (unchanged when left out)." }
12045
+ },
12046
+ required: ["layerId", "enabled"],
12047
+ additionalProperties: false
12048
+ },
12049
+ annotations: { title: "Switch layer effects on or off", ...WRITE_IDEMPOTENT },
12050
+ handler: ({ layerId, enabled, scale }) => {
12051
+ const id = layerArg(layerId);
12052
+ host.setLayerEffectsEnabled(id, enabled, scale);
12053
+ return result(id);
12054
+ }
12055
+ };
12056
+ const light = {
12057
+ name: "set_global_light",
12058
+ title: "Set the global light",
12059
+ description: "Sets the document global light that shadows and bevels with useGlobalLight follow (Photoshop default: angle 120\xB0, altitude 30\xB0). One undo step. Returns the light.",
12060
+ inputSchema: {
12061
+ type: "object",
12062
+ properties: {
12063
+ angle: { type: "number", minimum: -360, maximum: 360, description: "Degrees, counter-clockwise from 3 o'clock: where the light comes from (unchanged when left out)." },
12064
+ altitude: { type: "number", minimum: 0, maximum: 90, description: "Degrees above the canvas, for bevels (unchanged when left out)." }
12065
+ },
12066
+ additionalProperties: false
12067
+ },
12068
+ annotations: { title: "Set the global light", ...WRITE_IDEMPOTENT },
12069
+ handler: ({ angle, altitude }) => {
12070
+ if (angle === void 0 && altitude === void 0) throw error("Give angle, altitude or both.");
12071
+ const next = {};
12072
+ if (angle !== void 0) next.angle = angle;
12073
+ if (altitude !== void 0) next.altitude = altitude;
12074
+ return { globalLight: host.setGlobalLight(next) };
12075
+ }
12076
+ };
12077
+ return host.setGlobalLight ? [list2, add, update, remove, setEnabled, light] : [list2, add, update, remove, setEnabled];
12078
+ }
12079
+
11726
12080
  export {
11727
12081
  LEGACY_PROCESS_VERSION,
11728
12082
  LATEST_PROCESS_VERSION,
@@ -12084,5 +12438,8 @@ export {
12084
12438
  psdToLayers,
12085
12439
  importPsd,
12086
12440
  smartContentsFile,
12087
- exportPsd
12441
+ exportPsd,
12442
+ describeLayerEffects,
12443
+ createImageEffectTools,
12444
+ createLayerEffectTools
12088
12445
  };