Type Alias PanelExtensionContext

PanelExtensionContext: {
    dataSourceProfile?: string;
    initialState: unknown;
    layout: LayoutActions;
    onRender?: (renderState: Immutable<RenderState>, done: () => void) => void;
    panelElement: HTMLDivElement;
    saveState: (state: Partial<unknown>) => void;
    seekPlayback?: (time: number | Time) => void;
    setParameter: (name: string, value: ParameterValue) => void;
    setPreviewTime: (time: number | undefined) => void;
    setSharedPanelState: (state: undefined | Record<string, unknown>) => void;
    setVariable: (name: string, value: VariableValue) => void;
    watch: (field: keyof RenderState) => void;
    advertise(
        topic: string,
        schemaName: string,
        options?: Record<string, unknown>,
    ): void;
    callService(service: string, request: unknown): Promise<unknown>;
    publish(topic: string, message: unknown): void;
    setDefaultPanelTitle(defaultTitle: undefined | string): void;
    subscribe(topics: string[]): void;
    subscribe(subscriptions: Subscription[]): void;
    subscribeAppSettings(settings: string[]): void;
    unadvertise(topic: string): void;
    unsubscribeAll(): void;
    updatePanelSettingsEditor(
        settings: {
            actionHandler: (action: SettingsTreeAction) => void;
            enableFilter?: boolean;
            focusedPath?: readonly string[];
            nodes: SettingsTreeNodes;
        },
    ): void;
}

Type declaration

  • Optional ReadonlydataSourceProfile?: string

    Identifies the semantics of the data being played back, such as which topics or parameters are semantically meaningful or normalization conventions to use. This typically maps to a shorthand identifier for a robotics framework such as "ros1", "ros2", or "ulog". See the MCAP profiles concept at https://github.com/foxglove/mcap/blob/main/docs/specification/appendix.md#well-known-profiles.

  • ReadonlyinitialState: unknown

    Initial panel state

  • Readonlylayout: LayoutActions

    Actions the panel may perform related to the user's current layout.

  • OptionalonRender?: (renderState: Immutable<RenderState>, done: () => void) => void

    Process render events for the panel. Each render event receives a render state and a done callback. Render events occur frequently (60hz, 30hz, etc).

    The done callback should be called once the panel has rendered the render state.

  • ReadonlypanelElement: HTMLDivElement

    The root element for the panel. Add your panel elements as children under this element.

  • saveState: (state: Partial<unknown>) => void

    Save arbitrary object as persisted panel state. This state is persisted for the panel within a layout.

    The state value should be JSON serializable.

  • OptionalseekPlayback?: (time: number | Time) => void

    Seek playback to the given time. Behaves as if the user had clicked the playback bar to seek.

    Clients can pass a number or alternatively a Time object for greater precision.

  • setParameter: (name: string, value: ParameterValue) => void

    Set the value of parameter name to value.

  • setPreviewTime: (time: number | undefined) => void

    Set the active preview time. Setting the preview time to undefined clears the preview time.

  • setSharedPanelState: (state: undefined | Record<string, unknown>) => void

    Set the transient state shared by panels of the same type as the caller of this function. This will not be persisted in the layout.

  • setVariable: (name: string, value: VariableValue) => void

    Set the value of variable name to value.

  • watch: (field: keyof RenderState) => void

    Subscribe to updates on this field within the render state. Render will only be invoked when this field changes.

  • advertise?:function
    • Indicate intent to publish messages on a specific topic.

      Parameters

      • topic: string

        The topic on which the extension will publish messages.

      • schemaName: string

        The name of the schema that the published messages will conform to.

      • Optionaloptions: Record<string, unknown>

        Options passed to the current data source for additional configuration.

      Returns void

  • callService?:function
    • Call a service.

      Parameters

      • service: string

        The name of the service to call

      • request: unknown

        The request payload for the service call

      Returns Promise<unknown>

      A promise that resolves when the result is available or rejected with an error

  • publish?:function
    • Publish a message on a given topic. You must first advertise on the topic before publishing.

      Parameters

      • topic: string

        The name of the topic to publish the message on

      • message: unknown

        The message to publish

      Returns void

  • setDefaultPanelTitle:function
    • Updates the panel's default title. Users can always override the default title by editing it manually. A value of undefined will display the panel's name in the title bar.

      Parameters

      • defaultTitle: undefined | string

      Returns void

  • subscribe:function
    • Subscribe to an array of topic names.

      Subscribe will update the current subscriptions to the list of topic names. Passing an empty array will unsubscribe from all topics.

      Calling subscribe with an empty array of topics is analagous to unsubscribeAll.

      Parameters

      • topics: string[]

      Returns void

      Use subscribe with an array of Subscription objects instead.

    • Subscribe to an array of topics with additional options for each subscription.

      Subscribe will update the current subscriptions to the new list of Subscriptions and unsubscribe from any previously subscribed topics no longer in the Subscription list. Passing an empty array will unsubscribe from all topics.

      Calling subscribe with an empty array is analagous to unsubscribeAll.

      Parameters

      Returns void

  • subscribeAppSettings:function
    • Subscribe to any changes in application settings for an array of setting names.

      Parameters

      • settings: string[]

      Returns void

  • unadvertise?:function
    • Indicate that you no longer want to advertise on this topic.

      Parameters

      • topic: string

      Returns void

  • unsubscribeAll:function
    • Unsubscribe from all topics.

      Note: This is analagous to calling subscribe([]) with an empty array of topics.

      Returns void

  • updatePanelSettingsEditor:function
    • Updates the panel's settings editor. Call this every time you want to update the representation of the panel settings in the editor.

      Parameters

      • settings: {
            actionHandler: (action: SettingsTreeAction) => void;
            enableFilter?: boolean;
            focusedPath?: readonly string[];
            nodes: SettingsTreeNodes;
        }
        • ReadonlyactionHandler: (action: SettingsTreeAction) => void

          Handler to process all actions on the settings tree initiated by the UI.

        • Optional ReadonlyenableFilter?: boolean

          True if the settings editor should show the filter control.

        • Optional ReadonlyfocusedPath?: readonly string[]

          Setting this will have a one-time effect of scrolling the editor to the node at the path and highlighting it. This is a transient effect so it is not necessary to subsequently unset this.

        • Readonlynodes: SettingsTreeNodes

          The settings tree root nodes. Updates to these will automatically be reflected in the editor UI.

      Returns void