2024-05-30 10:54:37 -05:00
|
|
|
import { PenpotFile } from '@ui/lib/types/penpotFile';
|
|
|
|
import { Uuid } from '@ui/lib/types/utils/uuid';
|
2024-06-26 01:11:57 -05:00
|
|
|
import { identifiers } from '@ui/parser';
|
2024-05-30 10:54:37 -05:00
|
|
|
|
|
|
|
export const parseFigmaId = (
|
|
|
|
file: PenpotFile,
|
|
|
|
figmaId?: string,
|
|
|
|
shapeRef: boolean = false
|
|
|
|
): Uuid | undefined => {
|
|
|
|
if (!figmaId) {
|
2024-06-26 01:11:57 -05:00
|
|
|
if (shapeRef) return;
|
2024-05-30 10:54:37 -05:00
|
|
|
|
|
|
|
return file.newId();
|
|
|
|
}
|
|
|
|
|
2024-06-25 10:12:20 -05:00
|
|
|
const id = identifiers.get(figmaId);
|
2024-06-26 01:11:57 -05:00
|
|
|
|
2024-05-30 10:54:37 -05:00
|
|
|
if (id) {
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
|
|
|
const newId = file.newId();
|
2024-06-26 01:11:57 -05:00
|
|
|
|
|
|
|
identifiers.set(figmaId, newId);
|
|
|
|
|
2024-05-30 10:54:37 -05:00
|
|
|
return newId;
|
|
|
|
};
|