@player-ui/player
Version:
109 lines • 4.09 kB
TypeScript
import type { Asset as AssetType, Expression, Binding } from "@player-ui/types";
export type AnyAssetType = AssetType<string>;
export declare enum NodeType {
Asset = "asset",
View = "view",
Applicability = "applicability",
Template = "template",
Value = "value",
MultiNode = "multi-node",
Switch = "switch",
Async = "async",
Unknown = "unknown",
Empty = "empty"
}
export declare namespace Node {
type ChildrenTypes = NodeType.Asset | NodeType.Value | NodeType.View;
interface Base<T extends NodeType> {
/** Every node contains a type to distinguish it from other nodes */
type: T;
/** Every node (outside of the root) contains a reference to it's parent */
parent?: Node;
}
type PathSegment = string | number;
interface Child {
/** The path of the child relative to the parent */
path: PathSegment[];
/** If true, the path points to an array, and the value will be appended to it result */
array?: boolean;
/** The child node */
value: Node;
}
interface BaseWithChildren<T extends NodeType> extends Base<T> {
/** Any node that contains a list of children underneath it */
children?: Child[];
}
interface Asset<T extends AnyAssetType = AnyAssetType> extends BaseWithChildren<NodeType.Asset>, PluginOptions {
/** Any asset nested within a view */
value: T;
}
interface View<T extends AnyAssetType = AnyAssetType> extends BaseWithChildren<NodeType.View>, PluginOptions {
/** The root of the parsed view */
value: T;
}
interface Applicability extends Base<NodeType.Applicability> {
/** The expression to execute that determines applicability of the target node */
expression: Expression;
/** The node to use if the expression is truthy */
value: Node;
}
interface Template extends Base<NodeType.Template> {
/** The location of an array in the model */
data: Binding;
/** The template to use when mapping over the data */
template: unknown;
/** The number of nested templates so far */
depth: number;
/** should the template recomputed when data changes */
dynamic?: boolean;
}
interface Value extends BaseWithChildren<NodeType.Value>, PluginOptions {
/** A simple node representing a value */
value: any;
}
interface MultiNode extends Base<NodeType.MultiNode> {
/**
* Should this list override the target node if they overlap?
* If not amend the existing list
*/
override?: boolean;
/** A list of values that comprise this node */
values: Array<Node>;
}
interface Switch extends Base<NodeType.Switch> {
/** Should this list be re-computed when data changes */
dynamic?: boolean;
/** A list of cases to evaluate in order */
cases: SwitchCase[];
}
interface SwitchCase {
/** The expression to evaluate for a single case statement */
case: Expression | true;
/** The value to use if this case is true */
value: Value;
}
interface Async extends Base<NodeType.Async> {
/** The unique id of the node */
id: string;
/** The value representing the node */
value: Node;
}
interface PluginOptions {
/** A list of plugins */
plugins?: {
/** StringResolverPlugin options */
stringResolver?: {
/**
* An optional array of node properties to skip during string resolution
* Specified in the AssetTransformPlugin
*/
propertiesToSkip?: string[];
};
};
}
type Unknown = Base<NodeType.Unknown>;
type Empty = Base<NodeType.Empty>;
type ViewOrAsset = View | Asset;
type Node = Asset | Applicability | Template | Value | View | MultiNode | Switch | Async | Unknown | Empty;
}
//# sourceMappingURL=types.d.ts.map