@textui/core 0.1.0
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/LICENSE +21 -0
- package/README.md +67 -0
- package/dist/adapters/index.d.ts +12 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +11 -0
- package/dist/app/app.d.ts +200 -0
- package/dist/app/app.d.ts.map +1 -0
- package/dist/app/app.js +980 -0
- package/dist/core/animation.d.ts +34 -0
- package/dist/core/animation.d.ts.map +1 -0
- package/dist/core/animation.js +125 -0
- package/dist/core/clipboard.d.ts +29 -0
- package/dist/core/clipboard.d.ts.map +1 -0
- package/dist/core/clipboard.js +30 -0
- package/dist/core/commands.d.ts +42 -0
- package/dist/core/commands.d.ts.map +1 -0
- package/dist/core/commands.js +146 -0
- package/dist/core/components.d.ts +27 -0
- package/dist/core/components.d.ts.map +1 -0
- package/dist/core/components.js +78 -0
- package/dist/core/events.d.ts +23 -0
- package/dist/core/events.d.ts.map +1 -0
- package/dist/core/events.js +77 -0
- package/dist/core/focus.d.ts +69 -0
- package/dist/core/focus.d.ts.map +1 -0
- package/dist/core/focus.js +336 -0
- package/dist/core/i18n.d.ts +27 -0
- package/dist/core/i18n.d.ts.map +1 -0
- package/dist/core/i18n.js +88 -0
- package/dist/core/keybindings.d.ts +53 -0
- package/dist/core/keybindings.d.ts.map +1 -0
- package/dist/core/keybindings.js +163 -0
- package/dist/core/layers.d.ts +28 -0
- package/dist/core/layers.d.ts.map +1 -0
- package/dist/core/layers.js +84 -0
- package/dist/core/manifest.d.ts +22 -0
- package/dist/core/manifest.d.ts.map +1 -0
- package/dist/core/manifest.js +85 -0
- package/dist/core/navigation.d.ts +47 -0
- package/dist/core/navigation.d.ts.map +1 -0
- package/dist/core/navigation.js +110 -0
- package/dist/core/resources.d.ts +115 -0
- package/dist/core/resources.d.ts.map +1 -0
- package/dist/core/resources.js +321 -0
- package/dist/core/services.d.ts +21 -0
- package/dist/core/services.d.ts.map +1 -0
- package/dist/core/services.js +63 -0
- package/dist/core/store.d.ts +60 -0
- package/dist/core/store.d.ts.map +1 -0
- package/dist/core/store.js +593 -0
- package/dist/core/surfaces.d.ts +81 -0
- package/dist/core/surfaces.d.ts.map +1 -0
- package/dist/core/surfaces.js +237 -0
- package/dist/core/syntax.d.ts +49 -0
- package/dist/core/syntax.d.ts.map +1 -0
- package/dist/core/syntax.js +172 -0
- package/dist/core/when.d.ts +15 -0
- package/dist/core/when.d.ts.map +1 -0
- package/dist/core/when.js +224 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +54 -0
- package/dist/jsx/factory.d.ts +27 -0
- package/dist/jsx/factory.d.ts.map +1 -0
- package/dist/jsx/factory.js +102 -0
- package/dist/jsx/intrinsics.d.ts +96 -0
- package/dist/jsx/intrinsics.d.ts.map +1 -0
- package/dist/jsx/intrinsics.js +1 -0
- package/dist/jsx/jsx-dev-runtime.d.ts +13 -0
- package/dist/jsx/jsx-dev-runtime.d.ts.map +1 -0
- package/dist/jsx/jsx-dev-runtime.js +12 -0
- package/dist/jsx/jsx-runtime.d.ts +42 -0
- package/dist/jsx/jsx-runtime.d.ts.map +1 -0
- package/dist/jsx/jsx-runtime.js +16 -0
- package/dist/render/buffer.d.ts +77 -0
- package/dist/render/buffer.d.ts.map +1 -0
- package/dist/render/buffer.js +275 -0
- package/dist/render/color.d.ts +35 -0
- package/dist/render/color.d.ts.map +1 -0
- package/dist/render/color.js +160 -0
- package/dist/render/diff.d.ts +37 -0
- package/dist/render/diff.d.ts.map +1 -0
- package/dist/render/diff.js +66 -0
- package/dist/render/layout.d.ts +72 -0
- package/dist/render/layout.d.ts.map +1 -0
- package/dist/render/layout.js +633 -0
- package/dist/render/static.d.ts +63 -0
- package/dist/render/static.d.ts.map +1 -0
- package/dist/render/static.js +209 -0
- package/dist/runtime/bindings.d.ts +46 -0
- package/dist/runtime/bindings.d.ts.map +1 -0
- package/dist/runtime/bindings.js +116 -0
- package/dist/runtime/hooks.d.ts +284 -0
- package/dist/runtime/hooks.d.ts.map +1 -0
- package/dist/runtime/hooks.js +846 -0
- package/dist/runtime/instance.d.ts +106 -0
- package/dist/runtime/instance.d.ts.map +1 -0
- package/dist/runtime/instance.js +181 -0
- package/dist/runtime/paint.d.ts +27 -0
- package/dist/runtime/paint.d.ts.map +1 -0
- package/dist/runtime/paint.js +567 -0
- package/dist/runtime/reconcile.d.ts +23 -0
- package/dist/runtime/reconcile.d.ts.map +1 -0
- package/dist/runtime/reconcile.js +260 -0
- package/dist/runtime/runtime.d.ts +42 -0
- package/dist/runtime/runtime.d.ts.map +1 -0
- package/dist/runtime/runtime.js +1 -0
- package/dist/runtime/style.d.ts +55 -0
- package/dist/runtime/style.d.ts.map +1 -0
- package/dist/runtime/style.js +143 -0
- package/dist/themes/borders.d.ts +10 -0
- package/dist/themes/borders.d.ts.map +1 -0
- package/dist/themes/borders.js +88 -0
- package/dist/themes/builtin.d.ts +31 -0
- package/dist/themes/builtin.d.ts.map +1 -0
- package/dist/themes/builtin.js +291 -0
- package/dist/themes/glyphs.d.ts +15 -0
- package/dist/themes/glyphs.d.ts.map +1 -0
- package/dist/themes/glyphs.js +97 -0
- package/dist/themes/index.d.ts +5 -0
- package/dist/themes/index.d.ts.map +1 -0
- package/dist/themes/index.js +4 -0
- package/dist/themes/registry.d.ts +20 -0
- package/dist/themes/registry.d.ts.map +1 -0
- package/dist/themes/registry.js +204 -0
- package/dist/types/adapter.d.ts +38 -0
- package/dist/types/adapter.d.ts.map +1 -0
- package/dist/types/adapter.js +1 -0
- package/dist/types/animation.d.ts +31 -0
- package/dist/types/animation.d.ts.map +1 -0
- package/dist/types/animation.js +1 -0
- package/dist/types/app.d.ts +148 -0
- package/dist/types/app.d.ts.map +1 -0
- package/dist/types/app.js +1 -0
- package/dist/types/async.d.ts +30 -0
- package/dist/types/async.d.ts.map +1 -0
- package/dist/types/async.js +1 -0
- package/dist/types/capabilities.d.ts +44 -0
- package/dist/types/capabilities.d.ts.map +1 -0
- package/dist/types/capabilities.js +33 -0
- package/dist/types/cells.d.ts +72 -0
- package/dist/types/cells.d.ts.map +1 -0
- package/dist/types/cells.js +10 -0
- package/dist/types/command.d.ts +127 -0
- package/dist/types/command.d.ts.map +1 -0
- package/dist/types/command.js +1 -0
- package/dist/types/component-registry.d.ts +77 -0
- package/dist/types/component-registry.d.ts.map +1 -0
- package/dist/types/component-registry.js +1 -0
- package/dist/types/disposable.d.ts +8 -0
- package/dist/types/disposable.d.ts.map +1 -0
- package/dist/types/disposable.js +1 -0
- package/dist/types/focus.d.ts +72 -0
- package/dist/types/focus.d.ts.map +1 -0
- package/dist/types/focus.js +1 -0
- package/dist/types/geometry.d.ts +28 -0
- package/dist/types/geometry.d.ts.map +1 -0
- package/dist/types/geometry.js +14 -0
- package/dist/types/graph.d.ts +129 -0
- package/dist/types/graph.d.ts.map +1 -0
- package/dist/types/graph.js +31 -0
- package/dist/types/i18n.d.ts +23 -0
- package/dist/types/i18n.d.ts.map +1 -0
- package/dist/types/i18n.js +1 -0
- package/dist/types/index.d.ts +32 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +31 -0
- package/dist/types/input.d.ts +65 -0
- package/dist/types/input.d.ts.map +1 -0
- package/dist/types/input.js +1 -0
- package/dist/types/keybinding.d.ts +49 -0
- package/dist/types/keybinding.d.ts.map +1 -0
- package/dist/types/keybinding.js +1 -0
- package/dist/types/layer.d.ts +54 -0
- package/dist/types/layer.d.ts.map +1 -0
- package/dist/types/layer.js +1 -0
- package/dist/types/manifest.d.ts +114 -0
- package/dist/types/manifest.d.ts.map +1 -0
- package/dist/types/manifest.js +1 -0
- package/dist/types/markdown.d.ts +58 -0
- package/dist/types/markdown.d.ts.map +1 -0
- package/dist/types/markdown.js +1 -0
- package/dist/types/navigation.d.ts +40 -0
- package/dist/types/navigation.d.ts.map +1 -0
- package/dist/types/navigation.js +1 -0
- package/dist/types/render.d.ts +72 -0
- package/dist/types/render.d.ts.map +1 -0
- package/dist/types/render.js +1 -0
- package/dist/types/resource.d.ts +170 -0
- package/dist/types/resource.d.ts.map +1 -0
- package/dist/types/resource.js +1 -0
- package/dist/types/services.d.ts +24 -0
- package/dist/types/services.d.ts.map +1 -0
- package/dist/types/services.js +3 -0
- package/dist/types/shell.d.ts +32 -0
- package/dist/types/shell.d.ts.map +1 -0
- package/dist/types/shell.js +1 -0
- package/dist/types/store.d.ts +124 -0
- package/dist/types/store.d.ts.map +1 -0
- package/dist/types/store.js +1 -0
- package/dist/types/stream.d.ts +18 -0
- package/dist/types/stream.d.ts.map +1 -0
- package/dist/types/stream.js +1 -0
- package/dist/types/style.d.ts +166 -0
- package/dist/types/style.d.ts.map +1 -0
- package/dist/types/style.js +1 -0
- package/dist/types/surface.d.ts +97 -0
- package/dist/types/surface.d.ts.map +1 -0
- package/dist/types/surface.js +1 -0
- package/dist/types/syntax.d.ts +68 -0
- package/dist/types/syntax.d.ts.map +1 -0
- package/dist/types/syntax.js +5 -0
- package/dist/types/terminal.d.ts +52 -0
- package/dist/types/terminal.d.ts.map +1 -0
- package/dist/types/terminal.js +1 -0
- package/dist/types/theme.d.ts +117 -0
- package/dist/types/theme.d.ts.map +1 -0
- package/dist/types/theme.js +1 -0
- package/dist/types/when.d.ts +19 -0
- package/dist/types/when.d.ts.map +1 -0
- package/dist/types/when.js +1 -0
- package/dist/ui/primitives.d.ts +56 -0
- package/dist/ui/primitives.d.ts.map +1 -0
- package/dist/ui/primitives.js +108 -0
- package/dist/ui/screen.d.ts +23 -0
- package/dist/ui/screen.d.ts.map +1 -0
- package/dist/ui/screen.js +18 -0
- package/dist/util/disposable.d.ts +6 -0
- package/dist/util/disposable.d.ts.map +1 -0
- package/dist/util/disposable.js +49 -0
- package/dist/util/markdown.d.ts +24 -0
- package/dist/util/markdown.d.ts.map +1 -0
- package/dist/util/markdown.js +220 -0
- package/dist/util/paths.d.ts +47 -0
- package/dist/util/paths.d.ts.map +1 -0
- package/dist/util/paths.js +134 -0
- package/dist/util/stream.d.ts +32 -0
- package/dist/util/stream.d.ts.map +1 -0
- package/dist/util/stream.js +206 -0
- package/dist/util/text.d.ts +65 -0
- package/dist/util/text.d.ts.map +1 -0
- package/dist/util/text.js +419 -0
- package/package.json +70 -0
- package/src/adapters/index.ts +11 -0
- package/src/app/app.ts +1096 -0
- package/src/core/animation.ts +144 -0
- package/src/core/clipboard.ts +40 -0
- package/src/core/commands.ts +169 -0
- package/src/core/components.ts +91 -0
- package/src/core/events.ts +95 -0
- package/src/core/focus.ts +358 -0
- package/src/core/i18n.ts +107 -0
- package/src/core/keybindings.ts +184 -0
- package/src/core/layers.ts +94 -0
- package/src/core/manifest.ts +84 -0
- package/src/core/navigation.ts +135 -0
- package/src/core/resources.ts +362 -0
- package/src/core/services.ts +69 -0
- package/src/core/store.ts +640 -0
- package/src/core/surfaces.ts +292 -0
- package/src/core/syntax.ts +200 -0
- package/src/core/when.ts +238 -0
- package/src/index.ts +76 -0
- package/src/jsx/factory.ts +124 -0
- package/src/jsx/intrinsics.ts +99 -0
- package/src/jsx/jsx-dev-runtime.ts +23 -0
- package/src/jsx/jsx-runtime.ts +76 -0
- package/src/render/buffer.ts +318 -0
- package/src/render/color.ts +180 -0
- package/src/render/diff.ts +99 -0
- package/src/render/layout.ts +764 -0
- package/src/render/static.ts +290 -0
- package/src/runtime/bindings.ts +150 -0
- package/src/runtime/hooks.ts +1057 -0
- package/src/runtime/instance.ts +284 -0
- package/src/runtime/paint.ts +737 -0
- package/src/runtime/reconcile.ts +335 -0
- package/src/runtime/runtime.ts +47 -0
- package/src/runtime/style.ts +205 -0
- package/src/themes/borders.ts +95 -0
- package/src/themes/builtin.ts +301 -0
- package/src/themes/glyphs.ts +101 -0
- package/src/themes/index.ts +4 -0
- package/src/themes/registry.ts +224 -0
- package/src/types/adapter.ts +41 -0
- package/src/types/animation.ts +34 -0
- package/src/types/app.ts +149 -0
- package/src/types/async.ts +35 -0
- package/src/types/capabilities.ts +79 -0
- package/src/types/cells.ts +79 -0
- package/src/types/command.ts +139 -0
- package/src/types/component-registry.ts +82 -0
- package/src/types/disposable.ts +8 -0
- package/src/types/focus.ts +77 -0
- package/src/types/geometry.ts +50 -0
- package/src/types/graph.ts +174 -0
- package/src/types/i18n.ts +25 -0
- package/src/types/index.ts +31 -0
- package/src/types/input.ts +81 -0
- package/src/types/keybinding.ts +51 -0
- package/src/types/layer.ts +46 -0
- package/src/types/manifest.ts +101 -0
- package/src/types/markdown.ts +47 -0
- package/src/types/navigation.ts +42 -0
- package/src/types/render.ts +86 -0
- package/src/types/resource.ts +185 -0
- package/src/types/services.ts +28 -0
- package/src/types/shell.ts +30 -0
- package/src/types/store.ts +148 -0
- package/src/types/stream.ts +24 -0
- package/src/types/style.ts +205 -0
- package/src/types/surface.ts +119 -0
- package/src/types/syntax.ts +93 -0
- package/src/types/terminal.ts +58 -0
- package/src/types/theme.ts +121 -0
- package/src/types/when.ts +21 -0
- package/src/ui/primitives.ts +118 -0
- package/src/ui/screen.ts +41 -0
- package/src/util/disposable.ts +49 -0
- package/src/util/markdown.ts +225 -0
- package/src/util/paths.ts +138 -0
- package/src/util/stream.ts +213 -0
- package/src/util/text.ts +428 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Softov
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# @textui/core
|
|
2
|
+
|
|
3
|
+
The runtime: a reactive store, typed registries, a cell-diffing renderer, hooks,
|
|
4
|
+
and the four host primitives. Everything else in TextUI sits on this.
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
npm install @textui/core
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## The one idea
|
|
11
|
+
|
|
12
|
+
**JSX compiles to data.** `<Row gap={1}/>` and `{ component: 'Row', gap: 1 }` are
|
|
13
|
+
the same value, and the runtime mounts either. A screen can be written in
|
|
14
|
+
TypeScript, loaded from JSON, generated, edited or sent over a wire without the
|
|
15
|
+
runtime changing.
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { h, renderToString } from '@textui/core';
|
|
19
|
+
|
|
20
|
+
console.log(renderToString(
|
|
21
|
+
h('box', { margin: 1, border: 'single' }, h('text', { content: 'hello' })),
|
|
22
|
+
{ width: 30 },
|
|
23
|
+
));
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Capitalized spellings of the primitives exist for JSX - `Box`, `Text`, `Canvas`
|
|
27
|
+
are the strings themselves, so `<Box/>` and `<box/>` produce the identical node.
|
|
28
|
+
|
|
29
|
+
## What is in here, and what is not
|
|
30
|
+
|
|
31
|
+
The four primitives - `box`, `text`, `canvas`, `spacer` - are here because the
|
|
32
|
+
layout engine and the painter are the things that reason about them. The
|
|
33
|
+
eighty-seven components built out of them are [`@textui/widgets`](https://github.com/softov/textui/tree/main/packages/widgets),
|
|
34
|
+
a separate package that depends on this one.
|
|
35
|
+
|
|
36
|
+
That split is not tidiness. An imported component travels on its own node, so a
|
|
37
|
+
screen written in JSX resolves without a registry at all:
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
import { Badge } from '@textui/widgets';
|
|
41
|
+
|
|
42
|
+
renderToString(h(Badge, { label: 'ok' }), { width: 20 }); // registry empty
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The registry is for the case JSX cannot cover - a component named by a string,
|
|
46
|
+
in JSON, a template renderer, or an extension. `render` takes those through its
|
|
47
|
+
`components` option.
|
|
48
|
+
|
|
49
|
+
## The parts
|
|
50
|
+
|
|
51
|
+
| | |
|
|
52
|
+
|---|---|
|
|
53
|
+
| Store | One reactive tree addressed by path. A prop can be `{ path: '$/x' }` and the runtime resolves it and redraws when it changes |
|
|
54
|
+
| Registries | Components, commands, keybindings, themes, shells, surfaces, resources - typed, and disposable |
|
|
55
|
+
| Renderer | Diffs cells rather than redrawing frames. `renderOnce` and `renderToString` draw one frame with no terminal at all |
|
|
56
|
+
| Hooks | `useState`, `useEffect`, `useStore`, `useFocus`, `useInterval` and thirty more - module imports, not a second argument |
|
|
57
|
+
| Layers | Dialogs, palettes, toasts and tooltips are entries on five planes, so focus trapping and dismissal are decided once |
|
|
58
|
+
|
|
59
|
+
## Runtime
|
|
60
|
+
|
|
61
|
+
No dependencies, and no `node:` imports - this package never touches a
|
|
62
|
+
filesystem or a process. It runs on Node 22+ and on Bun, and would run in a
|
|
63
|
+
browser against a virtual terminal.
|
|
64
|
+
|
|
65
|
+
## Documentation
|
|
66
|
+
|
|
67
|
+
<https://softov.github.io/textui/>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adapters.
|
|
3
|
+
*
|
|
4
|
+
* Nothing here is registered by default. An adapter is a choice - what a kind
|
|
5
|
+
* means, what opens it, what can be done to it - and choices belong to the
|
|
6
|
+
* application, not to the library that ships them.
|
|
7
|
+
*
|
|
8
|
+
* The adapters that have an opinion about *content* live in
|
|
9
|
+
* `@textui/documents`, beside the buffers they read and write.
|
|
10
|
+
*/
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adapters.
|
|
3
|
+
*
|
|
4
|
+
* Nothing here is registered by default. An adapter is a choice - what a kind
|
|
5
|
+
* means, what opens it, what can be done to it - and choices belong to the
|
|
6
|
+
* application, not to the library that ships them.
|
|
7
|
+
*
|
|
8
|
+
* The adapters that have an opinion about *content* live in
|
|
9
|
+
* `@textui/documents`, beside the buffers they read and write.
|
|
10
|
+
*/
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import type { CreateAppOptions, InspectorNode, TextUIApp } from '../types/app.js';
|
|
2
|
+
import type { ComponentNode } from '../types/graph.js';
|
|
3
|
+
import type { Disposable } from '../types/disposable.js';
|
|
4
|
+
import type { ResourceAdapter } from '../types/adapter.js';
|
|
5
|
+
import type { Size } from '../types/geometry.js';
|
|
6
|
+
import type { ResolvedTheme } from '../types/theme.js';
|
|
7
|
+
import type { TerminalCapabilities, CapabilityOverrides } from '../types/capabilities.js';
|
|
8
|
+
import type { InputEvent } from '../types/input.js';
|
|
9
|
+
import { Buffer } from '../render/buffer.js';
|
|
10
|
+
import { type Frame } from '../render/diff.js';
|
|
11
|
+
import { createStore } from '../core/store.js';
|
|
12
|
+
import { createEvents } from '../core/events.js';
|
|
13
|
+
import { createWhen } from '../core/when.js';
|
|
14
|
+
import { createComponents } from '../core/components.js';
|
|
15
|
+
import { createServices } from '../core/services.js';
|
|
16
|
+
import { createCommands } from '../core/commands.js';
|
|
17
|
+
import { createKeybindings } from '../core/keybindings.js';
|
|
18
|
+
import { createFocus } from '../core/focus.js';
|
|
19
|
+
import { createLayers } from '../core/layers.js';
|
|
20
|
+
import { createAnimation } from '../core/animation.js';
|
|
21
|
+
import { createI18n } from '../core/i18n.js';
|
|
22
|
+
import { createSurfaces, createLayouts, createShells } from '../core/surfaces.js';
|
|
23
|
+
import { createNavigation } from '../core/navigation.js';
|
|
24
|
+
import { createResources } from '../core/resources.js';
|
|
25
|
+
import { createSyntax } from '../core/syntax.js';
|
|
26
|
+
import { createManifests } from '../core/manifest.js';
|
|
27
|
+
import { createThemes } from '../themes/registry.js';
|
|
28
|
+
export declare class App implements TextUIApp {
|
|
29
|
+
private options;
|
|
30
|
+
readonly store: ReturnType<typeof createStore>;
|
|
31
|
+
readonly events: ReturnType<typeof createEvents>;
|
|
32
|
+
readonly when: ReturnType<typeof createWhen>;
|
|
33
|
+
readonly components: ReturnType<typeof createComponents>;
|
|
34
|
+
readonly themes: ReturnType<typeof createThemes>;
|
|
35
|
+
readonly services: ReturnType<typeof createServices>;
|
|
36
|
+
readonly i18n: ReturnType<typeof createI18n>;
|
|
37
|
+
readonly layouts: ReturnType<typeof createLayouts>;
|
|
38
|
+
readonly shells: ReturnType<typeof createShells>;
|
|
39
|
+
readonly animation: ReturnType<typeof createAnimation>;
|
|
40
|
+
readonly focus: ReturnType<typeof createFocus>;
|
|
41
|
+
readonly layers: ReturnType<typeof createLayers>;
|
|
42
|
+
readonly commands: ReturnType<typeof createCommands>;
|
|
43
|
+
readonly keybindings: ReturnType<typeof createKeybindings>;
|
|
44
|
+
readonly resources: ReturnType<typeof createResources>;
|
|
45
|
+
readonly syntax: ReturnType<typeof createSyntax>;
|
|
46
|
+
readonly surfaces: ReturnType<typeof createSurfaces>;
|
|
47
|
+
readonly screens: ReturnType<typeof createNavigation>;
|
|
48
|
+
readonly manifest: ReturnType<typeof createManifests>;
|
|
49
|
+
readonly terminal: NonNullable<CreateAppOptions['terminal']>;
|
|
50
|
+
private buffer_;
|
|
51
|
+
/** The mount holding the top of the screen stack, while there is one. */
|
|
52
|
+
private screenMount;
|
|
53
|
+
private root;
|
|
54
|
+
private frameScheduled;
|
|
55
|
+
private frameTimer;
|
|
56
|
+
private running_;
|
|
57
|
+
private disposed;
|
|
58
|
+
private themeId;
|
|
59
|
+
private shellId;
|
|
60
|
+
private resolvedTheme;
|
|
61
|
+
private bag;
|
|
62
|
+
private hovered;
|
|
63
|
+
/** Focus registrations created from `focusable` props, by focus id. */
|
|
64
|
+
private declaredFocus;
|
|
65
|
+
private lastFrame;
|
|
66
|
+
private renderCount;
|
|
67
|
+
private runtime;
|
|
68
|
+
constructor(options?: CreateAppOptions);
|
|
69
|
+
private requireTerminal;
|
|
70
|
+
get capabilities(): TerminalCapabilities;
|
|
71
|
+
get theme(): ResolvedTheme;
|
|
72
|
+
get size(): Size;
|
|
73
|
+
get running(): boolean;
|
|
74
|
+
private publishEnvironment;
|
|
75
|
+
setTheme(id: string): void;
|
|
76
|
+
setShell(id: string): void;
|
|
77
|
+
activeShell(): string;
|
|
78
|
+
setCapabilityOverrides(overrides: CapabilityOverrides): void;
|
|
79
|
+
start(): Promise<void>;
|
|
80
|
+
stop(): Promise<void>;
|
|
81
|
+
dispose(): void;
|
|
82
|
+
/**
|
|
83
|
+
* Swap the root node for another.
|
|
84
|
+
*
|
|
85
|
+
* Two paths, because there are two ways a root reaches the screen. With a
|
|
86
|
+
* shell registered it is a mount like any other and the surface registry
|
|
87
|
+
* owns it; with no shell at all - which is every application built out of
|
|
88
|
+
* primitives and nothing else - `rootNode` wraps `options.root` directly and
|
|
89
|
+
* the registry is never consulted. Setting one and not the other works in
|
|
90
|
+
* exactly half of the programs that can exist.
|
|
91
|
+
*/
|
|
92
|
+
setRoot(node: ComponentNode): void;
|
|
93
|
+
private requestRender;
|
|
94
|
+
flush(): void;
|
|
95
|
+
/**
|
|
96
|
+
* The tree the frame renders: the shell, always, when one is registered.
|
|
97
|
+
*
|
|
98
|
+
* `root` is an alternative to *screens*, not to the shell - it is mounted
|
|
99
|
+
* into `main` at boot. Returning it here instead meant an application built
|
|
100
|
+
* that way had no shell at all: no canvas background (so a light theme left
|
|
101
|
+
* the terminal's own dark one behind and only dialogs looked light), no
|
|
102
|
+
* status surface, no toast host, and `setShell` did nothing.
|
|
103
|
+
*/
|
|
104
|
+
/**
|
|
105
|
+
* Put the current screen into its surface.
|
|
106
|
+
*
|
|
107
|
+
* A screen is a mount like `root` is a mount: the shell arranges it, the
|
|
108
|
+
* layouts apply to it, and anything reading the surface registry sees it.
|
|
109
|
+
* Only the top of the stack is mounted - what a screen underneath keeps is
|
|
110
|
+
* its store scope, if it asked to, and not its instances.
|
|
111
|
+
*
|
|
112
|
+
* Parameters arrive as props. A screen that wants them deeper than its own
|
|
113
|
+
* signature reads `$/layout/screen/params` instead of forwarding them.
|
|
114
|
+
*/
|
|
115
|
+
private mountScreen;
|
|
116
|
+
private rootNode;
|
|
117
|
+
/**
|
|
118
|
+
* Layers are composed at the root rather than inside the tree, so an overlay
|
|
119
|
+
* is never clipped by whatever opened it.
|
|
120
|
+
*/
|
|
121
|
+
/**
|
|
122
|
+
* The root node: the shell, plus whatever is on the layers above it.
|
|
123
|
+
*
|
|
124
|
+
* The wrapper is unconditional, and that matters more than it looks. If the
|
|
125
|
+
* root were the bare shell whenever no layer is open, then opening the first
|
|
126
|
+
* toast would change the root's component - and a changed root is a full
|
|
127
|
+
* unmount and remount, so every screen would lose its state the moment
|
|
128
|
+
* anything notified it of anything. One shape, always.
|
|
129
|
+
*/
|
|
130
|
+
private composeRoot;
|
|
131
|
+
private layerNode;
|
|
132
|
+
private rectOf;
|
|
133
|
+
private stateOf;
|
|
134
|
+
private renderFrame;
|
|
135
|
+
/** Overridden by the test harness, which has no bytes to write. */
|
|
136
|
+
protected emitFrame(frame: Frame): void;
|
|
137
|
+
private cursorPosition;
|
|
138
|
+
/**
|
|
139
|
+
* `focusable` and `onKey` are props on every node, so a plain `box` can take
|
|
140
|
+
* focus without a hook. Those declarations are reconciled here rather than
|
|
141
|
+
* during render, because a node that has gone away must lose its
|
|
142
|
+
* registration - and only the render pass knows which are still mounted.
|
|
143
|
+
*/
|
|
144
|
+
private syncDeclaredFocusables;
|
|
145
|
+
private updateFocusRects;
|
|
146
|
+
private isDirty;
|
|
147
|
+
buffer(): Buffer;
|
|
148
|
+
frame(): Frame | null;
|
|
149
|
+
/**
|
|
150
|
+
* Input is processed one event at a time, and the tree is re-rendered
|
|
151
|
+
* between events rather than once at the end of the batch.
|
|
152
|
+
*
|
|
153
|
+
* This matters more than it looks. A terminal delivers several keystrokes in
|
|
154
|
+
* a single read, and a handler closes over the props from its last render -
|
|
155
|
+
* so without settling in between, typing "ab" quickly makes the handler for
|
|
156
|
+
* "b" see the state from before "a", and the character is lost. Rendering
|
|
157
|
+
* per key is what every terminal application does, and the frame diff makes
|
|
158
|
+
* it cheap.
|
|
159
|
+
*/
|
|
160
|
+
handleInput(event: InputEvent): void;
|
|
161
|
+
private dispatchInput;
|
|
162
|
+
/**
|
|
163
|
+
* Order matters. A focused text field must see a plain character before any
|
|
164
|
+
* keybinding does, or typing "q" in a search box quits the application. So
|
|
165
|
+
* the focused node gets first refusal, then chords, then global handlers.
|
|
166
|
+
*/
|
|
167
|
+
private handleKey;
|
|
168
|
+
private handleMouse;
|
|
169
|
+
/** Innermost box under the pointer first, then outward. */
|
|
170
|
+
private dispatchMouse;
|
|
171
|
+
private handleResize;
|
|
172
|
+
open: TextUIApp['open'];
|
|
173
|
+
openResource: TextUIApp['openResource'];
|
|
174
|
+
/**
|
|
175
|
+
* Fan an adapter out across the registries it touches, and hand back one
|
|
176
|
+
* disposable for the lot. Order matters: kinds first, so a viewer registered
|
|
177
|
+
* for `file.data.json` has something to match before anything is classified.
|
|
178
|
+
*/
|
|
179
|
+
registerAdapter(adapter: ResourceAdapter): Disposable;
|
|
180
|
+
execute: TextUIApp['execute'];
|
|
181
|
+
inspect(): InspectorNode | null;
|
|
182
|
+
stats(): {
|
|
183
|
+
renders: number;
|
|
184
|
+
runs: number;
|
|
185
|
+
instances: number;
|
|
186
|
+
};
|
|
187
|
+
private handleError;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* The frame writer is a service rather than an import, so core never depends
|
|
191
|
+
* on terminal encoding - the test harness and the static renderer simply do
|
|
192
|
+
* not provide one.
|
|
193
|
+
*/
|
|
194
|
+
export interface FrameWriter {
|
|
195
|
+
write(frame: Frame): string;
|
|
196
|
+
invalidate(): void;
|
|
197
|
+
}
|
|
198
|
+
export declare const WRITER_KEY: import("../types/services.js").ServiceKey<FrameWriter>;
|
|
199
|
+
export declare function createApp(options?: CreateAppOptions): App;
|
|
200
|
+
//# sourceMappingURL=app.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/app/app.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAAE,aAAa,EAAE,SAAS,EAC3C,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAe,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,IAAI,EAAQ,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC1F,OAAO,KAAK,EAAE,UAAU,EAAwB,MAAM,mBAAmB,CAAC;AAM1E,OAAO,EAAE,MAAM,EAAE,MAAM,qBA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