Skip to content

Commit 84d689b

Browse files
committed
chore: release v7.11.1
* (klein0r) Added exec result blockly block * (klein0r) Protect iobroker-data/files to avoid direct writes with node:fs * (klein0r) Escape single quotes in blockly obj attributes
1 parent 9fd0b4a commit 84d689b

File tree

14 files changed

+119
-54
lines changed

14 files changed

+119
-54
lines changed

CHANGELOG_OLD.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
The newest change log is in README.md
2+
## 7.9.4 (2024-03-20)
3+
4+
* (klein0r) Fixed urlencoding for basic auth in url (user:pass)
5+
* (klein0r) Added warning icon if trigger is positioned inside of another trigger or loop
6+
27
## 7.9.3 (2024-03-19)
38

49
* (klein0r) Added timeout option for http blocks

README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Since v5.5.0 of the JavaScript adapter the following locations (relative to the
4242
<!--
4343
### **WORK IN PROGRESS**
4444
-->
45-
### **WORK IN PROGRESS**
45+
### 7.11.1 (2024-03-28)
4646

4747
* (klein0r) Added exec result blockly block
4848
* (klein0r) Protect iobroker-data/files to avoid direct writes with node:fs
@@ -73,11 +73,6 @@ Since v5.5.0 of the JavaScript adapter the following locations (relative to the
7373
* (klein0r) Copy date object in getAstroDate
7474
* (klein0r) Added object id as tooltip
7575

76-
### 7.9.4 (2024-03-20)
77-
78-
* (klein0r) Fixed urlencoding for basic auth in url (user:pass)
79-
* (klein0r) Added warning icon if trigger is positioned inside of another trigger or loop
80-
8176
## License
8277
The MIT License (MIT)
8378

admin/asset-manifest.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"files": {
3-
"main.js": "/static/js/main.01873cd9.js",
3+
"main.js": "/static/js/main.12deb862.js",
44
"static/css/864.42bfc5f3.chunk.css": "/static/css/864.42bfc5f3.chunk.css",
5-
"static/js/864.2e977ad1.chunk.js": "/static/js/864.2e977ad1.chunk.js",
5+
"static/js/864.2966b63e.chunk.js": "/static/js/864.2966b63e.chunk.js",
66
"static/js/805.7c367e53.chunk.js": "/static/js/805.7c367e53.chunk.js",
77
"static/js/431.a62490cf.chunk.js": "/static/js/431.a62490cf.chunk.js",
88
"static/js/702.1692c400.chunk.js": "/static/js/702.1692c400.chunk.js",
@@ -160,9 +160,9 @@
160160
"static/media/Garage Doors.svg": "/static/media/Garage Doors.0c2a1cfca7ad1ea59625.svg",
161161
"static/media/Outdoor Blinds.svg": "/static/media/Outdoor Blinds.37b85a9c060a4af48da9.svg",
162162
"static/media/Upstairs.svg": "/static/media/Upstairs.441813e54e0daca0882d.svg",
163-
"main.01873cd9.js.map": "/static/js/main.01873cd9.js.map",
163+
"main.12deb862.js.map": "/static/js/main.12deb862.js.map",
164164
"864.42bfc5f3.chunk.css.map": "/static/css/864.42bfc5f3.chunk.css.map",
165-
"864.2e977ad1.chunk.js.map": "/static/js/864.2e977ad1.chunk.js.map",
165+
"864.2966b63e.chunk.js.map": "/static/js/864.2966b63e.chunk.js.map",
166166
"805.7c367e53.chunk.js.map": "/static/js/805.7c367e53.chunk.js.map",
167167
"431.a62490cf.chunk.js.map": "/static/js/431.a62490cf.chunk.js.map",
168168
"702.1692c400.chunk.js.map": "/static/js/702.1692c400.chunk.js.map",
@@ -195,6 +195,6 @@
195195
"96.fe9915d5.chunk.js.map": "/static/js/96.fe9915d5.chunk.js.map"
196196
},
197197
"entrypoints": [
198-
"static/js/main.01873cd9.js"
198+
"static/js/main.12deb862.js"
199199
]
200200
}

admin/google-blockly/own/blocks_action.js

Lines changed: 74 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Blockly.Action.blocks['exec'] =
2020
'<block type="exec">'
2121
+ ' <value name="COMMAND">'
2222
+ ' <shadow type="text">'
23-
+ ' <field name="TEXT">text</field>'
23+
+ ' <field name="TEXT">pwd</field>'
2424
+ ' </shadow>'
2525
+ ' </value>'
2626
+ ' <value name="LOG">'
@@ -33,7 +33,7 @@ Blockly.Action.blocks['exec'] =
3333
Blockly.Blocks['exec'] = {
3434
init: function() {
3535
this.appendDummyInput('TEXT')
36-
.appendField(Blockly.Translate('exec'));
36+
.appendField('» ' + Blockly.Translate('exec'));
3737

3838
this.appendValueInput('COMMAND')
3939
.appendField(Blockly.Translate('exec_command'));
@@ -96,26 +96,91 @@ Blockly.JavaScript['exec'] = function(block) {
9696

9797
let logText;
9898
if (logLevel) {
99-
logText = 'console.' + logLevel + '("exec: " + ' + value_command + ');\n'
99+
logText = `console.${logLevel}('exec: ' + ${value_command});\n`;
100100
} else {
101101
logText = '';
102102
}
103103

104104
if (withStatement === 'TRUE' || withStatement === 'true' || withStatement === true) {
105105
const statement = Blockly.JavaScript.statementToCode(block, 'STATEMENT');
106106
if (statement) {
107-
return 'exec(' + value_command + ', async (error, result, stderr) => {\n' + statement + '});\n' +
108-
logText;
107+
return `exec(${value_command}, async (error, result, stderr) => {\n` +
108+
statement +
109+
`});\n${logText}`;
109110
} else {
110-
return 'exec(' + value_command + ');\n' +
111-
logText;
111+
return `exec(${value_command});\n${logText}`;
112112
}
113113
} else {
114-
return 'exec(' + value_command + ');\n' +
115-
logText;
114+
return `exec(${value_command});\n${logText}`;
116115
}
117116
};
118117

118+
// --- exec_result -----------------------------------------------------------
119+
Blockly.Action.blocks['exec_result'] =
120+
'<block type="exec_result">'
121+
+ ' <value name="ATTR">'
122+
+ ' </value>'
123+
+ '</block>';
124+
125+
Blockly.Blocks['exec_result'] = {
126+
/**
127+
* Block for conditionally returning a value from a procedure.
128+
* @this Blockly.Block
129+
*/
130+
init: function() {
131+
this.appendDummyInput()
132+
.appendField('»');
133+
134+
this.appendDummyInput('ATTR')
135+
.appendField(new Blockly.FieldDropdown([
136+
[Blockly.Translate('exec_result_result'), 'result'],
137+
[Blockly.Translate('exec_result_stderr'), 'stderr'],
138+
[Blockly.Translate('exec_result_error'), 'error'],
139+
]), 'ATTR');
140+
141+
this.setInputsInline(true);
142+
this.setOutput(true);
143+
this.setColour(Blockly.Action.HUE);
144+
this.setTooltip(Blockly.Translate('exec_result_tooltip'));
145+
//this.setHelpUrl(getHelp('exec'));
146+
},
147+
/**
148+
* Called whenever anything on the workspace changes.
149+
* Add warning if this flow block is not nested inside a loop.
150+
* @param {!Blockly.Events.Abstract} e Change event.
151+
* @this Blockly.Block
152+
*/
153+
onchange: function(e) {
154+
let legal = false;
155+
// Is the block nested in an exec?
156+
let block = this;
157+
do {
158+
if (this.FUNCTION_TYPES.includes(block.type)) {
159+
legal = true;
160+
break;
161+
}
162+
block = block.getSurroundParent();
163+
} while (block);
164+
165+
if (legal) {
166+
this.setWarningText(null, this.id);
167+
} else {
168+
this.setWarningText(Blockly.Translate('exec_result_warning'), this.id);
169+
}
170+
},
171+
/**
172+
* List of block types that are functions and thus do not need warnings.
173+
* To add a new function type add this to your code:
174+
* Blockly.Blocks['procedures_ifreturn'].FUNCTION_TYPES.push('custom_func');
175+
*/
176+
FUNCTION_TYPES: ['exec'],
177+
};
178+
Blockly.JavaScript['exec_result'] = function(block) {
179+
const attr = block.getFieldValue('ATTR');
180+
181+
return [attr, Blockly.JavaScript.ORDER_ATOMIC];
182+
};
183+
119184
// --- action http_get --------------------------------------------------
120185
Blockly.Action.blocks['http_get'] =
121186
'<block type="http_get">'

admin/google-blockly/own/blocks_object.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ Blockly.JavaScript['object_new'] = function(block) {
229229
for (let n = 0; n < block.itemCount_; n++) {
230230
const val = Blockly.JavaScript.valueToCode(block, 'ATTR_' + n, Blockly.JavaScript.ORDER_COMMA);
231231
if (val) {
232-
attributes.push(`'${block.attributes_[n]}': ${val}`);
232+
attributes.push(`'${String(block.attributes_[n]).replaceAll(`'`, `\\'`)}': ${val}`);
233233
}
234234
}
235235

@@ -282,7 +282,7 @@ Blockly.JavaScript['object_set_attr'] = function(block) {
282282
obj = '{}';
283283
}
284284

285-
return `(() => { const obj = ${obj}; if (typeof obj === 'object') { obj['${attr}'] = ${value}; } })();\n`;
285+
return `((obj) => { if (typeof obj === 'object') { obj['${attr}'] = ${value}; } })(${obj});\n`;
286286
};
287287

288288
// --- delete attribute --------------------------------------------------
@@ -321,7 +321,7 @@ Blockly.JavaScript['object_del_attr'] = function(block) {
321321
obj = '{}';
322322
}
323323

324-
return `(() => { const obj = ${obj}; if (typeof obj === 'object') { delete obj['${attr}']; } })();\n`;
324+
return `((obj) => { if (typeof obj === 'object') { delete obj['${attr}']; } })(${obj});\n`;
325325
};
326326

327327
// --- has attribute --------------------------------------------------

0 commit comments

Comments
 (0)