@pipeline-moe/client-core 0.1.0 → 0.1.1
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.
- package/README.md +57 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# @pipeline-moe/client-core
|
|
2
|
+
|
|
3
|
+
Framework-agnostic client library for a
|
|
4
|
+
[pipeline-moe](https://github.com/DAXZEIT/pipeline-moe) server — the shared
|
|
5
|
+
core behind both official clients (the
|
|
6
|
+
[`pmoe` TUI](https://www.npmjs.com/package/@pipeline-moe/tui) and the bundled
|
|
7
|
+
web UI).
|
|
8
|
+
|
|
9
|
+
## What's inside
|
|
10
|
+
|
|
11
|
+
- **Typed REST surface** — `createApi(apiBase)` wraps every server endpoint
|
|
12
|
+
(rooms, messages, lineup, presets, providers) with typed requests/responses.
|
|
13
|
+
- **Pure SSE reducer** — `reduce(state, event) -> { state, effects }` turns the
|
|
14
|
+
server's event stream into room state deterministically; trivially unit
|
|
15
|
+
testable.
|
|
16
|
+
- **Effectful room store** — `createRoomStore` binds the reducer to a live
|
|
17
|
+
`EventSource`, with subscribe/notify semantics that plug straight into
|
|
18
|
+
`useSyncExternalStore` (web) or any render loop (TUI).
|
|
19
|
+
- **Injectable `EventSourceFactory`** — the browser uses the global
|
|
20
|
+
`EventSource`; Node clients inject one (e.g. the
|
|
21
|
+
[`eventsource`](https://www.npmjs.com/package/eventsource) package).
|
|
22
|
+
|
|
23
|
+
Ships as plain ESM with type declarations — no framework, no build-tool
|
|
24
|
+
assumptions.
|
|
25
|
+
|
|
26
|
+
## Install
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm i @pipeline-moe/client-core
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Usage sketch
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { createRoomStore } from "@pipeline-moe/client-core"
|
|
36
|
+
|
|
37
|
+
const store = createRoomStore({
|
|
38
|
+
apiBase: "http://localhost:5300",
|
|
39
|
+
roomId: "default",
|
|
40
|
+
// In the browser, omit eventSourceFactory (global EventSource is used).
|
|
41
|
+
// In Node, inject one built on the `eventsource` package:
|
|
42
|
+
eventSourceFactory: nodeEventSourceFactory,
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
const unsubscribe = store.subscribe(() => {
|
|
46
|
+
const state = store.getSnapshot() // roster, transcript, streaming buffers…
|
|
47
|
+
})
|
|
48
|
+
store.start() // loads the snapshot and opens the SSE stream
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
A Node factory is ~10 lines over the `EventSourceFactory` seam — see
|
|
52
|
+
[`packages/tui/src/nodeEventSource.ts`](https://github.com/DAXZEIT/pipeline-moe/blob/main/packages/tui/src/nodeEventSource.ts)
|
|
53
|
+
for the reference implementation.
|
|
54
|
+
|
|
55
|
+
## License
|
|
56
|
+
|
|
57
|
+
MIT — see the [repository](https://github.com/DAXZEIT/pipeline-moe).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipeline-moe/client-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Framework-agnostic client for a pipeline-moe server: typed REST surface, pure SSE reducer, and an effectful room store. Consumed by the web and terminal clients.",
|