import { ShaderPreset } from "@open-pencil/scene-graph/shaders"; import { SceneGraph, SceneNode } from "@open-pencil/scene-graph"; import { Rect } from "@open-pencil/scene-graph/primitives"; //#region src/import/font-faces.d.ts /** A stylesheet's `@font-face` rule: the face it declares and the files it loads from. */ interface CSSFontFaceRule { family: string; /** The rule's weight; for a variable font's range, 400 when the range holds it. */ weight: number; italic: boolean; /** The `src` URLs in the rule's order, resolved against the stylesheet's URL when it has one. */ sources: string[]; } /** * The `@font-face` rules of a stylesheet, wherever they sit in it, with their URLs resolved * against `baseURL`. A rule without a family or a source is left out. */ declare function parseFontFaceRules(cssText: string, baseURL?: string): CSSFontFaceRule[]; /** The URLs a stylesheet's `@import` rules load, resolved against `baseURL`, in order. */ declare function parseStylesheetImports(cssText: string, baseURL?: string): string[]; //#endregion //#region src/tokens/references.d.ts /** The mode CSS applies for each collection, by collection id. */ type CSSModes = ReadonlyMap; /** * Variable references for design-to-code. A bound field becomes `var(--name)` only when the * stylesheet resolves it to what the canvas draws: the element sits in the same modes, and the * token's CSS value is a length for a length, a bare number for opacity, or the paint's color. * Anything else keeps its literal value. */ declare class DesignTokens { #private; readonly names: ReadonlyMap; /** Tokens the output references, with every variable their aliases reach. */ readonly used: Set; constructor(graph: SceneGraph); /** The modes CSS applies outside the exported nodes: every collection's default. */ defaultModes(): CSSModes; /** * Attributes that put an element in the modes the canvas draws it in, and the modes CSS then * applies to it. An exported root takes the modes it is in; below it, a node changes * modes only where it sets one. Only a mode without its own condition can be set this way. */ enter(node: SceneNode, inherited: CSSModes, root: boolean): { attrs: Record; modes: CSSModes; }; /** `var(--name)` for a bound field, or `undefined` where the literal value must stay. */ reference(node: SceneNode, field: string, modes: CSSModes): string | undefined; /** * The variables a stylesheet for this output declares: the referenced ones and every variable * their aliases reach in any mode, since each mode's scope declares its own alias targets. */ stylesheetVariables(): Set; /** Custom properties the Tailwind stylesheet declares in `@theme`, which name utilities. */ themeVariables(): string[]; } //#endregion //#region src/types.d.ts type DesignNode = DesignElement | DesignText; interface DesignDocument { type: 'document'; children: DesignNode[]; stylesheets?: DesignStyleSheet[]; /** * The `@font-face` rules of the page's stylesheets, linked and imported ones included, for a * host to load the faces its text is set in. */ fontFaces?: CSSFontFaceRule[]; /** * The color the page's canvas is painted: the root element's background, or the body's when the * root has none, as CSS paints it; none when neither has one, which a browser shows as white. */ background?: string; sourceGraph?: SceneGraph; /** Variable references the projection wrote, for Tailwind names and the token stylesheet. */ tokens?: DesignTokens; } interface DesignElement { type: 'element'; tagName: string; attrs: Record; children: DesignNode[]; inlineStyle?: DesignStyleDeclaration; computedStyle?: DesignStyleDeclaration; /** Where the engine that computed the styles laid the element out, when it was asked to. */ layout?: DesignLayout; /** The picture an `` shows, as the runtime that styled the page loaded it. */ image?: DesignResource; /** * The pictures its `background-image` layers show, as the runtime that styled the page loaded * them, each by the address its computed `url()` names. */ backgroundImages?: DesignResource[]; 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; }; } /** A file a page loads, such as a stylesheet, a font, or a picture, as its host fetched it. */ interface DesignResource { /** Where it came from, after redirects. */ url: string; bytes: Uint8Array; /** Its media type without parameters, such as `image/svg+xml`, when the host knows it. */ contentType?: string; } /** * Fetches a file a page loads; null when it cannot. `signal` aborts when the request runs out of * time, and styling goes on without it. */ type DesignResourceFetch = (url: string, signal: AbortSignal) => Promise; interface DesignText { type: 'text'; text: string; } interface DesignStyleSheet { type: 'stylesheet'; cssText: string; href?: string; } type DesignStyleDeclaration = Record; /** * An element as laid out, in CSS pixels from the top-left of the document, before transforms, * which move what is drawn but not the layout. `fragments` are an inline element's boxes, one per * line it spans, and `lines` are the line boxes of the text it holds directly or through its * inline descendants. */ interface DesignLayout { box: Rect; fragments?: Rect[]; lines?: Rect[]; } /** The viewport an engine lays the document out in; `height` resolves `vh` units. */ interface DesignViewport { width: number; height: number; } interface CSSComputeOptions { includeBrowserDefaults?: boolean; /** Record where each element is laid out as well as its computed style. */ layout?: boolean; viewport?: DesignViewport; } interface CSSRuntime { readonly kind: 'browser' | 'headless'; parseHTML(html: string): DesignDocument; serializeHTML(document: DesignDocument): string; computeStyles(document: DesignDocument, cssText?: string, options?: CSSComputeOptions): Promise; } //#endregion export { CSSComputeOptions, CSSFontFaceRule, CSSRuntime, DesignDocument, DesignElement, DesignLayout, DesignNode, DesignResource, DesignResourceFetch, DesignStyleDeclaration, DesignStyleSheet, DesignText, DesignViewport, parseFontFaceRules, parseStylesheetImports }; //# sourceMappingURL=types.d.ts.map