@telperion/messenger 8.3.1 → 8.4.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/README.md +35 -4
- package/package.json +1 -1
- package/rtc/channel-controller.cjs +7 -3
- package/rtc/channel-controller.d.ts +1 -1
- package/rtc/channel-controller.js +7 -3
- package/rtc/channel-controller.js.map +1 -1
- package/rtc/initializer.cjs +47 -0
- package/rtc/initializer.d.ts +16 -0
- package/rtc/initializer.js +46 -0
- package/rtc/initializer.js.map +1 -0
- package/rtc/message-client.cjs +47 -54
- package/rtc/message-client.d.ts +26 -11
- package/rtc/message-client.js +46 -53
- package/rtc/message-client.js.map +1 -1
- package/rtc/message-host.cjs +50 -55
- package/rtc/message-host.d.ts +26 -10
- package/rtc/message-host.js +49 -54
- package/rtc/message-host.js.map +1 -1
- package/rtc/message-service.cjs +16 -6
- package/rtc/message-service.d.ts +7 -5
- package/rtc/message-service.js +18 -8
- package/rtc/message-service.js.map +1 -1
package/rtc/message-service.cjs
CHANGED
|
@@ -28,11 +28,12 @@ const default_channel_name_1 = require("./default-channel-name");
|
|
|
28
28
|
*/
|
|
29
29
|
class RTCMessageService extends (0, mixin_1.mixin)(message_host_1.RTCMessageHost, message_client_1.RTCMessageClient) {
|
|
30
30
|
/**
|
|
31
|
-
* @param connection
|
|
31
|
+
* @param connection - RTCPeerConnection instance, promise, or factory function.
|
|
32
32
|
* @param channelName - Name for the negotiated data channel.
|
|
33
|
+
* @param channelId - Explicit negotiated channel ID. Overrides the hash-derived default.
|
|
33
34
|
*/
|
|
34
|
-
constructor(connection, channelName = default_channel_name_1.DEFAULT_CHANNEL_NAME) {
|
|
35
|
-
super([connection, channelName], [connection, channelName]);
|
|
35
|
+
constructor(connection, channelName = default_channel_name_1.DEFAULT_CHANNEL_NAME, channelId) {
|
|
36
|
+
super([connection, channelName, channelId], [connection, channelName, channelId]);
|
|
36
37
|
Reflect.defineProperty(this, 'ready', {
|
|
37
38
|
get: () => {
|
|
38
39
|
return Promise.race([
|
|
@@ -42,10 +43,19 @@ class RTCMessageService extends (0, mixin_1.mixin)(message_host_1.RTCMessageHost
|
|
|
42
43
|
},
|
|
43
44
|
configurable: false
|
|
44
45
|
});
|
|
46
|
+
Reflect.defineProperty(this, 'created', {
|
|
47
|
+
get: () => {
|
|
48
|
+
return Promise.race([
|
|
49
|
+
this[message_client_1.CREATED],
|
|
50
|
+
this[message_host_1.CREATED]
|
|
51
|
+
]);
|
|
52
|
+
},
|
|
53
|
+
configurable: false
|
|
54
|
+
});
|
|
45
55
|
}
|
|
46
|
-
initialize = (connection) => {
|
|
47
|
-
message_host_1.RTCMessageHost.prototype.initialize.call(this, connection);
|
|
48
|
-
message_client_1.RTCMessageClient.prototype.initialize.call(this, connection);
|
|
56
|
+
initialize = (connection, channelId) => {
|
|
57
|
+
message_host_1.RTCMessageHost.prototype.initialize.call(this, connection, channelId);
|
|
58
|
+
message_client_1.RTCMessageClient.prototype.initialize.call(this, connection, channelId);
|
|
49
59
|
};
|
|
50
60
|
}
|
|
51
61
|
exports.RTCMessageService = RTCMessageService;
|
package/rtc/message-service.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { RTCMessageClient } from "./message-client";
|
|
2
2
|
import { RTCConnectionArg } from "./rtc.type";
|
|
3
|
-
declare const RTCMessageService_base: new (args_0: [connection?: RTCConnectionArg, channelName?: string | undefined], args_1: [connection?: RTCConnectionArg, channelName?: string | undefined]) => {
|
|
3
|
+
declare const RTCMessageService_base: new (args_0: [connection?: RTCConnectionArg, channelName?: string | undefined, channelId?: number | undefined], args_1: [connection?: RTCConnectionArg, channelName?: string | undefined, channelId?: number | undefined]) => {
|
|
4
|
+
readonly created: Promise<RTCDataChannel>;
|
|
4
5
|
readonly ready: Promise<RTCDataChannel>;
|
|
5
|
-
initialize: (connection?: RTCConnectionArg) => void;
|
|
6
|
+
initialize: (connection?: RTCConnectionArg, channelId?: number) => void;
|
|
6
7
|
terminate: () => void;
|
|
7
8
|
} & RTCMessageClient;
|
|
8
9
|
/**
|
|
@@ -28,10 +29,11 @@ declare const RTCMessageService_base: new (args_0: [connection?: RTCConnectionAr
|
|
|
28
29
|
*/
|
|
29
30
|
export declare class RTCMessageService extends RTCMessageService_base {
|
|
30
31
|
/**
|
|
31
|
-
* @param connection
|
|
32
|
+
* @param connection - RTCPeerConnection instance, promise, or factory function.
|
|
32
33
|
* @param channelName - Name for the negotiated data channel.
|
|
34
|
+
* @param channelId - Explicit negotiated channel ID. Overrides the hash-derived default.
|
|
33
35
|
*/
|
|
34
|
-
constructor(connection?: RTCConnectionArg, channelName?: string);
|
|
35
|
-
initialize: (connection: RTCConnectionArg) => void;
|
|
36
|
+
constructor(connection?: RTCConnectionArg, channelName?: string, channelId?: number);
|
|
37
|
+
initialize: (connection: RTCConnectionArg, channelId?: number) => void;
|
|
36
38
|
}
|
|
37
39
|
export {};
|
package/rtc/message-service.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { mixin } from "@telperion/js-utils/class/mixin";
|
|
2
|
-
import { READY as CLIENT_READY, RTCMessageClient } from "./message-client";
|
|
3
|
-
import { READY as HOST_READY, RTCMessageHost } from "./message-host";
|
|
2
|
+
import { READY as CLIENT_READY, CREATED as CLIENT_CREATED, RTCMessageClient } from "./message-client";
|
|
3
|
+
import { READY as HOST_READY, CREATED as HOST_CREATED, RTCMessageHost } from "./message-host";
|
|
4
4
|
import { DEFAULT_CHANNEL_NAME } from "./default-channel-name";
|
|
5
5
|
/**
|
|
6
6
|
* Bidirectional message service for WebRTC DataChannel communication.
|
|
@@ -25,11 +25,12 @@ import { DEFAULT_CHANNEL_NAME } from "./default-channel-name";
|
|
|
25
25
|
*/
|
|
26
26
|
export class RTCMessageService extends mixin(RTCMessageHost, RTCMessageClient) {
|
|
27
27
|
/**
|
|
28
|
-
* @param connection
|
|
28
|
+
* @param connection - RTCPeerConnection instance, promise, or factory function.
|
|
29
29
|
* @param channelName - Name for the negotiated data channel.
|
|
30
|
+
* @param channelId - Explicit negotiated channel ID. Overrides the hash-derived default.
|
|
30
31
|
*/
|
|
31
|
-
constructor(connection, channelName = DEFAULT_CHANNEL_NAME) {
|
|
32
|
-
super([connection, channelName], [connection, channelName]);
|
|
32
|
+
constructor(connection, channelName = DEFAULT_CHANNEL_NAME, channelId) {
|
|
33
|
+
super([connection, channelName, channelId], [connection, channelName, channelId]);
|
|
33
34
|
Reflect.defineProperty(this, 'ready', {
|
|
34
35
|
get: () => {
|
|
35
36
|
return Promise.race([
|
|
@@ -39,10 +40,19 @@ export class RTCMessageService extends mixin(RTCMessageHost, RTCMessageClient) {
|
|
|
39
40
|
},
|
|
40
41
|
configurable: false
|
|
41
42
|
});
|
|
43
|
+
Reflect.defineProperty(this, 'created', {
|
|
44
|
+
get: () => {
|
|
45
|
+
return Promise.race([
|
|
46
|
+
this[CLIENT_CREATED],
|
|
47
|
+
this[HOST_CREATED]
|
|
48
|
+
]);
|
|
49
|
+
},
|
|
50
|
+
configurable: false
|
|
51
|
+
});
|
|
42
52
|
}
|
|
43
|
-
initialize = (connection) => {
|
|
44
|
-
RTCMessageHost.prototype.initialize.call(this, connection);
|
|
45
|
-
RTCMessageClient.prototype.initialize.call(this, connection);
|
|
53
|
+
initialize = (connection, channelId) => {
|
|
54
|
+
RTCMessageHost.prototype.initialize.call(this, connection, channelId);
|
|
55
|
+
RTCMessageClient.prototype.initialize.call(this, connection, channelId);
|
|
46
56
|
};
|
|
47
57
|
}
|
|
48
58
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../libs/messenger/src/rtc/message-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAC;AAExD,OAAO,EAAE,KAAK,IAAI,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"sources":["../../../../../libs/messenger/src/rtc/message-service.ts"],"names":[],"mappings":"AAAA,O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C,IAAI,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;QACtE,gBAAgB,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;IAC1E,CAAC,CAAC;CACH","file":"message-service.js","sourcesContent":["import { mixin } from \"@telperion/js-utils/class/mixin\";\r\n\r\nimport { READY as CLIENT_READY, CREATED as CLIENT_CREATED, RTCMessageClient } from \"./message-client\";\r\nimport { READY as HOST_READY, CREATED as HOST_CREATED, RTCMessageHost } from \"./message-host\";\r\nimport { RTCConnectionArg } from \"./rtc.type\";\r\nimport { DEFAULT_CHANNEL_NAME } from \"./default-channel-name\";\r\n\r\n/**\r\n * Bidirectional message service for WebRTC DataChannel communication.\r\n *\r\n * Combines {@link RTCMessageHost} and {@link RTCMessageClient} via mixin,\r\n * enabling both `@Listen` and `@Request` decorators on the same class.\r\n *\r\n * @example\r\n * ```typescript\r\n * class GamePeer extends RTCMessageService {\r\n * @Request('move')\r\n * sendMove(pos: [number, number]): Observable<boolean> { return null!; }\r\n *\r\n * @Listen('move')\r\n * handleMove({ data }: { data: [number, number] }): Observable<boolean> {\r\n * return of(applyMove(data));\r\n * }\r\n * }\r\n *\r\n * const peer = new GamePeer(peerConnection, 'game-events');\r\n * ```\r\n */\r\nexport class RTCMessageService extends mixin(RTCMessageHost, RTCMessageClient) {\r\n /**\r\n * @param connection - RTCPeerConnection instance, promise, or factory function.\r\n * @param channelName - Name for the negotiated data channel.\r\n * @param channelId - Explicit negotiated channel ID. Overrides the hash-derived default.\r\n */\r\n constructor(connection?: RTCConnectionArg, channelName = DEFAULT_CHANNEL_NAME, channelId?: number) {\r\n super([connection, channelName, channelId], [connection, channelName, channelId]);\r\n\r\n Reflect.defineProperty(this, 'ready', {\r\n get: () => {\r\n return Promise.race([\r\n this[CLIENT_READY],\r\n (this as any)[HOST_READY]\r\n ]);\r\n },\r\n configurable: false\r\n });\r\n\r\n Reflect.defineProperty(this, 'created', {\r\n get: () => {\r\n return Promise.race([\r\n this[CLIENT_CREATED],\r\n (this as any)[HOST_CREATED]\r\n ]);\r\n },\r\n configurable: false\r\n });\r\n }\r\n\r\n public override initialize = (connection: RTCConnectionArg, channelId?: number): void => {\r\n RTCMessageHost.prototype.initialize.call(this, connection, channelId);\r\n RTCMessageClient.prototype.initialize.call(this, connection, channelId);\r\n };\r\n}\r\n"]}
|