streamtree 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. streamtree-0.1.0/CHANGELOG.md +19 -0
  2. streamtree-0.1.0/LICENSE +21 -0
  3. streamtree-0.1.0/MANIFEST.in +4 -0
  4. streamtree-0.1.0/PKG-INFO +207 -0
  5. streamtree-0.1.0/README.md +175 -0
  6. streamtree-0.1.0/docs/STREAMTREE_DEPENDENCY_STRATEGY.md +796 -0
  7. streamtree-0.1.0/docs/STREAMTREE_PLAN.md +347 -0
  8. streamtree-0.1.0/docs/STREAMTREE_ROADMAP.md +260 -0
  9. streamtree-0.1.0/examples/counter.py +22 -0
  10. streamtree-0.1.0/pyproject.toml +79 -0
  11. streamtree-0.1.0/setup.cfg +4 -0
  12. streamtree-0.1.0/src/streamtree/__init__.py +19 -0
  13. streamtree-0.1.0/src/streamtree/core/__init__.py +13 -0
  14. streamtree-0.1.0/src/streamtree/core/component.py +36 -0
  15. streamtree-0.1.0/src/streamtree/core/context.py +66 -0
  16. streamtree-0.1.0/src/streamtree/core/element.py +51 -0
  17. streamtree-0.1.0/src/streamtree/elements/__init__.py +59 -0
  18. streamtree-0.1.0/src/streamtree/elements/layout.py +164 -0
  19. streamtree-0.1.0/src/streamtree/elements/widgets.py +235 -0
  20. streamtree-0.1.0/src/streamtree/py.typed +0 -0
  21. streamtree-0.1.0/src/streamtree/renderers/__init__.py +5 -0
  22. streamtree-0.1.0/src/streamtree/renderers/streamlit.py +335 -0
  23. streamtree-0.1.0/src/streamtree/state/__init__.py +166 -0
  24. streamtree-0.1.0/src/streamtree/testing/__init__.py +204 -0
  25. streamtree-0.1.0/src/streamtree.egg-info/PKG-INFO +207 -0
  26. streamtree-0.1.0/src/streamtree.egg-info/SOURCES.txt +36 -0
  27. streamtree-0.1.0/src/streamtree.egg-info/dependency_links.txt +1 -0
  28. streamtree-0.1.0/src/streamtree.egg-info/requires.txt +9 -0
  29. streamtree-0.1.0/src/streamtree.egg-info/top_level.txt +1 -0
  30. streamtree-0.1.0/tests/test_component_and_testing.py +97 -0
  31. streamtree-0.1.0/tests/test_context.py +39 -0
  32. streamtree-0.1.0/tests/test_element.py +66 -0
  33. streamtree-0.1.0/tests/test_package_meta.py +9 -0
  34. streamtree-0.1.0/tests/test_render_streamlit_mocked.py +355 -0
  35. streamtree-0.1.0/tests/test_state.py +139 -0
  36. streamtree-0.1.0/tests/test_streamlit_app.py +119 -0
  37. streamtree-0.1.0/tests/test_testing_all_nodes.py +68 -0
  38. streamtree-0.1.0/tests/test_tree.py +25 -0
