Skip to content

AI-native design editor. Open-source Figma alternative.

refactor(fig): own full archive parsing

Danila Poyarkovf9e2588b843c
diff --git a/AGENTS.md b/AGENTS.md
index f1d6f32f6..46aaab7ce 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -9,9 +9,9 @@ Vue 3 + CanvasKit (Skia WASM) + Yoga WASM design editor. Tauri v2 desktop, also
Bun workspace packages:
- `packages/scene-graph` — `@open-pencil/scene-graph`: SceneGraph, node types, copy/snap/undo helpers, variables, instances, hit testing. Framework-agnostic.
-- `packages/pen` — `@open-pencil/pen`: Pen/vector editing helpers shared by core/editor surfaces.
+- `packages/pen` — `@open-pencil/pen`: Pencil.dev `.pen` document model, parser, and SceneGraph import adapter.
- `packages/kiwi` — `@open-pencil/kiwi`: pure Kiwi schema/runtime/protocol package. Owns low-level Figma Kiwi codec/container/parse helpers and stays SceneGraph-agnostic.
-- `packages/fig` — `@open-pencil/fig`: publishable `.fig` package shell and low-level smoke/test boundary. Production SceneGraph `.fig` policy still lives mostly in core while this package grows.
+- `packages/fig` — `@open-pencil/fig`: `.fig` archive/parser package and staged home for Figma-specific SceneGraph conversion policy. Core keeps format-neutral IO registration and runtime rendering integration.
- `packages/core` — `@open-pencil/core`: renderer, layout, editor core, Figma API, tools, clipboard, vector conversion, and app/CLI-facing document I/O. Depends on scene-graph/pen/kiwi but keeps browser DOM out of core.
- `packages/dom-css` — `@open-pencil/dom-css`: DOM/CSS projection layer for HTML/CSS/JSX/Tailwind compatibility. Owns DesignDOM types and browser/headless CSS runtime adapters; keeps DOM/CSS parser dependencies out of core.
- `packages/vue` — `@open-pencil/vue`: headless Vue 3 SDK (Reka UI-style) for building custom OpenPencil-powered editor shells and embedded editing surfaces. Renderless components and composables. The app is one consumer of the SDK.
@@ -295,7 +295,7 @@ Self-review checklist:
## File format
-- `.fig` files use Figma's Kiwi schema and `NodeChange[]` records. Low-level schema/runtime/codec/container/parse helpers live in `packages/kiwi/src/fig/**` and `packages/kiwi/src/schema-runtime/**`.
+- `.fig` files use Figma's Kiwi schema and `NodeChange[]` records. Low-level schema/runtime/codec/container helpers live in `packages/kiwi/src/fig/**` and `packages/kiwi/src/schema-runtime/**`; complete `.fig` archive parsing lives in `packages/fig`.
- Core still owns SceneGraph `.fig` policy: import/export orchestration in `packages/core/src/io/formats/fig/**`, SceneGraph ⇄ NodeChange conversion in `packages/core/src/kiwi/fig/node-change/**`, and component/instance override interpretation in `packages/core/src/kiwi/fig/instance-overrides/**`.
- `packages/fig` is the publishable boundary for future `.fig` policy extraction; do not move behavior there without package-local tests and dist smoke.
- Vector data uses reverse-engineered `vectorNetworkBlob` binary format — encoder/decoder in `packages/core/src/vector/` and scene-graph vector-network types in `@open-pencil/scene-graph`.
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e1962a664..19097c984 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,7 @@
### Changed
+- Move complete `.fig` archive parsing into `@open-pencil/fig`, keeping `@open-pencil/kiwi` focused on Kiwi schema, message, and raw container mechanics.
- Add Figma-style page management in the Pages panel, including rename/delete actions and drag-and-drop page reordering.
- Add DOM/CSS import and authoring support so HTML, CSS, Tailwind, and JSX can be converted into editable OpenPencil documents from the app, CLI, and SDK.
- Add Tailwind class serialization for DOM/CSS HTML export in the SDK and CLI.
diff --git a/bun.lock b/bun.lock
index be1e55a26..9f14f859b 100644
--- a/bun.lock
+++ b/bun.lock
@@ -135,6 +135,7 @@
"dependencies": {
"@chenglou/pretext": "^0.0.7",
"@iconify/utils": "^3.1.0",
+ "@open-pencil/fig": "workspace:*",
"@open-pencil/kiwi": "workspace:*",
"@open-pencil/pen": "workspace:*",
"@open-pencil/scene-graph": "workspace:*",
@@ -205,6 +206,9 @@
"packages/fig": {
"name": "@open-pencil/fig",
"version": "0.13.2",
+ "dependencies": {
+ "fflate": "^0.8.2",
+ },
"devDependencies": {
"@types/bun": "^1.3.14",
"tsdown": "^0.22.3",
@@ -3260,6 +3264,8 @@
"@open-pencil/docs/@tailwindcss/vite": ["@tailwindcss/[email protected]", "", { "dependencies": { "@tailwindcss/node": "4.3.2", "@tailwindcss/oxide": "4.3.2", "tailwindcss": "4.3.2" }, "peerDependencies": { "vite": "^5.2.0 || ^6 || ^7 || ^8" } }, "sha512-eHpMeX4JXfVNJDEcsouTeCBubJBTcTLigeaw/NTUW6PB5ATKKXdyonnXgTBX2VuRbjz1hjfz6C5XAhr52ImQXA=="],
+ "@open-pencil/fig/fflate": ["[email protected]", "", {}, "sha512-tbZNuJrLwGUp3zshBtdy4W+ORxZuIh8a5ilyIEQDC5rY1f3U20JMry0Ll3WBzU58EZKsEuJFXhb5gwv8CsPvgA=="],
+
"@open-pencil/kiwi/fflate": ["[email protected]", "", {}, "sha512-tbZNuJrLwGUp3zshBtdy4W+ORxZuIh8a5ilyIEQDC5rY1f3U20JMry0Ll3WBzU58EZKsEuJFXhb5gwv8CsPvgA=="],
"@oxc-resolver/binding-wasm32-wasi/@emnapi/core": ["@emnapi/[email protected]", "", { "dependencies": { "@emnapi/wasi-threads": "1.2.2", "tslib": "^2.4.0" } }, "sha512-l9Oo58x0HOP5znGzVhYW9U3e5wVuA4LAZU2AGezTmkhO1CgQRFDhDg4nneHsu/t3WniXg9QrG2nIXL/ZS8ln8Q=="],
diff --git a/packages/core/package.json b/packages/core/package.json
index b1709056f..a08b540d2 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -167,6 +167,7 @@
"dependencies": {
"@chenglou/pretext": "^0.0.7",
"@iconify/utils": "^3.1.0",
+ "@open-pencil/fig": "workspace:*",
"@open-pencil/kiwi": "workspace:*",
"@open-pencil/pen": "workspace:*",
"@open-pencil/scene-graph": "workspace:*",
diff --git a/packages/core/src/io/formats/fig/read.ts b/packages/core/src/io/formats/fig/read.ts
index 1eba5fb3d..dceef8e57 100644
--- a/packages/core/src/io/formats/fig/read.ts
+++ b/packages/core/src/io/formats/fig/read.ts
@@ -1,4 +1,4 @@
-import { parseFigBuffer } from '@open-pencil/kiwi/fig/parse'
+import { parseFigBuffer } from '@open-pencil/fig'
import type { SceneGraph } from '@open-pencil/scene-graph'
import { IS_BROWSER } from '#core/constants'
diff --git a/packages/core/src/kiwi/fig/parse/worker.ts b/packages/core/src/kiwi/fig/parse/worker.ts
index abe95a16e..96691d427 100644
--- a/packages/core/src/kiwi/fig/parse/worker.ts
+++ b/packages/core/src/kiwi/fig/parse/worker.ts
@@ -1,4 +1,4 @@
-import { parseFigBuffer } from '@open-pencil/kiwi/fig/parse'
+import { parseFigBuffer } from '@open-pencil/fig'
import { importNodeChanges } from '#core/kiwi/fig/import'
import {
diff --git a/packages/fig/README.md b/packages/fig/README.md
index 8abd34667..6b9134b96 100644
--- a/packages/fig/README.md
+++ b/packages/fig/README.md
@@ -1,28 +1,35 @@
# @open-pencil/fig
-`.fig` document policy package for OpenPencil.
+`.fig` file-format package for OpenPencil.
-This package currently exposes low-level `fig-kiwi` container read/write helpers and remains the staging area for the next package-split stage. Use `@open-pencil/core` for production SceneGraph `.fig` read/write APIs until higher-level behavior moves here.
+The package owns the outer `.fig` archive boundary and is the staged home for Figma-specific
+SceneGraph conversion policy. Production SceneGraph read/write remains available through
+`@open-pencil/core/io` while conversion modules move behind this package's public API.
Current ownership:
-- `readFigContainer()` / `writeFigContainer()` wrappers over `@open-pencil/kiwi` container helpers
-- `.fig` document source typing
+- Complete `.fig` archive parsing through `parseFigBuffer()`
+- Canvas payload and image resource discovery
+- `readFigContainer()` / `writeFigContainer()` helpers for raw `fig-kiwi` payloads
+- `.fig` source and archive result types
Planned ownership:
-- `.fig` read/write orchestration
-- SceneGraph ⇄ Figma NodeChange conversion policy
-- raw Figma metadata preservation and invalidation
-- component/instance interpretation
-- oracle-backed `.fig` fixtures and package-local tests
+- `.fig` archive assembly
+- SceneGraph ⇄ Figma `NodeChange` conversion
+- Raw Figma metadata precedence and invalidation policy
+- Component and instance interpretation
+- Oracle-backed `.fig` fixtures and package-local tests
Non-goals:
-- low-level Kiwi schema/runtime/codec internals — use `@open-pencil/kiwi`
-- editor actions, renderer behavior, Vue/app UI, CLI formatting, or MCP transport
+- Generic Kiwi schema/runtime internals — use `@open-pencil/kiwi`
+- Format-neutral IO registration, export targeting, CanvasKit thumbnails, or browser workers — use
+ `@open-pencil/core/io`
+- Editor actions, renderer behavior, Vue/app UI, CLI formatting, or MCP transport
-See `packages/docs/development/fig-package-plan.md` for the staged migration plan.
+This follows the existing `@open-pencil/pen` pattern: a format package owns its source model/parser
+and SceneGraph policy, while core registers it in the shared IO system.
## Checks
diff --git a/packages/fig/package.json b/packages/fig/package.json
index 4a25c7921..32e2fafc1 100644
--- a/packages/fig/package.json
+++ b/packages/fig/package.json
@@ -38,6 +38,9 @@
"peerDependencies": {
"@open-pencil/kiwi": "workspace:*"
},
+ "dependencies": {
+ "fflate": "^0.8.2"
+ },
"devDependencies": {
"@types/bun": "^1.3.14",
"tsdown": "^0.22.3",
diff --git a/packages/fig/scripts/smoke-dist.ts b/packages/fig/scripts/smoke-dist.ts
index 92e432415..1643dec64 100644
--- a/packages/fig/scripts/smoke-dist.ts
+++ b/packages/fig/scripts/smoke-dist.ts
@@ -2,8 +2,8 @@ export {}
const mod = await import('../dist/index.js')
-if (mod.FIG_PACKAGE_STATUS !== 'container-api') {
- throw new Error('Expected @open-pencil/fig container API export')
+if (mod.FIG_PACKAGE_STATUS !== 'archive-api' || typeof mod.parseFigBuffer !== 'function') {
+ throw new Error('Expected @open-pencil/fig archive API exports')
}
const bytes = mod.writeFigContainer({
diff --git a/packages/fig/src/archive.ts b/packages/fig/src/archive.ts
new file mode 100644
index 000000000..b297d4d9e
--- /dev/null
+++ b/packages/fig/src/archive.ts
@@ -0,0 +1,53 @@
+import { unzipSync } from 'fflate'
+
+import type { NodeChange } from '@open-pencil/kiwi/fig/codec'
+import { decodeFigKiwiCanvas } from '@open-pencil/kiwi/fig/parse'
+
+export interface FigParseResult {
+ nodeChanges: NodeChange[]
+ blobs: Uint8Array[]
+ images: Array<[string, Uint8Array]>
+ figKiwiVersion: number
+ /** Deflated Kiwi schema bytes from the original file, retained for round-trip fidelity. */
+ figSchemaDeflated: Uint8Array
+}
+
+function isLikelyAsset(name: string): boolean {
+ const lower = name.toLowerCase()
+ return lower.endsWith('.png') || lower.endsWith('.jpg') || lower.endsWith('.json')
+}
+
+function findCanvasData(entries: Partial<Record<string, Uint8Array>>): Uint8Array | null {
+ const canonical = entries['canvas.fig'] ?? entries.canvas
+ if (canonical) return canonical
+
+ let largest: Uint8Array | null = null
+ for (const [name, data] of Object.entries(entries)) {
+ if (!data || isLikelyAsset(name)) continue
+ if (!largest || data.byteLength > largest.byteLength) largest = data
+ }
+ return largest
+}
+
+/** Parse a complete zipped `.fig` file into its Figma protocol payload and binary resources. */
+export function parseFigBuffer(buffer: ArrayBuffer): FigParseResult {
+ const archive = unzipSync(new Uint8Array(buffer), {
+ filter: (file) =>
+ file.name === 'canvas.fig' ||
+ file.name === 'canvas' ||
+ (file.name.startsWith('images/') && file.name !== 'images/')
+ })
+ const canvasData = findCanvasData(archive)
+ if (!canvasData) {
+ throw new Error(
+ `No canvas data found in .fig file. Entries: ${Object.keys(archive).join(', ')}`
+ )
+ }
+
+ const decoded = decodeFigKiwiCanvas(canvasData)
+ const images = Object.entries(archive)
+ .filter(([name]) => name.startsWith('images/') && name !== 'images/')
+ .map(([name, data]) => [name.slice('images/'.length), data] as [string, Uint8Array])
+
+ return { ...decoded, images }
+}
diff --git a/packages/fig/src/index.ts b/packages/fig/src/index.ts
index ce79fbd94..67deb4cd3 100644
--- a/packages/fig/src/index.ts
+++ b/packages/fig/src/index.ts
@@ -1,3 +1,5 @@
+export { parseFigBuffer, type FigParseResult } from './archive'
+
import {
FIG_KIWI_DEFAULT_VERSION,
buildFigKiwi,
@@ -37,7 +39,7 @@ export interface WriteFigContainerOptions {
readonly version?: number
}
-export const FIG_PACKAGE_STATUS = 'container-api' as const
+export const FIG_PACKAGE_STATUS = 'archive-api' as const
export function readFigContainer(
bytes: Uint8Array,
@@ -66,6 +68,6 @@ export function writeFigContainer(
export function assertFigPackageReady(): void {
throw new Error(
- '@open-pencil/fig currently exposes low-level container APIs; use @open-pencil/core for SceneGraph .fig read/write APIs for now.'
+ '@open-pencil/fig currently exposes archive/container APIs; use @open-pencil/core for SceneGraph .fig read/write APIs for now.'
)
}
diff --git a/packages/fig/tests/index.test.ts b/packages/fig/tests/index.test.ts
index 442f2be62..2f2f13b1a 100644
--- a/packages/fig/tests/index.test.ts
+++ b/packages/fig/tests/index.test.ts
@@ -1,15 +1,29 @@
-import { describe, expect, it } from 'bun:test'
+import { beforeAll, describe, expect, it } from 'bun:test'
+
+import { deflateSync, zipSync } from 'fflate'
+
+import {
+ createNodeChangesMessage,
+ encodeMessage,
+ getSchemaBytes,
+ initCodec
+} from '@open-pencil/kiwi/fig/codec'
import {
FIG_PACKAGE_STATUS,
assertFigPackageReady,
+ parseFigBuffer,
readFigContainer,
writeFigContainer
} from '../src/index'
describe('@open-pencil/fig package API', () => {
- it('exports container API status', () => {
- expect(FIG_PACKAGE_STATUS).toBe('container-api')
+ beforeAll(async () => {
+ await initCodec()
+ })
+
+ it('exports archive API status', () => {
+ expect(FIG_PACKAGE_STATUS).toBe('archive-api')
})
it('round-trips fig-kiwi container bytes', () => {
@@ -25,11 +39,37 @@ describe('@open-pencil/fig package API', () => {
expect(document.source?.fileName).toBe('fixture.fig')
})
+ it('parses complete .fig archives and image resources', () => {
+ const canvas = writeFigContainer({
+ schemaDeflated: deflateSync(getSchemaBytes()),
+ dataRaw: encodeMessage(
+ createNodeChangesMessage(0, 0, [
+ {
+ guid: { sessionID: 0, localID: 0 },
+ type: 'DOCUMENT',
+ phase: 'CREATED',
+ name: 'Document'
+ }
+ ])
+ ),
+ source: { fileName: 'fixture.fig' }
+ })
+ const bytes = zipSync({
+ 'canvas.fig': canvas,
+ 'images/hash': new Uint8Array([9, 8, 7])
+ })
+ const parsed = parseFigBuffer(bytes.buffer as ArrayBuffer)
+
+ expect(parsed.nodeChanges).toHaveLength(1)
+ expect(parsed.nodeChanges[0]?.type).toBe('DOCUMENT')
+ expect(parsed.images).toEqual([['hash', new Uint8Array([9, 8, 7])]])
+ })
+
it('rejects invalid fig-kiwi containers', () => {
expect(() => readFigContainer(new Uint8Array([1, 2, 3]))).toThrow('Invalid fig-kiwi')
})
it('directs consumers to core for SceneGraph read/write', () => {
- expect(() => assertFigPackageReady()).toThrow('low-level container APIs')
+ expect(() => assertFigPackageReady()).toThrow('archive/container APIs')
})
})
diff --git a/packages/kiwi/README.md b/packages/kiwi/README.md
index be5914b4c..52c71a036 100644
--- a/packages/kiwi/README.md
+++ b/packages/kiwi/README.md
@@ -2,7 +2,7 @@
Scene-graph-agnostic Kiwi runtime utilities for OpenPencil.
-This package owns pure Kiwi schema parsing, Figma Kiwi schema data, low-level Figma message encode/decode, FIG Kiwi container helpers, GUID formatting, and raw `.fig` parse helpers. `.fig` import/export policy stays in `@open-pencil/core`: SceneGraph conversion, raw metadata invalidation, component/instance interpretation, and app/CLI document I/O are not part of this package.
+This package owns pure Kiwi schema parsing, Figma Kiwi schema data, low-level Figma message encode/decode, raw `fig-kiwi` container helpers, and GUID formatting. Complete `.fig` archive parsing lives in `@open-pencil/fig`; SceneGraph integration remains outside this package.
## Installation
@@ -74,19 +74,16 @@ const container = buildFigKiwi(new Uint8Array([1, 2, 3]))
const chunks = parseFigKiwiChunks(container)
```
-## Raw `.fig` parsing
+## Raw `fig-kiwi` payload decoding
```ts
-import { parseFigBytes } from '@open-pencil/kiwi/fig/parse'
+import { decodeFigKiwiCanvas } from '@open-pencil/kiwi/fig/parse'
-const parsed = await parseFigBytes(await Bun.file('design.fig').arrayBuffer())
-
-for (const canvas of parsed.canvases) {
- console.log(canvas.name, canvas.nodeChanges.length)
-}
+const decoded = decodeFigKiwiCanvas(canvasBytes)
+console.log(decoded.nodeChanges.length, decoded.blobs.length)
```
-`parseFigBytes()` returns structural `NodeChange` data, blobs, images, schema bytes, and container metadata. Use `@open-pencil/core` for converting that data into an editable `SceneGraph`.
+Use `parseFigBuffer()` from `@open-pencil/fig` for complete zipped `.fig` files, including image resources. Use `@open-pencil/core/io` for conversion into an editable `SceneGraph`.
## GUID helpers
diff --git a/packages/kiwi/src/fig/parse.ts b/packages/kiwi/src/fig/parse.ts
index 3f4baeafd..4b5a301d4 100644
--- a/packages/kiwi/src/fig/parse.ts
+++ b/packages/kiwi/src/fig/parse.ts
@@ -1,4 +1,4 @@
-import { unzipSync, inflateSync } from 'fflate'
+import { inflateSync } from 'fflate'
import { decompress as zstdDecompress } from 'fzstd'
import { decodeBinarySchema, compileSchema, ByteBuffer } from '../schema-runtime'
@@ -84,48 +84,17 @@ export function parseFigKiwiContainer(data: Uint8Array): FigKiwiPayload | null {
return { schemaDeflated: chunks[0], dataRaw, version }
}
-export interface FigParseResult {
+export interface FigKiwiDecodeResult {
nodeChanges: NodeChange[]
blobs: Uint8Array[]
- images: Array<[string, Uint8Array]>
figKiwiVersion: number
/** Deflated kiwi schema bytes from the original file (for roundtrip fidelity). */
figSchemaDeflated: Uint8Array
}
-export function parseFigBuffer(buffer: ArrayBuffer): FigParseResult {
- const zip = unzipSync(new Uint8Array(buffer), {
- filter: (file) =>
- file.name === 'canvas.fig' ||
- file.name === 'canvas' ||
- (file.name.startsWith('images/') && file.name !== 'images/')
- })
- const entries = Object.keys(zip)
-
- let canvasData: Uint8Array | null = null
- for (const name of entries) {
- if (name === 'canvas.fig' || name === 'canvas') {
- canvasData = zip[name]
- break
- }
- }
- if (!canvasData) {
- let maxSize = 0
- for (const name of entries) {
- const lower = name.toLowerCase()
- if (lower.endsWith('.png') || lower.endsWith('.jpg') || lower.endsWith('.json')) continue
- if (zip[name].byteLength > maxSize) {
- maxSize = zip[name].byteLength
- canvasData = zip[name]
- }
- }
- }
-
- if (!canvasData) {
- throw new Error(`No canvas data found in .fig file. Entries: ${entries.join(', ')}`)
- }
-
- const payload = parseFigKiwiContainer(canvasData)
+/** Decode one raw `fig-kiwi` canvas payload. Outer `.fig` archive handling lives in `@open-pencil/fig`. */
+export function decodeFigKiwiCanvas(data: Uint8Array): FigKiwiDecodeResult {
+ const payload = parseFigKiwiContainer(data)
if (!payload) throw new Error('Invalid fig-kiwi container')
const schemaBytes = inflateSync(payload.schemaDeflated)
@@ -138,25 +107,15 @@ export function parseFigBuffer(buffer: ArrayBuffer): FigParseResult {
throw new Error('No nodes found in .fig file')
}
- // Deduplicate before returning — critical for worker path where raw
- // nodeChanges are serialized via postMessage before extractPluginData runs
deduplicateNodeChangePluginData(nodeChanges)
- const blobs: Uint8Array[] = (message.blobs ?? []).map((b) =>
- b.bytes instanceof Uint8Array ? b.bytes : new Uint8Array(Object.values(b.bytes))
+ const blobs: Uint8Array[] = (message.blobs ?? []).map((blob) =>
+ blob.bytes instanceof Uint8Array ? blob.bytes : new Uint8Array(Object.values(blob.bytes))
)
- const images: Array<[string, Uint8Array]> = []
- for (const name of entries) {
- if (name.startsWith('images/') && name !== 'images/') {
- images.push([name.replace('images/', ''), zip[name]])
- }
- }
-
return {
nodeChanges,
blobs,
- images,
figKiwiVersion: payload.version,
figSchemaDeflated: payload.schemaDeflated
}
diff --git a/tests/engine/io/fig/export/component-properties.test.ts b/tests/engine/io/fig/export/component-properties.test.ts
index 68d933029..b7cc8d3c4 100644
--- a/tests/engine/io/fig/export/component-properties.test.ts
+++ b/tests/engine/io/fig/export/component-properties.test.ts
@@ -1,7 +1,7 @@
import { beforeAll, describe, expect, test } from 'bun:test'
import { exportFigFile, initCodec } from '@open-pencil/core'
-import { parseFigBuffer } from '@open-pencil/kiwi/fig/parse'
+import { parseFigBuffer } from '@open-pencil/fig'
import { SceneGraph } from '@open-pencil/scene-graph'
import { importNodeChanges } from '#core/kiwi/fig/import'
diff --git a/tests/engine/io/fig/export/shared-styles.test.ts b/tests/engine/io/fig/export/shared-styles.test.ts
index cdabca697..d4498245e 100644
--- a/tests/engine/io/fig/export/shared-styles.test.ts
+++ b/tests/engine/io/fig/export/shared-styles.test.ts
@@ -1,7 +1,7 @@
import { beforeAll, describe, expect, test } from 'bun:test'
import { exportFigFile, initCodec } from '@open-pencil/core'
-import { parseFigBuffer } from '@open-pencil/kiwi/fig/parse'
+import { parseFigBuffer } from '@open-pencil/fig'
import { SceneGraph } from '@open-pencil/scene-graph'
import { sceneNodeToKiwi } from '#core/kiwi/fig/node-change/serialize'
diff --git a/tests/engine/io/fig/heavy/component-metadata.test.ts b/tests/engine/io/fig/heavy/component-metadata.test.ts
index 6332df808..9fc4dc880 100644
--- a/tests/engine/io/fig/heavy/component-metadata.test.ts
+++ b/tests/engine/io/fig/heavy/component-metadata.test.ts
@@ -1,7 +1,7 @@
import { expect, setDefaultTimeout, test } from 'bun:test'
import { readFileSync } from 'node:fs'
-import { parseFigBuffer } from '@open-pencil/kiwi/fig/parse'
+import { parseFigBuffer } from '@open-pencil/fig'
import { importNodeChanges } from '#core/kiwi'
diff --git a/tests/engine/io/fig/roundtrip/export-settings.test.ts b/tests/engine/io/fig/roundtrip/export-settings.test.ts
index a37197880..8802b5f0e 100644
--- a/tests/engine/io/fig/roundtrip/export-settings.test.ts
+++ b/tests/engine/io/fig/roundtrip/export-settings.test.ts
@@ -8,7 +8,7 @@ import {
SceneGraph,
type NodeChange
} from '@open-pencil/core'
-import { parseFigBuffer } from '@open-pencil/kiwi/fig/parse'
+import { parseFigBuffer } from '@open-pencil/fig'
import { MAX_EXPORT_SCALE } from '@open-pencil/scene-graph'
function decodeExport(bytes: Uint8Array) {
diff --git a/tests/engine/io/fig/roundtrip/glyph-blob.test.ts b/tests/engine/io/fig/roundtrip/glyph-blob.test.ts
index f58b5428c..045254eb4 100644
--- a/tests/engine/io/fig/roundtrip/glyph-blob.test.ts
+++ b/tests/engine/io/fig/roundtrip/glyph-blob.test.ts
@@ -4,7 +4,7 @@ import { resolve } from 'node:path'
import { exportFigFile, initCodec, parseFigFile, SceneGraph } from '@open-pencil/core'
import { fontManager } from '@open-pencil/core/text'
-import { parseFigBuffer } from '@open-pencil/kiwi/fig/parse'
+import { parseFigBuffer } from '@open-pencil/fig'
import { HEAVY_TEST_TIMEOUT_MS } from '#tests/helpers/test-utils'
diff --git a/tests/engine/io/fig/roundtrip/source-metadata.test.ts b/tests/engine/io/fig/roundtrip/source-metadata.test.ts
index 80eafed33..0456fffd5 100644
--- a/tests/engine/io/fig/roundtrip/source-metadata.test.ts
+++ b/tests/engine/io/fig/roundtrip/source-metadata.test.ts
@@ -2,7 +2,7 @@ import { beforeAll, describe, expect, test } from 'bun:test'
import { exportFigFile, initCodec, parseFigFile, SceneGraph } from '@open-pencil/core'
import { guidToString } from '@open-pencil/core/kiwi/fig/node-change/convert'
-import { parseFigBuffer } from '@open-pencil/kiwi/fig/parse'
+import { parseFigBuffer } from '@open-pencil/fig'
function decodeExport(bytes: Uint8Array) {
return parseFigBuffer(bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength))
diff --git a/tests/engine/io/subgraph.test.ts b/tests/engine/io/subgraph.test.ts
index 1531fe705..ffc1decca 100644
--- a/tests/engine/io/subgraph.test.ts
+++ b/tests/engine/io/subgraph.test.ts
@@ -3,8 +3,8 @@ import { readFileSync } from 'node:fs'
import { exportFigFile, extractExportGraph, parseFigFile } from '@open-pencil/core/io'
import { initCodec } from '@open-pencil/core/kiwi'
+import { parseFigBuffer } from '@open-pencil/fig'
import { guidToString } from '@open-pencil/kiwi/fig/guid'
-import { parseFigBuffer } from '@open-pencil/kiwi/fig/parse'
import { SceneGraph } from '@open-pencil/scene-graph'
describe('export subgraph extraction', () => {
diff --git a/tools/package-quality/src/smoke.ts b/tools/package-quality/src/smoke.ts
index 82ede4dc6..974894d1f 100644
--- a/tools/package-quality/src/smoke.ts
+++ b/tools/package-quality/src/smoke.ts
@@ -90,7 +90,7 @@ try {
tempDir
)
nodeEval(
- "const { FIG_PACKAGE_STATUS, readFigContainer, writeFigContainer } = await import('@open-pencil/fig'); if (FIG_PACKAGE_STATUS !== 'container-api') throw new Error('Fig package status smoke failed'); const document = readFigContainer(writeFigContainer({ schemaDeflated: new Uint8Array([1]), dataRaw: new Uint8Array([2]) })); if (document.dataRaw[0] !== 2) throw new Error('Fig container smoke failed')",
+ "const { FIG_PACKAGE_STATUS, parseFigBuffer, readFigContainer, writeFigContainer } = await import('@open-pencil/fig'); if (FIG_PACKAGE_STATUS !== 'archive-api' || typeof parseFigBuffer !== 'function') throw new Error('Fig package status smoke failed'); const document = readFigContainer(writeFigContainer({ schemaDeflated: new Uint8Array([1]), dataRaw: new Uint8Array([2]) })); if (document.dataRaw[0] !== 2) throw new Error('Fig container smoke failed')",
tempDir
)
nodeEval(