@threadbase-sh/scanner 0.13.0 → 0.14.1

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/dist/index.cjs CHANGED
@@ -2026,7 +2026,13 @@ function openDatabase(dbPath) {
2026
2026
  if (dbPath !== ":memory:") {
2027
2027
  (0, import_fs9.mkdirSync)((0, import_path8.dirname)(dbPath), { recursive: true });
2028
2028
  }
2029
- const db = new import_better_sqlite3.default(dbPath);
2029
+ let db;
2030
+ try {
2031
+ db = new import_better_sqlite3.default(dbPath);
2032
+ } catch (err) {
2033
+ if (isNativeBindingFailure(err)) throw nativeBindingError(err, dbPath);
2034
+ throw err;
2035
+ }
2030
2036
  db.pragma("journal_mode = WAL");
2031
2037
  db.pragma("synchronous = NORMAL");
2032
2038
  db.pragma("temp_store = MEMORY");
@@ -2036,6 +2042,30 @@ function openDatabase(dbPath) {
2036
2042
  getLogger().debug({ dbPath }, "db: opened");
2037
2043
  return db;
2038
2044
  }
2045
+ function isNativeBindingFailure(err) {
2046
+ const message = err instanceof Error ? err.message : String(err);
2047
+ return /could not locate the bindings file|NODE_MODULE_VERSION|was compiled against|\.node['"\s]/i.test(
2048
+ message
2049
+ );
2050
+ }
2051
+ function nativeBindingError(err, dbPath) {
2052
+ const detail = err instanceof Error ? err.message : String(err);
2053
+ return new Error(
2054
+ [
2055
+ `Could not load better-sqlite3's native binary, so the persistent index at ${dbPath} cannot be opened.`,
2056
+ "This usually means the binary was never built or downloaded \u2014 not that your Node version is wrong.",
2057
+ "",
2058
+ "Try, in order:",
2059
+ " 1. npm rebuild better-sqlite3",
2060
+ " 2. rm -rf node_modules && npm install",
2061
+ " (npm 12 blocks package install scripts by default; approve better-sqlite3 if asked)",
2062
+ " 3. Run without SQLite entirely: new ConversationScanner({ persistent: false })",
2063
+ " or pass --no-persist on the CLI. Search falls back to the in-memory index.",
2064
+ "",
2065
+ `Original error: ${detail}`
2066
+ ].join("\n")
2067
+ );
2068
+ }
2039
2069
 
2040
2070
  // src/persistent/dir-watermark.ts
2041
2071
  var import_promises6 = require("fs/promises");