@100mslive/react-native-hms 1.9.9 → 1.9.11

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 (205) hide show
  1. package/android/local.properties +8 -1
  2. package/android/src/main/java/com/reactnativehmssdk/HMSDecoder.kt +2 -0
  3. package/android/src/main/java/com/reactnativehmssdk/HMSManager.kt +61 -2
  4. package/android/src/main/java/com/reactnativehmssdk/HMSRNSDK.kt +10 -3
  5. package/android/src/main/java/com/reactnativehmssdk/Interactivity/HMSInteractivityDecoder.kt +328 -0
  6. package/android/src/main/java/com/reactnativehmssdk/Interactivity/HMSInteractivityHelper.kt +352 -0
  7. package/android/src/main/java/com/reactnativehmssdk/Interactivity/HMSRNInteractivityCenter.kt +184 -0
  8. package/ios/HMSConstants.swift +1 -0
  9. package/ios/HMSDecoder.swift +3 -1
  10. package/ios/HMSInteractivityDecoder.swift +223 -0
  11. package/ios/HMSInteractivityHelper.swift +169 -0
  12. package/ios/HMSManager.m +17 -0
  13. package/ios/HMSManager.swift +30 -1
  14. package/ios/HMSRNInteractivityCenter.swift +89 -0
  15. package/ios/HMSRNSDK.swift +10 -4
  16. package/ios/Hmssdk.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  17. package/ios/Hmssdk.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  18. package/ios/Hmssdk.xcodeproj/project.xcworkspace/xcuserdata/jatinnagar.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  19. package/ios/Hmssdk.xcodeproj/xcuserdata/jatinnagar.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
  20. package/lib/commonjs/classes/HMSInteractivityCenter.js +99 -0
  21. package/lib/commonjs/classes/HMSInteractivityCenter.js.map +1 -0
  22. package/lib/commonjs/classes/HMSInteractivityEncoder.js +33 -0
  23. package/lib/commonjs/classes/HMSInteractivityEncoder.js.map +1 -0
  24. package/lib/commonjs/classes/HMSPermissions.js +4 -0
  25. package/lib/commonjs/classes/HMSPermissions.js.map +1 -1
  26. package/lib/commonjs/classes/HMSPollsListenerActions.js +11 -0
  27. package/lib/commonjs/classes/HMSPollsListenerActions.js.map +1 -0
  28. package/lib/commonjs/classes/HMSSDK.js +8 -0
  29. package/lib/commonjs/classes/HMSSDK.js.map +1 -1
  30. package/lib/commonjs/classes/polls/HMSPoll.js +6 -0
  31. package/lib/commonjs/classes/polls/HMSPoll.js.map +1 -0
  32. package/lib/commonjs/classes/polls/HMSPollCategory.js +12 -0
  33. package/lib/commonjs/classes/polls/HMSPollCategory.js.map +1 -0
  34. package/lib/commonjs/classes/polls/HMSPollCreateParams.js +6 -0
  35. package/lib/commonjs/classes/polls/HMSPollCreateParams.js.map +1 -0
  36. package/lib/commonjs/classes/polls/HMSPollQuestion.js +6 -0
  37. package/lib/commonjs/classes/polls/HMSPollQuestion.js.map +1 -0
  38. package/lib/commonjs/classes/polls/HMSPollQuestionAnswer.js +2 -0
  39. package/lib/commonjs/classes/polls/HMSPollQuestionAnswer.js.map +1 -0
  40. package/lib/commonjs/classes/polls/HMSPollQuestionCreateParams.js +6 -0
  41. package/lib/commonjs/classes/polls/HMSPollQuestionCreateParams.js.map +1 -0
  42. package/lib/commonjs/classes/polls/HMSPollQuestionOption.js +2 -0
  43. package/lib/commonjs/classes/polls/HMSPollQuestionOption.js.map +1 -0
  44. package/lib/commonjs/classes/polls/HMSPollQuestionOptionCreateParams.js +6 -0
  45. package/lib/commonjs/classes/polls/HMSPollQuestionOptionCreateParams.js.map +1 -0
  46. package/lib/commonjs/classes/polls/HMSPollQuestionQuizOptionCreateParams.js +6 -0
  47. package/lib/commonjs/classes/polls/HMSPollQuestionQuizOptionCreateParams.js.map +1 -0
  48. package/lib/commonjs/classes/polls/HMSPollQuestionResponse.js +6 -0
  49. package/lib/commonjs/classes/polls/HMSPollQuestionResponse.js.map +1 -0
  50. package/lib/commonjs/classes/polls/HMSPollQuestionResponseCreateParams.js +6 -0
  51. package/lib/commonjs/classes/polls/HMSPollQuestionResponseCreateParams.js.map +1 -0
  52. package/lib/commonjs/classes/polls/HMSPollQuestionResponseResult.js +2 -0
  53. package/lib/commonjs/classes/polls/HMSPollQuestionResponseResult.js.map +1 -0
  54. package/lib/commonjs/classes/polls/HMSPollQuestionResult.js +2 -0
  55. package/lib/commonjs/classes/polls/HMSPollQuestionResult.js.map +1 -0
  56. package/lib/commonjs/classes/polls/HMSPollQuestionType.js +14 -0
  57. package/lib/commonjs/classes/polls/HMSPollQuestionType.js.map +1 -0
  58. package/lib/commonjs/classes/polls/HMSPollResponsePeerInfo.js +2 -0
  59. package/lib/commonjs/classes/polls/HMSPollResponsePeerInfo.js.map +1 -0
  60. package/lib/commonjs/classes/polls/HMSPollResult.js +6 -0
  61. package/lib/commonjs/classes/polls/HMSPollResult.js.map +1 -0
  62. package/lib/commonjs/classes/polls/HMSPollState.js +13 -0
  63. package/lib/commonjs/classes/polls/HMSPollState.js.map +1 -0
  64. package/lib/commonjs/classes/polls/HMSPollType.js +12 -0
  65. package/lib/commonjs/classes/polls/HMSPollType.js.map +1 -0
  66. package/lib/commonjs/classes/polls/HMSPollUpdateType.js +13 -0
  67. package/lib/commonjs/classes/polls/HMSPollUpdateType.js.map +1 -0
  68. package/lib/commonjs/classes/polls/HMSPollUserTrackingMode.js +13 -0
  69. package/lib/commonjs/classes/polls/HMSPollUserTrackingMode.js.map +1 -0
  70. package/lib/commonjs/hooks/polls.js +17 -0
  71. package/lib/commonjs/hooks/polls.js.map +1 -0
  72. package/lib/commonjs/index.js +56 -0
  73. package/lib/commonjs/index.js.map +1 -1
  74. package/lib/commonjs/stores/hms-interactivity-store.js +21 -0
  75. package/lib/commonjs/stores/hms-interactivity-store.js.map +1 -0
  76. package/lib/commonjs/stores/hms-polls-slice.js +19 -0
  77. package/lib/commonjs/stores/hms-polls-slice.js.map +1 -0
  78. package/lib/commonjs/stores/types.js.map +1 -1
  79. package/lib/commonjs/utils/emitter/EventEmitter.js +19 -0
  80. package/lib/commonjs/utils/emitter/EventEmitter.js.map +1 -1
  81. package/lib/module/classes/HMSInteractivityCenter.js +91 -0
  82. package/lib/module/classes/HMSInteractivityCenter.js.map +1 -0
  83. package/lib/module/classes/HMSInteractivityEncoder.js +26 -0
  84. package/lib/module/classes/HMSInteractivityEncoder.js.map +1 -0
  85. package/lib/module/classes/HMSPermissions.js +4 -0
  86. package/lib/module/classes/HMSPermissions.js.map +1 -1
  87. package/lib/module/classes/HMSPollsListenerActions.js +5 -0
  88. package/lib/module/classes/HMSPollsListenerActions.js.map +1 -0
  89. package/lib/module/classes/HMSSDK.js +8 -0
  90. package/lib/module/classes/HMSSDK.js.map +1 -1
  91. package/lib/module/classes/polls/HMSPoll.js +2 -0
  92. package/lib/module/classes/polls/HMSPoll.js.map +1 -0
  93. package/lib/module/classes/polls/HMSPollCategory.js +6 -0
  94. package/lib/module/classes/polls/HMSPollCategory.js.map +1 -0
  95. package/lib/module/classes/polls/HMSPollCreateParams.js +2 -0
  96. package/lib/module/classes/polls/HMSPollCreateParams.js.map +1 -0
  97. package/lib/module/classes/polls/HMSPollQuestion.js +2 -0
  98. package/lib/module/classes/polls/HMSPollQuestion.js.map +1 -0
  99. package/lib/module/classes/polls/HMSPollQuestionAnswer.js +2 -0
  100. package/lib/module/classes/polls/HMSPollQuestionAnswer.js.map +1 -0
  101. package/lib/module/classes/polls/HMSPollQuestionCreateParams.js +2 -0
  102. package/lib/module/classes/polls/HMSPollQuestionCreateParams.js.map +1 -0
  103. package/lib/module/classes/polls/HMSPollQuestionOption.js +2 -0
  104. package/lib/module/classes/polls/HMSPollQuestionOption.js.map +1 -0
  105. package/lib/module/classes/polls/HMSPollQuestionOptionCreateParams.js +2 -0
  106. package/lib/module/classes/polls/HMSPollQuestionOptionCreateParams.js.map +1 -0
  107. package/lib/module/classes/polls/HMSPollQuestionQuizOptionCreateParams.js +2 -0
  108. package/lib/module/classes/polls/HMSPollQuestionQuizOptionCreateParams.js.map +1 -0
  109. package/lib/module/classes/polls/HMSPollQuestionResponse.js +2 -0
  110. package/lib/module/classes/polls/HMSPollQuestionResponse.js.map +1 -0
  111. package/lib/module/classes/polls/HMSPollQuestionResponseCreateParams.js +2 -0
  112. package/lib/module/classes/polls/HMSPollQuestionResponseCreateParams.js.map +1 -0
  113. package/lib/module/classes/polls/HMSPollQuestionResponseResult.js +2 -0
  114. package/lib/module/classes/polls/HMSPollQuestionResponseResult.js.map +1 -0
  115. package/lib/module/classes/polls/HMSPollQuestionResult.js +2 -0
  116. package/lib/module/classes/polls/HMSPollQuestionResult.js.map +1 -0
  117. package/lib/module/classes/polls/HMSPollQuestionType.js +8 -0
  118. package/lib/module/classes/polls/HMSPollQuestionType.js.map +1 -0
  119. package/lib/module/classes/polls/HMSPollResponsePeerInfo.js +2 -0
  120. package/lib/module/classes/polls/HMSPollResponsePeerInfo.js.map +1 -0
  121. package/lib/module/classes/polls/HMSPollResult.js +2 -0
  122. package/lib/module/classes/polls/HMSPollResult.js.map +1 -0
  123. package/lib/module/classes/polls/HMSPollState.js +7 -0
  124. package/lib/module/classes/polls/HMSPollState.js.map +1 -0
  125. package/lib/module/classes/polls/HMSPollType.js +6 -0
  126. package/lib/module/classes/polls/HMSPollType.js.map +1 -0
  127. package/lib/module/classes/polls/HMSPollUpdateType.js +7 -0
  128. package/lib/module/classes/polls/HMSPollUpdateType.js.map +1 -0
  129. package/lib/module/classes/polls/HMSPollUserTrackingMode.js +7 -0
  130. package/lib/module/classes/polls/HMSPollUserTrackingMode.js.map +1 -0
  131. package/lib/module/hooks/polls.js +12 -0
  132. package/lib/module/hooks/polls.js.map +1 -0
  133. package/lib/module/index.js +7 -0
  134. package/lib/module/index.js.map +1 -1
  135. package/lib/module/stores/hms-interactivity-store.js +15 -0
  136. package/lib/module/stores/hms-interactivity-store.js.map +1 -0
  137. package/lib/module/stores/hms-polls-slice.js +12 -0
  138. package/lib/module/stores/hms-polls-slice.js.map +1 -0
  139. package/lib/module/stores/types.js.map +1 -1
  140. package/lib/module/utils/emitter/EventEmitter.js +19 -0
  141. package/lib/module/utils/emitter/EventEmitter.js.map +1 -1
  142. package/lib/typescript/classes/HMSInteractivityCenter.d.ts +35 -0
  143. package/lib/typescript/classes/HMSInteractivityEncoder.d.ts +4 -0
  144. package/lib/typescript/classes/HMSPermissions.d.ts +4 -0
  145. package/lib/typescript/classes/HMSPollsListenerActions.d.ts +3 -0
  146. package/lib/typescript/classes/HMSSDK.d.ts +3 -0
  147. package/lib/typescript/classes/polls/HMSPoll.d.ts +81 -0
  148. package/lib/typescript/classes/polls/HMSPollCategory.d.ts +10 -0
  149. package/lib/typescript/classes/polls/HMSPollCreateParams.d.ts +9 -0
  150. package/lib/typescript/classes/polls/HMSPollQuestion.d.ts +61 -0
  151. package/lib/typescript/classes/polls/HMSPollQuestionAnswer.d.ts +17 -0
  152. package/lib/typescript/classes/polls/HMSPollQuestionCreateParams.d.ts +25 -0
  153. package/lib/typescript/classes/polls/HMSPollQuestionOption.d.ts +21 -0
  154. package/lib/typescript/classes/polls/HMSPollQuestionOptionCreateParams.d.ts +3 -0
  155. package/lib/typescript/classes/polls/HMSPollQuestionQuizOptionCreateParams.d.ts +4 -0
  156. package/lib/typescript/classes/polls/HMSPollQuestionResponse.d.ts +47 -0
  157. package/lib/typescript/classes/polls/HMSPollQuestionResponseCreateParams.d.ts +2 -0
  158. package/lib/typescript/classes/polls/HMSPollQuestionResponseResult.d.ts +17 -0
  159. package/lib/typescript/classes/polls/HMSPollQuestionResult.d.ts +29 -0
  160. package/lib/typescript/classes/polls/HMSPollQuestionType.d.ts +18 -0
  161. package/lib/typescript/classes/polls/HMSPollResponsePeerInfo.d.ts +21 -0
  162. package/lib/typescript/classes/polls/HMSPollResult.d.ts +22 -0
  163. package/lib/typescript/classes/polls/HMSPollState.d.ts +14 -0
  164. package/lib/typescript/classes/polls/HMSPollType.d.ts +4 -0
  165. package/lib/typescript/classes/polls/HMSPollUpdateType.d.ts +5 -0
  166. package/lib/typescript/classes/polls/HMSPollUserTrackingMode.d.ts +14 -0
  167. package/lib/typescript/hooks/polls.d.ts +3 -0
  168. package/lib/typescript/index.d.ts +8 -0
  169. package/lib/typescript/stores/hms-interactivity-store.d.ts +9 -0
  170. package/lib/typescript/stores/hms-polls-slice.d.ts +5 -0
  171. package/lib/typescript/stores/types.d.ts +6 -0
  172. package/lib/typescript/utils/emitter/EventEmitter.d.ts +7 -0
  173. package/package.json +1 -1
  174. package/sdk-versions.json +2 -2
  175. package/src/classes/HMSInteractivityCenter.ts +137 -0
  176. package/src/classes/HMSInteractivityEncoder.ts +29 -0
  177. package/src/classes/HMSPermissions.ts +6 -0
  178. package/src/classes/HMSPollsListenerActions.ts +3 -0
  179. package/src/classes/HMSSDK.tsx +10 -0
  180. package/src/classes/polls/HMSPoll.ts +108 -0
  181. package/src/classes/polls/HMSPollCategory.ts +11 -0
  182. package/src/classes/polls/HMSPollCreateParams.ts +20 -0
  183. package/src/classes/polls/HMSPollQuestion.ts +92 -0
  184. package/src/classes/polls/HMSPollQuestionAnswer.ts +29 -0
  185. package/src/classes/polls/HMSPollQuestionCreateParams.ts +36 -0
  186. package/src/classes/polls/HMSPollQuestionOption.ts +24 -0
  187. package/src/classes/polls/HMSPollQuestionOptionCreateParams.ts +8 -0
  188. package/src/classes/polls/HMSPollQuestionQuizOptionCreateParams.ts +6 -0
  189. package/src/classes/polls/HMSPollQuestionResponse.ts +72 -0
  190. package/src/classes/polls/HMSPollQuestionResponseCreateParams.ts +6 -0
  191. package/src/classes/polls/HMSPollQuestionResponseResult.ts +19 -0
  192. package/src/classes/polls/HMSPollQuestionResult.ts +41 -0
  193. package/src/classes/polls/HMSPollQuestionType.ts +21 -0
  194. package/src/classes/polls/HMSPollResponsePeerInfo.ts +24 -0
  195. package/src/classes/polls/HMSPollResult.ts +26 -0
  196. package/src/classes/polls/HMSPollState.ts +16 -0
  197. package/src/classes/polls/HMSPollType.ts +4 -0
  198. package/src/classes/polls/HMSPollUpdateType.ts +5 -0
  199. package/src/classes/polls/HMSPollUserTrackingMode.ts +16 -0
  200. package/src/hooks/polls.ts +14 -0
  201. package/src/index.ts +9 -0
  202. package/src/stores/hms-interactivity-store.ts +18 -0
  203. package/src/stores/hms-polls-slice.ts +20 -0
  204. package/src/stores/types.ts +20 -3
  205. package/src/utils/emitter/EventEmitter.ts +26 -0
