mirror of
https://github.com/penpot/penpot-exporter-figma-plugin.git
synced 2025-04-18 01:34:17 -05:00
improve
This commit is contained in:
parent
7e6fdb686b
commit
540558c681
4 changed files with 26 additions and 24 deletions
|
@ -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();
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Add table
Reference in a new issue