@iobroker/adapter-react-v5 3.1.34 → 3.1.35

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 (243) hide show
  1. package/Components/404.js +0 -23
  2. package/Components/404.js.map +1 -1
  3. package/Components/ColorPicker.js +6 -37
  4. package/Components/ColorPicker.js.map +1 -1
  5. package/Components/ComplexCron.js +10 -84
  6. package/Components/ComplexCron.js.map +1 -1
  7. package/Components/CustomModal.js +29 -54
  8. package/Components/CustomModal.js.map +1 -1
  9. package/Components/FileBrowser.js +15 -265
  10. package/Components/FileBrowser.js.map +1 -1
  11. package/Components/FileViewer.js +7 -68
  12. package/Components/FileViewer.js.map +1 -1
  13. package/Components/Icon.d.ts +1 -1
  14. package/Components/Icon.js +2 -42
  15. package/Components/Icon.js.map +1 -1
  16. package/Components/IconPicker.js +6 -28
  17. package/Components/IconPicker.js.map +1 -1
  18. package/Components/IconSelector.js +3 -55
  19. package/Components/IconSelector.js.map +1 -1
  20. package/Components/Image.js +1 -38
  21. package/Components/Image.js.map +1 -1
  22. package/Components/JsonConfigComponent/ChipInput.js +66 -197
  23. package/Components/JsonConfigComponent/ChipInput.js.map +1 -1
  24. package/Components/JsonConfigComponent/ConfigAlive.js +0 -31
  25. package/Components/JsonConfigComponent/ConfigAlive.js.map +1 -1
  26. package/Components/JsonConfigComponent/ConfigAutocomplete.js +6 -39
  27. package/Components/JsonConfigComponent/ConfigAutocomplete.js.map +1 -1
  28. package/Components/JsonConfigComponent/ConfigAutocompleteSendTo.js +6 -52
  29. package/Components/JsonConfigComponent/ConfigAutocompleteSendTo.js.map +1 -1
  30. package/Components/JsonConfigComponent/ConfigCRON.js +5 -39
  31. package/Components/JsonConfigComponent/ConfigCRON.js.map +1 -1
  32. package/Components/JsonConfigComponent/ConfigCertificateSelect.js +4 -42
  33. package/Components/JsonConfigComponent/ConfigCertificateSelect.js.map +1 -1
  34. package/Components/JsonConfigComponent/ConfigCheckbox.js +0 -28
  35. package/Components/JsonConfigComponent/ConfigCheckbox.js.map +1 -1
  36. package/Components/JsonConfigComponent/ConfigChip.js +4 -33
  37. package/Components/JsonConfigComponent/ConfigChip.js.map +1 -1
  38. package/Components/JsonConfigComponent/ConfigColor.js +0 -34
  39. package/Components/JsonConfigComponent/ConfigColor.js.map +1 -1
  40. package/Components/JsonConfigComponent/ConfigCoordinates.js +0 -33
  41. package/Components/JsonConfigComponent/ConfigCoordinates.js.map +1 -1
  42. package/Components/JsonConfigComponent/ConfigCustom.js +14 -73
  43. package/Components/JsonConfigComponent/ConfigCustom.js.map +1 -1
  44. package/Components/JsonConfigComponent/ConfigDatePicker.js +0 -25
  45. package/Components/JsonConfigComponent/ConfigDatePicker.js.map +1 -1
  46. package/Components/JsonConfigComponent/ConfigFile.js +0 -46
  47. package/Components/JsonConfigComponent/ConfigFile.js.map +1 -1
  48. package/Components/JsonConfigComponent/ConfigFileSelector.js +7 -126
  49. package/Components/JsonConfigComponent/ConfigFileSelector.js.map +1 -1
  50. package/Components/JsonConfigComponent/ConfigFunc.js +0 -34
  51. package/Components/JsonConfigComponent/ConfigFunc.js.map +1 -1
  52. package/Components/JsonConfigComponent/ConfigGeneric.js +15 -110
  53. package/Components/JsonConfigComponent/ConfigGeneric.js.map +1 -1
  54. package/Components/JsonConfigComponent/ConfigIP.js +2 -35
  55. package/Components/JsonConfigComponent/ConfigIP.js.map +1 -1
  56. package/Components/JsonConfigComponent/ConfigImageUpload.js +4 -44
  57. package/Components/JsonConfigComponent/ConfigImageUpload.js.map +1 -1
  58. package/Components/JsonConfigComponent/ConfigInstanceSelect.js +1 -59
  59. package/Components/JsonConfigComponent/ConfigInstanceSelect.js.map +1 -1
  60. package/Components/JsonConfigComponent/ConfigJsonEditor.js +7 -40
  61. package/Components/JsonConfigComponent/ConfigJsonEditor.js.map +1 -1
  62. package/Components/JsonConfigComponent/ConfigLanguage.js +2 -42
  63. package/Components/JsonConfigComponent/ConfigLanguage.js.map +1 -1
  64. package/Components/JsonConfigComponent/ConfigNumber.js +2 -45
  65. package/Components/JsonConfigComponent/ConfigNumber.js.map +1 -1
  66. package/Components/JsonConfigComponent/ConfigObjectId.js +6 -40
  67. package/Components/JsonConfigComponent/ConfigObjectId.js.map +1 -1
  68. package/Components/JsonConfigComponent/ConfigPanel.js +7 -91
  69. package/Components/JsonConfigComponent/ConfigPanel.js.map +1 -1
  70. package/Components/JsonConfigComponent/ConfigPassword.js +0 -42
  71. package/Components/JsonConfigComponent/ConfigPassword.js.map +1 -1
  72. package/Components/JsonConfigComponent/ConfigPattern.js +0 -25
  73. package/Components/JsonConfigComponent/ConfigPattern.js.map +1 -1
  74. package/Components/JsonConfigComponent/ConfigRoom.js +0 -34
  75. package/Components/JsonConfigComponent/ConfigRoom.js.map +1 -1
  76. package/Components/JsonConfigComponent/ConfigSelect.js +4 -34
  77. package/Components/JsonConfigComponent/ConfigSelect.js.map +1 -1
  78. package/Components/JsonConfigComponent/ConfigSelectSendTo.js +11 -67
  79. package/Components/JsonConfigComponent/ConfigSelectSendTo.js.map +1 -1
  80. package/Components/JsonConfigComponent/ConfigSendto.js +8 -91
  81. package/Components/JsonConfigComponent/ConfigSendto.js.map +1 -1
  82. package/Components/JsonConfigComponent/ConfigSetState.js +0 -55
  83. package/Components/JsonConfigComponent/ConfigSetState.js.map +1 -1
  84. package/Components/JsonConfigComponent/ConfigSlider.js +0 -28
  85. package/Components/JsonConfigComponent/ConfigSlider.js.map +1 -1
  86. package/Components/JsonConfigComponent/ConfigStaticDivider.js +0 -21
  87. package/Components/JsonConfigComponent/ConfigStaticDivider.js.map +1 -1
  88. package/Components/JsonConfigComponent/ConfigStaticHeader.js +0 -24
  89. package/Components/JsonConfigComponent/ConfigStaticHeader.js.map +1 -1
  90. package/Components/JsonConfigComponent/ConfigStaticImage.js +0 -23
  91. package/Components/JsonConfigComponent/ConfigStaticImage.js.map +1 -1
  92. package/Components/JsonConfigComponent/ConfigStaticText.js +0 -31
  93. package/Components/JsonConfigComponent/ConfigStaticText.js.map +1 -1
  94. package/Components/JsonConfigComponent/ConfigTable.js +13 -105
  95. package/Components/JsonConfigComponent/ConfigTable.js.map +1 -1
  96. package/Components/JsonConfigComponent/ConfigTabs.js +2 -35
  97. package/Components/JsonConfigComponent/ConfigTabs.js.map +1 -1
  98. package/Components/JsonConfigComponent/ConfigText.js +0 -34
  99. package/Components/JsonConfigComponent/ConfigText.js.map +1 -1
  100. package/Components/JsonConfigComponent/ConfigTextSendTo.js +0 -37
  101. package/Components/JsonConfigComponent/ConfigTextSendTo.js.map +1 -1
  102. package/Components/JsonConfigComponent/ConfigTimePicker.js +0 -25
  103. package/Components/JsonConfigComponent/ConfigTimePicker.js.map +1 -1
  104. package/Components/JsonConfigComponent/ConfigTopic.js +0 -29
  105. package/Components/JsonConfigComponent/ConfigTopic.js.map +1 -1
  106. package/Components/JsonConfigComponent/ConfigUser.js +2 -40
  107. package/Components/JsonConfigComponent/ConfigUser.js.map +1 -1
  108. package/Components/JsonConfigComponent/index.js +5 -81
  109. package/Components/JsonConfigComponent/index.js.map +1 -1
  110. package/Components/Loader.js +2 -20
  111. package/Components/Loader.js.map +1 -1
  112. package/Components/Loaders/PT.js +2 -20
  113. package/Components/Loaders/PT.js.map +1 -1
  114. package/Components/Loaders/Vendor.js +2 -21
  115. package/Components/Loaders/Vendor.js.map +1 -1
  116. package/Components/Logo.js +6 -39
  117. package/Components/Logo.js.map +1 -1
  118. package/Components/MDUtils.js +3 -27
  119. package/Components/MDUtils.js.map +1 -1
  120. package/Components/ObjectBrowser.d.ts +1 -1
  121. package/Components/ObjectBrowser.js +181 -788
  122. package/Components/ObjectBrowser.js.map +1 -1
  123. package/Components/Router.js +7 -31
  124. package/Components/Router.js.map +1 -1
  125. package/Components/SaveCloseButtons.js +2 -32
  126. package/Components/SaveCloseButtons.js.map +1 -1
  127. package/Components/Schedule.js +29 -251
  128. package/Components/Schedule.js.map +1 -1
  129. package/Components/SelectWithIcon.d.ts +1 -1
  130. package/Components/SelectWithIcon.js +0 -48
  131. package/Components/SelectWithIcon.js.map +1 -1
  132. package/Components/SimpleCron/cron2text.js +45 -91
  133. package/Components/SimpleCron/cron2text.js.map +1 -1
  134. package/Components/SimpleCron/cronText.js +0 -6
  135. package/Components/SimpleCron/cronText.js.map +1 -1
  136. package/Components/SimpleCron/index.js +19 -102
  137. package/Components/SimpleCron/index.js.map +1 -1
  138. package/Components/SimpleCron/jquery.cron.locale.js +44 -24
  139. package/Components/SimpleCron/jquery.cron.locale.js.map +1 -1
  140. package/Components/TabContainer.js +2 -23
  141. package/Components/TabContainer.js.map +1 -1
  142. package/Components/TabContent.js +2 -22
  143. package/Components/TabContent.js.map +1 -1
  144. package/Components/TabHeader.js +1 -17
  145. package/Components/TabHeader.js.map +1 -1
  146. package/Components/TableResize.js +6 -51
  147. package/Components/TableResize.js.map +1 -1
  148. package/Components/TextWithIcon.js +0 -20
  149. package/Components/TextWithIcon.js.map +1 -1
  150. package/Components/ToggleThemeMenu.js +5 -13
  151. package/Components/ToggleThemeMenu.js.map +1 -1
  152. package/Components/TreeTable.js +4 -121
  153. package/Components/TreeTable.js.map +1 -1
  154. package/Components/UploadImage.js +17 -60
  155. package/Components/UploadImage.js.map +1 -1
  156. package/Components/Utils.js +87 -263
  157. package/Components/Utils.js.map +1 -1
  158. package/Components/copy-to-clipboard.js +16 -38
  159. package/Components/copy-to-clipboard.js.map +1 -1
  160. package/Components/withWidth.js +2 -10
  161. package/Components/withWidth.js.map +1 -1
  162. package/Connection.d.ts +1 -0
  163. package/Connection.js +156 -527
  164. package/Connection.js.map +1 -1
  165. package/Dialogs/ComplexCron.js +0 -34
  166. package/Dialogs/ComplexCron.js.map +1 -1
  167. package/Dialogs/Confirm.js +1 -39
  168. package/Dialogs/Confirm.js.map +1 -1
  169. package/Dialogs/Cron.js +1 -37
  170. package/Dialogs/Cron.js.map +1 -1
  171. package/Dialogs/Error.d.ts +1 -1
  172. package/Dialogs/Error.js +2 -29
  173. package/Dialogs/Error.js.map +1 -1
  174. package/Dialogs/FileSelect.js +2 -36
  175. package/Dialogs/FileSelect.js.map +1 -1
  176. package/Dialogs/Message.js +2 -27
  177. package/Dialogs/Message.js.map +1 -1
  178. package/Dialogs/SelectID.d.ts +1 -1
  179. package/Dialogs/SelectID.js +3 -40
  180. package/Dialogs/SelectID.js.map +1 -1
  181. package/Dialogs/SimpleCron.js +1 -33
  182. package/Dialogs/SimpleCron.js.map +1 -1
  183. package/Dialogs/TextInput.js +2 -34
  184. package/Dialogs/TextInput.js.map +1 -1
  185. package/GenericApp.js +54 -150
  186. package/GenericApp.js.map +1 -1
  187. package/Prompt.js +0 -2
  188. package/Prompt.js.map +1 -1
  189. package/README.md +8 -4
  190. package/Theme.js +7 -22
  191. package/Theme.js.map +1 -1
  192. package/i18n.d.ts +2 -0
  193. package/i18n.js +9 -29
  194. package/i18n.js.map +1 -1
  195. package/icons/IconAdapter.d.ts +2 -2
  196. package/icons/IconAdapter.js +2 -6
  197. package/icons/IconAdapter.js.map +1 -1
  198. package/icons/IconAlias.d.ts +2 -2
  199. package/icons/IconAlias.js +2 -6
  200. package/icons/IconAlias.js.map +1 -1
  201. package/icons/IconChannel.d.ts +2 -2
  202. package/icons/IconChannel.js +2 -6
  203. package/icons/IconChannel.js.map +1 -1
  204. package/icons/IconClearFilter.d.ts +2 -2
  205. package/icons/IconClearFilter.js +0 -5
  206. package/icons/IconClearFilter.js.map +1 -1
  207. package/icons/IconClosed.d.ts +2 -2
  208. package/icons/IconClosed.js +0 -5
  209. package/icons/IconClosed.js.map +1 -1
  210. package/icons/IconCopy.d.ts +2 -2
  211. package/icons/IconCopy.js +0 -5
  212. package/icons/IconCopy.js.map +1 -1
  213. package/icons/IconDevice.d.ts +2 -2
  214. package/icons/IconDevice.js +0 -5
  215. package/icons/IconDevice.js.map +1 -1
  216. package/icons/IconDocument.d.ts +2 -2
  217. package/icons/IconDocument.js +0 -5
  218. package/icons/IconDocument.js.map +1 -1
  219. package/icons/IconDocumentReadOnly.d.ts +2 -2
  220. package/icons/IconDocumentReadOnly.js +0 -5
  221. package/icons/IconDocumentReadOnly.js.map +1 -1
  222. package/icons/IconExpert.d.ts +2 -2
  223. package/icons/IconExpert.js +0 -5
  224. package/icons/IconExpert.js.map +1 -1
  225. package/icons/IconFx.d.ts +2 -2
  226. package/icons/IconFx.js +0 -5
  227. package/icons/IconFx.js.map +1 -1
  228. package/icons/IconInstance.d.ts +2 -2
  229. package/icons/IconInstance.js +0 -5
  230. package/icons/IconInstance.js.map +1 -1
  231. package/icons/IconLogout.d.ts +2 -2
  232. package/icons/IconLogout.js +0 -5
  233. package/icons/IconLogout.js.map +1 -1
  234. package/icons/IconNoIcon.d.ts +2 -2
  235. package/icons/IconNoIcon.js +0 -5
  236. package/icons/IconNoIcon.js.map +1 -1
  237. package/icons/IconOpen.d.ts +2 -2
  238. package/icons/IconOpen.js +0 -5
  239. package/icons/IconOpen.js.map +1 -1
  240. package/icons/IconState.d.ts +2 -2
  241. package/icons/IconState.js +0 -6
  242. package/icons/IconState.js.map +1 -1
  243. package/package.json +15 -15
package/Connection.js CHANGED
@@ -1,20 +1,14 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports["default"] = exports.PROGRESS = exports.ERRORS = void 0;
9
-
10
8
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
-
12
9
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
-
14
10
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
-
16
11
  var _propTypes = _interopRequireDefault(require("prop-types"));
17
-
18
12
  /**
19
13
  * Copyright 2020-2022, bluefox <dogafox@gmail.com>
20
14
  *
@@ -26,13 +20,10 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
26
20
  var PROGRESS = {
27
21
  /** The socket is connecting. */
28
22
  CONNECTING: 0,
29
-
30
23
  /** The socket is successfully connected. */
31
24
  CONNECTED: 1,
32
-
33
25
  /** All objects are loaded. */
34
26
  OBJECTS_LOADED: 2,
35
-
36
27
  /** The socket is ready for use. */
37
28
  READY: 3
38
29
  };
@@ -45,7 +36,6 @@ var ERRORS = {
45
36
  NOT_CONNECTED: NOT_CONNECTED
46
37
  };
47
38
  exports.ERRORS = ERRORS;
