From c95d442e74b2e59ab8873dab808f9f95cdfb4021 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20S=C3=A1nchez?= Date: Fri, 20 Sep 2024 09:02:30 +0200 Subject: [PATCH] Fix for huge vectors crashing the plugin (#220) * fixed big vectors issue * fixes --- .changeset/lemon-jars-think.md | 5 +++++ .../transformers/partials/transformVectorPaths.ts | 12 +++++------- 2 files changed, 10 insertions(+), 7 deletions(-) create mode 100644 .changeset/lemon-jars-think.md diff --git a/.changeset/lemon-jars-think.md b/.changeset/lemon-jars-think.md new file mode 100644 index 0000000..df4f01c --- /dev/null +++ b/.changeset/lemon-jars-think.md @@ -0,0 +1,5 @@ +--- +'penpot-exporter': patch +--- + +Fixed issue where big vectors are making the plugin crash diff --git a/plugin-src/transformers/partials/transformVectorPaths.ts b/plugin-src/transformers/partials/transformVectorPaths.ts index 448d499..f02e3b5 100644 --- a/plugin-src/transformers/partials/transformVectorPaths.ts +++ b/plugin-src/transformers/partials/transformVectorPaths.ts @@ -14,16 +14,14 @@ import { translateCommands, translateWindingRule } from '@plugin/translators/vec import { PathShape } from '@ui/lib/types/shapes/pathShape'; export const transformVectorPaths = (node: VectorNode): PathShape[] => { + const regions = node.vectorNetwork?.regions ?? []; + const strokeLength = node.strokes.length; + const pathShapes = node.vectorPaths .filter((vectorPath, index) => { - return ( - nodeHasFills(node, vectorPath, (node.vectorNetwork.regions ?? [])[index]) || - node.strokes.length > 0 - ); + return nodeHasFills(node, vectorPath, regions[index]) || strokeLength > 0; }) - .map((vectorPath, index) => - transformVectorPath(node, vectorPath, (node.vectorNetwork.regions ?? [])[index]) - ); + .map((vectorPath, index) => transformVectorPath(node, vectorPath, regions[index])); const geometryShapes = node.fillGeometry .filter(