iobroker.javascript 7.0.8 → 7.0.10

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/README.md CHANGED
@@ -46,6 +46,10 @@ Since v5.5.0 of the JavaScript adapter the following locations (relative to the
46
46
  <!--
47
47
  ### **WORK IN PROGRESS**
48
48
  -->
49
+ ### 7.0.10 (2023-06-13)
50
+ * (klein0r) Added new blocks: new line, random number, value between min and max, if empty
51
+ * (bluefox) corrected blockly
52
+
49
53
  ### 7.0.8 (2023-06-12)
50
54
  * (klein0r) Corrected trigger block
51
55
  * (klein0r) Corrected typescript V5
@@ -65,17 +69,6 @@ Since v5.5.0 of the JavaScript adapter the following locations (relative to the
65
69
  * (bluefox) made the editor visible in full height
66
70
  * (paul53) small fixes on blockly and translations are made
67
71
 
68
- ### 7.0.2 (2023-03-13)
69
- * (bluefox) Breaking change: all usages of `jsonata` must be rewritten to use promises.
70
- * (bluefox) Breaking change: all blockly scripts with `jsonata` blocks must be changed (just move some blocks) and saved anew.
71
- * (bluefox) Extended `createState` command with possibility to create aliases.
72
- * (bluefox) Corrected CRON card in rules
73
- * (bluefox) Added additional options to show the attributes of object in blockly
74
- * (bluefox) Corrected `existsStateAsync` function
75
- * (bluefox) Added `isDaylightSaving` state to indicate day saving time
76
- * (AlCalzone) Pinned `@types/node` to v14
77
- * (bluefox) Added list of astrological events in GUI
78
-
79
72
  ## License
80
73
  The MIT License (MIT)
81
74
 
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "files": {
3
- "main.js": "/static/js/main.d9e7d255.js",
3
+ "main.js": "/static/js/main.d5dc2784.js",
4
4
  "static/css/98.d346bb5b.chunk.css": "/static/css/98.d346bb5b.chunk.css",
5
- "static/js/98.bf3dfa2b.chunk.js": "/static/js/98.bf3dfa2b.chunk.js",
5
+ "static/js/98.eee0c52f.chunk.js": "/static/js/98.eee0c52f.chunk.js",
6
6
  "static/js/90.30165444.chunk.js": "/static/js/90.30165444.chunk.js",
7
7
  "static/js/305.11168aa5.chunk.js": "/static/js/305.11168aa5.chunk.js",
8
8
  "static/js/281.6af18b40.chunk.js": "/static/js/281.6af18b40.chunk.js",
@@ -11,7 +11,7 @@
11
11
  "static/js/164.d2d05c2a.chunk.js": "/static/js/164.d2d05c2a.chunk.js",
12
12
  "static/js/365.e144d615.chunk.js": "/static/js/365.e144d615.chunk.js",
13
13
  "static/js/815.5bc63a3b.chunk.js": "/static/js/815.5bc63a3b.chunk.js",
14
- "static/js/565.643198c0.chunk.js": "/static/js/565.643198c0.chunk.js",
14
+ "static/js/569.e2b427a7.chunk.js": "/static/js/569.e2b427a7.chunk.js",
15
15
  "static/js/910.e1389bdb.chunk.js": "/static/js/910.e1389bdb.chunk.js",
16
16
  "static/js/223.8f122ff3.chunk.js": "/static/js/223.8f122ff3.chunk.js",
17
17
  "static/js/827.a91bfa67.chunk.js": "/static/js/827.a91bfa67.chunk.js",
@@ -143,9 +143,9 @@
143
143
  "static/media/Garage Doors.svg": "/static/media/Garage Doors.0c2a1cfca7ad1ea59625.svg",
144
144
  "static/media/Outdoor Blinds.svg": "/static/media/Outdoor Blinds.37b85a9c060a4af48da9.svg",
145
145
  "static/media/Upstairs.svg": "/static/media/Upstairs.441813e54e0daca0882d.svg",
146
- "main.d9e7d255.js.map": "/static/js/main.d9e7d255.js.map",
146
+ "main.d5dc2784.js.map": "/static/js/main.d5dc2784.js.map",
147
147
  "98.d346bb5b.chunk.css.map": "/static/css/98.d346bb5b.chunk.css.map",
148
- "98.bf3dfa2b.chunk.js.map": "/static/js/98.bf3dfa2b.chunk.js.map",
148
+ "98.eee0c52f.chunk.js.map": "/static/js/98.eee0c52f.chunk.js.map",
149
149
  "90.30165444.chunk.js.map": "/static/js/90.30165444.chunk.js.map",
150
150
  "305.11168aa5.chunk.js.map": "/static/js/305.11168aa5.chunk.js.map",
151
151
  "281.6af18b40.chunk.js.map": "/static/js/281.6af18b40.chunk.js.map",
@@ -154,7 +154,7 @@
154
154
  "164.d2d05c2a.chunk.js.map": "/static/js/164.d2d05c2a.chunk.js.map",
155
155
  "365.e144d615.chunk.js.map": "/static/js/365.e144d615.chunk.js.map",
156
156
  "815.5bc63a3b.chunk.js.map": "/static/js/815.5bc63a3b.chunk.js.map",
157
- "565.643198c0.chunk.js.map": "/static/js/565.643198c0.chunk.js.map",
157
+ "569.e2b427a7.chunk.js.map": "/static/js/569.e2b427a7.chunk.js.map",
158
158
  "910.e1389bdb.chunk.js.map": "/static/js/910.e1389bdb.chunk.js.map",
159
159
  "223.8f122ff3.chunk.js.map": "/static/js/223.8f122ff3.chunk.js.map",
160
160
  "827.a91bfa67.chunk.js.map": "/static/js/827.a91bfa67.chunk.js.map",
@@ -166,6 +166,6 @@
166
166
  "472.dae7221e.chunk.js.map": "/static/js/472.dae7221e.chunk.js.map"
167
167
  },
168
168
  "entrypoints": [
169
- "static/js/main.d9e7d255.js"
169
+ "static/js/main.d5dc2784.js"
170
170
  ]
171
171
  }
@@ -0,0 +1,64 @@
1
+ 'use strict';
2
+
3
+ if (typeof goog !== 'undefined') {
4
+ goog.require('Blockly.JavaScript');
5
+ }
6
+
7
+ // --- logic between --------------------------------------------------
8
+
9
+ Blockly.Blocks['logic_between'] = {
10
+ init: function() {
11
+ this.appendValueInput('MIN')
12
+ .setCheck('Number');
13
+ this.appendValueInput('VALUE')
14
+ .setCheck('Number')
15
+ .appendField(new Blockly.FieldDropdown([['<', 'LT'], ['≤', 'LE']]), 'MIN_OPERATOR');
16
+ this.appendValueInput('MAX')
17
+ .setCheck('Number')
18
+ .appendField(new Blockly.FieldDropdown([['<', 'LT'], ['≤', 'LE']]), 'MAX_OPERATOR');
19
+
20
+ this.setInputsInline(true);
21
+ this.setOutput(true, 'Boolean');
22
+ this.setColour("%{BKY_LOGIC_HUE}");
23
+ this.setTooltip(Blockly.Translate('logic_between_tooltip'));
24
+ // this.setHelpUrl(Blockly.Translate('logic_between_helpurl'));
25
+ }
26
+ }
27
+
28
+ Blockly.JavaScript['logic_between'] = function(block) {
29
+ const min = Blockly.JavaScript.valueToCode(block, 'MIN', Blockly.JavaScript.ORDER_RELATIONAL) || 0;
30
+ const value = Blockly.JavaScript.valueToCode(block, 'VALUE', Blockly.JavaScript.ORDER_RELATIONAL) || 0;
31
+ const max = Blockly.JavaScript.valueToCode(block, 'MAX', Blockly.JavaScript.ORDER_RELATIONAL) || 0;
32
+ const minOperator = block.getFieldValue('MIN_OPERATOR') === 'LT' ? '<' : '<=';
33
+ const maxOperator = block.getFieldValue('MAX_OPERATOR') === 'LT' ? '<' : '<=';
34
+
35
+ return [`${min} ${minOperator} ${value} && ${value} ${maxOperator} ${max}`, Blockly.JavaScript.ORDER_LOGICAL_AND];
36
+ }
37
+
38
+ // --- logic ifempty --------------------------------------------------
39
+
40
+ Blockly.Blocks['logic_ifempty'] = {
41
+ init: function() {
42
+ this.appendValueInput('VALUE')
43
+ .setCheck(null)
44
+ .setAlign(Blockly.ALIGN_RIGHT)
45
+ .appendField(Blockly.Translate('logic_ifempty'));
46
+ this.appendValueInput('DEFLT')
47
+ .setCheck(null)
48
+ .setAlign(Blockly.ALIGN_RIGHT)
49
+ .appendField(Blockly.Translate('logic_ifempty_then'));
50
+
51
+ this.setOutput(true, null);
52
+ this.setInputsInline(true);
53
+ this.setColour("%{BKY_LOGIC_HUE}");
54
+ this.setTooltip(Blockly.Translate('logic_ifempty_tooltip'));
55
+ // this.setHelpUrl(Blockly.Translate('logic_ifempty_helpurl'));
56
+ }
57
+ }
58
+
59
+ Blockly.JavaScript['logic_ifempty'] = function(block) {
60
+ const value = Blockly.JavaScript.valueToCode(block, 'VALUE', Blockly.JavaScript.ORDER_LOGICAL_OR) || null;
61
+ const deflt = Blockly.JavaScript.valueToCode(block, 'DEFLT', Blockly.JavaScript.ORDER_LOGICAL_OR) || null;
62
+
63
+ return [value + ' || ' + deflt, Blockly.JavaScript.ORDER_LOGICAL_OR];
64
+ };
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ // --- Round Number to n decimal places -------------------------------
4
+
5
+ Blockly.Blocks['math_rndfixed'] = {
6
+ init: function() {
7
+ this.appendValueInput('x')
8
+ .setCheck('Number')
9
+ .appendField(Blockly.Translate('math_rndfixed_round'));
10
+ this.appendDummyInput()
11
+ .appendField(Blockly.Translate('math_rndfixed_to'))
12
+ .appendField(new Blockly.FieldNumber(0, 1, 25), 'n')
13
+ .appendField(Blockly.Translate('math_rndfixed_decplcs'));
14
+ this.setInputsInline(true);
15
+ this.setColour(Blockly.Msg['MATH_HUE']);
16
+ this.setOutput(true, 'Number');
17
+ this.setTooltip(Blockly.Translate('math_rndfixed_tooltip'));
18
+ }
19
+ };
20
+
21
+ Blockly.JavaScript['math_rndfixed'] = function(block) {
22
+ var x = Blockly.JavaScript.valueToCode(block, 'x', Blockly.JavaScript.ORDER_ATOMIC);
23
+ var exp = Math.pow(10, block.getFieldValue('n'));
24
+ return ['Math.round(' + x + ' * ' + exp + ') / ' + exp, Blockly.JavaScript.ORDER_ATOMIC];
25
+ };
@@ -9,10 +9,6 @@ if (typeof goog !== 'undefined') {
9
9
  Blockly.CustomBlocks = Blockly.CustomBlocks || [];
10
10
  Blockly.CustomBlocks.push('System');
11
11
 
12
- function getHelp(word) {
13
- return 'https://github.com/ioBroker/ioBroker.javascript/blob/master/docs/en/javascript.md#' + Blockly.Words[word][systemLang];
14
- }
15
-
16
12
  Blockly.System = {
17
13
  HUE: 210,
18
14
  blocks: {}
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ // --- Text new line --------------------------------------------------
4
+
5
+ Blockly.Blocks['text_newline'] = {
6
+ // Checkbox.
7
+ init: function() {
8
+ this.appendDummyInput()
9
+ .appendField(Blockly.Translate('text_newline'));
10
+
11
+ this.appendDummyInput()
12
+ .appendField(new Blockly.FieldDropdown([['\\n', '\\n'], ['\\r\\n', '\\r\\n'], ['\\r', '\\r']]), 'Type');
13
+ this.setInputsInline(true);
14
+ this.setColour(Blockly.Msg['TEXTS_HUE']);
15
+ this.setOutput(true, 'String');
16
+ this.setTooltip(Blockly.Translate('text_newline_tooltip'));
17
+ }
18
+ };
19
+
20
+ Blockly.JavaScript['text_newline'] = function(block) {
21
+ var dropdown_type = block.getFieldValue('Type');
22
+ return ['\'' + dropdown_type + '\'', Blockly.JavaScript.ORDER_ATOMIC];
23
+ };
@@ -163,12 +163,12 @@ Blockly.Words['get_value_comment'] = {'en': 'Value comment',
163
163
  Blockly.Words['get_value_from'] = {'en': 'Source', 'de': 'Quelle', 'ru': 'Происхождение', 'pt': 'Fonte', 'nl': 'Bron', 'fr': 'La source', 'it': 'fonte', 'es': 'Fuente', 'pl': 'Source', 'zh-cn': '上次变更发起者', 'uk': 'Джерело'};
164
164
  Blockly.Words['get_common_name'] = {'en': 'Object name', 'de': 'Objektname', 'ru': 'Имя объекта', 'pt': 'Nome do objeto', 'nl': 'Object naam', 'fr': 'Nom de l\'objet', 'it': 'Nome oggetto', 'es': 'Nombre del objeto', 'pl': 'Nazwa obiektu', 'zh-cn': '对象名称', 'uk': 'Назва об\'єкта'};
165
165
  Blockly.Words['get_common_desc'] = {'en': 'Object description', 'de': 'Objektbeschreibung', 'ru': 'Описание объекта', 'pt': 'Descrição do objeto', 'nl': 'Objectbeschrijving', 'fr': 'Descriptif de l\'objet', 'it': 'Descrizione dell\'oggetto', 'es': 'Descripción del objeto', 'pl': 'Opis obiektu', 'zh-cn': '对象描述', 'uk': 'Опис об\'єкта'};
166
- Blockly.Words['get_common_unit'] = {'en': 'State unit', 'de': 'Zustands-Einheit', 'ru': 'Единица измерения', 'pt': 'unidade estadual', 'nl': 'Staatseenheid', 'fr': 'Unité d\'état', 'it': 'Unità statale', 'es': 'unidad estatal', 'pl': 'Jednostka państwowa', 'zh-cn': '国家单位', 'uk': 'Державна одиниця'};
166
+ Blockly.Words['get_common_unit'] = {'en': 'State unit', 'de': 'Zustands-Einheit', 'ru': 'Единица измерения', 'pt': 'unidade estadual', 'nl': 'Staatseenheid', 'fr': 'Unité d\'état', 'it': 'Unità statale', 'es': 'unidad estatal', 'pl': 'Jednostka państwowa', 'zh-cn': '国家单位', 'uk': 'Державна одиниця'};
167
167
  Blockly.Words['get_common_role'] = {'en': 'Object role', 'de': 'Objektrolle', 'ru': 'Роль объекта', 'pt': 'função do objeto', 'nl': 'Object rol', 'fr': 'Rôle d\'objet', 'it': 'Ruolo dell\'oggetto', 'es': 'Rol de objeto', 'pl': 'Rola obiektu', 'zh-cn': '对象角色', 'uk': 'Об\'єктна роль'};
168
168
  Blockly.Words['get_common_state_type'] = {'en': 'State type', 'de': 'Zustandstyp', 'ru': 'Тип состояния', 'pt': 'tipo de estado', 'nl': 'Type staat', 'fr': 'Type d\'état', 'it': 'Tipo di stato', 'es': 'tipo de estado', 'pl': 'Typ stanu', 'zh-cn': '状态类型', 'uk': 'Державний тип'};
169
169
  Blockly.Words['get_common_object_type'] = {'en': 'Object type', 'de': 'Objekttyp', 'ru': 'Тип объекта', 'pt': 'Tipo de objeto', 'nl': 'Object type', 'fr': 'Type d\'objet', 'it': 'Tipo di oggetto', 'es': 'Tipo de objeto', 'pl': 'Rodzaj obiektu', 'zh-cn': '对象类型', 'uk': 'Тип об\'єкта'};
170
- Blockly.Words['get_common_read'] = {'en': 'Is state readable', 'de': 'Zustand lesbar ist', 'ru': 'Является читаемым', 'pt': 'O estado é legível', 'nl': 'Staat leesbaar', 'fr': 'L\'état est-il lisible', 'it': 'È leggibile dallo stato', 'es': 'Es estado legible', 'pl': 'Czy stan jest czytelny', 'zh-cn': '状态是否可读', 'uk': 'Чи читається стан'};
171
- Blockly.Words['get_common_write'] = {'en': 'Is state writable', 'de': 'Zustand beschreibbar ist', 'ru': 'Доступно для записи', 'pt': 'É estado gravável', 'nl': 'Staat beschrijfbaar', 'fr': 'L\'état est-il accessible en écriture', 'it': 'È stato scrivibile', 'es': 'Es el estado escribible', 'pl': 'Czy stan jest zapisywalny', 'zh-cn': '状态是否可写', 'uk': 'Доступний для запису в стані'};
170
+ Blockly.Words['get_common_read'] = {'en': 'Is state readable', 'de': 'Zustand lesbar ist', 'ru': 'Является читаемым', 'pt': 'O estado é legível', 'nl': 'Staat leesbaar', 'fr': 'L\'état est-il lisible', 'it': 'È leggibile dallo stato', 'es': 'Es estado legible', 'pl': 'Czy stan jest czytelny', 'zh-cn': '状态是否可读', 'uk': 'Чи читається стан'};
171
+ Blockly.Words['get_common_write'] = {'en': 'Is state writable', 'de': 'Zustand beschreibbar ist', 'ru': 'Доступно для записи', 'pt': 'É estado gravável', 'nl': 'Staat beschrijfbaar', 'fr': 'L\'état est-il accessible en écriture', 'it': 'È stato scrivibile', 'es': 'Es el estado escribible', 'pl': 'Czy stan jest zapisywalny', 'zh-cn': '状态是否可写', 'uk': 'Доступний для запису в стані'};
172
172
  Blockly.Words['get_value_async'] = {'en': 'Get state value', 'de': 'Zustandswert nehmen', 'ru': 'Взять значение состояния', 'pt': 'Tome o valor do estado', 'nl': 'Krijg statuswaarde', 'fr': 'Obtenir la valeur de l\'état', 'it': 'Ottieni valore statale', 'es': 'Obtener valor de estado', 'pl': 'Get state value', 'zh-cn': '获取状态的值', 'uk': 'Отримати державне значення'};
173
173
 
174
174
  // --- system field --------------------------------------------------
@@ -444,16 +444,21 @@ Blockly.Words['onMessage_message'] = {'en': 'message',
444
444
  Blockly.Words['onMessage_tooltip'] = {'en': 'message', 'de': 'Meldung', 'ru': 'сообщение', 'pt': 'mensagem', 'nl': 'bericht', 'fr': 'message', 'it': 'messaggio', 'es': 'mensaje', 'pl': 'komunikat', 'zh-cn': '消息', 'uk': 'повідомлення'};
445
445
  Blockly.Words['onMessage_help'] = {'en': 'onMessage', 'de': 'onMessage', 'ru': 'onMessage', 'pt': 'onMessage', 'nl': 'onMessage', 'fr': 'onMessage', 'it': 'onMessage', 'es': 'onMessage', 'pl': 'onMessage', 'zh-cn': 'onMessage', 'uk': 'onMessage'};
446
446
 
447
- // --- OTHER --------------------------------------------------
448
- Blockly.Words['Other'] = {'en': 'Other', 'de': 'Sonstige', 'ru': 'Другое', 'pt': 'Outros', 'nl': 'Andere', 'fr': 'Autres', 'it': 'Altri', 'es': 'Otros', 'pl': 'Inny', 'zh-cn': '其他', 'uk': 'Інше'};
447
+ // --- LOGIC --------------------------------------------------
449
448
 
450
- // --- other between --------------------------------------------------
451
- Blockly.Words['other_between_min'] = { "en": "Min", "de": "Min", "ru": "Мин", "pt": "Min", "nl": "Min", "fr": "Min", "it": "Min", "es": "Min", "pl": "Min", "uk": "Мінуси", "zh-cn": "明 明" };
452
- Blockly.Words['other_between_max'] = { "en": "Max", "de": "Max", "ru": "Макс", "pt": "Max", "nl": "Max", "fr": "Max", "it": "Max", "es": "Max", "pl": "Max", "uk": "Макс", "zh-cn": "Max" };
449
+ // --- logic between --------------------------------------------------
450
+ Blockly.Words['logic_between_min'] = {'en': 'Min', 'de': 'Min', 'ru': 'Мин', 'pt': 'Min', 'nl': 'Min', 'fr': 'Min', 'it': 'Min', 'es': 'Min', 'pl': 'Min', 'zh-cn': '明 明', 'uk': 'Мінуси'};
451
+ Blockly.Words['logic_between_max'] = {'en': 'Max', 'de': 'Max', 'ru': 'Макс', 'pt': 'Max', 'nl': 'Max', 'fr': 'Max', 'it': 'Max', 'es': 'Max', 'pl': 'Max', 'zh-cn': 'Max', 'uk': 'Макс'};
452
+ Blockly.Words['logic_between_tooltip'] = {'en': 'if a number between min and max', 'de': 'wenn eine Zahl zwischen min und max', 'ru': 'если число между min и max', 'pt': 'se um número entre min e max', 'nl': 'als een getal tussen min en max', 'fr': 'si un nombre entre min et max', 'it': 'se un numero compreso tra min e max', 'es': 'si un número entre min y max', 'pl': 'jeśli liczba między min a max', 'zh-cn': '如果最小值和最大值之间的数字', 'uk': 'якщо число між min і max'};
453
453
 
454
- // --- other_ifempty --------------------------------------------------
455
- Blockly.Words['other_ifempty'] = { "en": "if empty", "de": "wenn leer", "ru": "если пусто", "pt": "se vazio", "nl": "_", "fr": "si vide", "it": "se vuoto", "es": "si está vacío", "pl": "jeśli chodzi o puste", "uk": "якщо порожній", "zh-cn": "" };
456
- Blockly.Words['other_ifempty_then'] = { "en": "then", "de": "dann", "ru": "затем", "pt": "então", "nl": "dan", "fr": "puis", "it": "allora", "es": "entonces", "pl": "potem", "uk": "потім", "zh-cn": "然后" };
454
+ // --- logic ifempty --------------------------------------------------
455
+ Blockly.Words['logic_ifempty'] = {'en': 'if empty', 'de': 'wenn leer', 'ru': 'если пусто', 'pt': 'se vazio', 'nl': '_', 'fr': 'si vide', 'it': 'se vuoto', 'es': 'si está vacío', 'pl': 'jeśli chodzi o puste', 'zh-cn': '', 'uk': 'якщо порожній'};
456
+ Blockly.Words['logic_ifempty_then'] = {'en': 'then', 'de': 'dann', 'ru': 'затем', 'pt': 'então', 'nl': 'dan', 'fr': 'puis', 'it': 'allora', 'es': 'entonces', 'pl': 'potem', 'zh-cn': '然后', 'uk': 'потім'};
457
+ Blockly.Words['logic_ifempty_tooltip'] = {'en': 'check if empty', 'de': 'Überprüfen, ob es leer ist', 'ru': 'проверить, если пусто', 'pt': 'verifique se está vazio', 'nl': 'controleer of leeg', 'fr': 'vérifier si vide', 'it': 'controlla se vuoto', 'es': 'comprobar si está vacío', 'pl': 'sprawdź, czy jest pusty', 'zh-cn': '检查是否为空', 'uk': 'перевірити, чи порожній'};
458
+
459
+ function getHelp(word) {
460
+ return 'https://github.com/ioBroker/ioBroker.javascript/blob/master/docs/en/javascript.md#' + Blockly.Words[word][systemLang];
461
+ }
457
462
 
458
463
  Blockly.Translate = function (word, lang) {
459
464
  lang = lang || systemLang;
@@ -466,4 +471,4 @@ Blockly.Translate = function (word, lang) {
466
471
 
467
472
  if (typeof module !== 'undefined' && typeof module.parent !== 'undefined') {
468
473
  module.exports = Blockly;
469
- }
474
+ }