AI-native design editor. Open-source Figma alternative.
import type { SceneGraph, SceneNode } from '@open-pencil/scene-graph'
import type { ShaderPreset } from '@open-pencil/scene-graph/shaders'
import type { DesignTokens } from './tokens/references'
export type DesignNode = DesignElement | DesignText
export interface DesignDocument {
type: 'document'
children: DesignNode[]
stylesheets?: DesignStyleSheet[]
sourceGraph?: SceneGraph
/** Variable references the projection wrote, for Tailwind names and the token stylesheet. */
tokens?: DesignTokens
}
export interface DesignElement {
type: 'element'
tagName: string
attrs: Record<string, string>
children: DesignNode[]
inlineStyle?: DesignStyleDeclaration
computedStyle?: DesignStyleDeclaration
sourceSceneNodeId?: string
sourceSceneNode?: SceneNode
/**
* The shader the layer fills with, which plays behind its content: a framework draws it with
* the `shaders` library, static HTML shows `frame`, its still frame as a data URL.
*/
shader?: { preset: ShaderPreset; frame?: string }
}
export interface DesignText {
type: 'text'
text: string
}
export interface DesignStyleSheet {
type: 'stylesheet'
cssText: string
href?: string
}
export type DesignStyleDeclaration = Record<string, string>
export interface CSSComputeOptions {
includeBrowserDefaults?: boolean
}
export interface CSSRuntime {
readonly kind: 'browser' | 'headless'
parseHTML(html: string): DesignDocument
serializeHTML(document: DesignDocument): string
computeStyles(
document: DesignDocument,
cssText?: string,
options?: CSSComputeOptions
): Promise<DesignDocument>
}