@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/rtc/message-host.js
CHANGED
|
@@ -2,17 +2,18 @@ import { noop } from '@telperion/js-utils/function/noop';
|
|
|
2
2
|
import { call } from '@telperion/js-utils/function/call';
|
|
3
3
|
import { NEVER } from '@telperion/js-utils/promise/never';
|
|
4
4
|
import { Subject } from 'rxjs';
|
|
5
|
-
import { MessageHost } from '../message-host';
|
|
6
|
-
import { LISTEN, RESPONSE } from '../selectors';
|
|
7
|
-
import { DEFAULT_CHANNEL_NAME } from './default-channel-name';
|
|
8
|
-
import { initialize } from './initializer';
|
|
5
|
+
import { MessageHost } from '../message-host.js';
|
|
6
|
+
import { LISTEN, RESPONSE } from '../selectors.js';
|
|
7
|
+
import { DEFAULT_CHANNEL_NAME } from './default-channel-name.js';
|
|
8
|
+
import { initialize } from './initializer.js';
|
|
9
|
+
|
|
9
10
|
const CHANNEL_NAME = Symbol('RTCMessageHost Channel Name');
|
|
10
11
|
const CHANNEL = Symbol('RTCMessageHost Channel');
|
|
11
12
|
const CHANNEL_OPEN = Symbol('RTCMessageHost Channel Open');
|
|
12
13
|
const DEINITIALIZE = Symbol('RTCMessageHost Deinitialize');
|
|
13
14
|
const REQUESTS = Symbol('RTCMessageHost Requests');
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
const READY = Symbol('RTCMessageHost Ready');
|
|
16
|
+
const CREATED = Symbol('RTCMessageHost Created');
|
|
16
17
|
/**
|
|
17
18
|
* WebRTC DataChannel message host that listens for incoming request messages
|
|
18
19
|
* and dispatches responses over the same negotiated channel.
|
|
@@ -37,7 +38,7 @@ export const CREATED = Symbol('RTCMessageHost Created');
|
|
|
37
38
|
* const host = new GameHost(peerConnection, 'game-events');
|
|
38
39
|
* ```
|
|
39
40
|
*/
|
|
40
|
-
|
|
41
|
+
class RTCMessageHost extends MessageHost {
|
|
41
42
|
[REQUESTS] = new Subject();
|
|
42
43
|
[CHANNEL_NAME];
|
|
43
44
|
[CHANNEL] = NEVER;
|
|
@@ -96,8 +97,17 @@ export class RTCMessageHost extends MessageHost {
|
|
|
96
97
|
}
|
|
97
98
|
async [RESPONSE](message) {
|
|
98
99
|
const dataChannel = await this[CHANNEL_OPEN];
|
|
99
|
-
|
|
100
|
+
// If the channel closed, the requester is gone, so the response is dropped.
|
|
101
|
+
if (dataChannel.readyState !== 'open')
|
|
102
|
+
return;
|
|
103
|
+
try {
|
|
104
|
+
dataChannel.send(JSON.stringify({ ...message, type: 'response' }));
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
// The channel closed while sending. The requester is gone, so drop it.
|
|
108
|
+
}
|
|
100
109
|
}
|
|
101
110
|
}
|
|
102
111
|
|
|
112
|
+
export { CREATED, READY, RTCMessageHost };
|
|
103
113
|
//# sourceMappingURL=message-host.js.map
|
package/rtc/message-host.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"file":"message-host.js","sources":["../../../../libs/messenger/src/rtc/message-host.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;AAaA,MAAM,YAAY,GAAG,MAAM,CAAC,6BAA6B,CAAC;AAC1D,MAAM,OAAO,GAAG,MAAM,CAAC,wBAAwB,CAAC;AAChD,MAAM,YAAY,GAAG,MAAM,CAAC,6BAA6B,CAAC;AAC1D,MAAM,YAAY,GAAG,MAAM,CAAC,6BAA6B,CAAC;AAC1D,MAAM,QAAQ,GAAG,MAAM,CAAC,yBAAyB,CAAC;MACrC,KAAK,GAAG,MAAM,CAAC,sBAAsB;MACrC,OAAO,GAAG,MAAM,CAAC,wBAAwB;AAEtD;;;;;;;;;;;;;;;;;;;;;;;AAuBG;AACG,MAAO,cAAe,SAAQ,WAAW,CAAA;AACrC,IAAA,CAAC,QAAQ,IAAI,IAAI,OAAO,EAAW;IACnC,CAAC,YAAY;AACb,IAAA,CAAC,OAAO,IAA6B,KAAK;AAC1C,IAAA,CAAC,YAAY,IAA6B,KAAK;IAC/C,CAAC,YAAY,IAAyB,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;IAEnE,KAAa,OAAO,CAAC,GAAA;AACnB,QAAA,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB;;AAGA,IAAA,IAAI,OAAO,GAAA;AACT,QAAA,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB;IAEA,KAAa,KAAK,CAAC,GAAA;AACjB,QAAA,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B;;AAGA,IAAA,IAAI,KAAK,GAAA;AACP,QAAA,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB;AAEA;;;;AAIG;AACH,IAAA,WAAA,CACE,UAA6B,EAC7B,WAAW,GAAG,oBAAoB,EAClC,SAAkB,EAAA;AAElB,QAAA,KAAK,EAAE;AAEP,QAAA,IAAI,CAAC,YAAY,CAAC,GAAG,WAAW;AAChC,QAAA,cAAc,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,CAAC;QACrE,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC9B;AAEA;;;;;;AAMG;IACH,UAAU,CAAC,UAA6B,EAAE,SAAkB,EAAA;AAC1D,QAAA,UAAU,CAAC;AACT,YAAA,OAAO,EAAE,IAAI;AACb,YAAA,SAAS,EAAE;AACT,gBAAA,OAAO,EAAE,OAAO;AAChB,gBAAA,WAAW,EAAE,YAAY;AACzB,gBAAA,MAAM,EAAE,YAAY;AACpB,gBAAA,OAAO,EAAE;AACV,aAAA;YACD,UAAU;AACV,YAAA,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC;YAC/B,SAAS;AACT,YAAA,iBAAiB,EAAE;AACpB,SAAA,CAAC;IACJ;;IAGO,SAAS,GAAA;QACd,IAAI,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;IAC/B;AAEU,IAAA,OAAO,QAAQ,CAAC,CAAC,OAAwB,EAAA;AACjD,QAAA,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC;;AAG5C,QAAA,IAAI,WAAW,CAAC,UAAU,KAAK,MAAM;YAAE;AAEvC,QAAA,IAAI;AACF,YAAA,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAC,GAAG,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC;QACnE;AAAE,QAAA,MAAM;;QAER;IACF;AACD;;;;"}
|
package/rtc/message-service.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var mixin = require('@telperion/js-utils/class/mixin');
|
|
4
|
+
var rtc_messageClient = require('./message-client.cjs');
|
|
5
|
+
var rtc_messageHost = require('./message-host.cjs');
|
|
6
|
+
var rtc_defaultChannelName = require('./default-channel-name.cjs');
|
|
7
|
+
|
|
8
8
|
/**
|
|
9
9
|
* Bidirectional message service for WebRTC DataChannel communication.
|
|
10
10
|
*
|
|
@@ -26,19 +26,19 @@ const default_channel_name_1 = require("./default-channel-name");
|
|
|
26
26
|
* const peer = new GamePeer(peerConnection, 'game-events');
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
|
-
class RTCMessageService extends
|
|
29
|
+
class RTCMessageService extends mixin.mixin(rtc_messageHost.RTCMessageHost, rtc_messageClient.RTCMessageClient) {
|
|
30
30
|
/**
|
|
31
31
|
* @param connection - RTCPeerConnection instance, promise, or factory function.
|
|
32
32
|
* @param channelName - Name for the negotiated data channel.
|
|
33
33
|
* @param channelId - Explicit negotiated channel ID. Overrides the hash-derived default.
|
|
34
34
|
*/
|
|
35
|
-
constructor(connection, channelName =
|
|
35
|
+
constructor(connection, channelName = rtc_defaultChannelName.DEFAULT_CHANNEL_NAME, channelId) {
|
|
36
36
|
super([connection, channelName, channelId], [connection, channelName, channelId]);
|
|
37
37
|
Reflect.defineProperty(this, 'ready', {
|
|
38
38
|
get: () => {
|
|
39
39
|
return Promise.race([
|
|
40
|
-
this[
|
|
41
|
-
this[
|
|
40
|
+
this[rtc_messageClient.READY],
|
|
41
|
+
this[rtc_messageHost.READY]
|
|
42
42
|
]);
|
|
43
43
|
},
|
|
44
44
|
configurable: false
|
|
@@ -46,16 +46,18 @@ class RTCMessageService extends (0, mixin_1.mixin)(message_host_1.RTCMessageHost
|
|
|
46
46
|
Reflect.defineProperty(this, 'created', {
|
|
47
47
|
get: () => {
|
|
48
48
|
return Promise.race([
|
|
49
|
-
this[
|
|
50
|
-
this[
|
|
49
|
+
this[rtc_messageClient.CREATED],
|
|
50
|
+
this[rtc_messageHost.CREATED]
|
|
51
51
|
]);
|
|
52
52
|
},
|
|
53
53
|
configurable: false
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
56
|
initialize = (connection, channelId) => {
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
rtc_messageHost.RTCMessageHost.prototype.initialize.call(this, connection, channelId);
|
|
58
|
+
rtc_messageClient.RTCMessageClient.prototype.initialize.call(this, connection, channelId);
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
|
+
|
|
61
62
|
exports.RTCMessageService = RTCMessageService;
|
|
63
|
+
//# sourceMappingURL=message-service.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-service.cjs","sources":["../../../../libs/messenger/src/rtc/message-service.ts"],"sourcesContent":[null],"names":["mixin","RTCMessageHost","RTCMessageClient","DEFAULT_CHANNEL_NAME","CLIENT_READY","HOST_READY","CLIENT_CREATED","HOST_CREATED"],"mappings":";;;;;;;AAOA;;;;;;;;;;;;;;;;;;;;AAoBG;AACG,MAAO,iBAAkB,SAAQA,WAAK,CAACC,8BAAc,EAAEC,kCAAgB,CAAC,CAAA;AAC5E;;;;AAIG;AACH,IAAA,WAAA,CAAY,UAA6B,EAAE,WAAW,GAAGC,2CAAoB,EAAE,SAAkB,EAAA;AAC/F,QAAA,KAAK,CAAC,CAAC,UAAU,EAAE,WAAW,EAAE,SAAS,CAAC,EAAE,CAAC,UAAU,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;AAEjF,QAAA,OAAO,CAAC,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE;YACpC,GAAG,EAAE,MAAK;gBACR,OAAO,OAAO,CAAC,IAAI,CAAC;oBAClB,IAAI,CAACC,uBAAY,CAAC;oBACjB,IAAY,CAACC,qBAAU;AACzB,iBAAA,CAAC;YACJ,CAAC;AACD,YAAA,YAAY,EAAE;AACf,SAAA,CAAC;AAEF,QAAA,OAAO,CAAC,cAAc,CAAC,IAAI,EAAE,SAAS,EAAE;YACtC,GAAG,EAAE,MAAK;gBACR,OAAO,OAAO,CAAC,IAAI,CAAC;oBAClB,IAAI,CAACC,yBAAc,CAAC;oBACnB,IAAY,CAACC,uBAAY;AAC3B,iBAAA,CAAC;YACJ,CAAC;AACD,YAAA,YAAY,EAAE;AACf,SAAA,CAAC;IACJ;AAEgB,IAAA,UAAU,GAAG,CAAC,UAA4B,EAAE,SAAkB,KAAU;AACtF,QAAAN,8BAAc,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,CAAC;AACrE,QAAAC,kCAAgB,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,CAAC;AACzE,IAAA,CAAC;AACF;;;;"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { RTCMessageClient } from './message-client.cjs';
|
|
2
|
+
import { RTCConnectionArg } from './rtc.type.cjs';
|
|
3
|
+
import 'rxjs';
|
|
4
|
+
import '../message-client.cjs';
|
|
5
|
+
import '../message-response.type.cjs';
|
|
6
|
+
import '../message.interface.cjs';
|
|
7
|
+
import '../selectors.cjs';
|
|
8
|
+
|
|
9
|
+
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]) => {
|
|
10
|
+
readonly created: Promise<RTCDataChannel>;
|
|
11
|
+
readonly ready: Promise<RTCDataChannel>;
|
|
12
|
+
initialize: (connection?: RTCConnectionArg, channelId?: number) => void;
|
|
13
|
+
terminate: () => void;
|
|
14
|
+
} & RTCMessageClient;
|
|
15
|
+
/**
|
|
16
|
+
* Bidirectional message service for WebRTC DataChannel communication.
|
|
17
|
+
*
|
|
18
|
+
* Combines {@link RTCMessageHost} and {@link RTCMessageClient} via mixin,
|
|
19
|
+
* enabling both `@Listen` and `@Request` decorators on the same class.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* class GamePeer extends RTCMessageService {
|
|
24
|
+
* @Request('move')
|
|
25
|
+
* sendMove(pos: [number, number]): Observable<boolean> { return null!; }
|
|
26
|
+
*
|
|
27
|
+
* @Listen('move')
|
|
28
|
+
* handleMove({ data }: { data: [number, number] }): Observable<boolean> {
|
|
29
|
+
* return of(applyMove(data));
|
|
30
|
+
* }
|
|
31
|
+
* }
|
|
32
|
+
*
|
|
33
|
+
* const peer = new GamePeer(peerConnection, 'game-events');
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
declare class RTCMessageService extends RTCMessageService_base {
|
|
37
|
+
/**
|
|
38
|
+
* @param connection - RTCPeerConnection instance, promise, or factory function.
|
|
39
|
+
* @param channelName - Name for the negotiated data channel.
|
|
40
|
+
* @param channelId - Explicit negotiated channel ID. Overrides the hash-derived default.
|
|
41
|
+
*/
|
|
42
|
+
constructor(connection?: RTCConnectionArg, channelName?: string, channelId?: number);
|
|
43
|
+
initialize: (connection: RTCConnectionArg, channelId?: number) => void;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { RTCMessageService };
|
package/rtc/message-service.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import { RTCMessageClient } from
|
|
2
|
-
import { RTCConnectionArg } from
|
|
1
|
+
import { RTCMessageClient } from './message-client.js';
|
|
2
|
+
import { RTCConnectionArg } from './rtc.type.js';
|
|
3
|
+
import 'rxjs';
|
|
4
|
+
import '../message-client.js';
|
|
5
|
+
import '../message-response.type.js';
|
|
6
|
+
import '../message.interface.js';
|
|
7
|
+
import '../selectors.js';
|
|
8
|
+
|
|
3
9
|
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
10
|
readonly created: Promise<RTCDataChannel>;
|
|
5
11
|
readonly ready: Promise<RTCDataChannel>;
|
|
@@ -27,7 +33,7 @@ declare const RTCMessageService_base: new (args_0: [connection?: RTCConnectionAr
|
|
|
27
33
|
* const peer = new GamePeer(peerConnection, 'game-events');
|
|
28
34
|
* ```
|
|
29
35
|
*/
|
|
30
|
-
|
|
36
|
+
declare class RTCMessageService extends RTCMessageService_base {
|
|
31
37
|
/**
|
|
32
38
|
* @param connection - RTCPeerConnection instance, promise, or factory function.
|
|
33
39
|
* @param channelName - Name for the negotiated data channel.
|
|
@@ -36,4 +42,5 @@ export declare class RTCMessageService extends RTCMessageService_base {
|
|
|
36
42
|
constructor(connection?: RTCConnectionArg, channelName?: string, channelId?: number);
|
|
37
43
|
initialize: (connection: RTCConnectionArg, channelId?: number) => void;
|
|
38
44
|
}
|
|
39
|
-
|
|
45
|
+
|
|
46
|
+
export { RTCMessageService };
|
package/rtc/message-service.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { mixin } from
|
|
2
|
-
import { READY
|
|
3
|
-
import { READY as
|
|
4
|
-
import { DEFAULT_CHANNEL_NAME } from
|
|
1
|
+
import { mixin } from '@telperion/js-utils/class/mixin';
|
|
2
|
+
import { RTCMessageClient, READY, CREATED } from './message-client.js';
|
|
3
|
+
import { RTCMessageHost, READY as READY$1, CREATED as CREATED$1 } from './message-host.js';
|
|
4
|
+
import { DEFAULT_CHANNEL_NAME } from './default-channel-name.js';
|
|
5
|
+
|
|
5
6
|
/**
|
|
6
7
|
* Bidirectional message service for WebRTC DataChannel communication.
|
|
7
8
|
*
|
|
@@ -23,7 +24,7 @@ import { DEFAULT_CHANNEL_NAME } from "./default-channel-name";
|
|
|
23
24
|
* const peer = new GamePeer(peerConnection, 'game-events');
|
|
24
25
|
* ```
|
|
25
26
|
*/
|
|
26
|
-
|
|
27
|
+
class RTCMessageService extends mixin(RTCMessageHost, RTCMessageClient) {
|
|
27
28
|
/**
|
|
28
29
|
* @param connection - RTCPeerConnection instance, promise, or factory function.
|
|
29
30
|
* @param channelName - Name for the negotiated data channel.
|
|
@@ -34,8 +35,8 @@ export class RTCMessageService extends mixin(RTCMessageHost, RTCMessageClient) {
|
|
|
34
35
|
Reflect.defineProperty(this, 'ready', {
|
|
35
36
|
get: () => {
|
|
36
37
|
return Promise.race([
|
|
37
|
-
this[
|
|
38
|
-
this[
|
|
38
|
+
this[READY],
|
|
39
|
+
this[READY$1]
|
|
39
40
|
]);
|
|
40
41
|
},
|
|
41
42
|
configurable: false
|
|
@@ -43,8 +44,8 @@ export class RTCMessageService extends mixin(RTCMessageHost, RTCMessageClient) {
|
|
|
43
44
|
Reflect.defineProperty(this, 'created', {
|
|
44
45
|
get: () => {
|
|
45
46
|
return Promise.race([
|
|
46
|
-
this[
|
|
47
|
-
this[
|
|
47
|
+
this[CREATED],
|
|
48
|
+
this[CREATED$1]
|
|
48
49
|
]);
|
|
49
50
|
},
|
|
50
51
|
configurable: false
|
|
@@ -56,4 +57,5 @@ export class RTCMessageService extends mixin(RTCMessageHost, RTCMessageClient) {
|
|
|
56
57
|
};
|
|
57
58
|
}
|
|
58
59
|
|
|
60
|
+
export { RTCMessageService };
|
|
59
61
|
//# sourceMappingURL=message-service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"file":"message-service.js","sources":["../../../../libs/messenger/src/rtc/message-service.ts"],"sourcesContent":[null],"names":["CLIENT_READY","HOST_READY","CLIENT_CREATED","HOST_CREATED"],"mappings":";;;;;AAOA;;;;;;;;;;;;;;;;;;;;AAoBG;AACG,MAAO,iBAAkB,SAAQ,KAAK,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAA;AAC5E;;;;AAIG;AACH,IAAA,WAAA,CAAY,UAA6B,EAAE,WAAW,GAAG,oBAAoB,EAAE,SAAkB,EAAA;AAC/F,QAAA,KAAK,CAAC,CAAC,UAAU,EAAE,WAAW,EAAE,SAAS,CAAC,EAAE,CAAC,UAAU,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;AAEjF,QAAA,OAAO,CAAC,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE;YACpC,GAAG,EAAE,MAAK;gBACR,OAAO,OAAO,CAAC,IAAI,CAAC;oBAClB,IAAI,CAACA,KAAY,CAAC;oBACjB,IAAY,CAACC,OAAU;AACzB,iBAAA,CAAC;YACJ,CAAC;AACD,YAAA,YAAY,EAAE;AACf,SAAA,CAAC;AAEF,QAAA,OAAO,CAAC,cAAc,CAAC,IAAI,EAAE,SAAS,EAAE;YACtC,GAAG,EAAE,MAAK;gBACR,OAAO,OAAO,CAAC,IAAI,CAAC;oBAClB,IAAI,CAACC,OAAc,CAAC;oBACnB,IAAY,CAACC,SAAY;AAC3B,iBAAA,CAAC;YACJ,CAAC;AACD,YAAA,YAAY,EAAE;AACf,SAAA,CAAC;IACJ;AAEgB,IAAA,UAAU,GAAG,CAAC,UAA4B,EAAE,SAAkB,KAAU;AACtF,QAAA,cAAc,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,CAAC;AACrE,QAAA,gBAAgB,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,CAAC;AACzE,IAAA,CAAC;AACF;;;;"}
|
package/rtc/rtc.type.cjs
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
//# sourceMappingURL=rtc.type.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rtc.type.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** An RTCPeerConnection instance or `undefined` if not yet available. */
|
|
2
|
+
type RTCConnectionType = RTCPeerConnection | undefined;
|
|
3
|
+
/** A promise that resolves to an RTCPeerConnection (or `undefined`). */
|
|
4
|
+
type RTCConnectionPromise = Promise<RTCConnectionType>;
|
|
5
|
+
/** A factory function that returns an RTCPeerConnection synchronously or asynchronously. */
|
|
6
|
+
type RTCConnectionFactory = () => RTCConnectionType | RTCConnectionPromise;
|
|
7
|
+
/**
|
|
8
|
+
* Flexible connection argument accepted by RTC message classes.
|
|
9
|
+
*
|
|
10
|
+
* Supports direct instances, promises, and factory functions for lazy or async initialization.
|
|
11
|
+
*/
|
|
12
|
+
type RTCConnectionArg = RTCConnectionType | RTCConnectionPromise | RTCConnectionFactory;
|
|
13
|
+
|
|
14
|
+
export type { RTCConnectionArg, RTCConnectionFactory, RTCConnectionPromise, RTCConnectionType };
|
package/rtc/rtc.type.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/** An RTCPeerConnection instance or `undefined` if not yet available. */
|
|
2
|
-
|
|
2
|
+
type RTCConnectionType = RTCPeerConnection | undefined;
|
|
3
3
|
/** A promise that resolves to an RTCPeerConnection (or `undefined`). */
|
|
4
|
-
|
|
4
|
+
type RTCConnectionPromise = Promise<RTCConnectionType>;
|
|
5
5
|
/** A factory function that returns an RTCPeerConnection synchronously or asynchronously. */
|
|
6
|
-
|
|
6
|
+
type RTCConnectionFactory = () => RTCConnectionType | RTCConnectionPromise;
|
|
7
7
|
/**
|
|
8
8
|
* Flexible connection argument accepted by RTC message classes.
|
|
9
9
|
*
|
|
10
10
|
* Supports direct instances, promises, and factory functions for lazy or async initialization.
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
type RTCConnectionArg = RTCConnectionType | RTCConnectionPromise | RTCConnectionFactory;
|
|
13
|
+
|
|
14
|
+
export type { RTCConnectionArg, RTCConnectionFactory, RTCConnectionPromise, RTCConnectionType };
|
package/rtc/rtc.type.js
CHANGED
package/rtc/rtc.type.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"rtc.type.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/selectors.cjs
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const MESSAGE_LISTENERS = Symbol('Message Listeners');
|
|
4
|
+
const RESPONSES$ = Symbol('Responses');
|
|
5
|
+
const SEND = Symbol('Send');
|
|
6
|
+
const GET_NEW_ID = Symbol('Get New Id');
|
|
7
|
+
const LISTEN = Symbol('Listen');
|
|
8
|
+
const TERMINATE_MESSAGE$ = Symbol('Terminate Message');
|
|
9
|
+
const RESPONSE = Symbol('Response');
|
|
10
|
+
|
|
11
|
+
exports.GET_NEW_ID = GET_NEW_ID;
|
|
12
|
+
exports.LISTEN = LISTEN;
|
|
13
|
+
exports.MESSAGE_LISTENERS = MESSAGE_LISTENERS;
|
|
14
|
+
exports.RESPONSE = RESPONSE;
|
|
15
|
+
exports.RESPONSES$ = RESPONSES$;
|
|
16
|
+
exports.SEND = SEND;
|
|
17
|
+
exports.TERMINATE_MESSAGE$ = TERMINATE_MESSAGE$;
|
|
18
|
+
//# sourceMappingURL=selectors.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectors.cjs","sources":["../../../libs/messenger/src/selectors.ts"],"sourcesContent":[null],"names":[],"mappings":";;MAAa,iBAAiB,GAAG,MAAM,CAAC,mBAAmB;MAC9C,UAAU,GAAG,MAAM,CAAC,WAAW;MAC/B,IAAI,GAAG,MAAM,CAAC,MAAM;MACpB,UAAU,GAAG,MAAM,CAAC,YAAY;MAChC,MAAM,GAAG,MAAM,CAAC,QAAQ;MACxB,kBAAkB,GAAG,MAAM,CAAC,mBAAmB;MAC/C,QAAQ,GAAG,MAAM,CAAC,UAAU;;;;;;;;;;"}
|
package/selectors.d.cts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare const MESSAGE_LISTENERS: unique symbol;
|
|
2
|
+
declare const RESPONSES$: unique symbol;
|
|
3
|
+
declare const SEND: unique symbol;
|
|
4
|
+
declare const GET_NEW_ID: unique symbol;
|
|
5
|
+
declare const LISTEN: unique symbol;
|
|
6
|
+
declare const TERMINATE_MESSAGE$: unique symbol;
|
|
7
|
+
declare const RESPONSE: unique symbol;
|
|
8
|
+
|
|
9
|
+
export { GET_NEW_ID, LISTEN, MESSAGE_LISTENERS, RESPONSE, RESPONSES$, SEND, TERMINATE_MESSAGE$ };
|
package/selectors.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
declare const MESSAGE_LISTENERS: unique symbol;
|
|
2
|
+
declare const RESPONSES$: unique symbol;
|
|
3
|
+
declare const SEND: unique symbol;
|
|
4
|
+
declare const GET_NEW_ID: unique symbol;
|
|
5
|
+
declare const LISTEN: unique symbol;
|
|
6
|
+
declare const TERMINATE_MESSAGE$: unique symbol;
|
|
7
|
+
declare const RESPONSE: unique symbol;
|
|
8
|
+
|
|
9
|
+
export { GET_NEW_ID, LISTEN, MESSAGE_LISTENERS, RESPONSE, RESPONSES$, SEND, TERMINATE_MESSAGE$ };
|
package/selectors.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
const MESSAGE_LISTENERS = Symbol('Message Listeners');
|
|
2
|
+
const RESPONSES$ = Symbol('Responses');
|
|
3
|
+
const SEND = Symbol('Send');
|
|
4
|
+
const GET_NEW_ID = Symbol('Get New Id');
|
|
5
|
+
const LISTEN = Symbol('Listen');
|
|
6
|
+
const TERMINATE_MESSAGE$ = Symbol('Terminate Message');
|
|
7
|
+
const RESPONSE = Symbol('Response');
|
|
8
8
|
|
|
9
|
+
export { GET_NEW_ID, LISTEN, MESSAGE_LISTENERS, RESPONSE, RESPONSES$, SEND, TERMINATE_MESSAGE$ };
|
|
9
10
|
//# sourceMappingURL=selectors.js.map
|
package/selectors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["
|
|
1
|
+
{"version":3,"file":"selectors.js","sources":["../../../libs/messenger/src/selectors.ts"],"sourcesContent":[null],"names":[],"mappings":"MAAa,iBAAiB,GAAG,MAAM,CAAC,mBAAmB;MAC9C,UAAU,GAAG,MAAM,CAAC,WAAW;MAC/B,IAAI,GAAG,MAAM,CAAC,MAAM;MACpB,UAAU,GAAG,MAAM,CAAC,YAAY;MAChC,MAAM,GAAG,MAAM,CAAC,QAAQ;MACxB,kBAAkB,GAAG,MAAM,CAAC,mBAAmB;MAC/C,QAAQ,GAAG,MAAM,CAAC,UAAU;;;;"}
|
package/worker/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 worker_messageService = require('./message-service.cjs');
|
|
4
|
+
var worker_messageClient = require('./message-client.cjs');
|
|
5
|
+
var worker_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.WorkerMessageService = worker_messageService.WorkerMessageService;
|
|
12
|
+
exports.WorkerMessageClient = worker_messageClient.WorkerMessageClient;
|
|
13
|
+
exports.WorkerMessageHost = worker_messageHost.WorkerMessageHost;
|
|
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":";;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { WorkerMessageService } from './message-service.cjs';
|
|
2
|
+
export { WorkerMessageClient } from './message-client.cjs';
|
|
3
|
+
export { WorkerMessageHost } from './message-host.cjs';
|
|
4
|
+
export { Request, RequestOptions, SingleRequestDecorator } from '../request.decorator.cjs';
|
|
5
|
+
export { Listen } from '../listen.decorator.cjs';
|
|
6
|
+
import './initializer.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/worker/index.d.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
export { WorkerMessageService } from './message-service';
|
|
2
|
-
export { WorkerMessageClient } from './message-client';
|
|
3
|
-
export { WorkerMessageHost } from './message-host';
|
|
4
|
-
export { Request } from '../request.decorator';
|
|
5
|
-
export { Listen } from '../listen.decorator';
|
|
1
|
+
export { WorkerMessageService } from './message-service.js';
|
|
2
|
+
export { WorkerMessageClient } from './message-client.js';
|
|
3
|
+
export { WorkerMessageHost } from './message-host.js';
|
|
4
|
+
export { Request, RequestOptions, SingleRequestDecorator } from '../request.decorator.js';
|
|
5
|
+
export { Listen } from '../listen.decorator.js';
|
|
6
|
+
import './initializer.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/worker/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
export { WorkerMessageService } from './message-service';
|
|
2
|
-
export { WorkerMessageClient } from './message-client';
|
|
3
|
-
export { WorkerMessageHost } from './message-host';
|
|
4
|
-
export { Request } from '../request.decorator';
|
|
5
|
-
export { Listen } from '../listen.decorator';
|
|
6
|
-
|
|
1
|
+
export { WorkerMessageService } from './message-service.js';
|
|
2
|
+
export { WorkerMessageClient } from './message-client.js';
|
|
3
|
+
export { WorkerMessageHost } 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/worker/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
package/worker/initializer.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var noop = require('@telperion/js-utils/function/noop');
|
|
4
|
+
var promisify = require('@telperion/js-utils/promise/promisify');
|
|
5
|
+
|
|
6
6
|
/**
|
|
7
7
|
* Initializes a Web Worker or the worker context for message communication.
|
|
8
8
|
* @param prevWorker The previous worker promise to deinitialize
|
|
@@ -19,11 +19,11 @@ function initializer(prevWorker, worker, handler) {
|
|
|
19
19
|
else {
|
|
20
20
|
removeEventListener('message', handler);
|
|
21
21
|
}
|
|
22
|
-
}).catch(
|
|
22
|
+
}).catch(noop.noop);
|
|
23
23
|
// Resolve worker parameter: execute function if provided, otherwise use value directly
|
|
24
24
|
const _worker = typeof worker === 'function' ? worker() : worker;
|
|
25
25
|
// Ensure worker is wrapped in a promise for consistent async handling
|
|
26
|
-
const newWorker =
|
|
26
|
+
const newWorker = promisify.promisify(_worker);
|
|
27
27
|
// Set up message listener once worker is resolved
|
|
28
28
|
newWorker.then(worker => {
|
|
29
29
|
if (worker) {
|
|
@@ -34,6 +34,9 @@ function initializer(prevWorker, worker, handler) {
|
|
|
34
34
|
// Worker thread context: listen to messages from main thread
|
|
35
35
|
addEventListener('message', handler);
|
|
36
36
|
}
|
|
37
|
-
}).catch(
|
|
37
|
+
}).catch(noop.noop);
|
|
38
38
|
return newWorker;
|
|
39
39
|
}
|
|
40
|
+
|
|
41
|
+
exports.initializer = initializer;
|
|
42
|
+
//# sourceMappingURL=initializer.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initializer.cjs","sources":["../../../../libs/messenger/src/worker/initializer.ts"],"sourcesContent":[null],"names":["noop","promisify"],"mappings":";;;;;AAQA;;;;;;AAMG;SACa,WAAW,CACzB,UAA+B,EAC/B,MAAuB,EACvB,OAAsC,EAAA;;AAGtC,IAAA,UAAU,CAAC,IAAI,CAAC,EAAE,IAAG;QACnB,IAAI,EAAE,EAAE;AACN,YAAA,EAAE,CAAC,mBAAmB,CAAC,SAAS,EAAE,OAAO,CAAC;QAC5C;aAAO;AACL,YAAA,mBAAmB,CAAC,SAAS,EAAE,OAAO,CAAC;QACzC;AACF,IAAA,CAAC,CAAC,CAAC,KAAK,CAACA,SAAI,CAAC;;AAGd,IAAA,MAAM,OAAO,GAAuD,OAAO,MAAM,KAAK,UAAU,GAAG,MAAM,EAAE,GAAG,MAAM;;AAEpH,IAAA,MAAM,SAAS,GAAGC,mBAAS,CAAC,OAAO,CAAC;;AAGpC,IAAA,SAAS,CAAC,IAAI,CAAC,MAAM,IAAG;QACtB,IAAI,MAAM,EAAE;;AAEV,YAAA,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC;QAC7C;aAAO;;AAEL,YAAA,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC;QACtC;AACF,IAAA,CAAC,CAAC,CAAC,KAAK,CAACD,SAAI,CAAC;AAEd,IAAA,OAAO,SAAS;AAClB;;;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type ClientWorkerType = Worker | undefined;
|
|
2
|
+
type ClientWorkerPromise = Promise<ClientWorkerType>;
|
|
3
|
+
type ClientWorkerFactory = () => ClientWorkerType | ClientWorkerPromise;
|
|
4
|
+
type ClientWorkerArg = ClientWorkerType | ClientWorkerPromise | ClientWorkerFactory;
|
|
5
|
+
/**
|
|
6
|
+
* Initializes a Web Worker or the worker context for message communication.
|
|
7
|
+
* @param prevWorker The previous worker promise to deinitialize
|
|
8
|
+
* @param worker The new worker argument (Worker instance, promise, or factory function)
|
|
9
|
+
* @param handler The message event handler to attach
|
|
10
|
+
* @returns A promise resolving to the initialized Worker or undefined if in worker context
|
|
11
|
+
*/
|
|
12
|
+
declare function initializer(prevWorker: ClientWorkerPromise, worker: ClientWorkerArg, handler: (event: MessageEvent) => void): Promise<Worker | undefined>;
|
|
13
|
+
|
|
14
|
+
export { initializer };
|
|
15
|
+
export type { ClientWorkerArg, ClientWorkerFactory, ClientWorkerPromise, ClientWorkerType };
|
package/worker/initializer.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
type ClientWorkerType = Worker | undefined;
|
|
2
|
+
type ClientWorkerPromise = Promise<ClientWorkerType>;
|
|
3
|
+
type ClientWorkerFactory = () => ClientWorkerType | ClientWorkerPromise;
|
|
4
|
+
type ClientWorkerArg = ClientWorkerType | ClientWorkerPromise | ClientWorkerFactory;
|
|
5
5
|
/**
|
|
6
6
|
* Initializes a Web Worker or the worker context for message communication.
|
|
7
7
|
* @param prevWorker The previous worker promise to deinitialize
|
|
@@ -9,4 +9,7 @@ export type ClientWorkerArg = ClientWorkerType | ClientWorkerPromise | ClientWor
|
|
|
9
9
|
* @param handler The message event handler to attach
|
|
10
10
|
* @returns A promise resolving to the initialized Worker or undefined if in worker context
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
declare function initializer(prevWorker: ClientWorkerPromise, worker: ClientWorkerArg, handler: (event: MessageEvent) => void): Promise<Worker | undefined>;
|
|
13
|
+
|
|
14
|
+
export { initializer };
|
|
15
|
+
export type { ClientWorkerArg, ClientWorkerFactory, ClientWorkerPromise, ClientWorkerType };
|