@node-projects/web-component-designer-visualization-addons 0.1.33 → 0.1.35
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/blockly/components/Console.js +1 -1
- package/dist/blockly/components/Debugger.js +1 -1
- package/dist/blockly/components/Delay.js +1 -1
- package/dist/blockly/components/GetParameter.js +1 -1
- package/dist/blockly/components/GetState.js +1 -1
- package/dist/blockly/components/GetSubProperty.js +1 -1
- package/dist/blockly/components/OpenScreen.js +1 -1
- package/dist/blockly/components/QuerySelector.js +1 -1
- package/dist/blockly/components/QuerySelectorAll.js +1 -1
- package/dist/blockly/components/Return.js +1 -1
- package/dist/blockly/components/SetElement.js +1 -1
- package/dist/blockly/components/SetState.js +1 -1
- package/dist/blockly/components/StartEvent.js +1 -1
- package/dist/scripting/ScriptSystem.d.ts +1 -0
- package/dist/scripting/ScriptSystem.js +14 -10
- package/package.json +1 -1
|
@@ -16,7 +16,7 @@ Blockly.Blocks['console'] = {
|
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
18
|
//@ts-ignore
|
|
19
|
-
Blockly.JavaScript['console'] = function (block) {
|
|
19
|
+
Blockly.JavaScript.forBlock['console'] = function (block, generator) {
|
|
20
20
|
var level = block.getFieldValue('LEVEL');
|
|
21
21
|
//@ts-ignore
|
|
22
22
|
const value = Blockly.JavaScript.valueToCode(block, 'VALUE', Blockly.JavaScript.ORDER_ATOMIC);
|
|
@@ -12,7 +12,7 @@ Blockly.Blocks['delay'] = {
|
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
14
|
//@ts-ignore
|
|
15
|
-
Blockly.JavaScript['delay'] = function (block) {
|
|
15
|
+
Blockly.JavaScript.forBlock['delay'] = function (block) {
|
|
16
16
|
//@ts-ignore
|
|
17
17
|
const delay = Blockly.JavaScript.valueToCode(block, 'DELAY', Blockly.JavaScript.ORDER_ATOMIC);
|
|
18
18
|
let code = 'await delay(' + delay + ');\n';
|
|
@@ -12,7 +12,7 @@ Blockly.Blocks['get_parameter'] = {
|
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
14
|
//@ts-ignore
|
|
15
|
-
Blockly.JavaScript['get_parameter'] = function (block, generator) {
|
|
15
|
+
Blockly.JavaScript.forBlock['get_parameter'] = function (block, generator) {
|
|
16
16
|
//@ts-ignore
|
|
17
17
|
const name = Blockly.JavaScript.valueToCode(block, 'NAME', Blockly.JavaScript.ORDER_ATOMIC);
|
|
18
18
|
const code = `context.parameters[${name}]`;
|
|
@@ -12,7 +12,7 @@ Blockly.Blocks['get_state'] = {
|
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
14
|
//@ts-ignore
|
|
15
|
-
Blockly.JavaScript['get_state'] = function (block, generator) {
|
|
15
|
+
Blockly.JavaScript.forBlock['get_state'] = function (block, generator) {
|
|
16
16
|
//@ts-ignore
|
|
17
17
|
const id = Blockly.JavaScript.valueToCode(block, 'OID', Blockly.JavaScript.ORDER_ATOMIC);
|
|
18
18
|
const code = `(await IOB.getState((${id}[0] === '.' ? relativeSignalsPath : '') + ${id})).val`;
|
|
@@ -16,7 +16,7 @@ Blockly.Blocks['get_sub_property'] = {
|
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
18
|
//@ts-ignore
|
|
19
|
-
Blockly.JavaScript['get_sub_property'] = function (block, generator) {
|
|
19
|
+
Blockly.JavaScript.forBlock['get_sub_property'] = function (block, generator) {
|
|
20
20
|
//@ts-ignore
|
|
21
21
|
const obj = Blockly.JavaScript.valueToCode(block, 'OBJECT', Blockly.JavaScript.ORDER_ATOMIC);
|
|
22
22
|
//@ts-ignore
|
|
@@ -19,7 +19,7 @@ Blockly.Blocks['open_screen'] = {
|
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
21
|
//@ts-ignore
|
|
22
|
-
Blockly.JavaScript['open_screen'] = function (block) {
|
|
22
|
+
Blockly.JavaScript.forBlock['open_screen'] = function (block) {
|
|
23
23
|
//@ts-ignore
|
|
24
24
|
const screen = Blockly.JavaScript.valueToCode(block, 'SCREEN', Blockly.JavaScript.ORDER_ATOMIC);
|
|
25
25
|
//@ts-ignore
|
|
@@ -16,7 +16,7 @@ Blockly.Blocks['query_selector'] = {
|
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
18
|
//@ts-ignore
|
|
19
|
-
Blockly.JavaScript['query_selector'] = function (block, generator) {
|
|
19
|
+
Blockly.JavaScript.forBlock['query_selector'] = function (block, generator) {
|
|
20
20
|
var dropdown_source = block.getFieldValue('SOURCE');
|
|
21
21
|
//@ts-ignore
|
|
22
22
|
const selector = Blockly.JavaScript.valueToCode(block, 'SELECTOR', Blockly.JavaScript.ORDER_ATOMIC);
|
|
@@ -16,7 +16,7 @@ Blockly.Blocks['query_selector_all'] = {
|
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
18
|
//@ts-ignore
|
|
19
|
-
Blockly.JavaScript['query_selector_all'] = function (block, generator) {
|
|
19
|
+
Blockly.JavaScript.forBlock['query_selector_all'] = function (block, generator) {
|
|
20
20
|
var dropdown_source = block.getFieldValue('SOURCE');
|
|
21
21
|
//@ts-ignore
|
|
22
22
|
const selector = Blockly.JavaScript.valueToCode(block, 'SELECTOR', Blockly.JavaScript.ORDER_ATOMIC);
|
|
@@ -13,7 +13,7 @@ Blockly.Blocks['return'] = {
|
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
15
|
//@ts-ignore
|
|
16
|
-
Blockly.JavaScript['return'] = function (block) {
|
|
16
|
+
Blockly.JavaScript.forBlock['return'] = function (block) {
|
|
17
17
|
//@ts-ignore
|
|
18
18
|
const value = Blockly.JavaScript.valueToCode(block, 'VALUE', Blockly.JavaScript.ORDER_ATOMIC);
|
|
19
19
|
let code = 'return ' + value + ';';
|
|
@@ -22,7 +22,7 @@ Blockly.Blocks['set_element'] = {
|
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
24
|
//@ts-ignore
|
|
25
|
-
Blockly.JavaScript['set_element'] = function (block) {
|
|
25
|
+
Blockly.JavaScript.forBlock['set_element'] = function (block) {
|
|
26
26
|
var dropdown_target = block.getFieldValue('TARGET');
|
|
27
27
|
//@ts-ignore
|
|
28
28
|
const element = Blockly.JavaScript.valueToCode(block, 'ELEMENT', Blockly.JavaScript.ORDER_ATOMIC);
|
|
@@ -16,7 +16,7 @@ Blockly.Blocks['set_state'] = {
|
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
18
|
//@ts-ignore
|
|
19
|
-
Blockly.JavaScript['set_state'] = function (block) {
|
|
19
|
+
Blockly.JavaScript.forBlock['set_state'] = function (block) {
|
|
20
20
|
//@ts-ignore
|
|
21
21
|
const id = Blockly.JavaScript.valueToCode(block, 'OID', Blockly.JavaScript.ORDER_ATOMIC);
|
|
22
22
|
//@ts-ignore
|
|
@@ -16,7 +16,7 @@ Blockly.defineBlocksWithJsonArray([
|
|
|
16
16
|
},
|
|
17
17
|
]);
|
|
18
18
|
//@ts-ignore
|
|
19
|
-
Blockly.JavaScript['start_event'] = function (block) {
|
|
19
|
+
Blockly.JavaScript.forBlock['start_event'] = function (block) {
|
|
20
20
|
//@ts-ignore
|
|
21
21
|
let name = Blockly.JavaScript.getVariableName(block.getField('EVENTVAR').variable.name);
|
|
22
22
|
return name + ' = ' + 'eventData;\n';
|
|
@@ -14,6 +14,7 @@ export declare class ScriptSystem {
|
|
|
14
14
|
constructor(visualizationHandler: VisualizationHandler);
|
|
15
15
|
execute(scriptCommands: ScriptCommands[], outerContext: contextType): Promise<void>;
|
|
16
16
|
runScriptCommand<T extends ScriptCommands>(command: T, context: contextType): Promise<void>;
|
|
17
|
+
getTargetFromTargetSelector(context: contextType, targetSelectorTarget: 'currentScreen' | 'parentScreen' | 'currentElement' | 'parentElement', targetSelector: string): Iterable<Element>;
|
|
17
18
|
getValue<T>(value: string | number | boolean | IScriptMultiplexValue, outerContext: contextType): Promise<any>;
|
|
18
19
|
getStateOrFieldOrParameter(name: string, context: contextType): Promise<any>;
|
|
19
20
|
parseStringWithValues(text: string, context: contextType): Promise<string>;
|
|
@@ -98,16 +98,7 @@ export class ScriptSystem {
|
|
|
98
98
|
case 'SetElementProperty': {
|
|
99
99
|
const name = await this.getValue(command.name, context);
|
|
100
100
|
const value = await this.getValue(command.value, context);
|
|
101
|
-
let
|
|
102
|
-
if (command.targetSelectorTarget == 'currentElement')
|
|
103
|
-
host = context.element;
|
|
104
|
-
else if (command.targetSelectorTarget == 'parentElement')
|
|
105
|
-
host = context.element.parentElement;
|
|
106
|
-
else if (command.targetSelectorTarget == 'parentScreen')
|
|
107
|
-
host = host.getRootNode().host;
|
|
108
|
-
let elements = [host];
|
|
109
|
-
if (command.targetSelector)
|
|
110
|
-
elements = host.shadowRoot.querySelectorAll(command.targetSelector);
|
|
101
|
+
let elements = this.getTargetFromTargetSelector(context, command.targetSelectorTarget, command.targetSelector);
|
|
111
102
|
for (let e of elements) {
|
|
112
103
|
if (command.target == 'attribute') {
|
|
113
104
|
e.setAttribute(name, value);
|
|
@@ -123,6 +114,19 @@ export class ScriptSystem {
|
|
|
123
114
|
}
|
|
124
115
|
}
|
|
125
116
|
}
|
|
117
|
+
getTargetFromTargetSelector(context, targetSelectorTarget, targetSelector) {
|
|
118
|
+
let host = context.element.getRootNode().host;
|
|
119
|
+
if (targetSelector == 'currentElement')
|
|
120
|
+
host = context.element;
|
|
121
|
+
else if (targetSelector == 'parentElement')
|
|
122
|
+
host = context.element.parentElement;
|
|
123
|
+
else if (targetSelector == 'parentScreen')
|
|
124
|
+
host = host.getRootNode().host;
|
|
125
|
+
let elements = [host];
|
|
126
|
+
if (targetSelector)
|
|
127
|
+
elements = host.shadowRoot.querySelectorAll(targetSelector);
|
|
128
|
+
return elements;
|
|
129
|
+
}
|
|
126
130
|
async getValue(value, outerContext) {
|
|
127
131
|
if (typeof value === 'object') {
|
|
128
132
|
switch (value.source) {
|
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.35",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"author": "jochen.kuehner@gmx.de",
|