@100mslive/react-native-hms 1.6.0 → 1.6.2

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.
Files changed (60) hide show
  1. package/android/build.gradle +1 -1
  2. package/android/src/main/java/com/reactnativehmssdk/HMSAudioshareActivity.kt +44 -44
  3. package/android/src/main/java/com/reactnativehmssdk/HMSDecoder.kt +12 -12
  4. package/android/src/main/java/com/reactnativehmssdk/HMSHelper.kt +35 -35
  5. package/android/src/main/java/com/reactnativehmssdk/HMSRNSDK.kt +11 -3
  6. package/android/src/main/java/com/reactnativehmssdk/HMSSDKViewManager.kt +4 -3
  7. package/android/src/main/java/com/reactnativehmssdk/HMSView.kt +31 -33
  8. package/android/src/main/java/com/reactnativehmssdk/HmsScreenshareActivity.kt +41 -41
  9. package/android/src/main/java/com/reactnativehmssdk/PipActionReceiver.kt +2 -2
  10. package/ios/HMSRNSDK.swift +4 -4
  11. package/lib/commonjs/classes/HMSAudioMixerSource.js.map +1 -1
  12. package/lib/commonjs/classes/HMSEncoder.js +1 -0
  13. package/lib/commonjs/classes/HMSEncoder.js.map +1 -1
  14. package/lib/commonjs/classes/HMSLocalAudioTrack.js.map +1 -1
  15. package/lib/commonjs/classes/HMSLocalVideoTrack.js.map +1 -1
  16. package/lib/commonjs/classes/HMSLogger.js.map +1 -1
  17. package/lib/commonjs/classes/HMSMessage.js +2 -1
  18. package/lib/commonjs/classes/HMSMessage.js.map +1 -1
  19. package/lib/commonjs/classes/HMSNativeEventEmitter.js.map +1 -1
  20. package/lib/commonjs/classes/HMSPeer.js.map +1 -1
  21. package/lib/commonjs/classes/HMSPeersCache.js.map +1 -1
  22. package/lib/commonjs/classes/HMSRemoteAudioTrack.js.map +1 -1
  23. package/lib/commonjs/classes/HMSRemoteVideoTrack.js.map +1 -1
  24. package/lib/commonjs/classes/HMSRoom.js.map +1 -1
  25. package/lib/commonjs/classes/HMSRoomCache.js.map +1 -1
  26. package/lib/commonjs/classes/HMSSDK.js +6 -3
  27. package/lib/commonjs/classes/HMSSDK.js.map +1 -1
  28. package/lib/commonjs/classes/HMSSessionStore.js.map +1 -1
  29. package/lib/commonjs/classes/HmsView.js +19 -29
  30. package/lib/commonjs/classes/HmsView.js.map +1 -1
  31. package/lib/commonjs/utils/emitter/EventEmitter.js.map +1 -1
  32. package/lib/module/classes/HMSAudioMixerSource.js.map +1 -1
  33. package/lib/module/classes/HMSEncoder.js +1 -0
  34. package/lib/module/classes/HMSEncoder.js.map +1 -1
  35. package/lib/module/classes/HMSLocalAudioTrack.js.map +1 -1
  36. package/lib/module/classes/HMSLocalVideoTrack.js.map +1 -1
  37. package/lib/module/classes/HMSLogger.js.map +1 -1
  38. package/lib/module/classes/HMSMessage.js +2 -1
  39. package/lib/module/classes/HMSMessage.js.map +1 -1
  40. package/lib/module/classes/HMSNativeEventEmitter.js.map +1 -1
  41. package/lib/module/classes/HMSPeer.js.map +1 -1
  42. package/lib/module/classes/HMSPeersCache.js.map +1 -1
  43. package/lib/module/classes/HMSRemoteAudioTrack.js.map +1 -1
  44. package/lib/module/classes/HMSRemoteVideoTrack.js.map +1 -1
  45. package/lib/module/classes/HMSRoom.js.map +1 -1
  46. package/lib/module/classes/HMSRoomCache.js.map +1 -1
  47. package/lib/module/classes/HMSSDK.js +6 -3
  48. package/lib/module/classes/HMSSDK.js.map +1 -1
  49. package/lib/module/classes/HMSSessionStore.js.map +1 -1
  50. package/lib/module/classes/HmsView.js +21 -31
  51. package/lib/module/classes/HmsView.js.map +1 -1
  52. package/lib/module/utils/emitter/EventEmitter.js.map +1 -1
  53. package/lib/typescript/classes/HMSMessage.d.ts +2 -0
  54. package/lib/typescript/classes/HMSSDK.d.ts +9 -3
  55. package/package.json +7 -5
  56. package/sdk-versions.json +2 -2
  57. package/src/classes/HMSEncoder.ts +1 -0
  58. package/src/classes/HMSMessage.ts +3 -1
  59. package/src/classes/HMSSDK.tsx +26 -17
  60. package/src/classes/HmsView.tsx +21 -32
