@foxglove/extension 2.27.0 → 2.28.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,6 +1,6 @@
1
1
  {
2
2
  "name": "@foxglove/extension",
3
- "version": "2.27.0",
3
+ "version": "2.28.0",
4
4
  "license": "MIT",
5
5
  "author": {
6
6
  "name": "Foxglove Technologies",
@@ -1,53 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/no-namespace */
2
2
 
3
- import { Immutable } from "./immutable";
4
- import {
5
- ExtensionContext as BaseExtensionContext,
6
- RegisterMessageConverterArgs as LegacyRegisterMessageConverterArgs,
7
- MessageEvent,
8
- } from "./stable";
9
-
10
- export type MessageSchemaField = "string" | "number" | "bool" | "byte";
11
-
12
- /**
13
- * Describes the structure of a message with field names and their types.
14
- *
15
- * @example
16
- * ```typescript
17
- * {
18
- * // Primitive fields
19
- * position: "number",
20
- * name: "string",
21
- * active: "bool",
22
- * singleByte: "byte",
23
- *
24
- * // Arrays of primitive types
25
- * coordinates: ["number"],
26
- * labels: ["string"],
27
- * flags: ["bool"],
28
- * rawData: ["byte"],
29
- *
30
- * // Nested objects
31
- * metadata: {
32
- * timestamp: "number",
33
- * source: "string"
34
- * },
35
- *
36
- * // Arrays of objects
37
- * points: [{
38
- * x: "number",
39
- * y: "number",
40
- * z: "number"
41
- * }]
42
- * }
43
- * ```
44
- */
45
- export type MessageSchemaDescription = {
46
- [key: string]:
47
- | MessageSchemaField
48
- | MessageSchemaDescription
49
- | [MessageSchemaField | MessageSchemaDescription];
50
- };
3
+ import { ExtensionContext as BaseExtensionContext } from "./stable";
51
4
 
52
5
  /**
53
6
  * The experimental namespace contains experimental APIs that are not yet stable and WILL change or
@@ -60,155 +13,9 @@ export type MessageSchemaDescription = {
60
13
  * @hidden
61
14
  */
62
15
  export namespace Experimental {
63
- type TopicConverterReturnType = (messageEvent: Immutable<MessageEvent>) => unknown;
64
- /**
65
- * This type represents the arguments you pass to
66
- * {@link ExtensionContext.registerMessageConverter} when you want to register a topic message
67
- * converter.
68
- *
69
- * @category Message converters
70
- */
71
- export type RegisterMessageConverterArgsTopic = {
72
- type: "topic";
73
- inputTopics: string[];
74
- outputTopic: string;
75
- schemaName: string;
76
- /**
77
- * Describes the structure of the output messages produced by this converter.
78
- *
79
- * This optional field allows Foxglove to understand the structure of your messages, enabling
80
- * features like autocompletion for message path selection.
81
- *
82
- * The schema can include:
83
- * - Primitive types: "string", "number", "bool", "byte"
84
- * - Arrays of primitives: ["string"], ["number"], ["bool"], ["byte"]
85
- * - Nested objects with their own field definitions
86
- * - Arrays of objects (each element having the same structure)
87
- *
88
- * @example
89
- * ```
90
- * schemaDescription: {
91
- * // Simple fields
92
- * timestamp: "number",
93
- * label: "string",
94
- * enabled: "bool",
95
- * flags: "byte",
96
- *
97
- * // Array of primitives
98
- * values: ["number"],
99
- * names: ["string"],
100
- * options: ["bool"],
101
- * data: ["byte"],
102
- *
103
- * // Nested object
104
- * position: {
105
- * x: "number",
106
- * y: "number",
107
- * z: "number"
108
- * },
109
- *
110
- * // Array of objects
111
- * landmarks: [{
112
- * id: "string",
113
- * position: {
114
- * x: "number",
115
- * y: "number"
116
- * }
117
- * }]
118
- * }
119
- * ```
120
- */
121
- schemaDescription?: MessageSchemaDescription;
122
- create: () => TopicConverterReturnType;
123
- };
124
-
125
- /**
126
- * This type represents the arguments you pass to
127
- * {@link ExtensionContext.registerMessageConverter} when you want to register a schema message
128
- * converter.
129
- *
130
- * `schema` converters allow you to leverage Foxglove's built-in visualization panels by
131
- * transforming messages to adhere to Foxglove-supported schemas — for example, you can convert
132
- * your custom GPS messages to
133
- * [`foxglove.LocationFix`](https://docs.foxglove.dev/docs/visualization/message-schemas/location-fix)
134
- * messages for visualization in the [Map
135
- * panel](https://docs.foxglove.dev/docs/visualization/panels/map).
136
- *
137
- * See the [Creating a message
138
- * converter](https://docs.foxglove.dev/docs/visualization/extensions/guides/create-message-converter)
139
- * guide for more details.
140
- *
141
- * @category Message converters
142
- */
143
- export type RegisterMessageConverterArgsSchema<Src = unknown> = {
144
- type: "schema";
145
-
146
- /** The source message schema name. This is the schema name of the original message. */
147
- fromSchemaName: string;
148
-
149
- /**
150
- * The converted message schema name. This is the schema name of the message you will output
151
- * from the converter.
152
- */
153
- toSchemaName: string;
154
-
155
- /**
156
- * A function which takes the original message and returns the converted message.
157
- *
158
- * If the function returns `undefined`, the output is ignored, and no message is provided to the
159
- * panel. This is useful if you want to selectively output converted messages depending on the
160
- * input messages' contents.
161
- */
162
- converter: (msg: Src, event: Immutable<MessageEvent<Src>>) => unknown;
163
- };
164
-
165
- export type RegisterMessageConverterArgs =
166
- | LegacyRegisterMessageConverterArgs
167
- | RegisterMessageConverterArgsSchema
168
- | RegisterMessageConverterArgsTopic;
169
-
16
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
170
17
  export interface ExtensionContext extends BaseExtensionContext {
171
- /**
172
- * `registerMessageConverter` registers converters to transform message data within Foxglove.
173
- *
174
- * You can register two kinds of converters: `schema` and `topic`.
175
- *
176
- * `schema` converters transform messages of one schema into another. Most often this is used to
177
- * turn messages using a custom or proprietary schema into a well-known Foxglove schema for
178
- * visualization in one of the built-in panels. `schema` converters allow a built-in panel which
179
- * requires well-known messages to natively support visualizing any topic for which there is a
180
- * schema converter registered. An example is converting an `acme.Gps` message to
181
- * `foxglove.LocationFix` to visualize any topics which publish `acme.Gps` messages in the
182
- * built-in map panel.
183
- *
184
- * See: {@link RegisterMessageConverterArgsSchema}.
185
- *
186
- * `topic` converters transform messages from one-or-more input topics to a new in-app topic.
187
- * Topic converters are more flexible than schema converters but require more logic and
188
- * decisions to implement. They can transform existing data into new topics for plotting,
189
- * inspecting, and visualizing. Topic converters can combine data from several input topics,
190
- * maintain state, and create messages from these multiple topics. They can also do the opposite
191
- * - take a single topic and turn it into multiple output topics.
192
- *
193
- * See: {@link RegisterMessageConverterArgsTopic}.
194
- */
195
- registerMessageConverter(args: RegisterMessageConverterArgs): void;
196
- /**
197
- * @deprecated Use `registerMessageConverter` with `type: "schema"` or `type: "topic"` instead.
198
- */
199
- registerMessageConverter<Src>(args: LegacyRegisterMessageConverterArgs<Src>): void;
200
- /**
201
- * Register a schema message converter.
202
- *
203
- * See: {@link RegisterMessageConverterArgsSchema}.
204
- */
205
- registerMessageConverter<Src>(args: RegisterMessageConverterArgsSchema<Src>): void;
206
- /**
207
- * Register a topic message converter.
208
- *
209
- * See: {@link RegisterMessageConverterArgsTopic}.
210
- */
211
- registerMessageConverter(args: RegisterMessageConverterArgsTopic): void;
18
+ // no-op until we have experimental APIs
212
19
  }
213
20
 
214
21
  export interface ExtensionModule {
package/src/stable.ts CHANGED
@@ -879,17 +879,170 @@ export type ExtensionPanelRegistration = {
879
879
  initPanel: (context: PanelExtensionContext) => void | (() => void);
880
880
  };
881
881
 
882
+ export type MessageSchemaField = "string" | "number" | "bool" | "byte";
883
+
882
884
  /**
883
- * This type represents the arguments you pass to {@link ExtensionContext.registerMessageConverter}.
885
+ * Describes the structure of a message with field names and their types.
886
+ *
887
+ * @example
888
+ * ```typescript
889
+ * {
890
+ * // Primitive fields
891
+ * position: "number",
892
+ * name: "string",
893
+ * active: "bool",
894
+ * singleByte: "byte",
895
+ *
896
+ * // Arrays of primitive types
897
+ * coordinates: ["number"],
898
+ * labels: ["string"],
899
+ * flags: ["bool"],
900
+ * rawData: ["byte"],
901
+ *
902
+ * // Nested objects
903
+ * metadata: {
904
+ * timestamp: "number",
905
+ * source: "string"
906
+ * },
907
+ *
908
+ * // Arrays of objects
909
+ * points: [{
910
+ * x: "number",
911
+ * y: "number",
912
+ * z: "number"
913
+ * }]
914
+ * }
915
+ * ```
916
+ */
917
+ export type MessageSchemaDescription = {
918
+ [key: string]:
919
+ | MessageSchemaField
920
+ | MessageSchemaDescription
921
+ | [MessageSchemaField | MessageSchemaDescription];
922
+ };
923
+
924
+ /**
925
+ * This type represents the arguments you pass to
926
+ * {@link ExtensionContext.registerMessageConverter} when you want to register a topic message
927
+ * converter.
928
+ *
929
+ * @category Message converters
930
+ */
931
+ export type RegisterMessageConverterArgsTopic = {
932
+ type: "topic";
933
+ inputTopics: string[];
934
+ outputTopic: string;
935
+ schemaName: string;
936
+ /**
937
+ * Describes the structure of the output messages produced by this converter.
938
+ *
939
+ * This optional field allows Foxglove to understand the structure of your messages, enabling
940
+ * features like autocompletion for message path selection.
941
+ *
942
+ * The schema can include:
943
+ * - Primitive types: "string", "number", "bool", "byte"
944
+ * - Arrays of primitives: ["string"], ["number"], ["bool"], ["byte"]
945
+ * - Nested objects with their own field definitions
946
+ * - Arrays of objects (each element having the same structure)
947
+ *
948
+ * @example
949
+ * ```
950
+ * schemaDescription: {
951
+ * // Simple fields
952
+ * timestamp: "number",
953
+ * label: "string",
954
+ * enabled: "bool",
955
+ * flags: "byte",
956
+ *
957
+ * // Array of primitives
958
+ * values: ["number"],
959
+ * names: ["string"],
960
+ * options: ["bool"],
961
+ * data: ["byte"],
962
+ *
963
+ * // Nested object
964
+ * position: {
965
+ * x: "number",
966
+ * y: "number",
967
+ * z: "number"
968
+ * },
969
+ *
970
+ * // Array of objects
971
+ * landmarks: [{
972
+ * id: "string",
973
+ * position: {
974
+ * x: "number",
975
+ * y: "number"
976
+ * }
977
+ * }]
978
+ * }
979
+ * ```
980
+ */
981
+ schemaDescription?: MessageSchemaDescription;
982
+ create: () => TopicConverterReturnType;
983
+ };
984
+
985
+ type TopicConverterReturnType = (messageEvent: Immutable<MessageEvent>) => unknown;
986
+
987
+ /**
988
+ * This type represents the arguments you pass to
989
+ * {@link ExtensionContext.registerMessageConverter} when you want to register a schema message
990
+ * converter.
991
+ *
992
+ * `schema` converters allow you to leverage Foxglove's built-in visualization panels by
993
+ * transforming messages to adhere to Foxglove-supported schemas — for example, you can convert
994
+ * your custom GPS messages to
995
+ * [`foxglove.LocationFix`](https://docs.foxglove.dev/docs/visualization/message-schemas/location-fix)
996
+ * messages for visualization in the [Map
997
+ * panel](https://docs.foxglove.dev/docs/visualization/panels/map).
998
+ *
999
+ * See the [Creating a message
1000
+ * converter](https://docs.foxglove.dev/docs/visualization/extensions/guides/create-message-converter)
1001
+ * guide for more details.
884
1002
  *
885
1003
  * @category Message converters
886
1004
  */
887
- export type RegisterMessageConverterArgs<Src = unknown> = {
1005
+ export type RegisterMessageConverterArgsSchema<Src = unknown> = {
1006
+ type: "schema";
1007
+
1008
+ /** The source message schema name. This is the schema name of the original message. */
1009
+ fromSchemaName: string;
1010
+
1011
+ /**
1012
+ * The converted message schema name. This is the schema name of the message you will output
1013
+ * from the converter.
1014
+ */
1015
+ toSchemaName: string;
1016
+
1017
+ /**
1018
+ * A function which takes the original message and returns the converted message.
1019
+ *
1020
+ * If the function returns `undefined`, the output is ignored, and no message is provided to the
1021
+ * panel. This is useful if you want to selectively output converted messages depending on the
1022
+ * input messages' contents.
1023
+ */
1024
+ converter: (msg: Src, event: Immutable<MessageEvent<Src>>) => unknown;
1025
+ };
1026
+
1027
+ /**
1028
+ * @deprecated Use {@link RegisterMessageConverterArgsSchema} instead.
1029
+ */
1030
+ export type LegacyRegisterMessageConverterArgs<Src = unknown> = {
888
1031
  fromSchemaName: string;
889
1032
  toSchemaName: string;
890
1033
  converter: (msg: Src, event: Immutable<MessageEvent<Src>>) => unknown;
891
1034
  };
892
1035
 
1036
+ /**
1037
+ * This type represents the arguments you pass to {@link ExtensionContext.registerMessageConverter}.
1038
+ *
1039
+ * @category Message converters
1040
+ */
1041
+ export type RegisterMessageConverterArgs =
1042
+ | LegacyRegisterMessageConverterArgs
1043
+ | RegisterMessageConverterArgsSchema
1044
+ | RegisterMessageConverterArgsTopic;
1045
+
893
1046
  /** @category Topic aliases */
894
1047
  export type BaseTopic = { name: string; schemaName?: string };
895
1048
  /** @category Topic aliases */
@@ -942,27 +1095,46 @@ export interface ExtensionContext {
942
1095
  registerPanel(params: ExtensionPanelRegistration): void;
943
1096
 
944
1097
  /**
945
- * `registerMessageConverter` registers a function to convert messages from one schema to another.
1098
+ * `registerMessageConverter` registers converters to transform message data within Foxglove.
946
1099
  *
947
- * Message converters allow you to leverage Foxglove's built-in visualization panels by
948
- * transforming messages to adhere to Foxglove-supported schemas — for example, you can convert
949
- * your custom GPS messages to
950
- * [`foxglove.LocationFix`](https://docs.foxglove.dev/docs/visualization/message-schemas/location-fix)
951
- * messages for visualization in the [Map
952
- * panel](https://docs.foxglove.dev/docs/visualization/panels/map).
1100
+ * You can register two kinds of converters: `schema` and `topic`.
953
1101
  *
954
- * Whenever a panel subscribes to a topic with the
955
- * [`convertTo`](https://docs.foxglove.dev/docs/visualization/extensions/api/panel#message-converters)
956
- * option, the converter function runs on the original message and outputs the converted message,
957
- * which it then provides it to the panel. If the function returns `undefined`, the output is
958
- * ignored, and no message is provided to the panel. This is useful if you want to selectively
959
- * output converted messages depending on the input messages' contents.
1102
+ * `schema` converters transform messages of one schema into another. Most often this is used to
1103
+ * turn messages using a custom or proprietary schema into a well-known Foxglove schema for
1104
+ * visualization in one of the built-in panels. `schema` converters allow a built-in panel which
1105
+ * requires well-known messages to natively support visualizing any topic for which there is a
1106
+ * schema converter registered. An example is converting an `acme.Gps` message to
1107
+ * `foxglove.LocationFix` to visualize any topics which publish `acme.Gps` messages in the
1108
+ * built-in map panel.
960
1109
  *
961
- * See the [Creating a message
962
- * converter](https://docs.foxglove.dev/docs/visualization/extensions/guides/create-message-converter)
963
- * guide for more details.
1110
+ * See: {@link RegisterMessageConverterArgsSchema}.
1111
+ *
1112
+ * `topic` converters transform messages from one-or-more input topics to a new in-app topic.
1113
+ * Topic converters are more flexible than schema converters but require more logic and
1114
+ * decisions to implement. They can transform existing data into new topics for plotting,
1115
+ * inspecting, and visualizing. Topic converters can combine data from several input topics,
1116
+ * maintain state, and create messages from these multiple topics. They can also do the opposite
1117
+ * - take a single topic and turn it into multiple output topics.
1118
+ *
1119
+ * See: {@link RegisterMessageConverterArgsTopic}.
1120
+ */
1121
+ registerMessageConverter(args: RegisterMessageConverterArgs): void;
1122
+ /**
1123
+ * @deprecated Use `registerMessageConverter` with `type: "schema"` or `type: "topic"` instead.
1124
+ */
1125
+ registerMessageConverter<Src>(args: LegacyRegisterMessageConverterArgs<Src>): void;
1126
+ /**
1127
+ * Register a schema message converter.
1128
+ *
1129
+ * See: {@link RegisterMessageConverterArgsSchema}.
1130
+ */
1131
+ registerMessageConverter<Src>(args: RegisterMessageConverterArgsSchema<Src>): void;
1132
+ /**
1133
+ * Register a topic message converter.
1134
+ *
1135
+ * See: {@link RegisterMessageConverterArgsTopic}.
964
1136
  */
965
- registerMessageConverter<Src>(args: RegisterMessageConverterArgs<Src>): void;
1137
+ registerMessageConverter(args: RegisterMessageConverterArgsTopic): void;
966
1138
 
967
1139
  /**
968
1140
  * `registerTopicAliases` registers a function to compute topic aliases. The provided alias
@@ -1236,7 +1408,7 @@ export type SettingsTreeNodeActionItem = {
1236
1408
  type: "action";
1237
1409
 
1238
1410
  /**
1239
- * A unique idenfier for the action.
1411
+ * A unique identifier for the action.
1240
1412
  */
1241
1413
  id: string;
1242
1414
 
@@ -1256,6 +1428,11 @@ export type SettingsTreeNodeActionItem = {
1256
1428
  * as an icon only if their icon is specified.
1257
1429
  */
1258
1430
  display?: "menu" | "inline";
1431
+
1432
+ /**
1433
+ * Whether this action is disabled or not. Defaults to false.
1434
+ */
1435
+ disabled?: boolean;
1259
1436
  };
1260
1437
 
1261
1438
  /**