Metadata-Version: 2.4
Name: pihanga-remote
Version: 0.1.1
Summary: Drive a Pihanga card UI (prebuilt generic bundle) from Python via JSON-Patch over WebSocket
License-Expression: MIT
Keywords: pihanga,ui,fastapi,websocket,json-patch,shadcn,server-driven-ui
Author: Max Ott
Author-email: max.ott@data61.csiro.au
Requires-Python: >=3.10,<4.0
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: FastAPI
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: User Interfaces
Requires-Dist: fastapi (>=0.110)
Requires-Dist: jsonpatch (>=1.33)
Requires-Dist: pydantic (>=2.6)
Requires-Dist: uvicorn[standard] (>=0.29)
Project-URL: Documentation, https://github.com/ivcap-works/pihanga-remote#readme
Project-URL: Homepage, https://github.com/ivcap-works/pihanga-remote
Project-URL: Repository, https://github.com/ivcap-works/pihanga-remote
Description-Content-Type: text/markdown

# pihanga-remote

Drive a [Pihanga](https://github.com/ivcap-works/pihanga-core) card UI from Python.

The package contains:
- a prebuilt browser bundle: the lean runtime plus the `@pihanga2/shadcn` cards;
- typed pydantic classes for every card (`pihanga_remote.cards.shadcn`);
- a FastAPI server that serves the bundle and keeps each browser tab in sync over a WebSocket, using JSON Patch.

You don't need any JavaScript tooling to use it.

```python
from pihanga_remote import create_app
from pihanga_remote.cards.shadcn import SdFramework, Stack, Typography, Button

def build(s):                                  # called once per browser tab
    count = Typography(text="0", level="h2")
    def inc(ev):
        count.text = str(int(count.text) + 1)  # mutate the card; the browser is patched
    s.window(SdFramework(page=Stack(direction="column",
                                    content=[count, Button(label="+", on_clicked=inc)])))

app = create_app(build)                        # python -m uvicorn mymodule:app
```

See the project README for the protocol, the design, and how to build an app.

