2024-05-29 10:33:29 -05:00
|
|
|
import { componentsLibrary } from '@plugin/ComponentLibrary';
|
|
|
|
|
2024-05-29 05:52:21 -05:00
|
|
|
import { createFile } from '@ui/lib/penpot';
|
|
|
|
import { createComponentLibrary, createPage } from '@ui/parser/creators';
|
2024-05-29 10:33:29 -05:00
|
|
|
import { uiComponents } from '@ui/parser/libraries/UiComponents';
|
|
|
|
import { PenpotDocument } from '@ui/types';
|
2024-05-29 05:52:21 -05:00
|
|
|
|
2024-05-30 10:54:37 -05:00
|
|
|
import { idLibrary } from '.';
|
|
|
|
|
2024-05-29 10:33:29 -05:00
|
|
|
export const parse = ({ name, children = [], components }: PenpotDocument) => {
|
|
|
|
componentsLibrary.init(components);
|
|
|
|
uiComponents.init();
|
2024-05-30 10:54:37 -05:00
|
|
|
idLibrary.init();
|
2024-05-29 05:52:21 -05:00
|
|
|
|
|
|
|
const file = createFile(name);
|
|
|
|
|
|
|
|
for (const page of children) {
|
|
|
|
createPage(file, page);
|
|
|
|
}
|
|
|
|
|
|
|
|
createComponentLibrary(file);
|
|
|
|
|
|
|
|
return file;
|
|
|
|
};
|