@xuda.io/runtime-bundle 1.0.915 → 1.0.917
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
const _this={};export const init_module=e=>{_this.func=e.func;_this.glb=e.glb;_this.SESSION_OBJ=e.SESSION_OBJ;_this.APP_OBJ=e.APP_OBJ;_this.IS_DOCKER=e.IS_DOCKER;_this.IS_API_SERVER=e.IS_API_SERVER;_this.IS_PROCESS_SERVER=e.IS_PROCESS_SERVER};export const get_doc_from_studio=async function(SESSION_ID,app_id,idP){return new Promise(function(resolve,reject){var _session=_this.SESSION_OBJ[SESSION_ID];if(glb.IS_WORKER){func.utils.post_back_to_client(SESSION_ID,"get_doc_from_studio",_session.worker_id,{doc_id:idP});self.addEventListener("live_preview_get_obj_response_worker_"+idP,event=>{resolve(event.detail.data)})}else{STUDIO_PEER_CONN_SEND_METHOD({service:"get_doc_obj",data:{doc_id:idP},session_id:SESSION_ID,id:STUDIO_PEER.id,source:"runtime",app_id:app_id});$("body").on("live_preview_get_obj_response_"+idP,function(e,data){resolve(data.data);$("body").off("live_preview_get_obj_response_"+idP)})}})};export const get_doc_from_websocket=async function(SESSION_ID,app_id,idP){var _session=_this.SESSION_OBJ[SESSION_ID];return new Promise(function(resolve,reject){if(glb.IS_WORKER){func.utils.post_back_to_client(SESSION_ID,"get_doc_from_websocket",_session.worker_id,{doc_id:idP});self.addEventListener("get_doc_obj_from_build_worker_"+idP,event=>{resolve(event.detail.data)})}else{if(RUNTIME_SERVER_WEBSOCKET&&RUNTIME_SERVER_WEBSOCKET_CONNECTED){RUNTIME_SERVER_WEBSOCKET.emit("message",{service:"get_doc_obj_from_build",data:{doc_id:idP}});$("body").on("get_doc_obj_from_build_response_"+idP,(e,data)=>{resolve(data.data);$("body").off("get_doc_obj_from_build_response_"+idP)})}else{throw new Error("fail to fetch from ws websocket inactive")}}})};export const DOCS_OBJ_get=async function(SESSION_ID,idP){if(!idP)return;if(idP==="_empty_panel_program"){return{_id:"_empty_panel_program",properties:{menuName:"_empty_panel_program",menuTitle:"_empty_panel_program",menuType:"component",renderType:"form"},progUi:[{id:"node-empty_panel_program",tagName:"xu-single-view",children:[{id:"node-empty_panel_program-span",tagName:"span",children:[],content:"",type:"element",attributes:{}}],content:"",type:"element",attributes:{}}],progDataSource:{},progFields:[],progEvents:[]}}var _session=_this.SESSION_OBJ[SESSION_ID];const app_id=_session.app_id;var views_ret;if(_session.engine_mode==="live_preview"){return await get_doc_from_studio(SESSION_ID,app_id,idP)}if(glb.register_startup_programs){func.common.db(SESSION_ID,"register_startup_programs",{prog_id:idP,build_id:_session?.build_info?.build||0})}views_ret=await read_objects_cache(SESSION_ID,idP,"DOCS_OBJ");if(!views_ret){if(typeof _this.IS_DOCKER==="undefined"&&typeof _this.IS_PROCESS_SERVER==="undefined"){let url=_this.func.common.get_url(SESSION_ID,"rpi","");if(["master"].includes(_this.APP_OBJ[app_id].app_type)){url+="get_doc_obj_raw"}else{url+="get_doc_obj_from_build"}let app_id_reference=_this.APP_OBJ[app_id].app_id_reference;const http=async function(){const response=await fetch(url,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","xu-gtp-token":_session.gtp_token,"xu-app-token":_session.app_token},body:JSON.stringify({app_id:app_id,doc_id:idP,build:_session.build_info.instance_build||_session.build_info.build||_session.opt.app_build_id,app_id_reference:app_id_reference})});const json=await response.json();if(response){if(response&&response.status===400){return _this.func.utils.request_error(SESSION_ID,"ajax",response.statusText)}views_ret=json.data}};
|
|
1
|
+
const _this={};export const init_module=e=>{_this.func=e.func;_this.glb=e.glb;_this.SESSION_OBJ=e.SESSION_OBJ;_this.APP_OBJ=e.APP_OBJ;_this.IS_DOCKER=e.IS_DOCKER;_this.IS_API_SERVER=e.IS_API_SERVER;_this.IS_PROCESS_SERVER=e.IS_PROCESS_SERVER};export const get_doc_from_studio=async function(SESSION_ID,app_id,idP){return new Promise(function(resolve,reject){var _session=_this.SESSION_OBJ[SESSION_ID];if(glb.IS_WORKER){func.utils.post_back_to_client(SESSION_ID,"get_doc_from_studio",_session.worker_id,{doc_id:idP});self.addEventListener("live_preview_get_obj_response_worker_"+idP,event=>{resolve(event.detail.data)})}else{STUDIO_PEER_CONN_SEND_METHOD({service:"get_doc_obj",data:{doc_id:idP},session_id:SESSION_ID,id:STUDIO_PEER.id,source:"runtime",app_id:app_id});$("body").on("live_preview_get_obj_response_"+idP,function(e,data){resolve(data.data);$("body").off("live_preview_get_obj_response_"+idP)})}})};export const get_doc_from_websocket=async function(SESSION_ID,app_id,idP){var _session=_this.SESSION_OBJ[SESSION_ID];return new Promise(function(resolve,reject){if(glb.IS_WORKER){func.utils.post_back_to_client(SESSION_ID,"get_doc_from_websocket",_session.worker_id,{doc_id:idP});self.addEventListener("get_doc_obj_from_build_worker_"+idP,event=>{resolve(event.detail.data)})}else{if(RUNTIME_SERVER_WEBSOCKET&&RUNTIME_SERVER_WEBSOCKET_CONNECTED){RUNTIME_SERVER_WEBSOCKET.emit("message",{service:"get_doc_obj_from_build",data:{doc_id:idP}});$("body").on("get_doc_obj_from_build_response_"+idP,(e,data)=>{resolve(data.data);$("body").off("get_doc_obj_from_build_response_"+idP)})}else{throw new Error("fail to fetch from ws websocket inactive")}}})};export const DOCS_OBJ_get=async function(SESSION_ID,idP){if(!idP)return;if(idP==="_empty_panel_program"){return{_id:"_empty_panel_program",properties:{menuName:"_empty_panel_program",menuTitle:"_empty_panel_program",menuType:"component",renderType:"form"},progUi:[{id:"node-empty_panel_program",tagName:"xu-single-view",children:[{id:"node-empty_panel_program-span",tagName:"span",children:[],content:"",type:"element",attributes:{}}],content:"",type:"element",attributes:{}}],progDataSource:{},progFields:[],progEvents:[]}}var _session=_this.SESSION_OBJ[SESSION_ID];const app_id=_session.app_id;var views_ret;if(_session.engine_mode==="live_preview"){return await get_doc_from_studio(SESSION_ID,app_id,idP)}if(glb.register_startup_programs){func.common.db(SESSION_ID,"register_startup_programs",{prog_id:idP,build_id:_session?.build_info?.build||0})}views_ret=await read_objects_cache(SESSION_ID,idP,"DOCS_OBJ");if(!views_ret){if(typeof _this.IS_DOCKER==="undefined"&&typeof _this.IS_PROCESS_SERVER==="undefined"){let url=_this.func.common.get_url(SESSION_ID,"rpi","");if(["master"].includes(_this.APP_OBJ[app_id].app_type)){url+="get_doc_obj_raw"}else{url+="get_doc_obj_from_build"}let app_id_reference=_this.APP_OBJ[app_id].app_id_reference;const http=async function(){const response=await fetch(url,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json","xu-gtp-token":_session.gtp_token,"xu-app-token":_session.app_token},body:JSON.stringify({app_id:app_id,doc_id:idP,build:_session.build_info.instance_build||_session.build_info.build||_session.opt.app_build_id,app_id_reference:app_id_reference,engine_mode:_session.engine_mode})});const json=await response.json();if(response){if(response&&response.status===400){return _this.func.utils.request_error(SESSION_ID,"ajax",response.statusText)}views_ret=json.data}};if(_session.engine_mode==="cms"){await http()}else{views_ret=await get_doc_from_websocket(SESSION_ID,app_id,idP)}}if(typeof _this.IS_DOCKER!=="undefined"||typeof _this.IS_PROCESS_SERVER!=="undefined"){var ret=await __.rpi.get_prog(app_id,idP);if(ret.data){views_ret=ret.data}}if(views_ret){if(views_ret.error){console.error(views_ret);views_ret="";return}await save_objects_cache(SESSION_ID,idP,"DOCS_OBJ",views_ret)}}return views_ret};export const save_objects_cache=async function(SESSION_ID,id,obj_type,data){var _session=_this.SESSION_OBJ[SESSION_ID];if(typeof _this.IS_DOCKER!=="undefined"||typeof _this.IS_PROCESS_SERVER!=="undefined"||_session.worker_type==="Dev"){return}var build_id=_session?.build_info?.build||0;const db=await _this.func.utils.connect_pouchdb(SESSION_ID);var doc={_id:`cache_${build_id}_${obj_type}_${id}`,id:id,docType:"cache_objects",build_id:build_id.toString(),obj_type:obj_type,data:data};setTimeout(async function(){try{await db.get(doc_id);return}catch(e){if(await read_objects_cache(SESSION_ID,id,obj_type)){return}if(!doc.data||doc.data&&typeof doc.data==="string"&&doc.data.indexOf("error")>-1){return}try{return await db.put(doc)}catch(err){return}}},1e3)};export const read_objects_cache=async function(SESSION_ID,id,obj_type){if(typeof _this.IS_DOCKER!=="undefined"||typeof _this.IS_PROCESS_SERVER!=="undefined"){try{const data=fs.readFileSync("/var/xuda/progs/"+id+".json","utf8");return JSON.parse(data)}catch(err){console.error("read_objects_cache",err);return}}var _session=_this.SESSION_OBJ[SESSION_ID];var build_id=_session?.build_info?.build||0;const db=await _this.func.utils.connect_pouchdb(SESSION_ID);var ret;try{ret=await db.get(`cache_${build_id}_${obj_type}_${id}`);if(ret.data&&typeof ret.data==="string"&&ret.data.indexOf("error")>-1){return""}return ret.data}catch(err){return ret}};export const delete_objects_cache=async function(SESSION_ID,id,obj_type){const app_id=_this.SESSION_OBJ[SESSION_ID].app_id;var build_id=_session?.build_info?.build||0;const db=await _this.func.utils.connect_pouchdb(SESSION_ID);try{var doc=await db.get(`cache_${build_id}_${obj_type}_${id}`);if(!doc)return;var ret=await db.remove(doc)}catch(err){return}return ret};export const load_objects_cache=async function(SESSION_ID){var _session=_this.SESSION_OBJ[SESSION_ID];if(typeof _this.IS_DOCKER!=="undefined"||typeof _this.IS_PROCESS_SERVER!=="undefined"){return}const app_id=_session.app_id;const db=await _this.func.utils.connect_pouchdb(SESSION_ID);const build_id=_this.APP_OBJ[app_id].app_build_id;let ret=await db.find({selector:{docType:"cache_objects",build_id:build_id}});for(let val of ret.docs){eval(val.obj_type)[_session.app_id][val.id]=val.data}};
|
|
@@ -14,33 +14,25 @@ export const get_doc_from_studio = async function (SESSION_ID, app_id, idP) {
|
|
|
14
14
|
return new Promise(function (resolve, reject) {
|
|
15
15
|
var _session = _this.SESSION_OBJ[SESSION_ID];
|
|
16
16
|
if (glb.IS_WORKER) {
|
|
17
|
-
func.utils.post_back_to_client(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
self.addEventListener(
|
|
25
|
-
"live_preview_get_obj_response_worker_" + idP,
|
|
26
|
-
(event) => {
|
|
27
|
-
// console.log("Custom event triggered:", event);
|
|
28
|
-
resolve(event.detail.data);
|
|
29
|
-
}
|
|
30
|
-
);
|
|
17
|
+
func.utils.post_back_to_client(SESSION_ID, 'get_doc_from_studio', _session.worker_id, { doc_id: idP });
|
|
18
|
+
|
|
19
|
+
self.addEventListener('live_preview_get_obj_response_worker_' + idP, (event) => {
|
|
20
|
+
// console.log("Custom event triggered:", event);
|
|
21
|
+
resolve(event.detail.data);
|
|
22
|
+
});
|
|
31
23
|
} else {
|
|
32
24
|
STUDIO_PEER_CONN_SEND_METHOD({
|
|
33
|
-
service:
|
|
25
|
+
service: 'get_doc_obj',
|
|
34
26
|
data: { doc_id: idP },
|
|
35
27
|
session_id: SESSION_ID,
|
|
36
28
|
id: STUDIO_PEER.id,
|
|
37
|
-
source:
|
|
29
|
+
source: 'runtime',
|
|
38
30
|
app_id,
|
|
39
31
|
});
|
|
40
32
|
|
|
41
|
-
$(
|
|
33
|
+
$('body').on('live_preview_get_obj_response_' + idP, function (e, data) {
|
|
42
34
|
resolve(data.data);
|
|
43
|
-
$(
|
|
35
|
+
$('body').off('live_preview_get_obj_response_' + idP);
|
|
44
36
|
});
|
|
45
37
|
}
|
|
46
38
|
});
|
|
@@ -51,29 +43,24 @@ export const get_doc_from_websocket = async function (SESSION_ID, app_id, idP) {
|
|
|
51
43
|
return new Promise(function (resolve, reject) {
|
|
52
44
|
if (glb.IS_WORKER) {
|
|
53
45
|
// throw new Error("fail to fetch from ws");
|
|
54
|
-
func.utils.post_back_to_client(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
_session.worker_id,
|
|
58
|
-
{ doc_id: idP }
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
self.addEventListener("get_doc_obj_from_build_worker_" + idP, (event) => {
|
|
46
|
+
func.utils.post_back_to_client(SESSION_ID, 'get_doc_from_websocket', _session.worker_id, { doc_id: idP });
|
|
47
|
+
|
|
48
|
+
self.addEventListener('get_doc_obj_from_build_worker_' + idP, (event) => {
|
|
62
49
|
resolve(event.detail.data);
|
|
63
50
|
});
|
|
64
51
|
} else {
|
|
65
52
|
if (RUNTIME_SERVER_WEBSOCKET && RUNTIME_SERVER_WEBSOCKET_CONNECTED) {
|
|
66
|
-
RUNTIME_SERVER_WEBSOCKET.emit(
|
|
67
|
-
service:
|
|
53
|
+
RUNTIME_SERVER_WEBSOCKET.emit('message', {
|
|
54
|
+
service: 'get_doc_obj_from_build',
|
|
68
55
|
data: { doc_id: idP },
|
|
69
56
|
});
|
|
70
|
-
$(
|
|
57
|
+
$('body').on('get_doc_obj_from_build_response_' + idP, (e, data) => {
|
|
71
58
|
// views_ret = data.data;
|
|
72
59
|
resolve(data.data);
|
|
73
|
-
$(
|
|
60
|
+
$('body').off('get_doc_obj_from_build_response_' + idP);
|
|
74
61
|
});
|
|
75
62
|
} else {
|
|
76
|
-
throw new Error(
|
|
63
|
+
throw new Error('fail to fetch from ws websocket inactive');
|
|
77
64
|
}
|
|
78
65
|
}
|
|
79
66
|
});
|
|
@@ -82,33 +69,33 @@ export const get_doc_from_websocket = async function (SESSION_ID, app_id, idP) {
|
|
|
82
69
|
export const DOCS_OBJ_get = async function (SESSION_ID, idP) {
|
|
83
70
|
if (!idP) return;
|
|
84
71
|
|
|
85
|
-
if (idP ===
|
|
72
|
+
if (idP === '_empty_panel_program') {
|
|
86
73
|
return {
|
|
87
|
-
_id:
|
|
74
|
+
_id: '_empty_panel_program',
|
|
88
75
|
|
|
89
76
|
properties: {
|
|
90
|
-
menuName:
|
|
91
|
-
menuTitle:
|
|
92
|
-
menuType:
|
|
77
|
+
menuName: '_empty_panel_program',
|
|
78
|
+
menuTitle: '_empty_panel_program',
|
|
79
|
+
menuType: 'component',
|
|
93
80
|
// uiFramework: "@xuda.io/xuda-framework-plugin-tailwind",
|
|
94
|
-
renderType:
|
|
81
|
+
renderType: 'form',
|
|
95
82
|
},
|
|
96
83
|
progUi: [
|
|
97
84
|
{
|
|
98
|
-
id:
|
|
99
|
-
tagName:
|
|
85
|
+
id: 'node-empty_panel_program',
|
|
86
|
+
tagName: 'xu-single-view',
|
|
100
87
|
children: [
|
|
101
88
|
{
|
|
102
|
-
id:
|
|
103
|
-
tagName:
|
|
89
|
+
id: 'node-empty_panel_program-span',
|
|
90
|
+
tagName: 'span',
|
|
104
91
|
children: [],
|
|
105
|
-
content:
|
|
106
|
-
type:
|
|
92
|
+
content: '',
|
|
93
|
+
type: 'element',
|
|
107
94
|
attributes: {},
|
|
108
95
|
},
|
|
109
96
|
],
|
|
110
|
-
content:
|
|
111
|
-
type:
|
|
97
|
+
content: '',
|
|
98
|
+
type: 'element',
|
|
112
99
|
attributes: {},
|
|
113
100
|
},
|
|
114
101
|
],
|
|
@@ -122,35 +109,28 @@ export const DOCS_OBJ_get = async function (SESSION_ID, idP) {
|
|
|
122
109
|
const app_id = _session.app_id;
|
|
123
110
|
var views_ret;
|
|
124
111
|
|
|
125
|
-
if (_session.engine_mode ===
|
|
112
|
+
if (_session.engine_mode === 'live_preview') {
|
|
126
113
|
return await get_doc_from_studio(SESSION_ID, app_id, idP);
|
|
127
114
|
}
|
|
128
115
|
|
|
129
116
|
if (glb.register_startup_programs) {
|
|
130
|
-
func.common.db(SESSION_ID,
|
|
117
|
+
func.common.db(SESSION_ID, 'register_startup_programs', {
|
|
131
118
|
prog_id: idP,
|
|
132
119
|
build_id: _session?.build_info?.build || 0,
|
|
133
120
|
});
|
|
134
121
|
}
|
|
135
122
|
|
|
136
|
-
views_ret = await read_objects_cache(SESSION_ID, idP,
|
|
123
|
+
views_ret = await read_objects_cache(SESSION_ID, idP, 'DOCS_OBJ');
|
|
137
124
|
|
|
138
125
|
if (!views_ret) {
|
|
139
|
-
if (
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
if (
|
|
146
|
-
[
|
|
147
|
-
"master",
|
|
148
|
-
// "master_team"
|
|
149
|
-
].includes(_this.APP_OBJ[app_id].app_type)
|
|
150
|
-
) {
|
|
151
|
-
url += "get_doc_obj_raw";
|
|
126
|
+
if (typeof _this.IS_DOCKER === 'undefined' && typeof _this.IS_PROCESS_SERVER === 'undefined') {
|
|
127
|
+
let url = _this.func.common.get_url(SESSION_ID, 'rpi', '');
|
|
128
|
+
|
|
129
|
+
// Jul 7,25 build condition for master need to be added
|
|
130
|
+
if (['master'].includes(_this.APP_OBJ[app_id].app_type)) {
|
|
131
|
+
url += 'get_doc_obj_raw';
|
|
152
132
|
} else {
|
|
153
|
-
url +=
|
|
133
|
+
url += 'get_doc_obj_from_build';
|
|
154
134
|
}
|
|
155
135
|
|
|
156
136
|
let app_id_reference = _this.APP_OBJ[app_id].app_id_reference;
|
|
@@ -159,56 +139,50 @@ export const DOCS_OBJ_get = async function (SESSION_ID, idP) {
|
|
|
159
139
|
|
|
160
140
|
const http = async function () {
|
|
161
141
|
const response = await fetch(url, {
|
|
162
|
-
method:
|
|
142
|
+
method: 'POST',
|
|
163
143
|
headers: {
|
|
164
|
-
Accept:
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
144
|
+
Accept: 'application/json',
|
|
145
|
+
'Content-Type': 'application/json',
|
|
146
|
+
'xu-gtp-token': _session.gtp_token,
|
|
147
|
+
'xu-app-token': _session.app_token,
|
|
168
148
|
},
|
|
169
149
|
body: JSON.stringify({
|
|
170
150
|
app_id: app_id,
|
|
171
151
|
doc_id: idP,
|
|
172
|
-
build:
|
|
173
|
-
_session.build_info.instance_build ||
|
|
174
|
-
_session.build_info.build ||
|
|
175
|
-
_session.opt.app_build_id,
|
|
152
|
+
build: _session.build_info.instance_build || _session.build_info.build || _session.opt.app_build_id,
|
|
176
153
|
app_id_reference: app_id_reference,
|
|
154
|
+
engine_mode: _session.engine_mode,
|
|
177
155
|
}),
|
|
178
156
|
});
|
|
179
157
|
const json = await response.json();
|
|
180
158
|
if (response) {
|
|
181
159
|
if (response && response.status === 400) {
|
|
182
|
-
return _this.func.utils.request_error(
|
|
183
|
-
SESSION_ID,
|
|
184
|
-
"ajax",
|
|
185
|
-
response.statusText
|
|
186
|
-
);
|
|
160
|
+
return _this.func.utils.request_error(SESSION_ID, 'ajax', response.statusText);
|
|
187
161
|
}
|
|
188
162
|
|
|
189
163
|
views_ret = json.data;
|
|
190
164
|
}
|
|
191
165
|
};
|
|
192
166
|
|
|
193
|
-
|
|
194
|
-
if (
|
|
195
|
-
SESSION_OBJ?.[SESSION_ID]?.rpi_http_methods?.includes(
|
|
196
|
-
"get_doc_obj_from_build"
|
|
197
|
-
)
|
|
198
|
-
) {
|
|
199
|
-
views_ret = await get_doc_from_websocket(SESSION_ID, app_id, idP);
|
|
200
|
-
} else {
|
|
201
|
-
throw new Error("not a get_doc_obj_from_build method");
|
|
202
|
-
}
|
|
203
|
-
} catch (err) {
|
|
167
|
+
if (_session.engine_mode === 'cms') {
|
|
204
168
|
await http();
|
|
169
|
+
} else {
|
|
170
|
+
views_ret = await get_doc_from_websocket(SESSION_ID, app_id, idP);
|
|
205
171
|
}
|
|
172
|
+
|
|
173
|
+
// // Jul 7,25 replaced ^^
|
|
174
|
+
// try {
|
|
175
|
+
// if (SESSION_OBJ?.[SESSION_ID]?.rpi_http_methods?.includes('get_doc_obj_from_build')) {
|
|
176
|
+
// views_ret = await get_doc_from_websocket(SESSION_ID, app_id, idP);
|
|
177
|
+
// } else {
|
|
178
|
+
// throw new Error('not a get_doc_obj_from_build method');
|
|
179
|
+
// }
|
|
180
|
+
// } catch (err) {
|
|
181
|
+
// await http();
|
|
182
|
+
// }
|
|
206
183
|
}
|
|
207
184
|
|
|
208
|
-
if (
|
|
209
|
-
typeof _this.IS_DOCKER !== "undefined" ||
|
|
210
|
-
typeof _this.IS_PROCESS_SERVER !== "undefined"
|
|
211
|
-
) {
|
|
185
|
+
if (typeof _this.IS_DOCKER !== 'undefined' || typeof _this.IS_PROCESS_SERVER !== 'undefined') {
|
|
212
186
|
var ret = await __.rpi.get_prog(app_id, idP);
|
|
213
187
|
|
|
214
188
|
if (ret.data) {
|
|
@@ -219,28 +193,19 @@ export const DOCS_OBJ_get = async function (SESSION_ID, idP) {
|
|
|
219
193
|
if (views_ret) {
|
|
220
194
|
if (views_ret.error) {
|
|
221
195
|
console.error(views_ret);
|
|
222
|
-
views_ret =
|
|
196
|
+
views_ret = '';
|
|
223
197
|
return;
|
|
224
198
|
}
|
|
225
|
-
await save_objects_cache(SESSION_ID, idP,
|
|
199
|
+
await save_objects_cache(SESSION_ID, idP, 'DOCS_OBJ', views_ret);
|
|
226
200
|
}
|
|
227
201
|
}
|
|
228
202
|
|
|
229
203
|
return views_ret;
|
|
230
204
|
};
|
|
231
205
|
|
|
232
|
-
export const save_objects_cache = async function (
|
|
233
|
-
SESSION_ID,
|
|
234
|
-
id,
|
|
235
|
-
obj_type,
|
|
236
|
-
data
|
|
237
|
-
) {
|
|
206
|
+
export const save_objects_cache = async function (SESSION_ID, id, obj_type, data) {
|
|
238
207
|
var _session = _this.SESSION_OBJ[SESSION_ID];
|
|
239
|
-
if (
|
|
240
|
-
typeof _this.IS_DOCKER !== "undefined" ||
|
|
241
|
-
typeof _this.IS_PROCESS_SERVER !== "undefined" ||
|
|
242
|
-
_session.worker_type === "Dev"
|
|
243
|
-
) {
|
|
208
|
+
if (typeof _this.IS_DOCKER !== 'undefined' || typeof _this.IS_PROCESS_SERVER !== 'undefined' || _session.worker_type === 'Dev') {
|
|
244
209
|
return;
|
|
245
210
|
}
|
|
246
211
|
|
|
@@ -250,7 +215,7 @@ export const save_objects_cache = async function (
|
|
|
250
215
|
var doc = {
|
|
251
216
|
_id: `cache_${build_id}_${obj_type}_${id}`,
|
|
252
217
|
id: id,
|
|
253
|
-
docType:
|
|
218
|
+
docType: 'cache_objects',
|
|
254
219
|
build_id: build_id.toString(),
|
|
255
220
|
obj_type: obj_type,
|
|
256
221
|
data: data,
|
|
@@ -263,12 +228,7 @@ export const save_objects_cache = async function (
|
|
|
263
228
|
if (await read_objects_cache(SESSION_ID, id, obj_type)) {
|
|
264
229
|
return;
|
|
265
230
|
}
|
|
266
|
-
if (
|
|
267
|
-
!doc.data ||
|
|
268
|
-
(doc.data &&
|
|
269
|
-
typeof doc.data === "string" &&
|
|
270
|
-
doc.data.indexOf("error") > -1)
|
|
271
|
-
) {
|
|
231
|
+
if (!doc.data || (doc.data && typeof doc.data === 'string' && doc.data.indexOf('error') > -1)) {
|
|
272
232
|
return;
|
|
273
233
|
}
|
|
274
234
|
|
|
@@ -281,15 +241,12 @@ export const save_objects_cache = async function (
|
|
|
281
241
|
}, 1000);
|
|
282
242
|
};
|
|
283
243
|
export const read_objects_cache = async function (SESSION_ID, id, obj_type) {
|
|
284
|
-
if (
|
|
285
|
-
typeof _this.IS_DOCKER !== "undefined" ||
|
|
286
|
-
typeof _this.IS_PROCESS_SERVER !== "undefined"
|
|
287
|
-
) {
|
|
244
|
+
if (typeof _this.IS_DOCKER !== 'undefined' || typeof _this.IS_PROCESS_SERVER !== 'undefined') {
|
|
288
245
|
try {
|
|
289
|
-
const data = fs.readFileSync(
|
|
246
|
+
const data = fs.readFileSync('/var/xuda/progs/' + id + '.json', 'utf8');
|
|
290
247
|
return JSON.parse(data);
|
|
291
248
|
} catch (err) {
|
|
292
|
-
console.error(
|
|
249
|
+
console.error('read_objects_cache', err);
|
|
293
250
|
return;
|
|
294
251
|
}
|
|
295
252
|
}
|
|
@@ -302,12 +259,8 @@ export const read_objects_cache = async function (SESSION_ID, id, obj_type) {
|
|
|
302
259
|
try {
|
|
303
260
|
ret = await db.get(`cache_${build_id}_${obj_type}_${id}`);
|
|
304
261
|
|
|
305
|
-
if (
|
|
306
|
-
|
|
307
|
-
typeof ret.data === "string" &&
|
|
308
|
-
ret.data.indexOf("error") > -1
|
|
309
|
-
) {
|
|
310
|
-
return "";
|
|
262
|
+
if (ret.data && typeof ret.data === 'string' && ret.data.indexOf('error') > -1) {
|
|
263
|
+
return '';
|
|
311
264
|
}
|
|
312
265
|
|
|
313
266
|
return ret.data;
|
|
@@ -334,10 +287,7 @@ export const delete_objects_cache = async function (SESSION_ID, id, obj_type) {
|
|
|
334
287
|
};
|
|
335
288
|
export const load_objects_cache = async function (SESSION_ID) {
|
|
336
289
|
var _session = _this.SESSION_OBJ[SESSION_ID];
|
|
337
|
-
if (
|
|
338
|
-
typeof _this.IS_DOCKER !== "undefined" ||
|
|
339
|
-
typeof _this.IS_PROCESS_SERVER !== "undefined"
|
|
340
|
-
) {
|
|
290
|
+
if (typeof _this.IS_DOCKER !== 'undefined' || typeof _this.IS_PROCESS_SERVER !== 'undefined') {
|
|
341
291
|
return;
|
|
342
292
|
}
|
|
343
293
|
|
|
@@ -346,7 +296,7 @@ export const load_objects_cache = async function (SESSION_ID) {
|
|
|
346
296
|
const db = await _this.func.utils.connect_pouchdb(SESSION_ID);
|
|
347
297
|
const build_id = _this.APP_OBJ[app_id].app_build_id;
|
|
348
298
|
let ret = await db.find({
|
|
349
|
-
selector: { docType:
|
|
299
|
+
selector: { docType: 'cache_objects', build_id },
|
|
350
300
|
});
|
|
351
301
|
|
|
352
302
|
for (let val of ret.docs) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xuda.io/runtime-bundle",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.917",
|
|
4
4
|
"description": "The Xuda Runtime Bundle refers to a collection of scripts and libraries packaged together to provide the necessary runtime environment for executing plugins or components in the Xuda platform. ",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"pub": "npm version patch --force && npm publish --access public"
|