| Name | starfyre JSON |
| Version |
0.21.0
JSON |
| download |
| home_page | |
| Summary | A Python Framework for writing Reactive web Front-Ends |
| upload_time | 2024-01-20 22:25:56 |
| maintainer | |
| docs_url | None |
| author | Sanskar Jethi |
| requires_python | >=3.10,<4.0 |
| license | BSD 2.0 |
| keywords |
|
| VCS |
|
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
<p align="center">
<img alt="Starfyre Logo" src="https://user-images.githubusercontent.com/29942790/221331176-609e156a-3896-4c1a-9386-7bf595dfb879.png" width="350" />
</p>
[](https://discord.gg/ThQcpvJMZ6)
[](https://pepy.tech/project/starfyre)
# Starfyre ⭐🔥
## Introduction:
Starfyre is a library that allows you to build reactive frontends using only Python. With Starfyre, you can create interactive, real-time applications with minimal effort. Simply define your frontend as a collection of observables and reactive functions, and let Starfyre handle the rest. Starfyre is based on Pyscript for client side functions and uses the concept of `pyxides` when structuring code.
- pyxide - translates to a container. Every component is a container. It can contain other components or HTML elements.
## 📦 Installation:
```
pip install starfyre
```
A sample project is hosted on [GitHub](https://github.com/sansyrox/first-starfyre-app/).
## 🚀 Sample App
To create an application
```bash
starfyre --create="my-app"
```
It will use the [create-starfyre-app](https://github.com/sparckles/create-starfyre-app) as the template to create a new project.
## IDE/Editor Plugins
- [vim-starfyre](https://github.com/sparckles/vim-starfyre) : A Vim plugin for syntax highlighting Starfyre files.
- [vscode-starfyre](https://marketplace.visualstudio.com/items?itemName=SanskarJethi.starfyre) : A VSCode extension for syntax highlighting Starfyre files.
### A simple component
`my-app/pages/__init__.fyre`
```python
import "../styles/index.css"
def message():
return "World"
---client
from starfyre import js
def handle_click():
js.console.log("Hello World")
---
<pyxide>
<div onclick={handle_click()}>
Hello, {message()}
</div>
</pyxide>
```
### Using Components
<details>
<summary>Click to expand</summary>
`my-app/pages/__init__.fyre`
```python
import "../styles/index.css"
from @.components.custom_component import custom_component
# @ is the alias for the source directory. e.g. my-app in our case
<pyxide>
<custom_component></custom_component>
</pyxide>
```
`my-app/src/components/custom_component.fyre`
```python
<pyxide>
<div> This is a custom component </div>
</pyxide>
```
</details>
### State Management
<details>
<summary>Click to expand</summary>
Signals are super early at this moment. You need to have the word "signal" when declaring a variable. e.g. get_signal, set_signal, use_signal. And use_signal and get_signal can't be evaluated on the client, i.e. can't have `{use_signal()+1}`. This will be fixed with a better serialization.
`my-app/pages/__init__.fyre`
```python
---client
[get_signal, set_signal, use_signal] = create_signal("Hello World")
def handle_click():
set_signal("Goodbye World")
---
<pyxide>
<div onclick={handle_click}>
{use_signal()}
</div>
</pyxide>
```
</details>
### Routing
<details>
<summary>File based Routing</summary>
Starfyre supports file based routing.
```bash
my-app
├── pages
│ ├── __init__.fyre
│ ├── about.fyre
│ └── nav.fyre
```
</details>
### Styling
<details>
<summary>Click to expand</summary>
Starfyre supports CSS and file based css.
```python
import "../styles/index.css"
<style>
.component {
/* CSS here */
}
</style>
<pyxide>
<div class="component"> Hello World </div>
</pyxide>
```
</details>
### Dependencies
You need to have a `starfyre_config.toml` file in your project root directory. This file is used to specify the dependencies for your project. The dependencies are specified in the following format:
```toml
pyxide_packages = [] # for client side packages
server_packages = [] # for server side packages
[js_modules]
is_odd = "https://cdn.jsdelivr.net/npm/is-odd@3.0.1/+esm"
Fireworks = "https://cdn.jsdelivr.net/npm/fireworks-js@2.10.7/+esm"
```
You can specify the dependencies using the following commands:
```bash
starfyre --add-pyxide-package="package-name"
starfyre --add-server-package="package-name"
starfyre --add-js-module="module-name" --as="alias"
```
## 🚀 Sample CLI usage
```bash
Usage: python -m starfyre [OPTIONS]
Command-line interface to compile and build a Starfyre project.
Args:
path (str): Path to the project directory.
build (bool): Whether to start the build package.
create (str): Name of the project to create.
serve (bool): Whether to serve the project.
Options:
--path TEXT Path to the project. Requires --build.
--build Compile and build package. Requires --path.
--create TEXT Create a new project. Requires a project name.
--serve Serve the project. Requires --path.
--help Show this message and exit.
```
## 🗒️ How to contribute
### 🏁 Get started
Please read the code of conduct and go through CONTRIBUTING.md before contributing to Starfyre. Feel free to open an issue for any clarifications or suggestions.
If you're feeling curious. You can take a look at a more detailed architecture here.
If you still need help to get started, feel free to reach out on our community discord.
## ⚙️ Developing Locally
1. Fork this [repo](https://github.com/sparckles/starfyre)
2. Clone this repo - `git clone https://github.com/sparckles/starfyre`
3. Go in to the starfyre directory - `cd starfyre`
4. Download poetry `curl -sSL https://install.python-poetry.org/ | python3 -`
5. Install the dependencies `poetry install`
6. Activate poetry virtual environment `poetry shell`
7. Run the script `./build.sh`. This command will run the build process in starfyre against the test application in `test-application` directory.
- The `build.sh` file is a simple script that runs two commands sequentially.
- `python -m starfyre --build=True --path="test_application/"`
- The `path` variable here is the path to our application.
- The `build` directory is basically a python package that contains all the compiled files. We use the `--build` flag to run that package.
8. You can find a small test application in the `test_application` directory.
9. Navigate to `cd test_application/dist`.
10. Open `index.html` in your browser to see the output.
## Feedback
Feel free to open an issue and let me know what you think of it.
Raw data
{
"_id": null,
"home_page": "",
"name": "starfyre",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.10,<4.0",
"maintainer_email": "",
"keywords": "",
"author": "Sanskar Jethi",
"author_email": "sansyrox@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/7b/b0/c6773d9d795231d3571db2163d26ece83523b9d0a565869869d726634ca0/starfyre-0.21.0.tar.gz",
"platform": null,
"description": "<p align=\"center\">\n <img alt=\"Starfyre Logo\" src=\"https://user-images.githubusercontent.com/29942790/221331176-609e156a-3896-4c1a-9386-7bf595dfb879.png\" width=\"350\" />\n</p>\n\n[](https://discord.gg/ThQcpvJMZ6)\n[](https://pepy.tech/project/starfyre)\n\n\n# Starfyre \u2b50\ud83d\udd25\n\n## Introduction:\n\nStarfyre is a library that allows you to build reactive frontends using only Python. With Starfyre, you can create interactive, real-time applications with minimal effort. Simply define your frontend as a collection of observables and reactive functions, and let Starfyre handle the rest. Starfyre is based on Pyscript for client side functions and uses the concept of `pyxides` when structuring code.\n\n- pyxide - translates to a container. Every component is a container. It can contain other components or HTML elements.\n\n\n\n\n## \ud83d\udce6 Installation:\n\n```\npip install starfyre\n```\n\nA sample project is hosted on [GitHub](https://github.com/sansyrox/first-starfyre-app/).\n\n## \ud83d\ude80 Sample App\n\nTo create an application\n\n```bash\nstarfyre --create=\"my-app\"\n```\n\nIt will use the [create-starfyre-app](https://github.com/sparckles/create-starfyre-app) as the template to create a new project.\n\n## IDE/Editor Plugins\n- [vim-starfyre](https://github.com/sparckles/vim-starfyre) : A Vim plugin for syntax highlighting Starfyre files. \n- [vscode-starfyre](https://marketplace.visualstudio.com/items?itemName=SanskarJethi.starfyre) : A VSCode extension for syntax highlighting Starfyre files. \n\n### A simple component\n`my-app/pages/__init__.fyre`\n\n```python\nimport \"../styles/index.css\"\n\ndef message():\n return \"World\"\n\n---client\nfrom starfyre import js\n\ndef handle_click():\n js.console.log(\"Hello World\")\n---\n\n<pyxide>\n <div onclick={handle_click()}>\n Hello, {message()}\n </div>\n</pyxide>\n\n```\n\n### Using Components\n<details>\n<summary>Click to expand</summary>\n\n`my-app/pages/__init__.fyre`\n\n```python\nimport \"../styles/index.css\"\nfrom @.components.custom_component import custom_component\n# @ is the alias for the source directory. e.g. my-app in our case\n\n<pyxide>\n <custom_component></custom_component>\n</pyxide>\n```\n\n`my-app/src/components/custom_component.fyre`\n\n```python\n\n<pyxide>\n <div> This is a custom component </div>\n</pyxide>\n```\n</details>\n\n### State Management\n\n<details>\n<summary>Click to expand</summary>\n\nSignals are super early at this moment. You need to have the word \"signal\" when declaring a variable. e.g. get_signal, set_signal, use_signal. And use_signal and get_signal can't be evaluated on the client, i.e. can't have `{use_signal()+1}`. This will be fixed with a better serialization.\n\n`my-app/pages/__init__.fyre`\n\n```python\n\n---client\n\n[get_signal, set_signal, use_signal] = create_signal(\"Hello World\")\n\ndef handle_click():\n set_signal(\"Goodbye World\")\n---\n\n<pyxide>\n <div onclick={handle_click}>\n {use_signal()}\n </div>\n</pyxide>\n\n```\n</details>\n\n### Routing\n<details>\n<summary>File based Routing</summary>\n\nStarfyre supports file based routing.\n\n```bash\nmy-app\n\u251c\u2500\u2500 pages\n\u2502 \u251c\u2500\u2500 __init__.fyre\n\u2502 \u251c\u2500\u2500 about.fyre\n\u2502 \u2514\u2500\u2500 nav.fyre\n```\n\n</details>\n\n### Styling\n<details>\n<summary>Click to expand</summary>\n\nStarfyre supports CSS and file based css.\n\n```python\nimport \"../styles/index.css\"\n\n<style>\n.component {\n/* CSS here */\n}\n\n</style>\n\n<pyxide>\n <div class=\"component\"> Hello World </div>\n</pyxide>\n```\n</details>\n\n### Dependencies\n\nYou need to have a `starfyre_config.toml` file in your project root directory. This file is used to specify the dependencies for your project. The dependencies are specified in the following format:\n\n```toml\n\npyxide_packages = [] # for client side packages\nserver_packages = [] # for server side packages\n\n[js_modules]\nis_odd = \"https://cdn.jsdelivr.net/npm/is-odd@3.0.1/+esm\"\nFireworks = \"https://cdn.jsdelivr.net/npm/fireworks-js@2.10.7/+esm\"\n```\n\nYou can specify the dependencies using the following commands:\n\n```bash\nstarfyre --add-pyxide-package=\"package-name\"\nstarfyre --add-server-package=\"package-name\"\nstarfyre --add-js-module=\"module-name\" --as=\"alias\"\n```\n\n\n## \ud83d\ude80 Sample CLI usage\n\n```bash\nUsage: python -m starfyre [OPTIONS]\n\n Command-line interface to compile and build a Starfyre project.\n\n Args:\n\n path (str): Path to the project directory.\n\n build (bool): Whether to start the build package.\n\n create (str): Name of the project to create.\n\n serve (bool): Whether to serve the project.\n\nOptions:\n --path TEXT Path to the project. Requires --build.\n --build Compile and build package. Requires --path.\n --create TEXT Create a new project. Requires a project name.\n --serve Serve the project. Requires --path.\n --help Show this message and exit.\n```\n\n## \ud83d\uddd2\ufe0f How to contribute\n\n### \ud83c\udfc1 Get started\nPlease read the code of conduct and go through CONTRIBUTING.md before contributing to Starfyre. Feel free to open an issue for any clarifications or suggestions.\n\nIf you're feeling curious. You can take a look at a more detailed architecture here.\n\nIf you still need help to get started, feel free to reach out on our community discord.\n\n\n## \u2699\ufe0f Developing Locally\n\n1. Fork this [repo](https://github.com/sparckles/starfyre)\n2. Clone this repo - `git clone https://github.com/sparckles/starfyre`\n3. Go in to the starfyre directory - `cd starfyre`\n4. Download poetry `curl -sSL https://install.python-poetry.org/ | python3 -`\n5. Install the dependencies `poetry install`\n6. Activate poetry virtual environment `poetry shell`\n7. Run the script `./build.sh`. This command will run the build process in starfyre against the test application in `test-application` directory.\n - The `build.sh` file is a simple script that runs two commands sequentially.\n - `python -m starfyre --build=True --path=\"test_application/\"`\n - The `path` variable here is the path to our application.\n - The `build` directory is basically a python package that contains all the compiled files. We use the `--build` flag to run that package.\n\n8. You can find a small test application in the `test_application` directory.\n9. Navigate to `cd test_application/dist`.\n10. Open `index.html` in your browser to see the output.\n\n\n## Feedback\n\nFeel free to open an issue and let me know what you think of it. \n\n",
"bugtrack_url": null,
"license": "BSD 2.0",
"summary": "A Python Framework for writing Reactive web Front-Ends",
"version": "0.21.0",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "c7a5f144ee2097617970a82e008911d997511b37ad0c038e9bbee5107f5f9cf9",
"md5": "7afce63e2926d1283a49b171e4b3f8aa",
"sha256": "e0268d607bb471c7840224aaa23e0f0b55e3752f93be5004d2c8b1e8e8295712"
},
"downloads": -1,
"filename": "starfyre-0.21.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7afce63e2926d1283a49b171e4b3f8aa",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10,<4.0",
"size": 25167,
"upload_time": "2024-01-20T22:25:54",
"upload_time_iso_8601": "2024-01-20T22:25:54.491902Z",
"url": "https://files.pythonhosted.org/packages/c7/a5/f144ee2097617970a82e008911d997511b37ad0c038e9bbee5107f5f9cf9/starfyre-0.21.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "7bb0c6773d9d795231d3571db2163d26ece83523b9d0a565869869d726634ca0",
"md5": "6c36beea1a58d656c9692f6e808eac48",
"sha256": "d3f4c82fc0d43b4d13c0a7f3d41f3b39156c0b3980939d14822ac28e90712b26"
},
"downloads": -1,
"filename": "starfyre-0.21.0.tar.gz",
"has_sig": false,
"md5_digest": "6c36beea1a58d656c9692f6e808eac48",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10,<4.0",
"size": 22229,
"upload_time": "2024-01-20T22:25:56",
"upload_time_iso_8601": "2024-01-20T22:25:56.343870Z",
"url": "https://files.pythonhosted.org/packages/7b/b0/c6773d9d795231d3571db2163d26ece83523b9d0a565869869d726634ca0/starfyre-0.21.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-20 22:25:56",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "starfyre"
}