39 Commits

Author SHA1 Message Date
Nicholas Tollervey
a02ff691d2 pyscript API/docstring refactor with comprehensive tests (#2414)
* Revise display module. TODO: more comprehensive tests. Especially around mimebundles.

* Markdown corrections in example code in display.py docstrings.

* Minor adjustments and a much more comprehensive test-suite for the display module.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Updated docstring in __init__.py.

* Remove unused imports and black-ify the source.

* Refactor, docs and tests for the Event class in events.py.

* Refactored, simplified and documented @when decorator.

* Extensive test suite for @when decorator.

* Documentation and minor refactoring of the fetch.py module. TODO: Check tests.

* Refactored and more comprehensive tests for the fetch module.

* Add/clarify Event related interactions. Thanks @Neon22 for the suggestion.

* Refactor, document ffi.py module.

* More complete passing tests for ffi.py.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add docstrings to flatted.py. Since this is actually an external(ish) module, tests for it should be in the external repository from which this code is derived.

* Minor docstring cleanup in ffi.py.

* Added docstrings and clarifications to fs.py.

* Add very limited test suite for fs.py.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Rename magic_js.py to context.py, add comprehensive docstrings, and rename certain internal things for readability and comprehension.

* Fix dict check in ffi.py.

* Rename test_js_modules to test_context.

* Fix test configuration aftert rename.

* Docs and refactor of media.py.

* Comprehensive tests for media.py.

* Refactor and docstrings for storage.py

* Appease the ruff gods.

* Further storage.py changes and a more complete test suite for storage.

* Refactor and docstrings for the util.py module. Fixed a problem with is_awaitable not handling async bound methods.

* More comprehensive test suite for util.py. Updated to latest upytest.

* A major refactoring, documenting and simplification of the web.py module substantially reducing it in size and complexity with only a few minor (edge) behavioural changes.

Softly breaking changes include:

- An element's classes are just a set.
- An element's styles are just a dict.
- Explicitly use `update_all` with ElementCollections (simpler and greater flexibility).
- Extract a child element by id with `my_container["#an-id"]`

* Updates and additions for a more comprehensive test suite for the web.py module. All code paths are exercised and checked.

* Black tidy-ups in test suite.

* Refactor and documentation for websocket.py module.

* Tests for websocket.py. Disabled due to playwright flakiness, but they all pass in a local browser.

* Refactor and documentation of workers.py module.

* Added tests for workers.py module. Updated related test suite to account for the new named worker in the test HTML.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Refactor away remaining "is not None" not caught before.

* Remove check-docstring-first because it interferes with the auto-generated documentation (where triple quoted strings are used to document module attributes).

* Careful Markdown changes so the docstrings render properly in the PyScript docs.

* Typo correction.

* More typo corrections and clarifications.

* Add clarification about SVG handling to _render_image docstring.

* Add DOM event options to the @when decorator (with new tests to exercise this functionality).

* Fixes default value for options if no options passed into @when.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-12-11 17:19:24 +00:00
Andrea Giammarchi
7afe5c55e1 Fix #2404 - avoid throwing on string config (#2405) 2025-11-25 09:26:14 +01:00
Andrea Giammarchi
ec090922cb Fix #2372 - Allow custom TOML parser (#2390)
* Fix #2372 - Allow custom TOML parser

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-10-10 17:07:36 +02:00
Nicholas Tollervey
ffc78ab6a2 Remove superfluous code now MicroPython supports inspect API for function signature inspection. (#2387)
* Remove superfluous code now MicroPython supports inspect API for function signature inspection. 
* Added test to ensure all callables are covered.
2025-10-08 09:27:53 +01:00
Jeremy Kawahara
b609b605f5 Fix py-editor execute code on ctrl-enter (#2385)
* Fix dist path

* Remove defaultKeymap

* Return true from listener

* Put defaultKeymap after custom key map
2025-10-07 22:57:14 +02:00
Andrea Giammarchi
2647e78480 Updated polyscript to bring in latest MicroPython (#2383)
* Updated polyscript to bring in latest MicroPython

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-10-06 11:13:10 +02:00
Christian Clauss
8b35304ab4 Fix undefined names in Python code (#2371)
Co-authored-by: Andrea Giammarchi <andrea.giammarchi@gmail.com>
2025-08-18 13:57:33 +02:00
Christian Clauss
4bf3651c9a pre-commit: Upgrade the Python linter ruff (#2370) 2025-08-18 13:36:36 +02:00
Andrea Giammarchi
b4e9a3093c Fix #2338 - Added explicit fs.revoke(path) (#2368) 2025-08-06 14:40:52 +02:00
Andrea Giammarchi
a129be8136 WebSocket and PyWorker fixes (#2366)
* WebSocket and PyWorker fixes

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-07-24 15:03:51 +02:00
Andrea Giammarchi
71ad1a40cb Update Polyscript with latest Micropython (#2357) 2025-07-04 09:34:12 +02:00
Andrea Giammarchi
87256a662b Updated Polyscript to its latest (#2355)
* Updated Polyscript to its latest
* added tests for `experimental_ffi_timeout`
2025-07-01 13:07:28 +02:00
Nicholas Tollervey
d68260c0c7 Fix a bug in <label> handling where 'for_' attribute should be 'htmlFor' on underlying HTML element. (#2352)
* Fix bug in label handling where 'for_' attribute should be 'htmlFor' on underlying HTML element.

* Fix comment.
2025-06-18 15:01:33 +01:00
Andrea Giammarchi
7284f7f15f Fix #2320 - Dispatch an event on code run in PyEditor (#2329)
* Fix #2320 - Dispatch an event on code run in PyEditor
2025-04-16 22:01:40 +02:00
Dan Yeaw
b911ea99fb Add media module tests (#2306)
* Add media Python tests

* Add media js test

* Remove try except blocks

* Make Python tests more end-to-end

* Add media Python tests

* Add media js test

* Remove try except blocks

* Make Python tests more end-to-end

* MicroPython explorations.

* Fix websocket tests, so they just skip.

* Fix MicroPython media tests, if no permission is given for a video device.

---------

Co-authored-by: Nicholas H.Tollervey <ntoll@ntoll.org>
Co-authored-by: Andrea Giammarchi <andrea.giammarchi@gmail.com>
2025-03-20 14:35:01 +01:00
Andrea Giammarchi
b22f384d73 PyGame - TOML + JSON absolute URL + input patch (#2313)
* Make config URL canonical

* Better baseURL + input patch
2025-03-11 11:32:30 +01:00
Andrea Giammarchi
caeab77a8e Fix #2304 - Make pyimport work as expected (#2311)
* Fix #2304 - Make pyimport work as expected

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-03-10 16:28:42 +01:00
Andrea Giammarchi
f2bbc6ed5f Fix #2309 - Use all config options (#2310)
* Fix #2309 - Use all config options

* dropped websocket test as it takes forever even locally
2025-03-10 15:57:12 +01:00
Andrea Giammarchi
290eb03388 Fix #2302 - Updated Polyscript to its latest (#2303)
* Fix #2302 - Updated Polyscript to its latest
2025-02-27 11:09:46 +01:00
Andrea Giammarchi
edbac13713 Splitting integration tests (#2296) 2025-02-20 15:16:36 +01:00
Christian Clauss
46239caa19 Re ruff (#2292)
* Ruff fixes

* Ruff fixes

* from __future__ import annotations breaks MicroPython

* noqa: FURB188 because there is no str.replacesuffix() in MicroPython

* Add ruff to pre-commit
2025-02-20 09:43:09 +01:00
Andrea Giammarchi
0366e48fad Introducing pyscript.fs namespace/module (#2289)
* introducing pyscript.fs namespace/module

* Added proper rejection when showDirectoryPicker is not supported

* Improved exports to make explicit import in 3rd party modules easier

* implemented `fs.unmount(path)`:

  * verified that RAM gets freed
  * allowed to mount different handlers within the same path through different `id` as that's the Web best way to do so
2025-02-17 14:45:43 +01:00
Andrea Giammarchi
fc53356a1d Introducing <script type="py-game"> (#2265)
* Introducing <script type="py-game">

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-02-05 13:24:35 +01:00
Andrea Giammarchi
796373cfa6 Fix #2246 - Override builtins.input to avoid duplicating it (#2254) 2024-11-25 14:17:30 +01:00
Andrea Giammarchi
4e43d3e92d Fix #2242 - Improved Xterm.js glyphs handling (#2248)
* Updated dev/dependencies

* Fix #2242 - Improved Xterm.js glyphs handling
2024-11-14 10:28:38 +01:00
Nicholas Tollervey
56c64cbee7 Refactor @when and add Event (#2239)
* Add two unit tests for illustrative purposes.

* Radical simplification of @when, more tests and some minor refactoring.
Handle ElementCollections, tests for ElementCollection, make serve for running tests locally.

* Skip flakey Pyodide in worker test (it works 50/50 and appears to be a timing issue).

* Ensure onFOO relates to an underlying FOO event in an Element.

* Minor comment cleanup.

* Add async test for Event listeners.

* Handlers no longer require an event parameter.

* Add tests for async handling via when.

* Docstring cleanup.

* Refactor onFOO to on_FOO.

* Minor typo tidy ups.

* Use correct check for MicroPython.

---------

Co-authored-by: Andrea Giammarchi <andrea.giammarchi@gmail.com>
2024-11-05 13:55:28 +00:00
Andrea Giammarchi
283eabdb30 Added pinned lockFileURL test (#2234) 2024-10-29 11:12:21 +01:00
Andrea Giammarchi
9233d5e45a Fix #2220 - Delay plugins resolution due Safari 17.6 greedy resolution (#2229)
* Fix #2220 - Delay plugins resolution due Safari 17.6 greedy resolution

* Fix #2228 - Workaround in Polyscript for lockFileURL
2024-10-28 11:00:23 +01:00
Andrea Giammarchi
6b1330d28a Fix #2220 - Avoid DOM notifications on errors (#2226)
* Fix #2220 - Avoid DOM notifications on errors
2024-10-17 16:18:05 +02:00
Andrea Giammarchi
c3517f7973 Donkey clear and reset now terminate when busy (#2225)
* Donkey clear and reset now terminate when busy
2024-10-15 12:56:11 +02:00
Andrea Giammarchi
722abda895 Provide an xworker to PyEditors (#2216) 2024-10-09 12:42:20 +02:00
Andrea Giammarchi
8061bc0143 Fixed typo on donkey code (#2213) 2024-10-08 17:17:51 +02:00
Andrea Giammarchi
a6b6dd8479 Refactor named workers test to avoid circular dependencies + free CI (#2212)
* Refactor named workers test to avoid circular dependencies + free CI
2024-10-08 14:58:22 +02:00
Andrea Giammarchi
febbb031ac Add Pyodide lockFileURL test (#2209) 2024-10-07 13:23:05 +02:00
Andrea Giammarchi
f827efe2fc Add a "donkey" worker that execs or evaluates all the things (#2210)
* WIP

* Add a "donkey" worker that execs or evaluates all the things

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-10-04 17:06:07 +02:00
Andrea Giammarchi
62c78b0f42 Updated Polyscript to provide out of the box Pyodide cache (#2205) 2024-10-03 09:20:02 +02:00
Andrea Giammarchi
6fab9a1c26 Fix #2200 - Cleaned up manual tests + added media back (#2201) 2024-10-01 12:51:31 +02:00
Andrea Giammarchi
8de97a7e7b Updated coincident to use a local channel (#2195)
* Updated coincident to use a local channel
2024-09-30 14:03:33 +02:00
Nicholas Tollervey
9dad29ec17 Refactor repository. Fixes #2161 (#2192)
* Remove duplicate LICENSE.
* Remove un-userd pyscript.sw directory and its content.
* Remove ReadTheDocs settings (unused).
* Remove un-used pyproject.toml
* Remove now unused CHANGELOG. Changes now tracked via release notes on GitHub.
* Updated / cleaned release page template and associated GH actions.
* Update prettierignore to remove un-needed refs.
* Move troubleshooting into correct README.
* Add reason for the index.html
* Rename the "pyscript.core" directory to "core".
* Update PR template because CHANGELOG is no longer used.
* Codespell configuration in pyproject.toml.
* Update pyscript.core -> core in .githubignore
* Remove test-results/.last-run.json. This should be ignored by git.
* Pin nodejs version.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-09-30 10:29:26 +01:00