Type alias PanelExtensionContext

PanelExtensionContext: {
    dataSourceProfile?: string;
    initialState: unknown;
    layout: LayoutActions;
    onRender?: ((renderState, done) => void);
    panelElement: HTMLDivElement;
    saveState: ((state) => void);
    seekPlayback?: ((time) => void);
    setParameter: ((name, value) => void);
    setPreviewTime: ((time) => void);
    setSharedPanelState: ((state) => void);
    setVariable: ((name, value) => void);
    watch: ((field) => void);
    advertise?(topic, schemaName, options?): void;
    callService?(service, request): Promise<unknown>;
    publish?(topic, message): void;
    setDefaultPanelTitle(defaultTitle): void;
    subscribe(topics): void;
    subscribe(subscriptions): void;
    subscribeAppSettings(settings): void;
    unadvertise?(topic): void;
    unsubscribeAll(): void;
    updatePanelSettingsEditor(settings): void;
}

Type declaration

  • Optional Readonly dataSourceProfile?: 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.

  • Readonly initialState: unknown

    Initial panel state

  • Readonly layout: LayoutActions

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

  • Optional onRender?: ((renderState, done) => 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.

      • (renderState, done): void
      • Parameters

        Returns void

  • Readonly panelElement: HTMLDivElement

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

  • saveState: ((state) => 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.

      • (state): void
      • Parameters

        • state: Partial<unknown>

        Returns void

  • Optional seekPlayback?: ((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.

      • (time): void
      • Parameters

        Returns void

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

    Set the value of parameter name to value.

      • (name, value): void
      • Parameters

        • name: string

          The name of the parameter to set.

        • value: ParameterValue

          The new value of the parameter.

        Returns void

  • setPreviewTime: ((time) => void)

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

      • (time): void
      • Parameters

        • time: number | undefined

        Returns void

  • setSharedPanelState: ((state) => 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.

      • (state): void
      • Parameters

        • state: undefined | Record<string, unknown>

        Returns void

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

    Set the value of variable name to value.

      • (name, value): void
      • Parameters

        • name: string

          The name of the variable to set.

        • value: VariableValue

          The new value of the variable.

        Returns void

  • watch: ((field) => void)

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

      • (field): void
      • Parameters

        Returns void

  • 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.

      • Optional options: 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

      Deprecated

      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) => void);
            enableFilter?: boolean;
            focusedPath?: readonly string[];
            nodes: SettingsTreeNodes;
        }
        • Readonly actionHandler: ((action) => void)

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

        • Optional Readonly enableFilter?: boolean

          True if the settings editor should show the filter control.

        • Optional Readonly focusedPath?: 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.

        • Readonly nodes: SettingsTreeNodes

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

      Returns void