evmux-app-framework 0.1.11 → 0.1.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "evmux-app-framework",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -55,7 +55,7 @@ export const availableRequests = {
55
55
  getParticipants: "getParticipants",
56
56
  accountPlanCapabilities: "accountPlanCapabilities",
57
57
  upgradePopup: "upgradePopup",
58
-
58
+ getVolumeMultiplier: "getVolumeMultiplier",
59
59
 
60
60
  }
61
61
 
@@ -85,6 +85,7 @@ let createEventResultObject = (requestName, eventName, result) => {
85
85
  }
86
86
 
87
87
  init(app) {
88
+ this._app = app
88
89
  window.onmessage = this.onPostMessage.bind(this);
89
90
  this.initRequestHandlerProjectSpecific(app)
90
91
  }
@@ -159,6 +160,37 @@ let createEventResultObject = (requestName, eventName, result) => {
159
160
 
160
161
  }
161
162
 
163
+ raiseEventForComponent(userAppInstanceId, componentId, eventName, data) {
164
+ const appInstance = this._userAppInstances[userAppInstanceId]
165
+ if (!appInstance || !appInstance.events || !appInstance.events[eventName]) return
166
+ const component = appInstance.instances[componentId]
167
+ if (!component) return
168
+ const eventObj = createEventResultObject("EvEvent", eventName, data)
169
+ component.window.postMessage(JSON.stringify(eventObj), "*")
170
+ }
171
+
172
+ getComponentCount(userAppInstanceId) {
173
+ const appInstance = this._userAppInstances[userAppInstanceId]
174
+ if (!appInstance || !appInstance.instances) return 0
175
+ return Object.keys(appInstance.instances).length
176
+ }
177
+
178
+ setComponentProps(userAppInstanceId, componentId, props) {
179
+ const appInstance = this._userAppInstances[userAppInstanceId]
180
+ if (appInstance && appInstance.instances && appInstance.instances[componentId]) {
181
+ Object.assign(appInstance.instances[componentId], props)
182
+ }
183
+ }
184
+
185
+ computeVolumeMultiplier(userAppInstanceId, componentId) {
186
+ if (this.getComponentCount(userAppInstanceId) <= 1) return 1
187
+ const isPrv = componentId.startsWith('live_')
188
+ if (this._app?.studioMode && !isPrv) return 0
189
+ const comp = this._userAppInstances[userAppInstanceId]?.instances?.[componentId]
190
+ if (this._app?.isLandscapeAndPortraitMode && comp?.portraitMode) return 0
191
+ return 1
192
+ }
193
+
162
194
  signalApp(userAppInstanceId, data){
163
195
  let theApp = this._userAppInstances[userAppInstanceId]
164
196
  if(theApp && theApp.events[availableEvents.signalingEvent]){
@@ -214,6 +246,7 @@ let createEventResultObject = (requestName, eventName, result) => {
214
246
 
215
247
  this._userAppInstances[requestObj.userAppInstanceId].instances[requestObj.componentId] = { window: evt.source }
216
248
  this._eventHandler.publish("appComponentLoaded", requestObj)
249
+ this._eventHandler.publish("componentCountChanged", { userAppInstanceId: requestObj.userAppInstanceId })
217
250
 
218
251
  result = this.getAppSettingsForAppInstanceId(requestObj.userAppInstanceId)
219
252
  }
@@ -228,6 +261,10 @@ let createEventResultObject = (requestName, eventName, result) => {
228
261
  this._makeSureAppInstanceExist(requestObj.userAppInstanceId);
229
262
  delete this._userAppInstances[requestObj.userAppInstanceId].events[requestObj.data.eventName]
230
263
  }
264
+ else if (requestObj.request == availableRequests.getVolumeMultiplier)
265
+ {
266
+ result = { value: this.computeVolumeMultiplier(requestObj.userAppInstanceId, requestObj.componentId) }
267
+ }
231
268
  else {
232
269
  for (let i = 0; i < this._requestHandlers.length; i++)
233
270
  {
@@ -255,9 +292,10 @@ let createEventResultObject = (requestName, eventName, result) => {
255
292
  {
256
293
  if (this._userAppInstances[userAppInstanceId] && this._userAppInstances[userAppInstanceId].instances[componentId]) {
257
294
  delete this._userAppInstances[userAppInstanceId].instances[componentId]
295
+ this._eventHandler.publish("componentCountChanged", { userAppInstanceId })
258
296
  if (Object.keys(this._userAppInstances[userAppInstanceId].instances).length == 0)
259
297
  {
260
- delete this._userAppInstances[userAppInstanceId]
298
+ delete this._userAppInstances[userAppInstanceId]
261
299
  }
262
300
  }
263
301
  }
@@ -27,6 +27,7 @@ export const availableEvents = {
27
27
  signalingEvent: "signalingEvent",
28
28
  participantJoined: "participantJoined",
29
29
  participantLeft: "participantLeft",
30
+ volumeMultiplier: "volumeMultiplier",
30
31
  }
31
32
 
32
33
  export const layerTypes = {
@@ -101,6 +102,11 @@ export default class EvmuxAppsApi {
101
102
  let reqObj = {request: availableRequests.getSettings, userAppInstanceId: this._userAppInstanceId, componentId: this._componentId}
102
103
  return this._postMessageManager.sendRequestAsync(reqObj);
103
104
  }
105
+
106
+ async getVolumeMultiplier() {
107
+ let reqObj = {request: availableRequests.getVolumeMultiplier, userAppInstanceId: this._userAppInstanceId, componentId: this._componentId}
108
+ return this._postMessageManager.sendRequestAsync(reqObj);
109
+ }
104
110
 
105
111
  raiseAppMessagingEvent(data) {
106
112
  let requestObj = {