UNPKG

modern-idoc

Version:

Intermediate document for modern codec libs

906 lines (838 loc) 34.3 kB
import { Colord } from 'colord'; interface NormalizedAudio { src: string; } type Audio = string | NormalizedAudio; declare function normalizeAudio(audio: Audio): NormalizedAudio | undefined; interface RgbColor { r: number; g: number; b: number; } interface HslColor { h: number; s: number; l: number; } interface HsvColor { h: number; s: number; v: number; } interface HwbColor { h: number; w: number; b: number; } interface XyzColor { x: number; y: number; z: number; } interface LabColor { l: number; a: number; b: number; } interface LchColor { l: number; c: number; h: number; } interface CmykColor { c: number; m: number; y: number; k: number; } type WithAlpha<O> = O & { a: number; }; type RgbaColor = WithAlpha<RgbColor>; type HslaColor = WithAlpha<HslColor>; type HsvaColor = WithAlpha<HsvColor>; type HwbaColor = WithAlpha<HwbColor>; type XyzaColor = WithAlpha<XyzColor>; type LabaColor = LabColor & { alpha: number; }; type LchaColor = WithAlpha<LchColor>; type CmykaColor = WithAlpha<CmykColor>; type ObjectColor = RgbColor | RgbaColor | HslColor | HslaColor | HsvColor | HsvaColor | HwbColor | HwbaColor | XyzColor | XyzaColor | LabColor | LabaColor | LchColor | LchaColor | CmykColor | CmykaColor; type Uint32Color = number; type Color = Uint32Color | ObjectColor | string; type Hex8Color = string; type NormalizedColor = Hex8Color; declare function parseColor(color: Color): Colord; declare const defaultColor: NormalizedColor; declare function isColor(value: string): boolean; declare function normalizeColor(color: Color, orFail?: boolean): NormalizedColor; interface ColorStop { offset: number; color: NormalizedColor; } interface LinearGradient { angle: number; stops: ColorStop[]; repeat?: boolean; } type LinearGradientWithType = LinearGradient & { type: 'linear-gradient'; }; interface RadialGradient { stops: ColorStop[]; repeat?: boolean; } type RadialGradientWithType = RadialGradient & { type: 'radial-gradient'; }; declare function isGradient(cssText: string): boolean; declare function normalizeGradient(cssText: string): (LinearGradientWithType | RadialGradientWithType)[]; interface LinearGradientNode { type: 'linear-gradient' orientation?: DirectionalNode | AngularNode | undefined colorStops: ColorStopNode[] } interface RepeatingLinearGradientNode { type: 'repeating-linear-gradient' orientation?: DirectionalNode | AngularNode | undefined colorStops: ColorStopNode[] } interface RadialGradientNode { type: 'radial-gradient' orientation?: (ShapeNode | DefaultRadialNode | ExtentKeywordNode)[] | undefined colorStops: ColorStopNode[] } interface RepeatingRadialGradientNode { type: 'repeating-radial-gradient' orientation?: (ShapeNode | DefaultRadialNode | ExtentKeywordNode)[] | undefined colorStops: ColorStopNode[] } interface DirectionalNode { type: 'directional' value: | 'left' | 'top' | 'bottom' | 'right' | 'left top' | 'top left' | 'left bottom' | 'bottom left' | 'right top' | 'top right' | 'right bottom' | 'bottom right' } interface AngularNode { type: 'angular' value: string } interface LiteralNode { type: 'literal' value: string length?: PxNode | EmNode | PercentNode | undefined } interface HexNode { type: 'hex' value: string length?: PxNode | EmNode | PercentNode | undefined } interface RgbNode { type: 'rgb' value: [string, string, string] length?: PxNode | EmNode | PercentNode | undefined } interface RgbaNode { type: 'rgba' value: [string, string, string, string?] length?: PxNode | EmNode | PercentNode | undefined } interface ShapeNode { type: 'shape' style?: ExtentKeywordNode | PxNode | EmNode | PercentNode | PositionKeywordNode | undefined value: 'ellipse' | 'circle' at?: PositionNode | undefined } interface DefaultRadialNode { type: 'default-radial' at: PositionNode } interface PositionKeywordNode { type: 'position-keyword' value: 'center' | 'left' | 'top' | 'bottom' | 'right' } interface PositionNode { type: 'position' value: { x: ExtentKeywordNode | PxNode | EmNode | PercentNode | PositionKeywordNode y: ExtentKeywordNode | PxNode | EmNode | PercentNode | PositionKeywordNode } } interface ExtentKeywordNode { type: 'extent-keyword' value: 'closest-side' | 'closest-corner' | 'farthest-side' | 'farthest-corner' | 'contain' | 'cover' at?: PositionNode | undefined } interface PxNode { type: 'px' value: string } interface EmNode { type: 'em' value: string } interface PercentNode { type: '%' value: string } type ColorStopNode = LiteralNode | HexNode | RgbNode | RgbaNode type GradientNode = LinearGradientNode | RepeatingLinearGradientNode | RadialGradientNode | RepeatingRadialGradientNode declare function parseGradient(cssText: string): GradientNode[] declare function stringifyGradient(ast: GradientNode[]): string interface ColorFillObject { color: Color; } type ColorFill = string | ColorFillObject; interface NormalizedColorFill { color: NormalizedColor; } declare function normalizeColorFill(fill: ColorFill): NormalizedColorFill; type GradientFillObject = { image?: string; } & Partial<NormalizedGradientFill>; type GradientFill = string | GradientFillObject; interface NormalizedGradientFill { linearGradient?: LinearGradient; radialGradient?: RadialGradient; rotateWithShape?: boolean; } declare function normalizeGradientFill(fill: GradientFill): NormalizedGradientFill; /** * 0 -0.5 0 * -0.5 -0.5 * 0 -0.5 0 */ interface ImageFillCropRect { left?: number; top?: number; bottom?: number; right?: number; } /** * 0 0.5 0 * 0.5 0.5 * 0 0.5 0 */ interface ImageFillStretchRect { left?: number; top?: number; bottom?: number; right?: number; } interface ImageFillTile { alignment?: string; scaleX?: number; scaleY?: number; translateX?: number; translateY?: number; flip?: string; } interface ImageFillObject { image: string; cropRect?: ImageFillCropRect; stretchRect?: ImageFillStretchRect; tile?: ImageFillTile; dpi?: number; opacity?: number; rotateWithShape?: boolean; } type ImageFill = string | ImageFillObject; interface NormalizedImageFill extends ImageFillObject { } declare function normalizeImageFill(fill: ImageFill): NormalizedImageFill; type None = undefined | null | 'none'; type WithNone<T> = T | None; type WithStyleNone<T> = T | 'none'; type LineCap = 'butt' | 'round' | 'square'; type LineJoin = 'miter' | 'round' | 'bevel'; interface PresetFillObject { preset: string; foregroundColor?: WithNone<Color>; backgroundColor?: WithNone<Color>; } type PresetFill = string | PresetFillObject; interface NormalizedPresetFill extends PresetFillObject { foregroundColor?: NormalizedColor; backgroundColor?: NormalizedColor; } declare function normalizePresetFill(fill: PresetFill): NormalizedPresetFill; type FillObject = { enabled?: boolean; } & Partial<ColorFillObject> & Partial<GradientFillObject> & Partial<ImageFillObject> & Partial<PresetFillObject>; type Fill = string | FillObject; type NormalizedFill = { enabled?: boolean; } & Partial<NormalizedColorFill> & Partial<NormalizedGradientFill> & Partial<NormalizedImageFill> & Partial<NormalizedPresetFill>; declare function isColorFillObject(fill: FillObject): fill is ColorFillObject; declare function isColorFill(fill: Fill): fill is ColorFill; declare function isGradientFillObject(fill: FillObject): fill is GradientFillObject; declare function isGradientFill(fill: Fill): fill is GradientFill; declare function isImageFillObject(fill: FillObject): fill is ImageFillObject; declare function isImageFill(fill: Fill): fill is ImageFill; declare function isPresetFillObject(fill: FillObject): fill is PresetFillObject; declare function isPresetFill(fill: Fill): fill is PresetFill; declare function normalizeFill(fill: Fill): NormalizedFill; interface NormalizedBaseBackground { fillWithShape?: boolean; } type NormalizedBackground = NormalizedFill & NormalizedBaseBackground; type BackgroundObject = FillObject & Partial<NormalizedBaseBackground>; type Background = string | BackgroundObject; declare function normalizeBackground(background: Background): NormalizedBackground; interface PropertyDeclaration { [key: string]: unknown; default?: unknown | (() => unknown); fallback?: unknown | (() => unknown); alias?: string; internal?: boolean; internalKey: symbol; } interface PropertyAccessor { getProperty?: (key: string) => any; setProperty?: (key: string, newValue: any) => void; onUpdateProperty?: (key: string, newValue: any, oldValue: any) => void; } declare function getDeclarations(constructor: any): Map<string, PropertyDeclaration>; declare function propertyOffsetSet(target: any & PropertyAccessor, key: string, newValue: any, declaration: PropertyDeclaration): void; declare function propertyOffsetGet(target: any & PropertyAccessor, key: string, declaration: PropertyDeclaration): any; declare function propertyOffsetDefaultValue(target: any & PropertyAccessor, key: string, declaration: PropertyDeclaration): any; declare function getPropertyDescriptor<V, T extends PropertyAccessor>(key: string, declaration: PropertyDeclaration): { get: () => any; set: (v: any) => void; }; declare function defineProperty<V, T extends PropertyAccessor>(constructor: any, key: string, declaration?: Partial<PropertyDeclaration>): void; declare function property<V, T extends PropertyAccessor>(declaration?: Partial<PropertyDeclaration>): PropertyDecorator; declare function property2<V, T extends PropertyAccessor>(declaration?: Partial<PropertyDeclaration>): (_: ClassAccessorDecoratorTarget<T, V>, context: ClassAccessorDecoratorContext) => ClassAccessorDecoratorResult<T, V>; interface NormalizedInnerShadow { color: NormalizedColor; offsetX: number; offsetY: number; blurRadius: number; } type InnerShadowObject = Partial<NormalizedInnerShadow> & { color?: WithNone<Color>; }; type InnerShadow = InnerShadowObject; declare function getDefaultInnerShadow(): NormalizedInnerShadow; declare function normalizeInnerShadow(shadow: InnerShadow): NormalizedInnerShadow; interface NormalizedBaseOuterShadow { scaleX: number; scaleY: number; } type NormalizedOuterShadow = NormalizedBaseOuterShadow & NormalizedInnerShadow; type OuterShadowObject = Partial<NormalizedBaseOuterShadow> & InnerShadowObject; type OuterShadow = OuterShadowObject; declare function getDefaultOuterShadow(): NormalizedOuterShadow; declare function normalizeOuterShadow(shadow: OuterShadow): NormalizedOuterShadow; interface NormalizedSoftEdge { radius: number; } type SoftEdge = NormalizedSoftEdge; declare function normalizeSoftEdge(softEdge: SoftEdge): NormalizedSoftEdge; interface NormalizedEffect { innerShadow?: NormalizedInnerShadow; outerShadow?: NormalizedOuterShadow; softEdge?: NormalizedSoftEdge; } interface EffectObject { innerShadow?: WithNone<InnerShadow>; outerShadow?: WithNone<OuterShadow>; softEdge?: WithNone<SoftEdge>; } type Effect = EffectObject; declare function normalizeEffect(effect: Effect): NormalizedEffect; interface NormalizedBaseForeground { fillWithShape?: boolean; } type NormalizedForeground = NormalizedBaseForeground & NormalizedFill; type ForegroundObject = Partial<NormalizedBaseForeground> & FillObject; type Foreground = string | ForegroundObject; declare function normalizeForeground(foreground: Foreground): NormalizedForeground | undefined; interface Meta { [key: string]: any; } interface Node<T = Meta> { name?: string; children?: Node[]; meta?: T; } type LineEndType = 'oval' | 'stealth' | 'triangle' | 'arrow' | 'diamond'; type LineEndSize = 'sm' | 'md' | 'lg'; interface HeadEnd { type: LineEndType; width?: WithNone<LineEndSize>; height?: WithNone<LineEndSize>; } interface TailEnd { type: LineEndType; width?: WithNone<LineEndSize>; height?: WithNone<LineEndSize>; } type OutlineStyle = 'dashed' | 'solid' | string; interface NormalizedBaseOutline { width?: number; style?: OutlineStyle; lineCap?: LineCap; lineJoin?: LineJoin; headEnd?: HeadEnd; tailEnd?: TailEnd; } type NormalizedOutline = NormalizedFill & NormalizedBaseOutline; type OutlineObject = FillObject & Partial<NormalizedBaseOutline>; type Outline = string | OutlineObject; declare function normalizeOutline(outline: Outline): NormalizedOutline; type BoxShadow = string; interface NormalizedShadow { color: NormalizedColor; offsetX?: number; offsetY?: number; blur?: number; } type ShadowObject = Partial<NormalizedShadow> & { color?: WithNone<Color>; }; type Shadow = BoxShadow | ShadowObject; declare function normalizeShadow(shadow: Shadow): NormalizedShadow; interface NormalizedShadowStyle { boxShadow: BoxShadow; shadowColor?: NormalizedColor; shadowOffsetX?: number; shadowOffsetY?: number; shadowBlur?: number; } declare function getDefaultShadowStyle(): NormalizedShadowStyle; type SVGPathData = string; type FillRule = 'nonzero' | 'evenodd'; type StrokeLinecap = 'butt' | 'round' | 'square'; type StrokeLinejoin = 'arcs' | 'bevel' | 'miter' | 'miter-clip' | 'round'; interface ShapePathStyle { [key: string]: any; opacity: number; visibility: string; shadowColor: NormalizedColor; shadowOffsetX: number; shadowOffsetY: number; shadowBlur: number; fill: string; fillOpacity: number; fillRule: FillRule; stroke: string; strokeOpacity: number; strokeWidth: number; strokeLinecap: StrokeLinecap; strokeLinejoin: StrokeLinejoin; strokeMiterlimit: number; strokeDasharray: number[]; strokeDashoffset: number; } interface ShapePath extends Partial<ShapePathStyle> { data: SVGPathData; } interface NormalizedShape { preset?: string; viewBox?: number[]; svg?: string; paths?: ShapePath[]; } type Shape = SVGPathData | SVGPathData[] | ShapePath[] | NormalizedShape; declare function normalizeShape(shape: Shape): NormalizedShape; type StyleUnit = `${number}%` | number; type Display = 'flex' | 'contents'; type Direction = 'inherit' | 'ltr' | 'rtl'; type Overflow = 'hidden' | 'visible'; type Visibility = 'hidden' | 'visible'; type FontWeight = 'normal' | 'bold' | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900; type FontStyle = 'normal' | 'italic' | 'oblique' | `oblique ${string}`; type FontKerning = WithStyleNone<'auto' | 'normal'>; type TextWrap = 'wrap' | 'nowrap'; type TextAlign = WithStyleNone<'center' | 'end' | 'left' | 'right' | 'start' | 'justify'>; type TextTransform = WithStyleNone<'uppercase' | 'lowercase'>; type TextOrientation = 'mixed' | 'upright' | 'sideways-right' | 'sideways'; type TextDecoration = WithStyleNone<'underline' | 'line-through' | 'overline'>; type VerticalAlign = 'baseline' | 'top' | 'middle' | 'bottom' | 'sub' | 'super' | 'text-top' | 'text-bottom'; type WritingMode = 'horizontal-tb' | 'vertical-lr' | 'vertical-rl'; type Align = 'auto' | 'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline' | 'space-between' | 'space-around' | 'space-evenly'; type FlexDirection = 'column' | 'column-reverse' | 'row' | 'row-reverse'; type FlexWrap = 'nowrap' | 'wrap' | 'Wrap-reverse'; type Justify = 'flex-start' | 'center' | 'flex-end' | 'space-between' | 'space-around' | 'space-evenly'; type Position = 'static' | 'relative' | 'absolute'; type BorderStyle = WithStyleNone<'dashed' | 'solid'>; type BoxSizing = 'border-box' | 'content-box'; type PointerEvents = 'auto' | 'none'; type ListStyleType = WithStyleNone<'disc'>; type ListStyleImage = WithStyleNone<string>; type ListStyleColormap = WithStyleNone<Record<string, string>>; type ListStyleSize = StyleUnit | `${number}rem` | 'cover'; type ListStylePosition = 'inside' | 'outside'; type HighlightLine = TextDecoration | 'outline'; type HighlightImage = WithStyleNone<string>; type HighlightReferImage = WithStyleNone<string>; type HighlightColormap = WithStyleNone<Record<string, string>>; type HighlightSize = StyleUnit | `${number}rem` | 'cover'; type HighlightThickness = StyleUnit; interface NormalizedLayoutStyle { overflow: Overflow; direction: Direction; display: Display; boxSizing: BoxSizing; width: StyleUnit | 'auto'; height: StyleUnit | 'auto'; maxHeight: StyleUnit; maxWidth: StyleUnit; minHeight: StyleUnit; minWidth: StyleUnit; position: Position; left: StyleUnit; top: StyleUnit; right: StyleUnit; bottom: StyleUnit; borderTop: string; borderLeft: string; borderRight: string; borderBottom: string; borderWidth: number; border: string; flex: number; flexBasis: StyleUnit | 'auto'; flexDirection: FlexDirection; flexGrow: number; flexShrink: number; flexWrap: FlexWrap; alignContent: Align; alignItems: Align; alignSelf: Align; justifyContent: Justify; gap: StyleUnit; marginTop: WithStyleNone<StyleUnit | 'auto'>; marginLeft: WithStyleNone<StyleUnit | 'auto'>; marginRight: WithStyleNone<StyleUnit | 'auto'>; marginBottom: WithStyleNone<StyleUnit | 'auto'>; margin: WithStyleNone<StyleUnit | 'auto'>; paddingTop: StyleUnit; paddingLeft: StyleUnit; paddingRight: StyleUnit; paddingBottom: StyleUnit; padding: StyleUnit; } declare function getDefaultLayoutStyle(): Partial<NormalizedLayoutStyle>; interface NormalizedTransformStyle { rotate: number; scaleX: number; scaleY: number; skewX: number; skewY: number; translateX: number; translateY: number; transform: WithStyleNone<string>; transformOrigin: string; } declare function getDefaultTransformStyle(): NormalizedTransformStyle; type BackgroundSize = 'contain' | 'cover' | string | 'stretch' | 'rigid'; type NormalizedElementStyle = Partial<NormalizedLayoutStyle> & NormalizedTransformStyle & NormalizedShadowStyle & { backgroundImage: WithStyleNone<string>; backgroundSize: BackgroundSize; backgroundColor: WithStyleNone<NormalizedColor>; backgroundColormap: WithStyleNone<Record<string, string>>; borderRadius: number; borderColor: WithStyleNone<NormalizedColor>; borderStyle: BorderStyle; outlineWidth: number; outlineOffset: number; outlineColor: WithStyleNone<NormalizedColor>; outlineStyle: string; visibility: Visibility; filter: string; opacity: number; pointerEvents: PointerEvents; maskImage: WithStyleNone<string>; }; declare function getDefaultElementStyle(): NormalizedElementStyle; interface NormalizedHighlight { image: HighlightImage; referImage: HighlightReferImage; colormap: HighlightColormap; line: HighlightLine; size: HighlightSize; thickness: HighlightThickness; } interface NormalizedHighlightStyle { highlight: Partial<NormalizedHighlight>; highlightImage: HighlightImage; highlightReferImage: HighlightReferImage; highlightColormap: HighlightColormap; highlightLine: HighlightLine; highlightSize: HighlightSize; highlightThickness: HighlightThickness; } declare function getDefaultHighlightStyle(): Required<NormalizedHighlightStyle>; interface NormalizedListStyle { type: ListStyleType; image: ListStyleImage; colormap: ListStyleColormap; size: ListStyleSize; position: ListStylePosition; } interface NormalizedListStyleStyle { listStyle: Partial<NormalizedListStyle>; listStyleType: ListStyleType; listStyleImage: ListStyleImage; listStyleColormap: ListStyleColormap; listStyleSize: ListStyleSize; listStylePosition: ListStylePosition; } declare function getDefaultListStyleStyle(): NormalizedListStyleStyle; type NormalizedTextInlineStyle = NormalizedHighlightStyle & { color: NormalizedColor; verticalAlign: VerticalAlign; letterSpacing: number; wordSpacing: number; fontSize: number; fontWeight: FontWeight; fontFamily: string; fontStyle: FontStyle; fontKerning: FontKerning; textTransform: TextTransform; textOrientation: TextOrientation; textDecoration: TextDecoration; }; declare function getDefaultTextInlineStyle(): Required<NormalizedTextInlineStyle>; type NormalizedTextLineStyle = NormalizedListStyleStyle & { writingMode: WritingMode; textWrap: TextWrap; textAlign: TextAlign; textIndent: number; lineHeight: number; }; declare function getDefaultTextLineStyle(): NormalizedTextLineStyle; interface NormalizedTextDrawStyle { textStrokeWidth: number; textStrokeColor: NormalizedColor; } type NormalizedTextStyle = NormalizedTextLineStyle & NormalizedTextInlineStyle & NormalizedTextDrawStyle; declare function getDefaultTextStyle(): Required<NormalizedTextStyle>; type FullStyle = NormalizedTextStyle & NormalizedElementStyle; type NormalizedStyle = Partial<FullStyle>; type StyleObject = NormalizedStyle & { color?: WithStyleNone<Color>; backgroundColor?: WithStyleNone<Color>; borderColor?: WithStyleNone<Color>; outlineColor?: WithStyleNone<Color>; shadowColor?: WithStyleNone<Color>; }; type Style = StyleObject; declare function normalizeStyle(style: Style): NormalizedStyle; declare function getDefaultStyle(): FullStyle; interface FragmentObject extends StyleObject { content: string; fill?: Fill; outline?: Outline; } interface NormalizedFragment extends NormalizedStyle { content: string; fill?: NormalizedFill; outline?: NormalizedOutline; } interface ParagraphObject extends StyleObject { fragments: FragmentObject[]; fill?: Fill; outline?: Outline; } interface NormalizedParagraph extends NormalizedStyle { fragments: NormalizedFragment[]; fill?: NormalizedFill; outline?: NormalizedOutline; } type FlatTextContent = string | FragmentObject | ParagraphObject | (string | FragmentObject)[]; type TextContent = FlatTextContent | FlatTextContent[]; type NormalizedTextContent = NormalizedParagraph[]; interface TextObject { content?: TextContent; enabled?: boolean; style?: Style; effects?: Style[]; measureDom?: any; fonts?: any; fill?: Fill; outline?: Outline; } interface NormalizedText { content: NormalizedTextContent; enabled?: boolean; style?: NormalizedStyle; effects?: NormalizedStyle[]; measureDom?: any; fonts?: any; fill?: NormalizedFill; outline?: NormalizedOutline; } type Text = string | FlatTextContent[] | TextObject; declare function hasCRLF(content: string): boolean; declare function isCRLF(char: string): boolean; declare function normalizeCRLF(content: string): string; declare function normalizeTextContent(value: TextContent): NormalizedTextContent; declare function isParagraphObject(value: any): value is ParagraphObject; declare function isFragmentObject(value: any): value is FragmentObject; declare function normalizeText(value: Text): NormalizedText; declare function textContentToString(value: TextContent): string; interface NormalizedVideo { src: string; } type Video = string | NormalizedVideo; declare function normalizeVideo(video: Video): NormalizedVideo | undefined; interface Element<T = Meta> extends Omit<Node<T>, 'children'> { id?: string; style?: WithNone<Style>; text?: WithNone<Text>; background?: WithNone<Background>; shape?: WithNone<Shape>; fill?: WithNone<Fill>; outline?: WithNone<Outline>; foreground?: WithNone<Foreground>; shadow?: WithNone<Shadow>; video?: WithNone<Video>; audio?: WithNone<Audio>; effect?: WithNone<Effect>; children?: Element[]; } interface NormalizedElement<T = Meta> extends Omit<Node<T>, 'children'> { id: string; style?: NormalizedStyle; text?: NormalizedText; background?: NormalizedBackground; shape?: NormalizedShape; fill?: NormalizedFill; outline?: NormalizedOutline; foreground?: NormalizedForeground; shadow?: NormalizedShadow; video?: NormalizedVideo; audio?: NormalizedAudio; effect?: NormalizedEffect; children?: NormalizedElement[]; } declare function normalizeElement<T = Meta>(element: Element<T>): NormalizedElement<T>; interface Document extends Element { fonts?: any; } interface NormalizedDocument extends NormalizedElement { fonts?: any; } declare function normalizeDocument(doc: Document): NormalizedDocument; interface FlatElement extends Omit<Element, 'children'> { parentId?: string; childrenIds?: string[]; } interface FlatDocument extends Omit<Element, 'children'> { fonts?: any; children: Record<string, FlatElement>; } interface NormalizedFlatElement extends Omit<NormalizedElement, 'children'> { parentId?: string; childrenIds?: string[]; } interface NormalizedFlatDocument { fonts?: any; children: Record<string, NormalizedFlatElement>; } declare function normalizeFlatDocument(doc: FlatDocument): NormalizedFlatDocument; declare function flatDocumentToDocument(flatDoc: FlatDocument): Document; type IdGenerator = () => string; declare const nanoid: IdGenerator; declare const idGenerator: IdGenerator; type EventListenerValue<T extends any[] = any[]> = (...args: T) => void; type EventListenerOptions = boolean | { once?: boolean; }; interface EventListener$1<T extends any[] = any[]> { value: EventListenerValue<T>; options?: EventListenerOptions; } declare class EventEmitter<T extends Record<string, any> = Record<string, any>> { eventListeners: Map<keyof T, EventListener$1<any[]> | EventListener$1<any[]>[]>; addEventListener<K extends keyof T>(event: K, listener: EventListenerValue<T[K]>, options?: EventListenerOptions): this; removeEventListener<K extends keyof T>(event: K, listener: EventListenerValue<T[K]>, options?: EventListenerOptions): this; removeAllListeners(): this; hasEventListener(event: string): boolean; dispatchEvent<K extends keyof T>(event: K, ...args: T[K]): boolean; on<K extends keyof T>(event: K, listener: EventListenerValue<T[K]>, options?: EventListenerOptions): this; once<K extends keyof T>(event: K, listener: EventListenerValue<T[K]>): this; off<K extends keyof T>(event: K, listener: EventListenerValue<T[K]>, options?: EventListenerOptions): this; emit<K extends keyof T>(event: K, ...args: T[K]): void; } declare function isNone<T>(value: T): value is Extract<T, null | undefined | 'none'>; declare function round(number: number, digits?: number, base?: number): number; declare function clearUndef<T>(obj: T, deep?: boolean): T; declare function pick<T extends object, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>; declare function isEqualObject(a: any, b: any): boolean; declare function getNestedValue(obj: any, path: (string | number)[], fallback?: any): any; declare function setNestedValue(obj: any, path: (string | number)[], value: any): void; declare function getObjectValueByPath(obj: any, path: string, fallback?: any): any; declare function setObjectValueByPath(obj: any, path: string, value: any): void; type EventListener = (...args: any[]) => void; interface ObservableEvents { [event: string]: EventListener; } declare class Observable<T extends ObservableEvents = ObservableEvents> { _observers: Map<string, Set<any>>; on<K extends keyof T & string>(event: K, listener: T[K]): this; once<K extends keyof T & string>(event: K, listener: T[K]): this; off<K extends keyof T & string>(event: K, listener: T[K]): this; emit<K extends keyof T & string>(event: K, ...args: Parameters<T[K]>): this; destroy(): void; } declare class RawWeakMap<K extends WeakKey = WeakKey, V = any> { protected _map: WeakMap<K, V>; protected _toRaw(value: any): any; delete(key: K): boolean; get(key: K): V | undefined; has(key: K): boolean; set(key: K, value: V): this; } interface ReactivableEvents extends ObservableEvents { updateProperty: (key: string, newValue: any, oldValue: any) => void; } interface Reactivable { on: <K extends keyof ReactivableEvents & string>(event: K, listener: ReactivableEvents[K]) => this; once: <K extends keyof ReactivableEvents & string>(event: K, listener: ReactivableEvents[K]) => this; off: <K extends keyof ReactivableEvents & string>(event: K, listener: ReactivableEvents[K]) => this; emit: <K extends keyof ReactivableEvents & string>(event: K, ...args: Parameters<ReactivableEvents[K]>) => this; } declare class Reactivable extends Observable implements PropertyAccessor { protected _propertyAccessor?: PropertyAccessor; protected _properties: Map<string, unknown>; protected _updatedProperties: Map<string, unknown>; protected _changedProperties: Set<string>; protected _updatingPromise: Promise<void>; protected _updating: boolean; constructor(properties?: Record<string, any>); isDirty(key?: string): boolean; getProperty(key: string): any; setProperty(key: string, newValue: any): void; getProperties(keys?: string[]): Record<string, any>; setProperties(properties?: Record<string, any>): this; resetProperties(): this; getPropertyDeclarations(): Map<string, PropertyDeclaration>; getPropertyDeclaration(key: string): PropertyDeclaration | undefined; setPropertyAccessor(accessor: PropertyAccessor): this; protected _nextTick(): Promise<void>; protected _enqueueUpdate(): Promise<void>; onUpdate(): void; onUpdateProperty(key: string, newValue: any, oldValue: any): void; requestUpdate(key?: string, newValue?: any, oldValue?: any): void; protected _update(changed: Map<string, any>): void; protected _updateProperty(key: string, newValue: any, oldValue: any): void; toJSON(): Record<string, any>; clone(): this; } export { EventEmitter, Observable, RawWeakMap, Reactivable, clearUndef, defaultColor, defineProperty, flatDocumentToDocument, getDeclarations, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, getNestedValue, getObjectValueByPath, getPropertyDescriptor, hasCRLF, idGenerator, isCRLF, isColor, isColorFill, isColorFillObject, isEqualObject, isFragmentObject, isGradient, isGradientFill, isGradientFillObject, isImageFill, isImageFillObject, isNone, isParagraphObject, isPresetFill, isPresetFillObject, nanoid, normalizeAudio, normalizeBackground, normalizeCRLF, normalizeColor, normalizeColorFill, normalizeDocument, normalizeEffect, normalizeElement, normalizeFill, normalizeFlatDocument, normalizeForeground, normalizeGradient, normalizeGradientFill, normalizeImageFill, normalizeInnerShadow, normalizeOuterShadow, normalizeOutline, normalizePresetFill, normalizeShadow, normalizeShape, normalizeSoftEdge, normalizeStyle, normalizeText, normalizeTextContent, normalizeVideo, parseColor, parseGradient, pick, property, property2, propertyOffsetDefaultValue, propertyOffsetGet, propertyOffsetSet, round, setNestedValue, setObjectValueByPath, stringifyGradient, textContentToString }; export type { Align, AngularNode, Audio, Background, BackgroundObject, BackgroundSize, BorderStyle, BoxShadow, BoxSizing, CmykColor, CmykaColor, Color, ColorFill, ColorFillObject, ColorStop, ColorStopNode, DefaultRadialNode, Direction, DirectionalNode, Display, Document, Effect, EffectObject, Element, EmNode, EventListenerOptions, EventListenerValue, ExtentKeywordNode, Fill, FillObject, FillRule, FlatDocument, FlatElement, FlatTextContent, FlexDirection, FlexWrap, FontKerning, FontStyle, FontWeight, Foreground, ForegroundObject, FragmentObject, FullStyle, GradientFill, GradientFillObject, GradientNode, HeadEnd, Hex8Color, HexNode, HighlightColormap, HighlightImage, HighlightLine, HighlightReferImage, HighlightSize, HighlightThickness, HslColor, HslaColor, HsvColor, HsvaColor, HwbColor, HwbaColor, IdGenerator, ImageFill, ImageFillCropRect, ImageFillObject, ImageFillStretchRect, ImageFillTile, InnerShadow, InnerShadowObject, Justify, LabColor, LabaColor, LchColor, LchaColor, LineCap, LineEndSize, LineEndType, LineJoin, LinearGradient, LinearGradientNode, LinearGradientWithType, ListStyleColormap, ListStyleImage, ListStylePosition, ListStyleSize, ListStyleType, LiteralNode, Meta, Node, None, NormalizedAudio, NormalizedBackground, NormalizedBaseBackground, NormalizedBaseForeground, NormalizedBaseOuterShadow, NormalizedBaseOutline, NormalizedColor, NormalizedColorFill, NormalizedDocument, NormalizedEffect, NormalizedElement, NormalizedElementStyle, NormalizedFill, NormalizedFlatDocument, NormalizedFlatElement, NormalizedForeground, NormalizedFragment, NormalizedGradientFill, NormalizedHighlight, NormalizedHighlightStyle, NormalizedImageFill, NormalizedInnerShadow, NormalizedLayoutStyle, NormalizedListStyle, NormalizedListStyleStyle, NormalizedOuterShadow, NormalizedOutline, NormalizedParagraph, NormalizedPresetFill, NormalizedShadow, NormalizedShadowStyle, NormalizedShape, NormalizedSoftEdge, NormalizedStyle, NormalizedText, NormalizedTextContent, NormalizedTextDrawStyle, NormalizedTextInlineStyle, NormalizedTextLineStyle, NormalizedTextStyle, NormalizedTransformStyle, NormalizedVideo, ObjectColor, ObservableEvents, OuterShadow, OuterShadowObject, Outline, OutlineObject, OutlineStyle, Overflow, ParagraphObject, PercentNode, PointerEvents, Position, PositionKeywordNode, PositionNode, PresetFill, PresetFillObject, PropertyAccessor, PropertyDeclaration, PxNode, RadialGradient, RadialGradientNode, RadialGradientWithType, ReactivableEvents, RepeatingLinearGradientNode, RepeatingRadialGradientNode, RgbColor, RgbNode, RgbaColor, RgbaNode, SVGPathData, Shadow, ShadowObject, Shape, ShapeNode, ShapePath, ShapePathStyle, SoftEdge, StrokeLinecap, StrokeLinejoin, Style, StyleObject, StyleUnit, TailEnd, Text, TextAlign, TextContent, TextDecoration, TextObject, TextOrientation, TextTransform, TextWrap, Uint32Color, VerticalAlign, Video, Visibility, WithNone, WithStyleNone, WritingMode, XyzColor, XyzaColor };