iobroker.javascript 7.9.3 → 7.9.4

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,11 @@ 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.9.4 (2024-03-20)
50
+
51
+ * (klein0r) Fixed urlencoding for basic auth in url (user:pass)
52
+ * (klein0r) Add warning icon if trigger is positioned inside of another trigger or loop
53
+
49
54
  ### 7.9.3 (2024-03-19)
50
55
 
51
56
  * (klein0r) Added timeout option for http blocks
@@ -69,12 +74,6 @@ Since v5.5.0 of the JavaScript adapter the following locations (relative to the
69
74
  * (klein0r) Raise warning if more than 100 triggers have been registered (per script)
70
75
  * (klein0r) Fixed astro state calculation (and display server time in dialog)
71
76
 
72
- ### 7.8.0 (2024-01-29)
73
-
74
- * (klein0r) Added block for multiple or conditions
75
- * (klein0r) Raised supported ecmaVersion from es2018 to es2021
76
- * (klein0r) Fixed getIdByName (returned the same id as array)
77
-
78
77
  ## License
79
78
  The MIT License (MIT)
80
79
 
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "files": {
3
- "main.js": "/static/js/main.86e49ae9.js",
3
+ "main.js": "/static/js/main.333e4250.js",
4
4
  "static/css/184.7463f8b6.chunk.css": "/static/css/184.7463f8b6.chunk.css",
5
- "static/js/184.2d8f4f6a.chunk.js": "/static/js/184.2d8f4f6a.chunk.js",
5
+ "static/js/184.e7ed24fc.chunk.js": "/static/js/184.e7ed24fc.chunk.js",
6
6
  "static/js/966.088c1225.chunk.js": "/static/js/966.088c1225.chunk.js",
7
7
  "static/js/30.8bf17a3b.chunk.js": "/static/js/30.8bf17a3b.chunk.js",
8
8
  "static/js/704.4ede9892.chunk.js": "/static/js/704.4ede9892.chunk.js",
@@ -32,7 +32,7 @@
32
32
  "static/js/9.1974e3b5.chunk.js": "/static/js/9.1974e3b5.chunk.js",
33
33
  "static/js/310.b6dfc5a1.chunk.js": "/static/js/310.b6dfc5a1.chunk.js",
34
34
  "static/js/360.10c9e6c6.chunk.js": "/static/js/360.10c9e6c6.chunk.js",
35
- "static/js/77.97f379b6.chunk.js": "/static/js/77.97f379b6.chunk.js",
35
+ "static/js/77.b19f5770.chunk.js": "/static/js/77.b19f5770.chunk.js",
36
36
  "static/media/tileRules.png": "/static/media/tileRules.7ed5885a66686cc288b1.png",
37
37
  "static/media/docs.md": "/static/media/docs.1f96bec81cf08933d921.md",
38
38
  "static/media/back.jpg": "/static/media/back.bda2bbe51be338a0f657.jpg",
@@ -160,9 +160,9 @@
160
160
  "static/media/Garage Doors.svg": "/static/media/Garage Doors.0c2a1cfca7ad1ea59625.svg",
161
161
  "static/media/Outdoor Blinds.svg": "/static/media/Outdoor Blinds.37b85a9c060a4af48da9.svg",
162
162
  "static/media/Upstairs.svg": "/static/media/Upstairs.441813e54e0daca0882d.svg",
163
- "main.86e49ae9.js.map": "/static/js/main.86e49ae9.js.map",
163
+ "main.333e4250.js.map": "/static/js/main.333e4250.js.map",
164
164
  "184.7463f8b6.chunk.css.map": "/static/css/184.7463f8b6.chunk.css.map",
165
- "184.2d8f4f6a.chunk.js.map": "/static/js/184.2d8f4f6a.chunk.js.map",
165
+ "184.e7ed24fc.chunk.js.map": "/static/js/184.e7ed24fc.chunk.js.map",
166
166
  "966.088c1225.chunk.js.map": "/static/js/966.088c1225.chunk.js.map",
167
167
  "30.8bf17a3b.chunk.js.map": "/static/js/30.8bf17a3b.chunk.js.map",
168
168
  "704.4ede9892.chunk.js.map": "/static/js/704.4ede9892.chunk.js.map",
@@ -192,9 +192,9 @@
192
192
  "9.1974e3b5.chunk.js.map": "/static/js/9.1974e3b5.chunk.js.map",
193
193
  "310.b6dfc5a1.chunk.js.map": "/static/js/310.b6dfc5a1.chunk.js.map",
194
194
  "360.10c9e6c6.chunk.js.map": "/static/js/360.10c9e6c6.chunk.js.map",
195
- "77.97f379b6.chunk.js.map": "/static/js/77.97f379b6.chunk.js.map"
195
+ "77.b19f5770.chunk.js.map": "/static/js/77.b19f5770.chunk.js.map"
196
196
  },
197
197
  "entrypoints": [
198
- "static/js/main.86e49ae9.js"
198
+ "static/js/main.333e4250.js"
199
199
  ]
200
200
  }