@@ -0,0 +1,19 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.1.0] — 2026-05-12
9
+
10
+ ### Added
11
+
12
+ - Initial public API: `@component`, `render`, virtual elements (`Page`, layouts, widgets).
13
+ - Session helpers: `state`, `toggle_state`, `form_state`, `session_state`, `memo`, `cache`.
14
+ - Streamlit renderer mapping the virtual tree to `st.*` calls (including `Form` and submit flows).
15
+ - `streamtree.testing.render_to_tree` for structure-focused tests without a live Streamlit session.
16
+ - Runnable example: `examples/counter.py`.
17
+ - Design docs under `docs/` (plan, roadmap, dependency strategy).
18
+
19
+ [0.1.0]: https://github.com/streamtree-dev/streamtree/releases/tag/v0.1.0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Streamtree contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,4 @@
1
+ include LICENSE
2
+ include CHANGELOG.md
3
+ recursive-include docs *.md
4
+ recursive-include examples *.py
@@ -0,0 +1,207 @@
1
+ Metadata-Version: 2.4
2
+ Name: streamtree
3
+ Version: 0.1.0
4
+ Summary: Composable, typed Streamlit applications with a declarative component model.
5
+ Author: Streamtree contributors
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/streamtree-dev/streamtree
8
+ Project-URL: Documentation, https://github.com/streamtree-dev/streamtree#readme
9
+ Project-URL: Repository, https://github.com/streamtree-dev/streamtree
10
+ Project-URL: Issues, https://github.com/streamtree-dev/streamtree/issues
11
+ Project-URL: Changelog, https://github.com/streamtree-dev/streamtree/blob/main/CHANGELOG.md
12
+ Keywords: streamlit,ui,components,declarative
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Typing :: Typed
20
+ Requires-Python: >=3.10
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: streamlit>=1.28.0
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest>=7.4.0; extra == "dev"
26
+ Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
27
+ Requires-Dist: pytest-xdist>=3.5.0; extra == "dev"
28
+ Requires-Dist: mypy>=1.8.0; extra == "dev"
29
+ Requires-Dist: ruff>=0.2.0; extra == "dev"
30
+ Requires-Dist: ty>=0.0.30; extra == "dev"
31
+ Dynamic: license-file
32
+
33
+ # Streamtree
34
+
35
+ **Composable, typed Streamlit applications** — a small Python layer that turns UIs into declarative trees instead of long imperative scripts.
36
+
37
+ Streamtree keeps Streamlit’s execution model and widgets, but adds **components**, **virtual elements**, **scoped session state**, and a path toward **Pydantic-typed** forms and props. No JavaScript is required for the core experience.
38
+
39
+ ---
40
+
41
+ ## Why Streamtree
42
+
43
+ | Without Streamtree | With Streamtree |
44
+ |--------------------|-----------------|
45
+ | Layout and widgets interleaved in one script | `@component` functions return a **tree** of elements |
46
+ | `st.session_state` keys scattered and stringly | `state()` keys scoped to the render path |
47
+ | Hard to snapshot or reason about structure | `streamtree.testing.render_to_tree()` for structure checks |
48
+
49
+ Streamtree is **not** a React clone, a browser framework, or a JS build step. It is an **architecture layer** for teams who want maintainable Streamlit apps.
50
+
51
+ ---
52
+
53
+ ## Features
54
+
55
+ - **Python-first** — decorators, plain functions, standard typing
56
+ - **Declarative layouts** — `Page`, `Card`, `Grid`, `VStack`, `Form`, `Tabs`, `Sidebar`, …
57
+ - **Session-backed state** — `state`, `toggle_state`, `form_state`, `memo`, `cache`
58
+ - **Streamlit renderer** — virtual tree → `st.*` on each rerun
59
+ - **Testing helpers** — serialize trees for snapshots (`render_to_tree`)
60
+ - **Typed trajectory** — roadmap and dependency strategy center on **Pydantic** and curated optional extras
61
+
62
+ ---
63
+
64
+ ## Requirements
65
+
66
+ - **Python 3.10+**
67
+ - **Streamlit ≥ 1.28** (declared in `pyproject.toml`)
68
+
69
+ ---
70
+
71
+ ## Install
72
+
73
+ **From PyPI** (after you publish this version):
74
+
75
+ ```bash
76
+ pip install streamtree==0.1.0
77
+ ```
78
+
79
+ **From a clone** (editable, with dev tools):
80
+
81
+ ```bash
82
+ git clone https://github.com/streamtree-dev/streamtree.git
83
+ cd streamtree
84
+ pip install -e ".[dev]"
85
+ # or, with uv:
86
+ uv sync --extra dev
87
+ ```
88
+
89
+ Optional install groups (`tables`, `charts`, `ui`, `auth`, `all`) are specified in the [dependency strategy](docs/STREAMTREE_DEPENDENCY_STRATEGY.md) and will appear in `pyproject.toml` as those integrations ship.
90
+
91
+ ---
92
+
93
+ ## Quick start
94
+
95
+ ```python
96
+ from streamtree import component, render
97
+ from streamtree.elements import Button, Card, Page, Text
98
+ from streamtree.state import state
99
+
100
+
101
+ @component
102
+ def Counter():
103
+ count = state(0)
104
+
105
+ return Card(
106
+ Text(f"Count: {count()}"),
107
+ Button("Increment", on_click=lambda: count.increment(1)),
108
+ Button("Reset", on_click=lambda: count.set(0)),
109
+ )
110
+
111
+
112
+ if __name__ == "__main__":
113
+ render(Page(Counter()))
114
+ ```
115
+
116
+ Run the bundled demo from the repo root:
117
+
118
+ ```bash
119
+ streamlit run examples/counter.py
120
+ ```
121
+
122
+ ---
123
+
124
+ ## Layout and state at a glance
125
+
126
+ **Grid of components**
127
+
128
+ ```python
129
+ from streamtree.elements import Grid
130
+
131
+ Grid(
132
+ UserCard(user1),
133
+ UserCard(user2),
134
+ columns=2,
135
+ )
136
+ ```
137
+
138
+ **Bound text input**
139
+
140
+ ```python
141
+ from streamtree.elements import TextInput
142
+ from streamtree.state import state
143
+
144
+ search = state("")
145
+ TextInput(label="Search", value=search)
146
+ ```
147
+
148
+ ---
149
+
150
+ ## Project layout
151
+
152
+ ```text
153
+ src/streamtree/ # installable package
154
+ core/ # elements, @component, render, context
155
+ elements/ # layouts + widgets
156
+ state/ # session state helpers
157
+ renderers/ # Streamlit backend
158
+ testing/ # tree serialization for tests
159
+ docs/ # plan, roadmap, dependency strategy
160
+ examples/ # runnable Streamlit examples
161
+ tests/ # pytest
162
+ ```
163
+
164
+ ---
165
+
166
+ ## Documentation
167
+
168
+ | Document | Contents |
169
+ |----------|----------|
170
+ | [STREAMTREE_PLAN.md](docs/STREAMTREE_PLAN.md) | Vision, goals, architecture, risks |
171
+ | [STREAMTREE_ROADMAP.md](docs/STREAMTREE_ROADMAP.md) | Phased delivery and dependency alignment |
172
+ | [STREAMTREE_DEPENDENCY_STRATEGY.md](docs/STREAMTREE_DEPENDENCY_STRATEGY.md) | Base vs optional deps, extras, wrapper-first API |
173
+ | [CHANGELOG.md](CHANGELOG.md) | Version history |
174
+
175
+ ---
176
+
177
+ ## Contributing
178
+
179
+ With **[uv](https://docs.astral.sh/uv/)** (recommended):
180
+
181
+ ```bash
182
+ uv sync --extra dev
183
+ uv run ruff check src tests
184
+ uv run ty check src
185
+ uv run pytest
186
+ ```
187
+
188
+ With **pip**:
189
+
190
+ ```bash
191
+ pip install -e ".[dev]"
192
+ ruff check src tests
193
+ ty check src
194
+ pytest
195
+ ```
196
+
197
+ CI runs the same checks on Python 3.10–3.12 (see `.github/workflows/ci.yml`).
198
+
199
+ ### Publishing
200
+
201
+ For **0.1.0**, build artifacts with `uv build` (or `python -m build`), then upload the contents of `dist/` to PyPI using **twine**, **uv publish**, or [Trusted Publishing](https://docs.pypi.org/trusted-publishers/). Tag the release commit `v0.1.0` on your default branch and record changes in [CHANGELOG.md](CHANGELOG.md). Keep `version` in `pyproject.toml`, `streamtree.__version__`, `tests/test_package_meta.py`, and the changelog entry aligned when you cut releases.
202
+
203
+ ---
204
+
205
+ ## License
206
+
207
+ MIT — see the [`LICENSE`](LICENSE) file.
@@ -0,0 +1,175 @@
1
+ # Streamtree
2
+
3
+ **Composable, typed Streamlit applications** — a small Python layer that turns UIs into declarative trees instead of long imperative scripts.
4
+
5
+ Streamtree keeps Streamlit’s execution model and widgets, but adds **components**, **virtual elements**, **scoped session state**, and a path toward **Pydantic-typed** forms and props. No JavaScript is required for the core experience.
6
+
7
+ ---
8
+
9
+ ## Why Streamtree
10
+
11
+ | Without Streamtree | With Streamtree |
12
+ |--------------------|-----------------|
13
+ | Layout and widgets interleaved in one script | `@component` functions return a **tree** of elements |
14
+ | `st.session_state` keys scattered and stringly | `state()` keys scoped to the render path |
15
+ | Hard to snapshot or reason about structure | `streamtree.testing.render_to_tree()` for structure checks |
16
+
17
+ Streamtree is **not** a React clone, a browser framework, or a JS build step. It is an **architecture layer** for teams who want maintainable Streamlit apps.
18
+
19
+ ---
20
+
21
+ ## Features
22
+
23
+ - **Python-first** — decorators, plain functions, standard typing
24
+ - **Declarative layouts** — `Page`, `Card`, `Grid`, `VStack`, `Form`, `Tabs`, `Sidebar`, …
25
+ - **Session-backed state** — `state`, `toggle_state`, `form_state`, `memo`, `cache`
26
+ - **Streamlit renderer** — virtual tree → `st.*` on each rerun
27
+ - **Testing helpers** — serialize trees for snapshots (`render_to_tree`)
28
+ - **Typed trajectory** — roadmap and dependency strategy center on **Pydantic** and curated optional extras
29
+
30
+ ---
31
+
32
+ ## Requirements
33
+
34
+ - **Python 3.10+**
35
+ - **Streamlit ≥ 1.28** (declared in `pyproject.toml`)
36
+
37
+ ---
38
+
39
+ ## Install
40
+
41
+ **From PyPI** (after you publish this version):
42
+
43
+ ```bash
44
+ pip install streamtree==0.1.0
45
+ ```
46
+
47
+ **From a clone** (editable, with dev tools):
48
+
49
+ ```bash
50
+ git clone https://github.com/streamtree-dev/streamtree.git
51
+ cd streamtree
52
+ pip install -e ".[dev]"
53
+ # or, with uv:
54
+ uv sync --extra dev
55
+ ```
56
+
57
+ Optional install groups (`tables`, `charts`, `ui`, `auth`, `all`) are specified in the [dependency strategy](docs/STREAMTREE_DEPENDENCY_STRATEGY.md) and will appear in `pyproject.toml` as those integrations ship.
58
+
59
+ ---
60
+
61
+ ## Quick start
62
+
63
+ ```python
64
+ from streamtree import component, render
65
+ from streamtree.elements import Button, Card, Page, Text
66
+ from streamtree.state import state
67
+
68
+
69
+ @component
70
+ def Counter():
71
+ count = state(0)
72
+
73
+ return Card(
74
+ Text(f"Count: {count()}"),
75
+ Button("Increment", on_click=lambda: count.increment(1)),
76
+ Button("Reset", on_click=lambda: count.set(0)),
77
+ )
78
+
79
+
80
+ if __name__ == "__main__":
81
+ render(Page(Counter()))
82
+ ```
83
+
84
+ Run the bundled demo from the repo root:
85
+
86
+ ```bash
87
+ streamlit run examples/counter.py
88
+ ```
89
+
90
+ ---
91
+
92
+ ## Layout and state at a glance
93
+
94
+ **Grid of components**
95
+
96
+ ```python
97
+ from streamtree.elements import Grid
98
+
99
+ Grid(
100
+ UserCard(user1),
101
+ UserCard(user2),
102
+ columns=2,
103
+ )
104
+ ```
105
+
106
+ **Bound text input**
107
+
108
+ ```python
109
+ from streamtree.elements import TextInput
110
+ from streamtree.state import state
111
+
112
+ search = state("")
113
+ TextInput(label="Search", value=search)
114
+ ```
115
+
116
+ ---
117
+
118
+ ## Project layout
119
+
120
+ ```text
121
+ src/streamtree/ # installable package
122
+ core/ # elements, @component, render, context
123
+ elements/ # layouts + widgets
124
+ state/ # session state helpers
125
+ renderers/ # Streamlit backend
126
+ testing/ # tree serialization for tests
127
+ docs/ # plan, roadmap, dependency strategy
128
+ examples/ # runnable Streamlit examples
129
+ tests/ # pytest
130
+ ```
131
+
132
+ ---
133
+
134
+ ## Documentation
135
+
136
+ | Document | Contents |
137
+ |----------|----------|
138
+ | [STREAMTREE_PLAN.md](docs/STREAMTREE_PLAN.md) | Vision, goals, architecture, risks |
139
+ | [STREAMTREE_ROADMAP.md](docs/STREAMTREE_ROADMAP.md) | Phased delivery and dependency alignment |
140
+ | [STREAMTREE_DEPENDENCY_STRATEGY.md](docs/STREAMTREE_DEPENDENCY_STRATEGY.md) | Base vs optional deps, extras, wrapper-first API |
141
+ | [CHANGELOG.md](CHANGELOG.md) | Version history |
142
+
143
+ ---
144
+
145
+ ## Contributing
146
+
147
+ With **[uv](https://docs.astral.sh/uv/)** (recommended):
148
+
149
+ ```bash
150
+ uv sync --extra dev
151
+ uv run ruff check src tests
152
+ uv run ty check src
153
+ uv run pytest
154
+ ```
155
+
156
+ With **pip**:
157
+
158
+ ```bash
159
+ pip install -e ".[dev]"
160
+ ruff check src tests
161
+ ty check src
162
+ pytest
163
+ ```
164
+
165
+ CI runs the same checks on Python 3.10–3.12 (see `.github/workflows/ci.yml`).
166
+
167
+ ### Publishing
168
+
169
+ For **0.1.0**, build artifacts with `uv build` (or `python -m build`), then upload the contents of `dist/` to PyPI using **twine**, **uv publish**, or [Trusted Publishing](https://docs.pypi.org/trusted-publishers/). Tag the release commit `v0.1.0` on your default branch and record changes in [CHANGELOG.md](CHANGELOG.md). Keep `version` in `pyproject.toml`, `streamtree.__version__`, `tests/test_package_meta.py`, and the changelog entry aligned when you cut releases.
170
+
171
+ ---
172
+
173
+ ## License
174
+
175
+ MIT — see the [`LICENSE`](LICENSE) file.