48
-
49
39
  function fixAdminUI(obj) {
50
40
  if (obj && obj.common && !obj.common.adminUI) {
51
41
  if (obj.common.noConfig) {
@@ -61,7 +51,6 @@ function fixAdminUI(obj) {
61
51
  obj.common.adminUI = obj.common.adminUI || {};
62
52
  obj.common.adminUI.config = 'html';
63
53
  }
64
-
65
54
  if (obj.common.jsonCustom) {
66
55
  obj.common.adminUI = obj.common.adminUI || {};
67
56
  obj.common.adminUI.custom = 'json';
@@ -69,7 +58,6 @@ function fixAdminUI(obj) {
69
58
  obj.common.adminUI = obj.common.adminUI || {};
70
59
  obj.common.adminUI.custom = 'json';
71
60
  }
72
-
73
61
  if (obj.common.materializeTab && obj.common.adminTab) {
74
62
  obj.common.adminUI = obj.common.adminUI || {};
75
63
  obj.common.adminUI.tab = 'materialize';
@@ -77,20 +65,16 @@ function fixAdminUI(obj) {
77
65
  obj.common.adminUI = obj.common.adminUI || {};
78
66
  obj.common.adminUI.tab = 'html';
79
67
  }
80
-
81
68
  obj.common.adminUI && console.debug("Please add to \"".concat(obj._id.replace(/\.\d+$/, ''), "\" common.adminUI=").concat(JSON.stringify(obj.common.adminUI)));
82
69
  }
83
-
84
70
  return obj;
85
71
  }
86
-
87
72
  var Connection = /*#__PURE__*/function () {
88
73
  /**
89
74
  * @param {import('./types').ConnectionProps} props
90
75
  */
91
76
  function Connection(props) {
92
77
  var _this = this;
93
-
94
78
  (0, _classCallCheck2["default"])(this, Connection);
95
79
  props = props || {
96
80
  protocol: window.location.protocol,
@@ -103,80 +87,68 @@ var Connection = /*#__PURE__*/function () {
103
87
  this.props.host = this.props.host || window.location.hostname;
104
88
  this.props.port = this.props.port || (window.location.port === '3000' ? Connection.isWeb() ? 8082 : 8081 : window.location.port);
105
89
  this.props.ioTimeout = Math.max(this.props.ioTimeout || 20000, 20000);
106
- this.props.cmdTimeout = Math.max(this.props.cmdTimeout || 5000, 5000); // breaking change. Do not load all objects by default is true
90
+ this.props.cmdTimeout = Math.max(this.props.cmdTimeout || 5000, 5000);
107
91
 
92
+ // breaking change. Do not load all objects by default is true
108
93
  this.doNotLoadAllObjects = this.props.doNotLoadAllObjects === undefined ? true : this.props.doNotLoadAllObjects;
109
94
  this.doNotLoadACL = this.props.doNotLoadACL === undefined ? true : this.props.doNotLoadACL;
110
- /** @type {Record<string, ioBroker.State>} */
111
95
 
96
+ /** @type {Record<string, ioBroker.State>} */
112
97
  this.states = {};
113
98
  this.objects = null;
114
99
  this.acl = null;
115
100
  this.firstConnect = true;
116
101
  this.waitForRestart = false;
117
102
  /** @type {ioBroker.Languages} */
118
-
119
103
  this.systemLang = 'en';
120
104
  this.connected = false;
121
105
  this._waitForFirstConnection = new Promise(function (resolve) {
122
106
  _this._waitForFirstConnectionResolve = resolve;
123
107
  });
124
- /** @type {Record<string, { reg: RegExp; cbs: ioBroker.StateChangeHandler[]}>} */
125
108
 
109
+ /** @type {Record<string, { reg: RegExp; cbs: ioBroker.StateChangeHandler[]}>} */
126
110
  this.statesSubscribes = {}; // subscribe for states
127
111
 
128
112
  /** @type {Record<string, { reg: RegExp; cbs: import('./types').ObjectChangeHandler[]}>} */
129
-
130
113
  this.objectsSubscribes = {}; // subscribe for objects
131
-
132
114
  this.onProgress = this.props.onProgress || function () {};
133
-
134
115
  this.onError = this.props.onError || function (err) {
135
116
  console.error(err);
136
117
  };
137
-
138
118
  this.loaded = false;
139
119
  this.loadTimer = null;
140
120
  this.loadCounter = 0;
141
121
  this.admin5only = this.props.admin5only || false;
142
- /** @type {((connected: boolean) => void)[]} */
143
122
 
123
+ /** @type {((connected: boolean) => void)[]} */
144
124
  this.onConnectionHandlers = [];
145
125
  /** @type {((message: string) => void)[]} */
146
-
147
126
  this.onLogHandlers = [];
148
- /** @type {Record<string, Promise<any>>} */
149
127
 
128
+ /** @type {Record<string, Promise<any>>} */
150
129
  this._promises = {};
151
-
152
130
  this.log.error = function (text) {
153
131
  return _this.log(text, 'error');
154
132
  };
155
-
156
133
  this.log.warn = function (text) {
157
134
  return _this.log(text, 'warn');
158
135
  };
159
-
160
136
  this.log.info = function (text) {
161
137
  return _this.log(text, 'info');
162
138
  };
163
-
164
139
  this.log.debug = function (text) {
165
140
  return _this.log(text, 'debug');
166
141
  };
167
-
168
142
  this.log.silly = function (text) {
169
143
  return _this.log(text, 'silly');
170
144
  };
171
-
172
145
  this.startSocket();
173
146
  }
147
+
174
148
  /**
175
149
  * Checks if this connection is running in a web adapter and not in an admin.
176
150
  * @returns {boolean} True if running in a web adapter or in a socketio adapter.
177
151
  */
178
-
179
-
180
152
  (0, _createClass2["default"])(Connection, [{
181
153
  key: "startSocket",
182
154
  value:
@@ -186,7 +158,6 @@ var Connection = /*#__PURE__*/function () {
186
158
  */
187
159
  function startSocket() {
188
160
  var _this2 = this;
189
-
190
161
  // if socket io is not yet loaded
191
162
  if (typeof window.io === 'undefined') {
192
163
  // if in index.html the onLoad function not defined
@@ -194,7 +165,6 @@ var Connection = /*#__PURE__*/function () {
194
165
  // poll if loaded
195
166
  this.scriptLoadCounter = this.scriptLoadCounter || 0;
196
167
  this.scriptLoadCounter++;
197
-
198
168
  if (this.scriptLoadCounter < 30) {
199
169
  // wait till the script loaded
200
170
  setTimeout(function () {
@@ -210,7 +180,6 @@ var Connection = /*#__PURE__*/function () {
210
180
  return _this2.startSocket();
211
181
  });
212
182
  }
213
-
214
183
  return;
215
184
  } else {
216
185
  // socket was initialized, do not repeat
@@ -218,12 +187,10 @@ var Connection = /*#__PURE__*/function () {
218
187
  return;
219
188
  }
220
189
  }
221
-
222
190
  var host = this.props.host;
223
191
  var port = this.props.port;
224
192
  var protocol = this.props.protocol.replace(':', '');
225
193
  var path = window.location.pathname;
226
-
227
194
  if (window.location.hostname === 'iobroker.net' || window.location.hostname === 'iobroker.pro') {
228
195
  path = '';
229
196
  } else {
@@ -232,39 +199,34 @@ var Connection = /*#__PURE__*/function () {
232
199
  var parts = window.socketUrl.split(':');
233
200
  host = parts[0] || host;
234
201
  port = parts[1] || port;
235
-
236
202
  if (host.includes('://')) {
237
203
  parts = host.split('://');
238
204
  protocol = parts[0];
239
205
  host = parts[1];
240
206
  }
241
- } // get current path
242
-
243
-
207
+ }
208
+ // get current path
244
209
  var pos = path.lastIndexOf('/');
245
-
246
210
  if (pos !== -1) {
247
211
  path = path.substring(0, pos + 1);
248
212
  }
249
-
250
213
  if (Connection.isWeb()) {
251
214
  // remove one level, like echarts, vis, .... We have here: '/echarts/'
252
215
  var _parts = path.split('/');
253
-
254
216
  if (_parts.length > 2) {
255
217
  _parts.pop();
256
-
218
+ // if it is version, like in material, so remove it too
219
+ if (_parts[_parts.length - 1].match(/\d+\.\d+\.\d+/)) {
220
+ _parts.pop();
221
+ }
257
222
  _parts.pop();
258
-
259
223
  path = _parts.join('/');
260
-
261
224
  if (!path.endsWith('/')) {
262
225
  path += '/';
263
226
  }
264
227
  }
265
228
  }
266
229
  }
267
-
268
230
  var url = port ? "".concat(protocol, "://").concat(host, ":").concat(port).concat(path) : "".concat(protocol, "://").concat(host).concat(path);
269
231
  this._socket = window.io.connect(url, {
270
232
  path: path.endsWith('/') ? path + 'socket.io' : path + '/socket.io',
@@ -272,23 +234,20 @@ var Connection = /*#__PURE__*/function () {
272
234
  name: this.props.name,
273
235
  timeout: this.props.ioTimeout
274
236
  });
275
-
276
237
  this._socket.on('connect', function (noTimeout) {
277
238
  // If the user is not admin it takes some time to install the handlers, because all rights must be checked
278
239
  if (noTimeout !== true) {
279
240
  setTimeout(function () {
280
241
  return _this2.getVersion().then(function (info) {
281
242
  var _info$version$split = info.version.split('.'),
282
- _info$version$split2 = (0, _slicedToArray2["default"])(_info$version$split, 3),
283
- major = _info$version$split2[0],
284
- minor = _info$version$split2[1],
285
- patch = _info$version$split2[2];
286
-
243
+ _info$version$split2 = (0, _slicedToArray2["default"])(_info$version$split, 3),
244
+ major = _info$version$split2[0],
245
+ minor = _info$version$split2[1],
246
+ patch = _info$version$split2[2];
287
247
  var v = parseInt(major, 10) * 10000 + parseInt(minor, 10) * 100 + parseInt(patch, 10);
288
-
289
248
  if (v < 40102) {
290
- _this2._authTimer = null; // possible this is old version of admin
291
-
249
+ _this2._authTimer = null;
250
+ // possible this is old version of admin
292
251
  _this2.onPreConnect(false, false);
293
252
  } else {
294
253
  _this2._socket.emit('authenticate', function (isOk, isSecure) {
@@ -304,67 +263,51 @@ var Connection = /*#__PURE__*/function () {
304
263
  });
305
264
  }
306
265
  });
307
-
308
266
  this._socket.on('reconnect', function () {
309
267
  _this2.onProgress(PROGRESS.READY);
310
-
311
268
  _this2.connected = true;
312
-
313
269
  if (_this2.waitForRestart) {
314
270
  window.location.reload(false);
315
271
  } else {
316
272
  _this2._subscribe(true);
317
-
318
273
  _this2.onConnectionHandlers.forEach(function (cb) {
319
274
  return cb(true);
320
275
  });
321
276
  }
322
277
  });
323
-
324
278
  this._socket.on('disconnect', function () {
325
279
  _this2.connected = false;
326
280
  _this2.subscribed = false;
327
-
328
281
  _this2.onProgress(PROGRESS.CONNECTING);
329
-
330
282
  _this2.onConnectionHandlers.forEach(function (cb) {
331
283
  return cb(false);
332
284
  });
333
285
  });
334
-
335
286
  this._socket.on('reauthenticate', function () {
336
287
  return _this2.authenticate();
337
288
  });
338
-
339
289
  this._socket.on('log', function (message) {
340
290
  _this2.props.onLog && _this2.props.onLog(message);
341
-
342
291
  _this2.onLogHandlers.forEach(function (cb) {
343
292
  return cb(message);
344
293
  });
345
294
  });
346
-
347
295
  this._socket.on('error', function (err) {
348
296
  var _err = err || '';
349
-
350
297
  if (typeof _err.toString !== 'function') {
351
298
  _err = JSON.stringify(_err);
352
299
  console.error("Received strange error: ".concat(_err));
353
300
  }
354
-
355
301
  _err = _err.toString();
356
-
357
302
  if (_err.includes('User not authorized')) {
358
303
  _this2.authenticate();
359
304
  } else {
360
305
  window.alert("Socket Error: ".concat(err));
361
306
  }
362
307
  });
363
-
364
308
  this._socket.on('connect_error', function (err) {
365
309
  return console.error("Connect error: ".concat(err));
366
310
  });
367
-
368
311
  this._socket.on('permissionError', function (err) {
369
312
  return _this2.onError({
370
313
  message: 'no permission',
@@ -373,51 +316,43 @@ var Connection = /*#__PURE__*/function () {
373
316
  id: err.id || ''
374
317
  });
375
318
  });
376
-
377
319
  this._socket.on('objectChange', function (id, obj) {
378
320
  return setTimeout(function () {
379
321
  return _this2.objectChange(id, obj);
380
322
  }, 0);
381
323
  });
382
-
383
324
  this._socket.on('stateChange', function (id, state) {
384
325
  return setTimeout(function () {
385
326
  return _this2.stateChange(id, state);
386
327
  }, 0);
387
328
  });
388
-
389
329
  this._socket.on('cmdStdout', function (id, text) {
390
330
  return _this2.onCmdStdoutHandler && _this2.onCmdStdoutHandler(id, text);
391
331
  });
392
-
393
332
  this._socket.on('cmdStderr', function (id, text) {
394
333
  return _this2.onCmdStderrHandler && _this2.onCmdStderrHandler(id, text);
395
334
  });
396
-
397
335
  this._socket.on('cmdExit', function (id, exitCode) {
398
336
  return _this2.onCmdExitHandler && _this2.onCmdExitHandler(id, exitCode);
399
337
  });
400
338
  }
339
+
401
340
  /**
402
341
  * Called internally.
403
342
  * @private
404
343
  * @param {boolean} isOk
405
344
  * @param {boolean} isSecure
406
345
  */
407
-
408
346
  }, {
409
347
  key: "onPreConnect",
410
348
  value: function onPreConnect(isOk, isSecure) {
411
349
  var _this3 = this;
412
-
413
350
  if (this._authTimer) {
414
351
  clearTimeout(this._authTimer);
415
352
  this._authTimer = null;
416
353
  }
417
-
418
354
  this.connected = true;
419
355
  this.isSecure = isSecure;
420
-
421
356
  if (this.waitForRestart) {
422
357
  window.location.reload(false);
423
358
  } else {
@@ -426,57 +361,51 @@ var Connection = /*#__PURE__*/function () {
426
361
  this.loadTimer = setTimeout(function () {
427
362
  _this3.loadTimer = null;
428
363
  _this3.loadCounter++;
429
-
430
364
  if (_this3.loadCounter < 10) {
431
365
  _this3.onConnect();
432
366
  }
433
367
  }, 1000);
434
-
435
368
  if (!this.loaded) {
436
369
  this.onConnect();
437
370
  }
438
371
  } else {
439
372
  this.onProgress(PROGRESS.READY);
440
373
  }
441
-
442
374
  this._subscribe(true);
443
-
444
375
  this.onConnectionHandlers.forEach(function (cb) {
445
376
  return cb(true);
446
377
  });
447
378
  }
448
-
449
379
  if (this._waitForFirstConnectionResolve) {
450
380
  this._waitForFirstConnectionResolve();
451
-
452
381
  this._waitForFirstConnectionResolve = null;
453
382
  }
454
383
  }
384
+
455
385
  /**
456
386
  * Checks if the socket is connected.
457
387
  * @returns {boolean} true if connected.
458
388
  */
459
-
460
389
  }, {
461
390
  key: "isConnected",
462
391
  value: function isConnected() {
463
392
  return this.connected;
464
393
  }
394
+
465
395
  /**
466
396
  * Checks if the socket is connected.
467
397
  * @returns {Promise<void>} Promise resolves if once connected.
468
398
  */
469
-
470
399
  }, {
471
400
  key: "waitForFirstConnection",
472
401
  value: function waitForFirstConnection() {
473
402
  return this._waitForFirstConnection;
474
403
  }
404
+
475
405
  /**
476
406
  * Called internally.
477
407
  * @private
478
408
  */
479
-
480
409
  }, {
481
410
  key: "_getUserPermissions",
482
411
  value: function _getUserPermissions(cb) {
@@ -486,16 +415,15 @@ var Connection = /*#__PURE__*/function () {
486
415
  this._socket.emit('getUserPermissions', cb);
487
416
  }
488
417
  }
418
+
489
419
  /**
490
420
  * Called internally.
491
421
  * @private
492
422
  */
493
-
494
423
  }, {
495
424
  key: "onConnect",
496
425
  value: function onConnect() {
497
426
  var _this4 = this;
498
-
499
427
  this._getUserPermissions(function (err, acl) {
500
428
  if (err) {
501
429
  return _this4.onError('Cannot read user permissions: ' + err);
@@ -503,75 +431,60 @@ var Connection = /*#__PURE__*/function () {
503
431
  if (_this4.loaded) {
504
432
  return;
505
433
  }
506
-
507
434
  _this4.loaded = true;
508
435
  clearTimeout(_this4.loadTimer);
509
436
  _this4.loadTimer = null;
510
-
511
437
  _this4.onProgress(PROGRESS.CONNECTED);
512
-
513
438
  _this4.firstConnect = false;
514
439
  _this4.acl = acl;
515
- } // Read system configuration
516
-
440
+ }
517
441
 
442
+ // Read system configuration
518
443
  return (_this4.admin5only && !window.vendorPrefix ? _this4.getCompactSystemConfig() : _this4.getSystemConfig()).then(function (data) {
519
444
  if (_this4.doNotLoadACL) {
520
445
  if (_this4.loaded) {
521
446
  return undefined;
522
447
  }
523
-
524
448
  _this4.loaded = true;
525
449
  clearTimeout(_this4.loadTimer);
526
450
  _this4.loadTimer = null;
527
-
528
451
  _this4.onProgress(PROGRESS.CONNECTED);
529
-
530
452
  _this4.firstConnect = false;
531
453
  }
532
-
533
454
  _this4.systemConfig = data;
534
-
535
455
  if (_this4.systemConfig && _this4.systemConfig.common) {
536
456
  _this4.systemLang = _this4.systemConfig.common.language;
537
457
  } else {
538
458
  _this4.systemLang = window.navigator.userLanguage || window.navigator.language;
539
-
540
459
  if (_this4.systemLang !== 'en' && _this4.systemLang !== 'de' && _this4.systemLang !== 'ru') {
541
460
  _this4.systemConfig.common.language = 'en';
542
461
  _this4.systemLang = 'en';
543
462
  }
544
463
  }
545
-
546
464
  _this4.props.onLanguage && _this4.props.onLanguage(_this4.systemLang);
547
-
548
465
  if (!_this4.doNotLoadAllObjects) {
549
466
  return _this4.getObjects().then(function () {
550
467
  _this4.onProgress(PROGRESS.READY);
551
-
552
468
  _this4.props.onReady && _this4.props.onReady(_this4.objects);
553
469
  });
554
470
  } else {
555
471
  _this4.objects = _this4.admin5only ? {} : {
556
472
  'system.config': data
557
473
  };
558
-
559
474
  _this4.onProgress(PROGRESS.READY);
560
-
561
475
  _this4.props.onReady && _this4.props.onReady(_this4.objects);
562
476
  }
563
-
564
477
  return undefined;
565
478
  })["catch"](function (e) {
566
479
  return _this4.onError('Cannot read system config: ' + e);
567
480
  });
568
481
  });
569
482
  }
483
+
570
484
  /**
571
485
  * Called internally.
572
486
  * @private
573
487
  */
574
-
575
488
  }, {
576
489
  key: "authenticate",
577
490
  value: function authenticate() {
@@ -581,19 +494,18 @@ var Connection = /*#__PURE__*/function () {
581
494
  window.location = "".concat(window.location.protocol, "//").concat(window.location.host).concat(window.location.pathname, "?login&href=").concat(window.location.search).concat(window.location.hash);
582
495
  }
583
496
  }
497
+
584
498
  /**
585
499
  * Subscribe to changes of the given state.
586
500
  * @param {string} id The ioBroker state ID.
587
501
  * @param {ioBroker.StateChangeHandler} cb The callback.
588
502
  */
589
-
590
503
  /**
591
504
  * Subscribe to changes of the given state.
592
505
  * @param {string} id The ioBroker state ID.
593
506
  * @param {boolean} binary Set to true if the given state is binary and requires Base64 decoding.
594
507
  * @param {ioBroker.StateChangeHandler} cb The callback.
595
508
  */
596
-
597
509
  }, {
598
510
  key: "subscribeState",
599
511
  value: function subscribeState(id, binary, cb) {
@@ -601,27 +513,22 @@ var Connection = /*#__PURE__*/function () {
601
513
  cb = binary;
602
514
  binary = false;
603
515
  }
604
-
605
516
  if (!this.statesSubscribes[id]) {
606
517
  var reg = id.replace(/\./g, '\\.').replace(/\*/g, '.*').replace(/\(/g, '\\(').replace(/\)/g, '\\)').replace(/\+/g, '\\+').replace(/\[/g, '\\[');
607
-
608
518
  if (reg.indexOf('*') === -1) {
609
519
  reg += '$';
610
520
  }
611
-
612
521
  this.statesSubscribes[id] = {
613
522
  reg: new RegExp(reg),
614
523
  cbs: []
615
524
  };
616
525
  this.statesSubscribes[id].cbs.push(cb);
617
-
618
526
  if (this.connected) {
619
527
  this._socket.emit('subscribe', id);
620
528
  }
621
529
  } else {
622
530
  !this.statesSubscribes[id].cbs.includes(cb) && this.statesSubscribes[id].cbs.push(cb);
623
531
  }
624
-
625
532
  if (typeof cb === 'function' && this.connected) {
626
533
  if (binary) {
627
534
  this.getBinaryState(id).then(function (base64) {
@@ -648,17 +555,16 @@ var Connection = /*#__PURE__*/function () {
648
555
  }
649
556
  }
650
557
  }
558
+
651
559
  /**
652
560
  * Unsubscribes all callbacks from changes of the given state.
653
561
  * @param {string} id The ioBroker state ID.
654
562
  */
655
-
656
563
  /**
657
564
  * Unsubscribes the given callback from changes of the given state.
658
565
  * @param {string} id The ioBroker state ID.
659
566
  * @param {ioBroker.StateChangeHandler} cb The callback.
660
567
  */
661
-
662
568
  }, {
663
569
  key: "unsubscribeState",
664
570
  value: function unsubscribeState(id, cb) {
@@ -669,30 +575,27 @@ var Connection = /*#__PURE__*/function () {
669
575
  } else {
670
576
  this.statesSubscribes[id].cbs = [];
671
577
  }
672
-
673
578
  if (!this.statesSubscribes[id].cbs || !this.statesSubscribes[id].cbs.length) {
674
579
  delete this.statesSubscribes[id];
675
580
  this.connected && this._socket.emit('unsubscribe', id);
676
581
  }
677
582
  }
678
583
  }
584
+
679
585
  /**
680
586
  * Subscribe to changes of the given object.
681
587
  * @param {string} id The ioBroker object ID.
682
588
  * @param {import('./types').ObjectChangeHandler} cb The callback.
683
589
  * @returns {Promise<void>}
684
590
  */
685
-
686
591
  }, {
687
592
  key: "subscribeObject",
688
593
  value: function subscribeObject(id, cb) {
689
594
  if (!this.objectsSubscribes[id]) {
690
595
  var reg = id.replace(/\./g, '\\.').replace(/\*/g, '.*');
691
-
692
596
  if (!reg.includes('*')) {
693
597
  reg += '$';
694
598
  }
695
-
696
599
  this.objectsSubscribes[id] = {
697
600
  reg: new RegExp(reg),
698
601
  cbs: []
@@ -702,22 +605,20 @@ var Connection = /*#__PURE__*/function () {
702
605
  } else {
703
606
  !this.objectsSubscribes[id].cbs.includes(cb) && this.objectsSubscribes[id].cbs.push(cb);
704
607
  }
705
-
706
608
  return Promise.resolve();
707
609
  }
610
+
708
611
  /**
709
612
  * Unsubscribes all callbacks from changes of the given object.
710
613
  * @param {string} id The ioBroker object ID.
711
614
  * @returns {Promise<void>}
712
615
  */
713
-
714
616
  /**
715
617
  * Unsubscribes the given callback from changes of the given object.
716
618
  * @param {string} id The ioBroker object ID.
717
619
  * @param {import('./types').ObjectChangeHandler} cb The callback.
718
620
  * @returns {Promise<void>}
719
621
  */
720
-
721
622
  }, {
722
623
  key: "unsubscribeObject",
723
624
  value: function unsubscribeObject(id, cb) {
@@ -728,49 +629,42 @@ var Connection = /*#__PURE__*/function () {
728
629
  } else {
729
630
  this.objectsSubscribes[id].cbs = [];
730
631
  }
731
-
732
632
  if (this.connected && (!this.objectsSubscribes[id].cbs || !this.objectsSubscribes[id].cbs.length)) {
733
633
  delete this.objectsSubscribes[id];
734
634
  this.connected && this._socket.emit('unsubscribeObjects', id);
735
635
  }
736
636
  }
737
-
738
637
  return Promise.resolve();
739
638
  }
639
+
740
640
  /**
741
641
  * Called internally.
742
642
  * @private
743
643
  * @param {string} id
744
644
  * @param {ioBroker.Object | null | undefined} obj
745
645
  */
746
-
747
646
  }, {
748
647
  key: "objectChange",
749
648
  value: function objectChange(id, obj) {
750
649
  var _this5 = this;
751
-
752
650
  // update main.objects cache
753
651
  if (!this.objects) {
754
652
  return;
755
653
  }
756
- /** @type {import("./types").OldObject} */
757
-
758
654
 
655
+ /** @type {import("./types").OldObject} */
759
656
  var oldObj;
760
657
  var changed = false;
761
-
762
658
  if (obj) {
763
659
  if (obj._rev && this.objects[id]) {
764
660
  this.objects[id]._rev = obj._rev;
765
661
  }
766
-
767
662
  if (this.objects[id]) {
768
663
  oldObj = {
769
664
  _id: id,
770
665
  type: this.objects[id].type
771
666
  };
772
667
  }
773
-
774
668
  if (!this.objects[id] || JSON.stringify(this.objects[id]) !== JSON.stringify(obj)) {
775
669
  this.objects[id] = obj;
776
670
  changed = true;
@@ -783,7 +677,6 @@ var Connection = /*#__PURE__*/function () {
783
677
  delete this.objects[id];
784
678
  changed = true;
785
679
  }
786
-
787
680
  Object.keys(this.objectsSubscribes).forEach(function (_id) {
788
681
  if (_id === id || _this5.objectsSubscribes[_id].reg.test(id)) {
789
682
  //@ts-ignore
@@ -792,18 +685,17 @@ var Connection = /*#__PURE__*/function () {
792
685
  });
793
686
  }
794
687
  });
795
-
796
688
  if (changed && this.props.onObjectChange) {
797
689
  this.props.onObjectChange(id, obj);
798
690
  }
799
691
  }
692
+
800
693
  /**
801
694
  * Called internally.
802
695
  * @private
803
696
  * @param {string} id
804
697
  * @param {ioBroker.State | null | undefined} state
805
698
  */
806
-
807
699
  }, {
808
700
  key: "stateChange",
809
701
  value: function stateChange(id, state) {
@@ -815,96 +707,91 @@ var Connection = /*#__PURE__*/function () {
815
707
  }
816
708
  }
817
709
  }
710
+
818
711
  /**
819
712
  * Gets all states.
820
713
  * @param {boolean} disableProgressUpdate don't call onProgress() when done
821
714
  * @returns {Promise<Record<string, ioBroker.State>>}
822
715
  */
823
-
824
716
  }, {
825
717
  key: "getStates",
826
718
  value: function getStates(disableProgressUpdate) {
827
719
  var _this6 = this;
828
-
829
720
  if (!this.connected) {
830
721
  return Promise.reject(NOT_CONNECTED);
831
722
  }
832
-
833
723
  return new Promise(function (resolve, reject) {
834
724
  return _this6._socket.emit('getStates', function (err, res) {
835
- _this6.states = res; //@ts-ignore
836
-
725
+ _this6.states = res;
726
+ //@ts-ignore
837
727
  !disableProgressUpdate && _this6.onProgress(PROGRESS.STATES_LOADED);
838
728
  return err ? reject(err) : resolve(_this6.states);
839
729
  });
840
730
  });
841
731
  }
732
+
842
733
  /**
843
734
  * Gets the given state.
844
735
  * @param {string} id The state ID.
845
736
  * @returns {Promise<ioBroker.State | null | undefined>}
846
737
  */
847
-
848
738
  }, {
849
739
  key: "getState",
850
740
  value: function getState(id) {
851
741
  var _this7 = this;
852
-
853
742
  if (!this.connected) {
854
743
  return Promise.reject(NOT_CONNECTED);
855
744
  }
856
-
857
745
  return new Promise(function (resolve, reject) {
858
746
  return _this7._socket.emit('getState', id, function (err, state) {
859
747
  return err ? reject(err) : resolve(state);
860
748
  });
861
749
  });
862
750
  }
751
+
863
752
  /**
864
753
  * Gets the given binary state.
865
754
  * @param {string} id The state ID.
866
755
  * @returns {Promise<Buffer | undefined>}
867
756
  */
868
-
869
757
  }, {
870
758
  key: "getBinaryState",
871
759
  value: function getBinaryState(id) {
872
760
  var _this8 = this;
873
-
874
761
  if (!this.connected) {
875
762
  return Promise.reject(NOT_CONNECTED);
876
- } // the data will come in base64
877
-
763
+ }
878
764
 
765
+ // the data will come in base64
879
766
  return new Promise(function (resolve, reject) {
880
767
  return _this8._socket.emit('getBinaryState', id, function (err, state) {
881
768
  return err ? reject(err) : resolve(state);
882
769
  });
883
770
  });
884
771
  }
772
+
885
773
  /**
886
774
  * Sets the given binary state.
887
775
  * @param {string} id The state ID.
888
776
  * @param {string} base64 The Base64 encoded binary data.
889
777
  * @returns {Promise<void>}
890
778
  */
891
-
892
779
  }, {
893
780
  key: "setBinaryState",
894
781
  value: function setBinaryState(id, base64) {
895
782
  var _this9 = this;
896
-
897
783
  if (!this.connected) {
898
784
  return Promise.reject(NOT_CONNECTED);
899
- } // the data will come in base64
900
-
785
+ }
901
786
 
787
+ // the data will come in base64
902
788
  return new Promise(function (resolve, reject) {
903
789
  return _this9._socket.emit('setBinaryState', id, base64, function (err) {
904
790
  return err ? reject(err) : resolve();
905
791
  });
906
792
  });
907
793
  }
794
+
908
795
  /**
909
796
  * Sets the given state value.
910
797
  * @param {string} id The state ID.
@@ -912,47 +799,41 @@ var Connection = /*#__PURE__*/function () {
912
799
  * @param {boolean | null} ack Acknowledge flag
913
800
  * @returns {Promise<void>}
914
801
  */
915
-
916
802
  }, {
917
803
  key: "setState",
918
804
  value: function setState(id, val, ack) {
919
805
  var _this10 = this;
920
-
921
806
  if (!this.connected) {
922
807
  return Promise.reject(NOT_CONNECTED);
923
808
  }
924
-
925
809
  if (typeof ack === 'boolean') {
926
810
  val = {
927
811
  val: val,
928
812
  ack: ack
929
813
  };
930
814
  }
931
-
932
815
  return new Promise(function (resolve, reject) {
933
816
  return _this10._socket.emit('setState', id, val, function (err) {
934
817
  return err ? reject(err) : resolve();
935
818
  });
936
819
  });
937
820
  }
821
+
938
822
  /**
939
823
  * Gets all objects.
940
824
  * @param {(objects?: Record<string, ioBroker.Object>) => void} update Callback that is executed when all objects are retrieved.
941
825
  * @returns {void}
942
826
  */
943
-
944
827
  /**
945
828
  * Gets all objects.
946
829
  * @param {boolean} update Set to true to retrieve all objects from the server (instead of using the local cache).
947
830
  * @param {boolean} disableProgressUpdate don't call onProgress() when done
948
831
  * @returns {Promise<Record<string, ioBroker.Object>> | undefined}
949
832
  */
950
-
951
833
  }, {
952
834
  key: "getObjects",
953
835
  value: function getObjects(update, disableProgressUpdate) {
954
836
  var _this11 = this;
955
-
956
837
  if (!this.connected) {
957
838
  return Promise.reject(NOT_CONNECTED);
958
839
  } else {
@@ -960,7 +841,6 @@ var Connection = /*#__PURE__*/function () {
960
841
  if (!update && _this11.objects) {
961
842
  return resolve(_this11.objects);
962
843
  }
963
-
964
844
  _this11._socket.emit(Connection.isWeb() ? 'getObjects' : 'getAllObjects', function (err, res) {
965
845
  _this11.objects = res;
966
846
  disableProgressUpdate && _this11.onProgress(PROGRESS.OBJECTS_LOADED);
@@ -969,86 +849,82 @@ var Connection = /*#__PURE__*/function () {
969
849
  });
970
850
  }
971
851
  }
852
+
972
853
  /**
973
854
  * Called internally.
974
855
  * @private
975
856
  * @param {boolean} isEnable
976
857
  */
977
-
978
858
  }, {
979
859
  key: "_subscribe",
980
860
  value: function _subscribe(isEnable) {
981
861
  var _this12 = this;
982
-
983
862
  if (isEnable && !this.subscribed) {
984
863
  this.subscribed = true;
985
864
  this.autoSubscribes.forEach(function (id) {
986
865
  return _this12._socket.emit('subscribeObjects', id);
987
- }); // re subscribe objects
988
-
866
+ });
867
+ // re subscribe objects
989
868
  Object.keys(this.objectsSubscribes).forEach(function (id) {
990
869
  return _this12._socket.emit('subscribeObjects', id);
991
- }); // re-subscribe logs
992
-
993
- this.autoSubscribeLog && this._socket.emit('requireLog', true); // re subscribe states
994
-
870
+ });
871
+ // re-subscribe logs
872
+ this.autoSubscribeLog && this._socket.emit('requireLog', true);
873
+ // re subscribe states
995
874
  Object.keys(this.statesSubscribes).forEach(function (id) {
996
875
  return _this12._socket.emit('subscribe', id);
997
876
  });
998
877
  } else if (!isEnable && this.subscribed) {
999
- this.subscribed = false; // un-subscribe objects
1000
-
878
+ this.subscribed = false;
879
+ // un-subscribe objects
1001
880
  this.autoSubscribes.forEach(function (id) {
1002
881
  return _this12._socket.emit('unsubscribeObjects', id);
1003
882
  });
1004
883
  Object.keys(this.objectsSubscribes).forEach(function (id) {
1005
884
  return _this12._socket.emit('unsubscribeObjects', id);
1006
- }); // un-subscribe logs
1007
-
1008
- this.autoSubscribeLog && this._socket.emit('requireLog', false); // un-subscribe states
885
+ });
886
+ // un-subscribe logs
887
+ this.autoSubscribeLog && this._socket.emit('requireLog', false);
1009
888
 
889
+ // un-subscribe states
1010
890
  Object.keys(this.statesSubscribes).forEach(function (id) {
1011
891
  return _this12._socket.emit('unsubscribe', id);
1012
892
  });
1013
893
  }
1014
894
  }
895
+
1015
896
  /**
1016
897
  * Requests log updates.
1017
898
  * @param {boolean} isEnabled Set to true to get logs.
1018
899
  * @returns {Promise<void>}
1019
900
  */
1020
-
1021
901
  }, {
1022
902
  key: "requireLog",
1023
903
  value: function requireLog(isEnabled) {
1024
904
  var _this13 = this;
1025
-
1026
905
  if (!this.connected) {
1027
906
  return Promise.reject(NOT_CONNECTED);
1028
907
  }
1029
-
1030
908
  return new Promise(function (resolve, reject) {
1031
909
  return _this13._socket.emit('requireLog', isEnabled, function (err) {
1032
910
  return err ? reject(err) : resolve();
1033
911
  });
1034
912
  });
1035
913
  }
914
+
1036
915
  /**
1037
916
  * Deletes the given object.
1038
917
  * @param {string} id The object ID.
1039
918
  * @param {boolean} maintenance Force deletion of non conform IDs.
1040
919
  * @returns {Promise<void>}
1041
920
  */
1042
-
1043
921
  }, {
1044
922
  key: "delObject",
1045
923
  value: function delObject(id, maintenance) {
1046
924
  var _this14 = this;
1047
-
1048
925
  if (!this.connected) {
1049
926
  return Promise.reject(NOT_CONNECTED);
1050
927
  }
1051
-
1052
928
  return new Promise(function (resolve, reject) {
1053
929
  return _this14._socket.emit('delObject', id, {
1054
930
  maintenance: !!maintenance
@@ -1057,22 +933,20 @@ var Connection = /*#__PURE__*/function () {
1057
933
  });
1058
934
  });
1059
935
  }
936
+
1060
937
  /**
1061
938
  * Deletes the given object and all its children.
1062
939
  * @param {string} id The object ID.
1063
940
  * @param {boolean} maintenance Force deletion of non conform IDs.
1064
941
  * @returns {Promise<void>}
1065
942
  */
1066
-
1067
943
  }, {
1068
944
  key: "delObjects",
1069
945
  value: function delObjects(id, maintenance) {
1070
946
  var _this15 = this;
1071
-
1072
947
  if (!this.connected) {
1073
948
  return Promise.reject(NOT_CONNECTED);
1074
949
  }
1075
-
1076
950
  return new Promise(function (resolve, reject) {
1077
951
  return _this15._socket.emit('delObjects', id, {
1078
952
  maintenance: !!maintenance
@@ -1081,104 +955,88 @@ var Connection = /*#__PURE__*/function () {
1081
955
  });
1082
956
  });
1083
957
  }
958
+
1084
959
  /**
1085
960
  * Sets the object.
1086
961
  * @param {string} id The object ID.
1087
962
  * @param {ioBroker.SettableObject} obj The object.
1088
963
  * @returns {Promise<void>}
1089
964
  */
1090
-
1091
965
  }, {
1092
966
  key: "setObject",
1093
967
  value: function setObject(id, obj) {
1094
968
  var _this16 = this;
1095
-
1096
969
  if (!this.connected) {
1097
970
  return Promise.reject(NOT_CONNECTED);
1098
971
  }
1099
-
1100
972
  if (!obj) {
1101
973
  return Promise.reject('Null object is not allowed');
1102
974
  }
1103
-
1104
975
  obj = JSON.parse(JSON.stringify(obj));
1105
-
1106
976
  if (obj.hasOwnProperty('from')) {
1107
977
  delete obj.from;
1108
978
  }
1109
-
1110
979
  if (obj.hasOwnProperty('user')) {
1111
980
  delete obj.user;
1112
981
  }
1113
-
1114
982
  if (obj.hasOwnProperty('ts')) {
1115
983
  delete obj.ts;
1116
984
  }
1117
-
1118
985
  return new Promise(function (resolve, reject) {
1119
986
  return _this16._socket.emit('setObject', id, obj, function (err) {
1120
987
  return err ? reject(err) : resolve();
1121
988
  });
1122
989
  });
1123
990
  }
991
+
1124
992
  /**
1125
993
  * Gets the object with the given id from the server.
1126
994
  * @param {string} id The object ID.
1127
995
  * @returns {ioBroker.GetObjectPromise} The object.
1128
996
  */
1129
-
1130
997
  }, {
1131
998
  key: "getObject",
1132
999
  value: function getObject(id) {
1133
1000
  var _this17 = this;
1134
-
1135
1001
  if (!this.connected) {
1136
1002
  return Promise.reject(NOT_CONNECTED);
1137
1003
  }
1138
-
1139
1004
  return new Promise(function (resolve, reject) {
1140
1005
  return _this17._socket.emit('getObject', id, function (err, obj) {
1141
1006
  return err ? reject(err) : resolve(obj);
1142
1007
  });
1143
1008
  });
1144
1009
  }
1010
+
1145
1011
  /**
1146
1012
  * Get all adapter instances.
1147
1013
  * @param {boolean} [update] Force update.
1148
1014
  * @returns {Promise<ioBroker.Object[]>}
1149
1015
  */
1150
-
1151
1016
  /**
1152
1017
  * Get all instances of the given adapter.
1153
1018
  * @param {string} adapter The name of the adapter.
1154
1019
  * @param {boolean} [update] Force update.
1155
1020
  * @returns {Promise<ioBroker.Object[]>}
1156
1021
  */
1157
-
1158
1022
  }, {
1159
1023
  key: "getAdapterInstances",
1160
1024
  value: function getAdapterInstances(adapter, update) {
1161
1025
  var _this18 = this;
1162
-
1163
1026
  if (typeof adapter === 'boolean') {
1164
1027
  update = adapter;
1165
1028
  adapter = '';
1166
1029
  }
1167
-
1168
1030
  adapter = adapter || '';
1169
-
1170
1031
  if (!update && this._promises['instances_' + adapter]) {
1171
1032
  return this._promises['instances_' + adapter];
1172
1033
  }
1173
-
1174
1034
  if (!this.connected) {
1175
1035
  return Promise.reject(NOT_CONNECTED);
1176
1036
  }
1177
-
1178
1037
  this._promises['instances_' + adapter] = new Promise(function (resolve, reject) {
1179
1038
  var timeout = setTimeout(function () {
1180
1039
  timeout = null;
1181
-
1182
1040
  _this18.getObjectView("system.adapter.".concat(adapter ? adapter + '.' : ''), "system.adapter.".concat(adapter ? adapter + '.' : '', "\u9999"), 'instance').then(function (items) {
1183
1041
  return resolve(Object.keys(items).map(function (id) {
1184
1042
  return fixAdminUI(items[id]);
@@ -1187,7 +1045,6 @@ var Connection = /*#__PURE__*/function () {
1187
1045
  return reject(e);
1188
1046
  });
1189
1047
  }, TIMEOUT_FOR_ADMIN4);
1190
-
1191
1048
  _this18._socket.emit('getAdapterInstances', adapter, function (err, instances) {
1192
1049
  if (timeout) {
1193
1050
  clearTimeout(timeout);
@@ -1198,47 +1055,39 @@ var Connection = /*#__PURE__*/function () {
1198
1055
  });
1199
1056
  return this._promises['instances_' + adapter];
1200
1057
  }
1058
+
1201
1059
  /**
1202
1060
  * Get all adapters.
1203
1061
  * @param {boolean} [update] Force update.
1204
1062
  * @returns {Promise<ioBroker.Object[]>}
1205
1063
  */
1206
-
1207
1064
  /**
1208
1065
  * Get adapters with the given name.
1209
1066
  * @param {string} adapter The name of the adapter.
1210
1067
  * @param {boolean} [update] Force update.
1211
1068
  * @returns {Promise<ioBroker.Object[]>}
1212
1069
  */
1213
-
1214
1070
  }, {
1215
1071
  key: "getAdapters",
1216
1072
  value: function getAdapters(adapter, update) {
1217
1073
  var _this19 = this;
1218
-
1219
1074
  if (Connection.isWeb()) {
1220
1075
  return Promise.reject('Allowed only in admin');
1221
1076
  }
1222
-
1223
1077
  if (typeof adapter === 'boolean') {
1224
1078
  update = adapter;
1225
1079
  adapter = '';
1226
1080
  }
1227
-
1228
1081
  adapter = adapter || '';
1229
-
1230
1082
  if (!update && this._promises['adapter_' + adapter]) {
1231
1083
  return this._promises['adapter_' + adapter];
1232
1084
  }
1233
-
1234
1085
  if (!this.connected) {
1235
1086
  return Promise.reject(NOT_CONNECTED);
1236
1087
  }
1237
-
1238
1088
  this._promises['adapter_' + adapter] = new Promise(function (resolve, reject) {
1239
1089
  var timeout = setTimeout(function () {
1240
1090
  timeout = null;
1241
-
1242
1091
  _this19.getObjectView("system.adapter.".concat(adapter, "."), "system.adapter.".concat(adapter, ".\u9999"), 'adapter').then(function (items) {
1243
1092
  return resolve(Object.keys(items).map(function (id) {
1244
1093
  return fixAdminUI(items[id]);
@@ -1247,7 +1096,6 @@ var Connection = /*#__PURE__*/function () {
1247
1096
  return reject(e);
1248
1097
  });
1249
1098
  }, TIMEOUT_FOR_ADMIN4);
1250
-
1251
1099
  _this19._socket.emit('getAdapters', adapter, function (err, adapters) {
1252
1100
  if (timeout) {
1253
1101
  clearTimeout(timeout);
@@ -1258,18 +1106,17 @@ var Connection = /*#__PURE__*/function () {
1258
1106
  });
1259
1107
  return this._promises['adapter_' + adapter];
1260
1108
  }
1109
+
1261
1110
  /**
1262
1111
  * Called internally.
1263
1112
  * @private
1264
1113
  * @param {any[]} objs
1265
1114
  * @param {(err?: any) => void} cb
1266
1115
  */
1267
-
1268
1116
  }, {
1269
1117
  key: "_renameGroups",
1270
1118
  value: function _renameGroups(objs, cb) {
1271
1119
  var _this20 = this;
1272
-
1273
1120
  if (!objs || !objs.length) {
1274
1121
  cb && cb();
1275
1122
  } else {
@@ -1288,22 +1135,20 @@ var Connection = /*#__PURE__*/function () {
1288
1135
  });
1289
1136
  }
1290
1137
  }
1138
+
1291
1139
  /**
1292
1140
  * Rename a group.
1293
1141
  * @param {string} id The id.
1294
1142
  * @param {string} newId The new id.
1295
1143
  * @param {string | { [lang in ioBroker.Languages]?: string; }} newName The new name.
1296
1144
  */
1297
-
1298
1145
  }, {
1299
1146
  key: "renameGroup",
1300
1147
  value: function renameGroup(id, newId, newName) {
1301
1148
  var _this21 = this;
1302
-
1303
1149
  if (Connection.isWeb()) {
1304
1150
  return Promise.reject('Allowed only in admin');
1305
1151
  }
1306
-
1307
1152
  return this.getGroups(true).then(function (groups) {
1308
1153
  if (groups.length) {
1309
1154
  // find all elements
@@ -1321,15 +1166,12 @@ var Connection = /*#__PURE__*/function () {
1321
1166
  var obj = groups.find(function (group) {
1322
1167
  return group._id === id;
1323
1168
  });
1324
-
1325
1169
  if (obj) {
1326
1170
  obj._id = newId;
1327
-
1328
1171
  if (newName !== undefined) {
1329
1172
  obj.common = obj.common || {};
1330
1173
  obj.common.name = newName;
1331
1174
  }
1332
-
1333
1175
  return _this21.setObject(obj._id, obj).then(function () {
1334
1176
  return _this21.delObject(id);
1335
1177
  });
@@ -1338,6 +1180,7 @@ var Connection = /*#__PURE__*/function () {
1338
1180
  }
1339
1181
  });
1340
1182
  }
1183
+
1341
1184
  /**
1342
1185
  * Sends a message to a specific instance or all instances of some specific adapter.
1343
1186
  * @param {string} instance The instance to send this message to.
@@ -1345,179 +1188,167 @@ var Connection = /*#__PURE__*/function () {
1345
1188
  * @param {ioBroker.MessagePayload} [data] The message data to send.
1346
1189
  * @returns {Promise<ioBroker.Message | undefined>}
1347
1190
  */
1348
-
1349
1191
  }, {
1350
1192
  key: "sendTo",
1351
1193
  value: function sendTo(instance, command, data) {
1352
1194
  var _this22 = this;
1353
-
1354
1195
  if (!this.connected) {
1355
1196
  return Promise.reject(NOT_CONNECTED);
1356
1197
  }
1357
-
1358
1198
  return new Promise(function (resolve) {
1359
1199
  return _this22._socket.emit('sendTo', instance, command, data, function (result) {
1360
1200
  return resolve(result);
1361
1201
  });
1362
1202
  });
1363
1203
  }
1204
+
1364
1205
  /**
1365
1206
  * Extend an object and create it if it might not exist.
1366
1207
  * @param {string} id The id.
1367
1208
  * @param {ioBroker.PartialObject} obj The object.
1368
1209
  */
1369
-
1370
1210
  }, {
1371
1211
  key: "extendObject",
1372
1212
  value: function extendObject(id, obj) {
1373
1213
  var _this23 = this;
1374
-
1375
1214
  if (!this.connected) {
1376
1215
  return Promise.reject(NOT_CONNECTED);
1377
1216
  }
1378
-
1379
1217
  obj = JSON.parse(JSON.stringify(obj));
1380
-
1381
1218
  if (obj.hasOwnProperty('from')) {
1382
1219
  delete obj.from;
1383
1220
  }
1384
-
1385
1221
  if (obj.hasOwnProperty('user')) {
1386
1222
  delete obj.user;
1387
1223
  }
1388
-
1389
1224
  if (obj.hasOwnProperty('ts')) {
1390
1225
  delete obj.ts;
1391
1226
  }
1392
-
1393
1227
  return new Promise(function (resolve, reject) {
1394
1228
  return _this23._socket.emit('extendObject', id, obj, function (err) {
1395
1229
  return err ? reject(err) : resolve();
1396
1230
  });
1397
1231
  });
1398
1232
  }
1233
+
1399
1234
  /**
1400
1235
  * Register a handler for log messages.
1401
1236
  * @param {(message: string) => void} handler The handler.
1402
1237
  */
1403
-
1404
1238
  }, {
1405
1239
  key: "registerLogHandler",
1406
1240
  value: function registerLogHandler(handler) {
1407
1241
  !this.onLogHandlers.includes(handler) && this.onLogHandlers.push(handler);
1408
1242
  }
1243
+
1409
1244
  /**
1410
1245
  * Unregister a handler for log messages.
1411
1246
  * @param {(message: string) => void} handler The handler.
1412
1247
  */
1413
-
1414
1248
  }, {
1415
1249
  key: "unregisterLogHandler",
1416
1250
  value: function unregisterLogHandler(handler) {
1417
1251
  var pos = this.onLogHandlers.indexOf(handler);
1418
1252
  pos !== -1 && this.onLogHandlers.splice(pos, 1);
1419
1253
  }
1254
+
1420
1255
  /**
1421
1256
  * Register a handler for the connection state.
1422
1257
  * @param {(connected: boolean) => void} handler The handler.
1423
1258
  */
1424
-
1425
1259
  }, {
1426
1260
  key: "registerConnectionHandler",
1427
1261
  value: function registerConnectionHandler(handler) {
1428
1262
  !this.onConnectionHandlers.includes(handler) && this.onConnectionHandlers.push(handler);
1429
1263
  }
1264
+
1430
1265
  /**
1431
1266
  * Unregister a handler for the connection state.
1432
1267
  * @param {(connected: boolean) => void} handler The handler.
1433
1268
  */
1434
-
1435
1269
  }, {
1436
1270
  key: "unregisterConnectionHandler",
1437
1271
  value: function unregisterConnectionHandler(handler) {
1438
1272
  var pos = this.onConnectionHandlers.indexOf(handler);
1439
1273
  pos !== -1 && this.onConnectionHandlers.splice(pos, 1);
1440
1274
  }
1275
+
1441
1276
  /**
1442
1277
  * Set the handler for standard output of a command.
1443
1278
  * @param {(id: string, text: string) => void} handler The handler.
1444
1279
  */
1445
-
1446
1280
  }, {
1447
1281
  key: "registerCmdStdoutHandler",
1448
1282
  value: function registerCmdStdoutHandler(handler) {
1449
1283
  this.onCmdStdoutHandler = handler;
1450
1284
  }
1285
+
1451
1286
  /**
1452
1287
  * Unset the handler for standard output of a command.
1453
1288
  * @param {(id: string, text: string) => void} handler The handler.
1454
1289
  */
1455
-
1456
1290
  }, {
1457
1291
  key: "unregisterCmdStdoutHandler",
1458
1292
  value: function unregisterCmdStdoutHandler(handler) {
1459
1293
  this.onCmdStdoutHandler = null;
1460
1294
  }
1295
+
1461
1296
  /**
1462
1297
  * Set the handler for standard error of a command.
1463
1298
  * @param {(id: string, text: string) => void} handler The handler.
1464
1299
  */
1465
-
1466
1300
  }, {
1467
1301
  key: "registerCmdStderrHandler",
1468
1302
  value: function registerCmdStderrHandler(handler) {
1469
1303
  this.onCmdStderrHandler = handler;
1470
1304
  }
1305
+
1471
1306
  /**
1472
1307
  * Unset the handler for standard error of a command.
1473
1308
  * @param {(id: string, text: string) => void} handler The handler.
1474
1309
  */
1475
-
1476
1310
  }, {
1477
1311
  key: "unregisterCmdStderrHandler",
1478
1312
  value: function unregisterCmdStderrHandler(handler) {
1479
1313
  this.onCmdStderrHandler = null;
1480
1314
  }
1315
+
1481
1316
  /**
1482
1317
  * Set the handler for exit of a command.
1483
1318
  * @param {(id: string, exitCode: number) => void} handler The handler.
1484
1319
  */
1485
-
1486
1320
  }, {
1487
1321
  key: "registerCmdExitHandler",
1488
1322
  value: function registerCmdExitHandler(handler) {
1489
1323
  this.onCmdExitHandler = handler;
1490
1324
  }
1325
+
1491
1326
  /**
1492
1327
  * Unset the handler for exit of a command.
1493
1328
  * @param {(id: string, exitCode: number) => void} handler The handler.
1494
1329
  */
1495
-
1496
1330
  }, {
1497
1331
  key: "unregisterCmdExitHandler",
1498
1332
  value: function unregisterCmdExitHandler(handler) {
1499
1333
  this.onCmdExitHandler = null;
1500
1334
  }
1335
+
1501
1336
  /**
1502
1337
  * Get all enums with the given name.
1503
1338
  * @param {string} [_enum] The name of the enum
1504
1339
  * @param {boolean} [update] Force update.
1505
1340
  * @returns {Promise<Record<string, ioBroker.Object>>}
1506
1341
  */
1507
-
1508
1342
  }, {
1509
1343
  key: "getEnums",
1510
1344
  value: function getEnums(_enum, update) {
1511
1345
  var _this24 = this;
1512
-
1513
1346
  if (!update && this._promises['enums_' + (_enum || 'all')]) {
1514
1347
  return this._promises['enums_' + (_enum || 'all')];
1515
1348
  }
1516
-
1517
1349
  if (!this.connected) {
1518
1350
  return Promise.reject(NOT_CONNECTED);
1519
1351
  }
1520
-
1521
1352
  this._promises['enums_' + (_enum || 'all')] = new Promise(function (resolve, reject) {
1522
1353
  _this24._socket.emit('getObjectView', 'system', 'enum', {
1523
1354
  startkey: 'enum.' + (_enum || ''),
@@ -1525,15 +1356,12 @@ var Connection = /*#__PURE__*/function () {
1525
1356
  }, function (err, res) {
1526
1357
  if (!err && res) {
1527
1358
  var _res = {};
1528
-
1529
1359
  for (var i = 0; i < res.rows.length; i++) {
1530
1360
  if (_enum && res.rows[i].id === 'enum.' + _enum) {
1531
1361
  continue;
1532
1362
  }
1533
-
1534
1363
  _res[res.rows[i].id] = res.rows[i].value;
1535
1364
  }
1536
-
1537
1365
  resolve(_res);
1538
1366
  } else {
1539
1367
  reject(err);
@@ -1542,6 +1370,7 @@ var Connection = /*#__PURE__*/function () {
1542
1370
  });
1543
1371
  return this._promises['enums_' + (_enum || 'all')];
1544
1372
  }
1373
+
1545
1374
  /**
1546
1375
  * Query a predefined object view.
1547
1376
  * @param {string} start The start ID.
@@ -1549,16 +1378,13 @@ var Connection = /*#__PURE__*/function () {
1549
1378
  * @param {string} type The type of object.
1550
1379
  * @returns {Promise<Record<string, ioBroker.Object>>}
1551
1380
  */
1552
-
1553
1381
  }, {
1554
1382
  key: "getObjectView",
1555
1383
  value: function getObjectView(start, end, type) {
1556
1384
  var _this25 = this;
1557
-
1558
1385
  if (!this.connected) {
1559
1386
  return Promise.reject(NOT_CONNECTED);
1560
1387
  }
1561
-
1562
1388
  start = start || '';
1563
1389
  end = end || "\u9999";
1564
1390
  return new Promise(function (resolve, reject) {
@@ -1568,13 +1394,11 @@ var Connection = /*#__PURE__*/function () {
1568
1394
  }, function (err, res) {
1569
1395
  if (!err) {
1570
1396
  var _res = {};
1571
-
1572
1397
  if (res && res.rows) {
1573
1398
  for (var i = 0; i < res.rows.length; i++) {
1574
1399
  _res[res.rows[i].id] = res.rows[i].value;
1575
1400
  }
1576
1401
  }
1577
-
1578
1402
  resolve(_res);
1579
1403
  } else {
1580
1404
  reject(err);
@@ -1582,43 +1406,37 @@ var Connection = /*#__PURE__*/function () {
1582
1406
  });
1583
1407
  });
1584
1408
  }
1409
+
1585
1410
  /**
1586
1411
  * Get the stored certificates.
1587
1412
  * @param {boolean} [update] Force update.
1588
1413
  * @returns {Promise<{name: string; type: 'public' | 'private' | 'chained'}[]>}
1589
1414
  */
1590
-
1591
1415
  }, {
1592
1416
  key: "getCertificates",
1593
1417
  value: function getCertificates(update) {
1594
1418
  if (Connection.isWeb()) {
1595
1419
  return Promise.reject('Allowed only in admin');
1596
1420
  }
1597
-
1598
1421
  if (this._promises.cert && !update) {
1599
1422
  return this._promises.cert;
1600
1423
  }
1601
-
1602
1424
  if (!this.connected) {
1603
1425
  return Promise.reject(NOT_CONNECTED);
1604
1426
  }
1605
-
1606
1427
  this._promises.cert = this.getObject('system.certificates').then(function (res) {
1607
1428
  var certs = [];
1608
-
1609
1429
  if (res && res["native"] && res["native"].certificates) {
1610
1430
  Object.keys(res["native"].certificates).forEach(function (c) {
1611
1431
  var cert = res["native"].certificates[c];
1612
-
1613
1432
  if (!cert) {
1614
1433
  return;
1615
1434
  }
1616
-
1617
1435
  var _cert = {
1618
1436
  name: c,
1619
1437
  type: ''
1620
- }; // If it is filename, it could be everything
1621
-
1438
+ };
1439
+ // If it is filename, it could be everything
1622
1440
  if (cert.length < 700 && (cert.indexOf('/') !== -1 || cert.indexOf('\\') !== -1)) {
1623
1441
  if (c.toLowerCase().includes('private')) {
1624
1442
  _cert.type = 'private';
@@ -1629,119 +1447,103 @@ var Connection = /*#__PURE__*/function () {
1629
1447
  } else if (cert.toLowerCase().includes('public')) {
1630
1448
  _cert.type = 'public';
1631
1449
  }
1632
-
1633
1450
  certs.push(_cert);
1634
1451
  } else {
1635
1452
  _cert.type = cert.substring(0, '-----BEGIN RSA PRIVATE KEY'.length) === '-----BEGIN RSA PRIVATE KEY' || cert.substring(0, '-----BEGIN PRIVATE KEY'.length) === '-----BEGIN PRIVATE KEY' ? 'private' : 'public';
1636
-
1637
1453
  if (_cert.type === 'public') {
1638
1454
  var m = cert.split('-----END CERTIFICATE-----');
1639
-
1640
1455
  if (m.filter(function (t) {
1641
1456
  return t.replace(/\r\n|\r|\n/, '').trim();
1642
1457
  }).length > 1) {
1643
1458
  _cert.type = 'chained';
1644
1459
  }
1645
1460
  }
1646
-
1647
1461
  certs.push(_cert);
1648
1462
  }
1649
1463
  });
1650
1464
  }
1651
-
1652
1465
  return certs;
1653
1466
  });
1654
1467
  return this._promises.cert;
1655
1468
  }
1469
+
1656
1470
  /**
1657
1471
  * Get the logs from a host (only for admin connection).
1658
1472
  * @param {string} host
1659
1473
  * @param {number} [linesNumber]
1660
1474
  * @returns {Promise<string[]>}
1661
1475
  */
1662
-
1663
1476
  }, {
1664
1477
  key: "getLogs",
1665
1478
  value: function getLogs(host, linesNumber) {
1666
1479
  var _this26 = this;
1667
-
1668
1480
  if (Connection.isWeb()) {
1669
1481
  return Promise.reject('Allowed only in admin');
1670
1482
  }
1671
-
1672
1483
  if (!this.connected) {
1673
1484
  return Promise.reject(NOT_CONNECTED);
1674
1485
  }
1675
-
1676
1486
  return new Promise(function (resolve) {
1677
1487
  return _this26._socket.emit('sendToHost', host, 'getLogs', linesNumber || 200, function (lines) {
1678
1488
  return resolve(lines);
1679
1489
  });
1680
1490
  });
1681
1491
  }
1492
+
1682
1493
  /**
1683
1494
  * Get the log files (only for admin connection).
1684
1495
  * @returns {Promise<string[]>}
1685
1496
  */
1686
-
1687
1497
  }, {
1688
1498
  key: "getLogsFiles",
1689
1499
  value: function getLogsFiles(host) {
1690
1500
  var _this27 = this;
1691
-
1692
1501
  if (Connection.isWeb()) {
1693
1502
  return Promise.reject('Allowed only in admin');
1694
1503
  }
1695
-
1696
1504
  if (!this.connected) {
1697
1505
  return Promise.reject(NOT_CONNECTED);
1698
1506
  }
1699
-
1700
1507
  return new Promise(function (resolve, reject) {
1701
1508
  return _this27._socket.emit('readLogs', host, function (err, files) {
1702
1509
  return err ? reject(err) : resolve(files);
1703
1510
  });
1704
1511
  });
1705
1512
  }
1513
+
1706
1514
  /**
1707
1515
  * Delete the logs from a host (only for admin connection).
1708
1516
  * @param {string} host
1709
1517
  * @returns {Promise<void>}
1710
1518
  */
1711
-
1712
1519
  }, {
1713
1520
  key: "delLogs",
1714
1521
  value: function delLogs(host) {
1715
1522
  var _this28 = this;
1716
-
1717
1523
  if (Connection.isWeb()) {
1718
1524
  return Promise.reject('Allowed only in admin');
1719
1525
  }
1720
-
1721
1526
  if (!this.connected) {
1722
1527
  return Promise.reject(NOT_CONNECTED);
1723
1528
  }
1724
-
1725
1529
  return new Promise(function (resolve, reject) {
1726
1530
  return _this28._socket.emit('sendToHost', host, 'delLogs', null, function (error) {
1727
1531
  return error ? reject(error) : resolve();
1728
1532
  });
1729
1533
  });
1730
1534
  }
1535
+
1731
1536
  /**
1732
1537
  * Read the meta items.
1733
1538
  * @returns {Promise<ioBroker.Object[]>}
1734
1539
  */
1735
-
1736
1540
  }, {
1737
1541
  key: "readMetaItems",
1738
1542
  value: function readMetaItems() {
1739
1543
  var _this29 = this;
1740
-
1741
1544
  if (!this.connected) {
1742
1545
  return Promise.reject(NOT_CONNECTED);
1743
1546
  }
1744
-
1745
1547
  return new Promise(function (resolve, reject) {
1746
1548
  return _this29._socket.emit('getObjectView', 'system', 'meta', {
1747
1549
  startkey: '',
@@ -1753,28 +1555,27 @@ var Connection = /*#__PURE__*/function () {
1753
1555
  });
1754
1556
  });
1755
1557
  }
1558
+
1756
1559
  /**
1757
1560
  * Read the directory of an adapter.
1758
1561
  * @param {string} adapter The adapter name.
1759
1562
  * @param {string} fileName The directory name.
1760
1563
  * @returns {Promise<ioBroker.ReadDirResult[]>}
1761
1564
  */
1762
-
1763
1565
  }, {
1764
1566
  key: "readDir",
1765
1567
  value: function readDir(adapter, fileName) {
1766
1568
  var _this30 = this;
1767
-
1768
1569
  if (!this.connected) {
1769
1570
  return Promise.reject(NOT_CONNECTED);
1770
1571
  }
1771
-
1772
1572
  return new Promise(function (resolve, reject) {
1773
1573
  return _this30._socket.emit('readDir', adapter, fileName, function (err, files) {
1774
1574
  return err ? reject(err) : resolve(files);
1775
1575
  });
1776
1576
  });
1777
1577
  }
1578
+
1778
1579
  /**
1779
1580
  * Read a file of an adapter.
1780
1581
  * @param {string} adapter The adapter name.
@@ -1782,16 +1583,13 @@ var Connection = /*#__PURE__*/function () {
1782
1583
  * @param {boolean} base64 If it must be a base64 format
1783
1584
  * @returns {Promise<string>}
1784
1585
  */
1785
-
1786
1586
  }, {
1787
1587
  key: "readFile",
1788
1588
  value: function readFile(adapter, fileName, base64) {
1789
1589
  var _this31 = this;
1790
-
1791
1590
  if (!this.connected) {
1792
1591
  return Promise.reject(NOT_CONNECTED);
1793
1592
  }
1794
-
1795
1593
  return new Promise(function (resolve, reject) {
1796
1594
  if (!base64) {
1797
1595
  _this31._socket.emit('readFile', adapter, fileName, function (err, data, type) {
@@ -1808,6 +1606,7 @@ var Connection = /*#__PURE__*/function () {
1808
1606
  }
1809
1607
  });
1810
1608
  }
1609
+
1811
1610
  /**
1812
1611
  * Write a file of an adapter.
1813
1612
  * @param {string} adapter The adapter name.
@@ -1815,16 +1614,13 @@ var Connection = /*#__PURE__*/function () {
1815
1614
  * @param {Buffer | string} data The data (if it's a Buffer, it will be converted to Base64).
1816
1615
  * @returns {Promise<void>}
1817
1616
  */
1818
-
1819
1617
  }, {
1820
1618
  key: "writeFile64",
1821
1619
  value: function writeFile64(adapter, fileName, data) {
1822
1620
  var _this32 = this;
1823
-
1824
1621
  if (!this.connected) {
1825
1622
  return Promise.reject(NOT_CONNECTED);
1826
1623
  }
1827
-
1828
1624
  return new Promise(function (resolve, reject) {
1829
1625
  if (typeof data === 'string') {
1830
1626
  _this32._socket.emit('writeFile', adapter, fileName, data, function (err) {
@@ -1834,13 +1630,13 @@ var Connection = /*#__PURE__*/function () {
1834
1630
  var base64 = btoa(new Uint8Array(data).reduce(function (data, _byte) {
1835
1631
  return data + String.fromCharCode(_byte);
1836
1632
  }, ''));
1837
-
1838
1633
  _this32._socket.emit('writeFile64', adapter, fileName, base64, function (err) {
1839
1634
  return err ? reject(err) : resolve();
1840
1635
  });
1841
1636
  }
1842
1637
  });
1843
1638
  }
1639
+
1844
1640
  /**
1845
1641
  * Rename a file or folder of an adapter.
1846
1642
  *
@@ -1850,44 +1646,40 @@ var Connection = /*#__PURE__*/function () {
1850
1646
  * @param {string} newName The new file name.
1851
1647
  * @returns {Promise<void>}
1852
1648
  */
1853
-
1854
1649
  }, {
1855
1650
  key: "rename",
1856
1651
  value: function rename(adapter, oldName, newName) {
1857
1652
  var _this33 = this;
1858
-
1859
1653
  if (!this.connected) {
1860
1654
  return Promise.reject(NOT_CONNECTED);
1861
1655
  }
1862
-
1863
1656
  return new Promise(function (resolve, reject) {
1864
1657
  return _this33._socket.emit('rename', adapter, oldName, newName, function (err) {
1865
1658
  return err ? reject(err) : resolve();
1866
1659
  });
1867
1660
  });
1868
1661
  }
1662
+
1869
1663
  /**
1870
1664
  * Delete a file of an adapter.
1871
1665
  * @param {string} adapter The adapter name.
1872
1666
  * @param {string} fileName The file name.
1873
1667
  * @returns {Promise<void>}
1874
1668
  */
1875
-
1876
1669
  }, {
1877
1670
  key: "deleteFile",
1878
1671
  value: function deleteFile(adapter, fileName) {
1879
1672
  var _this34 = this;
1880
-
1881
1673
  if (!this.connected) {
1882
1674
  return Promise.reject(NOT_CONNECTED);
1883
1675
  }
1884
-
1885
1676
  return new Promise(function (resolve, reject) {
1886
1677
  return _this34._socket.emit('unlink', adapter, fileName, function (err) {
1887
1678
  return err ? reject(err) : resolve();
1888
1679
  });
1889
1680
  });
1890
1681
  }
1682
+
1891
1683
  /**
1892
1684
  * Delete a folder of an adapter.
1893
1685
  * All files in folder will be deleted.
@@ -1895,45 +1687,38 @@ var Connection = /*#__PURE__*/function () {
1895
1687
  * @param {string} folderName The folder name.
1896
1688
  * @returns {Promise<void>}
1897
1689
  */
1898
-
1899
1690
  }, {
1900
1691
  key: "deleteFolder",
1901
1692
  value: function deleteFolder(adapter, folderName) {
1902
1693
  var _this35 = this;
1903
-
1904
1694
  if (!this.connected) {
1905
1695
  return Promise.reject(NOT_CONNECTED);
1906
1696
  }
1907
-
1908
1697
  return new Promise(function (resolve, reject) {
1909
1698
  return _this35._socket.emit('deleteFolder', adapter, folderName, function (err) {
1910
1699
  return err ? reject(err) : resolve();
1911
1700
  });
1912
1701
  });
1913
1702
  }
1703
+
1914
1704
  /**
1915
1705
  * Get the list of all hosts.
1916
1706
  * @param {boolean} [update] Force update.
1917
1707
  * @returns {Promise<ioBroker.Object[]>}
1918
1708
  */
1919
-
1920
1709
  }, {
1921
1710
  key: "getHosts",
1922
1711
  value: function getHosts(update) {
1923
1712
  var _this36 = this;
1924
-
1925
1713
  if (Connection.isWeb()) {
1926
1714
  return Promise.reject('Allowed only in admin');
1927
1715
  }
1928
-
1929
1716
  if (!update && this._promises.hosts) {
1930
1717
  return this._promises.hosts;
1931
1718
  }
1932
-
1933
1719
  if (!this.connected) {
1934
1720
  return Promise.reject(NOT_CONNECTED);
1935
1721
  }
1936
-
1937
1722
  this._promises.hosts = new Promise(function (resolve, reject) {
1938
1723
  return _this36._socket.emit('getObjectView', 'system', 'host', {
1939
1724
  startkey: 'system.host.',
@@ -1950,29 +1735,25 @@ var Connection = /*#__PURE__*/function () {
1950
1735
  });
1951
1736
  return this._promises.hosts;
1952
1737
  }
1738
+
1953
1739
  /**
1954
1740
  * Get the list of all users.
1955
1741
  * @param {boolean} [update] Force update.
1956
1742
  * @returns {Promise<ioBroker.Object[]>}
1957
1743
  */
1958
-
1959
1744
  }, {
1960
1745
  key: "getUsers",
1961
1746
  value: function getUsers(update) {
1962
1747
  var _this37 = this;
1963
-
1964
1748
  if (Connection.isWeb()) {
1965
1749
  return Promise.reject('Allowed only in admin');
1966
1750
  }
1967
-
1968
1751
  if (!update && this._promises.users) {
1969
1752
  return this._promises.users;
1970
1753
  }
1971
-
1972
1754
  if (!this.connected) {
1973
1755
  return Promise.reject(NOT_CONNECTED);
1974
1756
  }
1975
-
1976
1757
  this._promises.users = new Promise(function (resolve, reject) {
1977
1758
  return _this37._socket.emit('getObjectView', 'system', 'user', {
1978
1759
  startkey: 'system.user.',
@@ -1989,25 +1770,22 @@ var Connection = /*#__PURE__*/function () {
1989
1770
  });
1990
1771
  return this._promises.users;
1991
1772
  }
1773
+
1992
1774
  /**
1993
1775
  * Get the list of all groups.
1994
1776
  * @param {boolean} [update] Force update.
1995
1777
  * @returns {Promise<ioBroker.Object[]>}
1996
1778
  */
1997
-
1998
1779
  }, {
1999
1780
  key: "getGroups",
2000
1781
  value: function getGroups(update) {
2001
1782
  var _this38 = this;
2002
-
2003
1783
  if (!update && this._promises.groups) {
2004
1784
  return this._promises.groups;
2005
1785
  }
2006
-
2007
1786
  if (!this.connected) {
2008
1787
  return Promise.reject(NOT_CONNECTED);
2009
1788
  }
2010
-
2011
1789
  this._promises.groups = new Promise(function (resolve, reject) {
2012
1790
  return _this38._socket.emit('getObjectView', 'system', 'group', {
2013
1791
  startkey: 'system.group.',
@@ -2024,6 +1802,7 @@ var Connection = /*#__PURE__*/function () {
2024
1802
  });
2025
1803
  return this._promises.groups;
2026
1804
  }
1805
+
2027
1806
  /**
2028
1807
  * Get the host information.
2029
1808
  * @param {string} host
@@ -2031,28 +1810,22 @@ var Connection = /*#__PURE__*/function () {
2031
1810
  * @param {number} [timeoutMs] optional read timeout.
2032
1811
  * @returns {Promise<any>}
2033
1812
  */
2034
-
2035
1813
  }, {
2036
1814
  key: "getHostInfo",
2037
1815
  value: function getHostInfo(host, update, timeoutMs) {
2038
1816
  var _this39 = this;
2039
-
2040
1817
  if (Connection.isWeb()) {
2041
1818
  return Promise.reject('Allowed only in admin');
2042
1819
  }
2043
-
2044
1820
  if (!host.startsWith('system.host.')) {
2045
1821
  host += 'system.host.' + host;
2046
1822
  }
2047
-
2048
1823
  if (!update && this._promises['hostInfo' + host]) {
2049
1824
  return this._promises['hostInfo' + host];
2050
1825
  }
2051
-
2052
1826
  if (!this.connected) {
2053
1827
  return Promise.reject(NOT_CONNECTED);
2054
1828
  }
2055
-
2056
1829
  this._promises['hostInfo' + host] = new Promise(function (resolve, reject) {
2057
1830
  var timeout = setTimeout(function () {
2058
1831
  if (timeout) {
@@ -2060,12 +1833,10 @@ var Connection = /*#__PURE__*/function () {
2060
1833
  reject('getHostInfo timeout');
2061
1834
  }
2062
1835
  }, timeoutMs || _this39.props.cmdTimeout);
2063
-
2064
1836
  _this39._socket.emit('sendToHost', host, 'getHostInfo', null, function (data) {
2065
1837
  if (timeout) {
2066
1838
  clearTimeout(timeout);
2067
1839
  timeout = null;
2068
-
2069
1840
  if (data === PERMISSION_ERROR) {
2070
1841
  reject('May not read "getHostInfo"');
2071
1842
  } else if (!data) {
@@ -2078,6 +1849,7 @@ var Connection = /*#__PURE__*/function () {
2078
1849
  });
2079
1850
  return this._promises['hostInfo' + host];
2080
1851
  }
1852
+
2081
1853
  /**
2082
1854
  * Get the host information (short version).
2083
1855
  * @param {string} host
@@ -2085,28 +1857,22 @@ var Connection = /*#__PURE__*/function () {
2085
1857
  * @param {number} [timeoutMs] optional read timeout.
2086
1858
  * @returns {Promise<any>}
2087
1859
  */
2088
-
2089
1860
  }, {
2090
1861
  key: "getHostInfoShort",
2091
1862
  value: function getHostInfoShort(host, update, timeoutMs) {
2092
1863
  var _this40 = this;
2093
-
2094
1864
  if (Connection.isWeb()) {
2095
1865
  return Promise.reject('Allowed only in admin');
2096
1866
  }
2097
-
2098
1867
  if (!host.startsWith('system.host.')) {
2099
1868
  host += 'system.host.' + host;
2100
1869
  }
2101
-
2102
1870
  if (!update && this._promises['hostInfoShort' + host]) {
2103
1871
  return this._promises['hostInfoShort' + host];
2104
1872
  }
2105
-
2106
1873
  if (!this.connected) {
2107
1874
  return Promise.reject(NOT_CONNECTED);
2108
1875
  }
2109
-
2110
1876
  this._promises['hostInfoShort' + host] = new Promise(function (resolve, reject) {
2111
1877
  var timeout = setTimeout(function () {
2112
1878
  if (timeout) {
@@ -2114,12 +1880,10 @@ var Connection = /*#__PURE__*/function () {
2114
1880
  reject('hostInfoShort timeout');
2115
1881
  }
2116
1882
  }, timeoutMs || _this40.props.cmdTimeout);
2117
-
2118
1883
  _this40._socket.emit('sendToHost', host, 'getHostInfoShort', null, function (data) {
2119
1884
  if (timeout) {
2120
1885
  clearTimeout(timeout);
2121
1886
  timeout = null;
2122
-
2123
1887
  if (data === PERMISSION_ERROR) {
2124
1888
  reject('May not read "getHostInfoShort"');
2125
1889
  } else if (!data) {
@@ -2132,6 +1896,7 @@ var Connection = /*#__PURE__*/function () {
2132
1896
  });
2133
1897
  return this._promises['hostInfoShort' + host];
2134
1898
  }
1899
+
2135
1900
  /**
2136
1901
  * Get the repository.
2137
1902
  * @param {string} host
@@ -2140,28 +1905,22 @@ var Connection = /*#__PURE__*/function () {
2140
1905
  * @param {number} [timeoutMs] timeout in ms.
2141
1906
  * @returns {Promise<any>}
2142
1907
  */
2143
-
2144
1908
  }, {
2145
1909
  key: "getRepository",
2146
1910
  value: function getRepository(host, args, update, timeoutMs) {
2147
1911
  var _this41 = this;
2148
-
2149
1912
  if (Connection.isWeb()) {
2150
1913
  return Promise.reject('Allowed only in admin');
2151
1914
  }
2152
-
2153
1915
  if (!update && this._promises.repo) {
2154
1916
  return this._promises.repo;
2155
1917
  }
2156
-
2157
1918
  if (!this.connected) {
2158
1919
  return Promise.reject(NOT_CONNECTED);
2159
1920
  }
2160
-
2161
1921
  if (!host.startsWith('system.host.')) {
2162
1922
  host += 'system.host.' + host;
2163
1923
  }
2164
-
2165
1924
  this._promises.repo = new Promise(function (resolve, reject) {
2166
1925
  var timeout = setTimeout(function () {
2167
1926
  if (timeout) {
@@ -2169,12 +1928,10 @@ var Connection = /*#__PURE__*/function () {
2169
1928
  reject('getRepository timeout');
2170
1929
  }
2171
1930
  }, timeoutMs || _this41.props.cmdTimeout);
2172
-
2173
1931
  _this41._socket.emit('sendToHost', host, 'getRepository', args, function (data) {
2174
1932
  if (timeout) {
2175
1933
  clearTimeout(timeout);
2176
1934
  timeout = null;
2177
-
2178
1935
  if (data === PERMISSION_ERROR) {
2179
1936
  reject('May not read "getRepository"');
2180
1937
  } else if (!data) {
@@ -2187,6 +1944,7 @@ var Connection = /*#__PURE__*/function () {
2187
1944
  });
2188
1945
  return this._promises.repo;
2189
1946
  }
1947
+
2190
1948
  /**
2191
1949
  * Get the installed.
2192
1950
  * @param {string} host
@@ -2194,30 +1952,23 @@ var Connection = /*#__PURE__*/function () {
2194
1952
  * @param {number} [cmdTimeout] timeout in ms (optional)
2195
1953
  * @returns {Promise<any>}
2196
1954
  */
2197
-
2198
1955
  }, {
2199
1956
  key: "getInstalled",
2200
1957
  value: function getInstalled(host, update, cmdTimeout) {
2201
1958
  var _this42 = this;
2202
-
2203
1959
  if (Connection.isWeb()) {
2204
1960
  return Promise.reject('Allowed only in admin');
2205
1961
  }
2206
-
2207
1962
  this._promises.installed = this._promises.installed || {};
2208
-
2209
1963
  if (!update && this._promises.installed[host]) {
2210
1964
  return this._promises.installed[host];
2211
1965
  }
2212
-
2213
1966
  if (!this.connected) {
2214
1967
  return Promise.reject(NOT_CONNECTED);
2215
1968
  }
2216
-
2217
1969
  if (!host.startsWith('system.host.')) {
2218
1970
  host += 'system.host.' + host;
2219
1971
  }
2220
-
2221
1972
  this._promises.installed[host] = new Promise(function (resolve, reject) {
2222
1973
  var timeout = setTimeout(function () {
2223
1974
  if (timeout) {
@@ -2225,12 +1976,10 @@ var Connection = /*#__PURE__*/function () {
2225
1976
  reject('getInstalled timeout');
2226
1977
  }
2227
1978
  }, cmdTimeout || _this42.props.cmdTimeout);
2228
-
2229
1979
  _this42._socket.emit('sendToHost', host, 'getInstalled', null, function (data) {
2230
1980
  if (timeout) {
2231
1981
  clearTimeout(timeout);
2232
1982
  timeout = null;
2233
-
2234
1983
  if (data === PERMISSION_ERROR) {
2235
1984
  reject('May not read "getInstalled"');
2236
1985
  } else if (!data) {
@@ -2243,6 +1992,7 @@ var Connection = /*#__PURE__*/function () {
2243
1992
  });
2244
1993
  return this._promises.installed[host];
2245
1994
  }
1995
+
2246
1996
  /**
2247
1997
  * Execute a command on a host.
2248
1998
  * @param {string} host The host name.
@@ -2251,24 +2001,19 @@ var Connection = /*#__PURE__*/function () {
2251
2001
  * @param {number} cmdTimeout Timeout of command in ms
2252
2002
  * @returns {Promise<void>}
2253
2003
  */
2254
-
2255
2004
  }, {
2256
2005
  key: "cmdExec",
2257
2006
  value: function cmdExec(host, cmd, cmdId, cmdTimeout) {
2258
2007
  var _this43 = this;
2259
-
2260
2008
  if (Connection.isWeb()) {
2261
2009
  return Promise.reject('Allowed only in admin');
2262
2010
  }
2263
-
2264
2011
  if (!this.connected) {
2265
2012
  return Promise.reject(NOT_CONNECTED);
2266
2013
  }
2267
-
2268
2014
  if (!host.startsWith(host)) {
2269
2015
  host += 'system.host.' + host;
2270
2016
  }
2271
-
2272
2017
  return new Promise(function (resolve, reject) {
2273
2018
  var timeout = cmdTimeout && setTimeout(function () {
2274
2019
  if (timeout) {
@@ -2276,12 +2021,10 @@ var Connection = /*#__PURE__*/function () {
2276
2021
  reject('cmdExec timeout');
2277
2022
  }
2278
2023
  }, cmdTimeout);
2279
-
2280
2024
  _this43._socket.emit('cmdExec', host, cmdId, cmd, null, function (err) {
2281
2025
  if (!cmdTimeout || timeout) {
2282
2026
  timeout && clearTimeout(timeout);
2283
2027
  timeout = null;
2284
-
2285
2028
  if (err) {
2286
2029
  reject(err);
2287
2030
  } else {
@@ -2291,26 +2034,23 @@ var Connection = /*#__PURE__*/function () {
2291
2034
  });
2292
2035
  });
2293
2036
  }
2037
+
2294
2038
  /**
2295
2039
  * Checks if a given feature is supported.
2296
2040
  * @param {string} feature The feature to check.
2297
2041
  * @param {boolean} [update] Force update.
2298
2042
  * @returns {Promise<any>}
2299
2043
  */
2300
-
2301
2044
  }, {
2302
2045
  key: "checkFeatureSupported",
2303
2046
  value: function checkFeatureSupported(feature, update) {
2304
2047
  var _this44 = this;
2305
-
2306
2048
  if (!update && this._promises['supportedFeatures_' + feature]) {
2307
2049
  return this._promises['supportedFeatures_' + feature];
2308
2050
  }
2309
-
2310
2051
  if (!this.connected) {
2311
2052
  return Promise.reject(NOT_CONNECTED);
2312
2053
  }
2313
-
2314
2054
  this._promises['supportedFeatures_' + feature] = new Promise(function (resolve, reject) {
2315
2055
  return _this44._socket.emit('checkFeatureSupported', feature, function (err, features) {
2316
2056
  err ? reject(err) : resolve(features);
@@ -2318,27 +2058,24 @@ var Connection = /*#__PURE__*/function () {
2318
2058
  });
2319
2059
  return this._promises['supportedFeatures_' + feature];
2320
2060
  }
2061
+
2321
2062
  /**
2322
2063
  * Read the base settings of a given host.
2323
2064
  * @param {string} host
2324
2065
  * @returns {Promise<any>}
2325
2066
  */
2326
-
2327
2067
  }, {
2328
2068
  key: "readBaseSettings",
2329
2069
  value: function readBaseSettings(host) {
2330
2070
  var _this45 = this;
2331
-
2332
2071
  if (Connection.isWeb()) {
2333
2072
  return Promise.reject('Allowed only in admin');
2334
2073
  }
2335
-
2336
2074
  return this.checkFeatureSupported('CONTROLLER_READWRITE_BASE_SETTINGS').then(function (result) {
2337
2075
  if (result) {
2338
2076
  if (!_this45.connected) {
2339
2077
  return Promise.reject(NOT_CONNECTED);
2340
2078
  }
2341
-
2342
2079
  return new Promise(function (resolve, reject) {
2343
2080
  var timeout = setTimeout(function () {
2344
2081
  if (timeout) {
@@ -2346,16 +2083,13 @@ var Connection = /*#__PURE__*/function () {
2346
2083
  reject('readBaseSettings timeout');
2347
2084
  }
2348
2085
  }, _this45.props.cmdTimeout);
2349
-
2350
2086
  if (host.startsWith('system.host.')) {
2351
2087
  host = host.replace(/^system\.host\./, '');
2352
2088
  }
2353
-
2354
2089
  _this45._socket.emit('sendToHost', host, 'readBaseSettings', null, function (data) {
2355
2090
  if (timeout) {
2356
2091
  clearTimeout(timeout);
2357
2092
  timeout = null;
2358
-
2359
2093
  if (data === PERMISSION_ERROR) {
2360
2094
  reject('May not read "BaseSettings"');
2361
2095
  } else if (!data) {
@@ -2371,28 +2105,25 @@ var Connection = /*#__PURE__*/function () {
2371
2105
  }
2372
2106
  });
2373
2107
  }
2108
+
2374
2109
  /**
2375
2110
  * Write the base settings of a given host.
2376
2111
  * @param {string} host
2377
2112
  * @param {any} config
2378
2113
  * @returns {Promise<any>}
2379
2114
  */
2380
-
2381
2115
  }, {
2382
2116
  key: "writeBaseSettings",
2383
2117
  value: function writeBaseSettings(host, config) {
2384
2118
  var _this46 = this;
2385
-
2386
2119
  if (Connection.isWeb()) {
2387
2120
  return Promise.reject('Allowed only in admin');
2388
2121
  }
2389
-
2390
2122
  return this.checkFeatureSupported('CONTROLLER_READWRITE_BASE_SETTINGS').then(function (result) {
2391
2123
  if (result) {
2392
2124
  if (!_this46.connected) {
2393
2125
  return Promise.reject(NOT_CONNECTED);
2394
2126
  }
2395
-
2396
2127
  return new Promise(function (resolve, reject) {
2397
2128
  var timeout = setTimeout(function () {
2398
2129
  if (timeout) {
@@ -2400,12 +2131,10 @@ var Connection = /*#__PURE__*/function () {
2400
2131
  reject('writeBaseSettings timeout');
2401
2132
  }
2402
2133
  }, _this46.props.cmdTimeout);
2403
-
2404
2134
  _this46._socket.emit('sendToHost', host, 'writeBaseSettings', config, function (data) {
2405
2135
  if (timeout) {
2406
2136
  clearTimeout(timeout);
2407
2137
  timeout = null;
2408
-
2409
2138
  if (data === PERMISSION_ERROR) {
2410
2139
  reject('May not write "BaseSettings"');
2411
2140
  } else if (!data) {
@@ -2421,64 +2150,58 @@ var Connection = /*#__PURE__*/function () {
2421
2150
  }
2422
2151
  });
2423
2152
  }
2153
+
2424
2154
  /**
2425
2155
  * Send command to restart the iobroker on host
2426
2156
  * @param {string} host
2427
2157
  * @returns {Promise<any>}
2428
2158
  */
2429
-
2430
2159
  }, {
2431
2160
  key: "restartController",
2432
2161
  value: function restartController(host) {
2433
2162
  var _this47 = this;
2434
-
2435
2163
  if (Connection.isWeb()) {
2436
2164
  return Promise.reject('Allowed only in admin');
2437
2165
  }
2438
-
2439
2166
  return new Promise(function (resolve, reject) {
2440
2167
  _this47._socket.emit('sendToHost', host, 'restartController', null, function (error) {
2441
2168
  error ? reject(error) : resolve(true);
2442
2169
  });
2443
2170
  });
2444
2171
  }
2172
+
2445
2173
  /**
2446
2174
  * Read statistics information from host
2447
2175
  * @param {string} host
2448
2176
  * @param {string} typeOfDiag one of none, normal, no-city, extended
2449
2177
  * @returns {Promise<any>}
2450
2178
  */
2451
-
2452
2179
  }, {
2453
2180
  key: "getDiagData",
2454
2181
  value: function getDiagData(host, typeOfDiag) {
2455
2182
  var _this48 = this;
2456
-
2457
2183
  if (Connection.isWeb()) {
2458
2184
  return Promise.reject('Allowed only in admin');
2459
2185
  }
2460
-
2461
2186
  return new Promise(function (resolve) {
2462
2187
  _this48._socket.emit('sendToHost', host, 'getDiagData', typeOfDiag, function (result) {
2463
2188
  return resolve(result);
2464
2189
  });
2465
2190
  });
2466
2191
  }
2192
+
2467
2193
  /**
2468
2194
  * Read all states (which might not belong to this adapter) which match the given pattern.
2469
2195
  * @param {string} pattern
2470
2196
  * @returns {ioBroker.GetStatesPromise}
2471
2197
  */
2472
-
2473
2198
  }, {
2474
2199
  key: "getForeignStates",
2475
2200
  value: function getForeignStates(pattern) {
2476
2201
  var _this49 = this;
2477
-
2478
2202
  if (!this.connected) {
2479
2203
  return Promise.reject(NOT_CONNECTED);
2480
2204
  }
2481
-
2482
2205
  if (Connection.isWeb()) {
2483
2206
  return new Promise(function (resolve, reject) {
2484
2207
  return _this49._socket.emit('getStates', pattern || '*', function (err, states) {
@@ -2493,119 +2216,110 @@ var Connection = /*#__PURE__*/function () {
2493
2216
  });
2494
2217
  }
2495
2218
  }
2219
+
2496
2220
  /**
2497
2221
  * Get foreign objects by pattern, by specific type and resolve their enums.
2498
2222
  * @param {string} pattern
2499
2223
  * @param {string} [type]
2500
2224
  * @returns {ioBroker.GetObjectsPromise}
2501
2225
  */
2502
-
2503
2226
  }, {
2504
2227
  key: "getForeignObjects",
2505
2228
  value: function getForeignObjects(pattern, type) {
2506
2229
  var _this50 = this;
2507
-
2508
2230
  if (!this.connected) {
2509
2231
  return Promise.reject(NOT_CONNECTED);
2510
2232
  }
2511
-
2512
2233
  return new Promise(function (resolve, reject) {
2513
2234
  return _this50._socket.emit('getForeignObjects', pattern || '*', type, function (err, states) {
2514
2235
  return err ? reject(err) : resolve(states);
2515
2236
  });
2516
2237
  });
2517
2238
  }
2239
+
2518
2240
  /**
2519
2241
  * Gets the system configuration.
2520
2242
  * @param {boolean} [update] Force update.
2521
2243
  * @returns {Promise<ioBroker.OtherObject>}
2522
2244
  */
2523
-
2524
2245
  }, {
2525
2246
  key: "getSystemConfig",
2526
2247
  value: function getSystemConfig(update) {
2527
2248
  if (!update && this._promises.systemConfig) {
2528
2249
  return this._promises.systemConfig;
2529
2250
  }
2530
-
2531
2251
  if (!this.connected) {
2532
2252
  return Promise.reject(NOT_CONNECTED);
2533
2253
  }
2534
-
2535
2254
  this._promises.systemConfig = this.getObject('system.config').then(function (systemConfig) {
2536
2255
  //@ts-ignore
2537
- systemConfig = systemConfig || {}; //@ts-ignore
2538
-
2539
- systemConfig.common = systemConfig.common || {}; //@ts-ignore
2540
-
2256
+ systemConfig = systemConfig || {};
2257
+ //@ts-ignore
2258
+ systemConfig.common = systemConfig.common || {};
2259
+ //@ts-ignore
2541
2260
  systemConfig["native"] = systemConfig["native"] || {};
2542
2261
  return systemConfig;
2543
2262
  });
2544
2263
  return this._promises.systemConfig;
2545
2264
  }
2265
+
2546
2266
  /**
2547
2267
  * Sets the system configuration.
2548
2268
  * @param {ioBroker.SettableObjectWorker<ioBroker.OtherObject>} obj
2549
2269
  * @returns {Promise<ioBroker.SettableObjectWorker<ioBroker.OtherObject>>}
2550
2270
  */
2551
-
2552
2271
  }, {
2553
2272
  key: "setSystemConfig",
2554
2273
  value: function setSystemConfig(obj) {
2555
2274
  var _this51 = this;
2556
-
2557
2275
  return this.setObject('system.config', obj).then(function () {
2558
2276
  return _this51._promises.systemConfig = Promise.resolve(obj);
2559
2277
  });
2560
2278
  }
2279
+
2561
2280
  /**
2562
2281
  * Get the raw socket.io socket.
2563
2282
  * @returns {any}
2564
2283
  */
2565
-
2566
2284
  }, {
2567
2285
  key: "getRawSocket",
2568
2286
  value: function getRawSocket() {
2569
2287
  return this._socket;
2570
2288
  }
2289
+
2571
2290
  /**
2572
2291
  * Get the history of a given state.
2573
2292
  * @param {string} id
2574
2293
  * @param {ioBroker.GetHistoryOptions} options
2575
2294
  * @returns {Promise<ioBroker.GetHistoryResult>}
2576
2295
  */
2577
-
2578
2296
  }, {
2579
2297
  key: "getHistory",
2580
2298
  value: function getHistory(id, options) {
2581
2299
  var _this52 = this;
2582
-
2583
2300
  if (!this.connected) {
2584
2301
  return Promise.reject(NOT_CONNECTED);
2585
2302
  }
2586
-
2587
2303
  return new Promise(function (resolve, reject) {
2588
2304
  return _this52._socket.emit('getHistory', id, options, function (err, values) {
2589
2305
  return err ? reject(err) : resolve(values);
2590
2306
  });
2591
2307
  });
2592
2308
  }
2309
+
2593
2310
  /**
2594
2311
  * Get the history of a given state.
2595
2312
  * @param {string} id
2596
2313
  * @param {ioBroker.GetHistoryOptions} options
2597
2314
  * @returns {Promise<{values: ioBroker.GetHistoryResult; sesionId: string; stepIgnore: number}>}
2598
2315
  */
2599
-
2600
2316
  }, {
2601
2317
  key: "getHistoryEx",
2602
2318
  value: function getHistoryEx(id, options) {
2603
2319
  var _this53 = this;
2604
-
2605
2320
  if (!this.connected) {
2606
2321
  return Promise.reject(NOT_CONNECTED);
2607
2322
  }
2608
-
2609
2323
  return new Promise(function (resolve, reject) {
2610
2324
  return _this53._socket.emit('getHistory', id, options, function (err, values, stepIgnore, sessionId) {
2611
2325
  return err ? reject(err) : resolve({
@@ -2616,83 +2330,73 @@ var Connection = /*#__PURE__*/function () {
2616
2330
  });
2617
2331
  });
2618
2332
  }
2333
+
2619
2334
  /**
2620
2335
  * Change the password of the given user.
2621
2336
  * @param {string} user
2622
2337
  * @param {string} password
2623
2338
  * @returns {Promise<void>}
2624
2339
  */
2625
-
2626
2340
  }, {
2627
2341
  key: "changePassword",
2628
2342
  value: function changePassword(user, password) {
2629
2343
  var _this54 = this;
2630
-
2631
2344
  if (Connection.isWeb()) {
2632
2345
  return Promise.reject('Allowed only in admin');
2633
2346
  }
2634
-
2635
2347
  return new Promise(function (resolve, reject) {
2636
2348
  return _this54._socket.emit('changePassword', user, password, function (err) {
2637
2349
  return err ? reject(err) : resolve();
2638
2350
  });
2639
2351
  });
2640
2352
  }
2353
+
2641
2354
  /**
2642
2355
  * Get the IP addresses of the given host.
2643
2356
  * @param {string} host
2644
2357
  * @param {boolean} [update] Force update.
2645
2358
  * @returns {Promise<string[]>}
2646
2359
  */
2647
-
2648
2360
  }, {
2649
2361
  key: "getIpAddresses",
2650
2362
  value: function getIpAddresses(host, update) {
2651
2363
  if (Connection.isWeb()) {
2652
2364
  return Promise.reject('Allowed only in admin');
2653
2365
  }
2654
-
2655
2366
  if (!host.startsWith('system.host.')) {
2656
2367
  host = 'system.host.' + host;
2657
2368
  }
2658
-
2659
2369
  if (!update && this._promises['IPs_' + host]) {
2660
2370
  return this._promises['IPs_' + host];
2661
2371
  }
2662
-
2663
2372
  this._promises['IPs_' + host] = this.getObject(host).then(function (obj) {
2664
2373
  return obj && obj.common ? obj.common.address || [] : [];
2665
2374
  });
2666
2375
  return this._promises['IPs_' + host];
2667
2376
  }
2377
+
2668
2378
  /**
2669
2379
  * Get the IP addresses with interface names of the given host or find host by IP.
2670
2380
  * @param {string} ipOrHostName
2671
2381
  * @param {boolean} [update] Force update.
2672
2382
  * @returns {Promise<any[<name, address, family>]>}
2673
2383
  */
2674
-
2675
2384
  }, {
2676
2385
  key: "getHostByIp",
2677
2386
  value: function getHostByIp(ipOrHostName, update) {
2678
2387
  var _this55 = this;
2679
-
2680
2388
  if (Connection.isWeb()) {
2681
2389
  return Promise.reject('Allowed only in admin');
2682
2390
  }
2683
-
2684
2391
  if (ipOrHostName.startsWith('system.host.')) {
2685
2392
  ipOrHostName = ipOrHostName.replace(/^system\.host\./, '');
2686
2393
  }
2687
-
2688
2394
  if (!update && this._promises['rIPs_' + ipOrHostName]) {
2689
2395
  return this._promises['rIPs_' + ipOrHostName];
2690
2396
  }
2691
-
2692
2397
  this._promises['rIPs_' + ipOrHostName] = new Promise(function (resolve) {
2693
2398
  return _this55._socket.emit('getHostByIp', ipOrHostName, function (ip, host) {
2694
2399
  var _host$native, _host$native$hardware;
2695
-
2696
2400
  var IPs4 = [{
2697
2401
  name: '[IPv4] 0.0.0.0 - Listen on all IPs',
2698
2402
  address: '0.0.0.0',
@@ -2703,13 +2407,11 @@ var Connection = /*#__PURE__*/function () {
2703
2407
  address: '::',
2704
2408
  family: 'ipv6'
2705
2409
  }];
2706
-
2707
2410
  if (host !== null && host !== void 0 && (_host$native = host["native"]) !== null && _host$native !== void 0 && (_host$native$hardware = _host$native.hardware) !== null && _host$native$hardware !== void 0 && _host$native$hardware.networkInterfaces) {
2708
2411
  for (var eth in host["native"].hardware.networkInterfaces) {
2709
2412
  if (!host["native"].hardware.networkInterfaces.hasOwnProperty(eth)) {
2710
2413
  continue;
2711
2414
  }
2712
-
2713
2415
  for (var num = 0; num < host["native"].hardware.networkInterfaces[eth].length; num++) {
2714
2416
  if (host["native"].hardware.networkInterfaces[eth][num].family !== 'IPv6') {
2715
2417
  IPs4.push({
@@ -2727,72 +2429,64 @@ var Connection = /*#__PURE__*/function () {
2727
2429
  }
2728
2430
  }
2729
2431
  }
2730
-
2731
2432
  for (var i = 0; i < IPs6.length; i++) {
2732
2433
  IPs4.push(IPs6[i]);
2733
2434
  }
2734
-
2735
2435
  resolve(IPs4);
2736
2436
  });
2737
2437
  });
2738
2438
  return this._promises['rIPs_' + ipOrHostName];
2739
2439
  }
2440
+
2740
2441
  /**
2741
2442
  * Encrypt a text
2742
2443
  * @param {string} text
2743
2444
  * @returns {Promise<string>}
2744
2445
  */
2745
-
2746
2446
  }, {
2747
2447
  key: "encrypt",
2748
2448
  value: function encrypt(text) {
2749
2449
  var _this56 = this;
2750
-
2751
2450
  if (Connection.isWeb()) {
2752
2451
  return Promise.reject('Allowed only in admin');
2753
2452
  }
2754
-
2755
2453
  return new Promise(function (resolve, reject) {
2756
2454
  return _this56._socket.emit('encrypt', text, function (err, text) {
2757
2455
  return err ? reject(err) : resolve(text);
2758
2456
  });
2759
2457
  });
2760
2458
  }
2459
+
2761
2460
  /**
2762
2461
  * Decrypt a text
2763
2462
  * @param {string} encryptedText
2764
2463
  * @returns {Promise<string>}
2765
2464
  */
2766
-
2767
2465
  }, {
2768
2466
  key: "decrypt",
2769
2467
  value: function decrypt(encryptedText) {
2770
2468
  var _this57 = this;
2771
-
2772
2469
  if (Connection.isWeb()) {
2773
2470
  return Promise.reject('Allowed only in admin');
2774
2471
  }
2775
-
2776
2472
  return new Promise(function (resolve, reject) {
2777
2473
  return _this57._socket.emit('decrypt', encryptedText, function (err, text) {
2778
2474
  return err ? reject(err) : resolve(text);
2779
2475
  });
2780
2476
  });
2781
2477
  }
2478
+
2782
2479
  /**
2783
2480
  * Gets the version.
2784
2481
  * @returns {Promise<{version: string; serverName: string}>}
2785
2482
  */
2786
-
2787
2483
  }, {
2788
2484
  key: "getVersion",
2789
2485
  value: function getVersion(update) {
2790
2486
  var _this58 = this;
2791
-
2792
2487
  if (update && this._promises.version) {
2793
2488
  this._promises.version = null;
2794
2489
  }
2795
-
2796
2490
  this._promises.version = this._promises.version || new Promise(function (resolve, reject) {
2797
2491
  return _this58._socket.emit('getVersion', function (err, version, serverName) {
2798
2492
  // support of old socket.io
@@ -2811,16 +2505,15 @@ var Connection = /*#__PURE__*/function () {
2811
2505
  });
2812
2506
  return this._promises.version;
2813
2507
  }
2508
+
2814
2509
  /**
2815
2510
  * Gets the web server name.
2816
2511
  * @returns {Promise<string>}
2817
2512
  */
2818
-
2819
2513
  }, {
2820
2514
  key: "getWebServerName",
2821
2515
  value: function getWebServerName() {
2822
2516
  var _this59 = this;
2823
-
2824
2517
  this._promises.webName = this._promises.webName || new Promise(function (resolve, reject) {
2825
2518
  return _this59._socket.emit('getAdapterName', function (err, name) {
2826
2519
  return err ? reject(err) : resolve(name);
@@ -2828,18 +2521,19 @@ var Connection = /*#__PURE__*/function () {
2828
2521
  });
2829
2522
  return this._promises.webName;
2830
2523
  }
2524
+
2831
2525
  /**
2832
2526
  * Gets the admin version.
2833
2527
  * @deprecated use getVersion()
2834
2528
  * @returns {Promise<{version: string; serverName: string}>}
2835
2529
  */
2836
-
2837
2530
  }, {
2838
2531
  key: "getAdminVersion",
2839
2532
  value: function getAdminVersion() {
2840
2533
  console.log('Deprecated: use getVersion');
2841
2534
  return this.getVersion();
2842
2535
  }
2536
+
2843
2537
  /**
2844
2538
  * Change access rights for file
2845
2539
  * @param {string} [adapter] adapter name
@@ -2847,20 +2541,16 @@ var Connection = /*#__PURE__*/function () {
2847
2541
  * @param {object} [options] like {mode: 0x644}
2848
2542
  * @returns {Promise<{entries: array}>}
2849
2543
  */
2850
-
2851
2544
  }, {
2852
2545
  key: "chmodFile",
2853
2546
  value: function chmodFile(adapter, filename, options) {
2854
2547
  var _this60 = this;
2855
-
2856
2548
  if (Connection.isWeb()) {
2857
2549
  return Promise.reject('Allowed only in admin');
2858
2550
  }
2859
-
2860
2551
  if (!this.connected) {
2861
2552
  return Promise.reject(NOT_CONNECTED);
2862
2553
  }
2863
-
2864
2554
  return new Promise(function (resolve, reject) {
2865
2555
  return _this60._socket.emit('chmodFile', adapter, filename, options, function (err, entries, id) {
2866
2556
  return err ? reject(err) : resolve({
@@ -2870,6 +2560,7 @@ var Connection = /*#__PURE__*/function () {
2870
2560
  });
2871
2561
  });
2872
2562
  }
2563
+
2873
2564
  /**
2874
2565
  * Change owner or/and owner group for file
2875
2566
  * @param {string} [adapter] adapter name
@@ -2877,20 +2568,16 @@ var Connection = /*#__PURE__*/function () {
2877
2568
  * @param {object} [options] like {owner: 'newOwner', ownerGroup: 'newGroup'}
2878
2569
  * @returns {Promise<{entries: array}>}
2879
2570
  */
2880
-
2881
2571
  }, {
2882
2572
  key: "chownFile",
2883
2573
  value: function chownFile(adapter, filename, options) {
2884
2574
  var _this61 = this;
2885
-
2886
2575
  if (Connection.isWeb()) {
2887
2576
  return Promise.reject('Allowed only in admin');
2888
2577
  }
2889
-
2890
2578
  if (!this.connected) {
2891
2579
  return Promise.reject(NOT_CONNECTED);
2892
2580
  }
2893
-
2894
2581
  return new Promise(function (resolve, reject) {
2895
2582
  return _this61._socket.emit('chownFile', adapter, filename, options, function (err, entries, id) {
2896
2583
  return err ? reject(err) : resolve({
@@ -2900,48 +2587,43 @@ var Connection = /*#__PURE__*/function () {
2900
2587
  });
2901
2588
  });
2902
2589
  }
2590
+
2903
2591
  /**
2904
2592
  * Check if the file exists
2905
2593
  * @param {string} [adapter] adapter name
2906
2594
  * @param {string} [filename] file name with full path. it could be like vis.0/*
2907
2595
  * @returns {Promise<boolean>}
2908
2596
  */
2909
-
2910
2597
  }, {
2911
2598
  key: "fileExists",
2912
2599
  value: function fileExists(adapter, filename) {
2913
2600
  var _this62 = this;
2914
-
2915
2601
  if (!this.connected) {
2916
2602
  return Promise.reject(NOT_CONNECTED);
2917
2603
  }
2918
-
2919
2604
  return new Promise(function (resolve, reject) {
2920
2605
  return _this62._socket.emit('fileExists', adapter, filename, function (err, exists) {
2921
2606
  return err ? reject(err) : resolve(exists);
2922
2607
  });
2923
2608
  });
2924
2609
  }
2610
+
2925
2611
  /**
2926
2612
  * Get the alarm notifications from a host (only for admin connection).
2927
2613
  * @param {string} host
2928
2614
  * @param {string} [category] - optional
2929
2615
  * @returns {Promise<any>}
2930
2616
  */
2931
-
2932
2617
  }, {
2933
2618
  key: "getNotifications",
2934
2619
  value: function getNotifications(host, category) {
2935
2620
  var _this63 = this;
2936
-
2937
2621
  if (Connection.isWeb()) {
2938
2622
  return Promise.reject('Allowed only in admin');
2939
2623
  }
2940
-
2941
2624
  if (!this.connected) {
2942
2625
  return Promise.reject(NOT_CONNECTED);
2943
2626
  }
2944
-
2945
2627
  return new Promise(function (resolve) {
2946
2628
  return _this63._socket.emit('sendToHost', host, 'getNotifications', {
2947
2629
  category: category
@@ -2950,26 +2632,23 @@ var Connection = /*#__PURE__*/function () {
2950
2632
  });
2951
2633
  });
2952
2634
  }
2635
+
2953
2636
  /**
2954
2637
  * Clear the alarm notifications on a host (only for admin connection).
2955
2638
  * @param {string} host
2956
2639
  * @param {string} [category] - optional
2957
2640
  * @returns {Promise<any>}
2958
2641
  */
2959
-
2960
2642
  }, {
2961
2643
  key: "clearNotifications",
2962
2644
  value: function clearNotifications(host, category) {
2963
2645
  var _this64 = this;
2964
-
2965
2646
  if (Connection.isWeb()) {
2966
2647
  return Promise.reject('Allowed only in admin');
2967
2648
  }
2968
-
2969
2649
  if (!this.connected) {
2970
2650
  return Promise.reject(NOT_CONNECTED);
2971
2651
  }
2972
-
2973
2652
  return new Promise(function (resolve) {
2974
2653
  return _this64._socket.emit('sendToHost', host, 'clearNotifications', {
2975
2654
  category: category
@@ -2978,68 +2657,60 @@ var Connection = /*#__PURE__*/function () {
2978
2657
  });
2979
2658
  });
2980
2659
  }
2660
+
2981
2661
  /**
2982
2662
  * Read if only easy mode is allowed (only for admin connection).
2983
2663
  * @returns {Promise<boolean>}
2984
2664
  */
2985
-
2986
2665
  }, {
2987
2666
  key: "getIsEasyModeStrict",
2988
2667
  value: function getIsEasyModeStrict() {
2989
2668
  var _this65 = this;
2990
-
2991
2669
  if (Connection.isWeb()) {
2992
2670
  return Promise.reject('Allowed only in admin');
2993
2671
  }
2994
-
2995
2672
  if (!this.connected) {
2996
2673
  return Promise.reject(NOT_CONNECTED);
2997
2674
  }
2998
-
2999
2675
  return new Promise(function (resolve, reject) {
3000
2676
  return _this65._socket.emit('getIsEasyModeStrict', function (error, isStrict) {
3001
2677
  return error ? reject(error) : resolve(isStrict);
3002
2678
  });
3003
2679
  });
3004
2680
  }
2681
+
3005
2682
  /**
3006
2683
  * Read easy mode configuration (only for admin connection).
3007
2684
  * @returns {Promise<any>}
3008
2685
  */
3009
-
3010
2686
  }, {
3011
2687
  key: "getEasyMode",
3012
2688
  value: function getEasyMode() {
3013
2689
  var _this66 = this;
3014
-
3015
2690
  if (Connection.isWeb()) {
3016
2691
  return Promise.reject('Allowed only in admin');
3017
2692
  }
3018
-
3019
2693
  if (!this.connected) {
3020
2694
  return Promise.reject(NOT_CONNECTED);
3021
2695
  }
3022
-
3023
2696
  return new Promise(function (resolve, reject) {
3024
2697
  return _this66._socket.emit('getEasyMode', function (error, config) {
3025
2698
  return error ? reject(error) : resolve(config);
3026
2699
  });
3027
2700
  });
3028
2701
  }
2702
+
3029
2703
  /**
3030
2704
  * Read current user
3031
2705
  * @returns {Promise<string>}
3032
2706
  */
3033
-
3034
2707
  }, {
3035
2708
  key: "getCurrentUser",
3036
2709
  value: function getCurrentUser() {
3037
2710
  var _this67 = this;
3038
-
3039
2711
  if (!this.connected) {
3040
2712
  return Promise.reject(NOT_CONNECTED);
3041
2713
  }
3042
-
3043
2714
  return new Promise(function (resolve) {
3044
2715
  return _this67._socket.emit('authEnabled', function (isSecure, user) {
3045
2716
  return resolve(user);
@@ -3052,7 +2723,6 @@ var Connection = /*#__PURE__*/function () {
3052
2723
  if (!this.connected) {
3053
2724
  return Promise.reject(NOT_CONNECTED);
3054
2725
  }
3055
-
3056
2726
  return new Promise(function (resolve, reject) {
3057
2727
  var controller = new AbortController();
3058
2728
  var timeout = setTimeout(function () {
@@ -3077,69 +2747,61 @@ var Connection = /*#__PURE__*/function () {
3077
2747
  });
3078
2748
  });
3079
2749
  }
2750
+
3080
2751
  /**
3081
2752
  * Read adapter ratings
3082
2753
  * @returns {Promise<any>}
3083
2754
  */
3084
-
3085
2755
  }, {
3086
2756
  key: "getRatings",
3087
2757
  value: function getRatings(update) {
3088
2758
  var _this68 = this;
3089
-
3090
2759
  if (Connection.isWeb()) {
3091
2760
  return Promise.reject('Allowed only in admin');
3092
2761
  }
3093
-
3094
2762
  if (!this.connected) {
3095
2763
  return Promise.reject(NOT_CONNECTED);
3096
2764
  }
3097
-
3098
2765
  return new Promise(function (resolve, reject) {
3099
2766
  return _this68._socket.emit('getRatings', update, function (err, ratings) {
3100
2767
  return err ? reject(err) : resolve(ratings);
3101
2768
  });
3102
2769
  });
3103
2770
  }
2771
+
3104
2772
  /**
3105
2773
  * Read current web, socketio or admin namespace, like admin.0
3106
2774
  * @returns {Promise<string>}
3107
2775
  */
3108
-
3109
2776
  }, {
3110
2777
  key: "getCurrentInstance",
3111
2778
  value: function getCurrentInstance() {
3112
2779
  var _this69 = this;
3113
-
3114
2780
  if (!this.connected) {
3115
2781
  return Promise.reject(NOT_CONNECTED);
3116
2782
  }
3117
-
3118
2783
  this._promises.currentInstance = this._promises.currentInstance || new Promise(function (resolve, reject) {
3119
2784
  return _this69._socket.emit('getCurrentInstance', function (err, namespace) {
3120
2785
  return err ? reject(err) : resolve(namespace);
3121
2786
  });
3122
2787
  });
3123
2788
  return this._promises.currentInstance;
3124
- } // returns very optimized information for adapters to minimize connection load
2789
+ }
3125
2790
 
2791
+ // returns very optimized information for adapters to minimize connection load
3126
2792
  }, {
3127
2793
  key: "getCompactAdapters",
3128
2794
  value: function getCompactAdapters(update) {
3129
2795
  var _this70 = this;
3130
-
3131
2796
  if (Connection.isWeb()) {
3132
2797
  return Promise.reject('Allowed only in admin');
3133
2798
  }
3134
-
3135
2799
  if (!update && this._promises.compactAdapters) {
3136
2800
  return this._promises.compactAdapters;
3137
2801
  }
3138
-
3139
2802
  if (!this.connected) {
3140
2803
  return Promise.reject(NOT_CONNECTED);
3141
2804
  }
3142
-
3143
2805
  this._promises.compactAdapters = new Promise(function (resolve, reject) {
3144
2806
  return _this70._socket.emit('getCompactAdapters', function (err, adapters) {
3145
2807
  return err ? reject(err) : resolve(adapters);
@@ -3153,25 +2815,22 @@ var Connection = /*#__PURE__*/function () {
3153
2815
  adapter = adapter || '';
3154
2816
  this._promises.compactAdapters = null;
3155
2817
  this._promises['adapter_' + adapter] = null;
3156
- } // returns very optimized information for adapters to minimize connection load
2818
+ }
3157
2819
 
2820
+ // returns very optimized information for adapters to minimize connection load
3158
2821
  }, {
3159
2822
  key: "getCompactInstances",
3160
2823
  value: function getCompactInstances(update) {
3161
2824
  var _this71 = this;
3162
-
3163
2825
  if (Connection.isWeb()) {
3164
2826
  return Promise.reject('Allowed only in admin');
3165
2827
  }
3166
-
3167
2828
  if (!update && this._promises.compactInstances) {
3168
2829
  return this._promises.compactInstances;
3169
2830
  }
3170
-
3171
2831
  if (!this.connected) {
3172
2832
  return Promise.reject(NOT_CONNECTED);
3173
2833
  }
3174
-
3175
2834
  this._promises.compactInstances = new Promise(function (resolve, reject) {
3176
2835
  return _this71._socket.emit('getCompactInstances', function (err, instances) {
3177
2836
  return err ? reject(err) : resolve(instances);
@@ -3185,32 +2844,27 @@ var Connection = /*#__PURE__*/function () {
3185
2844
  adapter = adapter || '';
3186
2845
  this._promises.compactInstances = null;
3187
2846
  this._promises['instances_' + adapter] = null;
3188
- } // returns very optimized information for adapters to minimize connection load
3189
- // reads only version of installed adapter
2847
+ }
3190
2848
 
2849
+ // returns very optimized information for adapters to minimize connection load
2850
+ // reads only version of installed adapter
3191
2851
  }, {
3192
2852
  key: "getCompactInstalled",
3193
2853
  value: function getCompactInstalled(host, update, cmdTimeout) {
3194
2854
  var _this72 = this;
3195
-
3196
2855
  if (Connection.isWeb()) {
3197
2856
  return Promise.reject('Allowed only in admin');
3198
2857
  }
3199
-
3200
2858
  this._promises.installedCompact = this._promises.installedCompact || {};
3201
-
3202
2859
  if (!update && this._promises.installedCompact[host]) {
3203
2860
  return this._promises.installedCompact[host];
3204
2861
  }
3205
-
3206
2862
  if (!this.connected) {
3207
2863
  return Promise.reject(NOT_CONNECTED);
3208
2864
  }
3209
-
3210
2865
  if (!host.startsWith('system.host.')) {
3211
2866
  host += 'system.host.' + host;
3212
2867
  }
3213
-
3214
2868
  this._promises.installedCompact[host] = new Promise(function (resolve, reject) {
3215
2869
  var timeout = setTimeout(function () {
3216
2870
  if (timeout) {
@@ -3218,12 +2872,10 @@ var Connection = /*#__PURE__*/function () {
3218
2872
  reject('getCompactInstalled timeout');
3219
2873
  }
3220
2874
  }, cmdTimeout || _this72.props.cmdTimeout);
3221
-
3222
2875
  _this72._socket.emit('getCompactInstalled', host, function (data) {
3223
2876
  if (timeout) {
3224
2877
  clearTimeout(timeout);
3225
2878
  timeout = null;
3226
-
3227
2879
  if (data === PERMISSION_ERROR) {
3228
2880
  reject('May not read "getCompactInstalled"');
3229
2881
  } else if (!data) {
@@ -3235,24 +2887,21 @@ var Connection = /*#__PURE__*/function () {
3235
2887
  });
3236
2888
  });
3237
2889
  return this._promises.installedCompact[host];
3238
- } // returns very optimized information for adapters to minimize connection load
3239
- // reads only version of installed adapter
2890
+ }
3240
2891
 
2892
+ // returns very optimized information for adapters to minimize connection load
2893
+ // reads only version of installed adapter
3241
2894
  }, {
3242
2895
  key: "getCompactSystemRepositories",
3243
2896
  value: function getCompactSystemRepositories(update, cmdTimeout) {
3244
2897
  var _this73 = this;
3245
-
3246
2898
  if (Connection.isWeb()) {
3247
2899
  return Promise.reject('Allowed only in admin');
3248
2900
  }
3249
-
3250
2901
  this._promises.installedCompact = this._promises.installedCompact || {};
3251
-
3252
2902
  if (!this.connected) {
3253
2903
  return Promise.reject(NOT_CONNECTED);
3254
2904
  }
3255
-
3256
2905
  this._promises.getCompactSystemRepositories = new Promise(function (resolve, reject) {
3257
2906
  var timeout = setTimeout(function () {
3258
2907
  if (timeout) {
@@ -3260,12 +2909,10 @@ var Connection = /*#__PURE__*/function () {
3260
2909
  reject('getCompactSystemRepositories timeout');
3261
2910
  }
3262
2911
  }, cmdTimeout || _this73.props.cmdTimeout);
3263
-
3264
2912
  _this73._socket.emit('getCompactSystemRepositories', function (data) {
3265
2913
  if (timeout) {
3266
2914
  clearTimeout(timeout);
3267
2915
  timeout = null;
3268
-
3269
2916
  if (data === PERMISSION_ERROR) {
3270
2917
  reject('May not read "getCompactSystemRepositories"');
3271
2918
  } else if (!data) {
@@ -3284,26 +2931,24 @@ var Connection = /*#__PURE__*/function () {
3284
2931
  this._promises.repoCompact = null;
3285
2932
  this._promises.repo = null;
3286
2933
  }
2934
+
3287
2935
  /**
3288
2936
  * Get the list of all hosts in compact form (only _id, common.name, common.icon, common.color, native.hardware.networkInterfaces)
3289
2937
  * @param {boolean} [update] Force update.
3290
2938
  * @returns {Promise<ioBroker.Object[]>}
3291
2939
  */
3292
-
3293
2940
  }, {
3294
2941
  key: "getCompactSystemConfig",
3295
- value: // returns very optimized information for adapters to minimize connection load
2942
+ value:
2943
+ // returns very optimized information for adapters to minimize connection load
3296
2944
  function getCompactSystemConfig(update) {
3297
2945
  var _this74 = this;
3298
-
3299
2946
  if (!update && this._promises.systemConfigCommon) {
3300
2947
  return this._promises.systemConfigCommon;
3301
2948
  }
3302
-
3303
2949
  if (!this.connected) {
3304
2950
  return Promise.reject(NOT_CONNECTED);
3305
2951
  }
3306
-
3307
2952
  this._promises.systemConfigCommon = new Promise(function (resolve, reject) {
3308
2953
  return _this74._socket.emit('getCompactSystemConfig', function (err, systemConfig) {
3309
2954
  return err ? reject(err) : resolve(systemConfig);
@@ -3311,6 +2956,7 @@ var Connection = /*#__PURE__*/function () {
3311
2956
  });
3312
2957
  return this._promises.systemConfigCommon;
3313
2958
  }
2959
+
3314
2960
  /**
3315
2961
  * Get the repository in compact form (only version and icon).
3316
2962
  * @param {string} host
@@ -3318,28 +2964,22 @@ var Connection = /*#__PURE__*/function () {
3318
2964
  * @param {number} [timeoutMs] timeout in ms.
3319
2965
  * @returns {Promise<any>}
3320
2966
  */
3321
-
3322
2967
  }, {
3323
2968
  key: "getCompactRepository",
3324
2969
  value: function getCompactRepository(host, update, timeoutMs) {
3325
2970
  var _this75 = this;
3326
-
3327
2971
  if (Connection.isWeb()) {
3328
2972
  return Promise.reject('Allowed only in admin');
3329
2973
  }
3330
-
3331
2974
  if (!update && this._promises.repoCompact) {
3332
2975
  return this._promises.repoCompact;
3333
2976
  }
3334
-
3335
2977
  if (!this.connected) {
3336
2978
  return Promise.reject(NOT_CONNECTED);
3337
2979
  }
3338
-
3339
2980
  if (!host.startsWith('system.host.')) {
3340
2981
  host += 'system.host.' + host;
3341
2982
  }
3342
-
3343
2983
  this._promises.repoCompact = new Promise(function (resolve, reject) {
3344
2984
  var timeout = setTimeout(function () {
3345
2985
  if (timeout) {
@@ -3347,12 +2987,10 @@ var Connection = /*#__PURE__*/function () {
3347
2987
  reject('getCompactRepository timeout');
3348
2988
  }
3349
2989
  }, timeoutMs || _this75.props.cmdTimeout);
3350
-
3351
2990
  _this75._socket.emit('getCompactRepository', host, function (data) {
3352
2991
  if (timeout) {
3353
2992
  clearTimeout(timeout);
3354
2993
  timeout = null;
3355
-
3356
2994
  if (data === PERMISSION_ERROR) {
3357
2995
  reject('May not read "getCompactRepository"');
3358
2996
  } else if (!data) {
@@ -3369,19 +3007,15 @@ var Connection = /*#__PURE__*/function () {
3369
3007
  key: "getCompactHosts",
3370
3008
  value: function getCompactHosts(update) {
3371
3009
  var _this76 = this;
3372
-
3373
3010
  if (Connection.isWeb()) {
3374
3011
  return Promise.reject('Allowed only in admin');
3375
3012
  }
3376
-
3377
3013
  if (!update && this._promises.hostsCompact) {
3378
3014
  return this._promises.hostsCompact;
3379
3015
  }
3380
-
3381
3016
  if (!this.connected) {
3382
3017
  return Promise.reject(NOT_CONNECTED);
3383
3018
  }
3384
-
3385
3019
  this._promises.hostsCompact = new Promise(function (resolve, reject) {
3386
3020
  return _this76._socket.emit('getCompactHosts', function (err, hosts) {
3387
3021
  return err ? reject(err) : resolve(hosts);
@@ -3389,56 +3023,52 @@ var Connection = /*#__PURE__*/function () {
3389
3023
  });
3390
3024
  return this._promises.hostsCompact;
3391
3025
  }
3026
+
3392
3027
  /**
3393
3028
  * Get uuid
3394
3029
  * @returns {Promise<ioBroker.Object[]>}
3395
3030
  */
3396
-
3397
3031
  }, {
3398
3032
  key: "getUuid",
3399
3033
  value: function getUuid() {
3400
3034
  if (this._promises.uuid) {
3401
3035
  return this._promises.uuid;
3402
3036
  }
3403
-
3404
3037
  if (!this.connected) {
3405
3038
  return Promise.reject(NOT_CONNECTED);
3406
3039
  }
3407
-
3408
- this._promises.uuid = this.getObject('system.meta.uuid') //@ts-ignore
3040
+ this._promises.uuid = this.getObject('system.meta.uuid')
3041
+ //@ts-ignore
3409
3042
  .then(function (obj) {
3410
3043
  var _obj$native;
3411
-
3412
3044
  return obj === null || obj === void 0 ? void 0 : (_obj$native = obj["native"]) === null || _obj$native === void 0 ? void 0 : _obj$native.uuid;
3413
3045
  });
3414
3046
  return this._promises.uuid;
3415
3047
  }
3048
+
3416
3049
  /**
3417
3050
  * Send log to ioBroker log
3418
3051
  * @param {string} [text] Log text
3419
3052
  * @param {string} [level] `info`, `debug`, `warn`, `error` or `silly`
3420
3053
  * @returns {void}
3421
3054
  */
3422
-
3423
3055
  }, {
3424
3056
  key: "log",
3425
3057
  value: function log(text, level) {
3426
3058
  text && this._socket.emit('log', text, level || 'debug');
3427
3059
  }
3060
+
3428
3061
  /**
3429
3062
  * Logout current user
3430
3063
  * @returns {Promise<null>}
3431
3064
  */
3432
-
3433
3065
  }, {
3434
3066
  key: "logout",
3435
3067
  value: function logout() {
3436
3068
  var _this77 = this;
3437
-
3438
3069
  if (!this.connected) {
3439
3070
  return Promise.reject(NOT_CONNECTED);
3440
3071
  }
3441
-
3442
3072
  return new Promise(function (resolve, reject) {
3443
3073
  return _this77._socket.emit('logout', function (err) {
3444
3074
  return err ? reject(err) : resolve(null);
@@ -3453,7 +3083,6 @@ var Connection = /*#__PURE__*/function () {
3453
3083
  }]);
3454
3084
  return Connection;
3455
3085
  }();
3456
-
3457
3086
  Connection.Connection = {
3458
3087
  onLog: _propTypes["default"].func,
3459
3088
  onReady: _propTypes["default"].func,