@@ -1 +1 @@
1
- {"version":3,"names":["NativeModules","DeviceEventEmitter","HMSConstants","getLogger","HMSUpdateListenerActions","EventEmitter","HMSManager","HMSSessionStore","constructor","_defineProperty","set","value","key","data","setSessionMetadataForKey","id","DEFAULT_SDK_ID","get","getSessionMetadataForKey","addKeyChangeListener","forKeys","callback","_deviceEventEmitterSubscription","addListener","ON_SESSION_STORE_CHANGED","_deviceEventEmitterListener","bind","_eventEmitter","uniqueId","join","Date","now","toString","eventEmitter","subscriptions","map","cleanupHandler","_cleanup","keys","catch","err","_addedKeyChangeListenerCount","remove","subscriptionsToRemove","length","context","forEach","subscription","removeKeyChangeListener","error","logger","verbose","Object","getOwnPropertyNames","includes","removeListener","undefined","_getLogger","_this$_eventEmitter","emit"],"sources":["HMSSessionStore.ts"],"sourcesContent":["import {\n NativeModules,\n DeviceEventEmitter,\n EmitterSubscription as RNEmitterSubscription,\n} from 'react-native';\nimport { HMSConstants } from './HMSConstants';\nimport { getLogger } from './HMSLogger';\nimport { HMSUpdateListenerActions } from './HMSUpdateListenerActions';\nimport { EventEmitter } from '../utils';\nimport type { EmitterSubscription } from '../utils';\n\nconst { HMSManager } = NativeModules;\n\ntype Nullable<T> = T | null | undefined;\n\nexport type HMSSessionStoreValue = Nullable<string>;\n\n/**\n * Session store is a shared realtime key-value store that is accessible by everyone in the room.\n * It can be utilized to implement features such as pinned text, spotlight (which brings a particular\n * peer to the center stage for everyone in the room) and more.\n *\n * To get an instance of `HMSSessionStore` class, You can add an event listener for `ON_SESSION_STORE_AVAILABLE`\n * event on the `HMSSDK` instance\n *\n * For example:\n * ```\n * hmsInstance.addEventListener(HMSUpdateListenerActions.ON_SESSION_STORE_AVAILABLE, <your callback function>);\n * ```\n *\n * Checkout Session Store docs fore more details ${@link https://www.100ms.live/docs/react-native/v2/how-to-guides/interact-with-room/room/session-store}\n */\nexport class HMSSessionStore {\n private _deviceEventEmitterSubscription?: RNEmitterSubscription;\n private _eventEmitter?: EventEmitter;\n private _addedKeyChangeListenerCount = 0;\n\n /**\n * This method sets a value for a specific key on session store.\n * Once a value is assigned, it will be available for other peers in the room\n * who are listening for changes in value for that specific key.\n *\n * @param {HMSSessionStoreValue} value\n * @param {string} key\n * @returns {Promise}\n */\n async set(value: HMSSessionStoreValue, key: string) {\n const data: { success: true; finalValue: HMSSessionStoreValue } =\n await HMSManager.setSessionMetadataForKey({\n id: HMSConstants.DEFAULT_SDK_ID,\n key,\n value,\n });\n return data;\n }\n\n /**\n * This method returns the value of any specified key on session store.\n * Note that you will not get updates for any change in value of the specified key,\n * It returns the latest value at the time it was called.\n *\n * To listen to value change updates use `addKeyChangeListener` method instead.\n *\n * @param {string} key\n * @returns {Promise}\n */\n async get(key: string) {\n const data: HMSSessionStoreValue =\n await HMSManager.getSessionMetadataForKey({\n id: HMSConstants.DEFAULT_SDK_ID,\n key,\n });\n return data;\n }\n\n /**\n * This method registers a callback function for listening to value changes of a particular key.\n * Registered Callback function will be called initially with latest value and whenever the value updates\n *\n * @param {string[]} forKeys\n * @param {Function} callback\n * @returns {Object} subscription object\n */\n addKeyChangeListener<T extends string[]>(\n forKeys: T,\n callback: (\n error: string | null,\n data: { key: T[number]; value: HMSSessionStoreValue } | null\n ) => void\n ) {\n // Add Native Device Event Emitter if it is not already added\n if (!this._deviceEventEmitterSubscription) {\n this._deviceEventEmitterSubscription = DeviceEventEmitter.addListener(\n HMSUpdateListenerActions.ON_SESSION_STORE_CHANGED,\n this._deviceEventEmitterListener.bind(this)\n );\n }\n\n // Create JS side EventEmitter\n if (!this._eventEmitter) {\n this._eventEmitter = new EventEmitter();\n }\n\n // Unique Identifier for adding native event listener\n const uniqueId = forKeys.join('') + '_' + Date.now().toString();\n\n const eventEmitter = this._eventEmitter;\n\n // Add listeners on eventEmitter for each key\n const subscriptions = forKeys.map((key) =>\n eventEmitter.addListener(key, callback, { uniqueId })\n );\n\n //\n let cleanupHandler: (() => void) | null = () => {\n this._cleanup(subscriptions);\n };\n\n // Adding 'KeyChangeListener' on native side\n HMSManager.addKeyChangeListener({\n id: HMSConstants.DEFAULT_SDK_ID,\n keys: forKeys,\n uniqueId,\n })\n // Adding 'KeyChangeListener' fails on native side\n .catch((err: any) => {\n if (typeof cleanupHandler === 'function') {\n callback(err, null);\n cleanupHandler();\n cleanupHandler = null;\n }\n });\n\n this._addedKeyChangeListenerCount += 1;\n\n return {\n remove: () => {\n if (typeof cleanupHandler === 'function') {\n cleanupHandler();\n cleanupHandler = null;\n }\n },\n };\n }\n\n private _cleanup(subscriptionsToRemove: EmitterSubscription[]) {\n // Extracting `uniqueId` from first subscription (all subscriptions have same uniqueId)\n // this `uniqueId` will be used to remove 'KeyChangeListener' from native side\n const uniqueId =\n subscriptionsToRemove.length > 0\n ? (subscriptionsToRemove[0].context as { uniqueId: string }).uniqueId\n : null;\n\n // Removing required subscriptions from 'eventEmitter'\n subscriptionsToRemove.forEach((subscription) => subscription.remove());\n\n // Removing 'KeyChangeListener' from native side\n HMSManager.removeKeyChangeListener({\n id: HMSConstants.DEFAULT_SDK_ID,\n uniqueId,\n }).catch((error: any) => {\n const logger = getLogger();\n logger?.verbose(\n \"Error while removing key change listener, Listener didn't get registerred at first place or was already removed\",\n error\n );\n });\n\n this._addedKeyChangeListenerCount -= 1;\n\n if (this._addedKeyChangeListenerCount <= 0) {\n this._addedKeyChangeListenerCount = 0;\n if (\n this._deviceEventEmitterSubscription &&\n Object.getOwnPropertyNames(\n this._deviceEventEmitterSubscription\n ).includes('remove') &&\n typeof this._deviceEventEmitterSubscription.remove === 'function'\n ) {\n this._deviceEventEmitterSubscription.remove();\n } else {\n DeviceEventEmitter.removeListener(\n HMSUpdateListenerActions.ON_SESSION_STORE_CHANGED,\n this._deviceEventEmitterListener\n );\n }\n\n this._deviceEventEmitterSubscription = undefined;\n\n this._eventEmitter = undefined;\n }\n }\n\n private _deviceEventEmitterListener(data: {\n id: string;\n key: string;\n value: HMSSessionStoreValue;\n }) {\n // if id is different from default sdk_id, return early\n if (data.id !== HMSConstants.DEFAULT_SDK_ID) {\n return;\n }\n\n // emit event for the key\n getLogger()?.verbose('#Listener ON_SESSION_STORE_CHANGED event: ', data);\n\n this._eventEmitter?.emit(data.key, null, data);\n }\n}\n"],"mappings":";;;AAAA,SACEA,aAAa,EACbC,kBAAkB,QAEb,cAAc;AACrB,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,wBAAwB,QAAQ,4BAA4B;AACrE,SAASC,YAAY,QAAQ,UAAU;AAGvC,MAAM;EAAEC;AAAW,CAAC,GAAGN,aAAa;AAMpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMO,eAAe,CAAC;EAAAC,YAAA;IAAAC,eAAA;IAAAA,eAAA;IAAAA,eAAA,uCAGY,CAAC;EAAA;EAExC;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,MAAMC,GAAGA,CAACC,KAA2B,EAAEC,GAAW,EAAE;IAClD,MAAMC,IAAyD,GAC7D,MAAMP,UAAU,CAACQ,wBAAwB,CAAC;MACxCC,EAAE,EAAEb,YAAY,CAACc,cAAc;MAC/BJ,GAAG;MACHD;IACF,CAAC,CAAC;IACJ,OAAOE,IAAI;EACb;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,MAAMI,GAAGA,CAACL,GAAW,EAAE;IACrB,MAAMC,IAA0B,GAC9B,MAAMP,UAAU,CAACY,wBAAwB,CAAC;MACxCH,EAAE,EAAEb,YAAY,CAACc,cAAc;MAC/BJ;IACF,CAAC,CAAC;IACJ,OAAOC,IAAI;EACb;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;EACEM,oBAAoBA,CAClBC,OAAU,EACVC,QAGS,EACT;IACA;IACA,IAAI,CAAC,IAAI,CAACC,+BAA+B,EAAE;MACzC,IAAI,CAACA,+BAA+B,GAAGrB,kBAAkB,CAACsB,WAAW,CACnEnB,wBAAwB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AAtD,SAAS,EAAE,cAAAsD,UAAA,uBAAXA,UAAA,CAAaN,OAAO,CAAC,4CAA4C,EAAEtC,IAAI,CAAC;IAExE,CAAA6C,mBAAA,OAAI,CAAC/B,aAAa,cAAA+B,mBAAA,uBAAlBA,mBAAA,CAAoBC,IAAI,CAAC9C,IAAI,CAACD,GAAG,EAAE,IAAI,EAAEC,IAAI,CAAC;EAChD;AACF"}
1
+ {"version":3,"names":["NativeModules","DeviceEventEmitter","HMSConstants","getLogger","HMSUpdateListenerActions","EventEmitter","HMSManager","HMSSessionStore","constructor","_defineProperty","set","value","key","data","setSessionMetadataForKey","id","DEFAULT_SDK_ID","get","getSessionMetadataForKey","addKeyChangeListener","forKeys","callback","_deviceEventEmitterSubscription","addListener","ON_SESSION_STORE_CHANGED","_deviceEventEmitterListener","bind","_eventEmitter","uniqueId","join","Date","now","toString","eventEmitter","subscriptions","map","cleanupHandler","_cleanup","keys","catch","err","_addedKeyChangeListenerCount","remove","subscriptionsToRemove","length","context","forEach","subscription","removeKeyChangeListener","error","logger","verbose","Object","getOwnPropertyNames","includes","removeListener","undefined","_getLogger","_this$_eventEmitter","emit"],"sources":["HMSSessionStore.ts"],"sourcesContent":["import {\n NativeModules,\n DeviceEventEmitter,\n EmitterSubscription as RNEmitterSubscription,\n} from 'react-native';\nimport { HMSConstants } from './HMSConstants';\nimport { getLogger } from './HMSLogger';\nimport { HMSUpdateListenerActions } from './HMSUpdateListenerActions';\nimport { EventEmitter } from '../utils';\nimport type { EmitterSubscription } from '../utils';\n\nconst { HMSManager } = NativeModules;\n\ntype Nullable<T> = T | null | undefined;\n\nexport type HMSSessionStoreValue = Nullable<string>;\n\n/**\n * Session store is a shared realtime key-value store that is accessible by everyone in the room.\n * It can be utilized to implement features such as pinned text, spotlight (which brings a particular\n * peer to the center stage for everyone in the room) and more.\n *\n * To get an instance of `HMSSessionStore` class, You can add an event listener for `ON_SESSION_STORE_AVAILABLE`\n * event on the `HMSSDK` instance\n *\n * For example:\n * ```\n * hmsInstance.addEventListener(HMSUpdateListenerActions.ON_SESSION_STORE_AVAILABLE, <your callback function>);\n * ```\n *\n * Checkout Session Store docs fore more details ${@link https://www.100ms.live/docs/react-native/v2/how-to-guides/interact-with-room/room/session-store}\n */\nexport class HMSSessionStore {\n private _deviceEventEmitterSubscription?: RNEmitterSubscription;\n private _eventEmitter?: EventEmitter;\n private _addedKeyChangeListenerCount = 0;\n\n /**\n * This method sets a value for a specific key on session store.\n * Once a value is assigned, it will be available for other peers in the room\n * who are listening for changes in value for that specific key.\n *\n * @param {HMSSessionStoreValue} value\n * @param {string} key\n * @returns {Promise}\n */\n async set(value: HMSSessionStoreValue, key: string) {\n const data: { success: true; finalValue: HMSSessionStoreValue } =\n await HMSManager.setSessionMetadataForKey({\n id: HMSConstants.DEFAULT_SDK_ID,\n key,\n value,\n });\n return data;\n }\n\n /**\n * This method returns the value of any specified key on session store.\n * Note that you will not get updates for any change in value of the specified key,\n * It returns the latest value at the time it was called.\n *\n * To listen to value change updates use `addKeyChangeListener` method instead.\n *\n * @param {string} key\n * @returns {Promise}\n */\n async get(key: string) {\n const data: HMSSessionStoreValue =\n await HMSManager.getSessionMetadataForKey({\n id: HMSConstants.DEFAULT_SDK_ID,\n key,\n });\n return data;\n }\n\n /**\n * This method registers a callback function for listening to value changes of a particular key.\n * Registered Callback function will be called initially with latest value and whenever the value updates\n *\n * @param {string[]} forKeys\n * @param {Function} callback\n * @returns {Object} subscription object\n */\n addKeyChangeListener<T extends string[]>(\n forKeys: T,\n callback: (\n error: string | null,\n data: { key: T[number]; value: HMSSessionStoreValue } | null\n ) => void\n ) {\n // Add Native Device Event Emitter if it is not already added\n if (!this._deviceEventEmitterSubscription) {\n this._deviceEventEmitterSubscription = DeviceEventEmitter.addListener(\n HMSUpdateListenerActions.ON_SESSION_STORE_CHANGED,\n this._deviceEventEmitterListener.bind(this)\n );\n }\n\n // Create JS side EventEmitter\n if (!this._eventEmitter) {\n this._eventEmitter = new EventEmitter();\n }\n\n // Unique Identifier for adding native event listener\n const uniqueId = forKeys.join('') + '_' + Date.now().toString();\n\n const eventEmitter = this._eventEmitter;\n\n // Add listeners on eventEmitter for each key\n const subscriptions = forKeys.map((key) =>\n eventEmitter.addListener(key, callback, { uniqueId })\n );\n\n //\n let cleanupHandler: (() => void) | null = () => {\n this._cleanup(subscriptions);\n };\n\n // Adding 'KeyChangeListener' on native side\n HMSManager.addKeyChangeListener({\n id: HMSConstants.DEFAULT_SDK_ID,\n keys: forKeys,\n uniqueId,\n })\n // Adding 'KeyChangeListener' fails on native side\n .catch((err: any) => {\n if (typeof cleanupHandler === 'function') {\n callback(err, null);\n cleanupHandler();\n cleanupHandler = null;\n }\n });\n\n this._addedKeyChangeListenerCount += 1;\n\n return {\n remove: () => {\n if (typeof cleanupHandler === 'function') {\n cleanupHandler();\n cleanupHandler = null;\n }\n },\n };\n }\n\n private _cleanup(subscriptionsToRemove: EmitterSubscription[]) {\n // Extracting `uniqueId` from first subscription (all subscriptions have same uniqueId)\n // this `uniqueId` will be used to remove 'KeyChangeListener' from native side\n const uniqueId =\n subscriptionsToRemove.length > 0\n ? (subscriptionsToRemove[0].context as { uniqueId: string }).uniqueId\n : null;\n\n // Removing required subscriptions from 'eventEmitter'\n subscriptionsToRemove.forEach((subscription) => subscription.remove());\n\n // Removing 'KeyChangeListener' from native side\n HMSManager.removeKeyChangeListener({\n id: HMSConstants.DEFAULT_SDK_ID,\n uniqueId,\n }).catch((error: any) => {\n const logger = getLogger();\n logger?.verbose(\n \"Error while removing key change listener, Listener didn't get registerred at first place or was already removed\",\n error\n );\n });\n\n this._addedKeyChangeListenerCount -= 1;\n\n if (this._addedKeyChangeListenerCount <= 0) {\n this._addedKeyChangeListenerCount = 0;\n if (\n this._deviceEventEmitterSubscription &&\n Object.getOwnPropertyNames(\n this._deviceEventEmitterSubscription\n ).includes('remove') &&\n typeof this._deviceEventEmitterSubscription.remove === 'function'\n ) {\n this._deviceEventEmitterSubscription.remove();\n } else {\n DeviceEventEmitter.removeListener(\n HMSUpdateListenerActions.ON_SESSION_STORE_CHANGED,\n this._deviceEventEmitterListener\n );\n }\n\n this._deviceEventEmitterSubscription = undefined;\n\n this._eventEmitter = undefined;\n }\n }\n\n private _deviceEventEmitterListener(data: {\n id: string;\n key: string;\n value: HMSSessionStoreValue;\n }) {\n // if id is different from default sdk_id, return early\n if (data.id !== HMSConstants.DEFAULT_SDK_ID) {\n return;\n }\n\n // emit event for the key\n getLogger()?.verbose('#Listener ON_SESSION_STORE_CHANGED event: ', data);\n\n this._eventEmitter?.emit(data.key, null, data);\n }\n}\n"],"mappings":";;;AAAA,SACEA,aAAa,EACbC,kBAAkB,QAEb,cAAc;AACrB,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,wBAAwB,QAAQ,4BAA4B;AACrE,SAASC,YAAY,QAAQ,UAAU;AAGvC,MAAM;EAAEC;AAAW,CAAC,GAAGN,aAAa;AAMpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMO,eAAe,CAAC;EAAAC,YAAA;IAAAC,eAAA;IAAAA,eAAA;IAAAA,eAAA,uCAGY,CAAC;EAAA;EAExC;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,MAAMC,GAAGA,CAACC,KAA2B,EAAEC,GAAW,EAAE;IAClD,MAAMC,IAAyD,GAC7D,MAAMP,UAAU,CAACQ,wBAAwB,CAAC;MACxCC,EAAE,EAAEb,YAAY,CAACc,cAAc;MAC/BJ,GAAG;MACHD;IACF,CAAC,CAAC;IACJ,OAAOE,IAAI;EACb;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,MAAMI,GAAGA,CAACL,GAAW,EAAE;IACrB,MAAMC,IAA0B,GAC9B,MAAMP,UAAU,CAACY,wBAAwB,CAAC;MACxCH,EAAE,EAAEb,YAAY,CAACc,cAAc;MAC/B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C,2BACP,CAAC;MACH;MAEA,IAAI,CAACH,+BAA+B,GAAGkC,SAAS;MAEhD,IAAI,CAAC7B,aAAa,GAAG6B,SAAS;IAChC;EACF;EAEQ/B,2BAA2BA,CAACZ,IAInC,EAAE;IAAA,IAAA4C,UAAA,EAAAC,mBAAA;IACD;IACA,IAAI7C,IAAI,CAACE,EAAE,KAAKb,YAAY,CAACc,cAAc,EAAE;MAC3C;IACF;;IAEA;IACA,CAAAyC,UAAA,GAAAtD,SAAS,CAAC,CAAC,cAAAsD,UAAA,uBAAXA,UAAA,CAAaN,OAAO,CAAC,4CAA4C,EAAEtC,IAAI,CAAC;IAExE,CAAA6C,mBAAA,OAAI,CAAC/B,aAAa,cAAA+B,mBAAA,uBAAlBA,mBAAA,CAAoBC,IAAI,CAAC9C,IAAI,CAACD,GAAG,EAAE,IAAI,EAAEC,IAAI,CAAC;EAChD;AACF"}
@@ -1,5 +1,5 @@
1
- import React, { useState, useEffect, useImperativeHandle, useRef } from 'react';
2
- import { findNodeHandle, requireNativeComponent, StyleSheet, UIManager } from 'react-native';
1
+ import React, { useState, useImperativeHandle, useRef } from 'react';
2
+ import { findNodeHandle, requireNativeComponent, StyleSheet, UIManager, Platform } from 'react-native';
3
3
  import { HMSConstants } from './HMSConstants';