@@ -256,27 +256,27 @@ Blockly.Blocks['sendto_custom'] = {
256
256
  names[i] = Blockly.Translate('sendto_custom_argument') + (i + 1);
257
257
  }
258
258
  _input.appendField(new Blockly.FieldTextInput(names[i]));
259
- setTimeout(function (_input) {
260
- if (!_input.connection.isConnected()) {
259
+ setTimeout(function (input) {
260
+ if (!input.connection.isConnected()) {
261
261
  const _shadow = wp.newBlock('text');
262
262
  _shadow.setShadow(true);
263
263
  _shadow.initSvg();
264
264
  _shadow.render();
265
- _shadow.outputConnection.connect(_input.connection);
265
+ _shadow.outputConnection.connect(input.connection);
266
266
  //console.log('New ' + names[i]);
267
267
  }
268
268
  }, 100, _input);
269
269
  } else {
270
270
  _input.fieldRow[0].setValue(names[i]);
271
271
  //console.log('Exist ' + names[i]);
272
- setTimeout(function (_input, name) {
273
- if (!_input.connection.isConnected()) {
272
+ setTimeout(function (input, name) {
273
+ if (!input.connection.isConnected()) {
274
274
  //console.log('Create ' + name);
275
275
  const shadow = wp.newBlock('text');
276
276
  shadow.setShadow(true);
277
277
  shadow.initSvg();
278
278
  shadow.render();
279
- shadow.outputConnection.connect(_input.connection);
279
+ shadow.outputConnection.connect(input.connection);
280
280
  }
281
281
  }, 100, _input, names[i]);
282
282
  }
@@ -9,10 +9,14 @@ if (typeof goog !== 'undefined') {
9
9
  Blockly.CustomBlocks = Blockly.CustomBlocks || [];
10
10
  Blockly.CustomBlocks.push('Trigger');
11
11
 
12
-
13
12
  Blockly.Trigger = {
14
13
  HUE: 330,
15
14
  blocks: {},
15
+ WARNING_PARENTS: [
16
+ 'on', 'on_ext', 'schedule', 'schedule_by_id', 'schedule_create', 'astro', 'onMessage', 'onFile', // trigger blocks
17
+ 'timeouts_setinterval', 'timeouts_setinterval_variable', // timeouts
18
+ 'controls_repeat_ext', 'controls_repeat_ext', 'controls_for', 'controls_forEach', // loops
19
+ ],
16
20
  };
17
21
 
18
22
  // --- ON Extended-----------------------------------------------------------
@@ -207,21 +211,21 @@ Blockly.Blocks['on_ext'] = {
207
211
  if (i === 0) {
208
212
  _input.appendField(Blockly.Translate('on_ext'));
209
213
  }
210
- setTimeout((_input) => {
211
- if (!_input.connection.isConnected()) {
214
+ setTimeout((input) => {
215
+ if (!input.connection.isConnected()) {
212
216
  const shadow = wp.newBlock('field_oid');
213
217
  shadow.setShadow(true);
214
- shadow.outputConnection.connect(_input.connection);
218
+ shadow.outputConnection.connect(input.connection);
215
219
  shadow.initSvg();
216
220
  shadow.render();
217
221
  }
218
222
  }, 100, _input);
219
223
  } else {
220
- setTimeout((_input) => {
221
- if (!_input.connection.isConnected()) {
224
+ setTimeout((input) => {
225
+ if (!input.connection.isConnected()) {
222
226
  const shadow = wp.newBlock('field_oid');
223
227
  shadow.setShadow(true);
224
- shadow.outputConnection.connect(_input.connection);
228
+ shadow.outputConnection.connect(input.connection);
225
229
  shadow.initSvg();
226
230
  shadow.render();
227
231
  }
@@ -267,6 +271,30 @@ Blockly.Blocks['on_ext'] = {
267
271
  this.appendStatementInput('STATEMENT')
268
272
  .setCheck(null)
269
273
  }
274
+ },
275
+ /**
276
+ * Called whenever anything on the workspace changes.
277
+ * Add warning if this flow block is not nested inside a loop.
278
+ * @param {!Blockly.Events.Abstract} e Change event.
279
+ * @this Blockly.Block
280
+ */
281
+ onchange: function(e) {
282
+ let legal = true;
283
+
284
+ // Is the block nested in a trigger?
285
+ let block = this;
286
+ while (block = block.getSurroundParent()) {
287
+ if (block && Blockly.Trigger.WARNING_PARENTS.includes(block.type)) {
288
+ legal = false;
289
+ break;
290
+ }
291
+ }
292
+
293
+ if (legal) {
294
+ this.setWarningText(null, this.id);
295
+ } else {
296
+ this.setWarningText(Blockly.Translate('trigger_in_trigger_warning'), this.id);
297
+ }
270
298
  }
271
299
  };
272
300
  Blockly.JavaScript['on_ext'] = function(block) {
@@ -353,6 +381,30 @@ Blockly.Blocks['on'] = {
353
381
  this.setColour(Blockly.Trigger.HUE);
354
382
  this.setTooltip(Blockly.Translate('on_tooltip'));
355
383
  this.setHelpUrl(getHelp('on_help'));
384
+ },
385
+ /**
386
+ * Called whenever anything on the workspace changes.
387
+ * Add warning if this flow block is not nested inside a loop.
388
+ * @param {!Blockly.Events.Abstract} e Change event.
389
+ * @this Blockly.Block
390
+ */
391
+ onchange: function(e) {
392
+ let legal = true;
393
+
394
+ // Is the block nested in a trigger?
395
+ let block = this;
396
+ while (block = block.getSurroundParent()) {
397
+ if (block && Blockly.Trigger.WARNING_PARENTS.includes(block.type)) {
398
+ legal = false;
399
+ break;
400
+ }
401
+ }
402
+
403
+ if (legal) {
404
+ this.setWarningText(null, this.id);
405
+ } else {
406
+ this.setWarningText(Blockly.Translate('trigger_in_trigger_warning'), this.id);
407
+ }
356
408
  }
357
409
  };
358
410
  Blockly.JavaScript['on'] = function(block) {
@@ -500,6 +552,30 @@ Blockly.Blocks['schedule'] = {
500
552
  this.setColour(Blockly.Trigger.HUE);
501
553
  this.setTooltip(Blockly.Translate('schedule_tooltip'));
502
554
  this.setHelpUrl(getHelp('schedule_help'));
555
+ },
556
+ /**
557
+ * Called whenever anything on the workspace changes.
558
+ * Add warning if this flow block is not nested inside a loop.
559
+ * @param {!Blockly.Events.Abstract} e Change event.
560
+ * @this Blockly.Block
561
+ */
562
+ onchange: function(e) {
563
+ let legal = true;
564
+
565
+ // Is the block nested in a trigger?
566
+ let block = this;
567
+ while (block = block.getSurroundParent()) {
568
+ if (block && Blockly.Trigger.WARNING_PARENTS.includes(block.type)) {
569
+ legal = false;
570
+ break;
571
+ }
572
+ }
573
+
574
+ if (legal) {
575
+ this.setWarningText(null, this.id);
576
+ } else {
577
+ this.setWarningText(Blockly.Translate('trigger_in_trigger_warning'), this.id);
578
+ }
503
579
  }
504
580
  };
505
581
  Blockly.JavaScript['schedule'] = function(block) {
@@ -620,6 +696,30 @@ Blockly.Blocks['astro'] = {
620
696
  this.setColour(Blockly.Trigger.HUE);
621
697
  this.setTooltip(Blockly.Translate('astro_tooltip'));
622
698
  this.setHelpUrl(getHelp('astro_help'));
699
+ },
700
+ /**
701
+ * Called whenever anything on the workspace changes.
702
+ * Add warning if this flow block is not nested inside a loop.
703
+ * @param {!Blockly.Events.Abstract} e Change event.
704
+ * @this Blockly.Block
705
+ */
706
+ onchange: function(e) {
707
+ let legal = true;
708
+
709
+ // Is the block nested in a trigger?
710
+ let block = this;
711
+ while (block = block.getSurroundParent()) {
712
+ if (block && Blockly.Trigger.WARNING_PARENTS.includes(block.type)) {
713
+ legal = false;
714
+ break;
715
+ }
716
+ }
717
+
718
+ if (legal) {
719
+ this.setWarningText(null, this.id);
720
+ } else {
721
+ this.setWarningText(Blockly.Translate('trigger_in_trigger_warning'), this.id);
722
+ }
623
723
  }
624
724
  };
625
725
  Blockly.JavaScript['astro'] = function(block) {
@@ -734,14 +834,6 @@ Blockly.Blocks['schedule_create'] = {
734
834
  this.setColour(Blockly.Trigger.HUE);
735
835
  this.setTooltip(Blockly.Translate('schedule_create_tooltip'));
736
836
  this.setHelpUrl(getHelp('schedule_create_help'));
737
- },
738
- isSchedule_: true,
739
- getVars: function () {
740
- return [this.getFieldValue('NAME')];
741
- },
742
- getVarModels: function () {
743
- const name = this.getFieldValue('NAME');
744
- return [{ getId: () => { return name; }, name: name, type: 'cron' }];
745
837
  }
746
838
  };
747
839
 
@@ -750,7 +842,7 @@ Blockly.JavaScript['schedule_create'] = function (block) {
750
842
  const schedule = Blockly.JavaScript.valueToCode(block, 'SCHEDULE', Blockly.JavaScript.ORDER_ATOMIC);
751
843
  const statement = Blockly.JavaScript.statementToCode(block, 'STATEMENT');
752
844
 
753
- return name + ' = schedule(' + schedule + ', async () => {\n' +
845
+ return `${name} = schedule(${schedule}, async () => {\n` +
754
846
  statement +
755
847
  '});\n';
756
848
  };
@@ -783,8 +875,8 @@ Blockly.Trigger.getAllSchedules = function (workspace) {
783
875
 
784
876
  Blockly.Trigger.blocks['schedule_clear'] =
785
877
  '<block type="schedule_clear">'
786
- + ' <value name="NAME">'
787
- + ' </value>'
878
+ + ' <value name="NAME">'
879
+ + ' </value>'
788
880
  + '</block>';
789
881
 
790
882
  Blockly.Blocks['schedule_clear'] = {
@@ -834,7 +926,7 @@ Blockly.Blocks['field_cron'] = {
834
926
 
835
927
  Blockly.JavaScript['field_cron'] = function(block) {
836
928
  const cron = block.getFieldValue('CRON');
837
- return [`'${cron}'`, Blockly.JavaScript.ORDER_ATOMIC]
929
+ return [`'${cron}'`, Blockly.JavaScript.ORDER_ATOMIC];
838
930
  };
839
931
 
840
932
  // --- CRON builder --------------------------------------------------
@@ -874,60 +966,60 @@ Blockly.Blocks['cron_builder'] = {
874
966
 
875
967
  const wp = this.workspace;
876
968
 
877
- setTimeout((_input) => {
878
- if (!_input.connection.isConnected()) {
969
+ setTimeout((input) => {
970
+ if (!input.connection.isConnected()) {
879
971
  const _shadow = wp.newBlock('text');
880
972
  _shadow.setShadow(true);
881
973
  _shadow.setFieldValue('*', 'TEXT');
882
- _shadow.outputConnection.connect(_input.connection);
974
+ _shadow.outputConnection.connect(input.connection);
883
975
  }
884
976
  }, 100, _input);
885
977
 
886
978
  _input = this.appendValueInput('MONTHS')
887
979
  .appendField(Blockly.Translate('cron_builder_month'));
888
980
 
889
- setTimeout((_input) => {
890
- if (!_input.connection.isConnected()) {
981
+ setTimeout((input) => {
982
+ if (!input.connection.isConnected()) {
891
983
  const _shadow = wp.newBlock('text');
892
984
  _shadow.setShadow(true);
893
985
  _shadow.setFieldValue('*', 'TEXT');
894
- _shadow.outputConnection.connect(_input.connection);
986
+ _shadow.outputConnection.connect(input.connection);
895
987
  }
896
988
  }, 100, _input);
897
989
 
898
990
  _input = this.appendValueInput('DAYS')
899
991
  .appendField(Blockly.Translate('cron_builder_day'));
900
992
 
901
- setTimeout((_input) => {
902
- if (!_input.connection.isConnected()) {
993
+ setTimeout((input) => {
994
+ if (!input.connection.isConnected()) {
903
995
  const _shadow = wp.newBlock('text');
904
996
  _shadow.setShadow(true);
905
997
  _shadow.setFieldValue('*', 'TEXT');
906
- _shadow.outputConnection.connect(_input.connection);
998
+ _shadow.outputConnection.connect(input.connection);
907
999
  }
908
1000
  }, 100, _input);
909
1001
 
910
1002
  _input = this.appendValueInput('HOURS')
911
1003
  .appendField(Blockly.Translate('cron_builder_hour'));
912
1004
 
913
- setTimeout((_input) => {
914
- if (!_input.connection.isConnected()) {
1005
+ setTimeout((input) => {
1006
+ if (!input.connection.isConnected()) {
915
1007
  const _shadow = wp.newBlock('text');
916
1008
  _shadow.setShadow(true);
917
1009
  _shadow.setFieldValue('*', 'TEXT');
918
- _shadow.outputConnection.connect(_input.connection);
1010
+ _shadow.outputConnection.connect(input.connection);
919
1011
  }
920
1012
  }, 100, _input);
921
1013
 
922
1014
  _input = this.appendValueInput('MINUTES')
923
1015
  .appendField(Blockly.Translate('cron_builder_minutes'));
924
1016
 
925
- setTimeout((_input) => {
926
- if (!_input.connection.isConnected()) {
1017
+ setTimeout((input) => {
1018
+ if (!input.connection.isConnected()) {
927
1019
  const _shadow = wp.newBlock('text');
928
1020
  _shadow.setShadow(true);
929
1021
  _shadow.setFieldValue('*', 'TEXT');
930
- _shadow.outputConnection.connect(_input.connection);
1022
+ _shadow.outputConnection.connect(input.connection);
931
1023
  }
932
1024
  }, 100, _input);
933
1025
 
@@ -978,14 +1070,14 @@ Blockly.Blocks['cron_builder'] = {
978
1070
  const _input = this.appendValueInput('SECONDS');
979
1071
  _input.appendField(Blockly.Translate('cron_builder_seconds'));
980
1072
  const wp = this.workspace;
981
- setTimeout((_input) => {
982
- if (!_input.connection.isConnected()) {
1073
+ setTimeout((input) => {
1074
+ if (!input.connection.isConnected()) {
983
1075
  const _shadow = wp.newBlock('text');
984
1076
  _shadow.setShadow(true);
985
1077
  _shadow.setFieldValue('*', 'TEXT');
986
1078
  _shadow.initSvg();
987
1079
  _shadow.render();
988
- _shadow.outputConnection.connect(_input.connection);
1080
+ _shadow.outputConnection.connect(input.connection);
989
1081
  }
990
1082
  }, 100, _input);
991
1083
  }
@@ -1045,6 +1137,30 @@ Blockly.Blocks['onMessage'] = {
1045
1137
  this.setColour(Blockly.Trigger.HUE);
1046
1138
  this.setTooltip(Blockly.Translate('onMessage_tooltip'));
1047
1139
  this.setHelpUrl(getHelp('onMessage_help'));
1140
+ },
1141
+ /**
1142
+ * Called whenever anything on the workspace changes.
1143
+ * Add warning if this flow block is not nested inside a loop.
1144
+ * @param {!Blockly.Events.Abstract} e Change event.
1145
+ * @this Blockly.Block
1146
+ */
1147
+ onchange: function(e) {
1148
+ let legal = true;
1149
+
1150
+ // Is the block nested in a trigger?
1151
+ let block = this;
1152
+ while (block = block.getSurroundParent()) {
1153
+ if (block && Blockly.Trigger.WARNING_PARENTS.includes(block.type)) {
1154
+ legal = false;
1155
+ break;
1156
+ }
1157
+ }
1158
+
1159
+ if (legal) {
1160
+ this.setWarningText(null, this.id);
1161
+ } else {
1162
+ this.setWarningText(Blockly.Translate('trigger_in_trigger_warning'), this.id);
1163
+ }
1048
1164
  }
1049
1165
  };
1050
1166
 
@@ -1100,6 +1216,30 @@ Blockly.Blocks['onFile'] = {
1100
1216
  this.setColour(Blockly.Trigger.HUE);
1101
1217
  this.setTooltip(Blockly.Translate('onFile_tooltip'));
1102
1218
  this.setHelpUrl(getHelp('onFile_help'));
1219
+ },
1220
+ /**
1221
+ * Called whenever anything on the workspace changes.
1222
+ * Add warning if this flow block is not nested inside a loop.
1223
+ * @param {!Blockly.Events.Abstract} e Change event.
1224
+ * @this Blockly.Block
1225
+ */
1226
+ onchange: function(e) {
1227
+ let legal = true;
1228
+
1229
+ // Is the block nested in a trigger?
1230
+ let block = this;
1231
+ while (block = block.getSurroundParent()) {
1232
+ if (block && Blockly.Trigger.WARNING_PARENTS.includes(block.type)) {
1233
+ legal = false;
1234
+ break;
1235
+ }
1236
+ }
1237
+
1238
+ if (legal) {
1239
+ this.setWarningText(null, this.id);
1240
+ } else {
1241
+ this.setWarningText(Blockly.Translate('trigger_in_trigger_warning'), this.id);
1242
+ }
1103
1243
  }
1104
1244
  };
1105
1245
 
@@ -411,6 +411,8 @@ Blockly.Words['timeouts_getinterval_help'] = {'en': 'getinterval',
411
411
  // --- TRIGGER --------------------------------------------------
412
412
  Blockly.Words['Trigger'] = {'en': 'Trigger', 'de': 'Trigger', 'ru': 'События', 'pt': 'Trigger', 'nl': 'In gang zetten', 'fr': 'Déclencheur', 'it': 'Grilletto', 'es': 'Desencadenar', 'pl': 'Trigger', 'zh-cn': '触发', 'uk': 'Тригер'};
413
413
 
414
+ Blockly.Words['trigger_in_trigger_warning'] = {'en': 'This may create a lot of triggers', 'de': 'Dies kann eine Menge Auslöser erstellen', 'ru': 'Это может создать много триггеров', 'pt': 'Isso pode criar muitos gatilhos', 'nl': 'Dit kan veel triggers creëren', 'fr': 'Cela peut créer beaucoup de déclencheurs', 'it': 'Questo può creare un sacco di trigger', 'es': 'Esto puede crear muchos desencadenantes', 'pl': 'To może stworzyć wiele wyzwalaczy', 'zh-cn': '这会造成很多触发器', 'uk': 'Це може створити багато райдерів'};
415
+
414
416
  // --- trigger on --------------------------------------------------
415
417
  Blockly.Words['on_onchange'] = {'en': 'was changed', 'de': 'wurde geändert', 'ru': 'изменился', 'pt': 'foi alterado', 'nl': 'was veranderd', 'fr': 'a été changé', 'it': 'era cambiato', 'es': 'fue cambiado', 'pl': 'was changed', 'zh-cn': '已改变', 'uk': 'було змінено'};
416
418
  Blockly.Words['on_any'] = {'en': 'was updated', 'de': 'wurde aktualisiert', 'ru': 'обновился', 'pt': 'foi atualizado', 'nl': 'is geupdated', 'fr': 'a été mis à jour', 'it': 'è stato aggiornato', 'es': 'fue actualizado', 'pl': 'was updated', 'zh-cn': '已更新', 'uk': 'було оновлено'};