import { BrsValue, ValueKind, BrsString, BrsInvalid, BrsBoolean } from "../BrsType"; import { BrsComponent, BrsIterable } from "./BrsComponent"; import { BrsType } from ".."; import { Callable } from "../Callable"; import { Interpreter } from "../../interpreter"; import { RoAssociativeArray } from "./RoAssociativeArray"; import { RoArray } from "./RoArray"; import { AAMember } from "./RoAssociativeArray"; /** Set of value types that a field could be. */ declare enum FieldKind { Interface = "interface", Array = "array", AssocArray = "assocarray", Int32 = "integer", Int64 = "longinteger", Double = "double", Float = "float", Node = "node", Boolean = "boolean", String = "string", Function = "function" } declare namespace FieldKind { function fromString(type: string): FieldKind | undefined; function fromBrsType(brsType: BrsType): FieldKind | undefined; } /** This is used to define a field (usually a default/built-in field in a component definition). */ export type FieldModel = { name: string; type: string; value?: string; hidden?: boolean; alwaysNotify?: boolean; }; export declare class Field { private value; private type; private alwaysNotify; private hidden; private permanentObservers; private unscopedObservers; private scopedObservers; constructor(value: BrsType, type: FieldKind, alwaysNotify: boolean, hidden?: boolean); toString(parent?: BrsType): string; /** * Returns whether or not the field is "hidden". * * The reason for this is that some fields (content metadata fields) are * by default "hidden". This means they are accessible on the * node without an access error, but they don't show up when you print the node. */ isHidden(): boolean; setHidden(isHidden: boolean): void; getType(): FieldKind; getValue(): BrsType; setValue(value: BrsType): void; canAcceptValue(value: BrsType): boolean; addObserver(mode: "permanent" | "unscoped" | "scoped", interpreter: Interpreter, callable: Callable, subscriber: RoSGNode, target: RoSGNode, fieldName: BrsString, infoFields?: RoArray): void; removeUnscopedObservers(): void; removeScopedObservers(hostNode: RoSGNode): void; private executeCallbacks; } export declare class RoSGNode extends BrsComponent implements BrsValue, BrsIterable { readonly nodeSubtype: string; readonly kind = ValueKind.Object; private fields; private children; private parent; readonly defaultFields: FieldModel[]; m: RoAssociativeArray; constructor(initializedFields: AAMember[], nodeSubtype?: string); toString(parent?: BrsType): string; equalTo(other: BrsType): BrsBoolean; getElements(): BrsString[]; getValues(): BrsType[]; getFields(): Map; get(index: BrsType): BrsType; set(index: BrsType, value: BrsType, alwaysNotify?: boolean, kind?: FieldKind): BrsInvalid; getParent(): BrsInvalid | RoSGNode; setParent(parent: RoSGNode): void; removeParent(): void; isChildrenFocused(interpreter: Interpreter): boolean; private findNodeById; private removeChildByReference; private appendChildToParent; private replaceChildAtIndex; private insertChildAtIndex; protected setExtendsType(): void; /** * Calls the function specified on this node. */ private callfunc; /** Removes all fields from the node */ private clear; /** Removes a given item from the node */ private delete; /** Given a key and value, adds an item to the node if it doesn't exist * Or replaces the value of a key that already exists in the node */ private addreplace; /** Returns the number of items in the node */ protected count: Callable; /** Returns a boolean indicating whether or not a given key exists in the node */ private doesexist; /** Appends a new node to another. If two keys are the same, the value of the original AA is replaced with the new one. */ private append; /** Returns an array of keys from the node in lexicographical order */ protected keys: Callable; /** Returns an array of key/value pairs in lexicographical order of key. */ protected items: Callable; /** Given a key, returns the value associated with that key. This method is case insensitive. */ private lookup; /** Given a key, returns the value associated with that key. This method is case insensitive. */ private lookupCI; /** Adds a new field to the node, if the field already exists it doesn't change the current value. */ private addfield; /** Adds one or more fields defined as an associative aray of key values. */ private addfields; /** Returns the value of the field passed as argument, if the field doesn't exist it returns invalid. */ private getfield; /** Returns the names and values of all the fields in the node. */ private getfields; /** Returns true if the field exists */ protected hasfield: Callable; /** Registers a callback to be executed when the value of the field changes */ private observefield; /** * Removes all observers of a given field, regardless of whether or not the host node is the subscriber. */ private unobserveField; private observeFieldScoped; private unobserveFieldScoped; /** Removes the given field from the node */ /** TODO: node built-in fields shouldn't be removable (i.e. id, change, focusable,) */ private removefield; /** Updates the value of an existing field only if the types match. */ private setfield; /** Updates the value of multiple existing field only if the types match. */ private setfields; private update; private getchildcount; private appendchild; private getchildren; private removechild; private getparent; private createchild; /** * If the subject node has a child node in the index position, replace that child * node with the newChild node in the subject node list of children, otherwise do nothing. */ private replacechild; /** * Removes the child nodes specified by child_nodes from the subject node. Returns * true if the child nodes were successfully removed. */ private removechildren; /** * Removes the number of child nodes specified by num_children from the subject node * starting at the position specified by index. */ private removechildrenindex; /** * If the subject node has a child node at the index position, return it, otherwise * return invalid. */ private getchild; /** * Appends the nodes specified by child_nodes to the subject node. */ private appendchildren; /** Creates the number of children specified by num_children for the subject node, * of the type or extended type specified by subtype. */ private createchildren; /** Replaces the child nodes in the subject node, starting at the position specified * by index, with new child nodes specified by child_nodes. */ private replacechildren; /** * Inserts the child nodes specified by child_nodes to the subject node starting * at the position specified by index. */ private insertchildren; /** * Inserts a previously-created child node at the position index in the subject * node list of children, so that this is the position that the new child node * is traversed during render. */ private insertchild; /** * If the subject node has a child node in the index position, remove that child * node from the subject node list of children. */ private removechildindex; /** * Moves the subject node to another node. * If adjustTransform is true, the subject node transformation factor fields (translation/rotation/scale) * are adjusted so that the node has the same transformation factors relative to the screen as it previously did. * If adjustTransform is false, the subject node is simply parented to the new node without adjusting its * transformation factor fields, in which case, the reparenting operation could cause the node to jump to a * new position on the screen. */ private reparent; private hasfocus; private boundingRect; /** * Starting with a leaf node, traverses upward through the parents until it reaches * a node without a parent (root node). * @param {RoSGNode} node The leaf node to create the tree with * @returns RoSGNode[] The parent chain starting with root-most parent */ private createPath; /** * If on is set to true, sets the current remote control focus to the subject node, * also automatically removing it from the node on which it was previously set. * If on is set to false, removes focus from the subject node if it had it. * * It also runs through all of the ancestors of the node that was focused prior to this call, * and the newly focused node, and sets the `focusedChild` field of each to reflect the new state. */ private setfocus; /** * Returns true if the subject node or any of its descendants in the SceneGraph node tree * has remote control focus */ private isinfocuschain; private findnode; private issubtype; private parentsubtype; private issamenode; private subtype; protected registerDefaultFields(fields: FieldModel[]): void; /** * Takes a list of preset fields and creates fields from them. * TODO: filter out any non-allowed members. For example, if we instantiate a Node like this: * * then Roku logs an error, because Node does not have a property called "thisisnotanodefield". */ protected registerInitializedFields(fields: AAMember[]): void; } export declare const mGlobal: RoSGNode; export declare function createNodeByType(interpreter: Interpreter, type: BrsString): RoSGNode | BrsInvalid; export {};