mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-21 03:05:38 -05:00
Provide an xworker to PyEditors (#2216)
This commit is contained in:
committed by
GitHub
parent
8061bc0143
commit
722abda895
@@ -77,6 +77,19 @@ async function execute({ currentTarget }) {
|
||||
|
||||
const xworker = XWorker.call(new Hook(null, hooks), srcLink, details);
|
||||
|
||||
// expose xworker like in terminal or other workers to allow
|
||||
// creation and destruction of editors on the fly
|
||||
if (hasRunButton) {
|
||||
for (const type of TYPES.keys()) {
|
||||
const editor = currentTarget.closest(`.${type}-editor-box`);
|
||||
const script = editor?.parentNode?.previousElementSibling;
|
||||
if (script) {
|
||||
defineProperties(script, { xworker: { value: xworker } });
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const { sync } = xworker;
|
||||
const { promise, resolve } = Promise.withResolvers();
|
||||
envs.set(env, promise);
|
||||
|
||||
Reference in New Issue
Block a user