UNPKG

@lottiefiles/last

Version:

Type definitions for Lottie Abstract Syntax Tree (LAST)

90 lines (86 loc) 2.97 kB
import { Node as Node$1, Parent as Parent$1, Literal as Literal$1, Position as Position$1, Point as Point$1, Data as Data$1 } from 'unist'; import { AnyTitle, AttributeTitle, CollectionTitle, ElementTitle, ObjectTitle, ArrayTitle, TITLES } from './titles.js'; export { BooleanTitle, ChildrenTitleHelper, CustomTitle, IntegerBooleanTitle, NumberTitle, ParentTitle, StringTitle, TitleHelper } from './titles.js'; /** * Copyright 2022 Design Barn Inc. */ interface Node extends Node$1 { } interface Parent extends Parent$1 { /** * Lottie's qualified name. */ title: AnyTitle; } interface Literal extends Literal$1 { } interface Position extends Position$1 { } interface Point extends Point$1 { } interface Data extends Data$1 { } declare type PrimitiveValueType = 'string' | 'number' | 'boolean' | 'null'; declare type PrimitiveValue = string | number | boolean | null; interface Primitive extends Literal { type: 'primitive'; value: PrimitiveValue; valueType?: PrimitiveValueType; } interface KeyNode extends Literal { type: 'key'; value: string; } declare type Key = string; declare type KeyValue = KeyNode | Key; /** * Base interface for Element, Collection & Attribute */ interface Member extends Parent { /** * Property's key */ key: KeyValue; title: AttributeTitle | CollectionTitle | ElementTitle; } declare type ObjectNodeValue = Attribute | Element | Collection; interface ObjectNode extends Parent { children: ObjectNodeValue[]; title: ObjectTitle; type: 'object'; } declare type ArrayNodeValue = Primitive | ObjectNode | ArrayNode; interface ArrayNode extends Parent { children: ArrayNodeValue[]; title: ArrayTitle; type: 'array'; } interface Attribute extends Member { children: [Primitive] | []; title: AttributeTitle; type: 'attribute'; } interface Element extends Member { children: [ObjectNode] | []; title: ElementTitle; type: 'element'; } interface Collection extends Member { children: [ArrayNode] | []; title: CollectionTitle; type: 'collection'; } /** * Top level Node, describing the Lottie animation */ interface Root extends Omit<ObjectNode, 'type'> { /** * whether the animation contains expressions */ hasExpressions: boolean; title: typeof TITLES.object.animation; type: 'root'; } declare type NodeValue = Root | Primitive | KeyNode | ArrayNode | ObjectNode | Attribute | Element | Collection; declare type NodeValueType = NodeValue['type']; export { AnyTitle, type ArrayNode, type ArrayNodeValue, ArrayTitle, type Attribute, AttributeTitle, type Collection, CollectionTitle, type Data, type Element, ElementTitle, type Key, type KeyNode, type KeyValue, type Literal, type Node, type NodeValue, type NodeValueType, type ObjectNode, type ObjectNodeValue, ObjectTitle, type Parent, type Point, type Position, type Primitive, type PrimitiveValue, type PrimitiveValueType, type Root, TITLES };