@100mslive/react-native-hms 1.4.0 → 1.6.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/android/build.gradle +3 -2
- package/android/src/main/java/com/reactnativehmssdk/HMSDecoder.kt +189 -55
- package/android/src/main/java/com/reactnativehmssdk/HMSHelper.kt +1 -0
- package/android/src/main/java/com/reactnativehmssdk/HMSManager.kt +94 -38
- package/android/src/main/java/com/reactnativehmssdk/HMSRNSDK.kt +446 -107
- package/android/src/main/java/com/reactnativehmssdk/HMSSDKViewManager.kt +5 -0
- package/android/src/main/java/com/reactnativehmssdk/HMSView.kt +42 -25
- package/android/src/main/res/layout/hms_view.xml +2 -2
- package/ios/HMSConstants.swift +33 -0
- package/ios/HMSDecoder.swift +372 -157
- package/ios/HMSHelper.swift +44 -7
- package/ios/HMSManager.m +17 -2
- package/ios/HMSManager.swift +177 -75
- package/ios/HMSRNSDK.swift +641 -199
- package/ios/HMSView.m +1 -0
- package/ios/HMSView.swift +21 -19
- package/lib/commonjs/classes/HMSAudioTrackSettings.js +14 -0
- package/lib/commonjs/classes/HMSAudioTrackSettings.js.map +1 -1
- package/lib/commonjs/classes/HMSCameraControl.js +28 -0
- package/lib/commonjs/classes/HMSCameraControl.js.map +1 -0
- package/lib/commonjs/classes/HMSEncoder.js +97 -14
- package/lib/commonjs/classes/HMSEncoder.js.map +1 -1
- package/lib/commonjs/classes/HMSIOSAudioMode.js +13 -0
- package/lib/commonjs/classes/HMSIOSAudioMode.js.map +1 -0
- package/lib/commonjs/classes/HMSLayer.js +14 -0
- package/lib/commonjs/classes/HMSLayer.js.map +1 -0
- package/lib/commonjs/classes/HMSLocalVideoStats.js +11 -0
- package/lib/commonjs/classes/HMSLocalVideoStats.js.map +1 -1
- package/lib/commonjs/classes/HMSPeer.js +1 -1
- package/lib/commonjs/classes/HMSPeer.js.map +1 -1
- package/lib/commonjs/classes/HMSPublishSettings.js +2 -0
- package/lib/commonjs/classes/HMSPublishSettings.js.map +1 -1
- package/lib/commonjs/classes/HMSQualityLimitationReason.js +16 -0
- package/lib/commonjs/classes/HMSQualityLimitationReason.js.map +1 -0
- package/lib/commonjs/classes/HMSQualityLimitationReasons.js +27 -0
- package/lib/commonjs/classes/HMSQualityLimitationReasons.js.map +1 -0
- package/lib/commonjs/classes/HMSRemotePeer.js.map +1 -1
- package/lib/commonjs/classes/HMSRemoteVideoTrack.js +39 -3
- package/lib/commonjs/classes/HMSRemoteVideoTrack.js.map +1 -1
- package/lib/commonjs/classes/HMSRoom.js +4 -0
- package/lib/commonjs/classes/HMSRoom.js.map +1 -1
- package/lib/commonjs/classes/HMSRoomUpdate.js +1 -0
- package/lib/commonjs/classes/HMSRoomUpdate.js.map +1 -1
- package/lib/commonjs/classes/HMSSDK.js +82 -45
- package/lib/commonjs/classes/HMSSDK.js.map +1 -1
- package/lib/commonjs/classes/HMSSessionStore.js +173 -0
- package/lib/commonjs/classes/HMSSessionStore.js.map +1 -0
- package/lib/commonjs/classes/HMSSimulcastLayerDefinition.js +19 -0
- package/lib/commonjs/classes/HMSSimulcastLayerDefinition.js.map +1 -0
- package/lib/commonjs/classes/HMSSimulcastLayerSettingsPolicy.js +23 -0
- package/lib/commonjs/classes/HMSSimulcastLayerSettingsPolicy.js.map +1 -0
- package/lib/commonjs/classes/HMSSimulcastSettings.js +5 -4
- package/lib/commonjs/classes/HMSSimulcastSettings.js.map +1 -1
- package/lib/commonjs/classes/HMSSimulcastSettingsPolicy.js +17 -0
- package/lib/commonjs/classes/HMSSimulcastSettingsPolicy.js.map +1 -0
- package/lib/commonjs/classes/HMSSubscribeDegradationPolicy.js +21 -0
- package/lib/commonjs/classes/HMSSubscribeDegradationPolicy.js.map +1 -0
- package/lib/commonjs/classes/HMSSubscribeSettings.js +2 -0
- package/lib/commonjs/classes/HMSSubscribeSettings.js.map +1 -1
- package/lib/commonjs/classes/HMSUpdateListenerActions.js +8 -0
- package/lib/commonjs/classes/HMSUpdateListenerActions.js.map +1 -1
- package/lib/commonjs/classes/HMSVideoResolution.js.map +1 -1
- package/lib/commonjs/classes/HMSVideoTrackSettings.js +5 -0
- package/lib/commonjs/classes/HMSVideoTrackSettings.js.map +1 -1
- package/lib/commonjs/classes/HmsView.js +2 -0
- package/lib/commonjs/classes/HmsView.js.map +1 -1
- package/lib/commonjs/index.js +72 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/utils/emitter/EventEmitter.js +162 -0
- package/lib/commonjs/utils/emitter/EventEmitter.js.map +1 -0
- package/lib/commonjs/utils/emitter/_EmitterSubscription.js +46 -0
- package/lib/commonjs/utils/emitter/_EmitterSubscription.js.map +1 -0
- package/lib/commonjs/utils/emitter/_EventSubscription.js +36 -0
- package/lib/commonjs/utils/emitter/_EventSubscription.js.map +1 -0
- package/lib/commonjs/utils/emitter/_EventSubscriptionVendor.js +90 -0
- package/lib/commonjs/utils/emitter/_EventSubscriptionVendor.js.map +1 -0
- package/lib/commonjs/utils/index.js +17 -0
- package/lib/commonjs/utils/index.js.map +1 -0
- package/lib/module/classes/HMSAudioTrackSettings.js +14 -0
- package/lib/module/classes/HMSAudioTrackSettings.js.map +1 -1
- package/lib/module/classes/HMSCameraControl.js +21 -0
- package/lib/module/classes/HMSCameraControl.js.map +1 -0
- package/lib/module/classes/HMSEncoder.js +97 -14
- package/lib/module/classes/HMSEncoder.js.map +1 -1
- package/lib/module/classes/HMSIOSAudioMode.js +6 -0
- package/lib/module/classes/HMSIOSAudioMode.js.map +1 -0
- package/lib/module/classes/HMSLayer.js +7 -0
- package/lib/module/classes/HMSLayer.js.map +1 -0
- package/lib/module/classes/HMSLocalVideoStats.js +11 -0
- package/lib/module/classes/HMSLocalVideoStats.js.map +1 -1
- package/lib/module/classes/HMSPeer.js +1 -1
- package/lib/module/classes/HMSPeer.js.map +1 -1
- package/lib/module/classes/HMSPublishSettings.js +2 -0
- package/lib/module/classes/HMSPublishSettings.js.map +1 -1
- package/lib/module/classes/HMSQualityLimitationReason.js +9 -0
- package/lib/module/classes/HMSQualityLimitationReason.js.map +1 -0
- package/lib/module/classes/HMSQualityLimitationReasons.js +20 -0
- package/lib/module/classes/HMSQualityLimitationReasons.js.map +1 -0
- package/lib/module/classes/HMSRemotePeer.js.map +1 -1
- package/lib/module/classes/HMSRemoteVideoTrack.js +39 -3
- package/lib/module/classes/HMSRemoteVideoTrack.js.map +1 -1
- package/lib/module/classes/HMSRoom.js +4 -0
- package/lib/module/classes/HMSRoom.js.map +1 -1
- package/lib/module/classes/HMSRoomUpdate.js +1 -0
- package/lib/module/classes/HMSRoomUpdate.js.map +1 -1
- package/lib/module/classes/HMSSDK.js +83 -45
- package/lib/module/classes/HMSSDK.js.map +1 -1
- package/lib/module/classes/HMSSessionStore.js +166 -0
- package/lib/module/classes/HMSSessionStore.js.map +1 -0
- package/lib/module/classes/HMSSimulcastLayerDefinition.js +12 -0
- package/lib/module/classes/HMSSimulcastLayerDefinition.js.map +1 -0
- package/lib/module/classes/HMSSimulcastLayerSettingsPolicy.js +16 -0
- package/lib/module/classes/HMSSimulcastLayerSettingsPolicy.js.map +1 -0
- package/lib/module/classes/HMSSimulcastSettings.js +5 -4
- package/lib/module/classes/HMSSimulcastSettings.js.map +1 -1
- package/lib/module/classes/HMSSimulcastSettingsPolicy.js +10 -0
- package/lib/module/classes/HMSSimulcastSettingsPolicy.js.map +1 -0
- package/lib/module/classes/HMSSubscribeDegradationPolicy.js +14 -0
- package/lib/module/classes/HMSSubscribeDegradationPolicy.js.map +1 -0
- package/lib/module/classes/HMSSubscribeSettings.js +2 -0
- package/lib/module/classes/HMSSubscribeSettings.js.map +1 -1
- package/lib/module/classes/HMSUpdateListenerActions.js +8 -0
- package/lib/module/classes/HMSUpdateListenerActions.js.map +1 -1
- package/lib/module/classes/HMSVideoResolution.js.map +1 -1
- package/lib/module/classes/HMSVideoTrackSettings.js +5 -0
- package/lib/module/classes/HMSVideoTrackSettings.js.map +1 -1
- package/lib/module/classes/HmsView.js +2 -0
- package/lib/module/classes/HmsView.js.map +1 -1
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/emitter/EventEmitter.js +151 -0
- package/lib/module/utils/emitter/EventEmitter.js.map +1 -0
- package/lib/module/utils/emitter/_EmitterSubscription.js +39 -0
- package/lib/module/utils/emitter/_EmitterSubscription.js.map +1 -0
- package/lib/module/utils/emitter/_EventSubscription.js +29 -0
- package/lib/module/utils/emitter/_EventSubscription.js.map +1 -0
- package/lib/module/utils/emitter/_EventSubscriptionVendor.js +83 -0
- package/lib/module/utils/emitter/_EventSubscriptionVendor.js.map +1 -0
- package/lib/module/utils/index.js +2 -0
- package/lib/module/utils/index.js.map +1 -0
- package/lib/typescript/classes/HMSAudioTrackSettings.d.ts +14 -0
- package/lib/typescript/classes/HMSCameraControl.d.ts +9 -0
- package/lib/typescript/classes/HMSEncoder.d.ts +13 -1
- package/lib/typescript/classes/HMSIOSAudioMode.d.ts +4 -0
- package/lib/typescript/classes/HMSLayer.d.ts +5 -0
- package/lib/typescript/classes/HMSLocalVideoStats.d.ts +6 -0
- package/lib/typescript/classes/HMSPeer.d.ts +1 -1
- package/lib/typescript/classes/HMSPublishSettings.d.ts +3 -0
- package/lib/typescript/classes/HMSQualityLimitationReason.d.ts +7 -0
- package/lib/typescript/classes/HMSQualityLimitationReasons.d.ts +17 -0
- package/lib/typescript/classes/HMSRemotePeer.d.ts +0 -1
- package/lib/typescript/classes/HMSRemoteVideoTrack.d.ts +6 -2
- package/lib/typescript/classes/HMSRoomUpdate.d.ts +2 -1
- package/lib/typescript/classes/HMSSDK.d.ts +21 -31
- package/lib/typescript/classes/HMSSessionStore.d.ts +63 -0
- package/lib/typescript/classes/HMSSimulcastLayerDefinition.d.ts +10 -0
- package/lib/typescript/classes/HMSSimulcastLayerSettingsPolicy.d.ts +12 -0
- package/lib/typescript/classes/HMSSimulcastSettings.d.ts +7 -3
- package/lib/typescript/classes/HMSSimulcastSettingsPolicy.d.ts +7 -0
- package/lib/typescript/classes/HMSSubscribeDegradationPolicy.d.ts +10 -0
- package/lib/typescript/classes/HMSSubscribeSettings.d.ts +5 -2
- package/lib/typescript/classes/HMSUpdateListenerActions.d.ts +9 -1
- package/lib/typescript/classes/HMSVideoResolution.d.ts +2 -2
- package/lib/typescript/classes/HMSVideoTrackSettings.d.ts +5 -0
- package/lib/typescript/classes/HmsView.d.ts +2 -2
- package/lib/typescript/index.d.ts +7 -0
- package/lib/typescript/utils/emitter/EventEmitter.d.ts +91 -0
- package/lib/typescript/utils/emitter/_EmitterSubscription.d.ts +29 -0
- package/lib/typescript/utils/emitter/_EventSubscription.d.ts +19 -0
- package/lib/typescript/utils/emitter/_EventSubscriptionVendor.d.ts +44 -0
- package/lib/typescript/utils/index.d.ts +1 -0
- package/package.json +21 -2
- package/sdk-versions.json +3 -3
- package/src/classes/HMSAudioTrackSettings.ts +16 -0
- package/src/classes/HMSCameraControl.ts +21 -0
- package/src/classes/HMSEncoder.ts +126 -11
- package/src/classes/HMSIOSAudioMode.ts +4 -0
- package/src/classes/HMSLayer.ts +5 -0
- package/src/classes/HMSLocalVideoStats.ts +21 -0
- package/src/classes/HMSPeer.ts +1 -1
- package/src/classes/HMSPublishSettings.ts +4 -0
- package/src/classes/HMSQualityLimitationReason.ts +7 -0
- package/src/classes/HMSQualityLimitationReasons.ts +27 -0
- package/src/classes/HMSRemotePeer.ts +0 -1
- package/src/classes/HMSRemoteVideoTrack.ts +52 -4
- package/src/classes/HMSRoom.ts +2 -0
- package/src/classes/HMSRoomUpdate.ts +1 -0
- package/src/classes/HMSSDK.tsx +124 -52
- package/src/classes/HMSSessionStore.ts +209 -0
- package/src/classes/HMSSimulcastLayerDefinition.ts +12 -0
- package/src/classes/HMSSimulcastLayerSettingsPolicy.ts +18 -0
- package/src/classes/HMSSimulcastSettings.ts +12 -3
- package/src/classes/HMSSimulcastSettingsPolicy.ts +9 -0
- package/src/classes/HMSSubscribeDegradationPolicy.ts +15 -0
- package/src/classes/HMSSubscribeSettings.ts +10 -2
- package/src/classes/HMSUpdateListenerActions.ts +8 -0
- package/src/classes/HMSVideoResolution.ts +1 -1
- package/src/classes/HMSVideoTrackSettings.ts +5 -0
- package/src/classes/HmsView.tsx +5 -1
- package/src/index.ts +10 -0
- package/src/utils/emitter/EventEmitter.ts +160 -0
- package/src/utils/emitter/_EmitterSubscription.ts +44 -0
- package/src/utils/emitter/_EventSubscription.ts +28 -0
- package/src/utils/emitter/_EventSubscriptionVendor.ts +89 -0
- package/src/utils/index.ts +1 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
3
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
4
|
+
import { EmitterSubscription } from './_EmitterSubscription';
|
|
5
|
+
import { EventSubscriptionVendor } from './_EventSubscriptionVendor';
|
|
6
|
+
const sparseFilterPredicate = () => true;
|
|
7
|
+
export { EmitterSubscription } from './_EmitterSubscription';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @class EventEmitter
|
|
11
|
+
* @description
|
|
12
|
+
* An EventEmitter is responsible for managing a set of listeners and publishing
|
|
13
|
+
* events to them when it is told that such events happened. In addition to the
|
|
14
|
+
* data for the given event it also sends a event control object which allows
|
|
15
|
+
* the listeners/handlers to prevent the default behavior of the given event.
|
|
16
|
+
*
|
|
17
|
+
* The emitter is designed to be generic enough to support all the different
|
|
18
|
+
* contexts in which one might want to emit events. It is a simple multicast
|
|
19
|
+
* mechanism on top of which extra functionality can be composed. For example, a
|
|
20
|
+
* more advanced emitter may use an EventHolder and EventFactory.
|
|
21
|
+
*/
|
|
22
|
+
export class EventEmitter {
|
|
23
|
+
/**
|
|
24
|
+
* @constructor
|
|
25
|
+
*
|
|
26
|
+
* @param {EventSubscriptionVendor} subscriber - Optional subscriber instance
|
|
27
|
+
* to use. If omitted, a new subscriber will be created for the emitter.
|
|
28
|
+
*/
|
|
29
|
+
constructor(subscriber) {
|
|
30
|
+
_defineProperty(this, "_subscriber", void 0);
|
|
31
|
+
this._subscriber = subscriber || new EventSubscriptionVendor();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Adds a listener to be invoked when events of the specified type are
|
|
36
|
+
* emitted. An optional calling context may be provided. The data arguments
|
|
37
|
+
* emitted will be passed to the listener function.
|
|
38
|
+
*
|
|
39
|
+
* TODO: Annotate the listener arg's type. This is tricky because listeners
|
|
40
|
+
* can be invoked with varargs.
|
|
41
|
+
*
|
|
42
|
+
* @param {string} eventType - Name of the event to listen to
|
|
43
|
+
* @param {function} listener - Function to invoke when the specified event is
|
|
44
|
+
* emitted
|
|
45
|
+
* @param {*} context - Optional context object to use when invoking the
|
|
46
|
+
* listener
|
|
47
|
+
*/
|
|
48
|
+
addListener(eventType, listener, context) {
|
|
49
|
+
return this._subscriber.addSubscription(eventType, new EmitterSubscription(this, this._subscriber, listener, context));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Removes all of the registered listeners, including those registered as
|
|
54
|
+
* listener maps.
|
|
55
|
+
*
|
|
56
|
+
* @param {?string} eventType - Optional name of the event whose registered
|
|
57
|
+
* listeners to remove
|
|
58
|
+
*/
|
|
59
|
+
removeAllListeners(eventType) {
|
|
60
|
+
this._subscriber.removeAllSubscriptions(eventType);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Removes a specific subscription. Called by the `remove()` method of the
|
|
65
|
+
* subscription itself to ensure any necessary cleanup is performed.
|
|
66
|
+
*/
|
|
67
|
+
removeSubscription(subscription) {
|
|
68
|
+
if (subscription.emitter !== this) {
|
|
69
|
+
console.warn('Subscription does not belong to this emitter.'); // TODO: use HMSLogger here
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
this._subscriber.removeSubscription(subscription);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Returns the number of listeners that are currently registered for the given
|
|
77
|
+
* event.
|
|
78
|
+
*
|
|
79
|
+
* @param {string} eventType - Name of the event to query
|
|
80
|
+
* @returns {number}
|
|
81
|
+
*/
|
|
82
|
+
listenerCount(eventType) {
|
|
83
|
+
const subscriptions = this._subscriber.getSubscriptionsForType(eventType);
|
|
84
|
+
return subscriptions ?
|
|
85
|
+
// We filter out missing entries because the array is sparse.
|
|
86
|
+
// "callbackfn is called only for elements of the array which actually
|
|
87
|
+
// exist; it is not called for missing elements of the array."
|
|
88
|
+
// https://www.ecma-international.org/ecma-262/9.0/index.html#sec-array.prototype.filter
|
|
89
|
+
subscriptions.filter(sparseFilterPredicate).length : 0;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Emits an event of the given type with the given data. All handlers of that
|
|
94
|
+
* particular type will be notified.
|
|
95
|
+
*
|
|
96
|
+
* @param {string} eventType - Name of the event to emit
|
|
97
|
+
* @param {...*} Arbitrary arguments to be passed to each registered listener
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* emitter.addListener('someEvent', function(message) {
|
|
101
|
+
* console.log(message);
|
|
102
|
+
* });
|
|
103
|
+
*
|
|
104
|
+
* emitter.emit('someEvent', 'abc'); // logs 'abc'
|
|
105
|
+
*/
|
|
106
|
+
emit(eventType) {
|
|
107
|
+
const subscriptions = this._subscriber.getSubscriptionsForType(eventType);
|
|
108
|
+
if (subscriptions) {
|
|
109
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
110
|
+
args[_key - 1] = arguments[_key];
|
|
111
|
+
}
|
|
112
|
+
for (let i = 0, l = subscriptions.length; i < l; i++) {
|
|
113
|
+
const subscription = subscriptions[i];
|
|
114
|
+
|
|
115
|
+
// The subscription may have been removed during this event loop.
|
|
116
|
+
if (subscription && subscription.listener) {
|
|
117
|
+
subscription.listener.apply(subscription.context, args);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Removes the given listener for event of specific type.
|
|
125
|
+
*
|
|
126
|
+
* @param {string} eventType - Name of the event to emit
|
|
127
|
+
* @param {function} listener - Function to invoke when the specified event is
|
|
128
|
+
* emitted
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* emitter.removeListener('someEvent', function(message) {
|
|
132
|
+
* console.log(message);
|
|
133
|
+
* }); // removes the listener if already registered
|
|
134
|
+
*
|
|
135
|
+
*/
|
|
136
|
+
removeListener(eventType, listener) {
|
|
137
|
+
const subscriptions = this._subscriber.getSubscriptionsForType(eventType);
|
|
138
|
+
if (subscriptions) {
|
|
139
|
+
for (let i = 0, l = subscriptions.length; i < l; i++) {
|
|
140
|
+
const subscription = subscriptions[i];
|
|
141
|
+
|
|
142
|
+
// The subscription may have been removed during this event loop.
|
|
143
|
+
// its listener matches the listener in method parameters
|
|
144
|
+
if (subscription && subscription.listener === listener) {
|
|
145
|
+
subscription.remove();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=EventEmitter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["EmitterSubscription","EventSubscriptionVendor","sparseFilterPredicate","EventEmitter","constructor","subscriber","_defineProperty","_subscriber","addListener","eventType","listener","context","addSubscription","removeAllListeners","removeAllSubscriptions","removeSubscription","subscription","emitter","console","warn","listenerCount","subscriptions","getSubscriptionsForType","filter","length","emit","_len","arguments","args","Array","_key","i","l","apply","removeListener","remove"],"sources":["EventEmitter.ts"],"sourcesContent":["import { EmitterSubscription } from './_EmitterSubscription';\nimport { EventSubscriptionVendor } from './_EventSubscriptionVendor';\n\nconst sparseFilterPredicate = () => true;\n\nexport { EmitterSubscription } from './_EmitterSubscription';\n\n/**\n * @class EventEmitter\n * @description\n * An EventEmitter is responsible for managing a set of listeners and publishing\n * events to them when it is told that such events happened. In addition to the\n * data for the given event it also sends a event control object which allows\n * the listeners/handlers to prevent the default behavior of the given event.\n *\n * The emitter is designed to be generic enough to support all the different\n * contexts in which one might want to emit events. It is a simple multicast\n * mechanism on top of which extra functionality can be composed. For example, a\n * more advanced emitter may use an EventHolder and EventFactory.\n */\nexport class EventEmitter {\n _subscriber: EventSubscriptionVendor;\n\n /**\n * @constructor\n *\n * @param {EventSubscriptionVendor} subscriber - Optional subscriber instance\n * to use. If omitted, a new subscriber will be created for the emitter.\n */\n constructor(subscriber?: EventSubscriptionVendor | null) {\n this._subscriber = subscriber || new EventSubscriptionVendor();\n }\n\n /**\n * Adds a listener to be invoked when events of the specified type are\n * emitted. An optional calling context may be provided. The data arguments\n * emitted will be passed to the listener function.\n *\n * TODO: Annotate the listener arg's type. This is tricky because listeners\n * can be invoked with varargs.\n *\n * @param {string} eventType - Name of the event to listen to\n * @param {function} listener - Function to invoke when the specified event is\n * emitted\n * @param {*} context - Optional context object to use when invoking the\n * listener\n */\n addListener(\n eventType: string,\n listener: Function,\n context: Object | null | undefined\n ): EmitterSubscription {\n return this._subscriber.addSubscription(\n eventType,\n new EmitterSubscription(this, this._subscriber, listener, context)\n ) as EmitterSubscription;\n }\n\n /**\n * Removes all of the registered listeners, including those registered as\n * listener maps.\n *\n * @param {?string} eventType - Optional name of the event whose registered\n * listeners to remove\n */\n removeAllListeners(eventType: string | undefined | null) {\n this._subscriber.removeAllSubscriptions(eventType);\n }\n\n /**\n * Removes a specific subscription. Called by the `remove()` method of the\n * subscription itself to ensure any necessary cleanup is performed.\n */\n removeSubscription(subscription: EmitterSubscription) {\n if (subscription.emitter !== this) {\n console.warn('Subscription does not belong to this emitter.'); // TODO: use HMSLogger here\n return;\n }\n\n this._subscriber.removeSubscription(subscription);\n }\n\n /**\n * Returns the number of listeners that are currently registered for the given\n * event.\n *\n * @param {string} eventType - Name of the event to query\n * @returns {number}\n */\n listenerCount(eventType: string): number {\n const subscriptions = this._subscriber.getSubscriptionsForType(eventType);\n return subscriptions\n ? // We filter out missing entries because the array is sparse.\n // \"callbackfn is called only for elements of the array which actually\n // exist; it is not called for missing elements of the array.\"\n // https://www.ecma-international.org/ecma-262/9.0/index.html#sec-array.prototype.filter\n subscriptions.filter(sparseFilterPredicate).length\n : 0;\n }\n\n /**\n * Emits an event of the given type with the given data. All handlers of that\n * particular type will be notified.\n *\n * @param {string} eventType - Name of the event to emit\n * @param {...*} Arbitrary arguments to be passed to each registered listener\n *\n * @example\n * emitter.addListener('someEvent', function(message) {\n * console.log(message);\n * });\n *\n * emitter.emit('someEvent', 'abc'); // logs 'abc'\n */\n emit(eventType: string, ...args: any[]) {\n const subscriptions = this._subscriber.getSubscriptionsForType(\n eventType\n ) as EmitterSubscription[] | null | undefined;\n if (subscriptions) {\n for (let i = 0, l = subscriptions.length; i < l; i++) {\n const subscription = subscriptions[i];\n\n // The subscription may have been removed during this event loop.\n if (subscription && subscription.listener) {\n subscription.listener.apply(subscription.context, args);\n }\n }\n }\n }\n\n /**\n * Removes the given listener for event of specific type.\n *\n * @param {string} eventType - Name of the event to emit\n * @param {function} listener - Function to invoke when the specified event is\n * emitted\n *\n * @example\n * emitter.removeListener('someEvent', function(message) {\n * console.log(message);\n * }); // removes the listener if already registered\n *\n */\n removeListener(eventType: string, listener: Function) {\n const subscriptions = this._subscriber.getSubscriptionsForType(\n eventType\n ) as EmitterSubscription[] | null | undefined;\n if (subscriptions) {\n for (let i = 0, l = subscriptions.length; i < l; i++) {\n const subscription = subscriptions[i];\n\n // The subscription may have been removed during this event loop.\n // its listener matches the listener in method parameters\n if (subscription && subscription.listener === listener) {\n subscription.remove();\n }\n }\n }\n }\n}\n"],"mappings":";;;AAAA,SAASA,mBAAmB,QAAQ,wBAAwB;AAC5D,SAASC,uBAAuB,QAAQ,4BAA4B;AAEpE,MAAMC,qBAAqB,GAAGA,CAAA,KAAM,IAAI;AAExC,SAASF,mBAAmB,QAAQ,wBAAwB;;AAE5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMG,YAAY,CAAC;EAGxB;AACF;AACA;AACA;AACA;AACA;EACEC,WAAWA,CAACC,UAA2C,EAAE;IAAAC,eAAA;IACvD,IAAI,CAACC,WAAW,GAAGF,UAAU,IAAI,IAAIJ,uBAAuB,EAAE;EAChE;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEO,WAAWA,CACTC,SAAiB,EACjBC,QAAkB,EAClBC,OAAkC,EACb;IACrB,OAAO,IAAI,CAACJ,WAAW,CAACK,eAAe,CACrCH,SAAS,EACT,IAAIT,mBAAmB,CAAC,IAAI,EAAE,IAAI,CAACO,WAAW,EAAEG,QAAQ,EAAEC,OAAO,CAAC,CACnE;EACH;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACEE,kBAAkBA,CAACJ,SAAoC,EAAE;IACvD,IAAI,CAACF,WAAW,CAACO,sBAAsB,CAACL,SAAS,CAAC;EACpD;;EAEA;AACF;AACA;AACA;EACEM,kBAAkBA,CAACC,YAAiC,EAAE;IACpD,IAAIA,YAAY,CAACC,OAAO,KAAK,IAAI,EAAE;MACjCC,OAAO,CAACC,IAAI,CAAC,+CAA+C,CAAC,CAAC,CAAC;MAC/D;IACF;IAEA,IAAI,CAACZ,WAAW,CAACQ,kBAAkB,CAACC,YAAY,CAAC;EACnD;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;EACEI,aAAaA,CAACX,SAAiB,EAAU;IACvC,MAAMY,aAAa,GAAG,IAAI,CAACd,WAAW,CAACe,uBAAuB,CAACb,SAAS,CAAC;IACzE,OAAOY,aAAa;IAChB;IACA;IACA;IACA;IACAA,aAAa,CAACE,MAAM,CAACrB,qBAAqB,CAAC,CAACsB,MAAM,GAClD,CAAC;EACP;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,IAAIA,CAAChB,SAAiB,EAAkB;IACtC,MAAMY,aAAa,GAAG,IAAI,CAACd,WAAW,CAACe,uBAAuB,CAC5Db,SAAS,CACkC;IAC7C,IAAIY,aAAa,EAAE;MAAA,SAAAK,IAAA,GAAAC,SAAA,CAAAH,MAAA,EAJMI,IAAI,OAAAC,KAAA,CAAAH,IAAA,OAAAA,IAAA,WAAAI,IAAA,MAAAA,IAAA,GAAAJ,IAAA,EAAAI,IAAA;QAAJF,IAAI,CAAAE,IAAA,QAAAH,SAAA,CAAAG,IAAA;MAAA;MAK3B,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAGX,aAAa,CAACG,MAAM,EAAEO,CAAC,GAAGC,CAAC,EAAED,CAAC,EAAE,EAAE;QACpD,MAAMf,YAAY,GAAGK,aAAa,CAACU,CAAC,CAAC;;QAErC;QACA,IAAIf,YAAY,IAAIA,YAAY,CAACN,QAAQ,EAAE;UACzCM,YAAY,CAACN,QAAQ,CAACuB,KAAK,CAACjB,YAAY,CAACL,OAAO,EAAEiB,IAAI,CAAC;QACzD;MACF;IACF;EACF;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEM,cAAcA,CAACzB,SAAiB,EAAEC,QAAkB,EAAE;IACpD,MAAMW,aAAa,GAAG,IAAI,CAACd,WAAW,CAACe,uBAAuB,CAC5Db,SAAS,CACkC;IAC7C,IAAIY,aAAa,EAAE;MACjB,KAAK,IAAIU,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAGX,aAAa,CAACG,MAAM,EAAEO,CAAC,GAAGC,CAAC,EAAED,CAAC,EAAE,EAAE;QACpD,MAAMf,YAAY,GAAGK,aAAa,CAACU,CAAC,CAAC;;QAErC;QACA;QACA,IAAIf,YAAY,IAAIA,YAAY,CAACN,QAAQ,KAAKA,QAAQ,EAAE;UACtDM,YAAY,CAACmB,MAAM,EAAE;QACvB;MACF;IACF;EACF;AACF"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
3
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
4
|
+
import { EventSubscription } from './_EventSubscription';
|
|
5
|
+
/**
|
|
6
|
+
* EmitterSubscription represents a subscription with listener and context data.
|
|
7
|
+
*/
|
|
8
|
+
export class EmitterSubscription extends EventSubscription {
|
|
9
|
+
/**
|
|
10
|
+
* @param {EventEmitter} emitter - The event emitter that registered this
|
|
11
|
+
* subscription
|
|
12
|
+
* @param {EventSubscriptionVendor} subscriber - The subscriber that controls
|
|
13
|
+
* this subscription
|
|
14
|
+
* @param {function} listener - Function to invoke when the specified event is
|
|
15
|
+
* emitted
|
|
16
|
+
* @param {*} context - Optional context object to use when invoking the
|
|
17
|
+
* listener
|
|
18
|
+
*/
|
|
19
|
+
constructor(emitter, subscriber, listener, context) {
|
|
20
|
+
super(subscriber);
|
|
21
|
+
_defineProperty(this, "emitter", void 0);
|
|
22
|
+
_defineProperty(this, "listener", void 0);
|
|
23
|
+
_defineProperty(this, "context", void 0);
|
|
24
|
+
this.emitter = emitter;
|
|
25
|
+
this.listener = listener;
|
|
26
|
+
this.context = context;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Removes this subscription from the emitter that registered it.
|
|
31
|
+
* Note: we're overriding the `remove()` method of EventSubscription here
|
|
32
|
+
* but deliberately not calling `super.remove()` as the responsibility
|
|
33
|
+
* for removing the subscription lies with the EventEmitter.
|
|
34
|
+
*/
|
|
35
|
+
remove() {
|
|
36
|
+
this.emitter.removeSubscription(this);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=_EmitterSubscription.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["EventSubscription","EmitterSubscription","constructor","emitter","subscriber","listener","context","_defineProperty","remove","removeSubscription"],"sources":["_EmitterSubscription.ts"],"sourcesContent":["import { EventSubscription } from './_EventSubscription';\nimport type { EventEmitter } from './EventEmitter';\nimport type { EventSubscriptionVendor } from './_EventSubscriptionVendor';\n\n/**\n * EmitterSubscription represents a subscription with listener and context data.\n */\nexport class EmitterSubscription extends EventSubscription {\n emitter: EventEmitter;\n listener: Function;\n context: Object | null | undefined;\n\n /**\n * @param {EventEmitter} emitter - The event emitter that registered this\n * subscription\n * @param {EventSubscriptionVendor} subscriber - The subscriber that controls\n * this subscription\n * @param {function} listener - Function to invoke when the specified event is\n * emitted\n * @param {*} context - Optional context object to use when invoking the\n * listener\n */\n constructor(\n emitter: EventEmitter,\n subscriber: EventSubscriptionVendor,\n listener: Function,\n context: Object | undefined | null\n ) {\n super(subscriber);\n this.emitter = emitter;\n this.listener = listener;\n this.context = context;\n }\n\n /**\n * Removes this subscription from the emitter that registered it.\n * Note: we're overriding the `remove()` method of EventSubscription here\n * but deliberately not calling `super.remove()` as the responsibility\n * for removing the subscription lies with the EventEmitter.\n */\n remove() {\n this.emitter.removeSubscription(this);\n }\n}\n"],"mappings":";;;AAAA,SAASA,iBAAiB,QAAQ,sBAAsB;AAIxD;AACA;AACA;AACA,OAAO,MAAMC,mBAAmB,SAASD,iBAAiB,CAAC;EAKzD;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEE,WAAWA,CACTC,OAAqB,EACrBC,UAAmC,EACnCC,QAAkB,EAClBC,OAAkC,EAClC;IACA,KAAK,CAACF,UAAU,CAAC;IAACG,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAClB,IAAI,CAACJ,OAAO,GAAGA,OAAO;IACtB,IAAI,CAACE,QAAQ,GAAGA,QAAQ;IACxB,IAAI,CAACC,OAAO,GAAGA,OAAO;EACxB;;EAEA;AACF;AACA;AACA;AACA;AACA;EACEE,MAAMA,CAAA,EAAG;IACP,IAAI,CAACL,OAAO,CAACM,kBAAkB,CAAC,IAAI,CAAC;EACvC;AACF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
3
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
4
|
+
/**
|
|
5
|
+
* EventSubscription represents a subscription to a particular event. It can
|
|
6
|
+
* remove its own subscription.
|
|
7
|
+
*/
|
|
8
|
+
export class EventSubscription {
|
|
9
|
+
/**
|
|
10
|
+
* @param {EventSubscriptionVendor} subscriber the subscriber that controls
|
|
11
|
+
* this subscription.
|
|
12
|
+
*/
|
|
13
|
+
constructor(subscriber) {
|
|
14
|
+
// @ts-ignore this value is assigned after creating instance of class
|
|
15
|
+
_defineProperty(this, "eventType", void 0);
|
|
16
|
+
// @ts-ignore this value is assigned after creating instance of class
|
|
17
|
+
_defineProperty(this, "key", void 0);
|
|
18
|
+
_defineProperty(this, "subscriber", void 0);
|
|
19
|
+
this.subscriber = subscriber;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Removes this subscription from the subscriber that controls it.
|
|
24
|
+
*/
|
|
25
|
+
remove() {
|
|
26
|
+
this.subscriber.removeSubscription(this);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=_EventSubscription.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["EventSubscription","constructor","subscriber","_defineProperty","remove","removeSubscription"],"sources":["_EventSubscription.ts"],"sourcesContent":["import type { EventSubscriptionVendor } from './_EventSubscriptionVendor';\n\n/**\n * EventSubscription represents a subscription to a particular event. It can\n * remove its own subscription.\n */\nexport class EventSubscription {\n // @ts-ignore this value is assigned after creating instance of class\n eventType: string;\n // @ts-ignore this value is assigned after creating instance of class\n key: number;\n subscriber: EventSubscriptionVendor;\n\n /**\n * @param {EventSubscriptionVendor} subscriber the subscriber that controls\n * this subscription.\n */\n constructor(subscriber: EventSubscriptionVendor) {\n this.subscriber = subscriber;\n }\n\n /**\n * Removes this subscription from the subscriber that controls it.\n */\n remove() {\n this.subscriber.removeSubscription(this);\n }\n}\n"],"mappings":";;;AAEA;AACA;AACA;AACA;AACA,OAAO,MAAMA,iBAAiB,CAAC;EAO7B;AACF;AACA;AACA;EACEC,WAAWA,CAACC,UAAmC,EAAE;IAVjD;IAAAC,eAAA;IAEA;IAAAA,eAAA;IAAAA,eAAA;IASE,IAAI,CAACD,UAAU,GAAGA,UAAU;EAC9B;;EAEA;AACF;AACA;EACEE,MAAMA,CAAA,EAAG;IACP,IAAI,CAACF,UAAU,CAACG,kBAAkB,CAAC,IAAI,CAAC;EAC1C;AACF"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
3
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
4
|
+
/**
|
|
5
|
+
* EventSubscriptionVendor stores a set of EventSubscriptions that are
|
|
6
|
+
* subscribed to a particular event type.
|
|
7
|
+
*/
|
|
8
|
+
export class EventSubscriptionVendor {
|
|
9
|
+
constructor() {
|
|
10
|
+
_defineProperty(this, "_subscriptionsForType", void 0);
|
|
11
|
+
_defineProperty(this, "_currentSubscription", void 0);
|
|
12
|
+
this._subscriptionsForType = {};
|
|
13
|
+
this._currentSubscription = null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Adds a subscription keyed by an event type.
|
|
18
|
+
*
|
|
19
|
+
* @param {string} eventType
|
|
20
|
+
* @param {EventSubscription} subscription
|
|
21
|
+
*/
|
|
22
|
+
addSubscription(eventType, subscription) {
|
|
23
|
+
if (subscription.subscriber !== this) {
|
|
24
|
+
console.warn('The subscriber of the subscription is incorrectly set.'); // TODO: throw error or use logger?
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (!this._subscriptionsForType[eventType]) {
|
|
28
|
+
this._subscriptionsForType[eventType] = [];
|
|
29
|
+
}
|
|
30
|
+
const eventSubscriptions = this._subscriptionsForType[eventType];
|
|
31
|
+
const key = eventSubscriptions.length;
|
|
32
|
+
eventSubscriptions.push(subscription);
|
|
33
|
+
subscription.eventType = eventType;
|
|
34
|
+
subscription.key = key;
|
|
35
|
+
return subscription;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Removes a bulk set of the subscriptions.
|
|
40
|
+
*
|
|
41
|
+
* @param {?string} eventType - Optional name of the event type whose
|
|
42
|
+
* registered supscriptions to remove, if null or undefined remove all subscriptions.
|
|
43
|
+
*/
|
|
44
|
+
removeAllSubscriptions(eventType) {
|
|
45
|
+
if (eventType === undefined || eventType === null) {
|
|
46
|
+
this._subscriptionsForType = {};
|
|
47
|
+
} else {
|
|
48
|
+
delete this._subscriptionsForType[eventType];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Removes a specific subscription. Instead of calling this function, call
|
|
54
|
+
* `subscription.remove()` directly.
|
|
55
|
+
*
|
|
56
|
+
* @param {object} subscription
|
|
57
|
+
*/
|
|
58
|
+
removeSubscription(subscription) {
|
|
59
|
+
const eventType = subscription.eventType;
|
|
60
|
+
const key = subscription.key;
|
|
61
|
+
const subscriptionsForType = this._subscriptionsForType[eventType];
|
|
62
|
+
if (subscriptionsForType) {
|
|
63
|
+
delete subscriptionsForType[key];
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Returns the array of subscriptions that are currently registered for the
|
|
69
|
+
* given event type.
|
|
70
|
+
*
|
|
71
|
+
* Note: This array can be potentially sparse as subscriptions are deleted
|
|
72
|
+
* from it when they are removed.
|
|
73
|
+
*
|
|
74
|
+
* TODO: This returns a nullable array. wat?
|
|
75
|
+
*
|
|
76
|
+
* @param {string} eventType
|
|
77
|
+
* @returns {?array}
|
|
78
|
+
*/
|
|
79
|
+
getSubscriptionsForType(eventType) {
|
|
80
|
+
return this._subscriptionsForType[eventType];
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=_EventSubscriptionVendor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["EventSubscriptionVendor","constructor","_defineProperty","_subscriptionsForType","_currentSubscription","addSubscription","eventType","subscription","subscriber","console","warn","eventSubscriptions","key","length","push","removeAllSubscriptions","undefined","removeSubscription","subscriptionsForType","getSubscriptionsForType"],"sources":["_EventSubscriptionVendor.ts"],"sourcesContent":["import type { EventSubscription } from './_EventSubscription';\n\n/**\n * EventSubscriptionVendor stores a set of EventSubscriptions that are\n * subscribed to a particular event type.\n */\nexport class EventSubscriptionVendor {\n _subscriptionsForType: Record<string, EventSubscription[] | null | undefined>;\n _currentSubscription: EventSubscription | null | undefined;\n\n constructor() {\n this._subscriptionsForType = {};\n this._currentSubscription = null;\n }\n\n /**\n * Adds a subscription keyed by an event type.\n *\n * @param {string} eventType\n * @param {EventSubscription} subscription\n */\n addSubscription(\n eventType: string,\n subscription: EventSubscription\n ): EventSubscription {\n if (subscription.subscriber !== this) {\n console.warn('The subscriber of the subscription is incorrectly set.'); // TODO: throw error or use logger?\n }\n if (!this._subscriptionsForType[eventType]) {\n this._subscriptionsForType[eventType] = [];\n }\n const eventSubscriptions = this._subscriptionsForType[\n eventType\n ] as EventSubscription[];\n const key = eventSubscriptions.length;\n eventSubscriptions.push(subscription);\n subscription.eventType = eventType;\n subscription.key = key;\n return subscription;\n }\n\n /**\n * Removes a bulk set of the subscriptions.\n *\n * @param {?string} eventType - Optional name of the event type whose\n * registered supscriptions to remove, if null or undefined remove all subscriptions.\n */\n removeAllSubscriptions(eventType: string | undefined | null) {\n if (eventType === undefined || eventType === null) {\n this._subscriptionsForType = {};\n } else {\n delete this._subscriptionsForType[eventType];\n }\n }\n\n /**\n * Removes a specific subscription. Instead of calling this function, call\n * `subscription.remove()` directly.\n *\n * @param {object} subscription\n */\n removeSubscription(subscription: EventSubscription) {\n const eventType = subscription.eventType;\n const key = subscription.key;\n\n const subscriptionsForType = this._subscriptionsForType[eventType];\n if (subscriptionsForType) {\n delete subscriptionsForType[key];\n }\n }\n\n /**\n * Returns the array of subscriptions that are currently registered for the\n * given event type.\n *\n * Note: This array can be potentially sparse as subscriptions are deleted\n * from it when they are removed.\n *\n * TODO: This returns a nullable array. wat?\n *\n * @param {string} eventType\n * @returns {?array}\n */\n getSubscriptionsForType(\n eventType: string\n ): EventSubscription[] | null | undefined {\n return this._subscriptionsForType[eventType];\n }\n}\n"],"mappings":";;;AAEA;AACA;AACA;AACA;AACA,OAAO,MAAMA,uBAAuB,CAAC;EAInCC,WAAWA,CAAA,EAAG;IAAAC,eAAA;IAAAA,eAAA;IACZ,IAAI,CAACC,qBAAqB,GAAG,CAAC,CAAC;IAC/B,IAAI,CAACC,oBAAoB,GAAG,IAAI;EAClC;;EAEA;AACF;AACA;AACA;AACA;AACA;EACEC,eAAeA,CACbC,SAAiB,EACjBC,YAA+B,EACZ;IACnB,IAAIA,YAAY,CAACC,UAAU,KAAK,IAAI,EAAE;MACpCC,OAAO,CAACC,IAAI,CAAC,wDAAwD,CAAC,CAAC,CAAC;IAC1E;;IACA,IAAI,CAAC,IAAI,CAACP,qBAAqB,CAACG,SAAS,CAAC,EAAE;MAC1C,IAAI,CAACH,qBAAqB,CAACG,SAAS,CAAC,GAAG,EAAE;IAC5C;IACA,MAAMK,kBAAkB,GAAG,IAAI,CAACR,qBAAqB,CACnDG,SAAS,CACa;IACxB,MAAMM,GAAG,GAAGD,kBAAkB,CAACE,MAAM;IACrCF,kBAAkB,CAACG,IAAI,CAACP,YAAY,CAAC;IACrCA,YAAY,CAACD,SAAS,GAAGA,SAAS;IAClCC,YAAY,CAACK,GAAG,GAAGA,GAAG;IACtB,OAAOL,YAAY;EACrB;;EAEA;AACF;AACA;AACA;AACA;AACA;EACEQ,sBAAsBA,CAACT,SAAoC,EAAE;IAC3D,IAAIA,SAAS,KAAKU,SAAS,IAAIV,SAAS,KAAK,IAAI,EAAE;MACjD,IAAI,CAACH,qBAAqB,GAAG,CAAC,CAAC;IACjC,CAAC,MAAM;MACL,OAAO,IAAI,CAACA,qBAAqB,CAACG,SAAS,CAAC;IAC9C;EACF;;EAEA;AACF;AACA;AACA;AACA;AACA;EACEW,kBAAkBA,CAACV,YAA+B,EAAE;IAClD,MAAMD,SAAS,GAAGC,YAAY,CAACD,SAAS;IACxC,MAAMM,GAAG,GAAGL,YAAY,CAACK,GAAG;IAE5B,MAAMM,oBAAoB,GAAG,IAAI,CAACf,qBAAqB,CAACG,SAAS,CAAC;IAClE,IAAIY,oBAAoB,EAAE;MACxB,OAAOA,oBAAoB,CAACN,GAAG,CAAC;IAClC;EACF;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEO,uBAAuBA,CACrBb,SAAiB,EACuB;IACxC,OAAO,IAAI,CAACH,qBAAqB,CAACG,SAAS,CAAC;EAC9C;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from './emitter/EventEmitter';\n"],"mappings":"AAAA,cAAc,wBAAwB"}
|
|
@@ -1,11 +1,25 @@
|
|
|
1
|
+
import type { HMSIOSAudioMode } from './HMSIOSAudioMode';
|
|
1
2
|
import type { HMSTrackSettingsInitState } from './HMSTrackSettingsInitState';
|
|
3
|
+
/**
|
|
4
|
+
* Customize local peer's Audio track settings before Joining the Room.
|
|
5
|
+
*
|
|
6
|
+
* Checkout Track Settings docs for more details {@link https://www.100ms.live/docs/react-native/v2/how-to-guides/interact-with-room/track/track-settings}
|
|
7
|
+
*/
|
|
2
8
|
export declare class HMSAudioTrackSettings {
|
|
3
9
|
initialState?: HMSTrackSettingsInitState;
|
|
4
10
|
useHardwareEchoCancellation?: boolean;
|
|
5
11
|
audioSource?: string[];
|
|
12
|
+
/**
|
|
13
|
+
* [iOS only] `audioMode` allows you to capture audio in its highest quality
|
|
14
|
+
* by disabling voice processing and increasing the maximum bandwidth limit
|
|
15
|
+
*
|
|
16
|
+
* Checkout Music Mode docs for more details {@link https://www.100ms.live/docs/react-native/v2/how-to-guides/configure-your-device/microphone/music-mode}
|
|
17
|
+
*/
|
|
18
|
+
audioMode?: HMSIOSAudioMode;
|
|
6
19
|
constructor(params: {
|
|
7
20
|
initialState?: HMSTrackSettingsInitState;
|
|
8
21
|
useHardwareEchoCancellation?: boolean;
|
|
9
22
|
audioSource?: string[];
|
|
23
|
+
audioMode?: HMSIOSAudioMode;
|
|
10
24
|
});
|
|
11
25
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare class HMSCameraControl {
|
|
2
|
+
/**
|
|
3
|
+
* It captures the image from the device camera at max possible resolution.
|
|
4
|
+
*
|
|
5
|
+
* @param {boolean} [flash=false] flash - value indicating whether to use flash while capturing image or not
|
|
6
|
+
* @returns Promise - which is resolved with the file path of the captured image saved on the disk
|
|
7
|
+
*/
|
|
8
|
+
static captureImageAtMaxSupportedResolution(flash?: boolean): Promise<string>;
|
|
9
|
+
}
|
|
@@ -28,10 +28,16 @@ import { HMSServerRecordingState } from './HMSServerRecordingState';
|
|
|
28
28
|
import { HMSMessage } from './HMSMessage';
|
|
29
29
|
import { HMSMessageRecipient } from './HMSMessageRecipient';
|
|
30
30
|
import { HMSException } from './HMSException';
|
|
31
|
+
import { HMSLocalAudioStats } from './HMSLocalAudioStats';
|
|
32
|
+
import { HMSLocalVideoStats } from './HMSLocalVideoStats';
|
|
33
|
+
import { HMSRemoteAudioStats } from './HMSRemoteAudioStats';
|
|
34
|
+
import { HMSRemoteVideoStats } from './HMSRemoteVideoStats';
|
|
35
|
+
import { HMSSimulcastLayerDefinition } from './HMSSimulcastLayerDefinition';
|
|
36
|
+
import { HMSQualityLimitationReasons } from './HMSQualityLimitationReasons';
|
|
31
37
|
export declare class HMSEncoder {
|
|
32
38
|
private static data;
|
|
33
39
|
static clearData(): void;
|
|
34
|
-
static encodeHmsRoom(room:
|
|
40
|
+
static encodeHmsRoom(room: any, id: string): HMSRoom;
|
|
35
41
|
static encodeHmsPeers(peers: any): HMSPeer[];
|
|
36
42
|
static encodeHmsPeer(peer: any): HMSPeer;
|
|
37
43
|
static encodeHmsPeerUpdate(hmsPeerUpdateOrdinal: string): import("./HMSPeerUpdate").HMSPeerUpdate | undefined;
|
|
@@ -69,4 +75,10 @@ export declare class HMSEncoder {
|
|
|
69
75
|
static encodeHMSMessage(data: any): HMSMessage | undefined;
|
|
70
76
|
static encodeHMSMessageRecipient(data: any): HMSMessageRecipient;
|
|
71
77
|
static encodeHMSException(data: any): HMSException;
|
|
78
|
+
static encodeHMSLocalAudioStats(data: any): HMSLocalAudioStats;
|
|
79
|
+
static encodeHMSLocalVideoStats(data: any[]): HMSLocalVideoStats[];
|
|
80
|
+
static encodeHMSRemoteAudioStats(data: any): HMSRemoteAudioStats;
|
|
81
|
+
static encodeHMSRemoteVideoStats(data: any): HMSRemoteVideoStats;
|
|
82
|
+
static encodeHMSSimulcastLayerDefinition(data: any[]): HMSSimulcastLayerDefinition[];
|
|
83
|
+
static encodeHMSQualityLimitationReasons(data: any): HMSQualityLimitationReasons;
|
|
72
84
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { HMSLayer } from './HMSLayer';
|
|
2
|
+
import type { HMSQualityLimitationReasons } from './HMSQualityLimitationReasons';
|
|
1
3
|
import type { HMSVideoResolution } from './HMSVideoResolution';
|
|
2
4
|
export declare class HMSLocalVideoStats {
|
|
3
5
|
bitrate?: number;
|
|
@@ -5,11 +7,15 @@ export declare class HMSLocalVideoStats {
|
|
|
5
7
|
roundTripTime?: number;
|
|
6
8
|
frameRate?: number;
|
|
7
9
|
resolution?: HMSVideoResolution;
|
|
10
|
+
qualityLimitationReasons?: HMSQualityLimitationReasons;
|
|
11
|
+
layer?: HMSLayer;
|
|
8
12
|
constructor(params: {
|
|
9
13
|
bitrate?: number;
|
|
10
14
|
bytesSent?: number;
|
|
11
15
|
roundTripTime?: number;
|
|
12
16
|
frameRate?: number;
|
|
13
17
|
resolution?: HMSVideoResolution;
|
|
18
|
+
qualityLimitationReasons?: HMSQualityLimitationReasons;
|
|
19
|
+
layer?: HMSLayer;
|
|
14
20
|
});
|
|
15
21
|
}
|
|
@@ -6,7 +6,7 @@ import type { HMSVideoTrack } from './HMSVideoTrack';
|
|
|
6
6
|
export declare class HMSPeer {
|
|
7
7
|
peerID: string;
|
|
8
8
|
/**
|
|
9
|
-
* @deprecated customerDescription has been deprecated in favor of metadata
|
|
9
|
+
* @deprecated customerDescription property has been deprecated in favor of metadata property
|
|
10
10
|
*/
|
|
11
11
|
customerDescription?: string;
|
|
12
12
|
constructor(params: {
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import type { HMSAudioSettings } from './HMSAudioSettings';
|
|
2
2
|
import type { HMSVideoSettings } from './HMSVideoSettings';
|
|
3
|
+
import type { HMSSimulcastSettings } from './HMSSimulcastSettings';
|
|
3
4
|
export declare class HMSPublishSettings {
|
|
4
5
|
audio?: HMSAudioSettings;
|
|
5
6
|
video?: HMSVideoSettings;
|
|
6
7
|
screen?: HMSVideoSettings;
|
|
7
8
|
allowed?: string[];
|
|
9
|
+
simulcast?: HMSSimulcastSettings;
|
|
8
10
|
constructor(params: {
|
|
9
11
|
audio?: HMSAudioSettings;
|
|
10
12
|
video?: HMSVideoSettings;
|
|
11
13
|
screen?: HMSVideoSettings;
|
|
12
14
|
allowed?: string[];
|
|
15
|
+
simulcast?: HMSSimulcastSettings;
|
|
13
16
|
});
|
|
14
17
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { HMSQualityLimitationReason } from './HMSQualityLimitationReason';
|
|
2
|
+
export declare class HMSQualityLimitationReasons {
|
|
3
|
+
bandwidth?: number;
|
|
4
|
+
cpu?: number;
|
|
5
|
+
none?: number;
|
|
6
|
+
other?: number;
|
|
7
|
+
qualityLimitationResolutionChanges?: number;
|
|
8
|
+
reason: HMSQualityLimitationReason;
|
|
9
|
+
constructor(params: {
|
|
10
|
+
bandwidth?: number;
|
|
11
|
+
cpu?: number;
|
|
12
|
+
none?: number;
|
|
13
|
+
other?: number;
|
|
14
|
+
qualityLimitationResolutionChanges?: number;
|
|
15
|
+
reason: HMSQualityLimitationReason;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { HMSVideoTrack } from './HMSVideoTrack';
|
|
2
2
|
import type { HMSTrackType } from './HMSTrackType';
|
|
3
|
+
import type { HMSLayer } from './HMSLayer';
|
|
4
|
+
import type { HMSSimulcastLayerDefinition } from './HMSSimulcastLayerDefinition';
|
|
3
5
|
export declare class HMSRemoteVideoTrack extends HMSVideoTrack {
|
|
4
|
-
layer?: any;
|
|
5
6
|
/**
|
|
6
7
|
* Switches Video of remote user on/off depending upon the value of playbackAllowed
|
|
7
8
|
*
|
|
@@ -10,14 +11,17 @@ export declare class HMSRemoteVideoTrack extends HMSVideoTrack {
|
|
|
10
11
|
*/
|
|
11
12
|
setPlaybackAllowed(playbackAllowed: boolean): void;
|
|
12
13
|
isPlaybackAllowed: () => Promise<any>;
|
|
14
|
+
getLayer(): Promise<HMSLayer>;
|
|
15
|
+
getLayerDefinition(): Promise<HMSSimulcastLayerDefinition[]>;
|
|
16
|
+
setLayer(layer: HMSLayer): Promise<any>;
|
|
13
17
|
constructor(params: {
|
|
14
18
|
trackId: string;
|
|
15
19
|
source?: number | string;
|
|
16
20
|
trackDescription?: string;
|
|
17
21
|
isMute?: boolean;
|
|
18
|
-
layer?: any;
|
|
19
22
|
playbackAllowed?: boolean;
|
|
20
23
|
id: string;
|
|
24
|
+
isDegraded?: boolean;
|
|
21
25
|
type?: HMSTrackType;
|
|
22
26
|
});
|
|
23
27
|
}
|
|
@@ -5,5 +5,6 @@ export declare enum HMSRoomUpdate {
|
|
|
5
5
|
RTMP_STREAMING_STATE_UPDATED = "RTMP_STREAMING_STATE_UPDATED",
|
|
6
6
|
BROWSER_RECORDING_STATE_UPDATED = "BROWSER_RECORDING_STATE_UPDATED",
|
|
7
7
|
HLS_STREAMING_STATE_UPDATED = "HLS_STREAMING_STATE_UPDATED",
|
|
8
|
-
HLS_RECORDING_STATE_UPDATED = "HLS_RECORDING_STATE_UPDATED"
|
|
8
|
+
HLS_RECORDING_STATE_UPDATED = "HLS_RECORDING_STATE_UPDATED",
|
|
9
|
+
ROOM_PEER_COUNT_UPDATED = "ROOM_PEER_COUNT_UPDATED"
|
|
9
10
|
}
|