evmux-app-framework 0.0.2 → 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;
|
|
@@ -36,7 +36,7 @@ let createEventResultObject = (eventName, result) => {
|
|
|
36
36
|
|
|
37
37
|
getAppSettingsForAppInstanceId(appInstanceId)
|
|
38
38
|
{
|
|
39
|
-
return
|
|
39
|
+
return appsDataManager.getUserAppInstanceById(appInstanceId)
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
_makeSureAppInstanceExist(userAppInstanceId)
|
|
@@ -45,6 +45,19 @@ let createEventResultObject = (eventName, result) => {
|
|
|
45
45
|
this._userAppInstances[userAppInstanceId].instances = this._userAppInstances[userAppInstanceId].instances || {};
|
|
46
46
|
this._userAppInstances[userAppInstanceId].events = this._userAppInstances[userAppInstanceId].events || {};
|
|
47
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
|
+
}
|
|
48
61
|
|
|
49
62
|
async onPostMessage(evt) {
|
|
50
63
|
|
|
@@ -61,18 +74,9 @@ let createEventResultObject = (eventName, result) => {
|
|
|
61
74
|
{
|
|
62
75
|
|
|
63
76
|
if (this._userAppInstances[requestObj.userAppInstanceId]) {
|
|
64
|
-
|
|
65
|
-
|
|
66
77
|
this._eventHandler.publish("updateSettings", requestObj)
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
{
|
|
70
|
-
let eventObj = createEventResultObject("settingsUpdated", requestObj.data)
|
|
71
|
-
let stringObjToSend = JSON.stringify(eventObj)
|
|
72
|
-
for (const [key, instanceWindow] of Object.entries(this._userAppInstances[requestObj.userAppInstanceId].instances)) {
|
|
73
|
-
instanceWindow.window.postMessage(stringObjToSend, "*")
|
|
74
|
-
}
|
|
75
|
-
}
|
|
78
|
+
|
|
79
|
+
this.updateAndNotifyAppInstancesOnSettingsUpdate(requestObj.userAppInstanceId, requestObj.data)
|
|
76
80
|
|
|
77
81
|
}
|
|
78
82
|
}
|
|
@@ -120,7 +124,7 @@ let createEventResultObject = (eventName, result) => {
|
|
|
120
124
|
|
|
121
125
|
onUserAppComponentUnload(userAppInstanceId, componentId)
|
|
122
126
|
{
|
|
123
|
-
if (this._userAppInstances[userAppInstanceId].instances[componentId]) {
|
|
127
|
+
if (this._userAppInstances[userAppInstanceId] && this._userAppInstances[userAppInstanceId].instances[componentId]) {
|
|
124
128
|
delete this._userAppInstances[userAppInstanceId].instances[componentId]
|
|
125
129
|
if (Object.keys(this._userAppInstances[userAppInstanceId].instances).length == 0)
|
|
126
130
|
{
|