mirror of
https://forge.fsky.io/oneflux/omegafox.git
synced 2026-02-10 18:22:03 -08:00
Handle list and dict types from main world
This commit is contained in:
parent
4305385f0b
commit
d11cbe4dee
1 changed files with 14 additions and 16 deletions
|
|
@ -118,15 +118,11 @@ class Runtime {
|
||||||
}
|
}
|
||||||
// Extract arguments for the main world function
|
// Extract arguments for the main world function
|
||||||
const functionArgs = args[5]?.value?.a || [];
|
const functionArgs = args[5]?.value?.a || [];
|
||||||
try {
|
const exceptionDetails = {};
|
||||||
const exceptionDetails = {};
|
const result = mainContext.executeInGlobal(mainWorldScript, functionArgs, exceptionDetails);
|
||||||
const result = mainContext.executeInGlobal(mainWorldScript, functionArgs, exceptionDetails);
|
if (!result)
|
||||||
if (!result)
|
return {exceptionDetails};
|
||||||
return {exceptionDetails};
|
return {result};
|
||||||
return {result};
|
|
||||||
} catch (e) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const exceptionDetails = {};
|
const exceptionDetails = {};
|
||||||
|
|
@ -136,7 +132,7 @@ class Runtime {
|
||||||
if (returnByValue)
|
if (returnByValue)
|
||||||
result = executionContext.ensureSerializedToValue(result);
|
result = executionContext.ensureSerializedToValue(result);
|
||||||
return {result};
|
return {result};
|
||||||
}
|
}
|
||||||
|
|
||||||
async getObjectProperties({executionContextId, objectId}) {
|
async getObjectProperties({executionContextId, objectId}) {
|
||||||
const executionContext = this.findExecutionContext(executionContextId);
|
const executionContext = this.findExecutionContext(executionContextId);
|
||||||
|
|
@ -380,10 +376,11 @@ class MainWorldContext {
|
||||||
try {
|
try {
|
||||||
const wrappedScript = `
|
const wrappedScript = `
|
||||||
(() => {
|
(() => {
|
||||||
const result = (${script});
|
let _s = (${script});
|
||||||
return typeof result === 'function'
|
let _r = typeof _s === 'function'
|
||||||
? result(${args.map(arg => JSON.stringify(arg)).join(', ')})
|
? _s(${args.map(arg => JSON.stringify(arg)).join(', ')})
|
||||||
: result;
|
: _s;
|
||||||
|
return JSON.stringify({value: _r});
|
||||||
})()
|
})()
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|
@ -393,8 +390,7 @@ class MainWorldContext {
|
||||||
if (!success) {
|
if (!success) {
|
||||||
return {exceptionDetails};
|
return {exceptionDetails};
|
||||||
}
|
}
|
||||||
|
return JSON.parse(obj);
|
||||||
return {value: obj};
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
exceptionDetails.text = e.message;
|
exceptionDetails.text = e.message;
|
||||||
exceptionDetails.stack = e.stack;
|
exceptionDetails.stack = e.stack;
|
||||||
|
|
@ -435,6 +431,8 @@ class ExecutionContext {
|
||||||
|
|
||||||
return hasSymbol ? undefined : result;
|
return hasSymbol ? undefined : result;
|
||||||
}).bind(null, JSON.stringify.bind(JSON))`).return;
|
}).bind(null, JSON.stringify.bind(JSON))`).return;
|
||||||
|
|
||||||
|
this.mainEquivalent = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
id() {
|
id() {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue