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-25 10:12:20 -05:00
|
|
|
import { identifiers } from '@ui/parser/libraries';
|
2024-05-30 10:54:37 -05:00
|
|
|
|
|
|
|
export const parseFigmaId = (
|
|
|
|
file: PenpotFile,
|
|
|
|
figmaId?: string,
|
|
|
|
shapeRef: boolean = false
|
|
|
|
): Uuid | undefined => {
|
|
|
|
if (!figmaId) {
|
|
|
|
if (shapeRef) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
return file.newId();
|
|
|
|
}
|
|
|
|
|
2024-06-25 10:12:20 -05:00
|
|
|
const id = identifiers.get(figmaId);
|
2024-05-30 10:54:37 -05:00
|
|
|
if (id) {
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
|
|
|
const newId = file.newId();
|
2024-06-25 10:12:20 -05:00
|
|
|
identifiers.register(figmaId, newId);
|
2024-05-30 10:54:37 -05:00
|
|
|
return newId;
|
|
|
|
};
|