projview 0.8.0 โ 0.8.2
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 +13 -0
- package/docs/how-to-set-up.md +1 -1
- package/docs/reference/api.md +30 -2
- package/package.json +1 -1
- package/public/comments.js +8 -1
package/README.md
CHANGED
|
@@ -34,6 +34,9 @@ and exit (no server, no browser), so an agent or script can query your docs:
|
|
|
34
34
|
```bash
|
|
35
35
|
projview search "<query>" [path] # ranked: filename matches + in-content hits w/ line snippets
|
|
36
36
|
projview tree [path] # the file tree as JSON
|
|
37
|
+
projview comment add <file> "โฆ" # leave a comment (--heading <id> to anchor a section)
|
|
38
|
+
projview comments [file] # list comments as JSON
|
|
39
|
+
projview usage [path] # views + searches recorded by the viewer
|
|
37
40
|
projview search "mermaid" --demo # quick test on the bundled docs
|
|
38
41
|
```
|
|
39
42
|
|
|
@@ -53,9 +56,19 @@ projview search "mermaid" --demo # quick test on the bundled docs
|
|
|
53
56
|
| index | builds an in-memory tree (nothing written to disk by default) |
|
|
54
57
|
| serve | spawns a localhost site + opens your browser |
|
|
55
58
|
| live | edits to files reload in the browser automatically |
|
|
59
|
+
| comment | leave notes on a file, a section, or a text selection (browser or CLI) |
|
|
56
60
|
|
|
57
61
|
> ephemeral by default - ctrl-c and it's gone. opt into persistence below.
|
|
58
62
|
|
|
63
|
+
## comments
|
|
64
|
+
|
|
65
|
+
Leave notes on a whole file, a heading/section, or a selected passage - from the
|
|
66
|
+
viewer (the ๐ฌ button, bottom-right) or via the CLI / HTTP API. Text comments
|
|
67
|
+
**re-anchor** as the doc changes and only flag themselves *orphaned* if the quoted
|
|
68
|
+
text truly disappears. Comments persist when you opt into a store
|
|
69
|
+
(`--persist` / `--store-url`); writes are **localhost-only** (an exposed instance
|
|
70
|
+
is read-only).
|
|
71
|
+
|
|
59
72
|
## persistence (opt-in)
|
|
60
73
|
|
|
61
74
|
By default the index is in-memory and nothing is written to disk. Opt in for a
|
package/docs/how-to-set-up.md
CHANGED
|
@@ -67,7 +67,7 @@ npm install
|
|
|
67
67
|
npm run demo # preview the bundled docs/ (alias for --demo)
|
|
68
68
|
npm start # index the current directory
|
|
69
69
|
node bin/projview.js ./docs # or call the CLI directly
|
|
70
|
-
npm test # run the test suite (node:test,
|
|
70
|
+
npm test # run the test suite (node:test, 49 tests)
|
|
71
71
|
```
|
|
72
72
|
|
|
73
73
|
See the [project README](README.md) for the architecture and the
|
package/docs/reference/api.md
CHANGED
|
@@ -12,15 +12,36 @@ state it records is its own usage events (views / searches) into the store.
|
|
|
12
12
|
|
|
13
13
|
### GET /api/tree
|
|
14
14
|
|
|
15
|
-
Returns the in-memory file tree as JSON
|
|
15
|
+
Returns the in-memory file tree as JSON, plus the `version` and a `writable`
|
|
16
|
+
flag (false when projview is exposed on a non-loopback host).
|
|
16
17
|
|
|
17
18
|
### GET /api/file
|
|
18
19
|
|
|
19
20
|
Renders a single file to HTML on demand. Query param `p` is the relative path.
|
|
21
|
+
Records a `view` usage event.
|
|
20
22
|
|
|
21
23
|
### GET /api/events
|
|
22
24
|
|
|
23
|
-
Server-sent events stream for live reload
|
|
25
|
+
Server-sent events stream: `change` / `tree` for live reload, `comments` when a
|
|
26
|
+
comment is created/edited/deleted.
|
|
27
|
+
|
|
28
|
+
### GET /api/comments
|
|
29
|
+
|
|
30
|
+
Lists comments as JSON. Optional `?file=<path>` filters to a single file.
|
|
31
|
+
|
|
32
|
+
### POST /api/comments
|
|
33
|
+
|
|
34
|
+
Creates a comment from `{ file, body, anchor?, author? }`. **Loopback only** -
|
|
35
|
+
returns `403` when bound to a non-loopback host. Author defaults to the server's
|
|
36
|
+
git/OS user when omitted.
|
|
37
|
+
|
|
38
|
+
### PATCH /api/comments/:id ยท DELETE /api/comments/:id
|
|
39
|
+
|
|
40
|
+
Resolve/edit (`{ resolved?, body? }`) or delete a comment. Loopback only.
|
|
41
|
+
|
|
42
|
+
### GET /api/usage
|
|
43
|
+
|
|
44
|
+
Aggregated usage: `{ total, byType, topFiles[], recentSearches[] }`.
|
|
24
45
|
|
|
25
46
|
## machine interface (CLI)
|
|
26
47
|
|
|
@@ -115,6 +136,13 @@ On-demand fetch + render, in-app link routing, anchor jumps.
|
|
|
115
136
|
|
|
116
137
|
A chokidar watcher broadcasts change/tree events over SSE.
|
|
117
138
|
|
|
139
|
+
### comments
|
|
140
|
+
|
|
141
|
+
A drawer (the ๐ฌ button, bottom-right) lists comments for the open file. Add one
|
|
142
|
+
by selecting text, hovering a heading, or "+ note". Text anchors re-anchor on
|
|
143
|
+
each render and paint via the CSS Custom Highlight API; create/resolve/delete
|
|
144
|
+
controls hide when the server isn't writable.
|
|
145
|
+
|
|
118
146
|
## stores (persistence)
|
|
119
147
|
|
|
120
148
|
The index - plus **comments** and **usage events** - is in-memory by default
|
package/package.json
CHANGED
package/public/comments.js
CHANGED
|
@@ -29,7 +29,14 @@ const cre = (tag, cls, html) => {
|
|
|
29
29
|
return e;
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
const
|
|
32
|
+
const FAB_ICON =
|
|
33
|
+
`<svg class="cmt-fab-ico" viewBox="0 0 24 24" width="23" height="23" fill="none" aria-hidden="true">
|
|
34
|
+
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"/>
|
|
35
|
+
<circle cx="8" cy="10" r="1.05" fill="currentColor"/>
|
|
36
|
+
<circle cx="12" cy="10" r="1.05" fill="currentColor"/>
|
|
37
|
+
<circle cx="16" cy="10" r="1.05" fill="currentColor"/>
|
|
38
|
+
</svg>`;
|
|
39
|
+
const fab = cre('button', 'cmt-fab', `${FAB_ICON}<span class="cmt-badge" hidden>0</span>`);
|
|
33
40
|
fab.title = 'comments';
|
|
34
41
|
fab.hidden = true;
|
|
35
42
|
|