@zenera/view 1.1.26 → 1.1.28
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 +79 -22
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,15 +1,74 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img
|
|
3
|
+
src="https://raw.githubusercontent.com/andreyryabov/ZeneraNeo/main/docs/imgs/zenera-logo-with-media-queries.svg"
|
|
4
|
+
alt="Zenera Logo"
|
|
5
|
+
width="20"
|
|
6
|
+
/>
|
|
7
|
+
<div>Powered By Zenera</div>
|
|
8
|
+
</div>
|
|
9
|
+
<br>
|
|
10
|
+
|
|
11
|
+
<div align="center">
|
|
12
|
+
<img src="https://raw.githubusercontent.com/andreyryabov/ZeneraNeo/main/docs/imgs/banner-view-with-media-queries.svg" alt="ZENERA VIEW" width="747">
|
|
13
|
+
|
|
14
|
+
[](https://www.npmjs.com/package/@zenera/view)
|
|
15
|
+
[](https://github.com/andreyryabov/ZeneraNeo/blob/main/LICENSE)
|
|
16
|
+
[](https://nodejs.org)
|
|
17
|
+
|
|
18
|
+
</div>
|
|
19
|
+
|
|
1
20
|
# @zenera/view
|
|
2
21
|
|
|
3
|
-
A live local viewer for a folder. Markdown
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
22
|
+
**A live local viewer for a folder. Markdown with tables and Mermaid diagrams,
|
|
23
|
+
highlighted code, directory listings - redrawn in place as the files change.**
|
|
24
|
+
|
|
25
|
+
> Part of [ZeneraNeo](https://github.com/andreyryabov/ZeneraNeo). It ships with
|
|
26
|
+
> [`zen`](https://github.com/andreyryabov/ZeneraNeo/blob/main/packages/cli/README.md)
|
|
27
|
+
> as the `view` **subcommand**, and works just as well as a library on its own.
|
|
28
|
+
|
|
29
|
+
## Why
|
|
30
|
+
|
|
31
|
+
Agents write reports, plans, traces and diagrams to disk, and keep rewriting
|
|
32
|
+
them while they work. `@zenera/view` turns that folder into a page you can leave
|
|
33
|
+
open: every change shows up within a second, with no reload, no lost scroll
|
|
34
|
+
position, and no flicker of diagrams that did not change.
|
|
35
|
+
|
|
36
|
+
- **Markdown as GitHub draws it** - GFM tables, task lists, heading anchors and
|
|
37
|
+
[Mermaid](https://mermaid.js.org) diagrams.
|
|
38
|
+
- **Highlighted code** - `.json`, `.jsonl`, `.py`, `.ts`, `.yaml`, `.patch` and more.
|
|
39
|
+
- **Directories as listings**, so the whole tree is navigable from one page.
|
|
40
|
+
- **Everything else as is** - images, HTML and PDF are handed to the browser.
|
|
41
|
+
- **Live, minimal updates** - only the nodes that changed are repainted.
|
|
42
|
+
- **Local and offline** - loopback only, nothing fetched from the network.
|
|
43
|
+
|
|
44
|
+
## Install
|
|
45
|
+
|
|
46
|
+
Node.js 24+, ESM only. It comes with the CLI:
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
npm i -g @zenera/cli
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
or on its own, as a library:
|
|
8
53
|
|
|
9
54
|
```sh
|
|
10
55
|
npm i @zenera/view
|
|
11
56
|
```
|
|
12
57
|
|
|
58
|
+
## Use
|
|
59
|
+
|
|
60
|
+
### From the command line
|
|
61
|
+
|
|
62
|
+
```sh
|
|
63
|
+
zen view # this folder
|
|
64
|
+
zen view finetune/STATUS.md --open # one file, opened in the browser
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
`zen view` serves until Ctrl-C and prints its address. `--port`, `--throttle`
|
|
68
|
+
and `--hidden` map to the options below; `zen view --help` has the details.
|
|
69
|
+
|
|
70
|
+
### From code
|
|
71
|
+
|
|
13
72
|
```ts
|
|
14
73
|
import { serveView } from '@zenera/view';
|
|
15
74
|
|
|
@@ -19,23 +78,7 @@ console.log(server.url); // http://127.0.0.1:<port>/STATUS.md
|
|
|
19
78
|
await server.close();
|
|
20
79
|
```
|
|
21
80
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
## How it works
|
|
25
|
-
|
|
26
|
-
The server parses each file into a sanitized HTML syntax tree (remark + GFM for
|
|
27
|
-
markdown, lowlight for code) and pushes it to the page over server-sent events -
|
|
28
|
-
on connect, and again whenever the file changes. The page is a small React app
|
|
29
|
-
that turns the tree into elements, so an update repaints only the nodes that
|
|
30
|
-
differ. Mermaid runs in the browser, from the copy installed with this package,
|
|
31
|
-
so nothing is fetched from the network.
|
|
32
|
-
|
|
33
|
-
Files are watched through their directory, so a writer that replaces a file by
|
|
34
|
-
renaming a temporary over it is followed; a slow poll backs up `fs.watch`.
|
|
35
|
-
A file is rendered once per change however many pages show it, and one path is
|
|
36
|
-
pushed at most once per `throttleMs`.
|
|
37
|
-
|
|
38
|
-
## Options
|
|
81
|
+
### Options
|
|
39
82
|
|
|
40
83
|
| option | default | meaning |
|
|
41
84
|
| ------------ | ------------------------------ | ------------------------------------------- |
|
|
@@ -47,6 +90,20 @@ pushed at most once per `throttleMs`.
|
|
|
47
90
|
| `maxClients` | 64 | pages open at once |
|
|
48
91
|
| `throttleMs` | 1000 | least time between two pushes of one path |
|
|
49
92
|
|
|
93
|
+
## How it works
|
|
94
|
+
|
|
95
|
+
The server parses each file into a sanitized HTML syntax tree (remark + GFM for
|
|
96
|
+
markdown, lowlight for code). It pushes that tree to the page over server-sent
|
|
97
|
+
events, on connect and again whenever the file changes. The page is a small
|
|
98
|
+
React app that turns the tree into elements, so an update repaints only the
|
|
99
|
+
nodes that differ. Mermaid runs in the browser from the copy installed with
|
|
100
|
+
this package.
|
|
101
|
+
|
|
102
|
+
Files are watched through their directory, so a writer that replaces a file by
|
|
103
|
+
renaming a temporary file over it is still followed. A slow poll backs up
|
|
104
|
+
`fs.watch`. Each change is rendered once however many pages show the file, and
|
|
105
|
+
one path is pushed at most once per `throttleMs`.
|
|
106
|
+
|
|
50
107
|
## Safety
|
|
51
108
|
|
|
52
109
|
- Listens on `127.0.0.1` only, and answers only requests whose `Host` names it,
|