mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-20 18:55:29 -05:00
Fix extensions regression bug (#489)
* add output div visibility rule and make sure CustomWidget is being registered * add new runAfterRuntimeInitialized method that classes can use to run code only after runtime actually initialized * replace setTimout with proper event to wait for runtime to be completed * replace setTimout on pyinpytbox with proper event to wait for runtime to be completed
This commit is contained in:
@@ -184,6 +184,7 @@ export class BaseEvalElement extends HTMLElement {
|
||||
this.errorElement.children[this.errorElement.children.length - 1].setAttribute('error', '');
|
||||
this.errorElement.hidden = false;
|
||||
this.errorElement.style.display = 'block';
|
||||
this.errorElement.style.visibility = 'visible';
|
||||
}
|
||||
} // end evaluate
|
||||
|
||||
@@ -200,6 +201,16 @@ export class BaseEvalElement extends HTMLElement {
|
||||
console.log(err);
|
||||
}
|
||||
} // end eval
|
||||
|
||||
runAfterRuntimeInitialized(callback: () => Promise<void>){
|
||||
pyodideLoaded.subscribe(value => {
|
||||
if ('runPythonAsync' in value) {
|
||||
setTimeout(async () => {
|
||||
await callback();
|
||||
}, 100);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function createWidget(name: string, code: string, klass: string) {
|
||||
@@ -270,6 +281,7 @@ function createWidget(name: string, code: string, klass: string) {
|
||||
}
|
||||
}
|
||||
}
|
||||
const xPyWidget = customElements.define(name, CustomWidget);
|
||||
}
|
||||
|
||||
export class PyWidget extends HTMLElement {
|
||||
|
||||
Reference in New Issue
Block a user