@foxglove/extension 2.24.0 → 2.25.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.24.0",
3
+ "version": "2.25.1",
4
4
  "license": "MIT",
5
5
  "author": {
6
6
  "name": "Foxglove Technologies",
@@ -0,0 +1,135 @@
1
+ /* eslint-disable @typescript-eslint/no-namespace */
2
+
3
+ import { Immutable } from "./immutable";
4
+ import {
5
+ ExtensionContext as BaseExtensionContext,
6
+ RegisterMessageConverterArgs as LegacyRegisterMessageConverterArgs,
7
+ MessageEvent,
8
+ } from "./stable";
9
+
10
+ /**
11
+ * The experimental namespace contains experimental APIs that are not yet stable and WILL change or
12
+ * be REMOVED at any time.
13
+ *
14
+ * These APIS are provided for isolated testing and feedback.You should avoid shipping org
15
+ * extensions which depend on them because they WILL break in different versions of Foxglove and
16
+ * can be CHANGED or REMOVED at any time.
17
+ *
18
+ * @hidden
19
+ */
20
+ export namespace Experimental {
21
+ type TopicConverterReturnType = (messageEvent: Immutable<MessageEvent>) => unknown;
22
+ /**
23
+ * This type represents the arguments you pass to
24
+ * {@link ExtensionContext.registerMessageConverter} when you want to register a topic message
25
+ * converter.
26
+ *
27
+ * @category Message converters
28
+ */
29
+ export type RegisterMessageConverterArgsTopic = {
30
+ type: "topic";
31
+ inputTopics: string[];
32
+ outputTopic: string;
33
+ schemaName: string;
34
+ create: () => TopicConverterReturnType;
35
+ };
36
+
37
+ /**
38
+ * This type represents the arguments you pass to
39
+ * {@link ExtensionContext.registerMessageConverter} when you want to register a schema message
40
+ * converter.
41
+ *
42
+ * `schema` converters allow you to leverage Foxglove's built-in visualization panels by
43
+ * transforming messages to adhere to Foxglove-supported schemas — for example, you can convert
44
+ * your custom GPS messages to
45
+ * [`foxglove.LocationFix`](https://docs.foxglove.dev/docs/visualization/message-schemas/location-fix)
46
+ * messages for visualization in the [Map
47
+ * panel](https://docs.foxglove.dev/docs/visualization/panels/map).
48
+ *
49
+ * See the [Creating a message
50
+ * converter](https://docs.foxglove.dev/docs/visualization/extensions/guides/create-message-converter)
51
+ * guide for more details.
52
+ *
53
+ * @category Message converters
54
+ */
55
+ export type RegisterMessageConverterArgsSchema<Src = unknown> = {
56
+ type: "schema";
57
+
58
+ /** The source message schema name. This is the schema name of the original message. */
59
+ fromSchemaName: string;
60
+
61
+ /**
62
+ * The converted message schema name. This is the schema name of the message you will output
63
+ * from the converter.
64
+ */
65
+ toSchemaName: string;
66
+
67
+ /**
68
+ * A function which takes the original message and returns the converted message.
69
+ *
70
+ * If the function returns `undefined`, the output is ignored, and no message is provided to the
71
+ * panel. This is useful if you want to selectively output converted messages depending on the
72
+ * input messages' contents.
73
+ */
74
+ converter: (msg: Src, event: Immutable<MessageEvent<Src>>) => unknown;
75
+ };
76
+
77
+ export type RegisterMessageConverterArgs =
78
+ | LegacyRegisterMessageConverterArgs
79
+ | RegisterMessageConverterArgsSchema
80
+ | RegisterMessageConverterArgsTopic;
81
+
82
+ export interface ExtensionContext extends BaseExtensionContext {
83
+ /**
84
+ * `registerMessageConverter` registers converters to transform message data within Foxglove.
85
+ *
86
+ * You can register two kinds of converters: `schema` and `topic`.
87
+ *
88
+ * `schema` converters transform messages of one schema into another. Most often this is used to
89
+ * turn messages using a custom or proprietary schema into a well-known Foxglove schema for
90
+ * visualization in one of the built-in panels. `schema` converters allow a built-in panel which
91
+ * requires well-known messages to natively support visualizing any topic for which there is a
92
+ * schema converter registered. An example is converting an `acme.Gps` message to
93
+ * `foxglove.LocationFix` to visualize any topics which publish `acme.Gps` messages in the
94
+ * built-in map panel.
95
+ *
96
+ * See: {@link RegisterMessageConverterArgsSchema}.
97
+ *
98
+ * `topic` converters transform messages from one-or-more input topics to a new in-app topic.
99
+ * Topic converters are more flexible than schema converters but require more logic and
100
+ * decisions to implement. They can transform existing data into new topics for plotting,
101
+ * inspecting, and visualizing. Topic converters can combine data from several input topics,
102
+ * maintain state, and create messages from these multiple topics. They can also do the opposite
103
+ * - take a single topic and turn it into multiple output topics.
104
+ *
105
+ * See: {@link RegisterMessageConverterArgsTopic}.
106
+ */
107
+ registerMessageConverter(args: RegisterMessageConverterArgs): void;
108
+ /**
109
+ * @deprecated Use `registerMessageConverter` with `type: "schema"` or `type: "topic"` instead.
110
+ */
111
+ registerMessageConverter<Src>(args: LegacyRegisterMessageConverterArgs<Src>): void;
112
+ /**
113
+ * Register a schema message converter.
114
+ *
115
+ * See: {@link RegisterMessageConverterArgsSchema}.
116
+ */
117
+ registerMessageConverter<Src>(args: RegisterMessageConverterArgsSchema<Src>): void;
118
+ /**
119
+ * Register a topic message converter.
120
+ *
121
+ * See: {@link RegisterMessageConverterArgsTopic}.
122
+ */
123
+ registerMessageConverter(args: RegisterMessageConverterArgsTopic): void;
124
+ }
125
+
126
+ export interface ExtensionModule {
127
+ /**
128
+ * This function will be called when your extension is loaded. In this function, you can register
129
+ * your custom panels or other types of extension features.
130
+ */
131
+ activate: ExtensionActivate;
132
+ }
133
+
134
+ export type ExtensionActivate = (extensionContext: ExtensionContext) => void;
135
+ }