iobroker.javascript 10.0.0 → 10.1.0

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.
Files changed (157) hide show
  1. package/README.md +41 -6
  2. package/admin/assets/AiChatPanel-C4kuqP2U.js +237 -0
  3. package/admin/assets/AiDiffView-zJTEnv05.js +1 -0
  4. package/admin/assets/BlocklyEditor-BB77aFJI.js +84 -0
  5. package/admin/assets/ContextWrapper-C2yvd2Tn.css +1 -0
  6. package/admin/assets/ContextWrapper-W2H0z6zD.js +136 -0
  7. package/admin/assets/Debugger-DCMWjeGm.js +15 -0
  8. package/admin/assets/Error-CBC2oZzb.js +1 -0
  9. package/admin/assets/Import-B-F9IhZ-.js +1 -0
  10. package/admin/assets/RulesEditor-ByjgEaVo.js +1 -0
  11. package/admin/assets/RulesEditor-k-DMHotH.css +1 -0
  12. package/admin/assets/{ScriptEditor-BGIuoNei.js → ScriptEditor-CMYUt5S4.js} +2 -2
  13. package/admin/assets/{ScriptEditorVanillaMonaco-DyMQtoTQ.js → ScriptEditorVanillaMonaco-v12-gORS.js} +3 -3
  14. package/admin/assets/Send-CChqR5Oy.js +1 -0
  15. package/admin/assets/_virtual_mf-localSharedImportMap___mfe_internal__iobroker_javascript__mf_owner__1-7EPUlgCk.js +1 -0
  16. package/admin/assets/_virtual_mf___mfe_internal__iobroker_javascript__mf_owner__1__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-DuplUOZN.js +1243 -0
  17. package/admin/assets/{_virtual_mf___mfe_internal__iobroker_javascript__mf_owner__1__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-BBAXJaqI.js → _virtual_mf___mfe_internal__iobroker_javascript__mf_owner__1__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-JkwfVf8d.js} +1 -1
  18. package/admin/assets/{aiCodeLensProvider-hyAmut0e.js → aiCodeLensProvider-BGvIu6hH.js} +1 -1
  19. package/admin/assets/blockly-C4zJerWL.js +1047 -0
  20. package/admin/assets/blocks_action-CvnOHXwt.js +1 -0
  21. package/admin/assets/blocks_convert-BZlKcd02.js +3 -0
  22. package/admin/assets/blocks_logic-B33Pypxr.js +1 -0
  23. package/admin/assets/blocks_number-k2IjE7OH.js +1 -0
  24. package/admin/assets/blocks_object-B64vSfel.js +1 -0
  25. package/admin/assets/blocks_procedures-BpvNI5dO.js +3 -0
  26. package/admin/assets/blocks_sendto-pwZchfe0.js +5 -0
  27. package/admin/assets/blocks_switch-DViYCmQd.js +2 -0
  28. package/admin/assets/blocks_system-BZZcGqTJ.js +1 -0
  29. package/admin/assets/blocks_text-BOvtHN2r.js +1 -0
  30. package/admin/assets/blocks_time-BH2F-ylT.js +1 -0
  31. package/admin/assets/blocks_timeout-C3BoW4XJ.js +1 -0
  32. package/admin/assets/blocks_trigger-gwXvuAHV.js +2 -0
  33. package/admin/assets/blocks_words-D8PL_nSE.js +1 -0
  34. package/admin/assets/{cronHoverProvider-pKJkSevo.js → cronHoverProvider-DjY3jLvQ.js} +1 -1
  35. package/admin/assets/dist-D6o4h8Pd.js +4 -0
  36. package/admin/assets/field_cron-BMQWPb61.js +1 -0
  37. package/admin/assets/field_oid-BGIMv9gw.js +1 -0
  38. package/admin/assets/field_script-CdzYBCe6.js +1 -0
  39. package/admin/assets/helpers-Crmcgphg.js +1 -0
  40. package/admin/assets/hostInit-DBlZi_Kt.js +1 -0
  41. package/admin/assets/index-BvPVHv3P.js +192 -0
  42. package/admin/assets/{inlineChatWidget-ZaisTOLh.js → inlineChatWidget-SDoyVtOR.js} +2 -2
  43. package/admin/assets/{inlineDiffController-hTwHHqcc.js → inlineDiffController-CnHE3Rwd.js} +2 -2
  44. package/admin/assets/javascript-DVIhlTDr.js +218 -0
  45. package/admin/assets/{mf-entry-bootstrap-0-d6052b31.js → mf-entry-bootstrap-0-a03ecebd.js} +6 -2
  46. package/admin/assets/{mjs-DWqivHEk.js → mjs-Bh7xFIpd.js} +2 -2
  47. package/admin/assets/{stateHoverProvider-C7DawIs-.js → stateHoverProvider-D0iXo6YF.js} +3 -3
  48. package/admin/assets/{virtualExposes-Ed0lGq7k.js → virtualExposes-DgGB-18P.js} +1 -1
  49. package/admin/assets/virtual_mf-REMOTE_ENTRY_ID___mfe_internal__iobroker_javascript__remoteEntry_js-DYEYnOkt.js +1 -0
  50. package/admin/assets/virtual_mf-exposes___mfe_internal__iobroker_javascript__remoteEntry_js-ChiJXsfH.js +1 -0
  51. package/admin/custom/assets/Components-CuFt9lAY.js +1 -0
  52. package/admin/custom/assets/_virtual_mf-localSharedImportMap___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1-DljJyQQg.js +1 -0
  53. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1__loadShare___mf_0_emotion_mf_1_react__loadShare__.js-D0M1SjIE.js +1 -0
  54. package/admin/custom/assets/{_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1__loadShare___mf_0_emotion_mf_1_styled__loadShare__.js-CGb5Cofy.js → _virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1__loadShare___mf_0_emotion_mf_1_styled__loadShare__.js-BD2OkSge.js} +1 -1
  55. package/admin/custom/assets/{_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-BVCIAgbo.js → _virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-pM642JFd.js} +91 -91
  56. package/admin/custom/assets/{_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1__loadShare___mf_0_iobroker_mf_1_json_mf_2_config__loadShare__.js-BkB0anQX.js → _virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1__loadShare___mf_0_iobroker_mf_1_json_mf_2_config__loadShare__.js-BLelmJ7Y.js} +74 -74
  57. package/admin/custom/assets/{_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-BotqDuw-.js → _virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-BGiB1l5e.js} +1 -1
  58. package/admin/custom/assets/{_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1__prebuild__date_mf_2_fns__prebuild__-Cb5TR7FB.js → _virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1__prebuild__date_mf_2_fns__prebuild__-D5hqXJXI.js} +1 -1
  59. package/admin/custom/assets/hostInit-0DGPuZTB.js +1 -0
  60. package/admin/custom/assets/{index-uEKAoVT7.js → index-DcFI5r-g.js} +1 -1
  61. package/admin/custom/assets/{lib-Yj8cfN0A.js → lib-BlUjuGH7.js} +1 -1
  62. package/admin/custom/assets/{mf-entry-bootstrap-0-77793feb.js → mf-entry-bootstrap-0-efd847a6.js} +6 -2
  63. package/admin/custom/assets/{setYear-DJ9FbdkO.js → setYear-BaCcPbbI.js} +1 -1
  64. package/admin/custom/assets/virtualExposes-DGxNcyb6.js +1 -0
  65. package/admin/custom/assets/virtual_mf-REMOTE_ENTRY_ID___mfe_internal__ConfigCustomJavascriptSet__customComponents_js-DVNwFcUr.js +1 -0
  66. package/admin/custom/assets/virtual_mf-exposes___mfe_internal__ConfigCustomJavascriptSet__customComponents_js-DPck7zEs.js +2 -0
  67. package/admin/custom/customComponents.js +1 -1
  68. package/admin/google-blockly/VERSION +1 -0
  69. package/admin/google-blockly/media/drop.mp3 +0 -0
  70. package/admin/google-blockly/msg/js/de.js +332 -56
  71. package/admin/google-blockly/msg/js/en.js +319 -43
  72. package/admin/google-blockly/msg/js/es.js +319 -42
  73. package/admin/google-blockly/msg/js/fr.js +315 -39
  74. package/admin/google-blockly/msg/js/it.js +327 -51
  75. package/admin/google-blockly/msg/js/nl.js +376 -100
  76. package/admin/google-blockly/msg/js/pl.js +318 -42
  77. package/admin/google-blockly/msg/js/pt.js +318 -42
  78. package/admin/google-blockly/msg/js/ru.js +320 -44
  79. package/admin/google-blockly/msg/js/uk.js +326 -50
  80. package/admin/google-blockly/msg/js/zh-cn.js +322 -46
  81. package/admin/i18n/de.json +48 -26
  82. package/admin/i18n/en.json +47 -25
  83. package/admin/i18n/es.json +48 -18
  84. package/admin/i18n/fr.json +47 -17
  85. package/admin/i18n/it.json +47 -17
  86. package/admin/i18n/nl.json +47 -17
  87. package/admin/i18n/pl.json +48 -18
  88. package/admin/i18n/pt.json +47 -17
  89. package/admin/i18n/ru.json +47 -17
  90. package/admin/i18n/uk.json +47 -17
  91. package/admin/i18n/zh-cn.json +47 -17
  92. package/admin/jsonConfig.json +367 -0
  93. package/admin/mf-manifest.json +1 -1
  94. package/admin/mf-stats.json +1 -1
  95. package/admin/remoteEntry.js +1 -1
  96. package/admin/tab.html +12 -95
  97. package/build/lib/mirror.js +9 -0
  98. package/build/lib/mirror.js.map +1 -1
  99. package/build/lib/sandbox.js +35 -0
  100. package/build/lib/sandbox.js.map +1 -1
  101. package/build/lib/typescriptSettings.js +112 -2
  102. package/build/lib/typescriptSettings.js.map +1 -1
  103. package/build/lib/typescriptTools.js +168 -43
  104. package/build/lib/typescriptTools.js.map +1 -1
  105. package/build/main.js +10 -5
  106. package/build/main.js.map +1 -1
  107. package/build/types.d.ts +41 -0
  108. package/docs/en/javascript.md +16 -0
  109. package/docs/en/upgrade-guide.md +3 -0
  110. package/io-package.json +45 -15
  111. package/package.json +8 -3
  112. package/admin/assets/AiChatPanel-p0KAg6Cs.js +0 -237
  113. package/admin/assets/AiDiffView-BPTLnNx1.js +0 -1
  114. package/admin/assets/BlocklyEditor-CAjVMhYT.js +0 -81
  115. package/admin/assets/ContextWrapper-BVc8wTK_.css +0 -1
  116. package/admin/assets/ContextWrapper-D9CrnNKs.js +0 -127
  117. package/admin/assets/Debugger-SjROokFI.js +0 -15
  118. package/admin/assets/Error-DDfrxAt2.js +0 -1
  119. package/admin/assets/Import-DpTg1Jow.js +0 -1
  120. package/admin/assets/RulesEditor-BSRFWpEm.css +0 -1
  121. package/admin/assets/RulesEditor-D0hgrcBc.js +0 -1
  122. package/admin/assets/_virtual_mf-localSharedImportMap___mfe_internal__iobroker_javascript__mf_owner__1-DWJotR1B.js +0 -1
  123. package/admin/assets/_virtual_mf___mfe_internal__iobroker_javascript__mf_owner__1__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-CxICLr5Z.js +0 -1243
  124. package/admin/assets/dist-uw5orDgd.js +0 -4
  125. package/admin/assets/hostInit-BFg5u9hY.js +0 -1
  126. package/admin/assets/index-B1gICjdq.js +0 -192
  127. package/admin/assets/virtual_mf-REMOTE_ENTRY_ID___mfe_internal__iobroker_javascript__remoteEntry_js-BYs71IQF.js +0 -1
  128. package/admin/assets/virtual_mf-exposes___mfe_internal__iobroker_javascript__remoteEntry_js-DnnXQRkG.js +0 -1
  129. package/admin/custom/assets/Components-BrDyDHXh.js +0 -1
  130. package/admin/custom/assets/_virtual_mf-localSharedImportMap___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1-CyYJM2-v.js +0 -1
  131. package/admin/custom/assets/_virtual_mf___mfe_internal__ConfigCustomJavascriptSet__mf_owner__1__loadShare___mf_0_emotion_mf_1_react__loadShare__.js-BdzCssLn.js +0 -1
  132. package/admin/custom/assets/hostInit-DJx2uXXy.js +0 -1
  133. package/admin/custom/assets/virtualExposes-CxDjLoYu.js +0 -1
  134. package/admin/custom/assets/virtual_mf-REMOTE_ENTRY_ID___mfe_internal__ConfigCustomJavascriptSet__customComponents_js-BU-ugy_7.js +0 -1
  135. package/admin/custom/assets/virtual_mf-exposes-ssr___mfe_internal__ConfigCustomJavascriptSet__customComponents_js-BEfZbrf7.js +0 -2
  136. package/admin/custom/assets/virtual_mf-exposes___mfe_internal__ConfigCustomJavascriptSet__customComponents_js-CTeZ0Jpm.js +0 -2
  137. package/admin/google-blockly/blockly_compressed.js +0 -1679
  138. package/admin/google-blockly/blocks_compressed.js +0 -193
  139. package/admin/google-blockly/javascript_compressed.js +0 -264
  140. package/admin/google-blockly/msg/messages.js +0 -1630
  141. package/admin/google-blockly/own/blocks_action.js +0 -765
  142. package/admin/google-blockly/own/blocks_convert.js +0 -480
  143. package/admin/google-blockly/own/blocks_logic.js +0 -459
  144. package/admin/google-blockly/own/blocks_number.js +0 -30
  145. package/admin/google-blockly/own/blocks_object.js +0 -402
  146. package/admin/google-blockly/own/blocks_procedures.js +0 -688
  147. package/admin/google-blockly/own/blocks_sendto.js +0 -702
  148. package/admin/google-blockly/own/blocks_switch.js +0 -257
  149. package/admin/google-blockly/own/blocks_system.js +0 -1409
  150. package/admin/google-blockly/own/blocks_text.js +0 -104
  151. package/admin/google-blockly/own/blocks_time.js +0 -639
  152. package/admin/google-blockly/own/blocks_timeout.js +0 -551
  153. package/admin/google-blockly/own/blocks_trigger.js +0 -1791
  154. package/admin/google-blockly/own/blocks_words.js +0 -708
  155. package/admin/google-blockly/own/field_cron.js +0 -158
  156. package/admin/google-blockly/own/field_oid.js +0 -642
  157. package/admin/google-blockly/own/field_script.js +0 -159
