@figma-export/core
Advanced tools
Comparing version 4.4.0 to 4.5.0
@@ -14,3 +14,3 @@ "use strict"; | ||
const figma_1 = require("./figma"); | ||
const components = ({ token, fileId, version, onlyFromPages = [], transformers = [], outputters = [], concurrency = 30, retries = 3, log = (msg) => { | ||
const components = ({ token, fileId, version, onlyFromPages = [], filterComponent = () => true, transformers = [], outputters = [], concurrency = 30, retries = 3, log = (msg) => { | ||
// eslint-disable-next-line no-console | ||
@@ -27,3 +27,3 @@ console.log(msg); | ||
} | ||
const pages = (0, figma_1.getPages)((document), { only: onlyFromPages }); | ||
const pages = (0, figma_1.getPages)((document), { only: onlyFromPages, filter: filterComponent }); | ||
log('preparing components'); | ||
@@ -30,0 +30,0 @@ const pagesWithSvg = yield (0, figma_1.enrichPagesWithSvg)(client, fileId, pages, { |
/// <reference types="react" /> | ||
import * as Figma from 'figma-js'; | ||
import * as FigmaExport from '@figma-export/types'; | ||
declare const getComponents: (children?: readonly Figma.Node[]) => FigmaExport.ComponentNode[]; | ||
declare const getComponents: (children?: readonly Figma.Node[], filter?: FigmaExport.ComponentFilter) => FigmaExport.ComponentNode[]; | ||
declare type GetPagesOptions = { | ||
only?: string | string[]; | ||
filter?: FigmaExport.ComponentFilter; | ||
}; | ||
@@ -27,4 +28,4 @@ declare const getPages: (document: Figma.Document, options?: GetPagesOptions) => FigmaExport.PageNode[]; | ||
declare const fileSvgs: (client: Figma.ClientInterface, fileId: string, ids: string[], { concurrency, retries, transformers, onFetchCompleted, }?: FileSvgOptions) => Promise<FigmaExportFileSvg>; | ||
declare const enrichPagesWithSvg: (client: Figma.ClientInterface, fileId: string, pages: FigmaExport.PageNode[], svgOptions?: FileSvgOptions | undefined) => Promise<FigmaExport.PageNode[]>; | ||
declare const enrichPagesWithSvg: (client: Figma.ClientInterface, fileId: string, pages: FigmaExport.PageNode[], svgOptions?: FileSvgOptions) => Promise<FigmaExport.PageNode[]>; | ||
export { getComponents, getPages, getIdsFromPages, getClient, getImages, fileSvgs, enrichPagesWithSvg, }; | ||
//# sourceMappingURL=figma.d.ts.map |
@@ -44,6 +44,6 @@ "use strict"; | ||
const utils_1 = require("./utils"); | ||
const getComponents = (children = []) => { | ||
const getComponents = (children = [], filter = () => true) => { | ||
let components = []; | ||
children.forEach((component) => { | ||
if (component.type === 'COMPONENT') { | ||
if (component.type === 'COMPONENT' && filter(component)) { | ||
components.push(Object.assign(Object.assign({}, component), { svg: '', figmaExport: { | ||
@@ -59,3 +59,3 @@ id: component.id, | ||
...components, | ||
...getComponents((component.children)), | ||
...getComponents((component.children), filter), | ||
]; | ||
@@ -73,3 +73,5 @@ } | ||
const pages = filterPagesByName(document.children, options.only); | ||
return pages.map((page) => (Object.assign(Object.assign({}, page), { components: getComponents(page.children) }))); | ||
return pages | ||
.map((page) => (Object.assign(Object.assign({}, page), { components: getComponents(page.children, options.filter) }))) | ||
.filter((page) => page.components.length > 0); | ||
}; | ||
@@ -133,5 +135,5 @@ exports.getPages = getPages; | ||
const svgs = yield fileSvgs(client, fileId, componentIds, svgOptions); | ||
return pages.map((page) => (Object.assign(Object.assign({}, page), { components: page.components.map((component) => (Object.assign(Object.assign({}, component), { svg: svgs[component.id] }))) }))); | ||
return pages.map((page) => (Object.assign(Object.assign({}, page), { components: page.components.map((component) => (Object.assign(Object.assign({}, component), { svg: svgs[component.id] || utils_1.emptySvg }))) }))); | ||
}); | ||
exports.enrichPagesWithSvg = enrichPagesWithSvg; | ||
//# sourceMappingURL=figma.js.map |
import * as Figma from 'figma-js'; | ||
import * as FigmaExport from '@figma-export/types'; | ||
declare const fetchStyles: (client: Figma.ClientInterface, fileId: string, version?: string | undefined, ids?: string[] | undefined) => Promise<FigmaExport.StyleNode[]>; | ||
declare const fetchStyles: (client: Figma.ClientInterface, fileId: string, version?: string, ids?: string[]) => Promise<FigmaExport.StyleNode[]>; | ||
declare const parseStyles: (styleNodes: FigmaExport.StyleNode[]) => FigmaExport.Style[]; | ||
export { fetchStyles, parseStyles, }; | ||
//# sourceMappingURL=index.d.ts.map |
export declare const toArray: <T>(any: T) => T[]; | ||
export declare const emptySvg = "<svg></svg>"; | ||
export declare const fromEntries: (iterable: any[][]) => { | ||
@@ -3,0 +4,0 @@ [key: string]: any; |
@@ -6,6 +6,7 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.notEmpty = exports.fetchAsSvgXml = exports.chunk = exports.promiseSequentially = exports.fromEntries = exports.toArray = void 0; | ||
exports.notEmpty = exports.fetchAsSvgXml = exports.chunk = exports.promiseSequentially = exports.fromEntries = exports.emptySvg = exports.toArray = void 0; | ||
const axios_1 = __importDefault(require("axios")); | ||
const toArray = (any) => (Array.isArray(any) ? any : [any]); | ||
exports.toArray = toArray; | ||
exports.emptySvg = '<svg></svg>'; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
@@ -47,3 +48,3 @@ const fromEntries = (iterable) => { | ||
if (response.data.length === 0) | ||
return '<svg></svg>'; | ||
return exports.emptySvg; | ||
return response.data; | ||
@@ -50,0 +51,0 @@ }).catch((error) => { |
{ | ||
"name": "@figma-export/core", | ||
"version": "4.4.0", | ||
"version": "4.5.0", | ||
"description": "@figma-export core functionalities", | ||
@@ -26,5 +26,5 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@figma-export/types": "^4.4.0", | ||
"@figma-export/types": "^4.5.0", | ||
"axios": "~0.27.2", | ||
"figma-js": "~1.15.0", | ||
"figma-js": "~1.16.0", | ||
"p-limit": "^3.1.0", | ||
@@ -36,3 +36,3 @@ "p-retry": "^4.6.2" | ||
}, | ||
"gitHead": "c7964f2efbc39bd33160555dd1612c152e112cfd" | ||
"gitHead": "a5cf8242a285a9ed1f62c97c72ee8fe00beeeb6b" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
55324
646
- Removedfigma-js@1.15.0(transitive)
Updated@figma-export/types@^4.5.0
Updatedfigma-js@~1.16.0