Import / Require LayerKind for Photoshop UXP

oh wow i see, im surprised its missing. I guess Photoshop UXP is still in a very early stage?
either way, on my end, when i use:

document.layers.forEach(layer => console.log(layer.kind);

it returns a number. What i did for now was just turn that enum from up above to an object


const LayerKind = {
    "any" : 0,
    "pixel" : 1,
    "adjustment" : 2,
    "text" : 3,
    "vector" : 4,
    "smartObject" : 5,
    "video" : 6,
    "group" : 7,
    "threeD" : 8,
    "gradient" : 9,
    "pattern" : 10,
    "solidColor" : 11,
    "background" : 12,
    "groupEnd" : 13
}

It works fine, so if i do

layer.kind === LayerKind.text

it works just fine. Still, very strange that i have to create this object… i would assume it was already in UXP. I just hope i dont run into more things that are “not complete”. I have some legacy scripts that are crashing photoshop. need to upgrade. But either way, it works for now. im glad at least i got to the bottom of it. hopefully it will be added soon. Thank you guys for all your help

2 Likes