@node-projects/web-component-designer-visualization-addons 0.1.123 → 0.1.124
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.
|
@@ -757,10 +757,7 @@ export class BindingsHelper {
|
|
|
757
757
|
else {
|
|
758
758
|
const cb = (id, value) => this.handleValueChanged(element, binding, value.val, valuesObject, i, signalVars, false, relativeSignalPath);
|
|
759
759
|
unsubscribeList.push([s, cb, this._visualizationHandler.subscribeState(s, cb)]);
|
|
760
|
-
this._visualizationHandler.getState(s).then(x =>
|
|
761
|
-
if (x)
|
|
762
|
-
this.handleValueChanged(element, binding, x?.val, valuesObject, i, signalVars, false, relativeSignalPath);
|
|
763
|
-
});
|
|
760
|
+
this._visualizationHandler.getState(s).then(x => this.handleValueChanged(element, binding, x?.val, valuesObject, i, signalVars, false, relativeSignalPath));
|
|
764
761
|
if (binding[1].twoWay && i == 0) {
|
|
765
762
|
this.addTwoWayBinding(binding, element, v => this._visualizationHandler.setState(s, v));
|
|
766
763
|
}
|
|
@@ -20,7 +20,7 @@ export declare class ScriptSystem {
|
|
|
20
20
|
getValue<T>(value: T, outerContext: contextType): Promise<T>;
|
|
21
21
|
getStateOrFieldOrParameter(name: string, context: contextType): Promise<any>;
|
|
22
22
|
parseStringWithValues(text: string, context: contextType): Promise<string>;
|
|
23
|
-
|
|
23
|
+
getSignalName(name: string, outerContext: contextType): string;
|
|
24
24
|
static extractPart(obj: any, propertyPath: string): any;
|
|
25
25
|
createScriptContext(root: HTMLElement, event: Event, element: Element, parameters: Record<string, any>, relativeSignalsPath: string): any;
|
|
26
26
|
assignAllScripts(source: string, javascriptCode: string, shadowRoot: ShadowRoot, instance: HTMLElement, visualizationHandler: VisualizationHandler, contextCreator?: (root: HTMLElement, event: Event, element: Element, parameters: Record<string, any>, relativeSignalsPath: string) => any, assignExternalScript?: (element: Element, event: string, scriptData: any) => void, runInitalization?: (jsObject: VisualisationElementScript) => void): Promise<VisualisationElementScript>;
|
|
@@ -112,25 +112,25 @@ export class ScriptSystem {
|
|
|
112
112
|
}
|
|
113
113
|
case 'ToggleSignalValue': {
|
|
114
114
|
const signal = await this.getValue(command.signal, context);
|
|
115
|
-
let state = await this._visualizationHandler.getState(this.
|
|
116
|
-
await this._visualizationHandler.setState(this.
|
|
115
|
+
let state = await this._visualizationHandler.getState(this.getSignalName(signal, context));
|
|
116
|
+
await this._visualizationHandler.setState(this.getSignalName(signal, context), !state?.val);
|
|
117
117
|
break;
|
|
118
118
|
}
|
|
119
119
|
case 'SetSignalValue': {
|
|
120
120
|
const signal = await this.getValue(command.signal, context);
|
|
121
|
-
await this._visualizationHandler.setState(this.
|
|
121
|
+
await this._visualizationHandler.setState(this.getSignalName(signal, context), await this.getValue(command.value, context));
|
|
122
122
|
break;
|
|
123
123
|
}
|
|
124
124
|
case 'IncrementSignalValue': {
|
|
125
125
|
const signal = await this.getValue(command.signal, context);
|
|
126
|
-
let state = await this._visualizationHandler.getState(this.
|
|
127
|
-
await this._visualizationHandler.setState(this.
|
|
126
|
+
let state = await this._visualizationHandler.getState(this.getSignalName(signal, context));
|
|
127
|
+
await this._visualizationHandler.setState(this.getSignalName(signal, context), (state.val + await this.getValue(command.value, context)));
|
|
128
128
|
break;
|
|
129
129
|
}
|
|
130
130
|
case 'DecrementSignalValue': {
|
|
131
131
|
const signal = await this.getValue(command.signal, context);
|
|
132
|
-
let state = await this._visualizationHandler.getState(this.
|
|
133
|
-
await this._visualizationHandler.setState(this.
|
|
132
|
+
let state = await this._visualizationHandler.getState(this.getSignalName(signal, context));
|
|
133
|
+
await this._visualizationHandler.setState(this.getSignalName(signal, context), state.val - await this.getValue(command.value, context));
|
|
134
134
|
break;
|
|
135
135
|
}
|
|
136
136
|
case 'CalculateSignalValue': {
|
|
@@ -138,35 +138,35 @@ export class ScriptSystem {
|
|
|
138
138
|
const targetSignal = await this.getValue(command.targetSignal, context);
|
|
139
139
|
let nm = await this.parseStringWithValues(formula, context);
|
|
140
140
|
let result = eval(nm);
|
|
141
|
-
await this._visualizationHandler.setState(this.
|
|
141
|
+
await this._visualizationHandler.setState(this.getSignalName(targetSignal, context), result);
|
|
142
142
|
break;
|
|
143
143
|
}
|
|
144
144
|
case 'SetBitInSignal': {
|
|
145
145
|
const signal = await this.getValue(command.signal, context);
|
|
146
146
|
const bitNumber = await this.getValue(command.bitNumber ?? 0, context);
|
|
147
|
-
let state = await this._visualizationHandler.getState(this.
|
|
147
|
+
let state = await this._visualizationHandler.getState(this.getSignalName(signal, context));
|
|
148
148
|
let mask = Long.fromNumber(1).shiftLeft(bitNumber);
|
|
149
149
|
const newVal = Long.fromNumber(state.val).or(mask).toNumber();
|
|
150
|
-
await this._visualizationHandler.setState(this.
|
|
150
|
+
await this._visualizationHandler.setState(this.getSignalName(signal, context), newVal);
|
|
151
151
|
break;
|
|
152
152
|
}
|
|
153
153
|
case 'ClearBitInSignal': {
|
|
154
154
|
const signal = await this.getValue(command.signal, context);
|
|
155
155
|
const bitNumber = await this.getValue(command.bitNumber ?? 0, context);
|
|
156
|
-
let state = await this._visualizationHandler.getState(this.
|
|
156
|
+
let state = await this._visualizationHandler.getState(this.getSignalName(signal, context));
|
|
157
157
|
let mask = Long.fromNumber(1).shiftLeft(bitNumber);
|
|
158
158
|
mask.negate();
|
|
159
159
|
const newVal = Long.fromNumber(state.val).and(mask).toNumber();
|
|
160
|
-
await this._visualizationHandler.setState(this.
|
|
160
|
+
await this._visualizationHandler.setState(this.getSignalName(signal, context), newVal);
|
|
161
161
|
break;
|
|
162
162
|
}
|
|
163
163
|
case 'ToggleBitInSignal': {
|
|
164
164
|
const signal = await this.getValue(command.signal, context);
|
|
165
165
|
const bitNumber = await this.getValue(command.bitNumber ?? 0, context);
|
|
166
|
-
let state = await this._visualizationHandler.getState(this.
|
|
166
|
+
let state = await this._visualizationHandler.getState(this.getSignalName(signal, context));
|
|
167
167
|
let mask = Long.fromNumber(1).shiftLeft(bitNumber);
|
|
168
168
|
const newVal = Long.fromNumber(state.val).xor(mask).toNumber();
|
|
169
|
-
await this._visualizationHandler.setState(this.
|
|
169
|
+
await this._visualizationHandler.setState(this.getSignalName(signal, context), newVal);
|
|
170
170
|
break;
|
|
171
171
|
}
|
|
172
172
|
case 'Javascript': {
|
|
@@ -320,7 +320,7 @@ export class ScriptSystem {
|
|
|
320
320
|
return outerContext.root[value.name];
|
|
321
321
|
}
|
|
322
322
|
case 'signal': {
|
|
323
|
-
let sng = await this._visualizationHandler.getState(this.
|
|
323
|
+
let sng = await this._visualizationHandler.getState(this.getSignalName(value.name, outerContext));
|
|
324
324
|
return sng.val;
|
|
325
325
|
}
|
|
326
326
|
case 'event': {
|
|
@@ -347,7 +347,7 @@ export class ScriptSystem {
|
|
|
347
347
|
let text = value.name;
|
|
348
348
|
if (text != null) {
|
|
349
349
|
const signal = await this.parseStringWithValues(text, outerContext);
|
|
350
|
-
const state = await this._visualizationHandler.getState(this.
|
|
350
|
+
const state = await this._visualizationHandler.getState(this.getSignalName(signal, outerContext));
|
|
351
351
|
return state.val;
|
|
352
352
|
}
|
|
353
353
|
return null;
|
|
@@ -372,13 +372,13 @@ export class ScriptSystem {
|
|
|
372
372
|
return context.root[name.substring(2)];
|
|
373
373
|
}
|
|
374
374
|
else if (name[0] === '?') {
|
|
375
|
-
return await this._visualizationHandler.getState(this.
|
|
375
|
+
return await this._visualizationHandler.getState(this.getSignalName(context.root[name.substring(2)], context));
|
|
376
376
|
}
|
|
377
|
-
return await this._visualizationHandler.getState(this.
|
|
377
|
+
return await this._visualizationHandler.getState(this.getSignalName(name, context));
|
|
378
378
|
}
|
|
379
379
|
async parseStringWithValues(text, context) {
|
|
380
380
|
const parsed = parseBindingString(text);
|
|
381
|
-
let results = await Promise.all(parsed.signals.map(x => this.getStateOrFieldOrParameter(this.
|
|
381
|
+
let results = await Promise.all(parsed.signals.map(x => this.getStateOrFieldOrParameter(this.getSignalName(x, context), context)));
|
|
382
382
|
let nm = parsed.parts[0];
|
|
383
383
|
for (let i = 0; i < parsed.parts.length - 1; i++) {
|
|
384
384
|
let v = results[i];
|
|
@@ -390,7 +390,7 @@ export class ScriptSystem {
|
|
|
390
390
|
}
|
|
391
391
|
return nm;
|
|
392
392
|
}
|
|
393
|
-
|
|
393
|
+
getSignalName(name, outerContext) {
|
|
394
394
|
if (name[0] === '.')
|
|
395
395
|
return outerContext.relativeSignalsPath + name;
|
|
396
396
|
return name;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ScriptCommands, SetElementProperty } from "./ScriptCommands";
|
|
2
2
|
export declare class ScriptUpgrades {
|
|
3
|
-
static upgradeScriptCommand(scriptCommand: ScriptCommands): import("./ScriptCommands").OpenScreen | import("./ScriptCommands").OpenUrl | import("./ScriptCommands").OpenDialog | import("./ScriptCommands").CloseDialog | import("./ScriptCommands").ToggleSignalValue | import("./ScriptCommands").SetSignalValue | import("./ScriptCommands").IncrementSignalValue | import("./ScriptCommands").DecrementSignalValue | import("./ScriptCommands").SetBitInSignal | import("./ScriptCommands").ClearBitInSignal | import("./ScriptCommands").ToggleBitInSignal | import("./ScriptCommands").Console | import("./ScriptCommands").CalculateSignalValue | import("./ScriptCommands").Javascript |
|
|
3
|
+
static upgradeScriptCommand(scriptCommand: ScriptCommands): SetElementProperty | import("./ScriptCommands").OpenScreen | import("./ScriptCommands").OpenUrl | import("./ScriptCommands").OpenDialog | import("./ScriptCommands").CloseDialog | import("./ScriptCommands").ToggleSignalValue | import("./ScriptCommands").SetSignalValue | import("./ScriptCommands").IncrementSignalValue | import("./ScriptCommands").DecrementSignalValue | import("./ScriptCommands").SetBitInSignal | import("./ScriptCommands").ClearBitInSignal | import("./ScriptCommands").ToggleBitInSignal | import("./ScriptCommands").Console | import("./ScriptCommands").CalculateSignalValue | import("./ScriptCommands").Javascript | import("./ScriptCommands").Delay | import("./ScriptCommands").SwitchLanguage | import("./ScriptCommands").Login | import("./ScriptCommands").Logout | import("./ScriptCommands").SubscribeSignal | import("./ScriptCommands").UnsubscribeSignal | import("./ScriptCommands").WriteSignalsInGroup | import("./ScriptCommands").ClearSignalsInGroup | import("./ScriptCommands").RunScript | import("./ScriptCommands").CopySignalValuesFromFolder | import("./ScriptCommands").ShowMessageBox | import("./ScriptCommands").ExportSignalValuesAsJson | import("./ScriptCommands").ImportSignalValuesFromJson | import("./ScriptCommands").Comment | import("./ScriptCommands").Condition | import("./ScriptCommands").Exit | import("./ScriptCommands").Label | import("./ScriptCommands").Goto;
|
|
4
4
|
static upgradeSetElementProperty(scriptCommand: SetElementProperty): SetElementProperty;
|
|
5
5
|
}
|
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.124",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"author": "jochen.kuehner@gmx.de",
|