mirror of
https://github.com/penpot/penpot-exporter-figma-plugin.git
synced 2024-12-22 13:43:03 -05:00
3094f05e98
* Optimize images before generating zip file * add changelog * refactor * fix lint
31 lines
802 B
TypeScript
31 lines
802 B
TypeScript
import { componentsLibrary } from '@plugin/ComponentLibrary';
|
|
|
|
import { createFile } from '@ui/lib/penpot';
|
|
import { createComponentLibrary, createPage } from '@ui/parser/creators';
|
|
import { uiComponents, uiImages } from '@ui/parser/libraries';
|
|
import { PenpotDocument } from '@ui/types';
|
|
|
|
import { idLibrary, parseImage } from '.';
|
|
|
|
export const parse = async ({ name, children = [], components, images }: PenpotDocument) => {
|
|
componentsLibrary.init(components);
|
|
|
|
for (const [key, bytes] of Object.entries(images)) {
|
|
if (!bytes) continue;
|
|
|
|
uiImages.register(key, await parseImage(bytes));
|
|
}
|
|
|
|
uiComponents.init();
|
|
idLibrary.init();
|
|
|
|
const file = createFile(name);
|
|
|
|
for (const page of children) {
|
|
createPage(file, page);
|
|
}
|
|
|
|
createComponentLibrary(file);
|
|
|
|
return file;
|
|
};
|