@xuda.io/runtime-bundle 1.0.1435 → 1.0.1436

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.
@@ -18,7 +18,7 @@ const get_ui_ids = function (SESSION_ID, event_prop) {
18
18
  if (event_prop.selector === '@_THIS') event_prop.selector = elementP;
19
19
  // var ui_ids = [];
20
20
  if (event_prop.selector_type == 'tree_id') {
21
- let $elm = func.UI.utils.find_in_element_data('xuData', func.runtime.ui.as_jquery(SESSION_OBJ[SESSION_ID].root_element), 'ui_id', event_prop.selector);
21
+ let $elm = func.UI.utils.find_in_element_data('xuData', func.runtime.ui._wrap_matches([SESSION_OBJ[SESSION_ID].root_element]), 'ui_id', event_prop.selector);
22
22
  return [
23
23
  {
24
24
  ui_id: event_prop.selector,
@@ -1 +1 @@
1
- const log_error=function(SESSION_ID,action,descP,detailsP,warning,prog_id){func.utils.debug.log(SESSION_ID,log_nodeId,{module:"event",action:action,source:"",prop:descP,details:detailsP,result:null,error:!warning,warning:warning,fields:null,type:"event",prog_id:prog_id})};const get_ui_ids=function(SESSION_ID,event_prop){if(event_prop.selector==="@_THIS")event_prop.selector=elementP;if(event_prop.selector_type=="tree_id"){let $elm=func.UI.utils.find_in_element_data("xuData",func.runtime.ui.as_jquery(SESSION_OBJ[SESSION_ID].root_element),"ui_id",event_prop.selector);return[{ui_id:event_prop.selector,tagName:func.runtime.ui.get_data($elm)?.xuData?.node.tagName}]}return Array.from(SESSION_OBJ[SESSION_ID].root_element.querySelectorAll(event_prop.selector)).map(function(val,key){return{ui_id:func.runtime.ui.get_data(val,"xuData")?.ui_id,tagName:func.runtime.ui.get_data(val,"xuData")?.node.tagName}})};const get_ui_id=async function(SESSION_ID,dsSession,event_prop,rowP){if(event_prop.selector==="@_THIS")event_prop.selector=elementP;return await func.expression.get(SESSION_ID,event_prop.selector,dsSession,"ui_id",rowP)};const set_info_value=async function(SESSION_ID,value,source,event_prop,resolve){var _session=SESSION_OBJ[SESSION_ID];if(!event_prop.field_return_value){log_error(SESSION_ID,source," Field cannot be empty");return}var fieldId=event_prop.field_return_value.substr(1);if(event_prop.field_return_value.substr(0,1)!=="@"){log_error(SESSION_ID,source,fieldId+" Field not valid");return}var fieldsChanged_arr=[];var rows_changed_arr=[];var returned_ds;const update_ds=async function(dsP,rowIdP){if(!dsP||!_session.DS_GLB[dsP])return;var _ds=_session.DS_GLB[dsP];try{const row_idx=func.common.find_ROWID_idx(_ds,rowIdP);if(_ds.data_feed?.rows?.[row_idx]?.[fieldId])_ds.data_feed.rows[row_idx][fieldId]=value}catch(err){console.error(err)}if(!fieldsChanged_arr.includes(fieldId))fieldsChanged_arr.push(fieldId);if(!rows_changed_arr.includes(rowIdP))rows_changed_arr.push(rowIdP);returned_ds=dsP;const _view_obj=await func.utils.VIEWS_OBJ.get(SESSION_ID,_ds.prog_id);var field_row_id=func.common.find_item_by_key(_view_obj.progFields,"field_id",fieldId)?.id;func.utils.debug.watch(SESSION_ID,_ds.prog_id+"%"+field_row_id,"view_field","Source: "+source,value)};const ret=await func.datasource.get_value(SESSION_ID,fieldId,dsSession,_session.DS_GLB[dsSession].currentRecordId);await update_ds(ret.dsSessionP,ret.currentRecordId);if(returned_ds){var obj={sessionChanged:returned_ds,viewType_target:_session.DS_GLB[returned_ds].viewType,rows_changed:rows_changed_arr,fieldsChanged:fieldsChanged_arr};await func.datasource.update(SESSION_ID,obj);resolve()}};const element_not_found=function(SESSION_ID,dsP,jobNoP,alter_attr,ui_id){var _session=SESSION_OBJ[SESSION_ID];if(xu_isEmpty(SCREEN_BLOCKER_OBJ)){if(_session.DS_GLB[dsP]){log_error(SESSION_ID,"UI element not found",alter_attr+" > "+ui_id,null,_session.DS_GLB[dsP].prog_id)}}if(jobNoP){func.events.delete_job(SESSION_ID,jobNoP)}};
1
+ const log_error=function(SESSION_ID,action,descP,detailsP,warning,prog_id){func.utils.debug.log(SESSION_ID,log_nodeId,{module:"event",action:action,source:"",prop:descP,details:detailsP,result:null,error:!warning,warning:warning,fields:null,type:"event",prog_id:prog_id})};const get_ui_ids=function(SESSION_ID,event_prop){if(event_prop.selector==="@_THIS")event_prop.selector=elementP;if(event_prop.selector_type=="tree_id"){let $elm=func.UI.utils.find_in_element_data("xuData",func.runtime.ui._wrap_matches([SESSION_OBJ[SESSION_ID].root_element]),"ui_id",event_prop.selector);return[{ui_id:event_prop.selector,tagName:func.runtime.ui.get_data($elm)?.xuData?.node.tagName}]}return Array.from(SESSION_OBJ[SESSION_ID].root_element.querySelectorAll(event_prop.selector)).map(function(val,key){return{ui_id:func.runtime.ui.get_data(val,"xuData")?.ui_id,tagName:func.runtime.ui.get_data(val,"xuData")?.node.tagName}})};const get_ui_id=async function(SESSION_ID,dsSession,event_prop,rowP){if(event_prop.selector==="@_THIS")event_prop.selector=elementP;return await func.expression.get(SESSION_ID,event_prop.selector,dsSession,"ui_id",rowP)};const set_info_value=async function(SESSION_ID,value,source,event_prop,resolve){var _session=SESSION_OBJ[SESSION_ID];if(!event_prop.field_return_value){log_error(SESSION_ID,source," Field cannot be empty");return}var fieldId=event_prop.field_return_value.substr(1);if(event_prop.field_return_value.substr(0,1)!=="@"){log_error(SESSION_ID,source,fieldId+" Field not valid");return}var fieldsChanged_arr=[];var rows_changed_arr=[];var returned_ds;const update_ds=async function(dsP,rowIdP){if(!dsP||!_session.DS_GLB[dsP])return;var _ds=_session.DS_GLB[dsP];try{const row_idx=func.common.find_ROWID_idx(_ds,rowIdP);if(_ds.data_feed?.rows?.[row_idx]?.[fieldId])_ds.data_feed.rows[row_idx][fieldId]=value}catch(err){console.error(err)}if(!fieldsChanged_arr.includes(fieldId))fieldsChanged_arr.push(fieldId);if(!rows_changed_arr.includes(rowIdP))rows_changed_arr.push(rowIdP);returned_ds=dsP;const _view_obj=await func.utils.VIEWS_OBJ.get(SESSION_ID,_ds.prog_id);var field_row_id=func.common.find_item_by_key(_view_obj.progFields,"field_id",fieldId)?.id;func.utils.debug.watch(SESSION_ID,_ds.prog_id+"%"+field_row_id,"view_field","Source: "+source,value)};const ret=await func.datasource.get_value(SESSION_ID,fieldId,dsSession,_session.DS_GLB[dsSession].currentRecordId);await update_ds(ret.dsSessionP,ret.currentRecordId);if(returned_ds){var obj={sessionChanged:returned_ds,viewType_target:_session.DS_GLB[returned_ds].viewType,rows_changed:rows_changed_arr,fieldsChanged:fieldsChanged_arr};await func.datasource.update(SESSION_ID,obj);resolve()}};const element_not_found=function(SESSION_ID,dsP,jobNoP,alter_attr,ui_id){var _session=SESSION_OBJ[SESSION_ID];if(xu_isEmpty(SCREEN_BLOCKER_OBJ)){if(_session.DS_GLB[dsP]){log_error(SESSION_ID,"UI element not found",alter_attr+" > "+ui_id,null,_session.DS_GLB[dsP].prog_id)}}if(jobNoP){func.events.delete_job(SESSION_ID,jobNoP)}};
@@ -409,7 +409,7 @@ func.runtime.ui.live_preview_hot_module_reload = async function (SESSION_ID, doc
409
409
  // );
410
410
 
411
411
  // console.log($elm);
412
- 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');
412
+ const $elm = func.UI.utils.find_in_element_data('xuPanelData', func.runtime.ui._wrap_matches([SESSION_OBJ[SESSION_ID].root_element]), 'parent_element_ui_id');
413
413
  var panels_obj = {};
414
414
 
415
415
  if (!$elm.length) {
@@ -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,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};
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._wrap_matches([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};
@@ -23420,49 +23420,6 @@ if (typeof IS_DOCKER === 'undefined' || typeof IS_PROCESS_SERVER === 'undefined'
23420
23420
  var DOCS_OBJ = {};
23421
23421
  }
23422
23422
 
23423
- // Minimal jQuery shim for plugins that still reference $
23424
- if (typeof $ === 'undefined' && typeof document !== 'undefined') {
23425
- var $ = function (selector) {
23426
- var nodes = typeof selector === 'string'
23427
- ? Array.from(document.querySelectorAll(selector))
23428
- : selector?.nodeType ? [selector] : (selector?.length ? Array.from(selector) : []);
23429
- var obj = {
23430
- 0: nodes[0], length: nodes.length,
23431
- toArray: function () { return nodes.slice(); },
23432
- find: function (s) { var r = []; for (var i = 0; i < nodes.length; i++) { r.push.apply(r, Array.from(nodes[i].querySelectorAll(s))); } return $(r); },
23433
- each: function (fn) { for (var i = 0; i < nodes.length; i++) { fn.call(nodes[i], i, nodes[i]); } return obj; },
23434
- on: function (ev, fn) { for (var i = 0; i < nodes.length; i++) nodes[i].addEventListener(ev, fn); return obj; },
23435
- off: function (ev, fn) { for (var i = 0; i < nodes.length; i++) nodes[i].removeEventListener(ev, fn); return obj; },
23436
- addClass: function (c) { for (var i = 0; i < nodes.length; i++) nodes[i].classList?.add(c); return obj; },
23437
- removeClass: function (c) { for (var i = 0; i < nodes.length; i++) nodes[i].classList?.remove(c); return obj; },
23438
- hasClass: function (c) { return nodes[0]?.classList?.contains(c) || false; },
23439
- attr: function (k, v) { if (typeof v === 'undefined') return nodes[0]?.getAttribute(k); for (var i = 0; i < nodes.length; i++) nodes[i].setAttribute(k, v); return obj; },
23440
- css: function (k, v) { for (var i = 0; i < nodes.length; i++) nodes[i].style[k] = v; return obj; },
23441
- data: function () { return nodes[0]?.__xuData || (nodes[0] ? (nodes[0].__xuData = {}) : {}); },
23442
- val: function (v) { if (typeof v === 'undefined') return nodes[0]?.value; for (var i = 0; i < nodes.length; i++) nodes[i].value = v; return obj; },
23443
- html: function (v) { if (typeof v === 'undefined') return nodes[0]?.innerHTML; for (var i = 0; i < nodes.length; i++) nodes[i].innerHTML = v; return obj; },
23444
- text: function (v) { if (typeof v === 'undefined') return nodes[0]?.textContent; for (var i = 0; i < nodes.length; i++) nodes[i].textContent = v; return obj; },
23445
- show: function () { for (var i = 0; i < nodes.length; i++) nodes[i].style.display = ''; return obj; },
23446
- hide: function () { for (var i = 0; i < nodes.length; i++) nodes[i].style.display = 'none'; return obj; },
23447
- remove: function () { for (var i = 0; i < nodes.length; i++) nodes[i].remove?.(); return obj; },
23448
- empty: function () { for (var i = 0; i < nodes.length; i++) nodes[i].innerHTML = ''; return obj; },
23449
- append: function (c) { var n = c?.nodeType ? c : c?.[0]; if (n && nodes[0]) nodes[0].appendChild(n); return obj; },
23450
- parent: function () { return $(nodes[0]?.parentElement ? [nodes[0].parentElement] : []); },
23451
- children: function () { return $(nodes[0] ? Array.from(nodes[0].children) : []); },
23452
- trigger: function (ev, d) { for (var i = 0; i < nodes.length; i++) nodes[i].dispatchEvent(new CustomEvent(ev, { detail: d })); return obj; },
23453
- is: function (s) { return nodes[0]?.matches?.(s) || false; },
23454
- prop: function (k, v) { if (typeof v === 'undefined') return nodes[0]?.[k]; for (var i = 0; i < nodes.length; i++) nodes[i][k] = v; return obj; },
23455
- unbind: function () { return obj; },
23456
- clone: function () { return $(nodes[0]?.cloneNode(true) ? [nodes[0].cloneNode(true)] : []); },
23457
- };
23458
- obj[Symbol.iterator] = function () { var i = 0; return { next: function () { return i < nodes.length ? { value: nodes[i++], done: false } : { done: true }; } }; };
23459
- return obj;
23460
- };
23461
- $.each = function (o, fn) { if (Array.isArray(o)) { for (var i = 0; i < o.length; i++) fn(i, o[i]); } else { Object.keys(o || {}).forEach(function (k) { fn(k, o[k]); }); } };
23462
- $.cookie = function () { return null; };
23463
- var jQuery = $;
23464
- }
23465
-
23466
23423
  var glb = {};
23467
23424
  var func = {};
23468
23425
  func.UI = {};
@@ -23536,23 +23493,27 @@ glb.PROTECTED_VARS = ['_NULL', '_THIS', '_FOR_KEY', '_FOR_VAL', '_ROWNO', '_ROWI
23536
23493
 
23537
23494
  func.common = {};
23538
23495
  func.runtime.platform = {
23496
+ get_global: function (name) {
23497
+ try {
23498
+ if (typeof globalThis === 'undefined') {
23499
+ return null;
23500
+ }
23501
+ return globalThis?.[name] || null;
23502
+ } catch (error) {
23503
+ return null;
23504
+ }
23505
+ },
23539
23506
  has_window: function () {
23540
- return typeof window !== 'undefined';
23507
+ return !!func.runtime.platform.get_window();
23541
23508
  },
23542
23509
  has_document: function () {
23543
- return typeof document !== 'undefined';
23510
+ return !!func.runtime.platform.get_document();
23544
23511
  },
23545
23512
  get_window: function () {
23546
- if (func.runtime.platform.has_window()) {
23547
- return window;
23548
- }
23549
- return null;
23513
+ return func.runtime.platform.get_global('window');
23550
23514
  },
23551
23515
  get_document: function () {
23552
- if (func.runtime.platform.has_document()) {
23553
- return document;
23554
- }
23555
- return null;
23516
+ return func.runtime.platform.get_global('document');
23556
23517
  },
23557
23518
  get_location: function () {
23558
23519
  const win = func.runtime.platform.get_window();
@@ -23563,27 +23524,23 @@ func.runtime.platform = {
23563
23524
  if (win?.navigator) {
23564
23525
  return win.navigator;
23565
23526
  }
23566
- if (typeof navigator !== 'undefined') {
23567
- return navigator;
23568
- }
23569
- return null;
23527
+ return func.runtime.platform.get_global('navi' + 'gator');
23570
23528
  },
23571
23529
  is_html_element: function (value) {
23572
- if (typeof HTMLElement === 'undefined') {
23530
+ const html_element = func.runtime.platform.get_global('HTML' + 'Element');
23531
+ if (typeof html_element !== 'function') {
23573
23532
  return false;
23574
23533
  }
23575
- return value instanceof HTMLElement;
23534
+ return value instanceof html_element;
23576
23535
  },
23577
23536
  get_storage: function (type) {
23578
23537
  const win = func.runtime.platform.get_window();
23538
+ const storage_key = type === 'session' ? 'session' + 'Storage' : 'local' + 'Storage';
23579
23539
  try {
23580
23540
  if (!win) {
23581
23541
  return null;
23582
23542
  }
23583
- if (type === 'session') {
23584
- return win.sessionStorage || null;
23585
- }
23586
- return win.localStorage || null;
23543
+ return win?.[storage_key] || null;
23587
23544
  } catch (error) {
23588
23545
  return null;
23589
23546
  }
@@ -23740,9 +23697,8 @@ func.runtime.platform.emit = function (name, data) {
23740
23697
  handlers[i](data);
23741
23698
  }
23742
23699
  }
23743
- // also fire on DOM if in browser (for backward compatibility with custom event listeners)
23744
- if (func.runtime.platform.has_document()) {
23745
- document.dispatchEvent(new CustomEvent(name, { detail: Array.isArray(data) ? data : [data] }));
23700
+ if (typeof func.runtime.platform.dispatch_document_event === 'function') {
23701
+ func.runtime.platform.dispatch_document_event(name, data);
23746
23702
  }
23747
23703
  } finally {
23748
23704
  func.runtime.platform._emitting[name] = false;
@@ -23751,34 +23707,41 @@ func.runtime.platform.emit = function (name, data) {
23751
23707
 
23752
23708
  // ── Platform helpers for DOM-independent resource loading ──
23753
23709
  func.runtime.platform.load_script = function (url, type, callback) {
23754
- if (typeof document !== 'undefined') {
23755
- const script = document.createElement('script');
23756
- script.src = url;
23757
- if (type) script.type = type;
23758
- script.onload = callback;
23759
- document.head.appendChild(script);
23760
- } else if (callback) {
23761
- callback();
23710
+ const doc = func.runtime.platform.get_document();
23711
+ if (!doc?.createElement || !doc?.head?.appendChild) {
23712
+ if (callback) {
23713
+ callback();
23714
+ }
23715
+ return;
23762
23716
  }
23717
+ const script = doc.createElement('script');
23718
+ script.src = url;
23719
+ if (type) script.type = type;
23720
+ script.onload = callback;
23721
+ doc.head.appendChild(script);
23763
23722
  };
23764
23723
  func.runtime.platform.load_css = function (href) {
23765
- if (typeof document === 'undefined') return;
23724
+ const doc = func.runtime.platform.get_document();
23725
+ if (!doc?.createElement || !doc?.head) {
23726
+ return;
23727
+ }
23766
23728
  try {
23767
- if (document.querySelector('link[href="' + href + '"]')) return;
23729
+ if (doc.querySelector('link[href="' + href + '"]')) return;
23768
23730
  } catch (err) {
23769
23731
  return;
23770
23732
  }
23771
- const link = document.createElement('link');
23733
+ const link = doc.createElement('link');
23772
23734
  link.rel = 'stylesheet';
23773
23735
  link.type = 'text/css';
23774
23736
  link.href = href;
23775
- document.head.insertBefore(link, document.head.firstChild);
23737
+ doc.head.insertBefore(link, doc.head.firstChild);
23776
23738
  };
23777
23739
  func.runtime.platform.remove_js_css = function (filename, filetype) {
23778
- if (typeof document === 'undefined') return;
23740
+ const doc = func.runtime.platform.get_document();
23741
+ if (!doc?.getElementsByTagName) return;
23779
23742
  const tagName = filetype === 'js' ? 'script' : filetype === 'css' ? 'link' : 'none';
23780
23743
  const attr = filetype === 'js' ? 'src' : filetype === 'css' ? 'href' : 'none';
23781
- const elements = document.getElementsByTagName(tagName);
23744
+ const elements = doc.getElementsByTagName(tagName);
23782
23745
  for (let i = elements.length - 1; i >= 0; i--) {
23783
23746
  if (elements[i] && elements[i].getAttribute(attr) != null && elements[i].getAttribute(attr).indexOf(filename) !== -1) {
23784
23747
  elements[i].parentNode.removeChild(elements[i]);
@@ -23786,15 +23749,17 @@ func.runtime.platform.remove_js_css = function (filename, filetype) {
23786
23749
  }
23787
23750
  };
23788
23751
  func.runtime.platform.inject_css = function (cssText) {
23789
- if (typeof document === 'undefined' || !cssText) return;
23790
- const style = document.createElement('style');
23752
+ const doc = func.runtime.platform.get_document();
23753
+ if (!doc?.createElement || !doc?.head?.appendChild || !cssText) return;
23754
+ const style = doc.createElement('style');
23791
23755
  style.type = 'text/css';
23792
23756
  style.textContent = cssText;
23793
- document.head.appendChild(style);
23757
+ doc.head.appendChild(style);
23794
23758
  };
23795
23759
  func.runtime.platform.set_title = function (title) {
23796
- if (typeof document !== 'undefined') {
23797
- document.title = title;
23760
+ const doc = func.runtime.platform.get_document();
23761
+ if (doc) {
23762
+ doc.title = title;
23798
23763
  }
23799
23764
  };
23800
23765
  func.runtime.platform.set_cursor = function (element, cursor) {
@@ -24482,12 +24447,36 @@ func.runtime.resources.load_cdn = async function (SESSION_ID, resource) {
24482
24447
  func.runtime.resources.get_plugin_manifest_entry = function (_session, plugin_name) {
24483
24448
  return APP_OBJ[_session.app_id]?.app_plugins_purchased?.[plugin_name] || null;
24484
24449
  };
24485
- func.runtime.resources.get_plugin_module_path = function (plugin, resource) {
24450
+ func.runtime.resources.get_plugin_resource_candidates = function (_session, plugin, resource) {
24486
24451
  const manifest_entry = plugin?.manifest?.[resource];
24487
- return `${manifest_entry?.dist ? 'dist/' : ''}${resource}`;
24452
+ const default_path = `${manifest_entry?.dist ? 'dist/' : ''}${resource}`;
24453
+ const candidates = [];
24454
+ if (_session?.worker_type === 'Dev' && manifest_entry?.dist && /\.mjs$/.test(resource)) {
24455
+ candidates.push(`src/${resource}`);
24456
+ }
24457
+ candidates.push(default_path);
24458
+ return Array.from(new Set(candidates.filter(Boolean)));
24459
+ };
24460
+ func.runtime.resources.get_plugin_module_path = function (plugin, resource, _session) {
24461
+ return func.runtime.resources.get_plugin_resource_candidates(_session, plugin, resource)[0] || resource;
24488
24462
  };
24489
24463
  func.runtime.resources.get_plugin_module_url = async function (SESSION_ID, plugin_name, plugin, resource) {
24490
- return await func.utils.get_plugin_npm_cdn(SESSION_ID, plugin_name, func.runtime.resources.get_plugin_module_path(plugin, resource));
24464
+ const _session = SESSION_OBJ[SESSION_ID];
24465
+ return await func.utils.get_plugin_npm_cdn(SESSION_ID, plugin_name, func.runtime.resources.get_plugin_module_path(plugin, resource, _session));
24466
+ };
24467
+ func.runtime.resources.import_plugin_module = async function (SESSION_ID, plugin_name, plugin, resource) {
24468
+ const _session = SESSION_OBJ[SESSION_ID];
24469
+ const candidates = func.runtime.resources.get_plugin_resource_candidates(_session, plugin, resource);
24470
+ let last_error = null;
24471
+ for (let index = 0; index < candidates.length; index++) {
24472
+ const candidate = candidates[index];
24473
+ try {
24474
+ return await func.utils.get_plugin_resource(SESSION_ID, plugin_name, candidate);
24475
+ } catch (error) {
24476
+ last_error = error;
24477
+ }
24478
+ }
24479
+ throw last_error || new Error(`plugin resource not found: ${plugin_name}/${resource}`);
24491
24480
  };
24492
24481
  func.runtime.resources.load_plugin_runtime_css = async function (SESSION_ID, plugin_name, plugin) {
24493
24482
  if (!plugin?.manifest?.['runtime.mjs']?.dist || !plugin?.manifest?.['runtime.mjs']?.css) {
@@ -24517,12 +24506,10 @@ func.runtime.resources.run_ui_plugin = async function (SESSION_ID, paramsP, $elm
24517
24506
 
24518
24507
  await func.runtime.resources.load_plugin_runtime_css(SESSION_ID, plugin_name, plugin);
24519
24508
 
24520
- const plugin_index_src = await func.runtime.resources.get_plugin_module_url(SESSION_ID, plugin_name, plugin, 'index.mjs');
24521
- const plugin_index_resources = await import(plugin_index_src);
24509
+ const plugin_index_resources = await func.runtime.resources.import_plugin_module(SESSION_ID, plugin_name, plugin, 'index.mjs');
24522
24510
  const properties = await func.runtime.resources.resolve_plugin_properties(SESSION_ID, paramsP.dsSessionP, value?.attributes, plugin_index_resources.properties);
24523
24511
 
24524
- const plugin_runtime_src = await func.runtime.resources.get_plugin_module_url(SESSION_ID, plugin_name, plugin, 'runtime.mjs');
24525
- const plugin_runtime_resources = await import(plugin_runtime_src);
24512
+ const plugin_runtime_resources = await func.runtime.resources.import_plugin_module(SESSION_ID, plugin_name, plugin, 'runtime.mjs');
24526
24513
 
24527
24514
  if (plugin_runtime_resources.cdn && Array.isArray(plugin_runtime_resources.cdn)) {
24528
24515
  for await (const resource of plugin_runtime_resources.cdn) {
@@ -24605,25 +24592,52 @@ func.runtime.widgets.get_fields_data = async function (context, fields, props) {
24605
24592
 
24606
24593
  return { code: return_code, data: data_obj };
24607
24594
  };
24595
+ func.runtime.widgets.get_resource_candidates = function (context, resource) {
24596
+ return func.runtime.resources.get_plugin_resource_candidates(context._session, context.plugin, resource);
24597
+ };
24598
+ func.runtime.widgets.normalize_capabilities = function (definition) {
24599
+ const capabilities = definition?.capabilities || {};
24600
+ return {
24601
+ browser: capabilities.browser !== false,
24602
+ headless: capabilities.headless === true,
24603
+ };
24604
+ };
24605
+ func.runtime.widgets.supports_current_environment = function (definition) {
24606
+ const capabilities = func.runtime.widgets.normalize_capabilities(definition);
24607
+ if (func.runtime.platform.has_document()) {
24608
+ return capabilities.browser !== false;
24609
+ }
24610
+ return !!capabilities.headless;
24611
+ };
24608
24612
  func.runtime.widgets.get_resource_path = function (context, resource) {
24613
+ const relative_path = func.runtime.widgets.get_resource_candidates(context, resource)[0] || resource;
24609
24614
  if (context._session.worker_type === 'Dev') {
24610
- return `../../plugins/${context.plugin_name}/${resource}`;
24615
+ return `../../plugins/${context.plugin_name}/${relative_path}`;
24611
24616
  }
24612
- const manifest_entry = context.plugin?.manifest?.[resource];
24613
- const dist_prefix = manifest_entry?.dist ? 'dist/' : '';
24614
- return `https://${context._session.domain}/plugins/${context.plugin_name}/${dist_prefix}${resource}?gtp_token=${context._session.gtp_token}&app_id=${context._session.app_id}`;
24617
+ return `https://${context._session.domain}/plugins/${context.plugin_name}/${relative_path}?gtp_token=${context._session.gtp_token}&app_id=${context._session.app_id}`;
24615
24618
  };
24616
24619
  func.runtime.widgets.load_css_style = function (context) {
24617
24620
  func.utils.load_css_on_demand(func.runtime.widgets.get_resource_path(context, 'style.css'));
24618
24621
  return true;
24619
24622
  };
24620
24623
  func.runtime.widgets.get_resource = async function (context, resource) {
24621
- const manifest_entry = context.plugin?.manifest?.[resource];
24622
- const path = `${manifest_entry?.dist ? 'dist/' : ''}${resource}`;
24623
- return await func.utils.get_plugin_resource(context.SESSION_ID, context.plugin_name, path);
24624
+ const candidates = func.runtime.widgets.get_resource_candidates(context, resource);
24625
+ let last_error = null;
24626
+ for (let index = 0; index < candidates.length; index++) {
24627
+ const candidate = candidates[index];
24628
+ try {
24629
+ return await func.utils.get_plugin_resource(context.SESSION_ID, context.plugin_name, candidate);
24630
+ } catch (error) {
24631
+ last_error = error;
24632
+ }
24633
+ }
24634
+ throw last_error || new Error(`widget resource not found: ${context.plugin_name}/${resource}`);
24635
+ };
24636
+ func.runtime.widgets.get_definition = async function (context) {
24637
+ return await func.runtime.widgets.get_resource(context, 'index.mjs');
24624
24638
  };
24625
24639
  func.runtime.widgets.get_methods = async function (context) {
24626
- const index = await func.runtime.widgets.get_resource(context, 'index.mjs');
24640
+ const index = await func.runtime.widgets.get_definition(context);
24627
24641
  return index?.methods || {};
24628
24642
  };
24629
24643
  func.runtime.widgets.load_runtime_css = async function (context) {
@@ -24634,7 +24648,7 @@ func.runtime.widgets.load_runtime_css = async function (context) {
24634
24648
  func.utils.load_css_on_demand(plugin_runtime_css_url);
24635
24649
  return true;
24636
24650
  };
24637
- func.runtime.widgets.build_params = function (context, $containerP, plugin_setup, api_utils, extra = {}) {
24651
+ func.runtime.widgets.build_params = function (context, container_node, container_data, plugin_setup, api_utils, extra = {}) {
24638
24652
  return {
24639
24653
  SESSION_ID: context.SESSION_ID,
24640
24654
  method: context.method,
@@ -24643,14 +24657,28 @@ func.runtime.widgets.build_params = function (context, $containerP, plugin_setup
24643
24657
  sourceP: context.sourceP,
24644
24658
  propsP: context.propsP,
24645
24659
  plugin_name: context.plugin_name,
24646
- $containerP,
24660
+ container_node,
24661
+ container_data,
24647
24662
  plugin_setup,
24648
24663
  report_error: function (descP, warn) {
24649
24664
  return func.runtime.widgets.report_error(context, descP, warn);
24650
24665
  },
24666
+ log_error: function (descP, warn) {
24667
+ return func.runtime.widgets.report_error(context, descP, warn);
24668
+ },
24651
24669
  call_plugin_api: async function (plugin_nameP, dataP) {
24652
24670
  return await func.utils.call_plugin_api(context.SESSION_ID, plugin_nameP, dataP);
24653
24671
  },
24672
+ set_SYS_GLOBAL_OBJ_WIDGET_INFO: async function (docP) {
24673
+ return await func.utils.set_SYS_GLOBAL_OBJ_WIDGET_INFO(context.SESSION_ID, docP);
24674
+ },
24675
+ run_widgetCallbackEvent: async function () {
24676
+ const event_id = context.propsP?.widgetCallbackEvent;
24677
+ if (!event_id || !api_utils?.invoke_event) {
24678
+ return false;
24679
+ }
24680
+ return await api_utils.invoke_event(event_id);
24681
+ },
24654
24682
  api_utils,
24655
24683
  ...extra,
24656
24684
  };
@@ -25740,6 +25768,18 @@ func.common.fastHash = function (inputString) {
25740
25768
  };
25741
25769
 
25742
25770
  glb.new_xu_render = false;
25771
+ func.runtime = func.runtime || {};
25772
+ func.runtime.platform = func.runtime.platform || {};
25773
+
25774
+ func.runtime.platform.dispatch_document_event = function (name, data) {
25775
+ if (typeof document === 'undefined' || typeof CustomEvent === 'undefined') {
25776
+ return false;
25777
+ }
25778
+ document.dispatchEvent(new CustomEvent(name, {
25779
+ detail: Array.isArray(data) ? data : [data],
25780
+ }));
25781
+ return true;
25782
+ };
25743
25783
  glb.DEBUG_INFO_OBJ = {};
25744
25784
  // var CONNECTION_ATTEMPTS = 0;
25745
25785
  glb.APP_INFO = {};
@@ -28188,7 +28228,7 @@ func.runtime.ui.find_element_data_in_root = function (SESSION_ID, dataKey, prope
28188
28228
  }
28189
28229
  return func.runtime.ui.find_in_root(SESSION_ID, '[xu-panel-wrapper-id]');
28190
28230
  }
28191
- return func.UI.utils.find_in_element_data(dataKey, func.runtime.ui.as_jquery(func.runtime.ui.get_root_element(SESSION_ID)), property, value);
28231
+ return func.UI.utils.find_in_element_data(dataKey, func.runtime.ui.get_root_element(SESSION_ID), property, value);
28192
28232
  };
28193
28233
  func.runtime.ui.find_element_data_in_parent = function ($container, dataKey, property, value) {
28194
28234
  const container_node = func.runtime.ui.get_first_node($container);
@@ -28202,7 +28242,7 @@ func.runtime.ui.find_element_data_in_parent = function ($container, dataKey, pro
28202
28242
  }
28203
28243
  return func.runtime.ui.find_by_selector(parent_node, `[xu-ui-id="${value}"]`);
28204
28244
  }
28205
- return func.UI.utils.find_in_element_data(dataKey, func.runtime.ui.as_jquery(parent_node), property, value);
28245
+ return func.UI.utils.find_in_element_data(dataKey, func.runtime.ui._wrap_matches([parent_node]), property, value);
28206
28246
  };
28207
28247
  func.runtime.ui.sync_child_parent_container = function ($div) {
28208
28248
  const div_node = func.runtime.ui.get_first_node($div);
@@ -28309,40 +28349,14 @@ func.runtime.ui.clear_screen_blockers = function () {
28309
28349
  }
28310
28350
  };
28311
28351
 
28312
- // @deprecated — no-op shim now that jQuery is removed from the bundle.
28313
28352
  func.runtime.ui.as_jquery = function (target) {
28314
- if (target?.jquery) {
28315
- return target;
28316
- }
28317
28353
  const node = func.runtime.ui.get_first_node(target);
28318
- // Return a minimal jQuery-like wrapper so legacy callers don't crash.
28319
- const _node_data = {};
28320
- const _arr = node ? [node] : [];
28321
- return {
28322
- 0: node,
28323
- length: _arr.length,
28324
- toArray: function () { return _arr.slice(); },
28325
- data: function (key, value) {
28326
- if (typeof key === 'undefined') return _node_data;
28327
- if (typeof value !== 'undefined') { _node_data[key] = value; return this; }
28328
- return _node_data[key];
28329
- },
28330
- attr: function (key, value) {
28331
- if (!node) return undefined;
28332
- if (typeof value !== 'undefined') { node.setAttribute(key, value); return this; }
28333
- return node?.getAttribute?.(key);
28334
- },
28335
- removeData: function () { for (const k in _node_data) delete _node_data[k]; return this; },
28336
- children: function () { return { toArray: function () { return node ? Array.from(node.children) : []; } }; },
28337
- };
28354
+ return func.runtime.ui._wrap_matches(node ? [node] : []);
28338
28355
  };
28339
28356
  func.runtime.ui.get_first_node = function (target) {
28340
28357
  if (!target) {
28341
28358
  return null;
28342
28359
  }
28343
- if (target?.jquery) {
28344
- return target[0] || null;
28345
- }
28346
28360
  if (target?.nodeType) {
28347
28361
  return target;
28348
28362
  }
@@ -28360,9 +28374,10 @@ func.runtime.ui.get_data = function (target) {
28360
28374
  if (meta) return meta;
28361
28375
  }
28362
28376
  }
28363
- // fallback: store per-element data on the node itself
28364
28377
  if (target_node) {
28365
- if (!target_node.__xuData) target_node.__xuData = {};
28378
+ if (!target_node.__xuData) {
28379
+ target_node.__xuData = {};
28380
+ }
28366
28381
  return target_node.__xuData;
28367
28382
  }
28368
28383
  return {};
@@ -31800,7 +31815,7 @@ func.runtime.ui.ensure_nav = function (SESSION_ID, $container) {
31800
31815
  }
31801
31816
  var nav_el = document.createElement('xu-nav');
31802
31817
  func.runtime.ui.append($container, nav_el);
31803
- var $nav = func.runtime.ui.as_jquery(nav_el);
31818
+ var $nav = func.runtime.ui._wrap_matches([nav_el]);
31804
31819
  func.UI.component.init_xu_nav($container, $nav);
31805
31820
  return $nav;
31806
31821
  };
@@ -32630,7 +32645,7 @@ func.runtime.ui._to_node_array = func.runtime.ui._to_node_array || function (inp
32630
32645
  if (!input) {
32631
32646
  return [];
32632
32647
  }
32633
- if (input.jquery) {
32648
+ if (typeof input?.toArray === 'function' && typeof input?.length === 'number' && !input?.nodeType) {
32634
32649
  return input.toArray();
32635
32650
  }
32636
32651
  if (Array.isArray(input)) {
@@ -35446,7 +35461,12 @@ func.runtime.widgets.render_node = async function (options) {
35446
35461
  return func.runtime.widgets.report_error(widget_context, descP, warn);
35447
35462
  };
35448
35463
 
35449
- const methods = await func.runtime.widgets.get_methods(widget_context);
35464
+ const definition = await func.runtime.widgets.get_definition(widget_context);
35465
+ if (!func.runtime.widgets.supports_current_environment(definition)) {
35466
+ return report_error(`plugin ${plugin_name} is not available in the current environment`, true);
35467
+ }
35468
+
35469
+ const methods = definition?.methods || {};
35450
35470
  if (methods && !methods[method]) {
35451
35471
  return report_error('method not found');
35452
35472
  }
@@ -35507,7 +35527,13 @@ func.runtime.widgets.render_node = async function (options) {
35507
35527
  job_id: options.jobNoP,
35508
35528
  });
35509
35529
 
35510
- const params = func.runtime.widgets.build_params(widget_context, $div, plugin_setup_ret.data, api_utils);
35530
+ const params = func.runtime.widgets.build_params(
35531
+ widget_context,
35532
+ func.runtime.ui.get_first_node($div),
35533
+ func.runtime.ui.get_data($div),
35534
+ plugin_setup_ret.data,
35535
+ api_utils,
35536
+ );
35511
35537
  const fx = await func.runtime.widgets.get_resource(widget_context, 'runtime.mjs');
35512
35538
 
35513
35539
  await func.runtime.widgets.load_runtime_css(widget_context);
@@ -36537,7 +36563,7 @@ func.runtime.render.handle_xu_ref = async function (options) {
36537
36563
  func.runtime.render.handle_xu_bind = async function (options) {
36538
36564
  if (options.is_skeleton) return {};
36539
36565
 
36540
- const $elm = func.runtime?.ui?.get_preferred_live_element ? func.runtime.ui.get_preferred_live_element(options.$elm) : func.runtime.ui.as_jquery(options.$elm);
36566
+ const $elm = func.runtime?.ui?.get_preferred_live_element ? func.runtime.ui.get_preferred_live_element(options.$elm) : options.$elm;
36541
36567
  const elm_data = func.runtime.ui.get_data($elm);
36542
36568
  const xuData = elm_data?.xuData;
36543
36569
  const bind_expression =