@youtyan/code-viewer 0.6.4 → 0.6.6

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.
@@ -1053,10 +1053,14 @@ function normalizeBlameRef(ref, base) {
1053
1053
  return { base, ref: rawRef };
1054
1054
  }
1055
1055
  function run(args, cwd) {
1056
- return runSync(resolveGitArgs(args), cwd);
1056
+ return runSync(resolveGitArgs(args), cwd, {
1057
+ timeout: GIT_COMMAND_TIMEOUT_MS
1058
+ });
1057
1059
  }
1058
1060
  function runBytes(args, cwd) {
1059
- return runBytesSync(resolveGitArgs(args), cwd);
1061
+ return runBytesSync(resolveGitArgs(args), cwd, {
1062
+ timeout: GIT_COMMAND_TIMEOUT_MS
1063
+ });
1060
1064
  }
1061
1065
  function resolveGitArgs(args) {
1062
1066
  if (args[0] !== "git")
@@ -1077,10 +1081,13 @@ function gitFailureResult(res, fallback) {
1077
1081
  status: 503
1078
1082
  };
1079
1083
  }
1080
- function repoRoot(cwd) {
1081
- const res = run(["git", "rev-parse", "--show-toplevel"], cwd);
1084
+ function runGitRefLookup(args, cwd) {
1085
+ const res = run(args, cwd);
1082
1086
  return res.code === 0 ? res.stdout.trimEnd() : null;
1083
1087
  }
1088
+ function repoRoot(cwd) {
1089
+ return runGitRefLookup(["git", "rev-parse", "--show-toplevel"], cwd);
1090
+ }
1084
1091
  function repoRootResult(cwd) {
1085
1092
  const res = run(["git", "rev-parse", "--show-toplevel"], cwd);
1086
1093
  if (res.code === 0)
@@ -1094,8 +1101,7 @@ function repoRootResult(cwd) {
1094
1101
  return { kind: "error", error: stderr || "git rev-parse failed" };
1095
1102
  }
1096
1103
  function currentBranch(cwd) {
1097
- const res = run(["git", "rev-parse", "--abbrev-ref", "HEAD"], cwd);
1098
- return res.code === 0 ? res.stdout.trimEnd() : null;
1104
+ return runGitRefLookup(["git", "rev-parse", "--abbrev-ref", "HEAD"], cwd);
1099
1105
  }
1100
1106
  function verifyCommit(ref, cwd) {
1101
1107
  const res = run(["git", "rev-parse", "--verify", `${ref}^{commit}`], cwd);
@@ -2112,7 +2118,7 @@ function truncateToNHunks(diffText, n, maxLines = Number.POSITIVE_INFINITY) {
2112
2118
  lineTruncated
2113
2119
  };
2114
2120
  }
2115
- var BLAME_ZERO_SHA = "0000000000000000000000000000000000000000", WORKTREE_RECURSIVE_DEPTH_LIMIT = 32, WORKTREE_RECURSIVE_ENTRY_LIMIT = 50000, DEFAULT_REF_COMMIT_LIMIT = 100, MAX_REF_COMMIT_LIMIT = 500, COMMIT_FORMAT = "%H%x00%s%x00%an%x00%aI", DEFAULT_WORKTREE_OMIT_DIR_NAMES, HISTORY_FORMAT = "%H%x00%s%x00%an%x00%aI%x00%P%x00%b", MAX_HISTORY_LIMIT = 200;
2121
+ var BLAME_ZERO_SHA = "0000000000000000000000000000000000000000", WORKTREE_RECURSIVE_DEPTH_LIMIT = 32, WORKTREE_RECURSIVE_ENTRY_LIMIT = 50000, DEFAULT_REF_COMMIT_LIMIT = 100, MAX_REF_COMMIT_LIMIT = 500, COMMIT_FORMAT = "%H%x00%s%x00%an%x00%aI", DEFAULT_WORKTREE_OMIT_DIR_NAMES, GIT_COMMAND_TIMEOUT_MS = 20000, HISTORY_FORMAT = "%H%x00%s%x00%an%x00%aI%x00%P%x00%b", MAX_HISTORY_LIMIT = 200;
2116
2122
  var init_git = __esm(() => {
2117
2123
  init_command_resolver();
2118
2124
  init_runtime();
@@ -11789,9 +11795,22 @@ var init_source_meta = __esm(() => {
11789
11795
  hcl: "terraform",
11790
11796
  xml: "xml",
11791
11797
  html: "xml",
11792
- vue: "xml",
11798
+ vue: "vue",
11799
+ svelte: "svelte",
11800
+ astro: "astro",
11801
+ erb: "erb",
11802
+ rhtml: "erb",
11803
+ ejs: "html",
11804
+ hbs: "handlebars",
11805
+ mustache: "handlebars",
11806
+ liquid: "liquid",
11807
+ pug: "pug",
11808
+ twig: "twig",
11809
+ haml: "haml",
11793
11810
  css: "css",
11794
11811
  scss: "scss",
11812
+ sass: "sass",
11813
+ less: "less",
11795
11814
  md: "markdown",
11796
11815
  dockerfile: "dockerfile",
11797
11816
  proto: "protobuf",
@@ -11834,7 +11853,26 @@ var init_source_meta = __esm(() => {
11834
11853
  mm: "objective-cpp",
11835
11854
  tex: "tex",
11836
11855
  bib: "bibtex",
11837
- rst: "rst"
11856
+ rst: "rst",
11857
+ graphql: "graphql",
11858
+ graphqls: "graphql",
11859
+ gql: "graphql",
11860
+ ps1: "powershell",
11861
+ psm1: "powershell",
11862
+ psd1: "powershell",
11863
+ ini: "ini",
11864
+ conf: "ini",
11865
+ env: "dotenv",
11866
+ prisma: "prisma",
11867
+ pas: "pascal",
11868
+ adoc: "asciidoc",
11869
+ asciidoc: "asciidoc",
11870
+ jsonc: "jsonc",
11871
+ mts: "typescript",
11872
+ cts: "typescript",
11873
+ kts: "kotlin",
11874
+ cxx: "cpp",
11875
+ hxx: "cpp"
11838
11876
  };
11839
11877
  TEXT_SOURCE_EXTENSIONS = new Set([
11840
11878
  ...Object.keys(EXT_TO_LANG),
@@ -11986,6 +12024,12 @@ var init_source_meta = __esm(() => {
11986
12024
  "rakefile",
11987
12025
  "procfile",
11988
12026
  "brewfile",
12027
+ "guardfile",
12028
+ "capfile",
12029
+ "vagrantfile",
12030
+ "podfile",
12031
+ "fastfile",
12032
+ "berksfile",
11989
12033
  "gnumakefile",
11990
12034
  "bsdmakefile",
11991
12035
  ".gitattributes",
@@ -12741,6 +12785,11 @@ function safePrepare(db, sql) {
12741
12785
  }
12742
12786
  return stmt;
12743
12787
  }
12788
+ function applyBusyTimeout(db) {
12789
+ try {
12790
+ db.prepare(`PRAGMA busy_timeout = ${SQLITE_BUSY_TIMEOUT_MS}`).get();
12791
+ } catch {}
12792
+ }
12744
12793
  function queryRowsToResult(rows, columns) {
12745
12794
  const columnNames = rows.length > 0 ? Object.keys(rows[0]) : columns.map((c) => c.name);
12746
12795
  const typeMap = new Map(columns.map((c) => [c.name, c.type]));
@@ -13047,7 +13096,7 @@ function createSqliteAdapter(rawDb, openRawWriteDb) {
13047
13096
  };
13048
13097
  return adapter;
13049
13098
  }
13050
- var sqliteAdapterFactory;
13099
+ var SQLITE_BUSY_TIMEOUT_MS = 2000, sqliteAdapterFactory;
13051
13100
  var init_sqlite = __esm(() => {
13052
13101
  init_mutate();
13053
13102
  init_sql_snapshot();
@@ -13058,7 +13107,12 @@ var init_sqlite = __esm(() => {
13058
13107
  async open(path) {
13059
13108
  const DbClass = await loadSqliteClass();
13060
13109
  const db = new DbClass(path, { readonly: true, create: false });
13061
- const openWriteDb = () => new DbClass(path);
13110
+ applyBusyTimeout(db);
13111
+ const openWriteDb = () => {
13112
+ const wdb = new DbClass(path);
13113
+ applyBusyTimeout(wdb);
13114
+ return wdb;
13115
+ };
13062
13116
  return createSqliteAdapter(db, openWriteDb);
13063
13117
  }
13064
13118
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@youtyan/code-viewer",
3
- "version": "0.6.4",
3
+ "version": "0.6.6",
4
4
  "description": "Local browser-based code and git diff viewer",
5
5
  "type": "module",
6
6
  "bin": {
@@ -28,7 +28,7 @@
28
28
  ],
29
29
  "scripts": {
30
30
  "build": "bun run build:web && bun run build:server",
31
- "build:web": "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 && node scripts/generate-third-party-notices.mjs",
31
+ "build:web": "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 && bun build --target=browser --format=iife --outfile=web/vendor/highlight.js/highlight.min.js web-src/highlight-entry.ts && node scripts/generate-third-party-notices.mjs",
32
32
  "build:server": "bun build --target=node --format=esm --outfile=dist/code-viewer.js web-src/server/cli.ts",
33
33
  "check": "bun run typecheck",
34
34
  "typecheck": "tsc --noEmit",
@@ -49,7 +49,7 @@
49
49
  "test:postgres:down": "docker compose -f data/test/postgresql/docker-compose.yml down -v",
50
50
  "test": "bun test",
51
51
  "lint": "biome lint web-src package.json biome.jsonc",
52
- "verify": "bun run check && bun run lint && bun run check:format && 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 && node --check dist/code-viewer.js && node dist/code-viewer.js --help && node scripts/node-smoke.mjs",
52
+ "verify": "bun run check && bun run lint && bun run check:format && 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 && node --check web/vendor/highlight.js/highlight.min.js && node --check dist/code-viewer.js && node dist/code-viewer.js --help && node scripts/node-smoke.mjs",
53
53
  "pack:dry": "npm pack --dry-run",
54
54
  "prepack": "bun run build",
55
55
  "prepublishOnly": "bun run verify"
@@ -68,6 +68,7 @@
68
68
  "@happy-dom/global-registrator": "^20.10.6",
69
69
  "@types/bun": "1.3.13",
70
70
  "@types/markdown-it": "14.1.2",
71
+ "highlight.js": "11.9.0",
71
72
  "markdown-it": "14.1.1",
72
73
  "markdown-it-anchor": "9.2.0",
73
74
  "markdown-it-footnote": "4.0.0",
package/web/app.js CHANGED
@@ -1186,9 +1186,22 @@ ${lines.join(`
1186
1186
  hcl: "terraform",
1187
1187
  xml: "xml",
1188
1188
  html: "xml",
1189
- vue: "xml",
1189
+ vue: "vue",
1190
+ svelte: "svelte",
1191
+ astro: "astro",
1192
+ erb: "erb",
1193
+ rhtml: "erb",
1194
+ ejs: "html",
1195
+ hbs: "handlebars",
1196
+ mustache: "handlebars",
1197
+ liquid: "liquid",
1198
+ pug: "pug",
1199
+ twig: "twig",
1200
+ haml: "haml",
1190
1201
  css: "css",
1191
1202
  scss: "scss",
1203
+ sass: "sass",
1204
+ less: "less",
1192
1205
  md: "markdown",
1193
1206
  dockerfile: "dockerfile",
1194
1207
  proto: "protobuf",
@@ -1231,7 +1244,26 @@ ${lines.join(`
1231
1244
  mm: "objective-cpp",
1232
1245
  tex: "tex",
1233
1246
  bib: "bibtex",
1234
- rst: "rst"
1247
+ rst: "rst",
1248
+ graphql: "graphql",
1249
+ graphqls: "graphql",
1250
+ gql: "graphql",
1251
+ ps1: "powershell",
1252
+ psm1: "powershell",
1253
+ psd1: "powershell",
1254
+ ini: "ini",
1255
+ conf: "ini",
1256
+ env: "dotenv",
1257
+ prisma: "prisma",
1258
+ pas: "pascal",
1259
+ adoc: "asciidoc",
1260
+ asciidoc: "asciidoc",
1261
+ jsonc: "jsonc",
1262
+ mts: "typescript",
1263
+ cts: "typescript",
1264
+ kts: "kotlin",
1265
+ cxx: "cpp",
1266
+ hxx: "cpp"
1235
1267
  };
1236
1268
  var TEXT_SOURCE_EXTENSIONS = new Set([
1237
1269
  ...Object.keys(EXT_TO_LANG),
@@ -1383,6 +1415,12 @@ ${lines.join(`
1383
1415
  "rakefile",
1384
1416
  "procfile",
1385
1417
  "brewfile",
1418
+ "guardfile",
1419
+ "capfile",
1420
+ "vagrantfile",
1421
+ "podfile",
1422
+ "fastfile",
1423
+ "berksfile",
1386
1424
  "gnumakefile",
1387
1425
  "bsdmakefile",
1388
1426
  ".gitattributes",
@@ -1403,7 +1441,16 @@ ${lines.join(`
1403
1441
  "go.mod": "go",
1404
1442
  "build.bazel": "starlark",
1405
1443
  "workspace.bazel": "starlark",
1406
- "module.bazel": "starlark"
1444
+ "module.bazel": "starlark",
1445
+ gemfile: "ruby",
1446
+ rakefile: "ruby",
1447
+ brewfile: "ruby",
1448
+ guardfile: "ruby",
1449
+ capfile: "ruby",
1450
+ vagrantfile: "ruby",
1451
+ podfile: "ruby",
1452
+ fastfile: "ruby",
1453
+ berksfile: "ruby"
1407
1454
  };
1408
1455
  function sourceFileName(path) {
1409
1456
  return (path.split("/").pop() || path).toLowerCase();
@@ -32092,6 +32139,8 @@ code-viewer query agent-help`
32092
32139
  return true;
32093
32140
  }
32094
32141
  const SOURCE_SHIKI_LANGS = Array.from(new Set([
32142
+ "asciidoc",
32143
+ "astro",
32095
32144
  "bash",
32096
32145
  "bibtex",
32097
32146
  "c",
@@ -32103,33 +32152,46 @@ code-viewer query agent-help`
32103
32152
  "dart",
32104
32153
  "diff",
32105
32154
  "dockerfile",
32155
+ "dotenv",
32106
32156
  "elixir",
32157
+ "erb",
32107
32158
  "erlang",
32108
32159
  "fortran",
32109
32160
  "go",
32110
32161
  "gradle",
32111
32162
  "graphql",
32163
+ "haml",
32164
+ "handlebars",
32112
32165
  "haskell",
32113
32166
  "html",
32167
+ "ini",
32114
32168
  "java",
32115
32169
  "javascript",
32116
32170
  "json",
32171
+ "jsonc",
32117
32172
  "julia",
32118
32173
  "kotlin",
32174
+ "less",
32175
+ "liquid",
32119
32176
  "lua",
32120
32177
  "make",
32121
32178
  "markdown",
32122
32179
  "nix",
32123
32180
  "ocaml",
32181
+ "pascal",
32124
32182
  "perl",
32125
32183
  "php",
32184
+ "powershell",
32185
+ "prisma",
32126
32186
  "properties",
32127
32187
  "protobuf",
32188
+ "pug",
32128
32189
  "python",
32129
32190
  "r",
32130
32191
  "rst",
32131
32192
  "ruby",
32132
32193
  "rust",
32194
+ "sass",
32133
32195
  "scala",
32134
32196
  "scss",
32135
32197
  "sql",
@@ -32137,6 +32199,7 @@ code-viewer query agent-help`
32137
32199
  "terraform",
32138
32200
  "tex",
32139
32201
  "toml",
32202
+ "twig",
32140
32203
  "typescript",
32141
32204
  "vim",
32142
32205
  "vue",
@@ -7,13 +7,17 @@ the generated bundles next to this directory are produced at build / pack time.
7
7
  | Package | Version | Files | License |
8
8
  | --- | --- | --- | --- |
9
9
  | diff2html | 3.4.56 | `diff2html/diff2html.min.css`, `diff2html/diff2html-ui.min.js` | MIT, https://github.com/rtfpessoa/diff2html |
10
- | highlight.js | 11.9.0 | `highlight.js/highlight.min.js`, `highlight.js/styles/github*.min.css` | BSD-3-Clause, https://github.com/highlightjs/highlight.js |
11
- | Browser bundle dependencies | fixed by `bun.lock` | generated `../app.js`, `../mermaid.js`, `../shiki.js` | see `THIRD_PARTY_NOTICES.txt` |
10
+ | highlight.js styles | 11.9.0 | `highlight.js/LICENSE`, `highlight.js/styles/github*.min.css` | BSD-3-Clause, https://github.com/highlightjs/highlight.js |
11
+ | Browser bundle dependencies | fixed by `bun.lock` | generated `../app.js`, `../mermaid.js`, `../shiki.js`, `highlight.js/highlight.min.js` | see `THIRD_PARTY_NOTICES.txt` |
12
12
 
13
- `diff2html-ui.min.js` is the UI bundle from the npm package. `highlight.min.js`
14
- is the standard browser build for highlight.js 11.9.0.
13
+ `diff2html-ui.min.js` is the UI bundle from the npm package. The
14
+ `highlight.js/styles/*.min.css` theme files and `highlight.js/LICENSE` are
15
+ committed manually; they only need to be refreshed when upgrading the
16
+ `highlight.js` version pinned in `package.json`.
15
17
 
16
- `../app.js`, `../mermaid.js`, and `../shiki.js` are generated by
17
- `bun run build:web` and are included in npm tarballs, but are not tracked in git.
18
+ `../app.js`, `../mermaid.js`, `../shiki.js`, and `highlight.js/highlight.min.js`
19
+ are generated by `bun run build:web` (the last one registers every language
20
+ bundled with `highlight.js`, not just its CDN "common" subset) and are
21
+ included in npm tarballs, but are not tracked in git.
18
22
  `THIRD_PARTY_NOTICES.txt` is generated from the installed npm packages during
19
23
  the same build.
@@ -2,7 +2,7 @@ Third Party Notices
2
2
  ===================
3
3
 
4
4
  This file is generated by scripts/generate-third-party-notices.mjs.
5
- It covers npm packages pulled into the browser bundles generated as web/app.js, web/mermaid.js, and web/shiki.js.
5
+ It covers npm packages pulled into the browser bundles generated as web/app.js, web/mermaid.js, web/shiki.js, and web/vendor/highlight.js/highlight.min.js.
6
6
 
7
7
  Package Summary
8
8
  ---------------
@@ -126,6 +126,7 @@ Package Summary
126
126
  | hachure-fill | 0.5.2 | MIT | https://github.com/pshihn/hachure-fill#readme |
127
127
  | hast-util-to-html | 9.0.5 | MIT | syntax-tree/hast-util-to-html |
128
128
  | hast-util-whitespace | 3.0.0 | MIT | syntax-tree/hast-util-whitespace |
129
+ | highlight.js | 11.9.0 | BSD-3-Clause | https://highlightjs.org/ |
129
130
  | html-void-elements | 3.0.0 | MIT | wooorm/html-void-elements |
130
131
  | iconv-lite | 0.6.3 | MIT | https://github.com/ashtuchkin/iconv-lite |
131
132
  | internmap | 1.0.1 | ISC | https://github.com/mbostock/internmap/ |
@@ -5635,6 +5636,45 @@ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
5635
5636
  TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
5636
5637
  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
5637
5638
 
5639
+ highlight.js@11.9.0
5640
+ -------------------
5641
+
5642
+ License metadata: BSD-3-Clause
5643
+ Source: https://highlightjs.org/
5644
+ Package metadata: node_modules/highlight.js/package.json
5645
+
5646
+ File: node_modules/highlight.js/LICENSE
5647
+
5648
+ BSD 3-Clause License
5649
+
5650
+ Copyright (c) 2006, Ivan Sagalaev.
5651
+ All rights reserved.
5652
+
5653
+ Redistribution and use in source and binary forms, with or without
5654
+ modification, are permitted provided that the following conditions are met:
5655
+
5656
+ * Redistributions of source code must retain the above copyright notice, this
5657
+ list of conditions and the following disclaimer.
5658
+
5659
+ * Redistributions in binary form must reproduce the above copyright notice,
5660
+ this list of conditions and the following disclaimer in the documentation
5661
+ and/or other materials provided with the distribution.
5662
+
5663
+ * Neither the name of the copyright holder nor the names of its
5664
+ contributors may be used to endorse or promote products derived from
5665
+ this software without specific prior written permission.
5666
+
5667
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
5668
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5669
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
5670
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
5671
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5672
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
5673
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
5674
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
5675
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
5676
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5677
+
5638
5678
  html-void-elements@3.0.0
5639
5679
  ------------------------
5640
5680