@foxglove/extension 2.32.1 → 2.33.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@foxglove/extension",
3
- "version": "2.32.1",
3
+ "version": "2.33.1",
4
4
  "license": "MIT",
5
5
  "author": {
6
6
  "name": "Foxglove Technologies",
@@ -2,7 +2,12 @@
2
2
  import type { Immutable } from "./immutable";
3
3
  import type {
4
4
  ExtensionContext as BaseExtensionContext,
5
+ MessageEvent,
5
6
  PanelExtensionContext as BasePanelExtensionContext,
7
+ SettingsTreeAction,
8
+ SettingsTreeFields,
9
+ SettingsTreeNode,
10
+ Topic,
6
11
  } from "./stable";
7
12
 
8
13
  /**
@@ -51,6 +56,13 @@ export namespace Experimental {
51
56
  * See: {@link RegisterDataLoaderArgs}
52
57
  */
53
58
  registerDataLoader(args: RegisterDataLoaderArgs): void;
59
+
60
+ /**
61
+ * Register a panel overlay extension to create 2D HTML overlays for 3D and Image panels
62
+ *
63
+ * See: {@link PanelOverlayExtensionArgs}
64
+ */
65
+ registerPanelOverlay(args: PanelOverlayExtensionArgs): void;
54
66
  }
55
67
 
56
68
  export interface ExtensionModule {
@@ -118,6 +130,98 @@ export namespace Experimental {
118
130
  */
119
131
  export type PanelToolbarItem = PanelToolbarButton | PanelToolbarLink | PanelToolbarDivider;
120
132
 
133
+ export type PanelOverlayExtensionBaseConfig = { visible: boolean };
134
+
135
+ export type PanelOverlaySubscription<T = unknown> = {
136
+ /**
137
+ * This method will only be run against Topics with schemas that match the topic or schema of the overarching subscription.
138
+ * So if you always want to receive messages from a topic with a given name or schema you can simply return true.
139
+ * These subscriptions will only be active when the custom layer extension's visibility is true.
140
+ */
141
+ shouldSubscribe?: (topic: string, schema: string) => boolean;
142
+ /** Callback that will be fired for each matching incoming message */
143
+ handler: (messageEvent: MessageEvent<T>) => void;
144
+ /** Queue of messages to be handled since last frame. Will be reassigned to new empty array each frame. */
145
+ queue?: MessageEvent<T>[] | undefined;
146
+ /** Optional callback to be called on `queue` to filter. Returns new queue. */
147
+ filterQueue?: (queue: MessageEvent<T>[]) => MessageEvent<T>[];
148
+ };
149
+
150
+ export type AnyPanelOverlaySubscription = Immutable<
151
+ | {
152
+ type: "schema";
153
+ schemaNames: Set<string>;
154
+ // any is used here to allow storing heterogeneous arrays of subscriptions
155
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
156
+ subscription: PanelOverlaySubscription<any>;
157
+ }
158
+ | {
159
+ type: "topic";
160
+ topicName: string;
161
+ // any is used here to allow storing heterogeneous arrays of subscriptions
162
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
163
+ subscription: PanelOverlaySubscription<any>;
164
+ }
165
+ >;
166
+
167
+ export type ActionHandler = (action: SettingsTreeAction) => void;
168
+
169
+ export type SettingsTreeNodeWithActionHandler = SettingsTreeNode & { handler?: ActionHandler };
170
+
171
+ export type SettingsPath = ReadonlyArray<string>;
172
+
173
+ export type SettingsTreeEntry = { path: SettingsPath; node: SettingsTreeNodeWithActionHandler };
174
+
175
+ export interface PanelOverlayExtensionContext<
176
+ Config extends PanelOverlayExtensionBaseConfig = PanelOverlayExtensionBaseConfig,
177
+ > {
178
+ /** Get the current config object for the panel overlay. */
179
+ getConfig: () => PanelOverlayExtensionBaseConfig & Partial<Config>;
180
+ /** Update the config object for the panel overlay.
181
+ * The draft object is meant to be mutated and set to the desired state.
182
+ */
183
+ updateConfig: (updateHandler: (draft: Partial<Config>) => void) => void;
184
+ /** Get all available topics that can be subscribed to. */
185
+ getTopics: () => readonly Topic[];
186
+ /** Queue an animation frame. This will call the extension's `startFrame` when the next animation frame is ready.*/
187
+ queueAnimationFrame: () => void;
188
+ /** The container element where the panel overlay will be rendered.
189
+ * The extension is meant to either use this as a react root element, or append elements and update them manually.
190
+ */
191
+ overlayContainerElement: HTMLElement;
192
+ }
193
+ export interface PanelOverlayExtension {
194
+ /** The unique identifier for the panel overlay. */
195
+ readonly id: string;
196
+ /** The label to display in the settings panel for the panel overlay. */
197
+ readonly label?: string;
198
+ getSubscriptions: () => AnyPanelOverlaySubscription[];
199
+ /** Callback that will be fired when the available topics change.
200
+ * To get the new state of topics call `getTopics`.
201
+ */
202
+ onTopicsChanged: () => void;
203
+ /** Called when there is a user-driven settings change from the settings panel. */
204
+ handleSettingsAction: (action: SettingsTreeAction) => void;
205
+ /** Used to specify the desired fields in the panel overlay's section of the settings tree */
206
+ settingsNodeFields: () => SettingsTreeFields;
207
+ /** Will be called when there is a seek on the playback bar or sometimes when subscriptions change. */
208
+ onSeek: () => void;
209
+ /** Will be called every time the panel canvas is re-rendered by an animation frame. */
210
+ startFrame: () => void;
211
+ /** Will be called when the 3D Renderer is disposed because of a parameter change or the panel is unmounted. */
212
+ dispose: () => void;
213
+ }
214
+
215
+ export type PanelOverlayExtensionArgs<
216
+ Config extends PanelOverlayExtensionBaseConfig = PanelOverlayExtensionBaseConfig,
217
+ > = {
218
+ /** The unique identifier for the panel overlay - should match the id of the PanelOverlay */
219
+ id: string;
220
+ /** Specifies the default config for the panel overlay. */
221
+ defaultConfig: Config;
222
+ init: (context: PanelOverlayExtensionContext) => PanelOverlayExtension;
223
+ };
224
+
121
225
  export interface PanelExtensionContext extends BasePanelExtensionContext {
122
226
  /**
123
227
  * Set the items in the panel toolbar.
package/src/stable.ts CHANGED
@@ -1233,7 +1233,6 @@ export interface ExtensionModule {
1233
1233
  export type SettingsIcon =
1234
1234
  | "Add"
1235
1235
  | "Addchart"
1236
- | "AutoAwesome"
1237
1236
  | "Background"
1238
1237
  | "Camera"
1239
1238
  | "Cells"
@@ -1535,6 +1534,11 @@ export type SettingsTreeNode = {
1535
1534
  */
1536
1535
  label?: string;
1537
1536
 
1537
+ /**
1538
+ * Optional help text to explain the purpose of the node.
1539
+ */
1540
+ help?: string;
1541
+
1538
1542
  /**
1539
1543
  * True if the node label can be edited by the user.
1540
1544
  */