@node-projects/web-component-designer-visualization-addons 0.1.57 → 0.1.59
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.
|
@@ -104,7 +104,7 @@ export class SimpleScriptEditor extends BaseCustomWebComponentConstructorAppend
|
|
|
104
104
|
if (!property.specialAllreadyAdded) {
|
|
105
105
|
//@ts-ignore
|
|
106
106
|
property.specialAllreadyAdded = true;
|
|
107
|
-
if (typeof currentValue === 'object' && currentValue !== null) {
|
|
107
|
+
if ((typeof currentValue === 'object' && currentValue !== null) || property.format === 'complex') {
|
|
108
108
|
let rB = document.createElement('button');
|
|
109
109
|
rB.style.height = 'calc(100% - 6px)';
|
|
110
110
|
rB.style.position = 'relative';
|
|
@@ -121,7 +121,8 @@ export class SimpleScriptEditor extends BaseCustomWebComponentConstructorAppend
|
|
|
121
121
|
let d = document.createElement('div');
|
|
122
122
|
d.style.display = 'flex';
|
|
123
123
|
let sp = document.createElement('span');
|
|
124
|
-
|
|
124
|
+
if (currentValue)
|
|
125
|
+
sp.innerText = 'complex: ' + JSON.stringify(currentValue);
|
|
125
126
|
sp.style.overflow = 'hidden';
|
|
126
127
|
sp.style.whiteSpace = 'nowrap';
|
|
127
128
|
sp.style.textOverflow = 'ellipsis';
|
|
@@ -19,6 +19,8 @@ export interface VisualizationHandler {
|
|
|
19
19
|
unsubscribeState(id: string, cb: StateChangeHandler, info: any): void;
|
|
20
20
|
getHistoricData(id: string, config: any): any;
|
|
21
21
|
getObject(id: string): Promise<Signal>;
|
|
22
|
+
writeSignalsInGroup?(group: string): Promise<void>;
|
|
23
|
+
clearSignalsInGroup?(group: string): Promise<void>;
|
|
22
24
|
getAllNames(type: string): any;
|
|
23
25
|
getSignalInformation(signal: Signal): SignalInformation;
|
|
24
26
|
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
export declare type ScriptCommands = OpenScreen | OpenUrl | OpenDialog | CloseDialog | ToggleSignalValue | SetSignalValue | IncrementSignalValue | DecrementSignalValue | SetBitInSignal | ClearBitInSignal | ToggleBitInSignal | Console | CalculateSignalValue | Javascript | SetElementProperty | Delay | SwitchLanguage | Login | Logout;
|
|
1
|
+
export declare type ScriptCommands = Comment | OpenScreen | OpenUrl | OpenDialog | CloseDialog | ToggleSignalValue | SetSignalValue | IncrementSignalValue | DecrementSignalValue | SetBitInSignal | ClearBitInSignal | ToggleBitInSignal | Console | CalculateSignalValue | Javascript | SetElementProperty | Delay | SwitchLanguage | Login | Logout | SubscribeSignal | UnsubscribeSignal | WriteSignalsInGroup | ClearSiganlsInGroup | Condition | Exit | Label | RunScript | Goto;
|
|
2
|
+
export interface Comment {
|
|
3
|
+
type: 'Comment';
|
|
4
|
+
comment: string;
|
|
5
|
+
}
|
|
2
6
|
export interface OpenScreen {
|
|
3
7
|
type: 'OpenScreen';
|
|
4
8
|
/**
|
|
@@ -190,3 +194,75 @@ export interface Login {
|
|
|
190
194
|
*/
|
|
191
195
|
password: string;
|
|
192
196
|
}
|
|
197
|
+
export interface SubscribeSignal {
|
|
198
|
+
type: 'SubscribeSignal';
|
|
199
|
+
/**
|
|
200
|
+
* Name of the signal
|
|
201
|
+
* @TJS-format signal
|
|
202
|
+
*/
|
|
203
|
+
signal: string;
|
|
204
|
+
oneTime: boolean;
|
|
205
|
+
}
|
|
206
|
+
export interface UnsubscribeSignal {
|
|
207
|
+
type: 'UnsubscribeSignal';
|
|
208
|
+
/**
|
|
209
|
+
* Name of the signal
|
|
210
|
+
* @TJS-format signal
|
|
211
|
+
*/
|
|
212
|
+
signal: string;
|
|
213
|
+
}
|
|
214
|
+
export interface WriteSignalsInGroup {
|
|
215
|
+
type: 'WriteSignalsInGroup';
|
|
216
|
+
/**
|
|
217
|
+
* Name of the Group
|
|
218
|
+
*/
|
|
219
|
+
group: string;
|
|
220
|
+
}
|
|
221
|
+
export interface ClearSiganlsInGroup {
|
|
222
|
+
type: 'ClearSiganlsInGroup';
|
|
223
|
+
/**
|
|
224
|
+
* Name of the Group
|
|
225
|
+
*/
|
|
226
|
+
group: string;
|
|
227
|
+
}
|
|
228
|
+
export interface Condition {
|
|
229
|
+
type: 'Condition';
|
|
230
|
+
/**
|
|
231
|
+
* Name of the value1
|
|
232
|
+
* @TJS-format complex
|
|
233
|
+
*/
|
|
234
|
+
value1: any;
|
|
235
|
+
value2?: any;
|
|
236
|
+
comparisonType: '==null' | '!=null' | '==true' | '==false' | '==' | '!=' | '>' | '<' | '>=' | '<=';
|
|
237
|
+
/**
|
|
238
|
+
* Name of the label to jumpe to when condition is true
|
|
239
|
+
*/
|
|
240
|
+
trueGotoLabel?: string;
|
|
241
|
+
trueScriptName?: string;
|
|
242
|
+
trueScriptType?: string;
|
|
243
|
+
falseGotoLabel?: string;
|
|
244
|
+
falseScriptName?: string;
|
|
245
|
+
falseScriptType?: string;
|
|
246
|
+
}
|
|
247
|
+
export interface Exit {
|
|
248
|
+
type: 'Exit';
|
|
249
|
+
}
|
|
250
|
+
export interface Label {
|
|
251
|
+
type: 'Label';
|
|
252
|
+
label: string;
|
|
253
|
+
}
|
|
254
|
+
export interface Goto {
|
|
255
|
+
type: 'Goto';
|
|
256
|
+
label: string;
|
|
257
|
+
}
|
|
258
|
+
export interface RunScript {
|
|
259
|
+
type: 'RunScript';
|
|
260
|
+
/**
|
|
261
|
+
* Name of the Script
|
|
262
|
+
*/
|
|
263
|
+
name: 'string';
|
|
264
|
+
/**
|
|
265
|
+
* Type of the Script
|
|
266
|
+
*/
|
|
267
|
+
scriptType: 'string';
|
|
268
|
+
}
|
|
@@ -11,8 +11,10 @@ export type contextType = {
|
|
|
11
11
|
};
|
|
12
12
|
export declare class ScriptSystem {
|
|
13
13
|
_visualizationHandler: VisualizationHandler;
|
|
14
|
+
_subscriptionCallback: () => void;
|
|
14
15
|
constructor(visualizationHandler: VisualizationHandler);
|
|
15
16
|
execute(scriptCommands: ScriptCommands[], outerContext: contextType): Promise<void>;
|
|
17
|
+
runExternalScript(name: string, type: string): Promise<void>;
|
|
16
18
|
runScriptCommand<T extends ScriptCommands>(command: T, context: contextType): Promise<void>;
|
|
17
19
|
getTargetFromTargetSelector(context: contextType, targetSelectorTarget: 'currentScreen' | 'parentScreen' | 'currentElement' | 'parentElement', targetSelector: string): Iterable<Element>;
|
|
18
20
|
getValue<T>(value: string | number | boolean | IScriptMultiplexValue, outerContext: contextType): Promise<any>;
|
|
@@ -4,16 +4,96 @@ import { parseBindingString } from "../helpers/BindingsHelper.js";
|
|
|
4
4
|
import Long from 'long';
|
|
5
5
|
export class ScriptSystem {
|
|
6
6
|
_visualizationHandler;
|
|
7
|
+
_subscriptionCallback = () => { };
|
|
7
8
|
constructor(visualizationHandler) {
|
|
8
9
|
this._visualizationHandler = visualizationHandler;
|
|
9
10
|
}
|
|
10
11
|
async execute(scriptCommands, outerContext) {
|
|
11
|
-
for (let
|
|
12
|
-
|
|
12
|
+
for (let i = 0; i < scriptCommands.length; i++) {
|
|
13
|
+
let c = scriptCommands[i];
|
|
14
|
+
if (c.type == "Exit") {
|
|
15
|
+
break;
|
|
16
|
+
}
|
|
17
|
+
else if (c.type == "Goto") {
|
|
18
|
+
const label = await this.getValue(c.label, outerContext);
|
|
19
|
+
i = scriptCommands.findIndex(x => x.type == "Label" && x.label == label);
|
|
20
|
+
if (i < 0)
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
else if (c.type == "Condition") {
|
|
24
|
+
const value1 = await this.getValue(c.value1, outerContext);
|
|
25
|
+
const value2 = await this.getValue(c.value2, outerContext);
|
|
26
|
+
const comparisonType = await this.getValue(c.comparisonType, outerContext);
|
|
27
|
+
let res = false;
|
|
28
|
+
switch (comparisonType) {
|
|
29
|
+
case '==null':
|
|
30
|
+
res = value1 == null;
|
|
31
|
+
break;
|
|
32
|
+
case '!=null':
|
|
33
|
+
res = value1 != null;
|
|
34
|
+
break;
|
|
35
|
+
case '==true':
|
|
36
|
+
res = value1 == true;
|
|
37
|
+
break;
|
|
38
|
+
case '==false':
|
|
39
|
+
res = value1 == false;
|
|
40
|
+
break;
|
|
41
|
+
case '==':
|
|
42
|
+
res = value1 == value2;
|
|
43
|
+
break;
|
|
44
|
+
case '!=':
|
|
45
|
+
res = value1 != value2;
|
|
46
|
+
break;
|
|
47
|
+
case '>':
|
|
48
|
+
res = value1 > value2;
|
|
49
|
+
break;
|
|
50
|
+
case '<':
|
|
51
|
+
res = value1 < value2;
|
|
52
|
+
break;
|
|
53
|
+
case '>=':
|
|
54
|
+
res = value1 >= value2;
|
|
55
|
+
break;
|
|
56
|
+
case '<=':
|
|
57
|
+
res = value1 <= value2;
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
if (res) {
|
|
61
|
+
await this.runExternalScript(await this.getValue(c.trueScriptName, outerContext), await this.getValue(c.trueScriptType, outerContext));
|
|
62
|
+
const trueGotoLabel = await this.getValue(c.trueGotoLabel, outerContext);
|
|
63
|
+
if (trueGotoLabel) {
|
|
64
|
+
i = scriptCommands.findIndex(x => x.type == "Label" && x.label == trueGotoLabel);
|
|
65
|
+
if (i < 0)
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
await this.runExternalScript(await this.getValue(c.falseScriptName, outerContext), await this.getValue(c.falseScriptType, outerContext));
|
|
71
|
+
const falseGotoLabel = await this.getValue(c.falseGotoLabel, outerContext);
|
|
72
|
+
if (falseGotoLabel) {
|
|
73
|
+
i = scriptCommands.findIndex(x => x.type == "Label" && x.label == falseGotoLabel);
|
|
74
|
+
if (i < 0)
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else
|
|
80
|
+
this.runScriptCommand(c, outerContext);
|
|
13
81
|
}
|
|
14
82
|
}
|
|
83
|
+
async runExternalScript(name, type) {
|
|
84
|
+
//TODO...
|
|
85
|
+
}
|
|
15
86
|
async runScriptCommand(command, context) {
|
|
16
87
|
switch (command.type) {
|
|
88
|
+
case 'Comment':
|
|
89
|
+
case 'Label':
|
|
90
|
+
case 'Condition':
|
|
91
|
+
case 'Goto':
|
|
92
|
+
case 'Exit':
|
|
93
|
+
{
|
|
94
|
+
//Do nothing on this commands
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
17
97
|
case 'OpenUrl': {
|
|
18
98
|
window.open(await this.getValue(command.url, context), command.target);
|
|
19
99
|
break;
|
|
@@ -123,6 +203,40 @@ export class ScriptSystem {
|
|
|
123
203
|
}
|
|
124
204
|
break;
|
|
125
205
|
}
|
|
206
|
+
case 'SubscribeSignal': {
|
|
207
|
+
const signal = await this.getValue(command.signal, context);
|
|
208
|
+
const oneTime = await this.getValue(command.oneTime, context);
|
|
209
|
+
if (oneTime) {
|
|
210
|
+
let cb = () => {
|
|
211
|
+
this._visualizationHandler.unsubscribeState(signal, cb, null);
|
|
212
|
+
};
|
|
213
|
+
this._visualizationHandler.subscribeState(signal, cb);
|
|
214
|
+
}
|
|
215
|
+
else
|
|
216
|
+
this._visualizationHandler.subscribeState(signal, this._subscriptionCallback);
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
219
|
+
case 'UnsubscribeSignal': {
|
|
220
|
+
const signal = await this.getValue(command.signal, context);
|
|
221
|
+
this._visualizationHandler.unsubscribeState(signal, this._subscriptionCallback, null);
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
224
|
+
case 'WriteSignalsInGroup': {
|
|
225
|
+
const group = await this.getValue(command.group, context);
|
|
226
|
+
this._visualizationHandler.writeSignalsInGroup(group);
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
case 'ClearSiganlsInGroup': {
|
|
230
|
+
const group = await this.getValue(command.group, context);
|
|
231
|
+
this._visualizationHandler.clearSignalsInGroup(group);
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
case 'RunScript': {
|
|
235
|
+
const name = await this.getValue(command.name, context);
|
|
236
|
+
const scriptType = await this.getValue(command.scriptType, context);
|
|
237
|
+
this.runExternalScript(name, scriptType);
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
126
240
|
}
|
|
127
241
|
}
|
|
128
242
|
getTargetFromTargetSelector(context, targetSelectorTarget, targetSelector) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"description": "web-component-designer addon for visualizations",
|
|
3
3
|
"name": "@node-projects/web-component-designer-visualization-addons",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.59",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"author": "jochen.kuehner@gmx.de",
|