mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-19 18:27:29 -05:00
Make the life-cycle more linear and kill some svelte stores (#830)
This is a follow-up of PR #806 and it's a big step forward towards solving issue #763. The basic idea is that at this stage I want to streamline the execution logic and make it as linear and easy to read/understand as possible. The diff is relatively big, but for the most part is just "shuffling code around". Svelte stores: the idea is to eventually kill of them, so that we can remove the dependency on svelte but also to avoid relying on so much global state, which makes things more complicated and error-prone (e.g., we have several issues related to using runtime when it's not ready yet). I killed addInitializer, addPostInitializer and the corresponding svelte stores tada. They are no longer needed since the relevant code is called directly from main.ts. I started to kill the usage of the runtimeLoaded svelte store: instead of relying on a global variable, I want to arrive at the point in which the runtime is passed as a parameter in all places where it's needed: pyscript.ts is now free of global state, but I couldn't kill it yet because it's used heavily by base.ts and pyrepl.ts. I will do it in another PR. Other misc changes: I added sanity checks (and corresponding tests!) which complain if you specify 0 or multiple runtimes. Currently we support having one and only one, so there is no point to pretend otherwise I modified the messages displayed by the loader, to be more informative from the user point of view.
This commit is contained in:
@@ -187,7 +187,7 @@ class PyScriptTest:
|
||||
"""
|
||||
# this is printed by runtime.ts:Runtime.initialize
|
||||
self.wait_for_console(
|
||||
"[pyscript/runtime] PyScript page fully initialized",
|
||||
"[pyscript/main] PyScript page fully initialized",
|
||||
timeout=timeout,
|
||||
check_errors=check_errors,
|
||||
)
|
||||
@@ -195,7 +195,7 @@ class PyScriptTest:
|
||||
# events aren't being triggered in the tests.
|
||||
self.page.wait_for_timeout(100)
|
||||
|
||||
def pyscript_run(self, snippet, *, extra_head=""):
|
||||
def pyscript_run(self, snippet, *, extra_head="", wait_for_pyscript=True):
|
||||
"""
|
||||
Main entry point for pyscript tests.
|
||||
|
||||
@@ -224,7 +224,8 @@ class PyScriptTest:
|
||||
filename = f"{self.testname}.html"
|
||||
self.writefile(filename, doc)
|
||||
self.goto(filename)
|
||||
self.wait_for_pyscript()
|
||||
if wait_for_pyscript:
|
||||
self.wait_for_pyscript()
|
||||
|
||||
|
||||
# ============== Helpers and utility functions ==============
|
||||
|
||||
Reference in New Issue
Block a user