motion-master-client 0.0.77 → 0.0.86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +227 -138
- package/package.json +1 -1
- package/src/cli.d.ts +1 -1
- package/src/cli.js +160 -160
- package/src/index.d.ts +30 -28
- package/src/index.js +33 -31
- package/src/index.js.map +1 -1
- package/src/lib/cia402.d.ts +184 -182
- package/src/lib/cia402.js +393 -391
- package/src/lib/cia402.js.map +1 -1
- package/src/lib/config-file.d.ts +13 -13
- package/src/lib/config-file.js +49 -49
- package/src/lib/data-monitoring.d.ts +12 -12
- package/src/lib/data-monitoring.js +33 -33
- package/src/lib/device-log-line.d.ts +5 -5
- package/src/lib/device-log-line.js +2 -2
- package/src/lib/device-parameter.d.ts +56 -56
- package/src/lib/device-parameter.js +38 -38
- package/src/lib/device.d.ts +46 -9
- package/src/lib/device.js +166 -2
- package/src/lib/device.js.map +1 -1
- package/src/lib/encoder-register.d.ts +16 -16
- package/src/lib/encoder-register.js +116 -116
- package/src/lib/hardware-description.d.ts +46 -46
- package/src/lib/hardware-description.js +109 -109
- package/src/lib/integro-encoder-calibration.d.ts +31 -0
- package/src/lib/integro-encoder-calibration.js +196 -0
- package/src/lib/integro-encoder-calibration.js.map +1 -0
- package/src/lib/logger.d.ts +1 -1
- package/src/lib/logger.js +7 -7
- package/src/lib/monitoring-config.d.ts +31 -31
- package/src/lib/monitoring-config.js +2 -2
- package/src/lib/monitoring-entry.d.ts +9 -9
- package/src/lib/monitoring-entry.js +2 -2
- package/src/lib/motion-master-client.d.ts +77 -77
- package/src/lib/motion-master-client.js +196 -196
- package/src/lib/motion-master-pub-sub-client.d.ts +17 -17
- package/src/lib/motion-master-pub-sub-client.js +72 -72
- package/src/lib/motion-master-pub-sub-client.js.map +1 -1
- package/src/lib/motion-master-pub-sub-socket.d.ts +42 -42
- package/src/lib/motion-master-pub-sub-socket.js +2 -2
- package/src/lib/motion-master-pub-sub-web-socket.d.ts +18 -18
- package/src/lib/motion-master-pub-sub-web-socket.js +65 -65
- package/src/lib/motion-master-pub-sub-worker-socket.d.ts +18 -18
- package/src/lib/motion-master-pub-sub-worker-socket.js +47 -47
- package/src/lib/motion-master-req-res-client.d.ts +1104 -1062
- package/src/lib/motion-master-req-res-client.js +2137 -1997
- package/src/lib/motion-master-req-res-client.js.map +1 -1
- package/src/lib/motion-master-req-res-socket.d.ts +60 -60
- package/src/lib/motion-master-req-res-socket.js +2 -2
- package/src/lib/motion-master-req-res-web-socket.d.ts +28 -28
- package/src/lib/motion-master-req-res-web-socket.js +97 -97
- package/src/lib/motion-master-req-res-worker-socket.d.ts +24 -24
- package/src/lib/motion-master-req-res-worker-socket.js +71 -71
- package/src/lib/motion-master.proto.d.ts +5183 -5183
- package/src/lib/motion-master.proto.js +53218 -53218
- package/src/lib/operators.d.ts +20 -20
- package/src/lib/operators.js +82 -83
- package/src/lib/operators.js.map +1 -1
- package/src/lib/options.d.ts +10 -10
- package/src/lib/options.js +13 -13
- package/src/lib/os-command.d.ts +387 -173
- package/src/lib/os-command.js +555 -269
- package/src/lib/os-command.js.map +1 -1
- package/src/lib/parameter.d.ts +156 -138
- package/src/lib/parameter.js +377 -152
- package/src/lib/parameter.js.map +1 -1
- package/src/lib/product-id-range.d.ts +7 -7
- package/src/lib/product-id-range.js +11 -11
- package/src/lib/request-status-resolver.d.ts +4 -4
- package/src/lib/request-status-resolver.js +344 -344
- package/src/lib/somanet-product.d.ts +37 -0
- package/src/lib/somanet-product.js +126 -0
- package/src/lib/somanet-product.js.map +1 -0
- package/src/lib/system-log-line.d.ts +9 -9
- package/src/lib/system-log-line.js +2 -2
- package/src/lib/types.d.ts +141 -141
- package/src/lib/types.js +28 -28
- package/src/lib/urls.d.ts +3 -3
- package/src/lib/urls.js +9 -9
- package/src/lib/util.d.ts +21 -45
- package/src/lib/util.js +113 -379
- package/src/lib/util.js.map +1 -1
- package/src/lib/web-socket-connection-close-codes.d.ts +8 -8
- package/src/lib/web-socket-connection-close-codes.js +88 -88
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MotionMasterPubSubClient = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const uuid_1 = require("uuid");
|
|
6
|
-
const operators_1 = require("./operators");
|
|
7
|
-
const equal = require("fast-deep-equal");
|
|
8
|
-
const motion_master_pub_sub_worker_socket_1 = require("./motion-master-pub-sub-worker-socket");
|
|
9
|
-
class MotionMasterPubSubClient {
|
|
10
|
-
constructor(socket) {
|
|
11
|
-
this.socket = socket;
|
|
12
|
-
this.data$ = new rxjs_1.Subject();
|
|
13
|
-
this.subscriptions = new Map();
|
|
14
|
-
this.notification$ = this.socket.data$.pipe((0, operators_1.selectMotionMasterMessageByTopic)('notification'));
|
|
15
|
-
this.systemEvent$ = this.notification$.pipe((0, operators_1.selectMotionMasterMessageStatusByKey)('systemEvent'));
|
|
16
|
-
this.deviceEvent$ = this.notification$.pipe((0, operators_1.selectMotionMasterMessageStatusByKey)('deviceEvent'));
|
|
17
|
-
}
|
|
18
|
-
get messageIds() {
|
|
19
|
-
return Array.from(this.subscriptions.keys());
|
|
20
|
-
}
|
|
21
|
-
subscribe(config) {
|
|
22
|
-
var _a;
|
|
23
|
-
const messageId = (_a = config.messageId) !== null && _a !== void 0 ? _a : (0, uuid_1.v4)();
|
|
24
|
-
if (!config.messageId) {
|
|
25
|
-
config = Object.assign(Object.assign({}, config), { messageId });
|
|
26
|
-
}
|
|
27
|
-
if (this.socket instanceof motion_master_pub_sub_worker_socket_1.MotionMasterPubSubWorkerSocket) {
|
|
28
|
-
this.socket.worker.postMessage({ subscribe: config });
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
const { bufferSize = 1, distinct = false, topic } = config;
|
|
32
|
-
let observable = this.socket.data$.pipe((0, rxjs_1.filter)((data) => data[0] === topic), (0, rxjs_1.map)((data) => data[1]));
|
|
33
|
-
if (distinct) {
|
|
34
|
-
observable = observable.pipe((0, rxjs_1.distinctUntilChanged)((prev, curr) => {
|
|
35
|
-
var _a, _b, _c, _d, _e, _f;
|
|
36
|
-
if (((_c = (_b = (_a = prev === null || prev === void 0 ? void 0 : prev.status) === null || _a === void 0 ? void 0 : _a.monitoringParameterValues) === null || _b === void 0 ? void 0 : _b.deviceParameterValues) === null || _c === void 0 ? void 0 : _c.parameterValues)
|
|
37
|
-
&& ((_f = (_e = (_d = curr === null || curr === void 0 ? void 0 : curr.status) === null || _d === void 0 ? void 0 : _d.monitoringParameterValues) === null || _e === void 0 ? void 0 : _e.deviceParameterValues) === null || _f === void 0 ? void 0 : _f.parameterValues)) {
|
|
38
|
-
return equal(prev.status.monitoringParameterValues.deviceParameterValues.parameterValues, curr.status.monitoringParameterValues.deviceParameterValues.parameterValues);
|
|
39
|
-
}
|
|
40
|
-
return false;
|
|
41
|
-
}));
|
|
42
|
-
}
|
|
43
|
-
const subscription = observable.pipe((0, rxjs_1.bufferCount)(bufferSize)).subscribe((data) => {
|
|
44
|
-
this.data$.next([topic, data]);
|
|
45
|
-
});
|
|
46
|
-
this.subscriptions.set(messageId, subscription);
|
|
47
|
-
}
|
|
48
|
-
return messageId;
|
|
49
|
-
}
|
|
50
|
-
unsubscribe(messageId) {
|
|
51
|
-
if (this.socket instanceof motion_master_pub_sub_worker_socket_1.MotionMasterPubSubWorkerSocket) {
|
|
52
|
-
this.socket.worker.postMessage({ unsubcribe: { messageId } });
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
const subscription = this.subscriptions.get(messageId);
|
|
56
|
-
if (subscription) {
|
|
57
|
-
subscription.unsubscribe();
|
|
58
|
-
this.subscriptions.delete(messageId);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
unsubscribeAll() {
|
|
63
|
-
if (this.socket instanceof motion_master_pub_sub_worker_socket_1.MotionMasterPubSubWorkerSocket) {
|
|
64
|
-
this.socket.worker.postMessage({ unsubscribeAll: true });
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
this.subscriptions.forEach((subscription) => subscription.unsubscribe());
|
|
68
|
-
this.subscriptions.clear();
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
exports.MotionMasterPubSubClient = MotionMasterPubSubClient;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MotionMasterPubSubClient = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const uuid_1 = require("uuid");
|
|
6
|
+
const operators_1 = require("./operators");
|
|
7
|
+
const equal = require("fast-deep-equal");
|
|
8
|
+
const motion_master_pub_sub_worker_socket_1 = require("./motion-master-pub-sub-worker-socket");
|
|
9
|
+
class MotionMasterPubSubClient {
|
|
10
|
+
constructor(socket) {
|
|
11
|
+
this.socket = socket;
|
|
12
|
+
this.data$ = new rxjs_1.Subject();
|
|
13
|
+
this.subscriptions = new Map();
|
|
14
|
+
this.notification$ = this.socket.data$.pipe((0, operators_1.selectMotionMasterMessageByTopic)('notification'));
|
|
15
|
+
this.systemEvent$ = this.notification$.pipe((0, operators_1.selectMotionMasterMessageStatusByKey)('systemEvent'));
|
|
16
|
+
this.deviceEvent$ = this.notification$.pipe((0, operators_1.selectMotionMasterMessageStatusByKey)('deviceEvent'));
|
|
17
|
+
}
|
|
18
|
+
get messageIds() {
|
|
19
|
+
return Array.from(this.subscriptions.keys());
|
|
20
|
+
}
|
|
21
|
+
subscribe(config) {
|
|
22
|
+
var _a;
|
|
23
|
+
const messageId = (_a = config.messageId) !== null && _a !== void 0 ? _a : (0, uuid_1.v4)();
|
|
24
|
+
if (!config.messageId) {
|
|
25
|
+
config = Object.assign(Object.assign({}, config), { messageId });
|
|
26
|
+
}
|
|
27
|
+
if (this.socket instanceof motion_master_pub_sub_worker_socket_1.MotionMasterPubSubWorkerSocket) {
|
|
28
|
+
this.socket.worker.postMessage({ subscribe: config });
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
const { bufferSize = 1, distinct = false, topic } = config;
|
|
32
|
+
let observable = this.socket.data$.pipe((0, rxjs_1.filter)((data) => data[0] === topic), (0, rxjs_1.map)((data) => data[1]));
|
|
33
|
+
if (distinct) {
|
|
34
|
+
observable = observable.pipe((0, rxjs_1.distinctUntilChanged)((prev, curr) => {
|
|
35
|
+
var _a, _b, _c, _d, _e, _f;
|
|
36
|
+
if (((_c = (_b = (_a = prev === null || prev === void 0 ? void 0 : prev.status) === null || _a === void 0 ? void 0 : _a.monitoringParameterValues) === null || _b === void 0 ? void 0 : _b.deviceParameterValues) === null || _c === void 0 ? void 0 : _c.parameterValues)
|
|
37
|
+
&& ((_f = (_e = (_d = curr === null || curr === void 0 ? void 0 : curr.status) === null || _d === void 0 ? void 0 : _d.monitoringParameterValues) === null || _e === void 0 ? void 0 : _e.deviceParameterValues) === null || _f === void 0 ? void 0 : _f.parameterValues)) {
|
|
38
|
+
return equal(prev.status.monitoringParameterValues.deviceParameterValues.parameterValues, curr.status.monitoringParameterValues.deviceParameterValues.parameterValues);
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
const subscription = observable.pipe((0, rxjs_1.bufferCount)(bufferSize)).subscribe((data) => {
|
|
44
|
+
this.data$.next([topic, data]);
|
|
45
|
+
});
|
|
46
|
+
this.subscriptions.set(messageId, subscription);
|
|
47
|
+
}
|
|
48
|
+
return messageId;
|
|
49
|
+
}
|
|
50
|
+
unsubscribe(messageId) {
|
|
51
|
+
if (this.socket instanceof motion_master_pub_sub_worker_socket_1.MotionMasterPubSubWorkerSocket) {
|
|
52
|
+
this.socket.worker.postMessage({ unsubcribe: { messageId } });
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
const subscription = this.subscriptions.get(messageId);
|
|
56
|
+
if (subscription) {
|
|
57
|
+
subscription.unsubscribe();
|
|
58
|
+
this.subscriptions.delete(messageId);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
unsubscribeAll() {
|
|
63
|
+
if (this.socket instanceof motion_master_pub_sub_worker_socket_1.MotionMasterPubSubWorkerSocket) {
|
|
64
|
+
this.socket.worker.postMessage({ unsubscribeAll: true });
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
this.subscriptions.forEach((subscription) => subscription.unsubscribe());
|
|
68
|
+
this.subscriptions.clear();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.MotionMasterPubSubClient = MotionMasterPubSubClient;
|
|
73
73
|
//# sourceMappingURL=motion-master-pub-sub-client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"motion-master-pub-sub-client.js","sourceRoot":"","sources":["../../../../../libs/motion-master-client/src/lib/motion-master-pub-sub-client.ts"],"names":[],"mappings":";;;AAAA,+BAAyG;AACzG,+BAA0B;AAG1B,2CAAqG;AAErG,yCAAyC;AACzC,+FAAuF;AAEvF,MAAa,wBAAwB;IAkBnC,YACkB,MAAgC;QAAhC,WAAM,GAAN,MAAM,CAA0B;QAjBzC,UAAK,GAAG,IAAI,cAAO,EAAoC,CAAC;QAEzD,kBAAa,GAAG,IAAI,GAAG,EAAwB,CAAC;QAE/C,kBAAa,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAC7C,IAAA,4CAAgC,EAAC,cAAc,CAAC,CACjD,CAAC;QAEO,iBAAY,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAC7C,IAAA,gDAAoC,EAA0C,aAAa,CAAC,CAC7F,CAAC;QAEO,iBAAY,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAC7C,IAAA,gDAAoC,EAA0C,aAAa,CAAC,CAC7F,CAAC;IAIE,CAAC;IAEL,IAAI,UAAU;QACZ,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa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AC3E,IAAI,CAAC,MAAM,CAAC,yBAAyB,CAAC,qBAAqB,CAAC,eAAe,CAC5E,
|
|
1
|
+
{"version":3,"file":"motion-master-pub-sub-client.js","sourceRoot":"","sources":["../../../../../libs/motion-master-client/src/lib/motion-master-pub-sub-client.ts"],"names":[],"mappings":";;;AAAA,+BAAyG;AACzG,+BAA0B;AAG1B,2CAAqG;AAErG,yCAAyC;AACzC,+FAAuF;AAEvF,MAAa,wBAAwB;IAkBnC,YACkB,MAAgC;QAAhC,WAAM,GAAN,MAAM,CAA0B;QAjBzC,UAAK,GAAG,IAAI,cAAO,EAAoC,CAAC;QAEzD,kBAAa,GAAG,IAAI,GAAG,EAAwB,CAAC;QAE/C,kBAAa,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAC7C,IAAA,4CAAgC,EAAC,cAAc,CAAC,CACjD,CAAC;QAEO,iBAAY,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAC7C,IAAA,gDAAoC,EAA0C,aAAa,CAAC,CAC7F,CAAC;QAEO,iBAAY,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAC7C,IAAA,gDAAoC,EAA0C,aAAa,CAAC,CAC7F,CAAC;IAIE,CAAC;IAEL,IAAI,UAAU;QACZ,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC;IAC/C,CAAC;IAED,SAAS,CAAC,MAAwB;;QAChC,MAAM,SAAS,GAAG,MAAA,MAAM,CAAC,SAAS,mCAAI,IAAA,SAAE,GAAE,CAAC;QAC3C,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE;YACrB,MAAM,mCAAQ,MAAM,KAAE,SAAS,GAAE,CAAC;SACnC;QAED,IAAI,IAAI,CAAC,MAAM,YAAY,oEAA8B,EAAE;YACzD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC;S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aAAa,CAAC,GAAG,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;SACjD;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,WAAW,CAAC,SAAiB;QAC3B,IAAI,IAAI,CAAC,MAAM,YAAY,oEAA8B,EAAE;YACzD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,UAAU,EAAE,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;SAC/D;aAAM;YACL,MAAM,YAAY,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YACvD,IAAI,YAAY,EAAE;gBAChB,YAAY,CAAC,WAAW,EAAE,CAAC;gBAC3B,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;aACtC;SACF;IACH,CAAC;IAED,cAAc;QACZ,IAAI,IAAI,CAAC,MAAM,YAAY,oEAA8B,EAAE;YACzD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC;SAC1D;aAAM;YACL,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC,CAAC;YACzE,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;SAC5B;IACH,CAAC;CAEF;AA1FD,4DA0FC"}
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import { BehaviorSubject, Observable } from "rxjs";
|
|
2
|
-
import { IMotionMasterMessage } from "./types";
|
|
3
|
-
export interface MotionMasterPubSubSocket {
|
|
4
|
-
/**
|
|
5
|
-
* Emits a boolean value when socket gets opened or closed.
|
|
6
|
-
*/
|
|
7
|
-
readonly opened$: BehaviorSubject<boolean>;
|
|
8
|
-
/**
|
|
9
|
-
* Emits close events with code and reason data.
|
|
10
|
-
* @link https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close_event
|
|
11
|
-
*/
|
|
12
|
-
readonly close$: Observable<{
|
|
13
|
-
code: number;
|
|
14
|
-
reason: string;
|
|
15
|
-
}>;
|
|
16
|
-
/**
|
|
17
|
-
* Incoming data is a tuple of topic and decoded message.
|
|
18
|
-
*/
|
|
19
|
-
readonly data$: Observable<[string, IMotionMasterMessage]>;
|
|
20
|
-
/**
|
|
21
|
-
* URL set in call to open.
|
|
22
|
-
*/
|
|
23
|
-
get url(): string | undefined;
|
|
24
|
-
/**
|
|
25
|
-
* Open socket.
|
|
26
|
-
*
|
|
27
|
-
* The connected$ and eventually alive$ observables will emit true values.
|
|
28
|
-
*/
|
|
29
|
-
open(url: string): void;
|
|
30
|
-
/**
|
|
31
|
-
* Reopen socket.
|
|
32
|
-
*
|
|
33
|
-
* Reopen if closed using the same url previously set in open.
|
|
34
|
-
*/
|
|
35
|
-
reopen(): void;
|
|
36
|
-
/**
|
|
37
|
-
* Close socket.
|
|
38
|
-
*
|
|
39
|
-
* The opened$ and alive$ observables will emit false values.
|
|
40
|
-
*/
|
|
41
|
-
close(): void;
|
|
42
|
-
}
|
|
1
|
+
import { BehaviorSubject, Observable } from "rxjs";
|
|
2
|
+
import { IMotionMasterMessage } from "./types";
|
|
3
|
+
export interface MotionMasterPubSubSocket {
|
|
4
|
+
/**
|
|
5
|
+
* Emits a boolean value when socket gets opened or closed.
|
|
6
|
+
*/
|
|
7
|
+
readonly opened$: BehaviorSubject<boolean>;
|
|
8
|
+
/**
|
|
9
|
+
* Emits close events with code and reason data.
|
|
10
|
+
* @link https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close_event
|
|
11
|
+
*/
|
|
12
|
+
readonly close$: Observable<{
|
|
13
|
+
code: number;
|
|
14
|
+
reason: string;
|
|
15
|
+
}>;
|
|
16
|
+
/**
|
|
17
|
+
* Incoming data is a tuple of topic and decoded message.
|
|
18
|
+
*/
|
|
19
|
+
readonly data$: Observable<[string, IMotionMasterMessage]>;
|
|
20
|
+
/**
|
|
21
|
+
* URL set in call to open.
|
|
22
|
+
*/
|
|
23
|
+
get url(): string | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Open socket.
|
|
26
|
+
*
|
|
27
|
+
* The connected$ and eventually alive$ observables will emit true values.
|
|
28
|
+
*/
|
|
29
|
+
open(url: string): void;
|
|
30
|
+
/**
|
|
31
|
+
* Reopen socket.
|
|
32
|
+
*
|
|
33
|
+
* Reopen if closed using the same url previously set in open.
|
|
34
|
+
*/
|
|
35
|
+
reopen(): void;
|
|
36
|
+
/**
|
|
37
|
+
* Close socket.
|
|
38
|
+
*
|
|
39
|
+
* The opened$ and alive$ observables will emit false values.
|
|
40
|
+
*/
|
|
41
|
+
close(): void;
|
|
42
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
//# sourceMappingURL=motion-master-pub-sub-socket.js.map
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { BehaviorSubject, Subject } from "rxjs";
|
|
2
|
-
import { MotionMasterPubSubSocket } from "./motion-master-pub-sub-socket";
|
|
3
|
-
import { IMotionMasterMessage } from "./types";
|
|
4
|
-
export declare class MotionMasterPubSubWebSocket implements MotionMasterPubSubSocket {
|
|
5
|
-
readonly opened$: BehaviorSubject<boolean>;
|
|
6
|
-
readonly close$: Subject<{
|
|
7
|
-
code: number;
|
|
8
|
-
reason: string;
|
|
9
|
-
}>;
|
|
10
|
-
readonly data$: Subject<[string, IMotionMasterMessage]>;
|
|
11
|
-
private webSocket$?;
|
|
12
|
-
private _url?;
|
|
13
|
-
get url(): string | undefined;
|
|
14
|
-
open(url: string): void;
|
|
15
|
-
close(): void;
|
|
16
|
-
reopen(): void;
|
|
17
|
-
private createWebSocket;
|
|
18
|
-
}
|
|
1
|
+
import { BehaviorSubject, Subject } from "rxjs";
|
|
2
|
+
import { MotionMasterPubSubSocket } from "./motion-master-pub-sub-socket";
|
|
3
|
+
import { IMotionMasterMessage } from "./types";
|
|
4
|
+
export declare class MotionMasterPubSubWebSocket implements MotionMasterPubSubSocket {
|
|
5
|
+
readonly opened$: BehaviorSubject<boolean>;
|
|
6
|
+
readonly close$: Subject<{
|
|
7
|
+
code: number;
|
|
8
|
+
reason: string;
|
|
9
|
+
}>;
|
|
10
|
+
readonly data$: Subject<[string, IMotionMasterMessage]>;
|
|
11
|
+
private webSocket$?;
|
|
12
|
+
private _url?;
|
|
13
|
+
get url(): string | undefined;
|
|
14
|
+
open(url: string): void;
|
|
15
|
+
close(): void;
|
|
16
|
+
reopen(): void;
|
|
17
|
+
private createWebSocket;
|
|
18
|
+
}
|
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MotionMasterPubSubWebSocket = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const webSocket_1 = require("rxjs/webSocket");
|
|
6
|
-
const logger_1 = require("./logger");
|
|
7
|
-
const types_1 = require("./types");
|
|
8
|
-
const util_1 = require("./util");
|
|
9
|
-
class MotionMasterPubSubWebSocket {
|
|
10
|
-
constructor() {
|
|
11
|
-
this.opened$ = new rxjs_1.BehaviorSubject(false);
|
|
12
|
-
this.close$ = new rxjs_1.Subject();
|
|
13
|
-
this.data$ = new rxjs_1.Subject();
|
|
14
|
-
}
|
|
15
|
-
get url() {
|
|
16
|
-
return this._url;
|
|
17
|
-
}
|
|
18
|
-
open(url) {
|
|
19
|
-
this._url = url;
|
|
20
|
-
this.webSocket$ = this.createWebSocket(url);
|
|
21
|
-
this.webSocket$.subscribe({
|
|
22
|
-
next: (value) => this.data$.next(value),
|
|
23
|
-
error: () => {
|
|
24
|
-
// ignore, clients will receive close$ event instead
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
close() {
|
|
29
|
-
var _a;
|
|
30
|
-
(_a = this.webSocket$) === null || _a === void 0 ? void 0 : _a.complete();
|
|
31
|
-
}
|
|
32
|
-
reopen() {
|
|
33
|
-
if (this.url && this.opened$.value === false) {
|
|
34
|
-
this.open(this.url);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
createWebSocket(url) {
|
|
38
|
-
const decoder = new TextDecoder('utf-8');
|
|
39
|
-
const webSocketConfig = {
|
|
40
|
-
binaryType: 'arraybuffer',
|
|
41
|
-
closeObserver: {
|
|
42
|
-
next: (ev) => {
|
|
43
|
-
this.opened$.next(false);
|
|
44
|
-
this.close$.next({ code: ev.code, reason: ev.reason });
|
|
45
|
-
logger_1.logger.info(`Connection closed ${url}`);
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
deserializer: (e) => {
|
|
49
|
-
const end = new Uint8Array(e.data, 0, 1)[0] + 1;
|
|
50
|
-
const topic = decoder.decode(e.data.slice(1, end)); // topic starts from the 2nd byte
|
|
51
|
-
const message = types_1.MotionMasterMessage.decode(new Uint8Array(e.data.slice(end)));
|
|
52
|
-
return [topic, (0, util_1.createPlainObjectFromMotionMasterMessage)(message)];
|
|
53
|
-
},
|
|
54
|
-
openObserver: {
|
|
55
|
-
next: () => {
|
|
56
|
-
this.opened$.next(true);
|
|
57
|
-
logger_1.logger.info(`Connection opened ${url}`);
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
url,
|
|
61
|
-
};
|
|
62
|
-
return (0, webSocket_1.webSocket)(webSocketConfig);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
exports.MotionMasterPubSubWebSocket = MotionMasterPubSubWebSocket;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MotionMasterPubSubWebSocket = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const webSocket_1 = require("rxjs/webSocket");
|
|
6
|
+
const logger_1 = require("./logger");
|
|
7
|
+
const types_1 = require("./types");
|
|
8
|
+
const util_1 = require("./util");
|
|
9
|
+
class MotionMasterPubSubWebSocket {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.opened$ = new rxjs_1.BehaviorSubject(false);
|
|
12
|
+
this.close$ = new rxjs_1.Subject();
|
|
13
|
+
this.data$ = new rxjs_1.Subject();
|
|
14
|
+
}
|
|
15
|
+
get url() {
|
|
16
|
+
return this._url;
|
|
17
|
+
}
|
|
18
|
+
open(url) {
|
|
19
|
+
this._url = url;
|
|
20
|
+
this.webSocket$ = this.createWebSocket(url);
|
|
21
|
+
this.webSocket$.subscribe({
|
|
22
|
+
next: (value) => this.data$.next(value),
|
|
23
|
+
error: () => {
|
|
24
|
+
// ignore, clients will receive close$ event instead
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
close() {
|
|
29
|
+
var _a;
|
|
30
|
+
(_a = this.webSocket$) === null || _a === void 0 ? void 0 : _a.complete();
|
|
31
|
+
}
|
|
32
|
+
reopen() {
|
|
33
|
+
if (this.url && this.opened$.value === false) {
|
|
34
|
+
this.open(this.url);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
createWebSocket(url) {
|
|
38
|
+
const decoder = new TextDecoder('utf-8');
|
|
39
|
+
const webSocketConfig = {
|
|
40
|
+
binaryType: 'arraybuffer',
|
|
41
|
+
closeObserver: {
|
|
42
|
+
next: (ev) => {
|
|
43
|
+
this.opened$.next(false);
|
|
44
|
+
this.close$.next({ code: ev.code, reason: ev.reason });
|
|
45
|
+
logger_1.logger.info(`Connection closed ${url}`);
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
deserializer: (e) => {
|
|
49
|
+
const end = new Uint8Array(e.data, 0, 1)[0] + 1;
|
|
50
|
+
const topic = decoder.decode(e.data.slice(1, end)); // topic starts from the 2nd byte
|
|
51
|
+
const message = types_1.MotionMasterMessage.decode(new Uint8Array(e.data.slice(end)));
|
|
52
|
+
return [topic, (0, util_1.createPlainObjectFromMotionMasterMessage)(message)];
|
|
53
|
+
},
|
|
54
|
+
openObserver: {
|
|
55
|
+
next: () => {
|
|
56
|
+
this.opened$.next(true);
|
|
57
|
+
logger_1.logger.info(`Connection opened ${url}`);
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
url,
|
|
61
|
+
};
|
|
62
|
+
return (0, webSocket_1.webSocket)(webSocketConfig);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.MotionMasterPubSubWebSocket = MotionMasterPubSubWebSocket;
|
|
66
66
|
//# sourceMappingURL=motion-master-pub-sub-web-socket.js.map
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { BehaviorSubject, Subject } from "rxjs";
|
|
2
|
-
import { MotionMasterPubSubSocket } from "./motion-master-pub-sub-socket";
|
|
3
|
-
import { IMotionMasterMessage } from "./types";
|
|
4
|
-
export declare class MotionMasterPubSubWorkerSocket implements MotionMasterPubSubSocket {
|
|
5
|
-
readonly worker: Worker;
|
|
6
|
-
opened$: BehaviorSubject<boolean>;
|
|
7
|
-
close$: Subject<{
|
|
8
|
-
code: number;
|
|
9
|
-
reason: string;
|
|
10
|
-
}>;
|
|
11
|
-
data$: Subject<[string, IMotionMasterMessage]>;
|
|
12
|
-
private _url?;
|
|
13
|
-
constructor(worker: Worker);
|
|
14
|
-
get url(): string | undefined;
|
|
15
|
-
open(url: string): void;
|
|
16
|
-
close(): void;
|
|
17
|
-
reopen(): void;
|
|
18
|
-
}
|
|
1
|
+
import { BehaviorSubject, Subject } from "rxjs";
|
|
2
|
+
import { MotionMasterPubSubSocket } from "./motion-master-pub-sub-socket";
|
|
3
|
+
import { IMotionMasterMessage } from "./types";
|
|
4
|
+
export declare class MotionMasterPubSubWorkerSocket implements MotionMasterPubSubSocket {
|
|
5
|
+
readonly worker: Worker;
|
|
6
|
+
opened$: BehaviorSubject<boolean>;
|
|
7
|
+
close$: Subject<{
|
|
8
|
+
code: number;
|
|
9
|
+
reason: string;
|
|
10
|
+
}>;
|
|
11
|
+
data$: Subject<[string, IMotionMasterMessage]>;
|
|
12
|
+
private _url?;
|
|
13
|
+
constructor(worker: Worker);
|
|
14
|
+
get url(): string | undefined;
|
|
15
|
+
open(url: string): void;
|
|
16
|
+
close(): void;
|
|
17
|
+
reopen(): void;
|
|
18
|
+
}
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MotionMasterPubSubWorkerSocket = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const logger_1 = require("./logger");
|
|
6
|
-
class MotionMasterPubSubWorkerSocket {
|
|
7
|
-
constructor(worker) {
|
|
8
|
-
this.worker = worker;
|
|
9
|
-
this.opened$ = new rxjs_1.BehaviorSubject(false);
|
|
10
|
-
this.close$ = new rxjs_1.Subject();
|
|
11
|
-
this.data$ = new rxjs_1.Subject();
|
|
12
|
-
}
|
|
13
|
-
get url() {
|
|
14
|
-
return this._url;
|
|
15
|
-
}
|
|
16
|
-
open(url) {
|
|
17
|
-
this._url = url;
|
|
18
|
-
this.worker.onmessage = ({ data }) => {
|
|
19
|
-
if ('opened' in data) {
|
|
20
|
-
const { opened } = data;
|
|
21
|
-
this.opened$.next(opened);
|
|
22
|
-
logger_1.logger.info(opened ? `Opened pub/sub 🔌 ${url}` : `Closed pub/sub 🔌 ${url}`);
|
|
23
|
-
}
|
|
24
|
-
else if ('topic' in data) {
|
|
25
|
-
const { topic, messages } = data;
|
|
26
|
-
messages.forEach((message) => this.data$.next([topic, message]));
|
|
27
|
-
}
|
|
28
|
-
else if ('close' in data) {
|
|
29
|
-
const { close } = data;
|
|
30
|
-
this.close$.next(close);
|
|
31
|
-
logger_1.logger.info(`Close event received on pub/sub 🔌 ${url} ${JSON.stringify(close)}`);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
this.worker.postMessage({
|
|
35
|
-
open: { url }
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
close() {
|
|
39
|
-
this.worker.postMessage({ close: true });
|
|
40
|
-
}
|
|
41
|
-
reopen() {
|
|
42
|
-
if (this.url && this.opened$.value === false) {
|
|
43
|
-
this.open(this.url);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
exports.MotionMasterPubSubWorkerSocket = MotionMasterPubSubWorkerSocket;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MotionMasterPubSubWorkerSocket = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const logger_1 = require("./logger");
|
|
6
|
+
class MotionMasterPubSubWorkerSocket {
|
|
7
|
+
constructor(worker) {
|
|
8
|
+
this.worker = worker;
|
|
9
|
+
this.opened$ = new rxjs_1.BehaviorSubject(false);
|
|
10
|
+
this.close$ = new rxjs_1.Subject();
|
|
11
|
+
this.data$ = new rxjs_1.Subject();
|
|
12
|
+
}
|
|
13
|
+
get url() {
|
|
14
|
+
return this._url;
|
|
15
|
+
}
|
|
16
|
+
open(url) {
|
|
17
|
+
this._url = url;
|
|
18
|
+
this.worker.onmessage = ({ data }) => {
|
|
19
|
+
if ('opened' in data) {
|
|
20
|
+
const { opened } = data;
|
|
21
|
+
this.opened$.next(opened);
|
|
22
|
+
logger_1.logger.info(opened ? `Opened pub/sub 🔌 ${url}` : `Closed pub/sub 🔌 ${url}`);
|
|
23
|
+
}
|
|
24
|
+
else if ('topic' in data) {
|
|
25
|
+
const { topic, messages } = data;
|
|
26
|
+
messages.forEach((message) => this.data$.next([topic, message]));
|
|
27
|
+
}
|
|
28
|
+
else if ('close' in data) {
|
|
29
|
+
const { close } = data;
|
|
30
|
+
this.close$.next(close);
|
|
31
|
+
logger_1.logger.info(`Close event received on pub/sub 🔌 ${url} ${JSON.stringify(close)}`);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
this.worker.postMessage({
|
|
35
|
+
open: { url }
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
close() {
|
|
39
|
+
this.worker.postMessage({ close: true });
|
|
40
|
+
}
|
|
41
|
+
reopen() {
|
|
42
|
+
if (this.url && this.opened$.value === false) {
|
|
43
|
+
this.open(this.url);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.MotionMasterPubSubWorkerSocket = MotionMasterPubSubWorkerSocket;
|
|
48
48
|
//# sourceMappingURL=motion-master-pub-sub-worker-socket.js.map
|