@youtyan/code-viewer 0.1.7 → 0.1.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 +56 -2
- package/package.json +13 -5
- package/web/app.js +7340 -526
- package/web/index.html +7 -3
- package/web/mermaid.js +156840 -0
- package/web/shiki.js +13182 -0
- package/web/style.css +719 -30
- package/web-src/server/dev-assets.ts +37 -0
- package/web-src/server/dev.ts +6 -1
- package/web-src/server/git.ts +114 -7
- package/web-src/server/preview.ts +309 -20
- package/web-src/server/runtime.d.ts +6 -0
- package/web-src/types.ts +2 -4
package/README.md
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
# code-viewer
|
|
2
2
|
|
|
3
|
-
Local browser-based git diff viewer.
|
|
3
|
+
Local browser-based code and git diff viewer.
|
|
4
4
|
|
|
5
5
|
Requires [Bun](https://bun.sh/) on your `PATH`.
|
|
6
6
|
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- Browse repository files and folders in a persistent sidebar.
|
|
10
|
+
- View git diffs with unified or split layout, lazy loading, and viewed-file state.
|
|
11
|
+
- Open files directly from the repository or diff view, including large generated files.
|
|
12
|
+
- Preview Markdown with a table of contents, task lists, Mermaid diagrams, and Shiki code highlighting.
|
|
13
|
+
- Preview browser-safe media and show metadata for binary files that cannot be rendered.
|
|
14
|
+
- Open repository folders in the OS file manager from localhost-only actions.
|
|
15
|
+
- Upload files into worktree folders when upload is explicitly enabled.
|
|
16
|
+
|
|
7
17
|
## Usage
|
|
8
18
|
|
|
9
19
|
```sh
|
|
@@ -27,6 +37,43 @@ code-viewer --cwd /path/to/repo --staged
|
|
|
27
37
|
|
|
28
38
|
Pass `--open` only when you want the browser opened automatically.
|
|
29
39
|
|
|
40
|
+
## Repository View
|
|
41
|
+
|
|
42
|
+
Open the root URL to browse the repository tree. Folder pages keep the sidebar
|
|
43
|
+
visible, and file pages show a preview when the browser can safely render the
|
|
44
|
+
file. Unsupported binary files show a clear unavailable state with file
|
|
45
|
+
metadata instead of dumping bytes as text.
|
|
46
|
+
|
|
47
|
+
Markdown files use a dedicated preview tab. Relative links and images are
|
|
48
|
+
resolved inside the repository, code blocks are highlighted with Shiki, and
|
|
49
|
+
Mermaid diagrams are rendered lazily in the browser.
|
|
50
|
+
|
|
51
|
+
Very large text files use a virtualized source viewer. Only visible rows are
|
|
52
|
+
rendered, and the page includes controls to copy the full file or reopen it in
|
|
53
|
+
the full non-virtual view.
|
|
54
|
+
|
|
55
|
+
## Uploads
|
|
56
|
+
|
|
57
|
+
File uploads are disabled by default. Enable them only for trusted local
|
|
58
|
+
worktrees:
|
|
59
|
+
|
|
60
|
+
```sh
|
|
61
|
+
code-viewer --cwd /path/to/repo --allow-upload
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Or place `.code-viewer.json` at the repository root:
|
|
65
|
+
|
|
66
|
+
```json
|
|
67
|
+
{
|
|
68
|
+
"upload": {
|
|
69
|
+
"enabled": true
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Uploads are accepted only for the worktree target. Git tree views remain
|
|
75
|
+
read-only.
|
|
76
|
+
|
|
30
77
|
## Development
|
|
31
78
|
|
|
32
79
|
```sh
|
|
@@ -36,10 +83,17 @@ bun run preview --cwd /path/to/repo
|
|
|
36
83
|
```
|
|
37
84
|
|
|
38
85
|
`bun run preview` is the development runner. It rebuilds the browser bundle
|
|
39
|
-
when
|
|
86
|
+
when browser source files change, restarts the preview server when
|
|
40
87
|
`web-src/server/*.ts` changes, and keeps the URL stable on
|
|
41
88
|
`http://127.0.0.1:64160/` unless you pass `--port <port>`.
|
|
42
89
|
|
|
90
|
+
Before releasing:
|
|
91
|
+
|
|
92
|
+
```sh
|
|
93
|
+
bun run verify
|
|
94
|
+
npm pack --dry-run
|
|
95
|
+
```
|
|
96
|
+
|
|
43
97
|
## License
|
|
44
98
|
|
|
45
99
|
MIT. Third-party licenses for bundled browser assets are included under
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@youtyan/code-viewer",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Local browser-based git diff viewer",
|
|
3
|
+
"version": "0.1.9",
|
|
4
|
+
"description": "Local browser-based code and git diff viewer",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"code-viewer": "web-src/server/preview.ts",
|
|
@@ -28,14 +28,14 @@
|
|
|
28
28
|
"LICENSE"
|
|
29
29
|
],
|
|
30
30
|
"scripts": {
|
|
31
|
-
"build": "bun build --target=browser --format=iife --outfile=web/app.js web-src/app.ts",
|
|
31
|
+
"build": "bun build --target=browser --format=iife --outfile=web/app.js web-src/app.ts && bun build --target=browser --format=esm --outfile=web/mermaid.js web-src/mermaid-entry.ts && bun build --target=browser --format=esm --outfile=web/shiki.js web-src/shiki-entry.ts",
|
|
32
32
|
"check": "tsc --noEmit",
|
|
33
|
-
"check:bundle": "bun build --target=browser --format=iife --outfile=/tmp/code-viewer-app.js web-src/app.ts && cmp /tmp/code-viewer-app.js web/app.js",
|
|
33
|
+
"check:bundle": "bun build --target=browser --format=iife --outfile=/tmp/code-viewer-app.js web-src/app.ts && cmp /tmp/code-viewer-app.js web/app.js && bun build --target=browser --format=esm --outfile=/tmp/code-viewer-mermaid.js web-src/mermaid-entry.ts && cmp /tmp/code-viewer-mermaid.js web/mermaid.js && bun build --target=browser --format=esm --outfile=/tmp/code-viewer-shiki.js web-src/shiki-entry.ts && cmp /tmp/code-viewer-shiki.js web/shiki.js",
|
|
34
34
|
"dev": "bun run web-src/server/dev.ts",
|
|
35
35
|
"preview": "bun run web-src/server/dev.ts",
|
|
36
36
|
"preview:raw": "bun run web-src/server/preview.ts",
|
|
37
37
|
"test": "bun test",
|
|
38
|
-
"verify": "bun run check && bun run build && bun run check:bundle && bun run test && node --check web/app.js",
|
|
38
|
+
"verify": "bun run check && bun run build && bun run check:bundle && bun run test && node --check web/app.js && node --check web/mermaid.js && node --check web/shiki.js",
|
|
39
39
|
"pack:dry": "npm pack --dry-run",
|
|
40
40
|
"prepublishOnly": "bun run verify"
|
|
41
41
|
},
|
|
@@ -52,5 +52,13 @@
|
|
|
52
52
|
},
|
|
53
53
|
"engines": {
|
|
54
54
|
"bun": ">=1.0.0"
|
|
55
|
+
},
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"@types/markdown-it": "^14.1.2",
|
|
58
|
+
"markdown-it": "^14.1.1",
|
|
59
|
+
"markdown-it-anchor": "^9.2.0",
|
|
60
|
+
"markdown-it-footnote": "^4.0.0",
|
|
61
|
+
"mermaid": "^11.14.0",
|
|
62
|
+
"shiki": "^4.0.2"
|
|
55
63
|
}
|
|
56
64
|
}
|