SimpleChatTC: Allow await in generated code that will be evald
This commit is contained in:
parent
92e5b2133e
commit
77d3e43cb4
|
|
@ -25,6 +25,7 @@ export async function evalWithPromiseTracking(codeToEval) {
|
|||
const promise = new _Promise(executor);
|
||||
trackedPromises.push(promise);
|
||||
|
||||
// @ts-ignore
|
||||
promise.then = function (...args) {
|
||||
console.info("WW:PT:Then")
|
||||
const newPromise = _Promise.prototype.then.apply(this, args);
|
||||
|
|
@ -47,12 +48,15 @@ export async function evalWithPromiseTracking(codeToEval) {
|
|||
|
||||
const fetch = function(/** @type {any[]} */ ...args) {
|
||||
console.info("WW:PT:Fetch")
|
||||
// @ts-ignore
|
||||
const fpromise = _fetch(args);
|
||||
trackedPromises.push(fpromise)
|
||||
return fpromise;
|
||||
}
|
||||
|
||||
eval(codeToEval);
|
||||
//let tf = new Function(codeToEval);
|
||||
//await tf()
|
||||
await eval(`(async () => { ${codeToEval} })()`);
|
||||
|
||||
//await Promise(resolve=>setTimeout(resolve, 0));
|
||||
//return _Promise.allSettled(trackedPromises);
|
||||
|
|
|
|||
Loading…
Reference in New Issue