diff --git a/packages/core/src/kiwi/node-change/export-node.ts b/packages/core/src/kiwi/node-change/export-node.ts index 3868da63b..cc9aaa5d0 100644 --- a/packages/core/src/kiwi/node-change/export-node.ts +++ b/packages/core/src/kiwi/node-change/export-node.ts @@ -279,7 +279,10 @@ export function sceneNodeToKiwiWithContext( } const result: KiwiNodeChange[] = [nc] - const children = context.graph.getChildren(node.id).filter((child) => !child.internalOnly) + const children = + node.type === 'INSTANCE' + ? [] + : context.graph.getChildren(node.id).filter((child) => !child.internalOnly) for (let i = 0; i < children.length; i++) { result.push(...context.sceneNodeToKiwi(children[i], guid, i, localIdCounter, context)) } diff --git a/tests/engine/io/fig/roundtrip/glyph-blob.test.ts b/tests/engine/io/fig/roundtrip/glyph-blob.test.ts index 0bd61573c..6900976d5 100644 --- a/tests/engine/io/fig/roundtrip/glyph-blob.test.ts +++ b/tests/engine/io/fig/roundtrip/glyph-blob.test.ts @@ -56,9 +56,8 @@ describe('roundtrip: text glyph blobs', () => { const output = countGlyphBlobs(exported) expect(input.glyphsWithBlob).toBeGreaterThan(0) - expect(output.glyphsWithBlob).toBeGreaterThan(0) - expect(output.uniqueGlyphBlobs).toBeLessThan(output.glyphsWithBlob / 100) - expect(output.uniqueGlyphBlobs).toBeLessThanOrEqual(input.uniqueGlyphBlobs + 20) + expect(output.glyphsWithBlob).toBe(input.glyphsWithBlob) + expect(output.uniqueGlyphBlobs).toBeLessThanOrEqual(input.uniqueGlyphBlobs) }) test('deduplicates generated glyph blobs across repeated text', async () => { diff --git a/tests/engine/io/subgraph.test.ts b/tests/engine/io/subgraph.test.ts index af635f73f..1a44c95f6 100644 --- a/tests/engine/io/subgraph.test.ts +++ b/tests/engine/io/subgraph.test.ts @@ -56,7 +56,7 @@ describe('export subgraph extraction', () => { expect(extracted.graph.getNode(libraryPage.id)?.type).toBe('CANVAS') }) - test('fig page export preserves valid instance component references', async () => { + test('fig page export preserves valid instance component references without serializing instance children', async () => { await initCodec() const graph = new SceneGraph() const page = graph.getPages()[0] @@ -79,5 +79,12 @@ describe('export subgraph extraction', () => { expect(parsedInstance?.type).toBe('INSTANCE') expect(parsedInstance?.componentId).toBeTruthy() expect(parsed.getNode(parsedInstance?.componentId ?? '')?.type).toBe('COMPONENT') + + const exportedAgain = await exportFigFile(extracted.graph) + const reparsed = await parseFigFile(exportedAgain.buffer as ArrayBuffer) + const reparsedInstance = [...reparsed.getAllNodes()].find( + (node) => node.type === 'INSTANCE' && node.name === instance.name + ) + expect(reparsedInstance?.childIds).toEqual([]) }) })