Files
pyscript/pyscript.core
Fabio Pliger 00fdc73015 [NEXT] Pydom (#1681)
* add pyweb

* build

* add test file

* fix pydom example code

* remove old reference to js

* temporarily comment out query functions on BaseElement while rearranging code to reuse the same underlying logic accross PyDom and other elements

* add temp TODO comment to content as it breaks with template elements

* update pydom example to define code on external file

* fix name type while renaming document -> dom

* add real pydom test files

* add classes to dom scope

* __len__ to ElementCollection

* fix some of the old tests

* rename test from test_query_by_class to test_getitem_by_class

* change test for read and write multiple elements

* add find method to BaseElement

* fix remaining tests

* add Collection Tests

* add equality to Collection

* add test for collection style manipulation

* fix getter for style property and rename style related attribute from pop to remove

* add single element creation test

* remove append on BaseElement and add body and head to dom

* add test_create_element_child to verify child creation

* add children getter property to Element

* remove old code

* remove more old code, change style attribute from visibility to visible and now default getters on collection to return a list with the value of an attribute for every element in the collection

* remove more old code and add possibility to customize test flags via url

* add support to pass Js and pydom.Element elements to when decorator

* remove methods related to input type of elements until we have a better design for it

* rename _element to _js

* add test_when decorator with a ElementCollection input

* when decorator now supporte pydom.ElementCollection as input

* update pyscript.js

* remove useless variable from when decorator

* remove base.py from pyweb

* add nodes for append collection test and add better feedback on successes vs failure

* add tests and fix code for support of append Element and ElementCollection

* manage access to content attribute when tagname is template

* fix comment

---------

Co-authored-by: Fabio Pliger <fpliger@anaconda.com>
2023-09-14 13:31:23 -07:00
..
2023-09-14 13:31:23 -07:00
2023-09-14 13:31:23 -07:00
2023-09-14 13:31:23 -07:00

@pyscript/core

We have moved and renamed previous core module as polyscript, which is the base module used in here to build up PyScript Next, now hosted in this folder.

Documentation

Please read core documentation to know more about this project.

Development

Clone this repository then run npm install within its folder.

Use npm run build to create all artifacts and dist files.

Use npm run server to test locally, via the http://localhost:8080/test/ url, smoke tests or to test manually anything you'd like to check.

Artifacts

There are two main artifacts in this project:

  • stdlib and its content, where src/stdlib/pyscript.js exposes as object literal all the Python content within the folder (recursively)
  • plugins and its content, where src/plugins.js exposes all available dynamic imports, able to instrument the bundler to create files a part within the dist/ folder, so that by default core remains as small as possible

Accordingly, whenever a file contains this warning at its first line, please do not change such file directly before submitting a merge request, as that file will be overwritten at the next npm run build command, either here or in CI:

// ⚠️ This file is an artifact: DO NOT MODIFY

Python stdlib

The pyscript module available in Python defines its exported utilities via src/stdlib/pyscript.py. Any file that would like to provide an export should be placed into src/stdlib/_pyscript folder (see the display.py as example) and its public functionalities should be explicit in the src/stdlib/pyscript.py file.

All Python files will be embedded automatically whenever npm run build happens and reflected into the src/stdlib/pyscript.js file.

It is core responsibility to ensure those files will be available through the Filesystem in either the main thread, or any worker.

JS plugins

While community or third party plugins don't need to be part of this repository and can be added just importing @pyscript/core as module, there are a few plugins that we would like to make available by default and these are considered core plugins.

To add a core plugin to this project you can define your plugin entry-point and name in the src/plugins folder (see the error.js example) and create, if necessary, a folder with the same name where extra files or dependencies can be added.

The build command will bring plugins by name as artifact so that the bundler can create ad-hoc files within the dist/ folder.