Skip to content

Commit 88b7570

Browse files
authored
Merge pull request #10 from bcdev/forman/start_0.1.1
Started dvelopment of v0.1.1
2 parents 197b182 + 2955130 commit 88b7570

9 files changed

Lines changed: 79 additions & 34 deletions

File tree

README.md

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
# RemoteState
22

33
[![CI](https://github.com/bcdev/remotestate/actions/workflows/ci.yml/badge.svg)](https://github.com/bcdev/remotestate/actions/workflows/ci.yml)
4+
5+
[![PyPI version](https://img.shields.io/pypi/v/remotestate?logo=pypi)](https://pypi.org/project/remotestate/)
6+
[![Python](https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white)](https://www.python.org/)
7+
[![FastAPI](https://img.shields.io/badge/FastAPI-009688?logo=fastapi&logoColor=white)](https://fastapi.tiangolo.com/)
8+
[![pydantic](https://img.shields.io/badge/pydantic-E92063?logo=pydantic&logoColor=white)](https://docs.pydantic.dev/)
9+
[![Ruff](https://img.shields.io/badge/Ruff-2C2F3A?logo=ruff&logoColor=white)](https://docs.astral.sh/ruff/)
10+
11+
[![npm version](https://img.shields.io/npm/v/remotestate?logo=npm)](https://www.npmjs.com/package/remotestate)
412
[![TypeScript](https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
13+
[![React](https://img.shields.io/badge/React-61DAFB?logo=react&logoColor=black)](https://react.dev/)
514
[![Vite](https://img.shields.io/badge/Vite-646CFF?logo=vite&logoColor=white)](https://vite.dev/)
6-
[![Ruff](https://img.shields.io/badge/Ruff-2C2F3A?logo=ruff&logoColor=white)](https://docs.astral.sh/ruff/)
7-
[![Python](https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white)](https://www.python.org/)
15+
816
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
917

1018
> **Python state, React UI.** One runtime for notebook apps and addon backends.
@@ -184,16 +192,16 @@ npm install remotestate
184192

185193
## Python API
186194

187-
### `Store(initial: dict)`
195+
### `Store(initial: dict[str, Any])`
188196

189197
Holds application state. Supports nested dicts, lists, Pydantic models, and dataclasses.
190198

191199
```python
192-
store = rs.Store({"items": [], "user": UserModel(name="Norman")})
193-
store.get("user.name") # "Norman"
200+
store = rs.Store({"items": [], "user": UserModel(name="forman")})
201+
store.get("user.name") # "forman"
194202
store.set("items[0].label", "foo")
195203
```
196-
204+
^^
197205
Paths use a JSONPath-inspired syntax such as `user.name` or `items[3].label`.
198206

199207
### `@action`
@@ -219,35 +227,38 @@ async def process(self, path: str) -> dict:
219227
return result
220228
```
221229

222-
### `rs.serve(service, *, dist_dir, host, port, open_browser, open_iframe, iframe_height)`
230+
### `rs.serve(service, *, ui_dist, app, open_browser, open_iframe, iframe_height, host, port, **uvicorn_settings)`
223231

224232
Starts the Remote State server and connects it to a frontend bundle.
225233

226-
| Parameter | Default | Description |
227-
|---|---|---|
228-
| `service` | required | A `Service` instance |
229-
| `dist_dir` | `None` | Path to the React build output (`dist/`) |
230-
| `host` | `"localhost"` | Server host |
231-
| `port` | `9753` | Server port |
232-
| `open_browser` | auto | Open in browser, default outside Jupyter |
233-
| `open_iframe` | auto | Render as IFrame, default in Jupyter |
234-
| `iframe_height` | `600` | IFrame height in pixels |
234+
| Parameter | Default | Description |
235+
|--------------------|---------------|-----------------------------------------------------------------|
236+
| `service` | required | A `Service` instance |
237+
| `ui_dist` | `None` | Path to the React build output (`dist/`) or URL |
238+
| `mounts` | `None` | Mapping of an endpoint paths to local directories |
239+
| `app` | `None` | [FastAPI](https://fastapi.tiangolo.com/) instance |
240+
| `open_browser` | auto | Open in browser, default outside Jupyter |
241+
| `open_iframe` | auto | Render as IFrame, default in Jupyter |
242+
| `iframe_height` | `400` | IFrame height in pixels |
243+
| `host` | `"localhost"` | Server host |
244+
| `port` | `9753` | Server port |
245+
| `uvicorn_settings` | - | Additional [uvicorn settings]((https://uvicorn.dev/settings/) |
235246

236247
Re-running the same Jupyter cell restarts the server automatically.
237248

238249
---
239250

240251
## TypeScript API
241252

242-
### `createRemoteState<TService>(url)`
253+
### `createRemoteState<S>(url)`
243254

244255
Creates a typed RemoteState bridge.
245256

246257
```typescript
247258
const remoteState = createRemoteState<MyService>("ws://localhost:9753/ws");
248259
```
249260

250-
### `RemoteStateProvider` and `useRemoteStateClient<TService>()`
261+
### `RemoteStateProvider` and `useRemoteStateClient<S>()`
251262

252263
React context wrapper for a RemoteState bridge bound to a WebSocket URL, plus
253264
a hook to access it.
@@ -260,7 +271,7 @@ a hook to access it.
260271
const remoteState = useRemoteStateClient<MyService>();
261272
```
262273

263-
### `useState<T>(path, initialValue?)`
274+
### `useRemoteState<T>(path, initialValue?)`
264275

265276
React-like state hook backed by the Python store. It returns `[value, setValue]`.
266277

@@ -275,7 +286,7 @@ Calls a Python `@action`. Fire-and-forget by default.
275286

276287
```typescript
277288
await remoteState.action("increment");
278-
await remoteState.action("set_name", ["Norman"]);
289+
await remoteState.action("set_name", ["forman"]);
279290
await remoteState.action("save", [], {}, { awaitInvalidate: true });
280291
```
281292

@@ -284,7 +295,7 @@ await remoteState.action("save", [], {}, { awaitInvalidate: true });
284295
Calls a Python `@query` and returns the result.
285296

286297
```typescript
287-
const result = await remoteState.query("compute", [5.0]);
298+
const result = await remoteState.query("compute", [2.5]);
288299
```
289300

290301
### `useRemoteStateValue<T>(path)`
@@ -297,9 +308,7 @@ re-renders on invalidation.
297308
- `RemoteState` is the bridge object that used to be called `Client`.
298309
- `useRemoteStateClient()` returns that bridge object.
299310
- `useRemoteStore()` returns the cached store view used by the hooks.
300-
- `useState()` remains the ergonomic path-bound state hook for components.
301-
- We use `useRemoteStateClient()` instead of `useRemoteState()` to keep it
302-
clearly distinct from `useState()` and `useRemoteStore()`.
311+
- `useRemoteState()` remains the ergonomic path-bound state hook for components.
303312

304313
---
305314

remotestate-demo/package-lock.json

Lines changed: 4 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

remotestate-py/CHANGES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
## Version 0.1.1 (in development)
2+
3+
4+
## Version 0.1.0
5+
6+
Initial release from 2026-06-09.

remotestate-py/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# RemoteState - Python
22

3+
[![CI](https://github.com/bcdev/remotestate/actions/workflows/ci.yml/badge.svg)](https://github.com/bcdev/remotestate/actions/workflows/ci.yml)
4+
5+
[![PyPI version](https://img.shields.io/pypi/v/remotestate?logo=pypi)](https://pypi.org/project/remotestate/)
6+
[![Python](https://img.shields.io/badge/Python-3776AB?logo=python&logoColor=white)](https://www.python.org/)
7+
[![FastAPI](https://img.shields.io/badge/FastAPI-009688?logo=fastapi&logoColor=white)](https://fastapi.tiangolo.com/)
8+
[![pydantic](https://img.shields.io/badge/pydantic-E92063?logo=pydantic&logoColor=white)](https://docs.pydantic.dev/)
9+
[![Ruff](https://img.shields.io/badge/Ruff-2C2F3A?logo=ruff&logoColor=white)](https://docs.astral.sh/ruff/)
10+
11+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
12+
13+
314
`remotestate` is the Python runtime for the _RemoteState_ library.
415

516
It gives you:

remotestate-py/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "remotestate"
3-
version = "0.1.0"
3+
version = "0.1.1.dev0"
44
authors = [{name = "forman"}]
55
description = "Python state, React UI."
66
readme = "README.md"

remotestate-ts/CHANGES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
## Version 0.1.1 (in development)
2+
3+
4+
## Version 0.1.0
5+
6+
Initial release from 2026-06-09.

remotestate-ts/README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# RemoteState - TypeScript/React
22

3+
[![CI](https://github.com/bcdev/remotestate/actions/workflows/ci.yml/badge.svg)](https://github.com/bcdev/remotestate/actions/workflows/ci.yml)
4+
5+
[![npm version](https://img.shields.io/npm/v/remotestate?logo=npm)](https://www.npmjs.com/package/remotestate)
6+
[![TypeScript](https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
7+
[![React](https://img.shields.io/badge/React-61DAFB?logo=react&logoColor=black)](https://react.dev/)
8+
[![Vite](https://img.shields.io/badge/Vite-646CFF?logo=vite&logoColor=white)](https://vite.dev/)
9+
10+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
11+
12+
313
`remotestate` is the TypeScript and React bridge of the _RemoteState_ library.
414

515
This package provides the frontend client, provider, and hooks that pair with
@@ -14,7 +24,7 @@ npm install remotestate
1424
## Use
1525

1626
```ts
17-
import { RemoteStateProvider, useRemoteStateClient } from "remotestate";
27+
import { RemoteStateProvider, useRemoteState } from "remotestate";
1828
```
1929

2030
For full project documentation, see the repository root README:

remotestate-ts/package-lock.json

Lines changed: 6 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

remotestate-ts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "remotestate",
3-
"version": "0.1.0",
3+
"version": "0.1.1-dev.0",
44
"description": "Python state, React UI.",
55
"type": "module",
66
"main": "./dist/remotestate.js",

0 commit comments

Comments
 (0)