Hosanna UI API v1.30.2-next
    Preparing search index...

    NodePool manages reusable SceneGraph nodes for performance and memory efficiency. Implements the INodePool interface.

    Implements

    Index

    Constructors

    Properties

    createdCounts: { [componentType: string]: number } = {}

    Tracks the number of created nodes for each component type.

    holder: ISGNGroup = ...

    The hidden holder group for storing pooled nodes off-screen.

    inUseByType: Record<string, Record<string, ISGNNode>> = {}

    Nodes currently checked out (not in free list), keyed by subtype then stable key.

    pool: { [componentType: string]: ISGNNode[] } = {}

    The pool of reusable nodes, keyed by component type.

    pristineConfig: undefined | INodePoolPristineDefaults

    Cached nodePoolPristineDefaults section from app config. Populated lazily the first time resolvePristineConfig() succeeds, then sticky. undefined before AppConfig is wired (unit tests, early boot). Shape: { '*': { field: value, ... }, <subtype>: { ... } }.

    pristineConfigResolved: boolean = false
    pristineDefaults: { [componentType: string]: IStyleDictionary } = {}

    Pristine default field values captured from the first freshly-created node of each type. Used to reset pooled nodes to a known-good state before reuse.

    retainedNodesByParentId: Record<string, Record<string, ISGNNode>> = {}

    Nodes released to the pool while intentionally remaining attached to their parent.

    Methods

    • Parameters

      Returns INodePoolDebugInfo

    • Captures the default field values from a freshly-created node (once per component type). Uses node.Keys() for the key list and node[key] for direct property access.

      This is the single point at which pooled-node reset state is defined. The resulting snapshot is replayed via node.update(...) on every get(), so any field that needs a specific "fresh" value on reuse must end up in this snapshot.

      Object-valued (non-array) fields cannot round-trip safely on Roku (roAssociativeArray handles often can't be written back verbatim — e.g. clippingRect's "uninitialized" marker activates the field as a real 0x0 clip rect on replay). To keep pooled reset semantics deterministic across all targets (web, Roku, mobile), NodePool treats object-valued fields uniformly. For those fields:

      • If the merged nodePoolPristineDefaults map (wildcard + subtype bucket) has an entry for the field, the configured value is stored in the snapshot so the next checkout starts clean.
      • If the field is required by schema and the merged map has no value, NodePool throws to prevent stale state leakage once config is loaded.
      • Otherwise the field is skipped.

      Scoping safety: the snapshot is built from node.Keys(), so only fields the subtype actually exposes land in the snapshot. Stray keys in a subtype bucket in app config can't pollute unrelated subtypes.

      Parameters

      Returns void

    • Removes retained-parent nodes that were released for a specific parent.

      Parameters

      • parent: ISGNNode

        Parent whose retained released nodes should be detached.

      Returns void

    • Retrieves a node of the specified component type from the pool, or creates a new one if none are available. Optionally applies an initial state to the node.

      Type Parameters

      Parameters

      • componentType: string

        The type of node to retrieve.

      • OptionalinitialState: IStyleDictionary

        Optional initial state to apply to the node.

      Returns T

      The node instance.

    • Debug-only: nodes that look incorrectly parented while checked out.

      Returns INodePoolDebugInfo[]

    • Debug-only: in-use nodes per subtype (plain objects).

      Returns Record<string, INodePoolDebugInfo[]>

    • Builds the merged wildcard + subtype defaults map for a subtype. Subtype bucket wins so a subtype can override or extend the wildcard. Called only from pristine snapshot capture.

      Parameters

      Returns IStyleDictionary

    • Applies loaded app-config pristine overrides to already-captured subtype snapshots and keeps the updated snapshots cached.

      Returns void

    • Prepopulates the pool with a specified number of nodes of the given component type. Nodes are created off-screen and added to the pool.

      Parameters

      • componentType: string

        The type of node to prepopulate.

      • count: number

        The number of nodes to create.

      Returns void

    • Releases a node back into the pool for reuse. Removes the node from its parent and appends it to the holder group.

      Parameters

      • node: ISGNNode

        The node to release.

      • removeFromParent: boolean = true

      Returns void

    • Resolves nodePoolPristineDefaults.

      Two-phase behavior:

      • Bootstrap (config not yet loaded): fallback-only operation.
      • Loaded config: strict validation and fail-fast on missing required defaults.

      Returns undefined | INodePoolPristineDefaults

    • Parameters

      Returns string

    • Parameters

      • componentType: string
      • field: string

      Returns boolean

    • Parent may be a partial mock (e.g. tests) without subtype().

      Parameters

      Returns undefined | string