UNPKG

@player-ui/player

Version:

50 lines 1.97 kB
import type { Node, AnyAssetType } from "../parser"; import { NodeType } from "../parser"; /** * Functions for building AST nodes (relatively) easily */ export declare class Builder { /** * Creates an asset node * * @param value - the value to put in the asset node */ static asset<T extends AnyAssetType>(value: T): Node.Asset<T>; static assetWrapper<T extends Node.Node>(value: T): Node.Value; /** * Creates a value node * * @param v - The object to put in the value node */ static value(v?: object): Node.Value; /** * Creates a multiNode and associates the multiNode as the parent * of all the value nodes * * @param values - the value, applicability or async nodes to put in the multinode */ static multiNode(...values: (Node.Value | Node.Applicability | Node.Async)[]): Node.MultiNode; /** * Creates an async node * * @param id - the id of async node. It should be identical for each async node */ static asyncNode(id: string, flatten?: boolean, onValueReceived?: (node: Node.Node) => Node.Node): Node.Async; /** * Adds a child node to a node * * @param node - The node to add a child to * @param path - The path at which to add the child * @param child - The child node */ static addChild<N extends Node.BaseWithChildren<NT>, NT extends NodeType>(node: N, path: Node.PathSegment | Node.PathSegment[], child: Node.Node): N; /** * Updates children of a node of the same path and preserves order * * @param node - The node to update children for * @param pathToMatch - The path to match against child paths * @param mapFn - Function to transform matching children */ static updateChildrenByPath<T extends Node.ViewOrAsset | Node.Value>(node: T, pathToMatch: Node.PathSegment[], updateFn: (child: Node.Child) => Node.Node): T; } //# sourceMappingURL=index.d.ts.map