@iobroker/adapter-react-v5 4.12.3 → 4.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LegacyConnection.d.ts +5 -4
- package/LegacyConnection.js +16 -13
- package/README.md +3 -0
- package/package.json +8 -8
package/LegacyConnection.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ export declare const ERRORS: {
|
|
|
31
31
|
PERMISSION_ERROR: string;
|
|
32
32
|
NOT_CONNECTED: string;
|
|
33
33
|
};
|
|
34
|
+
export type BinaryStateChangeHandler = (id: string, base64: string | null) => void;
|
|
34
35
|
/** Converts ioB pattern into regex */
|
|
35
36
|
export declare function pattern2RegEx(pattern: string): string;
|
|
36
37
|
interface ConnectionProps {
|
|
@@ -173,9 +174,9 @@ declare class Connection {
|
|
|
173
174
|
/** The ioBroker state ID. */
|
|
174
175
|
id: string | string[],
|
|
175
176
|
/** Set to true if the given state is binary and requires Base64 decoding. */
|
|
176
|
-
binary: boolean | ioBroker.StateChangeHandler |
|
|
177
|
+
binary: boolean | ioBroker.StateChangeHandler | BinaryStateChangeHandler,
|
|
177
178
|
/** The callback. */
|
|
178
|
-
cb?: ioBroker.StateChangeHandler |
|
|
179
|
+
cb?: ioBroker.StateChangeHandler | BinaryStateChangeHandler): void;
|
|
179
180
|
/**
|
|
180
181
|
* Subscribe to changes of the given state.
|
|
181
182
|
*/
|
|
@@ -191,7 +192,7 @@ declare class Connection {
|
|
|
191
192
|
/** The ioBroker state ID or array of states */
|
|
192
193
|
id: string | string[],
|
|
193
194
|
/** The callback. */
|
|
194
|
-
cb?: ioBroker.StateChangeHandler |
|
|
195
|
+
cb?: ioBroker.StateChangeHandler | BinaryStateChangeHandler): void;
|
|
195
196
|
/**
|
|
196
197
|
* Subscribe to changes of the given object.
|
|
197
198
|
*/
|
|
@@ -199,7 +200,7 @@ declare class Connection {
|
|
|
199
200
|
/** The ioBroker object ID. */
|
|
200
201
|
id: string | string[],
|
|
201
202
|
/** The callback. */
|
|
202
|
-
cb: ioBroker.ObjectChangeHandler): void
|
|
203
|
+
cb: ioBroker.ObjectChangeHandler): Promise<void>;
|
|
203
204
|
/**
|
|
204
205
|
* Unsubscribes all or the given callback from changes of the given object.
|
|
205
206
|
*/
|
package/LegacyConnection.js
CHANGED
|
@@ -479,24 +479,26 @@ class Connection {
|
|
|
479
479
|
!this.statesSubscribes[_id].cbs.includes(cb) && this.statesSubscribes[_id].cbs.push(cb);
|
|
480
480
|
}
|
|
481
481
|
}
|
|
482
|
-
if (
|
|
482
|
+
if (!this.connected) {
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
if (toSubscribe.length) {
|
|
483
486
|
// no answer from server required
|
|
484
487
|
this._socket.emit('subscribe', toSubscribe);
|
|
485
488
|
}
|
|
486
|
-
if (
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
.
|
|
491
|
-
.catch(e => console.error(`Cannot getForeignStates "${id}": ${JSON.stringify(e)}`));
|
|
492
|
-
}
|
|
493
|
-
else {
|
|
494
|
-
this._socket.emit(Connection.isWeb() ? 'getStates' : 'getForeignStates', id, (err, states) => {
|
|
495
|
-
err && console.error(`Cannot getForeignStates "${id}": ${JSON.stringify(err)}`);
|
|
496
|
-
states && Object.keys(states).forEach(_id => cb(_id, states[_id]));
|
|
497
|
-
});
|
|
489
|
+
if (binary) {
|
|
490
|
+
for (let i = 0; i < ids.length; i++) {
|
|
491
|
+
this.getBinaryState(ids[i])
|
|
492
|
+
.then((base64) => cb && cb(ids[i], base64))
|
|
493
|
+
.catch(e => console.error(`Cannot getBinaryState "${ids[i]}": ${JSON.stringify(e)}`));
|
|
498
494
|
}
|
|
499
495
|
}
|
|
496
|
+
else {
|
|
497
|
+
this._socket.emit(Connection.isWeb() ? 'getStates' : 'getForeignStates', id, (err, states) => {
|
|
498
|
+
err && console.error(`Cannot getForeignStates "${id}": ${JSON.stringify(err)}`);
|
|
499
|
+
states && Object.keys(states).forEach(_id => cb(_id, states[_id]));
|
|
500
|
+
});
|
|
501
|
+
}
|
|
500
502
|
}
|
|
501
503
|
/**
|
|
502
504
|
* Subscribe to changes of the given state.
|
|
@@ -628,6 +630,7 @@ class Connection {
|
|
|
628
630
|
if (this.connected && toSubscribe.length) {
|
|
629
631
|
this._socket.emit('subscribeObjects', toSubscribe);
|
|
630
632
|
}
|
|
633
|
+
return Promise.resolve();
|
|
631
634
|
}
|
|
632
635
|
/**
|
|
633
636
|
* Unsubscribes all or the given callback from changes of the given object.
|
package/README.md
CHANGED
|
@@ -670,6 +670,9 @@ socket.getObjectViewCustom('custom', 'state', 'startKey', 'endKey')
|
|
|
670
670
|
-->
|
|
671
671
|
|
|
672
672
|
## Changelog
|
|
673
|
+
### 4.13.1 (2024-03-30)
|
|
674
|
+
* (bluefox) used new connection classes
|
|
675
|
+
|
|
673
676
|
### 4.12.3 (2024-03-30)
|
|
674
677
|
* (bluefox) Migrated legacy connection to typescript
|
|
675
678
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iobroker/adapter-react-v5",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.13.1",
|
|
4
4
|
"description": "React classes to develop admin interfaces for ioBroker with react.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Denis Haev (bluefox)",
|
|
@@ -28,19 +28,19 @@
|
|
|
28
28
|
"devDependencies": {},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@emotion/react": "^11.11.4",
|
|
31
|
-
"@emotion/styled": "^11.11.
|
|
31
|
+
"@emotion/styled": "^11.11.5",
|
|
32
32
|
"@iobroker/dm-utils": "^0.1.9",
|
|
33
|
-
"@iobroker/json-config": "^6.
|
|
34
|
-
"@iobroker/socket-client": "^2.
|
|
33
|
+
"@iobroker/json-config": "^6.15.2",
|
|
34
|
+
"@iobroker/socket-client": "^2.4.0",
|
|
35
35
|
"@iobroker/types": "^5.0.19",
|
|
36
36
|
"@iobroker/js-controller-common": "^5.0.19",
|
|
37
37
|
"@iobroker/js-controller-common-db": "^5.0.19",
|
|
38
|
-
"@mui/icons-material": "^5.15.
|
|
38
|
+
"@mui/icons-material": "^5.15.14",
|
|
39
39
|
"@mui/material": "5.14.14",
|
|
40
40
|
"@mui/styles": "5.14.14",
|
|
41
|
-
"@mui/x-date-pickers": "^
|
|
42
|
-
"@sentry/browser": "^7.
|
|
43
|
-
"@sentry/integrations": "^7.
|
|
41
|
+
"@mui/x-date-pickers": "^7.1.0",
|
|
42
|
+
"@sentry/browser": "^7.109.0",
|
|
43
|
+
"@sentry/integrations": "^7.109.0",
|
|
44
44
|
"react-color": "^2.19.3",
|
|
45
45
|
"react-colorful": "^5.6.1",
|
|
46
46
|
"react-cropper": "^2.3.3",
|