4
4
  import { HMSVideoViewMode } from './HMSVideoViewMode';
5
5
  const HmsView = requireNativeComponent('HMSView');
@@ -8,7 +8,7 @@ let _requestMap = new Map();
8
8
  export const HmsViewComponent = /*#__PURE__*/React.forwardRef((props, ref) => {
9
9
  const {
10
10
  trackId,
11
- style = temporaryStyles.customStyle,
11
+ style = styles.hmsView,
12
12
  id = HMSConstants.DEFAULT_SDK_ID,
13
13
  mirror = false,
14
14
  setZOrderMediaOverlay = false,
@@ -16,30 +16,24 @@ export const HmsViewComponent = /*#__PURE__*/React.forwardRef((props, ref) => {
16
16
  scaleType = HMSVideoViewMode.ASPECT_FILL
17
17
  } = props;
18
18
  const hmsViewRef = useRef();
19
- const timerRef = useRef(null);
20
- const [tempVal, setTempVal] = useState(0);
19
+ const [applyStyles_ANDROID, setApplyStyles_ANDROID] = useState(false);
21
20
  const data = {
22
21
  trackId,
23
22
  id,
24
- mirror
25
- };
26
- useEffect(() => {
27
- return () => {
28
- if (timerRef.current) {
29
- clearTimeout(timerRef.current);
30
- }
31
- };
32
- }, []);
33
- const onChange = values => {
34
- console.log(values, 'values');
35
- if (timerRef.current) {
36
- clearTimeout(timerRef.current);
37
- }
38
- timerRef.current = setTimeout(() => {
39
- setTempVal(1);
40
- timerRef.current = null;
41
- }, 2000);
23
+ mirror,
24
+ scaleType
42
25
  };
26
+
27
+ /**
28
+ * This method is passed to `onChange` prop of `HmsView` Native Component.
29
+ * It is invoked when `HmsView` emits 'topChange' event.
30
+ */
31
+ const onChange = () => setApplyStyles_ANDROID(true);
32
+
33
+ /**
34
+ * This method is passed to `onDataReturned` prop of `HmsView` Native Component.
35
+ * It is invoked when `HmsView` emits 'captureFrame' event.
36
+ */
43
37
  const _onDataReturned = event => {
44
38
  // We grab the relevant data out of our event.
45
39
  let {
@@ -80,24 +74,20 @@ export const HmsViewComponent = /*#__PURE__*/React.forwardRef((props, ref) => {
80
74
  capture
81
75
  };
82
76
  });
83
- useEffect(() => {
84
- setTempVal(0);
85
- }, [tempVal]);
86
77
  return /*#__PURE__*/React.createElement(HmsView, {
87
78
  ref: hmsViewRef,
88
79
  onChange: onChange,
89
80
  data: data,
90
- style: tempVal === 0 ? style : temporaryStyles.customStyle,
81
+ style: Platform.OS === 'android' ? applyStyles_ANDROID ? style : {} : style,
91
82
  autoSimulcast: autoSimulcast,
92
83
  scaleType: scaleType,
93
84
  setZOrderMediaOverlay: setZOrderMediaOverlay,
94
85
  onDataReturned: _onDataReturned
95
86
  });
96
87
  });
97
- const temporaryStyles = StyleSheet.create({
98
- customStyle: {
99
- width: '100%',
100
- height: '50%'
88
+ const styles = StyleSheet.create({
89
+ hmsView: {
90
+ flex: 1
101
91
  }
102
92
  });
103
93
  //# sourceMappingURL=HmsView.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","useState","useEffect","useImperativeHandle","useRef","findNodeHandle","requireNativeComponent","StyleSheet","UIManager","HMSConstants","HMSVideoViewMode","HmsView","_nextRequestId","_requestMap","Map","HmsViewComponent","forwardRef","props","ref","trackId","style","temporaryStyles","customStyle","id","DEFAULT_SDK_ID","mirror","setZOrderMediaOverlay","autoSimulcast","scaleType","ASPECT_FILL","hmsViewRef","timerRef","tempVal","setTempVal","data","current","clearTimeout","onChange","values","console","log","setTimeout","_onDataReturned","event","requestId","result","error","nativeEvent","promise","get","resolve","reject","delete","capture","requestMap","Promise","set","viewManagerConfig","getViewManagerConfig","dispatchViewManagerCommand","Commands","createElement","onDataReturned","create","width","height"],"sources":["HmsView.tsx"],"sourcesContent":["import React, { useState, useEffect, useImperativeHandle, useRef } from 'react';\nimport {\n findNodeHandle,\n requireNativeComponent,\n StyleSheet,\n UIManager,\n ViewStyle,\n} from 'react-native';\nimport { HMSConstants } from './HMSConstants';\nimport { HMSVideoViewMode } from './HMSVideoViewMode';\n\ninterface HmsViewProps {\n data: {\n trackId: string;\n id: string;\n mirror: boolean;\n };\n autoSimulcast: boolean;\n setZOrderMediaOverlay: boolean;\n scaleType: HMSVideoViewMode;\n style: ViewStyle;\n onChange: Function;\n onDataReturned: Function;\n}\n\nconst HmsView = requireNativeComponent<HmsViewProps>('HMSView');\nlet _nextRequestId = 1;\nlet _requestMap = new Map();\n\nexport interface HmsComponentProps {\n trackId: string;\n style?: ViewStyle;\n mirror?: boolean;\n autoSimulcast?: boolean;\n scaleType?: HMSVideoViewMode;\n setZOrderMediaOverlay?: boolean;\n id: string;\n}\n\nexport const HmsViewComponent = React.forwardRef<any, HmsComponentProps>(\n (props, ref) => {\n const {\n trackId,\n style = temporaryStyles.customStyle,\n id = HMSConstants.DEFAULT_SDK_ID,\n mirror = false,\n setZOrderMediaOverlay = false,\n autoSimulcast = true,\n scaleType = HMSVideoViewMode.ASPECT_FILL,\n } = props;\n\n const hmsViewRef: any = useRef();\n const timerRef = useRef<null | NodeJS.Timeout>(null);\n const [tempVal, setTempVal] = useState(0);\n const data = {\n trackId,\n id,\n mirror,\n };\n\n useEffect(() => {\n return () => {\n if (timerRef.current) {\n clearTimeout(timerRef.current);\n }\n };\n }, []);\n\n const onChange = (values: any) => {\n console.log(values, 'values');\n if (timerRef.current) {\n clearTimeout(timerRef.current);\n }\n\n timerRef.current = setTimeout(() => {\n setTempVal(1);\n timerRef.current = null;\n }, 2000);\n };\n\n const _onDataReturned = (event: {\n nativeEvent: { requestId: any; result: any; error: any };\n }) => {\n // We grab the relevant data out of our event.\n let { requestId, result, error } = event.nativeEvent;\n // Then we get the promise we saved earlier for the given request ID.\n let promise = _requestMap.get(requestId);\n if (result) {\n // If it was successful, we resolve the promise.\n promise.resolve(result);\n } else {\n // Otherwise, we reject it.\n promise.reject(error);\n }\n // Finally, we clean up our request map.\n _requestMap.delete(requestId);\n };\n\n const capture = async () => {\n let requestId = _nextRequestId++;\n let requestMap = _requestMap;\n\n // We create a promise here that will be resolved once `_onRequestDone` is\n // called.\n let promise = new Promise(function (resolve, reject) {\n requestMap.set(requestId, { resolve, reject });\n });\n const viewManagerConfig = UIManager.getViewManagerConfig('HMSView');\n UIManager.dispatchViewManagerCommand(\n findNodeHandle(hmsViewRef.current),\n viewManagerConfig.Commands.capture,\n [requestId]\n );\n return promise;\n };\n\n useImperativeHandle(ref, () => {\n return {\n capture,\n };\n });\n\n useEffect(() => {\n setTempVal(0);\n }, [tempVal]);\n\n return (\n <HmsView\n ref={hmsViewRef}\n onChange={onChange}\n data={data}\n style={tempVal === 0 ? style : temporaryStyles.customStyle}\n autoSimulcast={autoSimulcast}\n scaleType={scaleType}\n setZOrderMediaOverlay={setZOrderMediaOverlay}\n onDataReturned={_onDataReturned}\n />\n );\n }\n);\n\nconst temporaryStyles = StyleSheet.create({\n customStyle: {\n width: '100%',\n height: '50%',\n },\n});\n"],"mappings":"AAAA,OAAOA,KAAK,IAAI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EACH,CAAC,CAAC;EAEFnD,SAAS,CAAC,MAAM;IACd+B,UAAU,CAAC,CAAC,CAAC;EACf,CAAC,EAAE,CAACD,OAAO,CAAC,CAAC;EAEb,oBACEhC,KAAA,CAAA6D,aAAA,CAAClD,OAAO;IACNO,GAAG,EAAEY,UAAW;IAChBO,QAAQ,EAAEA,QAAS;IACnBH,IAAI,EAAEA,IAAK;IACXd,KAAK,EAAEY,OAAO,KAAK,CAAC,GAAGZ,KAAK,GAAGC,eAAe,CAACC,WAAY;IAC3DK,aAAa,EAAEA,aAAc;IAC7BC,SAAS,EAAEA,SAAU;IACrBF,qBAAqB,EAAEA,qBAAsB;IAC7CoC,cAAc,EAAEpB;EAAgB,EAChC;AAEN,CAAC,CACF;AAED,MAAMrB,eAAe,GAAGd,UAAU,CAACwD,MAAM,CAAC;EACxCzC,WAAW,EAAE;IACX0C,KAAK,EAAE,MAAM;IACbC,MAAM,EAAE;EACV;AACF,CAAC,CAAC"}
1
+ {"version":3,"names":["React","useState","useImperativeHandle","useRef","findNodeHandle","requireNativeComponent","StyleSheet","UIManager","Platform","HMSConstants","HMSVideoViewMode","HmsView","_nextRequestId","_requestMap","Map","HmsViewComponent","forwardRef","props","ref","trackId","style","styles","hmsView","id","DEFAULT_SDK_ID","mirror","setZOrderMediaOverlay","autoSimulcast","scaleType","ASPECT_FILL","hmsViewRef","applyStyles_ANDROID","setApplyStyles_ANDROID","data","onChange","_onDataReturned","event","requestId","result","error","nativeEvent","promise","get","resolve","reject","delete","capture","requestMap","Promise","set","viewManagerConfig","getViewManagerConfig","dispatchViewManagerCommand","current","Commands","createElement","OS","onDataReturned","create","flex"],"sources":["HmsView.tsx"],"sourcesContent":["import React, { useState, useImperativeHandle, useRef } from 'react';\nimport {\n findNodeHandle,\n requireNativeComponent,\n StyleSheet,\n UIManager,\n ViewStyle,\n Platform,\n} from 'react-native';\nimport { HMSConstants } from './HMSConstants';\nimport { HMSVideoViewMode } from './HMSVideoViewMode';\n\ninterface HmsViewProps {\n data: {\n trackId: string;\n id: string;\n mirror: boolean;\n scaleType: HMSVideoViewMode;\n };\n autoSimulcast: boolean;\n setZOrderMediaOverlay: boolean;\n scaleType: HMSVideoViewMode;\n style: ViewStyle;\n onChange: Function;\n onDataReturned: Function;\n}\n\nconst HmsView = requireNativeComponent<HmsViewProps>('HMSView');\nlet _nextRequestId = 1;\nlet _requestMap = new Map();\n\nexport interface HmsComponentProps {\n trackId: string;\n style?: ViewStyle;\n mirror?: boolean;\n autoSimulcast?: boolean;\n scaleType?: HMSVideoViewMode;\n setZOrderMediaOverlay?: boolean;\n id: string;\n}\n\nexport const HmsViewComponent = React.forwardRef<any, HmsComponentProps>(\n (props, ref) => {\n const {\n trackId,\n style = styles.hmsView,\n id = HMSConstants.DEFAULT_SDK_ID,\n mirror = false,\n setZOrderMediaOverlay = false,\n autoSimulcast = true,\n scaleType = HMSVideoViewMode.ASPECT_FILL,\n } = props;\n\n const hmsViewRef: any = useRef();\n const [applyStyles_ANDROID, setApplyStyles_ANDROID] = useState(false);\n const data = {\n trackId,\n id,\n mirror,\n scaleType,\n };\n\n /**\n * This method is passed to `onChange` prop of `HmsView` Native Component.\n * It is invoked when `HmsView` emits 'topChange' event.\n */\n const onChange = () => setApplyStyles_ANDROID(true);\n\n /**\n * This method is passed to `onDataReturned` prop of `HmsView` Native Component.\n * It is invoked when `HmsView` emits 'captureFrame' event.\n */\n const _onDataReturned = (event: {\n nativeEvent: { requestId: any; result: any; error: any };\n }) => {\n // We grab the relevant data out of our event.\n let { requestId, result, error } = event.nativeEvent;\n // Then we get the promise we saved earlier for the given request ID.\n let promise = _requestMap.get(requestId);\n if (result) {\n // If it was successful, we resolve the promise.\n promise.resolve(result);\n } else {\n // Otherwise, we reject it.\n promise.reject(error);\n }\n // Finally, we clean up our request map.\n _requestMap.delete(requestId);\n };\n\n const capture = async () => {\n let requestId = _nextRequestId++;\n let requestMap = _requestMap;\n\n // We create a promise here that will be resolved once `_onRequestDone` is\n // called.\n let promise = new Promise(function (resolve, reject) {\n requestMap.set(requestId, { resolve, reject });\n });\n const viewManagerConfig = UIManager.getViewManagerConfig('HMSView');\n UIManager.dispatchViewManagerCommand(\n findNodeHandle(hmsViewRef.current),\n viewManagerConfig.Commands.capture,\n [requestId]\n );\n return promise;\n };\n\n useImperativeHandle(ref, () => {\n return {\n capture,\n };\n });\n\n return (\n <HmsView\n ref={hmsViewRef}\n onChange={onChange}\n data={data}\n style={\n Platform.OS === 'android' ? (applyStyles_ANDROID ? style : {}) : style\n }\n autoSimulcast={autoSimulcast}\n scaleType={scaleType}\n setZOrderMediaOverlay={setZOrderMediaOverlay}\n onDataReturned={_onDataReturned}\n />\n );\n }\n);\n\nconst styles = StyleSheet.create({\n hmsView: {\n flex: 1,\n },\n});\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,mBAAmB,EAAEC,MAAM,QAAQ,OAAO;AACpE,SACEC,cAAc,EACdC,sBAAsB,EACtBC,UAAU,EACVC,SAAS,EAETC,QAAQ,QACH,cAAc;AACrB,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,gBAAgB,QAAQ,oBAAoB;AAiBrD,MAAMC,OAAO,GAAGN,sBAAsB,CAAe,SAAS,CAAC;AAC/D,IAAIO,cAAc,GAAG,CAAC;AACtB,IAAIC,WAAW,GAAG,IAAIC,GAAG,CAAC,CAAC;AAY3B,OAAO,MAAMC,gBAAgB,gBAAGf,KAAK,CAACgB,UAAU,CAC9C,CAACC,KAAK,EAAEC,GAAG,KAAK;EACd,MAAM;IACJC,OAAO;IACPC,KAAK,GAAGC,MAAM,CAACC,OAAO;IACtBC,EAAE,GAAGd,YAAY,CAACe,cAAc;IAChCC,MAAM,GAAG,KAAK;IACdC,qBAAqB,GAAG,KAAK;IAC7BC,aAAa,GAAG,IAAI;IACpBC,SAAS,GAAGlB,gBAAgB,CAACmB;EAC/B,CAAC,GAAGZ,KAAK;EAET,MAAMa,UAAe,GAAG3B,MAAM,CAAC,CAAC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AAC;EAEDvC,mBAAmB,CAACgB,GAAG,EAAE,MAAM;IAC7B,OAAO;MACL4B;IACF,CAAC;EACH,CAAC,CAAC;EAEF,oBACE9C,KAAA,CAAAuD,aAAA,CAAC5C,OAAO;IACNO,GAAG,EAAEY,UAAW;IAChBI,QAAQ,EAAEA,QAAS;IACnBD,IAAI,EAAEA,IAAK;IACXb,KAAK,EACHZ,QAAQ,CAACgD,EAAE,KAAK,SAAS,GAAIzB,mBAAmB,GAAGX,KAAK,GAAG,CAAC,CAAC,GAAIA,KAClE;IACDO,aAAa,EAAEA,aAAc;IAC7BC,SAAS,EAAEA,SAAU;IACrBF,qBAAqB,EAAEA,qBAAsB;IAC7C+B,cAAc,EAAEtB;EAAgB,CACjC,CAAC;AAEN,CACF,CAAC;AAED,MAAMd,MAAM,GAAGf,UAAU,CAACoD,MAAM,CAAC;EAC/BpC,OAAO,EAAE;IACPqC,IAAI,EAAE;EACR;AACF,CAAC,CAAC"}
@@ -1 +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,W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AJMI,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"}
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,CAAC,CAAC;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,CACnE,CAAC;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,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M,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,CAAC,CAAC;QACvB;MACF;IACF;EACF;AACF"}
@@ -3,12 +3,14 @@ import type { HMSMessageType } from './HMSMessageType';
3
3
  import type { HMSPeer } from './HMSPeer';
4
4
  export declare class HMSMessage {
5
5
  message: string;
6
+ messageId: string;
6
7
  type: HMSMessageType;
7
8
  time: Date;
8
9
  sender?: HMSPeer;
9
10
  recipient: HMSMessageRecipient;
10
11
  constructor(params: {
11
12
  message: string;
13
+ messageId: string;
12
14
  type: HMSMessageType;
13
15
  time: Date;
14
16
  sender?: HMSPeer;
@@ -152,7 +152,9 @@ export declare class HMSSDK {
152
152
  * @param {message: string} and @param {type: string}
153
153
  * @memberof HMSSDK
154
154
  */
155
- sendBroadcastMessage: (message: string, type?: HMSMessageType) => Promise<any>;
155
+ sendBroadcastMessage: (message: string, type?: HMSMessageType) => Promise<{
156
+ messageId: string | undefined;
157
+ }>;
156
158
  /**
157
159
  * - sendGroupMessage sends a message to specific set of roles, whoever has any of those role in room
158
160
  * will get the message in onMessage listener.
@@ -161,7 +163,9 @@ export declare class HMSSDK {
161
163
  *
162
164
  * @memberof HMSSDK
163
165
  */
164
- sendGroupMessage: (message: string, roles: HMSRole[], type?: HMSMessageType) => Promise<any>;
166
+ sendGroupMessage: (message: string, roles: HMSRole[], type?: HMSMessageType) => Promise<{
167
+ messageId: string | undefined;
168
+ }>;
165
169
  /**
166
170
  * - sendDirectMessage sends a private message to a single peer, only that peer will get the message
167
171
  * in onMessage Listener.
@@ -170,7 +174,9 @@ export declare class HMSSDK {
170
174
  *
171
175
  * @memberof HMSSDK
172
176
  */
173
- sendDirectMessage: (message: string, peer: HMSPeer, type?: HMSMessageType) => Promise<any>;
177
+ sendDirectMessage: (message: string, peer: HMSPeer, type?: HMSMessageType) => Promise<{
178
+ messageId: string | undefined;
179
+ }>;
174
180
  /**
175
181
  * - changeMetadata changes a specific field in localPeer which is [metadata] it is a string that can
176
182
  * be used for various functionalities like raiseHand, beRightBack and many more that explains the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@100mslive/react-native-hms",
3
- "version": "1.6.0",
3
+ "version": "1.6.2",
4
4
  "description": "Integrate Real Time Audio and Video conferencing, Interactive Live Streaming, and Chat in your apps with 100ms React Native SDK. With support for HLS and RTMP Live Streaming and Recording, Picture-in-Picture (PiP), one-to-one Video Call Modes, Audio Rooms, Video Player and much more, add immersive real-time communications to your apps.",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -30,7 +30,8 @@
30
30
  "release": "release-it",
31
31
  "example": "yarn --cwd example",
32
32
  "pods": "cd example && pod-install --quiet",
33
- "bootstrap": "yarn example && yarn && yarn pods"
33
+ "bootstrap": "yarn example && yarn && yarn pods",
34
+ "typedoc": "npx typedoc src/index.ts --excludePrivate --excludeProtected --excludeInternal"
34
35
  },
35
36
  "keywords": [
36
37
  "react-native",
@@ -112,10 +113,11 @@
112
113
  "husky": "^4.2.5",
113
114
  "jest": "^26.0.1",
114
115
  "prettier": "^2.0.5",
115
- "react-native-builder-bob": "^0.18.0",
116
- "typescript": "^4.6.3",
117
116
  "react": "17.0.1",
118
- "react-native": "0.64.4"
117
+ "react-native": "0.64.4",
118
+ "react-native-builder-bob": "^0.18.0",
119
+ "typedoc": "^0.24.7",
120
+ "typescript": "^4.6.3"
119
121
  },
120
122
  "peerDependencies": {
121
123
  "react": "*",
package/sdk-versions.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "ios": "0.9.3",
2
+ "ios": "0.9.4",
3
3
  "iOSBroadcastExtension": "0.0.9",
4
- "android": "2.6.2"
4
+ "android": "2.6.4"
5
5
  }
@@ -528,6 +528,7 @@ export class HMSEncoder {
528
528
  if (data) {
529
529
  return new HMSMessage({
530
530
  message: data?.message,
531
+ messageId: data?.messageId,
531
532
  type: data?.type,
532
533
  time: new Date(parseInt(data?.time)),
533
534
  sender: this.encodeHmsPeer(data?.sender),
@@ -3,8 +3,8 @@ import type { HMSMessageType } from './HMSMessageType';
3
3
  import type { HMSPeer } from './HMSPeer';
4
4
 
5
5
  export class HMSMessage {
6
- // endpoint: string;
7
6
  public message: string;
7
+ public messageId: string;
8
8
  public type: HMSMessageType;
9
9
  public time: Date;
10
10
  public sender?: HMSPeer;
@@ -12,12 +12,14 @@ export class HMSMessage {
12
12
 
13
13
  constructor(params: {
14
14
  message: string;
15
+ messageId: string;
15
16
  type: HMSMessageType;
16
17
  time: Date;
17
18
  sender?: HMSPeer;
18
19
  recipient: HMSMessageRecipient;
19
20
  }) {
20
21
  this.message = params.message;
22
+ this.messageId = params.messageId;
21
23
  this.type = params.type;
22
24
  this.time = params.time;
23
25
  this.sender = params.sender;
@@ -314,11 +314,14 @@ export class HMSSDK {
314
314
  type: type || null,
315
315
  id: this.id,
316
316
  });
317
- return await HMSManager.sendBroadcastMessage({
318
- message,
319
- type: type || null,
320
- id: this.id,
321
- });
317
+ const data: { messageId: string | undefined } =
318
+ await HMSManager.sendBroadcastMessage({
319
+ message,
320
+ type: type || null,
321
+ id: this.id,
322
+ });
323
+
324
+ return data;
322
325
  };
323
326
 
324
327
  /**
@@ -340,12 +343,15 @@ export class HMSSDK {
340
343
  id: this.id,
341
344
  type: type || null,
342
345
  });
343
- return await HMSManager.sendGroupMessage({
344
- message,
345
- roles: HMSHelper.getRoleNames(roles),
346
- id: this.id,
347
- type: type || null,
348
- });
346
+ const data: { messageId: string | undefined } =
347
+ await HMSManager.sendGroupMessage({
348
+ message,
349
+ roles: HMSHelper.getRoleNames(roles),
350
+ id: this.id,
351
+ type: type || null,
352
+ });
353
+
354
+ return data;
349
355
  };
350
356
 
351
357
  /**
@@ -367,12 +373,15 @@ export class HMSSDK {
367
373
  id: this.id,
368
374
  type: type || null,
369
375
  });
370
- return await HMSManager.sendDirectMessage({
371
- message,
372
- peerId: peer.peerID,
373
- id: this.id,
374
- type: type || null,
375
- });
376
+ const data: { messageId: string | undefined } =
377
+ await HMSManager.sendDirectMessage({
378
+ message,
379
+ peerId: peer.peerID,
380
+ id: this.id,
381
+ type: type || null,
382
+ });
383
+
384
+ return data;
376
385
  };
377
386
 
378
387
  /**
@@ -1,10 +1,11 @@
1
- import React, { useState, useEffect, useImperativeHandle, useRef } from 'react';
1
+ import React, { useState, useImperativeHandle, useRef } from 'react';
2
2
  import {
3
3
  findNodeHandle,
4
4
  requireNativeComponent,
5
5
  StyleSheet,
6
6
  UIManager,
7
7
  ViewStyle,
8
+ Platform,
8
9
  } from 'react-native';
9
10
  import { HMSConstants } from './HMSConstants';
10
11
  import { HMSVideoViewMode } from './HMSVideoViewMode';
@@ -14,6 +15,7 @@ interface HmsViewProps {
14
15
  trackId: string;
15
16
  id: string;
16
17
  mirror: boolean;
18
+ scaleType: HMSVideoViewMode;
17
19
  };
18
20
  autoSimulcast: boolean;
19
21
  setZOrderMediaOverlay: boolean;
@@ -41,7 +43,7 @@ export const HmsViewComponent = React.forwardRef<any, HmsComponentProps>(
41
43
  (props, ref) => {
42
44
  const {
43
45
  trackId,
44
- style = temporaryStyles.customStyle,
46
+ style = styles.hmsView,
45
47
  id = HMSConstants.DEFAULT_SDK_ID,
46
48
  mirror = false,
47
49
  setZOrderMediaOverlay = false,
@@ -50,34 +52,24 @@ export const HmsViewComponent = React.forwardRef<any, HmsComponentProps>(
50
52
  } = props;
51
53
 
52
54
  const hmsViewRef: any = useRef();
53
- const timerRef = useRef<null | NodeJS.Timeout>(null);
54
- const [tempVal, setTempVal] = useState(0);
55
+ const [applyStyles_ANDROID, setApplyStyles_ANDROID] = useState(false);
55
56
  const data = {
56
57
  trackId,
57
58
  id,
58
59
  mirror,
60
+ scaleType,
59
61
  };
60
62
 
61
- useEffect(() => {
62
- return () => {
63
- if (timerRef.current) {
64
- clearTimeout(timerRef.current);
65
- }
66
- };
67
- }, []);
68
-
69
- const onChange = (values: any) => {
70
- console.log(values, 'values');
71
- if (timerRef.current) {
72
- clearTimeout(timerRef.current);
73
- }
74
-
75
- timerRef.current = setTimeout(() => {
76
- setTempVal(1);
77
- timerRef.current = null;
78
- }, 2000);
79
- };
63
+ /**
64
+ * This method is passed to `onChange` prop of `HmsView` Native Component.
65
+ * It is invoked when `HmsView` emits 'topChange' event.
66
+ */
67
+ const onChange = () => setApplyStyles_ANDROID(true);
80
68
 
69
+ /**
70
+ * This method is passed to `onDataReturned` prop of `HmsView` Native Component.
71
+ * It is invoked when `HmsView` emits 'captureFrame' event.
72
+ */
81
73
  const _onDataReturned = (event: {
82
74
  nativeEvent: { requestId: any; result: any; error: any };
83
75
  }) => {
@@ -120,16 +112,14 @@ export const HmsViewComponent = React.forwardRef<any, HmsComponentProps>(
120
112
  };
121
113
  });
122
114
 
123
- useEffect(() => {
124
- setTempVal(0);
125
- }, [tempVal]);
126
-
127
115
  return (
128
116
  <HmsView
129
117
  ref={hmsViewRef}
130
118
  onChange={onChange}
131
119
  data={data}
132
- style={tempVal === 0 ? style : temporaryStyles.customStyle}
120
+ style={
121
+ Platform.OS === 'android' ? (applyStyles_ANDROID ? style : {}) : style
122
+ }
133
123
  autoSimulcast={autoSimulcast}
134
124
  scaleType={scaleType}
135
125
  setZOrderMediaOverlay={setZOrderMediaOverlay}
@@ -139,9 +129,8 @@ export const HmsViewComponent = React.forwardRef<any, HmsComponentProps>(
139
129
  }
140
130
  );
141
131
 
142
- const temporaryStyles = StyleSheet.create({
143
- customStyle: {
144
- width: '100%',
145
- height: '50%',
132
+ const styles = StyleSheet.create({
133
+ hmsView: {
134
+ flex: 1,
146
135
  },
147
136
  });