@foxglove/extension 2.45.0 → 2.47.0

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,13 +1,18 @@
1
1
  {
2
2
  "name": "@foxglove/extension",
3
- "version": "2.45.0",
3
+ "version": "2.47.0",
4
4
  "license": "MIT",
5
5
  "author": {
6
6
  "name": "Foxglove Technologies",
7
7
  "email": "support@foxglove.dev"
8
8
  },
9
9
  "homepage": "https://foxglove.dev/",
10
+ "type": "module",
10
11
  "main": "./src/index.ts",
12
+ "exports": {
13
+ ".": "./src/index.ts",
14
+ "./experimental": "./src/experimental.ts"
15
+ },
11
16
  "files": [
12
17
  "src"
13
18
  ],
@@ -15,7 +20,7 @@
15
20
  "prepack": "tsc -b tsconfig.json"
16
21
  },
17
22
  "devDependencies": {
18
- "@foxglove/tsconfig": "3.1.0",
23
+ "@foxglove/tsconfig": "3.2.0",
19
24
  "typescript": "5.9.3"
20
25
  }
21
26
  }
@@ -1,14 +1,9 @@
1
1
  /* eslint-disable @typescript-eslint/no-namespace */
2
- import type { Immutable } from "./immutable";
2
+ import type { Immutable } from "./immutable.ts";
3
3
  import type {
4
4
  ExtensionContext as BaseExtensionContext,
5
- MessageEvent,
6
5
  PanelExtensionContext as BasePanelExtensionContext,
7
- SettingsTreeAction,
8
- SettingsTreeFields,
9
- SettingsTreeNode,
10
- Topic,
11
- } from "./stable";
6
+ } from "./stable.ts";
12
7
 
13
8
  /**
14
9
  * The experimental namespace contains experimental APIs that are not yet stable and WILL change or
@@ -119,7 +114,7 @@ export namespace Experimental {
119
114
  */
120
115
  export type VideoFrameDecoder = Pick<
121
116
  VideoDecoder,
122
- "close" | "configure" | "decode" | "reset" | "state"
117
+ "close" | "configure" | "decode" | "reset" | "state" | "decodeQueueSize" | "ondequeue"
123
118
  >;
124
119
 
125
120
  /**
@@ -140,13 +135,6 @@ export namespace Experimental {
140
135
  */
141
136
  registerDataLoader(args: RegisterDataLoaderArgs): void;
142
137
 
143
- /**
144
- * Register a panel overlay extension to create 2D HTML overlays for 3D and Image panels
145
- *
146
- * See: {@link PanelOverlayExtensionArgs}
147
- */
148
- registerPanelOverlay(args: PanelOverlayExtensionArgs): void;
149
-
150
138
  /**
151
139
  * `registerPanel` adds a new panel to the Foxglove interface. To register a panel you provide a
152
140
  * `name` and an `initPanel` function.
@@ -210,11 +198,15 @@ export namespace Experimental {
210
198
  /**
211
199
  * This function will be called when your extension is loaded. In this function, you can register
212
200
  * your custom panels or other types of extension features.
201
+ *
202
+ * The function may return a Promise if async initialization is needed before registering
203
+ * extension features. The extension will not be considered fully activated until the Promise
204
+ * resolves.
213
205
  */
214
206
  activate: ExtensionActivate;
215
207
  }
216
208
 
217
- export type ExtensionActivate = (extensionContext: ExtensionContext) => void;
209
+ export type ExtensionActivate = (extensionContext: ExtensionContext) => void | Promise<void>;
218
210
 
219
211
  /**
220
212
  * A button in the panel toolbar.
@@ -277,98 +269,6 @@ export namespace Experimental {
277
269
  */
278
270
  export type PanelToolbarItem = PanelToolbarButton | PanelToolbarLink | PanelToolbarDivider;
279
271
 
