@foxglove/extension 2.29.1 → 2.31.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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  This package contains type definitions for writing [Foxglove](https://foxglove.dev/) extensions.
4
4
 
5
- See https://docs.foxglove.dev/docs/visualization/extensions/introduction
5
+ See https://docs.foxglove.dev/docs/extensions
6
6
 
7
7
  ## Stay in touch
8
8
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@foxglove/extension",
3
- "version": "2.29.1",
3
+ "version": "2.31.0",
4
4
  "license": "MIT",
5
5
  "author": {
6
6
  "name": "Foxglove Technologies",
package/src/stable.ts CHANGED
@@ -360,7 +360,7 @@ export type SubscribeMessageRangeArgs = {
360
360
  * extension `panelElement` unmounts.
361
361
  *
362
362
  * See the [Creating a custom
363
- * panel](https://docs.foxglove.dev/docs/visualization/extensions/guides/create-custom-panel) guide
363
+ * panel](https://docs.foxglove.dev/docs/extensions/guides/create-custom-panel) guide
364
364
  * for more details.
365
365
  *
366
366
  * @category Custom panels
@@ -415,7 +415,7 @@ export type PanelExtensionContext = {
415
415
  /**
416
416
  * Use `context.saveState` to save an arbitrary object as persisted panel state (also known as
417
417
  * panel settings) in the current layout. You can view the current panel state using
418
- * [Import/export settings](https://docs.foxglove.dev/docs/visualization/panels/introduction#importexport-settings).
418
+ * [Import/export settings](https://docs.foxglove.dev/docs/visualization/panels#importexport-settings).
419
419
  *
420
420
  * ```ts
421
421
  * context.initialState = undefined; // your panel's initial state
@@ -932,7 +932,21 @@ export type RegisterMessageConverterArgsTopic = {
932
932
  type: "topic";
933
933
  inputTopics: string[];
934
934
  outputTopic: string;
935
- schemaName: string;
935
+
936
+ /** Name of the schema for messages output by the converter.
937
+ *
938
+ * If you output well-known messages like a foxglove CompressedImage then your schema name would
939
+ * be `foxglove.CompressedImage`.
940
+ *
941
+ * If you are creating a new custom schema you can assign any name. Avoid picking an existing name
942
+ * if your data uses a different schema.
943
+ *
944
+ * NOTE: For ROS users, we also support names like `sensor_msgs/msg/CompressedImage`. See the
945
+ * supported messages documentation for each panel to learn what kinds of schemas it can display.
946
+ *
947
+ */
948
+ outputSchemaName: string;
949
+
936
950
  /**
937
951
  * Describes the structure of the output messages produced by this converter.
938
952
  *
@@ -978,11 +992,38 @@ export type RegisterMessageConverterArgsTopic = {
978
992
  * }
979
993
  * ```
980
994
  */
995
+ outputSchemaDescription?: MessageSchemaDescription;
996
+
997
+ /** @deprecated use `outputSchemaName` instead */
998
+ schemaName?: string;
999
+
1000
+ /** @deprecated use `outputSchemaDescription` instead */
981
1001
  schemaDescription?: MessageSchemaDescription;
1002
+
1003
+ /**
1004
+ *
1005
+ * The create function initializes the converter. It is called by the app to create the converter
1006
+ * when some panel subscribes to the output topic.
1007
+ *
1008
+ * ```
1009
+ * create: () => {
1010
+ * return (msgEvent: MessageEvent) => {
1011
+ * const msg = msgEvent.message as MySignal;
1012
+ * return { value: Math.abs(msg.acceleration) };
1013
+ * };
1014
+ * },
1015
+ * ```
1016
+ *
1017
+ * @returns A function that is called with a MessageEvent for every input message. It performs any
1018
+ * computation and returns a new message(s) matching the schema description. The function can
1019
+ * optionally return undefined to skip producing message(s) for the given input.
1020
+ */
982
1021
  create: () => TopicConverterReturnType;
983
1022
  };
984
1023
 
985
- type TopicConverterReturnType = (messageEvent: Immutable<MessageEvent>) => unknown;
1024
+ type TopicConverterReturnType = (
1025
+ messageEvent: Immutable<MessageEvent>,
1026
+ ) => undefined | Record<string, unknown> | Record<string, unknown>[];
986
1027
 
987
1028
  /**
988
1029
  * This type represents the arguments you pass to
@@ -996,8 +1037,8 @@ type TopicConverterReturnType = (messageEvent: Immutable<MessageEvent>) => unkno
996
1037
  * messages for visualization in the [Map
997
1038
  * panel](https://docs.foxglove.dev/docs/visualization/panels/map).
998
1039
  *
999
- * See the [Creating a message
1000
- * converter](https://docs.foxglove.dev/docs/visualization/extensions/guides/create-message-converter)
1040
+ * See the [Creating a topic
1041
+ * converter](https://docs.foxglove.dev/docs/extensions/guides/create-topic-converter)
1001
1042
  * guide for more details.
1002
1043
  *
1003
1044
  * @category Message converters
@@ -1089,7 +1130,7 @@ export interface ExtensionContext {
1089
1130
  * optional cleanup function to run when the extension `panelElement` unmounts.
1090
1131
  *
1091
1132
  * See the [Creating a custom
1092
- * panel](https://docs.foxglove.dev/docs/visualization/extensions/guides/create-custom-panel)
1133
+ * panel](https://docs.foxglove.dev/docs/extensions/guides/create-custom-panel)
1093
1134
  * guide for more details.
1094
1135
  */
1095
1136
  registerPanel(params: ExtensionPanelRegistration): void;
@@ -1284,7 +1325,7 @@ export type SettingsTreeFieldValue =
1284
1325
  validTypes?: string[];
1285
1326
  /** Only include paths from these topics in autocomplete suggestions */
1286
1327
  validTopics?: string[];
1287
- /** True if the input should allow math modifiers like @abs */
1328
+ /** True if the input should allow math modifiers like "@abs" */
1288
1329
  supportsMathModifiers?: boolean;
1289
1330
  }
1290
1331
  | {