@youtyan/code-viewer 0.6.5 → 0.6.7

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();
@@ -2136,6 +2142,8 @@ var init_git = __esm(() => {
2136
2142
  "out",
2137
2143
  "target",
2138
2144
  ".gradle",
2145
+ ".devbox",
2146
+ ".direnv",
2139
2147
  ".pnpm-store",
2140
2148
  ".turbo",
2141
2149
  ".parcel-cache",
@@ -12779,6 +12787,11 @@ function safePrepare(db, sql) {
12779
12787
  }
12780
12788
  return stmt;
12781
12789
  }
12790
+ function applyBusyTimeout(db) {
12791
+ try {
12792
+ db.prepare(`PRAGMA busy_timeout = ${SQLITE_BUSY_TIMEOUT_MS}`).get();
12793
+ } catch {}
12794
+ }
12782
12795
  function queryRowsToResult(rows, columns) {
12783
12796
  const columnNames = rows.length > 0 ? Object.keys(rows[0]) : columns.map((c) => c.name);
12784
12797
  const typeMap = new Map(columns.map((c) => [c.name, c.type]));
@@ -13085,7 +13098,7 @@ function createSqliteAdapter(rawDb, openRawWriteDb) {
13085
13098
  };
13086
13099
  return adapter;
13087
13100
  }
13088
- var sqliteAdapterFactory;
13101
+ var SQLITE_BUSY_TIMEOUT_MS = 2000, sqliteAdapterFactory;
13089
13102
  var init_sqlite = __esm(() => {
13090
13103
  init_mutate();
13091
13104
  init_sql_snapshot();
@@ -13096,7 +13109,12 @@ var init_sqlite = __esm(() => {
13096
13109
  async open(path) {
13097
13110
  const DbClass = await loadSqliteClass();
13098
13111
  const db = new DbClass(path, { readonly: true, create: false });
13099
- const openWriteDb = () => new DbClass(path);
13112
+ applyBusyTimeout(db);
13113
+ const openWriteDb = () => {
13114
+ const wdb = new DbClass(path);
13115
+ applyBusyTimeout(wdb);
13116
+ return wdb;
13117
+ };
13100
13118
  return createSqliteAdapter(db, openWriteDb);
13101
13119
  }
13102
13120
  };
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.7",
4
4
  "description": "Local browser-based code and git diff viewer",
5
5
  "type": "module",
6
6
  "bin": {