@kemu-io/edge-runtime 0.1.13 → 0.1.15

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 (3) hide show
  1. package/package.json +1 -1
  2. package/runner.d.ts +70 -0
  3. package/runner.js +2 -2
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kemu-io/edge-runtime",
3
3
  "type": "module",
4
- "version": "0.1.13",
4
+ "version": "0.1.15",
5
5
  "description": "Kemu Edge runtime for running Kemu recipes",
6
6
  "author": "Kemu Pty Ltd",
7
7
  "main": "runner.js",
package/runner.d.ts CHANGED
@@ -71,6 +71,69 @@ export type Data = {
71
71
  timestamp: number;
72
72
  };
73
73
  export type PartialData = Omit<Data, "timestamp">;
74
+ declare enum WidgetType {
75
+ input = "input",
76
+ counter = "counter",
77
+ play = "play",
78
+ elapsed = "elapsed",
79
+ ifGate = "ifGate",
80
+ skipEvent = "skipEvent",
81
+ between = "between",
82
+ map = "map",
83
+ parser = "parser",
84
+ slider = "slider",
85
+ suspend = "suspend",
86
+ display = "display",
87
+ json = "json",
88
+ arrayItem = "arrayItem",
89
+ extractImage = "extractImage",
90
+ imageConvolution = "imageConvolution",
91
+ firstEvent = "firstEvent",
92
+ pixelDraw = "pixelDraw",
93
+ randomBetween = "randomBetween",
94
+ arrayCombine = "arrayCombine",
95
+ clock = "clock",
96
+ multiplication = "multiplication",
97
+ object = "object",
98
+ widgetGroup = "widgetGroup",
99
+ script = "script",
100
+ base64ToImageData = "base64ToImageData",
101
+ jsonParse = "jsonParse",
102
+ text = "text",
103
+ imageCrop = "imageCrop",
104
+ imageResize = "imageResize",
105
+ value = "value",
106
+ imageWarp = "imageWarp",
107
+ widgetBundle = "widgetBundle",
108
+ sequence = "sequence",
109
+ variable = "variable",
110
+ hubService = "hubService",
111
+ imageFilter = "imageFilter",
112
+ recipeLoad = "recipeLoad"
113
+ }
114
+ export type VariableDefinition = {
115
+ /**
116
+ * the type of widget that created the variable, this in
117
+ * order to speed up scope resolution of the variable when accessed.
118
+ **/
119
+ ownerType: WidgetType;
120
+ /**
121
+ * The data type held by the variable.
122
+ */
123
+ type: DataType;
124
+ /**
125
+ * indicates if its value should be stored as part of the recipe
126
+ * when the recipe is saved
127
+ **/
128
+ storeValueInRecipe: boolean;
129
+ /** the id of the widget that registered the variable */
130
+ createdByWidgetId: string;
131
+ /** indicates if the variable is a reference to a widget's custom field */
132
+ isCustomFieldVar: boolean;
133
+ /** the current value of the variable */
134
+ value?: SupportedTypes;
135
+ };
136
+ export type VarValueChangeEvt = Readonly<Pick<VariableDefinition, "type" | "value">>;
74
137
  export declare const utils: {
75
138
  /**
76
139
  * Builds an object that represents an ImageData type. This is useful when services
@@ -100,6 +163,13 @@ declare const _default: {
100
163
  }) => Promise<{
101
164
  /** use it to send data to input widgets */
102
165
  sendToInputWidget: (inputName: string, data: PartialData, thingId?: string | undefined) => Promise<void>;
166
+ /**
167
+ * Sets a listener to changes in the value of a variable.
168
+ * @param varName the name of the variable to listen to. Set it to `*` to listen to all variable changes.
169
+ * @param cb the callback function to be invoked.
170
+ * @returns a function to remove the listener.
171
+ */
172
+ onVariableChange: (varName: string, cb: (evt: VarValueChangeEvt) => void | Promise<void>) => void;
103
173
  }>;
104
174
  terminate: () => Promise<void>;
105
175
  };