@xuda.io/runtime-bundle 1.0.885 → 1.0.887

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.
@@ -661,7 +661,7 @@ func.utils.ws_worker.functions = {
661
661
  APP_OBJ[data.app_id] = data.APP_OBJ;
662
662
  PROJECT_OBJ[data.app_id] = data.PROJECT_OBJ;
663
663
 
664
- if (data.SESSION_INFO.engine_mode === 'live_preview') {
664
+ if (['live_preview', 'cms'].includes(data.SESSION_INFO.engine_mode)) {
665
665
  DOCS_OBJ[data.app_id] = data.DOCS_OBJ;
666
666
  } else if (typeof IS_DOCKER === 'undefined' && typeof IS_PROCESS_SERVER === 'undefined') {
667
667
  if (!DOCS_OBJ[data.app_id]) {
@@ -1 +1 @@
1
- glb.DEBUG_INFO_OBJ={};glb.APP_INFO={};var SYSTEM_READY=null;var GLB_JS_SCRIPTS_LOADED=[];var STUDIO_WEBSOCKET=null;var STUDIO_WEBSOCKET_CONNECTION_ID=null;var STUDIO_PEER=null;var STUDIO_PEER_CONN_SEND_METHOD=null;var STUDIO_PEER_CONN_ID=null;var SUPPORT_PEER=null;var SUPPORT_PEER_CONN=null;var STUDIO_PEER_CONN_MSG_QUEUE=[];var CLIENT_ACTIVITY_TS;glb.REFERENCE_LESS_FUNCTIONS=["update","raise_event","call_library","invoke_action","loader_on","loader_off","emit_event","delay","execute_evaluate_javascript","execute_native_javascript"];var CACHE_PROG_UI={};var ALERT_IS_ACTIVE=false;glb.WORKER_ATTEMPTS_NOT_RESPONDING=2e5;glb.WORKER_TIMEOUT=6e5;glb.WORKER_PAUSE=false;var DATASOURCE_INTERVALS={};var APP_MODAL_OBJ={};var CURRENT_APP_POPOVER=null;var ELEMENT_CLICK_EVENT=null;var posX=0;var posY=0;var LOADER_ACTIVE=false;var LOADER_TEXT="";var REFRESHER_IN_PROGRESS=false;glb.screen_num=0;var RESPONSE_FROM_STUDIO_QUEUE={};var SCREEN_BLOCKER_OBJ={};var IS_PROGRESS_SCREEN_OPEN=null;var UI_WORKER_OBJ={jobs:[],num:9e3,cache:{},viewport_height_set_ids:[]};glb.html5_events_handler=["onabort","onafterprint","onautocomplete","onautocompleteerror","onbeforeprint","onbeforeunload","onblur","oncancel","oncanplay","oncanplaythrough","onchange","onclick","onclose","oncontextmenu","oncopy","oncuechange","oncut","ondblclick","ondrag","ondragend","ondragenter","ondragexit","ondragleave","ondragover","ondragstart","ondrop","ondurationchange","onemptied","onended","onerror","onfocus","onhashchange","oninput","oninvalid","onkeydown","onkeypress","onkeyup","onload","onloadeddata","onloadedmetadata","onloadstart","onmessage","onmousedown","onmouseenter","onmouseleave","onmousemove","onmouseout","onmouseover","onmouseup","onmousewheel","onoffline","ononline","onpagehide","onpageshow","onpaste","onpause","onplay","onplaying","onpopstate","onprogress","onratechange","onreset","onresize","onscroll","onsearch","onseeked","onseeking","onselect","onshow","onsort","onstalled","onstorage","onsubmit","onsuspend","ontimeupdate","ontoggle","onunload","onvolumechange","onwaiting"];glb.lifecycle={plugins:{},fn_arr:["beforeInit","initialized","systemReady","beforeMounted","mounted"],execute:async function(SESSION_ID,event){const _session=SESSION_OBJ[SESSION_ID];const xu_api=await func.common.get_module(SESSION_ID,"xuda-api-library.mjs",{func:func,glb:glb,SESSION_OBJ:SESSION_OBJ,SESSION_ID:SESSION_ID,APP_OBJ:APP_OBJ,dsSession:func.utils.get_last_datasource_no(SESSION_ID)});var params={SESSION_ID:SESSION_ID,session_data:_session,app_obj:APP_OBJ[_session.app_id],xu_api:xu_api};for await(const[plugin_name,val]of Object.entries(glb.lifecycle.plugins)){if(val?.plugin_script?.[event]){params.setup_data=val.setup_data;await val.plugin_script[event](params)}}}};glb.run_xu_before=["xu-cdn","xu-style","xu-render","xu-for-key","xu-for-val"];glb.run_xu_after=["xu-bind","xu-class","xu-script","xu-ui-plugin"];glb.attr_abbreviations_arr=["xu-click","xu-dblclick","xu-contextmenu","xu-focus","xu-keyup","xu-change","xu-blur","xu-init"];glb.solid_attributes=["disabled"];func.utils={};func.utils.debug={};func.utils.debug.watch=async function(SESSION_ID,key,type,info,result,condition,not_executed){if(!glb.DEBUG_MODE)return;const debug_utils=await func.common.get_module(SESSION_ID,"xuda-debug-utils-module.mjs");debug_utils.watch(SESSION_ID,key,type,info,result,condition,not_executed)};func.utils.debug.log=async function(SESSION_ID,node_idP,jsonP){if(typeof IS_PROCESS_SERVER!=="undefined")return;if(!glb.DEBUG_MODE&&!glb.TRACE_ON)return;const debug_utils=await func.common.get_module(SESSION_ID,"xuda-debug-utils-module.mjs");debug_utils.log(SESSION_ID,node_idP,jsonP)};func.utils.debug.write=async function(SESSION_ID,logP,callbackP){if(!glb.DEBUG_MODE)return;const debug_utils=await func.common.get_module(SESSION_ID,"xuda-debug-utils-module.mjs");debug_utils.write(SESSION_ID,logP,callbackP)};func.utils.debug.read_command=async function(data){if(!glb.DEBUG_MODE)return;const debug_utils=await func.common.get_module(SESSION_ID,"xuda-debug-utils-module.mjs");debug_utils.read_command(data)};func.utils.DOCS_OBJ={};func.utils.DOCS_OBJ.get=async function(SESSION_ID,idP){if(!idP||idP==="0")return;var _session=SESSION_OBJ[SESSION_ID];const _app_id=_session.app_id;if(!DOCS_OBJ[_app_id]){DOCS_OBJ[_app_id]={}}if(DOCS_OBJ[_app_id][idP]){return DOCS_OBJ[_app_id][idP]}if(_session.project_data){if(idP==="system"){if(_session.project_data.globals){DOCS_OBJ[_app_id][idP]=_session.project_data.globals}else{DOCS_OBJ[_app_id][idP]={}}return DOCS_OBJ[_app_id][idP]}let val=_session.project_data?.programs?.[idP];if(val){return DOCS_OBJ[_app_id][idP]=val}}if(typeof _session.SLIM_BUNDLE==="undefined"||!_session.SLIM_BUNDLE){const module=await func.common.get_module(SESSION_ID,`xuda-progs-loader-module.mjs`);if(idP!=="system"){DOCS_OBJ[_app_id][idP]=await module.DOCS_OBJ_get(SESSION_ID,idP);if(DOCS_OBJ[_app_id][idP]&&_.isEmpty(DOCS_OBJ[_app_id][idP])){await func.utils.remove_cached_objects(SESSION_ID);delete DOCS_OBJ[_app_id][idP]}return DOCS_OBJ[_app_id][idP]}DOCS_OBJ[_app_id][idP]=await module.DOCS_OBJ_get(SESSION_ID,"global_"+(APP_OBJ[_app_id].app_replicate||_app_id));if(APP_OBJ[_app_id].app_imported_projects){for await(const imported_app_id of APP_OBJ[_app_id].app_imported_projects){var view_ret=await module.DOCS_OBJ_get(SESSION_ID,"global_"+imported_app_id);DOCS_OBJ[_app_id][idP]=_.merge(DOCS_OBJ[_app_id][idP],view_ret)}}return DOCS_OBJ[_app_id][idP]}console.error(`${idP} not found`)};func.utils.FILES_OBJ={};func.utils.FILES_OBJ.get=async function(SESSION_ID,idP){if(!idP)return;return await func.utils.DOCS_OBJ.get(SESSION_ID,idP)};func.utils.VIEWS_OBJ={};func.utils.VIEWS_OBJ.get=async function(SESSION_ID,idP){if(!idP)return;return await func.utils.DOCS_OBJ.get(SESSION_ID,idP)};func.utils.TREE_OBJ={};func.utils.TREE_OBJ.get=async function(SESSION_ID,idP){if(!idP)return;var ret=await func.utils.DOCS_OBJ.get(SESSION_ID,idP);if(ret?.properties){ret.properties.id=idP}return ret.properties};func.utils.get_dateTime=async function(SESSION_ID,typeP,dateP){const get_server_ts=async function(){var _session=SESSION_OBJ[SESSION_ID];const response=await fetch(`https://${_session.domain}/cpi/get_utc_ts`,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({})});const json=await response.json();return json.data};function getWeekNumber(d){d=new Date(+d);d.setHours(0,0,0);d.setDate(d.getDate()+4-(d.getDay()||7));var yearStart=new Date(d.getFullYear(),0,1);var weekNo=Math.ceil(((d-yearStart)/864e5+1)/7);return weekNo}var sysDate=new Date(dateP);if(!dateP){let ts=await get_server_ts();sysDate=new Date(ts)}var day=_.padStart(sysDate.getDate(),2,"0");var month=_.padStart(sysDate.getMonth()+1,2,"0");var year=sysDate.getFullYear();var week=_.padStart(getWeekNumber(sysDate),2,"0");var hour=_.padStart(sysDate.getHours(),2,"0");var minute=_.padStart(sysDate.getMinutes(),2,"0");var second=_.padStart(sysDate.getSeconds(),2,"0");if(typeP==="SYS_DATE")return year+"-"+month+"-"+day;if(typeP==="SYS_DATE_TIME")return year+"-"+month+"-"+day+"T"+hour+":"+minute;if(typeP==="SYS_DATE_VALUE")return sysDate.valueOf();if(typeP==="SYS_DATE_WEEK_YEAR")return year+"W"+week;if(typeP==="SYS_DATE_MONTH_YEAR")return year+"-"+month;if(typeP==="SYS_TIME")return hour+":"+minute+":"+second;if(typeP==="SYS_TIME_SHORT")return hour+":"+minute};func.utils.is_onscreen_event=function(functionP){const arr=["invoke_action","cache_refresh","call_popover","call_modal","call_page","loader_on","loader_off","emit_event"];return arr.includes(functionP)};func.utils.get_screen_obj=async function(SESSION_ID,id){const prog_obj=await func.utils.VIEWS_OBJ.get(SESSION_ID,id);if(!prog_obj)return console.error("prog not found: "+id);if(prog_obj.properties.menuType==="screen"||prog_obj.properties.menuType==="api"||glb.FUNCTION_NODES_ARR.includes(prog_obj.properties.menuType)||glb.MOBILE_ARR.includes(prog_obj.properties.menuType)){return prog_obj}return};func.utils.clean_returned_datasource=function(SESSION_ID,DS){const clean_object_functions=function(obj){for(const[key,val]of Object.entries(obj)){if(typeof val==="function"){delete obj[key]}}};var _session=SESSION_OBJ[SESSION_ID];if(!_session.DS_GLB[DS])return;var obj=_.clone(_session.DS_GLB[DS]);delete obj.screen_params;try{clean_object_functions(obj);obj=JSON.parse(JSON.stringify(obj,func.utils.clean_stringify_null,"\t"))}catch(e){console.error(e)}delete obj.pre_init_fields;delete obj.oninit_triggers_to_run;delete obj.debug;const clean_empty_objects=function(){for(const[key,val]of Object.entries(obj)){if(typeof val==="object"&&!Array.isArray(val)&&_.isEmpty(val)){delete obj[key]}}for(const[key,val]of Object.entries(obj)){if(typeof val==="object"&&Array.isArray(val)&&!val.length){delete obj[key]}}};delete obj.screenInfo;delete obj.viewEventsProp;delete obj.viewSourceDesc;delete obj.viewSourceProp;delete obj.v;clean_empty_objects();return obj};func.utils.post_back_to_client=function(SESSION_ID,service,id,data){if(typeof IS_PROCESS_SERVER!=="undefined")return;worker_post_message({fx_to_execute:service,params:data,session_id:SESSION_ID,worker_id:id})};func.utils.job_worker={};func.utils.job_worker=function(session_id){var SESSION_ID=session_id;var _session=SESSION_OBJ[SESSION_ID];var is_progressScreen_on;var is_not_responding;var attempt=0;const lock=function(dsP){if(!_session.WORKER_OBJ.jobs[_session.WORKER_OBJ.stat]||_session.WORKER_OBJ.jobs[_session.WORKER_OBJ.stat].typeP==="system_interval"||_session.WORKER_OBJ.jobs[_session.WORKER_OBJ.stat].typeP==="system event"){return}if(glb.IS_WORKER){func.utils.post_back_to_client(SESSION_ID,"screen_blocker_on",_session.worker_id,null)}else{func.UI.utils.screen_blocker(true,"Worker",dsP)}};const unlock=function(){if(glb.IS_WORKER){}else{func.UI.utils.screen_blocker(false,"Worker")}};const not_responding=function(){is_not_responding=true;func.UI.utils.progressScreen.hide("Working, Please wait..");setTimeout(function(){if(!is_not_responding)return;reset()},500)};const idle=function(){if(is_progressScreen_on){setTimeout(function(){if(!attempt&&is_progressScreen_on){is_progressScreen_on=false;is_not_responding=false;func.UI.utils.progressScreen.hide("Working, Please wait..")}else if(attempt>300&&is_not_responding){is_not_responding=false;busy()}},310)}else{if(!glb.IS_WORKER){}}};const busy=function(){if(glb.IS_WORKER)return;func.utils.debug_report(SESSION_ID,"utils.worker.busy","worker processing more then 10 second","W","",_session.WORKER_OBJ.jobs);is_progressScreen_on=true};const reset=function(){func.utils.debug_report(SESSION_ID,"utils.worker.reset","worker not responding","E","",_session.WORKER_OBJ.jobs);_session.WORKER_OBJ.jobs=[];_session.WORKER_OBJ.stat=null;$(".screen_blocker").remove()};return{_interval:null,_was_busy:null,init:async function(){var _this=this;this._interval=setInterval(async function(){var _session=SESSION_OBJ[SESSION_ID];if(!_session?.WORKER_OBJ)return;if(typeof _session.WORKER_OBJ.stat==="undefined"||_session.WORKER_OBJ.stat==="undefined"||_session.WORKER_OBJ.stat===null){unlock();if(_session.WORKER_OBJ.jobs.length){for await(const[key,val]of Object.entries(_session.WORKER_OBJ.jobs)){if(val.stat){break}if(!_session.WORKER_OBJ.jobs[Number(key)]||val.job_num===9999999){continue}if(val.dsSessionP&&!_session.DS_GLB[val.dsSessionP]){func.events.delete_job(SESSION_ID,val.job_num);break}await func.events.execute(SESSION_ID,val.job_num,val.eventIdP,val.triggerP,val.functionP,val.refIdP,val.containerP,val.elementP,val.rowP,val.evt,val.descP,val.rootScreenIdP,val.dsSessionP,null,val.typeP,null,val.event_propertiesP,val.calling_triggerP,null,val.paramsP,val.target_frame_idP,val.calling_trigger_prop,val.calling_program,val.argumentsP,val.prog_id,val.nodeId,val.parentDataSourceNo,val.$container)}_this._was_busy=true}else{if(_this._was_busy){if(glb.IS_WORKER){func.utils.post_back_to_client(SESSION_ID,"worker_busy_off",_session.worker_id,null)}else{func.UI.utils.indicator.worker.normal()}}_this._was_busy=false}attempt=0;is_not_responding=false;idle()}else{_this._was_busy=true;if(glb.IS_WORKER){func.utils.post_back_to_client(SESSION_ID,"worker_busy_on",_session.worker_id,null)}else{func.UI.utils.indicator.worker.busy()}if(glb.WORKER_PAUSE)return;attempt++;if(!is_progressScreen_on&&attempt>glb.WORKER_TIMEOUT)busy();if(!is_not_responding&&attempt>=glb.WORKER_ATTEMPTS_NOT_RESPONDING){not_responding()}var ds=null;if(_session.WORKER_OBJ.jobs[0])ds=_session.WORKER_OBJ.jobs[0].dsSessionP;lock(ds)}},1)},stop:function(){clearInterval(this._interval)}}};func.utils.base64MimeType=function(encoded){var result=null;if(typeof encoded!=="string"){return result}var mime=encoded.match(/data:([a-zA-Z0-9]+\/[a-zA-Z0-9-.+]+).*,.*/);if(mime&&mime.length){result=mime[1]}return result};func.utils.makeid=function(length){var result="";var characters="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";var charactersLength=characters.length;for(var i=0;i<length;i++){result+=characters.charAt(Math.floor(Math.random()*charactersLength))}return result};func.utils.get_device=function(){var device;try{if(window.cordova){device=window.cordova.platformId}}catch(e){console.error("error using ui element in server side request")}return device};func.utils.ws_worker={};func.utils.ws_worker.functions={init:async function(data){var SESSION_ID=data.SESSION_ID;APP_OBJ[data.app_id]=data.APP_OBJ;PROJECT_OBJ[data.app_id]=data.PROJECT_OBJ;if(data.SESSION_INFO.engine_mode==="live_preview"){DOCS_OBJ[data.app_id]=data.DOCS_OBJ}else if(typeof IS_DOCKER==="undefined"&&typeof IS_PROCESS_SERVER==="undefined"){if(!DOCS_OBJ[data.app_id]){DOCS_OBJ[data.app_id]={}}}glb.APP_INFO[data.app_id]=data.APP_INFO;glb.DEBUG_MODE=data.DEBUG_MODE;glb.DEBUG_INFO_OBJ=data.DEBUG_INFO_OBJ;glb.WINDOW_LOCATION_SEARCH=data.WINDOW_LOCATION_SEARCH;glb.ROOT_ELEMENT_ATTRIBUTES=data.ROOT_ELEMENT_ATTRIBUTES;DATASOURCE_INTERVALS[SESSION_ID]={};SESSION_OBJ[SESSION_ID]=data.SESSION_INFO;var _session=SESSION_OBJ[SESSION_ID];glb.SESSION_INFO=data.SESSION_INFO;_session.engine_mode=data.engine_mode;STUDIO_WEBSOCKET_CONNECTION_ID=data.STUDIO_WEBSOCKET_CONNECTION_ID;for(let[key,val]of Object.entries(_session.DS_GLB)){if(Number(key)>_session.dataSourceSessionGlobal){_session.dataSourceSessionGlobal=Number(key)}}if(typeof _session.SLIM_BUNDLE==="undefined"||!_session.SLIM_BUNDLE){const db_adapter=await func.common.get_module(SESSION_ID,"xuda-db-adapter-module.mjs");func.db=db_adapter._db}_session.WORKER_OBJ.fx=new func.utils.job_worker(SESSION_ID);_session.WORKER_OBJ.fx.init();if(_session.app_id==="unknown"){worker_post_message({fx_to_execute:"init_done",worker_id:ws_worker_id,session_id:SESSION_ID})}else{const module=await func.common.get_module(SESSION_ID,`xuda-progs-loader-module.mjs`);await module.load_objects_cache(SESSION_ID);worker_post_message({fx_to_execute:"init_done",worker_id:ws_worker_id,session_id:SESSION_ID})}WEB_WORKER_CALLBACK_QUEUE[SESSION_ID]={}},datasource_create:async function(params,promise_queue_id){var SESSION_ID=params.session_id;var _session=SESSION_OBJ[SESSION_ID];_session.ts=(new Date).getTime();var args=params;args.SESSION_ID=SESSION_ID;if(show_log){console.log("DATASOURCE EXECUTING SESSION_ID: "+SESSION_ID,APP_OBJ[_session.app_id].app_name)}if(Number(params.dataSourceSessionGlobal)>_session.dataSourceSessionGlobal){_session.dataSourceSessionGlobal=Number(params.dataSourceSessionGlobal)}const ret=await func.datasource.prepare(args.SESSION_ID,args.prog_id,args.dataSourceNoP,args.parentDataSourceNoP,args.containerIdP,args.rowIdP,args.jobNoP,args.calling_trigger_prop,args.parameters_raw_obj,null,args.callingSourceP,args.calling_jobP,args.screen_dsP,args.is_panelP,args.parameters_obj_inP,args.static_refreshP,args.run_atP,args.worker_id);try{let _ds=_session.DS_GLB[ret.dsSessionP];if(show_log)console.log("DATASOURCE EXECUTION DONE "+ret.dsSessionP+" "+_ds?.tree_obj?.menuName||""+" SESSION_ID: "+SESSION_ID,APP_OBJ[_session.app_id].app_name);var obj=func.utils.clean_returned_datasource(SESSION_ID,ret?.dsSessionP);obj.dataSourceSessionGlobal=_session.dataSourceSessionGlobal;worker_post_message({promise_queue_id:promise_queue_id,params:obj,worker_id:ws_worker_id,session_id:SESSION_ID,process_pid:params.process_pid,service:params.service});_ds.stat="idle"}catch(error){debugger}},datasource_delete:function(params,promise_queue_id){var SESSION_ID=params.session_id;var _session=SESSION_OBJ[SESSION_ID];if(DATASOURCE_INTERVALS[SESSION_ID]&&DATASOURCE_INTERVALS[SESSION_ID][params.dssession]){DATASOURCE_INTERVALS[SESSION_ID][params.dssession].clear()}delete _session.DS_GLB[params.dssession];if(show_log)console.log("DATASOURCE DELETE SESSION_ID: "+SESSION_ID,APP_OBJ[_session.app_id].app_name,params.dssession);worker_post_message({promise_queue_id:promise_queue_id,worker_id:ws_worker_id,session_id:SESSION_ID,process_pid:params.process_pid,service:params.service})},update_datasource_changes_from_client:async function(params,promise_queue_id){if(_.isEmpty(SESSION_OBJ))return;var SESSION_ID=params.session_id;var _session=SESSION_OBJ[SESSION_ID];if(!_session){_session={};_session.app_id=params.app_id;_session.dataSourceSessionGlobal=-1;_session.DS_GLB={}}if(show_log)console.log("DATASOURCE UPDATE SESSION_ID: "+SESSION_ID,APP_OBJ[_session.app_id].app_name,params.dssession);await func.datasource.update(SESSION_ID,params.datasource_changes,true);worker_post_message({promise_queue_id:promise_queue_id,params:params.dssession,worker_id:ws_worker_id,session_id:SESSION_ID,process_pid:params.process_pid,service:params.service})},return_to_data_source:function(params,promise_queue_id){var SESSION_ID=params.session_id;var _session=SESSION_OBJ[SESSION_ID];var ds=_session.DS_GLB[params.dssession];var type=params.return_to_data_source_type;var args=ds.args;if(show_log)console.log("DATASOURCE RETURN TO DATASOURCE "+params.dssession+" SESSION_ID: "+SESSION_ID,APP_OBJ[_session.app_id].app_name);_session.DS_GLB[params.dssession].v.onscreen_events_active=params.onscreen_events_active;if(params.viewEventExec_arr)_session.DS_GLB[params.dssession].viewEventExec_arr=JSON.parse(params.viewEventExec_arr);var done=function(SESSION_ID,DS){if(show_log)console.log("DATASOURCE RETURN TO DATASOURCE DONE "+DS+" SESSION_ID: "+SESSION_ID,APP_OBJ[_session.app_id].app_name);var obj=func.utils.clean_returned_datasource(SESSION_ID,DS);obj.dataSourceSessionGlobal=_session.dataSourceSessionGlobal;worker_post_message({fx_to_execute:"post_datasource",params:{ds_obj:obj,dsSessionP:params.dssession},worker_id:ws_worker_id,session_id:SESSION_ID,process_pid:params.process_pid,service:params.service})};done(SESSION_ID,params.dssession)},acknowledged_worker_with_eventChangesResults_done:function(params){var SESSION_ID=params.session_id;var _session=SESSION_OBJ[SESSION_ID];var ds=_session.DS_GLB[params.dssession];if(show_log)console.log("UPDATE CHANGE EVENT DONE TO DATASOURCE "+params.dssession+" SESSION_ID: "+SESSION_ID,APP_OBJ[_session.app_id].app_name);ds.eventChangesResults_done=true},return_from_db_query:function(params){var SESSION_ID=params.session_id;var _session=SESSION_OBJ[SESSION_ID];var id=params.id;if(show_log)console.log("RETURN FROM DB_QUERY "+params.dssession+" SESSION_ID: "+SESSION_ID,APP_OBJ[_session.app_id].app_name);debugger;var callback=func.utils.get_callback_queue(SESSION_ID,params.callback_id);if(callback)callback(params.data)},return_from_sava_data:function(params){var SESSION_ID=params.session_id;var _session=SESSION_OBJ[SESSION_ID];var id=params.id;if(show_log)console.log("RETURN FROM SAVE_DATA "+params.dssession+" SESSION_ID: "+SESSION_ID,APP_OBJ[_session.app_id].app_name);func.utils.get_callback_queue(SESSION_ID,params.callback_id)()},update_debug_info:function(params){glb.DEBUG_INFO_OBJ=params},get_dataSourceSessionGlobal:function(params){var SESSION_ID=params.session_id;SESSION_OBJ[SESSION_ID].dataSourceSessionGlobal++;let new_dataSourceSessionGlobal=SESSION_OBJ[SESSION_ID].dataSourceSessionGlobal;return{new_dataSourceSessionGlobal:new_dataSourceSessionGlobal}},create_webworker_globals:function(params){var SESSION_ID=params.session_id;SESSION_OBJ[SESSION_ID].DS_GLB[0]=params.ds_data},return_doc_from_studio:function(params){var SESSION_ID=params.session_id;function emitCustomEvent(eventName,detail){const event=new CustomEvent(eventName,{detail:detail});self.dispatchEvent(event)}emitCustomEvent("live_preview_get_obj_response_worker_"+params._id,{data:params})},return_doc_from_websocket:function(params){var SESSION_ID=params.session_id;function emitCustomEvent(eventName,detail){const event=new CustomEvent(eventName,{detail:detail});self.dispatchEvent(event)}emitCustomEvent("get_doc_obj_from_build_worker_"+params._id,{data:params})},return_dbs_data_from_websocket:function(params){var SESSION_ID=params.session_id;function emitCustomEvent(eventName,detail){const event=new CustomEvent(eventName,{detail:detail});self.dispatchEvent(event)}emitCustomEvent("get_ws_data_worker_"+params.websocket_queue_num,{data:params.data})},heartbeat:async function(params){var SESSION_ID=params.session_id;try{const do_heartbeat=async function(app_replicate,app_id,token_id,fingerprint,device_name,stat){try{module.exports.close_expired_device_log_sessions(app_id);return await update_device(app_replicate,app_id,token_id,fingerprint,device_name,stat)}catch(err){return{code:-400,data:err.message}}};let ret=await do_heartbeat(params.app_replicate,params.app_id,params.gtp_token||req.body.app_token,params.fingerprint,params.device_name,params.stat);if(params.token){try{const couch=await __.rpi.get_app_couch(req.body.app_id);const session_doc=await couch.get(req.body.app_token);ret.session_stat=session_doc.stat}catch(error){}}}catch(error){debugger}},return_rpi_request_from_studio:function(params){var SESSION_ID=params.session_id;function emitCustomEvent(eventName,detail){const event=new CustomEvent(eventName,{detail:detail});self.dispatchEvent(event)}emitCustomEvent("rpi_request_response_worker_"+params.table_id,{data:params.data})}};func.utils.set_callback_queue=function(SESSION_ID,func){var t=(new Date).valueOf().toString()+Math.random().toString();try{WEB_WORKER_CALLBACK_QUEUE[SESSION_ID][t]=func}catch(e){console.error(id);func.utils.remove_cached_objects(SESSION_ID)}return t};func.utils.get_callback_queue=function(SESSION_ID,t){var func=WEB_WORKER_CALLBACK_QUEUE[SESSION_ID][t];setTimeout(function(){if(WEB_WORKER_CALLBACK_QUEUE[SESSION_ID][t])delete WEB_WORKER_CALLBACK_QUEUE[SESSION_ID][t]},1e3);return func};func.utils.clean_stringify_null=function(key,value){if(value===null){return undefined}return value};func.utils.load_js_on_demand=async function(js_src,type){const get_script=function(callback){function getScript(scriptUrl,callback){const script=document.createElement("script");script.src=scriptUrl;if(type)script.type=type;script.onload=callback;document.head.appendChild(script)}if(glb.IS_WORKER){callback(script);return}function isScriptLoaded(src){return GLB_JS_SCRIPTS_LOADED.includes(src)}if(isScriptLoaded(js_src)){callback(false)}else{getScript(js_src,function(response,status){callback(true);GLB_JS_SCRIPTS_LOADED.push(js_src)})}};return new Promise(resolve=>{get_script(resolve)})};func.utils.load_css_on_demand=function(css_href){function isCssLoaded(src){try{return document.querySelector('link[href="'+src+'"]')?true:false}catch(err){console.warn(`load css ${css_href} failed`);return true}}if(isCssLoaded(css_href)){return}return $("<link/>",{rel:"stylesheet",type:"text/css",href:css_href}).prependTo("head")};func.utils.remove_js_css_file=function(filename,filetype){var targetelement=filetype=="js"?"script":filetype=="css"?"link":"none";var targetattr=filetype=="js"?"src":filetype=="css"?"href":"none";var allsuspects=document.getElementsByTagName(targetelement);for(var i=allsuspects.length;i>=0;i--){if(allsuspects[i]&&allsuspects[i].getAttribute(targetattr)!=null&&allsuspects[i].getAttribute(targetattr).indexOf(filename)!=-1)allsuspects[i].parentNode.removeChild(allsuspects[i])}};func.utils.replace_studio_drive_url=function(SESSION_ID,val){var _session=SESSION_OBJ[SESSION_ID];if(!_session.is_deployment)return val;try{return val.replaceAll(`https://xuda.io/studio-drive/${APP_OBJ[_session.app_id].app_replicate}`,`https://${_session.domain}/studio-drive/${APP_OBJ[_session.app_id].app_replicate}`)}catch(err){return val}};func.utils.get_drive_url=function(SESSION_ID,val,wrap){var _session=SESSION_OBJ[SESSION_ID];function replaceFiletoURL(fileString){const _app=APP_OBJ[_session.app_id];let url=`https://${_session.domain}/workspace-drive/${_app.is_deployment?_app.app_datacenter_id:_app.app_id_reference}/`;let FILE_REPLACE_URL=`${url}${val}`;if(!_app.is_deployment){FILE_REPLACE_URL+=`?app_token=${_session.app_token}&ts=${Date.now()}`}else{FILE_REPLACE_URL+=`?ts=${_session?.opt?.app_build_id||0}`}let match=`drv_${_app.app_replicate||_session.app_id}_[0-9a-f\\-]+\\.[a-zA-Z0-9]+`;let pat=new RegExp(match,"g");let URLString=fileString.replace(pat,function(match,idx){const hasURLbefore=fileString.substring(idx-url.length,idx)===url;if(hasURLbefore){return match}return FILE_REPLACE_URL.replace("{val}",match)});return URLString}if(typeof val==="string"||typeof val==="object"){if(typeof val==="string"){if(val.includes(".")&&val.includes("drv_")&&val.length>30){var ret=replaceFiletoURL(val);if(wrap){return{value:'"'+ret+'"',changed:true}}else{return{value:ret,changed:true}}}else{return{value:val,changed:false}}}if(typeof val==="object"){try{let str=JSON.stringify(val);if(str.includes(".")&&str.includes("drv_")&&str.length>30){let new_val=replaceFiletoURL(str);return{value:new_val,changed:true}}else{return{value:val,changed:false}}}catch(err){return{value:val,changed:false}}}}else{return{value:val,changed:false}}};func.utils.debug_report=async function(SESSION_ID,sourceP,msgP,typeP,errP,objP){var _session=SESSION_OBJ[SESSION_ID];var details=[sourceP];if(errP)details.push(errP);if(objP)details.push(objP);if(!typeP||typeP==="E"){setTimeout(()=>{},1e3);console.error("XUDA","ERROR",sourceP,msgP,details);if(typeof IS_API_SERVER!=="undefined"||typeof IS_DOCKER!=="undefined"||typeof IS_PROCESS_SERVER!=="undefined"){return __.rpi.write_log(SESSION_OBJ[SESSION_ID].app_id,"error","worker","runtime",msgP,null,objP,sourceP)}if(glb.IS_WORKER){let obj={service:"write_log",data:msgP,log_type:"error",id:STUDIO_WEBSOCKET_CONNECTION_ID,uid:_session.USR_OBJ._id,source:"runtime",app_id:_session.app_id,gtp_token:_session.gtp_token,app_token:_session.app_token};return func.utils.post_back_to_client(SESSION_ID,"write_log",_session.worker_id,obj)}}if(typeP==="W")console.warn("XUDA","WARNING",msgP,details);if(typeP==="I")console.log("XUDA","INFO",msgP,details)};func.utils.request_error=function(SESSION_ID,type,e){var _session=SESSION_OBJ[SESSION_ID];console.error(type,e);if(typeof IS_PROCESS_SERVER!=="undefined")return;if(!glb.IS_WORKER){func.utils.debug_report(SESSION_ID,type,e,"E");setTimeout(function(){if(!glb.debug_js){console.warn("** reload request")}},2e3)}else{func.utils.post_back_to_client(SESSION_ID,"ajax_error",_session.worker_id,null)}};func.utils.alerts={};func.utils.alerts.invoke=async function(SESSION_ID,typeP,paramsP,sourceP,dsSessionP,msgP){try{var _session=SESSION_OBJ[SESSION_ID];if(ALERT_IS_ACTIVE)return;ALERT_IS_ACTIVE=true;var title;var message="";var alert_type="console";var alertDisplay;var expRet={};var _ds=_session.DS_GLB[dsSessionP];var type="";var createLog;const get_alert_properties=async function(value,fx){var ret=value||"";if(fx){const exp_ret=await func.expression.get(SESSION_ID,fx,dsSessionP,"alert");ret=exp_ret.result}return ret};switch(typeP){case"alert":type="User defined alert";title=await get_alert_properties(paramsP.alertTitle,paramsP.alertTitleFx);alert_type=await get_alert_properties(paramsP.alertType,paramsP.alertTypeFx);message=await get_alert_properties(paramsP.alertBody,paramsP.alertBodyFx);alertDisplay=await get_alert_properties(paramsP.alertDisplay,paramsP.alertDisplayFx);createLog=paramsP.createLog;break;case"call_alert":type="User defined call alert";let prop=await func.utils.TREE_OBJ.get(SESSION_ID,paramsP.prog);if(!prop){console.log("events.execute","Missing details for alert message object: "+paramsP.prog,"W")}let ret=await func.utils.VIEWS_OBJ.get(SESSION_ID,paramsP.prog);if(ret?.alertData){title=await get_alert_properties(ret.alertData.alertTitle,ret.alertData.alertTitleFx);alert_type=await get_alert_properties(ret.alertData.alertType,ret.alertData.alertTypeFx);message=await get_alert_properties(ret.alertData.alertBody,ret.alertData.alertBodyFx);alertDisplay=await get_alert_properties(ret.alertData.alertDisplay,ret.alertData.alertDisplayFx);createLog=ret.alertData.createLog}if(!title){title=prop.menuTitle}if(!alert_type){alert_type="console"}if(!alertDisplay){alertDisplay="modal"}break;case"system_msg":{type="System alert";const sys_alerts_obj=func.utils.get_system_error_msg();if(sys_alerts_obj[paramsP]){title=sys_alerts_obj[paramsP].subject;alert_type=sys_alerts_obj[paramsP].alert_type;alertDisplay=sys_alerts_obj[paramsP].alertDisplay;expRet=await func.expression.get(SESSION_ID,sys_alerts_obj[paramsP].msg,dsSessionP,"alert");message=func.expression.remove_quotes(expRet.result);if(msgP)message=msgP;if(alert_type==="error"){if(_ds)_ds.error=title+" "+sourceP;func.utils.debug_report(SESSION_ID,sourceP,title+" "+sourceP,"E","",_ds)}}break}default:message=msgP;break}}catch(err){console.error(err);ALERT_IS_ACTIVE=false;return}if(glb.IS_WORKER){if(_session.IS_API){if(_ds){_ds.api_rendered_output=message}else{console.error(message)}return}ALERT_IS_ACTIVE=false;return func.utils.post_back_to_client(SESSION_ID,"alert",_session.worker_id,[SESSION_ID,alert_type,alertDisplay,message,title])}ALERT_IS_ACTIVE=false;func.utils.alerts.execute(SESSION_ID,alert_type,alertDisplay,message,title,type);if(createLog){func.utils.write_log(SESSION_ID,title,message,alert_type)}};func.utils.alerts.execute=function(SESSION_ID,alert_type,alertDisplay,message,title,type){if(!UI_FRAMEWORK_INSTALLED){ALERT_IS_ACTIVE=false;if(alertDisplay!=="console"){return alert(title+"\n \n"+message)}return console[alert_type==="error"?"error":"log"](alert_type,title,message)}switch(alertDisplay){case"console":console[alert_type==="success"?"log":alert_type==="warning"?"warn":alert_type](alert_type,title,message);ALERT_IS_ACTIVE=false;break;case"modal":func.utils.alerts.popup(title,message,alert_type);break;case"toast":func.utils.alerts.toast(SESSION_ID,title,message,alert_type);ALERT_IS_ACTIVE=false;break;case"browser":alert(title+"\n \n"+message);ALERT_IS_ACTIVE=false;default:console.log(alert_type,title,message);ALERT_IS_ACTIVE=false}};func.utils.alerts.toast=function(SESSION_ID,title,message,alert_type){if(!UI_FRAMEWORK_PLUGIN.toast)return;const toast=new UI_FRAMEWORK_PLUGIN.toast;toast.create(alert_type,message,title,func.common.get_url(SESSION_ID,"dist",`runtime/images/${alert_type}_alert_ico.svg`));ALERT_IS_ACTIVE=false};func.utils.alerts.popup=function(title,message,alert_type){const popup=new UI_FRAMEWORK_PLUGIN.popup;var buttons=[{text:"Ok",role:"cancel",handler:()=>{ALERT_IS_ACTIVE=false}}];popup.create(_.upperFirst(alert_type),title,message,buttons)};func.utils.get_system_error_msg=function(){var m={};m["SYS_MSG_0101"]={alert_type:"success",alertDisplay:"toast",subject:"Save Success",msg:"Settings successfully saved"};m["SYS_MSG_0102"]={alert_type:"error",alertDisplay:"toast",subject:"Save Failed CouchDB",msg:"Data fail save to database"};m["SYS_MSG_0103"]={alert_type:"error",alertDisplay:"toast",subject:"Save Failed Table Empty",msg:"Table empty, no fields declared"};m["SYS_MSG_0104"]={alert_type:"error",alertDisplay:"toast",subject:"Save Failed Missing Primary Index",msg:"Update failed, table missing Primary index"};m["SYS_MSG_0105"]={alert_type:"error",alertDisplay:"toast",subject:"Save Failed Table Missing",msg:"Table repository missing"};m["SYS_MSG_0106"]={alert_type:"error",alertDisplay:"toast",subject:"Save Failed Record Not Exist",msg:"Save update failed record not exist"};m["SYS_MSG_0107"]={alert_type:"error",alertDisplay:"modal",subject:"Save Failed Unique Key",msg:"Save Failed, record already exist"};m["SYS_MSG_0108"]={alert_type:"error",alertDisplay:"modal",subject:"Error reading document",msg:"Save Failed, record not found"};m["SYS_MSG_0110"]={alert_type:"warning",alertDisplay:"toast",subject:"Record Changed",msg:"Record changed by other user, reload to get the latest changes"};m["SYS_MSG_0120"]={alert_type:"error",alertDisplay:"modal",subject:"Create Mode Denied",msg:"Create mode not allowed for this program"};m["SYS_MSG_0122"]={alert_type:"error",alertDisplay:"modal",subject:"Modify Mode Denied",msg:"Modify mode not allowed for this program"};m["SYS_MSG_0124"]={alert_type:"error",alertDisplay:"modal",subject:"Delete Mode Denied",msg:"Delete mode not allowed for this program"};m["SYS_MSG_0126"]={alert_type:"error",alertDisplay:"modal",subject:"Program Read Only",msg:"Program set to Read Only"};m["SYS_MSG_0130"]={alert_type:"error",alertDisplay:"modal",subject:"Error Reduce",msg:"Select Index to Reduce"};m["SYS_MSG_0201"]={alert_type:"error",alertDisplay:"toast",subject:"Failed to change GUI Property",msg:"Failed to change GUI element property, GUI element missing"};m["SYS_MSG_0310"]={alert_type:"error",alertDisplay:"toast",subject:"Missing Reference Parameters Out",msg:"Parameter out not exist in dataset"};m["SYS_MSG_0400"]={alert_type:"error",alertDisplay:"modal",subject:"Delete Widget Folder Denied",msg:"The selected folder contains data, Please clean or move content to another folder"};m["SYS_MSG_0410"]={alert_type:"error",alertDisplay:"toast",subject:"Recipient Error",msg:"Check recipient data"};m["SYS_MSG_0412"]={alert_type:"error",alertDisplay:"modal",subject:"Recipient Empty",msg:"No recipients entered or selected"};m["SYS_MSG_0414"]={alert_type:"error",alertDisplay:"modal",subject:"Data Save Error",msg:"Widget has no content"};m["SYS_MSG_0416"]={alert_type:"error",alertDisplay:"modal",subject:"Required Field",msg:"Edit url field is empty"};m["SYS_MSG_0418"]={alert_type:"error",alertDisplay:"modal",subject:"Required Field",msg:"Publish url field is empty"};m["SYS_MSG_0420"]={alert_type:"error",alertDisplay:"modal",subject:"Connection Error",msg:"Cannot connect to mailbox"};m["SYS_MSG_0422"]={alert_type:"success",alertDisplay:"modal",subject:"Connection Ok",msg:"Connection Ok :)"};m["SYS_MSG_0424"]={alert_type:"error",alertDisplay:"modal",subject:"Connection Failed",msg:"Connection to POP3 failed"};m["SYS_MSG_0426"]={alert_type:"error",alertDisplay:"modal",subject:"Connection Failed",msg:"SMTP Connection error, Test Email was not sent"};m["SYS_MSG_0430"]={alert_type:"error",alertDisplay:"toast",subject:"Email Account Error",msg:"No email account found, Right Click Tree -> Settings->Manage Accounts -> Right click for menu options"};m["SYS_MSG_0440"]={alert_type:"error",alertDisplay:"modal",subject:"Widget Initiation Error",msg:"Missing information for Link Type or Link Name"};m["SYS_MSG_0442"]={alert_type:"error",alertDisplay:"modal",subject:"Error Init Widget",msg:"Missing record Id on Create Mode"};m["SYS_MSG_0450"]={alert_type:"error",alertDisplay:"modal",subject:"Validation Failed",msg:"Fix fields highlight in Red"};m["SYS_MSG_0501"]={alert_type:"error",alertDisplay:"modal",subject:"Mandatory Alert Save",msg:"Save action failed, Mandatory fields missing"};m["SYS_MSG_0550"]={alert_type:"error",alertDisplay:"toast",subject:"Illegal input number",msg:"@SYS_GLOBAL_OBJ_ACTIVE_FIELD_INFO.nameform +' only allow numbers!'"};m["SYS_MSG_0610"]={alert_type:"error",alertDisplay:"toast",subject:"Form Field Conflict",msg:"Field declared more than once for the form"};m["SYS_MSG_0612"]={alert_type:"error",alertDisplay:"toast",subject:"Mask Error - Missing Definition",msg:"Missing mask definition"};m["SYS_MSG_0614"]={alert_type:"error",alertDisplay:"toast",subject:"Mask Error - Wrong Definition",msg:"Wrong mask definition"};m["SYS_MSG_0616"]={alert_type:"error",alertDisplay:"toast",subject:"Mask Error - Size Parser",msg:"Size parser error"};m["SYS_MSG_0618"]={alert_type:"error",alertDisplay:"toast",subject:"Mask Error - Illegal Z switch",msg:"Illegal 'Z' in string mask"};m["SYS_MSG_0620"]={alert_type:"error",alertDisplay:"toast",subject:"Mask Error - Illegal N switch",msg:"Illegal 'N' in string mask"};m["SYS_MSG_0622"]={alert_type:"error",alertDisplay:"toast",subject:"Mask Error - Illegal + switch",msg:"Illegal '+' in string mask"};m["SYS_MSG_0624"]={alert_type:"error",alertDisplay:"toast",subject:"Mask Error - Illegal - switch",msg:"Illegal '-' in string mask"};m["SYS_MSG_0626"]={alert_type:"error",alertDisplay:"toast",subject:"Mask Error - Illegal C switch",msg:"Illegal 'C' in string mask"};m["SYS_MSG_0628"]={alert_type:"error",alertDisplay:"toast",subject:"Mask Error - Invalid switch",msg:"Invalid switch in string mask"};m["SYS_MSG_0630"]={alert_type:"error",alertDisplay:"toast",subject:"Mask Error - Missing DOM Element",msg:"Missing DOM element"};m["SYS_MSG_0632"]={alert_type:"error",alertDisplay:"toast",subject:"Mask Error - Too Big",msg:"Size to big, max: 15.5"};m["SYS_MSG_0700"]={alert_type:"warning",alertDisplay:"console",subject:"Table Warning - Empty",msg:"Table has no content"};m["SYS_MSG_0702"]={alert_type:"error",alertDisplay:"console",subject:"Table Error - No Fields",msg:"Table missing fields content"};m["SYS_MSG_0704"]={alert_type:"warning",alertDisplay:"console",subject:"Table Warning - Not In Use",msg:"Table not in use by any object"};m["SYS_MSG_0706"]={alert_type:"error",alertDisplay:"console",subject:"Table Error - No Primary Index",msg:"Table must have at least one index"};m["SYS_MSG_0708"]={alert_type:"error",alertDisplay:"console",subject:"Table Error - Bad Index Name",msg:"Index name is invalid or cannot contain any of non word characters"};m["SYS_MSG_0710"]={alert_type:"error",alertDisplay:"console",subject:"Table Error - Empty Index",msg:"Index has no keys"};m["SYS_MSG_0712"]={alert_type:"error",alertDisplay:"console",subject:"Table Error - Key Not Exist",msg:"Key not exist in the table fields repository"};m["SYS_MSG_0714"]={alert_type:"error",alertDisplay:"console",subject:"Table Error - Duplicate Fields",msg:"Duplicate fields in the table fields repository"};m["SYS_MSG_0716"]={alert_type:"error",alertDisplay:"console",subject:"Table Error - Bad Field Name",msg:"Field name is invalid or cannot contain any of non word characters"};m["SYS_MSG_0718"]={alert_type:"error",alertDisplay:"console",subject:"Table Error - Integrity Broken",msg:"Field broken from its properties, edit the field and save"};m["SYS_MSG_0720"]={alert_type:"error",alertDisplay:"console",subject:"Table Error - Model Not Exist",msg:"Model assigned to the field not exist"};m["SYS_MSG_0722"]={alert_type:"warning",alertDisplay:"console",subject:"Object Warning - Not In Use",msg:"Object not in use or not call by any object"};m["SYS_MSG_0724"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Table Not Exist",msg:"Table assigned in object datasource not exist"};m["SYS_MSG_0726"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Index Keys Mismatch",msg:"Table index has different structure"};m["SYS_MSG_0728"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Index Key From Empty",msg:"Index key From must have a value"};m["SYS_MSG_0730"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Index Key From Reference",msg:"Field reference not exist in any dataset or parameters"};m["SYS_MSG_0732"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Index Key To Empty",msg:"Index key To must have a value"};m["SYS_MSG_0734"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Index Key To Reference",msg:"Field reference not exist in any dataset or parameters"};m["SYS_MSG_0736"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Index Locate From Reference",msg:"Field reference not exist in any dataset or parameters"};m["SYS_MSG_0738"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Index Locate To Reference",msg:"Field reference not exist in any dataset or parameters"};m["SYS_MSG_0740"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Index Empty",msg:"Index empty - no keys defined"};m["SYS_MSG_0742"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Index Reference",msg:"Table index reference error"};m["SYS_MSG_0744"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Duplicate Fields",msg:"Duplicate fields in the dataset fields repository"};m["SYS_MSG_0746"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Field reference error",msg:"Field not exist in datasource table fields repository"};m["SYS_MSG_0748"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Mismatch Reference Type",msg:"Mismatch in calling reference type"};m["SYS_MSG_0750"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Reference Broken",msg:"Reference broken calling object not exist"};m["SYS_MSG_0752"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Empty Reference",msg:"Reference empty"};m["SYS_MSG_0754"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Action Not Exist",msg:"Action not exist"};m["SYS_MSG_0756"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Empty Event Reference",msg:"Empty event reference"};m["SYS_MSG_0758"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Bad Field Name",msg:"Field name is invalid or cannot contain any of non word characters"};m["SYS_MSG_0760"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Integrity Broken",msg:"Field broken from its properties, edit the object and save"};m["SYS_MSG_0762"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Model Not Exist",msg:"Model assigned to the field not exist"};m["SYS_MSG_0764"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Empty Dataset",msg:"Dataset empty from fields"};m["SYS_MSG_0766"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Field Type Mismatch",msg:"Field type not match to the underlined table field definition"};m["SYS_MSG_0768"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Field Mask Mismatch",msg:"Field masks not match to the underlined table field definition"};m["SYS_MSG_0770"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Bad Event Name",msg:"Event name is invalid or cannot contain any of non word characters"};m["SYS_MSG_0772"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - UI Field Not Exist",msg:"UI Field not exist in the dataset repository"};m["SYS_MSG_0774"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - UI Field Reference Broken",msg:"UI Field reference broken"};m["SYS_MSG_0780"]={alert_type:"error",alertDisplay:"toast",subject:"UI element error",msg:"UI element not exist"};m["SYS_MSG_1210"]={alert_type:"error",alertDisplay:"modal",subject:"Program error",msg:"Program not exist"};m["SYS_MSG_1220"]={alert_type:"error",alertDisplay:"modal",subject:"Program error",msg:"Non grid output defined"};m["SYS_MSG_1240"]={alert_type:"error",alertDisplay:"toast",subject:"Debug error",msg:""};m["SYS_MSG_1250"]={alert_type:"error",alertDisplay:"toast",subject:"Debug log error",msg:""};m["SYS_MSG_1260"]={alert_type:"error",alertDisplay:"toast",subject:"Session Expired",msg:"Renew token session in Studio"};return m};func.utils.find_key_in_ViewUITreeObj=function(arr,key,val){return arr.reduce((a,item)=>{if(a)return a;if(item[key]===val)return item;if(item.children)return findId(val,item.children)},null)};func.utils.get_plugin_setup=function(SESSION_ID,plugin_name){const report_error=function(descP,warn){func.utils.debug.log(SESSION_ID,plugin_name,{module:"plugin",action:"Init",source:"get_plugin_setup",prop:descP,details:descP,result:null,error:warn?false:true,fields:null,type:"plugin"})};return new Promise(async(resolve,reject)=>{try{const db=await func.utils.connect_pouchdb(SESSION_ID);try{let ret=await db.get(`cache_plugin_setup_${plugin_name}`);return resolve(ret.data)}catch(err){const json=await func.common.db(SESSION_ID,"get_plugin_setup",{plugin_name:plugin_name});if(json.code<0){report_error("Error: "+json.data,json.error_type==="W"?true:false)}resolve(json);var doc={_id:`cache_plugin_setup_${plugin_name}`,data:json,docType:"cache_plugin"};db.put(doc)}}catch(e){console.error(e);report_error("Error: "+e.msg,e.error_type==="W"?true:false);resolve(e.msg)}})};func.utils.connect_pouchdb=async function(SESSION_ID){const app_id=SESSION_OBJ[SESSION_ID].app_id;return new PouchDB("xuda_rt_"+app_id)};func.utils.call_plugin_api=function(SESSION_ID,plugin_nameP,dataP){var _session=SESSION_OBJ[SESSION_ID];const report_error=function(descP,warn){func.utils.debug.log(SESSION_ID,plugin_nameP,{module:"plugin",action:"Init",source:"call_plugin_api",prop:descP,details:descP,result:null,error:warn?false:true,fields:null,type:"plugin"})};return new Promise(async resolve=>{var data={app_id:APP_OBJ[_session.app_id]._id,debug:glb.DEBUG_MODE,uid:_session.USR_OBJ._id,gtp_token:_session.gtp_token,app_token:_session.app_token};data=_.assignIn(data,dataP);fetch(`https://xuda.io/ppi/${plugin_nameP}`,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(data)}).then(response=>{if(!response.ok){return response.text().then(text=>{throw new Error(text)})}return response.json()}).then(json=>{if(json.code<0){report_error("Error: "+json.data,json.error_type==="W"?true:false)}resolve(json.data)}).catch(err=>{report_error("Error: "+err.message);resolve(err.message)})})};func.utils.get_plugin_resource=function(SESSION_ID,plugin_name,plugin_resource){var _session=SESSION_OBJ[SESSION_ID];const get_path=function(resource){if(_session.worker_type==="Dev"){return`../../plugins/${plugin_name}/${resource}`}if(typeof IS_PROCESS_SERVER!=="undefined"){return`${_conf.plugins_drive_path}/${_session.app_id}/node_modules/${plugin_name}/${resource}`}else{return`https://${_session.domain}/plugins/${plugin_name}/${resource}?app_id=${_session.app_id}`}};return new Promise(async(resolve,reject)=>{try{const plugin_resource_res=await import(`${get_path(plugin_resource)}`);resolve(plugin_resource_res)}catch(err){console.error(err);reject()}})};func.utils.remove_cached_objects=async function(SESSION_ID){if(typeof IS_DOCKER!=="undefined"||typeof IS_PROCESS_SERVER!=="undefined")return;try{const db=await func.utils.connect_pouchdb(SESSION_ID);let opt={$or:[{docType:"cache_objects"},{docType:"cache_plugin"},{docType:"cache_app"}]};const res=await db.find({selector:opt});for await(let val of res.docs){await db.remove(val)}}catch(err){return}};func.utils.get_plugin_npm_cdn=async function(SESSION_ID,plugin_name,resource){const _session=SESSION_OBJ[SESSION_ID];const get_path=function(resource){if(_session.worker_type==="Dev"){return`../../plugins/${plugin_name}/${resource}`}return`https://${_session.domain}/plugins/${plugin_name}/${resource}?app_id=${_session.app_id}`};return get_path(resource)};func.utils.write_log=async function(SESSION_ID,method="",msg="",log_type="error",source="runtime",details){const _session=SESSION_OBJ[SESSION_ID];if(typeof IS_API_SERVER!=="undefined"||typeof IS_DOCKER!=="undefined"||typeof IS_PROCESS_SERVER!=="undefined"){return __.rpi.write_log(_session.app_id,log_type,source,msg,details)}await func.common.db(SESSION_ID,"write_log",{msg:msg,log_type:log_type,source:source,details:details,method:method})};func.utils.get_resource_filename=function(build,filename){if(build){return filename.replace(/(\.\w+)$/,`.${build}$1`)}return filename};func.utils.set_SYS_GLOBAL_OBJ_WIDGET_INFO=async function(SESSION_ID,docP){var obj=_.clone(docP);obj.date=await func.utils.get_dateTime(SESSION_ID,"SYS_DATE",docP.date);obj.time=await func.utils.get_dateTime(SESSION_ID,"SYS_TIME",docP.date);var datasource_changes={[0]:{["data_system"]:{["SYS_GLOBAL_OBJ_WIDGET_INFO"]:obj}}};await func.datasource.update(SESSION_ID,datasource_changes)};func.utils.get_last_datasource_no=function(SESSION_ID){if(typeof IS_PROCESS_SERVER!=="undefined"){return Object.keys(SESSION_OBJ[SESSION_ID].DS_GLB).at?.(-1)}else{const filtered=Object.values(SESSION_OBJ[SESSION_ID].DS_GLB).filter(e=>e.tree_obj.menuType!=="api");return filtered?.at?.(-1)?.dsSession}};
1
+ glb.DEBUG_INFO_OBJ={};glb.APP_INFO={};var SYSTEM_READY=null;var GLB_JS_SCRIPTS_LOADED=[];var STUDIO_WEBSOCKET=null;var STUDIO_WEBSOCKET_CONNECTION_ID=null;var STUDIO_PEER=null;var STUDIO_PEER_CONN_SEND_METHOD=null;var STUDIO_PEER_CONN_ID=null;var SUPPORT_PEER=null;var SUPPORT_PEER_CONN=null;var STUDIO_PEER_CONN_MSG_QUEUE=[];var CLIENT_ACTIVITY_TS;glb.REFERENCE_LESS_FUNCTIONS=["update","raise_event","call_library","invoke_action","loader_on","loader_off","emit_event","delay","execute_evaluate_javascript","execute_native_javascript"];var CACHE_PROG_UI={};var ALERT_IS_ACTIVE=false;glb.WORKER_ATTEMPTS_NOT_RESPONDING=2e5;glb.WORKER_TIMEOUT=6e5;glb.WORKER_PAUSE=false;var DATASOURCE_INTERVALS={};var APP_MODAL_OBJ={};var CURRENT_APP_POPOVER=null;var ELEMENT_CLICK_EVENT=null;var posX=0;var posY=0;var LOADER_ACTIVE=false;var LOADER_TEXT="";var REFRESHER_IN_PROGRESS=false;glb.screen_num=0;var RESPONSE_FROM_STUDIO_QUEUE={};var SCREEN_BLOCKER_OBJ={};var IS_PROGRESS_SCREEN_OPEN=null;var UI_WORKER_OBJ={jobs:[],num:9e3,cache:{},viewport_height_set_ids:[]};glb.html5_events_handler=["onabort","onafterprint","onautocomplete","onautocompleteerror","onbeforeprint","onbeforeunload","onblur","oncancel","oncanplay","oncanplaythrough","onchange","onclick","onclose","oncontextmenu","oncopy","oncuechange","oncut","ondblclick","ondrag","ondragend","ondragenter","ondragexit","ondragleave","ondragover","ondragstart","ondrop","ondurationchange","onemptied","onended","onerror","onfocus","onhashchange","oninput","oninvalid","onkeydown","onkeypress","onkeyup","onload","onloadeddata","onloadedmetadata","onloadstart","onmessage","onmousedown","onmouseenter","onmouseleave","onmousemove","onmouseout","onmouseover","onmouseup","onmousewheel","onoffline","ononline","onpagehide","onpageshow","onpaste","onpause","onplay","onplaying","onpopstate","onprogress","onratechange","onreset","onresize","onscroll","onsearch","onseeked","onseeking","onselect","onshow","onsort","onstalled","onstorage","onsubmit","onsuspend","ontimeupdate","ontoggle","onunload","onvolumechange","onwaiting"];glb.lifecycle={plugins:{},fn_arr:["beforeInit","initialized","systemReady","beforeMounted","mounted"],execute:async function(SESSION_ID,event){const _session=SESSION_OBJ[SESSION_ID];const xu_api=await func.common.get_module(SESSION_ID,"xuda-api-library.mjs",{func:func,glb:glb,SESSION_OBJ:SESSION_OBJ,SESSION_ID:SESSION_ID,APP_OBJ:APP_OBJ,dsSession:func.utils.get_last_datasource_no(SESSION_ID)});var params={SESSION_ID:SESSION_ID,session_data:_session,app_obj:APP_OBJ[_session.app_id],xu_api:xu_api};for await(const[plugin_name,val]of Object.entries(glb.lifecycle.plugins)){if(val?.plugin_script?.[event]){params.setup_data=val.setup_data;await val.plugin_script[event](params)}}}};glb.run_xu_before=["xu-cdn","xu-style","xu-render","xu-for-key","xu-for-val"];glb.run_xu_after=["xu-bind","xu-class","xu-script","xu-ui-plugin"];glb.attr_abbreviations_arr=["xu-click","xu-dblclick","xu-contextmenu","xu-focus","xu-keyup","xu-change","xu-blur","xu-init"];glb.solid_attributes=["disabled"];func.utils={};func.utils.debug={};func.utils.debug.watch=async function(SESSION_ID,key,type,info,result,condition,not_executed){if(!glb.DEBUG_MODE)return;const debug_utils=await func.common.get_module(SESSION_ID,"xuda-debug-utils-module.mjs");debug_utils.watch(SESSION_ID,key,type,info,result,condition,not_executed)};func.utils.debug.log=async function(SESSION_ID,node_idP,jsonP){if(typeof IS_PROCESS_SERVER!=="undefined")return;if(!glb.DEBUG_MODE&&!glb.TRACE_ON)return;const debug_utils=await func.common.get_module(SESSION_ID,"xuda-debug-utils-module.mjs");debug_utils.log(SESSION_ID,node_idP,jsonP)};func.utils.debug.write=async function(SESSION_ID,logP,callbackP){if(!glb.DEBUG_MODE)return;const debug_utils=await func.common.get_module(SESSION_ID,"xuda-debug-utils-module.mjs");debug_utils.write(SESSION_ID,logP,callbackP)};func.utils.debug.read_command=async function(data){if(!glb.DEBUG_MODE)return;const debug_utils=await func.common.get_module(SESSION_ID,"xuda-debug-utils-module.mjs");debug_utils.read_command(data)};func.utils.DOCS_OBJ={};func.utils.DOCS_OBJ.get=async function(SESSION_ID,idP){if(!idP||idP==="0")return;var _session=SESSION_OBJ[SESSION_ID];const _app_id=_session.app_id;if(!DOCS_OBJ[_app_id]){DOCS_OBJ[_app_id]={}}if(DOCS_OBJ[_app_id][idP]){return DOCS_OBJ[_app_id][idP]}if(_session.project_data){if(idP==="system"){if(_session.project_data.globals){DOCS_OBJ[_app_id][idP]=_session.project_data.globals}else{DOCS_OBJ[_app_id][idP]={}}return DOCS_OBJ[_app_id][idP]}let val=_session.project_data?.programs?.[idP];if(val){return DOCS_OBJ[_app_id][idP]=val}}if(typeof _session.SLIM_BUNDLE==="undefined"||!_session.SLIM_BUNDLE){const module=await func.common.get_module(SESSION_ID,`xuda-progs-loader-module.mjs`);if(idP!=="system"){DOCS_OBJ[_app_id][idP]=await module.DOCS_OBJ_get(SESSION_ID,idP);if(DOCS_OBJ[_app_id][idP]&&_.isEmpty(DOCS_OBJ[_app_id][idP])){await func.utils.remove_cached_objects(SESSION_ID);delete DOCS_OBJ[_app_id][idP]}return DOCS_OBJ[_app_id][idP]}DOCS_OBJ[_app_id][idP]=await module.DOCS_OBJ_get(SESSION_ID,"global_"+(APP_OBJ[_app_id].app_replicate||_app_id));if(APP_OBJ[_app_id].app_imported_projects){for await(const imported_app_id of APP_OBJ[_app_id].app_imported_projects){var view_ret=await module.DOCS_OBJ_get(SESSION_ID,"global_"+imported_app_id);DOCS_OBJ[_app_id][idP]=_.merge(DOCS_OBJ[_app_id][idP],view_ret)}}return DOCS_OBJ[_app_id][idP]}console.error(`${idP} not found`)};func.utils.FILES_OBJ={};func.utils.FILES_OBJ.get=async function(SESSION_ID,idP){if(!idP)return;return await func.utils.DOCS_OBJ.get(SESSION_ID,idP)};func.utils.VIEWS_OBJ={};func.utils.VIEWS_OBJ.get=async function(SESSION_ID,idP){if(!idP)return;return await func.utils.DOCS_OBJ.get(SESSION_ID,idP)};func.utils.TREE_OBJ={};func.utils.TREE_OBJ.get=async function(SESSION_ID,idP){if(!idP)return;var ret=await func.utils.DOCS_OBJ.get(SESSION_ID,idP);if(ret?.properties){ret.properties.id=idP}return ret.properties};func.utils.get_dateTime=async function(SESSION_ID,typeP,dateP){const get_server_ts=async function(){var _session=SESSION_OBJ[SESSION_ID];const response=await fetch(`https://${_session.domain}/cpi/get_utc_ts`,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify({})});const json=await response.json();return json.data};function getWeekNumber(d){d=new Date(+d);d.setHours(0,0,0);d.setDate(d.getDate()+4-(d.getDay()||7));var yearStart=new Date(d.getFullYear(),0,1);var weekNo=Math.ceil(((d-yearStart)/864e5+1)/7);return weekNo}var sysDate=new Date(dateP);if(!dateP){let ts=await get_server_ts();sysDate=new Date(ts)}var day=_.padStart(sysDate.getDate(),2,"0");var month=_.padStart(sysDate.getMonth()+1,2,"0");var year=sysDate.getFullYear();var week=_.padStart(getWeekNumber(sysDate),2,"0");var hour=_.padStart(sysDate.getHours(),2,"0");var minute=_.padStart(sysDate.getMinutes(),2,"0");var second=_.padStart(sysDate.getSeconds(),2,"0");if(typeP==="SYS_DATE")return year+"-"+month+"-"+day;if(typeP==="SYS_DATE_TIME")return year+"-"+month+"-"+day+"T"+hour+":"+minute;if(typeP==="SYS_DATE_VALUE")return sysDate.valueOf();if(typeP==="SYS_DATE_WEEK_YEAR")return year+"W"+week;if(typeP==="SYS_DATE_MONTH_YEAR")return year+"-"+month;if(typeP==="SYS_TIME")return hour+":"+minute+":"+second;if(typeP==="SYS_TIME_SHORT")return hour+":"+minute};func.utils.is_onscreen_event=function(functionP){const arr=["invoke_action","cache_refresh","call_popover","call_modal","call_page","loader_on","loader_off","emit_event"];return arr.includes(functionP)};func.utils.get_screen_obj=async function(SESSION_ID,id){const prog_obj=await func.utils.VIEWS_OBJ.get(SESSION_ID,id);if(!prog_obj)return console.error("prog not found: "+id);if(prog_obj.properties.menuType==="screen"||prog_obj.properties.menuType==="api"||glb.FUNCTION_NODES_ARR.includes(prog_obj.properties.menuType)||glb.MOBILE_ARR.includes(prog_obj.properties.menuType)){return prog_obj}return};func.utils.clean_returned_datasource=function(SESSION_ID,DS){const clean_object_functions=function(obj){for(const[key,val]of Object.entries(obj)){if(typeof val==="function"){delete obj[key]}}};var _session=SESSION_OBJ[SESSION_ID];if(!_session.DS_GLB[DS])return;var obj=_.clone(_session.DS_GLB[DS]);delete obj.screen_params;try{clean_object_functions(obj);obj=JSON.parse(JSON.stringify(obj,func.utils.clean_stringify_null,"\t"))}catch(e){console.error(e)}delete obj.pre_init_fields;delete obj.oninit_triggers_to_run;delete obj.debug;const clean_empty_objects=function(){for(const[key,val]of Object.entries(obj)){if(typeof val==="object"&&!Array.isArray(val)&&_.isEmpty(val)){delete obj[key]}}for(const[key,val]of Object.entries(obj)){if(typeof val==="object"&&Array.isArray(val)&&!val.length){delete obj[key]}}};delete obj.screenInfo;delete obj.viewEventsProp;delete obj.viewSourceDesc;delete obj.viewSourceProp;delete obj.v;clean_empty_objects();return obj};func.utils.post_back_to_client=function(SESSION_ID,service,id,data){if(typeof IS_PROCESS_SERVER!=="undefined")return;worker_post_message({fx_to_execute:service,params:data,session_id:SESSION_ID,worker_id:id})};func.utils.job_worker={};func.utils.job_worker=function(session_id){var SESSION_ID=session_id;var _session=SESSION_OBJ[SESSION_ID];var is_progressScreen_on;var is_not_responding;var attempt=0;const lock=function(dsP){if(!_session.WORKER_OBJ.jobs[_session.WORKER_OBJ.stat]||_session.WORKER_OBJ.jobs[_session.WORKER_OBJ.stat].typeP==="system_interval"||_session.WORKER_OBJ.jobs[_session.WORKER_OBJ.stat].typeP==="system event"){return}if(glb.IS_WORKER){func.utils.post_back_to_client(SESSION_ID,"screen_blocker_on",_session.worker_id,null)}else{func.UI.utils.screen_blocker(true,"Worker",dsP)}};const unlock=function(){if(glb.IS_WORKER){}else{func.UI.utils.screen_blocker(false,"Worker")}};const not_responding=function(){is_not_responding=true;func.UI.utils.progressScreen.hide("Working, Please wait..");setTimeout(function(){if(!is_not_responding)return;reset()},500)};const idle=function(){if(is_progressScreen_on){setTimeout(function(){if(!attempt&&is_progressScreen_on){is_progressScreen_on=false;is_not_responding=false;func.UI.utils.progressScreen.hide("Working, Please wait..")}else if(attempt>300&&is_not_responding){is_not_responding=false;busy()}},310)}else{if(!glb.IS_WORKER){}}};const busy=function(){if(glb.IS_WORKER)return;func.utils.debug_report(SESSION_ID,"utils.worker.busy","worker processing more then 10 second","W","",_session.WORKER_OBJ.jobs);is_progressScreen_on=true};const reset=function(){func.utils.debug_report(SESSION_ID,"utils.worker.reset","worker not responding","E","",_session.WORKER_OBJ.jobs);_session.WORKER_OBJ.jobs=[];_session.WORKER_OBJ.stat=null;$(".screen_blocker").remove()};return{_interval:null,_was_busy:null,init:async function(){var _this=this;this._interval=setInterval(async function(){var _session=SESSION_OBJ[SESSION_ID];if(!_session?.WORKER_OBJ)return;if(typeof _session.WORKER_OBJ.stat==="undefined"||_session.WORKER_OBJ.stat==="undefined"||_session.WORKER_OBJ.stat===null){unlock();if(_session.WORKER_OBJ.jobs.length){for await(const[key,val]of Object.entries(_session.WORKER_OBJ.jobs)){if(val.stat){break}if(!_session.WORKER_OBJ.jobs[Number(key)]||val.job_num===9999999){continue}if(val.dsSessionP&&!_session.DS_GLB[val.dsSessionP]){func.events.delete_job(SESSION_ID,val.job_num);break}await func.events.execute(SESSION_ID,val.job_num,val.eventIdP,val.triggerP,val.functionP,val.refIdP,val.containerP,val.elementP,val.rowP,val.evt,val.descP,val.rootScreenIdP,val.dsSessionP,null,val.typeP,null,val.event_propertiesP,val.calling_triggerP,null,val.paramsP,val.target_frame_idP,val.calling_trigger_prop,val.calling_program,val.argumentsP,val.prog_id,val.nodeId,val.parentDataSourceNo,val.$container)}_this._was_busy=true}else{if(_this._was_busy){if(glb.IS_WORKER){func.utils.post_back_to_client(SESSION_ID,"worker_busy_off",_session.worker_id,null)}else{func.UI.utils.indicator.worker.normal()}}_this._was_busy=false}attempt=0;is_not_responding=false;idle()}else{_this._was_busy=true;if(glb.IS_WORKER){func.utils.post_back_to_client(SESSION_ID,"worker_busy_on",_session.worker_id,null)}else{func.UI.utils.indicator.worker.busy()}if(glb.WORKER_PAUSE)return;attempt++;if(!is_progressScreen_on&&attempt>glb.WORKER_TIMEOUT)busy();if(!is_not_responding&&attempt>=glb.WORKER_ATTEMPTS_NOT_RESPONDING){not_responding()}var ds=null;if(_session.WORKER_OBJ.jobs[0])ds=_session.WORKER_OBJ.jobs[0].dsSessionP;lock(ds)}},1)},stop:function(){clearInterval(this._interval)}}};func.utils.base64MimeType=function(encoded){var result=null;if(typeof encoded!=="string"){return result}var mime=encoded.match(/data:([a-zA-Z0-9]+\/[a-zA-Z0-9-.+]+).*,.*/);if(mime&&mime.length){result=mime[1]}return result};func.utils.makeid=function(length){var result="";var characters="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";var charactersLength=characters.length;for(var i=0;i<length;i++){result+=characters.charAt(Math.floor(Math.random()*charactersLength))}return result};func.utils.get_device=function(){var device;try{if(window.cordova){device=window.cordova.platformId}}catch(e){console.error("error using ui element in server side request")}return device};func.utils.ws_worker={};func.utils.ws_worker.functions={init:async function(data){var SESSION_ID=data.SESSION_ID;APP_OBJ[data.app_id]=data.APP_OBJ;PROJECT_OBJ[data.app_id]=data.PROJECT_OBJ;if(["live_preview","cms"].includes(data.SESSION_INFO.engine_mode)){DOCS_OBJ[data.app_id]=data.DOCS_OBJ}else if(typeof IS_DOCKER==="undefined"&&typeof IS_PROCESS_SERVER==="undefined"){if(!DOCS_OBJ[data.app_id]){DOCS_OBJ[data.app_id]={}}}glb.APP_INFO[data.app_id]=data.APP_INFO;glb.DEBUG_MODE=data.DEBUG_MODE;glb.DEBUG_INFO_OBJ=data.DEBUG_INFO_OBJ;glb.WINDOW_LOCATION_SEARCH=data.WINDOW_LOCATION_SEARCH;glb.ROOT_ELEMENT_ATTRIBUTES=data.ROOT_ELEMENT_ATTRIBUTES;DATASOURCE_INTERVALS[SESSION_ID]={};SESSION_OBJ[SESSION_ID]=data.SESSION_INFO;var _session=SESSION_OBJ[SESSION_ID];glb.SESSION_INFO=data.SESSION_INFO;_session.engine_mode=data.engine_mode;STUDIO_WEBSOCKET_CONNECTION_ID=data.STUDIO_WEBSOCKET_CONNECTION_ID;for(let[key,val]of Object.entries(_session.DS_GLB)){if(Number(key)>_session.dataSourceSessionGlobal){_session.dataSourceSessionGlobal=Number(key)}}if(typeof _session.SLIM_BUNDLE==="undefined"||!_session.SLIM_BUNDLE){const db_adapter=await func.common.get_module(SESSION_ID,"xuda-db-adapter-module.mjs");func.db=db_adapter._db}_session.WORKER_OBJ.fx=new func.utils.job_worker(SESSION_ID);_session.WORKER_OBJ.fx.init();if(_session.app_id==="unknown"){worker_post_message({fx_to_execute:"init_done",worker_id:ws_worker_id,session_id:SESSION_ID})}else{const module=await func.common.get_module(SESSION_ID,`xuda-progs-loader-module.mjs`);await module.load_objects_cache(SESSION_ID);worker_post_message({fx_to_execute:"init_done",worker_id:ws_worker_id,session_id:SESSION_ID})}WEB_WORKER_CALLBACK_QUEUE[SESSION_ID]={}},datasource_create:async function(params,promise_queue_id){var SESSION_ID=params.session_id;var _session=SESSION_OBJ[SESSION_ID];_session.ts=(new Date).getTime();var args=params;args.SESSION_ID=SESSION_ID;if(show_log){console.log("DATASOURCE EXECUTING SESSION_ID: "+SESSION_ID,APP_OBJ[_session.app_id].app_name)}if(Number(params.dataSourceSessionGlobal)>_session.dataSourceSessionGlobal){_session.dataSourceSessionGlobal=Number(params.dataSourceSessionGlobal)}const ret=await func.datasource.prepare(args.SESSION_ID,args.prog_id,args.dataSourceNoP,args.parentDataSourceNoP,args.containerIdP,args.rowIdP,args.jobNoP,args.calling_trigger_prop,args.parameters_raw_obj,null,args.callingSourceP,args.calling_jobP,args.screen_dsP,args.is_panelP,args.parameters_obj_inP,args.static_refreshP,args.run_atP,args.worker_id);try{let _ds=_session.DS_GLB[ret.dsSessionP];if(show_log)console.log("DATASOURCE EXECUTION DONE "+ret.dsSessionP+" "+_ds?.tree_obj?.menuName||""+" SESSION_ID: "+SESSION_ID,APP_OBJ[_session.app_id].app_name);var obj=func.utils.clean_returned_datasource(SESSION_ID,ret?.dsSessionP);obj.dataSourceSessionGlobal=_session.dataSourceSessionGlobal;worker_post_message({promise_queue_id:promise_queue_id,params:obj,worker_id:ws_worker_id,session_id:SESSION_ID,process_pid:params.process_pid,service:params.service});_ds.stat="idle"}catch(error){debugger}},datasource_delete:function(params,promise_queue_id){var SESSION_ID=params.session_id;var _session=SESSION_OBJ[SESSION_ID];if(DATASOURCE_INTERVALS[SESSION_ID]&&DATASOURCE_INTERVALS[SESSION_ID][params.dssession]){DATASOURCE_INTERVALS[SESSION_ID][params.dssession].clear()}delete _session.DS_GLB[params.dssession];if(show_log)console.log("DATASOURCE DELETE SESSION_ID: "+SESSION_ID,APP_OBJ[_session.app_id].app_name,params.dssession);worker_post_message({promise_queue_id:promise_queue_id,worker_id:ws_worker_id,session_id:SESSION_ID,process_pid:params.process_pid,service:params.service})},update_datasource_changes_from_client:async function(params,promise_queue_id){if(_.isEmpty(SESSION_OBJ))return;var SESSION_ID=params.session_id;var _session=SESSION_OBJ[SESSION_ID];if(!_session){_session={};_session.app_id=params.app_id;_session.dataSourceSessionGlobal=-1;_session.DS_GLB={}}if(show_log)console.log("DATASOURCE UPDATE SESSION_ID: "+SESSION_ID,APP_OBJ[_session.app_id].app_name,params.dssession);await func.datasource.update(SESSION_ID,params.datasource_changes,true);worker_post_message({promise_queue_id:promise_queue_id,params:params.dssession,worker_id:ws_worker_id,session_id:SESSION_ID,process_pid:params.process_pid,service:params.service})},return_to_data_source:function(params,promise_queue_id){var SESSION_ID=params.session_id;var _session=SESSION_OBJ[SESSION_ID];var ds=_session.DS_GLB[params.dssession];var type=params.return_to_data_source_type;var args=ds.args;if(show_log)console.log("DATASOURCE RETURN TO DATASOURCE "+params.dssession+" SESSION_ID: "+SESSION_ID,APP_OBJ[_session.app_id].app_name);_session.DS_GLB[params.dssession].v.onscreen_events_active=params.onscreen_events_active;if(params.viewEventExec_arr)_session.DS_GLB[params.dssession].viewEventExec_arr=JSON.parse(params.viewEventExec_arr);var done=function(SESSION_ID,DS){if(show_log)console.log("DATASOURCE RETURN TO DATASOURCE DONE "+DS+" SESSION_ID: "+SESSION_ID,APP_OBJ[_session.app_id].app_name);var obj=func.utils.clean_returned_datasource(SESSION_ID,DS);obj.dataSourceSessionGlobal=_session.dataSourceSessionGlobal;worker_post_message({fx_to_execute:"post_datasource",params:{ds_obj:obj,dsSessionP:params.dssession},worker_id:ws_worker_id,session_id:SESSION_ID,process_pid:params.process_pid,service:params.service})};done(SESSION_ID,params.dssession)},acknowledged_worker_with_eventChangesResults_done:function(params){var SESSION_ID=params.session_id;var _session=SESSION_OBJ[SESSION_ID];var ds=_session.DS_GLB[params.dssession];if(show_log)console.log("UPDATE CHANGE EVENT DONE TO DATASOURCE "+params.dssession+" SESSION_ID: "+SESSION_ID,APP_OBJ[_session.app_id].app_name);ds.eventChangesResults_done=true},return_from_db_query:function(params){var SESSION_ID=params.session_id;var _session=SESSION_OBJ[SESSION_ID];var id=params.id;if(show_log)console.log("RETURN FROM DB_QUERY "+params.dssession+" SESSION_ID: "+SESSION_ID,APP_OBJ[_session.app_id].app_name);debugger;var callback=func.utils.get_callback_queue(SESSION_ID,params.callback_id);if(callback)callback(params.data)},return_from_sava_data:function(params){var SESSION_ID=params.session_id;var _session=SESSION_OBJ[SESSION_ID];var id=params.id;if(show_log)console.log("RETURN FROM SAVE_DATA "+params.dssession+" SESSION_ID: "+SESSION_ID,APP_OBJ[_session.app_id].app_name);func.utils.get_callback_queue(SESSION_ID,params.callback_id)()},update_debug_info:function(params){glb.DEBUG_INFO_OBJ=params},get_dataSourceSessionGlobal:function(params){var SESSION_ID=params.session_id;SESSION_OBJ[SESSION_ID].dataSourceSessionGlobal++;let new_dataSourceSessionGlobal=SESSION_OBJ[SESSION_ID].dataSourceSessionGlobal;return{new_dataSourceSessionGlobal:new_dataSourceSessionGlobal}},create_webworker_globals:function(params){var SESSION_ID=params.session_id;SESSION_OBJ[SESSION_ID].DS_GLB[0]=params.ds_data},return_doc_from_studio:function(params){var SESSION_ID=params.session_id;function emitCustomEvent(eventName,detail){const event=new CustomEvent(eventName,{detail:detail});self.dispatchEvent(event)}emitCustomEvent("live_preview_get_obj_response_worker_"+params._id,{data:params})},return_doc_from_websocket:function(params){var SESSION_ID=params.session_id;function emitCustomEvent(eventName,detail){const event=new CustomEvent(eventName,{detail:detail});self.dispatchEvent(event)}emitCustomEvent("get_doc_obj_from_build_worker_"+params._id,{data:params})},return_dbs_data_from_websocket:function(params){var SESSION_ID=params.session_id;function emitCustomEvent(eventName,detail){const event=new CustomEvent(eventName,{detail:detail});self.dispatchEvent(event)}emitCustomEvent("get_ws_data_worker_"+params.websocket_queue_num,{data:params.data})},heartbeat:async function(params){var SESSION_ID=params.session_id;try{const do_heartbeat=async function(app_replicate,app_id,token_id,fingerprint,device_name,stat){try{module.exports.close_expired_device_log_sessions(app_id);return await update_device(app_replicate,app_id,token_id,fingerprint,device_name,stat)}catch(err){return{code:-400,data:err.message}}};let ret=await do_heartbeat(params.app_replicate,params.app_id,params.gtp_token||req.body.app_token,params.fingerprint,params.device_name,params.stat);if(params.token){try{const couch=await __.rpi.get_app_couch(req.body.app_id);const session_doc=await couch.get(req.body.app_token);ret.session_stat=session_doc.stat}catch(error){}}}catch(error){debugger}},return_rpi_request_from_studio:function(params){var SESSION_ID=params.session_id;function emitCustomEvent(eventName,detail){const event=new CustomEvent(eventName,{detail:detail});self.dispatchEvent(event)}emitCustomEvent("rpi_request_response_worker_"+params.table_id,{data:params.data})}};func.utils.set_callback_queue=function(SESSION_ID,func){var t=(new Date).valueOf().toString()+Math.random().toString();try{WEB_WORKER_CALLBACK_QUEUE[SESSION_ID][t]=func}catch(e){console.error(id);func.utils.remove_cached_objects(SESSION_ID)}return t};func.utils.get_callback_queue=function(SESSION_ID,t){var func=WEB_WORKER_CALLBACK_QUEUE[SESSION_ID][t];setTimeout(function(){if(WEB_WORKER_CALLBACK_QUEUE[SESSION_ID][t])delete WEB_WORKER_CALLBACK_QUEUE[SESSION_ID][t]},1e3);return func};func.utils.clean_stringify_null=function(key,value){if(value===null){return undefined}return value};func.utils.load_js_on_demand=async function(js_src,type){const get_script=function(callback){function getScript(scriptUrl,callback){const script=document.createElement("script");script.src=scriptUrl;if(type)script.type=type;script.onload=callback;document.head.appendChild(script)}if(glb.IS_WORKER){callback(script);return}function isScriptLoaded(src){return GLB_JS_SCRIPTS_LOADED.includes(src)}if(isScriptLoaded(js_src)){callback(false)}else{getScript(js_src,function(response,status){callback(true);GLB_JS_SCRIPTS_LOADED.push(js_src)})}};return new Promise(resolve=>{get_script(resolve)})};func.utils.load_css_on_demand=function(css_href){function isCssLoaded(src){try{return document.querySelector('link[href="'+src+'"]')?true:false}catch(err){console.warn(`load css ${css_href} failed`);return true}}if(isCssLoaded(css_href)){return}return $("<link/>",{rel:"stylesheet",type:"text/css",href:css_href}).prependTo("head")};func.utils.remove_js_css_file=function(filename,filetype){var targetelement=filetype=="js"?"script":filetype=="css"?"link":"none";var targetattr=filetype=="js"?"src":filetype=="css"?"href":"none";var allsuspects=document.getElementsByTagName(targetelement);for(var i=allsuspects.length;i>=0;i--){if(allsuspects[i]&&allsuspects[i].getAttribute(targetattr)!=null&&allsuspects[i].getAttribute(targetattr).indexOf(filename)!=-1)allsuspects[i].parentNode.removeChild(allsuspects[i])}};func.utils.replace_studio_drive_url=function(SESSION_ID,val){var _session=SESSION_OBJ[SESSION_ID];if(!_session.is_deployment)return val;try{return val.replaceAll(`https://xuda.io/studio-drive/${APP_OBJ[_session.app_id].app_replicate}`,`https://${_session.domain}/studio-drive/${APP_OBJ[_session.app_id].app_replicate}`)}catch(err){return val}};func.utils.get_drive_url=function(SESSION_ID,val,wrap){var _session=SESSION_OBJ[SESSION_ID];function replaceFiletoURL(fileString){const _app=APP_OBJ[_session.app_id];let url=`https://${_session.domain}/workspace-drive/${_app.is_deployment?_app.app_datacenter_id:_app.app_id_reference}/`;let FILE_REPLACE_URL=`${url}${val}`;if(!_app.is_deployment){FILE_REPLACE_URL+=`?app_token=${_session.app_token}&ts=${Date.now()}`}else{FILE_REPLACE_URL+=`?ts=${_session?.opt?.app_build_id||0}`}let match=`drv_${_app.app_replicate||_session.app_id}_[0-9a-f\\-]+\\.[a-zA-Z0-9]+`;let pat=new RegExp(match,"g");let URLString=fileString.replace(pat,function(match,idx){const hasURLbefore=fileString.substring(idx-url.length,idx)===url;if(hasURLbefore){return match}return FILE_REPLACE_URL.replace("{val}",match)});return URLString}if(typeof val==="string"||typeof val==="object"){if(typeof val==="string"){if(val.includes(".")&&val.includes("drv_")&&val.length>30){var ret=replaceFiletoURL(val);if(wrap){return{value:'"'+ret+'"',changed:true}}else{return{value:ret,changed:true}}}else{return{value:val,changed:false}}}if(typeof val==="object"){try{let str=JSON.stringify(val);if(str.includes(".")&&str.includes("drv_")&&str.length>30){let new_val=replaceFiletoURL(str);return{value:new_val,changed:true}}else{return{value:val,changed:false}}}catch(err){return{value:val,changed:false}}}}else{return{value:val,changed:false}}};func.utils.debug_report=async function(SESSION_ID,sourceP,msgP,typeP,errP,objP){var _session=SESSION_OBJ[SESSION_ID];var details=[sourceP];if(errP)details.push(errP);if(objP)details.push(objP);if(!typeP||typeP==="E"){setTimeout(()=>{},1e3);console.error("XUDA","ERROR",sourceP,msgP,details);if(typeof IS_API_SERVER!=="undefined"||typeof IS_DOCKER!=="undefined"||typeof IS_PROCESS_SERVER!=="undefined"){return __.rpi.write_log(SESSION_OBJ[SESSION_ID].app_id,"error","worker","runtime",msgP,null,objP,sourceP)}if(glb.IS_WORKER){let obj={service:"write_log",data:msgP,log_type:"error",id:STUDIO_WEBSOCKET_CONNECTION_ID,uid:_session.USR_OBJ._id,source:"runtime",app_id:_session.app_id,gtp_token:_session.gtp_token,app_token:_session.app_token};return func.utils.post_back_to_client(SESSION_ID,"write_log",_session.worker_id,obj)}}if(typeP==="W")console.warn("XUDA","WARNING",msgP,details);if(typeP==="I")console.log("XUDA","INFO",msgP,details)};func.utils.request_error=function(SESSION_ID,type,e){var _session=SESSION_OBJ[SESSION_ID];console.error(type,e);if(typeof IS_PROCESS_SERVER!=="undefined")return;if(!glb.IS_WORKER){func.utils.debug_report(SESSION_ID,type,e,"E");setTimeout(function(){if(!glb.debug_js){console.warn("** reload request")}},2e3)}else{func.utils.post_back_to_client(SESSION_ID,"ajax_error",_session.worker_id,null)}};func.utils.alerts={};func.utils.alerts.invoke=async function(SESSION_ID,typeP,paramsP,sourceP,dsSessionP,msgP){try{var _session=SESSION_OBJ[SESSION_ID];if(ALERT_IS_ACTIVE)return;ALERT_IS_ACTIVE=true;var title;var message="";var alert_type="console";var alertDisplay;var expRet={};var _ds=_session.DS_GLB[dsSessionP];var type="";var createLog;const get_alert_properties=async function(value,fx){var ret=value||"";if(fx){const exp_ret=await func.expression.get(SESSION_ID,fx,dsSessionP,"alert");ret=exp_ret.result}return ret};switch(typeP){case"alert":type="User defined alert";title=await get_alert_properties(paramsP.alertTitle,paramsP.alertTitleFx);alert_type=await get_alert_properties(paramsP.alertType,paramsP.alertTypeFx);message=await get_alert_properties(paramsP.alertBody,paramsP.alertBodyFx);alertDisplay=await get_alert_properties(paramsP.alertDisplay,paramsP.alertDisplayFx);createLog=paramsP.createLog;break;case"call_alert":type="User defined call alert";let prop=await func.utils.TREE_OBJ.get(SESSION_ID,paramsP.prog);if(!prop){console.log("events.execute","Missing details for alert message object: "+paramsP.prog,"W")}let ret=await func.utils.VIEWS_OBJ.get(SESSION_ID,paramsP.prog);if(ret?.alertData){title=await get_alert_properties(ret.alertData.alertTitle,ret.alertData.alertTitleFx);alert_type=await get_alert_properties(ret.alertData.alertType,ret.alertData.alertTypeFx);message=await get_alert_properties(ret.alertData.alertBody,ret.alertData.alertBodyFx);alertDisplay=await get_alert_properties(ret.alertData.alertDisplay,ret.alertData.alertDisplayFx);createLog=ret.alertData.createLog}if(!title){title=prop.menuTitle}if(!alert_type){alert_type="console"}if(!alertDisplay){alertDisplay="modal"}break;case"system_msg":{type="System alert";const sys_alerts_obj=func.utils.get_system_error_msg();if(sys_alerts_obj[paramsP]){title=sys_alerts_obj[paramsP].subject;alert_type=sys_alerts_obj[paramsP].alert_type;alertDisplay=sys_alerts_obj[paramsP].alertDisplay;expRet=await func.expression.get(SESSION_ID,sys_alerts_obj[paramsP].msg,dsSessionP,"alert");message=func.expression.remove_quotes(expRet.result);if(msgP)message=msgP;if(alert_type==="error"){if(_ds)_ds.error=title+" "+sourceP;func.utils.debug_report(SESSION_ID,sourceP,title+" "+sourceP,"E","",_ds)}}break}default:message=msgP;break}}catch(err){console.error(err);ALERT_IS_ACTIVE=false;return}if(glb.IS_WORKER){if(_session.IS_API){if(_ds){_ds.api_rendered_output=message}else{console.error(message)}return}ALERT_IS_ACTIVE=false;return func.utils.post_back_to_client(SESSION_ID,"alert",_session.worker_id,[SESSION_ID,alert_type,alertDisplay,message,title])}ALERT_IS_ACTIVE=false;func.utils.alerts.execute(SESSION_ID,alert_type,alertDisplay,message,title,type);if(createLog){func.utils.write_log(SESSION_ID,title,message,alert_type)}};func.utils.alerts.execute=function(SESSION_ID,alert_type,alertDisplay,message,title,type){if(!UI_FRAMEWORK_INSTALLED){ALERT_IS_ACTIVE=false;if(alertDisplay!=="console"){return alert(title+"\n \n"+message)}return console[alert_type==="error"?"error":"log"](alert_type,title,message)}switch(alertDisplay){case"console":console[alert_type==="success"?"log":alert_type==="warning"?"warn":alert_type](alert_type,title,message);ALERT_IS_ACTIVE=false;break;case"modal":func.utils.alerts.popup(title,message,alert_type);break;case"toast":func.utils.alerts.toast(SESSION_ID,title,message,alert_type);ALERT_IS_ACTIVE=false;break;case"browser":alert(title+"\n \n"+message);ALERT_IS_ACTIVE=false;default:console.log(alert_type,title,message);ALERT_IS_ACTIVE=false}};func.utils.alerts.toast=function(SESSION_ID,title,message,alert_type){if(!UI_FRAMEWORK_PLUGIN.toast)return;const toast=new UI_FRAMEWORK_PLUGIN.toast;toast.create(alert_type,message,title,func.common.get_url(SESSION_ID,"dist",`runtime/images/${alert_type}_alert_ico.svg`));ALERT_IS_ACTIVE=false};func.utils.alerts.popup=function(title,message,alert_type){const popup=new UI_FRAMEWORK_PLUGIN.popup;var buttons=[{text:"Ok",role:"cancel",handler:()=>{ALERT_IS_ACTIVE=false}}];popup.create(_.upperFirst(alert_type),title,message,buttons)};func.utils.get_system_error_msg=function(){var m={};m["SYS_MSG_0101"]={alert_type:"success",alertDisplay:"toast",subject:"Save Success",msg:"Settings successfully saved"};m["SYS_MSG_0102"]={alert_type:"error",alertDisplay:"toast",subject:"Save Failed CouchDB",msg:"Data fail save to database"};m["SYS_MSG_0103"]={alert_type:"error",alertDisplay:"toast",subject:"Save Failed Table Empty",msg:"Table empty, no fields declared"};m["SYS_MSG_0104"]={alert_type:"error",alertDisplay:"toast",subject:"Save Failed Missing Primary Index",msg:"Update failed, table missing Primary index"};m["SYS_MSG_0105"]={alert_type:"error",alertDisplay:"toast",subject:"Save Failed Table Missing",msg:"Table repository missing"};m["SYS_MSG_0106"]={alert_type:"error",alertDisplay:"toast",subject:"Save Failed Record Not Exist",msg:"Save update failed record not exist"};m["SYS_MSG_0107"]={alert_type:"error",alertDisplay:"modal",subject:"Save Failed Unique Key",msg:"Save Failed, record already exist"};m["SYS_MSG_0108"]={alert_type:"error",alertDisplay:"modal",subject:"Error reading document",msg:"Save Failed, record not found"};m["SYS_MSG_0110"]={alert_type:"warning",alertDisplay:"toast",subject:"Record Changed",msg:"Record changed by other user, reload to get the latest changes"};m["SYS_MSG_0120"]={alert_type:"error",alertDisplay:"modal",subject:"Create Mode Denied",msg:"Create mode not allowed for this program"};m["SYS_MSG_0122"]={alert_type:"error",alertDisplay:"modal",subject:"Modify Mode Denied",msg:"Modify mode not allowed for this program"};m["SYS_MSG_0124"]={alert_type:"error",alertDisplay:"modal",subject:"Delete Mode Denied",msg:"Delete mode not allowed for this program"};m["SYS_MSG_0126"]={alert_type:"error",alertDisplay:"modal",subject:"Program Read Only",msg:"Program set to Read Only"};m["SYS_MSG_0130"]={alert_type:"error",alertDisplay:"modal",subject:"Error Reduce",msg:"Select Index to Reduce"};m["SYS_MSG_0201"]={alert_type:"error",alertDisplay:"toast",subject:"Failed to change GUI Property",msg:"Failed to change GUI element property, GUI element missing"};m["SYS_MSG_0310"]={alert_type:"error",alertDisplay:"toast",subject:"Missing Reference Parameters Out",msg:"Parameter out not exist in dataset"};m["SYS_MSG_0400"]={alert_type:"error",alertDisplay:"modal",subject:"Delete Widget Folder Denied",msg:"The selected folder contains data, Please clean or move content to another folder"};m["SYS_MSG_0410"]={alert_type:"error",alertDisplay:"toast",subject:"Recipient Error",msg:"Check recipient data"};m["SYS_MSG_0412"]={alert_type:"error",alertDisplay:"modal",subject:"Recipient Empty",msg:"No recipients entered or selected"};m["SYS_MSG_0414"]={alert_type:"error",alertDisplay:"modal",subject:"Data Save Error",msg:"Widget has no content"};m["SYS_MSG_0416"]={alert_type:"error",alertDisplay:"modal",subject:"Required Field",msg:"Edit url field is empty"};m["SYS_MSG_0418"]={alert_type:"error",alertDisplay:"modal",subject:"Required Field",msg:"Publish url field is empty"};m["SYS_MSG_0420"]={alert_type:"error",alertDisplay:"modal",subject:"Connection Error",msg:"Cannot connect to mailbox"};m["SYS_MSG_0422"]={alert_type:"success",alertDisplay:"modal",subject:"Connection Ok",msg:"Connection Ok :)"};m["SYS_MSG_0424"]={alert_type:"error",alertDisplay:"modal",subject:"Connection Failed",msg:"Connection to POP3 failed"};m["SYS_MSG_0426"]={alert_type:"error",alertDisplay:"modal",subject:"Connection Failed",msg:"SMTP Connection error, Test Email was not sent"};m["SYS_MSG_0430"]={alert_type:"error",alertDisplay:"toast",subject:"Email Account Error",msg:"No email account found, Right Click Tree -> Settings->Manage Accounts -> Right click for menu options"};m["SYS_MSG_0440"]={alert_type:"error",alertDisplay:"modal",subject:"Widget Initiation Error",msg:"Missing information for Link Type or Link Name"};m["SYS_MSG_0442"]={alert_type:"error",alertDisplay:"modal",subject:"Error Init Widget",msg:"Missing record Id on Create Mode"};m["SYS_MSG_0450"]={alert_type:"error",alertDisplay:"modal",subject:"Validation Failed",msg:"Fix fields highlight in Red"};m["SYS_MSG_0501"]={alert_type:"error",alertDisplay:"modal",subject:"Mandatory Alert Save",msg:"Save action failed, Mandatory fields missing"};m["SYS_MSG_0550"]={alert_type:"error",alertDisplay:"toast",subject:"Illegal input number",msg:"@SYS_GLOBAL_OBJ_ACTIVE_FIELD_INFO.nameform +' only allow numbers!'"};m["SYS_MSG_0610"]={alert_type:"error",alertDisplay:"toast",subject:"Form Field Conflict",msg:"Field declared more than once for the form"};m["SYS_MSG_0612"]={alert_type:"error",alertDisplay:"toast",subject:"Mask Error - Missing Definition",msg:"Missing mask definition"};m["SYS_MSG_0614"]={alert_type:"error",alertDisplay:"toast",subject:"Mask Error - Wrong Definition",msg:"Wrong mask definition"};m["SYS_MSG_0616"]={alert_type:"error",alertDisplay:"toast",subject:"Mask Error - Size Parser",msg:"Size parser error"};m["SYS_MSG_0618"]={alert_type:"error",alertDisplay:"toast",subject:"Mask Error - Illegal Z switch",msg:"Illegal 'Z' in string mask"};m["SYS_MSG_0620"]={alert_type:"error",alertDisplay:"toast",subject:"Mask Error - Illegal N switch",msg:"Illegal 'N' in string mask"};m["SYS_MSG_0622"]={alert_type:"error",alertDisplay:"toast",subject:"Mask Error - Illegal + switch",msg:"Illegal '+' in string mask"};m["SYS_MSG_0624"]={alert_type:"error",alertDisplay:"toast",subject:"Mask Error - Illegal - switch",msg:"Illegal '-' in string mask"};m["SYS_MSG_0626"]={alert_type:"error",alertDisplay:"toast",subject:"Mask Error - Illegal C switch",msg:"Illegal 'C' in string mask"};m["SYS_MSG_0628"]={alert_type:"error",alertDisplay:"toast",subject:"Mask Error - Invalid switch",msg:"Invalid switch in string mask"};m["SYS_MSG_0630"]={alert_type:"error",alertDisplay:"toast",subject:"Mask Error - Missing DOM Element",msg:"Missing DOM element"};m["SYS_MSG_0632"]={alert_type:"error",alertDisplay:"toast",subject:"Mask Error - Too Big",msg:"Size to big, max: 15.5"};m["SYS_MSG_0700"]={alert_type:"warning",alertDisplay:"console",subject:"Table Warning - Empty",msg:"Table has no content"};m["SYS_MSG_0702"]={alert_type:"error",alertDisplay:"console",subject:"Table Error - No Fields",msg:"Table missing fields content"};m["SYS_MSG_0704"]={alert_type:"warning",alertDisplay:"console",subject:"Table Warning - Not In Use",msg:"Table not in use by any object"};m["SYS_MSG_0706"]={alert_type:"error",alertDisplay:"console",subject:"Table Error - No Primary Index",msg:"Table must have at least one index"};m["SYS_MSG_0708"]={alert_type:"error",alertDisplay:"console",subject:"Table Error - Bad Index Name",msg:"Index name is invalid or cannot contain any of non word characters"};m["SYS_MSG_0710"]={alert_type:"error",alertDisplay:"console",subject:"Table Error - Empty Index",msg:"Index has no keys"};m["SYS_MSG_0712"]={alert_type:"error",alertDisplay:"console",subject:"Table Error - Key Not Exist",msg:"Key not exist in the table fields repository"};m["SYS_MSG_0714"]={alert_type:"error",alertDisplay:"console",subject:"Table Error - Duplicate Fields",msg:"Duplicate fields in the table fields repository"};m["SYS_MSG_0716"]={alert_type:"error",alertDisplay:"console",subject:"Table Error - Bad Field Name",msg:"Field name is invalid or cannot contain any of non word characters"};m["SYS_MSG_0718"]={alert_type:"error",alertDisplay:"console",subject:"Table Error - Integrity Broken",msg:"Field broken from its properties, edit the field and save"};m["SYS_MSG_0720"]={alert_type:"error",alertDisplay:"console",subject:"Table Error - Model Not Exist",msg:"Model assigned to the field not exist"};m["SYS_MSG_0722"]={alert_type:"warning",alertDisplay:"console",subject:"Object Warning - Not In Use",msg:"Object not in use or not call by any object"};m["SYS_MSG_0724"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Table Not Exist",msg:"Table assigned in object datasource not exist"};m["SYS_MSG_0726"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Index Keys Mismatch",msg:"Table index has different structure"};m["SYS_MSG_0728"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Index Key From Empty",msg:"Index key From must have a value"};m["SYS_MSG_0730"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Index Key From Reference",msg:"Field reference not exist in any dataset or parameters"};m["SYS_MSG_0732"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Index Key To Empty",msg:"Index key To must have a value"};m["SYS_MSG_0734"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Index Key To Reference",msg:"Field reference not exist in any dataset or parameters"};m["SYS_MSG_0736"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Index Locate From Reference",msg:"Field reference not exist in any dataset or parameters"};m["SYS_MSG_0738"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Index Locate To Reference",msg:"Field reference not exist in any dataset or parameters"};m["SYS_MSG_0740"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Index Empty",msg:"Index empty - no keys defined"};m["SYS_MSG_0742"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Index Reference",msg:"Table index reference error"};m["SYS_MSG_0744"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Duplicate Fields",msg:"Duplicate fields in the dataset fields repository"};m["SYS_MSG_0746"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Field reference error",msg:"Field not exist in datasource table fields repository"};m["SYS_MSG_0748"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Mismatch Reference Type",msg:"Mismatch in calling reference type"};m["SYS_MSG_0750"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Reference Broken",msg:"Reference broken calling object not exist"};m["SYS_MSG_0752"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Empty Reference",msg:"Reference empty"};m["SYS_MSG_0754"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Action Not Exist",msg:"Action not exist"};m["SYS_MSG_0756"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Empty Event Reference",msg:"Empty event reference"};m["SYS_MSG_0758"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Bad Field Name",msg:"Field name is invalid or cannot contain any of non word characters"};m["SYS_MSG_0760"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Integrity Broken",msg:"Field broken from its properties, edit the object and save"};m["SYS_MSG_0762"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Model Not Exist",msg:"Model assigned to the field not exist"};m["SYS_MSG_0764"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Empty Dataset",msg:"Dataset empty from fields"};m["SYS_MSG_0766"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Field Type Mismatch",msg:"Field type not match to the underlined table field definition"};m["SYS_MSG_0768"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Field Mask Mismatch",msg:"Field masks not match to the underlined table field definition"};m["SYS_MSG_0770"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - Bad Event Name",msg:"Event name is invalid or cannot contain any of non word characters"};m["SYS_MSG_0772"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - UI Field Not Exist",msg:"UI Field not exist in the dataset repository"};m["SYS_MSG_0774"]={alert_type:"error",alertDisplay:"console",subject:"Object Error - UI Field Reference Broken",msg:"UI Field reference broken"};m["SYS_MSG_0780"]={alert_type:"error",alertDisplay:"toast",subject:"UI element error",msg:"UI element not exist"};m["SYS_MSG_1210"]={alert_type:"error",alertDisplay:"modal",subject:"Program error",msg:"Program not exist"};m["SYS_MSG_1220"]={alert_type:"error",alertDisplay:"modal",subject:"Program error",msg:"Non grid output defined"};m["SYS_MSG_1240"]={alert_type:"error",alertDisplay:"toast",subject:"Debug error",msg:""};m["SYS_MSG_1250"]={alert_type:"error",alertDisplay:"toast",subject:"Debug log error",msg:""};m["SYS_MSG_1260"]={alert_type:"error",alertDisplay:"toast",subject:"Session Expired",msg:"Renew token session in Studio"};return m};func.utils.find_key_in_ViewUITreeObj=function(arr,key,val){return arr.reduce((a,item)=>{if(a)return a;if(item[key]===val)return item;if(item.children)return findId(val,item.children)},null)};func.utils.get_plugin_setup=function(SESSION_ID,plugin_name){const report_error=function(descP,warn){func.utils.debug.log(SESSION_ID,plugin_name,{module:"plugin",action:"Init",source:"get_plugin_setup",prop:descP,details:descP,result:null,error:warn?false:true,fields:null,type:"plugin"})};return new Promise(async(resolve,reject)=>{try{const db=await func.utils.connect_pouchdb(SESSION_ID);try{let ret=await db.get(`cache_plugin_setup_${plugin_name}`);return resolve(ret.data)}catch(err){const json=await func.common.db(SESSION_ID,"get_plugin_setup",{plugin_name:plugin_name});if(json.code<0){report_error("Error: "+json.data,json.error_type==="W"?true:false)}resolve(json);var doc={_id:`cache_plugin_setup_${plugin_name}`,data:json,docType:"cache_plugin"};db.put(doc)}}catch(e){console.error(e);report_error("Error: "+e.msg,e.error_type==="W"?true:false);resolve(e.msg)}})};func.utils.connect_pouchdb=async function(SESSION_ID){const app_id=SESSION_OBJ[SESSION_ID].app_id;return new PouchDB("xuda_rt_"+app_id)};func.utils.call_plugin_api=function(SESSION_ID,plugin_nameP,dataP){var _session=SESSION_OBJ[SESSION_ID];const report_error=function(descP,warn){func.utils.debug.log(SESSION_ID,plugin_nameP,{module:"plugin",action:"Init",source:"call_plugin_api",prop:descP,details:descP,result:null,error:warn?false:true,fields:null,type:"plugin"})};return new Promise(async resolve=>{var data={app_id:APP_OBJ[_session.app_id]._id,debug:glb.DEBUG_MODE,uid:_session.USR_OBJ._id,gtp_token:_session.gtp_token,app_token:_session.app_token};data=_.assignIn(data,dataP);fetch(`https://xuda.io/ppi/${plugin_nameP}`,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(data)}).then(response=>{if(!response.ok){return response.text().then(text=>{throw new Error(text)})}return response.json()}).then(json=>{if(json.code<0){report_error("Error: "+json.data,json.error_type==="W"?true:false)}resolve(json.data)}).catch(err=>{report_error("Error: "+err.message);resolve(err.message)})})};func.utils.get_plugin_resource=function(SESSION_ID,plugin_name,plugin_resource){var _session=SESSION_OBJ[SESSION_ID];const get_path=function(resource){if(_session.worker_type==="Dev"){return`../../plugins/${plugin_name}/${resource}`}if(typeof IS_PROCESS_SERVER!=="undefined"){return`${_conf.plugins_drive_path}/${_session.app_id}/node_modules/${plugin_name}/${resource}`}else{return`https://${_session.domain}/plugins/${plugin_name}/${resource}?app_id=${_session.app_id}`}};return new Promise(async(resolve,reject)=>{try{const plugin_resource_res=await import(`${get_path(plugin_resource)}`);resolve(plugin_resource_res)}catch(err){console.error(err);reject()}})};func.utils.remove_cached_objects=async function(SESSION_ID){if(typeof IS_DOCKER!=="undefined"||typeof IS_PROCESS_SERVER!=="undefined")return;try{const db=await func.utils.connect_pouchdb(SESSION_ID);let opt={$or:[{docType:"cache_objects"},{docType:"cache_plugin"},{docType:"cache_app"}]};const res=await db.find({selector:opt});for await(let val of res.docs){await db.remove(val)}}catch(err){return}};func.utils.get_plugin_npm_cdn=async function(SESSION_ID,plugin_name,resource){const _session=SESSION_OBJ[SESSION_ID];const get_path=function(resource){if(_session.worker_type==="Dev"){return`../../plugins/${plugin_name}/${resource}`}return`https://${_session.domain}/plugins/${plugin_name}/${resource}?app_id=${_session.app_id}`};return get_path(resource)};func.utils.write_log=async function(SESSION_ID,method="",msg="",log_type="error",source="runtime",details){const _session=SESSION_OBJ[SESSION_ID];if(typeof IS_API_SERVER!=="undefined"||typeof IS_DOCKER!=="undefined"||typeof IS_PROCESS_SERVER!=="undefined"){return __.rpi.write_log(_session.app_id,log_type,source,msg,details)}await func.common.db(SESSION_ID,"write_log",{msg:msg,log_type:log_type,source:source,details:details,method:method})};func.utils.get_resource_filename=function(build,filename){if(build){return filename.replace(/(\.\w+)$/,`.${build}$1`)}return filename};func.utils.set_SYS_GLOBAL_OBJ_WIDGET_INFO=async function(SESSION_ID,docP){var obj=_.clone(docP);obj.date=await func.utils.get_dateTime(SESSION_ID,"SYS_DATE",docP.date);obj.time=await func.utils.get_dateTime(SESSION_ID,"SYS_TIME",docP.date);var datasource_changes={[0]:{["data_system"]:{["SYS_GLOBAL_OBJ_WIDGET_INFO"]:obj}}};await func.datasource.update(SESSION_ID,datasource_changes)};func.utils.get_last_datasource_no=function(SESSION_ID){if(typeof IS_PROCESS_SERVER!=="undefined"){return Object.keys(SESSION_OBJ[SESSION_ID].DS_GLB).at?.(-1)}else{const filtered=Object.values(SESSION_OBJ[SESSION_ID].DS_GLB).filter(e=>e.tree_obj.menuType!=="api");return filtered?.at?.(-1)?.dsSession}};
@@ -1723,53 +1723,12 @@ glb.API_OUTPUT_ARR = ['json', 'html', 'xml', 'text', 'css', 'javascript'];
1723
1723
 
1724
1724
  const PROTECTED_NAMES_ARR = ['THIS', 'ROWID']; //tbd
1725
1725
 
1726
- // func.common.get_custom_icon = async function (
1727
- // SESSION_ID,
1728
- // menuIdP,
1729
- // fromTreeP,
1730
- // get_image_onlyP
1731
- // ) {
1732
- // var ret = "";
1733
- // var iconItemId;
1734
- // let tree_ret = await func.utils.TREE_OBJ.get(SESSION_ID, menuIdP);
1735
- // if (tree_ret) {
1736
- // if (tree_ret.menuType === "icon") {
1737
- // iconItemId = menuIdP;
1738
- // } else {
1739
- // if (tree_ret.rICN) iconItemId = tree_ret.rICN;
1740
- // }
1741
- // if (iconItemId) {
1742
- // let tree_ret2 = await func.utils.TREE_OBJ.get(SESSION_ID, iconItemId);
1743
- // if (tree_ret2) {
1744
- // if (get_image_onlyP) {
1745
- // return tree_ret2.rPTH;
1746
- // } else {
1747
- // const app_obj = APP_OBJ[SESSION_OBJ[SESSION_ID].app_id];
1748
- // const url = func.common.get_url(
1749
- // SESSION_ID,
1750
- // "studio-drive",
1751
- // `${app_obj.app_replicate ? app_obj.app_replicate : app_obj._id}/${
1752
- // tree_ret2.rPTH
1753
- // }`
1754
- // );
1755
- // return url;
1756
- // }
1757
- // // }
1758
- // } else {
1759
- // return ret;
1760
- // }
1761
- // } else {
1762
- // return ret;
1763
- // }
1764
- // } else return ret;
1765
- // };
1766
-
1767
1726
  func.common.db = async function (SESSION_ID, serviceP, dataP, opt = {}, dsSession) {
1768
1727
  return new Promise(async function (resolve, reject) {
1769
1728
  var _session = SESSION_OBJ[SESSION_ID];
1770
1729
  const app_id = _session.app_id;
1771
1730
 
1772
- if (_session.engine_mode === 'live_preview') {
1731
+ if (glb.DEBUG_MODE) {
1773
1732
  console.log('request', dataP);
1774
1733
  }
1775
1734
 
@@ -1804,7 +1763,7 @@ func.common.db = async function (SESSION_ID, serviceP, dataP, opt = {}, dsSessio
1804
1763
  });
1805
1764
  }
1806
1765
 
1807
- if (_session.engine_mode === 'live_preview') {
1766
+ if (glb.DEBUG_MODE) {
1808
1767
  console.log('response', ret);
1809
1768
  }
1810
1769
  resolve(ret, true);
@@ -2386,9 +2345,9 @@ func.common.get_module = async function (SESSION_ID, module, paramsP = {}) {
2386
2345
  }
2387
2346
  if (_session.worker_type === 'Debug') {
2388
2347
  if (typeof IS_DOCKER !== 'undefined' || typeof IS_PROCESS_SERVER !== 'undefined') {
2389
- ret = await get_ret(func.utils.get_resource_filename(SESSION_OBJ[SESSION_ID].engine_mode === 'live_preview' ? '' : SESSION_OBJ[SESSION_ID]?.opt?.app_build_id, `${_conf.xuda_home}root/dist/runtime/js/modules/` + module));
2348
+ ret = await get_ret(func.utils.get_resource_filename(['live_preview', 'cms'].includes(_session.engine_mode) ? '' : _session?.opt?.app_build_id, `${_conf.xuda_home}root/dist/runtime/js/modules/` + module));
2390
2349
  } else {
2391
- ret = await get_ret(func.common.get_url(SESSION_ID, 'dist', func.utils.get_resource_filename(SESSION_OBJ[SESSION_ID].engine_mode === 'live_preview' ? '' : SESSION_OBJ[SESSION_ID]?.opt?.app_build_id, 'runtime/js/modules/' + module)));
2350
+ ret = await get_ret(func.common.get_url(SESSION_ID, 'dist', func.utils.get_resource_filename(['live_preview', 'cms'].includes(_session.engine_mode) ? '' : _session?.opt?.app_build_id, 'runtime/js/modules/' + module)));
2392
2351
  }
2393
2352
 
2394
2353
  return ret;
@@ -2399,9 +2358,9 @@ func.common.get_module = async function (SESSION_ID, module, paramsP = {}) {
2399
2358
  };
2400
2359
 
2401
2360
  if (typeof IS_DOCKER !== 'undefined' || typeof IS_PROCESS_SERVER !== 'undefined') {
2402
- ret = await get_ret(func.utils.get_resource_filename(SESSION_OBJ[SESSION_ID].engine_mode === 'live_preview' ? '' : SESSION_OBJ[SESSION_ID]?.opt?.app_build_id, `${_conf.xuda_home}root/dist/runtime/js/modules/` + rep()));
2361
+ ret = await get_ret(func.utils.get_resource_filename(['live_preview', 'cms'].includes(_session.engine_mode) ? '' : _session?.opt?.app_build_id, `${_conf.xuda_home}root/dist/runtime/js/modules/` + rep()));
2403
2362
  } else {
2404
- ret = await get_ret(func.common.get_url(SESSION_ID, 'dist', func.utils.get_resource_filename(SESSION_OBJ[SESSION_ID].engine_mode === 'live_preview' ? '' : SESSION_OBJ[SESSION_ID]?.opt?.app_build_id, 'runtime/js/modules/' + rep())));
2363
+ ret = await get_ret(func.common.get_url(SESSION_ID, 'dist', func.utils.get_resource_filename(['live_preview', 'cms'].includes(_session.engine_mode) ? '' : _session?.opt?.app_build_id, 'runtime/js/modules/' + rep())));
2405
2364
  }
2406
2365
 
2407
2366
  return ret;
@@ -2982,7 +2941,7 @@ func.datasource.create = async function (
2982
2941
 
2983
2942
  var run_at = _prog_obj?.properties?.runAt;
2984
2943
 
2985
- if (_session.engine_mode !== 'live_preview') {
2944
+ if (!['live_preview', 'cms'].includes(_session.engine_mode)) {
2986
2945
  if (_session.opt.app_computing_mode === 'main') {
2987
2946
  run_at = 'client';
2988
2947
  }
@@ -3158,7 +3117,7 @@ func.datasource.prepare = async function (SESSION_ID, prog_id, dataSourceNoP, pa
3158
3117
 
3159
3118
  if (typeof parameters_obj_inP?.[val.data.parameter] !== 'undefined') {
3160
3119
  _ds.in_parameters[val.data.parameter].value = parameters_obj_inP[val.data.parameter];
3161
- } else if (_session.engine_mode === 'live_preview') {
3120
+ } else if (['live_preview', 'cms'].includes(_session.engine_mode)) {
3162
3121
  _ds.in_parameters[val.data.parameter].value = _session?.url_params?.[val.data.parameter];
3163
3122
  }
3164
3123
 
@@ -3180,7 +3139,7 @@ func.datasource.prepare = async function (SESSION_ID, prog_id, dataSourceNoP, pa
3180
3139
  _ds.data_system['SYS_GLOBAL_STR_SESSION_ID'] = SESSION_ID;
3181
3140
  _ds.data_system['SYS_GLOBAL_STR_LOGIN_USER_ID'] = _session.USR_OBJ._id;
3182
3141
 
3183
- if (_session.engine_mode !== 'live_preview' && PROJECT_OBJ[_session.app_id].info) {
3142
+ if (!['live_preview', 'cms'].includes(_session.engine_mode) && PROJECT_OBJ[_session.app_id].info) {
3184
3143
  _ds.data_system['SYS_GLOBAL_OBJ_APP_INFO'] = {
3185
3144
  build: PROJECT_OBJ[_session.app_id].info.build_id,
3186
3145
  author: PROJECT_OBJ[_session.app_id].info.author,
@@ -6245,7 +6204,7 @@ func.utils.ws_worker.functions = {
6245
6204
  APP_OBJ[data.app_id] = data.APP_OBJ;
6246
6205
  PROJECT_OBJ[data.app_id] = data.PROJECT_OBJ;
6247
6206
 
6248
- if (data.SESSION_INFO.engine_mode === 'live_preview') {
6207
+ if (['live_preview', 'cms'].includes(data.SESSION_INFO.engine_mode)) {
6249
6208
  DOCS_OBJ[data.app_id] = data.DOCS_OBJ;
6250
6209
  } else if (typeof IS_DOCKER === 'undefined' && typeof IS_PROCESS_SERVER === 'undefined') {
6251
6210
  if (!DOCS_OBJ[data.app_id]) {
@@ -11470,11 +11429,11 @@ func.UI.screen.refresh_xu_attributes = async function (SESSION_ID, fields_arr, j
11470
11429
  .find('*')
11471
11430
  .filter(function () {
11472
11431
  // // look if the changed field include in the calling in parameters
11473
- let parameter_in_filed_id;
11474
-
11432
+ const elm_data = $(this).data();
11433
+ const parameter_in_filed_id = elm_data?.paramsP?.parameters_raw_obj?.[val.substr(1)] ? val.substr(1) : '';
11475
11434
  let attr = [];
11476
11435
 
11477
- $.each($(this).data()?.xuAttributes, function (key, val) {
11436
+ $.each(elm_data?.xuAttributes, function (key, val) {
11478
11437
  if (key.substr(0, 3) !== 'xu-') return true;
11479
11438
 
11480
11439
  if (key === 'xu-bind') {
@@ -11691,7 +11650,7 @@ func.UI.screen.refresh_xu_attributes = async function (SESSION_ID, fields_arr, j
11691
11650
  if (avoid_xu_for_refresh) return;
11692
11651
  await func.UI.worker.add_to_queue(SESSION_ID, 'gui event', 'execute_xu_for', obj, new_job, _elem_val.$elm, _elem_val.$elm.data().xuData.paramsP.dsSessionP);
11693
11652
 
11694
- if (_session.engine_mode === 'live_preview') {
11653
+ if (glb.DEBUG_MODE) {
11695
11654
  console.info('node execute_xu_for', obj, panel_val);
11696
11655
  }
11697
11656
 
@@ -12532,7 +12491,16 @@ func.UI.screen.execute_xu_functions = async function (SESSION_ID, is_skeleton, $
12532
12491
  console.warn(e);
12533
12492
  }
12534
12493
 
12535
- return {};
12494
+ return { abort: true };
12495
+ },
12496
+ 'xu-text': async function ($elm, val) {
12497
+ try {
12498
+ $elm.text(val.value);
12499
+ } catch (error) {
12500
+ console.warn(e);
12501
+ }
12502
+
12503
+ return { abort: true };
12536
12504
  },
12537
12505
  'xu-for': async function ($elm, data) {
12538
12506
  // exit if call from rendered xu-for item to prevent infante loop (parent_infoP?.iterate_info indicate call from rendered item)
@@ -14521,6 +14489,7 @@ func.UI.screen.render_ui_tree = async function (SESSION_ID, $container, nodeP, p
14521
14489
  if (nodeP.content && nodeP.attributes) {
14522
14490
  nodeP.attributes['xu-content'] = nodeP.content;
14523
14491
  }
14492
+
14524
14493
  if (nodeP.tagName === 'xu-widget') {
14525
14494
  if (is_skeleton) return;
14526
14495
  return await fx['widget']();
@@ -15712,8 +15681,7 @@ function xuda(...args) {
15712
15681
  FIREBASE_TOKEN_ID: null,
15713
15682
 
15714
15683
  USR_OBJ: {},
15715
- // run_prog: null,
15716
- // engine_mode: null,
15684
+
15717
15685
  debug_js: null,
15718
15686
  DS_UI_EVENTS_GLB: {},
15719
15687
  host: location.host,
@@ -15740,7 +15708,7 @@ function xuda(...args) {
15740
15708
  val = window.location.host;
15741
15709
  break;
15742
15710
  case 'engine_mode':
15743
- val = 'run';
15711
+ val = 'cms'; //was 'run'
15744
15712
  break;
15745
15713
  case 'app_id':
15746
15714
  val = 'unknown';
@@ -15904,7 +15872,7 @@ function xuda(...args) {
15904
15872
  _client_info.time_zone = client.getTimeZone();
15905
15873
  _client_info.cpu_architecture = browser_data.cpu.architecture;
15906
15874
 
15907
- if ((engine_mode === 'app' || engine_mode === 'live_preview') && func.utils.get_device()) {
15875
+ if (['android', 'ios', 'windows', 'macos', 'linux', 'live_preview'].includes(engine_mode) && func.utils.get_device()) {
15908
15876
  _client_info.uuid = window.device.uuid;
15909
15877
  if (window.device) {
15910
15878
  _client_info.device_name = window.device.name;
@@ -16523,7 +16491,7 @@ func.index.new_webworker = async function (SESSION_ID, prog_obj, obj) {
16523
16491
  ver = APP_OBJ[_session.app_id].app_version;
16524
16492
  }
16525
16493
 
16526
- var build_id = _session.engine_mode === 'live_preview' ? '' : _session.opt.app_build_id;
16494
+ var build_id = ['live_preview', 'cms'].includes(_session.engine_mode) ? '' : _session.opt.app_build_id;
16527
16495
  if (typeof XUDA_BUILD_ID !== 'undefined') {
16528
16496
  build_id = XUDA_BUILD_ID;
16529
16497
  }
@@ -16629,8 +16597,8 @@ func.index.new_webworker = async function (SESSION_ID, prog_obj, obj) {
16629
16597
  const content = `importScripts( "${url}" );`;
16630
16598
  return URL.createObjectURL(new Blob([content], { type: 'text/javascript' }));
16631
16599
  }
16632
-
16633
- let blob = getWorkerURL(func.common.get_url(SESSION_ID, 'dist', func.utils.get_resource_filename(SESSION_OBJ[SESSION_ID].engine_mode === 'live_preview' ? '' : SESSION_OBJ[SESSION_ID]?.opt?.app_build_id, 'runtime/js/xuda_worker.js')));
16600
+ const _session = SESSION[SESSION_ID];
16601
+ let blob = getWorkerURL(func.common.get_url(SESSION_ID, 'dist', func.utils.get_resource_filename(['live_preview', 'cms'].includes(_session.engine_mode) ? '' : _session?.opt?.app_build_id, 'runtime/js/xuda_worker.js')));
16634
16602
  WEB_WORKER[SESSION_ID][worker_id] = {
16635
16603
  worker: new Worker(blob, {
16636
16604
  name: worker_name,