@byomakase/omakase-player
    Preparing search index...

    Interface UiApi

    interface UiApi {
        elements: UiElement<UiElementProps>[];
        onEvent$: Observable<UiEvent>;
        styleRules: StyleRule<any>[];
        getElement(id: string): UiElement<UiElementProps> | undefined;
        removeStyleRules(predicate: (rule: StyleRule<any>) => boolean): void;
        resolveStyle<S>(element: StyledElement<S>): Partial<S>;
        resolveStyleClass<T extends keyof ElementStyleByName>(name: T): string;
        updateElement(element: UiElement): void;
        updateStyleRule<S>(rule: StyleRule<S>): void;
    }

    Implemented by

    Index

    Properties

    Snapshot of all currently tracked UI elements.

    An element is tracked as long as it has at least one non-undefined prop. It is automatically removed (and UI_ELEMENTS_REMOVED emitted) once all its props are cleared.

    onEvent$: Observable<UiEvent>

    Emits whenever a style rule or element is updated or removed.

    Delivered asynchronously via asyncScheduler — subscribers always receive events on the next tick, never synchronously. Switch on event.type to handle specific event kinds:

    • UI_STYLE_RULE_UPDATED — a style rule was added or merged
    • UI_STYLE_RULES_REMOVED — style rules were removed
    • UI_ELEMENT_UPDATED — an element's props were updated
    • UI_ELEMENTS_REMOVED — one or more elements were removed
    styleRules: StyleRule<any>[]

    Snapshot of all registered style rules (both class-based and id-based).

    Methods

    • Removes all style rules for which predicate returns true.

      Iterates the rule registry and deletes every matching entry, then emits UI_STYLE_RULES_REMOVED. Default styles registered at construction time can also be removed this way.

      Parameters

      Returns void

      // Remove all per-instance scoped rules for a specific track
      ui.removeStyleRules((rule) => 'className' in rule && rule.className.startsWith('marker-track['));
    • Computes the merged style for an element using the following cascade priority (later steps override earlier ones):

      1. Class rules — applied in element.classes array order; later class wins
      2. Inline element.style
      3. Id rule — highest priority, overrides everything else

      Any combination of id, classes, and style on the element is accepted.

      Type Parameters

      • S

      Parameters

      Returns Partial<S>

    • Adds or updates an element's props in the registry.

      • If the element exists, props are shallow-merged. Keys explicitly set to undefined are deleted from the stored props.
      • If all props become undefined after the merge, the element is removed and UI_ELEMENTS_REMOVED is emitted instead.
      • If the element does not exist and has at least one non-undefined prop, it is created and UI_ELEMENT_UPDATED is emitted.

      Parameters

      Returns void

    • Adds or merges a style rule into the registry.

      If a rule with the same key already exists (id or className), its style is shallow-merged with the incoming rule. Otherwise the rule is appended. Emits UI_STYLE_RULE_UPDATED after the update.

      Type Parameters

      • S

      Parameters

      Returns void