@dronedeploy/rocos-js-sdk 4.4.4 → 4.4.5
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/LICENSE +3 -0
- package/cjs/api/StreamRegister.d.ts +18 -3
- package/cjs/api/StreamRegister.js +71 -38
- package/cjs/api/atoms/StreamHeartbeat.js +2 -2
- package/cjs/api/streams/telemetry/TelemetryStreamAbstract.d.ts +8 -1
- package/cjs/api/streams/telemetry/TelemetryStreamAbstract.js +83 -40
- package/cjs/api/streams/webRTCSignalling/WebRTCSignallingStreamAbstract.js +1 -1
- package/cjs/constants/api.d.ts +3 -2
- package/cjs/constants/api.js +5 -4
- package/cjs/constants/identifier.d.ts +1 -0
- package/cjs/constants/identifier.js +2 -1
- package/cjs/helpers/getUniqueId.js +2 -1
- package/cjs/models/callsigns/CallsignsLookup.d.ts +4 -0
- package/cjs/models/callsigns/CallsignsLookup.js +19 -0
- package/cjs/services/AssetStorageService.js +6 -1
- package/cjs/services/BaseServiceAbstract.js +1 -1
- package/cjs/services/BaseStreamService.d.ts +12 -1
- package/cjs/services/BaseStreamService.js +19 -30
- package/cjs/services/EnvironmentService.d.ts +4 -0
- package/cjs/services/EnvironmentService.js +5 -1
- package/cjs/services/MapService.d.ts +15 -3
- package/cjs/services/MapService.js +25 -13
- package/cjs/services/SearchService.js +1 -1
- package/cjs/services/TargetService.js +2 -2
- package/cjs/services/TelemetryService.d.ts +1 -1
- package/cjs/services/TelemetryService.js +29 -22
- package/cjs/services/WebRTCSignallingService.js +7 -9
- package/esm/api/StreamRegister.d.ts +18 -3
- package/esm/api/StreamRegister.js +71 -38
- package/esm/api/atoms/StreamHeartbeat.js +2 -2
- package/esm/api/streams/telemetry/TelemetryStreamAbstract.d.ts +8 -1
- package/esm/api/streams/telemetry/TelemetryStreamAbstract.js +84 -41
- package/esm/api/streams/webRTCSignalling/WebRTCSignallingStreamAbstract.js +2 -2
- package/esm/constants/api.d.ts +3 -2
- package/esm/constants/api.js +3 -2
- package/esm/constants/identifier.d.ts +1 -0
- package/esm/constants/identifier.js +1 -0
- package/esm/helpers/getUniqueId.js +2 -1
- package/esm/models/callsigns/CallsignsLookup.d.ts +4 -0
- package/esm/models/callsigns/CallsignsLookup.js +19 -0
- package/esm/services/AssetStorageService.js +6 -1
- package/esm/services/BaseServiceAbstract.js +1 -1
- package/esm/services/BaseStreamService.d.ts +12 -1
- package/esm/services/BaseStreamService.js +19 -30
- package/esm/services/EnvironmentService.d.ts +4 -0
- package/esm/services/EnvironmentService.js +5 -1
- package/esm/services/MapService.d.ts +15 -3
- package/esm/services/MapService.js +26 -14
- package/esm/services/SearchService.js +2 -2
- package/esm/services/TargetService.js +3 -3
- package/esm/services/TelemetryService.d.ts +1 -1
- package/esm/services/TelemetryService.js +30 -23
- package/esm/services/WebRTCSignallingService.js +8 -10
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { API_GRAPHS_ASSETS_UPLOAD_URL, API_GRAPHS_ASSETS_URL, API_GRAPHS_TARGETS_URL, API_GRAPHS_TARGET_UPLOAD_URL, } from '../constants/api';
|
|
1
|
+
import { API_GRAPHS_ASSETS_UPLOAD_URL, API_GRAPHS_ASSETS_URL, API_GRAPHS_TARGETS_URL, API_GRAPHS_TARGET_MEDIA_URL, API_GRAPHS_TARGET_UPLOAD_URL, } from '../constants/api';
|
|
2
2
|
import { RocosError, errorCodes } from '../models';
|
|
3
3
|
import { BaseServiceAbstract } from './BaseServiceAbstract';
|
|
4
4
|
import { RocosLogger } from '../logger/RocosLogger';
|
|
@@ -53,10 +53,10 @@ export class TargetService extends BaseServiceAbstract {
|
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
55
|
async addMedia(projectId, targetId, media) {
|
|
56
|
-
await this.
|
|
56
|
+
await this.callPut(formatServiceUrl(API_GRAPHS_TARGET_MEDIA_URL, {
|
|
57
57
|
url: this.config.url,
|
|
58
58
|
projectId,
|
|
59
|
-
targetId,
|
|
59
|
+
targetId: encodeURIComponent(targetId),
|
|
60
60
|
}, this.config.insecure), media, 'Failed to add media to a target');
|
|
61
61
|
}
|
|
62
62
|
}
|
|
@@ -46,6 +46,6 @@ export declare class TelemetryService extends BaseStreamService<ITelemetryStream
|
|
|
46
46
|
monitorTelemetryWithTimeout(projectId: string, callsign: string, source: string, heartbeatTimeoutMs?: number, intervalMs?: number): Observable<TelemetryMonitorStatus>;
|
|
47
47
|
protected initStream(stream: ITelemetryStream): Promise<void>;
|
|
48
48
|
private buildScope;
|
|
49
|
-
private
|
|
49
|
+
private buildStreamConfig;
|
|
50
50
|
protected getStream(config: ITelemetryStreamConfig): ITelemetryStream;
|
|
51
51
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BehaviorSubject, catchError, combineLatest, defer, distinctUntilChanged, from, interval, map, mergeAll, of, startWith, } from 'rxjs';
|
|
2
|
-
import { CallsignStatus, CallsignsLookup,
|
|
2
|
+
import { CallsignStatus, CallsignsLookup, RocosError, SubscriberStatusEnum, TelemetryMonitorStatus, errorCodes, } from '../models';
|
|
3
3
|
import { filter, finalize } from 'rxjs/operators';
|
|
4
4
|
import { BaseStreamService } from './BaseStreamService';
|
|
5
5
|
import { IDENTIFIER_NAME_TELEMETRY } from '../constants/identifier';
|
|
@@ -52,20 +52,33 @@ export class TelemetryService extends BaseStreamService {
|
|
|
52
52
|
// scope is used as a key to generate unique streams
|
|
53
53
|
// ideally there should be just one concurrent stream opened
|
|
54
54
|
const scope = this.buildScope(params, callsignsLookup);
|
|
55
|
-
const callsigns = callsignsLookup.lookupValue;
|
|
56
55
|
const subscriptionParams = {
|
|
57
56
|
uniqueId: getUniqueId(params.projectId, callsignsLookup, sources, scope),
|
|
58
|
-
callsigns: callsignsLookup
|
|
57
|
+
callsigns: callsignsLookup.getCallsigns(),
|
|
59
58
|
sources,
|
|
60
59
|
};
|
|
61
60
|
// `defer` acquires the stream only when subscribed; `finalize` releases it on unsubscribe, error
|
|
62
|
-
// and complete — so acquire and release stay balanced on every path.
|
|
61
|
+
// and complete — so acquire and release stay balanced on every path. The registry refcount taken
|
|
62
|
+
// here keeps the stream alive until the finalize, so everything in between is race-free.
|
|
63
63
|
return defer(() => {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
acquired = stream;
|
|
64
|
+
const { stream, isNew, ready, release } = this.acquireStream(IDENTIFIER_NAME_TELEMETRY, this.buildStreamConfig(params.projectId, callsignsLookup, sources, scope));
|
|
65
|
+
try {
|
|
67
66
|
stream.addSubscription(subscriptionParams);
|
|
68
|
-
|
|
67
|
+
if (!isNew) {
|
|
68
|
+
stream.statusStream$.subscribe((msg) => {
|
|
69
|
+
this.streamStatusSubject$.next({
|
|
70
|
+
scope,
|
|
71
|
+
status: msg,
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
catch (e) {
|
|
77
|
+
// finalize below is not wired up yet, so a throw here must hand the refcount back itself.
|
|
78
|
+
release();
|
|
79
|
+
throw e;
|
|
80
|
+
}
|
|
81
|
+
const messages$ = ready.then(() => {
|
|
69
82
|
if (!this.statusSubscription) {
|
|
70
83
|
this.statusSubscription = stream.statusStream$.subscribe((msg) => {
|
|
71
84
|
this.status = msg === SubscriberStatusEnum.STOPPED || msg === SubscriberStatusEnum.ALIVE;
|
|
@@ -74,9 +87,12 @@ export class TelemetryService extends BaseStreamService {
|
|
|
74
87
|
}
|
|
75
88
|
return from(stream.messageStream$);
|
|
76
89
|
});
|
|
77
|
-
return from(
|
|
78
|
-
return
|
|
79
|
-
}), finalize(() =>
|
|
90
|
+
return from(messages$).pipe(mergeAll(), filter((message) => {
|
|
91
|
+
return callsignsLookup.includesCallsign(message.callsign) && sources.includes(message.source);
|
|
92
|
+
}), finalize(() => {
|
|
93
|
+
void stream.removeSubscription(subscriptionParams, params.terminateReceiverGroupOnUnsubscribe);
|
|
94
|
+
release();
|
|
95
|
+
}));
|
|
80
96
|
});
|
|
81
97
|
}
|
|
82
98
|
/**
|
|
@@ -156,8 +172,8 @@ export class TelemetryService extends BaseStreamService {
|
|
|
156
172
|
return `${params.projectId}-default-${flattenCallsignsLookup(callsignsLookup).join()}`;
|
|
157
173
|
return `${params.projectId}-default`;
|
|
158
174
|
}
|
|
159
|
-
|
|
160
|
-
|
|
175
|
+
buildStreamConfig(projectId, callsignsLookup, sources, scope) {
|
|
176
|
+
return {
|
|
161
177
|
url: this.config.url,
|
|
162
178
|
projectId,
|
|
163
179
|
callsignsLookup,
|
|
@@ -169,16 +185,7 @@ export class TelemetryService extends BaseStreamService {
|
|
|
169
185
|
insecure: this.config.insecure,
|
|
170
186
|
transport: this.config.transport,
|
|
171
187
|
fetch: this.config.fetch,
|
|
172
|
-
}
|
|
173
|
-
if (!newStream.isNew) {
|
|
174
|
-
newStream.stream.statusStream$.subscribe((msg) => {
|
|
175
|
-
this.streamStatusSubject$.next({
|
|
176
|
-
scope,
|
|
177
|
-
status: msg,
|
|
178
|
-
});
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
return newStream.stream;
|
|
188
|
+
};
|
|
182
189
|
}
|
|
183
190
|
getStream(config) {
|
|
184
191
|
if (config.transport === 'grpc-web') {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IDENTIFIER_NAME_WEBRTC_SIGNALLING } from '../constants/identifier';
|
|
2
2
|
import { RocosLogger } from '../logger/RocosLogger';
|
|
3
3
|
import { RocosStore } from '../store/RocosStore';
|
|
4
4
|
import { StreamRegister } from '../api/StreamRegister';
|
|
@@ -34,11 +34,9 @@ export class WebRTCSignallingService {
|
|
|
34
34
|
}
|
|
35
35
|
async createSignallingStream() {
|
|
36
36
|
const scope = 'default';
|
|
37
|
-
const identifier = StreamRegister.getIdentifier(
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
if (!stream) {
|
|
41
|
-
stream = this.getStream({
|
|
37
|
+
const identifier = StreamRegister.getIdentifier(IDENTIFIER_NAME_WEBRTC_SIGNALLING, scope);
|
|
38
|
+
const { stream, ready } = StreamRegister.getInstance().acquireStream(identifier, () => {
|
|
39
|
+
const newStream = this.getStream({
|
|
42
40
|
url: this.config.url,
|
|
43
41
|
token: this.config.token,
|
|
44
42
|
scope,
|
|
@@ -46,13 +44,13 @@ export class WebRTCSignallingService {
|
|
|
46
44
|
port: this.config.port,
|
|
47
45
|
insecure: this.config.insecure,
|
|
48
46
|
});
|
|
49
|
-
|
|
47
|
+
newStream.statusStream$.subscribe((msg) => {
|
|
50
48
|
this.status = msg === SubscriberStatusEnum.STOPPED || msg === SubscriberStatusEnum.ALIVE;
|
|
51
49
|
this.status$.next(msg);
|
|
52
50
|
});
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
return newStream;
|
|
52
|
+
}, (newStream) => this.initStream(newStream));
|
|
53
|
+
await ready;
|
|
56
54
|
return stream;
|
|
57
55
|
}
|
|
58
56
|
async initStream(stream) {
|