AI-native design editor. Open-source Figma alternative.
feat(dom-css): harden package boundaries
Danila Poyarkov1eb227ed0269
diff --git a/bun.lock b/bun.lockindex fa2d482cf..55f9c5755 100644--- a/bun.lock+++ b/bun.lock@@ -166,6 +166,7 @@"dependencies": {"@acemir/cssom": "^0.9.31","parse5": "^8.0.1",+ "postcss-value-parser": "^4.2.0","tailwindcss": "^4.2.1",},"devDependencies": {@@ -2336,6 +2337,8 @@"postcss": ["[email protected]", "", { "dependencies": { "nanoid": "^3.3.11", "picocolors": "^1.1.1", "source-map-js": "^1.2.1" } }, "sha512-OW/rX8O/jXnm82Ey1k44pObPtdblfiuWnrd8X7GJ7emImCOstunGbXUpp7HdBrFQX6rJzn3sPT397Wp5aCwCHg=="],+ "postcss-value-parser": ["[email protected]", "", {}, "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ=="],+"postcss-values-parser": ["[email protected]", "", { "dependencies": { "color-name": "^1.1.4", "is-url-superb": "^4.0.0", "quote-unquote": "^1.0.0" }, "peerDependencies": { "postcss": "^8.2.9" } }, "sha512-YLJpK0N1brcNJrs9WatuJFtHaV9q5aAOj+S4DI5S7jgHlRfm0PIbDCAFRYMQD5SHq7Fy6xsDhyutgS0QOAs0qw=="],"preact": ["[email protected]", "", {}, "sha512-wSAGyk2bYR1c7t3SZ3jHcM6xy0lcBcDel6lODcs9ME6Th++Dx2KU+6D3HD8wMMKGA8Wpw7OMd3/4RGzYRpzwRg=="],diff --git a/packages/core/src/scene-graph/source-metadata.ts b/packages/core/src/scene-graph/source-metadata.tsindex cf27dc9dc..419536aa9 100644--- a/packages/core/src/scene-graph/source-metadata.ts+++ b/packages/core/src/scene-graph/source-metadata.ts@@ -10,6 +10,11 @@ const RAW_NODE_FIELD_KEYS = new Set(['blendMode','fills','strokes',+ 'borderTopWeight',+ 'borderRightWeight',+ 'borderBottomWeight',+ 'borderLeftWeight',+ 'independentStrokeWeights','effects','cornerRadius','topLeftRadius',diff --git a/packages/docs/development/dom-css-parser-audit.md b/packages/docs/development/dom-css-parser-audit.mdindex df7ee01aa..1601fffd9 100644--- a/packages/docs/development/dom-css-parser-audit.md+++ b/packages/docs/development/dom-css-parser-audit.md@@ -6,6 +6,7 @@ OpenPencil's DOM/CSS compatibility layer should not grow hand-rolled CSS parsing- HTML parsing: `parse5` in the headless runtime, native `DOMParser` in the browser runtime.- Stylesheet parsing and headless inline style declaration parsing: `@acemir/cssom` in the headless runtime, native CSSOM in the browser runtime.+- CSS value tokenization for shadow values: `postcss-value-parser`.- Tailwind generation: Tailwind v4 `compile()` / `build()`.- Color parsing: `@open-pencil/core/color` (`culori`-backed).@@ -19,7 +20,7 @@ These are intentionally limited and should not be expanded without replacing the| Shorthand expansion | `packages/dom-css/src/headless-css.ts` | Expands simple margin/padding boxes, border color/width, and background color. | Use parsed declarations from CSSOM/native computed style; avoid adding new shorthand parsers. || `calc()` / custom properties | `packages/dom-css/src/headless-css.ts` | Resolves variables by direct lookup and only handles `calc(<number><unit> * <number>)`. | Browser runtime for real computed values; do not add arithmetic or fallback parsing manually. || JSX object style serialization | `packages/dom-css/src/jsx/runtime.ts` | Serializes object style props to inline CSS strings with simple camelCase to kebab-case conversion. | Keep as JSX authoring serialization only; use CSSOM/native parsing after HTML parsing. |-| Shadow values | `packages/dom-css/src/css-values.ts` | Extracts one color and numeric offsets for simple shadows. | Replace with a CSS value parser before supporting multiple shadows, inset, color functions, or spread edge cases. |+| Shadow values | `packages/dom-css/src/css-values.ts` | Uses `postcss-value-parser` tokenization for one simple outer shadow layer. Multiple shadows and inset shadows remain unsupported. | Keep using value-parser/browser-computed values; do not add string splitting for complex shadow grammar. || Numeric lengths | `packages/dom-css/src/css-values.ts` | Parses px/rem-ish numbers with `Number.parseFloat`. | Consume browser-computed pixel values where available; keep headless numeric parsing narrow. |## Rule for new mapping workdiff --git a/packages/docs/reference/dom-css-mapping.md b/packages/docs/reference/dom-css-mapping.mdindex fa0cadc18..bb6e26cc4 100644--- a/packages/docs/reference/dom-css-mapping.md+++ b/packages/docs/reference/dom-css-mapping.md@@ -28,8 +28,9 @@ OpenPencil maps browser-computed DOM/CSS styles into SceneGraph fields through `| `border-style: dashed/dotted` | `dashPattern` | Unsupported border styles fall back to solid. || `border-radius`, `border-*-radius` | corner radii | Independent corners are preserved when sides differ. || `opacity` | node opacity | Numeric computed value. |-| `box-shadow` | drop shadow | Simple shadows only; see parser audit before expanding. |-| `<img src="data:...">` | image fill | Data URL images are stored in the graph image map. External URL fetching is not performed. |+| `box-shadow` | drop shadow | First simple outer shadow only; see parser audit before expanding. |+| `<img src="data:...">` | image fill | Data URL images are stored in the graph image map. |+| `<img src="https://...">` | preserved source URL metadata | External URL fetching is not performed; the URL is retained for HTML round-trip. || `object-fit: contain/cover` | image `FIT` / `FILL` scale mode | `scale-down` maps to `FIT`; other object-fit values are not mapped yet. |## Textdiff --git a/packages/dom-css/package.json b/packages/dom-css/package.jsonindex 01a6709da..e18175577 100644--- a/packages/dom-css/package.json+++ b/packages/dom-css/package.json@@ -71,6 +71,7 @@"dependencies": {"@acemir/cssom": "^0.9.31","parse5": "^8.0.1",+ "postcss-value-parser": "^4.2.0","tailwindcss": "^4.2.1"}}diff --git a/packages/dom-css/src/css-values.ts b/packages/dom-css/src/css-values.tsindex 2d691e322..ca359dec3 100644--- a/packages/dom-css/src/css-values.ts+++ b/packages/dom-css/src/css-values.ts@@ -1,3 +1,5 @@+import valueParser, { type ParsedNode } from 'postcss-value-parser'+import { colorToCSS, parseColor } from '@open-pencil/core/color'import type { Effect, Fill, SceneNode, Stroke } from '@open-pencil/core/scene-graph'import type { Color } from '@open-pencil/core/types'@@ -59,22 +61,47 @@ export function dropShadowToCSS(effect: Effect | undefined): string | undefinedreturn `${effect.offset.x}px ${effect.offset.y}px ${effect.radius}px ${effect.spread}px ${colorToCSS({ ...effect.color, a: effect.color.a })}`}+function firstShadowLayerNodes(value: string): ParsedNode[] {+ const nodes: ParsedNode[] = []+ for (const node of valueParser(value).nodes) {+ if (node.type === 'div' && node.value === ',') return nodes+ nodes.push(node)+ }+ return nodes+}++function shadowColorFromNodes(nodes: ParsedNode[]): Color | null {+ for (const node of nodes) {+ if (node.type === 'function') {+ const color = parseCSSColor(valueParser.stringify(node))+ if (color) return color+ continue+ }++ if (node.type !== 'word') continue+ const color = parseCSSColor(node.value)+ if (color) return color+ }+ return null+}++function shadowNumbersFromNodes(nodes: ParsedNode[]): number[] {+ return nodes+ .filter((node) => node.type === 'word' && valueParser.unit(node.value) !== false)+ .map((node) => parseCSSNumber(node.value))+ .filter((number): number is number => number !== null)+}+export function dropShadowFromCSS(value: string | undefined): Effect[] {if (!value || value.trim() === 'none') return []- const colorMatch = value.match(- /(?:rgba?|hsla?)\([^)]*\)|#[\da-fA-F]{3,8}|\b(?:black|white|red|green|blue)\b/- )- const color = parseCSSColor(colorMatch?.[0])+ const nodes = firstShadowLayerNodes(value)+ if (nodes.some((node) => node.type === 'word' && node.value === 'inset')) return []++ const color = shadowColorFromNodes(nodes)if (!color) return []- const numericPart = colorMatch ? value.replace(colorMatch[0], '') : value- const numbers = numericPart- .trim()- .split(/\s+/)- .map(parseCSSNumber)- .filter((number): number is number => number !== null)- const [offsetX = 0, offsetY = 0, radius = 0, spread = 0] = numbers+ const [offsetX = 0, offsetY = 0, radius = 0, spread = 0] = shadowNumbersFromNodes(nodes)return [{diff --git a/packages/dom-css/src/from-scene-graph.ts b/packages/dom-css/src/from-scene-graph.tsindex 85b3fd4de..0bd872174 100644--- a/packages/dom-css/src/from-scene-graph.ts+++ b/packages/dom-css/src/from-scene-graph.ts@@ -11,6 +11,9 @@ import {} from './css-values'import type { DesignDocument, DesignNode, DesignStyleDeclaration } from './types'+const DOM_CSS_PLUGIN_ID = 'open-pencil-dom-css'+const IMAGE_SOURCE_URL_KEY = 'image-source-url'+export interface SceneGraphToDesignOptions {rootId?: stringincludeSourceIds?: boolean@@ -143,8 +146,8 @@ function addFlexGap(style: DesignStyleDeclaration, node: SceneNode): void {}function addImageStyle(style: DesignStyleDeclaration, node: SceneNode): void {- const fill = node.fills[0]- if (fill.type !== 'IMAGE' || !fill.visible) return+ const fill = node.fills.at(0)+ if (fill?.type !== 'IMAGE' || !fill.visible) returnif (node.width > 0 && node.height > 0) style['aspect-ratio'] = `${node.width} / ${node.height}`if (fill.imageScaleMode === 'FIT') style['object-fit'] = 'contain'if (fill.imageScaleMode === 'FILL') style['object-fit'] = 'cover'@@ -154,7 +157,7 @@ function styleFromSceneNode(node: SceneNode): DesignStyleDeclaration {const style = sceneNodeSizeStyle(node)addPositioning(style, node)addSizeConstraints(style, node)- const fill = fillToCSS(node.fills[0])+ const fill = fillToCSS(node.fills.at(0))if (fill) style['background-color'] = filladdImageStyle(style, node)addStroke(style, node)@@ -184,7 +187,7 @@ function styleFromSceneNode(node: SceneNode): DesignStyleDeclaration {function styleFromTextNode(node: SceneNode): DesignStyleDeclaration {const style = sceneNodeSizeStyle(node)addPositioning(style, node)- style.color = fillToCSS(node.fills[0]) ?? colorToCSS(BLACK)+ style.color = fillToCSS(node.fills.at(0)) ?? colorToCSS(BLACK)style['font-family'] = node.fontFamilystyle['font-size'] = `${node.fontSize}px`style['font-weight'] = String(node.fontWeight)@@ -212,6 +215,12 @@ function bytesToBase64(bytes: Uint8Array): string {return globalThis.btoa(binary)}+function imageSourceURL(node: SceneNode): string | undefined {+ return node.pluginData.find(+ (entry) => entry.pluginId === DOM_CSS_PLUGIN_ID && entry.key === IMAGE_SOURCE_URL_KEY+ )?.value+}+function attrsForNode(graph: SceneGraph,node: SceneNode,@@ -220,16 +229,18 @@ function attrsForNode(const attrs: Record<string, string> = includeSourceIds? { 'data-open-pencil-node-id': node.id }: {}- const fill = node.fills[0]- if (fill.type !== 'IMAGE' || !fill.imageHash) return attrs+ const sourceURL = imageSourceURL(node)+ if (sourceURL) attrs.src = sourceURL+ const fill = node.fills.at(0)+ if (fill?.type !== 'IMAGE' || !fill.imageHash) return attrsconst bytes = graph.images.get(fill.imageHash)if (!bytes) return attrsreturn { ...attrs, src: `data:image/png;base64,${bytesToBase64(bytes)}` }}function tagNameForNode(node: SceneNode): string {- const fill = node.fills[0]- if (fill.type === 'IMAGE' && node.childIds.length === 0) return 'img'+ const fill = node.fills.at(0)+ if ((fill?.type === 'IMAGE' || imageSourceURL(node)) && node.childIds.length === 0) return 'img'return 'div'}diff --git a/packages/dom-css/src/postcss-value-parser.d.ts b/packages/dom-css/src/postcss-value-parser.d.tsnew file mode 100644index 000000000..72140fef5--- /dev/null+++ b/packages/dom-css/src/postcss-value-parser.d.ts@@ -0,0 +1,34 @@+declare module 'postcss-value-parser' {+ export interface ParsedNodeBase {+ type: string+ value: string+ before?: string+ after?: string+ sourceIndex?: number+ }++ export interface FunctionNode extends ParsedNodeBase {+ type: 'function'+ nodes: ParsedNode[]+ }++ export type ParsedNode = ParsedNodeBase | FunctionNode++ export interface ParsedValue {+ nodes: ParsedNode[]+ }++ export interface ParsedUnit {+ number: string+ unit: string+ }++ interface ValueParser {+ (value: string): ParsedValue+ stringify(node: ParsedNode | ParsedNode[]): string+ unit(value: string): ParsedUnit | false+ }++ const valueParser: ValueParser+ export default valueParser+}diff --git a/packages/dom-css/src/to-scene-graph.ts b/packages/dom-css/src/to-scene-graph.tsindex 31829cdf3..f5820b0f3 100644--- a/packages/dom-css/src/to-scene-graph.ts+++ b/packages/dom-css/src/to-scene-graph.ts@@ -18,6 +18,9 @@ import {} from './css-values'import type { DesignDocument, DesignElement, DesignNode, DesignStyleDeclaration } from './types'+const DOM_CSS_PLUGIN_ID = 'open-pencil-dom-css'+const IMAGE_SOURCE_URL_KEY = 'image-source-url'+export interface DesignDocumentToSceneGraphOptions {pageName?: string}@@ -247,8 +250,19 @@ function applyImageFill(style: DesignStyleDeclaration): void {if (element.tagName.toLowerCase() !== 'img') return- const bytes = bytesFromDataURL(element.attrs.src)- if (!bytes) return+ const source = element.attrs.src+ const bytes = bytesFromDataURL(source)+ if (!bytes) {+ if (source) {+ node.pluginData.push({+ pluginId: DOM_CSS_PLUGIN_ID,+ key: IMAGE_SOURCE_URL_KEY,+ value: source+ })+ }+ return+ }+const imageHash = computeImageHash(bytes)graph.images.set(imageHash, bytes)node.fills = [diff --git a/packages/dom-css/tests/conversion.test.ts b/packages/dom-css/tests/conversion.test.tsindex 623257c1a..7c872ff19 100644--- a/packages/dom-css/tests/conversion.test.ts+++ b/packages/dom-css/tests/conversion.test.ts@@ -50,7 +50,7 @@ function createStyleRoundTripGraph() {'border-bottom-width': '0px','border-left-width': '4px',opacity: '0.75',- 'box-shadow': `0px 8px 24px 0px ${TEST_COLORS.slateShadow}`+ 'box-shadow': `0px 8px 24px 0px ${TEST_COLORS.slateShadow}, 0 0 2px ${TEST_COLORS.slate200}`},children: [{@@ -257,6 +257,41 @@ describe('@open-pencil/dom-css conversion', () => {expect(card.strokes[0]?.weight).toBe(1)})+ it('preserves external image URLs without fetching bytes', () => {+ const graph = designDocumentToSceneGraph({+ type: 'document',+ children: [+ {+ type: 'element',+ tagName: 'img',+ attrs: { src: 'https://example.com/hero.png' },+ computedStyle: { width: '320px', height: '180px', 'object-fit': 'cover' },+ children: []+ }+ ]+ })+ const page = graph.getPages()[0]+ const image = expectFrame(page ? graph.getChildren(page.id)[0] : undefined)++ expect(image.fills[0]).toBeUndefined()+ expect(image.pluginData).toContainEqual({+ pluginId: 'open-pencil-dom-css',+ key: 'image-source-url',+ value: 'https://example.com/hero.png'+ })+ expect(graph.images.size).toBe(0)++ const roundTrip = sceneGraphToDesignDocument(graph)+ const root = roundTrip.children[0]+ expect(root?.type).toBe('element')+ if (root?.type !== 'element') throw new Error('Expected root element')+ const roundTripImage = root.children[0]+ expect(roundTripImage?.type).toBe('element')+ if (roundTripImage?.type !== 'element') throw new Error('Expected image element')+ expect(roundTripImage.tagName).toBe('img')+ expect(roundTripImage.attrs.src).toBe('https://example.com/hero.png')+ })+it('maps data URL images, object fit, and aspect ratio', () => {const graph = designDocumentToSceneGraph({type: 'document',diff --git a/packages/fig/README.md b/packages/fig/README.mdindex 34fc9cfac..8abd34667 100644--- a/packages/fig/README.md+++ b/packages/fig/README.md@@ -2,7 +2,12 @@`.fig` document policy package for OpenPencil.-This package is currently a scaffold for the next package-split stage. Use `@open-pencil/core` for production `.fig` read/write APIs until behavior moves here.+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.++Current ownership:++- `readFigContainer()` / `writeFigContainer()` wrappers over `@open-pencil/kiwi` container helpers+- `.fig` document source typingPlanned ownership:diff --git a/packages/fig/scripts/smoke-dist.ts b/packages/fig/scripts/smoke-dist.tsindex 466cc953d..92e432415 100644--- a/packages/fig/scripts/smoke-dist.ts+++ b/packages/fig/scripts/smoke-dist.ts@@ -2,6 +2,16 @@ export {}const mod = await import('../dist/index.js')-if (mod.FIG_PACKAGE_STATUS !== 'scaffold') {- throw new Error('Expected @open-pencil/fig scaffold export')+if (mod.FIG_PACKAGE_STATUS !== 'container-api') {+ throw new Error('Expected @open-pencil/fig container API export')+}++const bytes = mod.writeFigContainer({+ schemaDeflated: new Uint8Array([1]),+ dataRaw: new Uint8Array([2])+})+const document = mod.readFigContainer(bytes)++if (document.dataRaw[0] !== 2) {+ throw new Error('Expected @open-pencil/fig container round-trip')}diff --git a/packages/fig/src/index.ts b/packages/fig/src/index.tsindex 6d2b507cc..ce79fbd94 100644--- a/packages/fig/src/index.ts+++ b/packages/fig/src/index.ts@@ -1,3 +1,10 @@+import {+ FIG_KIWI_DEFAULT_VERSION,+ buildFigKiwi,+ decompressFigKiwiData,+ parseFigKiwiChunks+} from '@open-pencil/kiwi/fig/container'+export interface FigDocumentSource {readonly bytes?: Uint8Arrayreadonly fileName?: string@@ -16,10 +23,49 @@ export interface WriteFigOptions {readonly source?: FigDocumentSource}-export const FIG_PACKAGE_STATUS = 'scaffold' as const+export interface FigContainerDocument {+ readonly schemaDeflated: Uint8Array+ readonly dataRaw: Uint8Array+ readonly source?: FigDocumentSource+}++export interface ReadFigContainerOptions {+ readonly fileName?: string+}++export interface WriteFigContainerOptions {+ readonly version?: number+}++export const FIG_PACKAGE_STATUS = 'container-api' as const++export function readFigContainer(+ bytes: Uint8Array,+ options: ReadFigContainerOptions = {}+): FigContainerDocument {+ const chunks = parseFigKiwiChunks(bytes)+ if (!chunks) throw new Error('Invalid fig-kiwi container')+ const [schemaDeflated, dataDeflated] = chunks+ return {+ schemaDeflated,+ dataRaw: decompressFigKiwiData(dataDeflated),+ source: { bytes, fileName: options.fileName }+ }+}++export function writeFigContainer(+ document: FigContainerDocument,+ options: WriteFigContainerOptions = {}+): Uint8Array {+ return buildFigKiwi(+ document.schemaDeflated,+ document.dataRaw,+ options.version ?? FIG_KIWI_DEFAULT_VERSION+ )+}export function assertFigPackageReady(): void {throw new Error(- '@open-pencil/fig is scaffolded for package-boundary work; use @open-pencil/core for .fig read/write APIs for now.'+ '@open-pencil/fig currently exposes low-level 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.tsindex fd0697033..442f2be62 100644--- a/packages/fig/tests/index.test.ts+++ b/packages/fig/tests/index.test.ts@@ -1,13 +1,35 @@import { describe, expect, it } from 'bun:test'-import { FIG_PACKAGE_STATUS, assertFigPackageReady } from '../src/index'+import {+ FIG_PACKAGE_STATUS,+ assertFigPackageReady,+ readFigContainer,+ writeFigContainer+} from '../src/index'-describe('@open-pencil/fig package shell', () => {- it('exports scaffold status', () => {- expect(FIG_PACKAGE_STATUS).toBe('scaffold')+describe('@open-pencil/fig package API', () => {+ it('exports container API status', () => {+ expect(FIG_PACKAGE_STATUS).toBe('container-api')})- it('directs consumers to core until behavior moves', () => {- expect(() => assertFigPackageReady()).toThrow('@open-pencil/fig is scaffolded')+ it('round-trips fig-kiwi container bytes', () => {+ const bytes = writeFigContainer({+ schemaDeflated: new Uint8Array([1, 2, 3]),+ dataRaw: new Uint8Array([4, 5, 6])+ })+ const document = readFigContainer(bytes, { fileName: 'fixture.fig' })++ expect(document.schemaDeflated).toEqual(new Uint8Array([1, 2, 3]))+ expect(document.dataRaw).toEqual(new Uint8Array([4, 5, 6]))+ expect(document.source?.bytes).toBe(bytes)+ expect(document.source?.fileName).toBe('fixture.fig')+ })++ 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')})})diff --git a/tests/engine/io/fig/roundtrip/source-metadata.test.ts b/tests/engine/io/fig/roundtrip/source-metadata.test.tsindex 08fd0135b..aa221aea3 100644--- a/tests/engine/io/fig/roundtrip/source-metadata.test.ts+++ b/tests/engine/io/fig/roundtrip/source-metadata.test.ts@@ -337,6 +337,26 @@ describe('fig roundtrip source metadata', () => {expect(rect.source.fig.rawNodeFields.effects).toBeUndefined()})+ test('clears raw geometry payloads when independent stroke weights are edited', () => {+ const graph = new SceneGraph()+ const page = graph.getPages()[0]+ const rect = graph.createNode('RECTANGLE', page.id, { name: 'Independent stroke metadata' })+ rect.source.format = 'fig'+ rect.source.id = '4:507'+ rect.source.fig.rawNodeFields.fillGeometry = [{ windingRule: 'NONZERO', commands: [] }]+ rect.source.fig.rawNodeFields.strokeGeometry = [{ windingRule: 'NONZERO', commands: [] }]++ graph.updateNode(rect.id, {+ independentStrokeWeights: true,+ borderTopWeight: 2,+ borderRightWeight: 4,+ borderBottomWeight: 6,+ borderLeftWeight: 8+ })++ expect(rect.source.fig.rawNodeFields).toEqual({})+ })+test('clears raw font variation payloads when normalized axes are edited', async () => {const graph = new SceneGraph()const page = graph.getPages()[0]diff --git a/tools/package-quality/src/smoke.ts b/tools/package-quality/src/smoke.tsindex 53b95f685..03ab9299d 100644--- a/tools/package-quality/src/smoke.ts+++ b/tools/package-quality/src/smoke.ts@@ -89,13 +89,17 @@ try {tempDir)nodeEval(- "const { FIG_PACKAGE_STATUS } = await import('@open-pencil/fig'); if (FIG_PACKAGE_STATUS !== 'scaffold') throw new Error('Fig package smoke failed')",+ "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')",tempDir)nodeEval("const { htmlToSceneGraph } = await import('@open-pencil/dom-css'); const graph = await htmlToSceneGraph('<div class=card>OpenPencil</div>', { cssText: '.card { width: 320px; }' }); if (graph.getPages()[0].width !== 320) throw new Error('DOM/CSS scene graph smoke failed')",tempDir)+ nodeEval(+ "const browser = await import('@open-pencil/dom-css/browser'); for (const key of ['browserHTMLToDesignDocument', 'browserHTMLToSceneGraph', 'browserTailwindJSXToSceneGraph']) if (typeof browser[key] !== 'function') throw new Error('DOM/CSS browser export missing: ' + key)",+ tempDir+ )nodeEval("const { jsx, jsxToDesignDocument } = await import('@open-pencil/dom-css/jsx-runtime'); const document = await jsxToDesignDocument(jsx('section', { class: 'card', style: { width: '120px' }, children: 'OpenPencil' })); const node = document.children[0]; if (node?.type !== 'element' || node.inlineStyle?.width !== '120px') throw new Error('DOM/CSS JSX runtime smoke failed')",tempDir