@foxglove/extension 2.40.1 → 2.41.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 +1 -1
  2. package/src/stable.ts +16 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@foxglove/extension",
3
- "version": "2.40.1",
3
+ "version": "2.41.0",
4
4
  "license": "MIT",
5
5
  "author": {
6
6
  "name": "Foxglove Technologies",
package/src/stable.ts CHANGED
@@ -1007,16 +1007,28 @@ export type RegisterMessageConverterArgsTopic = {
1007
1007
  /** @deprecated use `outputSchemaDescription` instead */
1008
1008
  schemaDescription?: MessageSchemaDescription;
1009
1009
 
1010
+ /**
1011
+ * Optional list of global variable names that this converter depends on. When any of these
1012
+ * variables change, the converter will be recreated with the updated global variable values. If
1013
+ * watchVariables is an empty list or undefined, the converter will not be recreated when variables
1014
+ * change.
1015
+ */
1016
+ watchVariables?: string[];
1017
+
1010
1018
  /**
1011
1019
  *
1012
1020
  * The create function initializes the converter. It is called by the app to create the converter
1013
- * when some panel subscribes to the output topic.
1021
+ * when some panel subscribes to the output topic. This receive the global variables as an optional
1022
+ * first argument. When a watched variable changes, the converter will be recreated with the updated
1023
+ * global variable values.
1024
+ * Global variables do not cause re-processing of current frame data.
1014
1025
  *
1015
1026
  * ```
1016
- * create: () => {
1027
+ * create: (globalVariables) => {
1028
+ * const threshold = globalVariables.threshold ?? 0;
1017
1029
  * return (msgEvent: MessageEvent) => {
1018
1030
  * const msg = msgEvent.message as MySignal;
1019
- * return { value: Math.abs(msg.acceleration) };
1031
+ * return { value: Math.abs(msg.acceleration), aboveThreshold: Math.abs(msg.acceleration) > threshold };
1020
1032
  * };
1021
1033
  * },
1022
1034
  * ```
@@ -1025,7 +1037,7 @@ export type RegisterMessageConverterArgsTopic = {
1025
1037
  * computation and returns a new message(s) matching the schema description. The function can
1026
1038
  * optionally return undefined to skip producing message(s) for the given input.
1027
1039
  */
1028
- create: () => TopicConverterReturnType;
1040
+ create: (globalVariables: Readonly<Record<string, VariableValue>>) => TopicConverterReturnType;
1029
1041
  };
1030
1042
 
1031
1043
  type TopicConverterReturnType = (