@@ -0,0 +1,137 @@
1
+ import { EventEmitter } from '../utils';
2
+ import HMSManager from '../modules/HMSManagerModule';
3
+ import { HMSConstants } from './HMSConstants';
4
+ import { logger } from './HMSLogger';
5
+ import type { HMSPoll } from './polls/HMSPoll';
6
+ import type { HMSPollCreateParams } from './polls/HMSPollCreateParams';
7
+ import type { HMSPollUpdateType } from './polls/HMSPollUpdateType';
8
+ import { HMSPollsListenerActions } from './HMSPollsListenerActions';
9
+ import HMSNativeEventListener from './HMSNativeEventListener';
10
+ import type { HMSEventSubscription } from './HMSNativeEventEmitter';
11
+ import { HMSInteractivityEncoder } from './HMSInteractivityEncoder';
12
+ import { HMSHelper } from './HMSHelper';
13
+
14
+ type PollUpdateListener = (data: {
15
+ updatedPoll: HMSPoll;
16
+ update: HMSPollUpdateType;
17
+ }) => void;
18
+
19
+ type PollQuestionResponseCreateParams = {
20
+ pollId: string;
21
+ pollQuestionIndex: number;
22
+ responses:
23
+ | {
24
+ text: string;
25
+ duration?: number;
26
+ }
27
+ | {
28
+ options: number[];
29
+ duration?: number;
30
+ };
31
+ };
32
+
33
+ let pollUpdateSubscription: null | HMSEventSubscription = null;
34
+
35
+ function registerPollUpdateListener(listener: PollUpdateListener) {
36
+ if (pollUpdateSubscription !== null) {
37
+ return;
38
+ }
39
+ pollUpdateSubscription = HMSNativeEventListener.addListener(
40
+ HMSConstants.DEFAULT_SDK_ID,
41
+ HMSPollsListenerActions.ON_POLL_UPDATE,
42
+ listener
43
+ );
44
+ }
45
+
46
+ function unregisterPollUpdateListener() {
47
+ if (pollUpdateSubscription === null) {
48
+ return;
49
+ }
50
+ pollUpdateSubscription.remove();
51
+ pollUpdateSubscription = null;
52
+ }
53
+
54
+ export class HMSInteractivityCenter {
55
+ private _eventEmitter = new EventEmitter();
56
+
57
+ private _pollUpdateListener = (...args: Parameters<PollUpdateListener>) => {
58
+ const { updatedPoll, update } = args[0];
59
+ logger?.verbose('#Listener ON_POLL_UPDATE', {
60
+ update,
61
+ updatedPoll,
62
+ });
63
+ this._eventEmitter.emit(
64
+ HMSPollsListenerActions.ON_POLL_UPDATE,
65
+ HMSInteractivityEncoder.transformPoll(updatedPoll),
66
+ update
67
+ );
68
+ };
69
+
70
+ private _onAllPollUpdateListenerRemoved = () => {
71
+ unregisterPollUpdateListener();
72
+ };
73
+
74
+ constructor() {
75
+ this._eventEmitter.registerOnAllListenersRemoved(
76
+ this._onAllPollUpdateListenerRemoved
77
+ );
78
+ }
79
+
80
+ /**
81
+ * Adds a listener for poll updates
82
+ * @param listener - Callback to be called when a poll is updated
83
+ * @returns HMSEventSubscription
84
+ */
85
+ addPollUpdateListener(
86
+ listener: (updatedPoll: HMSPoll, update: HMSPollUpdateType) => void
87
+ ) {
88
+ registerPollUpdateListener(this._pollUpdateListener);
89
+ return this._eventEmitter.addListener(
90
+ HMSPollsListenerActions.ON_POLL_UPDATE,
91
+ listener,
92
+ null
93
+ );
94
+ }
95
+
96
+ /**
97
+ * Starts a poll
98
+ *
99
+ * @param pollParams
100
+ */
101
+ async startPoll(pollParams: HMSPollCreateParams) {
102
+ const transformedPollParams = {
103
+ ...pollParams,
104
+ rolesThatCanVote: pollParams.rolesThatCanVote
105
+ ? HMSHelper.getRoleNames(pollParams.rolesThatCanVote)
106
+ : undefined,
107
+ rolesThatCanViewResponses: pollParams.rolesThatCanViewResponses
108
+ ? HMSHelper.getRoleNames(pollParams.rolesThatCanViewResponses)
109
+ : undefined,
110
+ };
111
+
112
+ const data = {
113
+ ...transformedPollParams,
114
+ id: HMSConstants.DEFAULT_SDK_ID,
115
+ };
116
+ logger?.verbose('#Function startPoll', JSON.stringify(data));
117
+ return HMSManager.quickStartPoll(data);
118
+ }
119
+
120
+ async add(pollQuestionResponseParams: PollQuestionResponseCreateParams) {
121
+ const data = {
122
+ ...pollQuestionResponseParams,
123
+ id: HMSConstants.DEFAULT_SDK_ID,
124
+ };
125
+ logger?.verbose('#Function add', JSON.stringify(data));
126
+ return HMSManager.addResponseOnPollQuestion(data);
127
+ }
128
+
129
+ async stop(pollId: string) {
130
+ const data = {
131
+ id: HMSConstants.DEFAULT_SDK_ID,
132
+ pollId,
133
+ };
134
+ logger?.verbose('#Function stop', JSON.stringify(data));
135
+ return HMSManager.stopPoll(data);
136
+ }
137
+ }
@@ -0,0 +1,29 @@
1
+ import type { HMSPoll } from './polls/HMSPoll';
2
+
3
+ export class HMSInteractivityEncoder {
4
+ static transformPoll(poll: HMSPoll): HMSPoll {
5
+ if (poll.startedAt) {
6
+ const dateNum = parseInt(poll.startedAt as unknown as string);
7
+
8
+ if (isNaN(dateNum)) {
9
+ poll.startedAt = undefined;
10
+ } else {
11
+ poll.startedAt = new Date(dateNum);
12
+ }
13
+ }
14
+ if (poll.stoppedAt) {
15
+ const dateNum = parseInt(poll.stoppedAt as unknown as string);
16
+
17
+ if (isNaN(dateNum)) {
18
+ poll.stoppedAt = undefined;
19
+ } else {
20
+ poll.stoppedAt = new Date(dateNum);
21
+ }
22
+ }
23
+ // poll.rolesThatCanVote: HMSRole[];
24
+ // poll.rolesThatCanViewResponses: HMSRole[];
25
+ // --- poll.questions: HMSPollQuestion[]
26
+ // --- poll.result: HMSPollResult
27
+ return poll;
28
+ }
29
+ }
@@ -7,6 +7,8 @@ export class HMSPermissions {
7
7
  browserRecording?: boolean;
8
8
  hlsStreaming?: boolean;
9
9
  rtmpStreaming?: boolean;
10
+ pollRead?: boolean;
11
+ pollWrite?: boolean;
10
12
 
11
13
  constructor(params?: {
12
14
  endRoom?: boolean;
@@ -17,6 +19,8 @@ export class HMSPermissions {
17
19
  browserRecording?: boolean;
18
20
  hlsStreaming?: boolean;
19
21
  rtmpStreaming?: boolean;
22
+ pollRead?: boolean;
23
+ pollWrite?: boolean;
20
24
  }) {
21
25
  if (params) {
22
26
  this.endRoom = params.endRoom;
@@ -27,6 +31,8 @@ export class HMSPermissions {
27
31
  this.browserRecording = params.browserRecording;
28
32
  this.hlsStreaming = params.hlsStreaming;
29
33
  this.rtmpStreaming = params.rtmpStreaming;
34
+ this.pollRead = params.pollRead;
35
+ this.pollWrite = params.pollWrite;
30
36
  }
31
37
  }
32
38
  }
@@ -0,0 +1,3 @@
1
+ export enum HMSPollsListenerActions {
2
+ ON_POLL_UPDATE = 'ON_POLL_UPDATE',
3
+ }
@@ -46,6 +46,7 @@ import { HMSSessionStore } from './HMSSessionStore';
46
46
  import type { HMSPeerListIteratorOptions } from './HMSPeerListIteratorOptions';
47
47
  import { HMSPeerListIterator } from './HMSPeerListIterator';
48
48
  import type { HMSPIPConfig } from './HMSPIPConfig';
49
+ import { HMSInteractivityCenter } from './HMSInteractivityCenter';
49
50
 
50
51
  type HmsViewProps = Omit<HmsComponentProps, 'id'>;
51
52
 
@@ -55,6 +56,8 @@ let HmsSdk: HMSSDK | undefined;
55
56
 
56
57
  export class HMSSDK {
57
58
  id: string;
59
+ private _interactivityCenter: HMSInteractivityCenter | null = null;
60
+
58
61
  private appStateSubscription?: any;
59
62
  private onPreviewDelegate?: any;
60
63
  private onJoinDelegate?: any;
@@ -2491,6 +2494,13 @@ export class HMSSDK {
2491
2494
  });
2492
2495
  }
2493
2496
 
2497
+ get interactivityCenter() {
2498
+ if (!this._interactivityCenter) {
2499
+ this._interactivityCenter = new HMSInteractivityCenter();
2500
+ }
2501
+ return this._interactivityCenter;
2502
+ }
2503
+
2494
2504
  /**
2495
2505
  * - Returns the instance of logger which can be used to manipulate log levels.
2496
2506
  * @returns @instance HMSLogger
@@ -0,0 +1,108 @@
1
+ import type { HMSPollState } from './HMSPollState';
2
+ import type { HMSPollQuestion } from './HMSPollQuestion';
3
+ import type { HMSPollResult } from './HMSPollResult';
4
+ import type { HMSRole } from '../HMSRole';
5
+ import type { HMSPollUserTrackingMode } from './HMSPollUserTrackingMode';
6
+ import type { HMSPollType } from './HMSPollType';
7
+ import type { HMSPeer } from '../HMSPeer';
8
+
9
+ type HMSPeerSubset = {
10
+ peerID: HMSPeer['peerID'];
11
+ name: HMSPeer['name'];
12
+ };
13
+
14
+ type HMSRoleSubset = {
15
+ name: HMSRole['name'];
16
+ };
17
+
18
+ export interface HMSPoll {
19
+ /**
20
+ The unique identifier of the poll.
21
+ */
22
+ pollId: string;
23
+
24
+ /**
25
+ The title of the poll.
26
+ */
27
+ title: string;
28
+
29
+ /**
30
+ The duration of the poll in seconds.
31
+ */
32
+ duration?: number;
33
+
34
+ /**
35
+ A flag indicating whether the poll is anonymous or not.
36
+ */
37
+ anonymous?: boolean;
38
+
39
+ /**
40
+ The tracking mode for user participation in the poll.
41
+ */
42
+ mode?: HMSPollUserTrackingMode;
43
+
44
+ /**
45
+ The roles that can vote in the poll.
46
+ */
47
+ rolesThatCanVote?: HMSRoleSubset[];
48
+
49
+ /**
50
+ The roles that can view the poll responses.
51
+ */
52
+ rolesThatCanViewResponses?: HMSRoleSubset[];
53
+
54
+ /**
55
+ The peer who started the poll.
56
+ */
57
+ startedBy?: HMSPeerSubset;
58
+
59
+ /**
60
+ The peer who stopped the poll.
61
+ */
62
+ stoppedBy?: HMSPeerSubset;
63
+
64
+ /**
65
+ The peer who created the poll.
66
+ */
67
+ createdBy?: HMSPeerSubset;
68
+
69
+ /**
70
+ The date and time when the poll was started.
71
+ */
72
+ startedAt?: Date;
73
+
74
+ /**
75
+ The date and time when the poll was stopped.
76
+ */
77
+ stoppedAt?: Date;
78
+
79
+ /**
80
+ The type of the poll.
81
+ */
82
+ type: HMSPollType;
83
+
84
+ /**
85
+ The current state of the poll.
86
+ */
87
+ state?: HMSPollState;
88
+
89
+ /**
90
+ The list of questions in the poll.
91
+ */
92
+ questions?: HMSPollQuestion[];
93
+
94
+ /**
95
+ The result of the poll.
96
+ */
97
+ result?: HMSPollResult;
98
+
99
+ // /**
100
+ // The visiblity of the poll. (Not available on iOS)
101
+ // */
102
+ // visibility?: boolean;
103
+
104
+ // /**
105
+ // * Is poll locked currently? (Not available on iOS)
106
+ // */
107
+ // locked?: boolean;
108
+ }
@@ -0,0 +1,11 @@
1
+ export enum HMSPollCategory {
2
+ /**
3
+ The poll is a standard poll.
4
+ */
5
+ poll,
6
+
7
+ /**
8
+ The poll is a quiz.
9
+ */
10
+ quiz,
11
+ }
@@ -0,0 +1,20 @@
1
+ import type { HMSRole } from '../HMSRole';
2
+ import type { HMSPoll } from './HMSPoll';
3
+ import type { HMSPollQuestionCreateParams } from './HMSPollQuestionCreateParams';
4
+
5
+ export interface HMSPollCreateParams
6
+ extends Pick<
7
+ HMSPoll,
8
+ | 'title'
9
+ | 'type'
10
+ | 'duration'
11
+ | 'anonymous'
12
+ // | 'visibility'
13
+ // | 'locked'
14
+ | 'mode'
15
+ > {
16
+ pollId?: HMSPoll['pollId'];
17
+ questions?: HMSPollQuestionCreateParams[];
18
+ rolesThatCanVote?: HMSRole[];
19
+ rolesThatCanViewResponses?: HMSRole[];
20
+ }
@@ -0,0 +1,92 @@
1
+ import type { HMSPollQuestionAnswer } from './HMSPollQuestionAnswer';
2
+ import type { HMSPollQuestionOption } from './HMSPollQuestionOption';
3
+ import type { HMSPollQuestionResponse } from './HMSPollQuestionResponse';
4
+ import type { HMSPollQuestionType } from './HMSPollQuestionType';
5
+
6
+ /**
7
+ Represents a question in a poll.
8
+ */
9
+ export interface HMSPollQuestion {
10
+ /**
11
+ The index of the question within the poll.
12
+ */
13
+ index: number;
14
+
15
+ /**
16
+ The text of the question.
17
+ */
18
+ text: string;
19
+
20
+ /**
21
+ A flag indicating whether the question is skippable or not.
22
+ */
23
+ skippable: boolean;
24
+
25
+ /**
26
+ The duration hint of the question in seconds. Can be used for setting a timeframe withing which a question can be responded to. Not enforced by the server.
27
+ */
28
+ duration: number;
29
+
30
+ /**
31
+ A flag indicating whether the question can be answered only once.
32
+ */
33
+ once: boolean;
34
+
35
+ /**
36
+ The weight of the question in scoring.
37
+ */
38
+ weight: number;
39
+
40
+ /**
41
+ The minimum length of the answer (if applicable).
42
+ */
43
+ answerMinLen?: number;
44
+
45
+ /**
46
+ The maximum length of the answer (if applicable).
47
+ */
48
+ answerMaxLen?: number;
49
+
50
+ /**
51
+ The type of the question.
52
+ */
53
+ type: HMSPollQuestionType;
54
+
55
+ /**
56
+ The list of options for the question (if applicable).
57
+ */
58
+ options?: HMSPollQuestionOption[];
59
+
60
+ /**
61
+ The answer for the question (if it is a quiz).
62
+ */
63
+ answer?: HMSPollQuestionAnswer;
64
+
65
+ /**
66
+ The list of responses for the question.
67
+ */
68
+ responses?: HMSPollQuestionResponse[];
69
+
70
+ /**
71
+ The responses provided by the current user for the question.
72
+ */
73
+ myResponses: HMSPollQuestionResponse[];
74
+ }
75
+
76
+ // Web Inteface -
77
+ // export interface HMSPollQuestion {
78
+ // index: number;
79
+ // text: string;
80
+ // type: HMSPollQuestionType;
81
+ // skippable?: boolean;
82
+ // duration?: number;
83
+ // once?: boolean;
84
+ // weight?: number;
85
+ // negative?: boolean;
86
+ // answerMinLen?: number;
87
+ // answerMaxLen?: number;
88
+ // options?: HMSPollQuestionOption[];
89
+ // answer?: HMSPollQuestionAnswer;
90
+ // responses?: HMSPollQuestionResponse[];
91
+ // result?: HMSPollQuestionResult;
92
+ // }
@@ -0,0 +1,29 @@
1
+ /**
2
+ Provides the correct answer for a quiz question to check users' responses against.
3
+ */
4
+ export interface HMSPollQuestionAnswer {
5
+ /**
6
+ A flag indicating whether the answer should be hidden or not.
7
+ */
8
+ hidden: boolean;
9
+
10
+ /**
11
+ The index of the selected option (in case of single choice question).
12
+ */
13
+ option?: number;
14
+
15
+ /**
16
+ The list of indexes of selected options (in case of multiple choice question).
17
+ */
18
+ options?: number[];
19
+ }
20
+
21
+ // Web Inteface -
22
+ // export interface HMSPollQuestionAnswer {
23
+ // hidden: boolean; // if true answer will not be returned when poll is running
24
+ // option?: number; // option index for correct answer, in case of single choice
25
+ // options?: number[]; // list of options that shoould be in answer
26
+ // text?: string; // answer text for answer.
27
+ // case?: boolean; // if false case is ignored when comparing.
28
+ // trim?: boolean; // if true, empty space is trimmer from start and end of asnwer.
29
+ // }
@@ -0,0 +1,36 @@
1
+ import type { HMSPollQuestion } from './HMSPollQuestion';
2
+ import type { HMSPollQuestionOptionCreateParams } from './HMSPollQuestionOptionCreateParams';
3
+ import type { HMSPollQuestionQuizOptionCreateParams } from './HMSPollQuestionQuizOptionCreateParams';
4
+
5
+ export interface HMSPollQuestionCreateParams
6
+ extends Pick<
7
+ HMSPollQuestion,
8
+ 'text' | 'skippable' | 'type' | 'answerMinLen' | 'answerMaxLen'
9
+ > {
10
+ /**
11
+ * A flag indicating whether the question can be answered only once.
12
+ */
13
+ once?: HMSPollQuestion['once'];
14
+
15
+ /**
16
+ * The duration hint of the question in seconds. Can be used for setting a timeframe withing which a question can be responded to. Not enforced by the server.
17
+ */
18
+ duration?: HMSPollQuestion['duration'];
19
+
20
+ /**
21
+ * The index of the question within the poll.
22
+ */
23
+ index?: HMSPollQuestion['index'];
24
+
25
+ /**
26
+ * The options of the question.
27
+ */
28
+ options?:
29
+ | HMSPollQuestionOptionCreateParams[]
30
+ | HMSPollQuestionQuizOptionCreateParams[];
31
+
32
+ /**
33
+ * The weight of the question in scoring.
34
+ */
35
+ weight?: number;
36
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ Represents an option for a poll question.
3
+ */
4
+ export interface HMSPollQuestionOption {
5
+ /**
6
+ The index of the option within the question.
7
+ */
8
+ index: number;
9
+
10
+ /**
11
+ The text of the option.
12
+ */
13
+ text: string;
14
+
15
+ /**
16
+ The weight of the option in scoring.
17
+ */
18
+ weight: number; // (optional on web)
19
+
20
+ /**
21
+ The count of votes received for the option. `0` is the default value.
22
+ */
23
+ voteCount: number; // (optional on web)
24
+ }
@@ -0,0 +1,8 @@
1
+ import type { HMSPollQuestionOption } from './HMSPollQuestionOption';
2
+
3
+ export interface HMSPollQuestionOptionCreateParams
4
+ extends Pick<
5
+ HMSPollQuestionOption,
6
+ 'text'
7
+ // | 'weight' // `weight` field is not required as of now
8
+ > {}
@@ -0,0 +1,6 @@
1
+ import type { HMSPollQuestionOptionCreateParams } from './HMSPollQuestionOptionCreateParams';
2
+
3
+ export interface HMSPollQuestionQuizOptionCreateParams
4
+ extends HMSPollQuestionOptionCreateParams {
5
+ isCorrectAnswer: boolean;
6
+ }
@@ -0,0 +1,72 @@
1
+ import type { HMSPollQuestionType } from './HMSPollQuestionType';
2
+ import type { HMSPollResponsePeerInfo } from './HMSPollResponsePeerInfo';
3
+
4
+ /**
5
+ Represents a response for a poll question.
6
+ */
7
+ export interface HMSPollQuestionResponse {
8
+ /**
9
+ The ID of the question associated with the response.
10
+ */
11
+ questionID: number;
12
+
13
+ /**
14
+ The type of the question associated with the response.
15
+ */
16
+ type: HMSPollQuestionType;
17
+
18
+ /**
19
+ A flag indicating whether the question was skipped or not.
20
+ */
21
+ skipped: boolean;
22
+
23
+ /**
24
+ The index of the selected option (in case of single choice question).
25
+ */
26
+ option: number;
27
+
28
+ /**
29
+ The list of indexes of selected options (in case of multiple choice question).
30
+ */
31
+ options?: number[];
32
+
33
+ /**
34
+ The text answer provided (in case of short/long answer question).
35
+ */
36
+ text: string;
37
+
38
+ /**
39
+ A flag indicating whether the response was updated from previous response.
40
+ */
41
+ update: boolean;
42
+
43
+ /**
44
+ Time taken to respond.
45
+ */
46
+ duration: number;
47
+
48
+ /**
49
+ The peer information associated with the response. Depends on the tracking type selected for poll.
50
+ */
51
+ peer?: HMSPollResponsePeerInfo;
52
+
53
+ /**
54
+ A flag indicating whether the response is final in case multiple responses were sent for this question.
55
+ */
56
+ responseFinal?: boolean;
57
+ }
58
+
59
+ // Web Interface -
60
+ // export interface HMSPollQuestionResponse {
61
+ // id?: string;
62
+ // questionIndex: number;
63
+ // peer?: HMSPollResponsePeerInfo;
64
+ // type?: HMSPollQuestionType;
65
+ // skipped?: boolean;
66
+ // option?: number;
67
+ // options?: number[];
68
+ // text?: string;
69
+ // update?: boolean; // SDK Needs to track whether we previously answered and set accordingly
70
+ // duration?: number; // Time it took to answer the question for leaderboard
71
+ // responseFinal?: boolean; // Indicates whether this is last update when fetching responses
72
+ // }
@@ -0,0 +1,6 @@
1
+ import type { HMSPollQuestionResponse } from './HMSPollQuestionResponse';
2
+
3
+ export type HMSPollQuestionResponseCreateParams = Omit<
4
+ HMSPollQuestionResponse,
5
+ 'type' | 'peer' | 'update' | 'responseFinal'
6
+ >;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Represents the result of a poll question response.
3
+ */
4
+ export interface HMSPollQuestionResponse {
5
+ /**
6
+ * The ID of the question associated with the response result.
7
+ */
8
+ question: number;
9
+
10
+ /**
11
+ * A flag indicating whether the response was correct or not in case of quiz.
12
+ */
13
+ correct?: boolean;
14
+
15
+ /**
16
+ * An error associated with the response result (if any).
17
+ */
18
+ error?: string;
19
+ }