@xuda.io/runtime-bundle 1.0.1381 → 1.0.1382
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/js/modules/xuda-event-javascript-module.min.mjs +2 -2
- package/js/modules/xuda-event-javascript-module.mjs +2 -2
- package/js/xuda-runtime-bundle.js +4 -4
- package/js/xuda-runtime-bundle.min.js +1 -1
- package/js/xuda-runtime-slim.js +4 -4
- package/js/xuda-runtime-slim.min.es.js +4 -4
- package/js/xuda-runtime-slim.min.js +1 -1
- package/js/xuda-server-bundle.min.mjs +1 -1
- package/js/xuda-server-bundle.mjs +4 -4
- package/js/xuda-worker-bundle.js +4 -4
- package/js/xuda-worker-bundle.min.js +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export const run_javascript=async function(SESSION_ID,jobNoP,dsSession,script,evaluate,prog_id,params,evt,$container){const _session=SESSION_OBJ[SESSION_ID];const run_native_javascript_program_in_browser=async function(){const path_to_dist=`https://${_session.domain}/studio-drive/${APP_OBJ[_session.app_id].app_replicate||_session.app_id}/scripts/${prog_id}/dist/`;const index_mjs=await import(`${path_to_dist}index.mjs`);if(index_mjs.css){const css_url=`${path_to_dist}index.css`;func.utils.load_css_on_demand(css_url)}const code=func.utils.replace_studio_drive_url(SESSION_ID,index_mjs.default);const api_utils=await func.common.get_module(SESSION_ID,"xuda-api-library.mjs",{func:func,glb:glb,SESSION_OBJ:SESSION_OBJ,SESSION_ID:SESSION_ID,APP_OBJ:APP_OBJ,dsSession:dsSession,jobNoP:jobNoP});const xu=api_utils;const ret=await code(params,xu,SESSION_ID,SESSION_OBJ,jobNoP,$container);if(!code.toString().includes("func.api.callback")){func.events.delete_job(SESSION_ID,jobNoP)}return ret};const run_native_javascript_program_in_server=async function(){return new Promise(async(resolve,reject)=>{const studio_drive_script_folder=path.join(_conf.studio_drive_path,app_id,"scripts");const studio_drive_script_program_folder=path.join(studio_drive_script_folder,prog_id);const dist=path.join(studio_drive_script_program_folder,"dist");const index_mjs=path.join(dist,"index.mjs");process.on("uncaughtException",err=>{console.error("Asynchronous error caught.",err)});const resolve_local=function(e){if(!script.toString().includes("func.api.callback")){func.events.delete_job(SESSION_ID,jobNoP)}resolve(e)};const reject_local=function(e){func.events.delete_job(SESSION_ID,jobNoP);reject(e)};try{const script=new
|
|
1
|
+
export const run_javascript=async function(SESSION_ID,jobNoP,dsSession,script,evaluate,prog_id,params,evt,$container){const _session=SESSION_OBJ[SESSION_ID];const run_native_javascript_program_in_browser=async function(){const path_to_dist=`https://${_session.domain}/studio-drive/${APP_OBJ[_session.app_id].app_replicate||_session.app_id}/scripts/${prog_id}/dist/`;const index_mjs=await import(`${path_to_dist}index.mjs`);if(index_mjs.css){const css_url=`${path_to_dist}index.css`;func.utils.load_css_on_demand(css_url)}const code=func.utils.replace_studio_drive_url(SESSION_ID,index_mjs.default);const api_utils=await func.common.get_module(SESSION_ID,"xuda-api-library.mjs",{func:func,glb:glb,SESSION_OBJ:SESSION_OBJ,SESSION_ID:SESSION_ID,APP_OBJ:APP_OBJ,dsSession:dsSession,jobNoP:jobNoP});const xu=api_utils;const ret=await code(params,xu,SESSION_ID,SESSION_OBJ,jobNoP,$container);if(!code.toString().includes("func.api.callback")){func.events.delete_job(SESSION_ID,jobNoP)}return ret};const run_native_javascript_program_in_server=async function(){return new Promise(async(resolve,reject)=>{const studio_drive_script_folder=path.join(_conf.studio_drive_path,app_id,"scripts");const studio_drive_script_program_folder=path.join(studio_drive_script_folder,prog_id);const dist=path.join(studio_drive_script_program_folder,"dist");const index_mjs=path.join(dist,"index.mjs");process.on("uncaughtException",err=>{console.error("Asynchronous error caught.",err)});const resolve_local=function(e){if(!script.toString().includes("func.api.callback")){func.events.delete_job(SESSION_ID,jobNoP)}resolve(e)};const reject_local=function(e){func.events.delete_job(SESSION_ID,jobNoP);reject(e)};try{const script=new VMScript(`
|
|
2
2
|
const index_mjs = await import(${index_mjs});
|
|
3
3
|
|
|
4
|
-
try{index_mjs.default(req,params,setup_doc,resolve,reject);}catch(e){ console.error(e); }`,{filename:dist,dirname:dist});let vm=new
|
|
4
|
+
try{index_mjs.default(req,params,setup_doc,resolve,reject);}catch(e){ console.error(e); }`,{filename:dist,dirname:dist});let vm=new NodeVM({require:{external:true},sandbox:{resolve:resolve_local,reject:reject_local},timeout:6e4});return await vm.run(script,{filename:dist,dirname:dist})}catch(err){console.error("Failed to execute script.",err)}})};if(evaluate){var script_ret=(await func.expression.get(SESSION_ID,script,dsSession,"javascript",null,null,null,null,null,null,null,()=>{},jobNoP)).result}else{if(prog_id){if(typeof IS_API_SERVER!=="undefined"||typeof IS_DOCKER!=="undefined"||typeof IS_PROCESS_SERVER!=="undefined"){return await run_native_javascript_program_in_server()}else{return await run_native_javascript_program_in_browser()}}else{await func.expression.secure_eval(SESSION_ID,"javascript",func.utils.replace_studio_drive_url(SESSION_ID,script),jobNoP,dsSession,()=>{},evt)}}if(!script.includes("func.api.callback")){func.events.delete_job(SESSION_ID,jobNoP);return}};export const call_javascript=async function(SESSION_ID,jobNoP,refIdP,dsSession,evaluate,$container){const error_log=async function(msg){let _session=SESSION_OBJ[SESSION_ID];func.events.delete_job(SESSION_ID,jobNoP);if(typeof IS_API_SERVER!=="undefined"){return __.rpi.write_log(_session.app_id,"error","api",msg)}if(typeof IS_DOCKER!=="undefined"){return __.rpi.write_log(_session.app_id,"error","worker",msg)}await func.common.db(SESSION_ID,"write_log",{msg:msg,log_type:"error",source:"runtime"})};let view_ret=await func.utils.VIEWS_OBJ.get(SESSION_ID,refIdP.prog);if(!view_ret){return error_log("program not found")}if(!view_ret?.scriptData?.value){return error_log("script is empty")}return await run_javascript(SESSION_ID,jobNoP,dsSession,`(async function(${refIdP?.parameters||{}}) {
|
|
5
5
|
${view_ret.scriptData.value}
|
|
6
6
|
})();`,evaluate,refIdP.prog,refIdP?.parameters,null,$container)};
|
|
@@ -66,14 +66,14 @@ export const run_javascript = async function (SESSION_ID, jobNoP, dsSession, scr
|
|
|
66
66
|
};
|
|
67
67
|
|
|
68
68
|
try {
|
|
69
|
-
const script = new
|
|
69
|
+
const script = new VMScript(
|
|
70
70
|
`
|
|
71
71
|
const index_mjs = await import(${index_mjs});
|
|
72
72
|
|
|
73
73
|
try{index_mjs.default(req,params,setup_doc,resolve,reject);}catch(e){ console.error(e); }`,
|
|
74
74
|
{ filename: dist, dirname: dist },
|
|
75
75
|
);
|
|
76
|
-
let vm = new
|
|
76
|
+
let vm = new NodeVM({
|
|
77
77
|
require: {
|
|
78
78
|
external: true,
|
|
79
79
|
},
|
|
@@ -38730,7 +38730,7 @@ func.expression.get_property = async function (valP) {
|
|
|
38730
38730
|
}
|
|
38731
38731
|
|
|
38732
38732
|
try {
|
|
38733
|
-
let vm = new
|
|
38733
|
+
let vm = new NodeVM({
|
|
38734
38734
|
sandbox: {
|
|
38735
38735
|
func: func,
|
|
38736
38736
|
SESSION_ID: SESSION_ID,
|
|
@@ -38988,8 +38988,8 @@ func.expression.secure_eval = async function (SESSION_ID, sourceP, val, job_id,
|
|
|
38988
38988
|
process.on('uncaughtException', handleError);
|
|
38989
38989
|
try {
|
|
38990
38990
|
const dir = path.join(_conf.studio_drive_path, SESSION_OBJ[SESSION_ID].app_id, 'node_modules');
|
|
38991
|
-
const script = new
|
|
38992
|
-
const vm = new
|
|
38991
|
+
const script = new VMScript(`try { ${val} } catch (e) { func.api.error(SESSION_ID, "nodejs error", e); console.error(e); func.events.delete_job(SESSION_ID, "${job_id}"); }`, { filename: dir, dirname: dir });
|
|
38992
|
+
const vm = new NodeVM({
|
|
38993
38993
|
require: { external: true },
|
|
38994
38994
|
sandbox,
|
|
38995
38995
|
timeout: 60000,
|
|
@@ -39001,7 +39001,7 @@ func.expression.secure_eval = async function (SESSION_ID, sourceP, val, job_id,
|
|
|
39001
39001
|
}
|
|
39002
39002
|
|
|
39003
39003
|
try {
|
|
39004
|
-
const vm = new
|
|
39004
|
+
const vm = new NodeVM({
|
|
39005
39005
|
sandbox,
|
|
39006
39006
|
timeout: 1000,
|
|
39007
39007
|
allowAsync: false,
|