zp-figma-converter
Version:
Convert Figma designs to various code formats
50 lines • 2.38 kB
JavaScript
;
/**
* Main module for the JSON2CSD library.
* Should use the CLI tool: npm run cli
*
* Example:
* - Convert all files: npm run cli convert-all
* - Convert a file: npm run cli convert json/filename.json
* - Convert from Figma: npm run cli convert-figma <fileKey> [nodeId]
* - Show help: npm run cli help
*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CsdConverter = exports.FigmaConverter = void 0;
exports.convertFigmaToCode = convertFigmaToCode;
/**
* Figma Code Converter
* Convert Figma designs to various code formats
*/
const figma_converter_1 = require("./figma/figma-converter");
Object.defineProperty(exports, "FigmaConverter", { enumerable: true, get: function () { return figma_converter_1.FigmaConverter; } });
const csd_converter_1 = require("./converters/csd/csd-converter");
Object.defineProperty(exports, "CsdConverter", { enumerable: true, get: function () { return csd_converter_1.CsdConverter; } });
/**
* Convert Figma node to code
* @param fileKey Figma file key
* @param nodeId Figma node ID (optional)
* @param format Output format (default: csd)
* @param outputPath Output file path (optional)
* @returns Path to the generated file
*/
function convertFigmaToCode(apiKey_1, fileKey_1, nodeId_1) {
return __awaiter(this, arguments, void 0, function* (apiKey, fileKey, nodeId, format = 'csd', outputPath) {
const converter = new figma_converter_1.FigmaConverter(apiKey, fileKey);
return converter.convertNode(fileKey, nodeId || '', format, outputPath);
});
}
exports.default = {
FigmaConverter: figma_converter_1.FigmaConverter,
convertFigmaToCode
};
//# sourceMappingURL=index.js.map