@youtyan/code-viewer 0.6.5 → 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();
@@ -12779,6 +12785,11 @@ function safePrepare(db, sql) {
12779
12785
  }
12780
12786
  return stmt;
12781
12787
  }
12788
+ function applyBusyTimeout(db) {
12789
+ try {
12790
+ db.prepare(`PRAGMA busy_timeout = ${SQLITE_BUSY_TIMEOUT_MS}`).get();
12791
+ } catch {}
12792
+ }
12782
12793
  function queryRowsToResult(rows, columns) {
12783
12794
  const columnNames = rows.length > 0 ? Object.keys(rows[0]) : columns.map((c) => c.name);
12784
12795
  const typeMap = new Map(columns.map((c) => [c.name, c.type]));
@@ -13085,7 +13096,7 @@ function createSqliteAdapter(rawDb, openRawWriteDb) {
13085
13096
  };
13086
13097
  return adapter;
13087
13098
  }
13088
- var sqliteAdapterFactory;
13099
+ var SQLITE_BUSY_TIMEOUT_MS = 2000, sqliteAdapterFactory;
13089
13100
  var init_sqlite = __esm(() => {
13090
13101
  init_mutate();
13091
13102
  init_sql_snapshot();
@@ -13096,7 +13107,12 @@ var init_sqlite = __esm(() => {
13096
13107
  async open(path) {
13097
13108
  const DbClass = await loadSqliteClass();
13098
13109
  const db = new DbClass(path, { readonly: true, create: false });
13099
- const openWriteDb = () => new DbClass(path);
13110
+ applyBusyTimeout(db);
13111
+ const openWriteDb = () => {
13112
+ const wdb = new DbClass(path);
13113
+ applyBusyTimeout(wdb);
13114
+ return wdb;
13115
+ };
13100
13116
  return createSqliteAdapter(db, openWriteDb);
13101
13117
  }
13102
13118
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@youtyan/code-viewer",
3
- "version": "0.6.5",
3
+ "version": "0.6.6",
4
4
  "description": "Local browser-based code and git diff viewer",
5
5
  "type": "module",
6
6
  "bin": {