0
Fork 0
mirror of https://github.com/penpot/penpot-exporter-figma-plugin.git synced 2025-04-18 01:34:17 -05:00
This commit is contained in:
Jordi Sala Morales 2024-06-18 07:44:54 +00:00
parent 7e6fdb686b
commit 540558c681
No known key found for this signature in database
GPG key ID: C5127140107F55FD
4 changed files with 26 additions and 24 deletions

View file

@ -12,18 +12,21 @@ import { transformPageNode } from '.';
const downloadImages = async (): Promise<Record<string, Uint8Array>> => {
const imageToDownload = Object.entries(imagesLibrary.all());
const images: Record<string, Uint8Array> = {};
let currentImage = 1;
figma.ui.postMessage({
type: 'PROGRESS_STEP',
data: 'images'
});
if (imageToDownload.length === 0) return images;
let currentImage = 1;
figma.ui.postMessage({
type: 'PROGRESS_TOTAL_ITEMS',
data: imageToDownload.length
});
figma.ui.postMessage({
type: 'PROGRESS_STEP',
data: 'images'
});
for (const [key, image] of imageToDownload) {
const bytes = await image?.getBytesAsync();

View file

@ -12,18 +12,16 @@ export const createComponentLibrary = async (file: PenpotFile) => {
let componentsBuilt = 1;
const components = uiComponents.all();
sendMessage({
type: 'PROGRESS_STEP',
data: 'components'
});
await sleep(20);
sendMessage({
type: 'PROGRESS_TOTAL_ITEMS',
data: components.length
});
sendMessage({
type: 'PROGRESS_STEP',
data: 'components'
});
for (const uiComponent of components) {
const component = componentsLibrary.get(uiComponent.componentFigmaId);

View file

@ -14,18 +14,16 @@ export const createFile = async (name: string, children: PenpotPage[]) => {
uiComponents.init();
idLibrary.init();
sendMessage({
type: 'PROGRESS_STEP',
data: 'building'
});
await sleep(20);
sendMessage({
type: 'PROGRESS_TOTAL_ITEMS',
data: children.length
});
sendMessage({
type: 'PROGRESS_STEP',
data: 'building'
});
for (const page of children) {
await createPage(file, page);

View file

@ -11,18 +11,21 @@ import { parseImage } from '.';
const optimizeImages = async (images: Record<string, Uint8Array>) => {
const imagesToOptimize = Object.entries(images);
let imagesOptimized = 1;
sendMessage({
type: 'PROGRESS_STEP',
data: 'optimization'
});
if (imagesToOptimize.length === 0) return;
let imagesOptimized = 1;
sendMessage({
type: 'PROGRESS_TOTAL_ITEMS',
data: imagesToOptimize.length
});
sendMessage({
type: 'PROGRESS_STEP',
data: 'optimization'
});
for (const [key, bytes] of imagesToOptimize) {
if (bytes) {
uiImages.register(key, await parseImage(bytes));