@@ -1,459 +0,0 @@
1
- 'use strict';
2
-
3
- if (typeof goog !== 'undefined') {
4
- goog.require('Blockly.JavaScript');
5
- }
6
-
7
- // --- logic multi and --------------------------------------------------
8
-
9
- Blockly.Blocks['logic_multi_and_container'] = {
10
- /**
11
- * Mutator block for container.
12
- * @this Blockly.Block
13
- */
14
- init: function () {
15
- this.appendDummyInput()
16
- .appendField(Blockly.Translate('logic_multi_and'));
17
-
18
- this.appendStatementInput('STACK');
19
-
20
- this.setColour('%{BKY_LOGIC_HUE}');
21
-
22
- this.setTooltip(Blockly.Translate('logic_multi_and_tooltip'));
23
-
24
- this.contextMenu = false;
25
- },
26
- };
27
-
28
- Blockly.Blocks['logic_multi_and_mutator'] = {
29
- /**
30
- * Mutator block for add items.
31
- * @this Blockly.Block
32
- */
33
- init: function () {
34
- this.appendDummyInput('AND')
35
- .appendField(Blockly.Translate('logic_multi_and_and'));
36
-
37
- this.setPreviousStatement(true);
38
- this.setNextStatement(true);
39
-
40
- this.setColour('%{BKY_LOGIC_HUE}');
41
-
42
- this.setTooltip(Blockly.Translate('logic_multi_and_tooltip'));
43
-
44
- this.contextMenu = false;
45
- },
46
- };
47
-
48
- Blockly.Blocks['logic_multi_and'] = {
49
- init: function () {
50
- this.itemCount_ = 2;
51
- this.setMutator(new Blockly.icons.MutatorIcon(['logic_multi_and_mutator'], this));
52
-
53
- this.setInputsInline(false);
54
- this.setOutput(true, 'Boolean');
55
-
56
- this.setColour('%{BKY_LOGIC_HUE}');
57
-
58
- this.setTooltip(Blockly.Translate('logic_multi_and_tooltip'));
59
- // this.setHelpUrl(getHelp('logic_multi_and_help'));
60
- },
61
- /**
62
- * Create XML to represent number of text inputs.
63
- * @return {!Element} XML storage element.
64
- * @this Blockly.Block
65
- */
66
- mutationToDom: function () {
67
- const container = document.createElement('mutation');
68
- container.setAttribute('items', this.itemCount_);
69
-
70
- return container;
71
- },
72
- /**
73
- * Parse XML to restore the text inputs.
74
- * @param {!Element} xmlElement XML storage element.
75
- * @this Blockly.Block
76
- */
77
- domToMutation: function (xmlElement) {
78
- this.itemCount_ = parseInt(xmlElement.getAttribute('items'), 10);
79
- this.updateShape_();
80
- },
81
- /**
82
- * Populate the mutator's dialog with this block's components.
83
- * @param {!Blockly.Workspace} workspace Mutator's workspace.
84
- * @return {!Blockly.Block} Root block in mutator.
85
- * @this Blockly.Block
86
- */
87
- decompose: function (workspace) {
88
- const containerBlock = workspace.newBlock('logic_multi_and_container');
89
- containerBlock.initSvg();
90
-
91
- let connection = containerBlock.getInput('STACK').connection;
92
- for (let i = 0; i < this.itemCount_; i++) {
93
- const itemBlock = workspace.newBlock('logic_multi_and_mutator');
94
- itemBlock.initSvg();
95
- connection.connect(itemBlock.previousConnection);
96
- connection = itemBlock.nextConnection;
97
- }
98
-
99
- return containerBlock;
100
- },
101
- /**
102
- * Reconfigure this block based on the mutator dialog's components.
103
- * @param {!Blockly.Block} containerBlock Root block in mutator.
104
- * @this Blockly.Block
105
- */
106
- compose: function (containerBlock) {
107
- let itemBlock = containerBlock.getInputTargetBlock('STACK');
108
- // Count number of inputs.
109
- const connections = [];
110
- while (itemBlock) {
111
- connections.push(itemBlock.valueConnection_);
112
- itemBlock = itemBlock.nextConnection &&
113
- itemBlock.nextConnection.targetBlock();
114
- }
115
-
116
- // Disconnect any children that don't belong.
117
- for (let k = 0; k < this.itemCount_; k++) {
118
- const connection = this.getInput(`AND${k}`).connection.targetConnection;
119
- if (connection && !connections.includes(connection)) {
120
- connection.disconnect();
121
- }
122
- }
123
-
124
- this.itemCount_ = connections.length;
125
- if (this.itemCount_ < 2) {
126
- this.itemCount_ = 2;
127
- }
128
- this.updateShape_();
129
-
130
- // Reconnect any child blocks.
131
- for (let i = 0; i < this.itemCount_; i++) {
132
- Blockly.icons.MutatorIcon.reconnect(connections[i], this, 'AND' + i);
133
- }
134
- },
135
- /**
136
- * Store pointers to any connected child blocks.
137
- * @param {!Blockly.Block} containerBlock Root block in mutator.
138
- * @this Blockly.Block
139
- */
140
- saveConnections: function (containerBlock) {
141
- let itemBlock = containerBlock.getInputTargetBlock('STACK');
142
- let i = 0;
143
-
144
- while (itemBlock) {
145
- let input;
146
- try {
147
- input = this.getInput('AND' + i);
148
- } catch (e) {
149
- // If the input does not exist, it means that the block has been removed.
150
- input = null;
151
- }
152
- itemBlock.valueConnection_ = input?.connection.targetConnection;
153
- i++;
154
- itemBlock = itemBlock.nextConnection?.targetBlock();
155
- }
156
- },
157
- /**
158
- * Modify this block to have the correct number of inputs.
159
- * @private
160
- * @this Blockly.Block
161
- */
162
- updateShape_: function () {
163
- // Add new inputs.
164
- for (let i = 0; i < this.itemCount_; i++) {
165
- let input;
166
- try {
167
- input = this.getInput('AND' + i);
168
- } catch (e) {
169
- // If the input does not exist, it means that the block has been removed.
170
- input = null;
171
- }
172
- if (!input) {
173
- const input = this.appendValueInput('AND' + i).setAlign(Blockly.ALIGN_RIGHT);
174
- if (i > 0) {
175
- input.appendField(Blockly.Translate('logic_multi_and_and'));
176
- }
177
- }
178
- }
179
- // Remove deleted inputs.
180
- try {
181
- for (let i = this.itemCount_; this.getInput('AND' + i); i++) {
182
- this.removeInput('AND' + i);
183
- }
184
- } catch (e) {
185
- // If the input does not exist, it means that the block has been removed.
186
- // Do nothing.
187
- }
188
- },
189
- };
190
-
191
- Blockly.JavaScript.forBlock['logic_multi_and'] = function (block) {
192
- const ands = [];
193
- for (let n = 0; n < block.itemCount_; n++) {
194
- const vCondition = Blockly.JavaScript.valueToCode(block, `AND${n}`, Blockly.JavaScript.ORDER_ATOMIC);
195
- if (vCondition) {
196
- ands.push(vCondition);
197
- }
198
- }
199
-
200
- return [`${ands.length > 0 ? ands.join(' && ') : 'false'}`, Blockly.JavaScript.ORDER_LOGICAL_AND];
201
- };
202
-
203
- // --- logic multi or --------------------------------------------------
204
-
205
- Blockly.Blocks['logic_multi_or_container'] = {
206
- /**
207
- * Mutator block for container.
208
- * @this Blockly.Block
209
- */
210
- init: function () {
211
- this.appendDummyInput()
212
- .appendField(Blockly.Translate('logic_multi_or'));
213
-
214
- this.appendStatementInput('STACK');
215
-
216
- this.setColour('%{BKY_LOGIC_HUE}');
217
-
218
- this.setTooltip(Blockly.Translate('logic_multi_or_tooltip'));
219
-
220
- this.contextMenu = false;
221
- },
222
- };
223
-
224
- Blockly.Blocks['logic_multi_or_mutator'] = {
225
- /**
226
- * Mutator block for add items.
227
- * @this Blockly.Block
228
- */
229
- init: function () {
230
- this.appendDummyInput('OR')
231
- .appendField(Blockly.Translate('logic_multi_or_or'));
232
-
233
- this.setPreviousStatement(true);
234
- this.setNextStatement(true);
235
-
236
- this.setColour('%{BKY_LOGIC_HUE}');
237
-
238
- this.setTooltip(Blockly.Translate('logic_multi_or_tooltip'));
239
-
240
- this.contextMenu = false;
241
- },
242
- };
243
-
244
- Blockly.Blocks['logic_multi_or'] = {
245
- init: function () {
246
- this.itemCount_ = 2;
247
- this.setMutator(new Blockly.icons.MutatorIcon(['logic_multi_or_mutator'], this));
248
-
249
- this.setInputsInline(false);
250
- this.setOutput(true, 'Boolean');
251
-
252
- this.setColour('%{BKY_LOGIC_HUE}');
253
-
254
- this.setTooltip(Blockly.Translate('logic_multi_or_tooltip'));
255
- // this.setHelpUrl(getHelp('logic_multi_or_help'));
256
- },
257
- /**
258
- * Create XML to represent number of text inputs.
259
- * @return {!Element} XML storage element.
260
- * @this Blockly.Block
261
- */
262
- mutationToDom: function () {
263
- const container = document.createElement('mutation');
264
- container.setAttribute('items', this.itemCount_);
265
-
266
- return container;
267
- },
268
- /**
269
- * Parse XML to restore the text inputs.
270
- * @param {!Element} xmlElement XML storage element.
271
- * @this Blockly.Block
272
- */
273
- domToMutation: function (xmlElement) {
274
- this.itemCount_ = parseInt(xmlElement.getAttribute('items'), 10);
275
- this.updateShape_();
276
- },
277
- /**
278
- * Populate the mutator's dialog with this block's components.
279
- * @param {!Blockly.Workspace} workspace Mutator's workspace.
280
- * @return {!Blockly.Block} Root block in mutator.
281
- * @this Blockly.Block
282
- */
283
- decompose: function (workspace) {
284
- const containerBlock = workspace.newBlock('logic_multi_or_container');
285
- containerBlock.initSvg();
286
-
287
- let connection = containerBlock.getInput('STACK').connection;
288
- for (let i = 0; i < this.itemCount_; i++) {
289
- const itemBlock = workspace.newBlock('logic_multi_or_mutator');
290
- itemBlock.initSvg();
291
- connection.connect(itemBlock.previousConnection);
292
- connection = itemBlock.nextConnection;
293
- }
294
-
295
- return containerBlock;
296
- },
297
- /**
298
- * Reconfigure this block based on the mutator dialog's components.
299
- * @param {!Blockly.Block} containerBlock Root block in mutator.
300
- * @this Blockly.Block
301
- */
302
- compose: function (containerBlock) {
303
- let itemBlock = containerBlock.getInputTargetBlock('STACK');
304
- // Count number of inputs.
305
- const connections = [];
306
- while (itemBlock) {
307
- connections.push(itemBlock.valueConnection_);
308
- itemBlock = itemBlock.nextConnection &&
309
- itemBlock.nextConnection.targetBlock();
310
- }
311
-
312
- // Disconnect any children that don't belong.
313
- for (let k = 0; k < this.itemCount_; k++) {
314
- const connection = this.getInput('OR' + k).connection.targetConnection;
315
- if (connection && !connections.includes(connection)) {
316
- connection.disconnect();
317
- }
318
- }
319
-
320
- this.itemCount_ = connections.length;
321
- if (this.itemCount_ < 2) {
322
- this.itemCount_ = 2;
323
- }
324
- this.updateShape_();
325
-
326
- // Reconnect any child blocks.
327
- for (let i = 0; i < this.itemCount_; i++) {
328
- Blockly.icons.MutatorIcon.reconnect(connections[i], this, 'OR' + i);
329
- }
330
- },
331
- /**
332
- * Store pointers to any connected child blocks.
333
- * @param {!Blockly.Block} containerBlock Root block in mutator.
334
- * @this Blockly.Block
335
- */
336
- saveConnections: function (containerBlock) {
337
- let itemBlock = containerBlock.getInputTargetBlock('STACK');
338
- let i = 0;
339
-
340
- while (itemBlock) {
341
- let input;
342
- try {
343
- input = this.getInput('OR' + i);
344
- } catch (e) {
345
- // If the input does not exist, it means that the block has been removed.
346
- input = null;
347
- }
348
- itemBlock.valueConnection_ = input?.connection.targetConnection;
349
- i++;
350
- itemBlock = itemBlock.nextConnection?.targetBlock();
351
- }
352
- },
353
- /**
354
- * Modify this block to have the correct number of inputs.
355
- * @private
356
- * @this Blockly.Block
357
- */
358
- updateShape_: function () {
359
- // Add new inputs.
360
- for (let i = 0; i < this.itemCount_; i++) {
361
- let input;
362
- try {
363
- input = this.getInput('OR' + i);
364
- } catch (e) {
365
- input = null;
366
- }
367
- if (!input) {
368
- const input = this.appendValueInput('OR' + i).setAlign(Blockly.ALIGN_RIGHT);
369
- if (i > 0) {
370
- input.appendField(Blockly.Translate('logic_multi_or_or'));
371
- }
372
- }
373
- }
374
- // Remove deleted inputs.
375
- try {
376
- for (let i = this.itemCount_; this.getInput('OR' + i); i++) {
377
- this.removeInput('OR' + i);
378
- }
379
- } catch (e) {
380
- // If the input does not exist, it means that the block has been removed.
381
- // Do nothing.
382
- }
383
- },
384
- };
385
-
386
- Blockly.JavaScript.forBlock['logic_multi_or'] = function (block) {
387
- const ors = [];
388
- for (let n = 0; n < block.itemCount_; n++) {
389
- const vCondition = Blockly.JavaScript.valueToCode(block, `OR${n}`, Blockly.JavaScript.ORDER_ATOMIC);
390
- if (vCondition) {
391
- ors.push(vCondition);
392
- }
393
- }
394
-
395
- return [`${ors.length > 0 ? ors.join(' || ') : 'false'}`, Blockly.JavaScript.ORDER_LOGICAL_OR];
396
- };
397
-
398
- // --- logic between --------------------------------------------------
399
-
400
- Blockly.Blocks['logic_between'] = {
401
- init: function () {
402
- this.appendValueInput('MIN')
403
- .setCheck('Number');
404
- this.appendValueInput('VALUE')
405
- .setCheck('Number')
406
- .appendField(new Blockly.FieldDropdown([['<', 'LT'], ['≤', 'LE']]), 'MIN_OPERATOR');
407
- this.appendValueInput('MAX')
408
- .setCheck('Number')
409
- .appendField(new Blockly.FieldDropdown([['<', 'LT'], ['≤', 'LE']]), 'MAX_OPERATOR');
410
-
411
- this.setInputsInline(true);
412
- this.setOutput(true, 'Boolean');
413
-
414
- this.setColour('%{BKY_LOGIC_HUE}');
415
-
416
- this.setTooltip(Blockly.Translate('logic_between_tooltip'));
417
- // this.setHelpUrl(getHelp('logic_between_help'));
418
- },
419
- };
420
-
421
- Blockly.JavaScript.forBlock['logic_between'] = function (block) {
422
- const vMin = Blockly.JavaScript.valueToCode(block, 'MIN', Blockly.JavaScript.ORDER_RELATIONAL) || 0;
423
- const vValue = Blockly.JavaScript.valueToCode(block, 'VALUE', Blockly.JavaScript.ORDER_RELATIONAL) || 0;
424
- const vMax = Blockly.JavaScript.valueToCode(block, 'MAX', Blockly.JavaScript.ORDER_RELATIONAL) || 0;
425
- const fMinOperator = block.getFieldValue('MIN_OPERATOR') === 'LT' ? '<' : '<=';
426
- const fMaxOperator = block.getFieldValue('MAX_OPERATOR') === 'LT' ? '<' : '<=';
427
-
428
- return [`${vMin} ${fMinOperator} ${vValue} && ${vValue} ${fMaxOperator} ${vMax}`, Blockly.JavaScript.ORDER_LOGICAL_AND];
429
- };
430
-
431
- // --- logic ifempty --------------------------------------------------
432
-
433
- Blockly.Blocks['logic_ifempty'] = {
434
- init: function () {
435
- this.appendValueInput('VALUE')
436
- .setCheck(null)
437
- .setAlign(Blockly.ALIGN_RIGHT)
438
- .appendField(Blockly.Translate('logic_ifempty'));
439
- this.appendValueInput('DEFLT')
440
- .setCheck(null)
441
- .setAlign(Blockly.ALIGN_RIGHT)
442
- .appendField(Blockly.Translate('logic_ifempty_then'));
443
-
444
- this.setInputsInline(true);
445
- this.setOutput(true, null);
446
-
447
- this.setColour('%{BKY_LOGIC_HUE}');
448
-
449
- this.setTooltip(Blockly.Translate('logic_ifempty_tooltip'));
450
- // this.setHelpUrl(getHelp('logic_ifempty_help'));
451
- },
452
- };
453
-
454
- Blockly.JavaScript.forBlock['logic_ifempty'] = function (block) {
455
- const vValue = Blockly.JavaScript.valueToCode(block, 'VALUE', Blockly.JavaScript.ORDER_LOGICAL_OR) || null;
456
- const vDeflt = Blockly.JavaScript.valueToCode(block, 'DEFLT', Blockly.JavaScript.ORDER_LOGICAL_OR) || null;
457
-
458
- return [`${vValue} || ${vDeflt}`, Blockly.JavaScript.ORDER_LOGICAL_OR];
459
- };
@@ -1,30 +0,0 @@
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
-
11
- this.appendDummyInput()
12
- .appendField(Blockly.Translate('math_rndfixed_to'))
13
- .appendField(new Blockly.FieldNumber(0, 1, 25), 'n')
14
- .appendField(Blockly.Translate('math_rndfixed_decplcs'));
15
-
16
- this.setInputsInline(true);
17
- this.setOutput(true, 'Number');
18
-
19
- this.setColour(Blockly.Msg['MATH_HUE']);
20
-
21
- this.setTooltip(Blockly.Translate('math_rndfixed_tooltip'));
22
- },
23
- };
24
-
25
- Blockly.JavaScript.forBlock['math_rndfixed'] = function (block) {
26
- const vX = Blockly.JavaScript.valueToCode(block, 'x', Blockly.JavaScript.ORDER_ATOMIC);
27
- const fExp = Math.pow(10, block.getFieldValue('n'));
28
-
29
- return [`Math.round(${vX} * ${fExp}) / ${fExp}`, Blockly.JavaScript.ORDER_ATOMIC];
30
- };