0
Fork 0
mirror of https://github.com/penpot/penpot-exporter-figma-plugin.git synced 2025-01-10 17:10:06 -05:00
penpot-exporter-figma-plugin/ui-src/parser/creators/buildFile.ts
Alex Sánchez d3c144e5e9
Text libraries (#185)
* color library

* fixes

* wip

* wip

* wip

* wip

* working

* improvements

* changeset

* changeset

* changeset & cleaning

* changeset & cleaning

* improvements

* fixes

* rebase
2024-06-25 16:08:59 +02:00

48 lines
1 KiB
TypeScript

import { sleep } from '@plugin/utils/sleep';
import { sendMessage } from '@ui/context';
import { PenpotFile } from '@ui/lib/types/penpotFile';
import { PenpotPage } from '@ui/lib/types/penpotPage';
import { idLibrary } from '@ui/parser';
import {
createColorsLibrary,
createComponentsLibrary,
createPage,
createTextLibrary
} from '@ui/parser/creators';
import { uiComponents } from '@ui/parser/libraries';
export const buildFile = async (file: PenpotFile, children: PenpotPage[]) => {
let pagesBuilt = 1;
uiComponents.init();
idLibrary.init();
sendMessage({
type: 'PROGRESS_TOTAL_ITEMS',
data: children.length
});
sendMessage({
type: 'PROGRESS_STEP',
data: 'building'
});
for (const page of children) {
await createPage(file, page);
sendMessage({
type: 'PROGRESS_PROCESSED_ITEMS',
data: pagesBuilt++
});
await sleep(0);
}
await createColorsLibrary(file);
await createTextLibrary(file);
await createComponentsLibrary(file);
return file;
};