I tried using typescript and see the console.log, but array just detect “Normal” BlendMode. I work hard to find the bug and found Golang language (https://github.com/torie/figma/blob/8ac4168aa567/types.go#L149) and I tried again, it’s not fixed the bug.
Some example my code:
interface BlendModeObject {
PassThrough: string;
Normal: string;
Darken: string;
Multiply: string;
LinearBurn: string;
ColorBurn: string;
Lighten: string;
Screen: string;
LinearDodge: string;
ColorDodge: string;
Overlay: string;
SoftLight: string;
HardLight: string;
Difference: string;
Exclusion: string;
Hue: string;
Saturation: string;
Color: string;
Luminosity: string;
}
// Buat objek BlendMode yang sesuai dengan objek BlendModeObject
const BlendMode: BlendModeObject = {
PassThrough: “PASS_THROUGH”,
Normal: “NORMAL”,
Darken: “DARKEN”,
Multiply: “MULTIPLY”,
LinearBurn: “LINEAR_BURN”,
ColorBurn: “COLOR_BURN”,
Lighten: “LIGHTEN”,
Screen: “SCREEN”,
LinearDodge: “LINEAR_DODGE”,
ColorDodge: “COLOR_DODGE”,
Overlay: “OVERLAY”,
SoftLight: “SOFT_LIGHT”,
HardLight: “HARD_LIGHT”,
Difference: “DIFFERENCE”,
Exclusion: “EXCLUSION”,
Hue: “HUE”,
Saturation: “SATURATION”,
Color: “COLOR”,
Luminosity: “LUMINOSITY”,
};
// Kode yang mengakses frameNode.fills
if (Array.isArray(frameNode.fills)) {
const fillsArray = ;
for (let i = 0; i < frameNode.fills.length; i++) {
const fill = frameNode.fills[i]; // Variabel ‘fill’ dideklarasikan di dalam loop
// Periksa jika fill.blendMode sudah ada dan sesuai
const blendMode = fill.blendMode && BlendMode[fill.blendMode as keyof BlendModeObject] ? BlendMode[fill.blendMode as keyof BlendModeObject] : "NORMAL";
const fillObject = {
type: fill.type,
visible: fill.visible,
opacity: fill.opacity,
blendMode: blendMode,
color: { r: fill.color.r, g: fill.color.g, b: fill.color.b },
};
fillsArray.push(fillObject);
}
frameCode += frame.fills = ${JSON.stringify(fillsArray)};\n
;
}