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

    ViewFragmentProvider manages reusable view fragments for efficient UI rendering.

    • Provides pooling and recycling of view fragments by style key.
    • Supports fragment creation, release, and status application.
    • Integrates with style registry and font manager for fragment instantiation.

    Implements

    Index

    Constructors

    Properties

    allFragmentsById: { [id: string]: IViewFragment } = {}

    All fragments indexed by their unique ID.

    appConfig: AppConfig.AppConfig

    Style registry for resolving fragment styles.

    availableFragmentsavailableFragmentsById: { [key: string]: IViewFragment[] } = {}

    Available fragments for reuse, indexed by style key.

    callbackRegistry: {
        onApplyViewStatus?: {
            [name: string]:
                | ISpecificViewFragmentCallbackHandler
                | ViewFragmentCallbackHandler;
        };
        onDataChange?: {
            [name: string]: | ISpecificViewFragmentCallbackHandler
            | ViewFragmentCallbackHandler;
        };
        onMount?: {
            [name: string]: | ISpecificViewFragmentCallbackHandler
            | ViewFragmentCallbackHandler;
        };
        onSpecificViewDataChange?: {
            [name: string]: | ISpecificViewFragmentCallbackHandler
            | ViewFragmentCallbackHandler;
        };
        onUnmount?: {
            [name: string]: | ISpecificViewFragmentCallbackHandler
            | ViewFragmentCallbackHandler;
        };
    } = {}

    Registry for callback types and names mapped to handler functions.

    Font manager for resolving fonts in fragments.

    fragmentHolder: ISGNGroup

    Holder group for all fragment views.

    fragmentId: number = 0

    Internal fragment ID counter for unique IDs.

    hosannaDevice: IHosannaDevice
    inUseFragmentById: Record<string, IViewFragment> = {}

    Fragments currently checked out from the available pool (not in free stacks).

    uniqueSGId: number = 0
    viewsThatNeedToBeRemovedById: Record<string, ISGNGroup> = {}

    Views that should be removed during the next synchronization, indexed by view id.

    Methods

    • Efficiently appends a child view to a parent if the view is not already attached to the scene. If the view is already attached and was previously marked for removal, the mark is cleared.

      Parameters

      Returns void

    • Creates a fragment from a style JSON definition.

      Parameters

      • styleKey: string

        The style key.

      • styleJson: IFragmentStyle

        The style JSON.

      Returns IViewFragment

      The created view fragment.

    • Creates multiple fragments for a given style key.

      Parameters

      • styleKey: string

        The style key.

      • count: number

        The number of fragments to create.

      Returns void

    • Permanently drops a stale pooled fragment: unregisters it, removes it from the master index, and detaches its SG view so it can be rebuilt.

      Parameters

      Returns void

    • Generates a unique fragment ID.

      Returns string

      The unique fragment ID string.

    • Parameters

      • shapeStyleKey: string
      • width: number
      • height: number
      • translation: number[]

      Returns undefined | JsonData

    • Returns string

    • Resolves an hs_shape fragment child against theme.compiledShapes (see ShapeLoader). On Roku the child JSON is rewritten in place to a Poster pointing at the pre-generated nine-patch, with the compiled offsets played on top of the child's translation and width/height. On other platforms the child is left untouched — the HsShape node resolves its own shapeStyleKey when rendering.

      Returns false only when the style is not compiled yet (retryable on the next fragment creation); malformed children are not retried.

      Parameters

      Returns boolean

    • Translates status-style updates targeting a Roku shape node (already rendered as a Poster) into the equivalent Poster field updates. Status width/height/translation are logical shape geometry, so the compiled shape offsets are played on top of them, exactly like the base geometry was during fragment hydration. Handles both shapeStyleKey swaps and geometry-only updates (which keep the shape style a previous status or the base style applied).

      Parameters

      Returns JsonData

    • Resolves a mask child's shapeStyle against theme.compiledShapes. On Roku the field is swizzled to maskUri (the style's launch-compiled flat mask image) and, when the fragment declares no maskSize, the mask is sized to the child rect — matching the native fallback; the SG MaskGroup scales the bitmap to maskSize. On other platforms the child is left untouched — the bridge MaskGroup resolves its own shapeStyle when rendering.

      Parameters

      Returns void

    • Re-attempts hs_shape resolution for a fragment style whose first hydration ran before theme.compiledShapes contained every referenced style (loadShapes() not yet run, or a config reload wiped the compiled branch). Fonts and maskSize scaling are not re-applied.

      Parameters

      Returns void

    • Parameters

      Returns boolean

    • True when a pooled fragment was built while its hs_shape styles were not yet compiled AND those styles now resolve. In that case its realized SG nodes are stale hs_shape nodes that cannot be rewritten, so the caller must discard it and build a fresh fragment. Re-runs the shared-style retry so the freshly built fragment picks up the compiled Posters. If the shapes still have not compiled, the pooled fragment is reused as-is (nothing better is available yet).

      Parameters

      Returns boolean