280
- export type PanelOverlayExtensionBaseConfig = { visible: boolean };
281
-
282
- export type PanelOverlaySubscription<T = unknown> = {
283
- /**
284
- * This method will only be run against Topics with schemas that match the topic or schema of the overarching subscription.
285
- * So if you always want to receive messages from a topic with a given name or schema you can simply return true.
286
- * These subscriptions will only be active when the custom layer extension's visibility is true.
287
- */
288
- shouldSubscribe?: (topic: string, schema: string) => boolean;
289
- /** Callback that will be fired for each matching incoming message */
290
- handler: (messageEvent: MessageEvent<T>) => void;
291
- /** Queue of messages to be handled since last frame. Will be reassigned to new empty array each frame. */
292
- queue?: MessageEvent<T>[] | undefined;
293
- /** Optional callback to be called on `queue` to filter. Returns new queue. */
294
- filterQueue?: (queue: ReadonlyArray<MessageEvent<T>>) => ReadonlyArray<MessageEvent<T>>;
295
- };
296
-
297
- export type AnyPanelOverlaySubscription = Immutable<
298
- | {
299
- type: "schema";
300
- schemaNames: Set<string>;
301
- // any is used here to allow storing heterogeneous arrays of subscriptions
302
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
303
- subscription: PanelOverlaySubscription<any>;
304
- }
305
- | {
306
- type: "topic";
307
- topicName: string;
308
- // any is used here to allow storing heterogeneous arrays of subscriptions
309
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
310
- subscription: PanelOverlaySubscription<any>;
311
- }
312
- >;
313
-
314
- export type ActionHandler = (action: SettingsTreeAction) => void;
315
-
316
- export type SettingsTreeNodeWithActionHandler = SettingsTreeNode & { handler?: ActionHandler };
317
-
318
- export type SettingsPath = ReadonlyArray<string>;
319
-
320
- export type SettingsTreeEntry = { path: SettingsPath; node: SettingsTreeNodeWithActionHandler };
321
-
322
- export interface PanelOverlayExtensionContext<
323
- Config extends PanelOverlayExtensionBaseConfig = PanelOverlayExtensionBaseConfig,
324
- > {
325
- /** Get the current config object for the panel overlay. */
326
- getConfig: () => PanelOverlayExtensionBaseConfig & Partial<Config>;
327
- /** Update the config object for the panel overlay.
328
- * The draft object is meant to be mutated and set to the desired state.
329
- */
330
- updateConfig: (updateHandler: (draft: Partial<Config>) => void) => void;
331
- /** Get all available topics that can be subscribed to. */
332
- getTopics: () => readonly Topic[];
333
- /** Queue an animation frame. This will call the extension's `startFrame` when the next animation frame is ready.*/
334
- queueAnimationFrame: () => void;
335
- /** The container element where the panel overlay will be rendered.
336
- * The extension is meant to either use this as a react root element, or append elements and update them manually.
337
- */
338
- overlayContainerElement: HTMLElement;
339
- }
340
- export interface PanelOverlayExtension {
341
- /** The unique identifier for the panel overlay. */
342
- readonly id: string;
343
- /** The label to display in the settings panel for the panel overlay. */
344
- readonly label?: string;
345
- getSubscriptions: () => AnyPanelOverlaySubscription[];
346
- /** Callback that will be fired when the available topics change.
347
- * To get the new state of topics call `getTopics`.
348
- */
349
- onTopicsChanged: () => void;
350
- /** Called when there is a user-driven settings change from the settings panel. */
351
- handleSettingsAction: (action: SettingsTreeAction) => void;
352
- /** Used to specify the desired fields in the panel overlay's section of the settings tree */
353
- settingsNodeFields: () => SettingsTreeFields;
354
- /** Will be called when there is a seek on the playback bar or sometimes when subscriptions change. */
355
- onSeek: () => void;
356
- /** Will be called every time the panel canvas is re-rendered by an animation frame. */
357
- startFrame: () => void;
358
- /** Will be called when the 3D Renderer is disposed because of a parameter change or the panel is unmounted. */
359
- dispose: () => void;
360
- }
361
-
362
- export type PanelOverlayExtensionArgs<
363
- Config extends PanelOverlayExtensionBaseConfig = PanelOverlayExtensionBaseConfig,
364
- > = {
365
- /** The unique identifier for the panel overlay - should match the id of the PanelOverlay */
366
- id: string;
367
- /** Specifies the default config for the panel overlay. */
368
- defaultConfig: Config;
369
- init: (context: PanelOverlayExtensionContext) => PanelOverlayExtension;
370
- };
371
-
372
272
  export interface PanelExtensionContext extends BasePanelExtensionContext {
373
273
  /**
374
274
  * Set the items in the panel toolbar.
package/src/index.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from "./stable";
2
- export type { Immutable } from "./immutable";
3
- export type { Experimental } from "./experimental";
1
+ export * from "./stable.ts";
2
+ export type { Immutable } from "./immutable.ts";
3
+ export type { Experimental } from "./experimental.ts";
package/src/stable.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Immutable } from "./immutable";
1
+ import type { Immutable } from "./immutable.ts";
2
2
 
3
3
  /** Valid types for parameter data (such as rosparams) */
4
4
  export type ParameterValue =
@@ -1214,7 +1214,7 @@ export interface ExtensionContext {
1214
1214
  * @inline
1215
1215
  * @hidden
1216
1216
  */
1217
- export type ExtensionActivate = (extensionContext: ExtensionContext) => void;
1217
+ export type ExtensionActivate = (extensionContext: ExtensionContext) => void | Promise<void>;
1218
1218
 
1219
1219
  /**
1220
1220
  * ExtensionModule describes the interface your extension module must export. This typically corresponds to your `index.ts` file.
@@ -1234,12 +1234,29 @@ export type ExtensionActivate = (extensionContext: ExtensionContext) => void;
1234
1234
  * export default { activate };
1235
1235
  * ```
1236
1236
  *
1237
+ * The `activate` function can also return a Promise to perform async initialization before
1238
+ * registering panels or converters:
1239
+ *
1240
+ * ```typescript
1241
+ * export async function activate(context: ExtensionContext) {
1242
+ * // Initialize WASM or other async resources
1243
+ * await initializeWasm();
1244
+ *
1245
+ * // Now register panels/converters that depend on the initialized resources
1246
+ * context.registerPanel({ ... });
1247
+ * }
1248
+ * ```
1249
+ *
1237
1250
  * @category Entry point
1238
1251
  */
1239
1252
  export interface ExtensionModule {
1240
1253
  /**
1241
1254
  * This function will be called when your extension is loaded. In this function, you can register
1242
1255
  * your custom panels or other types of extension features.
1256
+ *
1257
+ * The function may return a Promise if async initialization is needed before registering
1258
+ * extension features. The extension will not be considered fully activated until the Promise
1259
+ * resolves.
1243
1260
  */
1244
1261
  activate: ExtensionActivate;
1245
1262
  }
@@ -1344,7 +1361,12 @@ export type SettingsTreeFieldValue =
1344
1361
  validTypes?: string[];
1345
1362
  /** Only include paths from these topics in autocomplete suggestions */
1346
1363
  validTopics?: string[];
1347
- /** True if the input should allow math modifiers like "@abs" */
1364
+ /** True if the input should allow message path functions like "@abs" */
1365
+ supportsMessagePathFunctions?: boolean;
1366
+ /**
1367
+ * @deprecated Use `supportsMessagePathFunctions` instead.
1368
+ * True if the input should allow message path functions like "@abs".
1369
+ */
1348
1370
  supportsMathModifiers?: boolean;
1349
1371
  }
1350
1372
  | {