evmux-app-framework 0.0.1 → 0.0.3
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
|
@@ -30,18 +30,28 @@ import { createPromise, generateGuid, pubSub } from '../EvmuxAppsApi/HelpersFrom
|
|
|
30
30
|
this._userAppInstances[instanceId] = { ...this._userAppInstances[instanceId], ...instanceData };
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
+
|
|
34
|
+
updateUserAppInstanceSettings(instanceId, settingsData) {
|
|
35
|
+
if (!this._userAppInstances[instanceId])
|
|
36
|
+
{
|
|
37
|
+
this._userAppInstances[instanceId] = {}
|
|
38
|
+
console.warn("app not exist when update")
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
this._userAppInstances[instanceId].settings = settingsData
|
|
42
|
+
}
|
|
33
43
|
|
|
34
|
-
|
|
44
|
+
getUserAppDataByAppId(userAppId) {
|
|
35
45
|
return this._userApps[userAppId];
|
|
36
46
|
}
|
|
37
47
|
|
|
38
|
-
|
|
48
|
+
getUserAppInstanceById(userInstanceId, includeAppData = false) {
|
|
39
49
|
|
|
40
50
|
let appInstance = this._userAppInstances[userInstanceId];
|
|
41
51
|
|
|
42
52
|
if (appInstance && includeAppData)
|
|
43
53
|
{
|
|
44
|
-
appInstance.appData =
|
|
54
|
+
appInstance.appData = this.getUserAppDataByAppId(appInstance.userAppId)
|
|
45
55
|
}
|
|
46
56
|
|
|
47
57
|
return appInstance;
|
|
@@ -24,6 +24,9 @@ let createEventResultObject = (eventName, result) => {
|
|
|
24
24
|
this._userAppInstances = {}
|
|
25
25
|
this._messagesEventHandlers = new pubSub()
|
|
26
26
|
this._eventHandler = new pubSub()
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
init() {
|
|
27
30
|
window.onmessage = this.onPostMessage.bind(this);
|
|
28
31
|
}
|
|
29
32
|
|
|
@@ -33,7 +36,7 @@ let createEventResultObject = (eventName, result) => {
|
|
|
33
36
|
|
|
34
37
|
getAppSettingsForAppInstanceId(appInstanceId)
|
|
35
38
|
{
|
|
36
|
-
return
|
|
39
|
+
return appsDataManager.getUserAppInstanceById(appInstanceId)
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
_makeSureAppInstanceExist(userAppInstanceId)
|
|
@@ -42,6 +45,19 @@ let createEventResultObject = (eventName, result) => {
|
|
|
42
45
|
this._userAppInstances[userAppInstanceId].instances = this._userAppInstances[userAppInstanceId].instances || {};
|
|
43
46
|
this._userAppInstances[userAppInstanceId].events = this._userAppInstances[userAppInstanceId].events || {};
|
|
44
47
|
}
|
|
48
|
+
|
|
49
|
+
updateAndNotifyAppInstancesOnSettingsUpdate(userAppInstanceId, data)
|
|
50
|
+
{
|
|
51
|
+
appsDataManager.updateUserAppInstanceSettings(userAppInstanceId, data)
|
|
52
|
+
if (this._userAppInstances[userAppInstanceId].events['settingsUpdated'])
|
|
53
|
+
{
|
|
54
|
+
let eventObj = createEventResultObject("settingsUpdated", data)
|
|
55
|
+
let stringObjToSend = JSON.stringify(eventObj)
|
|
56
|
+
for (const [key, instanceWindow] of Object.entries(this._userAppInstances[userAppInstanceId].instances)) {
|
|
57
|
+
instanceWindow.window.postMessage(stringObjToSend, "*")
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
45
61
|
|
|
46
62
|
async onPostMessage(evt) {
|
|
47
63
|
|
|
@@ -58,18 +74,9 @@ let createEventResultObject = (eventName, result) => {
|
|
|
58
74
|
{
|
|
59
75
|
|
|
60
76
|
if (this._userAppInstances[requestObj.userAppInstanceId]) {
|
|
61
|
-
|
|
62
|
-
|
|
63
77
|
this._eventHandler.publish("updateSettings", requestObj)
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
{
|
|
67
|
-
let eventObj = createEventResultObject("settingsUpdated", requestObj.data)
|
|
68
|
-
let stringObjToSend = JSON.stringify(eventObj)
|
|
69
|
-
for (const [key, instanceWindow] of Object.entries(this._userAppInstances[requestObj.userAppInstanceId].instances)) {
|
|
70
|
-
instanceWindow.window.postMessage(stringObjToSend, "*")
|
|
71
|
-
}
|
|
72
|
-
}
|
|
78
|
+
|
|
79
|
+
this.updateAndNotifyAppInstancesOnSettingsUpdate(requestObj.userAppInstanceId, requestObj.data)
|
|
73
80
|
|
|
74
81
|
}
|
|
75
82
|
}
|
|
@@ -117,7 +124,7 @@ let createEventResultObject = (eventName, result) => {
|
|
|
117
124
|
|
|
118
125
|
onUserAppComponentUnload(userAppInstanceId, componentId)
|
|
119
126
|
{
|
|
120
|
-
if (this._userAppInstances[userAppInstanceId].instances[componentId]) {
|
|
127
|
+
if (this._userAppInstances[userAppInstanceId] && this._userAppInstances[userAppInstanceId].instances[componentId]) {
|
|
121
128
|
delete this._userAppInstances[userAppInstanceId].instances[componentId]
|
|
122
129
|
if (Object.keys(this._userAppInstances[userAppInstanceId].instances).length == 0)
|
|
123
130
|
{
|