@node-projects/web-component-designer-visualization-addons 0.1.6 → 0.1.8
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/dist/helpers/BindingsHelper.d.ts +1 -1
- package/dist/helpers/BindingsHelper.js +5 -4
- package/dist/interfaces/IScriptMultiplexValue.d.ts +0 -1
- package/dist/interfaces/IScriptMultiplexValue.js +0 -1
- package/dist/interfaces/VisualizationHandler.d.ts +1 -1
- package/dist/scripting/ScriptSystem.js +9 -9
- package/dist/services/BindableObjectDragDropService.js +6 -6
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { VisualizationBinding } from "../interfaces/VisualizationBinding.js";
|
|
2
|
-
import { BindingTarget } from "@node-projects/web-component-designer";
|
|
3
2
|
import { State, VisualizationHandler } from "../interfaces/VisualizationHandler.js";
|
|
3
|
+
import { BindingTarget } from "@node-projects/web-component-designer/dist/elements/item/BindingTarget.js";
|
|
4
4
|
export declare const bindingPrefixProperty = "bind-prop:";
|
|
5
5
|
export declare const bindingPrefixAttribute = "bind-attr:";
|
|
6
6
|
export declare const bindingPrefixClass = "bind-class:";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { TypedEvent } from "@node-projects/base-custom-webcomponent";
|
|
2
|
-
import {
|
|
2
|
+
import { BindingTarget } from "@node-projects/web-component-designer/dist/elements/item/BindingTarget.js";
|
|
3
|
+
import { PropertiesHelper } from "@node-projects/web-component-designer/dist/elements/services/propertiesService/services/PropertiesHelper.js";
|
|
3
4
|
//;,[ are not allowed in bindings, so they could be used for a short form...
|
|
4
5
|
export const bindingPrefixProperty = 'bind-prop:';
|
|
5
6
|
export const bindingPrefixAttribute = 'bind-attr:';
|
|
@@ -448,7 +449,7 @@ export class BindingsHelper {
|
|
|
448
449
|
}
|
|
449
450
|
else {
|
|
450
451
|
if (s.includes('{')) {
|
|
451
|
-
let indirectSignal = new IndirectSignal(this._visualizationHandler, s, (value) => this.handleValueChanged(element, binding, value.
|
|
452
|
+
let indirectSignal = new IndirectSignal(this._visualizationHandler, s, (value) => this.handleValueChanged(element, binding, value.val, valuesObject, i, signalVars, false));
|
|
452
453
|
if (!cleanupCalls)
|
|
453
454
|
cleanupCalls = [];
|
|
454
455
|
cleanupCalls.push(() => indirectSignal.dispose());
|
|
@@ -479,10 +480,10 @@ export class BindingsHelper {
|
|
|
479
480
|
this._visualizationHandler.getHistoricData(s, binding[1].historic).then(x => this.handleValueChanged(element, binding, x?.values, valuesObject, i, signalVars, true));
|
|
480
481
|
}
|
|
481
482
|
else {
|
|
482
|
-
const cb = (id, value) => this.handleValueChanged(element, binding, value.
|
|
483
|
+
const cb = (id, value) => this.handleValueChanged(element, binding, value.val, valuesObject, i, signalVars, false);
|
|
483
484
|
unsubscribeList.push([s, cb]);
|
|
484
485
|
this._visualizationHandler.subscribeState(s, cb);
|
|
485
|
-
this._visualizationHandler.getState(s).then(x => this.handleValueChanged(element, binding, x?.
|
|
486
|
+
this._visualizationHandler.getState(s).then(x => this.handleValueChanged(element, binding, x?.val, valuesObject, i, signalVars, false));
|
|
486
487
|
if (binding[1].twoWay && i == 0) {
|
|
487
488
|
this.addTwoWayBinding(binding, element, v => this._visualizationHandler.setState(s, v));
|
|
488
489
|
}
|
|
@@ -3,7 +3,6 @@ export declare class IScriptMultiplexValue {
|
|
|
3
3
|
* signal - read the value from a IOB object
|
|
4
4
|
* property - read the value from a property of the customControl (not usable in screens)
|
|
5
5
|
* event - read the value of a property of the event object
|
|
6
|
-
* @TJS-format signal
|
|
7
6
|
*/
|
|
8
7
|
source: 'signal' | 'property' | 'event';
|
|
9
8
|
/**
|
|
@@ -3,7 +3,6 @@ export class IScriptMultiplexValue {
|
|
|
3
3
|
* signal - read the value from a IOB object
|
|
4
4
|
* property - read the value from a property of the customControl (not usable in screens)
|
|
5
5
|
* event - read the value of a property of the event object
|
|
6
|
-
* @TJS-format signal
|
|
7
6
|
*/
|
|
8
7
|
source;
|
|
9
8
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { sleep } from "@node-projects/web-component-designer";
|
|
1
|
+
import { sleep } from "@node-projects/web-component-designer/dist/elements/helper/Helper.js";
|
|
2
2
|
import { generateEventCodeFromBlockly } from "../blockly/BlocklyJavascriptHelper.js";
|
|
3
3
|
import { parseBindingString } from "../helpers/BindingsHelper.js";
|
|
4
4
|
import Long from 'long';
|
|
@@ -32,7 +32,7 @@ export class ScriptSystem {
|
|
|
32
32
|
case 'ToggleSignalValue': {
|
|
33
33
|
const signal = await this.getValue(command.signal, context);
|
|
34
34
|
let state = await this._visualizationHandler.getState(signal);
|
|
35
|
-
await this._visualizationHandler.setState(signal, !state?.
|
|
35
|
+
await this._visualizationHandler.setState(signal, !state?.val);
|
|
36
36
|
break;
|
|
37
37
|
}
|
|
38
38
|
case 'SetSignalValue': {
|
|
@@ -43,13 +43,13 @@ export class ScriptSystem {
|
|
|
43
43
|
case 'IncrementSignalValue': {
|
|
44
44
|
const signal = await this.getValue(command.signal, context);
|
|
45
45
|
let state = await this._visualizationHandler.getState(signal);
|
|
46
|
-
await this._visualizationHandler.setState(signal, state.
|
|
46
|
+
await this._visualizationHandler.setState(signal, state.val + await this.getValue(command.value, context));
|
|
47
47
|
break;
|
|
48
48
|
}
|
|
49
49
|
case 'DecrementSignalValue': {
|
|
50
50
|
const signal = await this.getValue(command.signal, context);
|
|
51
51
|
let state = await this._visualizationHandler.getState(signal);
|
|
52
|
-
await this._visualizationHandler.setState(signal, state.
|
|
52
|
+
await this._visualizationHandler.setState(signal, state.val - await this.getValue(command.value, context));
|
|
53
53
|
break;
|
|
54
54
|
}
|
|
55
55
|
case 'CalculateSignalValue': {
|
|
@@ -59,7 +59,7 @@ export class ScriptSystem {
|
|
|
59
59
|
let results = await Promise.all(parsed.signals.map(x => this._visualizationHandler.getState(x)));
|
|
60
60
|
let nm = '';
|
|
61
61
|
for (let i = 0; i < parsed.parts.length - 1; i++) {
|
|
62
|
-
let v = results[i].
|
|
62
|
+
let v = results[i].val;
|
|
63
63
|
if (v == null)
|
|
64
64
|
return;
|
|
65
65
|
nm += v + parsed.parts[i + 1];
|
|
@@ -72,7 +72,7 @@ export class ScriptSystem {
|
|
|
72
72
|
const signal = await this.getValue(command.signal, context);
|
|
73
73
|
let state = await this._visualizationHandler.getState(signal);
|
|
74
74
|
let mask = Long.fromNumber(1).shiftLeft(command.bitNumber);
|
|
75
|
-
const newVal = Long.fromNumber(state.
|
|
75
|
+
const newVal = Long.fromNumber(state.val).or(mask).toNumber();
|
|
76
76
|
await this._visualizationHandler.setState(signal, newVal);
|
|
77
77
|
break;
|
|
78
78
|
}
|
|
@@ -81,7 +81,7 @@ export class ScriptSystem {
|
|
|
81
81
|
let state = await this._visualizationHandler.getState(signal);
|
|
82
82
|
let mask = Long.fromNumber(1).shiftLeft(command.bitNumber);
|
|
83
83
|
mask.negate();
|
|
84
|
-
const newVal = Long.fromNumber(state.
|
|
84
|
+
const newVal = Long.fromNumber(state.val).and(mask).toNumber();
|
|
85
85
|
await this._visualizationHandler.setState(signal, newVal);
|
|
86
86
|
break;
|
|
87
87
|
}
|
|
@@ -89,7 +89,7 @@ export class ScriptSystem {
|
|
|
89
89
|
const signal = await this.getValue(command.signal, context);
|
|
90
90
|
let state = await this._visualizationHandler.getState(signal);
|
|
91
91
|
let mask = Long.fromNumber(1).shiftLeft(command.bitNumber);
|
|
92
|
-
const newVal = Long.fromNumber(state.
|
|
92
|
+
const newVal = Long.fromNumber(state.val).xor(mask).toNumber();
|
|
93
93
|
await this._visualizationHandler.setState(signal, newVal);
|
|
94
94
|
break;
|
|
95
95
|
}
|
|
@@ -139,7 +139,7 @@ export class ScriptSystem {
|
|
|
139
139
|
}
|
|
140
140
|
case 'signal': {
|
|
141
141
|
let sng = await this._visualizationHandler.getState(value.name);
|
|
142
|
-
return sng.
|
|
142
|
+
return sng.val;
|
|
143
143
|
}
|
|
144
144
|
case 'event': {
|
|
145
145
|
let obj = outerContext.event;
|
|
@@ -56,24 +56,24 @@ export class BindableObjectDragDropService {
|
|
|
56
56
|
let grp;
|
|
57
57
|
let state = await this._visualizationHandler.getState(bindableObject.fullName);
|
|
58
58
|
//TODO: only icon&image if val is a url with extension
|
|
59
|
-
if (info.role === 'url' && typeof state?.
|
|
60
|
-
if (state.
|
|
59
|
+
if (info.role === 'url' && typeof state?.val === 'string') {
|
|
60
|
+
if (state.val.endsWith('jpg') || state.val.endsWith('jpeg') || state.val.endsWith('png') || state.val.endsWith('gif') || state.val.endsWith('svg')) {
|
|
61
61
|
const img = document.createElement('img');
|
|
62
62
|
di = DesignItem.createDesignItemFromInstance(img, designerCanvas.serviceContainer, designerCanvas.instanceServiceContainer);
|
|
63
63
|
grp = di.openGroup("Insert");
|
|
64
64
|
const binding = { signal: bindableObject.fullName, target: BindingTarget.property };
|
|
65
65
|
let serializedBinding = this._bindingsHelper.serializeBinding(img, 'src', binding);
|
|
66
66
|
di.setAttribute(serializedBinding[0], serializedBinding[1]);
|
|
67
|
-
di.element.src = state.
|
|
67
|
+
di.element.src = state.val;
|
|
68
68
|
}
|
|
69
|
-
else if (state.
|
|
69
|
+
else if (state.val.endsWith('mp4')) {
|
|
70
70
|
const video = document.createElement('video');
|
|
71
71
|
di = DesignItem.createDesignItemFromInstance(video, designerCanvas.serviceContainer, designerCanvas.instanceServiceContainer);
|
|
72
72
|
grp = di.openGroup("Insert");
|
|
73
73
|
const binding = { signal: bindableObject.fullName, target: BindingTarget.property };
|
|
74
74
|
let serializedBinding = this._bindingsHelper.serializeBinding(video, 'src', binding);
|
|
75
75
|
di.setAttribute(serializedBinding[0], serializedBinding[1]);
|
|
76
|
-
di.element.src = state.
|
|
76
|
+
di.element.src = state.val;
|
|
77
77
|
}
|
|
78
78
|
else {
|
|
79
79
|
const video = document.createElement('iframe');
|
|
@@ -82,7 +82,7 @@ export class BindableObjectDragDropService {
|
|
|
82
82
|
const binding = { signal: bindableObject.fullName, target: BindingTarget.property };
|
|
83
83
|
let serializedBinding = this._bindingsHelper.serializeBinding(video, 'src', binding);
|
|
84
84
|
di.setAttribute(serializedBinding[0], serializedBinding[1]);
|
|
85
|
-
di.element.src = state.
|
|
85
|
+
di.element.src = state.val;
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
if (!di) {
|
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.8",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"author": "jochen.kuehner@gmx.de",
|