@foxglove/extension 2.20.0 → 2.22.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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/index.ts +59 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@foxglove/extension",
3
- "version": "2.20.0",
3
+ "version": "2.22.0",
4
4
  "license": "MIT",
5
5
  "author": {
6
6
  "name": "Foxglove Technologies",
@@ -16,6 +16,6 @@
16
16
  },
17
17
  "devDependencies": {
18
18
  "@foxglove/tsconfig": "2.0.0",
19
- "typescript": "5.6.3"
19
+ "typescript": "5.7.3"
20
20
  }
21
21
  }
package/src/index.ts CHANGED
@@ -235,6 +235,50 @@ export type RenderState = {
235
235
  appSettings?: Map<string, AppSettingValue>;
236
236
  };
237
237
 
238
+ type SubscribeMessageRangeArgs = {
239
+ /**
240
+ * Topic to be subscribed to.
241
+ */
242
+ topic: string;
243
+ /**
244
+ * Convert messages to this schema before delivering to the subscriber.
245
+ *
246
+ * MessageEvents for the subscription will contain the converted message and an
247
+ * `originalMessageEvent` field with the original message event. If no `convertTo` schema is
248
+ * specified, then no message converters will be used. If no message converter exists for
249
+ * converting the original schema to the `convertTo` schema, then no messages are delivered for
250
+ * this subscription.
251
+ */
252
+ convertTo?: string;
253
+ /**
254
+ * `onReset` is a function that receives an async iterable when there is message data available on
255
+ * the subscription.
256
+ *
257
+ * To read messages, your function should iterate through the provided async iterable. Each item
258
+ * of the iterable is a batch of message events for the subscription's topic. These batches and
259
+ * messages are in _log time_ order. When there are no more messages to read the iterator will
260
+ * finish.
261
+ *
262
+ * ```typescript
263
+ * async function onReset(batchIterator) {
264
+ * for await (const batch of batchIterator) {
265
+ * //...
266
+ * }
267
+ * }
268
+ * ```
269
+ *
270
+ * `onReset` is called again when the upstream topic data changes. I.E subscribing to a
271
+ * user-script output topic and the user script changes, or subscribing to an aliased topic and
272
+ * the alias changes. When topic data changes, the previous iterator will end, and its data is no
273
+ * longer valid. When `onReset` is called, you should discard previously received data.
274
+ *
275
+ * If your `onReset` function throws an error, the iterator will end and you will not receive any
276
+ * more messages until `onReset` is called again. Your error will appear in the problems sidebar
277
+ * for user visibility.
278
+ */
279
+ onReset: (batchIterator: AsyncIterable<Immutable<MessageEvent[]>>) => Promise<void>;
280
+ };
281
+
238
282
  export type PanelExtensionContext = {
239
283
  /**
240
284
  * The root element for the panel. Add your panel elements as children under this element.
@@ -391,6 +435,21 @@ export type PanelExtensionContext = {
391
435
  * manually. A value of `undefined` will display the panel's name in the title bar.
392
436
  */
393
437
  setDefaultPanelTitle(defaultTitle: string | undefined): void;
438
+ /**
439
+ * NOTE: UNSTABLE API SUBJECT TO CHANGE
440
+ *
441
+ * Subscribe to receive the entire time range of messages for a given topic for the current data source.
442
+ *
443
+ * See `SubscribeMessageRangeArgs` for more information on behavior.
444
+ *
445
+ * Note: This will not read messages for live sources, like foxglove bridge, rosbridge, or ROS1
446
+ * native. For those messages you will still need to use `context.subscribe()` and
447
+ * watch("currentFrame").
448
+ *
449
+ * @returns A function that will unsubscribe from the topic, cancel the active async iterator,
450
+ * and prevent `onReset` from being called again.
451
+ */
452
+ UNSTABLE_subscribeMessageRange?: (args: SubscribeMessageRangeArgs) => () => void;
394
453
  };
395
454
 
396
455
  export type ExtensionPanelRegistration = {