Skip to content

Commit

Permalink
chore: release v7.11.1
Browse files Browse the repository at this point in the history
* (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
  • Loading branch information
klein0r committed Mar 28, 2024
1 parent 9fd0b4a commit 84d689b
Show file tree
Hide file tree
Showing 14 changed files with 119 additions and 54 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG_OLD.md
@@ -1,4 +1,9 @@
The newest change log is in README.md
## 7.9.4 (2024-03-20)

* (klein0r) Fixed urlencoding for basic auth in url (user:pass)
* (klein0r) Added warning icon if trigger is positioned inside of another trigger or loop

## 7.9.3 (2024-03-19)

* (klein0r) Added timeout option for http blocks
Expand Down
7 changes: 1 addition & 6 deletions README.md
Expand Up @@ -42,7 +42,7 @@ Since v5.5.0 of the JavaScript adapter the following locations (relative to the
<!--
### **WORK IN PROGRESS**
-->
### **WORK IN PROGRESS**
### 7.11.1 (2024-03-28)

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

### 7.9.4 (2024-03-20)

* (klein0r) Fixed urlencoding for basic auth in url (user:pass)
* (klein0r) Added warning icon if trigger is positioned inside of another trigger or loop

## License
The MIT License (MIT)

Expand Down
10 changes: 5 additions & 5 deletions admin/asset-manifest.json
@@ -1,8 +1,8 @@
{
"files": {
"main.js": "/static/js/main.01873cd9.js",
"main.js": "/static/js/main.12deb862.js",
"static/css/864.42bfc5f3.chunk.css": "/static/css/864.42bfc5f3.chunk.css",
"static/js/864.2e977ad1.chunk.js": "/static/js/864.2e977ad1.chunk.js",
"static/js/864.2966b63e.chunk.js": "/static/js/864.2966b63e.chunk.js",
"static/js/805.7c367e53.chunk.js": "/static/js/805.7c367e53.chunk.js",
"static/js/431.a62490cf.chunk.js": "/static/js/431.a62490cf.chunk.js",
"static/js/702.1692c400.chunk.js": "/static/js/702.1692c400.chunk.js",
Expand Down Expand Up @@ -160,9 +160,9 @@
"static/media/Garage Doors.svg": "/static/media/Garage Doors.0c2a1cfca7ad1ea59625.svg",
"static/media/Outdoor Blinds.svg": "/static/media/Outdoor Blinds.37b85a9c060a4af48da9.svg",
"static/media/Upstairs.svg": "/static/media/Upstairs.441813e54e0daca0882d.svg",
"main.01873cd9.js.map": "/static/js/main.01873cd9.js.map",
"main.12deb862.js.map": "/static/js/main.12deb862.js.map",
"864.42bfc5f3.chunk.css.map": "/static/css/864.42bfc5f3.chunk.css.map",
"864.2e977ad1.chunk.js.map": "/static/js/864.2e977ad1.chunk.js.map",
"864.2966b63e.chunk.js.map": "/static/js/864.2966b63e.chunk.js.map",
"805.7c367e53.chunk.js.map": "/static/js/805.7c367e53.chunk.js.map",
"431.a62490cf.chunk.js.map": "/static/js/431.a62490cf.chunk.js.map",
"702.1692c400.chunk.js.map": "/static/js/702.1692c400.chunk.js.map",
Expand Down Expand Up @@ -195,6 +195,6 @@
"96.fe9915d5.chunk.js.map": "/static/js/96.fe9915d5.chunk.js.map"
},
"entrypoints": [
"static/js/main.01873cd9.js"
"static/js/main.12deb862.js"
]
}
83 changes: 74 additions & 9 deletions admin/google-blockly/own/blocks_action.js
Expand Up @@ -20,7 +20,7 @@ Blockly.Action.blocks['exec'] =
'<block type="exec">'
+ ' <value name="COMMAND">'
+ ' <shadow type="text">'
+ ' <field name="TEXT">text</field>'
+ ' <field name="TEXT">pwd</field>'
+ ' </shadow>'
+ ' </value>'
+ ' <value name="LOG">'
Expand All @@ -33,7 +33,7 @@ Blockly.Action.blocks['exec'] =
Blockly.Blocks['exec'] = {
init: function() {
this.appendDummyInput('TEXT')
.appendField(Blockly.Translate('exec'));
.appendField('» ' + Blockly.Translate('exec'));

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

let logText;
if (logLevel) {
logText = 'console.' + logLevel + '("exec: " + ' + value_command + ');\n'
logText = `console.${logLevel}('exec: ' + ${value_command});\n`;
} else {
logText = '';
}

if (withStatement === 'TRUE' || withStatement === 'true' || withStatement === true) {
const statement = Blockly.JavaScript.statementToCode(block, 'STATEMENT');
if (statement) {
return 'exec(' + value_command + ', async (error, result, stderr) => {\n' + statement + '});\n' +
logText;
return `exec(${value_command}, async (error, result, stderr) => {\n` +
statement +
`});\n${logText}`;
} else {
return 'exec(' + value_command + ');\n' +
logText;
return `exec(${value_command});\n${logText}`;
}
} else {
return 'exec(' + value_command + ');\n' +
logText;
return `exec(${value_command});\n${logText}`;
}
};

// --- exec_result -----------------------------------------------------------
Blockly.Action.blocks['exec_result'] =
'<block type="exec_result">'
+ ' <value name="ATTR">'
+ ' </value>'
+ '</block>';

Blockly.Blocks['exec_result'] = {
/**
* Block for conditionally returning a value from a procedure.
* @this Blockly.Block
*/
init: function() {
this.appendDummyInput()
.appendField('»');

this.appendDummyInput('ATTR')
.appendField(new Blockly.FieldDropdown([
[Blockly.Translate('exec_result_result'), 'result'],
[Blockly.Translate('exec_result_stderr'), 'stderr'],
[Blockly.Translate('exec_result_error'), 'error'],
]), 'ATTR');

this.setInputsInline(true);
this.setOutput(true);
this.setColour(Blockly.Action.HUE);
this.setTooltip(Blockly.Translate('exec_result_tooltip'));
//this.setHelpUrl(getHelp('exec'));
},
/**
* Called whenever anything on the workspace changes.
* Add warning if this flow block is not nested inside a loop.
* @param {!Blockly.Events.Abstract} e Change event.
* @this Blockly.Block
*/
onchange: function(e) {
let legal = false;
// Is the block nested in an exec?
let block = this;
do {
if (this.FUNCTION_TYPES.includes(block.type)) {
legal = true;
break;
}
block = block.getSurroundParent();
} while (block);

if (legal) {
this.setWarningText(null, this.id);
} else {
this.setWarningText(Blockly.Translate('exec_result_warning'), this.id);
}
},
/**
* List of block types that are functions and thus do not need warnings.
* To add a new function type add this to your code:
* Blockly.Blocks['procedures_ifreturn'].FUNCTION_TYPES.push('custom_func');
*/
FUNCTION_TYPES: ['exec'],
};
Blockly.JavaScript['exec_result'] = function(block) {
const attr = block.getFieldValue('ATTR');

return [attr, Blockly.JavaScript.ORDER_ATOMIC];
};

// --- action http_get --------------------------------------------------
Blockly.Action.blocks['http_get'] =
'<block type="http_get">'
Expand Down
6 changes: 3 additions & 3 deletions admin/google-blockly/own/blocks_object.js
Expand Up @@ -229,7 +229,7 @@ Blockly.JavaScript['object_new'] = function(block) {
for (let n = 0; n < block.itemCount_; n++) {
const val = Blockly.JavaScript.valueToCode(block, 'ATTR_' + n, Blockly.JavaScript.ORDER_COMMA);
if (val) {
attributes.push(`'${block.attributes_[n]}': ${val}`);
attributes.push(`'${String(block.attributes_[n]).replaceAll(`'`, `\\'`)}': ${val}`);
}
}

Expand Down Expand Up @@ -282,7 +282,7 @@ Blockly.JavaScript['object_set_attr'] = function(block) {
obj = '{}';
}

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

// --- delete attribute --------------------------------------------------
Expand Down Expand Up @@ -321,7 +321,7 @@ Blockly.JavaScript['object_del_attr'] = function(block) {
obj = '{}';
}

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

// --- has attribute --------------------------------------------------
Expand Down

0 comments on commit 84d689b

Please sign in to comment.