@orkestrel/terminal 0.0.7 → 0.0.9
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 +51 -33
- package/dist/src/core/index.cjs +785 -869
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +627 -862
- package/dist/src/core/index.d.ts +627 -862
- package/dist/src/core/index.js +777 -841
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +555 -205
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +232 -129
- package/dist/src/server/index.d.ts +232 -129
- package/dist/src/server/index.js +540 -206
- package/dist/src/server/index.js.map +1 -1
- package/package.json +8 -6
package/README.md
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
# @orkestrel/terminal
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
`
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
`@orkestrel/
|
|
3
|
+
The terminal side of a form, for the `@orkestrel` line. `@orkestrel/form` owns
|
|
4
|
+
the document — the schema, the twelve controls, the rules, the values, and the
|
|
5
|
+
settle-once `answer` promise. This package owns what form has no opinion about:
|
|
6
|
+
a key decoder, a theme, pure per-field reducers, and three surfaces one form
|
|
7
|
+
can be answered on. The server `Terminal` implements the one driving contract
|
|
8
|
+
against a real TTY (raw-mode stdin, live in-place re-render, a `node:readline`
|
|
9
|
+
fallback when piped). The headless `Prompt` broker PARKS a live form until
|
|
10
|
+
somebody elsewhere answers it. The `PromptClient` bridge carries a form parked
|
|
11
|
+
elsewhere to this machine's keyboard over SSE. Built beside
|
|
12
|
+
`@orkestrel/console` (the shared style engine), `@orkestrel/contract`,
|
|
13
|
+
`@orkestrel/emitter`, `@orkestrel/database`, and `@orkestrel/sse`.
|
|
13
14
|
|
|
14
15
|
## Install
|
|
15
16
|
|
|
@@ -17,60 +18,77 @@ style engine), `@orkestrel/contract`, `@orkestrel/emitter`, and
|
|
|
17
18
|
npm install @orkestrel/terminal
|
|
18
19
|
```
|
|
19
20
|
|
|
21
|
+
`@orkestrel/form` is pinned to a committed tarball until it is published, so
|
|
22
|
+
this package is not publishable yet. The pin, its standing conditions, and the
|
|
23
|
+
re-pin recipe are recorded in [guides/terminal.md](./guides/terminal.md).
|
|
24
|
+
|
|
20
25
|
## Requirements
|
|
21
26
|
|
|
22
27
|
- Node.js >= 22
|
|
23
|
-
- Core
|
|
28
|
+
- Core and `./server` both ship dual ESM+CJS builds
|
|
24
29
|
|
|
25
30
|
## Usage
|
|
26
31
|
|
|
27
|
-
|
|
28
|
-
remote terminal):
|
|
32
|
+
Ask one whole form at this machine's keyboard:
|
|
29
33
|
|
|
30
34
|
```ts
|
|
31
|
-
import {
|
|
35
|
+
import { createForm } from '@orkestrel/form'
|
|
36
|
+
import { createTerminal } from '@orkestrel/terminal/server'
|
|
32
37
|
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
38
|
+
const terminal = createTerminal()
|
|
39
|
+
const values = await terminal.ask(
|
|
40
|
+
createForm({
|
|
41
|
+
fields: [
|
|
42
|
+
{ control: 'text', name: 'name', label: 'Your name', rule: { required: true } },
|
|
43
|
+
{ control: 'confirm', name: 'terms', label: 'Accept the terms', rule: { required: true } },
|
|
44
|
+
],
|
|
45
|
+
}),
|
|
46
|
+
)
|
|
36
47
|
```
|
|
37
48
|
|
|
38
|
-
|
|
49
|
+
A bare return binds ABSENCE, not the empty string, so `required` refuses it and
|
|
50
|
+
the walk asks again.
|
|
51
|
+
|
|
52
|
+
Park a live form and answer it from anywhere else:
|
|
39
53
|
|
|
40
54
|
```ts
|
|
41
|
-
import {
|
|
55
|
+
import { createForm } from '@orkestrel/form'
|
|
56
|
+
import { createPrompt } from '@orkestrel/terminal'
|
|
42
57
|
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
58
|
+
const prompt = createPrompt()
|
|
59
|
+
prompt.emitter.on('pending', (form) => send(form)) // the wire-safe record
|
|
60
|
+
|
|
61
|
+
const form = createForm({ fields: [{ control: 'text', name: 'name' }] })
|
|
62
|
+
const id = prompt.park(form) // the id; you await the form's own `answer`
|
|
63
|
+
prompt.answer(id, { name: 'Ada' }) // fills and submits the AUTHORITATIVE form
|
|
64
|
+
const values = await form.answer // { name: 'Ada' }
|
|
46
65
|
```
|
|
47
66
|
|
|
48
|
-
Bridge a
|
|
67
|
+
Bridge a form parked elsewhere to a local terminal over SSE:
|
|
49
68
|
|
|
50
69
|
```ts
|
|
51
70
|
import { createPromptClient } from '@orkestrel/terminal'
|
|
52
71
|
import { createTerminal } from '@orkestrel/terminal/server'
|
|
53
72
|
|
|
54
73
|
const client = createPromptClient({
|
|
55
|
-
url: 'http://localhost:3000/
|
|
74
|
+
url: 'http://localhost:3000/forms',
|
|
56
75
|
terminal: createTerminal(),
|
|
57
76
|
})
|
|
58
|
-
await client.connect()
|
|
77
|
+
await client.connect() // renders each parked form here, POSTs { id, values } back
|
|
59
78
|
```
|
|
60
79
|
|
|
61
80
|
## Guide
|
|
62
81
|
|
|
63
|
-
See [guides/
|
|
64
|
-
|
|
65
|
-
|
|
82
|
+
See [guides/terminal.md](./guides/terminal.md) for the documented surface — the
|
|
83
|
+
driving contract, the pure reducers, the broker, the wire seam, the SSE bridge,
|
|
84
|
+
the multi-endpoint manager, the stores, and the TTY driver.
|
|
66
85
|
|
|
67
86
|
## Package
|
|
68
87
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
ESM+CJS builds.
|
|
88
|
+
Two entry points, per the `exports` field in `package.json`: `.` (the
|
|
89
|
+
host-independent core — the reducers, the broker, the bridge, the manager, and
|
|
90
|
+
the stores) and `./server` (the Node-only `Terminal` driver). Both entry points
|
|
91
|
+
ship dual ESM+CJS builds.
|
|
74
92
|
|
|
75
93
|
## License
|
|
76
94
|
|