@xuda.io/runtime-bundle 1.0.1415 → 1.0.1417

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.
@@ -172,7 +172,7 @@ export const action_execute = async function (SESSION_ID, actionP, params, isScr
172
172
  act_reload: async function () {
173
173
  var _ds = SESSION_OBJ[SESSION_ID].DS_GLB[params.dsSession];
174
174
 
175
- let screen_params = klona.klona(params.screen_params);
175
+ let screen_params = structuredClone(params.screen_params);
176
176
 
177
177
  switch (params.screen_params.screen_type) {
178
178
  case 'modal':
@@ -1 +1 @@
1
- const screen_save=async function(SESSION_ID,paramsP){var str='[screenid="'+paramsP.screenId+'"]';var elm=document.getElementById(paramsP.screenId)?.querySelectorAll(str);var dsSession;if(!elm||!elm.length){return func.db.save_data(SESSION_ID,paramsP.dsSession,0)}for await(const[key,val]of Object.entries(elm)){if(key==="length"){break}if(!val){continue}dsSession=func.runtime.ui.get_data(val,"xuData").dsSession;let _ds=SESSION_OBJ[SESSION_ID].DS_GLB[dsSession];if(!dsSession||!_ds){continue}if(_ds.tree_obj.renderType==="form"){if(_ds._dataSourceTableId){if(!_ds.abort_save)await func.db.save_data(SESSION_ID,dsSession,key);_ds.abort_save=false;continue}}}};export const action_execute=async function(SESSION_ID,actionP,params,isScreenActionP,event_sourceP,jobNoP,containerP){var _ds=SESSION_OBJ[SESSION_ID].DS_GLB[params.dsSession];if(!_ds){func.events.delete_job(SESSION_ID,jobNoP);return}var action=actionP;var formGrid_dsSession;var EVENTSUFFIX="_triggered";if(!isScreenActionP)formGrid_dsSession=params.dsSession;var do_event=async function(actionP){var delete_job=async function(jobsP){await func.events.check_jobs_idle(SESSION_ID,jobsP);func.events.delete_job(SESSION_ID,jobNoP)};const jobsP=await func.events.validate(SESSION_ID,actionP+EVENTSUFFIX,params.dsSession,null,"action");await delete_job(jobsP)};const fx={act_next:async function(){await locate_record(SESSION_ID,"next",params.dsSession);if(_ds.tree_obj.renderType==="form"){func.runtime.platform.emit("xu-bind-refresh."+params.dsSession.toString())}},act_prev:async function(){await locate_record(SESSION_ID,"prev",params.dsSession);if(_ds.tree_obj.renderType==="form")func.runtime.platform.emit("xu-bind-refresh."+params.dsSession.toString())},act_last:async function(){await locate_record(SESSION_ID,"last",params.dsSession);if(_ds.tree_obj.renderType==="form")func.runtime.platform.emit("xu-bind-refresh."+params.dsSession.toString())},act_first:async function(){await locate_record(SESSION_ID,"first",params.dsSession);if(_ds.tree_obj.renderType==="form")func.runtime.platform.emit("xu-bind-refresh."+params.dsSession.toString())},act_refresh:async function(sourceP){let screen_params=params.screen_params;await func.datasource.create(SESSION_ID,params.prog_id,params.dsSession,params.parentDataSourceNo,params.containerId,params.rowIdP);let _ds=SESSION_OBJ[SESSION_ID].DS_GLB[params.dsSession];_ds.screen_params=screen_params;func.runtime.ui.update_sys_obj_win_info(SESSION_ID,params.dsSession);func.runtime.platform.emit("xu-bind-refresh."+params.dsSession.toString());let prog_obj=await func.utils.VIEWS_OBJ.get(SESSION_ID,_ds.prog_id);let field_changed=[];for(let field of prog_obj?.progFields){field_changed.push(field?.data?.field_id||"")}func.runtime.ui.refresh_xu_attributes({SESSION_ID:SESSION_ID,fields_arr:field_changed})},act_save:async function(){await screen_save(SESSION_ID,params)},act_delete:async function(){_ds.data_feed.rows_deleted.push(_ds.currentRecordId);await screen_save(SESSION_ID,params)},act_reload:async function(){var _ds=SESSION_OBJ[SESSION_ID].DS_GLB[params.dsSession];let screen_params=klona.klona(params.screen_params);switch(params.screen_params.screen_type){case"modal":debugger;break;case"popover":debugger;break;case"panel":func.runtime.ui.refresh_screen({SESSION_ID:SESSION_ID,fields_changed_arr:null,datasource_changed:params.dsSession});func.events.delete_job(SESSION_ID,jobNoP);break;case"page":let nav=SESSION_OBJ[SESSION_ID].root_element.querySelector("xu-nav");nav.popTo();break;default:func.runtime.ui.empty(screen_params.$callingContainerP);break}let ret=await func.runtime.ui.init_screen({SESSION_ID:SESSION_ID,prog_id:params.screen_params.prog_id,sourceScreenP:params.screen_params.sourceScreenP,callingDataSource_objP:params.screen_params.callingDataSource_objP,$callingContainerP:params.screen_params.$callingContainerP,triggerIdP:params.screen_params.triggerIdP,rowIdP:params.screen_params.rowIdP,jobNoP:null,is_panelP:params.screen_params.is_panelP,parameters_obj_inP:params.screen_params.parameters_obj_inP,source_functionP:params.screen_params.source_functionP})},act_print:async function(){window.print()}};if(event_sourceP==="click"){await func.events.validate(SESSION_ID,action+"_clicked",params.dsSession,null,"toolbar");params.event_sourceP=event_sourceP;params.isScreenActionP=isScreenActionP;await func.events.add_to_queue(SESSION_ID,params.renderType,null,event_sourceP,"invoke_action",action,params.udfContainer,null,null,null,null,params.rootScreenIdP,null,null,null,null,null,"click",params,null,null,null)}else{await fx[action]();await do_event(action)}};const locate_record=async function(SESSION_ID,actionP,dsSessionP){var arr=[];var result;var _ds=SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP];var current=_ds.currentRecordId;if(!current)return;var i=1;try{let arr=ds?.data_feed?.rows||[];var len=srr.length;const idx=func.common.find_ROWID_idx(_ds,_ds.currentRecordId);if(actionP==="next"){if(idx+1<len){new_idx=idx+1;result=arr[new_idx]._ROWID}else{new_idx=idx;result=arr[new_idx]._ROWID}}if(actionP==="prev"){if(idx-1>0){new_idx=idx-1;result=arr[new_idx]._ROWID}else{new_idx=idx;result=arr[new_idx]._ROWID}}if(actionP==="first"){new_idx=1;result=arr[new_idx]._ROWID}if(actionP==="last"){new_idx=arr.length-1;result=arr[new_idx]._ROWID}var datasource_changes={[_ds.dsSession]:{[result]:"set"}};await func.datasource.update(SESSION_ID,datasource_changes)}catch(err){console.error(err)}};
1
+ const screen_save=async function(SESSION_ID,paramsP){var str='[screenid="'+paramsP.screenId+'"]';var elm=document.getElementById(paramsP.screenId)?.querySelectorAll(str);var dsSession;if(!elm||!elm.length){return func.db.save_data(SESSION_ID,paramsP.dsSession,0)}for await(const[key,val]of Object.entries(elm)){if(key==="length"){break}if(!val){continue}dsSession=func.runtime.ui.get_data(val,"xuData").dsSession;let _ds=SESSION_OBJ[SESSION_ID].DS_GLB[dsSession];if(!dsSession||!_ds){continue}if(_ds.tree_obj.renderType==="form"){if(_ds._dataSourceTableId){if(!_ds.abort_save)await func.db.save_data(SESSION_ID,dsSession,key);_ds.abort_save=false;continue}}}};export const action_execute=async function(SESSION_ID,actionP,params,isScreenActionP,event_sourceP,jobNoP,containerP){var _ds=SESSION_OBJ[SESSION_ID].DS_GLB[params.dsSession];if(!_ds){func.events.delete_job(SESSION_ID,jobNoP);return}var action=actionP;var formGrid_dsSession;var EVENTSUFFIX="_triggered";if(!isScreenActionP)formGrid_dsSession=params.dsSession;var do_event=async function(actionP){var delete_job=async function(jobsP){await func.events.check_jobs_idle(SESSION_ID,jobsP);func.events.delete_job(SESSION_ID,jobNoP)};const jobsP=await func.events.validate(SESSION_ID,actionP+EVENTSUFFIX,params.dsSession,null,"action");await delete_job(jobsP)};const fx={act_next:async function(){await locate_record(SESSION_ID,"next",params.dsSession);if(_ds.tree_obj.renderType==="form"){func.runtime.platform.emit("xu-bind-refresh."+params.dsSession.toString())}},act_prev:async function(){await locate_record(SESSION_ID,"prev",params.dsSession);if(_ds.tree_obj.renderType==="form")func.runtime.platform.emit("xu-bind-refresh."+params.dsSession.toString())},act_last:async function(){await locate_record(SESSION_ID,"last",params.dsSession);if(_ds.tree_obj.renderType==="form")func.runtime.platform.emit("xu-bind-refresh."+params.dsSession.toString())},act_first:async function(){await locate_record(SESSION_ID,"first",params.dsSession);if(_ds.tree_obj.renderType==="form")func.runtime.platform.emit("xu-bind-refresh."+params.dsSession.toString())},act_refresh:async function(sourceP){let screen_params=params.screen_params;await func.datasource.create(SESSION_ID,params.prog_id,params.dsSession,params.parentDataSourceNo,params.containerId,params.rowIdP);let _ds=SESSION_OBJ[SESSION_ID].DS_GLB[params.dsSession];_ds.screen_params=screen_params;func.runtime.ui.update_sys_obj_win_info(SESSION_ID,params.dsSession);func.runtime.platform.emit("xu-bind-refresh."+params.dsSession.toString());let prog_obj=await func.utils.VIEWS_OBJ.get(SESSION_ID,_ds.prog_id);let field_changed=[];for(let field of prog_obj?.progFields){field_changed.push(field?.data?.field_id||"")}func.runtime.ui.refresh_xu_attributes({SESSION_ID:SESSION_ID,fields_arr:field_changed})},act_save:async function(){await screen_save(SESSION_ID,params)},act_delete:async function(){_ds.data_feed.rows_deleted.push(_ds.currentRecordId);await screen_save(SESSION_ID,params)},act_reload:async function(){var _ds=SESSION_OBJ[SESSION_ID].DS_GLB[params.dsSession];let screen_params=structuredClone(params.screen_params);switch(params.screen_params.screen_type){case"modal":debugger;break;case"popover":debugger;break;case"panel":func.runtime.ui.refresh_screen({SESSION_ID:SESSION_ID,fields_changed_arr:null,datasource_changed:params.dsSession});func.events.delete_job(SESSION_ID,jobNoP);break;case"page":let nav=SESSION_OBJ[SESSION_ID].root_element.querySelector("xu-nav");nav.popTo();break;default:func.runtime.ui.empty(screen_params.$callingContainerP);break}let ret=await func.runtime.ui.init_screen({SESSION_ID:SESSION_ID,prog_id:params.screen_params.prog_id,sourceScreenP:params.screen_params.sourceScreenP,callingDataSource_objP:params.screen_params.callingDataSource_objP,$callingContainerP:params.screen_params.$callingContainerP,triggerIdP:params.screen_params.triggerIdP,rowIdP:params.screen_params.rowIdP,jobNoP:null,is_panelP:params.screen_params.is_panelP,parameters_obj_inP:params.screen_params.parameters_obj_inP,source_functionP:params.screen_params.source_functionP})},act_print:async function(){window.print()}};if(event_sourceP==="click"){await func.events.validate(SESSION_ID,action+"_clicked",params.dsSession,null,"toolbar");params.event_sourceP=event_sourceP;params.isScreenActionP=isScreenActionP;await func.events.add_to_queue(SESSION_ID,params.renderType,null,event_sourceP,"invoke_action",action,params.udfContainer,null,null,null,null,params.rootScreenIdP,null,null,null,null,null,"click",params,null,null,null)}else{await fx[action]();await do_event(action)}};const locate_record=async function(SESSION_ID,actionP,dsSessionP){var arr=[];var result;var _ds=SESSION_OBJ[SESSION_ID].DS_GLB[dsSessionP];var current=_ds.currentRecordId;if(!current)return;var i=1;try{let arr=ds?.data_feed?.rows||[];var len=srr.length;const idx=func.common.find_ROWID_idx(_ds,_ds.currentRecordId);if(actionP==="next"){if(idx+1<len){new_idx=idx+1;result=arr[new_idx]._ROWID}else{new_idx=idx;result=arr[new_idx]._ROWID}}if(actionP==="prev"){if(idx-1>0){new_idx=idx-1;result=arr[new_idx]._ROWID}else{new_idx=idx;result=arr[new_idx]._ROWID}}if(actionP==="first"){new_idx=1;result=arr[new_idx]._ROWID}if(actionP==="last"){new_idx=arr.length-1;result=arr[new_idx]._ROWID}var datasource_changes={[_ds.dsSession]:{[result]:"set"}};await func.datasource.update(SESSION_ID,datasource_changes)}catch(err){console.error(err)}};
@@ -463,7 +463,7 @@ func.runtime.ui.live_preview_hot_module_reload = async function (SESSION_ID, doc
463
463
  const new_div = await func.runtime.render.render_ui_tree(
464
464
  SESSION_ID,
465
465
  div_elm,
466
- klona.klona(func.runtime.ui.get_data(panel_val.div, 'xuPanelData').node),
466
+ structuredClone(func.runtime.ui.get_data(panel_val.div, 'xuPanelData').node),
467
467
  {},
468
468
  func.runtime.ui.get_data(org_panel, 'xuData').paramsP,
469
469
  null,
@@ -1 +1 @@
1
- const _this={};export const init_module=e=>{_this.func=e.func;_this.glb=e.glb;_this.SESSION_OBJ=e.SESSION_OBJ;_this.APP_OBJ=e.APP_OBJ;_this.IS_DOCKER=e.IS_DOCKER;_this.IS_API_SERVER=e.IS_API_SERVER;_this.IS_PROCESS_SERVER=e.IS_PROCESS_SERVER};export const live_preview_loader=async function(SESSION_ID){_this.glb.DEBUG_MODE=true;const ret=await init_studio_websocket(SESSION_ID);if(ret.error){_session.root_element.style.display="";_this.func.UI.utils.progressScreen.show(SESSION_ID,"Connection closed :(",null,true);throw"Connection closed :("}var data=ret.e;if(data.service==="init_runtime_websocket"){await _this.func.UI.main.embed_loader(SESSION_ID)}else{var data=e;const call_embed=function(){_session.prog_id=data.data.id;console.log("call_embed",data.data.id);_this.func.runtime.ui.call_embed(SESSION_ID,data.data.id)};if(data.service==="run_program_command"){if(_this.func.UI.utils.get_url_attribute(SESSION_ID,"prog")||typeof live_preview_getCookie!=="undefined"&&live_preview_getCookie("prog_id")&&data.data.id!==live_preview_getCookie("prog_id")&&live_preview_getCookie("gtp_prog_dynamic")==="0"&&_this.func.utils.get_device())return;try{throw"run new program, terminate prev execution"}catch(ex){call_embed()}}if(data.service==="debug_command"){_this.func.utils.debug.read_command(data.data);return}}};const init_studio_websocket=async function(SESSION_ID){return new Promise(async function(resolve,reject){var _session=_this.SESSION_OBJ[SESSION_ID];var app_id=_session.app_id;const set_connected=async function(stat){var datasource_changes={[0]:{["data_system"]:{SYS_GLOBAL_BOL_CONNECTED:stat}}};await func.datasource.update(SESSION_ID,datasource_changes)};const peer_actions_module=await func.common.get_module(SESSION_ID,"xuda-peer-actions-module.esm.js");var preview_name=_session.url_params.preview_name||_session.opt.preview_name;const connect_peer=function(){const peer=new Peer(SESSION_ID,{host:`${_session.domain}`,path:"/peer",secure:true,config:{iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun.l.google.com:5349"},{urls:"stun:stun1.l.google.com:3478"},{urls:"stun:stun1.l.google.com:5349"},{urls:"stun:stun2.l.google.com:19302"},{urls:"stun:stun2.l.google.com:5349"},{urls:"stun:stun3.l.google.com:3478"},{urls:"stun:stun3.l.google.com:5349"},{urls:"stun:stun4.l.google.com:19302"},{urls:"stun:stun4.l.google.com:5349"}]}});STUDIO_PEER=peer;peer.on("open",function(peer_id){var peer_token=_session.gtp_token;const connect_peer=function(){const loaderEl=document.querySelector(".loader");if(loaderEl){const loaderMsgEl=document.querySelector(".loader_msg");if(loaderMsgEl)loaderMsgEl.innerHTML="Awaiting connection to Xuda Studio"}const conn=peer.connect(peer_token,{metadata:{url_params:_session.url_params,client_info:_session.SYS_GLOBAL_OBJ_CLIENT_INFO,preview_name:preview_name,user_info:_session.login_info,live_token_id:_session.opt.live_token_id,live_token_stat:_session.opt.live_token_stat}});conn.on("open",e=>{STUDIO_PEER_CONN_SEND_METHOD=conn.send.bind(conn);STUDIO_PEER_CONN_ID=conn.connectionId;set_connected(1);conn.on("data",data=>{if(data.service==="auth"&&data.data.live_token_stat===2){if(SESSION_OBJ[SESSION_ID].system_ready){conn.send({service:"system_ready"});if(STUDIO_PEER_CONN_MSG_QUEUE.length){for(let val of STUDIO_PEER_CONN_MSG_QUEUE){val.id=conn.connectionId;conn.send(val)}STUDIO_PEER_CONN_MSG_QUEUE=[]}}return connect_to_ws(peer_id)}peer_actions_module.peer_actions(SESSION_ID,STUDIO_PEER_CONN_SEND_METHOD,data)});conn.on("error",e=>{console.error("peer conn",e)});conn.on("close",function(conn){set_connected(0);document.body.classList.remove("live_preview_online");if(_session.opt.live_token_stat===2){func.UI.utils.progressScreen.show(SESSION_ID,"Connection lost. Attempting to reconnect...",false,true);console.log("Connection lost. Attempting to reconnect...");setTimeout(function(){location.reload()},5e3)}})});conn.on("error",e=>{console.error("peer conn",e)});peer.on("call",function(call){const displayMediaStreamConstraints={video:{cursor:"always"},audio:true,preferCurrentTab:true};const success=function(stream){call.answer(stream)};const error=function(error){call.answer(error)};if(navigator.mediaDevices.getDisplayMedia){navigator.mediaDevices.getDisplayMedia(displayMediaStreamConstraints).then(success).catch(error)}else{navigator.getDisplayMedia(displayMediaStreamConstraints).then(success).catch(error)}})};connect_peer()});peer.on("error",function(e){const loaderEl2=document.querySelector(".loader");if(loaderEl2){const loaderMsgEl2=document.querySelector(".loader_msg");if(loaderMsgEl2)loaderMsgEl2.innerHTML="Session has expired. Please renew the token session in Studio and reload."}})};const broadcast_channel=function(){const channel=new BroadcastChannel(_session.gtp_token);STUDIO_PEER=channel;channel.onmessage=event=>{if(event.data.session_id!==SESSION_ID)return;peer_actions_module.peer_actions(SESSION_ID,STUDIO_PEER_CONN_SEND_METHOD,event.data)};channel.postMessage({service:"connection",metadata:{url_params:_session.url_params,client_info:_session.SYS_GLOBAL_OBJ_CLIENT_INFO,preview_name:preview_name,user_info:_session.login_info,session_id:SESSION_ID}});STUDIO_PEER_CONN_SEND_METHOD=channel.postMessage.bind(channel);set_connected(1);window.addEventListener("onCloseWindow",event=>{console.log("onCloseWindow");channel.postMessage({service:"disconnected",session_id:SESSION_ID,type:"onCloseWindow"})});window.addEventListener("beforeunload",event=>{console.log("beforeunload");channel.postMessage({service:"disconnected",session_id:SESSION_ID,type:"beforeunload"})});window.addEventListener("unload",event=>{console.log("beforeunload");channel.postMessage({service:"disconnected",session_id:SESSION_ID,type:"unload"})});resolve({e:{service:"init_runtime_websocket"}})};const connect_to_ws=function(peer_id){try{const url="https://"+_session.domain;STUDIO_WEBSOCKET=io(url,{secure:true,reconnection:_this.glb.debug_js?false:true,rejectUnauthorized:false,path:"/ws/socket.io"});const ws_data={service:"init",id:peer_id,uid:_session.USR_OBJ._id,source:"runtime",app_id:app_id,preview_name:preview_name,client_info:_session.SYS_GLOBAL_OBJ_CLIENT_INFO,session_id:SESSION_ID,gtp_token:_session.gtp_token,app_token:_session.app_token};STUDIO_WEBSOCKET.on("connect",()=>{STUDIO_WEBSOCKET_CONNECTION_ID=STUDIO_WEBSOCKET.id;STUDIO_WEBSOCKET.emit("join-room",ws_data);resolve({e:{service:"init_runtime_websocket"}})});STUDIO_WEBSOCKET.on("studio-connected",data=>{if(!data.reconnected){STUDIO_WEBSOCKET.emit("init-studio",{...ws_data,reconnected:true})}_session.root_element.classList.add("live_preview_connected")});STUDIO_WEBSOCKET.on("user-disconnected",data=>{_session.root_element.classList.remove("live_preview_connected");_session.root_element.classList.remove("live_preview_online")});STUDIO_WEBSOCKET.on("disconnect",()=>{console.log("disconnect",STUDIO_WEBSOCKET.id)});STUDIO_WEBSOCKET.io.on("reconnect",attempt=>{console.log("reconnect",attempt)})}catch(e){resolve(true)}};if(_session.local_live_preview==="true"){return broadcast_channel()}connect_peer()})};export const send_STUDIO_WEBSOCKET=function(SESSION_ID,service){var _session=_this.SESSION_OBJ[SESSION_ID];const data={service:service,data:_session.USR_OBJ,id:STUDIO_PEER_CONN_ID,uid:_session.USR_OBJ._id,source:"runtime",app_id:_session.app_id,gtp_token:_session.gtp_token,app_token:_session.app_token};if(!STUDIO_PEER_CONN_SEND_METHOD){STUDIO_PEER_CONN_MSG_QUEUE.push(data);return}STUDIO_PEER_CONN_SEND_METHOD(data)};func.runtime.ui.live_preview_hot_module_reload=async function(SESSION_ID,doc){const $elm=func.UI.utils.find_in_element_data("xuPanelData",func.runtime.ui.as_jquery(SESSION_OBJ[SESSION_ID].root_element),"parent_element_ui_id");var panels_obj={};if(!$elm.length){for await(const[key,val]of Object.entries(SESSION_OBJ[SESSION_ID].DS_GLB)){if(val.prog_id===doc._id){await func.action.execute(SESSION_ID,"act_reload",val);break}}return}for await(const[elem_key,elem_val]of Object.entries($elm)){if(elem_key==="length")break;var div=elem_val;let xuData=func.runtime.ui.get_data(div,"xuData");if(!func.runtime.ui.get_data(div,"xuPanelData"))continue;let dsSession=xuData.paramsP.dsSessionP;var _session=SESSION_OBJ[SESSION_ID];let _ds=_session?.DS_GLB[dsSession];if(!_ds)continue;if(_ds.prog_id!==doc._id){continue}const parent_element_ui_id=func.runtime.ui.get_data(div,"xuPanelData").parent_element_ui_id;if(!panels_obj[parent_element_ui_id]){panels_obj[parent_element_ui_id]={_ds:_ds,div:div,ids:[]}}panels_obj[parent_element_ui_id].ids.push(div.getAttribute("xu-ui-id"))}for await(const[parent_element_ui_id,panel_val]of Object.entries(panels_obj)){var div_elm=panel_val.div.parentElement.parentElement.querySelector("[xu-ui-id='"+parent_element_ui_id+"']");try{const org_panel=func.runtime.ui.get_data(panel_val.div,"xuPanelData").$panel_div;const new_div=await func.runtime.render.render_ui_tree(SESSION_ID,div_elm,klona.klona(func.runtime.ui.get_data(panel_val.div,"xuPanelData").node),{},func.runtime.ui.get_data(org_panel,"xuData").paramsP,null,null,func.runtime.ui.get_data(org_panel,"xuData").key,null,func.runtime.ui.get_data(org_panel,"xuData").parent_node,null,func.runtime.ui.get_data(org_panel,"xuData").$root_container);for(const val of panel_val.ids){const oldEl=document.querySelector("[xu-ui-id='"+val+"']");if(oldEl)oldEl.remove()}}catch(error){debugger}}return panels_obj};
1
+ const _this={};export const init_module=e=>{_this.func=e.func;_this.glb=e.glb;_this.SESSION_OBJ=e.SESSION_OBJ;_this.APP_OBJ=e.APP_OBJ;_this.IS_DOCKER=e.IS_DOCKER;_this.IS_API_SERVER=e.IS_API_SERVER;_this.IS_PROCESS_SERVER=e.IS_PROCESS_SERVER};export const live_preview_loader=async function(SESSION_ID){_this.glb.DEBUG_MODE=true;const ret=await init_studio_websocket(SESSION_ID);if(ret.error){_session.root_element.style.display="";_this.func.UI.utils.progressScreen.show(SESSION_ID,"Connection closed :(",null,true);throw"Connection closed :("}var data=ret.e;if(data.service==="init_runtime_websocket"){await _this.func.UI.main.embed_loader(SESSION_ID)}else{var data=e;const call_embed=function(){_session.prog_id=data.data.id;console.log("call_embed",data.data.id);_this.func.runtime.ui.call_embed(SESSION_ID,data.data.id)};if(data.service==="run_program_command"){if(_this.func.UI.utils.get_url_attribute(SESSION_ID,"prog")||typeof live_preview_getCookie!=="undefined"&&live_preview_getCookie("prog_id")&&data.data.id!==live_preview_getCookie("prog_id")&&live_preview_getCookie("gtp_prog_dynamic")==="0"&&_this.func.utils.get_device())return;try{throw"run new program, terminate prev execution"}catch(ex){call_embed()}}if(data.service==="debug_command"){_this.func.utils.debug.read_command(data.data);return}}};const init_studio_websocket=async function(SESSION_ID){return new Promise(async function(resolve,reject){var _session=_this.SESSION_OBJ[SESSION_ID];var app_id=_session.app_id;const set_connected=async function(stat){var datasource_changes={[0]:{["data_system"]:{SYS_GLOBAL_BOL_CONNECTED:stat}}};await func.datasource.update(SESSION_ID,datasource_changes)};const peer_actions_module=await func.common.get_module(SESSION_ID,"xuda-peer-actions-module.esm.js");var preview_name=_session.url_params.preview_name||_session.opt.preview_name;const connect_peer=function(){const peer=new Peer(SESSION_ID,{host:`${_session.domain}`,path:"/peer",secure:true,config:{iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun.l.google.com:5349"},{urls:"stun:stun1.l.google.com:3478"},{urls:"stun:stun1.l.google.com:5349"},{urls:"stun:stun2.l.google.com:19302"},{urls:"stun:stun2.l.google.com:5349"},{urls:"stun:stun3.l.google.com:3478"},{urls:"stun:stun3.l.google.com:5349"},{urls:"stun:stun4.l.google.com:19302"},{urls:"stun:stun4.l.google.com:5349"}]}});STUDIO_PEER=peer;peer.on("open",function(peer_id){var peer_token=_session.gtp_token;const connect_peer=function(){const loaderEl=document.querySelector(".loader");if(loaderEl){const loaderMsgEl=document.querySelector(".loader_msg");if(loaderMsgEl)loaderMsgEl.innerHTML="Awaiting connection to Xuda Studio"}const conn=peer.connect(peer_token,{metadata:{url_params:_session.url_params,client_info:_session.SYS_GLOBAL_OBJ_CLIENT_INFO,preview_name:preview_name,user_info:_session.login_info,live_token_id:_session.opt.live_token_id,live_token_stat:_session.opt.live_token_stat}});conn.on("open",e=>{STUDIO_PEER_CONN_SEND_METHOD=conn.send.bind(conn);STUDIO_PEER_CONN_ID=conn.connectionId;set_connected(1);conn.on("data",data=>{if(data.service==="auth"&&data.data.live_token_stat===2){if(SESSION_OBJ[SESSION_ID].system_ready){conn.send({service:"system_ready"});if(STUDIO_PEER_CONN_MSG_QUEUE.length){for(let val of STUDIO_PEER_CONN_MSG_QUEUE){val.id=conn.connectionId;conn.send(val)}STUDIO_PEER_CONN_MSG_QUEUE=[]}}return connect_to_ws(peer_id)}peer_actions_module.peer_actions(SESSION_ID,STUDIO_PEER_CONN_SEND_METHOD,data)});conn.on("error",e=>{console.error("peer conn",e)});conn.on("close",function(conn){set_connected(0);document.body.classList.remove("live_preview_online");if(_session.opt.live_token_stat===2){func.UI.utils.progressScreen.show(SESSION_ID,"Connection lost. Attempting to reconnect...",false,true);console.log("Connection lost. Attempting to reconnect...");setTimeout(function(){location.reload()},5e3)}})});conn.on("error",e=>{console.error("peer conn",e)});peer.on("call",function(call){const displayMediaStreamConstraints={video:{cursor:"always"},audio:true,preferCurrentTab:true};const success=function(stream){call.answer(stream)};const error=function(error){call.answer(error)};if(navigator.mediaDevices.getDisplayMedia){navigator.mediaDevices.getDisplayMedia(displayMediaStreamConstraints).then(success).catch(error)}else{navigator.getDisplayMedia(displayMediaStreamConstraints).then(success).catch(error)}})};connect_peer()});peer.on("error",function(e){const loaderEl2=document.querySelector(".loader");if(loaderEl2){const loaderMsgEl2=document.querySelector(".loader_msg");if(loaderMsgEl2)loaderMsgEl2.innerHTML="Session has expired. Please renew the token session in Studio and reload."}})};const broadcast_channel=function(){const channel=new BroadcastChannel(_session.gtp_token);STUDIO_PEER=channel;channel.onmessage=event=>{if(event.data.session_id!==SESSION_ID)return;peer_actions_module.peer_actions(SESSION_ID,STUDIO_PEER_CONN_SEND_METHOD,event.data)};channel.postMessage({service:"connection",metadata:{url_params:_session.url_params,client_info:_session.SYS_GLOBAL_OBJ_CLIENT_INFO,preview_name:preview_name,user_info:_session.login_info,session_id:SESSION_ID}});STUDIO_PEER_CONN_SEND_METHOD=channel.postMessage.bind(channel);set_connected(1);window.addEventListener("onCloseWindow",event=>{console.log("onCloseWindow");channel.postMessage({service:"disconnected",session_id:SESSION_ID,type:"onCloseWindow"})});window.addEventListener("beforeunload",event=>{console.log("beforeunload");channel.postMessage({service:"disconnected",session_id:SESSION_ID,type:"beforeunload"})});window.addEventListener("unload",event=>{console.log("beforeunload");channel.postMessage({service:"disconnected",session_id:SESSION_ID,type:"unload"})});resolve({e:{service:"init_runtime_websocket"}})};const connect_to_ws=function(peer_id){try{const url="https://"+_session.domain;STUDIO_WEBSOCKET=io(url,{secure:true,reconnection:_this.glb.debug_js?false:true,rejectUnauthorized:false,path:"/ws/socket.io"});const ws_data={service:"init",id:peer_id,uid:_session.USR_OBJ._id,source:"runtime",app_id:app_id,preview_name:preview_name,client_info:_session.SYS_GLOBAL_OBJ_CLIENT_INFO,session_id:SESSION_ID,gtp_token:_session.gtp_token,app_token:_session.app_token};STUDIO_WEBSOCKET.on("connect",()=>{STUDIO_WEBSOCKET_CONNECTION_ID=STUDIO_WEBSOCKET.id;STUDIO_WEBSOCKET.emit("join-room",ws_data);resolve({e:{service:"init_runtime_websocket"}})});STUDIO_WEBSOCKET.on("studio-connected",data=>{if(!data.reconnected){STUDIO_WEBSOCKET.emit("init-studio",{...ws_data,reconnected:true})}_session.root_element.classList.add("live_preview_connected")});STUDIO_WEBSOCKET.on("user-disconnected",data=>{_session.root_element.classList.remove("live_preview_connected");_session.root_element.classList.remove("live_preview_online")});STUDIO_WEBSOCKET.on("disconnect",()=>{console.log("disconnect",STUDIO_WEBSOCKET.id)});STUDIO_WEBSOCKET.io.on("reconnect",attempt=>{console.log("reconnect",attempt)})}catch(e){resolve(true)}};if(_session.local_live_preview==="true"){return broadcast_channel()}connect_peer()})};export const send_STUDIO_WEBSOCKET=function(SESSION_ID,service){var _session=_this.SESSION_OBJ[SESSION_ID];const data={service:service,data:_session.USR_OBJ,id:STUDIO_PEER_CONN_ID,uid:_session.USR_OBJ._id,source:"runtime",app_id:_session.app_id,gtp_token:_session.gtp_token,app_token:_session.app_token};if(!STUDIO_PEER_CONN_SEND_METHOD){STUDIO_PEER_CONN_MSG_QUEUE.push(data);return}STUDIO_PEER_CONN_SEND_METHOD(data)};func.runtime.ui.live_preview_hot_module_reload=async function(SESSION_ID,doc){const $elm=func.UI.utils.find_in_element_data("xuPanelData",func.runtime.ui.as_jquery(SESSION_OBJ[SESSION_ID].root_element),"parent_element_ui_id");var panels_obj={};if(!$elm.length){for await(const[key,val]of Object.entries(SESSION_OBJ[SESSION_ID].DS_GLB)){if(val.prog_id===doc._id){await func.action.execute(SESSION_ID,"act_reload",val);break}}return}for await(const[elem_key,elem_val]of Object.entries($elm)){if(elem_key==="length")break;var div=elem_val;let xuData=func.runtime.ui.get_data(div,"xuData");if(!func.runtime.ui.get_data(div,"xuPanelData"))continue;let dsSession=xuData.paramsP.dsSessionP;var _session=SESSION_OBJ[SESSION_ID];let _ds=_session?.DS_GLB[dsSession];if(!_ds)continue;if(_ds.prog_id!==doc._id){continue}const parent_element_ui_id=func.runtime.ui.get_data(div,"xuPanelData").parent_element_ui_id;if(!panels_obj[parent_element_ui_id]){panels_obj[parent_element_ui_id]={_ds:_ds,div:div,ids:[]}}panels_obj[parent_element_ui_id].ids.push(div.getAttribute("xu-ui-id"))}for await(const[parent_element_ui_id,panel_val]of Object.entries(panels_obj)){var div_elm=panel_val.div.parentElement.parentElement.querySelector("[xu-ui-id='"+parent_element_ui_id+"']");try{const org_panel=func.runtime.ui.get_data(panel_val.div,"xuPanelData").$panel_div;const new_div=await func.runtime.render.render_ui_tree(SESSION_ID,div_elm,structuredClone(func.runtime.ui.get_data(panel_val.div,"xuPanelData").node),{},func.runtime.ui.get_data(org_panel,"xuData").paramsP,null,null,func.runtime.ui.get_data(org_panel,"xuData").key,null,func.runtime.ui.get_data(org_panel,"xuData").parent_node,null,func.runtime.ui.get_data(org_panel,"xuData").$root_container);for(const val of panel_val.ids){const oldEl=document.querySelector("[xu-ui-id='"+val+"']");if(oldEl)oldEl.remove()}}catch(error){debugger}}return panels_obj};
@@ -103,7 +103,7 @@ export const peer_actions = async function (SESSION_ID, conn_send, data) {
103
103
  }
104
104
 
105
105
  case "live_preview_get_session": {
106
- let _session = klona.klona(_this.SESSION_OBJ[SESSION_ID]);
106
+ let _session = JSON.parse(JSON.stringify(_this.SESSION_OBJ[SESSION_ID]));
107
107
  for (const [key, val] of Object.entries(_session.DS_GLB)) {
108
108
  _session.DS_GLB[key] = await func.utils.clean_returned_datasource(
109
109
  SESSION_ID,
@@ -1 +1 @@
1
- const _this={};export const init_module=e=>{_this.func=e.func;_this.glb=e.glb;_this.SESSION_OBJ=e.SESSION_OBJ;_this.APP_OBJ=e.APP_OBJ;_this.IS_DOCKER=e.IS_DOCKER;_this.IS_API_SERVER=e.IS_API_SERVER;_this.IS_PROCESS_SERVER=e.IS_PROCESS_SERVER};export const peer_actions=async function(SESSION_ID,conn_send,data){var _session=_this.SESSION_OBJ[SESSION_ID];const take_screenshot=async function(service){await _this.func.utils.load_js_on_demand("https://html2canvas.hertzen.com/dist/html2canvas.js");html2canvas(document.body).then(canvas=>{conn_send({service:service,data:canvas.toDataURL("image/png"),id:data.id,uid:_session.USR_OBJ._id,source:"runtime",app_id:_session.app_id,gtp_token:_session.gtp_token,app_token:_session.app_token,session_id:SESSION_ID,ts:Date.now(),session:{SYS_GLOBAL_OBJ_CLIENT_INFO:_this.SESSION_OBJ[SESSION_ID].SYS_GLOBAL_OBJ_CLIENT_INFO}})})};switch(data.service){case"send_object_to_runtime":{if(STUDIO_WEBSOCKET_CONNECTION_ID===data.data.connection_id){if(RESPONSE_FROM_STUDIO_QUEUE[data.data.req_id]){RESPONSE_FROM_STUDIO_QUEUE[data.data.req_id].data=data.data}}break}case"live_preview_element_reference":case"live_preview_element_info":case"live_preview_element_dnd":{if(data.data.action==="on"){_this.func.UI.utils.live_preview_element_inspect_off();_this.func.UI.utils.live_preview_element_inspect_on(SESSION_ID,data.service)}else{_this.func.UI.utils.live_preview_element_inspect_off()}break}case"live_preview_show_selected_element":{_this.func.UI.utils.live_preview_show_selected_element(data.data.nodeid);break}case"live_preview_cmd_execute":{let res;try{res={data:eval(data.data.execute)}}catch(e){res={data:e.message,error:true}}conn_send({service:"debug_log",data:res,id:data.id,uid:_session.USR_OBJ._id,source:"runtime",app_id:_session.app_id,session_id:SESSION_ID,gtp_token:_session.gtp_token,app_token:_session.app_token,ts:Date.now()});break}case"live_preview_hard_reload":{await func.index.delete_pouch(SESSION_ID);location.reload();break}case"live_preview_screenshot":{await take_screenshot("live_preview_screenshot_captured");break}case"live_preview_get_session":{let _session=klona.klona(_this.SESSION_OBJ[SESSION_ID]);for(const[key,val]of Object.entries(_session.DS_GLB)){_session.DS_GLB[key]=await func.utils.clean_returned_datasource(SESSION_ID,key)}delete _session.root_element;delete _session.WORKER_OBJ;conn_send({service:"live_preview_session_result",data:_session,id:data.id,uid:_session.USR_OBJ._id,source:"runtime",app_id:_session.app_id,session_id:SESSION_ID,gtp_token:_session.gtp_token,app_token:_session.app_token,ts:Date.now()});break}case"live_preview_screen_share_start":{_this.live_preview_screen_share_interval=setInterval(async()=>{await take_screenshot("live_preview_screen_share")},500);break}case"live_preview_screen_share_end":{clearInterval(_this.live_preview_screen_share_interval);break}case"live_preview_connected":{_session.root_element.classList.add("live_preview_online");break}case"live_preview_disconnected":{_session.root_element.classList.remove("live_preview_online");break}case"live_preview_kickoff":{_session.opt.live_token_stat=2;func.UI.utils.progressScreen.show(SESSION_ID,"Session closed by the host",false,true);break}case"document_changed":{console.log("document_changed",data);func.runtime.ui.refresh_document_changes_for_realtime_update(SESSION_ID,data.data);break}case"live_preview_get_obj_response":{if(!data?.data?._id)return;func.runtime.platform.emit("live_preview_get_obj_response_"+data.data._id,{data:data.data});break}case"rpi_request_response":{func.runtime.platform.emit("rpi_request_response_"+data.req_id,{data:data.data});break}case"ping":{conn_send({service:"pong",data:{},id:data.id,uid:_session.USR_OBJ._id,source:"runtime",app_id:_session.app_id,session_id:SESSION_ID,gtp_token:_session.gtp_token,app_token:_session.app_token,ts:Date.now()});break}case"studio_doc_saved":{var _session=SESSION_OBJ[SESSION_ID];DOCS_OBJ[_session.app_id][data.data._id]=data.data;func.runtime.ui.live_preview_hot_module_reload(SESSION_ID,data.data);break}default:break}};
1
+ const _this={};export const init_module=e=>{_this.func=e.func;_this.glb=e.glb;_this.SESSION_OBJ=e.SESSION_OBJ;_this.APP_OBJ=e.APP_OBJ;_this.IS_DOCKER=e.IS_DOCKER;_this.IS_API_SERVER=e.IS_API_SERVER;_this.IS_PROCESS_SERVER=e.IS_PROCESS_SERVER};export const peer_actions=async function(SESSION_ID,conn_send,data){var _session=_this.SESSION_OBJ[SESSION_ID];const take_screenshot=async function(service){await _this.func.utils.load_js_on_demand("https://html2canvas.hertzen.com/dist/html2canvas.js");html2canvas(document.body).then(canvas=>{conn_send({service:service,data:canvas.toDataURL("image/png"),id:data.id,uid:_session.USR_OBJ._id,source:"runtime",app_id:_session.app_id,gtp_token:_session.gtp_token,app_token:_session.app_token,session_id:SESSION_ID,ts:Date.now(),session:{SYS_GLOBAL_OBJ_CLIENT_INFO:_this.SESSION_OBJ[SESSION_ID].SYS_GLOBAL_OBJ_CLIENT_INFO}})})};switch(data.service){case"send_object_to_runtime":{if(STUDIO_WEBSOCKET_CONNECTION_ID===data.data.connection_id){if(RESPONSE_FROM_STUDIO_QUEUE[data.data.req_id]){RESPONSE_FROM_STUDIO_QUEUE[data.data.req_id].data=data.data}}break}case"live_preview_element_reference":case"live_preview_element_info":case"live_preview_element_dnd":{if(data.data.action==="on"){_this.func.UI.utils.live_preview_element_inspect_off();_this.func.UI.utils.live_preview_element_inspect_on(SESSION_ID,data.service)}else{_this.func.UI.utils.live_preview_element_inspect_off()}break}case"live_preview_show_selected_element":{_this.func.UI.utils.live_preview_show_selected_element(data.data.nodeid);break}case"live_preview_cmd_execute":{let res;try{res={data:eval(data.data.execute)}}catch(e){res={data:e.message,error:true}}conn_send({service:"debug_log",data:res,id:data.id,uid:_session.USR_OBJ._id,source:"runtime",app_id:_session.app_id,session_id:SESSION_ID,gtp_token:_session.gtp_token,app_token:_session.app_token,ts:Date.now()});break}case"live_preview_hard_reload":{await func.index.delete_pouch(SESSION_ID);location.reload();break}case"live_preview_screenshot":{await take_screenshot("live_preview_screenshot_captured");break}case"live_preview_get_session":{let _session=JSON.parse(JSON.stringify(_this.SESSION_OBJ[SESSION_ID]));for(const[key,val]of Object.entries(_session.DS_GLB)){_session.DS_GLB[key]=await func.utils.clean_returned_datasource(SESSION_ID,key)}delete _session.root_element;delete _session.WORKER_OBJ;conn_send({service:"live_preview_session_result",data:_session,id:data.id,uid:_session.USR_OBJ._id,source:"runtime",app_id:_session.app_id,session_id:SESSION_ID,gtp_token:_session.gtp_token,app_token:_session.app_token,ts:Date.now()});break}case"live_preview_screen_share_start":{_this.live_preview_screen_share_interval=setInterval(async()=>{await take_screenshot("live_preview_screen_share")},500);break}case"live_preview_screen_share_end":{clearInterval(_this.live_preview_screen_share_interval);break}case"live_preview_connected":{_session.root_element.classList.add("live_preview_online");break}case"live_preview_disconnected":{_session.root_element.classList.remove("live_preview_online");break}case"live_preview_kickoff":{_session.opt.live_token_stat=2;func.UI.utils.progressScreen.show(SESSION_ID,"Session closed by the host",false,true);break}case"document_changed":{console.log("document_changed",data);func.runtime.ui.refresh_document_changes_for_realtime_update(SESSION_ID,data.data);break}case"live_preview_get_obj_response":{if(!data?.data?._id)return;func.runtime.platform.emit("live_preview_get_obj_response_"+data.data._id,{data:data.data});break}case"rpi_request_response":{func.runtime.platform.emit("rpi_request_response_"+data.req_id,{data:data.data});break}case"ping":{conn_send({service:"pong",data:{},id:data.id,uid:_session.USR_OBJ._id,source:"runtime",app_id:_session.app_id,session_id:SESSION_ID,gtp_token:_session.gtp_token,app_token:_session.app_token,ts:Date.now()});break}case"studio_doc_saved":{var _session=SESSION_OBJ[SESSION_ID];DOCS_OBJ[_session.app_id][data.data._id]=data.data;func.runtime.ui.live_preview_hot_module_reload(SESSION_ID,data.data);break}default:break}};
@@ -24232,11 +24232,10 @@ func.runtime.bind.toggle_array_value = function (arr_value_before_cast, value_fr
24232
24232
  };
24233
24233
  func.runtime.bind.get_cast_value = async function (SESSION_ID, field_prop, input_field_type, raw_value) {
24234
24234
  const field_type = func.runtime.bind.get_field_type(field_prop);
24235
- var value = await func.common.get_cast_val(SESSION_ID, 'xu-bind', 'value', field_type, raw_value);
24236
24235
  if (field_type === 'object') {
24237
- value = await func.common.get_cast_val(SESSION_ID, 'xu-bind', 'value', input_field_type, raw_value);
24236
+ return await func.common.get_cast_val(SESSION_ID, 'xu-bind', 'value', input_field_type, raw_value);
24238
24237
  }
24239
- return value;
24238
+ return await func.common.get_cast_val(SESSION_ID, 'xu-bind', 'value', field_type, raw_value);
24240
24239
  };
24241
24240
  func.runtime.bind.get_source_value = function (_ds, bind_field_id, is_dynamic_field) {
24242
24241
  if (is_dynamic_field) {
@@ -24273,7 +24272,7 @@ func.runtime.bind.update_reference_source_array = async function (options) {
24273
24272
 
24274
24273
  const arr_idx = Number(options.iterate_info._key);
24275
24274
  const dataset_arr = await func.datasource.get_value(options.SESSION_ID, reference_source_obj.fieldIdP, options.dsSessionP, reference_source_obj.currentRecordId);
24276
- let new_arr = klona.klona(dataset_arr.ret.value);
24275
+ let new_arr = structuredClone(dataset_arr.ret.value);
24277
24276
 
24278
24277
  if (field_type === 'object' && options.val_is_reference_field) {
24279
24278
  let obj_item = new_arr[arr_idx];
@@ -24339,7 +24338,7 @@ func.runtime.resources.load_plugin_runtime_css = async function (SESSION_ID, plu
24339
24338
  return true;
24340
24339
  };
24341
24340
  func.runtime.resources.resolve_plugin_properties = async function (SESSION_ID, dsSessionP, attributes, properties) {
24342
- let resolved_properties = klona.klona(properties);
24341
+ let resolved_properties = structuredClone(properties);
24343
24342
  for await (let [prop_name, prop_val] of Object.entries(resolved_properties || {})) {
24344
24343
  prop_val.value = attributes?.[prop_name];
24345
24344
  if (attributes?.[`xu-exp:${prop_name}`]) {
@@ -24762,7 +24761,7 @@ func.common.db = async function (SESSION_ID, serviceP, dataP, opt = {}, dsSessio
24762
24761
  }
24763
24762
 
24764
24763
  await db.get(row_id);
24765
- let _data = klona.klona(dataP);
24764
+ let _data = structuredClone(dataP);
24766
24765
  _data.ids = [row_id];
24767
24766
  return await func.db.pouch['dbs_delete'](SESSION_ID, _data);
24768
24767
  } catch (err) {
@@ -28507,7 +28506,7 @@ func.runtime.ui.get_node_snapshot = function (nodeP) {
28507
28506
  if (func.runtime.ui.node_snapshot_cache.has(nodeP)) {
28508
28507
  return func.runtime.ui.node_snapshot_cache.get(nodeP);
28509
28508
  }
28510
- const snapshot = klona.klona(nodeP);
28509
+ const snapshot = structuredClone(nodeP);
28511
28510
  func.runtime.ui.node_snapshot_cache.set(nodeP, snapshot);
28512
28511
  return snapshot;
28513
28512
  };
@@ -28687,7 +28686,7 @@ func.runtime.ui.generate_xu_ui_id = async function (SESSION_ID, nodeP, $containe
28687
28686
  return hashed_ui_id;
28688
28687
  };
28689
28688
  func.runtime.ui.create_container = async function (options) {
28690
- const _paramsP = klona.klona(options.paramsP);
28689
+ const _paramsP = structuredClone(options.paramsP);
28691
28690
  const _ds = SESSION_OBJ[options.SESSION_ID].DS_GLB[_paramsP.dsSessionP];
28692
28691
  const $appendTo = func.runtime.ui.get_append_target(options.$container, options.$appendToP);
28693
28692
  if (!$appendTo) return null;
@@ -30602,8 +30601,8 @@ func.UI.worker.execute = async function (SESSION_ID, queue_obj) {
30602
30601
  }
30603
30602
 
30604
30603
  if (plan.is_regular_attribute) {
30605
- if (elm_node) {
30606
- func.runtime.ui.set_attr($elm, plan.regular_attr_name, result);
30604
+ if (plan.regular_attr_name === 'class') {
30605
+ func.runtime.render.apply_expression_class($elm, result);
30607
30606
  } else {
30608
30607
  func.runtime.ui.set_attr($elm, plan.regular_attr_name, result);
30609
30608
  }
@@ -30639,21 +30638,11 @@ func.UI.worker.execute = async function (SESSION_ID, queue_obj) {
30639
30638
  return await func.UI.worker.delete_job(SESSION_ID, queue_obj.job_num);
30640
30639
  }
30641
30640
 
30642
- const xu_for_item_id = queue_obj?.paramsP?.xu_for_item_id;
30643
- const parent_node = func.runtime.ui.get_first_node($elm);
30644
- const children_before = func.runtime.ui.get_children($elm);
30645
- const _dbg_nodeids = children_before.map(c => func.runtime.ui.get_data(c)?.xuData?.nodeid);
30646
- console.warn('[xu-for-debug] execute_xu_for START xu_for_item_id=' + xu_for_item_id + ' children=' + children_before.length + ' nodeids=' + JSON.stringify(_dbg_nodeids));
30647
-
30648
30641
  const existing_children_map = new Set();
30649
30642
  if (func.runtime?.ui?.get_refresh_indexed_elements_by_node_id) {
30650
- const indexed_children = func.runtime.ui.get_refresh_indexed_elements_by_node_id(SESSION_ID, xu_for_item_id).toArray();
30651
- console.warn('[xu-for-debug] indexed_children', {
30652
- count: indexed_children.length,
30653
- parent_match: indexed_children.map(c => c.parentElement === parent_node),
30654
- });
30643
+ const indexed_children = func.runtime.ui.get_refresh_indexed_elements_by_node_id(SESSION_ID, queue_obj?.paramsP?.xu_for_item_id).toArray();
30655
30644
  for (let index = 0; index < indexed_children.length; index++) {
30656
- if (indexed_children[index].parentElement === parent_node) {
30645
+ if (indexed_children[index].parentElement === func.runtime.ui.get_first_node($elm)) {
30657
30646
  existing_children_map.add(indexed_children[index]);
30658
30647
  }
30659
30648
  }
@@ -30663,36 +30652,19 @@ func.UI.worker.execute = async function (SESSION_ID, queue_obj) {
30663
30652
  for (let index = 0; index < children.length; index++) {
30664
30653
  const child = children[index];
30665
30654
  const child_data = func.runtime.ui.get_data(child);
30666
- if (child_data?.xuData?.nodeid === xu_for_item_id) {
30655
+ if (child_data?.xuData?.nodeid === queue_obj?.paramsP?.xu_for_item_id) {
30667
30656
  existing_children_map.add(child);
30668
30657
  }
30669
30658
  }
30670
30659
 
30671
- console.warn('[xu-for-debug] cleanup', {
30672
- existing_children_map_size: existing_children_map.size,
30673
- });
30674
-
30675
30660
  if (existing_children_map.size) {
30676
30661
  func.runtime.ui.remove(func.runtime.ui._wrap_matches(Array.from(existing_children_map)));
30677
30662
  }
30678
30663
 
30679
- const children_after_cleanup = func.runtime.ui.get_children($elm);
30680
- console.warn('[xu-for-debug] after cleanup, before render', {
30681
- children_after_cleanup_count: children_after_cleanup.length,
30682
- });
30683
-
30684
30664
  let _data = live_context.data || func.runtime.ui.get_data($elm);
30685
- const node_to_render = fx.get_child_node_by_id(_data?.xuData, xu_for_item_id);
30686
- console.warn('[xu-for-debug] node_to_render', { id: node_to_render?.id, tagName: node_to_render?.tagName });
30665
+ const node_to_render = fx.get_child_node_by_id(_data?.xuData, queue_obj?.paramsP?.xu_for_item_id);
30687
30666
  await func.runtime.render.render_ui_tree(queue_obj.paramsP.SESSION_ID, $elm, node_to_render, null, _data.xuData.paramsP, queue_obj.jobNoP, null, _data.xuData.key, null, _data.xuData.parent_node, null, _data.xuData.$root_container);
30688
-
30689
- const children_after_render = func.runtime.ui.get_children($elm);
30690
- console.warn('[xu-for-debug] execute_xu_for END', {
30691
- children_after_render_count: children_after_render.length,
30692
- children_after_render_nodeids: children_after_render.map(c => func.runtime.ui.get_data(c)?.xuData?.nodeid),
30693
- });
30694
30667
  } catch (error) {
30695
- console.error('[xu-for-debug] execute_xu_for ERROR', error);
30696
30668
  } finally {
30697
30669
  perf_end?.();
30698
30670
  }
@@ -31413,7 +31385,7 @@ func.runtime.ui.init_screen = async function (options) {
31413
31385
  await func.UI.utils.init_ui_framework(SESSION_ID, prog_id);
31414
31386
 
31415
31387
  const _session = SESSION_OBJ[SESSION_ID];
31416
- const screenInfo = klona.klona(screen_ret);
31388
+ const screenInfo = structuredClone(screen_ret);
31417
31389
 
31418
31390
  const screen_type = source_functionP?.split('_')?.[1];
31419
31391
  const screenId = (glb.screen_num++).toString();
@@ -31529,7 +31501,7 @@ func.runtime.ui.init_screen = async function (options) {
31529
31501
  if (!viewDoc?.progUi) {
31530
31502
  return func.utils.alerts.invoke(SESSION_ID, 'system_msg', 'SYS_MSG_0780', params.renderType, ret.dsSessionP);
31531
31503
  }
31532
- let node = klona.klona(viewDoc.progUi);
31504
+ let node = structuredClone(viewDoc.progUi);
31533
31505
  if (!node.length) return console.warn('ui node empty');
31534
31506
  const ret_render_$container = await func.runtime.render.render_ui_tree(SESSION_ID, $rootFrame, node[0], null, params, jobNoP, null, null, null, null, null, $rootFrame);
31535
31507
 
@@ -31896,13 +31868,13 @@ func.runtime.ui.copy_runtime_state = function ($source, $target) {
31896
31868
  const xu_data_keys = Object.keys(source_data.xuData);
31897
31869
  for (let index = 0; index < xu_data_keys.length; index++) {
31898
31870
  const key = xu_data_keys[index];
31899
- target_data.xuData[key] = klona.klona(source_data.xuData[key]);
31871
+ target_data.xuData[key] = structuredClone(source_data.xuData[key]);
31900
31872
  }
31901
31873
 
31902
31874
  const xu_attribute_keys = Object.keys(source_data.xuAttributes);
31903
31875
  for (let index = 0; index < xu_attribute_keys.length; index++) {
31904
31876
  const key = xu_attribute_keys[index];
31905
- target_data.xuAttributes[key] = klona.klona(source_data.xuAttributes[key]);
31877
+ target_data.xuAttributes[key] = structuredClone(source_data.xuAttributes[key]);
31906
31878
  }
31907
31879
  return $target;
31908
31880
  };
@@ -34069,7 +34041,7 @@ func.runtime.ui.refresh_screen = async function (options) {
34069
34041
  await func.runtime.render.render_ui_tree(
34070
34042
  options.SESSION_ID,
34071
34043
  $elm,
34072
- klona.klona(elm_data.xuData.node),
34044
+ structuredClone(elm_data.xuData.node),
34073
34045
  {},
34074
34046
  elm_data.xuData.paramsP,
34075
34047
  null,
@@ -34163,7 +34135,7 @@ func.runtime.ui.refresh_screen = async function (options) {
34163
34135
  await func.runtime.render.render_ui_tree(
34164
34136
  options.SESSION_ID,
34165
34137
  $div_elm,
34166
- klona.klona(item),
34138
+ structuredClone(item),
34167
34139
  {},
34168
34140
  wrapper_data.xuData.paramsP,
34169
34141
  null,
@@ -34511,7 +34483,7 @@ func.runtime.render.collect_dependency_fields_from_attributes = function (xu_att
34511
34483
  func.runtime.render.build_xu_render_original_data = function (options) {
34512
34484
  return {
34513
34485
  $container: options.$container,
34514
- nodeP: func.runtime.ui.get_node_snapshot ? func.runtime.ui.get_node_snapshot(options.nodeP) : klona.klona(options.nodeP),
34486
+ nodeP: func.runtime.ui.get_node_snapshot ? func.runtime.ui.get_node_snapshot(options.nodeP) : structuredClone(options.nodeP),
34515
34487
  parent_infoP: options.parent_infoP,
34516
34488
  paramsP: options.paramsP,
34517
34489
  keyP: options.keyP,
@@ -36614,7 +36586,7 @@ func.runtime.render.handle_xu_for = async function (options) {
36614
36586
  reference_source_obj,
36615
36587
  });
36616
36588
  func.runtime.render.apply_iterate_info_to_current_record(options.SESSION_ID, options.paramsP.dsSessionP, currentRecordId, _progFields, iterate_info);
36617
- const _parent_info = klona.klona(options.parent_infoP) || {};
36589
+ const _parent_info = structuredClone(options.parent_infoP) || {};
36618
36590
  _parent_info.iterate_info = iterate_info;
36619
36591
 
36620
36592
  const $divP = await func.runtime.render.render_ui_tree(options.SESSION_ID, options.$container, options.nodeP, _parent_info, options.paramsP, options.jobNoP, null, i, null, options.nodeP, null, options.$root_container);
@@ -36639,7 +36611,7 @@ func.runtime.render.handle_xu_for = async function (options) {
36639
36611
  reference_source_obj,
36640
36612
  });
36641
36613
  func.runtime.render.apply_iterate_info_to_current_record(options.SESSION_ID, options.paramsP.dsSessionP, currentRecordId, _progFields, iterate_info);
36642
- const _parent_info = klona.klona(options.parent_infoP) || {};
36614
+ const _parent_info = structuredClone(options.parent_infoP) || {};
36643
36615
  _parent_info.iterate_info = iterate_info;
36644
36616
 
36645
36617
  const $divP = await func.runtime.render.render_ui_tree(options.SESSION_ID, options.$container, options.nodeP, _parent_info, options.paramsP, options.jobNoP, null, i, null, options.nodeP, null, options.$root_container);
@@ -36654,7 +36626,6 @@ func.runtime.render.handle_xu_for = async function (options) {
36654
36626
  // (the template and first iteration child share the same xu-ui-id
36655
36627
  // because their key_path values collide).
36656
36628
  const _live_node = func.runtime.ui.get_first_node($live_elm);
36657
- const _parent_children_before = _live_node?.parentElement ? _live_node.parentElement.children.length : -1;
36658
36629
  if (_live_node) {
36659
36630
  _live_node.removeAttribute('xu-ui-id');
36660
36631
  func.runtime.ui.remove($live_elm);
@@ -36664,16 +36635,6 @@ func.runtime.render.handle_xu_for = async function (options) {
36664
36635
  _options_node.removeAttribute('xu-ui-id');
36665
36636
  func.runtime.ui.remove(options.$elm);
36666
36637
  }
36667
- const _parent_children_after = _live_node?.parentElement ? _live_node.parentElement.children.length : (options.$container ? func.runtime.ui.get_first_node(options.$container)?.children?.length : -1);
36668
- console.warn('[xu-for-debug] handle_xu_for template removal', {
36669
- had_live_node: !!_live_node,
36670
- had_options_node: !!_options_node,
36671
- same_node: _live_node === _options_node,
36672
- live_connected: _live_node?.isConnected,
36673
- iterations: i,
36674
- parent_children_before: _parent_children_before,
36675
- parent_children_after: _parent_children_after,
36676
- });
36677
36638
  return { abort: true, consume_placeholder: true };
36678
36639
  } catch (e) {
36679
36640
  console.error(' Iterator Arr parse error');
@@ -36768,7 +36729,7 @@ func.runtime.render.handle_legacy_xu_render = async function (options) {
36768
36729
  const new_$div = await func.runtime.render.render_ui_tree(
36769
36730
  options.SESSION_ID,
36770
36731
  options.$elm,
36771
- klona.klona(original_data_obj.nodeP),
36732
+ structuredClone(original_data_obj.nodeP),
36772
36733
  original_data_obj.parent_infoP,
36773
36734
  original_data_obj.paramsP,
36774
36735
  options.jobNoP,
@@ -37020,10 +36981,37 @@ func.runtime.render.apply_expression_attribute = async function (options) {
37020
36981
  return await options.common_fx[new_val.key](options.$elm, new_val);
37021
36982
  }
37022
36983
 
36984
+ if (new_val.key === 'class') {
36985
+ return func.runtime.render.apply_expression_class(options.$elm, new_val.value);
36986
+ }
36987
+
37023
36988
  const existing_value = func.runtime.ui.get_attr(options.$elm, new_val.key) || '';
37024
36989
  func.runtime.ui.set_attr(options.$elm, new_val.key, existing_value + new_val.value);
37025
36990
  return {};
37026
36991
  };
36992
+ func.runtime.render.apply_expression_class = function ($elm, new_class_value) {
36993
+ const xuData = func.runtime.ui.get_data($elm)?.xuData;
36994
+ const old_exp_classes = xuData?._exp_class_cache || '';
36995
+
36996
+ if (old_exp_classes) {
36997
+ const old_classes = old_exp_classes.split(/\s+/).filter(Boolean);
36998
+ for (let i = 0; i < old_classes.length; i++) {
36999
+ func.runtime.ui.remove_class($elm, old_classes[i]);
37000
+ }
37001
+ }
37002
+
37003
+ const new_value = (new_class_value || '').toString();
37004
+ const new_classes = new_value.split(/\s+/).filter(Boolean);
37005
+ for (let i = 0; i < new_classes.length; i++) {
37006
+ func.runtime.ui.add_class($elm, new_classes[i]);
37007
+ }
37008
+
37009
+ if (xuData) {
37010
+ xuData._exp_class_cache = new_value;
37011
+ }
37012
+
37013
+ return {};
37014
+ };
37027
37015
  func.runtime.render.apply_visibility = function ($elm, value) {
37028
37016
  if (value) {
37029
37017
  func.runtime.ui.show($elm);
@@ -37946,7 +37934,7 @@ func.datasource.prepare = async function (SESSION_ID, prog_id, dataSourceNoP, pa
37946
37934
  _ds.data_feed = {};
37947
37935
 
37948
37936
  // _ds.v.old_dataSource = _.cloneDeep(_ds);
37949
- _ds.v.old_dataSource = klona.klona(_ds);
37937
+ _ds.v.old_dataSource = structuredClone(_ds);
37950
37938
  } catch (err) {
37951
37939
  console.error('function: init_existing_dataSource - error');
37952
37940
  return;
@@ -39517,7 +39505,7 @@ func.datasource.update = async function (SESSION_ID, datasource_changes, update_
39517
39505
 
39518
39506
  await func.runtime.ui.refresh_screen({
39519
39507
  SESSION_ID,
39520
- fields_changed_arr: klona.klona(fields_changed),
39508
+ fields_changed_arr: structuredClone(fields_changed),
39521
39509
  datasource_changed: datasource_changed[0],
39522
39510
  fields_changed_datasource: datasource_changed[0],
39523
39511
  watcher: value,
@@ -39632,7 +39620,7 @@ func.datasource.update = async function (SESSION_ID, datasource_changes, update_
39632
39620
  // await func.UI.screen.refresh_xu_attributes(SESSION_ID, _.cloneDeep(fields_changed), null, null, findMin(datasource_changed), avoid_xu_for_refresh, trigger);
39633
39621
  await func.runtime.ui.refresh_xu_attributes({
39634
39622
  SESSION_ID,
39635
- fields_arr: klona.klona(fields_changed),
39623
+ fields_arr: structuredClone(fields_changed),
39636
39624
  jobNoP: null,
39637
39625
  $elm_to_search: null,
39638
39626
  dsSession_changed: findMin(datasource_changed),
@@ -39643,7 +39631,7 @@ func.datasource.update = async function (SESSION_ID, datasource_changes, update_
39643
39631
  // await removed from the below function cause to dead lock Mar 3 25
39644
39632
  await func.runtime.ui.refresh_screen({
39645
39633
  SESSION_ID,
39646
- fields_changed_arr: klona.klona(fields_changed),
39634
+ fields_changed_arr: structuredClone(fields_changed),
39647
39635
  datasource_changed: null,
39648
39636
  fields_changed_datasource: datasource_changed[0],
39649
39637
  });
@@ -40293,7 +40281,7 @@ func.datasource.set_VIEW_data = async function (SESSION_ID, args, _ds) {
40293
40281
  };
40294
40282
  _ds.viewEventExec_arr = {};
40295
40283
 
40296
- var view = klona.klona(await func.utils.VIEWS_OBJ.get(SESSION_ID, args.prog_id));
40284
+ var view = structuredClone(await func.utils.VIEWS_OBJ.get(SESSION_ID, args.prog_id));
40297
40285
  // var view = klona.klona(await func.utils.VIEWS_OBJ.get(SESSION_ID, args.prog_id));
40298
40286
 
40299
40287
  _ds.v.dataSourceSrcType = view.dataSourceSrcType;
@@ -45224,7 +45212,7 @@ func.index.new_webworker = async function (SESSION_ID, prog_obj, obj) {
45224
45212
 
45225
45213
  const init_worker_session = function (worker_id) {
45226
45214
  const { root_element, ...sessionData } = SESSION_OBJ[SESSION_ID];
45227
- var _session = klona.klona(sessionData);
45215
+ var _session = JSON.parse(JSON.stringify(sessionData));
45228
45216
 
45229
45217
  const get_parent_ds = function (ds) {
45230
45218
  var ds_obj = {};