* ts strict getAttribute
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* mark xfail
* fix to string
* Remove
* use getAttribute for theme
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
As the title stays, the main goal of the branch is to kill the infamous runtimeLoaded global store and all the complications, problems and bugs caused by the fact that in many places we needed to ensure/wait that the global runtime was properly set before being able to execute code.
The core idea is that runtime is never a global object and that it's passed around explicitly, which means that when a function receives it, it is guaranteed to be initialized&ready.
This caused a bit of complications in pybutton.ts, pyinputbox.ts and pyrepl.ts, because they indirectly want to call runtime.run from connectedCallback, which is the only place where we cannot explicitly pass the runtime because it's automatically called by the browser.
But also, it is also a sign of a bad design, because it were entirely possible that connectedCallback was called before the runtime was ready, which probably caused many bugs, see e.g. #673 and #747.
The solution to is use dependency injection and create the class later on: so instead of having a global PyButton class which relies on a global runtime (whose state is uncertain) we have a make_PyButton function which takes a runtime and make a PyButton class which is tied to that specific runtime (whose state is certainly ready, because we call make_PyButton only when we know that the runtime is ready).
Similar for PyInputBox and PyRepl.
Other highlights: thanks to this, I could kill the also infamous runAfterRuntimeInitialized and a couple of smelly lines which used setTimeout to "wait" for the runtime.
While I was at it, I also called a lot of other stores which were completely unused and where probably leftovers from a past universe.
This PR tries to improve and rationalize what we log. Key points:
- introduce `logger.ts`: each file/component is encouraged to use the logger instead of writing directly to `console.*`
* the logger automatically prepend a prefix like `[py-config]`, `[py-env]` which make it easier to understand where a certain message is printed from
* it provide a central place where to add more features in the future. E.g., I can imagine having a config setting to completely silence the logs (not implemented yet)
- use the new loggers everywhere
- write to `.info()` instead of `.log()`. The idea is to keep `console.log` free, so that for the users it's easier to tell apart their own messages and the pyscript ones
- generally improve what we log. This is an endless exercise, but I tried to print more things which are useful to understand what's going on and in which order the various things are executed, and remove prints which were clearly debugging leftovers
* start removing tailwind and rebuilding some css
* add css to pybox and add class to repl
* set output component visibility
* replace tailwind class with single component class
* add styles to css
* replace classes on button
* replace classes on input
* replace classes in title
* replace classes on list
* replace classes
* add new style file
* add list element style
* remove tailwind classes from todo example
* revert link on examples files
* remove tailwind config files
* remove commented old code
* add missing ;
Adds utils.htmlDecode arround innerHTML to read the code for <py-repl> and
<py-script>, which preserves all newlines, tabs, and < & > characters.
Fix bug #480
* fix OutputManager _append setter
* fix OutputManager change parameters
* fix OutputCtxManager __init__ and change methods
* replacing OutputManager pyscript.write with write function
* add optional output-append attribute to py-repl
* add appendOutput(default: true) to base component
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update pyscriptjs/src/components/pyrepl.ts
Co-authored-by: woxtu <woxtup@gmail.com>
* change from output-append flag to output-mode attribute
* removed type annotation
* repositioned setOutputMode call for auto-generated REPLs to work
* fixed indentation error for indented input
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* added preEvaluate method
* moved output-mode logic to preEvaluate
* remove static write method from PyScript, add write method to Element
* removed err parameter from OutputCtxManager
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* add PyScript.write back with a deprecation warning
* fix wrong input name
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: woxtu <woxtup@gmail.com>
Co-authored-by: Fabio Pliger <fabio.pliger@gmail.com>
* Add type annotations
* Replace `StateCommand` with `Command`
* Revert "Replace `StateCommand` with `Command`"
This reverts commit 2dfc2d34e4.
* Fix the return value
* Add onscreen error when using py-env paths in local HTTP files without file server
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Remove redundant code, fix error handling, add 404 error
* Lint and Format
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* manage errors loading files
* use handleFetchError for handling fetch errors in env
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Fabio Pliger <fabio.pliger@gmail.com>
* fix: theme for <py-repl>
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* remove comment
* fix: populate initial theme on auto generated repls.
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* make copy of .py files part of build process
* move code out ofinterpreter file and make it download and load code during initialization
* fix double ; in interpreter
* remove debugging print
* update dependencies
* fix project name and version
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* lint
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* change fmt-py
* lint
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* remove extra content
* define missing strict type
* create build folder if doesn't exist
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>