@telperion/messenger 8.4.0 → 8.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.build-manifest.json +416 -0
- package/README.md +30 -1
- package/broadcast/default-channel-name.cjs +6 -4
- package/broadcast/default-channel-name.cjs.map +1 -0
- package/broadcast/default-channel-name.d.cts +3 -0
- package/broadcast/default-channel-name.d.ts +3 -1
- package/broadcast/default-channel-name.js +2 -1
- package/broadcast/default-channel-name.js.map +1 -1
- package/broadcast/index.cjs +16 -13
- package/broadcast/index.cjs.map +1 -0
- package/broadcast/index.d.cts +11 -0
- package/broadcast/index.d.ts +11 -5
- package/broadcast/index.js +5 -6
- package/broadcast/index.js.map +1 -1
- package/broadcast/message-client.cjs +15 -13
- package/broadcast/message-client.cjs.map +1 -0
- package/broadcast/message-client.d.cts +15 -0
- package/broadcast/message-client.d.ts +9 -6
- package/broadcast/message-client.js +7 -5
- package/broadcast/message-client.js.map +1 -1
- package/broadcast/message-host.cjs +14 -12
- package/broadcast/message-host.cjs.map +1 -0
- package/broadcast/message-host.d.cts +14 -0
- package/broadcast/message-host.d.ts +9 -4
- package/broadcast/message-host.js +7 -5
- package/broadcast/message-host.js.map +1 -1
- package/broadcast/message-service.cjs +11 -9
- package/broadcast/message-service.cjs.map +1 -0
- package/broadcast/message-service.d.cts +15 -0
- package/broadcast/message-service.d.ts +10 -3
- package/broadcast/message-service.js +7 -5
- package/broadcast/message-service.js.map +1 -1
- package/chrome/default-connection-name.cjs +6 -4
- package/chrome/default-connection-name.cjs.map +1 -0
- package/chrome/default-connection-name.d.cts +3 -0
- package/chrome/default-connection-name.d.ts +3 -1
- package/chrome/default-connection-name.js +2 -1
- package/chrome/default-connection-name.js.map +1 -1
- package/chrome/index.cjs +14 -11
- package/chrome/index.cjs.map +1 -0
- package/chrome/index.d.cts +10 -0
- package/chrome/index.d.ts +10 -4
- package/chrome/index.js +4 -5
- package/chrome/index.js.map +1 -1
- package/chrome/message-client.cjs +18 -16
- package/chrome/message-client.cjs.map +1 -0
- package/chrome/message-client.d.cts +17 -0
- package/chrome/message-client.d.ts +8 -6
- package/chrome/message-client.js +6 -4
- package/chrome/message-client.js.map +1 -1
- package/chrome/message-host.cjs +15 -13
- package/chrome/message-host.cjs.map +1 -0
- package/chrome/message-host.d.cts +14 -0
- package/chrome/message-host.d.ts +9 -4
- package/chrome/message-host.js +6 -4
- package/chrome/message-host.js.map +1 -1
- package/fesm/messenger.mjs +125 -0
- package/fesm/messenger.mjs.map +1 -0
- package/iframe/channel-path-splitter.cjs +6 -4
- package/iframe/channel-path-splitter.cjs.map +1 -0
- package/iframe/channel-path-splitter.d.cts +3 -0
- package/iframe/channel-path-splitter.d.ts +3 -1
- package/iframe/channel-path-splitter.js +2 -1
- package/iframe/channel-path-splitter.js.map +1 -1
- package/iframe/default-channel-name.cjs +6 -4
- package/iframe/default-channel-name.cjs.map +1 -0
- package/iframe/default-channel-name.d.cts +3 -0
- package/iframe/default-channel-name.d.ts +3 -1
- package/iframe/default-channel-name.js +2 -1
- package/iframe/default-channel-name.js.map +1 -1
- package/iframe/iframe.type.cjs +3 -2
- package/iframe/iframe.type.cjs.map +1 -0
- package/iframe/iframe.type.d.cts +6 -0
- package/iframe/iframe.type.d.ts +6 -4
- package/iframe/iframe.type.js +0 -1
- package/iframe/iframe.type.js.map +1 -1
- package/iframe/index.cjs +16 -13
- package/iframe/index.cjs.map +1 -0
- package/iframe/index.d.cts +13 -0
- package/iframe/index.d.ts +13 -6
- package/iframe/index.js +5 -6
- package/iframe/index.js.map +1 -1
- package/iframe/message-client.cjs +26 -24
- package/iframe/message-client.cjs.map +1 -0
- package/iframe/message-client.d.cts +19 -0
- package/iframe/message-client.d.ts +9 -7
- package/iframe/message-client.js +7 -5
- package/iframe/message-client.js.map +1 -1
- package/iframe/message-host.cjs +30 -28
- package/iframe/message-host.cjs.map +1 -0
- package/iframe/message-host.d.cts +23 -0
- package/iframe/message-host.d.ts +10 -6
- package/iframe/message-host.js +8 -6
- package/iframe/message-host.js.map +1 -1
- package/iframe/message-service.cjs +13 -11
- package/iframe/message-service.cjs.map +1 -0
- package/iframe/message-service.d.cts +18 -0
- package/iframe/message-service.d.ts +11 -4
- package/iframe/message-service.js +7 -5
- package/iframe/message-service.js.map +1 -1
- package/iframe/source-id-splitter.cjs +6 -4
- package/iframe/source-id-splitter.cjs.map +1 -0
- package/iframe/source-id-splitter.d.cts +3 -0
- package/iframe/source-id-splitter.d.ts +3 -1
- package/iframe/source-id-splitter.js +2 -1
- package/iframe/source-id-splitter.js.map +1 -1
- package/iframe/upcoming-message.cjs +3 -2
- package/iframe/upcoming-message.cjs.map +1 -0
- package/iframe/upcoming-message.d.cts +6 -0
- package/iframe/upcoming-message.d.ts +3 -1
- package/iframe/upcoming-message.js +0 -1
- package/iframe/upcoming-message.js.map +1 -1
- package/index.cjs +22 -13
- package/index.cjs.map +1 -0
- package/index.d.cts +8 -0
- package/index.d.ts +8 -7
- package/index.js +5 -6
- package/index.js.map +1 -1
- package/listen.decorator.cjs +11 -8
- package/listen.decorator.cjs.map +1 -0
- package/listen.decorator.d.cts +8 -0
- package/listen.decorator.d.ts +3 -1
- package/listen.decorator.js +4 -2
- package/listen.decorator.js.map +1 -1
- package/listener-storage.type.cjs +3 -2
- package/listener-storage.type.cjs.map +1 -0
- package/listener-storage.type.d.cts +5 -0
- package/listener-storage.type.d.ts +4 -1
- package/listener-storage.type.js +0 -1
- package/listener-storage.type.js.map +1 -1
- package/message-client.cjs +4 -4
- package/message-client.cjs.map +1 -0
- package/message-client.d.cts +26 -0
- package/message-client.d.ts +8 -5
- package/message-client.js +2 -2
- package/message-client.js.map +1 -1
- package/message-host.cjs +20 -18
- package/message-host.cjs.map +1 -0
- package/message-host.d.cts +29 -0
- package/message-host.d.ts +8 -5
- package/message-host.js +5 -3
- package/message-host.js.map +1 -1
- package/message-response.type.cjs +3 -2
- package/message-response.type.cjs.map +1 -0
- package/message-response.type.d.cts +18 -0
- package/message-response.type.d.ts +8 -6
- package/message-response.type.js +0 -1
- package/message-response.type.js.map +1 -1
- package/message.interface.cjs +3 -2
- package/message.interface.cjs.map +1 -0
- package/message.interface.d.cts +8 -0
- package/message.interface.d.ts +3 -1
- package/message.interface.js +0 -1
- package/message.interface.js.map +1 -1
- package/package.json +387 -75
- package/request.decorator.cjs +32 -14
- package/request.decorator.cjs.map +1 -0
- package/request.decorator.d.cts +55 -0
- package/request.decorator.d.ts +55 -1
- package/request.decorator.js +26 -9
- package/request.decorator.js.map +1 -1
- package/rtc/channel-controller.cjs +6 -4
- package/rtc/channel-controller.cjs.map +1 -0
- package/rtc/channel-controller.d.cts +8 -0
- package/rtc/channel-controller.d.ts +3 -2
- package/rtc/channel-controller.js +2 -1
- package/rtc/channel-controller.js.map +1 -1
- package/rtc/default-channel-name.cjs +6 -4
- package/rtc/default-channel-name.cjs.map +1 -0
- package/rtc/default-channel-name.d.cts +4 -0
- package/rtc/default-channel-name.d.ts +3 -1
- package/rtc/default-channel-name.js +2 -1
- package/rtc/default-channel-name.js.map +1 -1
- package/rtc/index.cjs +16 -13
- package/rtc/index.cjs.map +1 -0
- package/rtc/index.d.cts +12 -0
- package/rtc/index.d.ts +12 -5
- package/rtc/index.js +5 -6
- package/rtc/index.js.map +1 -1
- package/rtc/initializer.cjs +23 -18
- package/rtc/initializer.cjs.map +1 -0
- package/rtc/initializer.d.cts +20 -0
- package/rtc/initializer.d.ts +7 -3
- package/rtc/initializer.js +11 -7
- package/rtc/initializer.js.map +1 -1
- package/rtc/message-client.cjs +63 -31
- package/rtc/message-client.cjs.map +1 -0
- package/rtc/message-client.d.cts +75 -0
- package/rtc/message-client.d.ts +17 -9
- package/rtc/message-client.js +40 -10
- package/rtc/message-client.js.map +1 -1
- package/rtc/message-host.cjs +40 -28
- package/rtc/message-host.cjs.map +1 -0
- package/rtc/message-host.d.cts +70 -0
- package/rtc/message-host.d.ts +12 -8
- package/rtc/message-host.js +18 -8
- package/rtc/message-host.js.map +1 -1
- package/rtc/message-service.cjs +17 -15
- package/rtc/message-service.cjs.map +1 -0
- package/rtc/message-service.d.cts +46 -0
- package/rtc/message-service.d.ts +11 -4
- package/rtc/message-service.js +11 -9
- package/rtc/message-service.js.map +1 -1
- package/rtc/rtc.type.cjs +3 -2
- package/rtc/rtc.type.cjs.map +1 -0
- package/rtc/rtc.type.d.cts +14 -0
- package/rtc/rtc.type.d.ts +6 -4
- package/rtc/rtc.type.js +0 -1
- package/rtc/rtc.type.js.map +1 -1
- package/selectors.cjs +18 -10
- package/selectors.cjs.map +1 -0
- package/selectors.d.cts +9 -0
- package/selectors.d.ts +9 -7
- package/selectors.js +8 -7
- package/selectors.js.map +1 -1
- package/worker/index.cjs +16 -13
- package/worker/index.cjs.map +1 -0
- package/worker/index.d.cts +12 -0
- package/worker/index.d.ts +12 -5
- package/worker/index.js +5 -6
- package/worker/index.js.map +1 -1
- package/worker/initializer.cjs +11 -8
- package/worker/initializer.cjs.map +1 -0
- package/worker/initializer.d.cts +15 -0
- package/worker/initializer.d.ts +8 -5
- package/worker/initializer.js +5 -3
- package/worker/initializer.js.map +1 -1
- package/worker/message-client.cjs +19 -17
- package/worker/message-client.cjs.map +1 -0
- package/worker/message-client.d.cts +133 -0
- package/worker/message-client.d.ts +10 -8
- package/worker/message-client.js +9 -7
- package/worker/message-client.js.map +1 -1
- package/worker/message-host.cjs +17 -15
- package/worker/message-host.cjs.map +1 -0
- package/worker/message-host.d.cts +135 -0
- package/worker/message-host.d.ts +10 -6
- package/worker/message-host.js +8 -6
- package/worker/message-host.js.map +1 -1
- package/worker/message-service.cjs +11 -9
- package/worker/message-service.cjs.map +1 -0
- package/worker/message-service.d.cts +124 -0
- package/worker/message-service.d.ts +11 -4
- package/worker/message-service.js +6 -4
- package/worker/message-service.js.map +1 -1
package/request.decorator.d.ts
CHANGED
|
@@ -1 +1,55 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Options of the {@link Request} decorator
|
|
3
|
+
*/
|
|
4
|
+
interface RequestOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Return a `Promise` of the first response instead of an `Observable` of all responses
|
|
7
|
+
*
|
|
8
|
+
* The promise resolves with the first response, rejects with the error the host or the transport reports,
|
|
9
|
+
* and rejects with rxjs' `EmptyError` when the host completes without responding.
|
|
10
|
+
* Type the stub's return value as a `Promise`.
|
|
11
|
+
*
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
single?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Decorator of a {@link Request} stub that returns a `Promise` (`{ single: true }`)
|
|
18
|
+
*/
|
|
19
|
+
type SingleRequestDecorator = <T extends (...args: never[]) => Promise<unknown>>(target: object, key: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;
|
|
20
|
+
/**
|
|
21
|
+
* Turns a method stub of a {@link MessageClient} into a request to the hosts listening on `path`
|
|
22
|
+
*
|
|
23
|
+
* The request is sent **eagerly**, when the method is called, not when the returned `Observable` is subscribed:
|
|
24
|
+
* calling the method without subscribing still sends the message (and subscribing twice does not send it twice).
|
|
25
|
+
* Subscribe right away, because responses that arrive before the subscription are not replayed.
|
|
26
|
+
*
|
|
27
|
+
* By default the stub returns an `Observable` that emits every response and completes when the host completes.
|
|
28
|
+
* With `{ single: true }` it returns a `Promise` of the first response instead; see {@link RequestOptions.single}.
|
|
29
|
+
*
|
|
30
|
+
* ```typescript
|
|
31
|
+
* class Client extends IframeMessageClient {
|
|
32
|
+
* @Request('progress')
|
|
33
|
+
* progress(jobId: string): Observable<number> {
|
|
34
|
+
* return null!;
|
|
35
|
+
* }
|
|
36
|
+
*
|
|
37
|
+
* @Request('done', { single: true })
|
|
38
|
+
* done(result: Result): Promise<boolean> {
|
|
39
|
+
* return null!;
|
|
40
|
+
* }
|
|
41
|
+
* }
|
|
42
|
+
*
|
|
43
|
+
* const accepted = await client.done(result);
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @param path Acts like an api endpoint path of an XHR for extensions messaging
|
|
47
|
+
* @param options Whether to return a `Promise` of the first response
|
|
48
|
+
*/
|
|
49
|
+
declare function Request(path: string, options: RequestOptions & {
|
|
50
|
+
single: true;
|
|
51
|
+
}): SingleRequestDecorator;
|
|
52
|
+
declare function Request(path: string, options?: RequestOptions): MethodDecorator;
|
|
53
|
+
|
|
54
|
+
export { Request };
|
|
55
|
+
export type { RequestOptions, SingleRequestDecorator };
|
package/request.decorator.js
CHANGED
|
@@ -1,19 +1,36 @@
|
|
|
1
|
+
import { ReplaySubject, merge, firstValueFrom } from 'rxjs';
|
|
1
2
|
import { filter, map, takeWhile } from 'rxjs/operators';
|
|
2
|
-
import { GET_NEW_ID, RESPONSES$, SEND } from './selectors';
|
|
3
|
-
|
|
3
|
+
import { GET_NEW_ID, RESPONSES$, SEND } from './selectors.js';
|
|
4
|
+
|
|
5
|
+
function Request(path, { single = false } = {}) {
|
|
4
6
|
return function (target, key, descriptor) {
|
|
5
7
|
descriptor.value = function (message) {
|
|
6
8
|
const messageId = this[GET_NEW_ID]();
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
// Replays a send failure so it reaches the caller even if they subscribe late.
|
|
10
|
+
const sendFailure$ = new ReplaySubject(1);
|
|
11
|
+
const response$ = responsesOf(merge(this[RESPONSES$], sendFailure$), messageId);
|
|
12
|
+
// A promise subscribes before sending, so a response that arrives synchronously is not missed
|
|
13
|
+
const result = single ? firstValueFrom(response$) : response$;
|
|
14
|
+
const send = () => this[SEND]({ body: message, id: messageId, path });
|
|
15
|
+
// A promise-returning stub must not throw synchronously: a throwing send becomes a rejection
|
|
16
|
+
const sent = single ? new Promise(resolve => resolve(send())) : Promise.resolve(send());
|
|
17
|
+
sent.catch(error => sendFailure$.next({ id: messageId, completed: true, error }));
|
|
18
|
+
return result;
|
|
14
19
|
};
|
|
15
20
|
return descriptor;
|
|
16
21
|
};
|
|
17
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Bodies of the responses to one message, until the host completes or reports an error
|
|
25
|
+
*/
|
|
26
|
+
function responsesOf(responses$, messageId) {
|
|
27
|
+
return responses$.pipe(filter(({ id }) => id === messageId), map((data) => {
|
|
28
|
+
const { error } = data;
|
|
29
|
+
if (error)
|
|
30
|
+
throw error;
|
|
31
|
+
return data;
|
|
32
|
+
}), takeWhile((res) => !res.completed), map(({ body }) => body));
|
|
33
|
+
}
|
|
18
34
|
|
|
35
|
+
export { Request };
|
|
19
36
|
//# sourceMappingURL=request.decorator.js.map
|
package/request.decorator.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"file":"request.decorator.js","sources":["../../../libs/messenger/src/request.decorator.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AA+DM,SAAU,OAAO,CAAC,IAAY,EAAE,EAAE,MAAM,GAAG,KAAK,EAAA,GAAqB,EAAE,EAAA;AAC3E,IAAA,OAAO,UAAS,MAAM,EAAE,GAAG,EAAE,UAAwC,EAAA;AACnE,QAAA,UAAU,CAAC,KAAK,GAAG,UAA8B,OAAY,EAAA;AAC3D,YAAA,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,EAAE;;AAEpC,YAAA,MAAM,YAAY,GAAG,IAAI,aAAa,CAAkB,CAAC,CAAC;AAC1D,YAAA,MAAM,SAAS,GAAG,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,YAAY,CAAC,EAAE,SAAS,CAAC;;AAE/E,YAAA,MAAM,MAAM,GAAG,MAAM,GAAG,cAAc,CAAC,SAAS,CAAC,GAAG,SAAS;YAC7D,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;;AAErE,YAAA,MAAM,IAAI,GAAG,MAAM,GAAG,IAAI,OAAO,CAAO,OAAO,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YAE7F,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,YAAY,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;AAEjF,YAAA,OAAO,MAAM;AACf,QAAA,CAAC;AAED,QAAA,OAAO,UAAU;AACnB,IAAA,CAAC;AACH;AAEA;;AAEG;AACH,SAAS,WAAW,CAAC,UAAuC,EAAE,SAAiB,EAAA;IAC7E,OAAO,UAAU,CAAC,IAAI,CACpB,MAAM,CAAC,CAAC,EAAC,EAAE,EAAC,KAAK,EAAE,KAAK,SAAS,CAAC,EAClC,GAAG,CAAC,CAAC,IAAI,KAAI;AACX,QAAA,MAAM,EAAE,KAAK,EAAE,GAAG,IAA4B;AAE9C,QAAA,IAAI,KAAK;AAAE,YAAA,MAAM,KAAK;AAEtB,QAAA,OAAO,IAAiC;IAC1C,CAAC,CAAC,EACF,SAAS,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,EAClC,GAAG,CAAC,CAAC,EAAE,IAAI,EAA8B,KAAK,IAAI,CAAC,CACpD;AACH;;;;"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
2
3
|
var _a;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.CHANNEL_CONTROLLER = void 0;
|
|
5
4
|
class ChannelController {
|
|
6
5
|
static #DEFAULT_MAX_CHANNELS = 1024;
|
|
7
6
|
#connections = new WeakMap();
|
|
@@ -49,4 +48,7 @@ class ChannelController {
|
|
|
49
48
|
}
|
|
50
49
|
}
|
|
51
50
|
_a = ChannelController;
|
|
52
|
-
|
|
51
|
+
const CHANNEL_CONTROLLER = new ChannelController();
|
|
52
|
+
|
|
53
|
+
exports.CHANNEL_CONTROLLER = CHANNEL_CONTROLLER;
|
|
54
|
+
//# sourceMappingURL=channel-controller.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel-controller.cjs","sources":["../../../../libs/messenger/src/rtc/channel-controller.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAAA,MAAM,iBAAiB,CAAA;AACrB,IAAA,OAAO,qBAAqB,GAAG,IAAI;AAEnC,IAAA,YAAY,GAAG,IAAI,OAAO,EAAqD;AAC/E,IAAA,SAAS,GAAG,IAAI,OAAO,EAA0B;AAEjD,IAAA,UAAU,CAAC,UAA6B,EAAE,WAAmB,EAAE,SAAkB,EAAA;QAC/E,MAAM,EAAE,GAAG,SAAS,IAAI,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC;QAEvD,IAAI,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC;QAEhD,IAAI,CAAC,QAAQ,EAAE;YACb,QAAQ,GAAG,EAAE;YACb,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC;QAC7C;AAEA,QAAA,IAAI,OAAO,GAAG,QAAQ,CAAC,EAAE,CAAC;QAE1B,IAAI,CAAC,OAAO,EAAE;AACZ,YAAA,OAAO,GAAG,UAAU,CAAC,iBAAiB,CAAC,WAAW,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;YAC7F,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;AAC9B,YAAA,QAAQ,CAAC,EAAE,CAAC,GAAG,OAAO;QACxB;QAEA,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CA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eerConnection, channelName: string, channelId?: number): [RTCDataChannel, Promise<RTCDataChannel>];
|
|
4
|
+
close(channel: RTCDataChannel): void;
|
|
5
|
+
}
|
|
6
|
+
declare const CHANNEL_CONTROLLER: ChannelController;
|
|
7
|
+
|
|
8
|
+
export { CHANNEL_CONTROLLER };
|
|
@@ -3,5 +3,6 @@ declare class ChannelController {
|
|
|
3
3
|
getChannel(connection: RTCPeerConnection, channelName: string, channelId?: number): [RTCDataChannel, Promise<RTCDataChannel>];
|
|
4
4
|
close(channel: RTCDataChannel): void;
|
|
5
5
|
}
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
declare const CHANNEL_CONTROLLER: ChannelController;
|
|
7
|
+
|
|
8
|
+
export { CHANNEL_CONTROLLER };
|
|
@@ -46,6 +46,7 @@ class ChannelController {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
_a = ChannelController;
|
|
49
|
-
|
|
49
|
+
const CHANNEL_CONTROLLER = new ChannelController();
|
|
50
50
|
|
|
51
|
+
export { CHANNEL_CONTROLLER };
|
|
51
52
|
//# sourceMappingURL=channel-controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"file":"channel-controller.js","sources":["../../../../libs/messenger/src/rtc/channel-controller.ts"],"sourcesContent":[null],"names":[],"mappings":";AAAA,MAAM,iBAAiB,CAAA;AACrB,IAAA,OAAO,qBAAqB,GAAG,IAAI;AAEnC,IAAA,YAAY,GAAG,IAAI,OAAO,EAAqD;AAC/E,IAAA,SAAS,GAAG,IAAI,OAAO,EAA0B;AAEjD,IAAA,UAAU,CAAC,UAA6B,EAAE,WAAmB,EAAE,SAAkB,EAAA;QAC/E,MAAM,EAAE,GAAG,SAAS,IAAI,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC;QAEvD,IAAI,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC;QAEhD,IAAI,CAAC,QAAQ,EAA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GAAG,CAAC,OAAO,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;QACzC;IACF;AAEA,IAAA,aAAa,CAAC,WAAmB,EAAA;AAC/B,QAAA,IAAI,IAAI,GAAG,UAAU,CAAC;AAEtB,QAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AAC3C,YAAA,IAAI,IAAI,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC;YACjC,IAAI,GAAG,CAAC,IAAI,GAAG,UAAU,MAAM,CAAC,CAAC;QACnC;;AAGA,QAAA,OAAO,IAAI,GAAG,EAAiB,CAAC,qBAAqB;IACvD;;;AAGK,MAAM,kBAAkB,GAAG,IAAI,iBAAiB;;;;"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.DEFAULT_CHANNEL_NAME = void 0;
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
4
3
|
/** Default negotiated RTCDataChannel name used when no custom name is provided. */
|
|
5
|
-
|
|
4
|
+
const DEFAULT_CHANNEL_NAME = 'MessengerRTCChannelDefault';
|
|
5
|
+
|
|
6
|
+
exports.DEFAULT_CHANNEL_NAME = DEFAULT_CHANNEL_NAME;
|
|
7
|
+
//# sourceMappingURL=default-channel-name.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-channel-name.cjs","sources":["../../../../libs/messenger/src/rtc/default-channel-name.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;AACO,MAAM,oBAAoB,GAAG;;;;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/** Default negotiated RTCDataChannel name used when no custom name is provided. */
|
|
2
|
-
|
|
2
|
+
const DEFAULT_CHANNEL_NAME = 'MessengerRTCChannelDefault';
|
|
3
3
|
|
|
4
|
+
export { DEFAULT_CHANNEL_NAME };
|
|
4
5
|
//# sourceMappingURL=default-channel-name.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"file":"default-channel-name.js","sources":["../../../../libs/messenger/src/rtc/default-channel-name.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACO,MAAM,oBAAoB,GAAG;;;;"}
|
package/rtc/index.cjs
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var rtc_messageService = require('./message-service.cjs');
|
|
4
|
+
var rtc_messageClient = require('./message-client.cjs');
|
|
5
|
+
var rtc_messageHost = require('./message-host.cjs');
|
|
6
|
+
var request_decorator = require('../request.decorator.cjs');
|
|
7
|
+
var listen_decorator = require('../listen.decorator.cjs');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
exports.RTCMessageService = rtc_messageService.RTCMessageService;
|
|
12
|
+
exports.RTCMessageClient = rtc_messageClient.RTCMessageClient;
|
|
13
|
+
exports.RTCMessageHost = rtc_messageHost.RTCMessageHost;
|
|
14
|
+
exports.Request = request_decorator.Request;
|
|
15
|
+
exports.Listen = listen_decorator.Listen;
|
|
16
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;"}
|
package/rtc/index.d.cts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { RTCMessageService } from './message-service.cjs';
|
|
2
|
+
export { RTCMessageClient } from './message-client.cjs';
|
|
3
|
+
export { RTCMessageHost } from './message-host.cjs';
|
|
4
|
+
export { Request, RequestOptions, SingleRequestDecorator } from '../request.decorator.cjs';
|
|
5
|
+
export { Listen } from '../listen.decorator.cjs';
|
|
6
|
+
import './rtc.type.cjs';
|
|
7
|
+
import 'rxjs';
|
|
8
|
+
import '../message-client.cjs';
|
|
9
|
+
import '../message-response.type.cjs';
|
|
10
|
+
import '../message.interface.cjs';
|
|
11
|
+
import '../selectors.cjs';
|
|
12
|
+
import '../message-host.cjs';
|
package/rtc/index.d.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
export { RTCMessageService } from './message-service';
|
|
2
|
-
export { RTCMessageClient } from './message-client';
|
|
3
|
-
export { RTCMessageHost } from './message-host';
|
|
4
|
-
export { Request } from '../request.decorator';
|
|
5
|
-
export { Listen } from '../listen.decorator';
|
|
1
|
+
export { RTCMessageService } from './message-service.js';
|
|
2
|
+
export { RTCMessageClient } from './message-client.js';
|
|
3
|
+
export { RTCMessageHost } from './message-host.js';
|
|
4
|
+
export { Request, RequestOptions, SingleRequestDecorator } from '../request.decorator.js';
|
|
5
|
+
export { Listen } from '../listen.decorator.js';
|
|
6
|
+
import './rtc.type.js';
|
|
7
|
+
import 'rxjs';
|
|
8
|
+
import '../message-client.js';
|
|
9
|
+
import '../message-response.type.js';
|
|
10
|
+
import '../message.interface.js';
|
|
11
|
+
import '../selectors.js';
|
|
12
|
+
import '../message-host.js';
|
package/rtc/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
export { RTCMessageService } from './message-service';
|
|
2
|
-
export { RTCMessageClient } from './message-client';
|
|
3
|
-
export { RTCMessageHost } from './message-host';
|
|
4
|
-
export { Request } from '../request.decorator';
|
|
5
|
-
export { Listen } from '../listen.decorator';
|
|
6
|
-
|
|
1
|
+
export { RTCMessageService } from './message-service.js';
|
|
2
|
+
export { RTCMessageClient } from './message-client.js';
|
|
3
|
+
export { RTCMessageHost } from './message-host.js';
|
|
4
|
+
export { Request } from '../request.decorator.js';
|
|
5
|
+
export { Listen } from '../listen.decorator.js';
|
|
7
6
|
//# sourceMappingURL=index.js.map
|
package/rtc/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
package/rtc/initializer.cjs
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var noop = require('@telperion/js-utils/function/noop');
|
|
4
|
+
var call = require('@telperion/js-utils/function/call');
|
|
5
|
+
var timeout = require('@telperion/js-utils/promise/timeout');
|
|
6
|
+
var promisify = require('@telperion/js-utils/promise/promisify');
|
|
7
|
+
var never = require('@telperion/js-utils/promise/never');
|
|
8
|
+
var rtc_channelController = require('./channel-controller.cjs');
|
|
9
|
+
|
|
10
10
|
const INITIALIZATION_ERROR_TUPLE = [undefined, Promise.resolve(null)];
|
|
11
|
-
function initialize({ context, selectors: { channel, channelOpen, deinit, emitter }, connection, channelName, channelId, messageFilterType }) {
|
|
11
|
+
function initialize({ context, selectors: { channel, channelOpen, deinit, emitter }, connection, channelName, channelId, messageFilterType, onClose = noop.noop }) {
|
|
12
12
|
const channelWithOpen = Promise.race([
|
|
13
13
|
context[deinit],
|
|
14
|
-
|
|
14
|
+
timeout.timeout(5000, noop.noop)
|
|
15
15
|
])
|
|
16
|
-
.then(
|
|
16
|
+
.then(call.call)
|
|
17
17
|
.then(() => {
|
|
18
18
|
const conn = typeof connection === 'function' ? connection() : connection;
|
|
19
|
-
return
|
|
19
|
+
return promisify.promisify(conn);
|
|
20
20
|
})
|
|
21
21
|
.then(conn => {
|
|
22
22
|
if (!conn)
|
|
23
23
|
return INITIALIZATION_ERROR_TUPLE;
|
|
24
|
-
return
|
|
24
|
+
return rtc_channelController.CHANNEL_CONTROLLER.getChannel(conn, channelName, channelId);
|
|
25
25
|
})
|
|
26
26
|
.catch(error => {
|
|
27
27
|
console.error('Failed to initialize RTCMessageClient:', error);
|
|
28
28
|
return INITIALIZATION_ERROR_TUPLE;
|
|
29
29
|
});
|
|
30
|
-
context[channel] = channelWithOpen.then(([dataChannel]) => dataChannel ??
|
|
31
|
-
context[channelOpen] = channelWithOpen.then(([_, open]) => open).then(channel => channel ??
|
|
30
|
+
context[channel] = channelWithOpen.then(([dataChannel]) => dataChannel ?? never.NEVER);
|
|
31
|
+
context[channelOpen] = channelWithOpen.then(([_, open]) => open).then(channel => channel ?? never.NEVER);
|
|
32
32
|
context[deinit] = channelWithOpen.then(([channel]) => {
|
|
33
33
|
if (!channel)
|
|
34
|
-
return
|
|
34
|
+
return noop.noop;
|
|
35
35
|
const listener = (event) => {
|
|
36
36
|
const data = typeof event.data === 'string' ? JSON.parse(event.data) : event.data;
|
|
37
37
|
if (data.type !== messageFilterType)
|
|
@@ -39,9 +39,14 @@ function initialize({ context, selectors: { channel, channelOpen, deinit, emitte
|
|
|
39
39
|
context[emitter].next(data);
|
|
40
40
|
};
|
|
41
41
|
channel.addEventListener('message', listener);
|
|
42
|
+
channel.addEventListener('close', onClose);
|
|
42
43
|
return () => {
|
|
43
44
|
channel.removeEventListener('message', listener);
|
|
44
|
-
|
|
45
|
+
channel.removeEventListener('close', onClose);
|
|
46
|
+
rtc_channelController.CHANNEL_CONTROLLER.close(channel);
|
|
45
47
|
};
|
|
46
48
|
});
|
|
47
49
|
}
|
|
50
|
+
|
|
51
|
+
exports.initialize = initialize;
|
|
52
|
+
//# sourceMappingURL=initializer.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initializer.cjs","sources":["../../../../libs/messenger/src/rtc/initializer.ts"],"sourcesContent":[null],"names":["noop","timeout","call","promisify","CHANNEL_CONTROLLER","NEVER"],"mappings":";;;;;;;;;AA0BA,MAAM,0BAA0B,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAU;AAExE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QAAA,IAAI,CAAC,OAAO;AAAE,YAAA,OAAOL,SAAI;AAEzB,QAAA,MAAM,QAAQ,GAAG,CAAC,KAAmB,KAAI;YACvC,MAAM,IAAI,GAAuD,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI;AAErI,YAAA,IAAI,IAAI,CAAC,IAAI,KAAK,iBAAiB;gBAAE;YAErC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;AAC7B,QAAA,CAAC;AAED,QAAA,OAAO,CAAC,gBAAgB,CAAC,SAAS,EAAE,QAAQ,CAAC;AAC7C,QAAA,OAAO,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC;AAE1C,QAAA,OAAO,MAAK;AACV,YAAA,OAAO,CAAC,mBAAmB,CAAC,SAAS,EAAE,QAAQ,CAAC;AAChD,YAAA,OAAO,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC;AAC7C,YAAAI,wCAAkB,CAAC,KAAK,CAAC,OAAO,CAAC;AACnC,QAAA,CAAC;AACH,IAAA,CAAC,CAAC;AACJ;;;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { RTCConnectionArg } from './rtc.type.cjs';
|
|
2
|
+
|
|
3
|
+
interface InitializerConfig {
|
|
4
|
+
context: any;
|
|
5
|
+
selectors: {
|
|
6
|
+
channel: symbol;
|
|
7
|
+
channelOpen: symbol;
|
|
8
|
+
deinit: symbol;
|
|
9
|
+
emitter: symbol;
|
|
10
|
+
};
|
|
11
|
+
connection: RTCConnectionArg;
|
|
12
|
+
channelName: string;
|
|
13
|
+
channelId?: number;
|
|
14
|
+
messageFilterType: 'request' | 'response';
|
|
15
|
+
/** Called when the data channel fires `close`. */
|
|
16
|
+
onClose?: () => void;
|
|
17
|
+
}
|
|
18
|
+
declare function initialize({ context, selectors: { channel, channelOpen, deinit, emitter }, connection, channelName, channelId, messageFilterType, onClose }: InitializerConfig): void;
|
|
19
|
+
|
|
20
|
+
export { initialize };
|
package/rtc/initializer.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { RTCConnectionArg } from
|
|
1
|
+
import { RTCConnectionArg } from './rtc.type.js';
|
|
2
|
+
|
|
2
3
|
interface InitializerConfig {
|
|
3
4
|
context: any;
|
|
4
5
|
selectors: {
|
|
@@ -11,6 +12,9 @@ interface InitializerConfig {
|
|
|
11
12
|
channelName: string;
|
|
12
13
|
channelId?: number;
|
|
13
14
|
messageFilterType: 'request' | 'response';
|
|
15
|
+
/** Called when the data channel fires `close`. */
|
|
16
|
+
onClose?: () => void;
|
|
14
17
|
}
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
declare function initialize({ context, selectors: { channel, channelOpen, deinit, emitter }, connection, channelName, channelId, messageFilterType, onClose }: InitializerConfig): void;
|
|
19
|
+
|
|
20
|
+
export { initialize };
|
package/rtc/initializer.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { noop } from
|
|
2
|
-
import { call } from
|
|
3
|
-
import { timeout } from
|
|
4
|
-
import { promisify } from
|
|
5
|
-
import { NEVER } from
|
|
6
|
-
import { CHANNEL_CONTROLLER } from
|
|
1
|
+
import { noop } from '@telperion/js-utils/function/noop';
|
|
2
|
+
import { call } from '@telperion/js-utils/function/call';
|
|
3
|
+
import { timeout } from '@telperion/js-utils/promise/timeout';
|
|
4
|
+
import { promisify } from '@telperion/js-utils/promise/promisify';
|
|
5
|
+
import { NEVER } from '@telperion/js-utils/promise/never';
|
|
6
|
+
import { CHANNEL_CONTROLLER } from './channel-controller.js';
|
|
7
|
+
|
|
7
8
|
const INITIALIZATION_ERROR_TUPLE = [undefined, Promise.resolve(null)];
|
|
8
|
-
|
|
9
|
+
function initialize({ context, selectors: { channel, channelOpen, deinit, emitter }, connection, channelName, channelId, messageFilterType, onClose = noop }) {
|
|
9
10
|
const channelWithOpen = Promise.race([
|
|
10
11
|
context[deinit],
|
|
11
12
|
timeout(5000, noop)
|
|
@@ -36,11 +37,14 @@ export function initialize({ context, selectors: { channel, channelOpen, deinit,
|
|
|
36
37
|
context[emitter].next(data);
|
|
37
38
|
};
|
|
38
39
|
channel.addEventListener('message', listener);
|
|
40
|
+
channel.addEventListener('close', onClose);
|
|
39
41
|
return () => {
|
|
40
42
|
channel.removeEventListener('message', listener);
|
|
43
|
+
channel.removeEventListener('close', onClose);
|
|
41
44
|
CHANNEL_CONTROLLER.close(channel);
|
|
42
45
|
};
|
|
43
46
|
});
|
|
44
47
|
}
|
|
45
48
|
|
|
49
|
+
export { initialize };
|
|
46
50
|
//# sourceMappingURL=initializer.js.map
|
package/rtc/initializer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"file":"initializer.js","sources":["../../../../libs/messenger/src/rtc/initializer.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;AA0BA,MAAM,0BAA0B,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAU;AAExE,SAAU,UAAU,CAAC,EACzB,OAAO,EACP,SAAS,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,EACpD,UAAU,EACV,WAAW,EACX,SAAS,EACT,iBAAiB,EACjB,OAAO,GAAG,IAAI,EACI,EAAA;AAClB,IAAA,MAAM,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;QACnC,OAAO,CAAC,MAAM,CAAC;AACf,QAAA,OAAO,CAAC,IAAI,EAAE,IAAI;KACnB;SACE,IAAI,CAAC,IAAI;SACT,IAAI,CAAC,MAAK;AACT,QAAA,MAAM,IAAI,GAAG,OAAO,UAAU,KAAK,UAAU,GAAG,UAAU,EAAE,GAAG,UAAU;AAEzE,QAAA,OAAO,SAAS,CAAC,IAAI,CAAC;AACxB,IAAA,CAAC;SACA,IAAI,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