@wrongstack/tools 0.282.2 → 0.283.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/builtin.js +130 -11
- package/dist/builtin.js.map +1 -1
- package/dist/codebase-index/index.d.ts +11 -0
- package/dist/codebase-index/index.js +25 -6
- package/dist/codebase-index/index.js.map +1 -1
- package/dist/codebase-index/worker.js +25 -6
- package/dist/codebase-index/worker.js.map +1 -1
- package/dist/index.d.ts +20 -2
- package/dist/index.js +144 -13
- package/dist/index.js.map +1 -1
- package/dist/mode.d.ts +3 -0
- package/dist/mode.js +14 -2
- package/dist/mode.js.map +1 -1
- package/dist/pack.js +130 -11
- package/dist/pack.js.map +1 -1
- package/package.json +2 -2
|
@@ -269,6 +269,24 @@ var IndexStore = class {
|
|
|
269
269
|
* When false, ranked search falls back to the LIKE + in-process BM25 path.
|
|
270
270
|
*/
|
|
271
271
|
ftsAvailable = false;
|
|
272
|
+
/**
|
|
273
|
+
* Cache of prepared statements keyed by their SQL text. `DatabaseSync`
|
|
274
|
+
* compiles SQL on every `.prepare()` call; for the fixed-SQL methods
|
|
275
|
+
* (upsertFile, getFileMeta, deleteFile, insertRefs, …) that runs thousands
|
|
276
|
+
* of times during a full reindex. `StatementSync` objects are reusable
|
|
277
|
+
* across calls on the same connection, so we compile each distinct SQL once
|
|
278
|
+
* and reuse it. Cleared in {@link close} when the connection is torn down.
|
|
279
|
+
*/
|
|
280
|
+
stmtCache = /* @__PURE__ */ new Map();
|
|
281
|
+
/** Prepare-once helper: compile `sql` on first use, reuse thereafter. */
|
|
282
|
+
stmt(sql) {
|
|
283
|
+
let s = this.stmtCache.get(sql);
|
|
284
|
+
if (s === void 0) {
|
|
285
|
+
s = this.db.prepare(sql);
|
|
286
|
+
this.stmtCache.set(sql, s);
|
|
287
|
+
}
|
|
288
|
+
return s;
|
|
289
|
+
}
|
|
272
290
|
/**
|
|
273
291
|
* Execute a SQLite write operation with automatic retry on lock conflicts.
|
|
274
292
|
*
|
|
@@ -438,9 +456,9 @@ var IndexStore = class {
|
|
|
438
456
|
deleteSymbolsForFile(file) {
|
|
439
457
|
this.runWithRetry(() => {
|
|
440
458
|
if (this.ftsAvailable) {
|
|
441
|
-
this.
|
|
459
|
+
this.stmt("DELETE FROM symbols_fts WHERE rowid IN (SELECT id FROM symbols WHERE file_fk = ?)").run(file);
|
|
442
460
|
}
|
|
443
|
-
this.
|
|
461
|
+
this.stmt("DELETE FROM symbols WHERE file_fk = ?").run(file);
|
|
444
462
|
});
|
|
445
463
|
}
|
|
446
464
|
/**
|
|
@@ -452,13 +470,13 @@ var IndexStore = class {
|
|
|
452
470
|
this.runWithRetry(() => {
|
|
453
471
|
this.deleteRefsForFile(file);
|
|
454
472
|
this.deleteSymbolsForFile(file);
|
|
455
|
-
this.
|
|
473
|
+
this.stmt("DELETE FROM files WHERE file = ?").run(file);
|
|
456
474
|
});
|
|
457
475
|
}
|
|
458
476
|
// ─── File metadata ──────────────────────────────────────────────────────────
|
|
459
477
|
upsertFile(meta) {
|
|
460
478
|
this.runWithRetry(() => {
|
|
461
|
-
this.
|
|
479
|
+
this.stmt(
|
|
462
480
|
`INSERT INTO files(file, lang, mtime_ms, symbol_count, last_indexed)
|
|
463
481
|
VALUES (?, ?, ?, ?, ?)
|
|
464
482
|
ON CONFLICT(file) DO UPDATE SET
|
|
@@ -470,7 +488,7 @@ var IndexStore = class {
|
|
|
470
488
|
});
|
|
471
489
|
}
|
|
472
490
|
getFileMeta(file) {
|
|
473
|
-
const rows = this.
|
|
491
|
+
const rows = this.stmt(
|
|
474
492
|
"SELECT file, lang, mtime_ms, symbol_count, last_indexed FROM files WHERE file = ?"
|
|
475
493
|
).all(file);
|
|
476
494
|
if (!rows.length) return null;
|
|
@@ -693,7 +711,7 @@ var IndexStore = class {
|
|
|
693
711
|
*/
|
|
694
712
|
insertRefs(fromId, refs) {
|
|
695
713
|
this.runWithRetry(() => {
|
|
696
|
-
this.
|
|
714
|
+
this.stmt("DELETE FROM refs WHERE from_id = ?").run(fromId);
|
|
697
715
|
if (refs.length === 0) return;
|
|
698
716
|
const stmt = this.db.prepare(
|
|
699
717
|
`INSERT INTO refs(from_id, to_name, to_id, call_type, line)
|
|
@@ -894,6 +912,7 @@ var IndexStore = class {
|
|
|
894
912
|
}
|
|
895
913
|
}
|
|
896
914
|
close() {
|
|
915
|
+
this.stmtCache.clear();
|
|
897
916
|
try {
|
|
898
917
|
this.db.close();
|
|
899
918
|
} catch {
|